1212 BIDSInfo , BIDSFreeSurferDir
1313)
1414from niworkflows .utils .misc import fix_multi_T1w_source_name
15+ from niworkflows .utils .spaces import Reference
1516from smriprep .workflows .anatomical import init_anat_preproc_wf
1617
17- from niworkflows .utils .spaces import Reference
1818from ..interfaces import DerivativesDataSink , BIDSDataGrabber
1919from ..interfaces .reports import SubjectSummary , AboutSummary
2020from ..utils .bids import collect_data
@@ -253,21 +253,28 @@ def init_single_subject_wf(subject_id):
253253 anat_preproc_wf .__postdesc__ = (anat_preproc_wf .__postdesc__ or "" ) + f"""
254254Diffusion data preprocessing
255255
256- : For each of the { len (subject_data ["dwi" ])} dwi scans found per subject
257- (across all sessions), the following preprocessing was performed."""
256+ : For each of the { len (subject_data ["dwi" ])} DWI scans found per subject
257+ (across all sessions), the gradient table was vetted and converted into the *RASb*
258+ format (i.e., given in RAS+ scanner coordinates, normalized b-vectors and scaled b-values),
259+ and a *b=0* average for reference to the subsequent steps of preprocessing was calculated.
260+ """
258261
259262 layout = config .execution .layout
263+ dwi_data = tuple ([
264+ (dwi , layout .get_metadata (dwi ), layout .get_bvec (dwi ), layout .get_bval (dwi ))
265+ for dwi in subject_data ["dwi" ]
266+ ])
267+
260268 inputnode = pe .Node (niu .IdentityInterface (fields = ["dwi_data" ]),
261269 name = "inputnode" )
262- inputnode .iterables = [(
263- "dwi_data" , tuple ([
264- (dwi , layout .get_bvec (dwi ), layout .get_bval (dwi ),
265- layout .get_metadata (dwi )["PhaseEncodingDirection" ])
266- for dwi in subject_data ["dwi" ]
267- ])
268- )]
270+ inputnode .iterables = [("dwi_data" , dwi_data )]
271+
272+ referencenode = pe .JoinNode (niu .IdentityInterface (
273+ fields = ["dwi_file" , "metadata" , "dwi_reference" , "dwi_mask" , "gradients_rasb" ]),
274+ name = "referencenode" , joinsource = "inputnode" , run_without_submitting = True )
275+
269276 split_info = pe .Node (niu .Function (
270- function = _unpack , output_names = ["dwi_file" , "bvec " , "bval " , "pedir " ]),
277+ function = _unpack , output_names = ["dwi_file" , "metadata " , "bvec " , "bval " ]),
271278 name = "split_info" , run_without_submitting = True )
272279
273280 early_b0ref_wf = init_early_b0ref_wf ()
@@ -276,6 +283,13 @@ def init_single_subject_wf(subject_id):
276283 (split_info , early_b0ref_wf , [("dwi_file" , "inputnode.dwi_file" ),
277284 ("bvec" , "inputnode.in_bvec" ),
278285 ("bval" , "inputnode.in_bval" )]),
286+ (split_info , referencenode , [("dwi_file" , "dwi_file" ),
287+ ("metadata" , "metadata" )]),
288+ (early_b0ref_wf , referencenode , [
289+ ("outputnode.dwi_reference" , "dwi_reference" ),
290+ ("outputnode.dwi_mask" , "dwi_mask" ),
291+ ("outputnode.gradients_rasb" , "gradients_rasb" ),
292+ ]),
279293 ])
280294
281295 return workflow
0 commit comments