Skip to content

Commit

Permalink
Merge pull request #54 from yarikoptic/enh-codespell
Browse files Browse the repository at this point in the history
Add codespell: config, workflow (to detect new) + have it fixed a few of present typos
  • Loading branch information
smeisler authored Dec 4, 2023
2 parents 0c4ffee + 4c85be7 commit 8fbeccb
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[codespell]
skip = .git,*.pdf,*.svg,.codespellrc
check-hidden = true
# ignore-regex =
# ignore-words-list =
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 README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# _fsub-extractor_
This is an application for extracing **F**unctional **Su**bcomponents of **B**undles. This software can take gray matter regions, project them into white matter, and find streamlines that connect to them. It can also produce a visualization of the streamlines and sample scalar values along these streamlines (tract profile and average across all streamlines).
This is an application for extracting **F**unctional **Su**bcomponents of **B**undles. This software can take gray matter regions, project them into white matter, and find streamlines that connect to them. It can also produce a visualization of the streamlines and sample scalar values along these streamlines (tract profile and average across all streamlines).

This software was conceived of during NeuroHackademy 2022.

Expand Down
8 changes: 4 additions & 4 deletions fsub_extractor/cli_starters/extractor_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def get_parser():
"--reg-type",
"--reg_type",
choices=["mrtrix", "itk"],
help="Registration software compatability for .txt files. Only set if the program does not figure this out automatically.",
help="Registration software compatibility for .txt files. Only set if the program does not figure this out automatically.",
)

