siibra 1.0.1a1__py3-none-any.whl → 1.0.1a5__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.

Files changed (67) hide show
  1. siibra/VERSION +1 -1
  2. siibra/__init__.py +7 -16
  3. siibra/commons.py +19 -8
  4. siibra/configuration/configuration.py +5 -6
  5. siibra/configuration/factory.py +13 -8
  6. siibra/core/__init__.py +1 -1
  7. siibra/core/assignment.py +19 -7
  8. siibra/core/atlas.py +3 -3
  9. siibra/core/concept.py +4 -2
  10. siibra/core/parcellation.py +5 -5
  11. siibra/core/region.py +24 -25
  12. siibra/core/space.py +4 -6
  13. siibra/core/structure.py +2 -2
  14. siibra/explorer/url.py +2 -2
  15. siibra/features/anchor.py +3 -7
  16. siibra/features/connectivity/regional_connectivity.py +51 -40
  17. siibra/features/dataset/ebrains.py +1 -1
  18. siibra/features/feature.py +29 -20
  19. siibra/features/image/__init__.py +6 -3
  20. siibra/features/image/image.py +2 -4
  21. siibra/features/image/sections.py +81 -2
  22. siibra/features/image/volume_of_interest.py +8 -7
  23. siibra/features/tabular/__init__.py +1 -1
  24. siibra/features/tabular/bigbrain_intensity_profile.py +2 -1
  25. siibra/features/tabular/cell_density_profile.py +8 -9
  26. siibra/features/tabular/cortical_profile.py +6 -6
  27. siibra/features/tabular/gene_expression.py +34 -16
  28. siibra/features/tabular/layerwise_bigbrain_intensities.py +4 -3
  29. siibra/features/tabular/layerwise_cell_density.py +83 -24
  30. siibra/features/tabular/receptor_density_fingerprint.py +34 -9
  31. siibra/features/tabular/receptor_density_profile.py +1 -2
  32. siibra/features/tabular/regional_timeseries_activity.py +7 -7
  33. siibra/features/tabular/tabular.py +14 -7
  34. siibra/livequeries/allen.py +23 -22
  35. siibra/livequeries/bigbrain.py +239 -51
  36. siibra/livequeries/ebrains.py +13 -10
  37. siibra/livequeries/query.py +3 -3
  38. siibra/locations/__init__.py +17 -8
  39. siibra/locations/boundingbox.py +10 -8
  40. siibra/{experimental/plane3d.py → locations/experimental.py} +113 -13
  41. siibra/locations/location.py +17 -13
  42. siibra/locations/point.py +14 -19
  43. siibra/locations/pointcloud.py +57 -12
  44. siibra/retrieval/cache.py +1 -0
  45. siibra/retrieval/datasets.py +19 -13
  46. siibra/retrieval/repositories.py +10 -11
  47. siibra/retrieval/requests.py +26 -24
  48. siibra/vocabularies/__init__.py +1 -2
  49. siibra/volumes/__init__.py +4 -3
  50. siibra/volumes/parcellationmap.py +33 -17
  51. siibra/volumes/providers/freesurfer.py +4 -4
  52. siibra/volumes/providers/gifti.py +4 -4
  53. siibra/volumes/providers/neuroglancer.py +19 -22
  54. siibra/volumes/providers/nifti.py +6 -6
  55. siibra/volumes/providers/provider.py +3 -2
  56. siibra/volumes/sparsemap.py +19 -26
  57. siibra/volumes/volume.py +21 -28
  58. {siibra-1.0.1a1.dist-info → siibra-1.0.1a5.dist-info}/METADATA +37 -17
  59. siibra-1.0.1a5.dist-info/RECORD +80 -0
  60. {siibra-1.0.1a1.dist-info → siibra-1.0.1a5.dist-info}/WHEEL +1 -1
  61. siibra/experimental/__init__.py +0 -19
  62. siibra/experimental/contour.py +0 -61
  63. siibra/experimental/cortical_profile_sampler.py +0 -57
  64. siibra/experimental/patch.py +0 -98
  65. siibra-1.0.1a1.dist-info/RECORD +0 -84
  66. {siibra-1.0.1a1.dist-info → siibra-1.0.1a5.dist-info/licenses}/LICENSE +0 -0
  67. {siibra-1.0.1a1.dist-info → siibra-1.0.1a5.dist-info}/top_level.txt +0 -0
