Skip to content

Commit

Permalink
Switch to absolute imports and ensure the Ruff (linter and formatter)…
Browse files Browse the repository at this point in the history
… exclude patterns are correctly represented in `pyproject.toml` (#969)
  • Loading branch information
hoechenberger authored Jul 25, 2024
1 parent 0521bfe commit aeba4a0
Show file tree
Hide file tree
Showing 33 changed files with 280 additions and 181 deletions.
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
---
files: ^(.*\.(py|yaml))$
# We need to match the exclude list in pyproject.toml because pre-commit.ci
# passes filenames and these do not get passed through the tool.black filter
# for example
exclude: ^(\.[^/]*cache/.*|.*/freesurfer/contrib/.*)$
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.4
Expand Down
2 changes: 2 additions & 0 deletions docs/source/changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% include-markdown "./v1.10.md.inc" %}

{% include-markdown "./v1.9.md.inc" %}

{% include-markdown "./v1.8.md.inc" %}
Expand Down
21 changes: 21 additions & 0 deletions docs/source/v1.10.md.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## v1.10.0 (unreleased)

[//]: # (### :new: New features & enhancements)

[//]: # (- Whatever (#000 by @whoever))

[//]: # (### :warning: Behavior changes)

[//]: # (- Whatever (#000 by @whoever))

[//]: # (### :package: Requirements)

[//]: # (- Whatever (#000 by @whoever))

[//]: # (### :bug: Bug fixes)

[//]: # (- Whatever (#000 by @whoever))

### :medical_symbol: Code health

- Switch from using relative to using absolute imports (#969 by @hoechenberger)
6 changes: 3 additions & 3 deletions mne_bids_pipeline/steps/freesurfer/_01_recon_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

from mne.utils import run_subprocess

from ..._config_utils import get_fs_subjects_dir, get_subjects
from ..._logging import gen_log_kwargs, logger
from ..._parallel import get_parallel_backend, parallel_func
from mne_bids_pipeline._config_utils import get_fs_subjects_dir, get_subjects
from mne_bids_pipeline._logging import gen_log_kwargs, logger
from mne_bids_pipeline._parallel import get_parallel_backend, parallel_func

fs_bids_app = Path(__file__).parent / "contrib" / "run.py"

Expand Down
8 changes: 4 additions & 4 deletions mne_bids_pipeline/steps/freesurfer/_02_coreg_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

import mne.bem

from ..._config_utils import (
from mne_bids_pipeline._config_utils import (
get_fs_subject,
get_fs_subjects_dir,
get_subjects,
)
from ..._logging import gen_log_kwargs, logger
from ..._parallel import get_parallel_backend, parallel_func
from ..._run import _prep_out_files, failsafe_run
from mne_bids_pipeline._logging import gen_log_kwargs, logger
from mne_bids_pipeline._parallel import get_parallel_backend, parallel_func
from mne_bids_pipeline._run import _prep_out_files, failsafe_run

fs_bids_app = Path(__file__).parent / "contrib" / "run.py"

Expand Down
6 changes: 3 additions & 3 deletions mne_bids_pipeline/steps/init/_01_init_derivatives_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from mne_bids.config import BIDS_VERSION
from mne_bids.utils import _write_json

from ..._config_utils import _bids_kwargs, get_sessions, get_subjects
from ..._logging import gen_log_kwargs, logger
from ..._run import _prep_out_files, failsafe_run
from mne_bids_pipeline._config_utils import _bids_kwargs, get_sessions, get_subjects
from mne_bids_pipeline._logging import gen_log_kwargs, logger
from mne_bids_pipeline._run import _prep_out_files, failsafe_run


@failsafe_run()
Expand Down
15 changes: 10 additions & 5 deletions mne_bids_pipeline/steps/init/_02_find_empty_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@

from mne_bids import BIDSPath

from ..._config_utils import (
from mne_bids_pipeline._config_utils import (
_bids_kwargs,
_pl,
get_datatype,
get_mf_reference_run,
get_sessions,
get_subjects,
)
from ..._import_data import _empty_room_match_path
from ..._io import _write_json
from ..._logging import gen_log_kwargs, logger
from ..._run import _prep_out_files, _update_for_splits, failsafe_run, save_logs
from mne_bids_pipeline._import_data import _empty_room_match_path
from mne_bids_pipeline._io import _write_json
from mne_bids_pipeline._logging import gen_log_kwargs, logger
from mne_bids_pipeline._run import (
_prep_out_files,
_update_for_splits,
failsafe_run,
save_logs,
)


def get_input_fnames_find_empty_room(
Expand Down
16 changes: 8 additions & 8 deletions mne_bids_pipeline/steps/preprocessing/_01_data_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import mne
import pandas as pd

from ..._config_utils import (
from mne_bids_pipeline._config_utils import (
_do_mf_autobad,
_pl,
get_mf_cal_fname,
Expand All @@ -14,7 +14,7 @@
get_sessions,
get_subjects,
)
from ..._import_data import (
from mne_bids_pipeline._import_data import (
_bads_path,
_get_mf_reference_run_path,
_get_run_rest_noise_path,
Expand All @@ -23,12 +23,12 @@
import_er_data,
import_experimental_data,
)
from ..._io import _write_json
from ..._logging import gen_log_kwargs, logger
from ..._parallel import get_parallel_backend, parallel_func
from ..._report import _add_raw, _open_report
from ..._run import _prep_out_files, failsafe_run, save_logs
from ..._viz import plot_auto_scores
from mne_bids_pipeline._io import _write_json
from mne_bids_pipeline._logging import gen_log_kwargs, logger
from mne_bids_pipeline._parallel import get_parallel_backend, parallel_func
from mne_bids_pipeline._report import _add_raw, _open_report
from mne_bids_pipeline._run import _prep_out_files, failsafe_run, save_logs
from mne_bids_pipeline._viz import plot_auto_scores


def get_input_fnames_data_quality(
Expand Down
16 changes: 6 additions & 10 deletions mne_bids_pipeline/steps/preprocessing/_02_head_pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@

import mne

from ..._config_utils import (
get_runs_tasks,
get_sessions,
get_subjects,
)
from ..._import_data import (
from mne_bids_pipeline._config_utils import get_runs_tasks, get_sessions, get_subjects
from mne_bids_pipeline._import_data import (
_get_run_rest_noise_path,
_import_data_kwargs,
import_experimental_data,
)
from ..._logging import gen_log_kwargs, logger
from ..._parallel import get_parallel_backend, parallel_func
from ..._report import _open_report
from ..._run import _prep_out_files, failsafe_run, save_logs
from mne_bids_pipeline._logging import gen_log_kwargs, logger
from mne_bids_pipeline._parallel import get_parallel_backend, parallel_func
from mne_bids_pipeline._report import _open_report
from mne_bids_pipeline._run import _prep_out_files, failsafe_run, save_logs


def get_input_fnames_head_pos(
Expand Down
17 changes: 11 additions & 6 deletions mne_bids_pipeline/steps/preprocessing/_03_maxfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,31 @@
import numpy as np
from mne_bids import read_raw_bids

from ..._config_utils import (
from mne_bids_pipeline._config_utils import (
_pl,
get_mf_cal_fname,
get_mf_ctc_fname,
get_runs_tasks,
get_sessions,
get_subjects,
)
from ..._import_data import (
from mne_bids_pipeline._import_data import (
_get_mf_reference_run_path,
_get_run_path,
_get_run_rest_noise_path,
_import_data_kwargs,
import_er_data,
import_experimental_data,
)
from ..._logging import gen_log_kwargs, logger
from ..._parallel import get_parallel_backend, parallel_func
from ..._report import _add_raw, _open_report
from ..._run import _prep_out_files, _update_for_splits, failsafe_run, save_logs
from mne_bids_pipeline._logging import gen_log_kwargs, logger
from mne_bids_pipeline._parallel import get_parallel_backend, parallel_func
from mne_bids_pipeline._report import _add_raw, _open_report
from mne_bids_pipeline._run import (
_prep_out_files,
_update_for_splits,
failsafe_run,
save_logs,
)


# %% eSSS
Expand Down
21 changes: 11 additions & 10 deletions mne_bids_pipeline/steps/preprocessing/_04_frequency_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,23 @@
from mne.io.pick import _picks_to_idx
from mne.preprocessing import EOGRegression

from ..._config_utils import (
get_runs_tasks,
get_sessions,
get_subjects,
)
from ..._import_data import (
from mne_bids_pipeline._config_utils import get_runs_tasks, get_sessions, get_subjects
from mne_bids_pipeline._import_data import (
_get_run_rest_noise_path,
_import_data_kwargs,
_read_raw_msg,
import_er_data,
import_experimental_data,
)
from ..._logging import gen_log_kwargs, logger
from ..._parallel import get_parallel_backend, parallel_func
from ..._report import _add_raw, _open_report
from ..._run import _prep_out_files, _update_for_splits, failsafe_run, save_logs
from mne_bids_pipeline._logging import gen_log_kwargs, logger
from mne_bids_pipeline._parallel import get_parallel_backend, parallel_func
from mne_bids_pipeline._report import _add_raw, _open_report
from mne_bids_pipeline._run import (
_prep_out_files,
_update_for_splits,
failsafe_run,
save_logs,
)


def get_input_fnames_frequency_filter(
Expand Down
23 changes: 14 additions & 9 deletions mne_bids_pipeline/steps/preprocessing/_05_regress_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@
from mne.io.pick import _picks_to_idx
from mne.preprocessing import EOGRegression

from ..._config_utils import (
get_runs_tasks,
get_sessions,
get_subjects,
from mne_bids_pipeline._config_utils import get_runs_tasks, get_sessions, get_subjects
from mne_bids_pipeline._import_data import (
_get_run_rest_noise_path,
_import_data_kwargs,
_read_raw_msg,
)
from mne_bids_pipeline._logging import gen_log_kwargs, logger
from mne_bids_pipeline._parallel import get_parallel_backend, parallel_func
from mne_bids_pipeline._report import _add_raw, _open_report
from mne_bids_pipeline._run import (
_prep_out_files,
_update_for_splits,
failsafe_run,
save_logs,
)
from ..._import_data import _get_run_rest_noise_path, _import_data_kwargs, _read_raw_msg
from ..._logging import gen_log_kwargs, logger
from ..._parallel import get_parallel_backend, parallel_func
from ..._report import _add_raw, _open_report
from ..._run import _prep_out_files, _update_for_splits, failsafe_run, save_logs


def get_input_fnames_regress_artifact(
Expand Down
19 changes: 12 additions & 7 deletions mne_bids_pipeline/steps/preprocessing/_06a1_fit_ica.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,24 @@
from mne.preprocessing import ICA
from mne_bids import BIDSPath

from ..._config_utils import (
from mne_bids_pipeline._config_utils import (
_bids_kwargs,
get_eeg_reference,
get_runs,
get_sessions,
get_subjects,
)
from ..._import_data import annotations_to_events, make_epochs
from ..._logging import gen_log_kwargs, logger
from ..._parallel import get_parallel_backend, parallel_func
from ..._reject import _get_reject
from ..._report import _open_report
from ..._run import _prep_out_files, _update_for_splits, failsafe_run, save_logs
from mne_bids_pipeline._import_data import annotations_to_events, make_epochs
from mne_bids_pipeline._logging import gen_log_kwargs, logger
from mne_bids_pipeline._parallel import get_parallel_backend, parallel_func
from mne_bids_pipeline._reject import _get_reject
from mne_bids_pipeline._report import _open_report
from mne_bids_pipeline._run import (
_prep_out_files,
_update_for_splits,
failsafe_run,
save_logs,
)


def get_input_fnames_run_ica(
Expand Down
15 changes: 10 additions & 5 deletions mne_bids_pipeline/steps/preprocessing/_06a2_find_ica_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@
from mne.preprocessing import create_ecg_epochs, create_eog_epochs
from mne_bids import BIDSPath

from ..._config_utils import (
from mne_bids_pipeline._config_utils import (
_bids_kwargs,
get_eeg_reference,
get_runs,
get_sessions,
get_subjects,
)
from ..._logging import gen_log_kwargs, logger
from ..._parallel import get_parallel_backend, parallel_func
from ..._report import _open_report
from ..._run import _prep_out_files, _update_for_splits, failsafe_run, save_logs
from mne_bids_pipeline._logging import gen_log_kwargs, logger
from mne_bids_pipeline._parallel import get_parallel_backend, parallel_func
from mne_bids_pipeline._report import _open_report
from mne_bids_pipeline._run import (
_prep_out_files,
_update_for_splits,
failsafe_run,
save_logs,
)


def detect_bad_components(
Expand Down
17 changes: 11 additions & 6 deletions mne_bids_pipeline/steps/preprocessing/_06b_run_ssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,24 @@
from mne.preprocessing import find_ecg_events, find_eog_events
from mne_bids import BIDSPath

from ..._config_utils import (
from mne_bids_pipeline._config_utils import (
_bids_kwargs,
_pl,
_proj_path,
get_runs,
get_sessions,
get_subjects,
)
from ..._logging import gen_log_kwargs, logger
from ..._parallel import get_parallel_backend, parallel_func
from ..._reject import _get_reject
from ..._report import _open_report
from ..._run import _prep_out_files, _update_for_splits, failsafe_run, save_logs
from mne_bids_pipeline._logging import gen_log_kwargs, logger
from mne_bids_pipeline._parallel import get_parallel_backend, parallel_func
from mne_bids_pipeline._reject import _get_reject
from mne_bids_pipeline._report import _open_report
from mne_bids_pipeline._run import (
_prep_out_files,
_update_for_splits,
failsafe_run,
save_logs,
)


def _find_ecg_events(raw: mne.io.Raw, ch_name: str | None) -> np.ndarray:
Expand Down
12 changes: 6 additions & 6 deletions mne_bids_pipeline/steps/preprocessing/_07_make_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
import mne
from mne_bids import BIDSPath

from ..._config_utils import (
from mne_bids_pipeline._config_utils import (
_bids_kwargs,
get_eeg_reference,
get_runs,
get_sessions,
get_subjects,
)
from ..._import_data import annotations_to_events, make_epochs
from ..._logging import gen_log_kwargs, logger
from ..._parallel import get_parallel_backend, parallel_func
from ..._report import _open_report
from ..._run import (
from mne_bids_pipeline._import_data import annotations_to_events, make_epochs
from mne_bids_pipeline._logging import gen_log_kwargs, logger
from mne_bids_pipeline._parallel import get_parallel_backend, parallel_func
from mne_bids_pipeline._report import _open_report
from mne_bids_pipeline._run import (
_prep_out_files,
_sanitize_callable,
_update_for_splits,
Expand Down
Loading

0 comments on commit aeba4a0

Please sign in to comment.