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


Python pyhrf.get_tmp_path函数代码示例

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


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

示例1: setUp

    def setUp(self):

        pyhrf.verbose.set_verbosity(0)

        np.random.seed(8652761)

        self.tmp_dir = pyhrf.get_tmp_path()
开发者ID:Solvi,项目名称:pyhrf,代码行数:7,代码来源:jdetest.py

示例2: _test_spm_option_parse

    def _test_spm_option_parse(self, spm_ver):
        """
        Test parsing of option "-s SPM.mat" with given SPM version (int)
        """
        spm_file = op.join(pyhrf.get_tmp_path(), 'SPM.mat')
        tools._io._zip.gunzip(pyhrf.get_data_file_name('SPM_v%d.mat.gz' % spm_ver),
                              outFileName=spm_file)

        options = ['-s', spm_file]
        from optparse import OptionParser
        parser = OptionParser()
        ptr.append_common_treatment_options(parser)

        fd = ptr.parse_data_options(parser.parse_args(options)[0])

        self.assertEqual(fd.tr, 2.4)  # nb sessions
        p = fd.paradigm
        # nb sessions
        self.assertEqual(len(p.stimOnsets[p.stimOnsets.keys()[0]]), 2)
        npt.assert_almost_equal(p.stimOnsets['audio'][0],
                                ppar.onsets_loc_av['audio'][0])
        npt.assert_almost_equal(p.stimOnsets['audio'][1],
                                ppar.onsets_loc_av['audio'][0])
        npt.assert_almost_equal(p.stimOnsets['video'][1],
                                ppar.onsets_loc_av['video'][0])
开发者ID:ainafp,项目名称:pyhrf,代码行数:25,代码来源:test_treatment.py

示例3: remote_dir_is_writable

def remote_dir_is_writable(user, hosts, path):
    """
    Test if *path* is writable from each host in *hosts*. Sending bash
    commands to each host via ssh using the given *user* login.

    Args:

    """
    import os.path as op
    import pyhrf

    mode = 'dispatch'
    cmds = ['bash -c "echo -n \"[write_test]:%d:\"; '\
            'if [ -w %s ]; then echo \"OK\"; else echo \"NOTOK\"; fi;"' \
            %(ih, path) for ih in range(len(hosts))]
    tasks = read_tasks(cmds, mode)
    timeslot = read_timeslot('allday')

    tmp_dir = pyhrf.get_tmp_path()
    brokenfile = op.join(tmp_dir, 'pyhrf-broken_cmd.batch')
    logfile = op.join(tmp_dir, 'pyhrf-parallel.log')
    run_grid(mode, hosts, 'rsa', tasks, timeslot, brokenfile,
             logfile, user=user)
    kill_threads()

    log = open(logfile).readlines()

    res = [False] * len(hosts)
    for line in log:
        if line.startswith('[write_test]'):
            #print line
            _,ih,r = line.strip('\n').split(':')
            res[int(ih)] = ('OK' in r)

    return res
开发者ID:Solvi,项目名称:pyhrf,代码行数:35,代码来源:grid.py

示例4: _test_load_regnames

 def _test_load_regnames(self, spm_ver):
     spm_file = op.join(pyhrf.get_tmp_path(), 'SPM.mat')
     pio._zip.gunzip(pyhrf.get_data_file_name('SPM_v%d.mat.gz' % spm_ver),
                     outFileName=spm_file)
     expected = ['Sn(1) audio*bf(1)', 'Sn(1) video*bf(1)',
                 'Sn(2) audio*bf(1)', 'Sn(2) video*bf(1)',
                 'Sn(1) constant', 'Sn(2) constant']
     self.assertEqual(pio.spmio.load_regnames(spm_file), expected)
开发者ID:rcherbonnier,项目名称:pyhrf,代码行数:8,代码来源:iotest.py

示例5: setUp

    def setUp(self):
        cache_dir = tempfile.mkdtemp(prefix='pyhrf_validate',
                                     dir=pyhrf.cfg['global']['tmp_path'])
        mem = Memory(cache_dir)
        np.random.seed(8652761)

        self.tmp_dir = pyhrf.get_tmp_path()
        self.clean_tmp = True
