14
14
15
15
For example:
16
16
17
- python rsfmri_preprocessing.py -d /data/12345-34-1.dcm -f /data/Resting.nii -s subj001 -n 2 --despike -o output -p "plugin_args=dict(plugin='PBS', plugin_args=dict(qsub_args='-q many'))"
18
-
17
+ python rsfmri_preprocessing.py -d /data/12345-34-1.dcm -f /data/Resting.nii
18
+ -s subj001 -n 2 --despike -o output
19
+ -p "plugin_args=dict(plugin='PBS', plugin_args=dict(qsub_args='-q many'))"
19
20
"""
21
+
20
22
import os
21
23
22
24
from nipype import (ants , afni , fsl , freesurfer , nipy , Function , DataSink )
43
45
'from nipype.utils.filemanip import filename_to_list'
44
46
]
45
47
48
+
49
+ def get_info (dicom_files ):
50
+ """Given a Siemens dicom file return metadata
51
+
52
+ Returns
53
+ -------
54
+ RepetitionTime
55
+ Slice Acquisition Times
56
+ Spacing between slices
57
+ """
58
+ meta = default_extractor (read_file (filename_to_list (dicom_files )[0 ],
59
+ stop_before_pixels = True ,
60
+ force = True ))
61
+ return (meta ['RepetitionTime' ]/ 1000. , meta ['CsaImage.MosaicRefAcqTimes' ],
62
+ meta ['SpacingBetweenSlices' ])
63
+
64
+
46
65
def median (in_files ):
47
66
"""Computes an average of the median of each realigned timeseries
48
67
@@ -80,22 +99,6 @@ def get_aparc_aseg(files):
80
99
raise ValueError ('aparc+aseg.mgz not found' )
81
100
82
101
83
- def get_info (dicom_files ):
84
- """Given a Siemens dicom file return metadata
85
-
86
- Returns
87
- -------
88
- RepetitionTime
89
- Slice Acquisition Times
90
- Spacing between slices
91
- """
92
- meta = default_extractor (read_file (filename_to_list (dicom_files )[0 ],
93
- stop_before_pixels = True ,
94
- force = True ))
95
- return (meta ['RepetitionTime' ]/ 1000. , meta ['CsaImage.MosaicRefAcqTimes' ],
96
- meta ['SpacingBetweenSlices' ])
97
-
98
-
99
102
def motion_regressors (motion_params , order = 2 , derivatives = 2 ):
100
103
"""Compute motion regressors upto given order and derivative
101
104
@@ -273,14 +276,11 @@ def create_workflow(files,
273
276
wf .connect (remove_vol , 'roi_file' , despiker , 'in_file' )
274
277
275
278
# Run Nipy joint slice timing and realignment algorithm
276
- realign = Node (nipy .FmriRealign4d (), name = 'realign' )
279
+ realign = Node (nipy .SpaceTimeRealigner (), name = 'realign' )
277
280
realign .inputs .tr = TR
278
- realign .inputs .time_interp = True
279
- # FIX # dbg
280
- # This double argsort is necessary to convert slice order to space order
281
- # that's required by nipy realign currently. This will change in the next
282
- # release of Nipy.
283
- realign .inputs .slice_order = np .argsort (np .argsort (slice_times )).tolist ()
281
+ realign .inputs .slice_times = (np .array (slice_times )/ 1000. ).tolist ()
282
+ realign .inputs .slice_info = 2
283
+
284
284
if despike :
285
285
wf .connect (despiker , 'out_file' , realign , 'in_file' )
286
286
else :
@@ -671,6 +671,7 @@ def create_workflow(files,
671
671
Creates the full workflow including getting information from dicom files
672
672
"""
673
673
674
+
674
675
def create_resting_workflow (args ):
675
676
TR = args .TR
676
677
slice_times = args .slice_times
@@ -683,8 +684,8 @@ def create_resting_workflow(args):
683
684
img = load (args .files [0 ])
684
685
slice_thickness = max (img .get_header ().get_zooms ()[:3 ])
685
686
686
- kwargs = dict (files = [os .path .abspath (filename ) for
687
- filename in args .files ],
687
+ kwargs = dict (files = [os .path .abspath (filename ) for
688
+ filename in args .files ],
688
689
subject_id = args .subject_id ,
689
690
n_vol = args .n_vol ,
690
691
despike = args .despike ,
0 commit comments