diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 000000000..3ebbf5504 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -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 diff --git a/cortex/blender/__init__.py b/cortex/blender/__init__.py index a5eaa47d1..952cd7b4d 100644 --- a/cortex/blender/__init__.py +++ b/cortex/blender/__init__.py @@ -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)) diff --git a/cortex/database.py b/cortex/database.py index 75db0d96d..f4177d021 100644 --- a/cortex/database.py +++ b/cortex/database.py @@ -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. @@ -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)) @@ -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: diff --git a/cortex/dataset/viewRGB.py b/cortex/dataset/viewRGB.py index 530a486c7..08572e337 100644 --- a/cortex/dataset/viewRGB.py +++ b/cortex/dataset/viewRGB.py @@ -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 diff --git a/cortex/freesurfer.py b/cortex/freesurfer.py index c2b33480c..52f8a9fe5 100644 --- a/cortex/freesurfer.py +++ b/cortex/freesurfer.py @@ -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 ---------- @@ -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. diff --git a/cortex/mapper/samplers.py b/cortex/mapper/samplers.py index 1c3c595ef..cbd9c1334 100644 --- a/cortex/mapper/samplers.py +++ b/cortex/mapper/samplers.py @@ -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 diff --git a/cortex/mapper/volume.py b/cortex/mapper/volume.py index e9c70bea6..b787c4aed 100644 --- a/cortex/mapper/volume.py +++ b/cortex/mapper/volume.py @@ -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): diff --git a/cortex/polyutils/subsurface.py b/cortex/polyutils/subsurface.py index f07f1e343..55bb6f748 100644 --- a/cortex/polyutils/subsurface.py +++ b/cortex/polyutils/subsurface.py @@ -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 @@ -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) diff --git a/cortex/polyutils/surface.py b/cortex/polyutils/surface.py index 1ed8df0ae..877533337 100644 --- a/cortex/polyutils/surface.py +++ b/cortex/polyutils/surface.py @@ -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 ------- diff --git a/cortex/quickflat/view.py b/cortex/quickflat/view.py index e213efc9d..9109aee84 100644 --- a/cortex/quickflat/view.py +++ b/cortex/quickflat/view.py @@ -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 @@ -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 diff --git a/cortex/segment.py b/cortex/segment.py index 32f21ce48..7096a3569 100644 --- a/cortex/segment.py +++ b/cortex/segment.py @@ -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 @@ -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. diff --git a/cortex/utils.py b/cortex/utils.py index 2cf7cfbfb..edcd3aa72 100644 --- a/cortex/utils.py +++ b/cortex/utils.py @@ -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') @@ -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: @@ -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 @@ -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 diff --git a/cortex/version.py b/cortex/version.py index 960f71b75..bcba455d1 100644 --- a/cortex/version.py +++ b/cortex/version.py @@ -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 diff --git a/cortex/webgl/view.py b/cortex/webgl/view.py index 6a65bf4ec..9f8da9572 100644 --- a/cortex/webgl/view.py +++ b/cortex/webgl/view.py @@ -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 ---------- @@ -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. @@ -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 diff --git a/cortex/xfm.py b/cortex/xfm.py index 71568598f..cbdae9bdf 100644 --- a/cortex/xfm.py +++ b/cortex/xfm.py @@ -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 @@ -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 @@ -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 diff --git a/docs/align.rst b/docs/align.rst index c2e42d948..06b4ad9bb 100644 --- a/docs/align.rst +++ b/docs/align.rst @@ -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. @@ -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 diff --git a/docs/conf.py b/docs/conf.py index 4ea795243..38020b289 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 = [] diff --git a/docs/database.rst b/docs/database.rst index f3d4904a7..44be7a592 100644 --- a/docs/database.rst +++ b/docs/database.rst @@ -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 ~~~~~~~~~~~~~~ diff --git a/docs/transforms.rst b/docs/transforms.rst index e61b1b8ba..4fb41472c 100644 --- a/docs/transforms.rst +++ b/docs/transforms.rst @@ -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. diff --git a/docs/userguide/webgl.rst b/docs/userguide/webgl.rst index da248b6c6..46c45b525 100644 --- a/docs/userguide/webgl.rst +++ b/docs/userguide/webgl.rst @@ -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 diff --git a/examples/datasets/plot_vertex2D.py b/examples/datasets/plot_vertex2D.py index f5f75ca99..5eb602bab 100644 --- a/examples/datasets/plot_vertex2D.py +++ b/examples/datasets/plot_vertex2D.py @@ -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. diff --git a/examples/utils/multi_panels_plots.py b/examples/utils/multi_panels_plots.py index 037de9f7c..87a544b90 100644 --- a/examples/utils/multi_panels_plots.py +++ b/examples/utils/multi_panels_plots.py @@ -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 diff --git a/examples/utils/plot_roi_voxel_mask.py b/examples/utils/plot_roi_voxel_mask.py index 32cf50904..b0747167b 100644 --- a/examples/utils/plot_roi_voxel_mask.py +++ b/examples/utils/plot_roi_voxel_mask.py @@ -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. @@ -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 ) diff --git a/pyproject.toml b/pyproject.toml index df1485478..bad27b4f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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'