Skip to content

Commit 6cbf075

Browse files
committed
Merge branch 'main' into fix_query_bbprof_w_locations
2 parents f0b0596 + 3c900fe commit 6cbf075

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+147
-113
lines changed

.codespellrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[codespell]
2+
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
3+
# TODO: go through gene_names.json manually since might have some true positives
4+
skip = .git*,*.css,.codespellrc,gene_names.json,requirements*.txt,region_aliases.json
5+
check-hidden = true
6+
# embedded images and otherwise too long lines
7+
ignore-regex = ^\s*"image/\S+": ".*|.{300,}|\bFOM\b
8+
# ignore-words-list =

.github/workflows/codespell.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Codespell configuration is within .codespellrc
2+
---
3+
name: Codespell
4+
5+
on:
6+
push:
7+
branches: [main]
8+
pull_request:
9+
branches: [main]
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
codespell:
16+
name: Check for spelling errors
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
- name: Annotate locations with typos
23+
uses: codespell-project/codespell-problem-matcher@v1
24+
- name: Codespell
25+
uses: codespell-project/actions-codespell@v2

docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def is_allen_api_microarray_service_available():
122122
shell=False,
123123
)
124124

125-
# napolean settings
125+
# napoleon settings
126126
napoleon_google_docstring = False
127127
napoleon_use_param = True
128128
napoleon_use_ivar = True
@@ -213,7 +213,7 @@ def is_allen_api_microarray_service_available():
213213
html_theme = "sphinx_book_theme"
214214
html_show_sourcelink = False
215215
html_show_sphinx = True
216-
html_logo = "_static/siibra-python.jpeg" # overriden by logo in html_theme_options
216+
html_logo = "_static/siibra-python.jpeg" # overridden by logo in html_theme_options
217217
html_favicon = "_static/siibra_favicon.ico"
218218
html_permalinks = False
219219

docs/core_concepts.ipynb

+6-6
Large diffs are not rendered by default.

docs/create_preconfiguration.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ How to structure jsons?
1414
=======================
1515
In ``config_schema`` folder within
1616
`siibra-python <https://github.com/FZJ-INM1-BDA/siibra-python>`_, the existing
17-
schemes are provied as json files. These are meant to be a guide, particularly
17+
schemes are provided as json files. These are meant to be a guide, particularly
1818
for the minimum requirements.
1919

2020
Step-by-step
@@ -37,7 +37,7 @@ I. Determine the type
3737
* Volume of interest
3838
* Parcellation-based activity timeseries (tabular)
3939

40-
**Not listed:** If the data is not fitting to any of the catagories and would
40+
**Not listed:** If the data is not fitting to any of the categories and would
4141
like to see your data in siibra, then a new schema is needed as otherwise CI
4242
will fail. It is expected that each new schema should be as general as possible.
4343
For example, instead of a schema for regional BOLD data, a schema for activity
@@ -82,7 +82,7 @@ IV. Use/share your preconfiguration
8282
-----------------------------------
8383

8484
You can now use this json to load your desired data as a siibra object and take
85-
adventage its functionalities. You can also share this json with your colleagues
85+
advantage its functionalities. You can also share this json with your colleagues
8686
to collabrate.
8787

8888
At this stage, if you'd like to see your data in siibra-toolbox as default,

docs/developer.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ Adding data to siibra-toolsuite
219219

220220
Anatomical Anchor
221221
-----------------
222-
Each feautre instance requires an anatomical anchor. This could be a parcellation
222+
Each feature instance requires an anatomical anchor. This could be a parcellation
223223
(as in ``RegionalConnecticity``), a region, a region and a location, or a location.
224224
Using the anatomical anchor siibra can determine the semantic and spatial
225225
relationship between different ``AtlasConcepts``.

