From a385dad9bba8295ebd8e28afcd5af9a4d106873e Mon Sep 17 00:00:00 2001 From: Synchon Mandal Date: Wed, 12 Nov 2025 17:48:43 +0100 Subject: [PATCH 1/6] update: add _MARKER_INOUT_MAPPINGS to BaseMarker --- junifer/markers/base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/junifer/markers/base.py b/junifer/markers/base.py index cc7a8b684..0b12c9794 100644 --- a/junifer/markers/base.py +++ b/junifer/markers/base.py @@ -6,10 +6,10 @@ from abc import ABC, abstractmethod from copy import deepcopy -from typing import Any, Optional, Union +from typing import Any, ClassVar, Optional, Union from ..pipeline import PipelineStepMixin, UpdateMetaMixin -from ..typing import StorageLike +from ..typing import MarkerInOutMappings, StorageLike from ..utils import logger, raise_error @@ -40,6 +40,8 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin): """ + _MARKER_INOUT_MAPPINGS: ClassVar[MarkerInOutMappings] + def __init__( self, on: Optional[Union[list[str], str]] = None, -- 2.52.0 From fb50b4adf60585e806666c296a69346f4095d8d4 Mon Sep 17 00:00:00 2001 From: Synchon Mandal Date: Wed, 12 Nov 2025 17:53:25 +0100 Subject: [PATCH 2/6] refactor: add masks as parameter to BaseMarker and adapt other markers --- junifer/markers/base.py | 6 ++++++ junifer/markers/complexity/complexity_base.py | 3 +-- junifer/markers/ets_rss.py | 3 +-- junifer/markers/falff/falff_base.py | 8 +++++++- junifer/markers/falff/falff_maps.py | 2 +- junifer/markers/falff/falff_parcels.py | 2 +- junifer/markers/falff/falff_spheres.py | 2 +- .../crossparcellation_functional_connectivity.py | 3 +-- .../functional_connectivity_base.py | 3 +-- junifer/markers/maps_aggregation.py | 3 +-- junifer/markers/parcel_aggregation.py | 3 +-- junifer/markers/reho/reho_base.py | 8 +++++++- junifer/markers/reho/reho_maps.py | 3 +-- junifer/markers/reho/reho_parcels.py | 3 +-- junifer/markers/reho/reho_spheres.py | 3 +-- junifer/markers/sphere_aggregation.py | 3 +-- junifer/markers/temporal_snr/temporal_snr_base.py | 3 +-- 17 files changed, 34 insertions(+), 27 deletions(-) diff --git a/junifer/markers/base.py b/junifer/markers/base.py index 0b12c9794..f4dbef6fa 100644 --- a/junifer/markers/base.py +++ b/junifer/markers/base.py @@ -27,6 +27,10 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin): on : str or list of str or None, optional The data type to apply the marker on. If None, will work on all available data types (default None). + masks : str, dict or list of dict or str, optional + The specification of the masks to apply to regions before extracting + signals. Check :ref:`Using Masks ` for more details. + If None, will not apply any mask (default None). name : str, optional The name of the marker. If None, will use the class name as the name of the marker (default None). @@ -45,6 +49,7 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin): def __init__( self, on: Optional[Union[list[str], str]] = None, + masks: Union[str, dict, list[Union[dict, str]], None] = None, name: Optional[str] = None, ) -> None: # Check for missing mapping attribute @@ -66,6 +71,7 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin): wrong_on = [x for x in on if x not in self.get_valid_inputs()] raise_error(f"{self.name} cannot be computed on {wrong_on}") self._on = on + self.masks = masks def validate_input(self, input: list[str]) -> list[str]: """Validate input. diff --git a/junifer/markers/complexity/complexity_base.py b/junifer/markers/complexity/complexity_base.py index de5864d36..469f71ea9 100644 --- a/junifer/markers/complexity/complexity_base.py +++ b/junifer/markers/complexity/complexity_base.py @@ -68,8 +68,7 @@ class ComplexityBase(BaseMarker): self.parcellation = parcellation self.agg_method = agg_method self.agg_method_params = agg_method_params - self.masks = masks - super().__init__(on="BOLD", name=name) + super().__init__(on="BOLD", masks=masks, name=name) @abstractmethod def compute_complexity( diff --git a/junifer/markers/ets_rss.py b/junifer/markers/ets_rss.py index 6031d3b57..4c2c1d405 100644 --- a/junifer/markers/ets_rss.py +++ b/junifer/markers/ets_rss.py @@ -65,8 +65,7 @@ class RSSETSMarker(BaseMarker): self.parcellation = parcellation self.agg_method = agg_method self.agg_method_params = agg_method_params - self.masks = masks - super().__init__(name=name) + super().__init__(name=name, masks=masks) def compute( self, diff --git a/junifer/markers/falff/falff_base.py b/junifer/markers/falff/falff_base.py index 0960c0385..875331465 100644 --- a/junifer/markers/falff/falff_base.py +++ b/junifer/markers/falff/falff_base.py @@ -12,6 +12,7 @@ from typing import ( Any, ClassVar, Optional, + Union, ) from ...typing import ConditionalDependencies, MarkerInOutMappings @@ -46,6 +47,10 @@ class ALFFBase(BaseMarker): tr : positive float, optional The Repetition Time of the BOLD data. If None, will extract the TR from NIfTI header (default None). + masks : str, dict or list of dict or str, optional + The specification of the masks to apply to regions before extracting + signals. Check :ref:`Using Masks ` for more details. + If None, will not apply any mask (default None). name : str, optional The name of the marker. If None, it will use the class name (default None). @@ -92,6 +97,7 @@ class ALFFBase(BaseMarker): lowpass: float, using: str, tr: Optional[float] = None, + masks: Union[str, dict, list[Union[dict, str]], None] = None, name: Optional[str] = None, ) -> None: if highpass < 0: @@ -110,7 +116,7 @@ class ALFFBase(BaseMarker): ) self.using = using self.tr = tr - super().__init__(on="BOLD", name=name) + super().__init__(on="BOLD", masks=masks, name=name) def _compute( self, diff --git a/junifer/markers/falff/falff_maps.py b/junifer/markers/falff/falff_maps.py index 1d6434044..61cbdea67 100644 --- a/junifer/markers/falff/falff_maps.py +++ b/junifer/markers/falff/falff_maps.py @@ -75,10 +75,10 @@ class ALFFMaps(ALFFBase): lowpass=lowpass, using=using, tr=tr, + masks=masks, name=name, ) self.maps = maps - self.masks = masks def compute( self, diff --git a/junifer/markers/falff/falff_parcels.py b/junifer/markers/falff/falff_parcels.py index 7fbaf896b..74d796395 100644 --- a/junifer/markers/falff/falff_parcels.py +++ b/junifer/markers/falff/falff_parcels.py @@ -86,12 +86,12 @@ class ALFFParcels(ALFFBase): lowpass=lowpass, using=using, tr=tr, + masks=masks, name=name, ) self.parcellation = parcellation self.agg_method = agg_method self.agg_method_params = agg_method_params - self.masks = masks def compute( self, diff --git a/junifer/markers/falff/falff_spheres.py b/junifer/markers/falff/falff_spheres.py index faee35b57..800d7cda6 100644 --- a/junifer/markers/falff/falff_spheres.py +++ b/junifer/markers/falff/falff_spheres.py @@ -95,6 +95,7 @@ class ALFFSpheres(ALFFBase): lowpass=lowpass, using=using, tr=tr, + masks=masks, name=name, ) self.coords = coords @@ -102,7 +103,6 @@ class ALFFSpheres(ALFFBase): self.allow_overlap = allow_overlap self.agg_method = agg_method self.agg_method_params = agg_method_params - self.masks = masks def compute( self, diff --git a/junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py b/junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py index 97479cee7..a941c58a8 100644 --- a/junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +++ b/junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py @@ -77,8 +77,7 @@ class CrossParcellationFC(BaseMarker): self.agg_method = agg_method self.agg_method_params = agg_method_params self.corr_method = corr_method - self.masks = masks - super().__init__(on=["BOLD"], name=name) + super().__init__(on=["BOLD"], masks=masks, name=name) def compute( self, diff --git a/junifer/markers/functional_connectivity/functional_connectivity_base.py b/junifer/markers/functional_connectivity/functional_connectivity_base.py index e35bf23d3..25011ac17 100644 --- a/junifer/markers/functional_connectivity/functional_connectivity_base.py +++ b/junifer/markers/functional_connectivity/functional_connectivity_base.py @@ -76,8 +76,7 @@ class FunctionalConnectivityBase(BaseMarker): self.conn_method_params["empirical"] = self.conn_method_params.get( "empirical", True ) - self.masks = masks - super().__init__(on="BOLD", name=name) + super().__init__(on="BOLD", masks=masks, name=name) @abstractmethod def aggregate( diff --git a/junifer/markers/maps_aggregation.py b/junifer/markers/maps_aggregation.py index 2d231f67a..7ea69bdab 100644 --- a/junifer/markers/maps_aggregation.py +++ b/junifer/markers/maps_aggregation.py @@ -95,8 +95,7 @@ class MapsAggregation(BaseMarker): name: Optional[str] = None, ) -> None: self.maps = maps - self.masks = masks - super().__init__(on=on, name=name) + super().__init__(on=on, masks=masks, name=name) # Verify after super init so self._on is set if "BOLD" not in self._on and time_method is not None: diff --git a/junifer/markers/parcel_aggregation.py b/junifer/markers/parcel_aggregation.py index ca9cd3911..f71b68c29 100644 --- a/junifer/markers/parcel_aggregation.py +++ b/junifer/markers/parcel_aggregation.py @@ -110,8 +110,7 @@ class ParcelAggregation(BaseMarker): self.parcellation = parcellation self.method = method self.method_params = method_params or {} - self.masks = masks - super().__init__(on=on, name=name) + super().__init__(on=on, masks=masks, name=name) # Verify after super init so self._on is set if "BOLD" not in self._on and time_method is not None: diff --git a/junifer/markers/reho/reho_base.py b/junifer/markers/reho/reho_base.py index cb0e363ed..921a023e5 100644 --- a/junifer/markers/reho/reho_base.py +++ b/junifer/markers/reho/reho_base.py @@ -9,6 +9,7 @@ from typing import ( Any, ClassVar, Optional, + Union, ) from ...typing import ConditionalDependencies, MarkerInOutMappings @@ -35,6 +36,10 @@ class ReHoBase(BaseMarker): * "junifer" : Use ``junifer``'s own ReHo implementation * "afni" : Use AFNI's ``3dReHo`` + masks : str, dict or list of dict or str, optional + The specification of the masks to apply to regions before extracting + signals. Check :ref:`Using Masks ` for more details. + If None, will not apply any mask (default None). name : str, optional The name of the marker. If None, it will use the class name (default None). @@ -66,6 +71,7 @@ class ReHoBase(BaseMarker): def __init__( self, using: str, + masks: Union[str, dict, list[Union[dict, str]], None] = None, name: Optional[str] = None, ) -> None: # Validate `using` parameter @@ -75,7 +81,7 @@ class ReHoBase(BaseMarker): f"Invalid value for `using`, should be one of: {valid_using}" ) self.using = using - super().__init__(on="BOLD", name=name) + super().__init__(on="BOLD", masks=masks, name=name) def _compute( self, diff --git a/junifer/markers/reho/reho_maps.py b/junifer/markers/reho/reho_maps.py index 50ed38f7e..e42698972 100644 --- a/junifer/markers/reho/reho_maps.py +++ b/junifer/markers/reho/reho_maps.py @@ -92,10 +92,9 @@ class ReHoMaps(ReHoBase): name: Optional[str] = None, ) -> None: # Superclass init first to validate `using` parameter - super().__init__(using=using, name=name) + super().__init__(using=using, masks=masks, name=name) self.maps = maps self.reho_params = reho_params - self.masks = masks def compute( self, diff --git a/junifer/markers/reho/reho_parcels.py b/junifer/markers/reho/reho_parcels.py index f78a84251..91f90d35a 100644 --- a/junifer/markers/reho/reho_parcels.py +++ b/junifer/markers/reho/reho_parcels.py @@ -100,12 +100,11 @@ class ReHoParcels(ReHoBase): name: Optional[str] = None, ) -> None: # Superclass init first to validate `using` parameter - super().__init__(using=using, name=name) + super().__init__(using=using, masks=masks, name=name) self.parcellation = parcellation self.reho_params = reho_params self.agg_method = agg_method self.agg_method_params = agg_method_params - self.masks = masks def compute( self, diff --git a/junifer/markers/reho/reho_spheres.py b/junifer/markers/reho/reho_spheres.py index 0d6afb38d..ccf7153ae 100644 --- a/junifer/markers/reho/reho_spheres.py +++ b/junifer/markers/reho/reho_spheres.py @@ -113,14 +113,13 @@ class ReHoSpheres(ReHoBase): name: Optional[str] = None, ) -> None: # Superclass init first to validate `using` parameter - super().__init__(using=using, name=name) + super().__init__(using=using, masks=masks, name=name) self.coords = coords self.radius = radius self.allow_overlap = allow_overlap self.reho_params = reho_params self.agg_method = agg_method self.agg_method_params = agg_method_params - self.masks = masks def compute( self, diff --git a/junifer/markers/sphere_aggregation.py b/junifer/markers/sphere_aggregation.py index 04e75db1e..106af0d58 100644 --- a/junifer/markers/sphere_aggregation.py +++ b/junifer/markers/sphere_aggregation.py @@ -117,8 +117,7 @@ class SphereAggregation(BaseMarker): self.allow_overlap = allow_overlap self.method = method self.method_params = method_params or {} - self.masks = masks - super().__init__(on=on, name=name) + super().__init__(on=on, masks=masks, name=name) # Verify after super init so self._on is set if "BOLD" not in self._on and time_method is not None: diff --git a/junifer/markers/temporal_snr/temporal_snr_base.py b/junifer/markers/temporal_snr/temporal_snr_base.py index c0f946c12..072f68ff3 100644 --- a/junifer/markers/temporal_snr/temporal_snr_base.py +++ b/junifer/markers/temporal_snr/temporal_snr_base.py @@ -54,8 +54,7 @@ class TemporalSNRBase(BaseMarker): ) -> None: self.agg_method = agg_method self.agg_method_params = agg_method_params - self.masks = masks - super().__init__(on="BOLD", name=name) + super().__init__(on="BOLD", masks=masks, name=name) @abstractmethod def aggregate( -- 2.52.0 From c6d22cedb4ee0b643e494f4b2d056bb1f6fbe53f Mon Sep 17 00:00:00 2001 From: Synchon Mandal Date: Wed, 12 Nov 2025 17:54:22 +0100 Subject: [PATCH 3/6] chore: improve docstring for BaseMarker --- junifer/markers/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/junifer/markers/base.py b/junifer/markers/base.py index f4dbef6fa..2d899cb9f 100644 --- a/junifer/markers/base.py +++ b/junifer/markers/base.py @@ -17,9 +17,9 @@ __all__ = ["BaseMarker"] class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin): - """Abstract base class for all markers. + """Abstract base class for marker. - For every interface that is required, one needs to provide a concrete + For every marker, one needs to provide a concrete implementation of this abstract class. Parameters @@ -38,7 +38,7 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin): Raises ------ AttributeError - If the marker does not have `_MARKER_INOUT_MAPPINGS` attribute. + If the marker does not have ``_MARKER_INOUT_MAPPINGS`` attribute. ValueError If required input data type(s) is(are) not found. -- 2.52.0 From c1e26d9833eb8d2b67a0492d0aeee48f5e374fbd Mon Sep 17 00:00:00 2001 From: Synchon Mandal Date: Wed, 12 Nov 2025 18:13:38 +0100 Subject: [PATCH 4/6] refactor: rename get_output_type to storage_type to make intent clear in BaseMarker and adapt markers --- junifer/markers/base.py | 6 +++--- .../markers/complexity/tests/test_hurst_exponent.py | 10 +++++----- .../complexity/tests/test_multiscale_entropy_auc.py | 6 +++--- junifer/markers/complexity/tests/test_perm_entropy.py | 6 +++--- junifer/markers/complexity/tests/test_range_entropy.py | 6 +++--- .../markers/complexity/tests/test_range_entropy_auc.py | 10 +++++----- .../markers/complexity/tests/test_sample_entropy.py | 10 +++++----- .../complexity/tests/test_weighted_perm_entropy.py | 6 +++--- junifer/markers/falff/tests/test_falff_maps.py | 8 ++++---- junifer/markers/falff/tests/test_falff_parcels.py | 6 +++--- junifer/markers/falff/tests/test_falff_spheres.py | 6 +++--- .../test_crossparcellation_functional_connectivity.py | 8 +++----- .../tests/test_edge_functional_connectivity_maps.py | 2 +- .../tests/test_edge_functional_connectivity_parcels.py | 2 +- .../tests/test_edge_functional_connectivity_spheres.py | 2 +- .../tests/test_functional_connectivity_maps.py | 2 +- .../tests/test_functional_connectivity_parcels.py | 2 +- .../tests/test_functional_connectivity_spheres.py | 2 +- junifer/markers/reho/tests/test_reho_maps.py | 2 +- junifer/markers/reho/tests/test_reho_parcels.py | 2 +- junifer/markers/reho/tests/test_reho_spheres.py | 2 +- .../temporal_snr/tests/test_temporal_snr_maps.py | 2 +- .../temporal_snr/tests/test_temporal_snr_parcels.py | 2 +- .../temporal_snr/tests/test_temporal_snr_spheres.py | 2 +- junifer/markers/tests/test_brainprint.py | 6 +++--- junifer/markers/tests/test_ets_rss.py | 6 +++--- junifer/markers/tests/test_maps_aggregation.py | 2 +- junifer/markers/tests/test_parcel_aggregation.py | 2 +- junifer/markers/tests/test_sphere_aggregation.py | 2 +- 29 files changed, 64 insertions(+), 66 deletions(-) diff --git a/junifer/markers/base.py b/junifer/markers/base.py index 2d899cb9f..71a1277cb 100644 --- a/junifer/markers/base.py +++ b/junifer/markers/base.py @@ -113,8 +113,8 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin): """ return list(self._MARKER_INOUT_MAPPINGS.keys()) - def get_output_type(self, input_type: str, output_feature: str) -> str: - """Get output type. + def storage_type(self, input_type: str, output_feature: str) -> str: + """Get storage type for a feature. Parameters ---------- @@ -180,7 +180,7 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin): The storage class, for example, SQLiteFeatureStorage. """ - output_type_ = self.get_output_type(type_, feature) + output_type_ = self.storage_type(type_, feature) logger.debug(f"Storing {output_type_} in {storage}") storage.store(kind=output_type_, **out) diff --git a/junifer/markers/complexity/tests/test_hurst_exponent.py b/junifer/markers/complexity/tests/test_hurst_exponent.py index 771e28d35..4e6063517 100644 --- a/junifer/markers/complexity/tests/test_hurst_exponent.py +++ b/junifer/markers/complexity/tests/test_hurst_exponent.py @@ -43,11 +43,11 @@ def test_compute() -> None: assert feature_map["BOLD"]["complexity"]["data"].ndim == 2 -def test_get_output_type() -> None: - """Test HurstExponent get_output_type().""" - assert "vector" == HurstExponent( - parcellation=PARCELLATION - ).get_output_type(input_type="BOLD", output_feature="complexity") +def test_storage_type() -> None: + """Test HurstExponent storage_type.""" + assert "vector" == HurstExponent(parcellation=PARCELLATION).storage_type( + input_type="BOLD", output_feature="complexity" + ) @pytest.mark.skipif( diff --git a/junifer/markers/complexity/tests/test_multiscale_entropy_auc.py b/junifer/markers/complexity/tests/test_multiscale_entropy_auc.py index fa5b3c0a9..de65c5a82 100644 --- a/junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +++ b/junifer/markers/complexity/tests/test_multiscale_entropy_auc.py @@ -42,11 +42,11 @@ def test_compute() -> None: assert feature_map["BOLD"]["complexity"]["data"].ndim == 2 -def test_get_output_type() -> None: - """Test MultiscaleEntropyAUC get_output_type().""" +def test_storage_type() -> None: + """Test MultiscaleEntropyAUC storage_type.""" assert "vector" == MultiscaleEntropyAUC( parcellation=PARCELLATION - ).get_output_type(input_type="BOLD", output_feature="complexity") + ).storage_type(input_type="BOLD", output_feature="complexity") @pytest.mark.skipif( diff --git a/junifer/markers/complexity/tests/test_perm_entropy.py b/junifer/markers/complexity/tests/test_perm_entropy.py index 580446995..ac0db77b2 100644 --- a/junifer/markers/complexity/tests/test_perm_entropy.py +++ b/junifer/markers/complexity/tests/test_perm_entropy.py @@ -42,9 +42,9 @@ def test_compute() -> None: assert feature_map["BOLD"]["complexity"]["data"].ndim == 2 -def test_get_output_type() -> None: - """Test PermEntropy get_output_type().""" - assert "vector" == PermEntropy(parcellation=PARCELLATION).get_output_type( +def test_storage_type() -> None: + """Test PermEntropy storage_type.""" + assert "vector" == PermEntropy(parcellation=PARCELLATION).storage_type( input_type="BOLD", output_feature="complexity" ) diff --git a/junifer/markers/complexity/tests/test_range_entropy.py b/junifer/markers/complexity/tests/test_range_entropy.py index 873a0d2b8..ba477fffe 100644 --- a/junifer/markers/complexity/tests/test_range_entropy.py +++ b/junifer/markers/complexity/tests/test_range_entropy.py @@ -43,9 +43,9 @@ def test_compute() -> None: assert feature_map["BOLD"]["complexity"]["data"].ndim == 2 -def test_get_output_type() -> None: - """Test RangeEntropy get_output_type().""" - assert "vector" == RangeEntropy(parcellation=PARCELLATION).get_output_type( +def test_storage_type() -> None: + """Test RangeEntropy storage_type.""" + assert "vector" == RangeEntropy(parcellation=PARCELLATION).storage_type( input_type="BOLD", output_feature="complexity" ) diff --git a/junifer/markers/complexity/tests/test_range_entropy_auc.py b/junifer/markers/complexity/tests/test_range_entropy_auc.py index 5955e12ff..4cfac4720 100644 --- a/junifer/markers/complexity/tests/test_range_entropy_auc.py +++ b/junifer/markers/complexity/tests/test_range_entropy_auc.py @@ -43,11 +43,11 @@ def test_compute() -> None: assert feature_map["BOLD"]["complexity"]["data"].ndim == 2 -def test_get_output_type() -> None: - """Test RangeEntropyAUC get_output_type().""" - assert "vector" == RangeEntropyAUC( - parcellation=PARCELLATION - ).get_output_type(input_type="BOLD", output_feature="complexity") +def test_storage_type() -> None: + """Test RangeEntropyAUC storage_type.""" + assert "vector" == RangeEntropyAUC(parcellation=PARCELLATION).storage_type( + input_type="BOLD", output_feature="complexity" + ) @pytest.mark.skipif( diff --git a/junifer/markers/complexity/tests/test_sample_entropy.py b/junifer/markers/complexity/tests/test_sample_entropy.py index 73139343f..fc79cad8c 100644 --- a/junifer/markers/complexity/tests/test_sample_entropy.py +++ b/junifer/markers/complexity/tests/test_sample_entropy.py @@ -42,11 +42,11 @@ def test_compute() -> None: assert feature_map["BOLD"]["complexity"]["data"].ndim == 2 -def test_get_output_type() -> None: - """Test SampleEntropy get_output_type().""" - assert "vector" == SampleEntropy( - parcellation=PARCELLATION - ).get_output_type(input_type="BOLD", output_feature="complexity") +def test_storage_type() -> None: + """Test SampleEntropy storage_type.""" + assert "vector" == SampleEntropy(parcellation=PARCELLATION).storage_type( + input_type="BOLD", output_feature="complexity" + ) @pytest.mark.skipif( diff --git a/junifer/markers/complexity/tests/test_weighted_perm_entropy.py b/junifer/markers/complexity/tests/test_weighted_perm_entropy.py index 3ebe57894..485df7f4e 100644 --- a/junifer/markers/complexity/tests/test_weighted_perm_entropy.py +++ b/junifer/markers/complexity/tests/test_weighted_perm_entropy.py @@ -42,11 +42,11 @@ def test_compute() -> None: assert feature_map["BOLD"]["complexity"]["data"].ndim == 2 -def test_get_output_type() -> None: - """Test WeightedPermEntropy get_output_type().""" +def test_storage_type() -> None: + """Test WeightedPermEntropy storage_type.""" assert "vector" == WeightedPermEntropy( parcellation=PARCELLATION - ).get_output_type(input_type="BOLD", output_feature="complexity") + ).storage_type(input_type="BOLD", output_feature="complexity") @pytest.mark.skipif( diff --git a/junifer/markers/falff/tests/test_falff_maps.py b/junifer/markers/falff/tests/test_falff_maps.py index aee7a92b2..12e2c6b9b 100644 --- a/junifer/markers/falff/tests/test_falff_maps.py +++ b/junifer/markers/falff/tests/test_falff_maps.py @@ -27,8 +27,8 @@ MAPS = "Smith_rsn_10" "falff", ], ) -def test_ALFFMaps_get_output_type(feature: str) -> None: - """Test ALFFMaps get_output_type(). +def test_ALFFMaps_storage_type(feature: str) -> None: + """Test ALFFMaps storage_type. Parameters ---------- @@ -39,7 +39,7 @@ def test_ALFFMaps_get_output_type(feature: str) -> None: assert "vector" == ALFFMaps( maps=MAPS, using="junifer", - ).get_output_type(input_type="BOLD", output_feature=feature) + ).storage_type(input_type="BOLD", output_feature=feature) def test_ALFFMaps( @@ -74,7 +74,7 @@ def test_ALFFMaps( ) # Check correct output for name in ["alff", "falff"]: - assert "vector" == marker.get_output_type( + assert "vector" == marker.storage_type( input_type="BOLD", output_feature=name ) diff --git a/junifer/markers/falff/tests/test_falff_parcels.py b/junifer/markers/falff/tests/test_falff_parcels.py index 34fcd94ff..c9a55b756 100644 --- a/junifer/markers/falff/tests/test_falff_parcels.py +++ b/junifer/markers/falff/tests/test_falff_parcels.py @@ -28,8 +28,8 @@ PARCELLATION = "TianxS1x3TxMNInonlinear2009cAsym" "falff", ], ) -def test_ALFFParcels_get_output_type(feature: str) -> None: - """Test ALFFParcels get_output_type(). +def test_ALFFParcels_storage_type(feature: str) -> None: + """Test ALFFParcels storage_type. Parameters ---------- @@ -40,7 +40,7 @@ def test_ALFFParcels_get_output_type(feature: str) -> None: assert "vector" == ALFFParcels( parcellation=PARCELLATION, using="junifer", - ).get_output_type(input_type="BOLD", output_feature=feature) + ).storage_type(input_type="BOLD", output_feature=feature) def test_ALFFParcels(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None: diff --git a/junifer/markers/falff/tests/test_falff_spheres.py b/junifer/markers/falff/tests/test_falff_spheres.py index f57022e35..4a254448e 100644 --- a/junifer/markers/falff/tests/test_falff_spheres.py +++ b/junifer/markers/falff/tests/test_falff_spheres.py @@ -28,8 +28,8 @@ COORDINATES = "DMNBuckner" "falff", ], ) -def test_ALFFSpheres_get_output_type(feature: str) -> None: - """Test ALFFSpheres get_output_type(). +def test_ALFFSpheres_storage_type(feature: str) -> None: + """Test ALFFSpheres storage_type. Parameters ---------- @@ -40,7 +40,7 @@ def test_ALFFSpheres_get_output_type(feature: str) -> None: assert "vector" == ALFFSpheres( coords=COORDINATES, using="junifer", - ).get_output_type(input_type="BOLD", output_feature=feature) + ).storage_type(input_type="BOLD", output_feature=feature) def test_ALFFSpheres(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None: diff --git a/junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py b/junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py index 67a046286..19584a731 100644 --- a/junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +++ b/junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py @@ -31,13 +31,11 @@ def test_init() -> None: ) -def test_get_output_type() -> None: - """Test CrossParcellationFC get_output_type().""" +def test_storage_type() -> None: + """Test CrossParcellationFC storage_type.""" assert "matrix" == CrossParcellationFC( parcellation_one=parcellation_one, parcellation_two=parcellation_two - ).get_output_type( - input_type="BOLD", output_feature="functional_connectivity" - ) + ).storage_type(input_type="BOLD", output_feature="functional_connectivity") @pytest.mark.skipif( diff --git a/junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_maps.py b/junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_maps.py index ae44c9d07..84b763925 100644 --- a/junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_maps.py +++ b/junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_maps.py @@ -47,7 +47,7 @@ def test_EdgeCentricFCMaps( conn_method_params=conn_method_params, ) # Check correct output - assert "matrix" == marker.get_output_type( + assert "matrix" == marker.storage_type( input_type="BOLD", output_feature="functional_connectivity" ) diff --git a/junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py b/junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py index a7f0519d7..e6083b960 100644 --- a/junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +++ b/junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py @@ -45,7 +45,7 @@ def test_EdgeCentricFCParcels( conn_method_params=conn_method_params, ) # Check correct output - assert "matrix" == marker.get_output_type( + assert "matrix" == marker.storage_type( input_type="BOLD", output_feature="functional_connectivity" ) diff --git a/junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py b/junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py index f142a8467..db9f76b24 100644 --- a/junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +++ b/junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py @@ -46,7 +46,7 @@ def test_EdgeCentricFCSpheres( conn_method_params=conn_method_params, ) # Check correct output - assert "matrix" == marker.get_output_type( + assert "matrix" == marker.storage_type( input_type="BOLD", output_feature="functional_connectivity" ) diff --git a/junifer/markers/functional_connectivity/tests/test_functional_connectivity_maps.py b/junifer/markers/functional_connectivity/tests/test_functional_connectivity_maps.py index c4f92ccc3..281ad3210 100644 --- a/junifer/markers/functional_connectivity/tests/test_functional_connectivity_maps.py +++ b/junifer/markers/functional_connectivity/tests/test_functional_connectivity_maps.py @@ -60,7 +60,7 @@ def test_FunctionalConnectivityMaps( conn_method_params=conn_method_params, ) # Check correct output - assert "matrix" == marker.get_output_type( + assert "matrix" == marker.storage_type( input_type="BOLD", output_feature="functional_connectivity" ) diff --git a/junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py b/junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py index 07757e1d0..8f495b460 100644 --- a/junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +++ b/junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py @@ -61,7 +61,7 @@ def test_FunctionalConnectivityParcels( conn_method_params=conn_method_params, ) # Check correct output - assert "matrix" == marker.get_output_type( + assert "matrix" == marker.storage_type( input_type="BOLD", output_feature="functional_connectivity" ) diff --git a/junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py b/junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py index 854961804..f80ea1f3e 100644 --- a/junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +++ b/junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py @@ -63,7 +63,7 @@ def test_FunctionalConnectivitySpheres( conn_method_params=conn_method_params, ) # Check correct output - assert "matrix" == marker.get_output_type( + assert "matrix" == marker.storage_type( input_type="BOLD", output_feature="functional_connectivity" ) diff --git a/junifer/markers/reho/tests/test_reho_maps.py b/junifer/markers/reho/tests/test_reho_maps.py index 42db2d987..3dac74678 100644 --- a/junifer/markers/reho/tests/test_reho_maps.py +++ b/junifer/markers/reho/tests/test_reho_maps.py @@ -48,7 +48,7 @@ def test_ReHoMaps( using="junifer", ) # Check correct output - assert "vector" == marker.get_output_type( + assert "vector" == marker.storage_type( input_type="BOLD", output_feature="reho" ) diff --git a/junifer/markers/reho/tests/test_reho_parcels.py b/junifer/markers/reho/tests/test_reho_parcels.py index d7737e335..db0bcf245 100644 --- a/junifer/markers/reho/tests/test_reho_parcels.py +++ b/junifer/markers/reho/tests/test_reho_parcels.py @@ -43,7 +43,7 @@ def test_ReHoParcels(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None: using="junifer", ) # Check correct output - assert "vector" == marker.get_output_type( + assert "vector" == marker.storage_type( input_type="BOLD", output_feature="reho" ) diff --git a/junifer/markers/reho/tests/test_reho_spheres.py b/junifer/markers/reho/tests/test_reho_spheres.py index 9f89b036a..aeee29c68 100644 --- a/junifer/markers/reho/tests/test_reho_spheres.py +++ b/junifer/markers/reho/tests/test_reho_spheres.py @@ -41,7 +41,7 @@ def test_ReHoSpheres(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None: coords=COORDINATES, using="junifer", radius=10.0 ) # Check correct output - assert "vector" == marker.get_output_type( + assert "vector" == marker.storage_type( input_type="BOLD", output_feature="reho" ) diff --git a/junifer/markers/temporal_snr/tests/test_temporal_snr_maps.py b/junifer/markers/temporal_snr/tests/test_temporal_snr_maps.py index 173509fa2..320467421 100644 --- a/junifer/markers/temporal_snr/tests/test_temporal_snr_maps.py +++ b/junifer/markers/temporal_snr/tests/test_temporal_snr_maps.py @@ -27,7 +27,7 @@ def test_TemporalSNRMaps_computation( element_data = DefaultDataReader().fit_transform(element) marker = TemporalSNRMaps(maps="Smith_rsn_10") # Check correct output - assert "vector" == marker.get_output_type( + assert "vector" == marker.storage_type( input_type="BOLD", output_feature="tsnr" ) diff --git a/junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py b/junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py index cb97b3882..8cb535b05 100644 --- a/junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py +++ b/junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py @@ -20,7 +20,7 @@ def test_TemporalSNRParcels_computation() -> None: parcellation="TianxS1x3TxMNInonlinear2009cAsym" ) # Check correct output - assert "vector" == marker.get_output_type( + assert "vector" == marker.storage_type( input_type="BOLD", output_feature="tsnr" ) diff --git a/junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py b/junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py index 7957458b2..81e871c6c 100644 --- a/junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py +++ b/junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py @@ -20,7 +20,7 @@ def test_TemporalSNRSpheres_computation() -> None: element_data = DefaultDataReader().fit_transform(dg["sub001"]) marker = TemporalSNRSpheres(coords="DMNBuckner", radius=5.0) # Check correct output - assert "vector" == marker.get_output_type( + assert "vector" == marker.storage_type( input_type="BOLD", output_feature="tsnr" ) diff --git a/junifer/markers/tests/test_brainprint.py b/junifer/markers/tests/test_brainprint.py index 41557b8ee..65ef387a2 100644 --- a/junifer/markers/tests/test_brainprint.py +++ b/junifer/markers/tests/test_brainprint.py @@ -22,8 +22,8 @@ from junifer.pipeline.utils import _check_freesurfer ("distances", "vector"), ], ) -def test_get_output_type(feature: str, storage_type: str) -> None: - """Test BrainPrint get_output_type(). +def test_storage_type(feature: str, storage_type: str) -> None: + """Test BrainPrint storage_type. Parameters ---------- @@ -33,7 +33,7 @@ def test_get_output_type(feature: str, storage_type: str) -> None: The parametrized storage type. """ - assert storage_type == BrainPrint().get_output_type( + assert storage_type == BrainPrint().storage_type( input_type="FreeSurfer", output_feature=feature ) diff --git a/junifer/markers/tests/test_ets_rss.py b/junifer/markers/tests/test_ets_rss.py index 73f38e473..5f478cc60 100644 --- a/junifer/markers/tests/test_ets_rss.py +++ b/junifer/markers/tests/test_ets_rss.py @@ -45,11 +45,11 @@ def test_compute() -> None: assert extacted_timeseries.shape[0] == len(rss_ets["rss_ets"]["data"]) -def test_get_output_type() -> None: - """Test RSS ETS get_output_type().""" +def test_storage_type() -> None: + """Test RSS ETS storage_type.""" assert "timeseries" == RSSETSMarker( parcellation=PARCELLATION - ).get_output_type(input_type="BOLD", output_feature="rss_ets") + ).storage_type(input_type="BOLD", output_feature="rss_ets") def test_store(tmp_path: Path) -> None: diff --git a/junifer/markers/tests/test_maps_aggregation.py b/junifer/markers/tests/test_maps_aggregation.py index 9c2b3e8bb..10babfa30 100644 --- a/junifer/markers/tests/test_maps_aggregation.py +++ b/junifer/markers/tests/test_maps_aggregation.py @@ -74,7 +74,7 @@ def test_MapsAggregation_input_output( """ assert storage_type == MapsAggregation( maps="Smith_rsn_10", on=input_type - ).get_output_type(input_type=input_type, output_feature="aggregation") + ).storage_type(input_type=input_type, output_feature="aggregation") def test_MapsAggregation_3D( diff --git a/junifer/markers/tests/test_parcel_aggregation.py b/junifer/markers/tests/test_parcel_aggregation.py index 6e7098073..a0ff8c378 100644 --- a/junifer/markers/tests/test_parcel_aggregation.py +++ b/junifer/markers/tests/test_parcel_aggregation.py @@ -79,7 +79,7 @@ def test_ParcelAggregation_input_output( """ assert storage_type == ParcelAggregation( parcellation="Schaefer100x7", method="mean", on=input_type - ).get_output_type(input_type=input_type, output_feature="aggregation") + ).storage_type(input_type=input_type, output_feature="aggregation") def test_ParcelAggregation_3D() -> None: diff --git a/junifer/markers/tests/test_sphere_aggregation.py b/junifer/markers/tests/test_sphere_aggregation.py index 1f9ba2db1..2f41efe79 100644 --- a/junifer/markers/tests/test_sphere_aggregation.py +++ b/junifer/markers/tests/test_sphere_aggregation.py @@ -83,7 +83,7 @@ def test_SphereAggregation_input_output( coords="DMNBuckner", method="mean", on=input_type, - ).get_output_type(input_type=input_type, output_feature="aggregation") + ).storage_type(input_type=input_type, output_feature="aggregation") def test_SphereAggregation_3D() -> None: -- 2.52.0 From 8e46aea2b31ae20bdadb9debbbb0a26effd123a0 Mon Sep 17 00:00:00 2001 From: Synchon Mandal Date: Wed, 12 Nov 2025 18:17:39 +0100 Subject: [PATCH 5/6] chore: add changelog 477.enh --- docs/changes/newsfragments/477.enh | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/changes/newsfragments/477.enh diff --git a/docs/changes/newsfragments/477.enh b/docs/changes/newsfragments/477.enh new file mode 100644 index 000000000..af12220aa --- /dev/null +++ b/docs/changes/newsfragments/477.enh @@ -0,0 +1 @@ +Improve ``Marker`` interface and implementations by `Synchon Mandal`_ -- 2.52.0 From cca50e6542a2057e628913e5dcdb0ff48c9e384e Mon Sep 17 00:00:00 2001 From: Synchon Mandal Date: Wed, 12 Nov 2025 22:41:51 +0100 Subject: [PATCH 6/6] Revert "refactor: add masks as parameter to BaseMarker and adapt other markers" This reverts commit fb50b4adf60585e806666c296a69346f4095d8d4. --- junifer/markers/base.py | 6 ------ junifer/markers/complexity/complexity_base.py | 3 ++- junifer/markers/ets_rss.py | 3 ++- junifer/markers/falff/falff_base.py | 8 +------- junifer/markers/falff/falff_maps.py | 2 +- junifer/markers/falff/falff_parcels.py | 2 +- junifer/markers/falff/falff_spheres.py | 2 +- .../crossparcellation_functional_connectivity.py | 3 ++- .../functional_connectivity_base.py | 3 ++- junifer/markers/maps_aggregation.py | 3 ++- junifer/markers/parcel_aggregation.py | 3 ++- junifer/markers/reho/reho_base.py | 8 +------- junifer/markers/reho/reho_maps.py | 3 ++- junifer/markers/reho/reho_parcels.py | 3 ++- junifer/markers/reho/reho_spheres.py | 3 ++- junifer/markers/sphere_aggregation.py | 3 ++- junifer/markers/temporal_snr/temporal_snr_base.py | 3 ++- 17 files changed, 27 insertions(+), 34 deletions(-) diff --git a/junifer/markers/base.py b/junifer/markers/base.py index 71a1277cb..16636fc6a 100644 --- a/junifer/markers/base.py +++ b/junifer/markers/base.py @@ -27,10 +27,6 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin): on : str or list of str or None, optional The data type to apply the marker on. If None, will work on all available data types (default None). - masks : str, dict or list of dict or str, optional - The specification of the masks to apply to regions before extracting - signals. Check :ref:`Using Masks ` for more details. - If None, will not apply any mask (default None). name : str, optional The name of the marker. If None, will use the class name as the name of the marker (default None). @@ -49,7 +45,6 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin): def __init__( self, on: Optional[Union[list[str], str]] = None, - masks: Union[str, dict, list[Union[dict, str]], None] = None, name: Optional[str] = None, ) -> None: # Check for missing mapping attribute @@ -71,7 +66,6 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin): wrong_on = [x for x in on if x not in self.get_valid_inputs()] raise_error(f"{self.name} cannot be computed on {wrong_on}") self._on = on - self.masks = masks def validate_input(self, input: list[str]) -> list[str]: """Validate input. diff --git a/junifer/markers/complexity/complexity_base.py b/junifer/markers/complexity/complexity_base.py index 469f71ea9..de5864d36 100644 --- a/junifer/markers/complexity/complexity_base.py +++ b/junifer/markers/complexity/complexity_base.py @@ -68,7 +68,8 @@ class ComplexityBase(BaseMarker): self.parcellation = parcellation self.agg_method = agg_method self.agg_method_params = agg_method_params - super().__init__(on="BOLD", masks=masks, name=name) + self.masks = masks + super().__init__(on="BOLD", name=name) @abstractmethod def compute_complexity( diff --git a/junifer/markers/ets_rss.py b/junifer/markers/ets_rss.py index 4c2c1d405..6031d3b57 100644 --- a/junifer/markers/ets_rss.py +++ b/junifer/markers/ets_rss.py @@ -65,7 +65,8 @@ class RSSETSMarker(BaseMarker): self.parcellation = parcellation self.agg_method = agg_method self.agg_method_params = agg_method_params - super().__init__(name=name, masks=masks) + self.masks = masks + super().__init__(name=name) def compute( self, diff --git a/junifer/markers/falff/falff_base.py b/junifer/markers/falff/falff_base.py index 875331465..0960c0385 100644 --- a/junifer/markers/falff/falff_base.py +++ b/junifer/markers/falff/falff_base.py @@ -12,7 +12,6 @@ from typing import ( Any, ClassVar, Optional, - Union, ) from ...typing import ConditionalDependencies, MarkerInOutMappings @@ -47,10 +46,6 @@ class ALFFBase(BaseMarker): tr : positive float, optional The Repetition Time of the BOLD data. If None, will extract the TR from NIfTI header (default None). - masks : str, dict or list of dict or str, optional - The specification of the masks to apply to regions before extracting - signals. Check :ref:`Using Masks ` for more details. - If None, will not apply any mask (default None). name : str, optional The name of the marker. If None, it will use the class name (default None). @@ -97,7 +92,6 @@ class ALFFBase(BaseMarker): lowpass: float, using: str, tr: Optional[float] = None, - masks: Union[str, dict, list[Union[dict, str]], None] = None, name: Optional[str] = None, ) -> None: if highpass < 0: @@ -116,7 +110,7 @@ class ALFFBase(BaseMarker): ) self.using = using self.tr = tr - super().__init__(on="BOLD", masks=masks, name=name) + super().__init__(on="BOLD", name=name) def _compute( self, diff --git a/junifer/markers/falff/falff_maps.py b/junifer/markers/falff/falff_maps.py index 61cbdea67..1d6434044 100644 --- a/junifer/markers/falff/falff_maps.py +++ b/junifer/markers/falff/falff_maps.py @@ -75,10 +75,10 @@ class ALFFMaps(ALFFBase): lowpass=lowpass, using=using, tr=tr, - masks=masks, name=name, ) self.maps = maps + self.masks = masks def compute( self, diff --git a/junifer/markers/falff/falff_parcels.py b/junifer/markers/falff/falff_parcels.py index 74d796395..7fbaf896b 100644 --- a/junifer/markers/falff/falff_parcels.py +++ b/junifer/markers/falff/falff_parcels.py @@ -86,12 +86,12 @@ class ALFFParcels(ALFFBase): lowpass=lowpass, using=using, tr=tr, - masks=masks, name=name, ) self.parcellation = parcellation self.agg_method = agg_method self.agg_method_params = agg_method_params + self.masks = masks def compute( self, diff --git a/junifer/markers/falff/falff_spheres.py b/junifer/markers/falff/falff_spheres.py index 800d7cda6..faee35b57 100644 --- a/junifer/markers/falff/falff_spheres.py +++ b/junifer/markers/falff/falff_spheres.py @@ -95,7 +95,6 @@ class ALFFSpheres(ALFFBase): lowpass=lowpass, using=using, tr=tr, - masks=masks, name=name, ) self.coords = coords @@ -103,6 +102,7 @@ class ALFFSpheres(ALFFBase): self.allow_overlap = allow_overlap self.agg_method = agg_method self.agg_method_params = agg_method_params + self.masks = masks def compute( self, diff --git a/junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py b/junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py index a941c58a8..97479cee7 100644 --- a/junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +++ b/junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py @@ -77,7 +77,8 @@ class CrossParcellationFC(BaseMarker): self.agg_method = agg_method self.agg_method_params = agg_method_params self.corr_method = corr_method - super().__init__(on=["BOLD"], masks=masks, name=name) + self.masks = masks + super().__init__(on=["BOLD"], name=name) def compute( self, diff --git a/junifer/markers/functional_connectivity/functional_connectivity_base.py b/junifer/markers/functional_connectivity/functional_connectivity_base.py index 25011ac17..e35bf23d3 100644 --- a/junifer/markers/functional_connectivity/functional_connectivity_base.py +++ b/junifer/markers/functional_connectivity/functional_connectivity_base.py @@ -76,7 +76,8 @@ class FunctionalConnectivityBase(BaseMarker): self.conn_method_params["empirical"] = self.conn_method_params.get( "empirical", True ) - super().__init__(on="BOLD", masks=masks, name=name) + self.masks = masks + super().__init__(on="BOLD", name=name) @abstractmethod def aggregate( diff --git a/junifer/markers/maps_aggregation.py b/junifer/markers/maps_aggregation.py index 7ea69bdab..2d231f67a 100644 --- a/junifer/markers/maps_aggregation.py +++ b/junifer/markers/maps_aggregation.py @@ -95,7 +95,8 @@ class MapsAggregation(BaseMarker): name: Optional[str] = None, ) -> None: self.maps = maps - super().__init__(on=on, masks=masks, name=name) + self.masks = masks + super().__init__(on=on, name=name) # Verify after super init so self._on is set if "BOLD" not in self._on and time_method is not None: diff --git a/junifer/markers/parcel_aggregation.py b/junifer/markers/parcel_aggregation.py index f71b68c29..ca9cd3911 100644 --- a/junifer/markers/parcel_aggregation.py +++ b/junifer/markers/parcel_aggregation.py @@ -110,7 +110,8 @@ class ParcelAggregation(BaseMarker): self.parcellation = parcellation self.method = method self.method_params = method_params or {} - super().__init__(on=on, masks=masks, name=name) + self.masks = masks + super().__init__(on=on, name=name) # Verify after super init so self._on is set if "BOLD" not in self._on and time_method is not None: diff --git a/junifer/markers/reho/reho_base.py b/junifer/markers/reho/reho_base.py index 921a023e5..cb0e363ed 100644 --- a/junifer/markers/reho/reho_base.py +++ b/junifer/markers/reho/reho_base.py @@ -9,7 +9,6 @@ from typing import ( Any, ClassVar, Optional, - Union, ) from ...typing import ConditionalDependencies, MarkerInOutMappings @@ -36,10 +35,6 @@ class ReHoBase(BaseMarker): * "junifer" : Use ``junifer``'s own ReHo implementation * "afni" : Use AFNI's ``3dReHo`` - masks : str, dict or list of dict or str, optional - The specification of the masks to apply to regions before extracting - signals. Check :ref:`Using Masks ` for more details. - If None, will not apply any mask (default None). name : str, optional The name of the marker. If None, it will use the class name (default None). @@ -71,7 +66,6 @@ class ReHoBase(BaseMarker): def __init__( self, using: str, - masks: Union[str, dict, list[Union[dict, str]], None] = None, name: Optional[str] = None, ) -> None: # Validate `using` parameter @@ -81,7 +75,7 @@ class ReHoBase(BaseMarker): f"Invalid value for `using`, should be one of: {valid_using}" ) self.using = using - super().__init__(on="BOLD", masks=masks, name=name) + super().__init__(on="BOLD", name=name) def _compute( self, diff --git a/junifer/markers/reho/reho_maps.py b/junifer/markers/reho/reho_maps.py index e42698972..50ed38f7e 100644 --- a/junifer/markers/reho/reho_maps.py +++ b/junifer/markers/reho/reho_maps.py @@ -92,9 +92,10 @@ class ReHoMaps(ReHoBase): name: Optional[str] = None, ) -> None: # Superclass init first to validate `using` parameter - super().__init__(using=using, masks=masks, name=name) + super().__init__(using=using, name=name) self.maps = maps self.reho_params = reho_params + self.masks = masks def compute( self, diff --git a/junifer/markers/reho/reho_parcels.py b/junifer/markers/reho/reho_parcels.py index 91f90d35a..f78a84251 100644 --- a/junifer/markers/reho/reho_parcels.py +++ b/junifer/markers/reho/reho_parcels.py @@ -100,11 +100,12 @@ class ReHoParcels(ReHoBase): name: Optional[str] = None, ) -> None: # Superclass init first to validate `using` parameter - super().__init__(using=using, masks=masks, name=name) + super().__init__(using=using, name=name) self.parcellation = parcellation self.reho_params = reho_params self.agg_method = agg_method self.agg_method_params = agg_method_params + self.masks = masks def compute( self, diff --git a/junifer/markers/reho/reho_spheres.py b/junifer/markers/reho/reho_spheres.py index ccf7153ae..0d6afb38d 100644 --- a/junifer/markers/reho/reho_spheres.py +++ b/junifer/markers/reho/reho_spheres.py @@ -113,13 +113,14 @@ class ReHoSpheres(ReHoBase): name: Optional[str] = None, ) -> None: # Superclass init first to validate `using` parameter - super().__init__(using=using, masks=masks, name=name) + super().__init__(using=using, name=name) self.coords = coords self.radius = radius self.allow_overlap = allow_overlap self.reho_params = reho_params self.agg_method = agg_method self.agg_method_params = agg_method_params + self.masks = masks def compute( self, diff --git a/junifer/markers/sphere_aggregation.py b/junifer/markers/sphere_aggregation.py index 106af0d58..04e75db1e 100644 --- a/junifer/markers/sphere_aggregation.py +++ b/junifer/markers/sphere_aggregation.py @@ -117,7 +117,8 @@ class SphereAggregation(BaseMarker): self.allow_overlap = allow_overlap self.method = method self.method_params = method_params or {} - super().__init__(on=on, masks=masks, name=name) + self.masks = masks + super().__init__(on=on, name=name) # Verify after super init so self._on is set if "BOLD" not in self._on and time_method is not None: diff --git a/junifer/markers/temporal_snr/temporal_snr_base.py b/junifer/markers/temporal_snr/temporal_snr_base.py index 072f68ff3..c0f946c12 100644 --- a/junifer/markers/temporal_snr/temporal_snr_base.py +++ b/junifer/markers/temporal_snr/temporal_snr_base.py @@ -54,7 +54,8 @@ class TemporalSNRBase(BaseMarker): ) -> None: self.agg_method = agg_method self.agg_method_params = agg_method_params - super().__init__(on="BOLD", masks=masks, name=name) + self.masks = masks + super().__init__(on="BOLD", name=name) @abstractmethod def aggregate( -- 2.52.0