From bbdb1ce3edd9a9c79e8fb851e5b2ef9b1f996b7b Mon Sep 17 00:00:00 2001 From: Siddhartha Dhiman Date: Wed, 11 Sep 2024 00:06:14 -0400 Subject: [PATCH] Linting --- pydesigner/preprocessing/mrpreproc.py | 57 +++++---------------------- pydesigner/system/errors.py | 6 ++- tests/test_preprocessing_mrpreproc.py | 3 -- 3 files changed, 14 insertions(+), 52 deletions(-) diff --git a/pydesigner/preprocessing/mrpreproc.py b/pydesigner/preprocessing/mrpreproc.py index 79aae36..5956e51 100644 --- a/pydesigner/preprocessing/mrpreproc.py +++ b/pydesigner/preprocessing/mrpreproc.py @@ -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 @@ -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"] @@ -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 @@ -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") @@ -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. @@ -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) @@ -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") diff --git a/pydesigner/system/errors.py b/pydesigner/system/errors.py index 5e24e4d..0afa16f 100644 --- a/pydesigner/system/errors.py +++ b/pydesigner/system/errors.py @@ -3,6 +3,8 @@ class FileExtensionError(FileNotFoundError): pass + class MRTrixError(IOError): - """Raise an exception for MRPreproc-related issues. """ - pass \ No newline at end of file + """Raise an exception for MRPreproc-related issues.""" + + pass diff --git a/tests/test_preprocessing_mrpreproc.py b/tests/test_preprocessing_mrpreproc.py index 34862c0..d9c99d5 100644 --- a/tests/test_preprocessing_mrpreproc.py +++ b/tests/test_preprocessing_mrpreproc.py @@ -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) - - -