def do_registration(I0,I1,params,spacing,weight=None,multi_scale=True):
    sz = np.array(I0.shape)
    if not multi_scale:
        so = MO.SimpleSingleScaleRegistration(I0, I1, spacing, sz, params)
    else:
        so = MO.SimpleMultiScaleRegistration(I0, I1, spacing, sz, params)
    so.get_optimizer().set_visualization(True)
    so.get_optimizer().set_visualize_step(10)
    so.set_light_analysis_on(True)
    so.optimizer.set_model(params['model']['registration_model']['type'])
    so.optimizer.set_initial_weight_map(weight.cuda(),freeze_weight=True)
    so.register()
Esempio n. 2
0
    def test_lddmm_shooting_map_multi_scale(self):

        self.params = pars.ParameterDict()
        self.params.load_JSON('./json/test_lddmm_shooting_map_multi_scale_config.json')

        self.createImage()

        mo = MO.SimpleMultiScaleRegistration(self.ISource, self.ITarget, self.spacing, self.sz, self.params)
        mo.get_optimizer().set_visualization(False)
        mo.register()

        # E = [0.07970674], simE = [0.06657108], regE = [0.01313565], optParE = [0.], relF = [0.02088663]
        energy = mo.get_energy()

        npt.assert_almost_equal(energy[0], 0.07360865, decimal=4 )
        npt.assert_almost_equal(energy[1], 0.06016802, decimal=4 )
        npt.assert_almost_equal(energy[2], 0.01344063, decimal=4 )
Esempio n. 3
0
    def test_lddmm_shooting_scalar_momentum_map_multi_scale(self):

        self.params = pars.ParameterDict()
        self.params.load_JSON('./json/test_lddmm_shooting_scalar_momentum_map_multi_scale_config.json')

        self.createImage()

        mo = MO.SimpleMultiScaleRegistration(self.ISource, self.ITarget, self.spacing, self.sz, self.params)
        mo.get_optimizer().set_visualization(False)
        mo.register()

        # E = [0.08930502], simE = [0.08034889], regE = [0.00895613], optParE = [0.], relF = [0.03883468]
        energy = mo.get_energy()

        npt.assert_almost_equal(energy[0], 0.04333755, decimal=4 )
        npt.assert_almost_equal(energy[1], 0.03237363, decimal=4 )
        npt.assert_almost_equal(energy[2], 0.010963925, decimal=4 )
Esempio n. 4
0
    def test_lddmm_shooting_image_multi_scale(self):

        self.params = pars.ParameterDict()
        self.params.load_JSON('./json/test_lddmm_shooting_image_multi_scale_config.json')

        self.createImage()

        mo = MO.SimpleMultiScaleRegistration(self.ISource, self.ITarget, self.spacing, self.sz, self.params)
        mo.get_optimizer().set_visualization(False)
        mo.register()

        # E = [0.04338037], similarityE = [0.03070126], regE = [0.01267911], relF = [0.01936091]
        energy = mo.get_energy()

        npt.assert_almost_equal(energy[0], 0.04338037, decimal=4 )
        npt.assert_almost_equal(energy[1], 0.03070126, decimal=4 )
        npt.assert_almost_equal(energy[2], 0.01267911, decimal=4 )
Esempio n. 5
0
    def test_lddmm_shooting_scalar_momentum_image_multi_scale(self):

        self.params = pars.ParameterDict()
        self.params.load_JSON('./json/test_lddmm_shooting_scalar_momentum_image_multi_scale_config.json')

        self.createImage()

        mo = MO.SimpleMultiScaleRegistration(self.ISource, self.ITarget, self.spacing, self.sz, self.params)
        mo.get_optimizer().set_visualization(False)
        mo.register()

        # E=[ 0.03197587], similarityE=[ 0.02087387], regE=[ 0.01110199], relF=[ 0.00138645]
        energy = mo.get_energy()

        npt.assert_almost_equal(energy[0], 0.03184246, decimal=4 )
        npt.assert_almost_equal(energy[1], 0.0207199, decimal=4 )
        npt.assert_almost_equal(energy[2], 0.01112256, decimal=4 )