Skip to content

Commit

Permalink
MNT Add codespell: workflow, config and fix typos it finds (#506)
Browse files Browse the repository at this point in the history
* Add github action to codespell main on push and PRs

* Add rudimentary codespell config

* Some skips for codespell

* Ignore more words

* Add more skips

* [DATALAD RUNCMD] codespell -w || :

=== Do not change lines below ===
{
 "chain": [],
 "cmd": "codespell -w || :",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^

* [DATALAD RUNCMD] codespell -w -i 3 -C 2

=== Do not change lines below ===
{
 "chain": [],
 "cmd": "codespell -w -i 3 -C 2",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^

---------

Co-authored-by: Matteo Visconti di Oleggio Castello <[email protected]>
  • Loading branch information
yarikoptic and mvdoc authored Nov 15, 2023
1 parent a49116d commit f0e85fb
Show file tree
Hide file tree
Showing 24 changed files with 66 additions and 38 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
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@v3
- name: Codespell
uses: codespell-project/actions-codespell@v2
2 changes: 1 addition & 1 deletion cortex/blender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _check_file_blender_version(fpath):
import struct
with open(fpath, mode='rb') as fid:
fid.seek(7)
bitness, endianess, major, minor = struct.unpack("sss2s", fid.read(5))
bitness, endianness, major, minor = struct.unpack("sss2s", fid.read(5))
return (int(major), int(minor))


Expand Down
6 changes: 3 additions & 3 deletions cortex/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def get_anat(self, subject, type='raw', xfmname=None, recache=False, order=1, **
return volume.anat2epispace(anatnib.get_fdata().T.astype(float), subject, xfmname, order=order)

def get_surfinfo(self, subject, type="curvature", recache=False, **kwargs):
"""Return auxillary surface information from the filestore. Surface info is defined as
"""Return auxiliary surface information from the filestore. Surface info is defined as
anatomical information specific to a subject in surface space. A Vertex class will be returned
as necessary. Info not found in the filestore will be automatically generated.
Expand Down Expand Up @@ -319,7 +319,7 @@ def get_mri_surf2surf_matrix(self, subject, surface_type, hemi='both',
if fs_subj is None:
fs_subj = subject
fpath = self.get_paths(subject)['surf2surf'].format(source=fs_subj, target=target_subj)
# Backward compatiblity
# Backward compatibility
fdir, _ = os.path.split(fpath)
if not os.path.exists(fdir):
print("Creating surf2surf directory for subject %s"%(subject))
Expand All @@ -344,7 +344,7 @@ def get_overlay(self, subject, overlay_file=None, **kwargs):
pts, polys = self.get_surf(subject, "flat", merge=True, nudge=True)

paths = self.get_paths(subject)
# NOTE: This try loop is broken, in that it does nothing for the inteded
# NOTE: This try loop is broken, in that it does nothing for the intended
# use case (loading an overlay from a packed subject) - needs fixing.
# This hasn't come up yet due to very rare use of packed subjects.
if self.auxfile is not None:
Expand Down
2 changes: 1 addition & 1 deletion cortex/dataset/viewRGB.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class VolumeRGB(DataviewRGB):
Use the same vmin and vmax for all three color channels?
shared_vmin : float, optional
Predetermined shared vmin. Does nothing if shared_range == False. If not given,
will be the 1st percentil of all values across all three channels.
will be the 1st percentile of all values across all three channels.
shared_vmax : float, optional
Predetermined shared vmax. Does nothing if shared_range == False. If not given,
will be the 99th percentile of all values across all three channels
Expand Down
4 changes: 2 additions & 2 deletions cortex/freesurfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


def get_paths(fs_subject, hemi, type="patch", freesurfer_subject_dir=None):
"""Retrive paths for all surfaces for a subject processed by freesurfer
"""Retrieve paths for all surfaces for a subject processed by freesurfer
Parameters
----------
Expand Down Expand Up @@ -231,7 +231,7 @@ def import_flat(fs_subject, patch, hemis=['lh', 'rh'], cx_subject=None,
cx_subject : str
Pycortex subject name
freesurfer_subject_dir : str
directory for freesurfer subjects. None defaults to evironment variable
directory for freesurfer subjects. None defaults to environment variable
$SUBJECTS_DIR
clean : bool
If True, the flat surface is cleaned to remove the disconnected polys.
Expand Down
2 changes: 1 addition & 1 deletion cortex/mapper/samplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def trilinear(coords, shape, **kwargs):
return i, np.ravel_multi_index(j, shape, mode='clip'), data

def distance_func(func, coords, shape, renorm=True, mp=True):
"""Generates masks for seperable distance functions"""
"""Generates masks for separable distance functions"""
nZ, nY, nX = shape
dx = coords[:,0] - np.atleast_2d(np.arange(nX)).T
dy = coords[:,1] - np.atleast_2d(np.arange(nY)).T
Expand Down
2 changes: 1 addition & 1 deletion cortex/mapper/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PolyLinMapper(VolumeMapper):
patchsize = 1

class Polyhedral(VolumeMapper):
'''Uses an actual (likely concave) polyhedra betwen the pial and white surfaces
'''Uses an actual (likely concave) polyhedra between the pial and white surfaces
to estimate the thickness'''
@staticmethod
def _getmask(pia, wm, polys, shape):
Expand Down
4 changes: 2 additions & 2 deletions cortex/polyutils/subsurface.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SubsurfaceMixin(object):
Use Cases
---------
- performing many operations on a subset of cortex
- finding patches/patchs in cortical suface (see Performance Characteristics)
- finding patches/paths in cortical surface (see Performance Characteristics)
Performance Characteristics
Expand Down Expand Up @@ -279,7 +279,7 @@ def get_geodesic_patches(self, radius, seeds=None, n_random_seeds=None, output='
if seeds is None:
raise Exception('must specify seeds or n_random_seeds')

# intialize output
# initialize output
output_dims = (len(seeds), self.pts.shape[0])
if output == 'dense':
patches = np.zeros(output_dims, dtype=bool)
Expand Down
2 changes: 1 addition & 1 deletion cortex/polyutils/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def surface_gradient(self, scalars, at_verts=True):
A scalar-valued function across the cortex.
at_verts : bool, optional
If True (default), values will be returned for each vertex. Otherwise,
values will be retruned for each face.
values will be returned for each face.
Returns
-------
Expand Down
4 changes: 2 additions & 2 deletions cortex/quickflat/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def make_figure(braindata, recache=False, pixelwise=True, thick=32, sampler='nea
linecolor : tuple of float, optional
(R, G, B, A) specification of line color
roifill : tuple of float, optional
(R, G, B, A) sepcification for the fill of each ROI region
(R, G, B, A) specification for the fill of each ROI region
shadow : int, optional
Standard deviation of the gaussian shadow. Set to 0 if you want no shadow
labelsize : str, optional
Expand Down Expand Up @@ -293,7 +293,7 @@ def make_png(fname, braindata, recache=False, pixelwise=True, sampler='nearest',
linecolor : tuple of float, optional
(R, G, B, A) specification of line color
roifill : tuple of float, optional
(R, G, B, A) sepcification for the fill of each ROI region
(R, G, B, A) specification for the fill of each ROI region
shadow : int, optional
Standard deviation of the gaussian shadow. Set to 0 if you want no shadow
labelsize : str, optional
Expand Down
4 changes: 2 additions & 2 deletions cortex/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def cut_surface(cx_subject, hemi, name='flatten', fs_subject=None, data=None,
None defaults to `cx_subject`
freesurfer_subject_dir : str
Name of Freesurfer subject directory. None defaults to SUBJECTS_DIR
environment varible
environment variable
flatten_with : str
'freesurfer' or 'SLIM' - 'freesurfer' (default) uses freesurfer's
`mris_flatten` function to flatten the cut surface. 'SLIM' uses
Expand Down Expand Up @@ -420,7 +420,7 @@ def fix_wm(subject):

def fix_pia(subject):
"""Initializes an interface to make pial surface edits.
This function will open two windows -- a tkmedit window that makse the actual edits,
This function will open two windows -- a tkmedit window that makes the actual edits,
as well as a mayavi window to display the surface. Clicking on the mayavi window
will drop markers which can be loaded using the "Goto Save Point" button in tkmedit.
Expand Down
10 changes: 5 additions & 5 deletions cortex/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def get_roi_masks(subject, xfmname, roi_list=None, gm_sampler='cortical', split_
voxel (reflecting the fraction of that voxel inside the ROI) unless a threshold
is provided.
threshold : float [0-1]
value used to convert probablistic ROI values to a boolean mask for the ROI.
value used to convert probabilistic ROI values to a boolean mask for the ROI.
split_lr : bool
Whether to separate ROIs in to left and right hemispheres (e.g., 'V1' becomes
'V1_L' and 'V1_R')
Expand Down Expand Up @@ -648,7 +648,7 @@ def get_roi_masks(subject, xfmname, roi_list=None, gm_sampler='cortical', split_
continue
if use_mapper:
roi_voxels[roi] = mapper.backwards(roi_verts[roi].astype(float))
# Optionally threshold probablistic values returned by mapper
# Optionally threshold probabilistic values returned by mapper
if threshold is not None:
roi_voxels[roi] = roi_voxels[roi] > threshold
# Check for partial / empty rois:
Expand Down Expand Up @@ -700,7 +700,7 @@ def get_roi_masks(subject, xfmname, roi_list=None, gm_sampler='cortical', split_
else:
output = roi_voxels

# Check percent coverage / optionally cull emtpy ROIs
# Check percent coverage / optionally cull empty ROIs
for roi in set(roi_list)-set(['Cortex']):
if pct_coverage[roi] < 100:
# if not np.any(mask) : reject ROI
Expand Down Expand Up @@ -850,10 +850,10 @@ def get_shared_voxels(subject, xfmname, hemi="both", merge=True, use_astar=True)
Name of the transform
hemi : str, optional
Which hemisphere to return. For now, only 'lh' or 'rh'
merge : bool, optinal
merge : bool, optional
Join the hemispheres, if requesting both
use_astar: bool, optional
Toggle to decide whether to use A* seach or geodesic paths for the
Toggle to decide whether to use A* search or geodesic paths for the
shortest paths
Returns
Expand Down
2 changes: 1 addition & 1 deletion cortex/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# Hard coded version, to be done by release process,
# it is also "parsed" (not imported) by setup.py, that is why assigned as
# __hardcoded_version__ later and not vise versa
# __hardcoded_version__ later and not vice versa
#
# NOTE this should have the format of
# NEW_RELEASE.dev0
Expand Down
6 changes: 3 additions & 3 deletions cortex/webgl/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def make_static(outpath, data, types=("inflated",), recache=False, cmap="RdBu_r"
overlay_file=None, copy_ctmfiles=True, title='Brain', **kwargs):
"""
Creates a static webGL MRI viewer in your filesystem so that it can easily
be posted publically for sharing or just saved for later viewing.
be posted publicly for sharing or just saved for later viewing.
Parameters
----------
Expand All @@ -65,7 +65,7 @@ def make_static(outpath, data, types=("inflated",), recache=False, cmap="RdBu_r"
Whether to rename CTM and SVG files generically, for public distribution.
Default False
overlays_available : tuple, optional
Overlays availble in the viewer. If None, then all overlay layers of the
Overlays available in the viewer. If None, then all overlay layers of the
svg file will be potentially available in the viewer (whether initially
visible or not). This provides the option to include, e.g., only a subset
of layers for a given static viewer.
Expand Down Expand Up @@ -264,7 +264,7 @@ def show(data, types=("inflated", ), recache=False, cmap='RdBu_r', layout=None,
port : int or None, optional
The port that will be used by the server. If None, a random port will be
selected from the range 1024-65536. Default None
pickerfun : funcion or None, optional
pickerfun : function or None, optional
Should be a function that takes two arguments, a voxel index and a vertex
index. Is called whenever a location on the surface is clicked in the
viewer. This can be used to print information about individual voxels or
Expand Down
6 changes: 3 additions & 3 deletions cortex/xfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def to_fsl(self, anat_nii, direction='func>anat'):
Uses the stored "reference" file provided when the transform was created (usually
a functional data or statistical volume) and the supplied anatomical file to
create an FSL transform. By default, returns the transform FROM the refernce volume
create an FSL transform. By default, returns the transform FROM the reference volume
(usually the functional data volume) to the anatomical volume (`anat_nii` input).
Parameters
Expand Down Expand Up @@ -263,7 +263,7 @@ def from_freesurfer(cls, fs_register, func_nii, subject, freesurfer_subject_dir=
L = decode(subprocess.check_output(cmd)).splitlines()
anat_vox2ras = np.array([[np.float_(s) for s in ll.split() if s] for ll in L])
except OSError:
print ("Error occured while executing:\n{}".format(' '.join(cmd)))
print ("Error occurred while executing:\n{}".format(' '.join(cmd)))
raise

# Read tkrvox2ras transform for the anatomical volume
Expand Down Expand Up @@ -381,6 +381,6 @@ def _vox2ras_tkr(image):
tkrvox2ras = np.array(
[[np.float_(s) for s in ll.split() if s] for ll in L])
except OSError as e:
print("Error occured while executing:\n{}".format(' '.join(cmd)))
print("Error occurred while executing:\n{}".format(' '.join(cmd)))
raise e
return tkrvox2ras
4 changes: 2 additions & 2 deletions docs/align.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ There's weird gray blobs - click anywhere to get rid of them.
.. image:: ./aligner/snapshot2.png
:width: 600 px

Here you see 4 different views, showing the saggital, coronal, and transverse slices, and also the three slices in 3D.
Here you see 4 different views, showing the sagittal, coronal, and transverse slices, and also the three slices in 3D.
The background image is the reference image, and the mesh that you see is the surface that you will be aligning.
You'll be moving the mesh until it's aligned as much as possible with the reference.

Expand Down Expand Up @@ -105,7 +105,7 @@ You can also use the ``contrast`` and ``brightness`` sliders to adjust the color
:width: 600 px

The ``Outline color`` and ``Outline rep`` can be used to change the surface color, and the surface from a mesh (the default), to points only, to a solid surface.
Also, the sliders can be used to chane line and point weights.
Also, the sliders can be used to change line and point weights.
Here, we changed it to a green points only representation, with smaller points.

.. image:: ./aligner/surface.png
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@
# The format is a list of tuples containing the path and title.
#epub_pre_files = []

# HTML files shat should be inserted after the pages created by sphinx.
# HTML files that should be inserted after the pages created by sphinx.
# The format is a list of tuples containing the path and title.
#epub_post_files = []

Expand Down
2 changes: 1 addition & 1 deletion docs/database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ In order to plot cortical data for a subject, at least the fiducial and flat geo

Accessing surfaces
~~~~~~~~~~~~~~~~~~
Two methods exist for accessing the surface data once they are committed to the database: direct command access, or via a convienient tab completion interface.
Two methods exist for accessing the surface data once they are committed to the database: direct command access, or via a convenient tab completion interface.

Command access
~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pycortex includes a tool based on mayavi_ to do manual **affine** alignments. Pl

* **Subject** : name of the subject, must match the surfaces used to create the transform
* **Name** : A unique identifier for this transform
* **type** : The type of transform -- from fiducial to functional **magnet** space, or fiducial to **coord** inate space
* **type** : The type of transform -- from fiducial to functional **magnet** space, or fiducial to **coord** innate space
* **epifile** : the filename of the functional data that the fiducial is aligned to

Transforms always store the epifile in order to allow visual validation of alignment using the :module:`align` module.
Expand Down
2 changes: 1 addition & 1 deletion docs/userguide/webgl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ It is simple to post pycortex visualizations to a web page for public viewing. T
Using the WebGL Viewer
----------------------

There are two ways to create a WebGL viewer. A **dynamic viewer** is temporary viewer that is hosted by the pyhton process that generated it. A **static viewer** is a viewer that is saved permanently to disk and will persist beyond the lifetime of the python process. Using a static viewer requires hosting the created directory with a webserver such as nginx.
There are two ways to create a WebGL viewer. A **dynamic viewer** is temporary viewer that is hosted by the python process that generated it. A **static viewer** is a viewer that is saved permanently to disk and will persist beyond the lifetime of the python process. Using a static viewer requires hosting the created directory with a webserver such as nginx.


Keyboard Shortcuts
Expand Down
2 changes: 1 addition & 1 deletion examples/datasets/plot_vertex2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
The cortex.Vertex2D object is instantiated with two numpy arrays of the same
size as the total number of vertices in that subject's flatmap. Each pixel is
colored according to both vlaues given for the nearest vertex in the flatmap.
colored according to both values given for the nearest vertex in the flatmap.
Instead of random test data, you can replace these with any arrays that are
the length of the all the vertices in the subject.
Expand Down
2 changes: 1 addition & 1 deletion examples/utils/multi_panels_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
a webgl viewer. The best way to get the expected results is to keep the webgl
viewer visible during the process.
The selection of views and the aggregation is controled by a list of "panels".
The selection of views and the aggregation is controlled by a list of "panels".
Examples of panels can be imported with:
from cortex.export import params_flatmap_lateral_medial
Expand Down
4 changes: 2 additions & 2 deletions examples/utils/plot_roi_voxel_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Get proportion of each voxel that exists within a named ROI (this
constitutes a probability map for the ROI, with values ranging from
0-1). Plot this probablistic roi mask onto a flatmap.
0-1). Plot this probabilistic roi mask onto a flatmap.
In order for this to work, the specified ROI must exist in the
overlays.svg file in the pycortex filestore for this subject.
Expand All @@ -23,7 +23,7 @@
roi_list=[roi],
gm_sampler='cortical-conservative', # Select only voxels mostly within cortex
split_lr=False, # No separate left/right ROIs
threshold=None, # Leave roi mask values as probabilites / fractions
threshold=None, # Leave roi mask values as probabilities / fractions
return_dict=True
)

Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
# Minimum requirements for the build system to execute, according to PEP518
# specification.
requires = ["numpy", "cython<3.0", "setuptools", "wheel"]

[tool.codespell]
skip = '.git,*.pdf,*.svg,*.css,*.min.*,*.gii,resources,OpenCTM-1.0.3,filestore,build,_build'
check-hidden = true
# ignore-regex = ''
ignore-words-list = 'nd,acount,anormal,fpt,coo,transpart,FO'

0 comments on commit f0e85fb

Please sign in to comment.