Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX/DOC: read_ch_adjacency and "picks" argument #12066

Merged
merged 27 commits into from
Oct 5, 2023
Merged
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0b6afb9
mne.channels.read_ch_adjacency 'picks' argument does not function as …
zubara Oct 4, 2023
915f3b9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 4, 2023
e050c3d
Merge branch 'main' into main
zubara Oct 4, 2023
3e2adf7
updated devel.rst and test_channels.py to include channels subset sel…
zubara Oct 4, 2023
7e6fb48
Update mne/channels/channels.py
zubara Oct 4, 2023
311bde8
update to mne/channels/tests/test_channels.py
zubara Oct 4, 2023
7bfd028
merge with pre-commit changes
zubara Oct 4, 2023
e4abce2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 4, 2023
1e5b665
fixed typo in devel.rst
zubara Oct 4, 2023
f420981
Merge branch 'main' of https://github.com/zubara/mne-python
zubara Oct 4, 2023
5ef52e4
more typos to devel.rst
zubara Oct 4, 2023
ab01d2d
Docdict-based docstring in mne.channels.read_ch_adjacency
zubara Oct 4, 2023
7c72a26
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 4, 2023
6276831
Merge branch 'main' into main
zubara Oct 4, 2023
b8fde4f
style fixes to /utils/docs.py
zubara Oct 5, 2023
883eae0
Merge branch 'main' of https://github.com/zubara/mne-python
zubara Oct 5, 2023
ac2903e
Merge branch 'main' into main
zubara Oct 5, 2023
8a1c068
style fixes to /utils/docs.py#2
zubara Oct 5, 2023
45d3433
Merge branch 'main' of https://github.com/zubara/mne-python
zubara Oct 5, 2023
52b6863
Update mne/channels/tests/test_channels.py
zubara Oct 5, 2023
c851521
style fix in docs.py
zubara Oct 5, 2023
44ec2e1
Added: test_read_builtin_ch_adjacency_picks
zubara Oct 5, 2023
c91b178
merged test_channels
zubara Oct 5, 2023
c23239f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 5, 2023
65e5096
style fix
zubara Oct 5, 2023
56057dd
Merge branch 'main' of https://github.com/zubara/mne-python
zubara Oct 5, 2023
465add4
Merge branch 'main' into main
zubara Oct 5, 2023
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
19 changes: 10 additions & 9 deletions mne/channels/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,8 +1340,14 @@ def read_ch_adjacency(fname, picks=None):
You can retrieve the names of all
built-in channel adjacencies via
:func:`mne.channels.get_builtin_ch_adjacencies`.
%(picks_all)s
Picks must match the template.
picks : list
drammock marked this conversation as resolved.
Show resolved Hide resolved
Channels to include. Slices and lists of integers will be interpreted
as channel indices. In lists, channel name strings (e.g.,
['MEG0111', 'MEG2623'] will pick the given channels.
None (default) will pick all channels. Note that channels in
info['bads'] will be included if their names or
indices are explicitly provided. Picks must match the template.
zubara marked this conversation as resolved.
Show resolved Hide resolved


Returns
-------
Expand Down Expand Up @@ -1401,20 +1407,15 @@ def read_ch_adjacency(fname, picks=None):

nb = loadmat(fname)["neighbours"]
ch_names = _recursive_flatten(nb["label"], str)
picks = _picks_to_idx(len(ch_names), picks)
temp_info = create_info(ch_names, 1.0)
picks = _picks_to_idx(temp_info, picks)
neighbors = [_recursive_flatten(c, str) for c in nb["neighblabel"].flatten()]
assert len(ch_names) == len(neighbors)
adjacency = _ch_neighbor_adjacency(ch_names, neighbors)
# picking before constructing matrix is buggy
adjacency = adjacency[picks][:, picks]
ch_names = [ch_names[p] for p in picks]

# make sure MEG channel names contain space after "MEG"
for idx, ch_name in enumerate(ch_names):
if ch_name.startswith("MEG") and not ch_name[3] == " ":
ch_name = ch_name.replace("MEG", "MEG ")
ch_names[idx] = ch_name

return adjacency, ch_names


Expand Down
Loading