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 #603

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
check-hidden = true
# embedded images and otherwise too long lines
ignore-regex = ^\s*"image/\S+": ".*|.{300,}|\bFOM\b|.*codespell-ignore
# 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
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
from subprocess import run
run(f"pyreverse -k -o svg -p siibra {siibrapath} --colorized --all-ancestors --output-directory {staticpath}", shell=False)

# napolean settings
# napoleon settings
napoleon_google_docstring = False
napoleon_use_param = True
napoleon_use_ivar = True
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
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_map(space)
v_r = hoc1_r.get_regional_map(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/molecular/test_genes.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_gene_exp():
assert len(features_grandparent_struct) == 1
assert len(features_leaf_struct) == 1

# Using higher threshold should result in less gene expresssion measures
# Using higher threshold should result in less gene expression measures
assert len(features_grandparent_struct[0].data) > len(features_leaf_struct[0].data)


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_map('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_map('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
4 changes: 2 additions & 2 deletions siibra/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,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
12 changes: 6 additions & 6 deletions siibra/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,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 @@ -556,7 +556,7 @@ def connected_components(

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

Parameters
----------
Expand All @@ -570,7 +570,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 @@ -600,7 +600,7 @@ def length(self):

def sample(self, d):

# if d is interable, we assume a list of sample positions
# if d is iterable, we assume a list of sample positions
try:
iter(d)
except TypeError:
Expand Down Expand Up @@ -689,11 +689,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 @@ -136,9 +136,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
2 changes: 1 addition & 1 deletion siibra/core/parcellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,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
10 changes: 5 additions & 5 deletions siibra/core/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ def get_related_regions(self) -> Iterable["RegionRelationAssessments"]:
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 @@ -554,7 +554,7 @@ def get_regional_map(

def mapped_in_space(self, space, recurse: bool = True) -> 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 @@ -941,8 +941,8 @@ def get_related_regions(region: Region) -> Iterable["RegionRelationAssessments"]
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 @@ -77,7 +77,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, pointset.PointSet)
# 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 @@ -196,7 +196,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 @@ -273,7 +273,7 @@ def matches(r1, r2):

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}")
elif len(regions) > 1:
raise ValueError(f"Region specification {region} matched more than one profile: {regions}")
else:
Expand Down
Loading