docs/download_maps.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"source": [
77
"# Downloading parcellation and probability maps\n",
88
"\n",
9-
"`siibra` can facilitate structured, automatized and reprodicible download of parcellation maps. In this example, we demonstrate how to download all maximum probability and probabilistic maps of *Julich-Brain* - more then 300 structures available in different spaces. \n",
9+
"`siibra` can facilitate structured, automated and reproducible download of parcellation maps. In this example, we demonstrate how to download all maximum probability and probabilistic maps of *Julich-Brain* - more then 300 structures available in different spaces. \n",
1010
"\n",
1111
"As often, we start by loading the human atlas."
1212
]

e2e/core/test_parcellation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ def test_region_id_uniqueness(parcellation: Parcellation):
6565
duplicates.add(region.id)
6666
ids.add(region)
6767

68-
assert len(duplicates) == 0, f"Folowing regions a duplicate IDs in {parcellation.name}:\n{duplicates}"
68+
assert len(duplicates) == 0, f"Following regions a duplicate IDs in {parcellation.name}:\n{duplicates}"

e2e/core/test_region.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,5 @@ def test_boundingbox(space):
121121

122122
v_l = hoc1_l.get_regional_mask(space)
123123
v_r = hoc1_r.get_regional_mask(space)
124-
assert bbox_l == v_l.get_boundingbox(clip=True, background=0.0), "Boundingbox of regional mask should be the same as bouding mask of the regions"
125-
assert bbox_r == v_r.get_boundingbox(clip=True, background=0.0), "Boundingbox of regional mask should be the same as bouding mask of the regions"
124+
assert bbox_l == v_l.get_boundingbox(clip=True, background=0.0), "Boundingbox of regional mask should be the same as bounding mask of the regions"
125+
assert bbox_r == v_r.get_boundingbox(clip=True, background=0.0), "Boundingbox of regional mask should be the same as bounding mask of the regions"

e2e/features/image/test_image.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
def test_feature_has_datasets(feature: Image):
1919
if feature.name in PRERELEASE_FEATURES_W_NO_DATASET:
2020
if len(feature.datasets) > 0:
21-
pytest.fail(f"Feature '{feature}' was listed as prerelase previosly but now have dataset information. Please update `PRERELEASE_FEATURES_W_NO_DATASET`")
21+
pytest.fail(f"Feature '{feature}' was listed as prerelease previously but now have dataset information. Please update `PRERELEASE_FEATURES_W_NO_DATASET`")
2222
pytest.skip(f"Feature '{feature}' has no datasets yet as it is a prerelease data.")
2323
assert len(feature.datasets) > 0, f"{feature} has no datasets"
2424

e2e/features/test_get.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ def test_subclass_count(fid):
7171

7272
def test_querying_with_volume():
7373
# Use features with location anchors only. Because hybrid ones will also
74-
# employ sementic links between regions, potentially changing the result.
74+
# employ semantic links between regions, potentially changing the result.
7575
region = siibra.get_region("julich 2.9", "ca1")
7676
volume = region.get_regional_mask("mni152")
7777
profiles_region = siibra.features.get(region, "BigBrainIntensityProfile")[0]
7878
profiles_volume = siibra.features.get(volume, "BigBrainIntensityProfile")[0]
79-
# the ids will be diffent but the content has to be the same. Even the order.
79+
# the ids will be different but the content has to be the same. Even the order.
8080
assert [p.location for p in profiles_region] == [
8181
p.location for p in profiles_volume
8282
]

examples/02_maps_and_templates/002_accessing_templates.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
# or to fetch from a concrete resource format.
7979
# Meshes are provided as a dictionary with an Nx3 array of N vertices,
8080
# and an Mx3 array of M triangles defined from the vertices.
81-
# we can pre-check wether a volume provides image or mesh data
81+
# we can pre-check whether a volume provides image or mesh data
8282
# explicitly using `provides_mesh` and `provides_image`
8383
assert icbm_tpl.provides_mesh
8484
icbm_mesh = icbm_tpl.fetch(format='mesh')

examples/02_maps_and_templates/007_adding_custom_parcellation.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
# The text file with label mappings has a custom format. We provide a tsv
5151
# decoder to extract the list of region/label pairs since the txt file is tab
52-
# seperated.
52+
# separated.
5353
volume_info = conn.get("AICHA/AICHA_vol1.txt", decode_func=siibra.retrieval.requests.DECODERS['.tsv'])
5454
volume_info
5555

@@ -84,8 +84,8 @@
8484

8585

8686
# %%
87-
# On the other hand, some features are only anchored to a sementic region
88-
# object and the link to the custome region is not directly known to siibra.
87+
# On the other hand, some features are only anchored to a semantic region
88+
# object and the link to the custom region is not directly known to siibra.
8989
# However, siibra circumvents this by comparing volumes of these regions to
9090
# assign a link between them.
9191
volume = region.get_regional_mask('mni152')

examples/03_data_features/003_cell_distributions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
view.add_markers([tuple(location)])
8484

8585
# %%
86-
# Now let us look into BigBrain intenstiy profiles for V1 left and dispaly the
86+
# Now let us look into BigBrain intenstiy profiles for V1 left and display the
8787
# gray matter mesh coordinates on the region mask.
8888
v1left = siibra.get_region("julich 2.9", "v1 left")
8989
cf = siibra.features.get(v1left, "BigBrainIntensityProfile")[0]

examples/05_anatomical_assignment/002_activation_maps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
# assign cytoarchitectonic regions to this functional map. Since we are here
6767
# usually interested in correlations of the modes, we filter the result by
6868
# significant (positive) correlations.
69-
# To assigne an image, we first need to createa Volume which has to have a
69+
# To assign an image, we first need to create Volume which has to have a
7070
# space defined.
7171
volume = siibra.volumes.volume.from_nifti(img, difumo_maps.space, "fusiform posterior")
7272
with siibra.QUIET: # suppress progress output

siibra/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def set_feasible_download_size(maxsize_gbyte):
108108

109109
def set_cache_size(maxsize_gbyte: int):
110110
"""
111-
siibra runs maintainance on its local cache to keep it under a predetermined
111+
siibra runs maintenance on its local cache to keep it under a predetermined
112112
size of 2 gigabytes. This method changes the cache size.
113113
114114
Parameters
@@ -129,9 +129,9 @@ def warm_cache(level=WarmupLevel.INSTANCE):
129129
Preload preconfigured siibra concepts.
130130
131131
Siibra relies on preconfigurations that simplify integrating various
132-
concepts such as parcellations, refernce spaces, and multimodal data
132+
concepts such as parcellations, reference spaces, and multimodal data
133133
features. By preloading the instances, siibra commits all preconfigurations
134-
to the memory at once instead of commiting them when required.
134+
to the memory at once instead of committing them when required.
135135
"""
136136
Warmup.warmup(level)
137137

siibra/commons.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def __iter__(self) -> Iterator[T]:
139139
return (w for w in self._elements.values())
140140

