question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FR: Add "unit" parameter to get_data method for Epochs

See original GitHub issue

UPDATE: https://github.com/mne-tools/mne-python/pull/9136 implements this for “raw” … we still need it for “epochs”


I often find myself doing things like this:

# get EEG data and scale to micro volts
# ntrials x nchannels x ntimes
eeg_data_uV = epochs.get_data() * 1e6

… just to do different kinds of analyses with custom functions.

I think we should add a "unit" parameter to .get_data():

"""
Parameters
----------
unit : str, one of ["nV, uV, mV, V"]
    The unit in which the data will be returned. Defaults to "V".
"""

This would make it more transparent for users what units the data are in they are receiving, and also offer a chance for customization.

I have a complete déjà vu writing up this issue, but I couldn’t find existing threads on this.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
larsonercommented, Mar 16, 2021

I was wondering why the EOG channels are not considered as data channels in get_channel_types()

In some sense all channels are data channels. I think the idea is that the “data channels” in MNE correspond mostly to the channels that record brain data.

whether this units parameter should work on them?

I wouldn’t restrict it just to data channels. Any channels with units (which is most of them I think?) should be able to be modified by the unit parameter.

2reactions
sappelhoffcommented, Mar 16, 2021

The benefits are (at least) twofold:

  1. when somebody (a non-user) reads your code, something like epochs.get_data() * 1e6 is much more confusing than epochs.get_data(unit=dict(eeg='uV')) --> where does the magic number 1e6 come from? They’d need to learn that in MNE all EEG data is represented in Volts, and that 1e6 scales to microVolts
  2. as a fresh MNE user, I was confused about these units and a parameter unit would certainly have cleared up the situation for me

But I agree that this is an issue that requires quite some work, so no worries if you’d rather work on something else.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to update a parameter (at each epoch based on the input ...
Suppose, at each epoch, lambda = lambda + valX. I am new with customization of keras layer. Can anyone help me to get...
Read more >
mne-python/epochs.py at main - GitHub
The ``method`` parameter allows e.g. robust averaging. For example, one could do: >>> from scipy.stats import ...
Read more >
IGH_DataAccess.GetData(T) Method (String, T)
Retrieve data from an input parameter during GH_Component.SolveInstance(). Namespace: Grasshopper.Kernel Assembly: Grasshopper (in Grasshopper.dll).
Read more >
MNE : From raw data to epochs and evoked responses (ERF ...
This tutorial describes how to define epochs-of-interest (trials) from your recorded MEG-data, and how to apply the different preprocessing steps.
Read more >
Scripting Guide - cosmos.esa.int
Creating aliases for class and function names . ... Printing the methods available for a variable in the console.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found