Skip to content

Commit

Permalink
Run ruff format.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Oct 31, 2024
1 parent 6fdd6ad commit dba9ff7
Show file tree
Hide file tree
Showing 29 changed files with 40 additions and 20 deletions.
1 change: 1 addition & 0 deletions .circleci/get_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""Download test data."""

import sys

from aslprep.tests.utils import download_test_data
Expand Down
1 change: 1 addition & 0 deletions aslprep/__about__.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
1 change: 1 addition & 0 deletions aslprep/cli/aggregate_qc.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 3 additions & 2 deletions aslprep/cli/parser.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.'
),
)

Expand Down Expand Up @@ -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).'
),
)

Expand Down
1 change: 1 addition & 0 deletions aslprep/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# https://www.nipreps.org/community/licensing/
#
"""ASL preprocessing workflow."""

from aslprep import config


Expand Down
1 change: 1 addition & 0 deletions aslprep/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
:py:class:`~bids.layout.BIDSLayout`, etc.)
"""

import os
from multiprocessing import set_start_method

Expand Down
1 change: 1 addition & 0 deletions aslprep/interfaces/__init__.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion aslprep/interfaces/cbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 3 additions & 2 deletions aslprep/interfaces/confounds.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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',
Expand Down
9 changes: 5 additions & 4 deletions aslprep/interfaces/parcellation.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions aslprep/interfaces/reports.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 3 additions & 7 deletions aslprep/interfaces/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions aslprep/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions aslprep/tests/run_local_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""Run tests locally by calling Docker."""

import argparse
import os
import subprocess
Expand Down
1 change: 1 addition & 0 deletions aslprep/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions aslprep/utils/asl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'."
)

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions aslprep/utils/bids.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions aslprep/utils/misc.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions aslprep/utils/sentry.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions aslprep/workflows/asl/__init__.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
1 change: 1 addition & 0 deletions aslprep/workflows/asl/cbf.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions aslprep/workflows/asl/confounds.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions aslprep/workflows/asl/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# https://www.nipreps.org/community/licensing/
#
"""Fit workflows for ASLPrep."""

import os
import typing as ty

Expand Down
1 change: 1 addition & 0 deletions aslprep/workflows/asl/hmc.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions aslprep/workflows/asl/plotting.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions aslprep/workflows/asl/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions aslprep/workflows/asl/resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
TODO: Remove once fMRIPrep releases 23.2.0.
"""

from __future__ import annotations

import typing as ty
Expand Down
1 change: 1 addition & 0 deletions aslprep/workflows/base.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
)

Expand Down

0 comments on commit dba9ff7

Please sign in to comment.