Skip to content

Commit

Permalink
🚨 Rerun ruff format after upgrading to 0.3.2 (#2083)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChildMindInstituteCNL committed Mar 25, 2024
1 parent 88eede1 commit e75aff6
Show file tree
Hide file tree
Showing 73 changed files with 156 additions and 122 deletions.
1 change: 1 addition & 0 deletions .github/scripts/get_package_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Usage: python get_package_id.py $OWNER $IMAGE_TAG $VERSION_TAG
"""

import os
import sys

Expand Down
1 change: 1 addition & 0 deletions .github/scripts/get_pr_base_shas.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Get base SHAs for open PRs."""

import os

from github import Github
Expand Down
1 change: 1 addition & 0 deletions CPAC/_entrypoints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Entrypoints for C-PAC containers."""

__all__ = []
31 changes: 16 additions & 15 deletions CPAC/_entrypoints/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Run C-PAC in a container."""

import argparse
import datetime
import os
Expand Down Expand Up @@ -592,9 +593,9 @@ def run_main():
c["awsCredentialsFile"] = resolve_aws_credential(args.aws_input_creds)

if args.aws_output_creds:
c["pipeline_setup"]["Amazon-AWS"][
"aws_output_bucket_credentials"
] = resolve_aws_credential(args.aws_output_creds)
c["pipeline_setup"]["Amazon-AWS"]["aws_output_bucket_credentials"] = (
resolve_aws_credential(args.aws_output_creds)
)

c["pipeline_setup"]["output_directory"]["path"] = os.path.join(
output_dir, "output"
Expand All @@ -610,9 +611,9 @@ def run_main():
)

if args.mem_gb:
c["pipeline_setup"]["system_config"][
"maximum_memory_per_participant"
] = float(args.mem_gb)
c["pipeline_setup"]["system_config"]["maximum_memory_per_participant"] = (
float(args.mem_gb)
)
elif args.mem_mb:
c["pipeline_setup"]["system_config"]["maximum_memory_per_participant"] = (
float(args.mem_mb) / 1024.0
Expand Down Expand Up @@ -660,9 +661,9 @@ def run_main():
// c["pipeline_setup"]["system_config"]["num_participants_at_once"]
)
if c["pipeline_setup"]["system_config"]["max_cores_per_participant"] == 0:
c["pipeline_setup"]["system_config"][
"max_cores_per_participant"
] = args.n_cpus
c["pipeline_setup"]["system_config"]["max_cores_per_participant"] = (
args.n_cpus
)
c["pipeline_setup"]["system_config"]["num_participants_at_once"] = 1

if int(args.num_ants_threads) == 0:
Expand Down Expand Up @@ -690,13 +691,13 @@ def run_main():
)

if args.runtime_usage is not None:
c["pipeline_setup"]["system_config"]["observed_usage"][
"callback_log"
] = args.runtime_usage
c["pipeline_setup"]["system_config"]["observed_usage"]["callback_log"] = (
args.runtime_usage
)
if args.runtime_buffer is not None:
c["pipeline_setup"]["system_config"]["observed_usage"][
"buffer"
] = args.runtime_buffer
c["pipeline_setup"]["system_config"]["observed_usage"]["buffer"] = (
args.runtime_buffer
)

if args.save_working_dir is not False:
c["pipeline_setup"]["working_directory"]["remove_working_dir"] = False
Expand Down
5 changes: 2 additions & 3 deletions CPAC/anat_preproc/tests/test_anat_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,8 @@ def test_anat_reorient(self):
else:
assert int(anat_reorient_sform[i][i]) > 0

else:
if not (j == 3):
assert int(anat_reorient_sform[i][j]) == 0
elif not (j == 3):
assert int(anat_reorient_sform[i][j]) == 0

def test_anat_skullstrip(self):
"""
Expand Down
1 change: 1 addition & 0 deletions CPAC/aroma/aroma_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@author: nrajamani
"""

import os

import pytest
Expand Down
1 change: 1 addition & 0 deletions CPAC/connectome/connectivity_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Functions for creating connectome connectivity matrices."""

import os
from warnings import warn

Expand Down
1 change: 1 addition & 0 deletions CPAC/cwas/cwas.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""CWAS module for CPAC."""

