def saveRecTiff(self): try: self.savedir=QtGui.QFileDialog.getSaveFileName() if not self.savedir[0]: raise IndexError self.savedir=self.savedir[0] tomopy.xtomo_writer(self.d.data_recon,self.savedir,axis=0,digits=4) except IndexError: print "type the header name"
def main(): # read a series of SPE file_name = '/local/dataraid/databank/APS_13_BM/SPE/run2_soln1_2_.SPE' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/APS_13_BM_test_04.h5' white_start = 1 white_end = 8 white_step = 2 projections_start = 2 projections_end = 7 projections_step = 2 # set to convert slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 100 slices_end = 104 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images(file_name, projections_start = projections_start, projections_end = projections_end, projections_step = projections_step, slices_start = slices_start, slices_end = slices_end, white_start = white_start, white_end = white_end, white_step = white_step, projections_zeros=False, white_zeros=False, dark_zeros=False, data_type='spe', sample_name = 'Stripe_Solder_Sample_Tip1', log='INFO' ) ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center=705 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/APS_13BM_', axis=0)
def main(): # read a series of SPE file_name = '/local/dataraid/databank/APS_13_BM/SPE/run2_soln1_2_.SPE' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/APS_13_BM_test_04.h5' white_start = 1 white_end = 8 white_step = 2 projections_start = 2 projections_end = 7 projections_step = 2 # set to convert slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 100 slices_end = 104 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images( file_name, projections_start=projections_start, projections_end=projections_end, projections_step=projections_step, slices_start=slices_start, slices_end=slices_end, white_start=white_start, white_end=white_end, white_step=white_step, projections_zeros=False, white_zeros=False, dark_zeros=False, data_type='spe', sample_name='Stripe_Solder_Sample_Tip1', log='INFO') ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center = 705 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/APS_13BM_', axis=0)
def main(): file_name = '/local/dataraid/databank/CHESS/scan1/scan1_.tiff' dark_file_name = '/local/dataraid/databank/CHESS/scan1/scan1_dark_.tiff' white_file_name = '/local/dataraid/databank/CHESS/scan1/scan1_white_.tiff' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/CHESS_02.h5' sample_name = 'Dummy' projections_start = 1 projections_end = 361 white_start = 0 white_end = 1 white_step = 1 dark_start = 0 dark_end = 1 dark_step = 1 # set to convert slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 400 slices_end = 405 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images(file_name, projections_start = projections_start, projections_end = projections_end, slices_start = slices_start, slices_end = slices_end, sample_name = sample_name, projections_digits = 3, projections_zeros = True, log='INFO' ) # and/or read as data exchange # Read HDF5 file. ##data, white, dark, theta = tomopy.xtomo_reader('/local/dataraid/databank/dataExchange/microCT/CHESS_01.h5', ## slices_start=100, ## slices_end=101) # Xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() d.optimize_center() #d.phase_retrieval() #d.correct_drift() #d.center=99.5 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/CHESS_scan1_', axis=0)
def main(): # read a series of netCDF file_name = '/local/dataraid/databank/APS_13_BM/NC/Dorthe_F_.nc' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/APS_13_BM_NC_test_02.h5' white_start = 1 white_end = 4 white_step = 2 projections_start = 2 projections_end = 3 projections_step = 1 # set to convert slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 300 slices_end = 304 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images(file_name, projections_start = projections_start, projections_end = projections_end, projections_step = projections_step, slices_start = slices_start, slices_end = slices_end, white_start = white_start, white_end = white_end, white_step = white_step, projections_digits = 3, data_type='nc', log='INFO' ) ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center=484.5 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/APS_13BM_', axis=0)
def main(): file_name = '/local/dataraid/databank/CHESS/scan1/scan1_.tiff' dark_file_name = '/local/dataraid/databank/CHESS/scan1/scan1_dark_.tiff' white_file_name = '/local/dataraid/databank/CHESS/scan1/scan1_white_.tiff' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/CHESS_02.h5' sample_name = 'Dummy' projections_start = 1 projections_end = 361 white_start = 0 white_end = 1 white_step = 1 dark_start = 0 dark_end = 1 dark_step = 1 # set to convert slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 400 slices_end = 405 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images( file_name, projections_start=projections_start, projections_end=projections_end, slices_start=slices_start, slices_end=slices_end, sample_name=sample_name, projections_digits=3, projections_zeros=True, log='INFO') # and/or read as data exchange # Read HDF5 file. ##data, white, dark, theta = tomopy.xtomo_reader('/local/dataraid/databank/dataExchange/microCT/CHESS_01.h5', ## slices_start=100, ## slices_end=101) # Xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() d.optimize_center() #d.phase_retrieval() #d.correct_drift() #d.center=99.5 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/CHESS_scan1_', axis=0)
def main(): # read a series of netCDF file_name = '/local/dataraid/databank/APS_13_BM/NC/Dorthe_F_.nc' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/APS_13_BM_NC_test_02.h5' white_start = 1 white_end = 4 white_step = 2 projections_start = 2 projections_end = 3 projections_step = 1 # set to convert slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 300 slices_end = 304 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images( file_name, projections_start=projections_start, projections_end=projections_end, projections_step=projections_step, slices_start=slices_start, slices_end=slices_end, white_start=white_start, white_end=white_end, white_step=white_step, projections_digits=3, data_type='nc', log='INFO') ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center = 484.5 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/APS_13BM_', axis=0)
def main(): file_name = '/local/dataraid/2013_11/Vincent_201311/GA_exp/92_2_01/rad_0400ms_.tiff' white_file_name = '/local/dataraid/2013_11/Vincent_201311/GA_exp/92_2_01/ff_0350ms_.tiff' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/NSLS.h5' white_start = 0 white_end = 2580 white_step = 30 projections_start = 0 projections_end = 2600 # set to convert slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 800 slices_end = 804 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images(file_name, projections_start = projections_start, projections_end = projections_end, projections_digits=4, slices_start = slices_start, slices_end = slices_end, white_file_name = white_file_name, white_start = white_start, white_end = white_end, white_step = white_step, log='INFO' ) ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center=1010.0 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/SLS_', axis=0)
def main(): file_name = '/local/dataraid/databank/ESRF/scan.edf' dark_file_name = '/local/dataraid/databank/ESRF/dark.edf' white_file_name = '/local/dataraid/databank/ESRF/flat.edf' # only defined if used a converter # omit when used as direct importer in tomoPy hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/ESRF_test_02.h5' sample_name = 'esrf' # set to import/convert slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 300 slices_end = 304 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images(file_name, white_file_name = white_file_name, dark_file_name = dark_file_name, sample_name = sample_name, slices_start = slices_start, slices_end = slices_end, data_type='edf', log='INFO' ) ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange with: ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. # for full set of options see http://tomopy.github.io/tomopy/ d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center=549.84 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/ESRF_OK', axis=0)
def main(): file_name = '/local/dataraid/2013_11/Vincent_201311/GA_exp/92_2_01/rad_0400ms_.tiff' white_file_name = '/local/dataraid/2013_11/Vincent_201311/GA_exp/92_2_01/ff_0350ms_.tiff' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/NSLS.h5' white_start = 0 white_end = 2580 white_step = 30 projections_start = 0 projections_end = 2600 # set to convert slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 800 slices_end = 804 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images( file_name, projections_start=projections_start, projections_end=projections_end, projections_digits=4, slices_start=slices_start, slices_end=slices_end, white_file_name=white_file_name, white_start=white_start, white_end=white_end, white_step=white_step, log='INFO') ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center = 1010.0 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/SLS_', axis=0)
def main(): file_name = '/local/dataraid/databank/ESRF/scan.edf' dark_file_name = '/local/dataraid/databank/ESRF/dark.edf' white_file_name = '/local/dataraid/databank/ESRF/flat.edf' # only defined if used a converter # omit when used as direct importer in tomoPy hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/ESRF_test_02.h5' sample_name = 'esrf' # set to import/convert slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 300 slices_end = 304 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images( file_name, white_file_name=white_file_name, dark_file_name=dark_file_name, sample_name=sample_name, slices_start=slices_start, slices_end=slices_end, data_type='edf', log='INFO') ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange with: ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. # for full set of options see http://tomopy.github.io/tomopy/ d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center = 549.84 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/ESRF_OK', axis=0)
def main(): # only used to locate the wavelenght.dpt and angle.dpt files raw_tiff_base_name = "/local/dataraid/databank/dataExchange/microCT/SRC/raw/FPA_16_18_18_TOMO_243_Fiber_2500_50_50_" hdf5_base_name = "/local/dataraid/databank/dataExchange/microCT/SRC/dx/FPA_16_18_18_TOMO_243_Fiber_2500_50_50_" log_file = raw_tiff_base_name + "wavelength.dpt" angle_file = raw_tiff_base_name + "angle.dpt" dir_name = os.path.dirname(hdf5_base_name) sample_name_prefix = os.path.basename(hdf5_base_name) print dir_name print sample_name_prefix file = open(log_file, 'r') for line in file: linelist = line.split(",") hdf5_file_name = hdf5_base_name + linelist[0] + "cm-1.h5" sample_name = hdf5_base_name + linelist[0] + "cm-1" # set to read slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 30 slices_end = 36 # to create a data exchange file use convert_SRC.py module, data, white, dark, theta = tomopy.xtomo_reader( hdf5_file_name, slices_start=slices_start, slices_end=slices_end) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center = 64 d.gridrec() # Write to stack of TIFFs. rec_name = dir_name + "/rec/" + sample_name_prefix + linelist[ 0] + "cm-1" tomopy.xtomo_writer(d.data_recon, rec_name, axis=0) file.close()
def main(): # only used to locate the wavelenght.dpt and angle.dpt files raw_tiff_base_name = "/local/dataraid/databank/dataExchange/microCT/SRC/raw/FPA_16_18_18_TOMO_243_Fiber_2500_50_50_" hdf5_base_name = "/local/dataraid/databank/dataExchange/microCT/SRC/dx/FPA_16_18_18_TOMO_243_Fiber_2500_50_50_" log_file = raw_tiff_base_name + "wavelength.dpt" angle_file = raw_tiff_base_name + "angle.dpt" dir_name = os.path.dirname(hdf5_base_name) sample_name_prefix = os.path.basename(hdf5_base_name) print dir_name print sample_name_prefix file = open(log_file, 'r') for line in file: linelist=line.split(",") hdf5_file_name = hdf5_base_name+linelist[0]+"cm-1.h5" sample_name = hdf5_base_name+linelist[0]+"cm-1" # set to read slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 30 slices_end = 36 # to create a data exchange file use convert_SRC.py module, data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, slices_start=slices_start, slices_end=slices_end) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center=64 d.gridrec() # Write to stack of TIFFs. rec_name = dir_name + "/rec/" + sample_name_prefix + linelist[0] + "cm-1" tomopy.xtomo_writer(d.data_recon, rec_name, axis=0) file.close()
def hdf5_to_recon(inputDir = '.', inputFileName='out.h5', startSlice=None, endSlice=None, outputDir='./recon', outBase = 'recon_', center=None): # Make the output directory if it doesn't already exist. if not os.path.exists(outputDir): os.makedirs(outputDir) # This is the path to the input HDF5 file. inputFilePath = os.path.join(inputDir, inputFileName) # This is the path to the output files outputPath = os.path.join(outputDir, outBase) # Read HDF5 file. data, white, dark, theta = tomopy.xtomo_reader(inputFilePath, slices_start=startSlice, slices_end=endSlice) # Xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() d.phase_retrieval() d.correct_drift() # Appliy a median filter to the (images?) to improve the chance of success of the center finder. d.median_filter() # Find the center of rotation if center == None: d.optimize_center() else: d.center=center # Do the tomographic reconstruction d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, outputPath, axis=0, x_start=startSlice)
# d = tomopy.xtomo_dataset(log='debug') # d.dataset(data, white, dark, theta=theta) # d.zinger_removal(zinger_level=500, median_width=5) # d.normalize(negvals=1, cutoff=1) # # d.stripe_removal() # d.phase_retrieval(alpha=0.005) # d.center=1010 # d.gridrec(ringWidth=30) # d.apply_mask(ratio=0.95) # tomopy.xtomo_writer(d.data_recon, 'tmp/Tapuia_dentary_ant2_200mm_4_/rec_', dtype='uint16', axis=0) file_name = '/local/data/Tapuiasaurus_dentary_ant_200mm_1.hdf5' data, white, dark, theta = tomopy.xtomo_reader(file_name, projections_start=1, slices_start=300, slices_end=332) d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta=theta) d.zinger_removal(zinger_level=500, median_width=5) d.normalize(negvals=1, cutoff=1) d.stripe_removal() d.phase_retrieval(alpha=0.005) d.center=1010 d.gridrec(ringWidth=0) d.apply_mask(ratio=0.95) tomopy.xtomo_writer(d.data_recon, 'tmp/Tapuiasaurus_dentary_ant_200mm_1/rec_', dtype='uint16', axis=0)
data_min = d.data_recon.min() data_max = d.data_recon.max() ##________________________reconstruction______________________________ for ii in xrange(num_chunk): if ii == 0: SliceStart = offset + ii*chunk_size SliceEnd = offset + (ii+1)*chunk_size else: SliceStart = offset + ii*(chunk_size-margin_slices) SliceEnd = offset + SliceStart + chunk_size if SliceEnd > (2/3)*num_proj): SliceEnd = (2/3)*num_proj) data, white, dark, theta = tomopy.xtomo_reader(file_name,slices_start=SliceStart,slices_end=SliceEnd,white_start=3,white_end=9,dark_start=3,dark_end=9) data[0,:,:] = data[1,:,:] d.dataset(data, white, dark, theta) d.zinger_removal(median_width=15,zinger_level=200) d.normalize() d.correct_drift(10) d.stripe_removal(wname="sym16",level=10,sigma=4, padding=True) d.phase_retrieval(dist=z, energy=eng, pixel_size=pxl, alpha=rat,padding=False) d.center = center d.gridrec() d.apply_mask(ratio=0.95) tomopy.xtomo_writer(d.data_recon[np.int(margin_slices/2):(SliceEnd-SliceStart-np.int(margin_slices/2)),:,:], output_file, dtype='uint16', axis=0, x_start=SliceStart+np.int(margin_slices/2), data_min=data_min, data_max=data_max, overwrite = True) d.FLAG_THETA = False
def main(): # read a series of tiff file_name = '/local/dataraid/databank/VirginiaTech/test_sample_Diplo_4/Diplodocus_1_200mm_4_.tif' dark_file_name = '/local/dataraid/databank/VirginiaTech/test_sample_Diplo_4/Diplodocus_1_200mm_4postDark_.tif' white_file_name = '/local/dataraid/databank/VirginiaTech/test_sample_Diplo_4/Diplodocus_1_200mm_4postFlat_.tif' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/VirginiaTech_test.h5' sample_name = 'Diplodocus_1_200mm_' projections_start = 1 # projection 0 is dark so we skip it projections_end = 1500 white_start = 0 white_end = 10 white_step = 1 dark_start = 0 dark_end = 10 dark_step = 1 # to reconstruct slices from slices_start to slices_end # if omitted all data set is recontructed slices_start = 600 slices_end = 604 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images(file_name, projections_start = projections_start, projections_end = projections_end, slices_start = slices_start, slices_end = slices_end, white_file_name = white_file_name, white_start = white_start, white_end = white_end, white_step = white_step, dark_file_name = dark_file_name, dark_start = dark_start, dark_end = dark_end, dark_step = dark_step, sample_name = sample_name, projections_digits = 5, projections_zeros = True, log='INFO' ) ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() #d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center=1018.63 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/AAA_VT_', axis=0)
########################## finding num_overlap_pixels - Start ######################### #### phase retrieval - Start #### data, white, dark, theta = tomopy.xtomo_reader(file_name,slices_start=300,slices_end=310,white_start=3,white_end=9,dark_start=3,dark_end=9) data[0,:,:] = data[1,:,:] # in case the first projection image is corrupted d.dataset(data, white, dark, theta) d.normalize() d.stripe_removal(wname="db5",level=10,sigma=4.) data_size = d.data.shape d.phase_retrieval(dist=z, energy=eng, pixel_size=pxl, alpha=rat,padding=True) data_tem = d.data #### phase retrieval - End #### #### trial recons - Start #### for ii in range(nop_start,nop_end): d.dataset(data_tem,np.ones([d.data.shape[1],d.data.shape[2]]),None,None) d.correct_fov(num_overlap_pixels=ii) # tomopy.xtomo_writer(d.data[:,5:7,:], output_file+'sinogram_num_overlap_pixel_'+str(ii)+'_', axis=1,x_start=0,overwrite = True) # d.FLAG_THETA = False d_recon.dataset(d.data,np.ones([d.data.shape[1],d.data.shape[2]]),None,None) # print ii,d.data.shape,d_recon.data.shape d_recon.center = d_recon.data.shape[2]/2.0 d_recon.gridrec() # print d_recon.center tomopy.xtomo_writer(d_recon.data_recon[5:7,:,:], output_file+'num_overlap_pixel_'+str(ii)+'_', axis=0,x_start=0,overwrite = True) d.FLAG_THETA = False #### trial recons - Start #### ######################### finding num_overlap_pixels - End #########################
def main(): file_name = '/local/dataraid/databank/APS_1_ID/APS1ID_Cat4B_2/CAT4B_2_.tif' log_file = '/local/dataraid/databank/APS_1_ID/APS1ID_Cat4B_2/CAT4B_2_TomoStillScan.dat' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/CAT4B_2_test_01.h5' #Read APS 1-ID log file data file = open(log_file, 'r') for line in file: linelist=line.split() if len(linelist)>1: if (linelist[0]=="First" and linelist[1]=="image"): projections_start = int(linelist[4]) elif (linelist[0]=="Last" and linelist[1]=="image"): projections_end = int(linelist[4]) elif (linelist[0]=="Dark" and linelist[1]=="field"): dark_start = int(linelist[6]) elif (linelist[0]=="Number" and linelist[2]=="dark"): number_of_dark = int(linelist[5]) elif (linelist[0]=="White" and linelist[1]=="field"): white_start = int(linelist[6]) elif (linelist[0]=="Number" and linelist[2]=="white"): number_of_white = int(linelist[5]) file.close() dark_end = dark_start + number_of_dark white_end = white_start + number_of_white # to fix a data collection looging bug ? white_start = white_start + 1 dark_start = dark_start +1 projections_start = projections_start + 11 projections_end = projections_end - 9 ## # these are correct per Peter discussion ## projections_start = 943 ## projections_end = 1853 ## white_start = 1844 ## white_end = 1853 ## dark_start = 1854 ## dark_end = 1863 print projections_start, projections_end print dark_start, dark_end print white_start, white_end # set to convert slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 1000 slices_end = 1004 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images(file_name, projections_start = projections_start, projections_end = projections_end, slices_start = slices_start, slices_end = slices_end, white_start = white_start, white_end = white_end, dark_start = dark_start, dark_end = dark_end, projections_digits = 6, log='INFO' ) ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center=1026.0 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/APS_1ID_', axis=0)
def main(): log_file = '/local/dataraid/databank/APS_2_BM/Sam18_hornby/Sam18_exp.hdf' #Read APS 2-BM log file data f = SD.SD(log_file) sds = f.select('base_name') data = sds.get() base_name = ''.join(data) print base_name file_name = os.path.split(log_file)[0] + "/" + "raw" + "/" + base_name + "_.hdf" sds = f.select('start_angle') start_angle = sds.get()[0] sds = f.select('end_angle') end_angle = sds.get()[0] sds = f.select('angle_interval') angle_interval = sds.get()[0] sds = f.select('num_dark_fields') num_dark_fields = sds.get()[0] f.end() white_start = 1 white_end = 2 projections_start = 2 projections_end = projections_start + (int)((end_angle - start_angle) / angle_interval) + 1 dark_start = projections_end + 1 dark_end = dark_start + num_dark_fields sample_name = base_name # to reconstruct a subset of slices set slices_start and slices_end # if omitted the full data set is recontructed slices_start = 800 slices_end = 804 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images(file_name, projections_start = projections_start, projections_end = projections_end, slices_start = slices_start, slices_end = slices_end, white_start = white_start, white_end = white_end, dark_start = dark_start, dark_end = dark_end, projections_digits = 5, data_type = 'hdf4', log='INFO' ) ## # if you have already created a data exchange file using convert_APS_2BM.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## ## hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/Hornby_19keV_10x_APS_2011_01.h5' ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center=1023.4 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/APS_2_BM_', axis=0)
# d.phase_retrieval(dist=z, energy=eng, pixel_size=pxl, alpha=rat,padding=True) # if remove_stripe4: # mask_bad_val = crap_mask(white, 200, 40) # d.stripe_removal4(mask_bad_val) if remove_stripe2: d.stripe_removal2() # if remove_stripe: d.stripe_removal(level=stripe_lvl, sigma=sig, wname=Wname) d.downsample2d(level=level) # apply binning on the data if 1: if not best_center: d.optimize_center() else: d.center=best_center/pow(2,level) # Manage the rotation center d.gridrec(ringWidth=RingW) # Run the reconstruction d.apply_mask(ratio=1) # Write data as stack of TIFs. tomopy.xtomo_writer(d.data_recon, output_name, axis=0, x_start=slice_first) #### for the whole volume reconstruction if 0: f = h5py.File(file_name, "r"); nProj, nslices, nCol = f["/exchange/data"].shape nslices_per_chunk = nslices/chunk for iChunk in range(0,chunk): print '\n -- chunk # %i' % (iChunk+1) slice_first = nslices_per_chunk*iChunk slice_last = nslices_per_chunk*(iChunk+1) # Read HDF5 file. data, white, dark, theta = tomopy.xtomo_reader(file_name, exchange_rank = ExchangeRank,
### Create minimal data exchange hdf5 file ##mydata.xtomo_exchange(data = data, ## data_white = white, ## data_dark = dark, ## theta = theta, ## hdf5_file_name = hdf5_file_name, ## data_exchange_type = 'tomography_raw_projections' ## ) # and/or read as data exchange # Read HDF5 file. ##data, white, dark, theta = tomopy.xtomo_reader('/local/dataraid/databank/dataExchange/microCT/CHESS_01.h5', ## slices_start=100, ## slices_end=101) # Xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center=99.5 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/CHESS_Integrated_100_', axis=0)
def main(): # read a series of tiff # oster: pj: from 0 -> 1440; bf from 0 -> 19; df from 0 -> 19 file_name = '/local/dataraid/databank/PetraIII/2011_KW16_oster/oster02_0001/scan_0002/ccd/pco01/ccd_.tif' dark_file_name = '/local/dataraid/databank/PetraIII/2011_KW16_oster/oster02_0001/scan_0000/ccd/pco01/ccd_.tif' white_file_name = '/local/dataraid/databank/PetraIII/2011_KW16_oster/oster02_0001/scan_0001/ccd/pco01/ccd_.tif' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/PetraIII_oster02_0001.h5' sample_name = 'PetraIII P06 oster02_0001' projections_start = 0 projections_end = 1441 white_start = 0 white_end = 20 white_step = 1 dark_start = 0 dark_end = 20 dark_step = 1 # to reconstruct slices from slices_start to slices_end # if omitted all data set is recontructed slices_start = 1001 slices_end = 1501 # mydata = dx.Import() # # Read series of images # data, white, dark, theta = mydata.series_of_images(file_name, # projections_start = projections_start, # projections_end = projections_end, # slices_start = slices_start, # slices_end = slices_end, # #projections_angle_range=360, # white_file_name = white_file_name, # white_start = white_start, # white_end = white_end, # white_step = white_step, # dark_file_name = dark_file_name, # dark_start = dark_start, # dark_end = dark_end, # dark_step = dark_step, # sample_name = sample_name, # projections_digits = 4, # projections_zeros = True, # log='INFO' # ) # if you have already created a data exchange file using convert_PetraIII.py module, # comment the call above and read the data set as data exchange using: # Read HDF5 file. data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, slices_start=slices_start, slices_end=slices_end) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() d.phase_retrieval(pixel_size=0.9e-4, dist=6.9, energy=15.25) #d.correct_drift() d.center = 1872.87890625 d.gridrec() # Write to stack of TIFFs. # tomopy.xtomo_writer(d.data_recon, 'tmp/oster02_0001_', axis=0) tomopy.xtomo_writer(d.data_recon, 'tmp/oster02_0001_int_', axis=0, x_start=1001, overwrite=True, dtype='uint8', data_min=-0.0001, data_max=0.0003)
def main(): # read a series of tiff file_name = '/local/dataraid/databank/AS/Mayo_tooth_AS/SAMPLE_T_.tif' dark_file_name = '/local/dataraid/databank/AS/Mayo_tooth_AS/DF__AFTER_01.tif' white_file_name = '/local/dataraid/databank/AS/Mayo_tooth_AS/BG__BEFORE_01.tif' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/Australian_test.h5' sample_name = 'Teeth' projections_start = 0 projections_end = 1801 white_start = 0 white_end = 10 white_step = 1 dark_start = 0 dark_end = 10 dark_step = 1 # to reconstruct slices from slices_start to slices_end # if omitted all data set is recontructed slices_start = 290 slices_end = 294 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images( file_name, projections_start=projections_start, projections_end=projections_end, slices_start=slices_start, slices_end=slices_end, white_file_name=white_file_name, white_start=white_start, white_end=white_end, white_step=white_step, dark_file_name=dark_file_name, dark_start=dark_start, dark_end=dark_end, dark_step=dark_step, sample_name=sample_name, projections_digits=4, white_digits=2, dark_digits=2, projections_zeros=True, log='INFO') ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center = 1184.0 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/AS_', axis=0)
def main(): # read a series of tiff file_name = '/local/dataraid/databank/Elettra/Volcanic_rock/tomo_.tif' dark_file_name = '/local/dataraid/databank/Elettra/Volcanic_rock/dark_.tif' white_file_name = '/local/dataraid/databank/Elettra/Volcanic_rock/flat_.tif' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/Elettra_test.h5' projections_start = 1 projections_end = 1441 white_start = 1 white_end = 11 white_step = 1 dark_start = 1 dark_end = 11 dark_step = 1 sample_name = 'Volcanic_rock' # to reconstruct slices from slices_start to slices_end # if omitted all data set is recontructed slices_start = 150 slices_end = 154 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images( file_name, projections_start=projections_start, projections_end=projections_end, projections_digits=4, slices_start=slices_start, slices_end=slices_end, white_file_name=white_file_name, white_start=white_start, white_end=white_end, white_step=white_step, dark_file_name=dark_file_name, dark_start=dark_start, dark_end=dark_end, dark_step=dark_step, data_type='compressed_tiff', # comment this line if regular tiff projections_zeros=True, white_zeros=False, dark_zeros=False, sample_name=sample_name, log='INFO') ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() d.optimize_center() #d.phase_retrieval() #d.correct_drift() #d.center=1010.0 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/Elettra_', axis=0)
def main(): file_name = '/local/dataraid/databank/als/data/raw/sacarroll/20140731_001306_2477A_x00y08/20140731_001306_2477A_x00y08_0000_.tif' dark_file_name = '/local/dataraid/databank/als/data/raw/sacarroll/20140731_001306_2477A_x00y08/20140731_001306_2477A_x00y08drk_.tif' white_file_name = '/local/dataraid/databank/als/data/raw/sacarroll/20140731_001306_2477A_x00y08/20140731_001306_2477A_x00y08bak_.tif' log_file = '/local/dataraid/databank/als/data/raw/sacarroll/20140731_001306_2477A_x00y08/20140731_001306_2477A_x00y08.sct' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/ALS_20140731.h5' verbose = True # start = time.clock() # Read ALS log file data file = open(log_file, 'r') for line in file: if '-scanner' in line: Source = re.sub(r'-scanner ', "", line) if verbose: print 'Facility', Source if '-object' in line: Sample = re.sub(r'-object ', "", line) if verbose: print 'Sample', Sample if '-senergy' in line: Energy = re.findall(r'\d+.\d+', line) if verbose: print 'Energy', Energy[0] if '-scurrent' in line: Current = re.findall(r'\d+.\d+', line) if verbose: print 'Current', Current[0] if '-nangles' in line: Angles = re.findall(r'\d+', line) if verbose: print 'Angles', Angles[0] if '-i0cycle' in line: WhiteStep = re.findall(r'\s+\d+', line) if verbose: print 'White Step', WhiteStep[0] if '-num_bright_field' in line: WhiteEnd = re.findall(r'\d+', line) if '-num_dark_fields' in line: DarkEnd = re.findall(r'\d+', line) file.close() dark_start = 0 dark_end = int(DarkEnd[0]) dark_step = 1 white_start = 0 white_end = int(WhiteEnd[0]) white_step = int(WhiteStep[0]) projections_start = 0 projections_end = int(Angles[0]) # set to convert slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 245 slices_end = 265 # mydata = dx.Import() # Read series of images # data, white, dark, theta = mydata.series_of_images(file_name = file_name, # projections_start = projections_start, # projections_end = projections_end, ## slices_start = slices_start, ## slices_end = slices_end, # white_file_name = white_file_name, # white_start = white_start, # white_end = white_end, # dark_file_name = dark_file_name, # dark_start = dark_start, # dark_end = dark_end, # projections_digits = 4, # log='INFO' # ) start = time.clock() # if you have already created a data exchange file using convert_SLS.py module, # comment the call above and read the data set as data exchange # Read HDF5 file. data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, slices_start=slices_start, slices_end=slices_end) elapsed = (time.clock() - start) print "Total Time to read raw files:", elapsed # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center=1282.5 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/ALS_new', axis=0)
def main(): # read a series of tiff file_name = '/local/dataraid/databank/AS/Mayo_tooth_AS/SAMPLE_T_.tif' dark_file_name = '/local/dataraid/databank/AS/Mayo_tooth_AS/DF__AFTER_.tif' white_file_name = '/local/dataraid/databank/AS/Mayo_tooth_AS/BG__BEFORE_.tif' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/Australian_test.h5' sample_name = 'Teeth' projections_start = 0 projections_end = 1801 white_start = 0 white_end = 10 white_step = 1 dark_start = 0 dark_end = 10 dark_step = 1 # to reconstruct slices from slices_start to slices_end # if omitted all data set is recontructed slices_start = 290 slices_end = 294 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images(file_name, projections_start = projections_start, projections_end = projections_end, slices_start = slices_start, slices_end = slices_end, white_file_name = white_file_name, white_start = white_start, white_end = white_end, white_step = white_step, dark_file_name = dark_file_name, dark_start = dark_start, dark_end = dark_end, dark_step = dark_step, sample_name = sample_name, projections_digits = 4, white_digits = 2, dark_digits = 2, projections_zeros = True, log='INFO' ) ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() d.optimize_center() #d.phase_retrieval() #d.correct_drift() #d.center=1010.0 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/AS_', axis=0)
def main(): # read a series of tiff file_name = '/local/dataraid/databank/Anka/radios/image_.tif' dark_file_name = '/local/dataraid/databank/Anka/darks/image_.tif' white_file_name = '/local/dataraid/databank/Anka/flats/image_.tif' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/Anka_test.h5' projections_start = 0 projections_end = 3167 white_start = 0 white_end = 100 dark_start = 0 dark_end = 100 sample_name = 'Anka' # to reconstruct slices from slices_start to slices_end # if omitted all data set is recontructed slices_start = 800 slices_end = 804 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images( file_name, projections_start=projections_start, projections_end=projections_end, slices_start=slices_start, slices_end=slices_end, white_file_name=white_file_name, white_start=white_start, white_end=white_end, dark_file_name=dark_file_name, dark_start=dark_start, dark_end=dark_end, sample_name=sample_name, projections_digits=5, log='INFO') ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() d.optimize_center() #d.phase_retrieval() #d.correct_drift() #d.center=1010.0 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/ANKA_', axis=0)
def main(): file_name = '/local/dataraid/databank/APS_1_ID/APS1ID_Cat4B_2/CAT4B_2_.tif' log_file = '/local/dataraid/databank/APS_1_ID/APS1ID_Cat4B_2/CAT4B_2_TomoStillScan.dat' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/CAT4B_2_test_01.h5' #Read APS 1-ID log file data file = open(log_file, 'r') for line in file: linelist = line.split() if len(linelist) > 1: if (linelist[0] == "First" and linelist[1] == "image"): projections_start = int(linelist[4]) elif (linelist[0] == "Last" and linelist[1] == "image"): projections_end = int(linelist[4]) elif (linelist[0] == "Dark" and linelist[1] == "field"): dark_start = int(linelist[6]) elif (linelist[0] == "Number" and linelist[2] == "dark"): number_of_dark = int(linelist[5]) elif (linelist[0] == "White" and linelist[1] == "field"): white_start = int(linelist[6]) elif (linelist[0] == "Number" and linelist[2] == "white"): number_of_white = int(linelist[5]) file.close() dark_end = dark_start + number_of_dark white_end = white_start + number_of_white # to fix a data collection looging bug ? white_start = white_start + 1 dark_start = dark_start + 1 projections_start = projections_start + 11 projections_end = projections_end - 9 ## # these are correct per Peter discussion ## projections_start = 943 ## projections_end = 1853 ## white_start = 1844 ## white_end = 1853 ## dark_start = 1854 ## dark_end = 1863 print projections_start, projections_end print dark_start, dark_end print white_start, white_end # set to convert slices between slices_start and slices_end # if omitted all data set will be converted slices_start = 1000 slices_end = 1004 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images( file_name, projections_start=projections_start, projections_end=projections_end, slices_start=slices_start, slices_end=slices_end, white_start=white_start, white_end=white_end, dark_start=dark_start, dark_end=dark_end, projections_digits=6, log='INFO') ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center = 1026.0 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/APS_1ID_', axis=0)
def main(): # read a series of tiff file_name = '/local/dataraid/databank/SLS_2011/Hornby_SLS/Hornby_b.tif' log_file = '/local/dataraid/databank/SLS_2011/Hornby_SLS/Hornby.log' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/Hornby_SLS_2011_01.h5' #Read SLS log file data file = open(log_file, 'r') for line in file: linelist = line.split() if len(linelist) > 1: if (linelist[0] == "Number" and linelist[2] == "darks"): number_of_darks = int(linelist[4]) elif (linelist[0] == "Number" and linelist[2] == "flats"): number_of_flats = int(linelist[4]) elif (linelist[0] == "Number" and linelist[2] == "projections"): number_of_projections = int(linelist[4]) elif (linelist[0] == "Rot" and linelist[2] == "min"): rotation_min = float(linelist[6]) elif (linelist[0] == "Rot" and linelist[2] == "max"): rotation_max = float(linelist[6]) elif (linelist[0] == "Angular" and linelist[1] == "step"): angular_step = float(linelist[4]) file.close() dark_start = 1 dark_end = number_of_darks + 1 white_start = dark_end white_end = white_start + number_of_flats projections_start = white_end projections_end = projections_start + number_of_projections # to reconstruct a subset of slices set slices_start and slices_end # if omitted the full data set is recontructed slices_start = 800 slices_end = 804 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images( file_name, projections_start=projections_start, projections_end=projections_end, projections_digits=4, slices_start=slices_start, slices_end=slices_end, white_start=white_start, white_end=white_end, dark_start=dark_start, dark_end=dark_end, log='INFO') ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center = 1010.0 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/SLS_', axis=0)
def main(): # read a series of tiff file_name = '/local/dataraid/databank/Elettra/Volcanic_rock/tomo_.tif' dark_file_name = '/local/dataraid/databank/Elettra/Volcanic_rock/dark_.tif' white_file_name = '/local/dataraid/databank/Elettra/Volcanic_rock/flat_.tif' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/Elettra_test.h5' projections_start = 1 projections_end = 1441 white_start = 1 white_end = 11 white_step = 1 dark_start = 1 dark_end = 11 dark_step = 1 sample_name = 'Volcanic_rock' # to reconstruct slices from slices_start to slices_end # if omitted all data set is recontructed slices_start = 150 slices_end = 154 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images(file_name, projections_start = projections_start, projections_end = projections_end, projections_digits = 4, slices_start = slices_start, slices_end = slices_end, white_file_name = white_file_name, white_start = white_start, white_end = white_end, white_step = white_step, dark_file_name = dark_file_name, dark_start = dark_start, dark_end = dark_end, dark_step = dark_step, data_type = 'compressed_tiff', # comment this line if regular tiff projections_zeros = True, white_zeros = False, dark_zeros = False, sample_name = sample_name, log='INFO' ) ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() d.optimize_center() #d.phase_retrieval() #d.correct_drift() #d.center=1010.0 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/Elettra_', axis=0)
SliceEnd = offset + (ii+1)*chunk_size else: SliceStart = offset + ii*(chunk_size-margin_slices) SliceEnd = offset + SliceStart + chunk_size if SliceEnd > (offset+num_proj): SliceEnd = offset+num_proj data, white, dark, theta = tomopy.xtomo_reader(file_name,slices_start=SliceStart,slices_end=SliceEnd,white_start=3,white_end=9,dark_start=3,dark_end=9) data[0,:,:] = data[1,:,:] d.dataset(data, white, dark, theta) d.zinger_removal(median_width=10) d.normalize() d.correct_drift(10) d.stripe_removal(wname="sym16",level=10,sigma=4) d.phase_retrieval(dist=z, energy=eng, pixel_size=pxl, alpha=rat,padding=True) d.center = center d.gridrec() tomopy.xtomo_writer(d.data_recon[np.int(margin_slices/2):(SliceEnd-SliceStart-np.int(margin_slices/2)),:,:], output_file, axis=0,dtype='float32', x_start=SliceStart+np.int(margin_slices/2),overwrite = True) d.FLAG_THETA = False
def main(): # read a series of tiff file_name = '/local/dataraid/databank/Anka/radios/image_.tif' dark_file_name = '/local/dataraid/databank/Anka/darks/image_.tif' white_file_name = '/local/dataraid/databank/Anka/flats/image_.tif' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/Anka_test.h5' projections_start = 0 projections_end = 3167 white_start = 0 white_end = 100 dark_start = 0 dark_end = 100 sample_name = 'Anka' # to reconstruct slices from slices_start to slices_end # if omitted all data set is recontructed slices_start = 800 slices_end = 804 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images(file_name, projections_start = projections_start, projections_end = projections_end, slices_start = slices_start, slices_end = slices_end, white_file_name = white_file_name, white_start = white_start, white_end = white_end, dark_file_name = dark_file_name, dark_start = dark_start, dark_end = dark_end, sample_name = sample_name, projections_digits = 5, log='INFO' ) ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() d.optimize_center() #d.phase_retrieval() #d.correct_drift() #d.center=1010.0 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/ANKA_', axis=0)
projections_start = projections_start, projections_end = projections_end, projections_digits=4, slices_start = slices_start, slices_end = slices_end, white_file_name = white_file_name, white_start = white_start, white_end = white_end, white_step = white_step, log='INFO' ) s # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center=1010.0 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/SLS_', axis=0) if __name__ == "__main__": main()
def main(): log_file = '/local/dataraid/databank/APS_2_BM/Sam18_hornby/Sam18_exp.hdf' #Read APS 2-BM log file data f = SD.SD(log_file) sds = f.select('base_name') data = sds.get() base_name = ''.join(data) print base_name file_name = os.path.split( log_file)[0] + "/" + "raw" + "/" + base_name + "_.hdf" sds = f.select('start_angle') start_angle = sds.get()[0] sds = f.select('end_angle') end_angle = sds.get()[0] sds = f.select('angle_interval') angle_interval = sds.get()[0] sds = f.select('num_dark_fields') num_dark_fields = sds.get()[0] f.end() white_start = 1 white_end = 2 projections_start = 2 projections_end = projections_start + (int)( (end_angle - start_angle) / angle_interval) + 1 dark_start = projections_end + 1 dark_end = dark_start + num_dark_fields sample_name = base_name # to reconstruct a subset of slices set slices_start and slices_end # if omitted the full data set is recontructed slices_start = 800 slices_end = 804 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images( file_name, projections_start=projections_start, projections_end=projections_end, slices_start=slices_start, slices_end=slices_end, white_start=white_start, white_end=white_end, dark_start=dark_start, dark_end=dark_end, projections_digits=5, data_type='hdf4', log='INFO') ## # if you have already created a data exchange file using convert_APS_2BM.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## ## hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/Hornby_19keV_10x_APS_2011_01.h5' ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center = 1023.4 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/APS_2_BM_', axis=0)
# mask_bad_val = crap_mask(white, 200, 40) # d.stripe_removal4(mask_bad_val) if remove_stripe2: d.stripe_removal2() # if remove_stripe: d.stripe_removal(level=stripe_lvl, sigma=sig, wname=Wname) d.downsample2d(level=level) # apply binning on the data if 1: if not best_center: d.optimize_center() else: d.center = best_center / pow(2, level) # Manage the rotation center d.gridrec(ringWidth=RingW) # Run the reconstruction d.apply_mask(ratio=1) # Write data as stack of TIFs. tomopy.xtomo_writer(d.data_recon, output_name, axis=0, x_start=slice_first) #### for the whole volume reconstruction if 0: f = h5py.File(file_name, "r") nProj, nslices, nCol = f["/exchange/data"].shape nslices_per_chunk = nslices / chunk for iChunk in range(0, chunk): print '\n -- chunk # %i' % (iChunk + 1) slice_first = nslices_per_chunk * iChunk slice_last = nslices_per_chunk * (iChunk + 1) # Read HDF5 file. data, white, dark, theta = tomopy.xtomo_reader(
# -*- coding: utf-8 -*- import tomopy file_name = '/local/data/Tapuia_dentary_ant3_M_200mm_4.hdf5' slices_start = 300 chunk_size = 32 # keep it reasoably large depending on the available memory for m in range(4): # change range manually 4*32 slices will be reconstructed starting from 300 data, white, dark, theta = tomopy.xtomo_reader(file_name, projections_start=1, slices_start=slices_start, slices_end=slices_start+chunk_size) d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta=theta) d.zinger_removal(zinger_level=500, median_width=5) d.normalize(negvals=1, cutoff=1) d.stripe_removal() d.center=1013.90625 d.gridrec() d.apply_mask(ratio=0.95) # use the first chunks min max value for all chunks if m == 0: data_min = d.data_recon.min() data_max = d.data_recon.max() tomopy.xtomo_writer(d.data_recon, 'tmp/test/rec_', dtype='uint16', axis=0, x_start=slices_start, data_min=data_min, data_max=data_max) slices_start += chunk_size
def main(): # read a series of tiff file_name = '/local/dataraid/databank/ALS_2011/Blakely/blakely_raw/blakelyALS_.tif' dark_file_name = '/local/dataraid/databank/ALS_2011/Blakely/blakely_raw/blakelyALSdrk_.tif' white_file_name = '/local/dataraid/databank/ALS_2011/Blakely/blakely_raw/blakelyALSbak_.tif' log_file = '/local/dataraid/databank/ALS_2011/Blakely/blakely_raw/blakelyALS.sct' hdf5_file_name = '/local/dataraid/databank/dataExchange/tmp/blakely_ALS_2011_test.h5' verbose = True # Read ALS log file data file = open(log_file, 'r') for line in file: if '-scanner' in line: Source = re.sub(r'-scanner ', "", line) if verbose: print 'Facility', Source if '-object' in line: Sample = re.sub(r'-object ', "", line) if verbose: print 'Sample', Sample if '-senergy' in line: Energy = re.findall(r'\d+.\d+', line) if verbose: print 'Energy', Energy[0] if '-scurrent' in line: Current = re.findall(r'\d+.\d+', line) if verbose: print 'Current', Current[0] if '-nangles' in line: Angles = re.findall(r'\d+', line) if verbose: print 'Angles', Angles[0] if '-i0cycle' in line: WhiteStep = re.findall(r'\s+\d+', line) if verbose: print 'White Step', WhiteStep[0] file.close() dark_start = 0 dark_end = 20 dark_step = 1 white_start = 0 white_end = int(Angles[0]) white_step = int(WhiteStep[0]) projections_start = 0 projections_end = int(Angles[0]) # to reconstruct a subset of slices set slices_start and slices_end # if omitted the full data set is recontructed slices_start = 800 slices_end = 804 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images( file_name=file_name, projections_start=projections_start, projections_end=projections_end, slices_start=slices_start, slices_end=slices_end, white_file_name=white_file_name, white_start=white_start, white_end=white_end, white_step=white_step, dark_file_name=dark_file_name, dark_start=dark_start, dark_end=dark_end, dark_step=dark_step, projections_zeros=False, white_zeros=False, dark_zeros=False, log='INFO') ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center = 1683.8 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/ALS_', axis=0)
def main(): # read a series of tiff # oster: pj: from 0 -> 1440; bf from 0 -> 19; df from 0 -> 19 file_name = '/local/dataraid/databank/PetraIII/2011_KW16_oster/oster02_0001/scan_0002/ccd/pco01/ccd_.tif' dark_file_name = '/local/dataraid/databank/PetraIII/2011_KW16_oster/oster02_0001/scan_0000/ccd/pco01/ccd_.tif' white_file_name = '/local/dataraid/databank/PetraIII/2011_KW16_oster/oster02_0001/scan_0001/ccd/pco01/ccd_.tif' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/PetraIII_oster02_0001.h5' sample_name = 'PetraIII P06 oster02_0001' projections_start = 0 projections_end = 1441 white_start = 0 white_end = 20 white_step = 1 dark_start = 0 dark_end = 20 dark_step = 1 # to reconstruct slices from slices_start to slices_end # if omitted all data set is recontructed slices_start = 1001 slices_end = 1501 # mydata = dx.Import() # # Read series of images # data, white, dark, theta = mydata.series_of_images(file_name, # projections_start = projections_start, # projections_end = projections_end, # slices_start = slices_start, # slices_end = slices_end, # #projections_angle_range=360, # white_file_name = white_file_name, # white_start = white_start, # white_end = white_end, # white_step = white_step, # dark_file_name = dark_file_name, # dark_start = dark_start, # dark_end = dark_end, # dark_step = dark_step, # sample_name = sample_name, # projections_digits = 4, # projections_zeros = True, # log='INFO' # ) # if you have already created a data exchange file using convert_PetraIII.py module, # comment the call above and read the data set as data exchange using: # Read HDF5 file. data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, slices_start=slices_start, slices_end=slices_end ) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() d.phase_retrieval(pixel_size=0.9e-4, dist=6.9, energy=15.25) #d.correct_drift() d.center=1872.87890625 d.gridrec() # Write to stack of TIFFs. # tomopy.xtomo_writer(d.data_recon, 'tmp/oster02_0001_', axis=0) tomopy.xtomo_writer(d.data_recon, 'tmp/oster02_0001_int_', axis=0, x_start = 1001, overwrite=True, dtype='uint8', data_min=-0.0001, data_max=0.0003)
# -*- coding: utf-8 -*- import tomopy file_name = '/local/data/Tapuia_dentary_ant3_M_200mm_4.hdf5' slices_start = 32 # always keep larger or equal than offset chunk_size = 32 # keep it reasoably large depending on the available memory offset = 32 # you don't need to shange that. for m in range(4): data, white, dark, theta = tomopy.xtomo_reader(file_name, projections_start=1, slices_start=slices_start-offset, slices_end=slices_start+chunk_size+offset) d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta=theta) d.zinger_removal(zinger_level=500, median_width=5) d.normalize(negvals=1, cutoff=1) d.stripe_removal() d.phase_retrieval(alpha=0.005) d.center=1013.90625 d.gridrec() d.apply_mask(ratio=0.95) # use the first chunks min max value for all chunks if m == 0: data_min = d.data_recon.min() data_max = d.data_recon.max() tomopy.xtomo_writer(d.data_recon[offset:chunk_size+offset, :, :], 'tmp/test/rec_', dtype='uint16', axis=0, x_start=slices_start, data_min=data_min, data_max=data_max) slices_start += chunk_size
def main(): # read a series of tiff file_name = '/local/dataraid/databank/ALS_2011/Blakely/blakely_raw/blakelyALS_.tif' dark_file_name = '/local/dataraid/databank/ALS_2011/Blakely/blakely_raw/blakelyALSdrk_.tif' white_file_name = '/local/dataraid/databank/ALS_2011/Blakely/blakely_raw/blakelyALSbak_.tif' log_file = '/local/dataraid/databank/ALS_2011/Blakely/blakely_raw/blakelyALS.sct' hdf5_file_name = '/local/dataraid/databank/dataExchange/tmp/blakely_ALS_2011_test.h5' verbose = True # Read ALS log file data file = open(log_file, 'r') for line in file: if '-scanner' in line: Source = re.sub(r'-scanner ', "", line) if verbose: print 'Facility', Source if '-object' in line: Sample = re.sub(r'-object ', "", line) if verbose: print 'Sample', Sample if '-senergy' in line: Energy = re.findall(r'\d+.\d+', line) if verbose: print 'Energy', Energy[0] if '-scurrent' in line: Current = re.findall(r'\d+.\d+', line) if verbose: print 'Current', Current[0] if '-nangles' in line: Angles = re.findall(r'\d+', line) if verbose: print 'Angles', Angles[0] if '-i0cycle' in line: WhiteStep = re.findall(r'\s+\d+', line) if verbose: print 'White Step', WhiteStep[0] file.close() dark_start = 0 dark_end = 20 dark_step = 1 white_start = 0 white_end = int(Angles[0]) white_step = int(WhiteStep[0]) projections_start = 0 projections_end = int(Angles[0]) # to reconstruct a subset of slices set slices_start and slices_end # if omitted the full data set is recontructed slices_start = 800 slices_end = 804 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images(file_name = file_name, projections_start = projections_start, projections_end = projections_end, slices_start = slices_start, slices_end = slices_end, white_file_name = white_file_name, white_start = white_start, white_end = white_end, white_step = white_step, dark_file_name = dark_file_name, dark_start = dark_start, dark_end = dark_end, dark_step = dark_step, projections_zeros = False, white_zeros = False, dark_zeros = False, log='INFO' ) ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center=1683.8 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/ALS_', axis=0)
def main(): # read a series of tiff file_name = '/local/dataraid/databank/VirginiaTech/test_sample_Diplo_4/Diplodocus_1_200mm_4_.tif' dark_file_name = '/local/dataraid/databank/VirginiaTech/test_sample_Diplo_4/Diplodocus_1_200mm_4postDark_.tif' white_file_name = '/local/dataraid/databank/VirginiaTech/test_sample_Diplo_4/Diplodocus_1_200mm_4postFlat_.tif' hdf5_file_name = '/local/dataraid/databank/dataExchange/microCT/VirginiaTech_test.h5' sample_name = 'Diplodocus_1_200mm_' projections_start = 1 # projection 0 is dark so we skip it projections_end = 1500 white_start = 0 white_end = 10 white_step = 1 dark_start = 0 dark_end = 10 dark_step = 1 # to reconstruct slices from slices_start to slices_end # if omitted all data set is recontructed slices_start = 600 slices_end = 604 mydata = dx.Import() # Read series of images data, white, dark, theta = mydata.series_of_images( file_name, projections_start=projections_start, projections_end=projections_end, slices_start=slices_start, slices_end=slices_end, white_file_name=white_file_name, white_start=white_start, white_end=white_end, white_step=white_step, dark_file_name=dark_file_name, dark_start=dark_start, dark_end=dark_end, dark_step=dark_step, sample_name=sample_name, projections_digits=5, projections_zeros=True, log='INFO') ## # if you have already created a data exchange file using convert_SLS.py module, ## # comment the call above and read the data set as data exchange ## # Read HDF5 file. ## data, white, dark, theta = tomopy.xtomo_reader(hdf5_file_name, ## slices_start=0, ## slices_end=2) # TomoPy xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() #d.correct_drift() #d.optimize_center() #d.phase_retrieval() #d.correct_drift() d.center = 1018.63 d.gridrec() # Write to stack of TIFFs. tomopy.xtomo_writer(d.data_recon, 'tmp/AAA_VT_', axis=0)
def recon_180(data_dir='.', file = 'out.h5', output_dir='/Volumes/Socha_MP8/', num_proj=1800, z=15, eng=27.4, lens=2, center=None): ##_________________________inputs_and_parameters_______________________ file_name = os.path.join(data_dir, file) output_file = output_dir+'/recon_'+file.split(".")[-2]+'/recon_'+file.split(".")[-2] +'_' d = tomopy.xtomo_dataset(log='debug') # Program does not complete a sample if actual number of slices is input. This somewhat arbitrary scaled value seems to work well. #num_proj = (3/2)*num_proj # These values work well with the computer's available memory and produce quality images. chunk_size = 50 margin_slices = 20 # Define pixel size from function argument lens. pxl = 0 if lens == 2: pxl = 5.5e-4 #for 2X lens elif lens == 5: pxl = 2.2e-4 #for 5X lens rat = 5e-04 num_chunk = np.int(np.ceil(num_proj / (chunk_size - margin_slices))) if num_proj == chunk_size: num_chunk = 1 ##________________________rescale_for_16-bit_image____________________ # data, white, dark, theta = tomopy.xtomo_reader(file_name, projections_start=1, slices_start=(np.int(num_proj/2)), slices_end=(np.int(num_proj/2))+chunk_size) # # d = tomopy.xtomo_dataset(log='debug') # d.dataset(data, white, dark, theta=theta) # d.zinger_removal(zinger_level=500, median_width=5) # d.normalize(negvals=1, cutoff=1) # #d.stripe_removal() # #d.phase_retrieval(alpha=0.005) # d.center=center # # d.gridrec() # d.apply_mask(ratio=0.95) # # data_min = d.data_recon.min() # data_max = d.data_recon.max() ##________________________reconstruction______________________________ #Importing small arrays of data from a saved numpy array. data = np.load('/Volumes/Socha_MP8/Mosquito_tomo/arrays/data.npy') white = np.load('/Volumes/Socha_MP8/Mosquito_tomo/arrays/whitedata.npy') dark = np.load('/Volumes/Socha_MP8/Mosquito_tomo/arrays/darkdata.npy') theta = np.load('/Volumes/Socha_MP8/Mosquito_tomo/arrays/data.npy') # Xtomo object creation and pipeline of methods. d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta) d.normalize() d.correct_drift() d.phase_retrieval() d.correct_drift() d.center=661.5 d.gridrec() tomopy.xtomo_writer(output_file, dtype='uint16', axis=0, data_max=None, overwrite = True) d.FLAG_THETA = False print 'Finished reconstructing slices from ' + file
def recon_180(data_dir='.', file = 'out.h5', output_dir='/Volumes/Socha_MP8/', num_proj=1800, startSlice=None, endSlice=None, z=15, eng=27.4, lens=2, center=None): ##_________________________inputs_and_parameters_______________________ file_name = os.path.join(data_dir, file) output_file = output_dir+'/recon_'+file.split(".")[-2]+'/recon_'+file.split(".")[-2] +'_' d = tomopy.xtomo_dataset(log='debug') # Program does not complete a sample if actual number of slices is input. This somewhat arbitrary scaled value seems to work well. #num_proj = (3/2)*num_proj # These values work well with the computer's available memory and produce quality images. chunk_size = 60 margin_slices = 20 # Define pixel size from function argument lens. pxl = 0 if lens == 2: pxl = 5.5e-4 #for 2X lens elif lens == 5: pxl = 2.2e-4 #for 5X lens rat = 5e-04 num_chunk = np.int(num_proj/chunk_size) + 1 if num_proj == chunk_size: num_chunk = 1 #Set defalt start and end slice values. if endSlice == None: endSlice = num_proj if startSlice == None: startSlice=0 offset = startSlice else: offset = startSlice - (margin_slices/2) ##________________________rescale_for_16-bit_image____________________ data, white, dark, theta = tomopy.xtomo_reader(file_name, projections_start=1, slices_start=(num_proj/2), slices_end=(num_proj/2)+chunk_size) d = tomopy.xtomo_dataset(log='debug') d.dataset(data, white, dark, theta=theta) #d.zinger_removal(zinger_level=500, median_width=5) d.normalize(negvals=1, cutoff=1) # Helps minimize ring artifacts. d.stripe_removal() # Finds center of rotation if center == None: d.optimize_center(ratio=1) else: d.center=center d.gridrec() data_min = d.data_recon.min() data_max = d.data_recon.max() ##________________________reconstruction______________________________ for ii in xrange(num_chunk): if ii == 0: SliceStart = offset + ii*chunk_size SliceEnd = offset + (ii+1)*chunk_size else: SliceStart = offset + ii*(chunk_size-margin_slices) SliceEnd = offset + SliceStart + chunk_size if SliceEnd >= (endSlice-(margin_slices/2)) and SliceEnd < (endSlice-margin_slices+chunk_size): SliceEnd = (endSlice-(margin_slices/2)) if SliceEnd >= (endSlice-margin_slices+chunk_size): break data, white, dark, theta = tomopy.xtomo_reader(file_name,slices_start=SliceStart,slices_end=SliceEnd,white_start=3,white_end=9,dark_start=3,dark_end=9) data[0,:,:] = data[1,:,:] d.dataset(data, white, dark, theta) #d.zinger_removal(median_width=10) d.normalize() d.correct_drift(10) d.stripe_removal(wname="sym16",level=11,sigma=2) d.phase_retrieval(dist=z, energy=eng, pixel_size=pxl, alpha=rat,padding=True) # Finds center of rotation if center == None: d.optimize_center(ratio=0.8) else: d.center=center d.gridrec() d.apply_mask(ratio=0.95) #data[0,:,:] = data[1,:,:] #d = tomopy.xtomo_dataset(log='debug') #d.dataset(data, white, dark, theta) ##d.zinger_removal(median_width=15,zinger_level=200) #d.normalize() ##d.stripe_removal(wname="sym16",level=10,sigma=2) ##d.stripe_removal(level=10,sigma=1) #d.phase_retrieval(dist=z, energy=eng, pixel_size=pxl, alpha=rat,padding=True) ##d.stripe_removal(wname="sym16",level=10,sigma=4) #data_size = d.data.shape ##d.median_filter(10) ##d.optimize_center(ratio=0.3) ##print d.center tomopy.xtomo_writer(d.data_recon[np.int(margin_slices/2):(SliceEnd-SliceStart-np.int(margin_slices/2)),:,:], output_file, dtype='unit16', axis=0, x_start=SliceStart+np.int(margin_slices/2), data_min=data_min, data_max=data_max, overwrite=True) d.FLAG_THETA = False print 'Finished reconstructing slices from ' + file