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

Add option to change default channel type #12581

Open
PierreGtch opened this issue Apr 26, 2024 · 4 comments
Open

Add option to change default channel type #12581

PierreGtch opened this issue Apr 26, 2024 · 4 comments
Labels

Comments

@PierreGtch
Copy link

Describe the new feature or enhancement

Hi :)

At the moment, when loading an EDF raw file, the channel types are all set to EEG by default (the default type is hardcoded here and here).

The EDF format supports adding a prefix to the channel names to specify their types (such as "EEG C3") and mne.io.read_raw_edf() has a parameter infer_types which reads this prefix, sets the type of the channel and removes the prefix from the name.

However, in many datasets, the only channels with prefixes are the EEG channels, while the channels with "rare" types do not have a prefix. In this case, even when using infer_types=True, all types still end up in EEG.

I propose to allow the users to specify a different default channel type when reading EDF files (or any file with unknown channel types?).

Describe your proposed implementation

Option one, using the config:

mne.set_config('DEFAULT_CHANNEL_TYPE', 'misc')

Easiest option to implement I think.

Describe possible alternatives

Option two, via the function arguments:

raw = mne.io.read_raw_edf(
    ...
    infer_types=True,
    default_type='misc',
)

Additional context

@cbrnr Do you have an opinion on which option would be the best?

Also, are there other data formats in which the channel types can be inferred?

@PierreGtch PierreGtch added the ENH label Apr 26, 2024
Copy link

welcome bot commented Apr 26, 2024

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴

@larsoner
Copy link
Member

I think for a case like this you could do:

raw = mne.io.read_raw_edf(fname)
raw.set_channel_types({ch: "eeg" if ch.startswith("EEG") else "misc" for ch in raw.ch_names})

In general if such use cases can be handled by a one-liner like this it's probably better (more flexible and maintainable) to document it in the Notes of read_raw_edf for example than it would be to add more parameters to functions.

@PierreGtch
Copy link
Author

I agree this issue can be handled easily without changes to the code. But leaving things as they are makes the infer_types arg useless in many of its intended use cases...
Option one would require only minimal changes.

@cbrnr
Copy link
Contributor

cbrnr commented Apr 28, 2024

Also note that mne.io.read_raw_edf() has eog and misc parameters, which you can use to assign these types to selected channels if you are not happy with the default EEG type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants