siibra 1.0.1a0__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.

Files changed (82) hide show
  1. siibra/VERSION +1 -1
  2. siibra/__init__.py +11 -20
  3. siibra/commons.py +17 -14
  4. siibra/configuration/__init__.py +1 -1
  5. siibra/configuration/configuration.py +6 -6
  6. siibra/configuration/factory.py +10 -9
  7. siibra/core/__init__.py +2 -2
  8. siibra/core/assignment.py +2 -1
  9. siibra/core/atlas.py +4 -4
  10. siibra/core/concept.py +7 -5
  11. siibra/core/parcellation.py +10 -10
  12. siibra/core/region.py +82 -73
  13. siibra/core/space.py +5 -7
  14. siibra/core/structure.py +4 -4
  15. siibra/exceptions.py +6 -2
  16. siibra/explorer/__init__.py +1 -1
  17. siibra/explorer/url.py +2 -2
  18. siibra/explorer/util.py +1 -1
  19. siibra/features/__init__.py +1 -1
  20. siibra/features/anchor.py +4 -6
  21. siibra/features/connectivity/__init__.py +1 -1
  22. siibra/features/connectivity/functional_connectivity.py +1 -1
  23. siibra/features/connectivity/regional_connectivity.py +12 -15
  24. siibra/features/connectivity/streamline_counts.py +1 -1
  25. siibra/features/connectivity/streamline_lengths.py +1 -1
  26. siibra/features/connectivity/tracing_connectivity.py +1 -1
  27. siibra/features/dataset/__init__.py +1 -1
  28. siibra/features/dataset/ebrains.py +2 -2
  29. siibra/features/feature.py +31 -28
  30. siibra/features/image/__init__.py +5 -3
  31. siibra/features/image/image.py +4 -6
  32. siibra/features/image/sections.py +82 -3
  33. siibra/features/image/volume_of_interest.py +1 -9
  34. siibra/features/tabular/__init__.py +2 -2
  35. siibra/features/tabular/bigbrain_intensity_profile.py +3 -2
  36. siibra/features/tabular/cell_density_profile.py +10 -11
  37. siibra/features/tabular/cortical_profile.py +9 -9
  38. siibra/features/tabular/gene_expression.py +7 -6
  39. siibra/features/tabular/layerwise_bigbrain_intensities.py +5 -4
  40. siibra/features/tabular/layerwise_cell_density.py +5 -7
  41. siibra/features/tabular/receptor_density_fingerprint.py +47 -19
  42. siibra/features/tabular/receptor_density_profile.py +2 -3
  43. siibra/features/tabular/regional_timeseries_activity.py +9 -9
  44. siibra/features/tabular/tabular.py +10 -9
  45. siibra/livequeries/__init__.py +1 -1
  46. siibra/livequeries/allen.py +23 -25
  47. siibra/livequeries/bigbrain.py +252 -55
  48. siibra/livequeries/ebrains.py +14 -11
  49. siibra/livequeries/query.py +5 -5
  50. siibra/locations/__init__.py +19 -10
  51. siibra/locations/boundingbox.py +10 -13
  52. siibra/{experimental/plane3d.py → locations/experimental.py} +117 -17
  53. siibra/locations/location.py +11 -13
  54. siibra/locations/point.py +10 -19
  55. siibra/locations/pointcloud.py +59 -23
  56. siibra/retrieval/__init__.py +1 -1
  57. siibra/retrieval/cache.py +2 -1
  58. siibra/retrieval/datasets.py +23 -17
  59. siibra/retrieval/exceptions/__init__.py +1 -1
  60. siibra/retrieval/repositories.py +14 -15
  61. siibra/retrieval/requests.py +32 -30
  62. siibra/vocabularies/__init__.py +2 -3
  63. siibra/volumes/__init__.py +5 -4
  64. siibra/volumes/parcellationmap.py +55 -20
  65. siibra/volumes/providers/__init__.py +1 -1
  66. siibra/volumes/providers/freesurfer.py +7 -7
  67. siibra/volumes/providers/gifti.py +5 -5
  68. siibra/volumes/providers/neuroglancer.py +25 -28
  69. siibra/volumes/providers/nifti.py +7 -7
  70. siibra/volumes/providers/provider.py +4 -3
  71. siibra/volumes/sparsemap.py +8 -7
  72. siibra/volumes/volume.py +33 -40
  73. {siibra-1.0.1a0.dist-info → siibra-1.0.1a2.dist-info}/METADATA +21 -8
  74. siibra-1.0.1a2.dist-info/RECORD +80 -0
  75. {siibra-1.0.1a0.dist-info → siibra-1.0.1a2.dist-info}/WHEEL +1 -1
  76. siibra/experimental/__init__.py +0 -19
  77. siibra/experimental/contour.py +0 -61
  78. siibra/experimental/cortical_profile_sampler.py +0 -57
  79. siibra/experimental/patch.py +0 -98
  80. siibra-1.0.1a0.dist-info/RECORD +0 -84
  81. {siibra-1.0.1a0.dist-info → siibra-1.0.1a2.dist-info}/LICENSE +0 -0
  82. {siibra-1.0.1a0.dist-info → siibra-1.0.1a2.dist-info}/top_level.txt +0 -0
