Comments (12)
The latest pre-release includes some convenience functions to handle the rotations, assuming their anatomical coordinate spaces are correct. I believe the following should work.
After positioning the volume faceup or facedown, I suggest rotating the simulated C-arm by changing alpha/beta. This may not be how a cranial X-ray is normally taken, but our convenience functions are designed with intraoperative procedures in mind, so there is more support. You can of course pass in the camera matrix yourself instead of the C-arm object.
import dicom2nifti
# convert dicom to nifti
dicom2nifti.convert_directory(path_of_dicom_dir, filepath)
volume = Volume.from_nifti(filepath)
volume.faceup() # Available in latest pre-release
carm = deepdrr.MobileCArm(volume.center_in_world)
carm.move_to(alpha=0, beta=0, degrees=True) # Can also be done in the with block
# Extra args have reasonable defaults.
with deepdrr.Projector(volume, carm=carm) as projector:
image = projector.project()
plt.imshow(image, cmap='gray')
plt.show()
from deepdrr.
@junjun1023 You will have to translate the isocenter (which, by default, is on the principle ray), to be where you want in the anatomy. I assumed that was the center, but you may want to move the camera closer or further away. You can do this by translating the volume or repositioning the C-arm with built-in functions. You can also adjust the camera parameters passed to the C-arm class to change the magnification.
You may find the built-in visualization tools to be useful. The following will open an interactive VTK window with the C-arm and volume shown. This may help understand the geometry setup, so you can tinker with it.
from deepdrr import vis
...
vis.show(volume, carm, full=True)
from deepdrr.
Do you have a minimal code example?
from deepdrr.
(Closing was accidental)
from deepdrr.
import dicom2nifti
# convert dicom to nifti
dicom2nifti.convert_directory(path_of_dicom_dir, filepath)
# The code below is from deepdrr_demo.ipynb
volume = Volume.from_nifti(filepath)
carm = deepdrr.MobileCArm(isocenter=volume.center_in_world, alpha=0, beta=0, degrees=True, min_alpha=-40, max_alpha=40, min_beta=0, max_beta=20)
with deepdrr.Projector(
volume=volume,
carm=carm,
step=0.1, # stepsize along projection ray, measured in voxels
mode="linear",
max_block_index=200,
spectrum="90KV_AL40",
photon_count=100000,
add_scatter=False,
threads=8,
neglog=True,
) as projector:
image = projector.project()
plt.imshow(image, cmap='gray')
plt.show()
from deepdrr.
I can't tell what projection plane the result is.
from deepdrr.
@benjamindkilleen
Thank you for your reply! I'm not familiar with the way to adjust a 3D image and how is C-arm work in the scene.
I have tried your sample code, and encountered error isocenter [173.75 14. -7.596878 1. ] is out of bounds. Use world_from_device transform to position the carm in the world.
Does it mean that I need to pre-process my 3D image?
The image below is the result I read with pydicom
and extract with different axis.
from deepdrr.
Ah, that is my mistake. I have edited the excerpt to omit the isocenter keyword, which does something slightly different.
from deepdrr.
@benjamindkilleen
The result looks quite different from the single slice of AP view above. It seems like a patch of whole lung view.
Do you have any suggestion to get the whole PA view like the image of README?
from deepdrr.
Excuse me, is there any way to convert a 3D numpy.array
to Volume
? I saw that there are some parameters need to pass e.g. material, but I don't know what should be passed. What I want to do is to create subvolumes and project the subvolumes with Projector
.
from deepdrr.
I can get the whole PA view of projection by setting source_to_isocenter_vertical_distance
larger than default value. Thank you for helping.
from deepdrr.
That would work. You can do the numpy conversion with the class constructor itself or the from_hu()
method.
from deepdrr.
Related Issues (20)
- [Question]About parallel beam and cone beam HOT 1
- mapping 3D points to 2D points
- mapping 2Dpoint to 3Dpoint HOT 3
- Projection Matrix HOT 1
- FLIP AXIS HOT 5
- How to implement STL to DCM transformation in deepdrr HOT 1
- How to set up a simulation of an orthogonal projection? HOT 1
- Isocenter / origin question HOT 1
- Given extrinsic matrix and intrinsic matrix HOT 10
- Zooming out on the DRR HOT 1
- Error when trying out the main branch HOT 7
- Insert new material HOT 1
- About DRR Image HOT 7
- gpu utilization and performances HOT 5
- DRR is white. HOT 7
- cuMemcpyHtoD failed! HOT 6
- Error when compiling kernel (using the example python script) HOT 3
- Dead link to test data (used in Jupyter notebook)
- DEEPDRR Achieve gradient projection HOT 1
- Unexpected DRR orientation HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deepdrr.