Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add codespell support (config, workflow to detect/not fix) and make it fix few typos #638

Merged
merged 11 commits into from
Jan 16, 2025
Merged
8 changes: 8 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[codespell]
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
# TODO: go through gene_names.json manually since might have some true positives
skip = .git*,*.css,.codespellrc,gene_names.json,requirements*.txt,region_aliases.json
check-hidden = true
# embedded images and otherwise too long lines
ignore-regex = ^\s*"image/\S+": ".*|.{300,}|\bFOM\b
# ignore-words-list =
25 changes: 25 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Codespell configuration is within .codespellrc
---
name: Codespell

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Annotate locations with typos
uses: codespell-project/codespell-problem-matcher@v1
- name: Codespell
uses: codespell-project/actions-codespell@v2
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def is_allen_api_microarray_service_available():
shell=False,
)

# napolean settings
# napoleon settings
napoleon_google_docstring = False
napoleon_use_param = True
napoleon_use_ivar = True
Expand Down Expand Up @@ -213,7 +213,7 @@ def is_allen_api_microarray_service_available():
html_theme = "sphinx_book_theme"
html_show_sourcelink = False
html_show_sphinx = True
html_logo = "_static/siibra-python.jpeg" # overriden by logo in html_theme_options
html_logo = "_static/siibra-python.jpeg" # overridden by logo in html_theme_options
html_favicon = "_static/siibra_favicon.ico"
html_permalinks = False

Expand Down
12 changes: 6 additions & 6 deletions docs/core_concepts.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/create_preconfiguration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ How to structure jsons?
=======================
In ``config_schema`` folder within
`siibra-python <https://github.com/FZJ-INM1-BDA/siibra-python>`_, the existing
schemes are provied as json files. These are meant to be a guide, particularly
schemes are provided as json files. These are meant to be a guide, particularly
for the minimum requirements.

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

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

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

At this stage, if you'd like to see your data in siibra-toolbox as default,
Expand Down
2 changes: 1 addition & 1 deletion docs/developer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Adding data to siibra-toolsuite

Anatomical Anchor
-----------------
Each feautre instance requires an anatomical anchor. This could be a parcellation
Each feature instance requires an anatomical anchor. This could be a parcellation
(as in ``RegionalConnecticity``), a region, a region and a location, or a location.
Using the anatomical anchor siibra can determine the semantic and spatial
relationship between different ``AtlasConcepts``.
2 changes: 1 addition & 1 deletion docs/download_maps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Downloading parcellation and probability maps\n",
"\n",
"`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",
"`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",
"\n",
"As often, we start by loading the human atlas."
]
Expand Down
2 changes: 1 addition & 1 deletion e2e/core/test_parcellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ def test_region_id_uniqueness(parcellation: Parcellation):
duplicates.add(region.id)
ids.add(region)

assert len(duplicates) == 0, f"Folowing regions a duplicate IDs in {parcellation.name}:\n{duplicates}"
assert len(duplicates) == 0, f"Following regions a duplicate IDs in {parcellation.name}:\n{duplicates}"
4 changes: 2 additions & 2 deletions e2e/core/test_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,5 @@ def test_boundingbox(space):

v_l = hoc1_l.get_regional_mask(space)
v_r = hoc1_r.get_regional_mask(space)
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"
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"
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"
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"
2 changes: 1 addition & 1 deletion e2e/features/image/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
def test_feature_has_datasets(feature: Image):
if feature.name in PRERELEASE_FEATURES_W_NO_DATASET:
if len(feature.datasets) > 0:
pytest.fail(f"Feature '{feature}' was listed as prerelase previosly but now have dataset information. Please update `PRERELEASE_FEATURES_W_NO_DATASET`")
pytest.fail(f"Feature '{feature}' was listed as prerelease previously but now have dataset information. Please update `PRERELEASE_FEATURES_W_NO_DATASET`")
pytest.skip(f"Feature '{feature}' has no datasets yet as it is a prerelease data.")
assert len(feature.datasets) > 0, f"{feature} has no datasets"

Expand Down
4 changes: 2 additions & 2 deletions e2e/features/test_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ def test_subclass_count(fid):

def test_querying_with_volume():
# Use features with location anchors only. Because hybrid ones will also
# employ sementic links between regions, potentially changing the result.
# employ semantic links between regions, potentially changing the result.
region = siibra.get_region("julich 2.9", "ca1")
volume = region.get_regional_mask('mni152')
profiles_region = siibra.features.get(region, "BigBrainIntensityProfile")[0]
profiles_volume = siibra.features.get(volume, "BigBrainIntensityProfile")[0]
# the ids will be diffent but the content has to be the same. Even the order.
# the ids will be different but the content has to be the same. Even the order.
assert [p.location for p in profiles_region] == [p.location for p in profiles_volume]
2 changes: 1 addition & 1 deletion examples/02_maps_and_templates/002_accessing_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
# or to fetch from a concrete resource format.
# Meshes are provided as a dictionary with an Nx3 array of N vertices,
# and an Mx3 array of M triangles defined from the vertices.
# we can pre-check wether a volume provides image or mesh data
# we can pre-check whether a volume provides image or mesh data
# explicitly using `provides_mesh` and `provides_image`
assert icbm_tpl.provides_mesh
icbm_mesh = icbm_tpl.fetch(format='mesh')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

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

