Skip to content

FIX: Add brainvision captrack ref channels when set_montage#6797

Merged
larsoner merged 9 commits intomne-tools:masterfrom
massich:eeg_ref
Sep 21, 2019
Merged

FIX: Add brainvision captrack ref channels when set_montage#6797
larsoner merged 9 commits intomne-tools:masterfrom
massich:eeg_ref

Conversation

@massich
Copy link
Copy Markdown
Contributor

@massich massich commented Sep 20, 2019

fixes #6788

However I'm not sure that this is the right call. It does not
make sense that a single montage has 2 reference points.
And atleast in our test file we have 'GND' and 'REF' in the
same file. Which also seems to be the case
in https://github.com/mne-tools/mne-python/blob/master/mne/io/brainvision/tests/data/test.hpts
as reported #6764 (comment)

cc: @sappelhoff, @agramfort

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 20, 2019

Codecov Report

Merging #6797 into master will increase coverage by 0.04%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #6797      +/-   ##
==========================================
+ Coverage   89.59%   89.63%   +0.04%     
==========================================
  Files         422      422              
  Lines       76406    76486      +80     
  Branches    12490    12500      +10     
==========================================
+ Hits        68458    68561     +103     
+ Misses       5138     5122      -16     
+ Partials     2810     2803       -7

@massich
Copy link
Copy Markdown
Contributor Author

massich commented Sep 20, 2019

I've been trying to find what where this 'GND' and 'REF' locations in the doc and googling but I couldn't find it.

@agramfort suggested to plot the postitions and if they are truly the same as 'EEG000' they will appear behind the ear. Well they are not:

image

import os.path as op
from mne.channels import (Montage, read_montage, read_dig_montage,
                          get_builtin_montages, DigMontage,
                          read_dig_egi, read_dig_captrack, read_dig_fif,
                          make_standard_montage)
from mne import create_info
import mne
import matplotlib.pyplot as plt
from mne.viz import plot_alignment, set_3d_view
from mne.datasets import fetch_fsaverage

plt.switch_backend('Qt5Agg')

data_path = mne.datasets.testing.data_path(download=False)
subjects_dir = op.dirname(fetch_fsaverage())

montage = read_dig_captrack(
    fname=op.join(data_path, 'montage', 'captrak_coords.bvct')
)
info = create_info(ch_names=['GND', 'REF'], sfreq=1, ch_types='eeg',
                   montage=montage)

fig = plot_alignment(
    info=info,
    show_axes=True, dig=True, surfaces='head', trans=None,
    subject='fsaverage', subjects_dir=subjects_dir,
)
set_3d_view(figure=fig, azimuth=135, elevation=80)

What I would do is what this PR is doing, add those channels and positions to the montage.

@massich massich marked this pull request as ready for review September 20, 2019 17:11
@agramfort
Copy link
Copy Markdown
Member

it's weird to have both GND and REF. One should correspond to EEG000 with neuromag/fif conventions. If it's not called EEG000 then set_montage should be modified to understand that GND or REF are the reference.

@jona-sassenhagen @mmagnuski any idea what GND or REF correspond to here and why there are two things? Should we ignore GND and just take REF as the EEG000 electrode?

@larsoner
Copy link
Copy Markdown
Member

This is why:

https://pressrelease.brainproducts.com/referencing/#11

In the end we can ignore the ground and use REF as EEG000

@massich
Copy link
Copy Markdown
Contributor Author

massich commented Sep 20, 2019

ok this changes one of the dig['ident'] with respect of the fif reference file. Not really sure why.

Any clues?

@larsoner
Copy link
Copy Markdown
Member

ok this changes one of the dig['ident'] with respect of the fif reference file. Not really sure why.

It is possible that in this instance we are actually doing something better/more correct than the C code, for example if it does not have an ident=0 and/or does not set chs['loc'][3:6] and we do.

@massich
Copy link
Copy Markdown
Contributor Author

massich commented Sep 20, 2019

Ok then, I'll ignore info['dig'] and make sure that chs loc is propper.

@agramfort
Copy link
Copy Markdown
Member

@larsoner I did it for one of the two. The other one is more annoying.

Please merge if green and happy

@larsoner larsoner added this to the 0.19 milestone Sep 21, 2019
@larsoner larsoner merged commit 05d7eea into mne-tools:master Sep 21, 2019
@larsoner
Copy link
Copy Markdown
Member

Thanks @massich @agramfort

@massich massich deleted the eeg_ref branch September 22, 2019 10:20
alexrockhill pushed a commit to alexrockhill/mne-python that referenced this pull request Oct 1, 2019
…s#6797)

* WIP: Add ref

* revert reference in set_montage

* Add REF back

* Just use the position for comparison since the reference is incomplete

* fix tests

* ups

* keep GND

* cleanup

* address comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

read_dig_captrack ignores eeg ref

3 participants