Skip to content

Commit

Permalink
Add codespell support (config, workflow to detect/not fix) and make i…
Browse files Browse the repository at this point in the history
…t fix few typos (#12)

* Add github action to codespell master on push and PRs

* Add rudimentary codespell config

* [DATALAD RUNCMD] run codespell throughout fixing typos automagically (but ignoring overall fail due to ambigous ones)

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

* [DATALAD RUNCMD] Do interactive fixing of some ambigous typos

=== 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 ^^^

* refactor(ci): move codespell with the linters.

---------

Co-authored-by: Pierre-Antoine Comby <[email protected]>
  • Loading branch information
yarikoptic and paquiteau authored Oct 4, 2024
1 parent f392915 commit 1bca434
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 9 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ jobs:
shell: bash
run: ruff check src

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

test-suite:
runs-on: ${{ matrix.os }}
needs: linter-check
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ It includes several local-low-rank based denoising methods (see the `documentati
4. Optimal Thresholding
5. Raw Singular Value Thresholding

A mathematical description of theses methods is available in the documentation.
A mathematical description of these methods is available in the documentation.



Expand All @@ -58,7 +58,7 @@ After installing you can use the ``patch-denoise`` command-line.
$ patch-denoise input_file.nii output_file.nii --mask="auto"
See ``patch-denoise --help`` for detailled options.
See ``patch-denoise --help`` for detailed options.

Documentation and Examples
==========================
Expand Down
2 changes: 1 addition & 1 deletion docs/denoisers.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
LLR Denoising Methods
=====================

Patch-denoise implemement several local-low-rank methods, based on singular values thresholding.
Patch-denoise implement several local-low-rank methods, based on singular values thresholding.


Singular Value Thresholding
Expand Down
11 changes: 10 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "patch-denoise"
description = "Denoising method for sequence of images or volumes. Primarly targeting fMRI data."
description = "Denoising method for sequence of images or volumes. Primarily targeting fMRI data."
authors = [{name="Pierre-antoine Comby", email="[email protected]"}]

readme = "README.rst"
Expand Down Expand Up @@ -29,12 +29,14 @@ classifiers = [
[project.optional-dependencies]
optional = ["modopt", "nipype", "numba"]
test = ["pytest", "pytest-cov", "pytest-xdist", "pytest-sugar"]

doc = [
"pydata-sphinx-theme",
"numpydoc",
"sphinx_gallery",
"sphinx",
]

dev = ["black", "isort", "ruff"]

[project.scripts]
Expand Down Expand Up @@ -80,3 +82,10 @@ addopts = [
"--cov-report=term-missing",
"--cov-report=xml"
]

[tool.codespell]
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
skip = '.git*'
check-hidden = true
ignore-regex = '\bND\b'
ignore-words-list = 'fro'
1 change: 1 addition & 0 deletions src/patch_denoise/bindings/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def _get_parser():
),
default=None,
)

denoising_group.add_argument(
"--extra",
metavar="key=value",
Expand Down
2 changes: 1 addition & 1 deletion src/patch_denoise/bindings/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def __str__(self):


def load_as_array(input):
"""Load a file as a numpy array, and return affine matrix if avaiable."""
"""Load a file as a numpy array, and return affine matrix if available."""
import nibabel as nib

if input is None:
Expand Down
2 changes: 1 addition & 1 deletion src/patch_denoise/space_time/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def denoise(self, input_data, mask=None, mask_threshold=50, progbar=None):

# # Replace all nan by mean value of patch.
# # FIXME this behaviour should be documented
# # And ideally choosen by the user.
# # And ideally chosen by the user.

# patch[np.isnan(patch)] = np.mean(patch)
# p_denoise, maxidx, noise_var = self._patch_processing(
Expand Down
6 changes: 3 additions & 3 deletions src/patch_denoise/space_time/lowrank.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, patch_shape, patch_overlap, threshold_scale, **kwargs):
self.input_denoising_kwargs["threshold_scale"] = threshold_scale

def _patch_processing(self, patch, patch_idx=None, threshold_scale=1.0):
"""Process a pach with the MP-PCA method."""
"""Process a patch with the MP-PCA method."""
p_center, eig_vals, eig_vec, p_tmean = eig_analysis(patch)
maxidx = 0
meanvar = np.mean(eig_vals)
Expand Down Expand Up @@ -102,7 +102,7 @@ def denoise(
return super().denoise(input_data, mask, mask_threshold, progbar=progbar)

def _patch_processing(self, patch, patch_idx=None, var_apriori=None):
"""Process a pach with the Hybrid-PCA method."""
"""Process a patch with the Hybrid-PCA method."""
varest = np.mean(var_apriori.get_patch(patch_idx))
p_center, eig_vals, eig_vec, p_tmean = eig_analysis(patch)
maxidx = 0
Expand Down Expand Up @@ -168,7 +168,7 @@ def denoise(
return super().denoise(input_data, mask, mask_threshold, progbar=progbar)

def _patch_processing(self, patch, patch_idx=None, **kwargs):
"""Process a pach with the simple SVT method."""
"""Process a patch with the simple SVT method."""
# Centering for better precision in SVD
u_vec, s_values, v_vec, p_tmean = svd_analysis(patch)

Expand Down

0 comments on commit 1bca434

Please sign in to comment.