当前位置: 首页>>代码示例>>Python>>正文


Python treatment.FMRITreatment类代码示例

本文整理汇总了Python中pyhrf.ui.treatment.FMRITreatment的典型用法代码示例。如果您正苦于以下问题:Python FMRITreatment类的具体用法?Python FMRITreatment怎么用?Python FMRITreatment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FMRITreatment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_sub_treatment

    def test_sub_treatment(self):

        t = FMRITreatment(output_dir=self.tmp_dir)
        t.enable_draft_testing()
        sub_ts = t.split()
        for sub_t in sub_ts:
            sub_t.run()
开发者ID:Solvi,项目名称:pyhrf,代码行数:7,代码来源:test_treatment.py

示例2: test_default_treatment_parallel_LAN

 def test_default_treatment_parallel_LAN(self):
     #pyhrf.verbose.set_verbosity(1)
     if cfg['parallel-LAN']['enable_unit_test'] == 1:
         t = FMRITreatment(make_outputs=False, result_dump_file=None,
                           output_dir=self.tmp_dir)
         t.enable_draft_testing()
         t.run(parallel='LAN')
     else:
         print 'LAN testing is off '\
           '([parallel-LAN][enable_unit_test] = 0 in ~/.pyhrf/config.cfg'
开发者ID:Solvi,项目名称:pyhrf,代码行数:10,代码来源:test_treatment.py

示例3: test_default_jde_cmd_parallel_local

 def test_default_jde_cmd_parallel_local(self):
     t = FMRITreatment(make_outputs=False, result_dump_file=None)
     t.enable_draft_testing()
     t_fn = op.join(self.tmp_dir, 'treatment.pck')
     fout = open(t_fn, 'w')
     cPickle.dump(t, fout)
     fout.close()
     cmd = 'pyhrf_jde_estim -t %s -x local' %t_fn
     if os.system(cmd) != 0:
         raise Exception('"' + cmd + '" did not execute correctly')
开发者ID:Solvi,项目名称:pyhrf,代码行数:10,代码来源:test_treatment.py

示例4: glm_analyse

def glm_analyse(fdata, contrasts, output_dir, output_prefix,
                hrf_model="Canonical", fir_delays=None,
                rescale_factor_file=None):
    glm_analyser = GLMAnalyser(hrf_model=hrf_model, contrasts=contrasts,
                               outputPrefix=output_prefix, fir_delays=fir_delays,
                               rescale_factor_file=rescale_factor_file)
    glm_analyser.set_pass_errors(False)
    glm_analyser.set_gzip_outputs(True)
    tt = FMRITreatment(fdata, glm_analyser, output_dir=output_dir)
    tt.run()
开发者ID:ainafp,项目名称:pyhrf,代码行数:10,代码来源:real_data_jde_rfir_glm.py

示例5: test_jde_estim_from_treatment_pck

    def test_jde_estim_from_treatment_pck(self):

        t = FMRITreatment(make_outputs=False, result_dump_file=None)
        t.enable_draft_testing()
        sub_ts = t.split()
        sub_t_fn = op.join(self.tmp_dir, 'treatment.pck')
        fout = open(sub_t_fn, 'w')
        cPickle.dump(sub_ts[0], fout)
        fout.close()
        cmd = 'pyhrf_jde_estim  -t %s' %sub_t_fn
        if os.system(cmd) != 0:
            raise Exception('"' + cmd + '" did not execute correctly')
开发者ID:Solvi,项目名称:pyhrf,代码行数:12,代码来源:test_treatment.py

示例6: test_jdevemanalyser

 def test_jdevemanalyser(self):
     """ Test BOLD VEM sampler on small simulation with small
     nb of iterations. Estimation accuracy is not tested.
     """
     jde_vem_analyser = JDEVEMAnalyser(beta=.8, dt=.5, hrfDuration=25.,
                                       nItMax=2, nItMin=2, fast=True,
                                       computeContrast=False, PLOT=False,
                                       constrained=True)
     tjde_vem = FMRITreatment(fmri_data=self.data_simu,
                              analyser=jde_vem_analyser,
                              output_dir=None)
     tjde_vem.run()
开发者ID:pyhrf,项目名称:pyhrf,代码行数:12,代码来源:test_jde_vem_bold.py

示例7: jde_analyse