开发者ID:pyhrf,项目名称:pyhrf,代码行数:8,代码来源:valid_jde_vem_asl.py

示例6: setUp

    def setUp(self):

        self.tmp_dir = pyhrf.get_tmp_path()

        simu = simulate_sessions(output_dir=self.tmp_dir,
                                 snr_scenario='high_snr',
                                 spatial_size='random_small')
        self.data_simu = merge_fmri_sessions(simu)
开发者ID:ainafp,项目名称:pyhrf,代码行数:8,代码来源:jdetest.py

示例7: setUp

    def setUp(self):
        np.random.seed(8652761)

        self.simu_dir = pyhrf.get_tmp_path()

        # Parameters to setup a Sampler where all samplers are OFF and
        # set to their true values.
        # This is used by the function _test_specific_samplers,
        # which will turn on specific samplers to test.

        self.sampler_params_for_single_test = {
            'nb_iterations': 40,
            'smpl_hist_pace': -1,
            'obs_hist_pace': -1,
            # HRF by subject
            'hrf_subj': jms.HRF_Sampler(do_sampling=False,
                                        normalise=1.,
                                        use_true_value=True,
                                        zero_contraint=False,
                                        prior_type='singleHRF'),

            # HRF variance
            'hrf_var_subj': jms.HRFVarianceSubjectSampler(do_sampling=False,
                                                          use_true_value=True),
            # HRF group
            'hrf_group': jms.HRF_Group_Sampler(do_sampling=False,
                                               normalise=1.,
                                               use_true_value=True,
                                               zero_contraint=False,
                                               prior_type='singleHRF'),
            # HRF variance
            'hrf_var_group': jms.RHGroupSampler(do_sampling=False,
                                                use_true_value=True),

            # neural response levels (stimulus-induced effects) by subject
            'response_levels': jms.NRLs_Sampler(do_sampling=False,
                                                use_true_value=True),
            'labels': jms.LabelSampler(do_sampling=False,
                                       use_true_value=True),
            # drift
            'drift': jms.Drift_MultiSubj_Sampler(do_sampling=False,
                                                 use_true_value=True),
            # drift variance
            'drift_var': jms.ETASampler_MultiSubj(do_sampling=False,
                                                  use_true_value=True),
            # noise variance
            'noise_var':
            jms.NoiseVariance_Drift_MultiSubj_Sampler(do_sampling=False,
                                                      use_true_value=False),
            # weights o fthe mixture
            # parameters of the mixture
            'mixt_params': jms.MixtureParamsSampler(do_sampling=False,
                                                    use_true_value=False),
            #'alpha_subj' : Alpha_hgroup_Sampler(dict_alpha_single),
            #'alpha_var_subj' : AlphaVar_Sampler(dict_alpha_var_single),
            'check_final_value': 'none',  # print or raise
        }
开发者ID:pyhrf,项目名称:pyhrf,代码行数:57,代码来源:test_jde_multi_subj.py

示例8: setUp

    def setUp(self):
        tag = "subj0_%s.nii.gz"
        self.func_file = pyhrf.get_data_file_name(tag % "bold_session0")
        self.anatomy_file = pyhrf.get_data_file_name(tag % "anatomy")
        self.roi_mask_file = pyhrf.get_data_file_name(tag % "parcellation")

        self.ax_slice = 24
        self.sag_slice = 7
        self.cor_slice = 34

        self.tmp_dir = pyhrf.get_tmp_path()  #'./'
开发者ID:philouc,项目名称:pyhrf,代码行数:11,代码来源:test_plot.py

示例9: setUp

    def setUp(self):
        tag = 'subj0_%s.nii.gz'
        self.func_file = pyhrf.get_data_file_name(tag%'bold_session0')
        self.anatomy_file = pyhrf.get_data_file_name(tag%'anatomy')
        self.roi_mask_file = pyhrf.get_data_file_name(tag%'parcellation')

        self.ax_slice = 24
        self.sag_slice = 7
        self.cor_slice = 34

        self.tmp_dir = pyhrf.get_tmp_path() #'./'
开发者ID:thomas-vincent,项目名称:pyhrf,代码行数:11,代码来源:test_plot.py

