eigenvivek / DiffDRR

Auto-differentiable digitally reconstructed radiographs in PyTorch
https://vivekg.dev/DiffDRR
MIT License
148 stars 19 forks source link

A way to properly change the strenght of X-ray radiation #200

Open MarkoLeskovar opened 8 months ago

MarkoLeskovar commented 8 months ago

Hello,

I was wondering how could I change the X-ray radiation dose when generating the virtual X-ray images. I see there is a "bone_attenuation_multiplier" variable, but this seem kind of specific to the input data and does not seem to work with the attached chest dataset if I want to increase the dose, such the only the bones would be visible.

I think the proper way to set the X-ray power would be, instead of changing the CT intensity values, to add scaling to the natural exponential in Beer-Lambert law of attenuation. This worked in my case when I was projecting virtual X-ray from volumetric tetrahedral meshes. Take a look at ehlke2013 By doing so, we are also not bound to the intensity values of the CT [-2000 ... 4000+?].

Furthermore, by looking at your code, it seems to me that the DRR is only dependent on the ray length and its weight? From what I understand, there should be a final post-processing step that takes the contribution of each pixel and takes the exp(-a*x) of the contributions, similar as in ehlke2013 .

Let me know what you think and if this would be possible to implement.

Best regards, Marko Leskovar

eigenvivek commented 7 months ago

Hi @MarkoLeskovar, this is a good idea and something easy to implement.

In DiffDRR, for each ray cast, we model the amount of energy absorbed by the volume, not the attenuated intensity of the ray as you're suggesting. That is, the integral we compute is

image

where

Alternatively, you can exponentiate the image returned by DiffDRR to model the attenuated intensity of rays

image
eigenvivek commented 6 months ago

HI @MarkoLeskovar, been digging more into the literature based on your question. It appears the CT Hounsfield units -> LAC density conversion depends on the radiation dose (this paper was particularly illustrative).

Going to try and implement a dose-dependent conversion for DiffDRR v0.4.0.

eigenvivek commented 5 months ago

This proved to be a really interesting direction. Taking inspiration from DeepDRR, I found a few ways to implement dose-dependent rendering. However, I don't think the results look very accurate (the lumbar spine is way to prominent) and I need more time to figure out the best way to implement this. Going to remove this as a goal for v0.4.0, but something to pursue for the future.

60kVp 90kVp 120kVp