LLNL / LEAP

comprehensive library of 3D transmission Computed Tomography (CT) algorithms with Python API and fully integrated with PyTorch
https://leapct.readthedocs.io
MIT License
74 stars 8 forks source link

Calculate the HU value #48

Closed stefenmax closed 4 weeks ago

stefenmax commented 4 weeks ago

The Hounsfield scale of CT is set around water measuring 0 HU. By altering the attenuation level (mid-HU value) and range (extent of gray scale) at which the image is viewed, the tissue to be displayed can be determined. Will LEAP add a function to calculate the HU value automatically?

kylechampley commented 4 weeks ago

Yep, that's one of the reasons why I developed the XrayPhysics package. Just install this package and then run the following code:

from xrayphysics import *
physics = xrayPhysics()
physics.use_mm()
f = 1000.0/physics.mu('water', effectiveEnergy)*f - 1000.0

For this to work you'll need to know the effective x-ray energy (in units of keV) of the data; see the effectiveEnergy variable in the code above. This'll be a number between 50 and 100 keV for most medical purposes.

stefenmax commented 4 weeks ago

I used the 3D reconstructed result from LEAP and set the effective x-ray energy to 100. But the HU value calculated is strange from -4981677.0 to 132672040.0. Is it normal? from xrayphysics import physics = xrayPhysics() physics.use_mm() effectiveEnergy = 100 f = np.load('../recon_npy/recon1.npy') f = 1000.0/physics.mu('water', effectiveEnergy)f - 1000.0 print(np.min(f[f.shape[0]//2,:,:])) print(np.max(f[f.shape[0]//2,:,:]))

kylechampley commented 4 weeks ago

Ya, those values are not normal. But based on those values, it seems like before that scaling, i.e., the values in your npy file, were in the range: -85 to 2264. That range of values looks like Modified Hounsfield Units (MHU) which is HU+1000.0. Thus, I think that data that went into the LEAP reconstruction was already scaled. I think all you need to make that result in HU is to subtract 1000.

stefenmax commented 4 weeks ago

aha, that make sense. Thanks!