Exemple #1
0
 def test_callback(self):
     domain = odl.uniform_discr([0, 0], [1, 1], (1, 1))
     op = ScalingOperator(domain, 0.5)
     niter = 7
     iters = []
     callback = CallbackStore(iters)
     r = LandweberReconstructor(op, domain.one(), niter, callback=callback)
     r.reconstruct(domain.one())
     self.assertEqual(len(iters), niter)
Exemple #2
0
 def test_callback_assignment(self):
     domain = odl.uniform_discr([0, 0], [1, 1], (1, 1))
     op = ScalingOperator(domain, 0.5)
     callback = CallbackApply(lambda x: None)
     r = LandweberReconstructor(op, domain.one(), 7, callback=callback)
     self.assertEqual(r.callback, callback)
     r.reconstruct(domain.one())
     self.assertEqual(r.callback, callback)
     callback2 = CallbackApply(lambda x: 1.)
     r.reconstruct(domain.one(), callback=callback2)
     self.assertEqual(r.callback, callback)
Exemple #3
0
proj_data = ray_trafo(phantom)
observation = (proj_data + np.random.poisson(0.3, proj_data.shape)).asarray()

test_data = DataPairs(observation, ground_truth, name='shepp-logan + pois')

# %% task table and reconstructors
eval_tt = TaskTable()

fbp_reconstructor = FBPReconstructor(ray_trafo,
                                     hyper_params={
                                         'filter_type': 'Hann',
                                         'frequency_scaling': 0.8
                                     })
cg_reconstructor = CGReconstructor(ray_trafo, reco_space.zero(), 4)
gn_reconstructor = GaussNewtonReconstructor(ray_trafo, reco_space.zero(), 2)
lw_reconstructor = LandweberReconstructor(ray_trafo, reco_space.zero(), 8)
mlem_reconstructor = MLEMReconstructor(ray_trafo, 0.5 * reco_space.one(), 1)

reconstructors = [
    fbp_reconstructor, cg_reconstructor, gn_reconstructor, lw_reconstructor,
    mlem_reconstructor
]
options = {'save_iterates': True}

eval_tt.append_all_combinations(reconstructors=reconstructors,
                                test_data=[test_data],
                                options=options)

# %% run task table
results = eval_tt.run()
results.apply_measures([PSNR, SSIM])