def test3(nodes): ct = CT( dir, clean_intermediate_files=None, vertical_range=slice(900, 1000), parallel_nodes=nodes, ) ct.recon(tilt=-1.40, explore_rot_center=False) assert os.path.exists('work') return
def test2(nodes): ct = CT(dir, clean_intermediate_files='archive', vertical_range=slice(900, 1000), parallel_nodes=nodes, skip_df=True) ct.recon(tilt=-1.40, explore_rot_center=False) assert not os.path.exists('work') import glob assert glob.glob('out/work-*') return
def test(): nodes = os.environ.get('NODES') if nodes: nodes = int(nodes) print("Processing using %s nodes" % (nodes or 'all')) from imars3d.CT import CT ct = CT( dir, clean_on_the_fly=True, vertical_range=slice(900, 1000), parallel_nodes=nodes, ) ct.recon(tilt=-1.40, explore_rot_center=False) return
def nextStep(self): """ Creates and moves to the desired output directory. Then, creates/opens that directory's recon-config.pkl file, and dumps the contents of self.context.config into it. Then, after printing the configuration, creates a ct object, and stores the result in context.ct. Finally, removes the current panel, and replaces it with an MainUIPanel. """ # save path of current imars3d config import imars3d orig_imars3d_config = os.path.abspath(imars3d.conf_path) # create output dir and move over there os.makedirs(self.context.config.outdir) os.chdir(self.context.config.outdir) assert os.getcwd() == self.context.config.outdir # copy imars3d config if it exists if os.path.exists(orig_imars3d_config): import shutil shutil.copyfile(orig_imars3d_config, imars3d.conf_path) # save recon config with open('recon-config.pkl', 'wb') as open_config: pkl.dump(self.context.config, open_config) # logging logger.info("Configuration:") for k, v in self.context.config.__dict__.items(): if k.startswith('_'): continue sv = str(v) if len(sv) > 60: sv = sv[:50] + '...' logger.info("{0:20}{1:<}".format(k, sv)) # create CT object from imars3d.CT import CT context = self.context with wait_alert( "Gathering information for the CT reconstruction. Please wait..." ): ct = CT(context.config.datadir, CT_subdir=context.config.ct_dir, CT_identifier=context.config.ct_sig, workdir=context.config.workdir, outdir=context.config.outdir, ob_files=context.config.ob_files, df_files=context.config.df_files) context.ct = ct # new interface self.remove() imgslide = MainUIPanel(context) imgslide.show()
def nextStep(self): """ Removes the current panel. Then, creates a ct object, and saves it into context's ct member. Fianlly, creates an MainUIPanel and displays it. """ self.remove() from imars3d.CT import CT context = self.context ct = CT(context.config.datadir, CT_subdir=context.config.ct_dir, CT_identifier=context.config.ct_sig, workdir=context.config.workdir, outdir=context.config.outdir, ob_files=context.config.ob_files, df_files=context.config.df_files) context.ct = ct img_slide = MainUIPanel(context) img_slide.show()
#!/usr/bin/env python # -*- coding: utf-8 -*- datadir = 'data' workdir = "work" outdir = "out" import sys import os, numpy as np, imars3d as i3, tomopy from imars3d.CT import CT ct = CT(datadir) # dark field dfs = i3.io.imageCollection(ct.DF_pattern, name="Dark Field") # open beam obs = i3.io.imageCollection(ct.OB_pattern, name="Open Beam") # ct angles = ct.angles theta = angles * np.pi / 180. pattern = ct.CT_pattern ct_series = i3.io.ImageFileSeries(pattern, identifiers = angles, name = "CT") def main(): normalized = i3.normalize(ct_series, dfs, obs, workdir=os.path.join(workdir, 'normalization')) tilt_corrected = i3.correct_tilt(normalized, workdir=os.path.join(workdir, 'tilt-correction')) if_corrected = i3.correct_intensity_fluctuation(tilt_corrected, workdir=os.path.join(workdir, 'intensity-fluctuation-correction')) angles, sinograms = i3.build_sinograms(if_corrected, workdir=os.path.join(workdir, 'sinogram')) # take the middle part to calculate the center of rotation sino = [s.data for s in sinograms[900:1100]] sino= np.array(sino) proj = np.swapaxes(sino, 0, 1)
#!/usr/bin/env python # -*- coding: utf-8 -*- import os dir = os.path.dirname(__file__) datadir = os.path.join(dir, "raw") CT_subdir = os.path.join("ct_scans", "Derek_injec") workdir = "work" outdir = "out" import sys import numpy as np, imars3d as i3, tomopy from imars3d.CT import CT ct = CT(datadir, CT_subdir=CT_subdir, CT_identifier="Derek_injec") # dark field dfs = i3.io.imageCollection(ct.DF_pattern, name="Dark Field") # open beam obs = i3.io.imageCollection(ct.OB_pattern, name="Open Beam") # ct angles = ct.angles theta = angles * np.pi / 180. pattern = ct.CT_pattern ct_series = i3.io.ImageFileSeries(pattern, identifiers=angles, name="CT") def main(): normalized = i3.normalize(ct_series, dfs, obs, workdir=os.path.join(workdir, 'normalization'))
def test(): from imars3d.CT import CT ct = CT(dir) ct.recon() return