本文整理汇总了Python中nipype.interfaces.spm.base.scans_for_fnames函数的典型用法代码示例。如果您正苦于以下问题:Python scans_for_fnames函数的具体用法?Python scans_for_fnames怎么用?Python scans_for_fnames使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scans_for_fnames函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _format_arg
def _format_arg(self, opt, spec, val):
"""Convert input to appropriate format for spm
"""
if opt == 'target' or opt == 'source':
return scans_for_fnames(filename_to_list(val),
keep4d=True)
if opt == 'apply_to_files':
return scans_for_fnames(filename_to_list(val))
return val
开发者ID:danginsburg,项目名称:nipype,代码行数:9,代码来源:preprocess.py
示例2: _format_arg
def _format_arg(self, opt, spec, val):
"""Convert input to appropriate format for spm
"""
if opt in ["image_files"]:
return scans_for_fnames(val, keep4d=True, separate_sessions=True)
if opt in ["flowfield_files"]:
return scans_for_fnames(val, keep4d=True)
else:
return val
开发者ID:esc,项目名称:nipype,代码行数:10,代码来源:preprocess.py
示例3: _format_arg
def _format_arg(self, opt, spec, val):
"""Convert input to appropriate format for spm
"""
if opt == "target" or (opt == "source" and self.inputs.jobtype != "write"):
return scans_for_fnames(filename_to_list(val), keep4d=True)
if opt == "apply_to_files":
return scans_for_fnames(filename_to_list(val))
if opt == "source" and self.inputs.jobtype == "write":
if isdefined(self.inputs.apply_to_files):
return scans_for_fnames(val + self.inputs.apply_to_files)
else:
return scans_for_fnames(val)
return val
开发者ID:chaselgrove,项目名称:nipype,代码行数:13,代码来源:preprocess.py
示例4: _format_arg
def _format_arg(self, opt, spec, val):
"""Convert input to appropriate format for spm
"""
if opt == 'target' or (opt == 'source' and self.inputs.jobtype != "write"):
return scans_for_fnames(filename_to_list(val),
keep4d=True)
if opt == 'apply_to_files':
return np.array(filename_to_list(val), dtype=object)
if opt == 'source' and self.inputs.jobtype == "write":
if isdefined(self.inputs.apply_to_files):
return scans_for_fnames(val+self.inputs.apply_to_files)
else:
return scans_for_fnames(val)
return val
开发者ID:IBIC,项目名称:nipype,代码行数:14,代码来源:preprocess.py
示例5: test_generate_job
def test_generate_job(create_files_in_directory):
class TestClass(spm.SPMCommand):
input_spec = spm.SPMCommandInputSpec
dc = TestClass() # dc = derived_class
out = dc._generate_job()
assert out == ''
# struct array
contents = {'contents': [1, 2, 3, 4]}
out = dc._generate_job(contents=contents)
assert out == ('.contents(1) = 1;\n.contents(2) = 2;'
'\n.contents(3) = 3;\n.contents(4) = 4;\n')
# cell array of strings
filelist, outdir = create_files_in_directory
names = spm.scans_for_fnames(filelist, keep4d=True)
contents = {'files': names}
out = dc._generate_job(prefix='test', contents=contents)
assert out == "test.files = {...\n'a.nii';...\n'b.nii';...\n};\n"
# string assignment
contents = 'foo'
out = dc._generate_job(prefix='test', contents=contents)
assert out == "test = 'foo';\n"
# cell array of vectors
contents = {'onsets': np.array((1,), dtype=object)}
contents['onsets'][0] = [1, 2, 3, 4]
out = dc._generate_job(prefix='test', contents=contents)
assert out == 'test.onsets = {...\n[1, 2, 3, 4];...\n};\n'
开发者ID:LJWilliams,项目名称:nipype,代码行数:26,代码来源:test_base.py
示例6: _run_interface
def _run_interface(self, runtime):
from nipype.interfaces.spm.base import scans_for_fname,scans_for_fnames
from nipype.utils.filemanip import filename_to_list,list_to_filename
# setup parameters
input_dir = "."
in_files = "{"
asl_first = str(self.inputs.first_image_type)
TR = str(self.inputs.TR)
# convert images to cell array string in matlab
for f in sorted(scans_for_fnames(filename_to_list(self.inputs.in_files))):
in_files += "'"+f+"',\n"
input_dir = os.path.dirname(f)
in_files = in_files[:-2]+"}"
self.input_dir = input_dir
d = dict(in_files=in_files,in_dir=input_dir,first_image_type=asl_first,TR =TR)
myscript = Template("""
warning('off','all');
cd('$in_dir');
input = char($in_files);
asl_script(input,$first_image_type,0,$TR);
exit;
""").substitute(d)
mlab = MatlabCommand(script=myscript,matlab_cmd="matlab -nodesktop -nosplash",mfile=True)
result = mlab.run()
return result.runtime
开发者ID:tseytlin,项目名称:gold-pype,代码行数:27,代码来源:wrappers.py
示例7: _format_arg
def _format_arg(self, opt, spec, val):
"""Convert input to appropriate format for SPM
"""
if opt in ['in_files']:
return scans_for_fnames(filename_to_list(val), keep4d=False)
if opt == 'deformation_field':
return np.array([list_to_filename(val)], dtype=object)
return super(ApplyDeformationField, self)._format_arg(opt, spec, val)
开发者ID:neurospin,项目名称:caps-clinfmri,代码行数:8,代码来源:spm.py
示例8: _parse_inputs
def _parse_inputs(self):
"""validate spm realign options if set to None ignore
"""
einputs = super(Level1Design, self)._parse_inputs(skip=('mask_threshold'))
for sessinfo in einputs[0]['sess']:
sessinfo['scans'] = scans_for_fnames(filename_to_list(sessinfo['scans']), keep4d=False)
if not isdefined(self.inputs.spm_mat_dir):
einputs[0]['dir'] = np.array([str(os.getcwd())], dtype=object)
return einputs
开发者ID:colinbuchanan,项目名称:nipype,代码行数:9,代码来源:model.py
示例9: _format_arg
def _format_arg(self, opt, spec, val):
if opt in ["in_files"]:
return scans_for_fnames(filename_to_list(val))
if opt == "fwhm":
if not isinstance(val, list):
return [val, val, val]
if isinstance(val, list):
if len(val) == 1:
return [val[0], val[0], val[0]]
else:
return val
return val
开发者ID:schwarty,项目名称:nipype,代码行数:12,代码来源:preprocess.py
示例10: _format_arg
def _format_arg(self, opt, spec, val):
"""Convert input to appropriate format for spm
"""
if opt == 'in_files':
return scans_for_fnames(filename_to_list(val))
if opt == 'target':
return scans_for_fname(filename_to_list(val))
if opt == 'deformation':
return np.array([list_to_filename(val)], dtype=object)
if opt == 'deformation_field':
return np.array([list_to_filename(val)], dtype=object)
return val
开发者ID:ChadCumba,项目名称:nipype,代码行数:12,代码来源:utils.py
示例11: _parse_inputs
def _parse_inputs(self):
"""validate spm realign options if set to None ignore
"""
einputs = super(Normalize, self)._parse_inputs(skip=("jobtype", "apply_to_files"))
if isdefined(self.inputs.apply_to_files):
inputfiles = deepcopy(self.inputs.apply_to_files)
if isdefined(self.inputs.source):
inputfiles.extend(self.inputs.source)
einputs[0]["subj"]["resample"] = scans_for_fnames(inputfiles)
jobtype = self.inputs.jobtype
if jobtype in ["estwrite", "write"]:
if not isdefined(self.inputs.apply_to_files):
if isdefined(self.inputs.source):
einputs[0]["subj"]["resample"] = scans_for_fname(self.inputs.source)
return [{"%s" % (jobtype): einputs[0]}]
开发者ID:chaselgrove,项目名称:nipype,代码行数:15,代码来源:preprocess.py
示例12: _parse_inputs
def _parse_inputs(self):
"""validate spm realign options if set to None ignore
"""
einputs = super(Normalize, self)._parse_inputs(skip=('jobtype',
'apply_to_files'))
if isdefined(self.inputs.apply_to_files):
inputfiles = deepcopy(self.inputs.apply_to_files)
if isdefined(self.inputs.source):
inputfiles.extend(self.inputs.source)
einputs[0]['subj']['resample'] = scans_for_fnames(inputfiles)
jobtype = self.inputs.jobtype
if jobtype in ['estwrite', 'write']:
if not isdefined(self.inputs.apply_to_files):
if isdefined(self.inputs.source):
einputs[0]['subj']['resample'] = scans_for_fname(self.inputs.source)
return [{'%s' % (jobtype):einputs[0]}]
开发者ID:danginsburg,项目名称:nipype,代码行数:16,代码来源:preprocess.py
示例13: _format_arg
def _format_arg(self, opt, spec, val):
"""Convert input to appropriate format for spm
"""
if opt == 'in_files':
infiles = scans_for_fnames(val,
keep4d=True,
separate_sessions=True)
#return self._reformat_dict_for_savemat(dict(scans = infiles))
return infiles
#if opt == 'phase_map':
# infiles = val
# return self._reformat_dict_for_savemat(dict(pmscan = infiles))
if opt == 'register_to_mean': # XX check if this is necessary
return int(val)
return val
开发者ID:cindeem,项目名称:jagust_rsfmri,代码行数:16,代码来源:nipype_ext.py
示例14: _list_outputs
def _list_outputs(self):
import scipy.io as sp
#setup subject
input_dir = "."
for f in scans_for_fnames(filename_to_list(self.inputs.in_files)):
input_dir = os.path.dirname(f)
break
pt = re.compile(".*/embarc_CU_(.*)_mri_fmriraw.*")
mt = pt.match(input_dir)
if mt:
subject = mt.group(1)
# get the float value
mat = sp.loadmat(os.path.abspath(input_dir+"/mean_CBF_spm_save.mat"),squeeze_me=True)
outputs = self._outputs().get()
outputs['cbf_image'] = os.path.abspath(input_dir+"/meanCBF_"+subject+".nii")
outputs['cbf_value'] = mat['L']
return outputs
开发者ID:tseytlin,项目名称:gold-pype,代码行数:19,代码来源:wrappers.py
示例15: test_scan_for_fnames
def test_scan_for_fnames(create_files_in_directory):
filelist, outdir = create_files_in_directory
names = spm.scans_for_fnames(filelist, keep4d=True)
assert names[0] == filelist[0]
assert names[1] == filelist[1]
开发者ID:LJWilliams,项目名称:nipype,代码行数:5,代码来源:test_base.py
注:本文中的nipype.interfaces.spm.base.scans_for_fnames函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论