Skip to content

Add units param to get_data methods in Raw and Epochs#8476

Closed
sappelhoff wants to merge 2 commits intomne-tools:mainfrom
sappelhoff:get_data_units
Closed

Add units param to get_data methods in Raw and Epochs#8476
sappelhoff wants to merge 2 commits intomne-tools:mainfrom
sappelhoff:get_data_units

Conversation

@sappelhoff
Copy link
Copy Markdown
Member

closes #8473

Let me start by making a docstr proposal --> once we are clear on the functionality I can give it a try and implement it.

Should we link to https://mne.tools/stable/overview/implementation.html?highlight=units#id20 from the docstr?

@sappelhoff sappelhoff changed the title make docstr proposal Add units param to get_data methods in Raw and Epochs Nov 3, 2020
@sappelhoff sappelhoff added the ENH label Nov 3, 2020
@larsoner
Copy link
Copy Markdown
Member

larsoner commented Nov 3, 2020

Should we link to https://mne.tools/stable/overview/implementation.html?highlight=units#id20 from the docstr?

Yes, feel free to add a proper RST target name to that header and link to it with :ref:. And also maybe link to

:term:`data_channels`

here https://mne.tools/dev/glossary.html since we also talk about SI units there a bit.

@sappelhoff
Copy link
Copy Markdown
Member Author

These are the units we use in MNE (are these all the units we use?) (ref)


    Volts (eeg, eog, seeg, emg, ecg, bio, ecog)

    Teslas (magnetometers)

    Teslas/meter (gradiometers)

    Amperes*meter (dipole fits, minimum-norm estimates, etc.)

    Moles/liter (“molar”; fNIRS data: oxyhemoglobin (hbo), deoxyhemoglobin (hbr))

    Arbitrary units (various derived unitless quantities)

I am a bit confused how we would handle derived units like Teslas/meter, or Moles/liter

would we allow scaling to Teslas/millimeter? If yes, how?

@sappelhoff
Copy link
Copy Markdown
Member Author

finally, what "multiples" and "submultiples" should we allow? All those that are in this list?

https://bids-specification.readthedocs.io/en/stable/99-appendices/05-units.html#prefixes

That'd be based on the CMIXF-12 format for representing units in ASCII

@larsoner
Copy link
Copy Markdown
Member

larsoner commented Nov 3, 2020

would we allow scaling to Teslas/millimeter? If yes, how?

Yes. Somewhere we already parse fractional units and figure out what the scale factors are to get to SI units. Let me dig it up...

@larsoner
Copy link
Copy Markdown
Member

larsoner commented Nov 3, 2020

These are the units we use in MNE (are these all the units we use?) (ref)

No, but it's probably "good enough" for most people as a reference. The complete list is probably provided by the FIF spec at the moment, because we expand it as we need to:

https://github.com/mne-tools/mne-python/blob/master/mne/io/constants.py#L786-L836

I would not worry about supporting all of these. Let's just get the data units we're likely to need. We can always expand later.

would we allow scaling to Teslas/millimeter? If yes, how?

Refactor code from here, put it in mne/utils/numerics.py or something similar, reuse in the test and in your code:

https://github.com/mne-tools/mne-python/blob/master/mne/tests/test_defaults.py#L25

I would even just start with this list of prefixes and known_SI. It should have 99% of what you need (hopefully).

@hoechenberger
Copy link
Copy Markdown
Member

Just wondering if we can also allow µV in addition to uV, or would that become messy?

@sappelhoff
Copy link
Copy Markdown
Member Author

sappelhoff commented Nov 5, 2020

Just wondering if we can also allow µV in addition to uV, or would that become messy?

I would suggest to allow u as a common ASCII abbreviation of micro, as well as the two (different!) unicode characters µ (U+00B5) and μ (U+03BC)

Also brings up this comment again where I was a little too slow to chime in that U+03BC is preferred over U+00B5 by the unicode consortium: #7497 (comment)

@hoechenberger
Copy link
Copy Markdown
Member

Is there any way to easily figure out which unicode characterI'm producing on macOS via Option-M (µ)?

@sappelhoff
Copy link
Copy Markdown
Member Author

See screenshot:

image

The first one is the micro sign, the second one is small greek mu

@hoechenberger
Copy link
Copy Markdown
Member

wow… thanks!

@sappelhoff
Copy link
Copy Markdown
Member Author

sappelhoff commented Nov 8, 2020

I thought I'd get to this PR this weekend, but unfortunately that won't happen.

I'll come back to this in a few weeks - if in the meantime somebody wants to pick it up, please be my guest.

EDIT: I won't have time for this for now. Please take it over if you care about this!

This may be a nice lead: https://github.com/mne-tools/mne-python/pull/8760/files#r559649851

sappelhoff and others added 2 commits March 15, 2021 19:12
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
@sappelhoff
Copy link
Copy Markdown
Member Author

closing in favor of #9136

@sappelhoff sappelhoff closed this Mar 18, 2021
@sappelhoff sappelhoff deleted the get_data_units branch March 18, 2021 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants