from flexdata import data from flexdata import display import numpy import astra #%% Read data: path = '/ufs/ciacc/flexbox/good/' binning = 2 dark = data.read_stack(path, 'di00', sample = binning) flat = data.read_stack(path, 'io00', sample = binning) proj = data.read_stack(path, 'scan_', skip = binning, sample = binning) geom = data.read_flexraylog(path, sample = binning) #%% Prepro: flat = (flat - dark).mean(1) proj = (proj - dark) / flat[:, None, :] proj = -numpy.log(proj).astype('float32') proj = numpy.ascontiguousarray(proj) display.slice(proj, dim = 1, title = 'Projection', cmap = 'magma') #%% Astra reconstruction: vol = numpy.zeros([2000 // binning, 2000 // binning, 2000 // binning], dtype = 'float32') # Initialize ASTRA geometries:
#%% Read image stacks: # Read files with 'scan_' in them (sampling = 4 for speed): path = '/ufs/ciacc/flexbox/skull/' proj = data.read_stack(path, 'scan_', skip=4, sample=4) # Writing stack: data.write_stack(path + 'binned', 'scan_', proj, dim=1) # Display: display.slice(proj, dim=0, title='Sinogram', cmap='magma') display.slice(proj, dim=1, title='Projection', cmap='magma') #%% Read / write a geometry file: # Parcer for a flexray log file: geom = data.read_flexraylog(path, sample=4) print('\nParsing "scan settings.txt":') print(geom) # Write TOML format to disk: data.write_toml(path + 'geometry.toml', geom) print('\nReading raw TOML:') print(data.read_toml(path + 'geometry.toml')) print('\nParsing raw TOML:') print(data.read_geometry(path, sample=4))