siibra 1.0.1a1__tar.gz → 1.0.1a2__tar.gz
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-1.0.1a1/siibra.egg-info → siibra-1.0.1a2}/PKG-INFO +10 -6
- {siibra-1.0.1a1 → siibra-1.0.1a2}/README.rst +9 -5
- siibra-1.0.1a2/siibra/VERSION +1 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/__init__.py +7 -16
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/commons.py +9 -7
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/configuration/factory.py +9 -8
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/core/__init__.py +1 -1
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/core/assignment.py +1 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/core/concept.py +4 -2
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/core/region.py +24 -25
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/core/space.py +4 -6
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/anchor.py +2 -4
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/connectivity/regional_connectivity.py +10 -13
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/feature.py +21 -18
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/image/__init__.py +4 -2
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/image/image.py +2 -4
- siibra-1.0.1a2/siibra/features/image/sections.py +105 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/image/volume_of_interest.py +0 -8
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/tabular/__init__.py +1 -1
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/tabular/bigbrain_intensity_profile.py +2 -1
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/tabular/cell_density_profile.py +8 -9
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/tabular/gene_expression.py +6 -5
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/tabular/layerwise_bigbrain_intensities.py +4 -3
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/tabular/layerwise_cell_density.py +4 -6
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/tabular/receptor_density_fingerprint.py +34 -9
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/tabular/receptor_density_profile.py +1 -2
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/tabular/tabular.py +4 -5
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/livequeries/allen.py +20 -22
- siibra-1.0.1a2/siibra/livequeries/bigbrain.py +394 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/livequeries/ebrains.py +13 -10
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/locations/__init__.py +17 -8
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/locations/boundingbox.py +7 -6
- siibra-1.0.1a1/siibra/experimental/plane3d.py → siibra-1.0.1a2/siibra/locations/experimental.py +113 -13
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/locations/location.py +10 -12
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/locations/point.py +7 -16
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/locations/pointcloud.py +51 -10
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/retrieval/cache.py +1 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/retrieval/datasets.py +19 -13
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/retrieval/repositories.py +10 -11
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/retrieval/requests.py +26 -24
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/vocabularies/__init__.py +1 -2
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/volumes/__init__.py +4 -3
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/volumes/parcellationmap.py +30 -16
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/volumes/providers/neuroglancer.py +19 -22
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/volumes/providers/provider.py +3 -2
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/volumes/sparsemap.py +7 -6
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/volumes/volume.py +21 -28
- {siibra-1.0.1a1 → siibra-1.0.1a2/siibra.egg-info}/PKG-INFO +10 -6
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra.egg-info/SOURCES.txt +1 -5
- siibra-1.0.1a1/siibra/VERSION +0 -1
- siibra-1.0.1a1/siibra/experimental/__init__.py +0 -19
- siibra-1.0.1a1/siibra/experimental/contour.py +0 -61
- siibra-1.0.1a1/siibra/experimental/cortical_profile_sampler.py +0 -57
- siibra-1.0.1a1/siibra/experimental/patch.py +0 -98
- siibra-1.0.1a1/siibra/features/image/sections.py +0 -26
- siibra-1.0.1a1/siibra/livequeries/bigbrain.py +0 -206
- {siibra-1.0.1a1 → siibra-1.0.1a2}/LICENSE +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/MANIFEST.in +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/setup.cfg +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/setup.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/configuration/__init__.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/configuration/configuration.py +5 -5
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/core/atlas.py +3 -3
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/core/parcellation.py +5 -5
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/core/structure.py +2 -2
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/exceptions.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/explorer/__init__.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/explorer/url.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/explorer/util.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/__init__.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/connectivity/__init__.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/connectivity/functional_connectivity.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/connectivity/streamline_counts.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/connectivity/streamline_lengths.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/connectivity/tracing_connectivity.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/dataset/__init__.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/dataset/ebrains.py +1 -1
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/tabular/cortical_profile.py +6 -6
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/features/tabular/regional_timeseries_activity.py +7 -7
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/livequeries/__init__.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/livequeries/query.py +3 -3
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/retrieval/__init__.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/retrieval/exceptions/__init__.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/vocabularies/gene_names.json +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/vocabularies/receptor_symbols.json +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/vocabularies/region_aliases.json +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/volumes/providers/__init__.py +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/volumes/providers/freesurfer.py +4 -4
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/volumes/providers/gifti.py +4 -4
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra/volumes/providers/nifti.py +6 -6
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra.egg-info/dependency_links.txt +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra.egg-info/requires.txt +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/siibra.egg-info/top_level.txt +0 -0
- {siibra-1.0.1a1 → siibra-1.0.1a2}/test/test_siibra.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: siibra
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1a2
|
|
4
4
|
Summary: siibra - Software interfaces for interacting with brain atlases
|
|
5
5
|
Home-page: https://github.com/FZJ-INM1-BDA/siibra-python
|
|
6
6
|
Author: Big Data Analytics Group, Forschungszentrum Juelich, Institute of Neuroscience and Medicine (INM-1)
|
|
@@ -59,6 +59,14 @@ It aims to facilitate programmatic and reproducible incorporation of brain parce
|
|
|
59
59
|
It supports both discretely labelled and statistical (probabilistic) parcellation maps, which can be used to assign brain regions to spatial locations and image signals, to retrieve region-specific neuroscience datasets from multiple online repositories, and to sample information from high-resolution image data.
|
|
60
60
|
The datasets anchored to brain regions address features of molecular, cellular and architecture as well as connectivity, and are complemented with live queries to external repositories as well as dynamic extraction from "big" image volumes such as the 20 micrometer BigBrain model.
|
|
61
61
|
|
|
62
|
+
``siibra`` hides much of the complexity that would be required to collect and interact with the individual parcellations, templates and data repositories.
|
|
63
|
+
By encapsulating many aspects of interacting with different maps and reference templates spaces, it also minimizes common errors like misinterpretation of coordinates from different reference spaces, confusing label indices of brain regions, or using inconsistent versions of parcellation maps.
|
|
64
|
+
It aims to provide a safe way of using maps defined across multiple spatial scales for reproducible analysis.
|
|
65
|
+
|
|
66
|
+
.. intro-end
|
|
67
|
+
|
|
68
|
+
.. about-start
|
|
69
|
+
|
|
62
70
|
``siibra`` was developed in the frame of the `Human Brain Project <https://humanbrainproject.eu>`__ for accessing the `EBRAINS
|
|
63
71
|
human brain atlas <https://ebrains.eu/service/human-brain-atlas>`__.
|
|
64
72
|
It stores most of its contents as sustainable and open datasets in the `EBRAINS Knowledge Graph <https://kg.ebrains.eu>`__, and is designed to support the `OpenMINDS metadata standards <https://github.com/HumanBrainProject/openMINDS_SANDS>`__.
|
|
@@ -67,11 +75,7 @@ In fact, the viewer is a good resource for exploring ``siibra``\ ’s core funct
|
|
|
67
75
|
Feature queries in ``siibra`` are parameterized by data modality and anatomical location, while the latter could be a brain region, brain parcellation, or location in reference space.
|
|
68
76
|
Beyond the explorative focus of ``siibra-explorer``, the Python library supports a range of data analysis functions suitable for typical neuroscience workflows.
|
|
69
77
|
|
|
70
|
-
|
|
71
|
-
By encapsulating many aspects of interacting with different maps and reference templates spaces, it also minimizes common errors like misinterpretation of coordinates from different reference spaces, confusing label indices of brain regions, or using inconsistent versions of parcellation maps.
|
|
72
|
-
It aims to provide a safe way of using maps defined across multiple spatial scales for reproducible analysis.
|
|
73
|
-
|
|
74
|
-
.. intro-end
|
|
78
|
+
.. about-end
|
|
75
79
|
|
|
76
80
|
.. getting-started-start
|
|
77
81
|
|
|
@@ -20,6 +20,14 @@ It aims to facilitate programmatic and reproducible incorporation of brain parce
|
|
|
20
20
|
It supports both discretely labelled and statistical (probabilistic) parcellation maps, which can be used to assign brain regions to spatial locations and image signals, to retrieve region-specific neuroscience datasets from multiple online repositories, and to sample information from high-resolution image data.
|
|
21
21
|
The datasets anchored to brain regions address features of molecular, cellular and architecture as well as connectivity, and are complemented with live queries to external repositories as well as dynamic extraction from "big" image volumes such as the 20 micrometer BigBrain model.
|
|
22
22
|
|
|
23
|
+
``siibra`` hides much of the complexity that would be required to collect and interact with the individual parcellations, templates and data repositories.
|
|
24
|
+
By encapsulating many aspects of interacting with different maps and reference templates spaces, it also minimizes common errors like misinterpretation of coordinates from different reference spaces, confusing label indices of brain regions, or using inconsistent versions of parcellation maps.
|
|
25
|
+
It aims to provide a safe way of using maps defined across multiple spatial scales for reproducible analysis.
|
|
26
|
+
|
|
27
|
+
.. intro-end
|
|
28
|
+
|
|
29
|
+
.. about-start
|
|
30
|
+
|
|
23
31
|
``siibra`` was developed in the frame of the `Human Brain Project <https://humanbrainproject.eu>`__ for accessing the `EBRAINS
|
|
24
32
|
human brain atlas <https://ebrains.eu/service/human-brain-atlas>`__.
|
|
25
33
|
It stores most of its contents as sustainable and open datasets in the `EBRAINS Knowledge Graph <https://kg.ebrains.eu>`__, and is designed to support the `OpenMINDS metadata standards <https://github.com/HumanBrainProject/openMINDS_SANDS>`__.
|
|
@@ -28,11 +36,7 @@ In fact, the viewer is a good resource for exploring ``siibra``\ ’s core funct
|
|
|
28
36
|
Feature queries in ``siibra`` are parameterized by data modality and anatomical location, while the latter could be a brain region, brain parcellation, or location in reference space.
|
|
29
37
|
Beyond the explorative focus of ``siibra-explorer``, the Python library supports a range of data analysis functions suitable for typical neuroscience workflows.
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
By encapsulating many aspects of interacting with different maps and reference templates spaces, it also minimizes common errors like misinterpretation of coordinates from different reference spaces, confusing label indices of brain regions, or using inconsistent versions of parcellation maps.
|
|
33
|
-
It aims to provide a safe way of using maps defined across multiple spatial scales for reproducible analysis.
|
|
34
|
-
|
|
35
|
-
.. intro-end
|
|
39
|
+
.. about-end
|
|
36
40
|
|
|
37
41
|
.. getting-started-start
|
|
38
42
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.1-alpha.2
|
|
@@ -13,35 +13,29 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
+
import os as _os
|
|
17
|
+
|
|
16
18
|
from .commons import (
|
|
17
19
|
logger,
|
|
18
20
|
QUIET,
|
|
19
21
|
VERBOSE,
|
|
20
22
|
MapType,
|
|
21
|
-
MapIndex,
|
|
22
23
|
set_log_level,
|
|
23
24
|
__version__
|
|
24
25
|
)
|
|
25
|
-
|
|
26
|
+
from . import configuration, features, livequeries
|
|
27
|
+
from .configuration import factory
|
|
26
28
|
from .core import (
|
|
27
29
|
atlas as _atlas,
|
|
28
30
|
parcellation as _parcellation,
|
|
29
31
|
space as _space
|
|
30
32
|
)
|
|
31
33
|
from .volumes import parcellationmap as _parcellationmap
|
|
32
|
-
from .retrieval.requests import
|
|
33
|
-
EbrainsRequest as _EbrainsRequest,
|
|
34
|
-
CACHE as cache
|
|
35
|
-
)
|
|
34
|
+
from .retrieval.requests import CACHE as cache
|
|
36
35
|
from .retrieval.cache import Warmup, WarmupLevel
|
|
36
|
+
from .locations import Point, PointCloud, Plane, BoundingBox
|
|
37
37
|
|
|
38
|
-
from . import configuration
|
|
39
|
-
from . import experimental
|
|
40
|
-
from .configuration import factory
|
|
41
|
-
from . import features, livequeries
|
|
42
|
-
from siibra.locations import Point, PointCloud
|
|
43
38
|
|
|
44
|
-
import os as _os
|
|
45
39
|
logger.info(f"Version: {__version__}")
|
|
46
40
|
logger.warning("This is a development release. Use at your own risk.")
|
|
47
41
|
logger.info(
|
|
@@ -49,8 +43,6 @@ logger.info(
|
|
|
49
43
|
)
|
|
50
44
|
|
|
51
45
|
# forward access to some functions
|
|
52
|
-
set_ebrains_token = _EbrainsRequest.set_token
|
|
53
|
-
fetch_ebrains_token = _EbrainsRequest.fetch_token
|
|
54
46
|
find_regions = _parcellation.find_regions
|
|
55
47
|
from_json = factory.Factory.from_json
|
|
56
48
|
|
|
@@ -151,10 +143,9 @@ def __dir__():
|
|
|
151
143
|
"MapType",
|
|
152
144
|
"Point",
|
|
153
145
|
"PointCloud",
|
|
146
|
+
"BoundingBox",
|
|
154
147
|
"QUIET",
|
|
155
148
|
"VERBOSE",
|
|
156
|
-
"fetch_ebrains_token",
|
|
157
|
-
"set_ebrains_token",
|
|
158
149
|
"vocabularies",
|
|
159
150
|
"__version__",
|
|
160
151
|
"cache",
|
|
@@ -17,24 +17,26 @@
|
|
|
17
17
|
import os
|
|
18
18
|
import re
|
|
19
19
|
from enum import Enum
|
|
20
|
-
from nibabel import Nifti1Image
|
|
21
|
-
from nilearn.image import resample_to_img
|
|
22
20
|
import logging
|
|
23
|
-
from tqdm import tqdm
|
|
24
|
-
import numpy as np
|
|
25
|
-
import pandas as pd
|
|
26
|
-
from typing import Generic, Iterable, Iterator, List, TypeVar, Union, Dict, Generator, Tuple
|
|
27
|
-
from skimage.filters import gaussian
|
|
28
21
|
from dataclasses import dataclass
|
|
29
22
|
from hashlib import md5
|
|
30
23
|
from uuid import UUID
|
|
31
24
|
import math
|
|
25
|
+
from typing import Generic, Iterable, Iterator, List, TypeVar, Union, Dict, Generator, Tuple
|
|
32
26
|
try:
|
|
33
27
|
from typing import TypedDict
|
|
34
28
|
except ImportError:
|
|
35
29
|
# support python 3.7
|
|
36
30
|
from typing_extensions import TypedDict
|
|
37
31
|
|
|
32
|
+
from tqdm import tqdm
|
|
33
|
+
import numpy as np
|
|
34
|
+
import pandas as pd
|
|
35
|
+
from nibabel import Nifti1Image
|
|
36
|
+
from nilearn.image import resample_to_img
|
|
37
|
+
from skimage.filters import gaussian
|
|
38
|
+
|
|
39
|
+
|
|
38
40
|
logging.addLevelName(21, "INFO_WO_PROGRESS_BARS")
|
|
39
41
|
logger = logging.getLogger(__name__.split(os.path.extsep)[0])
|
|
40
42
|
ch = logging.StreamHandler()
|
|
@@ -13,6 +13,15 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
+
from os import path
|
|
17
|
+
import json
|
|
18
|
+
from typing import List, Dict, Callable
|
|
19
|
+
from io import BytesIO
|
|
20
|
+
from functools import wraps
|
|
21
|
+
|
|
22
|
+
import numpy as np
|
|
23
|
+
import pandas as pd
|
|
24
|
+
|
|
16
25
|
from ..commons import logger, Species
|
|
17
26
|
from ..features import anchor, connectivity
|
|
18
27
|
from ..features.tabular import (
|
|
@@ -29,14 +38,6 @@ from ..retrieval import datasets, repositories
|
|
|
29
38
|
from ..volumes import volume, sparsemap, parcellationmap
|
|
30
39
|
from ..volumes.providers.provider import VolumeProvider
|
|
31
40
|
|
|
32
|
-
from os import path
|
|
33
|
-
import json
|
|
34
|
-
import numpy as np
|
|
35
|
-
from typing import List, Dict, Callable
|
|
36
|
-
import pandas as pd
|
|
37
|
-
from io import BytesIO
|
|
38
|
-
from functools import wraps
|
|
39
|
-
|
|
40
41
|
|
|
41
42
|
_registered_build_fns: Dict[str, Callable] = {}
|
|
42
43
|
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
|
-
""":ref:`
|
|
15
|
+
"""Core concepts behind siibra, :ref:`see glossary <glossary>` for details."""
|
|
16
16
|
from . import atlas, parcellation, space
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
"""Parent class to siibra main concepts."""
|
|
16
|
+
|
|
17
|
+
import re
|
|
18
|
+
from typing import TypeVar, Type, Union, List, TYPE_CHECKING, Dict
|
|
19
|
+
|
|
16
20
|
from ..commons import (
|
|
17
21
|
create_key,
|
|
18
22
|
clear_name,
|
|
@@ -23,8 +27,6 @@ from ..commons import (
|
|
|
23
27
|
)
|
|
24
28
|
from ..retrieval import cache
|
|
25
29
|
|
|
26
|
-
import re
|
|
27
|
-
from typing import TypeVar, Type, Union, List, TYPE_CHECKING, Dict
|
|
28
30
|
|
|
29
31
|
T = TypeVar("T", bound="AtlasConcept")
|
|
30
32
|
_REGISTRIES: Dict[Type[T], InstanceTable[T]] = {}
|
|
@@ -14,9 +14,18 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
"""Representation of a brain region."""
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
from
|
|
17
|
+
import re
|
|
18
|
+
from typing import List, Union, Iterable, Dict, Callable, Tuple, Set
|
|
19
|
+
from difflib import SequenceMatcher
|
|
20
|
+
import json
|
|
21
|
+
from functools import wraps, reduce
|
|
22
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
23
|
+
from functools import lru_cache
|
|
24
|
+
|
|
25
|
+
import anytree
|
|
26
|
+
from ebrains_drive import BucketApiClient
|
|
19
27
|
|
|
28
|
+
from . import concept, structure, space as _space, parcellation as _parcellation, assignment
|
|
20
29
|
from ..retrieval.cache import cache_user_fn
|
|
21
30
|
from ..locations import location, pointcloud, boundingbox as _boundingbox
|
|
22
31
|
from ..volumes import parcellationmap, volume
|
|
@@ -29,16 +38,6 @@ from ..commons import (
|
|
|
29
38
|
)
|
|
30
39
|
from ..exceptions import NoMapAvailableError, SpaceWarpingFailedError
|
|
31
40
|
|
|
32
|
-
import re
|
|
33
|
-
import anytree
|
|
34
|
-
from typing import List, Union, Iterable, Dict, Callable, Tuple, Set
|
|
35
|
-
from difflib import SequenceMatcher
|
|
36
|
-
from ebrains_drive import BucketApiClient
|
|
37
|
-
import json
|
|
38
|
-
from functools import wraps, reduce
|
|
39
|
-
from concurrent.futures import ThreadPoolExecutor
|
|
40
|
-
from functools import lru_cache
|
|
41
|
-
|
|
42
41
|
|
|
43
42
|
REGEX_TYPE = type(re.compile("test"))
|
|
44
43
|
|
|
@@ -128,7 +127,7 @@ class Region(anytree.NodeMixin, concept.AtlasConcept, structure.BrainStructure):
|
|
|
128
127
|
|
|
129
128
|
Yields
|
|
130
129
|
------
|
|
131
|
-
Qualification
|
|
130
|
+
assignment.Qualification
|
|
132
131
|
|
|
133
132
|
Example
|
|
134
133
|
-------
|
|
@@ -595,7 +594,7 @@ class Region(anytree.NodeMixin, concept.AtlasConcept, structure.BrainStructure):
|
|
|
595
594
|
except NoMapAvailableError:
|
|
596
595
|
return False
|
|
597
596
|
|
|
598
|
-
def assign(self, other: structure.BrainStructure) -> AnatomicalAssignment:
|
|
597
|
+
def assign(self, other: structure.BrainStructure) -> assignment.AnatomicalAssignment:
|
|
599
598
|
"""
|
|
600
599
|
Compute assignment of a location to this region.
|
|
601
600
|
|
|
@@ -609,8 +608,8 @@ class Region(anytree.NodeMixin, concept.AtlasConcept, structure.BrainStructure):
|
|
|
609
608
|
|
|
610
609
|
Returns
|
|
611
610
|
-------
|
|
612
|
-
AnatomicalAssignment or None
|
|
613
|
-
None if there is no Qualification found.
|
|
611
|
+
assignment.AnatomicalAssignment or None
|
|
612
|
+
None if there is no assignment.Qualification found.
|
|
614
613
|
"""
|
|
615
614
|
if (self, other) in self._ASSIGNMENT_CACHE:
|
|
616
615
|
return self._ASSIGNMENT_CACHE[self, other]
|
|
@@ -659,17 +658,17 @@ class Region(anytree.NodeMixin, concept.AtlasConcept, structure.BrainStructure):
|
|
|
659
658
|
else: # other is a Region
|
|
660
659
|
assert isinstance(other, Region)
|
|
661
660
|
if self == other:
|
|
662
|
-
qualification = Qualification.EXACT
|
|
661
|
+
qualification = assignment.Qualification.EXACT
|
|
663
662
|
elif self.__contains__(other):
|
|
664
|
-
qualification = Qualification.CONTAINS
|
|
663
|
+
qualification = assignment.Qualification.CONTAINS
|
|
665
664
|
elif other.__contains__(self):
|
|
666
|
-
qualification = Qualification.CONTAINED
|
|
665
|
+
qualification = assignment.Qualification.CONTAINED
|
|
667
666
|
else:
|
|
668
667
|
qualification = None
|
|
669
668
|
if qualification is None:
|
|
670
669
|
self._ASSIGNMENT_CACHE[self, other] = None
|
|
671
670
|
else:
|
|
672
|
-
self._ASSIGNMENT_CACHE[self, other] = AnatomicalAssignment(self, other, qualification)
|
|
671
|
+
self._ASSIGNMENT_CACHE[self, other] = assignment.AnatomicalAssignment(self, other, qualification)
|
|
673
672
|
return self._ASSIGNMENT_CACHE[self, other]
|
|
674
673
|
|
|
675
674
|
def tree2str(self):
|
|
@@ -926,7 +925,7 @@ def get_related_regions(region: Region) -> Iterable["RegionRelationAssessments"]
|
|
|
926
925
|
|
|
927
926
|
Yields
|
|
928
927
|
------
|
|
929
|
-
Qualification
|
|
928
|
+
assignment.Qualification
|
|
930
929
|
|
|
931
930
|
Example
|
|
932
931
|
-------
|
|
@@ -968,7 +967,7 @@ def _register_region_reference_type(ebrain_type: str):
|
|
|
968
967
|
return outer
|
|
969
968
|
|
|
970
969
|
|
|
971
|
-
class RegionRelationAssessments(AnatomicalAssignment[Region]):
|
|
970
|
+
class RegionRelationAssessments(assignment.AnatomicalAssignment[Region]):
|
|
972
971
|
"""
|
|
973
972
|
A collection of methods on finding related regions and the quantification
|
|
974
973
|
of the relationship.
|
|
@@ -1110,7 +1109,7 @@ class RegionRelationAssessments(AnatomicalAssignment[Region]):
|
|
|
1110
1109
|
yield cls(
|
|
1111
1110
|
query_structure=src,
|
|
1112
1111
|
assigned_structure=found_target,
|
|
1113
|
-
qualification=Qualification.parse_relation_assessment(overlap)
|
|
1112
|
+
qualification=assignment.Qualification.parse_relation_assessment(overlap)
|
|
1114
1113
|
)
|
|
1115
1114
|
|
|
1116
1115
|
if "https://openminds.ebrains.eu/sands/ParcellationEntity" in target.get("type"):
|
|
@@ -1124,7 +1123,7 @@ class RegionRelationAssessments(AnatomicalAssignment[Region]):
|
|
|
1124
1123
|
yield cls(
|
|
1125
1124
|
query_structure=src,
|
|
1126
1125
|
assigned_structure=reg,
|
|
1127
|
-
qualification=Qualification.parse_relation_assessment(overlap)
|
|
1126
|
+
qualification=assignment.Qualification.parse_relation_assessment(overlap)
|
|
1128
1127
|
)
|
|
1129
1128
|
|
|
1130
1129
|
@classmethod
|
|
@@ -1178,7 +1177,7 @@ class RegionRelationAssessments(AnatomicalAssignment[Region]):
|
|
|
1178
1177
|
yield cls(
|
|
1179
1178
|
query_structure=src,
|
|
1180
1179
|
assigned_structure=region,
|
|
1181
|
-
qualification=Qualification.OTHER_VERSION
|
|
1180
|
+
qualification=assignment.Qualification.OTHER_VERSION
|
|
1182
1181
|
)
|
|
1183
1182
|
|
|
1184
1183
|
# homologuous
|
|
@@ -14,18 +14,16 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
"""A particular brain reference space."""
|
|
16
16
|
|
|
17
|
+
from typing import List, TYPE_CHECKING, Union
|
|
17
18
|
|
|
18
|
-
from .
|
|
19
|
-
|
|
19
|
+
from . import concept
|
|
20
20
|
from ..commons import logger, Species
|
|
21
21
|
|
|
22
|
-
from typing import List, TYPE_CHECKING, Union
|
|
23
|
-
|
|
24
22
|
if TYPE_CHECKING:
|
|
25
23
|
from ..volumes import volume
|
|
26
24
|
|
|
27
25
|
|
|
28
|
-
class Space(AtlasConcept, configuration_folder="spaces"):
|
|
26
|
+
class Space(concept.AtlasConcept, configuration_folder="spaces"):
|
|
29
27
|
|
|
30
28
|
def __init__(
|
|
31
29
|
self,
|
|
@@ -66,7 +64,7 @@ class Space(AtlasConcept, configuration_folder="spaces"):
|
|
|
66
64
|
Key: EBRAINS KG schema, value: EBRAINS KG @id
|
|
67
65
|
"""
|
|
68
66
|
|
|
69
|
-
AtlasConcept.__init__(
|
|
67
|
+
concept.AtlasConcept.__init__(
|
|
70
68
|
self,
|
|
71
69
|
identifier=identifier,
|
|
72
70
|
name=name,
|
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
"""Handles the relation between study targets and BrainStructures."""
|
|
16
16
|
|
|
17
|
-
from
|
|
17
|
+
from typing import Union, List, Dict, Iterable
|
|
18
18
|
|
|
19
|
+
from ..commons import Species, logger
|
|
19
20
|
from ..core.structure import BrainStructure
|
|
20
21
|
from ..core.assignment import AnatomicalAssignment, Qualification
|
|
21
22
|
from ..locations.location import Location
|
|
@@ -23,11 +24,8 @@ from ..core.parcellation import Parcellation, find_regions
|
|
|
23
24
|
from ..core.region import Region
|
|
24
25
|
from ..core.space import Space
|
|
25
26
|
from ..exceptions import SpaceWarpingFailedError
|
|
26
|
-
|
|
27
27
|
from ..vocabularies import REGION_ALIASES
|
|
28
28
|
|
|
29
|
-
from typing import Union, List, Dict, Iterable
|
|
30
|
-
|
|
31
29
|
|
|
32
30
|
class AnatomicalAnchor:
|
|
33
31
|
"""
|
|
@@ -14,11 +14,18 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
16
|
from zipfile import ZipFile
|
|
17
|
-
from
|
|
18
|
-
|
|
17
|
+
from typing import Callable, Union, List, Tuple, Iterator
|
|
18
|
+
try:
|
|
19
|
+
from typing import Literal
|
|
20
|
+
except ImportError: # support python 3.7
|
|
21
|
+
from typing_extensions import Literal
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
import numpy as np
|
|
24
|
+
import pandas as pd
|
|
21
25
|
|
|
26
|
+
from .. import anchor as _anchor
|
|
27
|
+
from ..feature import Feature, Compoundable
|
|
28
|
+
from ..tabular.tabular import Tabular
|
|
22
29
|
from ...commons import logger, QUIET, siibra_tqdm
|
|
23
30
|
from ...core import region as _region
|
|
24
31
|
from ...locations import pointcloud
|
|
@@ -26,16 +33,6 @@ from ...retrieval.repositories import RepositoryConnector
|
|
|
26
33
|
from ...retrieval.requests import HttpRequest
|
|
27
34
|
|
|
28
35
|
|
|
29
|
-
import pandas as pd
|
|
30
|
-
import numpy as np
|
|
31
|
-
from typing import Callable, Union, List, Tuple, Iterator
|
|
32
|
-
|
|
33
|
-
try:
|
|
34
|
-
from typing import Literal
|
|
35
|
-
except ImportError: # support python 3.7
|
|
36
|
-
from typing_extensions import Literal
|
|
37
|
-
|
|
38
|
-
|
|
39
36
|
class RegionalConnectivity(Feature, Compoundable):
|
|
40
37
|
"""
|
|
41
38
|
Parcellation-averaged connectivity, providing one or more matrices of a
|
|
@@ -14,12 +14,6 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
"""Handles multimodal data features and related queries."""
|
|
16
16
|
|
|
17
|
-
from . import anchor as _anchor
|
|
18
|
-
|
|
19
|
-
from ..commons import logger, InstanceTable, siibra_tqdm, __version__
|
|
20
|
-
from ..core import concept, space, region, parcellation, structure
|
|
21
|
-
from ..volumes import volume
|
|
22
|
-
|
|
23
17
|
from typing import Union, TYPE_CHECKING, List, Dict, Type, Tuple, BinaryIO, Any, Iterator
|
|
24
18
|
from hashlib import md5
|
|
25
19
|
from collections import defaultdict
|
|
@@ -28,6 +22,11 @@ from abc import ABC, abstractmethod
|
|
|
28
22
|
from re import sub
|
|
29
23
|
from textwrap import wrap
|
|
30
24
|
|
|
25
|
+
from . import anchor as _anchor
|
|
26
|
+
from ..commons import logger, InstanceTable, siibra_tqdm, __version__
|
|
27
|
+
from ..core import concept, space, region, parcellation, structure
|
|
28
|
+
from ..volumes import volume
|
|
29
|
+
|
|
31
30
|
if TYPE_CHECKING:
|
|
32
31
|
from ..retrieval.datasets import EbrainsDataset
|
|
33
32
|
TypeDataset = EbrainsDataset
|
|
@@ -130,23 +129,22 @@ class Feature:
|
|
|
130
129
|
# allows subclasses to implement lazy loading of an anchor
|
|
131
130
|
return self._anchor_cached
|
|
132
131
|
|
|
133
|
-
def __init_subclass__(cls, configuration_folder=None, category=None,
|
|
132
|
+
def __init_subclass__(cls, configuration_folder=None, category=None, **kwargs):
|
|
134
133
|
|
|
135
134
|
# Feature.SUBCLASSES serves as an index where feature class inheritance is cached. When users
|
|
136
135
|
# queries a branch on the hierarchy, all children will also be queried. There are usecases where
|
|
137
136
|
# such behavior is not desired (e.g. ProxyFeature, which wraps livequery features id to capture the
|
|
138
137
|
# query context).
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if do_not_index is False:
|
|
138
|
+
if "ProxyFeature" in cls.__name__:
|
|
139
|
+
return
|
|
142
140
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
141
|
+
# extend the subclass lists
|
|
142
|
+
# Iterate over all mro, not just immediate base classes
|
|
143
|
+
for BaseCls in cls.__mro__:
|
|
144
|
+
# some base classes may not be sub class of feature, ignore these
|
|
145
|
+
if not issubclass(BaseCls, Feature):
|
|
146
|
+
continue
|
|
147
|
+
cls._SUBCLASSES[BaseCls].append(cls)
|
|
150
148
|
|
|
151
149
|
cls._live_queries = []
|
|
152
150
|
cls._preconfigured_instances = None
|
|
@@ -156,6 +154,9 @@ class Feature:
|
|
|
156
154
|
cls._CATEGORIZED[category].add(cls.__name__, cls)
|
|
157
155
|
return super().__init_subclass__(**kwargs)
|
|
158
156
|
|
|
157
|
+
def __repr__(self) -> str:
|
|
158
|
+
return f"<{self.__class__.__name__}(id='{self.id}', name='{self.name}')>"
|
|
159
|
+
|
|
159
160
|
@classmethod
|
|
160
161
|
def _get_subclasses(cls):
|
|
161
162
|
return {Cls.__name__: Cls for Cls in cls._SUBCLASSES}
|
|
@@ -625,7 +626,9 @@ class Feature:
|
|
|
625
626
|
|
|
626
627
|
See docstring of serialize_query_context for further context.
|
|
627
628
|
"""
|
|
628
|
-
|
|
629
|
+
|
|
630
|
+
# if you change the name of this class, change the string in Feature.__init_subclass__
|
|
631
|
+
class ProxyFeature(feature.__class__):
|
|
629
632
|
|
|
630
633
|
# override __class__ property
|
|
631
634
|
# some instances of features accesses inst.__class__
|
|
@@ -22,6 +22,8 @@ from .volume_of_interest import (
|
|
|
22
22
|
XPCTVolumeOfInterest,
|
|
23
23
|
LSFMVolumeOfInterest,
|
|
24
24
|
DTIVolumeOfInterest
|
|
25
|
-
# SegmentedVolumeOfInterest
|
|
26
25
|
)
|
|
27
|
-
from .sections import
|
|
26
|
+
from .sections import (
|
|
27
|
+
CellbodyStainedSection,
|
|
28
|
+
BigBrain1MicronPatch
|
|
29
|
+
)
|
|
@@ -14,15 +14,13 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
"""Base type of features in volume format and related anatomical anchor."""
|
|
16
16
|
|
|
17
|
+
from typing import List, TYPE_CHECKING
|
|
17
18
|
from zipfile import ZipFile
|
|
18
|
-
from .. import feature
|
|
19
19
|
|
|
20
|
+
from .. import feature
|
|
20
21
|
from .. import anchor as _anchor
|
|
21
|
-
|
|
22
22
|
from ...volumes import volume as _volume
|
|
23
23
|
|
|
24
|
-
from typing import List, TYPE_CHECKING
|
|
25
|
-
|
|
26
24
|
if TYPE_CHECKING:
|
|
27
25
|
from ...locations.boundingbox import BoundingBox
|
|
28
26
|
from ...volumes.providers import provider
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Copyright 2018-2025
|
|
2
|
+
# Institute of Neuroscience and Medicine (INM-1), Forschungszentrum Jülich GmbH
|
|
3
|
+
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
"""Multimodal data features in 2D section."""
|
|
16
|
+
|
|
17
|
+
from typing import TYPE_CHECKING
|
|
18
|
+
|
|
19
|
+
from . import image
|
|
20
|
+
|
|
21
|
+
if TYPE_CHECKING:
|
|
22
|
+
from ...locations import AxisAlignedPatch, Contour
|
|
23
|
+
from ...features.anchor import AnatomicalAnchor
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class CellbodyStainedSection(
|
|
27
|
+
image.Image,
|
|
28
|
+
configuration_folder="features/images/sections/cellbody",
|
|
29
|
+
category="cellular",
|
|
30
|
+
):
|
|
31
|
+
def __init__(self, **kwargs):
|
|
32
|
+
image.Image.__init__(self, **kwargs, modality="cell body staining")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class BigBrain1MicronPatch(image.Image, category="cellular"):
|
|
36
|
+
|
|
37
|
+
_DESCRIPTION = """Sample approximately orthogonal cortical image patches
|
|
38
|
+
from BigBrain 1 micron sections, guided by an image volume
|
|
39
|
+
in a supported reference space providing. The image
|
|
40
|
+
volume is used as a weighted mask to extract patches
|
|
41
|
+
along the cortical midsurface with nonzero weights in the
|
|
42
|
+
input image.
|
|
43
|
+
An optional lower_threshold can be used to narrow down
|
|
44
|
+
the search. The weight is stored with the resulting features."""
|
|
45
|
+
|
|
46
|
+
def __init__(
|
|
47
|
+
self,
|
|
48
|
+
patch: "AxisAlignedPatch",
|
|
49
|
+
profile: "Contour",
|
|
50
|
+
section: CellbodyStainedSection,
|
|
51
|
+
vertex: int,
|
|
52
|
+
relevance: float,
|
|
53
|
+
anchor: "AnatomicalAnchor",
|
|
54
|
+
):
|
|
55
|
+
self._patch = patch
|
|
56
|
+
self._profile = profile
|
|
57
|
+
self._section = section
|
|
58
|
+
self.vertex = vertex
|
|
59
|
+
self.relevance = relevance
|
|
60
|
+
image.Image.__init__(
|
|
61
|
+
self,
|
|
62
|
+
name=f"Cortical patch in {section.name}",
|
|
63
|
+
modality=section.modality,
|
|
64
|
+
space_spec=section._space_spec,
|
|
65
|
+
providers=list(section._providers.values()),
|
|
66
|
+
region=None,
|
|
67
|
+
datasets=section.datasets,
|
|
68
|
+
bbox=patch.boundingbox,
|
|
69
|
+
id=None,
|
|
70
|
+
)
|
|
71
|
+
self._anchor_cached = anchor
|
|
72
|
+
self._description_cached = self._DESCRIPTION
|
|
73
|
+
|
|
74
|
+
def __repr__(self):
|
|
75
|
+
return (
|
|
76
|
+
f"<{self.__class__.__name__}(space_spec={self._space_spec}, "
|
|
77
|
+
f"name='{self.name}', "
|
|
78
|
+
f"section='{self._section.get_boundingbox().minpoint.bigbrain_section()}', "
|
|
79
|
+
f"vertex='{self.vertex}', providers={self._providers})>"
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def section(self) -> CellbodyStainedSection:
|
|
84
|
+
return self._section
|
|
85
|
+
|
|
86
|
+
def get_boundingbox(self, **fetch_kwargs):
|
|
87
|
+
"""Enforce that the bounding box spans the full section thickness."""
|
|
88
|
+
bbox_section = self._section.get_boundingbox(**fetch_kwargs)
|
|
89
|
+
bbox = self._patch.boundingbox
|
|
90
|
+
bbox.minpoint[1] = bbox_section.minpoint[1]
|
|
91
|
+
bbox.maxpoint[1] = bbox_section.maxpoint[1]
|
|
92
|
+
return bbox
|
|
93
|
+
|
|
94
|
+
@property
|
|
95
|
+
def profile(self) -> "Contour":
|
|
96
|
+
return self._profile
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def bigbrain_section(self):
|
|
100
|
+
return self.get_boundingbox().minpoint.bigbrain_section()
|
|
101
|
+
|
|
102
|
+
def fetch(self, flip: bool = False, resolution_mm: float = -1, **kwargs):
|
|
103
|
+
assert len(kwargs) == 0
|
|
104
|
+
p = self._patch.flip() if flip else self._patch
|
|
105
|
+
return p.extract_volume(self._section, resolution_mm=resolution_mm).fetch()
|