def _compute(lors, grid, center, size, model): map_model = BackProjectionOrdinary(model) t = RingEfficiencyMap('effmap', map_model, lors, grid=grid, center=center, size=size) t.make() with Session() as sess: result = t.run() sess.reset() return result
def main(config): model = CompleteLoRsModel('model', **config['projection_model']) master_loader = MasterLoader(config['shape'], config['center'], config['size']) worker_loader = siddonProjectionLoader(RESOURCE_ROOT + 'ring_nogap.h5', config['center'], config['size']) bproj_step = BprojStep('worker/backprojection', BackProjectionOrdinary(model)) g = LocalBackprojectionGraph( 'backprojection', MasterGraph('master', loader=master_loader, nb_workers=1), WorkerGraph('worker', bproj_step, loader=worker_loader, task_index=0)) g.make() with Session() as sess: g.run(sess)
def compute(lors, grid, center, size): # physics_model = SplitLorsModel('map_model', kernel_width=kernel_width) physics_model = CompleteLoRsModel('map_model') backprojection_model = BackProjectionOrdinary(physical_model=physics_model) # map_step = MapStep('compute/effmap', backprojection=backprojection_model) # t = RingEfficiencyMap('effmap', compute_graph=map_step, # lors=lors, grid=grid, # center=center, size=size) t = RingEfficiencyMap('effmap', backprojection_model, lors, grid, center, size) with Session() as sess: t.make() result = t.run() # print(result[result>0]) # sess.reset() return result
def main(config): model = CompleteLoRsModel('model', **config['projection_model']) master_loader = MasterLoader(config['shape'], config['center'], config['size']) worker_loader = CompleteWorkerLoader( RESOURCE_ROOT + 'mct_lors_debug.npy', RESOURCE_ROOT + 'summap.npy', # "./summap.npy", config['center'], config['size']) recon_step = ReconStep('worker/recon', ProjectionOrdinary(model), BackProjectionOrdinary(model), mlem_update_normal) g = LocalReconstructionGraph('reconstruction', MasterGraph('master', loader=master_loader, nb_workers=1), WorkerGraph('worker', recon_step, loader=worker_loader, task_index=0), nb_iteration=10) g.make() with Session() as sess: g.run(sess)
def _make_recon_task(self, task_index, task_config, distribution_config=None): """ Create a specific task object. A specific task object is built according to the user configuration on task. Args: scanner: the scanner used in this task. job: role of this host (master/worker). task_index: the index of this task. task_config: the configuation file of this task. distribution_config: hosts used to run this task. Returns: A task object. """ al_config = task_config['algorithm']['projection_model'] im_config = task_config['output']['image'] pj_config = task_config['scanner']['petscanner'] tof_bin, tof_sigma2 = self._get_tof_info() correction = make_correction(task_config['algorithm']['correction']) if ('siddon' in al_config): model = CompleteLoRsModel('model', tof_bin=tof_bin, tof_sigma2=tof_sigma2) worker_loader = CompleteWorkerLoader( task_config['input']['listmode']['path_file'], task_config['output']['image']['map_file']['path_file'], self._scanner, im_config, correction) elif ('siddon_sino' in al_config): model = CompleteSinoModel('model', pj_config) worker_loader = siddonSinogramLoader( pj_config, task_config['input']['listmode']['path_file'], "./summap.npy", im_config) else: model = SplitLoRsModel( al_config['tor']['kernel_width'], al_config['tor']['geometry_sigma2_correction'], tof_bin=tof_bin, tof_sigma2=tof_sigma2) worker_loader = SplitWorkerLoader( task_config['input']['listmode']['path_file'], task_config['output']['image']['map_file']['path_file'], self._scanner, im_config, correction) master_loader = MasterLoader(self._scanner, im_config) # decide if use PSF correction if correction.psf is not None: recon_step = PSFReconStep('worker/recon', ProjectionOrdinary(model), BackProjectionOrdinary(model), mlem_update) else: recon_step = ReconStep('worker/recon', ProjectionOrdinary(model), BackProjectionOrdinary(model), mlem_update) if ('mlem' in task_config['algorithm']['recon']): nb_iteration = task_config['algorithm']['recon']['mlem'][ 'nb_iterations'] else: nb_iteration = task_config['algorithm']['recon']['osem'][ 'nb_iterations'] output_filename = task_config['output']['image']['path_dataset_prefix'] g = LocalReconstructionGraph('reconstruction', MasterGraph('master', loader=master_loader, nb_workers=1), WorkerGraph('worker', recon_step, loader=worker_loader, task_index=task_index), output_filename=output_filename, nb_iteration=nb_iteration) g.make() with Session() as sess: g.run(sess)