Example #1
0
    def test_mu(self):
        """ Validate estimation of mu """
        # pyhrf.verbose.set_verbosity(2)
        pyhrf.logger.setLevel(logging.INFO)

        from pyhrf.sandbox.physio import simulate_asl_physio_rfs
        simu = simulate_asl_physio_rfs(self.tmp_dir)
        fdata = FmriData.from_simulation_dict(simu)
        self._test_specific_samplers(['truebrf'], fdata, nb_its=20,
                                     mu_prior_type='regularized',
                                     check_fv='raise')
Example #2
0
    def test_simulate_asl_physio_rfs(self):

        r = phy.simulate_asl_physio_rfs()
        # let's just test the shapes of objects and the presence of some
        # physio-specific simulation items:
        item_names = r.keys()
        self.assertIn('perf_stim_induced', item_names)
        self.assertIn('primary_brf', item_names)
        self.assertIn('perf_stim_induced', item_names)
        self.assertEqual(r['labels_vol'].shape, (3, 1, 2, 2))
        self.assertEqual(r['bold'].shape[1], 4)  # flat spatial axis
Example #3
0
    def test_simulate_asl_physio_rfs(self):

        r = phy.simulate_asl_physio_rfs()
        # let's just test the shapes of objects and the presence of some
        # physio-specific simulation items:
        item_names = r.keys()
        self.assertIn('perf_stim_induced', item_names)
        self.assertIn('primary_brf', item_names)
        self.assertIn('perf_stim_induced', item_names)
        self.assertEqual(r['labels_vol'].shape, (3, 1, 2, 2))
        self.assertEqual(r['bold'].shape[1], 4)  # flat spatial axis
Example #4
0
    def test_mu(self):
        """ Validate estimation of mu """
        pyhrf.verbose.set_verbosity(2)

        from pyhrf.sandbox.physio import simulate_asl_physio_rfs
        simu = simulate_asl_physio_rfs(self.tmp_dir)
        fdata = FmriData.from_simulation_dict(simu)
        self._test_specific_samplers(['truebrf'], fdata, nb_its=20,
                                     mu_prior_type='regularized',
                                     check_fv='raise')
        print 'pyhrf_view_qt3 %s/jde_mcmc_truebrf_pm.nii' %self.tmp_dir
Example #5
0
    def test_simulate_asl_physio_rfs(self):

        pyhrf.verbose.set_verbosity(0)

        r = phy.simulate_asl_physio_rfs()
        # let's just test the shapes of objects and the presence of some
        # physio-specific simulation items
        item_names = r.keys()
        self.assertIn("perf_stim_induced", item_names)
        self.assertIn("primary_brf", item_names)
        self.assertIn("perf_stim_induced", item_names)
        self.assertEqual(r["labels_vol"].shape, (3, 1, 2, 2))  # cond, spatial axes
        self.assertEqual(r["bold"].shape, (321, 4))  # nb scans, flat spatial axis
Example #6
0
    def test_simulate_asl_physio_rfs(self):

        # pyhrf.verbose.set_verbosity(0)
        pyhrf.logger.setLevel(logging.WARNING)

        r = phy.simulate_asl_physio_rfs()
        # let's just test the shapes of objects and the presence of some
        # physio-specific simulation items:
        item_names = r.keys()
        self.assertIn('perf_stim_induced', item_names)
        self.assertIn('primary_brf', item_names)
        self.assertIn('perf_stim_induced', item_names)
        # cond, spatial axes
        self.assertEqual(r['labels_vol'].shape, (3, 1, 2, 2))
        self.assertEqual(r['bold'].shape[1], 4)  # flat spatial axis
Example #7
0
    def test_default_jde_small_simulation(self):
        """ Test ASL Physio sampler on small simulation with small nb of
        iterations. Estimation accuracy is not tested.
        """
        pyhrf.verbose.set_verbosity(0)

        sampler_params = {
            jde_asl_physio.ASLPhysioSampler.P_NB_ITERATIONS : 100,
            jde_asl_physio.ASLPhysioSampler.P_SMPL_HIST_PACE : 1,
            jde_asl_physio.ASLPhysioSampler.P_OBS_HIST_PACE : 1,
            'brf' : jde_asl_physio.PhysioBOLDResponseSampler(zero_constraint=False),
            'brf_var' : jde_asl_physio.PhysioBOLDResponseVarianceSampler(val_ini=\
                                                                         np.array([1e-3])),
            'prf' : jde_asl_physio.PhysioPerfResponseSampler(zero_constraint=False),
            'prf_var' : jde_asl_physio.PhysioPerfResponseVarianceSampler(val_ini=\
                                                                         np.array([1e-3])),
            'noise_var' : jde_asl_physio.NoiseVarianceSampler(),
            'drift_var' : jde_asl_physio.DriftVarianceSampler(),
            'drift_coeff' : jde_asl_physio.DriftCoeffSampler(),
            'brl' : jde_asl_physio.BOLDResponseLevelSampler(),
            'prl' : jde_asl_physio.PerfResponseLevelSampler(),
            'bold_mixt_params' : jde_asl_physio.BOLDMixtureSampler(),
            'perf_mixt_params' : jde_asl_physio.PerfMixtureSampler(),
            'label' : jde_asl_physio.LabelSampler(),
            'perf_baseline' : jde_asl_physio.PerfBaselineSampler(),
            'perf_baseline_var' : jde_asl_physio.PerfBaselineVarianceSampler(),
            'assert_final_value_close_to_true' : False,
        }


        sampler = jde_asl_physio.ASLPhysioSampler(sampler_params)

        simu_items = phym.simulate_asl_physio_rfs(spatial_size='random_small')
        simu_fdata = FmriData.from_simulation_dict(simu_items)

        dt = simu_items['dt']
        analyser = JDEMCMCAnalyser(sampler=sampler, osfMax=4, dtMin=.4,
                                   dt=dt, driftParam=4, driftType='polynomial',
                                   outputFile=None,outputPrefix='jde_mcmc_',
                                   randomSeed=None)

        treatment = FMRITreatment(fmri_data=simu_fdata, analyser=analyser)
        treatment.run()
