mne-tools / mne-python

MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
https://mne.tools
BSD 3-Clause "New" or "Revised" License
2.7k stars 1.31k forks source link

Scaling is off for tiny_bids #11113

Closed hoechenberger closed 2 years ago

hoechenberger commented 2 years ago

Description of the problem

I think this screenshot demonstrates the issue:

Screen Shot 2022-08-29 at 16 22 03

Steps to reproduce

# %%
from pathlib import Path
import mne_bids
from mne_bids import BIDSPath, read_raw_bids

mne_bids_root = Path(mne_bids.__file__).parents[1]
tiny_bids_root = mne_bids_root / "mne_bids" / "tests" / "data" / "tiny_bids"

bids_path = BIDSPath(
    subject='01', session='eeg', task='rest', datatype='eeg',
    root=tiny_bids_root
)
raw = read_raw_bids(bids_path)
raw.plot(block=True)

This is with MNE and MNE-BIDS main

Expected results

Signal PTP should be in the range of maybe 300 or 500 µV max?

Actual results

PTP amplitude is much larger (2–3 units of magnitude)

Additional information

No response

sappelhoff commented 2 years ago

is this already a problem in the source for tiny_bids?

data_path = mne.datasets.testing.data_path()
vhdr_fname = op.join(data_path, "montage", "bv_dig_test.vhdr")
hoechenberger commented 2 years ago

is this already a problem in the source for tiny_bids?

Yes.

# %%
import mne

data_path = mne.datasets.testing.data_path()
vhdr_path = data_path / "montage" / "bv_dig_test.vhdr"

raw = mne.io.read_raw_brainvision(vhdr_path)
raw.plot()
Screen Shot 2022-08-29 at 17 20 43
sappelhoff commented 2 years ago

This was added to the testing data here: https://github.com/mne-tools/mne-testing-data/pull/49

As far as I remember I recorded this data in the lab at my institute and truncated it. No idea why the scaling is off 🤔

hoechenberger commented 2 years ago

No idea why the scaling is off 🤔

Could you try to read the data with BV Analyzer? I suspect our reader is the problem here…

sappelhoff commented 2 years ago

@alisenz -- do you have time to:

  1. download the BrainVision data in question (called bv_dig_test, see: https://github.com/mne-tools/mne-testing-data/tree/master/montage)
  2. Go to our lab and check
    1. whether you can read that data with BrainVision Analyzer
    2. It's installed on the recording PC
    3. The dongle is in the materials room (small red USB stick, should be on top right of shelf in a porcelain bowl)
  3. Report here whether you:
    1. can read and plot/view the data
    2. the units "seem right", i.e., that the voltages are in a reasonable range, unlike what Richard reports above when reading the data with MNE-Python

?

No worries if you don't find the time.

azinoveva commented 2 years ago

@hoechenberger @sappelhoff the data is readable but if you expect the amplitude of 300-500 µV, this is NOT the case. I'm seeing min 5000 µV here:

Capture

sappelhoff commented 2 years ago

wow, what the hell did I do back then? At least this confirms that the issue is with the data and not with our readers. Perhaps I did some weird scaling in a misguided attempt to obscure/anonymize the data, because I thought the severe cropping wasn't enough? After all this was originally only intended for a check of montages and the Brain Products CapTrak system.

Thanks for checking @alisenz

hoechenberger commented 2 years ago

If we're off by 3 orders of magnitude it's probably nV instead of uV?

sappelhoff commented 2 years ago

I don't think so. Knowing myself from 3 years ago I think this is most likely what happened (~80% sure):

Perhaps I did some weird scaling in a misguided attempt to obscure/anonymize the data, because I thought the severe cropping wasn't enough?

fixing this would involve:

hoechenberger commented 2 years ago

Thank you @sappelhoff for fixing this!