Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Regarding the quality issues of the DRR image. #344

Closed
linquanxu opened this issue Nov 11, 2024 · 5 comments
Closed

Regarding the quality issues of the DRR image. #344

linquanxu opened this issue Nov 11, 2024 · 5 comments

Comments

@linquanxu
Copy link

linquanxu commented Nov 11, 2024

Dear author,
I used this code to generate DRR images, but I found that the generated DRR image is very different from the real X-ray image. The generated DRR image is very blurry, while the real X-ray image is much clearer. Could you please help me understand what might be causing this issue? Below are the generated images and the code.

    subject = read(volume='./data/11Spine10B30s')

    # Make a mesh from the CT volume
    ct = drr_to_mesh(subject, "surface_nets", threshold=225, verbose=True)
    SDD = 2000
    HEIGHT = 256
    DELX = 7.1942
    # Initialize the DRR module for generating synthetic X-rays
    drr = DRR(subject, sdd=SDD, height=HEIGHT, delx=DELX).to(device)
    # Make a pose
    rot = torch.tensor([[0.0, 0.0, 0.0]], device=device) / 180 * torch.pi
    xyz = torch.tensor([[0.0, 600.0, 0.0]], device=device)
    pose = convert(rot, xyz, parameterization="euler_angles", convention="ZXY")
    img = drr(pose)
    plot_drr(img)
    plt.savefig("drr_image_plot.jpg")
    plt.show()

image
image
Additionally, in the DRR image, the area I marked in red appears abnormal. What could be causing this issue?

Lastly, I have attached the real X-ray image below:
image

@eigenvivek
Copy link
Owner

Hi @linquanxu, a few things I would try:

  • Try to look up the pixel spacing in the real X-ray image (if you have it in DICOM format, this is easy to find).
  • Also change the height, width, and SDD (all embedded in DICOM) so that the field of view of your DRR matches your X-ray.
  • What's the dimensions / voxel spacing of your CT? if the CT is not very high resolution, the rendered DRR won't be hi-res either.

Hope that helps, let me know if you have further questions!

@linquanxu
Copy link
Author

Hi, @eigenvivek,
Thank you for your quick response.

  1. The real X-ray image has a PixelSpacing of 0.139 and a DistanceSourceToDetector of 2000.

  2. In the CT DICOM, the PixelSpacing is 0.373, the DistanceSourceToDetector is 1085.6, the DistanceSourceToPatient is 595, and the SliceThickness is 1.0.

How should I set the parameters to make the generated DRR image as close as possible to the real X-ray image? Should I fully follow the parameters of the real X-ray equipment in this case?

@eigenvivek
Copy link
Owner

Yes, follow the parameters of the real X-ray for your DRR.

diffdrr.data.read should exactly extract the parameters from the CT DICOM.

Real X-rays are very large, and rendering a DRR that big will likely use more memory than you have on your GPU. To overcome this, you can downsample the detector (diffdrr.DRR.rescale_detector_) or use the patch_size argument.

@linquanxu
Copy link
Author

Thank you for your help, I'll try again.

@RoelHuysentruyt
Copy link

Hi, I hope this worked out for you!

Although this issue is closed, I wanted to share my experience in case others come across this in the future. I faced the same problem where the X-rays appeared extremely low-quality and blurry. Instead of adjusting the spacing, I found that modifying the bone_intensity_multiplier during subject reading significantly improved the image detail. Specifically, using a multiplier of 5–10 resulted in much clearer X-rays.

Here’s how I applied this in my case:
subject = read(image_file,labelmap=label_file,bone_attenuation_multiplier=5)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants