本文整理汇总了Python中nipype.interfaces.base.isdefined函数的典型用法代码示例。如果您正苦于以下问题:Python isdefined函数的具体用法?Python isdefined怎么用?Python isdefined使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isdefined函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _list_outputs
def _list_outputs(self):
"""Execute this module.
"""
outdir = self.inputs.base_directory
if not isdefined(outdir):
outdir = os.path.abspath('.')
if isdefined(self.inputs.container):
print "container defined", self.inputs.container
outdir = os.path.join(outdir, self.inputs.container)
print outdir
cwd = os.getcwd()
dst = self._get_dst(os.path.join(cwd,self.inputs.json_name+'.json'))
print "dst = ", dst
outdir = os.path.join(outdir,dst)
print "new outdir = ", outdir
outdir = self._substitute(outdir)
print "substituted outdir = ", outdir
if not os.path.exists(outdir):
try:
os.makedirs(outdir)
except OSError, inst:
if 'File exists' in inst:
pass
else:
raise(inst)
开发者ID:INCF,项目名称:BrainImagingPipelines,代码行数:28,代码来源:io.py
示例2: _run_interface
def _run_interface(self, runtime):
if not isdefined(self.inputs.screenshot_stem):
stem = "%s_%s_%s" % (
self.inputs.subject_id, self.inputs.hemi, self.inputs.surface)
else:
stem = self.inputs.screenshot_stem
stem_args = self.inputs.stem_template_args
if isdefined(stem_args):
args = tuple([getattr(self.inputs, arg) for arg in stem_args])
stem = stem % args
# Check if the DISPLAY variable is set -- should avoid crashes (might not?)
if not "DISPLAY" in os.environ:
raise RuntimeError("Graphics are not enabled -- cannot run tksurfer")
runtime.environ["_SNAPSHOT_STEM"] = stem
self._write_tcl_script()
runtime = super(SurfaceSnapshots, self)._run_interface(runtime)
# If a display window can't be opened, this will crash on
# aggregate_outputs. Let's try to parse stderr and raise a
# better exception here if that happened.
errors = ["surfer: failed, no suitable display found",
"Fatal Error in tksurfer.bin: could not open display"]
for err in errors:
if err in runtime.stderr:
self.raise_exception(runtime)
# Tksurfer always (or at least always when you run a tcl script)
# exits with a nonzero returncode. We have to force it to 0 here.
runtime.returncode = 0
return runtime
开发者ID:RanjitK,项目名称:nipype,代码行数:28,代码来源:utils.py
示例3: _gen_outfilename
def _gen_outfilename(self):
out_file = self.inputs.out_file
if not isdefined(out_file) and isdefined(self.inputs.in_file):
out_file = self._gen_fname(self.inputs.in_file, suffix="_surf")
#out_file = self._gen_fname(self.inputs.in_file, suffix="_surf")
return out_file
开发者ID:RanjitK,项目名称:NKI_NYU_Nipype,代码行数:7,代码来源:e_afni.py
示例4: _check_mlab_inputs
def _check_mlab_inputs(self):
if not isdefined(self.inputs.matlab_cmd) and self._matlab_cmd:
self.inputs.matlab_cmd = self._matlab_cmd
if not isdefined(self.inputs.paths) and self._paths:
self.inputs.paths = self._paths
if not isdefined(self.inputs.use_mcr) and self._use_mcr:
self.inputs.use_mcr = self._use_mcr
开发者ID:chaselgrove,项目名称:nipype,代码行数:7,代码来源:base.py
示例5: _run_interface
def _run_interface(self, runtime):
tracks, header = trk.read(self.inputs.in_file)
if not isdefined(self.inputs.data_dims):
data_dims = header['dim']
else:
data_dims = self.inputs.data_dims
if not isdefined(self.inputs.voxel_dims):
voxel_size = header['voxel_size']
else:
voxel_size = self.inputs.voxel_dims
affine = header['vox_to_ras']
streams = ((ii[0]) for ii in tracks)
data = density_map(streams, data_dims, voxel_size)
if data.max() < 2**15:
data = data.astype('int16')
img = nb.Nifti1Image(data,affine)
out_file = op.abspath(self.inputs.out_filename)
nb.save(img, out_file)
iflogger.info('Track density map saved as {i}'.format(i=out_file))
iflogger.info('Data Dimensions {d}'.format(d=data_dims))
iflogger.info('Voxel Dimensions {v}'.format(v=voxel_size))
return runtime
开发者ID:Guokr1991,项目名称:nipype,代码行数:26,代码来源:tracks.py
示例6: _list_outputs
def _list_outputs(self):
outputs = self._outputs().get()
outputs["out_file"] = self.inputs.out_file
if not isdefined(outputs["out_file"]):
source = self.inputs.source_file
# Some recon-all files don't have a proper extension (e.g. "lh.thickness")
# so we have to account for that here
bad_extensions = [".%s" % e for e in ["area", "mid", "pial", "avg_curv", "curv", "inflated",
"jacobian_white", "orig", "nofix", "smoothwm", "crv",
"sphere", "sulc", "thickness", "volume", "white"]]
use_ext = True
if split_filename(source)[2] in bad_extensions:
source = source + ".stripme"
use_ext = False
ext = ""
if isdefined(self.inputs.target_type):
ext = "." + filemap[self.inputs.target_type]
use_ext = False
outputs["out_file"] = fname_presuffix(source,
suffix=".%s%s" % (self.inputs.target_subject, ext),
newpath=os.getcwd(),
use_ext=use_ext)
else:
outputs["out_file"] = os.path.abspath(self.inputs.out_file)
return outputs
开发者ID:jsalva,项目名称:nipype,代码行数:25,代码来源:utils.py
示例7: _list_outputs
def _list_outputs(self):
outputs = self.output_spec().get()
outputs['out_file'] = self.inputs.out_file
if not isdefined(outputs['out_file']) and isdefined(self.inputs.in_file):
outputs['out_file']=self._gen_fname(self.inputs.in_file,
suffix='_sigloss')
return outputs
开发者ID:adamatus,项目名称:nipype,代码行数:7,代码来源:epi.py
示例8: _list_outputs
def _list_outputs(self):
outputs = self.output_spec().get()
outputs["out_reg_file"] = self.inputs.out_reg_file
if not isdefined(self.inputs.out_reg_file) and self.inputs.source_file:
outputs["out_reg_file"] = fname_presuffix(self.inputs.source_file, suffix="_robustreg.lta", use_ext=False)
prefices = dict(src=self.inputs.source_file, trg=self.inputs.target_file)
suffices = dict(
registered_file=("src", "_robustreg", True),
weights_file=("src", "_robustweights", True),
half_source=("src", "_halfway", True),
half_targ=("trg", "_halfway", True),
half_weights=("src", "_halfweights", True),
half_source_xfm=("src", "_robustxfm.lta", False),
half_targ_xfm=("trg", "_robustxfm.lta", False),
)
for name, sufftup in suffices.items():
value = getattr(self.inputs, name)
if isdefined(value):
if isinstance(value, bool):
outputs[name] = fname_presuffix(
prefices[sufftup[0]], suffix=sufftup[1], newpath=os.getcwd(), use_ext=sufftup[2]
)
else:
outputs[name] = value
return outputs
开发者ID:GaelVaroquaux,项目名称:nipype,代码行数:25,代码来源:preprocess.py
示例9: _list_outputs
def _list_outputs(self):
outputs = self.output_spec().get()
outputs['out_file'] = os.path.join(os.getcwd(),
self.inputs.out_base + '.nii.gz')
if not (isdefined(self.inputs.no_fmapreg) and self.inputs.no_fmapreg) and isdefined(self.inputs.fmap):
outputs['out_1vol'] = os.path.join(os.getcwd(),
self.inputs.out_base + '_1vol.nii.gz')
outputs['fmap2str_mat'] = os.path.join(os.getcwd(),
self.inputs.out_base + '_fieldmap2str.mat')
outputs['fmap2epi_mat'] = os.path.join(os.getcwd(),
self.inputs.out_base + '_fieldmaprads2epi.mat')
outputs['fmap_epi'] = os.path.join(os.getcwd(),
self.inputs.out_base + '_fieldmaprads2epi.nii.gz')
outputs['fmap_str'] = os.path.join(os.getcwd(),
self.inputs.out_base + '_fieldmaprads2str.ni `i.gz')
outputs['fmapmag_str'] = os.path.join(os.getcwd(),
self.inputs.out_base + '_fieldmap2str.nii.gz')
outputs['shiftmap'] = os.path.join(os.getcwd(),
self.inputs.out_base + '_fieldmaprads2epi_shift.nii.gz')
outputs['fullwarp'] = os.path.join(os.getcwd(),
self.inputs.out_base + '_warp.nii.gz')
outputs['epi2str_inv'] = os.path.join(os.getcwd(),
self.inputs.out_base + '_inv.mat')
outputs['epi2str_mat'] = os.path.join(os.getcwd(),
self.inputs.out_base + '.mat')
outputs['wmedge'] = os.path.join(os.getcwd(),
self.inputs.out_base + '_fast_wmedge.nii.gz')
outputs['wmseg'] = os.path.join(os.getcwd(),
self.inputs.out_base + '_fast_wmseg.nii.gz')
return outputs
开发者ID:veenasomareddy,项目名称:nipype,代码行数:32,代码来源:epi.py
示例10: _run_interface
def _run_interface(self, runtime):
out_file = op.abspath(self._gen_outfilename())
settings = dict(mask=None,
rician=(self.inputs.noise_model == 'rician'))
if isdefined(self.inputs.in_mask):
settings['mask'] = nb.load(self.inputs.in_mask).get_data()
if isdefined(self.inputs.patch_radius):
settings['patch_radius'] = self.inputs.patch_radius
if isdefined(self.inputs.block_radius):
settings['block_radius'] = self.inputs.block_radius
noise_mask = None
if isdefined(self.inputs.in_mask):
noise_mask = nb.load(self.inputs.noise_mask).get_data()
_, s = nlmeans_proxy(self.inputs.in_file,
settings,
noise_mask=noise_mask,
out_file=out_file)
iflogger.info(('Denoised image saved as {i}, estimated '
'sigma={s}').format(i=out_file, s=s))
return runtime
开发者ID:Alunisiira,项目名称:nipype,代码行数:26,代码来源:preprocess.py
示例11: _run_interface
def _run_interface(self, runtime):
in_file_ref = Path(self.inputs.in_file)
if isdefined(self.inputs.out_file):
in_file_ref = Path(self.inputs.out_file)
fname = in_file_ref.name.rstrip(
''.join(in_file_ref.suffixes))
out_file = (Path(runtime.cwd) / ('plot_%s_contours.svg' % fname)).resolve()
self._results['out_file'] = str(out_file)
vmax = None if not isdefined(self.inputs.vmax) else self.inputs.vmax
vmin = None if not isdefined(self.inputs.vmin) else self.inputs.vmin
plot_segmentation(
self.inputs.in_file,
self.inputs.in_contours,
out_file=str(out_file),
cut_coords=self.inputs.cut_coords,
display_mode=self.inputs.display_mode,
levels=self.inputs.levels,
colors=self.inputs.colors,
saturate=self.inputs.saturate,
vmin=vmin, vmax=vmax)
return runtime
开发者ID:oesteban,项目名称:mriqc,代码行数:26,代码来源:viz.py
示例12: _list_outputs
def _list_outputs(self):
outputs = self._outputs().get()
jobtype = self.inputs.jobtype
if jobtype.startswith('est'):
outputs['normalization_parameters'] = []
for imgf in filename_to_list(self.inputs.source):
outputs['normalization_parameters'].append(fname_presuffix(imgf, suffix='_sn.mat', use_ext=False))
outputs['normalization_parameters'] = list_to_filename(outputs['normalization_parameters'])
if self.inputs.jobtype == "estimate":
if isdefined(self.inputs.apply_to_files):
outputs['normalized_files'] = self.inputs.apply_to_files
outputs['normalized_source'] = self.inputs.source
elif 'write' in self.inputs.jobtype:
outputs['normalized_files'] = []
if isdefined(self.inputs.apply_to_files):
for imgf in filename_to_list(self.inputs.apply_to_files):
outputs['normalized_files'].append(fname_presuffix(imgf, prefix='w'))
if isdefined(self.inputs.source):
outputs['normalized_source'] = []
for imgf in filename_to_list(self.inputs.source):
outputs['normalized_source'].append(fname_presuffix(imgf, prefix='w'))
return outputs
开发者ID:IBIC,项目名称:nipype,代码行数:26,代码来源:preprocess.py
示例13: _list_outputs
def _list_outputs(self):
outputs = self._outputs().get()
jobtype = self.inputs.jobtype
if jobtype.startswith('est'):
outputs['normalization_parameters'] = []
for imgf in filename_to_list(self.inputs.source):
outputs['normalization_parameters'].append(fname_presuffix(imgf, suffix='_sn.mat', use_ext=False))
outputs['normalization_parameters'] = list_to_filename(outputs['normalization_parameters'])
if self.inputs.jobtype == "estimate":
if isdefined(self.inputs.apply_to_files):
outputs['normalized_files'] = self.inputs.apply_to_files
outputs['normalized_source'] = self.inputs.source
elif 'write' in self.inputs.jobtype:
outputs['normalized_files'] = []
if isdefined(self.inputs.apply_to_files):
filelist = filename_to_list(self.inputs.apply_to_files)
for f in filelist:
if isinstance(f, list):
run = [fname_presuffix(in_f, prefix=self.inputs.out_prefix) for in_f in f]
else:
run = [fname_presuffix(f, prefix=self.inputs.out_prefix)]
outputs['normalized_files'].extend(run)
if isdefined(self.inputs.source):
outputs['normalized_source'] = fname_presuffix(self.inputs.source, prefix=self.inputs.out_prefix)
return outputs
开发者ID:neurospin,项目名称:caps-clinfmri,代码行数:28,代码来源:spm.py
示例14: _generate_design
def _generate_design(self, infolist=None):
"""Generate design specification for a typical fmri paradigm
"""
realignment_parameters = []
if isdefined(self.inputs.realignment_parameters):
for parfile in self.inputs.realignment_parameters:
realignment_parameters.append(np.loadtxt(parfile))
outliers = []
if isdefined(self.inputs.outlier_files):
for filename in self.inputs.outlier_files:
try:
outindices = np.loadtxt(filename, dtype=int)
except IOError:
outliers.append([])
else:
if outindices.size == 1:
outliers.append([outindices.tolist()])
else:
outliers.append(outindices.tolist())
if infolist is None:
if isdefined(self.inputs.subject_info):
infolist = self.inputs.subject_info
else:
infolist = gen_info(self.inputs.event_files)
self._sessinfo = self._generate_standard_design(
infolist,
functional_runs=self.inputs.functional_runs,
realignment_parameters=realignment_parameters,
outliers=outliers,
)
开发者ID:heronjolin,项目名称:nipype,代码行数:30,代码来源:modelgen.py
示例15: _run_interface
def _run_interface(self, runtime):
mask_erode_mm = self.inputs.mask_erode_mm
if not isdefined(mask_erode_mm):
mask_erode_mm = None
erode_mm = self.inputs.erode_mm
if not isdefined(erode_mm):
erode_mm = None
mask_erode_prop = self.inputs.mask_erode_prop
if not isdefined(mask_erode_prop):
mask_erode_prop = None
erode_prop = self.inputs.erode_prop
if not isdefined(erode_prop):
erode_prop = None
roi_file, eroded_mask = _tpm2roi(
self.inputs.in_tpm,
self.inputs.in_mask,
mask_erode_mm,
erode_mm,
mask_erode_prop,
erode_prop,
self.inputs.prob_thresh,
newpath=runtime.cwd,
)
self._results['roi_file'] = roi_file
self._results['eroded_mask'] = eroded_mask
return runtime
开发者ID:poldracklab,项目名称:niworkflows,代码行数:26,代码来源:utils.py
示例16: _list_outputs
def _list_outputs(self):
outputs = self.output_spec().get()
#if isdefined(self.inputs.output_csv_file):
#write to a csv file and assign a value to self.coherence_file (a
#file name + path)
#Always defined (the arrays):
outputs['coherence_array']=self.coherence
outputs['timedelay_array']=self.delay
#Conditional
if isdefined(self.inputs.output_csv_file) and hasattr(self,'coherence'):
# we need to make a function that we call here that writes the
# coherence values to this file "coherence_csv" and makes the
# time_delay csv file??
self._make_output_files()
outputs['coherence_csv']=fname_presuffix(self.inputs.output_csv_file,suffix='_coherence')
outputs['timedelay_csv']=fname_presuffix(self.inputs.output_csv_file,suffix='_delay')
if isdefined(self.inputs.output_figure_file) and hasattr(self,
'coherence'):
self._make_output_figures()
outputs['coherence_fig'] = fname_presuffix(self.inputs.output_figure_file,suffix='_coherence')
outputs['timedelay_fig'] = fname_presuffix(self.inputs.output_figure_file,suffix='_delay')
return outputs
开发者ID:agramfort,项目名称:nipype,代码行数:29,代码来源:analysis.py
示例17: _parse_inputs
def _parse_inputs( self, skip=None ):
if skip is None:
skip = []
if not isdefined(self.inputs.out_base ):
self.inputs.out_base = './nipypetu'
self.inputs.out_base = os.path.abspath(self.inputs.out_base)
if isdefined( self.inputs.encoding_file ):
skip.append( 'encoding_direction' )
skip.append( 'readout_times' )
else:
encdir = 'y'
enctimes = None
if isdefined( self.inputs.encoding_direction ):
encdir = self.inputs.encoding_direction
if isdefined( self.inputs.readout_times ):
enctimes = self.inputs.readout_times
self.inputs.encoding_file = self._generate_encfile( encdir, enctimes )
return super(TOPUP, self)._parse_inputs(skip=skip)
开发者ID:adamatus,项目名称:nipype,代码行数:25,代码来源:epi.py
示例18: _run_interface
def _run_interface(self, runtime):
mask = None
if isdefined(self.inputs.in_mask):
mask = self.inputs.in_mask
title = self.inputs.title
if isdefined(self.inputs.subject):
title += ', subject %s' % self.inputs.subject
if isdefined(self.inputs.metadata):
title += ' (' + '_'.join(self.inputs.metadata) + ')'
if isdefined(self.inputs.figsize):
fig = plot_mosaic(
self.inputs.in_file,
title=title,
overlay_mask=mask,
figsize=self.inputs.figsize)
else:
fig = plot_mosaic(
self.inputs.in_file,
title=title,
overlay_mask=mask)
fig.savefig(self.inputs.out_file, dpi=self.inputs.dpi)
return runtime
开发者ID:dbkeator,项目名称:quality-assessment-protocol,代码行数:27,代码来源:interfaces.py
示例19: _format_arg
def _format_arg(self, opt, spec, val):
if opt == 'moving_image':
retval = []
for ii in range(len(self.inputs.moving_image)):
retval.append('--metric "%s[%s,%s,%d,%d]"' % (self.inputs.metric, self.inputs.fixed_image[ii], self.inputs.moving_image[ii],self.inputs.metric_weight,self.inputs.radius))
return " ".join(retval)
elif opt == 'moving_image_mask':
return '--masks "[%s,%s]"' % (self.inputs.fixed_image_mask, self.inputs.moving_image_mask)
elif opt == 'initial_moving_transform':
if isdefined(self.inputs.invert_initial_moving_transform) and self.inputs.invert_initial_moving_transform:
return '--initial-moving-transform "[%s,1]"' % self.inputs.initial_moving_transform
else:
return '--initial-moving-transform "[%s,0]"' % self.inputs.initial_moving_transform
elif opt == "number_of_iterations":
convergence_iter = "x".join([str(i) for i in self.inputs.number_of_iterations])
return '--convergence "[%s,%g,%d]"' % (convergence_iter,
self.inputs.convergence_threshold,
self.inputs.convergence_window_size)
elif opt == 'output_transform_prefix':
if isdefined(self.inputs.output_inverse_warped_image) and self.inputs.output_inverse_warped_image:
return '--output "[%s,%s,%s]"' % (self.inputs.output_transform_prefix, self.inputs.output_warped_image, self.inputs.output_inverse_warped_image )
elif isdefined(self.inputs.output_warped_image) and self.inputs.output_warped_image:
return '--output "[%s,%s]"' % (self.inputs.output_transform_prefix, self.inputs.output_warped_image )
else:
return '--output %s' % self.inputs.output_transform_prefix
return super(antsRegistration, self)._format_arg(opt, spec, val)
开发者ID:lwen,项目名称:BRAINSStandAlone,代码行数:26,代码来源:antsRegistration.py
示例20: _list_outputs
def _list_outputs(self):
outputs = self._outputs().get()
outputs['outlier_files'] = []
outputs['intensity_files'] = []
outputs['statistic_files'] = []
if isdefined(self.inputs.use_norm) and self.inputs.use_norm:
outputs['norm_files'] = []
if isdefined(self.inputs.save_plot) and self.inputs.save_plot:
outputs['plot_files'] = []
for i, f in enumerate(filename_to_list(self.inputs.realigned_files)):
outlierfile, intensityfile, statsfile, normfile, plotfile = self._get_output_filenames(f, os.getcwd())
outputs['outlier_files'].insert(i, outlierfile)
outputs['intensity_files'].insert(i, intensityfile)
outputs['statistic_files'].insert(i, statsfile)
if isdefined(self.inputs.use_norm) and self.inputs.use_norm:
outputs['norm_files'].insert(i, normfile)
if isdefined(self.inputs.save_plot) and self.inputs.save_plot:
outputs['plot_files'].insert(i, plotfile)
'''
outputs['outlier_files'] = list_to_filename(outputs['outlier_files'])
outputs['intensity_files'] = list_to_filename(outputs['intensity_files'])
outputs['statistic_files'] = list_to_filename(outputs['statistic_files'])
if isdefined(self.inputs.use_norm) and self.inputs.use_norm:
outputs['norm_files'] = list_to_filename(outputs['norm_files'])
if isdefined(self.inputs.save_plot) and self.inputs.save_plot:
outputs['plot_files'] = list_to_filename(outputs['plot_files'])
'''
return outputs
开发者ID:chaselgrove,项目名称:nipype,代码行数:28,代码来源:rapidart.py
注:本文中的nipype.interfaces.base.isdefined函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论