No Lung details
Hi together,
first thanks for the public available code. Since yesterday I try to get some good results for my project. What is very important to me is to display the abdomen part very detailed. With the following code, I could get the following result:
carm = MobileCArm(sensor_height=3000, sensor_width = 3000, pixel_size=0.2, source_to_detector_distance=1500, source_to_isocenter_vertical_distance = 1300)
ct = Volume.from_nifti(input_path)
# Initialize the Projector object (allocates GPU memory)
with Projector(ct, carm=carm) as projector:
# Orient and position the patient model in world space.
ct.orient_patient(head_first=True, supine=True)
ct.place_center(carm.isocenter_in_world)
# Move the C-arm to the desired pose.
carm.move_by(delta_isocenter = [0, -80, 0],delta_alpha=0, delta_beta=180, delta_gamma=-90, degrees=True)
# Run projection
image = projector()
# Convert to 8-bit image and save
img_8bit = (255 * (image - image.min()) / (image.max() - image.min())).astype(np.uint8)
pil_img = Image.fromarray(img_8bit)
pil_img.save(output_path)
print(f"Projection saved to: {output_path}")
Result is:
Some facts to the CT Volume I use:
- The CT Volume has Voxel dimensions: (277, 512, 512) (Sagittal, Coronal, Transverse)
- With Voxel Spacing (1.25, 0.878906, 0.878906)
If I compare this to a original X-Ray from the same body:
I recognize that, the generated x-ray lacks of a detailed lung and I can not see the ribs as well.
Is there something I do wrong in the code?
Thanks in advance
Best
Lung details will only appear if they are visible (and detailed) in the CT. Roughly 1mm voxel size is likely not sufficient for this. Additionally, the material segmentation may have to be manually provided with equivalent high resolution and accuracy, if you want bronchii to be accurately represented.
For the visibility of rib structures, it looks like a window and level issue with the visualization of the output.
Hi @benjamindkilleen,
thanks for the quick answer. The resolution of the scan is (1.25, 0.878906, 0.878906).
As an example, I cut the CT in the middle and the bronchi can be seen:
.
Regarding the window and level you mentioned I'm not sure if I fully understand you. The min HU is -1024 and the my is 3071. This should actually include all the necessary structures. Is that what you meant?
I mean the window and level of the X-ray image. I recommend viewing the output with FIJI image viewer or similar.
If the structures are visible in CT, you can also reduce the step size of the projector. Ultimately, DeepDRR is converting the HU to density using an approximation, and estimating material decomposition based either on thresholding or a V-Net (depending on settings). You can examine the material decomposition to see if it depicts the lung structures accurately. If not, you could provide this yourself.
@benjamindkilleen
After testing different settings playing around with window/level adjustment and segmentation masks, for the CT-Scan in the above example I couldn't get a better result.
For the following sample, I think this is a great example of window/level adjustment to make the lung more prominent.
Without adjustment:
With adjustment (window = 0.9531, level = 0.7734):
I tried samples from another dataset. Similar to the initial sample, I showed in the first post, in these the lung was hard to see and window/level adjustment didn't help. That's why I tried segmentation masks. But actual the results didn't improve, in my opinion they are even worse. Maybe I do something wrong or these samples are just not very good for the algorithm:
Without materials:
With segmented materials: