Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJaeger committed Sep 11, 2024
1 parent ac13dcd commit bbdb1ce
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 52 deletions.
57 changes: 10 additions & 47 deletions pydesigner/preprocessing/mrpreproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,11 @@
import numpy as np

from ..preprocessing import mrinfoutil, rician, smoothing
from ..system.models import modelmrtrix, input_path_validator, output_path_validator
from ..system.errors import MRTrixError
from ..system.models import input_path_validator, modelmrtrix, output_path_validator

def miftonii(
input: str,
output: str,
nthreads: bool = None,
force: bool = True, verbose:
bool = False
) -> None:

def miftonii(input: str, output: str, nthreads: bool = None, force: bool = True, verbose: bool = False) -> None:
"""Converts input `.mif` images to output `.nii` images
Parameters
Expand All @@ -46,13 +41,7 @@ def miftonii(
--------
niitomif
"""
opts = modelmrtrix(
input=input,
output=output,
nthreads=nthreads,
force=force,
verbose=verbose
)
opts = modelmrtrix(input=input, output=output, nthreads=nthreads, force=force, verbose=verbose)
input_path_validator(opts.input, ".mif")
output_path_validator(opts.output, ".nii")
arg = ["mrconvert"]
Expand All @@ -79,13 +68,7 @@ def miftonii(
raise MRTrixError(msg)


def niitomif(
input: str,
output: str,
nthreads: bool = None,
force: bool = True,
verbose: bool = False
) -> None:
def niitomif(input: str, output: str, nthreads: bool = None, force: bool = True, verbose: bool = False) -> None:
"""Converts input `.nii` images to output `.mif` images provided that
all BVEC, BVAL and JSON files are provided and named same as input .nii
Expand All @@ -112,13 +95,7 @@ def niitomif(
--------
miftonii
"""
opts = modelmrtrix(
input=input,
output=output,
nthreads=nthreads,
force=force,
verbose=verbose
)
opts = modelmrtrix(input=input, output=output, nthreads=nthreads, force=force, verbose=verbose)
input_path_validator(opts.input, ".nii")
path_bvec = input_path_validator(op.splitext(opts.input)[0] + ".bvec", ".bvec")
path_bval = input_path_validator(op.splitext(opts.input)[0] + ".bval", ".bval")
Expand All @@ -141,12 +118,9 @@ def niitomif(
msg += f"\nMRtrix3 error: {completion.stderr}"
raise MRTrixError(msg)


def stride_match(
target: str, moving: str,
output: str,
nthreads: bool = None,
force: bool = True,
verbose: bool = False
target: str, moving: str, output: str, nthreads: bool = None, force: bool = True, verbose: bool = False
) -> None:
"""Matches strides on inputs target and moving by converting strides
on moving image to those of target image.
Expand All @@ -172,12 +146,7 @@ def stride_match(
-------
None; writes out file
"""
opts = modelmrtrix(
output=output,
nthreads=nthreads,
force=force,
verbose=verbose
)
opts = modelmrtrix(output=output, nthreads=nthreads, force=force, verbose=verbose)
target = input_path_validator(target)
moving = input_path_validator(moving)

Expand Down Expand Up @@ -234,13 +203,7 @@ def denoise(
-------
None; writes out file
"""
opts = modelmrtrix(
input=input,
output=output,
nthreads=nthreads,
force=force,
verbose=verbose
)
opts = modelmrtrix(input=input, output=output, nthreads=nthreads, force=force, verbose=verbose)
if not isinstance(noisemap, bool):
raise TypeError("Please specify whether noisemap generation is True or False.")
noisemap_path = op.join(op.dirname(opts.output), "noisemap.nii")
Expand Down
6 changes: 4 additions & 2 deletions pydesigner/system/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ class FileExtensionError(FileNotFoundError):

pass


class MRTrixError(IOError):
"""Raise an exception for MRPreproc-related issues. """
pass
"""Raise an exception for MRPreproc-related issues."""

pass
3 changes: 0 additions & 3 deletions tests/test_preprocessing_mrpreproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,3 @@ def test_denoise_output_success(tmp_path, nthreads, force, verbose):
assert os.path.exists(noisemap_nii)
assert mrinfoutil.format(output_nii) == "NIfTI-1.1"
mrinfoutil.size(output_nii) == (2, 2, 2, 337)



0 comments on commit bbdb1ce

Please sign in to comment.