@@ -498,12 +498,15 @@ class DerivativesDataSink(SimpleInterface):
498
498
output_spec = _DerivativesDataSinkOutputSpec
499
499
out_path_base = "niworkflows"
500
500
_always_run = True
501
- _allowed_entities = set (BIDS_DERIV_ENTITIES )
501
+ _config_entities = BIDS_DERIV_ENTITIES
502
+ _standard_spaces = STANDARD_SPACES
503
+ _file_patterns = BIDS_DERIV_PATTERNS
504
+ _default_dtypes = DEFAULT_DTYPES
502
505
503
506
def __init__ (self , allowed_entities = None , out_path_base = None , ** inputs ):
504
507
"""Initialize the SimpleInterface and extend inputs with custom entities."""
505
508
self ._allowed_entities = set (allowed_entities or []).union (
506
- self ._allowed_entities
509
+ set ( self ._config_entities )
507
510
)
508
511
if out_path_base :
509
512
self .out_path_base = out_path_base
@@ -585,7 +588,7 @@ def _run_interface(self, runtime):
585
588
space = out_entities .get ("space" )
586
589
if resolution :
587
590
# Standard spaces
588
- if space in STANDARD_SPACES :
591
+ if space in self . _standard_spaces :
589
592
res = _get_tf_resolution (space , resolution )
590
593
else : # TODO: Nonstandard?
591
594
res = "Unknown"
@@ -595,8 +598,8 @@ def _run_interface(self, runtime):
595
598
out_entities ["extension" ] = out_entities ["extension" ][0 ]
596
599
597
600
# 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 ) - set (self . _config_entities )
602
+ patterns = self . _file_patterns
600
603
if custom_entities :
601
604
# Example: f"{key}-{{{key}}}" -> "task-{task}"
602
605
custom_pat = "_" .join (f"{ key } -{{{ key } }}" for key in sorted (custom_entities ))
@@ -648,7 +651,7 @@ def _run_interface(self, runtime):
648
651
is_nifti = out_file .name .endswith (
649
652
(".nii" , ".nii.gz" )
650
653
) and not out_file .name .endswith ((".dtseries.nii" , ".dtseries.nii.gz" ))
651
- data_dtype = self .inputs .data_dtype or DEFAULT_DTYPES [self .inputs .suffix ]
654
+ data_dtype = self .inputs .data_dtype or self . _default_dtypes [self .inputs .suffix ]
652
655
if is_nifti and any ((self .inputs .check_hdr , data_dtype )):
653
656
nii = nb .load (orig_file )
654
657
@@ -667,7 +670,7 @@ def _run_interface(self, runtime):
667
670
xcodes = (1 , 1 ) # Derivative in its original scanner space
668
671
if self .inputs .space :
669
672
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 )
671
674
)
672
675
673
676
curr_zooms = zooms = hdr .get_zooms ()
0 commit comments