141141
def __contains__(self, key: Union[str, T]) -> bool:
142-
"""Test wether the given key or element is defined by the registry."""
142+
"""Test whether the given key or element is defined by the registry."""
143143
if isinstance(key, str):
144144
return key in self._elements
145145
return key in [item for _, item in self._elements.values()]
@@ -536,7 +536,8 @@ def resample_img_to_img(
536536
resampled_img = resample_to_img(
537537
source_img=source_img,
538538
target_img=target_img,
539-
interpolation=interpolation
539+
interpolation=interpolation,
540+
force_resample=True, # False is intended for testing. see nilearn docs
540541
)
541542
return resampled_img
542543

@@ -554,7 +555,7 @@ def connected_components(
554555
555556
Note
556557
----
557-
`Uses skimage.measure.label()` to determine foreground compenents.
558+
`Uses skimage.measure.label()` to determine foreground components.
558559
559560
Parameters
560561
----------
@@ -568,7 +569,7 @@ def connected_components(
568569
Yields
569570
------
570571
Generator[Tuple[int, np.ndarray], None, None]
571-
tuple of integer label of the component and component as an nd.array in
572+
tuple of integer label of the component and component as an ndarray in
572573
the shape of the original image.
573574
"""
574575
from skimage import measure
@@ -644,11 +645,11 @@ def MI(arr1, arr2, nbins=100, normalized=True):
644645
assert (all(arr.size > 0) for arr in [arr1, arr2])
645646

646647
# compute the normalized joint 2D histogram as an
647-
# empirical measure of the joint probabily of arr1 and arr2
648+
# empirical measure of the joint probability of arr1 and arr2
648649
pxy, _, _ = np.histogram2d(arr1.ravel(), arr2.ravel(), bins=nbins)
649650
pxy /= pxy.sum()
650651

651-
# extract the empirical propabilities of intensities
652+
# extract the empirical probabilities of intensities
652653
# from the joint histogram
653654
px = np.sum(pxy, axis=1) # marginal for x over y
654655
py = np.sum(pxy, axis=0) # marginal for y over x

siibra/core/concept.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ def urls(self) -> List[str]:
145145
@property
146146
def authors(self):
147147
return [
148-
contributer['name']
148+
contributor['name']
149149
for ds in self.datasets
150-
for contributer in ds.contributors
150+
for contributor in ds.contributors
151151
]
152152

153153
@property

siibra/core/parcellation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def _split_group_spec(self, spec: str):
221221
"""
222222
spec = re.sub(r'Group: *', '', spec)
223223
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
225225
# because these are not region spec delimiters
226226
spec = spec.replace(substr, re.sub(r', *', '##', substr))
227227
# process the comma separated substrings
@@ -354,7 +354,7 @@ def find_regions(
354354
):
355355
"""
356356
Find regions matching the given region specification across all parcellation
357-
instances in the registery.
357+
instances in the registry.
358358
359359
Parameters
360360
----------

siibra/core/region.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ def get_related_regions(self) -> Iterable["RegionRelationAssessments"]:
133133
Example
134134
-------
135135
>>> region = siibra.get_region("monkey", "PG")
136-
>>> for assesment in region.get_related_regions():
137-
>>> print(assesment)
136+
>>> for assessment in region.get_related_regions():
137+
>>> print(assessment)
138138
'PG' is homologous to 'Area PGa (IPL)'
139139
'PG' is homologous to 'Area PGa (IPL) left'
140140
'PG' is homologous to 'Area PGa (IPL) right'
@@ -481,7 +481,7 @@ def get_regional_mask(
481481
volume.merge(descendant_volumes),
482482
label=1
483483
)
484-
name += f"'{result.space}' (built by merging the mask {threshold_info} of its decendants)"
484+
name += f"'{result.space}' (built by merging the mask {threshold_info} of its descendants)"
485485
else:
486486
raise e
487487
result._name = name
@@ -497,7 +497,7 @@ def get_regional_map(
497497
maptype: MapType = MapType.LABELLED,
498498
) -> Union[volume.FilteredVolume, volume.Volume, volume.Subvolume]:
499499
"""
500-
Get a volume reprsenting this region in the given space and MapType.
500+
Get a volume representing this region in the given space and MapType.
501501
502502
Note
503503
----
@@ -540,7 +540,7 @@ def get_regional_map(
540540

541541
def mapped_in_space(self, space, recurse: bool = False) -> bool:
542542
"""
543-
Verifies wether this region is defined by an explicit map in the given space.
543+
Verifies whether this region is defined by an explicit map in the given space.
544544
545545
Parameters
546546
----------
@@ -931,8 +931,8 @@ def get_related_regions(region: Region) -> Iterable["RegionRelationAssessments"]
931931
Example
932932
-------
933933
>>> region = siibra.get_region("monkey", "PG")
934-
>>> for assesment in siibra.core.region.get_related_regions(region):
935-
>>> print(assesment)
934+
>>> for assessment in siibra.core.region.get_related_regions(region):
935+
>>> print(assessment)
936936
'PG' is homologous to 'Area PGa (IPL)'
937937
'PG' is homologous to 'Area PGa (IPL) left'
938938
'PG' is homologous to 'Area PGa (IPL) right'

siibra/core/structure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def assign(self, other: "BrainStructure") -> assignment.AnatomicalAssignment:
7676
# Two cases:
7777
# 1) self is location, other is location -> look at spatial intersection/relationship, do it here
7878
# 2) self is location, other is region -> get region map, then call again. do it here
79-
# If self is region -> Region overwrite this method, adressed there
79+
# If self is region -> Region overwrite this method, addressed there
8080

8181
assert not isinstance(self, _region.Region) # method is overwritten by Region!
8282
if (self, other) in self._ASSIGNMENT_CACHE:

siibra/experimental/contour.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def crop(self, voi: boundingbox.BoundingBox):
4646

4747
if cropped is not None and not isinstance(cropped, point.Point):
4848
assert isinstance(cropped, pointcloud.PointCloud)
49-
# Identifiy contour splits are by discontinuouities ("jumps")
49+
# Identify contour splits are by discontinuouities ("jumps")
5050
# of their labels, which denote positions in the original contour
5151
jumps = np.diff([self.labels.index(lb) for lb in cropped.labels])
5252
splits = [0] + list(np.where(jumps > 1)[0] + 1) + [len(cropped)]

siibra/experimental/plane3d.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self, point1: point.Point, point2: point.Point, point3: point.Point
3333
The plane's reference space is defined by the first point.
3434
"""
3535
self.space = point1.space
36-
# normal is the cross product of two arbitray in-plane vectors
36+
# normal is the cross product of two arbitrary in-plane vectors
3737
n = np.cross(
3838
(point2.warp(self.space) - point1).coordinate,
3939
(point3.warp(self.space) - point1).coordinate,
@@ -107,7 +107,7 @@ def intersect_mesh(self, mesh: dict):
107107
)[0]
108108
faces = mesh["faces"][face_indices]
109109

110-
# for each of N selected faces, indicate wether we cross the plane
110+
# for each of N selected faces, indicate whether we cross the plane
111111
# as we go from vertex 2->0, 0->1, 1->2, respectively.
112112
# This gives us an Nx3 array, where forward crossings are identified by 1,
113113
# and backward crossings by -1.
@@ -160,7 +160,7 @@ def intersect_mesh(self, mesh: dict):
160160
face_id = 0 # index of the mesh face to consider
161161
while len(face_indices) > 0:
162162

163-
# continue the contour with the next foward edge intersection
163+
# continue the contour with the next forward edge intersection
164164
p = fwd_intersections[face_id]
165165
points.append(p)
166166
# Remember the ids of the face and start-/end vertices for the point

siibra/explorer/url.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def get_hash(full_string: str):
211211
for char in full_string:
212212
# overflowing is expected and in fact the whole reason why convert number to int32
213213

214-
# in windows, int32((0 - min_int32) << 5), rather than overflow to wraper around, raises OverflowError
214+
# in windows, int32((0 - min_int32) << 5), rather than overflow to wrapper around, raises OverflowError
215215
shifted_5 = int32(
216216
(return_val - min_int32) if return_val > max_int32 else return_val << 5
217217
)

siibra/features/anchor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def parcellations(self) -> List[Parcellation]:
8888

8989
@property
9090
def space(self) -> Space:
91-
# may be overriden by derived classes, e.g. in features.VolumeOfInterest
91+
# may be overridden by derived classes, e.g. in features.VolumeOfInterest
9292
return None if self.location is None else self.location.space
9393

9494
@property

0 commit comments

Comments
 (0)