Setting the Marker channel

Dear list,

I have data from emotive EEG and trying to read using MNE.

There I removed all unnecessary channels using drop_channels.

Now these are the channel labels

print(data.info['ch_names'])

[u'AF3', u'F7', u'F3', u'FC5', u'T7', u'P7', u'O1', u'O2', u'P8', u'T8',
u'FC6', u'F4', u'F8', u'AF4', u'MARKER']

I have markers in MARKER Channel and the value '1' is there in some places
of the array.

Eg: 00000000000001000000000000010000000000

Now to read events I used the commands:

events = mne.find_events(data, stim_channel='MARKER')
print('Found %s events, first five:' % len(events))
print(events[:5])

Unfortunately, I am getting this result:

Found 0 events, first five:
[]

Where am I wrong? Appreciate your support

  <https://mailtrack.io/> Sent with Mailtrack
<https://mailtrack.io/install?source=signature&lang=en&referral=senakahks at gmail.com&idSignature=22>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170707/0605654a/attachment.html

that's indeed unexpected.

can you share the file?

data.save('to_share-raw.fif')

thx
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170707/f2025d24/attachment.html

Dear Alex,

Please find the to_share-raw.fif file by accessing following link.

https://www.dropbox.com/s/58ji93q7xj6nett/to_share-raw.fif?dl=0

Best regards,

Senaka

<https://mailtrack.io/> Sent with Mailtrack
<https://mailtrack.io/install?source=signature&lang=en&referral=senakahks at gmail.com&idSignature=22>

Hi,
it seems that the stim channel is assigned as EEG for some reason (probably
a mistake in the acquisition). Also the values on the stim channel are
micro scale causing the event finding to fail. Here's a short script for
fixing raw object.

import mne
raw = mne.io.read_raw_fif('to_share-raw.fif', preload=True)
data = raw.get_data()
data[14] *= 1000000
raw = mne.io.RawArray(data, raw.info)
raw.set_channel_types({'STI 014': 'stim'})

-Jaakko

Just two quick questions Senaka, mostly out of curiosity, what is the
Emotiv file format and what are you using to read in the file for mne?

Dear Jaakko,

Thank you for quick reply. I tried your code and it complains telling that
'Raw' object has no attribute 'get_data'.

Here is the full report of error

Opening raw data file /Users/Senaka/to_share-raw.fif...
Isotrak not found
    Range : 0 ... 55935 = 0.000 ... 436.992 secs
Ready.
Adding average EEG reference projection.
1 projection items deactivated
Reading 0 ... 55935 = 0.000 ... 436.992 secs...
Traceback (most recent call last):
  File "/Users/Senaka//test.py", line 3, in <module>
    data = raw.get_data()
AttributeError: 'Raw' object has no attribute 'get_data'

Thanks and regards,

Senaka

<https://mailtrack.io/> Sent with Mailtrack
<https://mailtrack.io/install?source=signature&lang=en&referral=senakahks at gmail.com&idSignature=22>

hi,

just replace

data = raw.get_data()

by

data = raw[:, :][0]

the get_data method will appear in the next release.

Alex

Hi,

Got events detected successfully with following code.

data = raw[:, :][0]
data[14] *= 1000000
raw = mne.io.RawArray(data, raw.info)

events = mne.find_events(raw, stim_channel='MARKER')

# prints event data
print('Found %s events, first five:' % len(events))
print(events[:30])

event_id = {'auditory/left': 1, 'auditory/right': 2}

epochs = mne.Epochs(raw, events, event_id=event_id , tmin=-0.2, tmax=0.5)

epochs.plot(block=True)

Through raw.plot(block=True) shows channel signal, after epoching,
epochs.plot(block=True) show only events and no signal.

[image: Inline image 1]

Is there something wrong with the code?

<https://mailtrack.io/&gt; Sent with Mailtrack
<Email tracking for Gmail — Mailtrack at gmail.com&idSignature=22>

hi,

just replace

data = raw.get_data()

by

data = raw[:, :][0]

the get_data method will appear in the next release.

Alex

Dear Jaakko,

Thank you for quick reply. I tried your code and it complains telling
that 'Raw' object has no attribute 'get_data'.

Here is the full report of error

Opening raw data file /Users/Senaka/to_share-raw.fif...
Isotrak not found
    Range : 0 ... 55935 = 0.000 ... 436.992 secs
Ready.
Adding average EEG reference projection.
1 projection items deactivated
Reading 0 ... 55935 = 0.000 ... 436.992 secs...
Traceback (most recent call last):
  File "/Users/Senaka//test.py", line 3, in <module>
    data = raw.get_data()
AttributeError: 'Raw' object has no attribute 'get_data'

Thanks and regards,

Senaka

<https://mailtrack.io/&gt; Sent with Mailtrack
<Email tracking for Gmail — Mailtrack at gmail.com&idSignature=22>

Hi,
it seems that the stim channel is assigned as EEG for some reason
(probably a mistake in the acquisition). Also the values on the stim
channel are micro scale causing the event finding to fail. Here's a short
script for fixing raw object.

import mne
raw = mne.io.read_raw_fif('to_share-raw.fif', preload=True)
data = raw.get_data()
data[14] *= 1000000
raw = mne.io.RawArray(data, raw.info)
raw.set_channel_types({'STI 014': 'stim'})

-Jaakko

Dear Alex,

Please find the to_share-raw.fif file by accessing following link.

