本文整理汇总了Python中nipype.MapNode.plugin_args方法的典型用法代码示例。如果您正苦于以下问题:Python MapNode.plugin_args方法的具体用法?Python MapNode.plugin_args怎么用?Python MapNode.plugin_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nipype.MapNode
的用法示例。
在下文中一共展示了MapNode.plugin_args方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_timeseries_model_workflow
# 需要导入模块: from nipype import MapNode [as 别名]
# 或者: from nipype.MapNode import plugin_args [as 别名]
def create_timeseries_model_workflow(name="model", exp_info=None):
# Default experiment parameters for generating graph inamge, testing, etc.
if exp_info is None:
exp_info = default_experiment_parameters()
# Define constant inputs
inputs = ["design_file", "realign_file", "artifact_file", "timeseries"]
# Possibly add the regressor file to the inputs
if exp_info["regressor_file"] is not None:
inputs.append("regressor_file")
# Define the workflow inputs
inputnode = Node(IdentityInterface(inputs), "inputs")
# Set up the experimental design
modelsetup = MapNode(Function(["exp_info",
"design_file",
"realign_file",
"artifact_file",
"regressor_file",
"run"],
["design_matrix_file",
"contrast_file",
"design_matrix_pkl",
"report"],
setup_model,
imports),
["realign_file", "artifact_file", "run"],
"modelsetup")
modelsetup.inputs.exp_info = exp_info
if exp_info["regressor_file"] is None:
modelsetup.inputs.regressor_file = None
# Use film_gls to estimate the timeseries model
modelestimate = MapNode(fsl.FILMGLS(smooth_autocorr=True,
mask_size=5,
threshold=1000),
["design_file", "in_file"],
"modelestimate")
# Run the contrast estimation routine
contrastestimate = MapNode(fsl.ContrastMgr(),
["tcon_file",
"dof_file",
"corrections",
"param_estimates",
"sigmasquareds"],
"contrastestimate")
calcrsquared = MapNode(Function(["design_matrix_pkl",
"timeseries",
"pe_files"],
["r2_files",
"ss_files"],
compute_rsquareds,
imports),
["design_matrix_pkl",
"timeseries",
"pe_files"],
"calcrsquared")
calcrsquared.plugin_args = dict(qsub_args="-l h_vmem=8G")
# Save the experiment info for this run
dumpjson = MapNode(Function(["exp_info", "timeseries"], ["json_file"],
dump_exp_info, imports),
"timeseries",
"dumpjson")
dumpjson.inputs.exp_info = exp_info
# Report on the results of the model
modelreport = MapNode(Function(["timeseries",
"sigmasquareds_file",
"zstat_files",
"r2_files"],
["report"],
report_model,
imports),
["timeseries", "sigmasquareds_file",
"zstat_files", "r2_files"],
"modelreport")
# Define the workflow outputs
outputnode = Node(IdentityInterface(["results",
"copes",
"varcopes",
"zstats",
"r2_files",
"ss_files",
"report",
"design_mat",
"contrast_mat",
"design_pkl",
"design_report",
"json_file"]),
"outputs")
# Define the workflow and connect the nodes
model = Workflow(name=name)
#.........这里部分代码省略.........
示例2: create_workflow
# 需要导入模块: from nipype import MapNode [as 别名]
# 或者: from nipype.MapNode import plugin_args [as 别名]
def create_workflow(files,
target_file,
subject_id,
TR,
slice_times,
norm_threshold=1,
num_components=5,
vol_fwhm=None,
surf_fwhm=None,
lowpass_freq=-1,
highpass_freq=-1,
subjects_dir=None,
sink_directory=os.getcwd(),
target_subject=['fsaverage3', 'fsaverage4'],
name='resting'):
wf = Workflow(name=name)
# Rename files in case they are named identically
name_unique = MapNode(Rename(format_string='rest_%(run)02d'),
iterfield=['in_file', 'run'],
name='rename')
name_unique.inputs.keep_ext = True
name_unique.inputs.run = list(range(1, len(files) + 1))
name_unique.inputs.in_file = files
realign = Node(nipy.SpaceTimeRealigner(), name="spacetime_realign")
realign.inputs.slice_times = slice_times
realign.inputs.tr = TR
realign.inputs.slice_info = 2
realign.plugin_args = {'sbatch_args': '-c%d' % 4}
# Compute TSNR on realigned data regressing polynomials up to order 2
tsnr = MapNode(TSNR(regress_poly=2), iterfield=['in_file'], name='tsnr')
wf.connect(realign, "out_file", tsnr, "in_file")
# Compute the median image across runs
calc_median = Node(Function(input_names=['in_files'],
output_names=['median_file'],
function=median,
imports=imports),
name='median')
wf.connect(tsnr, 'detrended_file', calc_median, 'in_files')
"""Segment and Register
"""
registration = create_reg_workflow(name='registration')
wf.connect(calc_median, 'median_file', registration, 'inputspec.mean_image')
registration.inputs.inputspec.subject_id = subject_id
registration.inputs.inputspec.subjects_dir = subjects_dir
registration.inputs.inputspec.target_image = target_file
"""Quantify TSNR in each freesurfer ROI
"""
get_roi_tsnr = MapNode(fs.SegStats(default_color_table=True),
iterfield=['in_file'], name='get_aparc_tsnr')
get_roi_tsnr.inputs.avgwf_txt_file = True
wf.connect(tsnr, 'tsnr_file', get_roi_tsnr, 'in_file')
wf.connect(registration, 'outputspec.aparc', get_roi_tsnr, 'segmentation_file')
"""Use :class:`nipype.algorithms.rapidart` to determine which of the
images in the functional series are outliers based on deviations in
intensity or movement.
"""
art = Node(interface=ArtifactDetect(), name="art")
art.inputs.use_differences = [True, True]
art.inputs.use_norm = True
art.inputs.norm_threshold = norm_threshold
art.inputs.zintensity_threshold = 9
art.inputs.mask_type = 'spm_global'
art.inputs.parameter_source = 'NiPy'
"""Here we are connecting all the nodes together. Notice that we add the merge node only if you choose
to use 4D. Also `get_vox_dims` function is passed along the input volume of normalise to set the optimal
voxel sizes.
"""
wf.connect([(name_unique, realign, [('out_file', 'in_file')]),
(realign, art, [('out_file', 'realigned_files')]),
(realign, art, [('par_file', 'realignment_parameters')]),
])
def selectindex(files, idx):
import numpy as np
from nipype.utils.filemanip import filename_to_list, list_to_filename
return list_to_filename(np.array(filename_to_list(files))[idx].tolist())
mask = Node(fsl.BET(), name='getmask')
mask.inputs.mask = True
wf.connect(calc_median, 'median_file', mask, 'in_file')
# get segmentation in normalized functional space
def merge_files(in1, in2):
out_files = filename_to_list(in1)
out_files.extend(filename_to_list(in2))
return out_files
#.........这里部分代码省略.........
示例3: create_timeseries_model_workflow
# 需要导入模块: from nipype import MapNode [as 别名]
# 或者: from nipype.MapNode import plugin_args [as 别名]
def create_timeseries_model_workflow(name="model", exp_info=None):
# Default experiment parameters for generating graph image, testing, etc.
if exp_info is None:
exp_info = lyman.default_experiment_parameters()
# Define constant inputs
inputs = ["realign_file", "artifact_file", "timeseries"]
# Possibly add the design and regressor files to the inputs
if exp_info["design_name"] is not None:
inputs.append("design_file")
if exp_info["regressor_file"] is not None:
inputs.append("regressor_file")
# Define the workflow inputs
inputnode = Node(IdentityInterface(inputs), "inputs")
# Set up the experimental design
modelsetup = MapNode(ModelSetup(exp_info=exp_info),
["timeseries", "realign_file", "artifact_file"],
"modelsetup")
# For some nodes, make it possible to request extra memory
mem_request = {"qsub_args": "-l h_vmem=%dG" % exp_info["memory_request"]}
# Use film_gls to estimate the timeseries model
modelestimate = MapNode(fsl.FILMGLS(smooth_autocorr=True,
mask_size=5,
threshold=100),
["design_file", "in_file"],
"modelestimate")
modelestimate.plugin_args = mem_request
# Run the contrast estimation routine
contrastestimate = MapNode(fsl.ContrastMgr(),
["tcon_file",
"dof_file",
"corrections",
"param_estimates",
"sigmasquareds"],
"contrastestimate")
contrastestimate.plugin_args = mem_request
# Compute summary statistics about the model fit
modelsummary = MapNode(ModelSummary(),
["design_matrix_pkl",
"timeseries",
"pe_files"],
"modelsummary")
modelsummary.plugin_args = mem_request
# Save the experiment info for this run
# Save the experiment info for this run
saveparams = MapNode(SaveParameters(exp_info=exp_info),
"in_file", "saveparams")
# Report on the results of the model
# Note: see below for a conditional iterfield
modelreport = MapNode(ModelReport(),
["timeseries", "sigmasquareds_file",
"tsnr_file", "r2_files"],
"modelreport")
# Define the workflow outputs
outputnode = Node(IdentityInterface(["results",
"copes",
"varcopes",
"zstats",
"r2_files",
"ss_files",
"tsnr_file",
"report",
"design_mat",
"contrast_mat",
"design_pkl",
"design_report",
"json_file"]),
"outputs")
# Define the workflow and connect the nodes
model = Workflow(name=name)
model.connect([
(inputnode, modelsetup,
[("realign_file", "realign_file"),
("artifact_file", "artifact_file"),
("timeseries", "timeseries")]),
(inputnode, modelestimate,
[("timeseries", "in_file")]),
(inputnode, saveparams,
[("timeseries", "in_file")]),
(modelsetup, modelestimate,
[("design_matrix_file", "design_file")]),
(modelestimate, contrastestimate,
[("dof_file", "dof_file"),
("corrections", "corrections"),
("param_estimates", "param_estimates"),
("sigmasquareds", "sigmasquareds")]),
(modelsetup, contrastestimate,
[("contrast_file", "tcon_file")]),
#.........这里部分代码省略.........