Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass COR and tilt to CIL reconstruction #1051

Merged
merged 4 commits into from
Jul 21, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions mantidimaging/core/reconstruct/cil_recon.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,6 @@


class CILRecon(BaseRecon):
@staticmethod
def get_IMAT_AcquisitionGeometry(angles, shape):
pixel_size = (1., 1.)
if len(shape) == 3:
# shape of full data [angles, v_pixels, h_pixels]
ag = AcquisitionGeometry.create_Parallel3D()
pixel_num_h, pixel_num_v = shape[2], shape[1]
ag.set_panel([pixel_num_h, pixel_num_v], pixel_size=pixel_size)
elif len(shape) == 2:
# shape of sinogram is [angles, h_pixels]
ag = AcquisitionGeometry.create_Parallel2D()
pixel_num_h = shape[1]
ag.set_panel(pixel_num_h, pixel_size=pixel_size)
else:
raise ValueError("Shape should have 2 or 3 dimensions")

ag.set_angles(angles=angles, angle_unit='radian')
return ag

@staticmethod
def set_up_TV_regularisation(image_geometry, acquisition_data):
# Forward operator
Expand Down Expand Up @@ -87,9 +68,15 @@ def single_sino(sino: np.ndarray, cor: ScalarCoR, proj_angles: ProjectionAngles,
Should return a numpy array,
"""
sino = BaseRecon.negative_log(sino)
pixel_num_h = sino.shape[1]
pixel_size = 1.
rot_pos_x = (cor.value - pixel_num_h / 2) * pixel_size
ag = AcquisitionGeometry.create_Parallel2D(rotation_axis_position=[rot_pos_x, 0])

ag = CILRecon.get_IMAT_AcquisitionGeometry(proj_angles.value, sino.shape)
ag.set_panel(pixel_num_h, pixel_size=pixel_size)
ag.set_labels(DataOrder.ASTRA_AG_LABELS)
ag.set_angles(angles=proj_angles.value, angle_unit='radian')

# stick it into an AcquisitionData
data = ag.allocate(None)
data.fill(sino)
Expand Down Expand Up @@ -129,7 +116,17 @@ def full(images: Images, cors: List[ScalarCoR], recon_params: ReconstructionPara

angles = images.projection_angles(recon_params.max_projection_angle).value
shape = images.data.shape
ag = CILRecon.get_IMAT_AcquisitionGeometry(angles, shape)
pixel_num_h, pixel_num_v = shape[2], shape[1]
pixel_size = 1.
if recon_params.tilt is None:
raise ValueError("recon_params.tilt is not set")
rot_pos = [(cors[pixel_num_v // 2].value - pixel_num_h / 2) * pixel_size, 0, 0]
slope = -np.tan(np.deg2rad(recon_params.tilt.value))
rot_angle = [slope, 0, 1]

ag = AcquisitionGeometry.create_Parallel3D(rotation_axis_position=rot_pos, rotation_axis_direction=rot_angle)
ag.set_panel([pixel_num_h, pixel_num_v], pixel_size=(pixel_size, pixel_size))
ag.set_angles(angles=angles, angle_unit='radian')
ag.set_labels(DataOrder.TIGRE_AG_LABELS)

# stick it into an AcquisitionData
Expand Down