Expand Down Expand Up @@ -84,8 +84,8 @@


# %%
# On the other hand, some features are only anchored to a sementic region
# object and the link to the custome region is not directly known to siibra.
# On the other hand, some features are only anchored to a semantic region
# object and the link to the custom region is not directly known to siibra.
# However, siibra circumvents this by comparing volumes of these regions to
# assign a link between them.
volume = region.get_regional_mask('mni152')
Expand Down
2 changes: 1 addition & 1 deletion examples/03_data_features/003_cell_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
view.add_markers([tuple(location)])

# %%
# Now let us look into BigBrain intenstiy profiles for V1 left and dispaly the
# Now let us look into BigBrain intenstiy profiles for V1 left and display the
# gray matter mesh coordinates on the region mask.
v1left = siibra.get_region("julich 2.9", "v1 left")
cf = siibra.features.get(v1left, "BigBrainIntensityProfile")[0]
Expand Down
2 changes: 1 addition & 1 deletion examples/05_anatomical_assignment/002_activation_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
# assign cytoarchitectonic regions to this functional map. Since we are here
# usually interested in correlations of the modes, we filter the result by
# significant (positive) correlations.
# To assigne an image, we first need to createa Volume which has to have a
# To assign an image, we first need to create Volume which has to have a
# space defined.
volume = siibra.volumes.volume.from_nifti(img, difumo_maps.space, "fusiform posterior")
with siibra.QUIET: # suppress progress output
Expand Down
6 changes: 3 additions & 3 deletions siibra/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def set_feasible_download_size(maxsize_gbyte):

def set_cache_size(maxsize_gbyte: int):
"""
siibra runs maintainance on its local cache to keep it under a predetermined
siibra runs maintenance on its local cache to keep it under a predetermined
size of 2 gigabytes. This method changes the cache size.

Parameters
Expand All @@ -129,9 +129,9 @@ def warm_cache(level=WarmupLevel.INSTANCE):
Preload preconfigured siibra concepts.

Siibra relies on preconfigurations that simplify integrating various
concepts such as parcellations, refernce spaces, and multimodal data
concepts such as parcellations, reference spaces, and multimodal data
features. By preloading the instances, siibra commits all preconfigurations
to the memory at once instead of commiting them when required.
to the memory at once instead of committing them when required.
"""
Warmup.warmup(level)

Expand Down
10 changes: 5 additions & 5 deletions siibra/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def __iter__(self) -> Iterator[T]:
return (w for w in self._elements.values())