siibra/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1-alpha.0
1
+ 1.0.1-alpha.2
siibra/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2018-2024
1
+ # Copyright 2018-2025
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");
@@ -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
 
@@ -108,7 +100,7 @@ def set_feasible_download_size(maxsize_gbyte):
108
100
 
109
101
  def set_cache_size(maxsize_gbyte: int):
110
102
  """
111
- siibra runs maintainance on its local cache to keep it under a predetermined
103
+ siibra runs maintenance on its local cache to keep it under a predetermined
112
104
  size of 2 gigabytes. This method changes the cache size.
113
105
 
114
106
  Parameters
@@ -129,9 +121,9 @@ def warm_cache(level=WarmupLevel.INSTANCE):
129
121
  Preload preconfigured siibra concepts.
130
122
 
131
123
  Siibra relies on preconfigurations that simplify integrating various
132
- concepts such as parcellations, refernce spaces, and multimodal data
124
+ concepts such as parcellations, reference spaces, and multimodal data
133
125
  features. By preloading the instances, siibra commits all preconfigurations
134
- to the memory at once instead of commiting them when required.
126
+ to the memory at once instead of committing them when required.
135
127
  """
136
128
  Warmup.warmup(level)
137
129
 
@@ -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
@@ -1,4 +1,4 @@
1
- # Copyright 2018-2024
1
+ # Copyright 2018-2025
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");
@@ -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()
@@ -139,7 +141,7 @@ class InstanceTable(Generic[T], Iterable):
139
141
  return (w for w in self._elements.values())
140
142
 
141
143
  def __contains__(self, key: Union[str, T]) -> bool:
142
- """Test wether the given key or element is defined by the registry."""
144
+ """Test whether the given key or element is defined by the registry."""
143
145
  if isinstance(key, str):
144
146
  return key in self._elements
145
147
  return key in [item for _, item in self._elements.values()]
