Skip to content

Add QA output for TSNR of resting run #1088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Next release
* ENH: Added csvReader() utility (https://github.com/nipy/nipype/pull/1044)
* FIX: typo in nipype.interfaces.freesurfer.utils.py Tkregister2 (https://github.com/nipy/nipype/pull/1083)
* FIX: SSHDataGrabber outputs now return full path to the grabbed/downloaded files. (https://github.com/nipy/nipype/pull/1086)
* FIX: Add QA output for TSNR to resting workflow (https://github.com/nipy/nipype/pull/1088)

Release 0.10.0 (October 10, 2014)
============
Expand Down
35 changes: 27 additions & 8 deletions examples/rsfmri_vol_surface_preprocessing_nipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ def create_reg_workflow(name='registration'):
'transformed_mean',
'segmentation_files',
'anat2target',
'aparc'
'aparc',
'min_cost_file'
]),
name='outputspec')

Expand Down Expand Up @@ -505,7 +506,7 @@ def create_reg_workflow(name='registration'):
reg.inputs.args = '--float'
reg.inputs.output_warped_image = 'output_warped_image.nii.gz'
reg.inputs.num_threads = 4
reg.plugin_args = {'qsub_args': '-l nodes=1:ppn=4'}
reg.plugin_args = {'sbatch_args': '-c%d' % 4}
register.connect(stripper, 'out_file', reg, 'moving_image')
register.connect(inputnode,'target_image', reg,'fixed_image')

Expand All @@ -531,6 +532,7 @@ def create_reg_workflow(name='registration'):
warpmean.inputs.terminal_output = 'file'
warpmean.inputs.args = '--float'
warpmean.inputs.num_threads = 4
warpmean.plugin_args = {'sbatch_args': '-c%d' % 4}

register.connect(inputnode,'target_image', warpmean,'reference_image')
register.connect(inputnode, 'mean_image', warpmean, 'input_image')
Expand All @@ -554,6 +556,8 @@ def create_reg_workflow(name='registration'):
register.connect(reg, 'composite_transform',
outputnode, 'anat2target_transform')
register.connect(merge, 'out', outputnode, 'transforms')
register.connect(bbregister, 'min_cost_file',
outputnode, 'min_cost_file')

return register

Expand Down Expand Up @@ -593,6 +597,7 @@ def create_workflow(files,
realign.inputs.slice_times = slice_times
realign.inputs.tr = TR
realign.inputs.slice_info = 2
realign.plugin_args = {'sbatch_args': '-c%d' % 4}


# Comute TSNR on realigned data regressing polynomials upto order 2
Expand All @@ -615,6 +620,13 @@ def create_workflow(files,
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
Expand Down Expand Up @@ -754,7 +766,8 @@ def merge_files(in1, in2):
warpall.inputs.terminal_output = 'file'
warpall.inputs.reference_image = target_file
warpall.inputs.args = '--float'
warpall.inputs.num_threads = 1
warpall.inputs.num_threads = 2
warpall.plugin_args = {'sbatch_args': '-c%d' % 2}

# transform to target
wf.connect(collector, 'out', warpall, 'input_image')
Expand Down Expand Up @@ -874,13 +887,14 @@ def get_names(files, suffix):
substitutions += [("_filtermotion%d" % i,"") for i in range(11)[::-1]]
substitutions += [("_filter_noise_nosmooth%d" % i,"") for i in range(11)[::-1]]
substitutions += [("_makecompcorfilter%d" % i,"") for i in range(11)[::-1]]
substitutions += [("_get_aparc_tsnr%d/" % i, "run%d_" % (i + 1)) for i in range(11)[::-1]]

substitutions += [("T1_out_brain_pve_0_maths_warped","compcor_csf"),
("T1_out_brain_pve_1_maths_warped","compcor_gm"),
substitutions += [("T1_out_brain_pve_0_maths_warped", "compcor_csf"),
("T1_out_brain_pve_1_maths_warped", "compcor_gm"),
("T1_out_brain_pve_2_maths_warped", "compcor_wm"),
("output_warped_image_maths","target_brain_mask"),
("median_brain_mask","native_brain_mask"),
("corr_","")]
("output_warped_image_maths", "target_brain_mask"),
("median_brain_mask", "native_brain_mask"),
("corr_", "")]

regex_subs = [('_combiner.*/sar', '/smooth/'),
('_combiner.*/ar', '/unsmooth/'),
Expand Down Expand Up @@ -910,6 +924,11 @@ def get_names(files, suffix):
wf.connect(filter1, 'out_pf', datasink, 'resting.qa.compmaps.@mc_pF')
wf.connect(filter2, 'out_f', datasink, 'resting.qa.compmaps')
wf.connect(filter2, 'out_pf', datasink, 'resting.qa.compmaps.@p')
wf.connect(registration, 'outputspec.min_cost_file', datasink, 'resting.qa.mincost')
wf.connect(tsnr, 'tsnr_file', datasink, 'resting.qa.tsnr.@map')
wf.connect([(get_roi_tsnr, datasink, [('avgwf_txt_file', 'resting.qa.tsnr'),
('summary_file', 'resting.qa.tsnr.@summary')])])

wf.connect(bandpass, 'out_files', datasink, 'resting.timeseries.@bandpassed')
wf.connect(smooth, 'out_file', datasink, 'resting.timeseries.@smoothed')
wf.connect(createfilter1, 'out_files',
Expand Down