def __contains__(self, key: Union[str, T]) -> bool:
"""Test wether the given key or element is defined by the registry."""
"""Test whether the given key or element is defined by the registry."""
if isinstance(key, str):
return key in self._elements
return key in [item for _, item in self._elements.values()]
Expand Down Expand Up @@ -554,7 +554,7 @@ def connected_components(

Note
----
`Uses skimage.measure.label()` to determine foreground compenents.
`Uses skimage.measure.label()` to determine foreground components.

Parameters
----------
Expand All @@ -568,7 +568,7 @@ def connected_components(
Yields
------
Generator[Tuple[int, np.ndarray], None, None]
tuple of integer label of the component and component as an nd.array in
tuple of integer label of the component and component as an ndarray in
the shape of the original image.
"""
from skimage import measure
Expand Down Expand Up @@ -644,11 +644,11 @@ def MI(arr1, arr2, nbins=100, normalized=True):
assert (all(arr.size > 0) for arr in [arr1, arr2])

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

# extract the empirical propabilities of intensities
# extract the empirical probabilities of intensities
# from the joint histogram
px = np.sum(pxy, axis=1) # marginal for x over y
py = np.sum(pxy, axis=0) # marginal for y over x
Expand Down
4 changes: 2 additions & 2 deletions siibra/core/concept.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ def urls(self) -> List[str]:
@property
def authors(self):
return [
contributer['name']
contributor['name']
for ds in self.datasets
for contributer in ds.contributors
for contributor in ds.contributors
]

@property
Expand Down
4 changes: 2 additions & 2 deletions siibra/core/parcellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def _split_group_spec(self, spec: str):
"""
spec = re.sub(r'Group: *', '', spec)
for substr in re.findall(r'\(.*?\)', spec):
# temporarilty replace commas inside brackets with a placeholder
# temporarily replace commas inside brackets with a placeholder
# because these are not region spec delimiters
spec = spec.replace(substr, re.sub(r', *', '##', substr))
# process the comma separated substrings
Expand Down Expand Up @@ -354,7 +354,7 @@ def find_regions(
):
"""
Find regions matching the given region specification across all parcellation
instances in the registery.
instances in the registry.

Parameters
----------
Expand Down
14 changes: 7 additions & 7 deletions siibra/core/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@
Example
-------
>>> region = siibra.get_region("monkey", "PG")
>>> for assesment in region.get_related_regions():
>>> print(assesment)
>>> for assessment in region.get_related_regions():
>>> print(assessment)
'PG' is homologous to 'Area PGa (IPL)'
'PG' is homologous to 'Area PGa (IPL) left'
'PG' is homologous to 'Area PGa (IPL) right'
Expand Down Expand Up @@ -481,7 +481,7 @@
volume.merge(descendant_volumes),
label=1
)
name += f"'{result.space}' (built by merging the mask {threshold_info} of its decendants)"
name += f"'{result.space}' (built by merging the mask {threshold_info} of its descendants)"

Check warning on line 484 in siibra/core/region.py

View check run for this annotation

Codecov / codecov/patch

siibra/core/region.py#L484

Added line #L484 was not covered by tests
else:
raise e
result._name = name
Expand All @@ -497,7 +497,7 @@
maptype: MapType = MapType.LABELLED,
) -> Union[volume.FilteredVolume, volume.Volume, volume.Subvolume]:
"""
Get a volume reprsenting this region in the given space and MapType.
Get a volume representing this region in the given space and MapType.

Note
----
Expand Down Expand Up @@ -540,7 +540,7 @@

def mapped_in_space(self, space, recurse: bool = False) -> bool:
"""
Verifies wether this region is defined by an explicit map in the given space.
Verifies whether this region is defined by an explicit map in the given space.

Parameters
----------
Expand Down Expand Up @@ -931,8 +931,8 @@
Example
-------
>>> region = siibra.get_region("monkey", "PG")
>>> for assesment in siibra.core.region.get_related_regions(region):
>>> print(assesment)
>>> for assessment in siibra.core.region.get_related_regions(region):
>>> print(assessment)
'PG' is homologous to 'Area PGa (IPL)'
'PG' is homologous to 'Area PGa (IPL) left'
'PG' is homologous to 'Area PGa (IPL) right'
Expand Down
2 changes: 1 addition & 1 deletion siibra/core/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def assign(self, other: "BrainStructure") -> assignment.AnatomicalAssignment:
# Two cases:
# 1) self is location, other is location -> look at spatial intersection/relationship, do it here
# 2) self is location, other is region -> get region map, then call again. do it here
# If self is region -> Region overwrite this method, adressed there
# If self is region -> Region overwrite this method, addressed there

assert not isinstance(self, _region.Region) # method is overwritten by Region!
if (self, other) in self._ASSIGNMENT_CACHE:
Expand Down
2 changes: 1 addition & 1 deletion siibra/experimental/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def crop(self, voi: boundingbox.BoundingBox):

if cropped is not None and not isinstance(cropped, point.Point):
assert isinstance(cropped, pointcloud.PointCloud)
# Identifiy contour splits are by discontinuouities ("jumps")
# Identify contour splits are by discontinuouities ("jumps")
# of their labels, which denote positions in the original contour
jumps = np.diff([self.labels.index(lb) for lb in cropped.labels])
splits = [0] + list(np.where(jumps > 1)[0] + 1) + [len(cropped)]
Expand Down
6 changes: 3 additions & 3 deletions siibra/experimental/plane3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, point1: point.Point, point2: point.Point, point3: point.Point
The plane's reference space is defined by the first point.
"""
self.space = point1.space
# normal is the cross product of two arbitray in-plane vectors
# normal is the cross product of two arbitrary in-plane vectors
n = np.cross(
(point2.warp(self.space) - point1).coordinate,
(point3.warp(self.space) - point1).coordinate,
Expand Down Expand Up @@ -107,7 +107,7 @@ def intersect_mesh(self, mesh: dict):
)[0]
faces = mesh["faces"][face_indices]

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

# continue the contour with the next foward edge intersection
# continue the contour with the next forward edge intersection
p = fwd_intersections[face_id]
points.append(p)
# Remember the ids of the face and start-/end vertices for the point
Expand Down
2 changes: 1 addition & 1 deletion siibra/explorer/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def get_hash(full_string: str):
for char in full_string:
# overflowing is expected and in fact the whole reason why convert number to int32

# in windows, int32((0 - min_int32) << 5), rather than overflow to wraper around, raises OverflowError
# in windows, int32((0 - min_int32) << 5), rather than overflow to wrapper around, raises OverflowError
shifted_5 = int32(
(return_val - min_int32) if return_val > max_int32 else return_val << 5
)
Expand Down
2 changes: 1 addition & 1 deletion siibra/features/anchor.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def parcellations(self) -> List[Parcellation]:

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

@property
Expand Down
2 changes: 1 addition & 1 deletion siibra/features/connectivity/regional_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@

regions = [r for r in matrix.index if matches(r, region)]
if len(regions) == 0:
raise ValueError(f"Invalid region specificiation: {region}")
raise ValueError(f"Invalid region specification: {region}")

Check warning on line 278 in siibra/features/connectivity/regional_connectivity.py

View check run for this annotation

Codecov / codecov/patch

siibra/features/connectivity/regional_connectivity.py#L278

Added line #L278 was not covered by tests
elif len(regions) > 1:
raise ValueError(f"Region specification {region} matched more than one profile: {regions}")
else:
Expand Down
Loading
Loading