Skip to content

Commit bbddb11

Browse files
committed
ENH: Allow inclusion of additional BIDS entities to outputs
1 parent 5c7f02b commit bbddb11

File tree

1 file changed

+42
-5
lines changed

1 file changed

+42
-5
lines changed

smriprep/workflows/outputs.py

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ def init_ds_mask_wf(
324324
*,
325325
bids_root: str,
326326
output_dir: str,
327-
mask_type: str,
327+
mask_type: ty.Literal['brain', 'roi'],
328+
extra_entities: dict | None = None,
328329
name='ds_mask_wf',
329330
):
330331
"""
@@ -336,6 +337,8 @@ def init_ds_mask_wf(
336337
Root path of BIDS dataset
337338
output_dir : :obj:`str`
338339
Directory in which to save derivatives
340+
extra_entities : :obj:`dict` or None
341+
Additional entities to add to filename
339342
name : :obj:`str`
340343
Workflow name (default: ds_mask_wf)
341344
@@ -363,12 +366,15 @@ def init_ds_mask_wf(
363366
raw_sources = pe.Node(niu.Function(function=_bids_relative), name='raw_sources')
364367
raw_sources.inputs.bids_root = bids_root
365368

369+
extra_entities = extra_entities or {}
370+
366371
ds_mask = pe.Node(
367372
DerivativesDataSink(
368373
base_directory=output_dir,
369374
desc=mask_type,
370375
suffix='mask',
371376
compress=True,
377+
**extra_entities,
372378
),
373379
name='ds_anat_mask',
374380
run_without_submitting=True,
@@ -391,14 +397,21 @@ def init_ds_mask_wf(
391397
return workflow
392398

393399

394-
def init_ds_dseg_wf(*, output_dir: str, name: str = 'ds_dseg_wf'):
400+
def init_ds_dseg_wf(
401+
*,
402+
output_dir: str,
403+
extra_entities: dict | None = None,
404+
name: str = 'ds_dseg_wf',
405+
):
395406
"""
396407
Save discrete segmentations
397408
398409
Parameters
399410
----------
400411
output_dir : :obj:`str`
401412
Directory in which to save derivatives
413+
extra_entities : :obj:`dict` or None
414+
Additional entities to add to filename
402415
name : :obj:`str`
403416
Workflow name (default: ds_dseg_wf)
404417
@@ -423,12 +436,15 @@ def init_ds_dseg_wf(*, output_dir: str, name: str = 'ds_dseg_wf'):
423436
)
424437
outputnode = pe.Node(niu.IdentityInterface(fields=['anat_dseg']), name='outputnode')
425438

439+
extra_entities = extra_entities or {}
440+
426441
ds_anat_dseg = pe.Node(
427442
DerivativesDataSink(
428443
base_directory=output_dir,
429444
suffix='dseg',
430445
compress=True,
431446
dismiss_entities=['desc'],
447+
**extra_entities,
432448
),
433449
name='ds_anat_dseg',
434450
run_without_submitting=True,
@@ -448,6 +464,7 @@ def init_ds_dseg_wf(*, output_dir: str, name: str = 'ds_dseg_wf'):
448464
def init_ds_tpms_wf(
449465
*,
450466
output_dir: str,
467+
extra_entities: dict | None = None,
451468
name: str = 'ds_tpms_wf',
452469
tpm_labels: tuple = BIDS_TISSUE_ORDER,
453470
):
@@ -458,6 +475,8 @@ def init_ds_tpms_wf(
458475
----------
459476
output_dir : :obj:`str`
460477
Directory in which to save derivatives
478+
extra_entities : :obj:`dict` or None
479+
Additional entities to add to filename
461480
name : :obj:`str`
462481
Workflow name (default: anat_derivatives_wf)
463482
tpm_labels : :obj:`tuple`
@@ -484,12 +503,15 @@ def init_ds_tpms_wf(
484503
)
485504
outputnode = pe.Node(niu.IdentityInterface(fields=['anat_tpms']), name='outputnode')
486505

506+
extra_entities = extra_entities or {}
507+
487508
ds_anat_tpms = pe.Node(
488509
DerivativesDataSink(
489510
base_directory=output_dir,
490511
suffix='probseg',
491512
compress=True,
492513
dismiss_entities=['desc'],
514+
**extra_entities,
493515
),
494516
name='ds_anat_tpms',
495517
run_without_submitting=True,
@@ -907,7 +929,7 @@ def init_ds_anat_volumes_wf(
907929
inputnode = pe.Node(
908930
niu.IdentityInterface(
909931
fields=[
910-
# Original T1w image
932+
# Original anat image
911933
'source_files',
912934
# anat-space images
913935
'anat_preproc',
@@ -1036,6 +1058,7 @@ def init_ds_fs_segs_wf(
10361058
*,
10371059
bids_root: str,
10381060
output_dir: str,
1061+
extra_entities: dict | None = None,
10391062
name='ds_fs_segs_wf',
10401063
):
10411064
"""
@@ -1047,6 +1070,8 @@ def init_ds_fs_segs_wf(
10471070
Root path of BIDS dataset
10481071
output_dir : :obj:`str`
10491072
Directory in which to save derivatives
1073+
extra_entities : :obj:`dict` or None
1074+
Additional entities to add to filename
10501075
name : :obj:`str`
10511076
Workflow name (default: ds_anat_segs_wf)
10521077
@@ -1075,15 +1100,27 @@ def init_ds_fs_segs_wf(
10751100
raw_sources = pe.Node(niu.Function(function=_bids_relative), name='raw_sources')
10761101
raw_sources.inputs.bids_root = bids_root
10771102

1103+
extra_entities = extra_entities or {}
1104+
10781105
# Parcellations
10791106
ds_anat_fsaseg = pe.Node(
1080-
DerivativesDataSink(base_directory=output_dir, desc='aseg', suffix='dseg', compress=True),
1107+
DerivativesDataSink(
1108+
base_directory=output_dir,
1109+
desc='aseg',
1110+
suffix='dseg',
1111+
compress=True,
1112+
**extra_entities,
1113+
),
10811114
name='ds_anat_fsaseg',
10821115
run_without_submitting=True,
10831116
)
10841117
ds_anat_fsparc = pe.Node(
10851118
DerivativesDataSink(
1086-
base_directory=output_dir, desc='aparcaseg', suffix='dseg', compress=True
1119+
base_directory=output_dir,
1120+
desc='aparcaseg',
1121+
suffix='dseg',
1122+
compress=True,
1123+
**extra_entities,
10871124
),
10881125
name='ds_anat_fsparc',
10891126
run_without_submitting=True,

0 commit comments

Comments
 (0)