本文整理汇总了Python中pyhrf.get_data_file_name函数的典型用法代码示例。如果您正苦于以下问题:Python get_data_file_name函数的具体用法?Python get_data_file_name怎么用?Python get_data_file_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_data_file_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ward_spatial_real_data
def test_ward_spatial_real_data(self):
from pyhrf.glm import glm_nipy_from_files
fn = 'subj0_parcellation.nii.gz'
mask_file = pyhrf.get_data_file_name(fn)
bold = 'subj0_bold_session0.nii.gz'
bold_file = pyhrf.get_data_file_name(bold)
paradigm_csv_file = pyhrf.get_data_file_name('paradigm_loc_av.csv')
output_dir = self.tmp_dir
output_file = op.join(output_dir,
'parcellation_output_test_real_data.nii')
tr = 2.4
bet = glm_nipy_from_files(bold_file, tr,
paradigm_csv_file, output_dir,
mask_file, session=0,
contrasts=None,
hrf_model='Canonical',
drift_model='Cosine', hfcut=128,
residuals_model='spherical',
fit_method='ols', fir_delays=[0])[0]
logger.info('betas_files: %s', ' '.join(bet))
cmd = 'pyhrf_parcellate_glm -m %s %s -o %s -v %d -n %d '\
'-t ward_spatial ' \
% (mask_file, ' '.join(bet), output_file,
logger.getEffectiveLevel(), 10)
if os.system(cmd) != 0:
raise Exception('"' + cmd + '" did not execute correctly')
logger.info('cmd: %s', cmd)
示例2: test_load_fmri_surf_data
def test_load_fmri_surf_data(self):
""" Test surfacic data loading
"""
mesh_file = pyhrf.get_data_file_name('real_data_surf_tiny_mesh.gii')
bold_file = pyhrf.get_data_file_name('real_data_surf_tiny_bold.gii')
fn = 'real_data_surf_tiny_parcellation.gii'
parcel_file = pyhrf.get_data_file_name(fn)
# boldFn = pyhrf.get_data_file_name('localizer_surface_bold.tex')
# roiMaskFn = pyhrf.get_data_file_name('roimask_gyrii.tex')
# meshFn = pyhrf.get_data_file_name('right_hemisphere.mesh')
#g, b, ss, m, h = load_fmri_surf_data([boldFn, boldFn], meshFn,
# roiMaskFn)
# graph, bold, session_scans, mask, edge lengthes
#pyhrf.verbose.set_verbosity(3)
g, b, ss, m, el = load_fmri_surf_data([bold_file, bold_file],
mesh_file,
parcel_file)
assert len(g) == len(np.unique(m))
if 0:
first_parcel = g.keys()[0]
print len(g), 'g[%d]:'%first_parcel, len(g[first_parcel])
print 'edge lengthes of roi %d:' %first_parcel
print el[first_parcel]
print b[first_parcel].shape
print ss[0][0],'-',ss[0][-1],',',ss[1][0],'-',ss[1][-1]
print m.shape, _np.unique(m)
示例3: setDummyInputData
def setDummyInputData(self, xmlFile):
f = open(xmlFile, 'r')
xml = f.read()
t = xmlio.from_xml(xml)
if t.data.data_type == 'volume':
dataFn = pyhrf.get_data_file_name('dummySmallBOLD.nii.gz')
maskFn = pyhrf.get_data_file_name('dummySmallMask.nii.gz')
sd = FMRISessionVolumicData(bold_file=dataFn)
t.set_init_param('fmri_data',
FmriData.from_vol_ui(mask_file=maskFn,
sessions_data=[sd]))
elif t.data.data_type == 'surface':
fn = 'real_data_surf_tiny_bold.gii'
dataFn = pyhrf.get_data_file_name(fn)
fn = 'real_data_surf_tiny_parcellation.gii'
maskFn = pyhrf.get_data_file_name(fn)
fn = 'real_data_surf_tiny_mesh.gii'
meshFn = pyhrf.get_data_file_name(fn)
sd = FMRISessionSurfacicData(bold_file=dataFn)
t.set_init_param('fmri_data',
FmriData.from_surf_ui(mask_file=maskFn,
mesh_file=meshFn,
sessions_data=[sd]))
else:
raise Exception('Unsupported class ... todo')
f = open(xmlFile, 'w')
f.write(xmlio.to_xml(t))
f.close()
示例4: setDummyInputData
def setDummyInputData(self, xmlFile):
f = open(xmlFile, "r")
xml = f.read()
t = xmlio.fromXML(xml)
if t.data.data_type == "volume":
dataFn = pyhrf.get_data_file_name("dummySmallBOLD.nii.gz")
maskFn = pyhrf.get_data_file_name("dummySmallMask.nii.gz")
sd = FMRISessionVolumicData(bold_file=dataFn)
t.set_init_param("fmri_data", FmriData.from_vol_ui(mask_file=maskFn, sessions_data=[sd]))
elif t.data.data_type == "surface":
fn = "real_data_surf_tiny_bold.gii"
dataFn = pyhrf.get_data_file_name(fn)
fn = "real_data_surf_tiny_parcellation.gii"
maskFn = pyhrf.get_data_file_name(fn)
fn = "real_data_surf_tiny_mesh.gii"
meshFn = pyhrf.get_data_file_name(fn)
sd = FMRISessionSurfacicData(bold_file=dataFn)
t.set_init_param("fmri_data", FmriData.from_surf_ui(mask_file=maskFn, mesh_file=meshFn, sessions_data=[sd]))
else:
raise Exception("Unsupported class ... todo")
f = open(xmlFile, "w")
f.write(xmlio.toXML(t, handler=NumpyXMLHandler()))
f.close()
示例5: test_read_default_real_data_tiny
def test_read_default_real_data_tiny(self):
mesh_file = pyhrf.get_data_file_name('real_data_surf_tiny_mesh.gii')
bold_file = pyhrf.get_data_file_name('real_data_surf_tiny_bold.gii')
fn = 'real_data_surf_tiny_parcellation.gii'
parcel_file = pyhrf.get_data_file_name(fn)
cor, tri, mesh_gii = pio.read_mesh(mesh_file)
bold, bold_gii = pio.read_texture(bold_file)
parcellation, parcel_gii = pio.read_texture(parcel_file)
示例6: 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() #'./'
示例7: 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() #'./'
示例8: test_load_fmri_surf_data
def test_load_fmri_surf_data(self):
""" Test surfacic data loading
"""
mesh_file = pyhrf.get_data_file_name('real_data_surf_tiny_mesh.gii')
bold_file = pyhrf.get_data_file_name('real_data_surf_tiny_bold.gii')
fn = 'real_data_surf_tiny_parcellation.gii'
parcel_file = pyhrf.get_data_file_name(fn)
g, b, ss, m, el = pio.load_fmri_surf_data([bold_file, bold_file],
mesh_file,
parcel_file)
assert len(g) == len(np.unique(m))
示例9: test_frmi_vol
def test_frmi_vol(self):
""" Test volumic data loading
"""
boldFn = get_data_file_name('subj0_bold_session0.nii.gz')
roiMaskFn = get_data_file_name('subj0_parcellation.nii.gz')
g, b, ss, m, h = pio.load_fmri_vol_data([boldFn, boldFn], roiMaskFn)
if 0:
print len(g), g[1]
print b[1].shape
print ss
print m.shape, np.unique(m)
print h
示例10: test_read_default_real_data_tiny
def test_read_default_real_data_tiny(self):
mesh_file = pyhrf.get_data_file_name('real_data_surf_tiny_mesh.gii')
bold_file = pyhrf.get_data_file_name('real_data_surf_tiny_bold.gii')
fn = 'real_data_surf_tiny_parcellation.gii'
parcel_file = pyhrf.get_data_file_name(fn)
cor, tri, mesh_gii = read_mesh(mesh_file)
bold, bold_gii = read_texture(bold_file)
parcellation, parcel_gii = read_texture(parcel_file)
if 0:
print 'cor:', cor.shape, cor.dtype
print 'tri:', tri.shape, tri.dtype
print 'bold:', bold.shape, bold.dtype
print 'parcellation:', parcellation.shape, parcellation.dtype
示例11: load_many_hrf_territories
def load_many_hrf_territories(nb_hrf_territories):
from pyhrf.tools._io import read_volume
fn = pyhrf.get_data_file_name("simu_hrf_%d_territories.nii" % nb_hrf_territories)
assert op.exists(fn)
territories = read_volume(fn)[0]
return territories[np.where(np.ones_like(territories))]
示例12: _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(self.tmp_dir, 'SPM_v{}.mat'.format(spm_ver))
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])
示例13: test_paradigm_csv2
def test_paradigm_csv2(self):
pfn = get_data_file_name('paradigm_loc_av.csv')
o, d = pio.load_paradigm_from_csv(pfn, " ")
if 0:
print 'onsets:'
print o
print 'durations:'
print d
示例14: test_split4DVol
def test_split4DVol(self):
s = 'subj0_bold_session0.nii.gz'
bfn = pyhrf.get_data_file_name(s)
bold_files = pio.split4DVol(bfn, output_dir=self.tmp_dir)
i, meta = pio.read_volume(bold_files[0])
for bf in bold_files:
os.remove(bf)
示例15: _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)