Commit ea65e3b8 authored by Marian Dovgialo's avatar Marian Dovgialo

#45153 added removing of semicolons in ReadManager -> MNE conversion, removed...

#45153 added removing of semicolons in ReadManager -> MNE conversion, removed bug when converting mne raw to ReadManager would drop MNE stim channel
parent 50264b91
Pipeline #16946 passed with stages
in 57 seconds
......@@ -5,7 +5,7 @@
"""Mixin for readmanager to create MNE.Raw objects."""
import json
from typing import Union
from copy import copy
from copy import copy, deepcopy
import numpy
from ..signal.signal_constants import sample_type_from_numpy
......@@ -35,6 +35,14 @@ def add_stim_chnl(raw):
def _description_from_tag(tag):
tag_desc = copy(tag)
tag_custom_describtion = tag_desc['desc']
for key in tag_custom_describtion:
try:
value = tag_custom_describtion[key]
if ';' in value:
tag_custom_describtion[key] = value.replace(';', ':')
except TypeError:
pass
tag_desc.pop('start_timestamp')
tag_desc.pop('end_timestamp')
return json.dumps(tag_desc)
......@@ -129,9 +137,10 @@ class ReadManagerMNEMixin:
def from_mne(cls, mne_raw):
"""Read Raw mne object to ReadManager."""
assert isinstance(mne_raw, mne.io.BaseRaw)
mne_raw.drop_channels(['OBCI_STIM'])
data = mne_raw.get_data() * 1e6 # mne keeps signals in Volts
return cls._rm_from_mne_data(data, mne_raw.info, mne_raw.annotations)
mne_raw_copy = deepcopy(mne_raw)
mne_raw_copy.drop_channels(['OBCI_STIM'])
data = mne_raw_copy.get_data() * 1e6 # mne keeps signals in Volts
return cls._rm_from_mne_data(data, mne_raw_copy.info, mne_raw_copy.annotations)
@classmethod
def _rm_from_mne_data(cls, data, info, annotations=None):
......@@ -223,5 +232,5 @@ class ReadManagerMNEMixin:
add_stim_chnl(raw)
ans = self.mne_annotations()
events, _ = self.mne_events()
raw.set_annotations(ans, sync_orig=False)
raw.set_annotations(ans)
raw.add_events(events)
......@@ -15,7 +15,6 @@ from obci_readmanager.signal_processing.tags import smart_tag_definition as df
from test_smart_tags_manager import fabricate_data_file, fabricate_info_file
@pytest.mark.skip('To fix')
def test_mne_semicolon():
pth = os.path.abspath(__file__)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment