Skip to content

Commit

Permalink
Merge pull request #216 from yarikoptic/enh-codespell
Browse files Browse the repository at this point in the history
Add codespell: configuration, workflow + make it fix some typos
  • Loading branch information
marcelzwiers authored Jan 11, 2024
2 parents 495346b + e434d59 commit b8a0a5d
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 14 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Codespell configuration is within pyproject.toml
---
name: Codespell

on:
push:
branches: [master]
pull_request:
branches: [master]

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 bidscoin/bcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def test_bidscoin(bidsmapfile: Union[Path,dict], options: dict=None, testplugins
LOGGER.warning(f"Failed test: {plugin.stem}")

if not success:
LOGGER.warning('Not all tests finishd successfully (this may be ok, but check the output above)')
LOGGER.warning('Not all tests finished successfully (this may be ok, but check the output above)')
trackusage('bidscoin_error')
else:
LOGGER.success('All tests finished successfully :-)')
Expand Down
2 changes: 1 addition & 1 deletion bidscoin/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ def load_bidsmap(yamlfile: Path, folder: Path=Path(), plugins:Union[tuple,list]=
"""
Read the mapping heuristics from the bidsmap yaml-file. If yamlfile is not fullpath, then 'folder' is first searched before
the default 'heuristics'. If yamfile is empty, then first 'bidsmap.yaml' is searched for, then 'bidsmap_template'. So fullpath
has precendence over folder and bidsmap.yaml has precedence over the bidsmap_template.
has precedence over folder and bidsmap.yaml has precedence over the bidsmap_template.
NB: A run['datasource'] = DataSource object is added to every run-item
Expand Down
8 changes: 4 additions & 4 deletions bidscoin/bidseditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def set_tab_bidsmap(self, dataformat):
def set_tab_options(self):
"""Set the options tab"""

# Create the bidscoin tabel
# Create the bidscoin table
bidscoin_options = self.output_bidsmap['Options']['bidscoin']
self.options_label['bidscoin'] = bidscoin_label = QLabel('BIDScoin')
bidscoin_label.setToolTip(TOOLTIP_BIDSCOIN)
Expand All @@ -376,7 +376,7 @@ def set_tab_options(self):
layout.addWidget(bidscoin_label)
layout.addWidget(bidscoin_table)

# Add the plugin tabels
# Add the plugin tables
for plugin, options in self.output_bidsmap['Options']['plugins'].items():
plugin_label, plugin_table = self.plugin_table(plugin, options)
layout.addWidget(plugin_label)
Expand Down Expand Up @@ -1182,7 +1182,7 @@ def fill_table(self, table: QTableWidget, data: list):
suffix_dropdown.addItems(suffixes)
suffix_dropdown.setCurrentIndex(suffix_dropdown.findText(suffix))
suffix_dropdown.currentIndexChanged.connect(self.suffix_dropdown_change)
suffix_dropdown.setToolTip('The suffix that sets the different run types apart. First make sure the "Data type" dropdown-menu is set correctly before chosing the right suffix here')
suffix_dropdown.setToolTip('The suffix that sets the different run types apart. First make sure the "Data type" dropdown-menu is set correctly before choosing the right suffix here')
for n, suffix in enumerate(suffixes):
suffix_dropdown.setItemData(n, bids.get_suffixhelp(suffix, self.target_datatype), QtCore.Qt.ItemDataRole.ToolTipRole)
table.setCellWidget(i, 1, self.spacedwidget(suffix_dropdown))
Expand Down Expand Up @@ -1490,7 +1490,7 @@ def accept_run(self):
self.done(2)

def export_run(self):
"""Export the editted run to a (e.g. template) bidsmap on disk"""
"""Export the edited run to a (e.g. template) bidsmap on disk"""

yamlfile, _ = QFileDialog.getOpenFileName(self, 'Export run item to (template) bidsmap',
str(bidsmap_template), 'YAML Files (*.yaml *.yml);;All Files (*)')
Expand Down
2 changes: 1 addition & 1 deletion bidscoin/cli/_bidsmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_parser() -> argparse.ArgumentParser:
parser.add_argument('-n','--subprefix', help="The prefix common for all the source subject-folders (e.g. 'Pt' is the subprefix if subject folders are named 'Pt018', 'Pt019', ...). Use '*' when your subject folders do not have a prefix. Default: the value of the study/template bidsmap, e.g. 'sub-'")
parser.add_argument('-m','--sesprefix', help="The prefix common for all the source session-folders (e.g. 'M_' is the subprefix if session folders are named 'M_pre', 'M_post', ..). Use '*' when your session folders do not have a prefix. Default: the value of the study/template bidsmap, e.g. 'ses-'")
parser.add_argument('-u','--unzip', help='Wildcard pattern to unpack tarball/zip-files in the sub/ses sourcefolder that need to be unzipped (in a tempdir) to make the data readable. Default: the value of the study/template bidsmap')
parser.add_argument('-s','--store', help='Store provenance data samples in the bidsfolder/code/provenance folder (useful for inspecting e.g. zipped or transfered datasets)', action='store_true')
parser.add_argument('-s','--store', help='Store provenance data samples in the bidsfolder/code/provenance folder (useful for inspecting e.g. zipped or transferred datasets)', action='store_true')
parser.add_argument('-a','--automated', help='Save the automatically generated bidsmap to disk and without interactively tweaking it with the bidseditor', action='store_true')
parser.add_argument('-f','--force', help='Discard the previously saved bidsmap and logfile', action='store_true')
parser.add_argument('--no-update', help="Do not update any sub/sesprefixes in or prepend the sourcefolder name to the <<filepath:regex>> expression that extracts the subject/session labels. This is normally done to make the extraction more robust, but could cause problems for certain use cases", action='store_true')
Expand Down
2 changes: 1 addition & 1 deletion bidscoin/plugins/dcm2niix2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def bidscoiner_plugin(session: Path, bidsmap: dict, bidsses: Path) -> Union[None
bidstest = (Path('/')/subid/sesid/datasource.datatype/bidsname).with_suffix('.json').as_posix()
isbids = BIDSValidator().is_bids(bidstest)
if not isbids and not bidsignore:
LOGGER.warning(f"The '{bidstest}' ouput name did not pass the bids-validator test")
LOGGER.warning(f"The '{bidstest}' output name did not pass the bids-validator test")

# Check if the output file already exists (-> e.g. when a static runindex is used)
if (outfolder/bidsname).with_suffix('.json').is_file():
Expand Down
2 changes: 1 addition & 1 deletion bidscoin/plugins/nibabel2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def bidscoiner_plugin(session: Path, bidsmap: dict, bidsses: Path) -> None:
bidstest = (Path('/')/subid/sesid/datasource.datatype/bidsname).with_suffix('.json').as_posix()
isbids = BIDSValidator().is_bids(bidstest)
if not isbids and not bidsignore:
LOGGER.warning(f"The '{bidstest}' ouput name did not pass the bids-validator test")
LOGGER.warning(f"The '{bidstest}' output name did not pass the bids-validator test")

# Check if file already exists (-> e.g. when a static runindex is used)
if bidsfile.is_file():
Expand Down
2 changes: 1 addition & 1 deletion bidscoin/plugins/spec2nii2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def bidscoiner_plugin(session: Path, bidsmap: dict, bidsses: Path) -> Union[None
bidstest = (Path('/')/subid/sesid/datasource.datatype/bidsname).with_suffix('.json').as_posix()
isbids = BIDSValidator().is_bids(bidstest)
if not isbids and not bidsignore:
LOGGER.warning(f"The '{bidstest}' ouput name did not pass the bids-validator test")
LOGGER.warning(f"The '{bidstest}' output name did not pass the bids-validator test")

# Check if file already exists (-> e.g. when a static runindex is used)
if sidecar.is_file():
Expand Down
2 changes: 1 addition & 1 deletion docs/bidsmap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Editing the template bidsmap
filename: # File name, e.g. ".*fmap.*" or ".*(fmap|field.?map|B0.?map).*"
filesize: # File size, e.g. "2[4-6]\d MB" for matching files between 240-269 MB
nrfiles: # Number of files in the folder that match the above criteria, e.g. "5/d/d" for matching a number between 500-599
attributes: &anat_dicomattr # An empty / non-matching "reference" dictionary that can be derefenced in other run-items of this data type
attributes: &anat_dicomattr # An empty / non-matching "reference" dictionary that can be dereferenced in other run-items of this data type
Modality:
ProtocolName:
SeriesDescription:
Expand Down
2 changes: 1 addition & 1 deletion docs/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ As can be seen in the API code snippet below (but also see the default plugins f
def bidsmapper_plugin(session: Path, bidsmap_new: dict, bidsmap_old: dict, template: dict, store: dict) -> None:
"""
All the logic to map the Philips PAR/REC fields onto bids labels go into this plugin function. The function is
expecte to update / append new runs to the bidsmap_new data structure. The bidsmap options for this plugin can
expected to update / append new runs to the bidsmap_new data structure. The bidsmap options for this plugin can
be found in:
bidsmap_new/old['Options']['plugins']['README']
Expand Down
4 changes: 2 additions & 2 deletions docs/workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Step 1a: Running the bidsmapper
need to be unzipped (in a tempdir) to make the data readable. Default: the
value of the study/template bidsmap
-s, --store Store provenance data samples in the bidsfolder/code/provenance folder
(useful for inspecting e.g. zipped or transfered datasets)
(useful for inspecting e.g. zipped or transferred datasets)
-a, --automated Save the automatically generated bidsmap to disk and without interactively
tweaking it with the bidseditor
-f, --force Discard the previously saved bidsmap and logfile
Expand Down Expand Up @@ -151,7 +151,7 @@ If the preview of the BIDS filename and meta-data both look good, you can store

The edit window for customizing a bidsmap run item, featuring the DICOM attributes mapped onto BIDS values and (dynamic) metadata values (e.g. ``Comments``). BIDS values that are restricted to a limited set are presented with a drop-down menu.

Finally, if all BIDS output names in the main window are fine, you can click on the [Save] button and proceed with running the bidscoiner tool (step 2). Note that re-running the bidsmapper or bidseditor is always a safe thing to do since these tools will re-use the existing bidsmap yaml-file and will not delete or write anything to disk except to the bidsmap yaml-file.
Finally, if all BIDS output names in the main window are fine, you can click on the [Save] button and proceed with running the bidscoiner tool (step 2). Note that re-running the bidsmapper or bidseditor is always a safe thing to do since these tools will reuse the existing bidsmap yaml-file and will not delete or write anything to disk except to the bidsmap yaml-file.

Field maps
``````````
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,10 @@ commands = make -C docs html
linkchecker docs/_build/html/index.html
pyspelling -c docs/.pyspelling.yml
"""

# Ref: https://github.com/codespell-project/codespell#using-a-config-file
[tool.codespell]
skip = '.git,*.pdf,*.svg,go.sum'
check-hidden = true
ignore-regex = '\b(PULS|TE|ALS)\b'
ignore-words-list = 'compliancy,uptodate,mis'

0 comments on commit b8a0a5d

Please sign in to comment.