示例10: setUp

    def setUp(self):
        np.random.seed(8652761)

        self.tmp_dir = pyhrf.get_tmp_path()
        self.clean_tmp = True

        self.sampler_params_for_single_test = {
            'nb_iterations': 40,
            'smpl_hist_pace': 1,
            'obs_hist_pace': 1,
            'brf': jasl.PhysioBOLDResponseSampler(do_sampling=False,
                                                  normalise=1.,
                                                  use_true_value=True,
                                                  zero_constraint=False),
            'brf_var':
            jasl.PhysioBOLDResponseVarianceSampler(do_sampling=False,
                                                   val_ini=np.array([0.1]),
                                                   use_true_value=False),
            'prf': jasl.PhysioPerfResponseSampler(do_sampling=False,
                                                  normalise=1.,
                                                  use_true_value=True,
                                                  zero_constraint=False,
                                                  prior_type='physio_stochastic_regularized'),
            'prf_var':
            jasl.PhysioPerfResponseVarianceSampler(do_sampling=False,
                                                   val_ini=np.array(
                                                       [.001]),
                                                   use_true_value=False),
            'noise_var': jasl.NoiseVarianceSampler(do_sampling=False,
                                                   use_true_value=True),
            'drift_var': jasl.DriftVarianceSampler(do_sampling=False,
                                                   use_true_value=True),
            'drift': jasl.DriftCoeffSampler(do_sampling=False,
                                            use_true_value=True),
            'bold_response_levels':
            jasl.BOLDResponseLevelSampler(do_sampling=False,
                                          use_true_value=True),
            'perf_response_levels':
            jasl.PerfResponseLevelSampler(do_sampling=False,
                                          use_true_value=True),
            'labels': jasl.LabelSampler(do_sampling=False,
                                        use_true_value=True),
            'bold_mixt_params': jasl.BOLDMixtureSampler(do_sampling=False,
                                                        use_true_value=True),
            'perf_mixt_params': jasl.PerfMixtureSampler(do_sampling=False,
                                                        use_true_value=True),
            'perf_baseline': jasl.PerfBaselineSampler(do_sampling=False,
                                                      use_true_value=True),
            'perf_baseline_var':
            jasl.PerfBaselineVarianceSampler(do_sampling=False,
                                             use_true_value=True),
            'check_final_value': 'raise',  # print or raise
        }
开发者ID:pyhrf,项目名称:pyhrf,代码行数:53,代码来源:valid_jde_asl_physio.py

示例11: dump_roi_datasets

    def dump_roi_datasets(self, dry=False, output_dir=None):
        pyhrf.verbose(1,'Loading data ...')
        # if no file to dump (dry), assume it's only to get file names,
        # then don't build the graph (could take some time ...)
        if not dry:
            self.data.build_graphs()

        explData = self.analyser.split_data(self.data)
        files = []
        roiIds = []
        if output_dir is not None:
            roi_data_out_dir = output_dir
        else:
            if self.output_dir is not None:
                roi_data_out_dir = op.join(self.output_dir, 'ROI_datasets')
            else:
                roi_data_out_dir = op.join(pyhrf.get_tmp_path(), 'ROI_datasets')
            if not op.exists(roi_data_out_dir): os.makedirs(roi_data_out_dir)

        assert op.exists(roi_data_out_dir)

        if not dry:
            pyhrf.verbose(1,'Dump roi data in dir %s' %roi_data_out_dir)


        #data_order = sorted([d.get_nb_vox_in_mask() for d in explData])
        pyhrf.verbose(1,'Dump of roi data, ordering by size ...')
        cmp_size = lambda e1,e2:cmp(e1.get_nb_vox_in_mask(),
                                    e2.get_nb_vox_in_mask())
        for edata in sorted(explData, cmp=cmp_size, reverse=True):
            roiId = edata.get_roi_id()
            fn = op.abspath(op.join(roi_data_out_dir,
                                    "roidata_%04d.pck" %roiId))
            roiIds.append(roiId)
            if not dry:
                f = open(fn ,'w')
                cPickle.dump(edata, f)
                f.close()
            files.append(fn)

        pyhrf.verbose(1,'Dump of roi data done.')

        return files, roiIds
