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

using units in channels.tsv in read_raw_bids ? #1044

Open
agramfort opened this issue Aug 8, 2022 · 12 comments
Open

using units in channels.tsv in read_raw_bids ? #1044

agramfort opened this issue Aug 8, 2022 · 12 comments

Comments

@agramfort
Copy link
Member

playing with ds003775 I see that units say the data in the edf file are in uV but it's read by read_raw_bids as V.

openneuro-py download --dataset=ds003775 --include=sub-001
import mne
from mne_bids import BIDSPath, read_raw_bids

bp = BIDSPath(
    root='./ds003775',
    subject='001',
    task='resteyesc',
    datatype='eeg',
    session='t1',
    suffix='eeg',
    extension='.edf',
)

raw = read_raw_bids(bp)
# raw = mne.io.read_raw(bp)
raw.load_data()
# raw.apply_function(lambda x: x * 1e-6)
raw.plot()

I saw the pb with: https://output.circle-artifacts.com/output/job/869cb730-d785-46aa-9c16-afc668bf6b70/artifacts/0/site/examples/ds003775/sub-010_ses-t1_task-resteyesc_report.html from mne-tools/mne-bids-pipeline#585

@sappelhoff @hoechenberger any idea? can I consider the edf files broken? as mne.io.read_raw_edf screws up also the units

🙏

@sappelhoff
Copy link
Member

is it just that the BIDS metadata are wrong and it's actually in V?

@agramfort
Copy link
Member Author

agramfort commented Aug 8, 2022 via email

@hoechenberger
Copy link
Member

even if I change the channels.tsv file to have V and not uV it does not
change anything

Message ID: @.***>

This bit seems like a bug in MNE-BIDS then...

@agramfort
Copy link
Member Author

digging into the reader the .edf file does not contain units. So it defaults to 1 for scaling and so it's off by 1e6. Now I don't know what to do with the channels.tsv as if the units in the tsv copy the unit in the edf file then we could apply the scaling twice.

Here is an attempt #1045

it drives me nuts to have file format where units can be omitted...

@sappelhoff
Copy link
Member

If units can be omitted in EDF maybe we need to add a units param to mne.io.read_raw_edf and then in mne-bids pass an argument to that param, where we previously read the arg from the BIDS sidecar?

@agramfort
Copy link
Member Author

agramfort commented Aug 26, 2022 via email

@sappelhoff
Copy link
Member

Yes to both of your questions (IMHO) ... default should be None. and if we overwrite, we also warn.

@hoechenberger
Copy link
Member

hoechenberger commented Aug 26, 2022

@agramfort

if the units are not present in the edf files we require to pass it on read_raw_edf?

I'd say yes; fail hard and force users to specify the unit.

if we pass it it overwrites the units in the file?

If the param is present and the units are specified in the file, we should either fail, or at least print a big fat warning…

Are there actually situations where users might want to override the units? I'm worried that if we allow this override, we're about to open a can of worms, as this will creep into the reader functions for other file formats too over time. I'd rather force users to fix their input files than us allowing this override...

But then again, we actually quite often see users running into scaling issues and I don't think we currently have a "clean" way to address those, right? So maybe we should add this feature for all readers? 🤔

@agramfort
Copy link
Member Author

agramfort commented Aug 26, 2022 via email

@sappelhoff
Copy link
Member

@agramfort can this be closed now?

@hoechenberger
Copy link
Member

hoechenberger commented Aug 31, 2022

Closing as addressed upstream in mne-tools/mne-python#11099; actually reading the units from channels.tsv is to be addressed in #1045

@hoechenberger
Copy link
Member

I just realized that the title of this issue is exactly what we want to solve in #1045, so I'm re-opening.

@hoechenberger hoechenberger reopened this Aug 31, 2022
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

No branches or pull requests

3 participants