Example #8
0
    def test_default_jde_small_simulation(self):
        """ Test ASL Physio sampler on small simulation with small nb of
        iterations. Estimation accuracy is not tested.
        """
        pyhrf.verbose.set_verbosity(0)

        sampler_params = {
            'nb_iterations' : 3,
            'smpl_hist_pace' : 1,
            'obs_hist_pace' : 1,
            'brf' : jde_asl_physio.PhysioBOLDResponseSampler(zero_constraint=False),
            'brf_var' : jde_asl_physio.PhysioBOLDResponseVarianceSampler(val_ini=\
                                                                         np.array([1e-3])),
            'prf' : jde_asl_physio.PhysioPerfResponseSampler(zero_constraint=False),
            'prf_var' : jde_asl_physio.PhysioPerfResponseVarianceSampler(val_ini=\
                                                                         np.array([1e-3])),
            'noise_var' : jde_asl_physio.NoiseVarianceSampler(),
            'drift_var' : jde_asl_physio.DriftVarianceSampler(),
            'drift' : jde_asl_physio.DriftCoeffSampler(),
            'bold_response_levels' : jde_asl_physio.BOLDResponseLevelSampler(),
            'perf_response_levels' : jde_asl_physio.PerfResponseLevelSampler(),
            'bold_mixt_params' : jde_asl_physio.BOLDMixtureSampler(),
            'perf_mixt_params' : jde_asl_physio.PerfMixtureSampler(),
            'labels' : jde_asl_physio.LabelSampler(),
            'perf_baseline' : jde_asl_physio.PerfBaselineSampler(),
            'perf_baseline_var' : jde_asl_physio.PerfBaselineVarianceSampler(),
            'check_final_value' : None,
        }


        sampler = jde_asl_physio.ASLPhysioSampler(**sampler_params)

        simu_items = phym.simulate_asl_physio_rfs(spatial_size='random_small')
        simu_fdata = FmriData.from_simulation_dict(simu_items)

        dt = simu_items['dt']
        analyser = JDEMCMCAnalyser(sampler=sampler, osfMax=4, dtMin=.4,
                                   dt=dt, driftParam=4, driftType='polynomial',
                                   outputPrefix='jde_mcmc_')

        treatment = FMRITreatment(fmri_data=simu_fdata, analyser=analyser,
                                  output_dir=None)
        treatment.run()
Example #9
0
    def test_default_jde_small_simulation(self):
        """ Test ASL Physio sampler on small simulation with small nb of
        iterations. Estimation accuracy is not tested.
        """

        sampler_params = {
            'nb_iterations': 3,
            'smpl_hist_pace': 1,
            'obs_hist_pace': 1,
            'brf': jde_asl_physio.PhysioBOLDResponseSampler(zero_constraint=False),
            'brf_var': jde_asl_physio.PhysioBOLDResponseVarianceSampler(val_ini=np.array([1e-3])),
            'prf': jde_asl_physio.PhysioPerfResponseSampler(zero_constraint=False),
            'prf_var': jde_asl_physio.PhysioPerfResponseVarianceSampler(val_ini=np.array([1e-3])),
            'noise_var': jde_asl_physio.NoiseVarianceSampler(),
            'drift_var': jde_asl_physio.DriftVarianceSampler(),
            'drift': jde_asl_physio.DriftCoeffSampler(),
            'bold_response_levels': jde_asl_physio.BOLDResponseLevelSampler(),
            'perf_response_levels': jde_asl_physio.PerfResponseLevelSampler(),
            'bold_mixt_params': jde_asl_physio.BOLDMixtureSampler(),
            'perf_mixt_params': jde_asl_physio.PerfMixtureSampler(),
            'labels': jde_asl_physio.LabelSampler(),
            'perf_baseline': jde_asl_physio.PerfBaselineSampler(),
            'perf_baseline_var': jde_asl_physio.PerfBaselineVarianceSampler(),
            'check_final_value': None,
        }

        sampler = jde_asl_physio.ASLPhysioSampler(**sampler_params)

        simu_items = phym.simulate_asl_physio_rfs(spatial_size='random_small')
        simu_fdata = FmriData.from_simulation_dict(simu_items)

        dt = simu_items['dt']
        analyser = JDEMCMCAnalyser(sampler=sampler, osfMax=4, dtMin=.4,
                                   dt=dt, driftParam=4, driftType='polynomial',
                                   outputPrefix='jde_mcmc_')

        treatment = FMRITreatment(fmri_data=simu_fdata, analyser=analyser,
                                  output_dir=None)
        treatment.run()