siibra 1.0a14__py3-none-any.whl → 1.0.1a0__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 +15 -5
- siibra/commons.py +3 -48
- siibra/configuration/__init__.py +1 -1
- siibra/configuration/configuration.py +1 -1
- siibra/configuration/factory.py +164 -127
- siibra/core/__init__.py +1 -1
- siibra/core/assignment.py +1 -1
- siibra/core/atlas.py +24 -17
- siibra/core/concept.py +18 -9
- siibra/core/parcellation.py +76 -55
- siibra/core/region.py +163 -183
- siibra/core/space.py +3 -1
- siibra/core/structure.py +1 -2
- siibra/exceptions.py +17 -1
- siibra/experimental/contour.py +6 -6
- siibra/experimental/patch.py +2 -2
- siibra/experimental/plane3d.py +8 -8
- siibra/explorer/__init__.py +1 -1
- siibra/explorer/url.py +15 -0
- siibra/explorer/util.py +1 -1
- siibra/features/__init__.py +1 -1
- siibra/features/anchor.py +13 -14
- siibra/features/connectivity/__init__.py +1 -1
- siibra/features/connectivity/functional_connectivity.py +1 -1
- siibra/features/connectivity/regional_connectivity.py +7 -5
- siibra/features/connectivity/streamline_counts.py +1 -1
- siibra/features/connectivity/streamline_lengths.py +1 -1
- siibra/features/connectivity/tracing_connectivity.py +1 -1
- siibra/features/dataset/__init__.py +1 -1
- siibra/features/dataset/ebrains.py +1 -1
- siibra/features/feature.py +50 -28
- siibra/features/image/__init__.py +1 -1
- siibra/features/image/image.py +18 -13
- siibra/features/image/sections.py +1 -1
- siibra/features/image/volume_of_interest.py +1 -1
- siibra/features/tabular/__init__.py +1 -1
- siibra/features/tabular/bigbrain_intensity_profile.py +2 -2
- siibra/features/tabular/cell_density_profile.py +102 -66
- siibra/features/tabular/cortical_profile.py +5 -3
- siibra/features/tabular/gene_expression.py +1 -1
- siibra/features/tabular/layerwise_bigbrain_intensities.py +1 -1
- siibra/features/tabular/layerwise_cell_density.py +8 -25
- siibra/features/tabular/receptor_density_fingerprint.py +5 -3
- siibra/features/tabular/receptor_density_profile.py +5 -3
- siibra/features/tabular/regional_timeseries_activity.py +7 -5
- siibra/features/tabular/tabular.py +5 -3
- siibra/livequeries/__init__.py +1 -1
- siibra/livequeries/allen.py +46 -20
- siibra/livequeries/bigbrain.py +9 -9
- siibra/livequeries/ebrains.py +1 -1
- siibra/livequeries/query.py +1 -2
- siibra/locations/__init__.py +10 -10
- siibra/locations/boundingbox.py +77 -38
- siibra/locations/location.py +12 -4
- siibra/locations/point.py +14 -9
- siibra/locations/{pointset.py → pointcloud.py} +69 -27
- siibra/retrieval/__init__.py +1 -1
- siibra/retrieval/cache.py +1 -1
- siibra/retrieval/datasets.py +1 -1
- siibra/retrieval/exceptions/__init__.py +1 -1
- siibra/retrieval/repositories.py +10 -27
- siibra/retrieval/requests.py +20 -3
- siibra/vocabularies/__init__.py +1 -1
- siibra/volumes/__init__.py +2 -2
- siibra/volumes/parcellationmap.py +121 -94
- siibra/volumes/providers/__init__.py +1 -1
- siibra/volumes/providers/freesurfer.py +1 -1
- siibra/volumes/providers/gifti.py +1 -1
- siibra/volumes/providers/neuroglancer.py +68 -42
- siibra/volumes/providers/nifti.py +18 -28
- siibra/volumes/providers/provider.py +2 -2
- siibra/volumes/sparsemap.py +128 -247
- siibra/volumes/volume.py +252 -65
- {siibra-1.0a14.dist-info → siibra-1.0.1a0.dist-info}/METADATA +17 -4
- siibra-1.0.1a0.dist-info/RECORD +84 -0
- {siibra-1.0a14.dist-info → siibra-1.0.1a0.dist-info}/WHEEL +1 -1
- siibra-1.0a14.dist-info/RECORD +0 -84
- {siibra-1.0a14.dist-info → siibra-1.0.1a0.dist-info}/LICENSE +0 -0
- {siibra-1.0a14.dist-info → siibra-1.0.1a0.dist-info}/top_level.txt +0 -0
siibra/configuration/factory.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2018-
|
|
1
|
+
# Copyright 2018-2024
|
|
2
2
|
# Institute of Neuroscience and Medicine (INM-1), Forschungszentrum Jülich GmbH
|
|
3
3
|
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -20,11 +20,11 @@ from ..features.tabular import (
|
|
|
20
20
|
receptor_density_fingerprint,
|
|
21
21
|
cell_density_profile,
|
|
22
22
|
layerwise_cell_density,
|
|
23
|
-
regional_timeseries_activity
|
|
23
|
+
regional_timeseries_activity,
|
|
24
24
|
)
|
|
25
25
|
from ..features.image import sections, volume_of_interest
|
|
26
26
|
from ..core import atlas, parcellation, space, region
|
|
27
|
-
from ..locations import point,
|
|
27
|
+
from ..locations import point, pointcloud, boundingbox
|
|
28
28
|
from ..retrieval import datasets, repositories
|
|
29
29
|
from ..volumes import volume, sparsemap, parcellationmap
|
|
30
30
|
from ..volumes.providers.provider import VolumeProvider
|
|
@@ -48,7 +48,9 @@ def build_type(type_str: str):
|
|
|
48
48
|
@wraps(fn)
|
|
49
49
|
def inner(*args, **kwargs):
|
|
50
50
|
return fn(*args, **kwargs)
|
|
51
|
+
|
|
51
52
|
return inner
|
|
53
|
+
|
|
52
54
|
return outer
|
|
53
55
|
|
|
54
56
|
|
|
@@ -65,7 +67,9 @@ class Factory:
|
|
|
65
67
|
)
|
|
66
68
|
if "openminds/DatasetVersion" in spec.get("ebrains", {}):
|
|
67
69
|
result.append(
|
|
68
|
-
datasets.EbrainsV3DatasetVersion(
|
|
70
|
+
datasets.EbrainsV3DatasetVersion(
|
|
71
|
+
id=spec["ebrains"]["openminds/DatasetVersion"]
|
|
72
|
+
)
|
|
69
73
|
)
|
|
70
74
|
if "openminds/Dataset" in spec.get("ebrains", {}):
|
|
71
75
|
result.append(
|
|
@@ -78,40 +82,41 @@ class Factory:
|
|
|
78
82
|
contributors=pub["authors"],
|
|
79
83
|
url=pub["url"],
|
|
80
84
|
description=pub["description"],
|
|
81
|
-
license=pub.get("license")
|
|
85
|
+
license=pub.get("license"),
|
|
82
86
|
)
|
|
83
|
-
for pub in spec["publications"]
|
|
87
|
+
for pub in spec["publications"]
|
|
88
|
+
if pub.get("name")
|
|
84
89
|
)
|
|
85
90
|
return result
|
|
86
91
|
|
|
87
92
|
@classmethod
|
|
88
93
|
def extract_volumes(
|
|
89
|
-
cls,
|
|
90
|
-
spec,
|
|
91
|
-
space_id: str = None,
|
|
92
|
-
names: List[str] = None,
|
|
93
|
-
name_prefix: str = ""
|
|
94
|
+
cls, spec, space_id: str = None, names: List[str] = None, name_prefix: str = ""
|
|
94
95
|
):
|
|
95
96
|
volume_specs = spec.get("volumes", [])
|
|
96
97
|
if names:
|
|
97
98
|
if len(names) != len(volume_specs) and len(names) == 1:
|
|
98
|
-
variants = [vol[
|
|
99
|
+
variants = [vol["variant"] for vol in volume_specs]
|
|
99
100
|
names = [f"{name_prefix}{names[0]} {var} variant" for var in variants]
|
|
100
101
|
else:
|
|
101
102
|
names = [f"{name_prefix} - volume {i}" for i in range(len(volume_specs))]
|
|
102
103
|
for i, vspec in enumerate(volume_specs):
|
|
103
104
|
if space_id:
|
|
104
|
-
if
|
|
105
|
-
assert
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
vspec[
|
|
105
|
+
if "space" in vspec:
|
|
106
|
+
assert (
|
|
107
|
+
vspec["space"]["@id"] == space_id
|
|
108
|
+
), "Space spec {vspec['space']} in volume field must be the same with space field in the configuration."
|
|
109
|
+
vspec["space"] = {"@id": space_id}
|
|
110
|
+
if (
|
|
111
|
+
names and vspec.get("name") is None
|
|
112
|
+
): # only use provided name if the volume has no specific name
|
|
113
|
+
vspec["name"] = names[i]
|
|
109
114
|
return list(map(cls.build_volume, volume_specs))
|
|
110
115
|
|
|
111
116
|
@classmethod
|
|
112
117
|
def extract_decoder(cls, spec):
|
|
113
118
|
decoder_spec = spec.get("decoder", {})
|
|
114
|
-
if decoder_spec["@type"].endswith(
|
|
119
|
+
if decoder_spec["@type"].endswith("csv"):
|
|
115
120
|
kwargs = {k: v for k, v in decoder_spec.items() if k != "@type"}
|
|
116
121
|
return lambda b: pd.read_csv(BytesIO(b), **kwargs)
|
|
117
122
|
else:
|
|
@@ -119,52 +124,52 @@ class Factory:
|
|
|
119
124
|
|
|
120
125
|
@classmethod
|
|
121
126
|
def extract_anchor(cls, spec):
|
|
122
|
-
if spec.get(
|
|
123
|
-
region = spec[
|
|
124
|
-
elif spec.get(
|
|
127
|
+
if spec.get("region"):
|
|
128
|
+
region = spec["region"]
|
|
129
|
+
elif spec.get("parcellation", {}).get("@id"):
|
|
125
130
|
# a parcellation is a special region,
|
|
126
131
|
# and can be used if no region is found
|
|
127
|
-
region = spec[
|
|
128
|
-
elif spec.get(
|
|
129
|
-
region = spec[
|
|
132
|
+
region = spec["parcellation"]["@id"]
|
|
133
|
+
elif spec.get("parcellation", {}).get("name"):
|
|
134
|
+
region = spec["parcellation"]["name"]
|
|
130
135
|
else:
|
|
131
136
|
region = None
|
|
132
137
|
|
|
133
|
-
if
|
|
134
|
-
location = cls.from_json(spec[
|
|
138
|
+
if "location" in spec:
|
|
139
|
+
location = cls.from_json(spec["location"])
|
|
135
140
|
else:
|
|
136
141
|
location = None
|
|
137
142
|
|
|
138
143
|
if (region is None) and (location is None):
|
|
139
144
|
print(spec)
|
|
140
|
-
raise RuntimeError(
|
|
145
|
+
raise RuntimeError(
|
|
146
|
+
"Spec provides neither region or location - no anchor can be extracted."
|
|
147
|
+
)
|
|
141
148
|
|
|
142
|
-
if
|
|
143
|
-
species = Species.decode(spec[
|
|
144
|
-
elif
|
|
145
|
-
species = Species.decode(spec[
|
|
149
|
+
if "species" in spec:
|
|
150
|
+
species = Species.decode(spec["species"])
|
|
151
|
+
elif "ebrains" in spec:
|
|
152
|
+
species = Species.decode(spec["ebrains"])
|
|
146
153
|
else:
|
|
147
154
|
raise ValueError(f"No species information found in spec {spec}")
|
|
148
155
|
|
|
149
156
|
return anchor.AnatomicalAnchor(
|
|
150
|
-
region=region,
|
|
151
|
-
location=location,
|
|
152
|
-
species=species
|
|
157
|
+
region=region, location=location, species=species
|
|
153
158
|
)
|
|
154
159
|
|
|
155
160
|
@classmethod
|
|
156
161
|
def extract_connector(cls, spec):
|
|
157
|
-
repospec = spec.get(
|
|
162
|
+
repospec = spec.get("repository", {})
|
|
158
163
|
spectype = repospec["@type"]
|
|
159
164
|
if spectype == "siibra/repository/zippedfile/v1.0.0":
|
|
160
|
-
return repositories.ZipfileConnector(repospec[
|
|
165
|
+
return repositories.ZipfileConnector(repospec["url"])
|
|
161
166
|
if spectype == "siibra/repository/localfolder/v1.0.0":
|
|
162
|
-
return repositories.LocalFileRepository(repospec[
|
|
167
|
+
return repositories.LocalFileRepository(repospec["folder"])
|
|
163
168
|
if spectype == "siibra/repository/gitlab/v1.0.0":
|
|
164
169
|
return repositories.GitlabConnector(
|
|
165
|
-
server=repospec[
|
|
166
|
-
project=repospec[
|
|
167
|
-
reftag=repospec[
|
|
170
|
+
server=repospec["server"],
|
|
171
|
+
project=repospec["project"],
|
|
172
|
+
reftag=repospec["branch"],
|
|
168
173
|
)
|
|
169
174
|
|
|
170
175
|
logger.warning(
|
|
@@ -179,7 +184,8 @@ class Factory:
|
|
|
179
184
|
a = atlas.Atlas(
|
|
180
185
|
spec["@id"],
|
|
181
186
|
spec["name"],
|
|
182
|
-
species=Species.decode(spec.get(
|
|
187
|
+
species=Species.decode(spec.get("species")),
|
|
188
|
+
prerelease=spec.get("prerelease", False),
|
|
183
189
|
)
|
|
184
190
|
for space_id in spec["spaces"]:
|
|
185
191
|
a._register_space(space_id)
|
|
@@ -193,13 +199,16 @@ class Factory:
|
|
|
193
199
|
return space.Space(
|
|
194
200
|
identifier=spec["@id"],
|
|
195
201
|
name=spec["name"],
|
|
196
|
-
species=Species.decode(spec.get(
|
|
197
|
-
volumes=cls.extract_volumes(
|
|
202
|
+
species=Species.decode(spec.get("species")),
|
|
203
|
+
volumes=cls.extract_volumes(
|
|
204
|
+
spec, space_id=spec.get("@id"), names=[spec.get("name")]
|
|
205
|
+
),
|
|
198
206
|
shortname=spec.get("shortName", ""),
|
|
199
207
|
description=spec.get("description"),
|
|
200
208
|
modality=spec.get("modality"),
|
|
201
209
|
publications=spec.get("publications", []),
|
|
202
210
|
datasets=cls.extract_datasets(spec),
|
|
211
|
+
prerelease=spec.get("prerelease", False),
|
|
203
212
|
)
|
|
204
213
|
|
|
205
214
|
@classmethod
|
|
@@ -213,6 +222,7 @@ class Factory:
|
|
|
213
222
|
datasets=cls.extract_datasets(spec),
|
|
214
223
|
rgb=spec.get("rgb", None),
|
|
215
224
|
spec=spec,
|
|
225
|
+
prerelease=spec.get("prerelease", False),
|
|
216
226
|
)
|
|
217
227
|
|
|
218
228
|
@classmethod
|
|
@@ -228,17 +238,18 @@ class Factory:
|
|
|
228
238
|
p = parcellation.Parcellation(
|
|
229
239
|
identifier=spec["@id"],
|
|
230
240
|
name=spec["name"],
|
|
231
|
-
species=Species.decode(spec.get(
|
|
241
|
+
species=Species.decode(spec.get("species")),
|
|
232
242
|
regions=regions,
|
|
233
243
|
shortname=spec.get("shortName", ""),
|
|
234
244
|
description=spec.get("description", ""),
|
|
235
|
-
modality=spec.get(
|
|
245
|
+
modality=spec.get("modality", ""),
|
|
236
246
|
publications=spec.get("publications", []),
|
|
237
247
|
datasets=cls.extract_datasets(spec),
|
|
248
|
+
prerelease=spec.get("prerelease", False),
|
|
238
249
|
)
|
|
239
250
|
|
|
240
251
|
# add version object, if any is specified
|
|
241
|
-
versionspec = spec.get(
|
|
252
|
+
versionspec = spec.get("@version", None)
|
|
242
253
|
if versionspec is not None:
|
|
243
254
|
version = parcellation.ParcellationVersion(
|
|
244
255
|
name=versionspec.get("name", None),
|
|
@@ -246,35 +257,44 @@ class Factory:
|
|
|
246
257
|
collection=versionspec.get("collectionName", None),
|
|
247
258
|
prev_id=versionspec.get("@prev", None),
|
|
248
259
|
next_id=versionspec.get("@next", None),
|
|
249
|
-
deprecated=versionspec.get("deprecated", False)
|
|
260
|
+
deprecated=versionspec.get("deprecated", False),
|
|
250
261
|
)
|
|
251
262
|
p.version = version
|
|
252
263
|
|
|
253
264
|
return p
|
|
254
265
|
|
|
255
266
|
@classmethod
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
for srctype, provider_spec in spec.get("providers", {}).items():
|
|
267
|
+
def build_volumeproviders(cls, provider_specs: Dict) -> List["VolumeProvider"]:
|
|
268
|
+
providers: List[VolumeProvider] = []
|
|
269
|
+
for srctype, provider_spec in provider_specs.items():
|
|
261
270
|
for ProviderType in VolumeProvider._SUBCLASSES:
|
|
262
271
|
if srctype == ProviderType.srctype:
|
|
263
272
|
providers.append(ProviderType(provider_spec))
|
|
264
273
|
break
|
|
265
274
|
else:
|
|
266
275
|
if srctype not in cls._warnings_issued:
|
|
267
|
-
logger.warning(
|
|
276
|
+
logger.warning(
|
|
277
|
+
f"No provider defined for volume Source type {srctype}"
|
|
278
|
+
)
|
|
268
279
|
cls._warnings_issued.append(srctype)
|
|
269
|
-
|
|
270
280
|
assert all([isinstance(p, VolumeProvider) for p in providers])
|
|
281
|
+
return providers
|
|
282
|
+
|
|
283
|
+
@classmethod
|
|
284
|
+
@build_type("siibra/volume/v0.0.1")
|
|
285
|
+
def build_volume(cls, spec):
|
|
271
286
|
result = volume.Volume(
|
|
272
287
|
space_spec=spec.get("space", {}),
|
|
273
|
-
providers=providers,
|
|
288
|
+
providers=cls.build_volumeproviders(spec.get("providers")),
|
|
274
289
|
name=spec.get("name", ""),
|
|
275
290
|
variant=spec.get("variant"),
|
|
276
291
|
datasets=cls.extract_datasets(spec),
|
|
292
|
+
bbox=cls.build_boundingbox(spec),
|
|
277
293
|
)
|
|
294
|
+
if result._boundingbox is not None:
|
|
295
|
+
assert (
|
|
296
|
+
result._boundingbox._space_spec == result._space_spec
|
|
297
|
+
), "BoundingBox of a volume cannot be in a different space than the volume's space."
|
|
278
298
|
|
|
279
299
|
return result
|
|
280
300
|
|
|
@@ -282,19 +302,18 @@ class Factory:
|
|
|
282
302
|
@build_type("siibra/map/v0.0.1")
|
|
283
303
|
def build_map(cls, spec):
|
|
284
304
|
# maps have no configured identifier - we require the spec filename to build one
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
volumes = cls.extract_volumes(spec, space_id=spec["space"].get("@id"), name_prefix=basename)
|
|
305
|
+
identifier = spec.get("@id")
|
|
306
|
+
volumes = cls.extract_volumes(
|
|
307
|
+
spec, space_id=spec["space"].get("@id"), name_prefix=identifier
|
|
308
|
+
)
|
|
290
309
|
|
|
291
|
-
if spec.get("
|
|
310
|
+
if spec.get("represented_as_sparsemap", False):
|
|
292
311
|
Maptype = sparsemap.SparseMap
|
|
293
312
|
else:
|
|
294
313
|
Maptype = parcellationmap.Map
|
|
295
314
|
return Maptype(
|
|
296
|
-
identifier=
|
|
297
|
-
name=spec.get("name"
|
|
315
|
+
identifier=identifier,
|
|
316
|
+
name=spec.get("name"),
|
|
298
317
|
space_spec=spec.get("space", {}),
|
|
299
318
|
parcellation_spec=spec.get("parcellation", {}),
|
|
300
319
|
indices=spec.get("indices", {}),
|
|
@@ -303,7 +322,8 @@ class Factory:
|
|
|
303
322
|
description=spec.get("description"),
|
|
304
323
|
modality=spec.get("modality"),
|
|
305
324
|
publications=spec.get("publications", []),
|
|
306
|
-
datasets=cls.extract_datasets(spec)
|
|
325
|
+
datasets=cls.extract_datasets(spec),
|
|
326
|
+
prerelease=spec.get("prerelease", False),
|
|
307
327
|
)
|
|
308
328
|
|
|
309
329
|
@classmethod
|
|
@@ -320,11 +340,11 @@ class Factory:
|
|
|
320
340
|
@build_type("https://openminds.ebrains.eu/sands/CoordinatePoint")
|
|
321
341
|
@build_type("siibra/location/point/v0.1")
|
|
322
342
|
def build_point(cls, spec):
|
|
323
|
-
if spec.get(
|
|
343
|
+
if spec.get("@type") == "https://openminds.ebrains.eu/sands/CoordinatePoint":
|
|
324
344
|
space_id = spec["coordinateSpace"]["@id"]
|
|
325
345
|
coord = list(np.float16(c["value"]) for c in spec["coordinates"])
|
|
326
346
|
assert all(c["unit"]["@id"] == "id.link/mm" for c in spec["coordinates"])
|
|
327
|
-
elif spec.get(
|
|
347
|
+
elif spec.get("@type") == "siibra/location/point/v0.1":
|
|
328
348
|
space_id = spec.get("space").get("@id")
|
|
329
349
|
coord = spec.get("coordinate")
|
|
330
350
|
else:
|
|
@@ -336,94 +356,112 @@ class Factory:
|
|
|
336
356
|
|
|
337
357
|
@classmethod
|
|
338
358
|
@build_type("tmp/poly")
|
|
339
|
-
@build_type("siibra/location/
|
|
340
|
-
def
|
|
341
|
-
if spec.get(
|
|
359
|
+
@build_type("siibra/location/pointcloud/v0.1")
|
|
360
|
+
def build_pointcloud(cls, spec):
|
|
361
|
+
if spec.get("@type") == "tmp/poly":
|
|
342
362
|
space_id = spec["coordinateSpace"]["@id"]
|
|
343
363
|
coords = []
|
|
344
364
|
for coord in spec["coordinates"]:
|
|
345
365
|
assert all(c["unit"]["@id"] == "id.link/mm" for c in coord)
|
|
346
366
|
coords.append(list(np.float16(c["value"]) for c in coord))
|
|
347
|
-
elif spec.get(
|
|
367
|
+
elif spec.get("@type") == "siibra/location/pointcloud/v0.1":
|
|
348
368
|
space_id = spec.get("space").get("@id")
|
|
349
369
|
coords = [tuple(c) for c in spec.get("coordinates")]
|
|
350
|
-
return
|
|
370
|
+
return pointcloud.PointCloud(coords, space=space_id)
|
|
371
|
+
|
|
372
|
+
@classmethod
|
|
373
|
+
@build_type("siibra/location/boundingbox/v0.1")
|
|
374
|
+
def build_boundingbox(cls, spec):
|
|
375
|
+
bboxspec = spec.get("boundingbox", None)
|
|
376
|
+
if bboxspec is None:
|
|
377
|
+
return None
|
|
378
|
+
space_spec = bboxspec.get("space")
|
|
379
|
+
coords = [tuple(c) for c in bboxspec.get("coordinates")]
|
|
380
|
+
return boundingbox.BoundingBox(coords[0], coords[1], space=space_spec)
|
|
351
381
|
|
|
352
382
|
@classmethod
|
|
353
383
|
@build_type("siibra/feature/fingerprint/receptor/v0.1")
|
|
354
384
|
def build_receptor_density_fingerprint(cls, spec):
|
|
355
385
|
return receptor_density_fingerprint.ReceptorDensityFingerprint(
|
|
356
|
-
tsvfile=spec[
|
|
386
|
+
tsvfile=spec["file"],
|
|
357
387
|
anchor=cls.extract_anchor(spec),
|
|
358
388
|
datasets=cls.extract_datasets(spec),
|
|
359
|
-
id=spec.get("@id", None)
|
|
389
|
+
id=spec.get("@id", None),
|
|
390
|
+
prerelease=spec.get("prerelease", False),
|
|
360
391
|
)
|
|
361
392
|
|
|
362
393
|
@classmethod
|
|
363
394
|
@build_type("siibra/feature/fingerprint/celldensity/v0.1")
|
|
364
395
|
def build_cell_density_fingerprint(cls, spec):
|
|
365
396
|
return layerwise_cell_density.LayerwiseCellDensity(
|
|
366
|
-
segmentfiles=spec[
|
|
367
|
-
layerfiles=spec[
|
|
397
|
+
segmentfiles=spec["segmentfiles"],
|
|
398
|
+
layerfiles=spec["layerfiles"],
|
|
368
399
|
anchor=cls.extract_anchor(spec),
|
|
369
400
|
datasets=cls.extract_datasets(spec),
|
|
370
|
-
id=spec.get("@id", None)
|
|
401
|
+
id=spec.get("@id", None),
|
|
402
|
+
prerelease=spec.get("prerelease", False),
|
|
371
403
|
)
|
|
372
404
|
|
|
373
405
|
@classmethod
|
|
374
406
|
@build_type("siibra/feature/profile/receptor/v0.1")
|
|
375
407
|
def build_receptor_density_profile(cls, spec):
|
|
376
408
|
return receptor_density_profile.ReceptorDensityProfile(
|
|
377
|
-
receptor=spec[
|
|
378
|
-
tsvfile=spec[
|
|
409
|
+
receptor=spec["receptor"],
|
|
410
|
+
tsvfile=spec["file"],
|
|
379
411
|
anchor=cls.extract_anchor(spec),
|
|
380
412
|
datasets=cls.extract_datasets(spec),
|
|
381
|
-
id=spec.get("@id", None)
|
|
413
|
+
id=spec.get("@id", None),
|
|
414
|
+
prerelease=spec.get("prerelease", False),
|
|
382
415
|
)
|
|
383
416
|
|
|
384
417
|
@classmethod
|
|
385
418
|
@build_type("siibra/feature/profile/celldensity/v0.1")
|
|
386
419
|
def build_cell_density_profile(cls, spec):
|
|
387
420
|
return cell_density_profile.CellDensityProfile(
|
|
388
|
-
section=spec[
|
|
389
|
-
patch=spec[
|
|
390
|
-
url=spec[
|
|
421
|
+
section=spec["section"],
|
|
422
|
+
patch=spec["patch"],
|
|
423
|
+
url=spec["file"],
|
|
391
424
|
anchor=cls.extract_anchor(spec),
|
|
392
425
|
datasets=cls.extract_datasets(spec),
|
|
393
|
-
id=spec.get("@id", None)
|
|
426
|
+
id=spec.get("@id", None),
|
|
427
|
+
prerelease=spec.get("prerelease", False),
|
|
394
428
|
)
|
|
395
429
|
|
|
396
430
|
@classmethod
|
|
397
431
|
@build_type("siibra/feature/section/v0.1")
|
|
398
432
|
def build_section(cls, spec):
|
|
399
|
-
vol = cls.build_volume(spec)
|
|
400
433
|
kwargs = {
|
|
401
|
-
"name": spec.get(
|
|
402
|
-
"region": spec.get(
|
|
403
|
-
"space_spec":
|
|
404
|
-
"providers":
|
|
434
|
+
"name": spec.get("name"),
|
|
435
|
+
"region": spec.get("region", None),
|
|
436
|
+
"space_spec": spec.get("space"),
|
|
437
|
+
"providers": cls.build_volumeproviders(spec.get("providers")),
|
|
405
438
|
"datasets": cls.extract_datasets(spec),
|
|
406
|
-
"
|
|
439
|
+
"bbox": cls.build_boundingbox(spec),
|
|
440
|
+
"id": spec.get("@id", None),
|
|
441
|
+
"prerelease": spec.get("prerelease", False),
|
|
407
442
|
}
|
|
408
|
-
modality = spec.get(
|
|
443
|
+
modality = spec.get("modality", "")
|
|
409
444
|
if modality == "cell body staining":
|
|
410
445
|
return sections.CellbodyStainedSection(**kwargs)
|
|
411
446
|
else:
|
|
412
|
-
raise ValueError(
|
|
447
|
+
raise ValueError(
|
|
448
|
+
f"No method for building image section feature type {modality}."
|
|
449
|
+
)
|
|
413
450
|
|
|
414
451
|
@classmethod
|
|
415
452
|
@build_type("siibra/feature/voi/v0.1")
|
|
416
453
|
def build_volume_of_interest(cls, spec):
|
|
417
|
-
vol = cls.build_volume(spec)
|
|
418
454
|
kwargs = {
|
|
419
|
-
"name": spec.get(
|
|
420
|
-
"region": spec.get(
|
|
421
|
-
"space_spec":
|
|
422
|
-
"providers":
|
|
455
|
+
"name": spec.get("name"),
|
|
456
|
+
"region": spec.get("region", None),
|
|
457
|
+
"space_spec": spec.get("space"),
|
|
458
|
+
"providers": cls.build_volumeproviders(spec.get("providers")),
|
|
423
459
|
"datasets": cls.extract_datasets(spec),
|
|
424
|
-
"
|
|
460
|
+
"bbox": cls.build_boundingbox(spec),
|
|
461
|
+
"id": spec.get("@id", None),
|
|
462
|
+
"prerelease": spec.get("prerelease", False),
|
|
425
463
|
}
|
|
426
|
-
modality = spec.get(
|
|
464
|
+
modality = spec.get("modality", "")
|
|
427
465
|
if modality == "cell body staining":
|
|
428
466
|
return volume_of_interest.CellBodyStainedVolumeOfInterest(**kwargs)
|
|
429
467
|
elif modality == "blockface":
|
|
@@ -437,25 +475,21 @@ class Factory:
|
|
|
437
475
|
modality="transmittance", **kwargs
|
|
438
476
|
)
|
|
439
477
|
elif modality == "XPCT":
|
|
440
|
-
return volume_of_interest.XPCTVolumeOfInterest(
|
|
441
|
-
modality="XPCT", **kwargs
|
|
442
|
-
)
|
|
478
|
+
return volume_of_interest.XPCTVolumeOfInterest(modality="XPCT", **kwargs)
|
|
443
479
|
elif modality == "DTI":
|
|
444
|
-
return volume_of_interest.DTIVolumeOfInterest(
|
|
445
|
-
modality=modality, **kwargs
|
|
446
|
-
)
|
|
480
|
+
return volume_of_interest.DTIVolumeOfInterest(modality=modality, **kwargs)
|
|
447
481
|
# elif modality == "segmentation":
|
|
448
482
|
# return volume_of_interest.SegmentedVolumeOfInterest(**kwargs)
|
|
449
483
|
elif "MRI" in modality:
|
|
450
|
-
return volume_of_interest.MRIVolumeOfInterest(
|
|
451
|
-
modality=modality, **kwargs
|
|
452
|
-
)
|
|
484
|
+
return volume_of_interest.MRIVolumeOfInterest(modality=modality, **kwargs)
|
|
453
485
|
elif modality == "LSFM":
|
|
454
486
|
return volume_of_interest.LSFMVolumeOfInterest(
|
|
455
487
|
modality="Light Sheet Fluorescence Microscopy", **kwargs
|
|
456
488
|
)
|
|
457
489
|
else:
|
|
458
|
-
raise ValueError(
|
|
490
|
+
raise ValueError(
|
|
491
|
+
f"No method for building image section feature type {modality}."
|
|
492
|
+
)
|
|
459
493
|
|
|
460
494
|
@classmethod
|
|
461
495
|
@build_type("siibra/feature/connectivitymatrix/v0.3")
|
|
@@ -465,10 +499,14 @@ class Factory:
|
|
|
465
499
|
try:
|
|
466
500
|
conn_cls = getattr(connectivity, modality)
|
|
467
501
|
except Exception:
|
|
468
|
-
raise ValueError(
|
|
502
|
+
raise ValueError(
|
|
503
|
+
f"No method for building connectivity matrix of type {modality}."
|
|
504
|
+
)
|
|
469
505
|
|
|
470
506
|
decoder_func = cls.extract_decoder(spec)
|
|
471
|
-
repo_connector =
|
|
507
|
+
repo_connector = (
|
|
508
|
+
cls.extract_connector(spec) if spec.get("repository", None) else None
|
|
509
|
+
)
|
|
472
510
|
if repo_connector is None:
|
|
473
511
|
base_url = spec.get("base_url", "")
|
|
474
512
|
kwargs = {
|
|
@@ -479,7 +517,8 @@ class Factory:
|
|
|
479
517
|
"decode_func": decoder_func,
|
|
480
518
|
"anchor": cls.extract_anchor(spec),
|
|
481
519
|
"description": spec.get("description", ""),
|
|
482
|
-
"datasets": cls.extract_datasets(spec)
|
|
520
|
+
"datasets": cls.extract_datasets(spec),
|
|
521
|
+
"prerelease": spec.get("prerelease", False),
|
|
483
522
|
}
|
|
484
523
|
paradigm = spec.get("paradigm")
|
|
485
524
|
if paradigm:
|
|
@@ -488,13 +527,15 @@ class Factory:
|
|
|
488
527
|
assert files_indexed_by in ["subject", "feature"]
|
|
489
528
|
conn_by_file = []
|
|
490
529
|
for fkey, filename in files.items():
|
|
491
|
-
kwargs.update(
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
530
|
+
kwargs.update(
|
|
531
|
+
{
|
|
532
|
+
"filename": filename,
|
|
533
|
+
"subject": fkey if files_indexed_by == "subject" else "average",
|
|
534
|
+
"feature": fkey if files_indexed_by == "feature" else None,
|
|
535
|
+
"connector": repo_connector or base_url + filename,
|
|
536
|
+
"id": spec.get("@id", None),
|
|
537
|
+
}
|
|
538
|
+
)
|
|
498
539
|
conn_by_file.append(conn_cls(**kwargs))
|
|
499
540
|
return conn_by_file
|
|
500
541
|
|
|
@@ -517,18 +558,17 @@ class Factory:
|
|
|
517
558
|
"anchor": cls.extract_anchor(spec),
|
|
518
559
|
"description": spec.get("description", ""),
|
|
519
560
|
"datasets": cls.extract_datasets(spec),
|
|
520
|
-
"timestep": spec.get("timestep")
|
|
561
|
+
"timestep": spec.get("timestep"),
|
|
562
|
+
"prerelease": spec.get("prerelease", False),
|
|
521
563
|
}
|
|
522
564
|
paradigm = spec.get("paradigm")
|
|
523
565
|
if paradigm:
|
|
524
566
|
kwargs["paradigm"] = paradigm
|
|
525
567
|
timeseries_by_file = []
|
|
526
568
|
for fkey, filename in files.items():
|
|
527
|
-
kwargs.update(
|
|
528
|
-
"filename": filename,
|
|
529
|
-
|
|
530
|
-
"id": spec.get("@id", None)
|
|
531
|
-
})
|
|
569
|
+
kwargs.update(
|
|
570
|
+
{"filename": filename, "subject": fkey, "id": spec.get("@id", None)}
|
|
571
|
+
)
|
|
532
572
|
timeseries_by_file.append(timeseries_cls(**kwargs))
|
|
533
573
|
return timeseries_by_file
|
|
534
574
|
|
|
@@ -537,11 +577,8 @@ class Factory:
|
|
|
537
577
|
|
|
538
578
|
if isinstance(spec, str):
|
|
539
579
|
if path.isfile(spec):
|
|
540
|
-
fname = spec
|
|
541
580
|
with open(spec, "r") as f:
|
|
542
581
|
spec = json.load(f)
|
|
543
|
-
assert "filename" not in spec
|
|
544
|
-
spec['filename'] = fname
|
|
545
582
|
else:
|
|
546
583
|
spec = json.loads(spec)
|
|
547
584
|
|
siibra/core/__init__.py
CHANGED
siibra/core/assignment.py
CHANGED