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

Forward projection bug related to the voxel spacing #70

Closed oooo1114 closed 5 hours ago

oooo1114 commented 2 days ago

Hi, I have tested LEAP with my geometry. When the voxel spacing (width or height) is smaller than the real pixel width or height in the isocenter, i.e. pixel width or height * sod / sdd, the forward projection goes wrong. Most views are all zeroes, except for tens of weird views near the center of angles. Here are the scripts which can reproduce the bug:

import sys
import os
import time
import numpy as np
from leapctype import *
leapct = tomographicModels()
numCols = 860
numTurns = 6
numAngles = 8640
numRows = 32
pixelHeight = 1.12
pixelWidth = 1.0645
centerRow = 0.5*(numRows-1)
centerCol = 0.5*(numCols-1)-4.2412
phis = leapct.setAngleArray(numAngles, 360.0*numTurns)
sod = 570
sdd = 1005
pitch = 0.861
leapct.set_conebeam(numAngles, numRows, numCols, pixelHeight, pixelWidth, centerRow, centerCol, phis, sod, sdd)
leapct.set_normalizedHelicalPitch(pitch)
leapct.set_curvedDetector()

numX = 512
numY = 512
numZ = 137
voxelWidth = 0.6 # set to 0.6 will trigger the bug
# voxelWidth = 0.7 # set to 0.7 is the normal case
voxelHeight = 1.26
offsetX = 0
offsetY = 0
offsetZ = 0
leapct.set_volume(numX, numY, numZ, voxelWidth, voxelHeight, offsetX, offsetY, offsetZ)
leapct.set_diameterFOV(640)
# Trouble-Shooting Functions
leapct.print_parameters()
# leapct.sketch_system()
g = leapct.allocateProjections()
f = leapct.allocateVolume()
leapct.set_FORBILD(f,True)
leapct.project(g,f)

When voxelWidth is set to 0.7, the projection looks fine. See the No. 4161 view below. image

When voxelWidth is set to 0.6, the projection looks weird. See the No. 4161 view below. image

kylechampley commented 1 day ago

Yep, you're absolutely correct, that is a bug. Thanks for the code to reproduce the issue. I found it and I am nearly done fixing it. I'll release a new version in the next 24 hours that resolves this.

kylechampley commented 19 hours ago

This bug has been fixed and new code merged into the main branch. We also made a new release with this bug fix, v1.16.

When fixing this bug we also found that the scaling factor of the helical FBP algorithm was a little off and we fixed this.

Thanks for reporting this bug!

oooo1114 commented 7 hours ago

Thanks for your work!