-
Notifications
You must be signed in to change notification settings - Fork 21
/
execsummary.py
815 lines (707 loc) · 24.3 KB
/
execsummary.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""Workflows for generating the executive summary."""
import fnmatch
import os
from nipype import Function, logging
from nipype.interfaces import fsl
from nipype.interfaces import utility as niu
from nipype.pipeline import engine as pe
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
from xcp_d import config
from xcp_d.data import load as load_data
from xcp_d.interfaces.bids import DerivativesDataSink
from xcp_d.interfaces.execsummary import FormatForBrainSwipes
from xcp_d.interfaces.nilearn import BinaryMath, ResampleToImage
from xcp_d.interfaces.plotting import AnatomicalPlot, PNGAppend
from xcp_d.interfaces.workbench import ShowScene
from xcp_d.utils.doc import fill_doc
from xcp_d.utils.execsummary import (
get_n_frames,
get_png_image_names,
make_mosaic,
modify_brainsprite_scene_template,
modify_pngs_scene_template,
)
LOGGER = logging.getLogger("nipype.workflow")
@fill_doc
def init_brainsprite_figures_wf(t1w_available, t2w_available, name="brainsprite_figures_wf"):
"""Create mosaic and PNG files for executive summary brainsprite.
Workflow Graph
.. workflow::
:graph2use: orig
:simple_form: yes
from xcp_d.tests.tests import mock_config
from xcp_d import config
from xcp_d.workflows.execsummary import init_brainsprite_figures_wf
with mock_config():
wf = init_brainsprite_figures_wf(
t1w_available=True,
t2w_available=True,
name="brainsprite_figures_wf",
)
Parameters
----------
t1w_available : bool
True if a T1w image is available.
t2w_available : bool
True if a T2w image is available.
%(name)s
Default is "init_brainsprite_figures_wf".
Inputs
------
t1w
Path to T1w image. Optional. Should only be defined if ``t1w_available`` is True.
t2w
Path to T2w image. Optional. Should only be defined if ``t2w_available`` is True.
lh_wm_surf
rh_wm_surf
lh_pial_surf
rh_pial_surf
"""
workflow = Workflow(name=name)
output_dir = config.execution.xcp_d_dir
omp_nthreads = config.nipype.omp_nthreads
inputnode = pe.Node(
niu.IdentityInterface(
fields=[
"t1w",
"t2w",
"lh_wm_surf",
"rh_wm_surf",
"lh_pial_surf",
"rh_pial_surf",
],
),
name="inputnode",
)
# Load template scene file
brainsprite_scene_template = str(
load_data("executive_summary_scenes/brainsprite_template.scene.gz")
)
pngs_scene_template = str(load_data("executive_summary_scenes/pngs_template.scene.gz"))
if t1w_available and t2w_available:
image_types = ["T1", "T2"]
elif t2w_available:
image_types = ["T2"]
else:
image_types = ["T1"]
for image_type in image_types:
inputnode_anat_name = f"{image_type.lower()}w"
# Create frame-wise PNGs
get_number_of_frames = pe.Node(
Function(
function=get_n_frames,
input_names=["anat_file"],
output_names=["frame_numbers"],
),
name=f"get_number_of_frames_{image_type}",
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
omp_nthreads=omp_nthreads,
)
# fmt:off
workflow.connect([
(inputnode, get_number_of_frames, [(inputnode_anat_name, "anat_file")]),
])
# fmt:on
# Modify template scene file with file paths
modify_brainsprite_template_scene = pe.MapNode(
Function(
function=modify_brainsprite_scene_template,
input_names=[
"slice_number",
"anat_file",
"rh_pial_surf",
"lh_pial_surf",
"rh_wm_surf",
"lh_wm_surf",
"scene_template",
],
output_names=["out_file"],
),
name=f"modify_brainsprite_template_scene_{image_type}",
iterfield=["slice_number"],
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
omp_nthreads=omp_nthreads,
)
modify_brainsprite_template_scene.inputs.scene_template = brainsprite_scene_template
# fmt:off
workflow.connect([
(inputnode, modify_brainsprite_template_scene, [
(inputnode_anat_name, "anat_file"),
("lh_wm_surf", "lh_wm_surf"),
("rh_wm_surf", "rh_wm_surf"),
("lh_pial_surf", "lh_pial_surf"),
("rh_pial_surf", "rh_pial_surf"),
]),
(get_number_of_frames, modify_brainsprite_template_scene, [
("frame_numbers", "slice_number"),
]),
])
# fmt:on
create_framewise_pngs = pe.MapNode(
ShowScene(
scene_name_or_number=1,
image_width=900,
image_height=800,
),
name=f"create_framewise_pngs_{image_type}",
iterfield=["scene_file"],
mem_gb=1,
omp_nthreads=omp_nthreads,
)
# fmt:off
workflow.connect([
(modify_brainsprite_template_scene, create_framewise_pngs, [
("out_file", "scene_file"),
]),
])
# fmt:on
# Make mosaic
make_mosaic_node = pe.Node(
Function(
function=make_mosaic,
input_names=["png_files"],
output_names=["mosaic_file"],
),
name=f"make_mosaic_{image_type}",
mem_gb=1,
omp_nthreads=omp_nthreads,
)
workflow.connect([(create_framewise_pngs, make_mosaic_node, [("out_file", "png_files")])])
ds_mosaic_file = pe.Node(
DerivativesDataSink(
base_directory=output_dir,
dismiss_entities=["desc"],
desc="mosaic",
datatype="figures",
suffix=f"{image_type}w",
),
name=f"ds_mosaic_file_{image_type}",
run_without_submitting=False,
)
# fmt:off
workflow.connect([
(inputnode, ds_mosaic_file, [(inputnode_anat_name, "source_file")]),
(make_mosaic_node, ds_mosaic_file, [("mosaic_file", "in_file")]),
])
# fmt:on
# Start working on the selected PNG images for the button
modify_pngs_template_scene = pe.Node(
Function(
function=modify_pngs_scene_template,
input_names=[
"anat_file",
"rh_pial_surf",
"lh_pial_surf",
"rh_wm_surf",
"lh_wm_surf",
"scene_template",
],
output_names=["out_file"],
),
name=f"modify_pngs_template_scene_{image_type}",
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
omp_nthreads=omp_nthreads,
)
modify_pngs_template_scene.inputs.scene_template = pngs_scene_template
# fmt:off
workflow.connect([
(inputnode, modify_pngs_template_scene, [
(inputnode_anat_name, "anat_file"),
("lh_wm_surf", "lh_wm_surf"),
("rh_wm_surf", "rh_wm_surf"),
("lh_pial_surf", "lh_pial_surf"),
("rh_pial_surf", "rh_pial_surf"),
])
])
# fmt:on
# Create specific PNGs for button
get_png_scene_names = pe.Node(
Function(
function=get_png_image_names,
output_names=["scene_index", "scene_descriptions"],
),
name=f"get_png_scene_names_{image_type}",
)
create_scenewise_pngs = pe.MapNode(
ShowScene(image_width=900, image_height=800),
name=f"create_scenewise_pngs_{image_type}",
iterfield=["scene_name_or_number"],
mem_gb=1,
omp_nthreads=omp_nthreads,
)
# fmt:off
workflow.connect([
(modify_pngs_template_scene, create_scenewise_pngs, [("out_file", "scene_file")]),
(get_png_scene_names, create_scenewise_pngs, [
("scene_index", "scene_name_or_number"),
]),
])
# fmt:on
ds_scenewise_pngs = pe.MapNode(
DerivativesDataSink(
base_directory=output_dir,
dismiss_entities=["desc"],
datatype="figures",
suffix=f"{image_type}w",
),
name=f"ds_scenewise_pngs_{image_type}",
run_without_submitting=False,
iterfield=["desc", "in_file"],
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
)
# fmt:off
workflow.connect([
(inputnode, ds_scenewise_pngs, [(inputnode_anat_name, "source_file")]),
(get_png_scene_names, ds_scenewise_pngs, [("scene_descriptions", "desc")]),
(create_scenewise_pngs, ds_scenewise_pngs, [("out_file", "in_file")]),
])
# fmt:on
return workflow
@fill_doc
def init_execsummary_functional_plots_wf(
preproc_nifti,
t1w_available,
t2w_available,
mem_gb,
name="execsummary_functional_plots_wf",
):
"""Generate the functional figures for an executive summary.
Workflow Graph
.. workflow::
:graph2use: orig
:simple_form: yes
from xcp_d.tests.tests import mock_config
from xcp_d import config
from xcp_d.workflows.execsummary import init_execsummary_functional_plots_wf
with mock_config():
wf = init_execsummary_functional_plots_wf(
preproc_nifti=None,
t1w_available=True,
t2w_available=True,
mem_gb={"resampled": 1},
name="execsummary_functional_plots_wf",
)
Parameters
----------
preproc_nifti : :obj:`str` or None
BOLD data before post-processing.
A NIFTI file, not a CIFTI.
t1w_available : :obj:`bool`
Generally True.
t2w_available : :obj:`bool`
Generally False.
mem_gb : :obj:`dict`
Memory size in GB.
%(name)s
Inputs
------
preproc_nifti
BOLD data before post-processing.
A NIFTI file, not a CIFTI.
Set from the parameter.
%(boldref)s
t1w
T1w image in a standard space, taken from the output of init_postprocess_anat_wf.
t2w
T2w image in a standard space, taken from the output of init_postprocess_anat_wf.
"""
workflow = Workflow(name=name)
output_dir = config.execution.xcp_d_dir
layout = config.execution.layout
inputnode = pe.Node(
niu.IdentityInterface(
fields=[
"preproc_nifti",
"boldref", # a nifti boldref
"t1w",
"t2w", # optional
],
),
name="inputnode",
)
if not preproc_nifti:
raise ValueError(
"No preprocessed NIfTI found. Executive summary figures cannot be generated."
)
inputnode.inputs.preproc_nifti = preproc_nifti
# Get bb_registration_file prefix from fmriprep
# TODO: Replace with interfaces.
current_bold_file = os.path.basename(preproc_nifti)
if "_space" in current_bold_file:
bb_register_prefix = current_bold_file.split("_space")[0]
else:
bb_register_prefix = current_bold_file.split("_desc")[0]
# TODO: Switch to interface
bold_t1w_registration_files = layout.get(
desc=["bbregister", "coreg", "bbr", "flirtbbr", "flirtnobbr"],
extension=".svg",
suffix="bold",
return_type="file",
)
bold_t1w_registration_files = fnmatch.filter(
bold_t1w_registration_files,
f"*/{bb_register_prefix}*",
)
if not bold_t1w_registration_files:
LOGGER.warning("No coregistration figure found in preprocessing derivatives.")
else:
bold_t1w_registration_file = bold_t1w_registration_files[0]
ds_registration_figure = pe.Node(
DerivativesDataSink(
base_directory=output_dir,
in_file=bold_t1w_registration_file,
dismiss_entities=["den"],
datatype="figures",
desc="bbregister",
),
name="ds_registration_figure",
run_without_submitting=True,
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
)
workflow.connect([(inputnode, ds_registration_figure, [("preproc_nifti", "source_file")])])
# Calculate the mean bold image
calculate_mean_bold = pe.Node(
BinaryMath(expression="np.mean(img, axis=3)"),
name="calculate_mean_bold",
mem_gb=mem_gb["timeseries"],
)
workflow.connect([(inputnode, calculate_mean_bold, [("preproc_nifti", "in_file")])])
# Plot the mean bold image
plot_meanbold = pe.Node(AnatomicalPlot(), name="plot_meanbold")
workflow.connect([(calculate_mean_bold, plot_meanbold, [("out_file", "in_file")])])
# Write out the figures.
ds_meanbold_figure = pe.Node(
DerivativesDataSink(
base_directory=output_dir,
dismiss_entities=["den"],
datatype="figures",
desc="mean",
),
name="ds_meanbold_figure",
run_without_submitting=True,
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
)
# fmt:off
workflow.connect([
(inputnode, ds_meanbold_figure, [("preproc_nifti", "source_file")]),
(plot_meanbold, ds_meanbold_figure, [("out_file", "in_file")]),
])
# fmt:on
# Plot the reference bold image
plot_boldref = pe.Node(AnatomicalPlot(), name="plot_boldref")
workflow.connect([(inputnode, plot_boldref, [("boldref", "in_file")])])
# Write out the figures.
ds_boldref_figure = pe.Node(
DerivativesDataSink(
base_directory=output_dir,
dismiss_entities=["den"],
datatype="figures",
desc="boldref",
),
name="ds_boldref_figure",
run_without_submitting=True,
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
)
# fmt:off
workflow.connect([
(inputnode, ds_boldref_figure, [("preproc_nifti", "source_file")]),
(plot_boldref, ds_boldref_figure, [("out_file", "in_file")]),
])
# fmt:on
# Start plotting the overlay figures
# T1 in Task, Task in T1, Task in T2, T2 in Task
anatomicals = (["t1w"] if t1w_available else []) + (["t2w"] if t2w_available else [])
for anat in anatomicals:
# Resample BOLD to match resolution of T1w/T2w data
resample_bold_to_anat = pe.Node(
ResampleToImage(),
name=f"resample_bold_to_{anat}",
mem_gb=mem_gb["resampled"],
)
# fmt:off
workflow.connect([
(inputnode, resample_bold_to_anat, [(anat, "target_file")]),
(calculate_mean_bold, resample_bold_to_anat, [("out_file", "in_file")]),
])
# fmt:on
plot_anat_on_task_wf = init_plot_overlay_wf(
desc=f"{anat[0].upper()}{anat[1:]}OnTask",
name=f"plot_{anat}_on_task_wf",
)
# fmt:off
workflow.connect([
(inputnode, plot_anat_on_task_wf, [
("preproc_nifti", "inputnode.name_source"),
(anat, "inputnode.overlay_file"),
]),
(resample_bold_to_anat, plot_anat_on_task_wf, [
("out_file", "inputnode.underlay_file"),
]),
])
# fmt:on
plot_task_on_anat_wf = init_plot_overlay_wf(
desc=f"TaskOn{anat[0].upper()}{anat[1:]}",
name=f"plot_task_on_{anat}_wf",
)
# fmt:off
workflow.connect([
(inputnode, plot_task_on_anat_wf, [
("preproc_nifti", "inputnode.name_source"),
(anat, "inputnode.underlay_file"),
]),
(resample_bold_to_anat, plot_task_on_anat_wf, [
("out_file", "inputnode.overlay_file"),
]),
])
# fmt:on
return workflow
@fill_doc
def init_execsummary_anatomical_plots_wf(
t1w_available,
t2w_available,
name="execsummary_anatomical_plots_wf",
):
"""Generate the anatomical figures for an executive summary.
Workflow Graph
.. workflow::
:graph2use: orig
:simple_form: yes
from xcp_d.tests.tests import mock_config
from xcp_d import config
from xcp_d.workflows.execsummary import init_execsummary_anatomical_plots_wf
with mock_config():
wf = init_execsummary_anatomical_plots_wf(
t1w_available=True,
t2w_available=True,
)
Parameters
----------
t1w_available : bool
Generally True.
t2w_available : bool
Generally False.
%(name)s
Inputs
------
t1w
T1w image, after warping to standard space.
t2w
T2w image, after warping to standard space.
template
"""
workflow = Workflow(name=name)
inputnode = pe.Node(
niu.IdentityInterface(
fields=[
"t1w",
"t2w",
"template",
],
),
name="inputnode",
)
# Start plotting the overlay figures
# Atlas in T1w/T2w, T1w/T2w in Atlas
anatomicals = (["t1w"] if t1w_available else []) + (["t2w"] if t2w_available else [])
for anat in anatomicals:
# Resample anatomical to match resolution of template data
resample_anat = pe.Node(
ResampleToImage(),
name=f"resample_{anat}",
mem_gb=1,
)
# fmt:off
workflow.connect([
(inputnode, resample_anat, [
(anat, "in_file"),
("template", "target_file"),
]),
])
# fmt:on
plot_anat_on_atlas_wf = init_plot_overlay_wf(
desc="AnatOnAtlas",
name=f"plot_{anat}_on_atlas_wf",
)
# fmt:off
workflow.connect([
(inputnode, plot_anat_on_atlas_wf, [
("template", "inputnode.underlay_file"),
(anat, "inputnode.name_source"),
]),
(resample_anat, plot_anat_on_atlas_wf, [("out_file", "inputnode.overlay_file")]),
])
# fmt:on
plot_atlas_on_anat_wf = init_plot_overlay_wf(
desc="AtlasOnAnat",
name=f"plot_atlas_on_{anat}_wf",
)
# fmt:off
workflow.connect([
(inputnode, plot_atlas_on_anat_wf, [
("template", "inputnode.overlay_file"),
(anat, "inputnode.name_source"),
]),
(resample_anat, plot_atlas_on_anat_wf, [("out_file", "inputnode.underlay_file")]),
])
# fmt:on
# TODO: Add subcortical overlay images as well.
# 1. Binarize atlas.
return workflow
@fill_doc
def init_plot_custom_slices_wf(
output_dir,
desc,
name="plot_custom_slices_wf",
):
"""Plot a custom selection of slices with Slicer.
This workflow is used to produce subcortical registration plots specifically for
infant data.
Workflow Graph
.. workflow::
:graph2use: orig
:simple_form: yes
from xcp_d.workflows.execsummary import init_plot_custom_slices_wf
wf = init_plot_custom_slices_wf(
output_dir=".",
desc="AtlasOnSubcorticals",
name="plot_custom_slices_wf",
)
Parameters
----------
%(output_dir)s
desc : :obj:`str`
String to be used as ``desc`` entity in output filename.
%(name)s
Default is "plot_custom_slices_wf".
Inputs
------
underlay_file
overlay_file
name_source
"""
# NOTE: These slices are almost certainly specific to a given MNI template and resolution.
SINGLE_SLICES = ["x", "x", "x", "y", "y", "y", "z", "z", "z"]
SLICE_NUMBERS = [36, 45, 52, 43, 54, 65, 23, 33, 39]
workflow = Workflow(name=name)
inputnode = pe.Node(
niu.IdentityInterface(
fields=[
"underlay_file",
"overlay_file",
"name_source",
],
),
name="inputnode",
)
# slices/slicer does not do well trying to make the red outline when it
# cannot find the edges, so cannot use the ROI files with some low intensities.
binarize_edges = pe.Node(
BinaryMath(expression="img.astype(bool).astype(int)"),
name="binarize_edges",
mem_gb=1,
)
workflow.connect([(inputnode, binarize_edges, [("overlay_file", "in_file")])])
make_image = pe.MapNode(
fsl.Slicer(show_orientation=True, label_slices=True),
name="make_image",
iterfield=["single_slice", "slice_number"],
mem_gb=1,
)
make_image.inputs.single_slice = SINGLE_SLICES
make_image.inputs.slice_number = SLICE_NUMBERS
# fmt:off
workflow.connect([
(inputnode, make_image, [("underlay_file", "in_file")]),
(binarize_edges, make_image, [("out_file", "image_edges")]),
])
# fmt:on
combine_images = pe.Node(
PNGAppend(out_file="out.png"),
name="combine_images",
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
)
workflow.connect([(make_image, combine_images, [("out_file", "in_files")])])
ds_overlay_figure = pe.Node(
DerivativesDataSink(
base_directory=output_dir,
dismiss_entities=["den"],
datatype="figures",
desc=desc,
extension=".png",
),
name="ds_overlay_figure",
run_without_submitting=True,
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
)
# fmt:off
workflow.connect([
(inputnode, ds_overlay_figure, [("name_source", "source_file")]),
(combine_images, ds_overlay_figure, [("out_file", "in_file")]),
])
# fmt:on
return workflow
def init_plot_overlay_wf(desc, name="plot_overlay_wf"):
"""Use the default slices from slicesdir to make a plot."""
from xcp_d.interfaces.plotting import SlicesDir
workflow = Workflow(name=name)
output_dir = config.execution.xcp_d_dir
inputnode = pe.Node(
niu.IdentityInterface(
fields=[
"underlay_file",
"overlay_file",
"name_source",
],
),
name="inputnode",
)
plot_overlay_figure = pe.Node(
SlicesDir(out_extension=".png"),
name="plot_overlay_figure",
mem_gb=1,
)
workflow.connect([
(inputnode, plot_overlay_figure, [
("underlay_file", "in_files"),
("overlay_file", "outline_image"),
]),
]) # fmt:skip
ds_overlay_figure = pe.Node(
DerivativesDataSink(
base_directory=output_dir,
dismiss_entities=["den"],
datatype="figures",
desc=desc,
extension=".png",
),
name="ds_overlay_figure",
run_without_submitting=True,
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
)
workflow.connect([
(inputnode, ds_overlay_figure, [("name_source", "source_file")]),
(plot_overlay_figure, ds_overlay_figure, [("out_files", "in_file")]),
]) # fmt:skip
reformat_for_brain_swipes = pe.Node(FormatForBrainSwipes(), name="reformat_for_brain_swipes")
workflow.connect([
(plot_overlay_figure, reformat_for_brain_swipes, [("slicewise_files", "in_files")]),
]) # fmt:skip
ds_reformatted_figure = pe.Node(
DerivativesDataSink(
base_directory=output_dir,
dismiss_entities=["den"],
datatype="figures",
desc=f"{desc}BrainSwipes",
extension=".png",
),
name="ds_reformatted_figure",
run_without_submitting=True,
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
)
workflow.connect([
(inputnode, ds_reformatted_figure, [("name_source", "source_file")]),
(reformat_for_brain_swipes, ds_reformatted_figure, [("out_file", "in_file")]),
]) # fmt:skip
return workflow