Skip to content

Commit 6c09878

Browse files
committed
parse prerelease tag for AtlasConcepts and Features
1 parent 19b6e64 commit 6c09878

17 files changed

+75
-35
lines changed

siibra/configuration/factory.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def build_atlas(cls, spec):
180180
spec["@id"],
181181
spec["name"],
182182
species=Species.decode(spec.get('species')),
183+
prerelease=spec.get("prerelease", False),
183184
)
184185
for space_id in spec["spaces"]:
185186
a._register_space(space_id)
@@ -200,6 +201,7 @@ def build_space(cls, spec):
200201
modality=spec.get("modality"),
201202
publications=spec.get("publications", []),
202203
datasets=cls.extract_datasets(spec),
204+
prerelease=spec.get("prerelease", False),
203205
)
204206

205207
@classmethod
@@ -213,6 +215,7 @@ def build_region(cls, spec):
213215
datasets=cls.extract_datasets(spec),
214216
rgb=spec.get("rgb", None),
215217
spec=spec,
218+
prerelease=spec.get("prerelease", False),
216219
)
217220

218221
@classmethod
@@ -235,6 +238,7 @@ def build_parcellation(cls, spec):
235238
modality=spec.get('modality', ""),
236239
publications=spec.get("publications", []),
237240
datasets=cls.extract_datasets(spec),
241+
prerelease=spec.get("prerelease", False),
238242
)
239243

240244
# add version object, if any is specified
@@ -303,7 +307,8 @@ def build_map(cls, spec):
303307
description=spec.get("description"),
304308
modality=spec.get("modality"),
305309
publications=spec.get("publications", []),
306-
datasets=cls.extract_datasets(spec)
310+
datasets=cls.extract_datasets(spec),
311+
prerelease=spec.get("prerelease", False),
307312
)
308313

309314
@classmethod
@@ -421,7 +426,8 @@ def build_volume_of_interest(cls, spec):
421426
"space_spec": vol._space_spec,
422427
"providers": vol._providers.values(),
423428
"datasets": cls.extract_datasets(spec),
424-
"id": spec.get("@id", None)
429+
"id": spec.get("@id", None),
430+
"prerelease": spec.get("prerelease", False),
425431
}
426432
modality = spec.get('modality', "")
427433
if modality == "cell body staining":
@@ -479,7 +485,8 @@ def build_connectivity_matrix(cls, spec):
479485
"decode_func": decoder_func,
480486
"anchor": cls.extract_anchor(spec),
481487
"description": spec.get("description", ""),
482-
"datasets": cls.extract_datasets(spec)
488+
"datasets": cls.extract_datasets(spec),
489+
"prerelease": spec.get("prerelease", False),
483490
}
484491
paradigm = spec.get("paradigm")
485492
if paradigm:
@@ -517,7 +524,8 @@ def build_activity_timeseries(cls, spec):
517524
"anchor": cls.extract_anchor(spec),
518525
"description": spec.get("description", ""),
519526
"datasets": cls.extract_datasets(spec),
520-
"timestep": spec.get("timestep")
527+
"timestep": spec.get("timestep"),
528+
"prerelease": spec.get("prerelease", False),
521529
}
522530
paradigm = spec.get("paradigm")
523531
if paradigm:

