Esempio n. 1
0
 def test_recon_fbp(self):
     stack = ds.get_needle_data(True)
     slices = stack.isig[:, 120:121].deepcopy()
     rec = slices.reconstruct('FBP')
     assert type(stack) is tomotools.base.TomoStack
     assert type(rec) is tomotools.base.TomoStack
     assert rec.data.shape[1] == slices.data.shape[2]
Esempio n. 2
0
 def test_image_filter_none(self):
     stack = ds.get_needle_data()
     filt = stack.inav[0:10].filter(method=None)
     assert filt.axes_manager.navigation_shape == \
         stack.inav[0:10].axes_manager.navigation_shape
     assert filt.axes_manager.signal_shape == \
         stack.inav[0:10].axes_manager.signal_shape
Esempio n. 3
0
 def test_align_to_other(self):
     stack = ds.get_needle_data()
     stack2 = stack.deepcopy()
     reg = stack.stack_register('PC')
     reg2 = reg.align_other(stack2)
     diff = reg.data - reg2.data
     assert diff.sum() == 0.0
Esempio n. 4
0
 def test_stack_normalize(self):
     stack = ds.get_needle_data()
     norm = stack.normalize()
     assert norm.axes_manager.navigation_shape == \
         stack.axes_manager.navigation_shape
     assert norm.axes_manager.signal_shape == \
         stack.axes_manager.signal_shape
     assert norm.data.min() == 0.0
Esempio n. 5
0
 def test_tilt_align_com(self):
     stack = ds.get_needle_data()
     stack.axes_manager[0].offset = -76
     stack.axes_manager[0].scale = 2
     reg = stack.stack_register('PC')
     ali = reg.tilt_align(method='CoM', locs=[64, 128, 192])
     tilt_axis = ali.metadata.Tomography.tiltaxis
     assert abs(-2.7 - tilt_axis) < 1.0
Esempio n. 6
0
 def test_register_ecc(self):
     stack = ds.get_needle_data()
     reg = stack.inav[0:20].stack_register('ECC')
     assert type(reg) is tomotools.TomoStack
     assert reg.axes_manager.signal_shape == \
         stack.inav[0:20].axes_manager.signal_shape
     assert reg.axes_manager.navigation_shape == \
         stack.inav[0:20].axes_manager.navigation_shape
Esempio n. 7
0
 def test_tilt_align_maximage(self):
     stack = ds.get_needle_data()
     stack.axes_manager[0].offset = -76
     stack.axes_manager[0].scale = 2
     reg = stack.stack_register('PC')
     ali = reg.tilt_align(method='MaxImage')
     tilt_axis = ali.metadata.Tomography.tiltaxis
     assert abs(-2.3 - tilt_axis) < 1.0
Esempio n. 8
0
 def test_sirt_error(self):
     stack = ds.get_needle_data(True)
     rec_stack, error = stack.recon_error(128, iterations=50,
                                          constrain=True, cuda=False)
     assert error.data.shape[0] == rec_stack.data.shape[0]
     assert rec_stack.data.shape[1:] ==\
         (stack.data.shape[2], stack.data.shape[2])
     assert (1 - (3.8709e12 / error.data[0])) < 0.001
     assert (1 - (2.8624e12 / error.data[1])) < 0.001
Esempio n. 9
0
 def test_set_tilts(self):
     stack = ds.get_needle_data()
     stack.set_tilts(-50, 5)
     assert stack.axes_manager[0].name == "Tilt"
     assert stack.axes_manager[0].scale == 5
     assert stack.axes_manager[0].units == "degrees"
     assert stack.axes_manager[0].offset == -50
     assert stack.axes_manager[0].axis.all() == \
         np.arange(-50, stack.data.shape[0] * 5 + -50, 5).all()
Esempio n. 10
0
 def test_recon_sirt(self):
     stack = ds.get_needle_data(True)
     slices = stack.isig[:, 120:121].deepcopy()
     rec = slices.reconstruct('SIRT',
                              constrain=True,
                              iterations=2,
                              thresh=0)
     assert type(stack) is tomotools.base.TomoStack
     assert type(rec) is tomotools.base.TomoStack
     assert rec.data.shape[1] == slices.data.shape[2]
Esempio n. 11
0
 def test_register_com(self):
     stack = ds.get_needle_data()
     stack.metadata.Tomography.tilts = \
         stack.metadata.Tomography.tilts[0:20]
     reg = stack.inav[0:20].stack_register('COM')
     assert type(reg) is tomotools.TomoStack
     assert reg.axes_manager.signal_shape == \
         stack.inav[0:20].axes_manager.signal_shape
     assert reg.axes_manager.navigation_shape == \
         stack.inav[0:20].axes_manager.navigation_shape
