def shepp3d(sz=512): import tomopy.misc import tomobox vol = tomobox.volume(tomopy.misc.phantom.shepp3d(sz)) vol.meta.history.add_record('SheppLogan phantom is generated', sz) return vol
projections.reconstruct._initialize_astra() #%% import pdm segmenter = pdm.pdm() # initialise pdm object segmenter.rho_method = 'quadratic' segmenter.proj_geom = projections.reconstruct.proj_geom segmenter.vol_geom = projections.reconstruct.vol_geom segmenter.projections = projections.data._data tau_initial = [0.0, 0.00001, 0.0001] rho_initial = [0.00001, 0000.1, 0.001, 0.01] segmenter.rho_fixed = numpy.array([False, False, False, False], dtype=numpy.bool) segmenter.tau_fixed = numpy.array([False, False, False], dtype=numpy.bool) # #%% Run PDM start = time.time() [S, rho_opt, tau_opt] = segmenter.run(volume, projections.meta.theta, rho_initial, tau_initial) end = time.time() print(end - start) #%% v = tw.volume(S) #%% v.io.save(path='', fname='seg', fmt='tiff')
# -*- coding: utf-8 -*- """ Test of the reconstructor. """ #%% Test IO import tomobox import reconstruction import simulate #%% Create aphantom: #phantom = simulate.phantom.shepp3d([10, 256, 256]) phantom = simulate.phantom.checkers([10, 256, 256]) vol = tomobox.volume(array=phantom, img_pixel=[0.1, 0.1, 0.1], block_sizeGB=3) vol.display.slice() #%% Forward project: proj = tomobox.projections(block_sizeGB=3) proj.data.zeros([20, 100, 256]) proj.meta.geometry.init(100, 100, [0.1, 0.1], theta_n=100) recon = reconstruction.reconstruct(proj, vol) recon.forwardproject() proj.display.slice() #%% Test Back-projector: vol.data.zeros() #recon._projections_to_swap()
b.io.read_flexray('/export/scratch3/kostenko/Fast_Data/rijksmuseum/tiling/al_dummy_vertical_tile_1/') b.process.flat_field() b.process.log() b.display.slice(dim = 1) b.data.switch_to_swap(keep_data=True, swap_path = '/export/scratch3/kostenko/Fast_Data/swap', swap_name = 'swap_0') b.data.switch_to_swap(keep_data=True, swap_path = '/export/scratch3/kostenko/Fast_Data/swap', swap_name = 'swap_1') #%% QC: a.meta.geometry.report() b.meta.geometry.report() #%% Test import reconstruction pix = a.meta.geometry.img_pixel[1] volume = tomobox.volume([500,401,400], pix) recon = reconstruction.reconstruct([a, b], volume) #%% recon.FDK() volume.display.slice() volume.display.slice(dim = 0)
prj.io.read_flexray('/export/scratch3/kostenko/Fast_Data/naturalis/oct2017_femora_trinil/whale_ear_1/') # Process: prj.process.flat_field() prj.process.log() prj.display.slice(dim = 1) #energy, spec = numpy.loadtxt('/export/scratch3/kostenko/Fast_Data/rijksmuseum/dummy/spectrum.txt') #prj.process.equivalent_thickness(energy, spec, 'Bone, Compact (ICRU)', 1.6) prj.meta.geometry.report() #%% shape = numpy.array([1500,1900,1900]) // bine img_pixel = numpy.array([0.03, 0.03, 0.03]) * bine volume = tomobox.volume(shape = shape, img_pixel = img_pixel) recon = reconstruction.reconstruct(prj, volume) recon.FDK() volume.data.cast_uint8() volume.io.write_data('/export/scratch3/kostenko/Fast_Data/naturalis/oct2017_femora_trinil/whale_ear_1/'+ 'FDK') volume.display.slice() #%% Release: volume.release() prj.release()
#energy, spec = numpy.loadtxt('/export/scratch3/kostenko/Fast_Data/rijksmuseum/dummy/spectrum.txt') #index = [5,] index = numpy.arange(0, 8) path = '/export/scratch3/kostenko/Fast_Data/naturalis/oct2017_femora_trinil/femora_i/' for ii in index: prj = tomobox.projections(block_sizeGB=4, swap=False) #prj.data.switch_to_swap(swap_path = '/export/scratch1/kostenko/tomobox_swap', swap_name = 'swap') prj.io.options['binning'] = 1 prj.io.options['index_step'] = 1 img_pixel = numpy.ones(3) * 0.045 * prj.io.options['binning'] shape = numpy.array([1550, 1450, 1900], 'uint32') // prj.io.binning volume = tomobox.volume(shape=shape, img_pixel=img_pixel, block_sizeGB=4) # Read data: prj.io.read_flexray(path + 'femora_i_tile_%u' % ii) # Process: prj.process.flat_field() prj.process.log() # Reconstruct: prj.meta.geometry.vol_trans[0] = 0 prj.meta.geometry.vol_trans[2] = -10 recon = reconstruction.reconstruct(prj, volume)