File tree Expand file tree Collapse file tree 4 files changed +14
-3
lines changed
Expand file tree Collapse file tree 4 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 1+ Preserve event-to-epoch mapping when exporting EEGLAB .set files by `Scott Huberty `_
Original file line number Diff line number Diff line change 22# License: BSD-3-Clause
33# Copyright the MNE-Python contributors.
44
5+ from inspect import getfullargspec
6+
57import numpy as np
68
79from ..annotations import _sync_onset
@@ -64,6 +66,11 @@ def _export_epochs(fname, epochs):
6466 else :
6567 annot = None
6668
69+ # https://github.com/jackz314/eeglabio/pull/18
70+ kwargs = dict ()
71+ if "epoch_indices" in getfullargspec (eeglabio .epochs .export_set ).kwonlyargs :
72+ kwargs ["epoch_indices" ] = epochs .selection
73+
6774 eeglabio .epochs .export_set (
6875 fname ,
6976 data = epochs .get_data (picks = ch_names ),
@@ -75,6 +82,7 @@ def _export_epochs(fname, epochs):
7582 event_id = epochs .event_id ,
7683 ch_locs = cart_coords ,
7784 annotations = annot ,
85+ ** kwargs ,
7886 )
7987
8088
Original file line number Diff line number Diff line change 3535 _check_edfio_installed ,
3636 _record_warnings ,
3737 _resource_path ,
38+ check_version ,
3839 object_diff ,
3940)
4041
@@ -534,7 +535,7 @@ def test_export_raw_edf_does_not_fail_on_empty_header_fields(tmp_path):
534535 raw .export (tmp_path / "test.edf" , add_ch_type = True )
535536
536537
537- @pytest .mark .xfail ( reason = "eeglabio (usage?) bugs that should be fixed " )
538+ @pytest .mark .skipif ( not check_version ( "eeglabio" , "0.1.2" ), reason = "fixed by 0.1.2 " )
538539@pytest .mark .parametrize ("preload" , (True , False ))
539540def test_export_epochs_eeglab (tmp_path , preload ):
540541 """Test saving an Epochs instance to EEGLAB's set format."""
Original file line number Diff line number Diff line change @@ -631,13 +631,14 @@ def __init__(
631631 event_type = "/" .join ([str (et ) for et in ep .eventtype ])
632632 event_name .append (event_type )
633633 # store latency of only first event
634- event_latencies .append (events [ev_idx ].latency )
634+ # -1 to account for Matlab 1-based indexing of samples
635+ event_latencies .append (events [ev_idx ].latency - 1 )
635636 ev_idx += len (ep .eventtype )
636637 warn_multiple_events = True
637638 else :
638639 event_type = ep .eventtype
639640 event_name .append (ep .eventtype )
640- event_latencies .append (events [ev_idx ].latency )
641+ event_latencies .append (events [ev_idx ].latency - 1 )
641642 ev_idx += 1
642643
643644 if event_type not in unique_ev :
You can’t perform that action at this time.
0 commit comments