# Extractor-specific arguments
Expand Down Expand Up @@ -326,7 +326,7 @@ def get_parser():
viz_args.add_argument(
"--saggital-offset",
"--saggital_offset",
help="Float (-1,1) describing where to display saggital slice. -1.0 is left, 1.0 is right. Default is 0.0.",
help="Float (-1,1) describing where to display sagittal slice. -1.0 is left, 1.0 is right. Default is 0.0.",
type=float,
default=0.0,
metavar=("OFFSET"),
Expand All @@ -335,9 +335,9 @@ def get_parser():
viz_args.add_argument(
"--camera-angle",
"--camera_angle",
choices=["saggital", "axial"],
choices=["sagittal", "axial"],
help="Camera angle for visualization. Default is 'saggital.'",
default="saggital",
default="sagittal",
)

return parser
Expand Down
10 changes: 5 additions & 5 deletions fsub_extractor/functions/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ def extractor(
)
if float(projfrac_params_list[0]) >= 0:
raise Exception(
"The 'start' paramater of projfrac-params must be negative to project into white matter."
"The 'start' parameter of projfrac-params must be negative to project into white matter."
)
if float(projfrac_params_list[1]) <= float(projfrac_params_list[0]):
raise Exception(
"The 'stop' paramater of projfrac-params must be greater than the 'start' parameter."
"The 'stop' parameter of projfrac-params must be greater than the 'start' parameter."
)
if float(projfrac_params_list[-1]) <= 0:
raise Exception(
"The 'delta' paramater of projfrac-params must be positive to iterate correctly."
"The 'delta' parameter of projfrac-params must be positive to iterate correctly."
)

# Define and prepare registration
Expand Down Expand Up @@ -341,7 +341,7 @@ def extractor(
tck_file = tract

### Run MRtrix Tract Extraction ###
print("\n Extracing the sub-bundle \n")
print("\n Extracting the sub-bundle \n")
fsub_bundle = extract_tck_mrtrix(
tck_file,
rois_atlas_in,
Expand Down Expand Up @@ -468,7 +468,7 @@ def extractor(
ref_anat = img_viz
show_anat = True

# Make a picture for each hemisphere passed in, if saggital view
# Make a picture for each hemisphere passed in, if sagittal view
if hemi == None:
hemi_list = ["lh"]
else:
Expand Down
2 changes: 1 addition & 1 deletion fsub_extractor/functions/streamline_scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def streamline_scalar(
scalar_paths: str
Comma-delimited paths of scalars (.nii.gz) to analyze
scalar_names: str
Comma-delimited paths of scalar namess
Comma-delimited paths of scalar names
n_points: int
Number of points to use in tract profiles
out_dir: str
Expand Down
4 changes: 2 additions & 2 deletions fsub_extractor/utils/anat_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ def convert_to_mrtrix_reg(reg_in, mrtrix_reg_out, reg_in_type="itk", overwrite=T
Parameters
==========
reg_in: str
Path to input registation
Path to input registration
mrtrix_reg_out: str
Where to save output registation
Where to save output registration
reg_type: str
Format of input registration. Currently only ANTs/ITK is supported.
overwrite: bool
Expand Down
18 changes: 9 additions & 9 deletions fsub_extractor/utils/fury_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def visualize_sub_bundles(
show_anat=False,
axial_offset=0,
saggital_offset=0,
camera_angle="saggital",
camera_angle="sagittal",
hemi="lh",
):
"""Takes in tck and nifti files and makes a fury visualization
Expand All @@ -45,10 +45,10 @@ def visualize_sub_bundles(
show_anat (Optional): Whether to overlay anatomy on the figure (default = False)
axial_offset (Optional): Where to display axial slice (-1,1) where -1 is bottom of image and 1 is top.
(default = 0, which is the middle of the image)
saggital_offset (Optional): Where to display saggital slice (-1,1) where -1 is left of image and 1 is right.
saggital_offset (Optional): Where to display sagittal slice (-1,1) where -1 is left of image and 1 is right.
(default = 0, which is the middle of the image)
camera_angle (Optional): Angle for screenshot ('saggital' (default) or 'axial')
hemi (Optional): For saggital picture, what hemisphere to view from. Accepts either 'lh' or 'rh'.
hemi (Optional): For sagittal picture, what hemisphere to view from. Accepts either 'lh' or 'rh'.
Outputs
=======
Expand Down Expand Up @@ -123,7 +123,7 @@ def visualize_sub_bundles(
# add to figure
figure.add(slice_actor)

# make a copy to make a saggital slice
# make a copy to make a sagittal slice
saggital_actor = slice_actor.copy()

# calculate where to display the image based on the offset
Expand All @@ -137,7 +137,7 @@ def visualize_sub_bundles(

cam = figure.GetActiveCamera()
cam.SetViewUp(0, 0, 0)
if camera_angle == "saggital":
if camera_angle == "sagittal":
if hemi == "lh":
cam.Yaw(270)
cam.Roll(90)
Expand Down Expand Up @@ -238,7 +238,7 @@ def define_slice_actor(reference_anatomy, view="axial", offset=0):
if view == "axial":
offset = (slice_actor.shape[1] - (slice_actor.shape[1] // 2)) * offset
slice_actor.display(None, None, slice_actor.shape[1] // 2 + int(offset))
if view == "saggital":
if view == "sagittal":
offset = (slice_actor.shape[0] - (slice_actor.shape[0] // 2)) * offset
slice_actor.display(slice_actor.shape[0] // 2 + int(offset), None, None)

Expand All @@ -250,13 +250,13 @@ def visualize_bundles(
interactive,
slice_actor=None,
roi_actor=None,
camera_angle="saggital",
camera_angle="sagittal",
hemi="lh",
filename=None,
):

"""Takes in streamline actor, optional roi actor and slice actors
and ouputs a fury scene.
and outputs a fury scene.
Parameters
==========
Expand Down Expand Up @@ -293,7 +293,7 @@ def visualize_bundles(
cam = figure.GetActiveCamera()
cam.SetViewUp(0, 0, 0)

if camera_angle == "saggital":
if camera_angle == "sagittal":
if hemi == "lh":
cam.Yaw(270)
cam.Roll(90)
Expand Down

0 comments on commit 8fbeccb

Please sign in to comment.