Skip to content

Commit 03e848c

Browse files
committed
STY: Ruff 0.9.2
1 parent ca3230b commit 03e848c

File tree

10 files changed

+58
-53
lines changed

10 files changed

+58
-53
lines changed

nibabies/__about__.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

nibabies/__init__.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1-
from .__about__ import __version__ # noqa: F401
1+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
2+
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
#
4+
# Copyright The NiPreps Developers <[email protected]>
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
# We support and encourage derived works from this project, please read
19+
# about our expectations at
20+
#
21+
# https://www.nipreps.org/community/licensing/
22+
#
23+
"""Top-module metadata."""
24+
25+
try:
26+
from ._version import __version__
27+
except ImportError:
28+
__version__ = '0+unknown'

nibabies/cli/parser.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class DeprecatedAction(Action):
3232
def __call__(self, parser, namespace, values, option_string=None):
3333
new_opt, rem_vers = deprecations.get(self.dest, (None, None))
3434
msg = (
35-
f"{self.option_strings} has been deprecated and will be removed in "
36-
f"{rem_vers or 'a later version'}."
35+
f'{self.option_strings} has been deprecated and will be removed in '
36+
f'{rem_vers or "a later version"}.'
3737
)
3838
if new_opt:
3939
msg += f' Please use `{new_opt}` instead.'
@@ -140,7 +140,7 @@ def _slice_time_ref(value, parser):
140140
value = float(value)
141141
except ValueError as e:
142142
raise parser.error(
143-
"Slice time reference must be number, 'start', or 'middle'. " f'Received {value}.'
143+
f"Slice time reference must be number, 'start', or 'middle'. Received {value}."
144144
) from e
145145
if not 0 <= value <= 1:
146146
raise parser.error(f'Slice time reference must be in range 0-1. Received {value}.')
@@ -182,7 +182,7 @@ def _str_none(val):
182182
'output_dir',
183183
action='store',
184184
type=Path,
185-
help='the output path for the outcomes of preprocessing and visual ' 'reports',
185+
help='the output path for the outcomes of preprocessing and visual reports',
186186
)
187187
parser.add_argument(
188188
'analysis_level',
@@ -297,7 +297,7 @@ def _str_none(val):
297297
g_perfm.add_argument(
298298
'--low-mem',
299299
action='store_true',
300-
help='attempt to reduce memory usage (will increase disk usage ' 'in working directory)',
300+
help='attempt to reduce memory usage (will increase disk usage in working directory)',
301301
)
302302
g_perfm.add_argument(
303303
'--use-plugin',
@@ -497,8 +497,7 @@ def _str_none(val):
497497
action='store',
498498
default=0.5,
499499
type=float,
500-
help='Threshold for flagging a frame as an outlier on the basis of framewise '
501-
'displacement',
500+
help='Threshold for flagging a frame as an outlier on the basis of framewise displacement',
502501
)
503502
g_confounds.add_argument(
504503
'--dvars-spike-threshold',
@@ -507,7 +506,7 @@ def _str_none(val):
507506
action='store',
508507
default=1.5,
509508
type=float,
510-
help='Threshold for flagging a frame as an outlier on the basis of standardised ' 'DVARS',
509+
help='Threshold for flagging a frame as an outlier on the basis of standardised DVARS',
511510
)
512511

513512
# ANTs options
@@ -657,7 +656,7 @@ def _str_none(val):
657656
'--stop-on-first-crash',
658657
action='store_true',
659658
default=False,
660-
help='Force stopping on first crash, even if a work directory' ' was specified.',
659+
help='Force stopping on first crash, even if a work directory was specified.',
661660
)
662661
g_other.add_argument(
663662
'--notrack',
@@ -875,8 +874,7 @@ def parse_args(args=None, namespace=None):
875874
from ..utils.bids import validate_input_dir
876875

877876
build_log.info(
878-
'Making sure the input data is BIDS compliant (warnings can be ignored in most '
879-
'cases).'
877+
'Making sure the input data is BIDS compliant (warnings can be ignored in most cases).'
880878
)
881879
validate_input_dir(config.environment.exec_env, opts.bids_dir, opts.participant_label)
882880

@@ -896,8 +894,8 @@ def parse_args(args=None, namespace=None):
896894
missing_subjects = participant_label - set(all_subjects)
897895
if missing_subjects:
898896
parser.error(
899-
"One or more participant labels were not found in the BIDS directory: "
900-
f"{', '.join(missing_subjects)}."
897+
'One or more participant labels were not found in the BIDS directory: '
898+
f'{", ".join(missing_subjects)}.'
901899
)
902900

903901
config.execution.participant_label = sorted(participant_label)

nibabies/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ class execution(_Config):
413413
"""Force usage of this anatomical scan as the structural reference."""
414414
reports_only = False
415415
"""Only build the reports, based on the reportlets found in a cached working directory."""
416-
run_uuid = f"{strftime('%Y%m%d-%H%M%S')}_{uuid4()}"
416+
run_uuid = f'{strftime("%Y%m%d-%H%M%S")}_{uuid4()}'
417417
"""Unique identifier of this particular run."""
418418
segmentation_atlases_dir = None
419419
"""Directory with atlases to use for JLF segmentations"""
@@ -622,7 +622,7 @@ class workflow(_Config):
622622
class loggers:
623623
"""Keep loggers easily accessible (see :py:func:`init`)."""
624624

625-
_fmt = '%(asctime)s,%(msecs)d %(name)-2s ' '%(levelname)-2s:\n\t %(message)s'
625+
_fmt = '%(asctime)s,%(msecs)d %(name)-2s %(levelname)-2s:\n\t %(message)s'
626626
_datefmt = '%y%m%d-%H:%M:%S'
627627

628628
default = logging.getLogger()

nibabies/interfaces/metric.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ class MetricDilateInputSpec(CommandLineInputSpec):
7878
argstr='-exponent %f ',
7979
position=9,
8080
default=6.0,
81-
desc='exponent n to use in (area / (distance ^ n)) as the '
82-
'weighting function (default 6)',
81+
desc='exponent n to use in (area / (distance ^ n)) as the weighting function (default 6)',
8382
)
8483

