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

Bug using out with scaled Astra and Tigre projection operators. #2058

Open
MargaretDuff opened this issue Feb 3, 2025 · 1 comment · May be fixed by #2059
Open

Bug using out with scaled Astra and Tigre projection operators. #2058

MargaretDuff opened this issue Feb 3, 2025 · 1 comment · May be fixed by #2059
Assignees
Labels
bug Something isn't working

Comments

@MargaretDuff
Copy link
Member

MargaretDuff commented Feb 3, 2025

Description

Passing out to the direct or adjoint of a scaled Astra and Tigre projection operator leads to an error

from cil.processors import TransmissionAbsorptionConverter, Slicer
import numpy as np
from cil.plugins.tigre import ProjectionOperator


# Load data
ground_truth = dataexample.SIMULATED_SPHERE_VOLUME.get()

data = dataexample.SIMULATED_CONE_BEAM_DATA.get()

# Consider just a single 2D slice 
data = data.get_slice(vertical='centre')
ground_truth = ground_truth.get_slice(vertical='centre')

absorption = TransmissionAbsorptionConverter()(data)
absorption = Slicer(roi={'angle':(0, -1, 5)})(absorption)

ig = ground_truth.geometry

A = ProjectionOperator(image_geometry=ig, 
                       acquisition_geometry=absorption.geometry)
A_scaled=3*A

Image

Image

with

from cil.plugins.astra.operators import ProjectionOperator

Image

Image

@MargaretDuff MargaretDuff added the bug Something isn't working label Feb 3, 2025
@MargaretDuff MargaretDuff self-assigned this Feb 3, 2025
@MargaretDuff
Copy link
Member Author

In the ScaledOperator direct and adjoint it assumes that self.operator.adjoint(x, out=out) and self.operator.direct(x, out=out) returns as well as fills out: https://github.com/TomographicImaging/CIL/blob/5749b38a9f59a8d6730e86a395184e62cc152b44/Wrappers/Python/cil/optimisation/operators/Operator.py#L500C1-L512C19

However, the astra and tigre processors don't return if out is filled:

def process(self, out=None):
IM = self.get_input()
#ASTRA expects a 2D array with shape 1, CIL removes dimensions of len 1
new_shape_ig = [self.volume_geometry.voxel_num_y,self.volume_geometry.voxel_num_x]
new_shape_ig = [x if x>0 else 1 for x in new_shape_ig]
IM_data_temp = IM.as_array().reshape(new_shape_ig)
sinogram_id, arr_out = astra.create_sino(IM_data_temp, self.proj_id)
astra.data2d.delete(sinogram_id)
arr_out = np.squeeze(arr_out)
if out is None:
out = AcquisitionData(arr_out, deep_copy=False, geometry=self.sinogram_geometry.copy(), suppress_warning=True)
return out
else:
out.fill(arr_out)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant