32
32
33
33
from nipype .interfaces import utility as niu
34
34
from nipype .pipeline import engine as pe
35
+ from niworkflows .interfaces .bids import PrepareDerivative , SaveDerivative
35
36
from niworkflows .utils .connections import listify
36
37
37
38
from ... import config
38
- from ...interfaces import DerivativesDataSink
39
39
from ...utils .bids import dismiss_echo
40
40
from ...utils .misc import estimate_bold_mem_usage
41
41
@@ -336,22 +336,34 @@ def init_bold_wf(
336
336
if multiecho :
337
337
t2s_reporting_wf = init_t2s_reporting_wf ()
338
338
339
- ds_report_t2scomp = pe .Node (
340
- DerivativesDataSink (
339
+ prep_report_t2scomp = pe .Node (
340
+ PrepareDerivative (
341
341
desc = 't2scomp' ,
342
342
datatype = 'figures' ,
343
343
dismiss_entities = dismiss_echo (),
344
344
),
345
+ name = 'prep_report_t2scomp' ,
346
+ run_without_submitting = True ,
347
+ )
348
+
349
+ ds_report_t2scomp = pe .Node (
350
+ SaveDerivative (),
345
351
name = 'ds_report_t2scomp' ,
346
352
run_without_submitting = True ,
347
353
)
348
354
349
- ds_report_t2star_hist = pe .Node (
350
- DerivativesDataSink (
355
+ prep_report_t2star_hist = pe .Node (
356
+ PrepareDerivative (
351
357
desc = 't2starhist' ,
352
358
datatype = 'figures' ,
353
359
dismiss_entities = dismiss_echo (),
354
360
),
361
+ name = 'prep_report_t2star_hist' ,
362
+ run_without_submitting = True ,
363
+ )
364
+
365
+ ds_report_t2star_hist = pe .Node (
366
+ SaveDerivative (),
355
367
name = 'ds_report_t2star_hist' ,
356
368
run_without_submitting = True ,
357
369
)
@@ -365,15 +377,24 @@ def init_bold_wf(
365
377
(bold_native_wf , t2s_reporting_wf , [
366
378
('outputnode.t2star_map' , 'inputnode.t2star_file' ),
367
379
]),
368
- (t2s_reporting_wf , ds_report_t2scomp , [('outputnode.t2s_comp_report' , 'in_file' )]),
369
- (t2s_reporting_wf , ds_report_t2star_hist , [('outputnode.t2star_hist' , 'in_file' )]),
380
+ (t2s_reporting_wf , prep_report_t2scomp , [('outputnode.t2s_comp_report' , 'in_file' )]),
381
+ (t2s_reporting_wf , prep_report_t2star_hist , [('outputnode.t2star_hist' , 'in_file' )]),
382
+ (prep_report_t2scomp , ds_report_t2scomp , [
383
+ ('out_file' , 'in_file' ),
384
+ ('out_path' , 'relative_path' ),
385
+ ]),
386
+ (prep_report_t2star_hist , ds_report_t2star_hist , [
387
+ ('out_file' , 'in_file' ),
388
+ ('out_path' , 'relative_path' ),
389
+ ]),
370
390
]) # fmt:skip
371
391
372
392
if config .workflow .level == 'resampling' :
373
393
# Fill-in datasinks of reportlets seen so far
374
394
for node in workflow .list_node_names ():
375
395
if node .split ('.' )[- 1 ].startswith ('ds_report' ):
376
396
workflow .get_node (node ).inputs .base_directory = fmriprep_dir
397
+ if node .split ('.' )[- 1 ].startswith ('prep_report' ):
377
398
workflow .get_node (node ).inputs .source_file = bold_file
378
399
return workflow
379
400
@@ -584,9 +605,8 @@ def init_bold_wf(
584
605
repetition_time = all_metadata [0 ]['RepetitionTime' ],
585
606
)
586
607
587
- ds_bold_cifti = pe .Node (
588
- DerivativesDataSink (
589
- base_directory = fmriprep_dir ,
608
+ prep_bold_cifti = pe .Node (
609
+ PrepareDerivative (
590
610
dismiss_entities = dismiss_echo (),
591
611
space = 'fsLR' ,
592
612
density = config .workflow .cifti_output ,
@@ -595,10 +615,15 @@ def init_bold_wf(
595
615
TaskName = all_metadata [0 ].get ('TaskName' ),
596
616
** prepare_timing_parameters (all_metadata [0 ]),
597
617
),
618
+ name = 'prep_bold_cifti' ,
619
+ )
620
+ prep_bold_cifti .inputs .source_file = bold_file
621
+
622
+ ds_bold_cifti = pe .Node (
623
+ SaveDerivative (base_directory = fmriprep_dir ),
598
624
name = 'ds_bold_cifti' ,
599
625
run_without_submitting = True ,
600
626
)
601
- ds_bold_cifti .inputs .source_file = bold_file
602
627
603
628
workflow .connect ([
604
629
# Resample BOLD to MNI152NLin6Asym, may duplicate bold_std_wf above
@@ -637,9 +662,14 @@ def init_bold_wf(
637
662
(bold_fsLR_resampling_wf , bold_grayords_wf , [
638
663
('outputnode.bold_fsLR' , 'inputnode.bold_fsLR' ),
639
664
]),
640
- (bold_grayords_wf , ds_bold_cifti , [
665
+ (bold_grayords_wf , prep_bold_cifti , [
641
666
('outputnode.cifti_bold' , 'in_file' ),
642
- (('outputnode.cifti_metadata' , _read_json ), 'meta_dict' ),
667
+ ('outputnode.cifti_metadata' , 'meta_dict' ),
668
+ ]),
669
+ (prep_bold_cifti , ds_bold_cifti , [
670
+ ('out_file' , 'in_file' ),
671
+ ('out_path' , 'relative_path' ),
672
+ ('out_meta' , 'metadata' ),
643
673
]),
644
674
]) # fmt:skip
645
675
@@ -653,18 +683,21 @@ def init_bold_wf(
653
683
name = 'bold_confounds_wf' ,
654
684
)
655
685
656
- ds_confounds = pe .Node (
657
- DerivativesDataSink (
658
- base_directory = fmriprep_dir ,
686
+ prepare_confounds = pe .Node (
687
+ PrepareDerivative (
659
688
desc = 'confounds' ,
660
689
suffix = 'timeseries' ,
661
690
dismiss_entities = dismiss_echo (),
662
691
),
692
+ name = 'prepare_confounds' ,
693
+ run_without_submitting = True ,
694
+ )
695
+ ds_confounds = pe .Node (
696
+ SaveDerivative (base_directory = fmriprep_dir ),
663
697
name = 'ds_confounds' ,
664
698
run_without_submitting = True ,
665
- mem_gb = config .DEFAULT_MEMORY_MIN_GB ,
666
699
)
667
- ds_confounds .inputs .source_file = bold_file
700
+ prepare_confounds .inputs .source_file = bold_file
668
701
669
702
workflow .connect ([
670
703
(inputnode , bold_confounds_wf , [
@@ -681,10 +714,15 @@ def init_bold_wf(
681
714
(bold_native_wf , bold_confounds_wf , [
682
715
('outputnode.bold_native' , 'inputnode.bold' ),
683
716
]),
684
- (bold_confounds_wf , ds_confounds , [
717
+ (bold_confounds_wf , prepare_confounds , [
685
718
('outputnode.confounds_file' , 'in_file' ),
686
719
('outputnode.confounds_metadata' , 'meta_dict' ),
687
720
]),
721
+ (prepare_confounds , ds_confounds , [
722
+ ('out_file' , 'in_file' ),
723
+ ('out_path' , 'relative_path' ),
724
+ ('out_meta' , 'metadata' ),
725
+ ]),
688
726
]) # fmt:skip
689
727
690
728
if spaces .get_spaces (nonstandard = False , dim = (3 ,)):
@@ -726,6 +764,7 @@ def _last(inlist):
726
764
for node in workflow .list_node_names ():
727
765
if node .split ('.' )[- 1 ].startswith ('ds_report' ):
728
766
workflow .get_node (node ).inputs .base_directory = fmriprep_dir
767
+ if node .split ('.' )[- 1 ].startswith ('prep_report' ):
729
768
workflow .get_node (node ).inputs .source_file = bold_file
730
769
731
770
return workflow
0 commit comments