Ruyi-Zha / naf_cbct

"Neural Attenuation Fields for Sparse-View CBCT Reconstruction" (MICCAI 2022 Oral)
https://arxiv.org/abs/2209.14540
MIT License
123 stars 21 forks source link

question about generateData.py #20

Closed 1999kevin closed 1 month ago

1999kevin commented 5 months ago

Hi, in generateData.py line 178 projections = tigre.Ax(np.transpose(img, (2, 1, 0)).copy(), geo, data["train"]["angles"])[:, ::-1, :], why we need to transpose img from zyx to xyz and then reverse the first axis of the generated projections. Is it related to the coordinate transformation between the world and the camera?

Procat18cn commented 4 months ago

My personal understanding:

When performing Ax forward projection operations, TIGRE's Matlab and Python programs require different dimension definitions of Img. In Matlab, the 1-3 dimensions of the matrix are defined as xyz and in Python as zyx.

The first axis of the reverse projection may be related to the definition of the coordinates of the NAF projection.

1999kevin commented 4 months ago

Actually, I have checked the TIGRE demo (https://github.com/CERN/TIGRE/blob/master/Python/demos/d04_SimpleReconstruction.py). They do not apply the transpose and reverse for the forward projection.

I do not quite understand this operation because they have saved the original image into the pickle file, which should be the ground truth result for the reconstruction algorithm, but use its transposed one to obtain the projection X-ray figures. I guess the reconstruction result should be like the transposed result of the original image, right?

Ruyi-Zha commented 4 months ago

Apologies for the delayed response as I was on vacation. The main reason arises from the coordinate difference, particularly in 2D, between TIGRE and our implementation in OpenCV. As shown below, our 2D projection axis is centered at the top-left, whereas TIGRE's is at the bottom-left. Consequently, to achieve the correct X-ray projection with TIGRE, we transpose the 3D CT image. This transposed CT image is solely utilized for projection synthesis. There are of course alternative methods to obtain the projection, such as transposing the synthesized 2D results directly. Hope this helps.

TIGRE coordinate:

Screenshot 2024-07-12 at 10 52 33 AM

NAF coordinate:

Screenshot 2024-07-12 at 10 53 57 AM