Skip to content
Open
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0b1ecb8
MAINT: Modernize path handling in misc.py using pathlib
Akhila21-6 Mar 22, 2026
820f7ad
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 22, 2026
1322a09
Merge branch 'main' into main
Akhila21-6 Mar 22, 2026
416be7c
MAINT: Add changelog entry for #13775
Akhila21-6 Mar 22, 2026
7f5b6c4
Merge branch 'main' of https://github.com/Akhila21-6/mne-python
Akhila21-6 Mar 22, 2026
1d50715
Update mne/misc.py
Akhila21-6 Mar 22, 2026
0cdfea7
Update mne/misc.py
Akhila21-6 Mar 22, 2026
88d3ee9
Update mne/misc.py
Akhila21-6 Mar 22, 2026
71bb006
Update mne/misc.py
Akhila21-6 Mar 22, 2026
fb3fc60
Update mne/misc.py
Akhila21-6 Mar 22, 2026
b0d4b42
MAINT: Add changelog entry
Akhila21-6 Mar 25, 2026
ba1b693
Merge branch 'main' of https://github.com/Akhila21-6/mne-python
Akhila21-6 Mar 25, 2026
c6e3afa
Merge branch 'main' into main
Akhila21-6 Mar 25, 2026
c6e3cc4
MAINT: move changelog to dev/ and add contributor name
Akhila21-6 Mar 26, 2026
70f9fac
Merge branch 'main' of https://github.com/Akhila21-6/mne-python
Akhila21-6 Mar 26, 2026
cd25ecf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 26, 2026
197de22
MAINT: fix names.inc syntax and verify dev path
Akhila21-6 Mar 26, 2026
58535a7
Merge branch 'main' into main
Akhila21-6 Mar 26, 2026
9a386c5
MAINT: fix docs syntax and resolve rebase
Akhila21-6 Mar 26, 2026
3c982e9
MAINT: Restore names.inc and fix contribution syntax
Akhila21-6 Mar 27, 2026
9a79553
MAINT: restore names.inc and use newcontrib syntax
Akhila21-6 Mar 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions mne/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.

from pathlib import Path


def parse_config(fname):
"""Parse a config file (like .ave and .cov files).
Expand All @@ -20,10 +22,13 @@ def parse_config(fname):
tmin, tmax, name, grad_reject, mag_reject,
eeg_reject, eog_reject
"""
# Convert fname to Path object to ensure compatibility
Comment thread
Akhila21-6 marked this conversation as resolved.
Outdated
fname = Path(fname)

reject_params = read_reject_parameters(fname)

with open(fname) as f:
lines = f.readlines()
# Use pathlib to read text and split into lines directly
Comment thread
Akhila21-6 marked this conversation as resolved.
Outdated
lines = fname.read_text().splitlines()

cat_ind = [i for i, x in enumerate(lines) if "category {" in x]
event_dict = dict()
Expand All @@ -37,6 +42,7 @@ def parse_config(fname):
break
else:
raise ValueError("Could not find event id.")

Comment thread
Akhila21-6 marked this conversation as resolved.
Outdated
event_dict[event] = dict(**reject_params)
for k in range(ind + 1, ind + 7):
words = lines[k].split()
Expand Down Expand Up @@ -67,14 +73,20 @@ def read_reject_parameters(fname):
params : dict
The rejection parameters.
"""
with open(fname) as f:
lines = f.readlines()
# Ensure fname is a Path object
Comment thread
Akhila21-6 marked this conversation as resolved.
Outdated
fname = Path(fname)

# Use pathlib to read lines
Comment thread
Akhila21-6 marked this conversation as resolved.
Outdated
lines = fname.read_text().splitlines()

reject_names = ["gradReject", "magReject", "eegReject", "eogReject", "ecgReject"]
reject_pynames = ["grad", "mag", "eeg", "eog", "ecg"]
reject = dict()
for line in lines:
words = line.split()
# Defensive check for empty lines
if not words:
continue
if words[0] in reject_names:
reject[reject_pynames[reject_names.index(words[0])]] = float(words[1])

Expand Down