ExportingΒΆ

All three containers Recording, Session and Phase implement the ability to export the data (including events) to a mne.io.RawArray. To do this simply call the .to_mne() function of any container. Be aware that this process involves copying the data in memory, so it might require (at least momentary) up to double the size of the data in memory space.

[2]:
from neurone_loader import Recording
[3]:
rec = Recording(test_data_path)
session0 = rec.sessions[0]
[4]:
try:
    cnt = session0.to_mne()
except AssertionError as e:
    print(f'Error: {e}')
(Lazy) loading Phase.events
(Lazy) loading Phase.n_samples
(Lazy) loading Phase.events
(Lazy) loading Phase.n_samples
(Lazy) loading Phase.events
(Lazy) loading Phase.n_samples
(Lazy) loading Phase.events
(Lazy) loading Phase.n_samples
(Lazy) loading Session.data
(Lazy) loading Phase.data
(Lazy) loading Phase.data
(Lazy) loading Phase.data
(Lazy) loading Phase.data
Error: events with event code 0 are not supported by MNE, use the substitute_zero_events_with parameter of this method to substitute with an alternative code

The way MNE represents events in a stimulation channel prevents it from using events with the event code 0. In order to successfully convert you must either

  • manipulate the .events data of the container to remove or substitute the events with Code == 0
  • or use the substitute_zero_events_with argument to provide a alternative number for automatic subtitution

Make sure though that the alternative event code you are using is not already present in the data!

[5]:
alt_code = 10
assert alt_code not in session0.event_codes
cnt = session0.to_mne(substitute_zero_events_with=alt_code)
Creating RawArray with float64 data, n_channels=138, n_times=2504369
    Range : 0 ... 2504368 =      0.000 ...   500.874 secs
Ready.

For more details refer to the API documentation of .to_mne()