1
- def run_preAFQ (dwi_file , bvec_file , working_dir , sink_dir ):
1
+ def run_preAFQ (dwi_file , bvec_file , bval_file , working_dir , sink_dir ):
2
2
import nipype .interfaces .fsl as fsl
3
3
from nipype .interfaces .fsl .utils import AvScale
4
4
import nipype .pipeline .engine as pe
@@ -103,21 +103,29 @@ def rang(b):
103
103
104
104
datasink = pe .Node (nio .DataSink (),name = "sinker" )
105
105
datasink .inputs .base_directory = sink_dir
106
- datasink .inputs .substitutions = [("vol0000_flirt_merged.nii.gz" , dwi_filename + '_corrected.nii.gz' ),
107
- ("stats.vol0000_flirt_merged.txt" , dwi_filename + ".motion.txt" ),
108
- ("derivatives/dti" , "derivatives/{}/dti" .format (bids_subject_name ))]
106
+ datasink .inputs .substitutions = [("vol0000_flirt_merged.nii.gz" , dwi_filename + '.nii.gz' ),
107
+ ("stats.vol0000_flirt_merged.txt" , dwi_filename + ".art.json" ),
108
+ ("motion_parameters.par" , dwi_filename + ".motion.txt" ),
109
+ ("_rotated.bvec " , ".bvec" ),
110
+ ("derivatives/dwi" , "derivatives/{}/dwi" .format (bids_subject_name ))]
109
111
110
- wf .connect (art , "statistic_files" , datasink , "dti.@artstat" )
111
- wf .connect (outputspec , "dmri_corrected" , datasink , "dti.@corrected" )
112
- wf .connect (outputspec ,"bvec_rotated" , datasink , "dti.@rotated" )
112
+ wf .connect (art , "statistic_files" , datasink , "dwi.@artstat" )
113
+ wf .connect (outputspec , "dmri_corrected" , datasink , "dwi.@corrected" )
114
+ wf .connect (outputspec ,"bvec_rotated" , datasink , "dwi.@rotated" )
115
+ wf .connect (getmotion , "motion_params" , datasink , "dwi.@motion" )
113
116
114
117
wf .base_dir = working_dir
115
118
wf .run ()
116
119
117
120
from glob import glob
118
121
import os
122
+ from shutil import copyfile
123
+
124
+ copyfile (bval_file , os .path .join (sink_dir , bids_subject_name , "dwi" , os .path .split (bval_file )[1 ]))
119
125
120
- dmri_corrected = glob (os .path .join (sink_dir , 'dti' , '*.nii.gz' ))[0 ]
121
- bvec_rotated = glob (os .path .join (sink_dir , 'dti' , '*.bvec' ))[0 ]
122
- motion_outliers = glob (os .path .join (sink_dir , 'dti' , '*.txt' ))[0 ]
123
- return dmri_corrected , bvec_rotated , motion_outliers
126
+ dmri_corrected = glob (os .path .join (sink_dir , '*/dwi' , '*.nii.gz' ))[0 ]
127
+ bvec_rotated = glob (os .path .join (sink_dir , '*/dwi' , '*.bvec' ))[0 ]
128
+ bval_file = glob (os .path .join (sink_dir , '*/dwi' , '*.bval' ))[0 ]
129
+ art_file = glob (os .path .join (sink_dir , '*/dwi' , '*.art.json' ))[0 ]
130
+ motion_file = glob (os .path .join (sink_dir , '*/dwi' , '*.motion.txt' ))[0 ]
131
+ return dmri_corrected , bvec_rotated , art_file , motion_file
0 commit comments