开发者ID:pmesejo,项目名称:pyhrf,代码行数:43,代码来源:treatment.py

示例12: setUp

    def setUp(self):
        from pyhrf.ndarray import MRI3Daxes
        self.tmp_dir = pyhrf.get_tmp_path()

        self.p1 = np.array([[[1, 1, 1, 3],
                             [1, 1, 3, 3],
                             [0, 1, 2, 2],
                             [0, 2, 2, 2],
                             [0, 0, 2, 4]]], dtype=np.int32)

        self.p1_fn = op.join(self.tmp_dir, 'p1.nii')
        xndarray(self.p1, axes_names=MRI3Daxes).save(self.p1_fn)

        self.p2 = self.p1 * 4.5
        self.p2_fn = op.join(self.tmp_dir, 'p2.nii')
        xndarray(self.p2, axes_names=MRI3Daxes).save(self.p2_fn)

        self.mask = (self.p1 > 0).astype(np.int32)
        self.mask_fn = op.join(self.tmp_dir, 'mask.nii')
        xndarray(self.mask, axes_names=MRI3Daxes).save(self.mask_fn)
开发者ID:pyhrf,项目名称:pyhrf,代码行数:20,代码来源:test_parcellation.py

示例13: make_parcellation_cubed_blobs_from_file

def make_parcellation_cubed_blobs_from_file(parcellation_file, output_path,
                                            roi_ids=None, bg_parcel=0,
                                            skip_existing=False):


    p,mp = read_volume(parcellation_file)
    p = p.astype(np.int32)
    if bg_parcel==0 and p.min() == -1:
        p += 1 #set background to 0

    if roi_ids is None:
        roi_ids = np.unique(p)

    pyhrf.verbose(1,'%d rois to extract' %(len(roi_ids)-1))

    tmp_dir = pyhrf.get_tmp_path('blob_parcellation')
    tmp_parcel_mask_file = op.join(tmp_dir, 'parcel_for_blob.nii')

    out_files = []
    for roi_id in roi_ids:
        if roi_id != bg_parcel: #discard background
            output_blob_file = op.join(output_path, 'parcel_%d_cubed_blob.arg'\
                                           %roi_id)
            out_files.append(output_blob_file)
            if skip_existing and os.path.exists(output_blob_file):
                continue
            parcel_mask = (p==roi_id).astype(np.int32)
            write_volume(parcel_mask, tmp_parcel_mask_file, mp)
            pyhrf.verbose(3,'Extract ROI %d -> %s' %(roi_id,output_blob_file))
            cmd = 'AimsGraphConvert -i %s -o %s --bucket' \
                %(tmp_parcel_mask_file, output_blob_file)
            pyhrf.verbose(3,'Cmd: %s' %(cmd))
            os.system(cmd)
    if op.exists(tmp_parcel_mask_file):
        os.remove(tmp_parcel_mask_file)

    return out_files
开发者ID:pmesejo,项目名称:pyhrf,代码行数:37,代码来源:parcellation.py