def jde_analyse(fdata, contrasts, output_dir):
    from pyhrf.jde.models import BOLDGibbsSampler as BG
    from pyhrf.jde.hrf import RHSampler
    from pyhrf.jde.nrl.bigaussian import NRLSampler

    sampler = BG(nb_iterations=250,
                 hrf_var=RHSampler(do_sampling=False, val_ini=np.array([0.05])),
                 response_levels=NRLSampler(contrasts=contrasts))

    analyser = JDEMCMCAnalyser(sampler=sampler)
    analyser.set_gzip_outputs(True)
    tt = FMRITreatment(fdata, analyser, output_dir=output_dir)
    tt.run(parallel='local')
开发者ID:ainafp,项目名称:pyhrf,代码行数:13,代码来源:real_data_jde_rfir_glm.py

示例8: test_jdevemanalyser

 def test_jdevemanalyser(self):
     """ Test BOLD VEM sampler on small simulation with small
     nb of iterations. Estimation accuracy is not tested.
     """
     # pyhrf.verbose.set_verbosity(0)
     pyhrf.logger.setLevel(logging.WARNING)
     jde_vem_analyser = JDEVEMAnalyser(beta=.8, dt=.5, hrfDuration=25.,
                                       nItMax=2, nItMin=2, fast=True,
                                       PLOT=False,
                                       constrained=True)
     tjde_vem = FMRITreatment(fmri_data=self.data_simu,
                              analyser=jde_vem_analyser,
                              output_dir=None)
     tjde_vem.run()
开发者ID:ainafp,项目名称:pyhrf,代码行数:14,代码来源:test_jde_vem_asl.py

示例9: test_default_jde_small_simulation

    def test_default_jde_small_simulation(self):
        """ Test JDE multi-sessions sampler on small
        simulation with small nb of iterations.
        Estimation accuracy is not tested.
        """

        sampler = BMSS()

        analyser = JDEMCMCAnalyser(sampler=sampler, osfMax=4, dtMin=.4,
                                   dt=.5, driftParam=4, driftType='polynomial',
                                   outputPrefix='jde_MS_mcmc_',
                                   randomSeed=9778946)

        treatment = FMRITreatment(fmri_data=self.data_simu,
                                  analyser=analyser)

        treatment.run()
开发者ID:pyhrf,项目名称:pyhrf,代码行数:17,代码来源:jdetest.py

示例10: test_default_jde_small_simulation

    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()
开发者ID:pmesejo,项目名称:pyhrf,代码行数:43,代码来源:jdetest.py

示例11: test_default_jde_small_simulation

    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()
开发者ID:Solvi,项目名称:pyhrf,代码行数:43,代码来源:jdetest.py

示例12: dummy_jde

def dummy_jde(fmri_data, dt):
    print 'run dummy_jde ...'
    jde_mcmc_sampler = \
        physio_build_jde_mcmc_sampler(3, 'basic_regularized', 
                                        do_sampling_prf=False,
                                        do_sampling_brf=False,
                                        do_sampling_prls=False,
                                        do_sampling_labels=False,
                                        do_sampling_prf_var=False,
                                        do_sampling_brf_var=False,
                                        brf_var_ini=np.array([0.1]),
                                        prf_var_ini=np.array([0.1]))

    analyser = JDEMCMCAnalyser(jde_mcmc_sampler, copy_sampler=False, dt=dt)
    analyser.set_pass_errors(False)
    tjde_mcmc = FMRITreatment(fmri_data, analyser, output_dir=None)
    outputs, fns = tjde_mcmc.run()
    print 'dummy_jde done!'
    return tjde_mcmc.analyser.sampler
开发者ID:pmesejo,项目名称:pyhrf,代码行数:19,代码来源:asl_2steps.py

示例13: _test_specific_parameters

 def _test_specific_parameters(self, parameter_name, fdata, simu,
                               beta=.8, dt=.5, nItMax=100, nItMin=10,
                               hrfDuration=25., estimateSigmaH=False,
                               estimateBeta=False, estimateSigmaG=False,
                               PLOT=False, constrained=True, fast=False,
                               estimateH=False, estimateG=False,
                               estimateA=False, estimateC=False,
                               estimateZ=False, estimateLA=False,
                               estimateNoise=False, estimateMP=True):
     """
     Test specific samplers.
     """
     logger.info('_test_specific_parameters %s', str(parameter_name))
     output_dir = self.tmp_dir
     # JDE analysis
     jde_vem_analyser = JDEVEMAnalyser(beta=beta, dt=dt,
                                       hrfDuration=hrfDuration,
                                       estimateSigmaH=estimateSigmaH,
                                       nItMax=nItMax, nItMin=nItMin,
                                       estimateBeta=estimateBeta,
                                       estimateSigmaG=estimateSigmaG,
                                       PLOT=PLOT,
                                       constrained=constrained, fast=fast,
                                       fmri_data=fdata,
                                       simulation=simu,
                                       estimateH=estimateH,
                                       estimateG=estimateG,
                                       estimateA=estimateA,
                                       estimateC=estimateC,
                                       estimateLabels=estimateZ,
                                       estimateLA=estimateLA,
                                       estimateMixtParam=estimateMP,
                                       estimateNoise=estimateNoise)
     tjde_vem = FMRITreatment(fmri_data=fdata, analyser=jde_vem_analyser,
                              output_dir=output_dir)
     outputs = tjde_vem.run()
     print 'out_dir:', output_dir
     return outputs
