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

WIP : add support for EMG data #1129

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

agramfort
Copy link
Member

a quick attempt to see what it would take to support EMG data for mne-bids

cc @neuromechanist @robertoostenveld

follow up on bids-standard/bids-specification#1371

@agramfort
Copy link
Member Author

here is quick script to test:

import mne
from mne.datasets import eegbci

from mne_bids import write_raw_bids, BIDSPath

subject = 1
run = 2
eegbci.load_data(subject=subject, runs=run, update_path=True)

# Load the data from "2 minutes eyes closed rest"
edf_path = eegbci.load_data(subject=subject, runs=run)[0]
raw = mne.io.read_raw_edf(edf_path, preload=False)
raw.info['line_freq'] = 50  # specify power line frequency as required by BIDS

raw.set_channel_types({ch: "emg" for ch in raw.ch_names})

# zero padding to account for >100 subjects in this dataset
subject_id = '001'

bids_root = "./test_data"
bids_path = BIDSPath(subject=subject_id, task="task", root=bids_root)
write_raw_bids(raw, bids_path, overwrite=True)

@neuromechanist
Copy link

neuromechanist commented Apr 10, 2023

Thanks for initiating this effort. I think there are quite a few distinctions between EMG and EEG (or other electrophysiology data currently in BIDS) that require more attention.

Probably, the first issue is which data files/extensions should be allowed. This may seem straightforward, but each manufacturer has quite an obscure data type for themselves. For example, Delsys (.hpf) is not a transparent data file and exclusively requires Delsys File Utility to convert to C3D, CSV etc. OT Bioelecttronica, Noarxon, and TSMi hardware also seem to handle data within their software best. EDF and BDF seem good choices (open source, reach availability across program languages, and fast read-write).

The next issue that comes to mind is the sensor placement (anatomical location, inter-electrode distance, number of electrodes, etc.). For EMG (not the high-density version), SENIAM has been the longstanding guideline. But there should also be a feature to allow the user to define custom sensor placement. This can't be handled in the BIDS guidelines for *_electrodes.tsv, *_channles.tsv, or *_coordsystem.json.

Other differences, such as signal quality metrics, make EMG more distinct from EEG. Instead of impedance from *_electrodes.tsv, EMG's signal quality is measured by SNR and/or noise floor when the muscle is inactive. Further, *_electordes.tsv may not be a good presentation of the EMG sensors as they are, in most cases, bipolar sensors, which makes them channels.

Overall, I believe EMG requires more than carrying over the EEG-BIDS specs. Also, a decision should be made on whether to include HDsEMG, iEMG, and iEMG arrays in bids-standard/bids-specification#1371. We will circulate the first draft of the arguments for 1-including all EMG modalities under one BIDS specification proposal and 2-HDsEMG metadata information that is not covered by other modalities this week.

Given the active development of EMG interfaces at Reality Labs, It would be great if folks at MRL could join the effort here and in BIDS.

@robertoostenveld
Copy link

In the development of previous BEPs we experienced that being able to jointly look at an example was very helpful. @neuromechanist can you share a HD-sEMG dataset? Data from a single subject will do. Converting that to a draft BIDS dataset will reveal the challenges to be addressed.

@agramfort
Copy link
Member Author

agramfort commented Apr 10, 2023 via email

@hoechenberger
Copy link
Member

@robertoostenveld

In the development of previous BEPs we experienced that being able to jointly look at an example was very helpful.

I agree, let's try to go this route

@neuromechanist
Copy link

neuromechanist commented Apr 11, 2023

can you share an HD-sEMG dataset?

Of course, here is the link to a sample comparative data I collected a while ago with three systems: OTB Sessantaquattro, Delsys Galelio, and g.tec Pangolin: EMG sample files. Both original files and converted files are included for convenience.
Since there is also a follow-up question about whether to have EMG and HDsEMG together, I also added an example of Delsys Trigno Mini recordings. I will add a sample of the Noraxon EMG recording later this week. Noraxon sample files are also added.

EMG is a bit different but I see a lot of similarities too. I really see the EEG standard as the building block for EMG and I would seek for concept reuse as much as possible.

I 100% agree. Signal-wise, I see not much difference in storing any electrophysiological data either. However, what those signals mean, where they are collected from, and how they could/should be analyzed or reproduced are totally different stories.

I guess that it may turn out that the main items that may require updating are the required and recommended metadata to ensure transparency, reusability, and reproducibility.

@robertoostenveld
Copy link

I have had a first pass at converting the 4 examples. See here as a shared folder on my google drive. The code directory contains the scripts that I used. The bids 1-4 are the respective datasets. The EMG data is currently in the beh folder, as that is where data2bids puts it by default. That could of course be changed into emg.

The main information that is missing to make the data FAIR (especially reusable) is documentation on the electrode placement (which muscle, which arrangement), and on the montage and/or recording reference and ground. Furthermore, task information and timing of events is missing. Other than that, my guess is that MNE-Python (or any other software) would have no difficulty reading this BIDS-converted data, i.e., the interoperability should already be quite good.

@neuromechanist
Copy link

I realized that it may be best to move the discussion about the additional information needed to describe the signals to the BIDS issue. Please feel free to share your comments there.

@agramfort
Copy link
Member Author

agramfort commented Apr 14, 2023 via email

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

Successfully merging this pull request may close these issues.

5 participants