import os

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions CPAC/cwas/tests/test_cwas.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Test the CWAS pipeline."""

from logging import basicConfig, INFO

import pytest
Expand Down
1 change: 1 addition & 0 deletions CPAC/cwas/tests/test_pipeline_cwas.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Test the CWAS pipeline."""

from logging import basicConfig, INFO
import os
from urllib.error import URLError
Expand Down
1 change: 1 addition & 0 deletions CPAC/func_preproc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Functional preprocessing."""

from .func_motion import (
calc_motion_stats,
func_motion_correct,
Expand Down
1 change: 1 addition & 0 deletions CPAC/func_preproc/tests/test_preproc_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Test graph connections for functional preprocessing."""

from itertools import product
from random import sample
import re
Expand Down
1 change: 1 addition & 0 deletions CPAC/generate_motion_statistics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Functions for generating motion statistics."""

from .generate_motion_statistics import (
calculate_DVARS,
calculate_FD_J,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Functions to calculate motion statistics."""

import os
import sys
from typing import Optional
Expand Down
1 change: 1 addition & 0 deletions CPAC/generate_motion_statistics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Utilities for motion parameters."""

from typing import Optional

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions CPAC/longitudinal_pipeline/longitudinal_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Preprocessing for longitudinal pipelines."""

from collections import Counter
from multiprocessing.dummy import Pool as ThreadPool
import os
Expand Down
1 change: 1 addition & 0 deletions CPAC/nuisance/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Utilities for nuisance regression."""

from . import compcor
from .compcor import calc_compcor_components
from .utils import (
Expand Down
1 change: 1 addition & 0 deletions CPAC/nuisance/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""General utilities for nuisance regression."""

from collections import OrderedDict
import os
import re
Expand Down
1 change: 1 addition & 0 deletions CPAC/pipeline/check_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Test to check if all expected outputs were generated."""

from itertools import chain
from logging import Logger
import os
Expand Down
11 changes: 6 additions & 5 deletions CPAC/pipeline/cpac_group_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Run a group-level analysis with C-PAC."""

import fnmatch
import os

Expand Down Expand Up @@ -1249,9 +1250,9 @@ def run_feat(group_config_file, feat=True):
if contrasts_df.shape[0] == 1 and np.count_nonzero(contrasts_df.values[0][1:]) == 0:
err = (
"\n\n[!] C-PAC says: It appears you haven't defined any "
"contrasts in your contrasts CSV file.\n\nContrasts file:\n{0}"
f"contrasts in your contrasts CSV file.\n\nContrasts file:\n{custom_contrasts_csv}"
"\n\nDefine your contrasts in this file and run again."
"\n\n".format(custom_contrasts_csv)
"\n\n"
)
raise Exception(err)

Expand Down Expand Up @@ -1923,8 +1924,8 @@ def run_basc(pipeline_config):
if df_scan not in scan_inclusion:
continue