siibra/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1-alpha.1
1
+ 1.0.1-alpha.5
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()
@@ -532,13 +534,21 @@ def resample_img_to_img(
532
534
  -------
533
535
  Nifti1Image
534
536
  """
537
+ from nilearn._version import version as nilearn_version
538
+ from packaging.version import Version
539
+
535
540
  interpolation = "nearest" if np.array_equal(np.unique(source_img.dataobj), [0, 1]) else "linear"
536
- resampled_img = resample_to_img(
541
+ kwargs = dict(
537
542
  source_img=source_img,
538
543
  target_img=target_img,
539
544
  interpolation=interpolation,
540
545
  force_resample=True, # False is intended for testing. see nilearn docs
541
546
  )
547
+ if Version(nilearn_version) >= Version("0.11.0"):
548
+ # because nilearn>=0.11.0 don't support "copy_header" and python <= 3.8
549
+ kwargs["copy_header"] = True # use new default in nilearn >= 0.11.0
550
+
551
+ resampled_img = resample_to_img(**kwargs)
542
552
  return resampled_img
543
553
 
544
554
 
@@ -723,6 +733,7 @@ class Species(Enum):
723
733
  MACACA_MULATTA = 5
724
734
  MACACA_FUSCATA = 6
725
735
  CHLOROCEBUS_AETHIOPS_SABAEUS = 7
736
+ CALLITHRIX_JACCHUS = 8
726
737
 
727
738
  UNSPECIFIED_SPECIES = 999
728
739
 
@@ -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
  """
@@ -185,5 +185,4 @@ class Configuration:
185
185
 
186
186
 
187
187
  if SIIBRA_USE_CONFIGURATION:
188
- logger.warning(f"config.SIIBRA_USE_CONFIGURATION defined, use configuration at {SIIBRA_USE_CONFIGURATION}")
189
188
  Configuration.use_configuration(SIIBRA_USE_CONFIGURATION)
@@ -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
 
@@ -486,6 +487,10 @@ class Factory:
486
487
  return volume_of_interest.LSFMVolumeOfInterest(
487
488
  modality="Light Sheet Fluorescence Microscopy", **kwargs
488
489
  )
490
+ elif modality == "morphometry":
491
+ return volume_of_interest.MorphometryVolumeOfInterest(
492
+ modality="Morphometry", **kwargs
493
+ )
489
494
  else:
490
495
  raise ValueError(
491
496
  f"No method for building image section feature type {modality}."
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:`Main siibra concepts<mainconcepts>`"""
15
+ """Core concepts behind siibra, :ref:`see glossary <glossary>` for details."""
16
16
  from . import atlas, parcellation, space
siibra/core/assignment.py CHANGED
@@ -17,6 +17,7 @@
17
17
  from enum import Enum
18
18
  from dataclasses import dataclass
19
19
  from typing import Dict, Generic, TypeVar, TYPE_CHECKING
20
+
20
21
  if TYPE_CHECKING:
21
22
  from .structure import BrainStructure
22
23
 
@@ -25,12 +26,12 @@ T = TypeVar("T")
25
26
 
26
27
  class Qualification(Enum):
27
28
  EXACT = 1
28
- OVERLAPS = 2
29
- CONTAINED = 3
30
- CONTAINS = 4
31
- APPROXIMATE = 5
32
- HOMOLOGOUS = 6
33
- OTHER_VERSION = 7
29
+ APPROXIMATE = 2
30
+ OTHER_VERSION = 3
31
+ CONTAINED = 4
32
+ CONTAINS = 5
33
+ OVERLAPS = 6
34
+ HOMOLOGOUS = 7
34
35
 
35
36
  @property
36
37
  def verb(self):
@@ -66,6 +67,17 @@ class Qualification(Enum):
66
67
  assert self in inverses, f"{str(self)} inverses cannot be found."
67
68
  return inverses[self]
68
69
 
70
+ def __lt__(self, other: "Qualification"):
71
+ """
72
+ This is used to sort feature query results. Since it is very difficult
73
+ to determine a well-ordering principle and it is difficult to sort
74
+ without one, the enum values are used for sorting. This means
75
+ not all comparisons have logical basis but they are well-defined,
76
+ making it reproducible but also clearly distinguishes important
77
+ comparisons.
78
+ """
79
+ return self.value < other.value
80
+
69
81
  def __str__(self):
70
82
  return f"{self.__class__.__name__}={self.name.lower()}"
71
83
 
@@ -107,4 +119,4 @@ class AnatomicalAssignment(Generic[T]):
107
119
  def __lt__(self, other: 'AnatomicalAssignment'):
108
120
  if not isinstance(other, AnatomicalAssignment):
109
121
  raise ValueError(f"Cannot compare AnatomicalAssignment with instances of '{type(other)}'")
110
- return self.qualification.value < other.qualification.value
122
+ return self.qualification < other.qualification
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]] = {}
@@ -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
- from . import concept, structure, space as _space, parcellation as _parcellation
18
- from .assignment import Qualification, AnatomicalAssignment
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 .concept import AtlasConcept
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/explorer/url.py CHANGED
@@ -136,7 +136,7 @@ def encode_url(
136
136
 
137
137
  try:
138
138
  result_props = region.spatial_props(space, maptype="labelled")
139
- if len(result_props.components) == 0:
139
+ if len(result_props) == 0:
140
140
  return return_url + nav_string.format(encoded_nav=encoded_position or "0.0.0", **zoom_kwargs)
141
141
  except Exception as e:
142
142
  print(f"Cannot get_spatial_props {str(e)}")
@@ -144,7 +144,7 @@ def encode_url(
144
144
  raise e
145
145
  return return_url + nav_string.format(encoded_nav=encoded_position or "0.0.0", **zoom_kwargs)
146
146
 
147
- centroid = result_props.components[0].centroid
147
+ centroid = result_props[0].centroid
148
148
 
149
149
  encoded_centroid = separator.join(
150
150
  [encode_number(math.floor(val * 1e6)) for val in centroid]
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 ..commons import Species, logger
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
  """
@@ -178,9 +176,7 @@ class AnatomicalAnchor:
178
176
  assignments.append(region.assign(concept))
179
177
  self._assignments[concept] = sorted(a for a in assignments if a is not None)
180
178
 
181
- self._last_matched_concept = concept \
182
- if len(self._assignments[concept]) > 0 \
183
- else None
179
+ self._last_matched_concept = concept if len(self._assignments[concept]) > 0 else None
184
180
  return self._assignments[concept]
185
181
 
186
182
  def matches(self, concept: Union[BrainStructure, Space]) -> bool: