import matplotlib.pyplot as plt import corrct as cct import corrct.utils_test try: import phantom except ImportError: cct.utils_test.download_phantom() import phantom vol_shape = [256, 256, 3] data_type = np.float32 ph_or = np.squeeze(phantom.modified_shepp_logan(vol_shape).astype(data_type)) ph_or = ph_or[:, :, 1] # psf = spsig.gaussian(11, 1) psf = None det_angles = [+np.pi / 2, -np.pi / 2] (ph, vol_att_in, vol_att_out) = cct.utils_test.phantom_assign_concentration(ph_or) (sino, angles, expected_ph, _) = cct.utils_test.create_sino(ph, 120, detectors_pos_rad=det_angles, vol_att_in=vol_att_in, vol_att_out=vol_att_out, psf=psf)
import scipy.ndimage.interpolation as spni import phantom import numpy as np from skimage.transform import radon import pylab as pyl import tomopy_peri.tomopy # SIMULATED TOMO DATA #--------------------- p = 128 n_projections = 200 emission = True iters = 1 simulate_misaligned_projections = False theta = np.linspace(0,180,num=n_projections,endpoint=True) msl = phantom.modified_shepp_logan((p,p,p)) data = np.zeros((1, n_projections, p, p)) for i in range(p): data[0,:,i,:] = np.rollaxis(radon(msl[:,i,:], theta=theta, circle=True),1,0) if simulate_misaligned_projections: for i in range(n_projections): sx, sy = 3*(np.random.random()-0.5), 3*(np.random.random()-0.5) data[0,i,:,:]=spni.shift(data[0,i,:,:], (sx, sy)) d = tomopy.xftomo_dataset(data=data, theta=theta, channel_names=['Modified Shepp-Logan'], log='debug') tomopy.xftomo_writer(d.data, channel=0, output_file='/tmp/projections/projection_{:}_{:}.tif') if simulate_misaligned_projections: d.align_projections(output_gifs=True, output_filename='/tmp/projections.gif') d.align_projections(output_gifs=True, output_filename='/tmp/projections.gif')
except ImportError: cct.utils_test.download_phantom() import phantom try: import skimage.transform __have_skimage__ = True except ImportError: print( 'Scikit image not available, no comparison against other filters will be possible' ) __have_skimage__ = False vol_shape_xy = [256, 256] ph = np.squeeze( phantom.modified_shepp_logan([*vol_shape_xy, 3]).astype(np.float32)) ph = ph[:, :, 1] fbp_filter = 'Shepp-Logan' (sino, angles_rad, expected_ph, _) = cct.utils_test.create_sino(ph, 30, add_poisson=True, photon_flux=1e4) print('Reconstructing sino:') with cct.projectors.ProjectorUncorrected(vol_shape_xy, angles_rad) as p: print('- Filter: "%s"' % fbp_filter) vol_sl = p.fbp(sino, fbp_filter=fbp_filter) print('- Phantom power: %g, noise power: %g' % cct.utils_test.compute_error_power(expected_ph, vol_sl)) print('- Filter: "MR"') filter_mr = cct.projectors.FilterMR() vol_mr = p.fbp(sino, filter_mr)
try: import phantom except ImportError: cct.utils_test.download_phantom() import phantom def cm2inch(x): return np.array(x) / 2.54 data_type = np.float32 # Create the phantom shape ph_or = np.squeeze( phantom.modified_shepp_logan([256, 256, 3]).astype(data_type)) ph_or = ph_or[:, :, 1] # Simulate the XRF-CT acquisition data (sinogram) (ph, vol_att_in, vol_att_out) = cct.utils_test.phantom_assign_concentration(ph_or) (sinogram, angles, expected_ph, background_avg) = cct.utils_test.create_sino(ph, 30, add_poisson=True, dwell_time_s=2e-2, background_avg=1e-2, background_std=1e-4) prec = True iterations = 200
import ipdb import scipy.ndimage.interpolation as spni import phantom import numpy as np from skimage.transform import radon import pylab as pyl # SIMULATED TOMO DATA #--------------------- p = 128 n_projections = 200 emission = True iters = 1 simulate_misaligned_projections = False theta = np.linspace(0, 180, num=n_projections, endpoint=True) msl = phantom.modified_shepp_logan((p, p, p)) data = np.zeros((1, n_projections, p, p)) for i in range(p): data[0, :, i, :] = np.rollaxis(radon(msl[:, i, :], theta=theta, circle=True), 1, 0) if simulate_misaligned_projections: for i in range(n_projections): sx, sy = 3 * (np.random.random() - 0.5), 3 * (np.random.random() - 0.5) data[0, i, :, :] = spni.shift(data[0, i, :, :], (sx, sy)) d = tomopy.xftomo_dataset(data=data, theta=theta, channel_names=['Modified Shepp-Logan'], log='debug')