Skip to content

Commit 94c5c43

Browse files
committed
Make DataSink config/space info into attributes.
1 parent 456685f commit 94c5c43

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

niworkflows/interfaces/bids.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,10 @@ class DerivativesDataSink(SimpleInterface):
498498
output_spec = _DerivativesDataSinkOutputSpec
499499
out_path_base = "niworkflows"
500500
_always_run = True
501-
_allowed_entities = set(BIDS_DERIV_ENTITIES)
501+
_config_entities = BIDS_DERIV_ENTITIES
502+
_allowed_entities = set(_config_entities)
503+
_standard_spaces = STANDARD_SPACES
504+
_file_patterns = BIDS_DERIV_PATTERNS
502505

503506
def __init__(self, allowed_entities=None, out_path_base=None, **inputs):
504507
"""Initialize the SimpleInterface and extend inputs with custom entities."""
@@ -585,7 +588,7 @@ def _run_interface(self, runtime):
585588
space = out_entities.get("space")
586589
if resolution:
587590
# Standard spaces
588-
if space in STANDARD_SPACES:
591+
if space in self._standard_spaces:
589592
res = _get_tf_resolution(space, resolution)
590593
else: # TODO: Nonstandard?
591594
res = "Unknown"
@@ -595,8 +598,8 @@ def _run_interface(self, runtime):
595598
out_entities["extension"] = out_entities["extension"][0]
596599

597600
# Insert custom (non-BIDS) entities from allowed_entities.
598-
custom_entities = set(out_entities.keys()) - set(BIDS_DERIV_ENTITIES)
599-
patterns = BIDS_DERIV_PATTERNS
601+
custom_entities = set(out_entities.keys()) - set(self._config_entities)
602+
patterns = self._file_patterns
600603
if custom_entities:
601604
# Example: f"{key}-{{{key}}}" -> "task-{task}"
602605
custom_pat = "_".join(f"{key}-{{{key}}}" for key in sorted(custom_entities))
@@ -667,7 +670,7 @@ def _run_interface(self, runtime):
667670
xcodes = (1, 1) # Derivative in its original scanner space
668671
if self.inputs.space:
669672
xcodes = (
670-
(4, 4) if self.inputs.space in STANDARD_SPACES else (2, 2)
673+
(4, 4) if self.inputs.space in self._standard_spaces else (2, 2)
671674
)
672675

673676
curr_zooms = zooms = hdr.get_zooms()

0 commit comments

Comments
 (0)