Dropbox - to_share-raw.fif - Simplify your life

Best regards,

Senaka

<https://mailtrack.io/&gt; Sent with Mailtrack
<Email tracking for Gmail — Mailtrack at gmail.com&idSignature=22>

that's indeed unexpected.

can you share the file?

data.save('to_share-raw.fif')

thx
Alex

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom
it is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to
you in error
but does not contain patient information, please contact the sender
and properly
dispose of the e-mail.

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom
it is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you
in error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom
it is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you
in error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom it
is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you
in error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom it
is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you in
error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170708/0e82a157/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 32795 bytes
Desc: not available
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170708/0e82a157/attachment-0001.png

I don't see any problem. Make sure your data are in Volts not micro-Volts.

Best,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170708/4536c420/attachment.html

Hi Alex,

Thank you for your time. You can check screenshots of the graphs below,
which were not available in the last post.

raw.plot(block=True)
https://ibb.co/n6GeaF

epochs.plot(block=True)

https://ibb.co/ccKXvF

So, I guess this is not a problem with an amplitude of the signal. Am I
correct?

Thanks,

Senaka

<https://mailtrack.io/> Sent with Mailtrack
<https://mailtrack.io/install?source=signature&lang=en&referral=senakahks at gmail.com&idSignature=22>

hi,

did you baseline correct your Epochs or high pass filter the raw data?
if not please do.

you may have a big offset in the values.

HTH,
Alex

Hi,

I am migrating from EEGLAB and tried to apply baseline corrections and
filters, unfortunately, those attempts ended up with another set of errors.
Highly appreciating somebody's support since I am exhausted.

Sample file URL:
https://www.dropbox.com/s/vwvy4duwkahysfk/ChinthakaDahnushka.edf?dl=0

The code so far I used:

import mne
import numpy as np
import matplotlib.pyplot as plt

raw = mne.io.read_raw_edf('ChinthakaDahnushka.edf', preload=True)
raw = raw.drop_channels(['COUNTER',
'INTERPOLATED','RAW_CQ','GYROX','GYROY', 'SYNC', 'TIME_STAMP_s',
'TIME_STAMP_ms', 'CQ_AF3', 'CQ_F7', 'CQ_F3', 'CQ_FC5', 'CQ_T7',
'CQ_P7', 'CQ_O1', 'CQ_O2', 'CQ_P8', 'CQ_T8', 'CQ_FC6', 'CQ_F4',
'CQ_F8', 'CQ_AF4', 'CQ_CMS', 'STI 014'])

data = raw[:, :][0]

data[14] *= 1000000

raw = mne.io.RawArray(data, raw.info)

events = mne.find_events(raw, stim_channel='MARKER')

print('Found %s events, first five:' % len(events))
print(events[:5])

event_id = {'two': 2}

epochs = mne.Epochs(raw, events, event_id=event_id, tmin=-0.2, tmax=1.5)

epochs_data = epochs['two'].get_data()

print(epochs_data.shape)

epochs.plot(block=True)

This is the plot I ended up with

https://ibb.co/ccKXvF

Thanks,

Senaka

<https://mailtrack.io/> Sent with Mailtrack
<https://mailtrack.io/install?source=signature&lang=en&referral=senakahks at gmail.com&idSignature=22>

I was able to reproduce the plot with version 0.13. I'm not sure what's the
cause of it, but in v. 0.14 it looks better. Can you try updating mne to
the latest version?

-Jaakko

Dear Jaakko,

I issued the following command
pip install mne --upgrade

Result:
Requirement already up-to-date: mne in ./mne-python

Is there a direct command to check the version?

I use python 2.7 and macOS Sierra.

Thanks

Senaka

<https://mailtrack.io/> Sent with Mailtrack
<https://mailtrack.io/install?source=signature&lang=en&referral=senakahks at gmail.com&idSignature=22>

You can do

import mne
mne.sys_info()

I think you can also work around the issue by doing
raw.set_channel_types({'MARKER': 'stim'})

after constructing the RawArray. The amplitude of the stimulus channel is
messing up the plot.

-Jaakko

Hi Jaakko and Alex,

Thanks a lot. Finally, Jaakko's trick worked.

This is the plot.

https://ibb.co/eKt6Pa

Thank you again for spending your valuable to get the code fixed up.

Senaka

<https://mailtrack.io/> Sent with Mailtrack
<https://mailtrack.io/install?source=signature&lang=en&referral=senakahks at gmail.com&idSignature=22>

Hi all,

One more small problem to get fixed. When I apply a low-pass or high-pass
filter, SOME event ids are not detected. Tested with the code I specified
in the thread with linked data.

Any possible reasons?

Thank you,

Senaka

<https://mailtrack.io/> Sent with Mailtrack
<https://mailtrack.io/install?source=signature&lang=en&referral=senakahks at gmail.com&idSignature=22>

Could it be because the stim channel is getting filtered as well? You
should first reassign the channel as stim channel (with
raw.set_channel_types) and then filter.

-Jaakko

Dear Jaakko,

Your suggestion fixed the problem.

Thanks

Senaka

<https://mailtrack.io/> Sent with Mailtrack
<https://mailtrack.io/install?source=signature&lang=en&referral=senakahks at gmail.com&idSignature=22>

hi,

make sure the marker channel is set as stim channel so it is not filtered.

did you do this?

raw.set_channel_types({'MARKER': 'stim'})

Best,