Skip to content

Commit

Permalink
parse prerelease tag for AtlasConcepts and Features
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmetNSimsek committed Oct 15, 2024
1 parent 1df341a commit 61ff939
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 23 deletions.
16 changes: 14 additions & 2 deletions siibra/configuration/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def build_space(cls, spec):
modality=spec.get("modality"),
publications=spec.get("publications", []),
datasets=cls.extract_datasets(spec),
prerelease=spec.get("prerelease", False),
)

@classmethod
Expand All @@ -200,6 +201,7 @@ def build_region(cls, spec):
datasets=cls.extract_datasets(spec),
rgb=spec.get("rgb", None),
spec=spec,
prerelease=spec.get("prerelease", False),
)

@classmethod
Expand All @@ -222,6 +224,7 @@ def build_parcellation(cls, spec):
modality=spec.get('modality', ""),
publications=spec.get("publications", []),
datasets=cls.extract_datasets(spec),
prerelease=spec.get("prerelease", False),
)

# add version object, if any is specified
Expand Down Expand Up @@ -299,7 +302,8 @@ def build_map(cls, spec):
description=spec.get("description"),
modality=spec.get("modality"),
publications=spec.get("publications", []),
datasets=cls.extract_datasets(spec)
datasets=cls.extract_datasets(spec),
prerelease=spec.get("prerelease", False),
)

@classmethod
Expand Down Expand Up @@ -352,6 +356,7 @@ def build_receptor_density_fingerprint(cls, spec):
tsvfile=spec['file'],
anchor=cls.extract_anchor(spec),
datasets=cls.extract_datasets(spec),
prerelease=spec.get("prerelease", False),
)

@classmethod
Expand All @@ -362,6 +367,7 @@ def build_cell_density_fingerprint(cls, spec):
layerfiles=spec['layerfiles'],
anchor=cls.extract_anchor(spec),
datasets=cls.extract_datasets(spec),
prerelease=spec.get("prerelease", False),
)

@classmethod
Expand All @@ -372,6 +378,7 @@ def build_receptor_density_profile(cls, spec):
tsvfile=spec['file'],
anchor=cls.extract_anchor(spec),
datasets=cls.extract_datasets(spec),
prerelease=spec.get("prerelease", False),
)

@classmethod
Expand All @@ -383,6 +390,7 @@ def build_cell_density_profile(cls, spec):
url=spec['file'],
anchor=cls.extract_anchor(spec),
datasets=cls.extract_datasets(spec),
prerelease=spec.get("prerelease", False),
)

