Exemplo n.º 1
0
    def compare_FBP(self, atol):
        fbp = FBP(self.ig, self.ag)
        reco = fbp(self.acq_data)
        np.testing.assert_allclose(reco.as_array(),
                                   self.img_data.as_array(),
                                   atol=atol)

        reco2 = reco.copy()
        reco2.fill(0)
        fbp(self.acq_data, out=reco2)
        np.testing.assert_allclose(reco.as_array(),
                                   reco2.as_array(),
                                   atol=1e-8)
Exemplo n.º 2
0
    def test_FBP(self):
        reco_out = FBP(self.ig, self.ag)(self.fp.get_slice(vertical='centre'))
        mean_diff = (self.golden_data_cs - reco_out).abs().mean()
        self.assertLess(mean_diff, 0.01)
        np.testing.assert_allclose(self.golden_data_cs.as_array(),
                                   reco_out.as_array(),
                                   atol=1)

        reco_out3D = FBP(self.ig3D, self.ag3D)(self.fp)
        diff = (self.golden_data - reco_out3D).abs()
        self.assertLess(diff.mean(), 0.01)
        np.testing.assert_allclose(self.golden_data.as_array(),
                                   reco_out3D.as_array(),
                                   atol=1)
Exemplo n.º 3
0
    def compare_FBP_roi(self, atol):
        vox_size = self.ag.config.panel.pixel_size / self.ag.magnification
        roi = [20, 30, 40]

        center_offset = [50, -20, 5]
        center_offset = [0, -0, 0]

        ig = ImageGeometry(roi[2],roi[1],roi[0],\
            vox_size[1],vox_size[1],vox_size[0],\
            center_offset[2]*vox_size[1],center_offset[1]*vox_size[0],center_offset[0]*vox_size[0])

        fbp = FBP(ig, self.ag)
        reco = fbp(self.acq_data)

        x0 = int(ig.get_min_x() / vox_size[1] + self.img_data.shape[2] // 2)
        x1 = int(ig.get_max_x() / vox_size[1] + self.img_data.shape[2] // 2)
        y0 = int(ig.get_min_y() / vox_size[1] + self.img_data.shape[1] // 2)
        y1 = int(ig.get_max_y() / vox_size[1] + self.img_data.shape[1] // 2)
        z0 = int(ig.get_min_z() / vox_size[0] + self.img_data.shape[0] // 2)
        z1 = int(ig.get_max_z() / vox_size[0] + self.img_data.shape[0] // 2)

        gold_roi = self.img_data.as_array()[z0:z1, y0:y1, x0:x1]
        np.testing.assert_allclose(reco.as_array(), gold_roi, atol=atol)
Exemplo n.º 4
0
    def test_FBP_with_Astra(self):
        reco_ASTRA = AstraFBP(self.ig,
                              self.ag)(self.fp.subset(vertical='centre'))
        reco_TIGRE = FBP(self.ig, self.ag)(self.fp.subset(vertical='centre'))
        mean_diff = (reco_ASTRA - reco_TIGRE).abs().mean()
        self.assertLess(mean_diff, 1e-4)
        np.testing.assert_allclose(reco_ASTRA.as_array(),
                                   reco_TIGRE.as_array(),
                                   atol=1e-2)

        astra_transpose = self.fp.subset(['vertical', 'angle', 'horizontal'])
        reco_ASTRA3D = AstraFBP(self.ig3D,
                                astra_transpose.geometry)(astra_transpose)
        reco_TIGRE3D = FBP(self.ig3D, self.ag3D)(self.fp)
        diff = (reco_ASTRA3D - reco_TIGRE3D).abs()
        self.assertLess(diff.mean(), 1e-4)
        np.testing.assert_allclose(reco_ASTRA3D.as_array(),
                                   reco_TIGRE3D.as_array(),
                                   atol=1e-2)
Exemplo n.º 5
0
else:
    binner = Binner(roi={
        'horizontal': (None, None, 4),
        'vertical': (None, None, 4)
    })
    data = binner(data)

# show_geometry(data.geometry)

data = TransmissionAbsorptionConverter()(data)

data.reorder(order='tigre')

ig = data.geometry.get_ImageGeometry()

fbp = FBP(ig, data.geometry)
recon = fbp(data)
from cil.io import NEXUSDataWriter
writer = NEXUSDataWriter()
writer.set_up(data=recon, file_name=os.path.abspath('noce.nxs'))
writer.write()

# show2D([data, recon], fix_range=(-0.01,0.06))
from ccpi.viewer import viewer2D, viewer3D
from ccpi.viewer.utils.conversion import Converter
import vtk
from functools import partial

v = viewer3D()

Exemplo n.º 6
0
aq_data = aq_data_raw.log()
aq_data *= -1

#%% view data
ag = aq_data.geometry
islicer(aq_data, direction='angle')

#%% Set up reconstruction volume
ig = ag.get_ImageGeometry()
ig.voxel_num_x = int(num_pixels_x - 200 / bins)
ig.voxel_num_y = int(num_pixels_x - 600 / bins)
ig.voxel_num_z = int(400 // bins)
print(ig)

#%% Reconstruct with FDK
fbp = FBP(ig, ag)
fbp.set_input(aq_data)
FBP_3D_gpu = fbp.get_output()

show2D(FBP_3D_gpu,
       slice_list=[('vertical', 204 // bins), ('horizontal_y', 570 // bins)],
       title="FBP reconstruction",
       fix_range=(-0.02, 0.07))
#%% Setup least sqaures and force pre-calculation of Lipschitz constant
Projector = ProjectionOperator(ig, ag)
LS = LeastSquares(A=Projector, b=aq_data)
print("Lipschitz constant =", LS.L)

#%% Setup FISTA to solve for least squares
fista = FISTA(x_init=ig.allocate(0),
              f=LS,