basc_config_dct["analysis_ID"] = "{0}_{1}".format(
os.path.basename(pipeline_dir), df_scan
basc_config_dct["analysis_ID"] = (
f"{os.path.basename(pipeline_dir)}_{df_scan}"
)

# add scan label and nuisance regression strategy label to the
Expand Down Expand Up @@ -2161,7 +2162,7 @@ def run_isc(pipeline_config):
permutations = pipeconfig_dct.get("isc_permutations", 1000)
std_filter = pipeconfig_dct.get("isc_level_voxel_std_filter", None)

if std_filter == 0.0: # noqa: PLR2004
if std_filter == 0.0:
std_filter = None

levels = []
Expand Down
1 change: 1 addition & 0 deletions CPAC/pipeline/cpac_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Build a pipeline for C-PAC to run on a subject."""

import copy
import csv
import faulthandler
Expand Down
1 change: 1 addition & 0 deletions CPAC/pipeline/nipype_pipeline_engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
See https://nipype.readthedocs.io/en/latest/api/generated/nipype.pipeline.engine.html
for Nipype's documentation.
""" # pylint: disable=line-too-long

from nipype.pipeline import engine as pe

# import everything in nipype.pipeline.engine.__all__
Expand Down
1 change: 1 addition & 0 deletions CPAC/pipeline/nodeblock.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Class and decorator for NodeBlock functions."""

from typing import Any, Callable, Dict, List, Optional, Union


Expand Down
1 change: 1 addition & 0 deletions CPAC/pipeline/random_state/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Random state for C-PAC."""

from .seed import (
random_seed,
random_seed_flags,
Expand Down
1 change: 1 addition & 0 deletions CPAC/pipeline/random_state/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Functions to set, check, and log random seed."""

import random

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions CPAC/pipeline/test/test_cpac_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for cpac_pipeline.py."""

import pytest

from CPAC.pipeline.cpac_pipeline import run_workflow
Expand Down
1 change: 1 addition & 0 deletions CPAC/pipeline/test/test_schema_validation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for schema.py."""

from itertools import combinations

import pytest
Expand Down
1 change: 1 addition & 0 deletions CPAC/pipeline/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""C-PAC pipeline engine utilities."""

from itertools import chain
from typing import Union

Expand Down
1 change: 1 addition & 0 deletions CPAC/qc/xcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
normCoverage : float
"Normalization of T1w/Functional to Template:[…] Coverage index" :footcite:`xcp_22,Ciri19`
""" # pylint: disable=line-too-long

from io import BufferedReader
import os
import re
Expand Down
1 change: 1 addition & 0 deletions CPAC/randomise/test_randomise.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Test randomise."""

import os

import pytest
Expand Down
25 changes: 7 additions & 18 deletions CPAC/registration/output_func_to_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
"""Transform functional images to template space."""

from nipype.interfaces import ants, c3, fsl
from nipype.interfaces.afni import utils as afni_utils
import nipype.interfaces.utility as util
Expand Down Expand Up @@ -518,9 +519,7 @@ def ants_apply_warps_func_mni(
# define the node
collect_transforms = pe.Node(
util.Merge(num_transforms),
name="collect_transforms_{0}_{1}_{2}_{3}".format(
output_name, inverse_string, registration_template, num_strat
),
name=f"collect_transforms_{output_name}_{inverse_string}_{registration_template}_{num_strat}",
)

# wire in the various transformations
Expand All @@ -540,9 +539,7 @@ def ants_apply_warps_func_mni(
output_names=["checked_transform_list", "list_length"],
function=check_transforms,
),
name="check_transforms{0}_{1}_{2}_{3}".format(
output_name, inverse_string, registration_template, num_strat
),
name=f"check_transforms{output_name}_{inverse_string}_{registration_template}_{num_strat}",
)

workflow.connect(collect_transforms, "out", check_transform, "transform_list")
Expand All @@ -554,9 +551,7 @@ def ants_apply_warps_func_mni(
output_names=["inverse_transform_flags"],
function=generate_inverse_transform_flags,
),
name="inverse_transform_flags_{0}_{1}_{2}_{3}".format(
output_name, inverse_string, registration_template, num_strat
),
name=f"inverse_transform_flags_{output_name}_{inverse_string}_{registration_template}_{num_strat}",
)

workflow.connect(
Expand All @@ -582,19 +577,15 @@ def ants_apply_warps_func_mni(
if map_node:
apply_ants_warp = pe.MapNode(
interface=ants.ApplyTransforms(),
name="apply_ants_warp_{0}_mapnode_{1}_{2}_{3}".format(
output_name, inverse_string, registration_template, num_strat
),
name=f"apply_ants_warp_{output_name}_mapnode_{inverse_string}_{registration_template}_{num_strat}",
iterfield=["input_image"],
mem_gb=1,
mem_x=(1401462037888665 / 2361183241434822606848, "input_image"),
)
else:
apply_ants_warp = pe.Node(
interface=ants.ApplyTransforms(),
name="apply_ants_warp_{0}_{1}_{2}_{3}".format(
output_name, inverse_string, registration_template, num_strat
),
name=f"apply_ants_warp_{output_name}_{inverse_string}_{registration_template}_{num_strat}",
mem_gb=1,
mem_x=(1401462037888665 / 2361183241434822606848, "input_image"),
)
Expand Down Expand Up @@ -628,9 +619,7 @@ def ants_apply_warps_func_mni(
# write out the composite functional to standard transforms
write_composite_xfm = pe.Node(
interface=ants.ApplyTransforms(),
name="write_composite_xfm_{0}_{1}_{2}_{3}".format(
output_name, inverse_string, registration_template, num_strat
),
name=f"write_composite_xfm_{output_name}_{inverse_string}_{registration_template}_{num_strat}",
mem_gb=8.0,
)
write_composite_xfm.inputs.print_out_composite_warp_file = True
Expand Down
Loading

0 comments on commit e75aff6

Please sign in to comment.