@classmethod
Expand All @@ -395,6 +403,7 @@ def build_section(cls, spec):
"space_spec": vol._space_spec,
"providers": vol._providers.values(),
"datasets": cls.extract_datasets(spec),
"prerelease": spec.get("prerelease", False),
}
modality = spec.get('modality', "")
if modality == "cell body staining":
Expand All @@ -412,6 +421,7 @@ def build_volume_of_interest(cls, spec):
"space_spec": vol._space_spec,
"providers": vol._providers.values(),
"datasets": cls.extract_datasets(spec),
"prerelease": spec.get("prerelease", False),
}
modality = spec.get('modality', "")
if modality == "cell body staining":
Expand Down Expand Up @@ -461,6 +471,7 @@ def build_connectivity_matrix(cls, spec):
"anchor": cls.extract_anchor(spec),
"description": spec.get("description", ""),
"datasets": cls.extract_datasets(spec),
"prerelease": spec.get("prerelease", False),
}
if modality == "StreamlineCounts":
return connectivity.StreamlineCounts(**kwargs)
Expand Down Expand Up @@ -491,7 +502,8 @@ def build_activity_timeseries(cls, spec):
"anchor": cls.extract_anchor(spec),
"description": spec.get("description", ""),
"datasets": cls.extract_datasets(spec),
"timestep": spec.get("timestep", ("1 no_unit"))
"timestep": spec.get("timestep", ("1 no_unit")),
"prerelease": spec.get("prerelease", False),
}
if modality == "Regional BOLD signal":
kwargs["paradigm"] = spec.get("paradigm", "")
Expand Down
5 changes: 3 additions & 2 deletions siibra/core/atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ class Atlas(concept.AtlasConcept, configuration_folder="atlases"):
spaces, as well as common functionalities of those.
"""

def __init__(self, identifier: str, name: str, species: Species):
def __init__(self, identifier: str, name: str, species: Species, prerelease: bool = False):
"""Construct an empty atlas object with a name and identifier."""

concept.AtlasConcept.__init__(
self,
identifier=identifier,
name=name,
species=species
species=species,
prerelease=prerelease
)
self._parcellation_ids: List[str] = []
self._space_ids: List[str] = []
Expand Down
6 changes: 4 additions & 2 deletions siibra/core/concept.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def __init__(
modality: str = "",
publications: List[TypePublication] = [],
datasets: List['TypeDataset'] = [],
spec=None
spec=None,
prerelease: bool = False,
):
"""
Construct a new atlas concept base object.
Expand All @@ -78,7 +79,7 @@ def __init__(
The preconfigured specification.
"""
self._id = identifier
self.name = name
self.name = name if not prerelease else f"[PRERELEASE] {name}"
self._species_cached = None if species is None \
else Species.decode(species) # overwritable property implementation below
self.shortname = shortname
Expand All @@ -87,6 +88,7 @@ def __init__(
self._publications = publications
self.datasets = datasets
self._spec = spec
self._prerelease = prerelease

@property
def description(self):
Expand Down
4 changes: 3 additions & 1 deletion siibra/core/parcellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def __init__(
modality: str = None,
publications: list = [],
datasets: list = [],
prerelease: bool = False,
):
"""
Constructs a new parcellation object.
Expand Down Expand Up @@ -118,7 +119,8 @@ def __init__(
description=description,
publications=publications,
datasets=datasets,
modality=modality
modality=modality,
prerelease=prerelease,
)
self._species_cached = Species.decode(species)
self._id = identifier
Expand Down
4 changes: 3 additions & 1 deletion siibra/core/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def __init__(
datasets: list = [],
rgb: str = None,
spec=None,
prerelease: bool = False,
):
"""
Constructs a new Region object.
Expand Down Expand Up @@ -119,7 +120,8 @@ def __init__(
modality=modality,
publications=publications,
datasets=datasets,
spec=spec
spec=spec,
prerelease=prerelease,
)

# anytree node will take care to use this appropriately
Expand Down
2 changes: 2 additions & 0 deletions siibra/core/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(
modality: str = "",
publications: list = [],
datasets: list = [],
prerelease: bool = False,
):
"""
Constructs a new parcellation object.
Expand Down Expand Up @@ -76,6 +77,7 @@ def __init__(
modality=modality,
publications=publications,
datasets=datasets,
prerelease=prerelease,
)
self.volumes = volumes
for v in self.volumes:
Expand Down
2 changes: 2 additions & 0 deletions siibra/features/connectivity/regional_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(
anchor: _anchor.AnatomicalAnchor,
description: str = "",
datasets: list = [],
prerelease: bool = False,
):
"""
Construct a parcellation-averaged connectivity matrix.
Expand Down Expand Up @@ -84,6 +85,7 @@ def __init__(
description=description or '\n'.join({ds.description for ds in datasets}),
anchor=anchor,
datasets=datasets,
prerelease=prerelease,
)
self.cohort = cohort.upper()
self._connector = connector
Expand Down
7 changes: 5 additions & 2 deletions siibra/features/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def __init__(
modality: str,
description: str,
anchor: _anchor.AnatomicalAnchor,
datasets: List['TypeDataset'] = []
datasets: List['TypeDataset'] = [],
prerelease: bool = False,
):
"""
Parameters
Expand All @@ -109,6 +110,7 @@ def __init__(
self._description = description
self._anchor_cached = anchor
self.datasets = datasets
self._prerelease = prerelease

@property
def modality(self):
Expand Down Expand Up @@ -183,7 +185,8 @@ def authors(self):
@property
def name(self):
"""Returns a short human-readable name of this feature."""
return f"{self.__class__.__name__} ({self.modality}) anchored at {self.anchor}"
name_ = f"{self.__class__.__name__} ({self.modality}) anchored at {self.anchor}"
return name_ if not self._prerelease else f"[PRERELEASE] {name_}"

@classmethod
def get_instances(cls, **kwargs) -> List['Feature']:
Expand Down
4 changes: 3 additions & 1 deletion siibra/features/image/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ def __init__(
providers: List[_volume.VolumeProvider],
region: str = None,
datasets: List = [],
prerelease: bool = False,
):
feature.Feature.__init__(
self,
modality=modality,
description=None, # lazy implementation below!
anchor=None, # lazy implementation below!
datasets=datasets
datasets=datasets,
prerelease=prerelease,
)

_volume.Volume.__init__(
Expand Down
4 changes: 3 additions & 1 deletion siibra/features/tabular/cell_density_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def __init__(
patch: int,
url: str,
anchor: _anchor.AnatomicalAnchor,
datasets: list = []
datasets: list = [],
prerelease: bool = False,
):
"""
Generate a cell density profile from a URL to a cloud folder
Expand All @@ -80,6 +81,7 @@ def __init__(
unit="detected cells / 0.1mm3",
anchor=anchor,
datasets=datasets,
prerelease=prerelease,
)
self._step = 0.01
self._url = url
Expand Down
6 changes: 4 additions & 2 deletions siibra/features/tabular/cortical_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def __init__(
values: Union[list, np.ndarray] = None,
unit: str = None,
boundary_positions: Dict[Tuple[int, int], float] = None,
datasets: list = []
datasets: list = [],
prerelease: bool = False,
):
"""Initialize profile.
Expand Down Expand Up @@ -92,7 +93,8 @@ def __init__(
description=description,
anchor=anchor,
data=None, # lazy loader below
datasets=datasets
datasets=datasets,
prerelease=prerelease,
)

def _check_sanity(self):
Expand Down
4 changes: 3 additions & 1 deletion siibra/features/tabular/layerwise_cell_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ def __init__(
layerfiles: list,
anchor: _anchor.AnatomicalAnchor,
datasets: list = [],
prerelease: bool = False,
):
tabular.Tabular.__init__(
self,
description=self.DESCRIPTION,
modality="Cell body density",
anchor=anchor,
datasets=datasets,
data=None # lazy loading below
data=None, # lazy loading below
prerelease=prerelease,
)
self.unit = "# detected cells/0.1mm3"
self._filepairs = list(zip(segmentfiles, layerfiles))
Expand Down
4 changes: 3 additions & 1 deletion siibra/features/tabular/receptor_density_fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def __init__(
self,
tsvfile: str,
anchor: _anchor.AnatomicalAnchor,
datasets: list = []
datasets: list = [],
prerelease: bool = False,
):
""" Generate a receptor fingerprint from a URL to a .tsv file
formatted according to the structure used by Palomero-Gallagher et al.
Expand All @@ -54,6 +55,7 @@ def __init__(
anchor=anchor,
data=None, # lazy loading below
datasets=datasets,
prerelease=prerelease,
)
self._loader = requests.HttpRequest(tsvfile)

Expand Down
4 changes: 3 additions & 1 deletion siibra/features/tabular/receptor_density_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def __init__(
receptor: str,
tsvfile: str,
anchor: _anchor.AnatomicalAnchor,
datasets: list = []
datasets: list = [],
prerelease: bool = False,
):
"""Generate a receptor density profile from a URL to a .tsv file
formatted according to the structure used by Palomero-Gallagher et al.
Expand All @@ -50,6 +51,7 @@ def __init__(
modality=f"{receptor} receptor density",
anchor=anchor,
datasets=datasets,
prerelease=prerelease,
)
self.type = receptor
self._data_cached = None
Expand Down
6 changes: 4 additions & 2 deletions siibra/features/tabular/regional_timeseries_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def __init__(
timestep: str,
description: str = "",
datasets: list = [],
paradigm: str = ""
paradigm: str = "",
prerelease: bool = False,
):
"""
"""
Expand All @@ -57,7 +58,8 @@ def __init__(
description=description or '\n'.join({ds.description for ds in datasets}),
anchor=anchor,
datasets=datasets,
data=None # lazy loading below
data=None, # lazy loading below
prerelease=prerelease
)
self.cohort = cohort.upper()
self._connector = connector
Expand Down
6 changes: 4 additions & 2 deletions siibra/features/tabular/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ def __init__(
modality: str,
anchor: _anchor.AnatomicalAnchor,
data: pd.DataFrame, # sample x feature dimension
datasets: list = []
datasets: list = [],
prerelease: bool = False,
):
feature.Feature.__init__(
self,
modality=modality,
description=description,
anchor=anchor,
datasets=datasets
datasets=datasets,
prerelease=prerelease,
)
self._data_cached = data

Expand Down
Loading

0 comments on commit 61ff939

Please sign in to comment.