开发者ID:ainafp,项目名称:pyhrf,代码行数:38,代码来源:valid_jde_vem_asl.py

示例14: main

def main():
    """Run when calling the script"""

    start_time = time.time()

    if not os.path.isdir(config["output_dir"]):
        try:
            os.makedirs(config["output_dir"])
        except OSError as e:
            print("Ouput directory could not be created.\n"
                  "Error was: {}".format(e.strerror))
            sys.exit(1)

    bold_data = FmriData.from_vol_files(
        mask_file=config["parcels_file"], paradigm_csv_file=config["onsets_file"],
        bold_files=config["bold_data_file"], tr=config["tr"]
    )

    compute_contrasts, contrasts_def = load_contrasts_definitions(config["def_contrasts_file"])

    jde_vem_analyser = JDEVEMAnalyser(
        hrfDuration=config["hrf_duration"], sigmaH=config["sigma_h"], fast=True,
        computeContrast=compute_contrasts, nbClasses=2, PLOT=False,
        nItMax=config["nb_iter_max"], nItMin=config["nb_iter_min"], scale=False,
        beta=config["beta"], estimateSigmaH=True, estimateHRF=config["estimate_hrf"],
        TrueHrfFlag=False, HrfFilename='hrf.nii', estimateDrifts=True,
        hyper_prior_sigma_H=config["hrf_hyperprior"], dt=config["dt"], estimateBeta=True,
        contrasts=contrasts_def, simulation=False, estimateLabels=True,
        LabelsFilename=None, MFapprox=False, estimateMixtParam=True,
        constrained=False, InitVar=0.5, InitMean=2.0, MiniVemFlag=False, NbItMiniVem=5,
        zero_constraint=config["zero_constraint"], drifts_type=config["drifts_type"]
    )

    processing_jde_vem = FMRITreatment(
        fmri_data=bold_data, analyser=jde_vem_analyser,
        output_dir=config["output_dir"], make_outputs=True
    )

    if not config["parallel"]:
        processing_jde_vem.run()
    else:
        processing_jde_vem.run(parallel="local")


    if config["save_processing_config"]:
        # Let's canonicalize all paths
        config_save = dict(config)
        for file_nb, bold_file in enumerate(config_save["bold_data_file"]):
            config_save["bold_data_file"][file_nb] = os.path.abspath(bold_file)
        config_save["parcels_file"] = os.path.abspath(config_save["parcels_file"])
        config_save["onsets_file"] = os.path.abspath(config_save["onsets_file"])
        if config_save["def_contrasts_file"]:
            config_save["def_contrasts_file"] = os.path.abspath(config_save["def_contrasts_file"])
        config_save["output_dir"] = os.path.abspath(config_save["output_dir"])
        config_save_filename = "{}_processing.json".format(
            datetime.datetime.today()
        ).replace(" ", "_")
        config_save_path = os.path.join(config["output_dir"], config_save_filename)
        with open(config_save_path, 'w') as json_file:
            json.dump(config_save, json_file, sort_keys=True, indent=4)

    print("")
    print("Total computation took: {} seconds".format(format_duration(time.time() - start_time)))
开发者ID:pyhrf,项目名称:pyhrf,代码行数:63,代码来源:jde_vem_analysis.py

示例15: rfir_analyse

def rfir_analyse(fdata, output_dir):
    analyser = RFIRAnalyser(RFIREstim(nb_its_max=150))
    analyser.set_gzip_outputs(True)
    tt = FMRITreatment(fdata, analyser, output_dir=output_dir)
    tt.run()
开发者ID:ainafp,项目名称:pyhrf,代码行数:5,代码来源:real_data_jde_rfir_glm.py


注:本文中的pyhrf.ui.treatment.FMRITreatment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。