CERN/TIGRE

Why are the FDK algorithm results of Tigre and CIL modules so different?

TianSong1991 opened this issue · 5 comments

Expected Behavior

Hello, I ran the FDK algorithm of the CIL and Tigre modules and used my own data for reconstruction. The reconstruction results found that the CIL module reconstructed the effect very well, but the results using the Tigre FDK module were not visible at all. . It may be that the geometry setting of Tigre's FDK algorithm is wrong. I imitated and learned based on each case in the python demo. I don't know if there is a problem. Please give me a rough look. Thank you!

Actual Behavior

Code to reproduce the problem (If applicable)

** ## The tigre fdk code:**

`import tigre
import numpy as np
from tigre.utilities import sample_loader
from tigre.utilities import CTnoise
import tigre.algorithms as algs
import time
from tigre.utilities import gpu

geo = tigre.geometry_default() # Default cone beam geometry

geo.DSD = 590 # Distance Source Detector (mm)
geo.DSO = 110 # Distance Source Origin (mm)

geo.nDetector = np.array([2146, 1762]) # number of pixels (px)
geo.dDetector = np.array([0.139, 0.139]) # size of each pixel (mm)
geo.sDetector = geo.nDetector * geo.dDetector # total size of the detector (mm)

geo.nVoxel = np.array([2146, 2146, 1762]) # number of voxels (vx)
geo.sVoxel = np.array([2146, 2146, 1762]) # total size of the image (mm)
geo.dVoxel = geo.sVoxel / geo.nVoxel # size of each voxel (mm)

geo.offOrigin = np.array([0, 0, 0]) # Offset of image from origin (mm)
geo.offDetector = np.array([0.458, 0]) # Offset of Detector (mm)

angles = np.linspace(0, 2 * np.pi, 1800,endpoint=False)

ourdata = np.fromfile(r'D:\miniconda3\kevin\data\jianghanchu\images.raw',dtype=np.uint16)
ourdata = ourdata.reshape((1800,1762,2146))
ourdata = ourdata.transpose((0,2,1))
projections = ourdata.astype(np.float32)

time0 = time.time()
gpuName = 'NVIDIA RTX A6000'

gpuids = gpu.getGpuIds(gpuName)
imgFDK2 = algs.fdk(projections, geo, angles, filter="hamming",gpuids=gpuids)
time1 = time.time()
print("Tigre FDK alg cost time : ",time1 - time0)
imgFDK2.tofile('imgFDK.raw')`

# The CIL code is tested ok
`import os
from cil.io import ZEISSDataReader, TIFFWriter
from cil.processors import TransmissionAbsorptionConverter, Slicer
from cil.recon import FDK
from cil.utilities.display import show2D, show_geometry
from cil.utilities.jupyter import islicer, link_islicer
import numpy as np
from cil.framework import AcquisitionGeometry
from cil.utilities.display import show_geometry

filename = r"D:\Program Files\JetBrains\valnut_tomo-A.txrm"

data = ZEISSDataReader(file_name=filename).read()

print(data.geometry)

ag = AcquisitionGeometry.create_Cone3D(source_position=[0, -110, 0], detector_position=[0.458, 480, 0])
.set_panel(num_pixels=[2146, 1762],pixel_size=0.139)
.set_angles(angles=np.linspace(0, 360,1800,endpoint=False))

data.geometry = ag

ourdata = np.fromfile(r'D:\miniconda3\kevin\data\jianghanchu\images.raw',dtype=np.uint16)
ourdata = ourdata.reshape((1800,1762,2146))

data.array = ourdata.astype(np.float32)

data.reorder(order='tigre')

ig = data.geometry.get_ImageGeometry()

time1 = time.time()
fdk = FDK(data, ig, filter='ram-lak')
recon = fdk.run()
print("FDK with ram-lak filter cost time is :",time.time() - time1)
recon.array.tofile('imgFDK.raw')`

Specifications

  • MATLAB/python version: python
  • OS:win10
  • CUDA version:11.7

I think it should be that my geometry in the Tigre module is not set correctly, but I don't know where I set it wrong.

Hi!
It doesn't seem that you are log transforming the data loaded in Tigre, which may be missing.
As far as I can tell, you should be able to get almost exactly results in both.
Can you show how the images look like?

Hi! It doesn't seem that you are log transforming the data loaded in Tigre, which may be missing. As far as I can tell, you should be able to get almost exactly results in both. Can you show how the images look like?

@AnderBiguri Thank you for your quick reply despite your busy schedule. The images below show the FDK algorithm results of CIL and Tigre respectively. Judging from the reconstruction results, the FDK algorithm of the Tigre backend called by CIL is relatively good, but running Tigre alone The FDK algorithm shows nothing. I feel very confused. I don’t know whether there is a problem with the geometry settings or other errors. Thank you.
I use Volume Graphics tool to show the result.

CIL

Tigre

What about the log transform that I mentioned? Are you sure you are processing the raw data as needed? Check demo 22.

What about the log transform that I mentioned? Are you sure you are processing the raw data as needed? Check demo 22.

Succeed! Both CIL and Tigre FDK alg are ok!