Skip to content

Commit 328a8fd

Browse files
committed
Merge pull request #1088 from satra/fix/rsfmritsnr
Add QA output for TSNR of resting run
2 parents d12c3a3 + b9c7ebc commit 328a8fd

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Next release
5353
* ENH: Added csvReader() utility (https://github.com/nipy/nipype/pull/1044)
5454
* FIX: typo in nipype.interfaces.freesurfer.utils.py Tkregister2 (https://github.com/nipy/nipype/pull/1083)
5555
* FIX: SSHDataGrabber outputs now return full path to the grabbed/downloaded files. (https://github.com/nipy/nipype/pull/1086)
56+
* FIX: Add QA output for TSNR to resting workflow (https://github.com/nipy/nipype/pull/1088)
5657

5758
Release 0.10.0 (October 10, 2014)
5859
============

examples/rsfmri_vol_surface_preprocessing_nipy.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ def create_reg_workflow(name='registration'):
387387
'transformed_mean',
388388
'segmentation_files',
389389
'anat2target',
390-
'aparc'
390+
'aparc',
391+
'min_cost_file'
391392
]),
392393
name='outputspec')
393394

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

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

535537
register.connect(inputnode,'target_image', warpmean,'reference_image')
536538
register.connect(inputnode, 'mean_image', warpmean, 'input_image')
@@ -554,6 +556,8 @@ def create_reg_workflow(name='registration'):
554556
register.connect(reg, 'composite_transform',
555557
outputnode, 'anat2target_transform')
556558
register.connect(merge, 'out', outputnode, 'transforms')
559+
register.connect(bbregister, 'min_cost_file',
560+
outputnode, 'min_cost_file')
557561

558562
return register
559563

@@ -593,6 +597,7 @@ def create_workflow(files,
593597
realign.inputs.slice_times = slice_times
594598
realign.inputs.tr = TR
595599
realign.inputs.slice_info = 2
600+
realign.plugin_args = {'sbatch_args': '-c%d' % 4}
596601

597602

598603
# Comute TSNR on realigned data regressing polynomials upto order 2
@@ -615,6 +620,13 @@ def create_workflow(files,
615620
registration.inputs.inputspec.subjects_dir = subjects_dir
616621
registration.inputs.inputspec.target_image = target_file
617622

623+
"""Quantify TSNR in each freesurfer ROI
624+
"""
625+
get_roi_tsnr = MapNode(fs.SegStats(default_color_table=True),
626+
iterfield=['in_file'], name='get_aparc_tsnr')
627+
get_roi_tsnr.inputs.avgwf_txt_file = True
628+
wf.connect(tsnr, 'tsnr_file', get_roi_tsnr, 'in_file')
629+
wf.connect(registration, 'outputspec.aparc', get_roi_tsnr, 'segmentation_file')
618630

619631
"""Use :class:`nipype.algorithms.rapidart` to determine which of the
620632
images in the functional series are outliers based on deviations in
@@ -754,7 +766,8 @@ def merge_files(in1, in2):
754766
warpall.inputs.terminal_output = 'file'
755767
warpall.inputs.reference_image = target_file
756768
warpall.inputs.args = '--float'
757-
warpall.inputs.num_threads = 1
769+
warpall.inputs.num_threads = 2
770+
warpall.plugin_args = {'sbatch_args': '-c%d' % 2}
758771

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

878-
substitutions += [("T1_out_brain_pve_0_maths_warped","compcor_csf"),
879-
("T1_out_brain_pve_1_maths_warped","compcor_gm"),
892+
substitutions += [("T1_out_brain_pve_0_maths_warped", "compcor_csf"),
893+
("T1_out_brain_pve_1_maths_warped", "compcor_gm"),
880894
("T1_out_brain_pve_2_maths_warped", "compcor_wm"),
881-
("output_warped_image_maths","target_brain_mask"),
882-
("median_brain_mask","native_brain_mask"),
883-
("corr_","")]
895+
("output_warped_image_maths", "target_brain_mask"),
896+
("median_brain_mask", "native_brain_mask"),
897+
("corr_", "")]
884898

885899
regex_subs = [('_combiner.*/sar', '/smooth/'),
886900
('_combiner.*/ar', '/unsmooth/'),
@@ -910,6 +924,11 @@ def get_names(files, suffix):
910924
wf.connect(filter1, 'out_pf', datasink, 'resting.qa.compmaps.@mc_pF')
911925
wf.connect(filter2, 'out_f', datasink, 'resting.qa.compmaps')
912926
wf.connect(filter2, 'out_pf', datasink, 'resting.qa.compmaps.@p')
927+
wf.connect(registration, 'outputspec.min_cost_file', datasink, 'resting.qa.mincost')
928+
wf.connect(tsnr, 'tsnr_file', datasink, 'resting.qa.tsnr.@map')
929+
wf.connect([(get_roi_tsnr, datasink, [('avgwf_txt_file', 'resting.qa.tsnr'),
930+
('summary_file', 'resting.qa.tsnr.@summary')])])
931+
913932
wf.connect(bandpass, 'out_files', datasink, 'resting.timeseries.@bandpassed')
914933
wf.connect(smooth, 'out_file', datasink, 'resting.timeseries.@smoothed')
915934
wf.connect(createfilter1, 'out_files',

0 commit comments

Comments
 (0)