mne-python icon indicating copy to clipboard operation
mne-python copied to clipboard

Read MIT Annotations

Open withmywoessner opened this issue 1 year ago • 14 comments

Reference issue (if any)

Fixes #12660.

What does this implement/fix?

Adds the ability to read WaveForm Database (wfdb) annotations using the already existing library. My proposed API adds two new parameters to mne.read_annotations() fmt and suffix. fmt and suffix are used in combination to read an annotation whose file suffix is not strictly defined. If mne.annotations(fmt='wfbd'...) is called with no suffix, then the function will check to see if the suffix matches a default list of suffixes. If mne.annotations(fmt='wfbd', suffix='seizures'...) is called, then the function will bypass the default list of suffixes.

withmywoessner avatar Dec 16 '24 17:12 withmywoessner

Hi @drammock and @larsoner, I know you mentioned reading the annotations using a predefined list of suffixes in #12660, but I thought it would be useful to also allow for the option to read files using any suffix. Let me know if you prefer otherwise.

withmywoessner avatar Dec 16 '24 17:12 withmywoessner

Where is the best place to list the suffix mappings @larsoner? The WFBD library mentions a few that I would also like to include besides .seisuzes.

withmywoessner avatar Dec 16 '24 17:12 withmywoessner

Where is the best place to list the suffix mappings @larsoner?

Looks like the mapping currently lives here https://github.com/mne-tools/mne-python/blob/b38385ef90d0fd8214d54b15c5fd91333c3bc032/mne/annotations.py#L1203

larsoner avatar Dec 17 '24 16:12 larsoner

Okay, everything should be good then. Should I add tests and include a citation for the library somewhere? @larsoner

withmywoessner avatar Jan 02 '25 21:01 withmywoessner

Should I add tests and include a citation for the library somewhere?

Sure, it would be good to add it to environment.yml (and to conda-forge if it's not already on there) and pyproject.toml in the full deps. Then we'll also want to add it to mne-installers around https://github.com/mne-tools/mne-installers/blob/a18bf50444a0e258b7d09c0ce14eab1ec8d948a9/recipes/mne-python/construct.yaml#L92

larsoner avatar Jan 07 '25 17:01 larsoner

Would you mind cutting a new release for the testing data? @larsoner https://github.com/mne-tools/mne-testing-data/pull/118

I used the data from https://physionet.org/content/chbmit/1.0.0/

Then we'll also want to add it to mne-installers around https://github.com/mne-tools/mne-installers/blob/a18bf50444a0e258b7d09c0ce14eab1ec8d948a9/recipes/mne-python/construct.yaml#L92

Added a PR here: https://github.com/mne-tools/mne-installers/pull/325

withmywoessner avatar Jan 21 '25 23:01 withmywoessner

https://github.com/mne-tools/mne-testing-data/releases/tag/0.157

larsoner avatar Jan 22 '25 14:01 larsoner

Can anyone help me figure out why the new test file is not being recognized by pytest? Is it because it has two extensions? When I read it myself it works fine. image

withmywoessner avatar Jan 24 '25 19:01 withmywoessner

Can anyone help me figure out why the new test file is not being recognized by pytest? Is it because it has two extensions? When I read it myself it works fine.

You need to tell the CIs (via MNE-Python) to actually use the newest version of the testing dataset. See:

https://github.com/mne-tools/mne-python/pull/12800/files

drammock avatar Jan 24 '25 19:01 drammock

I see, thank you. The testing data PR was merged before I updated the version.txt file. Should I make a new PR or ask for the last one to be reverted?

withmywoessner avatar Jan 24 '25 19:01 withmywoessner

Whoops I missed that! Will fix both and cut a new version

larsoner avatar Jan 24 '25 19:01 larsoner

Done... use 0.158 :facepalm:

larsoner avatar Jan 24 '25 19:01 larsoner

@withmywoessner do you have time to come back to this or would it help if someone pushed commits?

larsoner avatar Nov 13 '25 17:11 larsoner

Yes, I can do this! Sorry about that! I have been dealing with NIH nonsense this year.

withmywoessner avatar Nov 13 '25 18:11 withmywoessner