siibra 1.0.1a1__py3-none-any.whl → 1.0.1a2__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 +7 -16
- siibra/commons.py +9 -7
- siibra/configuration/configuration.py +5 -5
- siibra/configuration/factory.py +9 -8
- siibra/core/__init__.py +1 -1
- siibra/core/assignment.py +1 -0
- siibra/core/atlas.py +3 -3
- siibra/core/concept.py +4 -2
- siibra/core/parcellation.py +5 -5
- siibra/core/region.py +24 -25
- siibra/core/space.py +4 -6
- siibra/core/structure.py +2 -2
- siibra/features/anchor.py +2 -4
- siibra/features/connectivity/regional_connectivity.py +10 -13
- siibra/features/dataset/ebrains.py +1 -1
- siibra/features/feature.py +21 -18
- siibra/features/image/__init__.py +4 -2
- siibra/features/image/image.py +2 -4
- siibra/features/image/sections.py +81 -2
- siibra/features/image/volume_of_interest.py +0 -8
- siibra/features/tabular/__init__.py +1 -1
- siibra/features/tabular/bigbrain_intensity_profile.py +2 -1
- siibra/features/tabular/cell_density_profile.py +8 -9
- siibra/features/tabular/cortical_profile.py +6 -6
- siibra/features/tabular/gene_expression.py +6 -5
- siibra/features/tabular/layerwise_bigbrain_intensities.py +4 -3
- siibra/features/tabular/layerwise_cell_density.py +4 -6
- siibra/features/tabular/receptor_density_fingerprint.py +34 -9
- siibra/features/tabular/receptor_density_profile.py +1 -2
- siibra/features/tabular/regional_timeseries_activity.py +7 -7
- siibra/features/tabular/tabular.py +4 -5
- siibra/livequeries/allen.py +20 -22
- siibra/livequeries/bigbrain.py +239 -51
- siibra/livequeries/ebrains.py +13 -10
- siibra/livequeries/query.py +3 -3
- siibra/locations/__init__.py +17 -8
- siibra/locations/boundingbox.py +7 -6
- siibra/{experimental/plane3d.py → locations/experimental.py} +113 -13
- siibra/locations/location.py +10 -12
- siibra/locations/point.py +7 -16
- siibra/locations/pointcloud.py +51 -10
- siibra/retrieval/cache.py +1 -0
- siibra/retrieval/datasets.py +19 -13
- siibra/retrieval/repositories.py +10 -11
- siibra/retrieval/requests.py +26 -24
- siibra/vocabularies/__init__.py +1 -2
- siibra/volumes/__init__.py +4 -3
- siibra/volumes/parcellationmap.py +30 -16
- siibra/volumes/providers/freesurfer.py +4 -4
- siibra/volumes/providers/gifti.py +4 -4
- siibra/volumes/providers/neuroglancer.py +19 -22
- siibra/volumes/providers/nifti.py +6 -6
- siibra/volumes/providers/provider.py +3 -2
- siibra/volumes/sparsemap.py +7 -6
- siibra/volumes/volume.py +21 -28
- {siibra-1.0.1a1.dist-info → siibra-1.0.1a2.dist-info}/METADATA +10 -6
- siibra-1.0.1a2.dist-info/RECORD +80 -0
- {siibra-1.0.1a1.dist-info → siibra-1.0.1a2.dist-info}/WHEEL +1 -1
- siibra/experimental/__init__.py +0 -19
- siibra/experimental/contour.py +0 -61
- siibra/experimental/cortical_profile_sampler.py +0 -57
- siibra/experimental/patch.py +0 -98
- siibra-1.0.1a1.dist-info/RECORD +0 -84
- {siibra-1.0.1a1.dist-info → siibra-1.0.1a2.dist-info}/LICENSE +0 -0
- {siibra-1.0.1a1.dist-info → siibra-1.0.1a2.dist-info}/top_level.txt +0 -0
siibra/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.1-alpha.
|
|
1
|
+
1.0.1-alpha.2
|
siibra/__init__.py
CHANGED
|
@@ -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",
|
siibra/commons.py
CHANGED
|
@@ -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,16 +13,16 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
-
from ..commons import logger, __version__, SIIBRA_USE_CONFIGURATION, siibra_tqdm
|
|
17
|
-
from ..retrieval.repositories import GitlabConnector, RepositoryConnector, GithubConnector
|
|
18
|
-
from ..retrieval.exceptions import NoSiibraConfigMirrorsAvailableException
|
|
19
|
-
from ..retrieval.requests import SiibraHttpRequestError
|
|
20
|
-
|
|
21
16
|
from typing import Union, List
|
|
22
17
|
from collections import defaultdict
|
|
23
18
|
from requests.exceptions import ConnectionError
|
|
24
19
|
from os import path
|
|
25
20
|
|
|
21
|
+
from ..commons import logger, __version__, SIIBRA_USE_CONFIGURATION, siibra_tqdm
|
|
22
|
+
from ..retrieval.repositories import GitlabConnector, RepositoryConnector, GithubConnector
|
|
23
|
+
from ..retrieval.exceptions import NoSiibraConfigMirrorsAvailableException
|
|
24
|
+
from ..retrieval.requests import SiibraHttpRequestError
|
|
25
|
+
|
|
26
26
|
|
|
27
27
|
class Configuration:
|
|
28
28
|
"""
|
siibra/configuration/factory.py
CHANGED
|
@@ -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
|
|
siibra/core/__init__.py
CHANGED
|
@@ -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
|
siibra/core/assignment.py
CHANGED
siibra/core/atlas.py
CHANGED
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
"""Provides reference systems for brains."""
|
|
16
|
-
from . import concept, space as _space, parcellation as _parcellation
|
|
17
|
-
|
|
18
|
-
from ..commons import MapType, logger, InstanceTable, Species
|
|
19
16
|
|
|
20
17
|
from typing import List
|
|
21
18
|
|
|
19
|
+
from . import concept, space as _space, parcellation as _parcellation
|
|
20
|
+
from ..commons import MapType, logger, InstanceTable, Species
|
|
21
|
+
|
|
22
22
|
|
|
23
23
|
VERSION_BLACKLIST_WORDS = ["beta", "rc", "alpha"]
|
|
24
24
|
|
siibra/core/concept.py
CHANGED
|
@@ -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]] = {}
|
siibra/core/parcellation.py
CHANGED
|
@@ -13,11 +13,6 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
"""Hierarchal brain regions and metadata."""
|
|
16
|
-
from . import region
|
|
17
|
-
|
|
18
|
-
from ..commons import logger, MapType, Species
|
|
19
|
-
from ..volumes import parcellationmap
|
|
20
|
-
from ..exceptions import MapNotFound
|
|
21
16
|
|
|
22
17
|
from functools import lru_cache
|
|
23
18
|
import re
|
|
@@ -28,6 +23,11 @@ except ImportError:
|
|
|
28
23
|
# support python 3.7
|
|
29
24
|
from typing_extensions import Literal
|
|
30
25
|
|
|
26
|
+
from . import region
|
|
27
|
+
from ..commons import logger, MapType, Species
|
|
28
|
+
from ..volumes import parcellationmap
|
|
29
|
+
from ..exceptions import MapNotFound
|
|
30
|
+
|
|
31
31
|
|
|
32
32
|
if TYPE_CHECKING:
|
|
33
33
|
from .space import Space
|
siibra/core/region.py
CHANGED
|
@@ -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
|
siibra/core/space.py
CHANGED
|
@@ -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,
|
siibra/core/structure.py
CHANGED
|
@@ -21,11 +21,11 @@ a brain region is a structure which is at the same time an AtlasConcept. A
|
|
|
21
21
|
bounding box in MNI space is a structure, but not an AtlasConcept.
|
|
22
22
|
"""
|
|
23
23
|
|
|
24
|
-
from . import assignment, region as _region
|
|
25
|
-
|
|
26
24
|
from abc import ABC, abstractmethod
|
|
27
25
|
from typing import Tuple, Dict
|
|
28
26
|
|
|
27
|
+
from . import assignment, region as _region
|
|
28
|
+
|
|
29
29
|
|
|
30
30
|
class BrainStructure(ABC):
|
|
31
31
|
"""Abstract base class for types who can act as a location filter."""
|
siibra/features/anchor.py
CHANGED
|
@@ -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
|
siibra/features/feature.py
CHANGED
|
@@ -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
|
+
)
|
siibra/features/image/image.py
CHANGED
|
@@ -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
|