8584
corrected_areas = File(
@@ -246,16 +245,14 @@ class MetricResample(WBCommand):
246245
def _format_arg(self, opt, spec, val):
247246
if opt in ['current_area', 'new_area']:
248247
if not self.inputs.area_surfs and not self.inputs.area_metrics:
249-
raise ValueError(
250-
f'{opt} was set but neither area_surfs or' ' area_metrics were set'
251-
)
248+
raise ValueError(f'{opt} was set but neither area_surfs or area_metrics were set')
252249
if opt == 'method':
253250
if (
254251
val == 'ADAP_BARY_AREA'
255252
and not self.inputs.area_surfs
256253
and not self.inputs.area_metrics
257254
):
258-
raise ValueError('Exactly one of area_surfs or area_metrics' ' must be specified')
255+
raise ValueError('Exactly one of area_surfs or area_metrics must be specified')
259256
if opt == 'valid_roi_out' and val:
260257
# generate a filename and add it to argstr
261258
roi_out = self._gen_filename(self.inputs.in_file, suffix='_roi')

nibabies/utils/bids.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ def write_bidsignore(deriv_dir):
4141

4242

4343
def write_derivative_description(bids_dir, deriv_dir, dataset_links=None):
44-
from ..__about__ import DOWNLOAD_URL, __packagename__, __version__
44+
from nibabies import __version__
45+
46+
DOWNLOAD_URL = f'https://github.com/nipreps/nibabies/archive/{__version__}.tar.gz'
4547

4648
bids_dir = Path(bids_dir)
4749
deriv_dir = Path(deriv_dir)
@@ -51,7 +53,7 @@ def write_derivative_description(bids_dir, deriv_dir, dataset_links=None):
5153
'DatasetType': 'derivative',
5254
'GeneratedBy': [
5355
{
54-
'Name': __packagename__,
56+
'Name': 'NiBabies',
5557
'Version': __version__,
5658
'CodeURL': DOWNLOAD_URL,
5759
}
@@ -63,7 +65,7 @@ def write_derivative_description(bids_dir, deriv_dir, dataset_links=None):
6365
if 'NIBABIES_DOCKER_TAG' in os.environ:
6466
desc['GeneratedBy'][0]['Container'] = {
6567
'Type': 'docker',
66-
'Tag': f"nipreps/nibabies:{os.environ['NIBABIES_DOCKER_TAG']}",
68+
'Tag': f'nipreps/nibabies:{os.environ["NIBABIES_DOCKER_TAG"]}',
6769
}
6870
if 'NIBABIES_SINGULARITY_URL' in os.environ:
6971
desc['GeneratedBy'][0]['Container'] = {

nibabies/workflows/anatomical/fit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ def init_infant_anat_fit_wf(
170170

171171
# Stage 2 - Anatomicals
172172
t1w_buffer = pe.Node(
173-
niu.IdentityInterface(fields=['t1w_preproc', 't1w_mask' 't1w_brain']),
173+
niu.IdentityInterface(fields=['t1w_preproc', 't1w_maskt1w_brain']),
174174
name='t1w_buffer',
175175
)
176176
t2w_buffer = pe.Node(
177-
niu.IdentityInterface(fields=['t2w_preproc', 't2w_mask' 't2w_brain', 't2w_probmap']),
177+
niu.IdentityInterface(fields=['t2w_preproc', 't2w_maskt2w_brain', 't2w_probmap']),
178178
name='t2w_buffer',
179179
)
180180
anat_buffer = pe.Node(

nibabies/workflows/anatomical/segmentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def _to_dtype(in_file, dtype='uint8'):
288288
import numpy as np
289289

290290
img = nb.load(in_file)
291-
out_file = Path(f"labels{''.join(Path(in_file).suffixes)}").absolute()
291+
out_file = Path(f'labels{"".join(Path(in_file).suffixes)}').absolute()
292292

293293
new_data = np.asanyarray(img.get_fdata(), dtype=dtype)
294294
img.set_data_dtype(dtype)

nibabies/workflows/base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def init_nibabies_wf(subworkflows_list: list[SubjectSession]):
118118
freesurfer_home=os.getenv('FREESURFER_HOME'),
119119
spaces=execution_spaces.get_fs_spaces(),
120120
),
121-
name=f"fsdir_run_{config.execution.run_uuid.replace('-', '_')}",
121+
name=f'fsdir_run_{config.execution.run_uuid.replace("-", "_")}',
122122
run_without_submitting=True,
123123
)
124124
if config.execution.fs_subjects_dir is not None:
@@ -291,9 +291,9 @@ def init_single_subject_wf(
291291

292292
if subject_data['roi']:
293293
warnings.warn(
294-
f"Lesion mask {subject_data['roi']} found. "
295-
"Future versions of NiBabies will use alternative conventions. "
296-
"Please refer to the documentation before upgrading.",
294+
f'Lesion mask {subject_data["roi"]} found. '
295+
'Future versions of NiBabies will use alternative conventions. '
296+
'Please refer to the documentation before upgrading.',
297297
FutureWarning,
298298
stacklevel=1,
299299
)
@@ -939,7 +939,7 @@ def map_fieldmap_estimation(
939939
for bold_file, estimator_key in all_estimators.items():
940940
if len(estimator_key) > 1:
941941
config.loggers.workflow.warning(
942-
f"Several fieldmaps <{', '.join(estimator_key)}> are "
942+
f'Several fieldmaps <{", ".join(estimator_key)}> are '
943943
f"'IntendedFor' <{bold_file}>, using {estimator_key[0]}"
944944
)
945945
estimator_key[1:] = []

nibabies/workflows/bold/stc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def init_bold_stc_wf(metadata, name='bold_stc_wf'):
115115
slice_timing_correction = pe.Node(
116116
TShift(
117117
outputtype='NIFTI_GZ',
118-
tr=f"{metadata['RepetitionTime']}s",
118+
tr=f'{metadata["RepetitionTime"]}s',
119119
slice_timing=metadata['SliceTiming'],
120120
slice_encoding_direction=metadata.get('SliceEncodingDirection', 'k'),
121121
tzero=tzero,

0 commit comments

Comments
 (0)