示例14: setUp

    def setUp(self):

        #pyhrf.verbose.set_verbosity(2)

        np.random.seed(8652761)

        # tmpDir = tempfile.mkdtemp(prefix='pyhrf_tests',
        #     dir=pyhrf.cfg['global']['tmp_path'])

        self.tmp_outputs = True #save outputs in tmp dir
                                #if False then save in current dir

        if not self.tmp_outputs:
            self.tmp_dir_small = './JDE_MS_test_small_simu'
            if not op.exists(self.tmp_dir_small): os.makedirs(self.tmp_dir_small)
            self.tmp_dir_big = './JDE_MS_test_big_simu'
            if not op.exists(self.tmp_dir_big): os.makedirs(self.tmp_dir_big)
        else:
            self.tmp_dir_small = pyhrf.get_tmp_path()
            self.tmp_dir_big = pyhrf.get_tmp_path()

        simu = simulate_sessions(output_dir = self.tmp_dir_small,
                                 snr_scenario='high_snr', spatial_size='tiny')
        self.data_small_simu = merge_fmri_sessions(simu)

        simu = simulate_sessions(output_dir=self.tmp_dir_big,
                                 snr_scenario='low_snr', spatial_size='normal')
        self.data_simu = merge_fmri_sessions(simu)

        # Parameters for multi-sessions sampler
        dict_beta_single = {
                    BetaSampler.P_VAL_INI : np.array([0.5]),
                    BetaSampler.P_SAMPLE_FLAG : False,
                    BetaSampler.P_PARTITION_FUNCTION_METH : 'es',
                    BetaSampler.P_USE_TRUE_VALUE : False,
                    }

        dict_hrf_single = {
                    HRF_MultiSess_Sampler.P_SAMPLE_FLAG : False,
                    HRF_MultiSess_Sampler.P_NORMALISE : 1., # normalise samples
                    HRF_MultiSess_Sampler.P_USE_TRUE_VALUE :  True,
                    HRF_MultiSess_Sampler.P_ZERO_CONSTR :  True,
                    #HRF_MultiSess_Sampler.P_PRIOR_TYPE : 'singleHRF',
                    }

        dict_var_hrf_single = {
                        RHSampler.P_SAMPLE_FLAG : False,
                        RHSampler.P_VAL_INI : np.array([0.001]),
                    }

        dict_nrl_sess_single =   {
                        NRL_Multi_Sess_Sampler.P_SAMPLE_FLAG : False,
                        NRL_Multi_Sess_Sampler.P_USE_TRUE_VALUE :  True,
                        }

        dict_nrl_sess_var_single = {
                            Variance_GaussianNRL_Multi_Sess.P_SAMPLE_FLAG : False,
                            Variance_GaussianNRL_Multi_Sess.P_USE_TRUE_VALUE :  True,
                            }

        dict_nrl_bar_single =  {
                        NRLsBar_Drift_Multi_Sess_Sampler.P_SAMPLE_FLAG : False,
                        NRLsBar_Drift_Multi_Sess_Sampler.P_USE_TRUE_NRLS : True,
                        NRLsBar_Drift_Multi_Sess_Sampler.P_SAMPLE_LABELS : False,
                        NRLsBar_Drift_Multi_Sess_Sampler.P_USE_TRUE_LABELS : True,
                        }

        dict_drift_single = {
                    Drift_MultiSess_Sampler.P_SAMPLE_FLAG : False,
                    Drift_MultiSess_Sampler.P_USE_TRUE_VALUE : True,
                    }

        dict_drift_var_single = {
                        ETASampler_MultiSess.P_SAMPLE_FLAG : False,
                        ETASampler_MultiSess.P_USE_TRUE_VALUE : True,
                        }

        dict_noise_var_single = {
                        NoiseVariance_Drift_Multi_Sess_Sampler.P_SAMPLE_FLAG : False,
                        NoiseVariance_Drift_Multi_Sess_Sampler.P_USE_TRUE_VALUE :  True,
                        }

        dict_mixt_param_single =  {
                            BiGaussMixtureParamsSampler.P_SAMPLE_FLAG : False,
                            BiGaussMixtureParamsSampler.P_USE_TRUE_VALUE : True,
                            BiGaussMixtureParamsSampler.P_HYPER_PRIOR : 'Jeffrey',
                            }


        self.sampler_params_for_single_test = {
            BMSS.P_NB_ITERATIONS : 100,
            BMSS.P_SMPL_HIST_PACE : -1,
            BMSS.P_OBS_HIST_PACE : -1,
            # level of spatial correlation = beta
            BMSS.P_BETA : BetaSampler(dict_beta_single),
            # HRF
            BMSS.P_HRF : HRF_MultiSess_Sampler(dict_hrf_single),
            # HRF variance
            BMSS.P_RH : RHSampler(dict_var_hrf_single),
            # neural response levels (stimulus-induced effects) by session
#.........这里部分代码省略.........
开发者ID:pmesejo,项目名称:pyhrf,代码行数:101,代码来源:valid_jde_bold_mono_subj_multi_sess.py

示例15: setUp

 def setUp(self):
     np.random.seed(8652761)
     self.tmp_dir = pyhrf.get_tmp_path()
开发者ID:pyhrf,项目名称:pyhrf,代码行数:3,代码来源:jdetest.py


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