@@ -536,7 +538,8 @@ def resample_img_to_img(
536
538
  resampled_img = resample_to_img(
537
539
  source_img=source_img,
538
540
  target_img=target_img,
539
- interpolation=interpolation
541
+ interpolation=interpolation,
542
+ force_resample=True, # False is intended for testing. see nilearn docs
540
543
  )
541
544
  return resampled_img
542
545
 
@@ -554,7 +557,7 @@ def connected_components(
554
557
 
555
558
  Note
556
559
  ----
557
- `Uses skimage.measure.label()` to determine foreground compenents.
560
+ `Uses skimage.measure.label()` to determine foreground components.
558
561
 
559
562
  Parameters
560
563
  ----------
@@ -568,7 +571,7 @@ def connected_components(
568
571
  Yields
569
572
  ------
570
573
  Generator[Tuple[int, np.ndarray], None, None]
571
- tuple of integer label of the component and component as an nd.array in
574
+ tuple of integer label of the component and component as an ndarray in
572
575
  the shape of the original image.
573
576
  """
574
577
  from skimage import measure
@@ -644,11 +647,11 @@ def MI(arr1, arr2, nbins=100, normalized=True):
644
647
  assert (all(arr.size > 0) for arr in [arr1, arr2])
645
648
 
646
649
  # compute the normalized joint 2D histogram as an
647
- # empirical measure of the joint probabily of arr1 and arr2
650
+ # empirical measure of the joint probability of arr1 and arr2
648
651
  pxy, _, _ = np.histogram2d(arr1.ravel(), arr2.ravel(), bins=nbins)
649
652
  pxy /= pxy.sum()
650
653
 
651
- # extract the empirical propabilities of intensities
654
+ # extract the empirical probabilities of intensities
652
655
  # from the joint histogram
653
656
  px = np.sum(pxy, axis=1) # marginal for x over y
654
657
  py = np.sum(pxy, axis=0) # marginal for y over x
@@ -1,4 +1,4 @@
1
- # Copyright 2018-2024
1
+ # Copyright 2018-2025
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");
@@ -1,4 +1,4 @@
1
- # Copyright 2018-2024
1
+ # Copyright 2018-2025
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");
@@ -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
  """
@@ -1,4 +1,4 @@
1
- # Copyright 2018-2024
1
+ # Copyright 2018-2025
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");
@@ -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
@@ -1,4 +1,4 @@
1
- # Copyright 2018-2024
1
+ # Copyright 2018-2025
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");
@@ -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
@@ -1,4 +1,4 @@
1
- # Copyright 2018-2024
1
+ # Copyright 2018-2025
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");
@@ -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
 
siibra/core/atlas.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2018-2024
1
+ # Copyright 2018-2025
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");
@@ -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
@@ -1,4 +1,4 @@
1
- # Copyright 2018-2024
1
+ # Copyright 2018-2025
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");
@@ -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]] = {}
@@ -145,9 +147,9 @@ class AtlasConcept:
145
147
  @property
146
148
  def authors(self):
147
149
  return [
148
- contributer['name']
150
+ contributor['name']
149
151
  for ds in self.datasets
150
- for contributer in ds.contributors
152
+ for contributor in ds.contributors
151
153
  ]
152
154
 
153
155
  @property
@@ -1,4 +1,4 @@
1
- # Copyright 2018-2024
1
+ # Copyright 2018-2025
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");
@@ -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 NoMapMatchingValues
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
@@ -193,13 +193,13 @@ class Parcellation(region.Region, configuration_folder="parcellations"):
193
193
  and m.parcellation.matches(self)
194
194
  ]
195
195
  if len(candidates) == 0:
196
- raise NoMapMatchingValues(f"No '{maptype}' map in '{space}' available for {str(self)}")
196
+ raise MapNotFound(f"No '{maptype}' map in '{space}' available for {str(self)}")
197
197
  if len(candidates) > 1:
198
198
  spec_candidates = [
199
199
  c for c in candidates if all(w.lower() in c.id.lower() for w in spec.split())
200
200
  ]
201
201
  if len(spec_candidates) == 0:
202
- raise NoMapMatchingValues(f"'{spec}' does not match any options from {[c.name for c in candidates]}.")
202
+ raise MapNotFound(f"'{spec}' does not match any options from {[c.name for c in candidates]}.")
203
203
  if len(spec_candidates) > 1:
204
204
  logger.warning(
205
205
  f"Multiple maps are available in this specification of space, parcellation, and map type.\n"
@@ -221,7 +221,7 @@ class Parcellation(region.Region, configuration_folder="parcellations"):
221
221
  """
222
222
  spec = re.sub(r'Group: *', '', spec)
223
223
  for substr in re.findall(r'\(.*?\)', spec):
224
- # temporarilty replace commas inside brackets with a placeholder
224
+ # temporarily replace commas inside brackets with a placeholder
225
225
  # because these are not region spec delimiters
226
226
  spec = spec.replace(substr, re.sub(r', *', '##', substr))
227
227
  # process the comma separated substrings
@@ -354,7 +354,7 @@ def find_regions(
354
354
  ):
355
355
  """
356
356
  Find regions matching the given region specification across all parcellation
357
- instances in the registery.
357
+ instances in the registry.
358
358
 
359
359
  Parameters
360
360
  ----------