siibra 0.4a33__py3-none-any.whl → 0.4a46__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of siibra might be problematic. Click here for more details.
- siibra/VERSION +1 -1
- siibra/__init__.py +2 -0
- siibra/commons.py +53 -8
- siibra/configuration/configuration.py +21 -17
- siibra/configuration/factory.py +95 -19
- siibra/core/atlas.py +11 -8
- siibra/core/concept.py +41 -8
- siibra/core/parcellation.py +94 -43
- siibra/core/region.py +160 -187
- siibra/core/space.py +44 -39
- siibra/features/__init__.py +19 -19
- siibra/features/anchor.py +9 -6
- siibra/features/connectivity/__init__.py +0 -8
- siibra/features/connectivity/functional_connectivity.py +11 -3
- siibra/features/{basetypes → connectivity}/regional_connectivity.py +46 -33
- siibra/features/connectivity/streamline_counts.py +3 -2
- siibra/features/connectivity/streamline_lengths.py +3 -2
- siibra/features/{basetypes → dataset}/__init__.py +2 -0
- siibra/features/{external → dataset}/ebrains.py +3 -3
- siibra/features/feature.py +420 -0
- siibra/{samplers → features/image}/__init__.py +7 -1
- siibra/features/{basetypes/volume_of_interest.py → image/image.py} +12 -7
- siibra/features/{external/__init__.py → image/sections.py} +8 -5
- siibra/features/image/volume_of_interest.py +70 -0
- siibra/features/{cellular → tabular}/__init__.py +7 -11
- siibra/features/{cellular → tabular}/bigbrain_intensity_profile.py +5 -2
- siibra/features/{cellular → tabular}/cell_density_profile.py +6 -2
- siibra/features/{basetypes → tabular}/cortical_profile.py +48 -41
- siibra/features/{molecular → tabular}/gene_expression.py +5 -2
- siibra/features/{cellular → tabular}/layerwise_bigbrain_intensities.py +6 -2
- siibra/features/{cellular → tabular}/layerwise_cell_density.py +9 -3
- siibra/features/{molecular → tabular}/receptor_density_fingerprint.py +3 -2
- siibra/features/{molecular → tabular}/receptor_density_profile.py +6 -2
- siibra/features/tabular/regional_timeseries_activity.py +213 -0
- siibra/features/{basetypes → tabular}/tabular.py +14 -9
- siibra/livequeries/allen.py +1 -1
- siibra/livequeries/bigbrain.py +2 -3
- siibra/livequeries/ebrains.py +3 -9
- siibra/livequeries/query.py +1 -1
- siibra/locations/location.py +4 -3
- siibra/locations/point.py +21 -17
- siibra/locations/pointset.py +2 -2
- siibra/retrieval/__init__.py +1 -1
- siibra/retrieval/cache.py +8 -2
- siibra/retrieval/datasets.py +149 -29
- siibra/retrieval/repositories.py +19 -8
- siibra/retrieval/requests.py +98 -116
- siibra/volumes/gifti.py +26 -11
- siibra/volumes/neuroglancer.py +35 -19
- siibra/volumes/nifti.py +8 -9
- siibra/volumes/parcellationmap.py +341 -184
- siibra/volumes/sparsemap.py +67 -53
- siibra/volumes/volume.py +25 -13
- {siibra-0.4a33.dist-info → siibra-0.4a46.dist-info}/METADATA +4 -3
- siibra-0.4a46.dist-info/RECORD +69 -0
- {siibra-0.4a33.dist-info → siibra-0.4a46.dist-info}/WHEEL +1 -1
- siibra/features/basetypes/feature.py +0 -248
- siibra/features/fibres/__init__.py +0 -14
- siibra/features/functional/__init__.py +0 -14
- siibra/features/molecular/__init__.py +0 -26
- siibra/samplers/bigbrain.py +0 -181
- siibra-0.4a33.dist-info/RECORD +0 -71
- {siibra-0.4a33.dist-info → siibra-0.4a46.dist-info}/LICENSE +0 -0
- {siibra-0.4a33.dist-info → siibra-0.4a46.dist-info}/top_level.txt +0 -0
siibra/core/parcellation.py
CHANGED
|
@@ -96,7 +96,7 @@ class Parcellation(region.Region, configuration_folder="parcellations"):
|
|
|
96
96
|
Specification of the species
|
|
97
97
|
regions: list or Region
|
|
98
98
|
shortname: str
|
|
99
|
-
|
|
99
|
+
Short form of human-readable name (optional)
|
|
100
100
|
description: str
|
|
101
101
|
Textual description of the parcellation
|
|
102
102
|
version : str or None
|
|
@@ -104,7 +104,8 @@ class Parcellation(region.Region, configuration_folder="parcellations"):
|
|
|
104
104
|
modality : str or None
|
|
105
105
|
Specification of the modality used for creating the parcellation
|
|
106
106
|
publications: list
|
|
107
|
-
List of
|
|
107
|
+
List of associated publications, each a dictionary with "doi"
|
|
108
|
+
and/or "citation" fields
|
|
108
109
|
datasets : list
|
|
109
110
|
datasets associated with this region
|
|
110
111
|
"""
|
|
@@ -136,25 +137,34 @@ class Parcellation(region.Region, configuration_folder="parcellations"):
|
|
|
136
137
|
return True
|
|
137
138
|
return super().matches(spec)
|
|
138
139
|
|
|
139
|
-
def get_map(self, space=None, maptype: Union[str, MapType] = MapType.LABELLED):
|
|
140
|
+
def get_map(self, space=None, maptype: Union[str, MapType] = MapType.LABELLED, spec: str = ""):
|
|
140
141
|
"""
|
|
141
|
-
Get the maps for the parcellation in the requested
|
|
142
|
-
|
|
143
|
-
3D volumes. For example,
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
Get the maps for the parcellation in the requested template space.
|
|
143
|
+
|
|
144
|
+
This might in general include multiple 3D volumes. For example,
|
|
145
|
+
the Julich-Brain atlas provides two separate maps, one per hemisphere.
|
|
146
|
+
Per default, multiple maps are concatenated into a 4D array, but you
|
|
147
|
+
can choose to retrieve a dict of 3D volumes instead using
|
|
148
|
+
`return_dict=True`.
|
|
146
149
|
|
|
147
150
|
Parameters
|
|
148
151
|
----------
|
|
149
|
-
space
|
|
152
|
+
space: Space or str
|
|
150
153
|
template space specification
|
|
151
|
-
maptype
|
|
152
|
-
Type of map requested (e.g.,
|
|
154
|
+
maptype: MapType
|
|
155
|
+
Type of map requested (e.g., statistical or labelled).
|
|
153
156
|
Use MapType.STATISTICAL to request probability maps.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
Defaults to MapType.LABELLED.
|
|
158
|
+
spec: str, optional
|
|
159
|
+
In case of multiple matching maps for the given parcellation, space
|
|
160
|
+
and type, use this field to specify keywords matching the desired
|
|
161
|
+
parcellation map name. Otherwise, siibra will default to the first
|
|
162
|
+
in the list of matches (and inform with a log message)
|
|
163
|
+
Returns
|
|
164
|
+
-------
|
|
165
|
+
parcellationmap.Map or SparseMap
|
|
166
|
+
A ParcellationMap representing the volumetric map or
|
|
167
|
+
a SparseMap representing the list of statistical maps.
|
|
158
168
|
"""
|
|
159
169
|
if not isinstance(maptype, MapType):
|
|
160
170
|
maptype = MapType[maptype.upper()]
|
|
@@ -170,16 +180,47 @@ class Parcellation(region.Region, configuration_folder="parcellations"):
|
|
|
170
180
|
logger.error(f"No {maptype} map in {space} available for {str(self)}")
|
|
171
181
|
return None
|
|
172
182
|
if len(candidates) > 1:
|
|
173
|
-
|
|
183
|
+
spec_candidates = [
|
|
184
|
+
c for c in candidates if all(w.lower() in c.name.lower() for w in spec.split())
|
|
185
|
+
]
|
|
186
|
+
if len(spec_candidates) == 0:
|
|
187
|
+
logger.warning(f"'{spec}' does not match any options from {[c.name for c in candidates]}.")
|
|
188
|
+
return None
|
|
189
|
+
if len(spec_candidates) > 1:
|
|
190
|
+
logger.warning(
|
|
191
|
+
f"Multiple maps are available in this specification of space, parcellation, and map type.\n"
|
|
192
|
+
f"Choosing the first map from {[c.name for c in spec_candidates]}."
|
|
193
|
+
)
|
|
194
|
+
return spec_candidates[0]
|
|
174
195
|
return candidates[0]
|
|
175
196
|
|
|
176
|
-
@
|
|
177
|
-
def find_regions(
|
|
178
|
-
|
|
197
|
+
@staticmethod
|
|
198
|
+
def find_regions(region_spec: str, parents_only=True):
|
|
199
|
+
"""
|
|
200
|
+
Find regions that match the given region specification in the subtree
|
|
201
|
+
headed by each parcellation in the registry.
|
|
202
|
+
Note
|
|
203
|
+
----
|
|
204
|
+
Use Region.find() to search for a region in an instance of a
|
|
205
|
+
parcellation.
|
|
206
|
+
|
|
207
|
+
Parameters
|
|
208
|
+
----------
|
|
209
|
+
regionspec: str
|
|
210
|
+
a string with a possibly inexact name, which is matched both
|
|
211
|
+
against the name and the identifier key,
|
|
212
|
+
parents_only: bool
|
|
213
|
+
If true, children of matched parents will not be returned
|
|
214
|
+
Returns
|
|
215
|
+
-------
|
|
216
|
+
List[Region]
|
|
217
|
+
list of matching regions
|
|
218
|
+
"""
|
|
219
|
+
MEM = Parcellation._CACHED_REGION_SEARCHES
|
|
179
220
|
if region_spec not in MEM:
|
|
180
221
|
MEM[region_spec] = [
|
|
181
222
|
r
|
|
182
|
-
for p in
|
|
223
|
+
for p in Parcellation.registry()
|
|
183
224
|
for r in p.find(regionspec=region_spec)
|
|
184
225
|
]
|
|
185
226
|
if parents_only:
|
|
@@ -216,41 +257,47 @@ class Parcellation(region.Region, configuration_folder="parcellations"):
|
|
|
216
257
|
else:
|
|
217
258
|
return [spec]
|
|
218
259
|
|
|
219
|
-
def get_region(
|
|
260
|
+
def get_region(
|
|
261
|
+
self,
|
|
262
|
+
regionspec: Union[str, region.Region],
|
|
263
|
+
find_topmost: bool = True,
|
|
264
|
+
allow_tuple: bool = False
|
|
265
|
+
):
|
|
220
266
|
"""
|
|
221
267
|
Given a unique specification, return the corresponding region.
|
|
222
|
-
|
|
223
|
-
region object.
|
|
268
|
+
|
|
269
|
+
The spec could be a (possibly incomplete) name, or a region object.
|
|
224
270
|
This method is meant to definitely determine a valid region. Therefore,
|
|
225
|
-
if no match is found, it raises a ValueError.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
allow_tuple=True - then a tuple of matched regions is returned
|
|
271
|
+
if no match is found, it raises a ValueError. If multiple matches are
|
|
272
|
+
found, the method tries to return only the common parent node. If there
|
|
273
|
+
is no common parent, an exception is raised, except when
|
|
274
|
+
allow_tuple=True - then a tuple of matched regions is returned.
|
|
229
275
|
|
|
230
276
|
Parameters
|
|
231
277
|
----------
|
|
232
|
-
regionspec
|
|
233
|
-
- a string with a possibly inexact name
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
- a region object
|
|
237
|
-
- a full MapIndex
|
|
238
|
-
find_topmost : Bool, default: True
|
|
278
|
+
regionspec: str, Region
|
|
279
|
+
- a string with a possibly inexact name (matched both against the name and the identifier key)
|
|
280
|
+
- a Region object
|
|
281
|
+
find_topmost: bool, default: True
|
|
239
282
|
If True, will automatically return the parent of a decoded region
|
|
240
283
|
the decoded region is its only child.
|
|
241
|
-
allow_tuple:
|
|
284
|
+
allow_tuple: bool, default: False
|
|
242
285
|
If multiple candidates without a common parent are found,
|
|
243
286
|
return a tuple of matches instead of raising an exception.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
Region
|
|
287
|
+
|
|
288
|
+
Returns
|
|
289
|
+
-------
|
|
290
|
+
Region
|
|
291
|
+
A region object defined in the parcellation
|
|
248
292
|
|
|
249
293
|
Raises
|
|
250
294
|
------
|
|
251
|
-
RuntimeError
|
|
252
|
-
|
|
295
|
+
RuntimeError
|
|
296
|
+
If the spec matches multiple regions
|
|
297
|
+
ValueError
|
|
298
|
+
If the spec cannot be matched against any region
|
|
253
299
|
"""
|
|
300
|
+
assert isinstance(regionspec, (str, region.Region)), f"get_region takes str or Region but you provided {type(regionspec)}"
|
|
254
301
|
if isinstance(regionspec, region.Region) and (regionspec.parcellation == self):
|
|
255
302
|
return regionspec
|
|
256
303
|
|
|
@@ -263,6 +310,10 @@ class Parcellation(region.Region, configuration_folder="parcellations"):
|
|
|
263
310
|
else:
|
|
264
311
|
candidates = self.find(regionspec, filter_children=True, find_topmost=find_topmost)
|
|
265
312
|
|
|
313
|
+
exact_matches = [r for r in candidates if regionspec == r]
|
|
314
|
+
if len(exact_matches) == 1:
|
|
315
|
+
return exact_matches[0]
|
|
316
|
+
|
|
266
317
|
if len(candidates) > 1 and isinstance(regionspec, str):
|
|
267
318
|
# if we have an exact match of words in one region, discard other candidates.
|
|
268
319
|
querywords = {w.replace(',', '').lower() for w in regionspec.split()}
|
|
@@ -282,7 +333,7 @@ class Parcellation(region.Region, configuration_folder="parcellations"):
|
|
|
282
333
|
if allow_tuple:
|
|
283
334
|
return tuple(candidates)
|
|
284
335
|
raise RuntimeError(
|
|
285
|
-
f"Spec {regionspec} resulted in multiple matches: {', '.join(r.name for r in candidates)}."
|
|
336
|
+
f"Spec {regionspec!r} resulted in multiple matches: {', '.join(r.name for r in candidates)}."
|
|
286
337
|
)
|
|
287
338
|
|
|
288
339
|
def __str__(self):
|
|
@@ -302,7 +353,7 @@ class Parcellation(region.Region, configuration_folder="parcellations"):
|
|
|
302
353
|
We sort parcellations by their version
|
|
303
354
|
"""
|
|
304
355
|
if (self.version is None) or (other.version is None):
|
|
305
|
-
logger.
|
|
356
|
+
logger.warning(
|
|
306
357
|
f"Sorting non-versioned instances of {self.__class__.__name__} "
|
|
307
358
|
f"by name: {self.name}, {other.name}"
|
|
308
359
|
)
|