From dba9ff76236d7617508de805af8fe34afcabc871 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Thu, 31 Oct 2024 19:24:20 -0400 Subject: [PATCH] Run ruff format. --- .circleci/get_data.py | 1 + aslprep/__about__.py | 1 + aslprep/cli/aggregate_qc.py | 1 + aslprep/cli/parser.py | 5 +++-- aslprep/cli/run.py | 1 + aslprep/config.py | 1 + aslprep/interfaces/__init__.py | 1 + aslprep/interfaces/cbf.py | 2 +- aslprep/interfaces/confounds.py | 5 +++-- aslprep/interfaces/parcellation.py | 9 +++++---- aslprep/interfaces/reports.py | 1 + aslprep/interfaces/utility.py | 10 +++------- aslprep/tests/conftest.py | 1 + aslprep/tests/run_local_tests.py | 1 + aslprep/tests/tests.py | 1 + aslprep/utils/asl.py | 4 ++-- aslprep/utils/bids.py | 1 + aslprep/utils/misc.py | 1 + aslprep/utils/sentry.py | 1 + aslprep/workflows/asl/__init__.py | 1 + aslprep/workflows/asl/cbf.py | 1 + aslprep/workflows/asl/confounds.py | 1 + aslprep/workflows/asl/fit.py | 1 + aslprep/workflows/asl/hmc.py | 1 + aslprep/workflows/asl/plotting.py | 1 + aslprep/workflows/asl/reference.py | 1 + aslprep/workflows/asl/resampling.py | 1 + aslprep/workflows/base.py | 1 + docs/conf.py | 3 +-- 29 files changed, 40 insertions(+), 20 deletions(-) diff --git a/.circleci/get_data.py b/.circleci/get_data.py index ca7ca09c3..717f1a4dc 100755 --- a/.circleci/get_data.py +++ b/.circleci/get_data.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 """Download test data.""" + import sys from aslprep.tests.utils import download_test_data diff --git a/aslprep/__about__.py b/aslprep/__about__.py index 7b113a7c2..6ca1d0066 100644 --- a/aslprep/__about__.py +++ b/aslprep/__about__.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Base module variables.""" + try: from aslprep._version import __version__ except ImportError: diff --git a/aslprep/cli/aggregate_qc.py b/aslprep/cli/aggregate_qc.py index 95af12242..e2e730460 100644 --- a/aslprep/cli/aggregate_qc.py +++ b/aslprep/cli/aggregate_qc.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Aggregate QC measures across all subjects in dataset.""" + import os from pathlib import Path diff --git a/aslprep/cli/parser.py b/aslprep/cli/parser.py index f5977bb58..29e1ead82 100644 --- a/aslprep/cli/parser.py +++ b/aslprep/cli/parser.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Parser.""" + import sys from aslprep import config @@ -252,7 +253,7 @@ def _bids_filter(value, parser): default=False, help=( "only generate reports, don't run workflows. This will only rerun report " - "aggregation, not reportlet generation for specific nodes." + 'aggregation, not reportlet generation for specific nodes.' ), ) @@ -473,7 +474,7 @@ def _bids_filter(value, parser): help=( "determiner for T1-weighted skull stripping ('force' ensures skull " "stripping, 'skip' ignores skull stripping, and 'auto' applies brain extraction " - "based on the outcome of a heuristic to check whether the brain is already masked)." + 'based on the outcome of a heuristic to check whether the brain is already masked).' ), ) diff --git a/aslprep/cli/run.py b/aslprep/cli/run.py index 6ab88bfcf..b29075a22 100755 --- a/aslprep/cli/run.py +++ b/aslprep/cli/run.py @@ -22,6 +22,7 @@ # https://www.nipreps.org/community/licensing/ # """ASL preprocessing workflow.""" + from aslprep import config diff --git a/aslprep/config.py b/aslprep/config.py index 3d71cf4e1..53f65b262 100644 --- a/aslprep/config.py +++ b/aslprep/config.py @@ -87,6 +87,7 @@ :py:class:`~bids.layout.BIDSLayout`, etc.) """ + import os from multiprocessing import set_start_method diff --git a/aslprep/interfaces/__init__.py b/aslprep/interfaces/__init__.py index a17bca907..e848f5338 100644 --- a/aslprep/interfaces/__init__.py +++ b/aslprep/interfaces/__init__.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Nipype interfaces for aslprep.""" + from aslprep.interfaces import ( ants, bids, diff --git a/aslprep/interfaces/cbf.py b/aslprep/interfaces/cbf.py index ab01c7e17..e5b13b5d9 100644 --- a/aslprep/interfaces/cbf.py +++ b/aslprep/interfaces/cbf.py @@ -843,7 +843,7 @@ class _BASILCBFInputSpec(FSLCommandInputSpec): ) alpha = traits.Float( desc=( - "Inversion efficiency - [default: 0.98 (pASL); 0.85 (cASL)]. " + 'Inversion efficiency - [default: 0.98 (pASL); 0.85 (cASL)]. ' "This is equivalent to the BIDS metadata field 'LabelingEfficiency'." ), argstr='--alpha %.2f', diff --git a/aslprep/interfaces/confounds.py b/aslprep/interfaces/confounds.py index 7851fed56..97421bfaf 100644 --- a/aslprep/interfaces/confounds.py +++ b/aslprep/interfaces/confounds.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Interfaces for calculating and collecting confounds.""" + import json import os @@ -337,8 +338,8 @@ def _run_interface(self, runtime): 'rmsd': { 'LongName': 'Mean Relative Root Mean Squared', 'Description': ( - "Average relative root mean squared calculated from motion parameters, " - "after removal of dummy volumes and high-motion outliers. " + 'Average relative root mean squared calculated from motion parameters, ' + 'after removal of dummy volumes and high-motion outliers. ' "Relative in this case means 'relative to the previous scan'." ), 'Units': 'arbitrary', diff --git a/aslprep/interfaces/parcellation.py b/aslprep/interfaces/parcellation.py index 5fcbe9ec4..000c81f07 100644 --- a/aslprep/interfaces/parcellation.py +++ b/aslprep/interfaces/parcellation.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Handling functional connectvity.""" + import nibabel as nb import numpy as np import pandas as pd @@ -117,16 +118,16 @@ def _run_interface(self, runtime): if n_poor_parcels: LOGGER.warning( - f"{n_poor_parcels}/{n_nodes} of parcels have <50% coverage. " + f'{n_poor_parcels}/{n_nodes} of parcels have <50% coverage. ' "These parcels' time series will be replaced with zeros." ) if n_partial_parcels: LOGGER.warning( - f"{n_partial_parcels}/{n_nodes} of parcels have at least one uncovered " - "voxel, but have enough good voxels to be usable. " + f'{n_partial_parcels}/{n_nodes} of parcels have at least one uncovered ' + 'voxel, but have enough good voxels to be usable. ' "The bad voxels will be ignored and the parcels' time series will be " - "calculated from the remaining voxels." + 'calculated from the remaining voxels.' ) masker = NiftiLabelsMasker( diff --git a/aslprep/interfaces/reports.py b/aslprep/interfaces/reports.py index 2d79a05b2..609d39e36 100644 --- a/aslprep/interfaces/reports.py +++ b/aslprep/interfaces/reports.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Interfaces to generate reportlets.""" + import os import re import time diff --git a/aslprep/interfaces/utility.py b/aslprep/interfaces/utility.py index 96566265e..118dfd3aa 100644 --- a/aslprep/interfaces/utility.py +++ b/aslprep/interfaces/utility.py @@ -44,7 +44,7 @@ def _run_interface(self, runtime): if asl_img.shape[3] != aslcontext.shape[0]: raise ValueError( f"Number of volumes in {self.inputs.asl_file} ({asl_img.shape[3]}) doesn't equal " - f"number of rows in {self.inputs.aslcontext} ({aslcontext.shape[0]})." + f'number of rows in {self.inputs.aslcontext} ({aslcontext.shape[0]}).' ) if self.inputs.processing_target == 'control': @@ -227,13 +227,9 @@ def _run_interface(self, runtime): out_mat_files = [None] * aslcontext.shape[0] if len(self.inputs.volume_types) != len(self.inputs.mat_files): - raise ValueError( - 'Number of volume types and number of mat files must be the same.' - ) + raise ValueError('Number of volume types and number of mat files must be the same.') if len(self.inputs.volume_types) != len(self.inputs.par_files): - raise ValueError( - 'Number of volume types and number of par files must be the same.' - ) + raise ValueError('Number of volume types and number of par files must be the same.') for i_type, volume_type in enumerate(self.inputs.volume_types): type_mat_files = self.inputs.mat_files[i_type] diff --git a/aslprep/tests/conftest.py b/aslprep/tests/conftest.py index 562e46116..5f9c6cd6b 100644 --- a/aslprep/tests/conftest.py +++ b/aslprep/tests/conftest.py @@ -9,6 +9,7 @@ def pytest_addoption(parser): """Collect pytest parameters for running tests.""" import tempfile + parser.addoption('--working_dir', action='store', default=tempfile.mkdtemp()) parser.addoption('--data_dir', action='store') parser.addoption('--output_dir', action='store') diff --git a/aslprep/tests/run_local_tests.py b/aslprep/tests/run_local_tests.py index 73e44db94..5df27c389 100755 --- a/aslprep/tests/run_local_tests.py +++ b/aslprep/tests/run_local_tests.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 """Run tests locally by calling Docker.""" + import argparse import os import subprocess diff --git a/aslprep/tests/tests.py b/aslprep/tests/tests.py index e7bd26564..0aba7b692 100644 --- a/aslprep/tests/tests.py +++ b/aslprep/tests/tests.py @@ -21,6 +21,7 @@ # https://www.nipreps.org/community/licensing/ # """Utilities and mocks for testing and documentation building.""" + import os import shutil from contextlib import contextmanager diff --git a/aslprep/utils/asl.py b/aslprep/utils/asl.py index ef1230b6a..f4dbd78b3 100644 --- a/aslprep/utils/asl.py +++ b/aslprep/utils/asl.py @@ -17,7 +17,7 @@ def pcasl_or_pasl(metadata): is_casl = False else: raise ValueError( - "Labeling type cannot be classified as (P)CASL or PASL based on " + 'Labeling type cannot be classified as (P)CASL or PASL based on ' f"ArterialSpinLabelingType: '{aslt}'." ) @@ -185,7 +185,7 @@ def reduce_metadata_lists(metadata, n_volumes, keep_idx): if isinstance(value, list): if len(value) != n_volumes: raise ValueError( - f"Number of elements in list-type metadata field {field} ({len(value)}) " + f'Number of elements in list-type metadata field {field} ({len(value)}) ' f"doesn't equal the number of volumes in the ASL file ({n_volumes})." ) # Reduce to only the selected volumes diff --git a/aslprep/utils/bids.py b/aslprep/utils/bids.py index c06462ed5..8e36b8cdf 100644 --- a/aslprep/utils/bids.py +++ b/aslprep/utils/bids.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Utilities to handle BIDS inputs.""" + from __future__ import annotations import json diff --git a/aslprep/utils/misc.py b/aslprep/utils/misc.py index a49d6997a..f49b2d648 100644 --- a/aslprep/utils/misc.py +++ b/aslprep/utils/misc.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Miscellaneous utilities.""" + from __future__ import annotations import os diff --git a/aslprep/utils/sentry.py b/aslprep/utils/sentry.py index 5f11245a5..453e7b5d2 100644 --- a/aslprep/utils/sentry.py +++ b/aslprep/utils/sentry.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Stripped out routines for Sentry.""" + import os import re diff --git a/aslprep/workflows/asl/__init__.py b/aslprep/workflows/asl/__init__.py index 363374069..4b393b489 100644 --- a/aslprep/workflows/asl/__init__.py +++ b/aslprep/workflows/asl/__init__.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Workflows for the ASL processing portions of ASLPrep.""" + from aslprep.workflows.asl import ( apply, base, diff --git a/aslprep/workflows/asl/cbf.py b/aslprep/workflows/asl/cbf.py index 3ff7bf36e..defa5c0bd 100644 --- a/aslprep/workflows/asl/cbf.py +++ b/aslprep/workflows/asl/cbf.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Workflows for calculating CBF.""" + import numpy as np from nipype.interfaces import utility as niu from nipype.interfaces.fsl import Info diff --git a/aslprep/workflows/asl/confounds.py b/aslprep/workflows/asl/confounds.py index 9f3d0a788..500b44ae7 100644 --- a/aslprep/workflows/asl/confounds.py +++ b/aslprep/workflows/asl/confounds.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Workflows for calculating confounds for ASL data.""" + from fmriprep.workflows.bold.confounds import _carpet_parcellation from nipype.algorithms import confounds as nac from nipype.interfaces import utility as niu diff --git a/aslprep/workflows/asl/fit.py b/aslprep/workflows/asl/fit.py index 71af0d703..6e8267bc2 100644 --- a/aslprep/workflows/asl/fit.py +++ b/aslprep/workflows/asl/fit.py @@ -21,6 +21,7 @@ # https://www.nipreps.org/community/licensing/ # """Fit workflows for ASLPrep.""" + import os import typing as ty diff --git a/aslprep/workflows/asl/hmc.py b/aslprep/workflows/asl/hmc.py index 1fc1415e7..f7615190f 100644 --- a/aslprep/workflows/asl/hmc.py +++ b/aslprep/workflows/asl/hmc.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Workflows for estimating and correcting head motion in ASL images.""" + from nipype.interfaces import fsl from nipype.interfaces import utility as niu from nipype.pipeline import engine as pe diff --git a/aslprep/workflows/asl/plotting.py b/aslprep/workflows/asl/plotting.py index b1360c4ec..5c716e54d 100644 --- a/aslprep/workflows/asl/plotting.py +++ b/aslprep/workflows/asl/plotting.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Workflows for plotting ASLPrep derivatives.""" + from nipype.interfaces import utility as niu from nipype.pipeline import engine as pe from niworkflows.engine.workflows import LiterateWorkflow as Workflow diff --git a/aslprep/workflows/asl/reference.py b/aslprep/workflows/asl/reference.py index b76281d82..c3a0169fb 100644 --- a/aslprep/workflows/asl/reference.py +++ b/aslprep/workflows/asl/reference.py @@ -21,6 +21,7 @@ # https://www.nipreps.org/community/licensing/ # """Workflows for generating reference images.""" + from nipype.interfaces import utility as niu from nipype.pipeline import engine as pe from niworkflows.engine.workflows import LiterateWorkflow as Workflow diff --git a/aslprep/workflows/asl/resampling.py b/aslprep/workflows/asl/resampling.py index 953c5f6a8..c8e3955d5 100644 --- a/aslprep/workflows/asl/resampling.py +++ b/aslprep/workflows/asl/resampling.py @@ -24,6 +24,7 @@ TODO: Remove once fMRIPrep releases 23.2.0. """ + from __future__ import annotations import typing as ty diff --git a/aslprep/workflows/base.py b/aslprep/workflows/base.py index 953f2a7bf..477c70eb3 100644 --- a/aslprep/workflows/base.py +++ b/aslprep/workflows/base.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """ASLprep base processing workflows.""" + import os import sys import warnings diff --git a/docs/conf.py b/docs/conf.py index 65c05243b..a3acda3f1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -295,8 +295,7 @@ linkcode_resolve = make_linkcode_resolve( 'aslprep', ( - 'https://github.com/pennlinc/aslprep/blob/' - '{revision}/{package}/{path}#L{lineno}' # noqa: FS003 + 'https://github.com/pennlinc/aslprep/blob/' '{revision}/{package}/{path}#L{lineno}' # noqa: FS003 ), )