Esempio n. 12
0
 def test_astra_sirt_2d_data(self):
     stack = ds.get_needle_data(True)
     angles = stack.axes_manager[0].axis
     slices = stack.isig[:, 120].deepcopy().data
     rec = recon.astra_sirt(slices, angles,
                            thickness=None, iterations=2,
                            constrain=True, thresh=0, cuda=False)
     assert rec.shape == (1, slices.shape[1], slices.shape[1])
     assert rec.shape[0] == 1
     assert type(rec) is numpy.ndarray
Esempio n. 13
0
 def test_astra_project_2d_data(self):
     stack = ds.get_needle_data(True)
     angles = stack.axes_manager[0].axis
     slices = stack.isig[:, 120].deepcopy().data
     rec = recon.astra_sirt(slices, angles,
                            thickness=None, iterations=1,
                            constrain=True, thresh=0, cuda=False)
     sino = recon.astra_project(rec, angles)
     assert sino.shape == (len(angles), rec.shape[0], rec.shape[2])
     assert sino.shape[1] == 1
     assert type(sino) is numpy.ndarray
Esempio n. 14
0
    def test_stack_stats(self):
        stack = ds.get_needle_data()
        stdout = sys.stdout
        sys.stdout = io.StringIO()

        stack.stats()

        out = sys.stdout.getvalue()
        sys.stdout = stdout
        out = out.split('\n')

        assert out[0] == 'Mean: %.1f' % stack.data.mean()
        assert out[1] == 'Std: %.2f' % stack.data.std()
        assert out[2] == 'Max: %.1f' % stack.data.max()
        assert out[3] == 'Min: %.1f' % stack.data.min()
Esempio n. 15
0
 def test_tilt_align_unknown_method(self):
     stack = ds.get_needle_data()
     with pytest.raises(ValueError):
         stack.tilt_align(method='WRONG')
Esempio n. 16
0
 def test_correlation_check(self):
     stack = ds.get_needle_data()
     fig = stack.test_correlation()
     assert type(fig) is matplotlib.figure.Figure
     assert len(fig.axes) == 3
Esempio n. 17
0
 def test_test_align_with_thickness(self):
     stack = ds.get_needle_data(True)
     stack.test_align(thickness=200)
     fig = matplotlib.pylab.gcf()
     assert len(fig.axes) == 3
Esempio n. 18
0
 def test_register_unknown_method(self):
     stack = ds.get_needle_data()
     with pytest.raises(ValueError):
         stack.inav[0:20].stack_register('WRONG')
Esempio n. 19
0
 def test_get_aligned_experimental_data(self):
     stack = ds.get_needle_data(aligned=True)
     assert type(stack) is tomotools.TomoStack
Esempio n. 20
0
 def test_get_experimental_data(self):
     stack = ds.get_needle_data()
     assert type(stack) is tomotools.TomoStack
Esempio n. 21
0
 def test_test_align_with_angle(self):
     stack = ds.get_needle_data(True)
     stack.test_align(angle=3.0)
     fig = matplotlib.pylab.gcf()
     assert len(fig.axes) == 3
Esempio n. 22
0
 def test_align_to_other_no_alignment(self):
     stack = ds.get_needle_data()
     stack2 = stack.deepcopy()
     reg = stack.deepcopy()
     with pytest.raises(ValueError):
         reg.align_other(stack2)
Esempio n. 23
0
 def test_stack_invert(self):
     stack = ds.get_needle_data()
     invert = stack.invert()
     hist, bins = np.histogram(stack.data)
     hist_inv, bins_inv = np.histogram(invert.data)
     assert hist[0] > hist_inv[0]
Esempio n. 24
0
 def test_image_filter_wrong_name(self):
     stack = ds.get_needle_data()
     with pytest.raises(ValueError):
         stack.inav[0:10].filter(method='WRONG')
Esempio n. 25
0
 def test_align_to_other_with_crop(self):
     stack = ds.get_needle_data()
     reg = stack.stack_register('PC', crop=True)
     reg2 = reg.align_other(stack)
     diff = reg.data - reg2.data
     assert diff.sum() == 0.0
Esempio n. 26
0
 def test_test_align_no_slices(self):
     stack = ds.get_needle_data(True)
     stack.test_align()
     fig = matplotlib.pylab.gcf()
     assert len(fig.axes) == 3