Skip to content

Commit

Permalink
Fix style issues (#910)
Browse files Browse the repository at this point in the history
* Fix style issues.

* Update eddy.py
  • Loading branch information
tsalo authored Jan 10, 2025
1 parent 716aac4 commit 4799ffc
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 34 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
linkcode_resolve = make_linkcode_resolve(
'qsiprep',
(
'https://github.com/pennlinc/qsiprep/blob/' '{revision}/{package}/{path}#L{lineno}' # noqa: FS003
'https://github.com/pennlinc/qsiprep/blob/{revision}/{package}/{path}#L{lineno}' # noqa: FS003
),
)

Expand Down
2 changes: 1 addition & 1 deletion qsiprep/_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _warn(message, category=None, stacklevel=1, source=None):
category = type(category).__name__
category = category.replace('type', 'WARNING')

logging.getLogger('py.warnings').warning(f"{category or 'WARNING'}: {message}")
logging.getLogger('py.warnings').warning(f'{category or "WARNING"}: {message}')


def _showwarning(message, category, filename, lineno, file=None, line=None):
Expand Down
15 changes: 7 additions & 8 deletions qsiprep/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class DeprecatedAction(Action):
def __call__(self, parser, namespace, values, option_string=None):
new_opt, rem_vers = deprecations.get(self.dest, (None, None))
msg = (
f"{self.option_strings} has been deprecated and will be removed in "
f"{rem_vers or 'a later version'}."
f'{self.option_strings} has been deprecated and will be removed in '
f'{rem_vers or "a later version"}.'
)
if new_opt:
msg += f' Please use `{new_opt}` instead.'
Expand Down Expand Up @@ -193,7 +193,7 @@ def _bids_filter(value, parser):
parser.add_argument(
'analysis_level',
choices=['participant'],
help='Processing stage to be run, only "participant" in the case of ' 'QSIPrep (for now).',
help='Processing stage to be run, only "participant" in the case of QSIPrep (for now).',
)

g_bids = parser.add_argument_group('Options for filtering BIDS queries')
Expand Down Expand Up @@ -507,7 +507,7 @@ def _bids_filter(value, parser):
action='store',
default='Affine',
choices=['Affine', 'Rigid'],
help='transformation to be optimized during head motion correction ' '(default: affine)',
help='transformation to be optimized during head motion correction (default: affine)',
)
g_moco.add_argument(
'--hmc-model',
Expand Down Expand Up @@ -739,7 +739,7 @@ def parse_args(args=None, namespace=None):

# Ensure input and output folders are not the same
if output_dir == bids_dir:
rec_path = output_dir / 'derivatives' / f"qsiprep-{version.split('+')[0]}"
rec_path = output_dir / 'derivatives' / f'qsiprep-{version.split("+")[0]}'
parser.error(
'The selected output folder is the same as the input BIDS folder. '
f'Please modify the output path (suggestion: {rec_path}).'
Expand All @@ -756,8 +756,7 @@ def parse_args(args=None, namespace=None):
from ..utils.bids import validate_input_dir

build_log.info(
'Making sure the input data is BIDS compliant (warnings can be ignored in most '
'cases).'
'Making sure the input data is BIDS compliant (warnings can be ignored in most cases).'
)
validate_input_dir(
config.environment.exec_env,
Expand All @@ -782,7 +781,7 @@ def parse_args(args=None, namespace=None):
if missing_subjects:
parser.error(
'One or more participant labels were not found in the BIDS directory: '
f"{', '.join(missing_subjects)}."
f'{", ".join(missing_subjects)}.'
)

# Determine which sessions to process and group them
Expand Down
6 changes: 3 additions & 3 deletions qsiprep/cli/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ def build_workflow(config_file, retval):
notice_path = Path(pkgrf('qsiprep', 'data/NOTICE'))
if notice_path.exists():
banner[0] += '\n'
banner += [f"License NOTICE {'#' * 50}"]
banner += [f'License NOTICE {"#" * 50}']
banner += [f'QSIPrep {version}']
banner += notice_path.read_text().splitlines(keepends=False)[1:]
banner += ['#' * len(banner[1])]
build_log.log(25, f"\n{' ' * 9}".join(banner))
build_log.log(25, f'\n{" " * 9}'.join(banner))

# warn if older results exist: check for dataset_description.json in output folder
# msg = check_pipeline_version("QSIPrep", version, output_dir / "dataset_description.json")
Expand Down Expand Up @@ -112,7 +112,7 @@ def build_workflow(config_file, retval):
f'Run identifier: {config.execution.run_uuid}.',
]

build_log.log(25, f"\n{' ' * 11}* ".join(init_msg))
build_log.log(25, f'\n{" " * 11}* '.join(init_msg))

# If qsiprep is being run on already preprocessed data:
retval['workflow'] = init_qsiprep_wf()
Expand Down
4 changes: 2 additions & 2 deletions qsiprep/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class execution(_Config):
# the command line) as spatial references for outputs."""
reports_only = False
"""Only build the reports, based on the reportlets found in a cached working directory."""
run_uuid = f"{strftime('%Y%m%d-%H%M%S')}_{uuid4()}"
run_uuid = f'{strftime("%Y%m%d-%H%M%S")}_{uuid4()}'
"""Unique identifier of this particular run."""
participant_label = None
"""List of participant identifiers that are to be preprocessed."""
Expand Down Expand Up @@ -766,7 +766,7 @@ def get(flat=False):
}
if 'processing_list' in settings['execution']:
settings['execution']['processing_list'] = [
f"{el[0]}:{','.join(el[1])}" for el in settings['execution']['processing_list']
f'{el[0]}:{",".join(el[1])}' for el in settings['execution']['processing_list']
]

if not flat:
Expand Down
2 changes: 1 addition & 1 deletion qsiprep/interfaces/dipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Patch2SelfInputSpec(SeriesPreprocReportInputSpec):
shift_intensity = traits.Bool(
True,
usedefault=True,
desc='Shifts the distribution of intensities per ' 'volume to give non-negative values',
desc='Shifts the distribution of intensities per volume to give non-negative values',
)
out_report = File(
'patch2self_report.svg', usedefault=True, desc='filename for the visual report'
Expand Down
10 changes: 5 additions & 5 deletions qsiprep/interfaces/eddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ def boilerplate_from_eddy_config(eddy_config, fieldmap_type, pepolar_method):

# did you sep_offs_mov?
if isdefined(ext_eddy.inputs.dont_sep_offs_move) and ext_eddy.inputs.dont_sep_offs_move:
desc.append('No attempt was made to separate field offset from ' 'subject movement.')
desc.append('No attempt was made to separate field offset from subject movement.')
else:
desc.append('Field offset was attempted to be separated from ' 'subject movement.')
desc.append('Field offset was attempted to be separated from subject movement.')

# did you peas?
if isdefined(ext_eddy.inputs.dont_peas) and ext_eddy.inputs.dont_peas:
Expand Down Expand Up @@ -355,7 +355,7 @@ def boilerplate_from_eddy_config(eddy_config, fieldmap_type, pepolar_method):
if mb_off != 0:
offs_txt = {-1: 'bottom', 1: 'top'}
offs_txt = f'and slices removed from the {offs_txt} of the volume were'
desc.append('A multi-band acceleration factor of %d ' '%s assumed.' % (mbf, offs_txt))
desc.append(f'A multi-band acceleration factor of {mbf} {offs_txt} assumed.')

# The threshold for outliers
std_threshold = (
Expand Down Expand Up @@ -420,7 +420,7 @@ def boilerplate_from_eddy_config(eddy_config, fieldmap_type, pepolar_method):
lsr_ref = ' [@fsllsr]' if ext_eddy.inputs.method == 'lsr' else ''
if doing_2stage:
desc.append(
'Interpolation after head motion and initial susceptibility ' 'distortion correction'
'Interpolation after head motion and initial susceptibility distortion correction'
)
else:
desc.append('Final interpolation')
Expand Down Expand Up @@ -450,7 +450,7 @@ def topup_boilerplate(fieldmap_type, pepolar_method):

desc.append('was used to estimate a susceptibility-induced off-resonance field based on')
if fieldmap_type == 'epi':
desc.append('b=0 reference images with reversed ' 'phase encoding directions.')
desc.append('b=0 reference images with reversed phase encoding directions.')
else:
desc.append(
'b=0 images extracted from multiple DWI series '
Expand Down
7 changes: 3 additions & 4 deletions qsiprep/interfaces/gradients.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class SliceQCInputSpec(BaseInterfaceInputSpec):
min_slice_size_percentile = traits.CFloat(
10.0,
usedefault=True,
desc='slices bigger than ' 'this percentile are candidates for imputation.',
desc='slices bigger than this percentile are candidates for imputation.',
)


Expand Down Expand Up @@ -351,7 +351,7 @@ class ComposeTransformsInputSpec(ApplyTransformsInputSpec):
b0_to_intramodal_template_transforms = InputMultiObject(
File(exists=True),
mandtory=False,
desc='list of transforms to register the b=0 to ' 'the intramodal template.',
desc='list of transforms to register the b=0 to the intramodal template.',
)
intramodal_template_to_t1_affine = File(
exists=True, desc='affine from the intramodal template to t1'
Expand Down Expand Up @@ -565,8 +565,7 @@ class GradientRotationInputSpec(BaseInterfaceInputSpec):
)
bvec_files = InputMultiObject(
File(exists=True),
desc='list of split bvec files, must correspond to a '
'non-oblique image/reference frame.',
desc='list of split bvec files, must correspond to a non-oblique image/reference frame.',
mandatory=True,
)
bval_files = InputMultiObject(
Expand Down
3 changes: 1 addition & 2 deletions qsiprep/interfaces/tortoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,7 @@ def generate_drbuddi_boilerplate(fieldmap_type, t2w_sdc, with_topup=False):
# Describe what's going on
if fieldmap_type == 'epi':
desc.append(
'DRBUDDI used b=0 reference images with reversed '
'phase encoding directions to estimate'
'DRBUDDI used b=0 reference images with reversed phase encoding directions to estimate'
)
else:
desc.append(
Expand Down
2 changes: 1 addition & 1 deletion qsiprep/tests/run_local_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def run_command(command, env=None):

if process.returncode != 0:
raise RuntimeError(
f'Non zero return code: {process.returncode}\n' f'{command}\n\n{process.stdout.read()}'
f'Non zero return code: {process.returncode}\n{command}\n\n{process.stdout.read()}'
)


Expand Down
2 changes: 1 addition & 1 deletion qsiprep/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def download_test_data(dset, data_dir=None):
return

if dset not in URLS:
raise ValueError(f"dset ({dset}) must be one of: {', '.join(URLS.keys())}")
raise ValueError(f'dset ({dset}) must be one of: {", ".join(URLS.keys())}')

if not data_dir:
data_dir = os.path.join(os.path.dirname(get_test_data_path()), 'test_data')
Expand Down
3 changes: 2 additions & 1 deletion qsiprep/workflows/dwi/distortion_group_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def init_distortion_group_merge_wf(
'merged_bval',
'merged_bvec',
'merged_qc',
'merged_cnr_map' 'dwi_mask_t1',
'merged_cnr_map',
'dwi_mask_t1',
'cnr_map_t1',
'merged_bval',
'bvecs_t1',
Expand Down
3 changes: 1 addition & 2 deletions qsiprep/workflows/dwi/hmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ def init_dwi_hmc_wf(
# If we're just aligning based on the b=0 images, compute the b=0 tsnr as the cnr
if hmc_model.lower() == 'none':
workflow.__postdesc__ = (
'Each b>0 image was transformed based on the registration '
' of the nearest b=0 image. '
'Each b>0 image was transformed based on the registration of the nearest b=0 image. '
)

concat_b0s = pe.Node(afni.TCat(outputtype='NIFTI_GZ'), name='concat_b0s')
Expand Down
3 changes: 1 addition & 2 deletions qsiprep/workflows/dwi/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,7 @@ def gen_denoising_boilerplate():
no_b0_harmonization = config.workflow.no_b0_harmonization
b0_threshold = config.workflow.b0_threshold
desc = [
f'Any images with a b-value less than {b0_threshold} s/mm^2 were treated as a '
'*b*=0 image.'
f'Any images with a b-value less than {b0_threshold} s/mm^2 were treated as a *b*=0 image.'
]
harmonize_b0s = not no_b0_harmonization
last_step = ''
Expand Down

0 comments on commit 4799ffc

Please sign in to comment.