siibra/core/atlas.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ class Atlas(concept.AtlasConcept, configuration_folder="atlases"):
3030
spaces, as well as common functionalities of those.
3131
"""
3232

33-
def __init__(self, identifier: str, name: str, species: Species):
33+
def __init__(self, identifier: str, name: str, species: Species, **kwargs):
3434
"""Construct an empty atlas object with a name and identifier."""
3535

3636
concept.AtlasConcept.__init__(
3737
self,
3838
identifier=identifier,
3939
name=name,
40-
species=species
40+
species=species,
41+
**kwargs
4142
)
4243
self._parcellation_ids: List[str] = []
4344
self._space_ids: List[str] = []

siibra/core/concept.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ def __init__(
6767
modality: str = "",
6868
publications: List[TypePublication] = [],
6969
datasets: List['TypeDataset'] = [],
70-
spec=None
70+
spec=None,
71+
prerelease: bool = False,
7172
):
7273
"""
7374
Construct a new atlas concept base object.
@@ -94,7 +95,7 @@ def __init__(
9495
The preconfigured specification.
9596
"""
9697
self._id = identifier
97-
self.name = name
98+
self.name = name if not prerelease else f"[PRERELEASE] {name}"
9899
self._species_cached = None if species is None \
99100
else Species.decode(species) # overwritable property implementation below
100101
self.shortname = shortname
@@ -104,6 +105,7 @@ def __init__(
104105
self.datasets = datasets
105106
self._spec = spec
106107
self._CACHED_MATCHES = {} # we cache match() function results
108+
self._prerelease = prerelease
107109

108110
@property
109111
def description(self):

siibra/core/parcellation.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def __init__(
8282
modality: str = None,
8383
publications: list = [],
8484
datasets: list = [],
85+
prerelease: bool = False,
8586
):
8687
"""
8788
Constructs a new parcellation object.
@@ -118,7 +119,8 @@ def __init__(
118119
description=description,
119120
publications=publications,
120121
datasets=datasets,
121-
modality=modality
122+
modality=modality,
123+
prerelease=prerelease,
122124
)
123125
self._species_cached = Species.decode(species)
124126
self._id = identifier

siibra/core/region.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def __init__(
8585
datasets: list = [],
8686
rgb: str = None,
8787
spec=None,
88+
prerelease: bool = False,
8889
):
8990
"""
9091
Constructs a new Region object.
@@ -122,7 +123,8 @@ def __init__(
122123
modality=modality,
123124
publications=publications,
124125
datasets=datasets,
125-
spec=spec
126+
spec=spec,
127+
prerelease=prerelease,
126128
)
127129

128130
# anytree node will take care to use this appropriately

siibra/core/space.py

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(
3838
modality: str = "",
3939
publications: list = [],
4040
datasets: list = [],
41+
prerelease: bool = False,
4142
):
4243
"""
4344
Constructs a new parcellation object.
@@ -75,6 +76,7 @@ def __init__(
7576
modality=modality,
7677
publications=publications,
7778
datasets=datasets,
79+
prerelease=prerelease,
7880
)
7981
self.volumes = volumes
8082
for v in self.volumes:

siibra/features/connectivity/regional_connectivity.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def __init__(
5858
datasets: list = [],
5959
subject: str = "average",
6060
feature: str = None,
61-
id: str = None
61+
id: str = None,
62+
prerelease: bool = False,
6263
):
6364
"""
6465
Construct a parcellation-averaged connectivity matrix.
@@ -92,7 +93,8 @@ def __init__(
9293
description=description,
9394
anchor=anchor,
9495
datasets=datasets,
95-
id=id
96+
id=id,
97+
prerelease=prerelease
9698
)
9799
self.cohort = cohort.upper()
98100
if isinstance(connector, str) and connector:

siibra/features/feature.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ def __init__(
9999
description: str,
100100
anchor: _anchor.AnatomicalAnchor,
101101
datasets: List['TypeDataset'] = [],
102-
id: str = None
102+
id: str = None,
103+
prerelease: bool = False,
103104
):
104105
"""
105106
Parameters
@@ -117,6 +118,7 @@ def __init__(
117118
self._anchor_cached = anchor
118119
self.datasets = datasets
119120
self._id = id
121+
self._prerelease = prerelease
120122

121123
@property
122124
def modality(self):
@@ -199,7 +201,8 @@ def authors(self):
199201
def name(self):
200202
"""Returns a short human-readable name of this feature."""
201203
readable_class_name = sub("([a-z])([A-Z])", r"\g<1> \g<2>", self.__class__.__name__)
202-
return sub("([b,B]ig [b,B]rain)", "BigBrain", readable_class_name)
204+
name_ = sub("([b,B]ig [b,B]rain)", "BigBrain", readable_class_name)
205+
return name_ if not self._prerelease else f"[PRERELEASE] {name_}"
203206

204207
@classmethod
205208
def _get_instances(cls, **kwargs) -> List['Feature']:
@@ -724,7 +727,7 @@ class CompoundFeature(Feature):
724727
def __init__(
725728
self,
726729
elements: List['Feature'],
727-
queryconcept: Union[region.Region, parcellation.Parcellation, space.Space]
730+
queryconcept: Union[region.Region, parcellation.Parcellation, space.Space],
728731
):
729732
"""
730733
A compound of several features of the same type with an anchor created
@@ -757,7 +760,8 @@ def __init__(
757760
modality=modality,
758761
description="\n".join({f.description for f in elements}),
759762
anchor=self._feature_type._merge_anchors([f.anchor for f in elements]),
760-
datasets=list(dict.fromkeys([ds for f in elements for ds in f.datasets]))
763+
datasets=list(dict.fromkeys([ds for f in elements for ds in f.datasets])),
764+
prerelease=all(f._prerelease for f in elements),
761765
)
762766
self._queryconcept = queryconcept
763767
self._merged_feature_cached = None
@@ -833,7 +837,8 @@ def name(self) -> str:
833837
for k, v in self._compounding_attributes.items()
834838
if k != 'modality'
835839
])
836-
return f"{len(self)} {readable_feature_type} features{f' {groupby}' if groupby else ''}"
840+
cf_name = f"{len(self)} {readable_feature_type} features{f' {groupby}' if groupby else ''}"
841+
return cf_name if not self._prerelease else f"[PRERELEASE] {cf_name}"
837842

838843
@property
839844
def id(self) -> str:

siibra/features/image/image.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,17 @@ def __init__(
6363
providers: List[provider.VolumeProvider],
6464
region: str = None,
6565
datasets: List = [],
66-
id: str = None
66+
id: str = None,
67+
prerelease: bool = False,
6768
):
6869
feature.Feature.__init__(
6970
self,
7071
modality=modality,
7172
description=None, # lazy implementation below!
7273
anchor=None, # lazy implementation below!
7374
datasets=datasets,
74-
id=id
75+
id=id,
76+
prerelease=prerelease
7577
)
7678

7779
_volume.Volume.__init__(

siibra/features/tabular/cell_density_profile.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def __init__(
7070
url: str,
7171
anchor: _anchor.AnatomicalAnchor,
7272
datasets: list = [],
73-
id: str = None
73+
id: str = None,
74+
prerelease: bool = False,
7475
):
7576
"""
7677
Generate a cell density profile from a URL to a cloud folder
@@ -83,7 +84,8 @@ def __init__(
8384
unit="cells / 0.1mm3",
8485
anchor=anchor,
8586
datasets=datasets,
86-
id=id
87+
id=id,
88+
prerelease=prerelease,
8789
)
8890
self._step = 0.01
8991
self._url = url

siibra/features/tabular/cortical_profile.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def __init__(
5757
unit: str = None,
5858
boundary_positions: Dict[Tuple[int, int], float] = None,
5959
datasets: list = [],
60-
id: str = None
60+
id: str = None,
61+
prerelease: bool = False,
6162
):
6263
"""Initialize profile.
6364
@@ -98,7 +99,8 @@ def __init__(
9899
anchor=anchor,
99100
data=None, # lazy loader below
100101
datasets=datasets,
101-
id=id
102+
id=id,
103+
prerelease=prerelease,
102104
)
103105

104106
def _check_sanity(self):

siibra/features/tabular/receptor_density_fingerprint.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def __init__(
4343
tsvfile: str,
4444
anchor: _anchor.AnatomicalAnchor,
4545
datasets: list = [],
46-
id: str = None
46+
id: str = None,
47+
prerelease: bool = False,
4748
):
4849
""" Generate a receptor fingerprint from a URL to a .tsv file
4950
formatted according to the structure used by Palomero-Gallagher et al.
@@ -55,7 +56,8 @@ def __init__(
5556
anchor=anchor,
5657
data=None, # lazy loading below
5758
datasets=datasets,
58-
id=id
59+
id=id,
60+
prerelease=prerelease,
5961
)
6062
self._loader = requests.HttpRequest(tsvfile)
6163

siibra/features/tabular/receptor_density_profile.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def __init__(
4242
tsvfile: str,
4343
anchor: _anchor.AnatomicalAnchor,
4444
datasets: list = [],
45-
id: str = None
45+
id: str = None,
46+
prerelease: bool = False,
4647
):
4748
"""Generate a receptor density profile from a URL to a .tsv file
4849
formatted according to the structure used by Palomero-Gallagher et al.
@@ -53,7 +54,8 @@ def __init__(
5354
modality="Receptor density",
5455
anchor=anchor,
5556
datasets=datasets,
56-
id=id
57+
id=id,
58+
prerelease=prerelease
5759
)
5860
self.receptor = receptor
5961
self._data_cached = None

siibra/features/tabular/regional_timeseries_activity.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def __init__(
4949
description: str = "",
5050
datasets: list = [],
5151
subject: str = "average",
52-
id: str = None
52+
id: str = None,
53+
prerelease: bool = False,
5354
):
5455
"""
5556
"""
@@ -60,7 +61,8 @@ def __init__(
6061
anchor=anchor,
6162
datasets=datasets,
6263
data=None, # lazy loading below
63-
id=id
64+
id=id,
65+
prerelease=prerelease,
6466
)
6567
self.cohort = cohort.upper()
6668
if isinstance(connector, str) and connector:

siibra/features/tabular/tabular.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,17 @@ def __init__(
4545
anchor: _anchor.AnatomicalAnchor,
4646
data: pd.DataFrame, # sample x feature dimension
4747
datasets: list = [],
48-
id: str = None
48+
id: str = None,
49+
prerelease: bool = False,
4950
):
5051
feature.Feature.__init__(
5152
self,
5253
modality=modality,
5354
description=description,
5455
anchor=anchor,
5556
datasets=datasets,
56-
id=id
57+
id=id,
58+
prerelease=prerelease
5759
)
5860
self._data_cached = data
5961

0 commit comments

Comments
 (0)