12
12
BIDSInfo , BIDSFreeSurferDir
13
13
)
14
14
from niworkflows .utils .misc import fix_multi_T1w_source_name
15
+ from niworkflows .utils .spaces import Reference
15
16
from smriprep .workflows .anatomical import init_anat_preproc_wf
16
17
17
- from niworkflows .utils .spaces import Reference
18
18
from ..interfaces import DerivativesDataSink , BIDSDataGrabber
19
19
from ..interfaces .reports import SubjectSummary , AboutSummary
20
20
from ..utils .bids import collect_data
@@ -253,21 +253,28 @@ def init_single_subject_wf(subject_id):
253
253
anat_preproc_wf .__postdesc__ = (anat_preproc_wf .__postdesc__ or "" ) + f"""
254
254
Diffusion data preprocessing
255
255
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
+ """
258
261
259
262
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
+
260
268
inputnode = pe .Node (niu .IdentityInterface (fields = ["dwi_data" ]),
261
269
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
+
269
276
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 " ]),
271
278
name = "split_info" , run_without_submitting = True )
272
279
273
280
early_b0ref_wf = init_early_b0ref_wf ()
@@ -276,6 +283,13 @@ def init_single_subject_wf(subject_id):
276
283
(split_info , early_b0ref_wf , [("dwi_file" , "inputnode.dwi_file" ),
277
284
("bvec" , "inputnode.in_bvec" ),
278
285
("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
+ ]),
279
293
])
280
294
281
295
return workflow
0 commit comments