22
22
from nipype .pipeline import engine as pe
23
23
from nipype .interfaces import utility as niu , fsl
24
24
from niworkflows .engine .workflows import LiterateWorkflow as Workflow
25
- from niworkflows .interfaces import itk
26
25
from niworkflows .interfaces .images import IntraModalMerge
27
26
from niworkflows .interfaces .registration import ANTSApplyTransformsRPT , ANTSRegistrationRPT
28
27
29
- from ..interfaces .fmap import get_ees as _get_ees , FieldToRadS
28
+ from ..interfaces .fmap import get_ees as _get_ees , FieldToRadS , FUGUEvsm2ANTSwarp
30
29
from .gre import init_fmap_postproc_wf , init_magnitude_wf
31
30
32
31
@@ -111,7 +110,8 @@ def init_fmap_wf(omp_nthreads, fmap_bspline, name='fmap_wf'):
111
110
return workflow
112
111
113
112
114
- def init_fmap2field_wf (omp_nthreads , debug , name = 'fmap2field_wf' ):
113
+ def init_fmap2field_wf (omp_nthreads , debug , name = 'fmap2field_wf' ,
114
+ generate_report = True ):
115
115
"""
116
116
Convert the estimated fieldmap in Hz into a displacements field.
117
117
@@ -187,13 +187,13 @@ def init_fmap2field_wf(omp_nthreads, debug, name='fmap2field_wf'):
187
187
'sdcflows' , 'data/fmap-any_registration_testing.json' )
188
188
189
189
fmap2ref_reg = pe .Node (
190
- ANTSRegistrationRPT (generate_report = True , from_file = ants_settings ,
190
+ ANTSRegistrationRPT (generate_report = False , from_file = ants_settings ,
191
191
output_inverse_warped_image = True , output_warped_image = True ),
192
192
name = 'fmap2ref_reg' , n_procs = omp_nthreads )
193
193
194
194
# Map the VSM into the EPI space
195
195
fmap2ref_apply = pe .Node (ANTSApplyTransformsRPT (
196
- generate_report = True , dimension = 3 , interpolation = 'BSpline' , float = True ),
196
+ generate_report = False , dimension = 3 , interpolation = 'BSpline' , float = True ),
197
197
name = 'fmap2ref_apply' )
198
198
199
199
fmap_mask2ref_apply = pe .Node (ANTSApplyTransformsRPT (
@@ -209,7 +209,7 @@ def init_fmap2field_wf(omp_nthreads, debug, name='fmap2field_wf'):
209
209
gen_vsm = pe .Node (fsl .FUGUE (save_unmasked_shift = True ), name = 'gen_vsm' )
210
210
# Convert the VSM into a DFM (displacements field map)
211
211
# or: FUGUE shift to ANTS warping.
212
- vsm2dfm = pe .Node (itk . FUGUEvsm2ANTSwarp (), name = 'vsm2dfm' )
212
+ vsm2dfm = pe .Node (FUGUEvsm2ANTSwarp (), name = 'vsm2dfm' )
213
213
214
214
workflow .connect ([
215
215
(inputnode , fmap2ref_reg , [('fmap_ref' , 'moving_image' ),
@@ -228,11 +228,32 @@ def init_fmap2field_wf(omp_nthreads, debug, name='fmap2field_wf'):
228
228
('composite_transform' , 'transforms' )]),
229
229
(fmap2ref_apply , torads , [('output_image' , 'in_file' )]),
230
230
(fmap_mask2ref_apply , gen_vsm , [('output_image' , 'mask_file' )]),
231
- (get_ees , gen_vsm , [('ees' , 'dwell_time' )]),
232
231
(gen_vsm , vsm2dfm , [('shift_out_file' , 'in_file' )]),
232
+ (get_ees , gen_vsm , [('ees' , 'dwell_time' )]),
233
233
(torads , gen_vsm , [('out_file' , 'fmap_in_file' )]),
234
234
(vsm2dfm , outputnode , [('out_file' , 'out_warp' )]),
235
235
])
236
+
237
+ if generate_report :
238
+ from niworkflows .interfaces .bids import DerivativesDataSink
239
+ from ..interfaces .reportlets import FieldmapReportlet
240
+
241
+ fmap_rpt = pe .Node (FieldmapReportlet (
242
+ reference_label = 'EPI Reference' ,
243
+ moving_label = 'Magnitude' , show = 'both' ), name = 'fmap_rpt' )
244
+ ds_report_sdc = pe .Node (
245
+ DerivativesDataSink (desc = 'fieldmap' , suffix = 'bold' ),
246
+ name = 'ds_report_fmap' , mem_gb = 0.01 , run_without_submitting = True
247
+ )
248
+
249
+ workflow .connect ([
250
+ (inputnode , fmap_rpt , [('in_reference' , 'reference' )]),
251
+ (fmap2ref_reg , fmap_rpt , [('warped_image' , 'moving' )]),
252
+ (fmap_mask2ref_apply , fmap_rpt , [('output_image' , 'mask' )]),
253
+ (vsm2dfm , fmap_rpt , [('fieldmap' , 'fieldmap' )]),
254
+ (fmap_rpt , ds_report_sdc , [('out_report' , 'in_file' )]),
255
+ ])
256
+
236
257
return workflow
237
258
238
259
0 commit comments