-
Notifications
You must be signed in to change notification settings - Fork 1.4k
add OTB (EMG) reader #13303
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
base: main
Are you sure you want to change the base?
add OTB (EMG) reader #13303
Conversation
from ...utils import _check_fname, fill_doc, logger, verbose, warn | ||
from ..base import BaseRaw | ||
|
||
OTB_PLUS_DTYPE = np.int16 # the file I have is int16; TBD if *all* OTB+ are like that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OTBioelettronica there are several TODO
items in the code here that maybe you can easily answer. Here's the first: are the data in .sig
files always 16-bit signed integer?
# TODO English-centric; any value of "sex" not starting with "m" or "f" will get | ||
# classed as "unknown". TBD if non-English-like values in the XML are possible | ||
# (e.g. maybe the recording GUI is localized but the XML values are not?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OTBioelettronica is "sex" always "M" or "F" in these files or can users input whatever they like in this field? If left unspecified, will the <sex>
node just be missing from the XML file?
# TODO verify these are the only non-data channel IDs | ||
NON_DATA_CHS = ("Quaternion", "BufferChannel", "RampChannel") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OTBioelettronica we need to distinguish which channels are EMG data from other channel types. Are these 3 the only non-EMG channel IDs, or are there others?
fnames = fid.getnames() | ||
# the .sig file is the binary channel data | ||
sig_fname = [_fname for _fname in fnames if _fname.endswith(".sig")] | ||
assert len(sig_fname) == 1 # TODO is this a valid assumption? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there guaranteed to be only 1 .sig
file in each OTB+ archive? The MATLAB code suggests "yes" but it's not totally clear.
# TODO better to call these "emg_1" etc? should we left-zeropad ix? | ||
ch_names.append(f"{ch_id}_{ix}" if ch_id in dupl_ids else ch_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right now we get channel names like "HD10MM0804_0", "HD10MM0804_1", etc. Seems like "EMG_000", "EMG_001" might be more user-friendly.
# TODO verify ch_type for quats, buffer channel, and ramp channel | ||
ch_types.append("misc" if ch_id in NON_DATA_CHS else "emg") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@larsoner is misc
the right channel type for these?
# TODO is the factor of 1000 (copied from the MATLAB code) to convert Volts | ||
# milliVolts? If so we should remove it (in MNE we always store in SI units, so | ||
# we should keep it in V) | ||
self._data = _data * (1000 * power_supply / 2**bit_depth / gains)[:, np.newaxis] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OTBioelettronica can you verify that the data in the .sig
file are recorded in Volts?
I think MNE-Python is better scope-wise than MNE-BIDS. Might make sense to add a MNE-EMG (or another package?) like we have MNE-NIRS if we expect a lot of EMG-specific functionality. In that case, the reader could live here or there. I think my vote is to start this |
agreed
Yes, I think following what we have with mne-nirs would be good. |
This implements a Raw reader for OTB files (EMG data). There are 2 formats, OTB4 and OTB+; so far only OTB+ implemented. Based in part on a MATLAB reader, with permission to translate and relicense as BSD-3, granted here: OTBioelettronica/OTB-Python#2 (comment)
.mat
files with source-of-truth for the signal values from the test data files.cc @OTBioelettronica @klotz-t @pranavm19 @agramfort