is the maxfilter software necessary?

Hello,

I am trying to do a parameter sweep on a large amount of data. My maxfilter
license only works on a single machine, which would take too long.

I noticed that there is 'maxwell_filter' in mne python. I wanted to ask
this before I dove into the code - can the python mne software do all the
things that maxfilter does?

Thanks,
Dan Howarth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160722/58a0bf36/attachment.html

Oh, the answer is at the bottom of the page:

http://martinos.org/mne/stable/generated/mne.preprocessing.maxwell_filter.html#mne.preprocessing.maxwell_filter

Hello,

I run into an error when trying to perform an ICA on my EEG data. The
error says "No digitization points found." with this warning before:
"Did not find any electrode locations the info, will attempt to use
digitization points instead. However, if digitization points do not
correspond to the EEG electrodes, this will lead to bad results.
Please verify that the sensor locations in the plot are accurate."
I can't figure out the problem. I created a montage instance like
shown in the code below. It mostly follows the tutorial on artifact
correction using ICA.

fpath = 'EDFs/EDFs/'
name = 'rem2'
raw = mne.io.read_raw_fif(fpath+name, preload=True)

montage =
mne.channels.read_montage('standard_1020',ch_names=['F3','F4','C3','C4','O1','O2'])
info = mne.create_info(['EMG l','EMG
r','E1','E2','F3','F4','C3','C4','O1','O2'], 512, \
    
ch_types=['misc','misc','eog','eog','eeg','eeg','eeg','eeg','eeg','eeg'],
montage=montage)

picks_eeg = mne.pick_types(info, meg=False, eeg=True, eog=False,
stim=False, exclude='bads')

n_components = 10
method = 'fastica'
decim = 3

ica = ICA(n_components=n_components, method=method)

reject = dict(mag=5e-12, grad=4000e-13)
ica.fit(raw, picks=picks_eeg, decim=decim, reject=reject)

ica.plot_components()

I would greatly appreciate any help.

Nico

Hi nico,

can you share a file so I can have a look?

Alex

ICA copies info from the object you pass to .fit(). It should be enough if
before fitting you apply the montage to raw:

raw.set_montage(montage)

?

Thanks a lot, this worked!

Nico

Quoting Miko?aj Magnuski <mmagnuski at swps.edu.pl>:

Is there a way to set parameters for automatic artifact rejection on
continuous data in MNE? I'm especially interested in setting
parameters such as "maximum allowed voltage step" or "maximum and
minimum amplitude". Is there a command that achieves this on raw data?

Hi Nico,

To reject chunks of continuous data, the best is probably to first chop it
into small segments, which comes down to creating adjacent events/epoch and
apply your favorite rejection threshold, i.e.

chunk_size = 1000
chunk_starts = np.arange(0, raw.n_times, chunk_size)
events = np.c_[chunk_starts, np.zeros((len(chunk_starts), 2))].astype(int)
epochs = mne.Epochs(raw, events, dict(chunk=0), tmin=0, tmax=chunk_size *
raw.info['sfreq'], reject=dict(mag=5e-12))

Don't forget to check out the artefact correction tutorial:
http://martinos.org/mne/stable/auto_tutorials/plot_artifacts_detection.htm

the gallery examples:
http://martinos.org/mne/stable/auto_examples/preprocessing/plot_find_eog_artifacts.html
http://martinos.org/mne/stable/auto_examples/preprocessing/plot_find_ecg_artifacts.html
http://martinos.org/mne/stable/auto_examples/preprocessing/plot_interpolate_bad_channels.html

as well as Jas' autoreject repository:
https://github.com/jasmainak/autoreject

Hope that helps,

Jean-R?mi

I think you missed an `l` on the artifacts rejection link:

http://martinos.org/mne/stable/auto_tutorials/plot_artifacts_detection.html

Just adding to Jean-Remi?s answer:
you can quickly and easily chop data into segments using _segment_raw:

from mne.epochs import _segment_raw
epochs = _segment_raw(raw_eeg, segment_length=2.)

This chops the data into 2-s long segments.
?

2016-07-25 15:30 GMT+02:00 JR KING <jeanremi.king at gmail.com>:

Thanks! I got it working so far with Jean-Remi's method, but using
_segment_raw gives me an attribute error.

I read that the "reject" parameter is the peak-to-peak amplitude. Are
there other rejection parameters such as maximum allowed voltage step,
or lowest allowed activity?

Quoting Miko?aj Magnuski <mmagnuski at swps.edu.pl>:

FYI, currently _segment_raw is a private function (as marked by the
original '_') which is we thus do not provide support for. So beware that
it could vary across mne versions.

Thanks! I got it working so far with Jean-Remi's method, but using
_segment_raw gives me an attribute error.

I read that the "reject" parameter is the peak-to-peak amplitude. Are
there other rejection parameters such as maximum allowed voltage step,
or lowest allowed activity?

You also have the parameter "flat" which will remove epochs with too low a
peak-to-peak amplitude.

Mainak

Quoting Miko?aj Magnuski <mmagnuski at swps.edu.pl>:

> Just adding to Jean-Remi?s answer:
> you can quickly and easily chop data into segments using _segment_raw:
>
> from mne.epochs import _segment_raw
> epochs = _segment_raw(raw_eeg, segment_length=2.)
>
> This chops the data into 2-s long segments.
> ?
>
> 2016-07-25 15:30 GMT+02:00 JR KING <jeanremi.king at gmail.com>:
>
>> Hi Nico,
>>
>> To reject chunks of continuous data, the best is probably to first chop
it
>> into small segments, which comes down to creating adjacent events/epoch
and
>> apply your favorite rejection threshold, i.e.
>>
>> chunk_size = 1000
>> chunk_starts = np.arange(0, raw.n_times, chunk_size)
>> events = np.c_[chunk_starts, np.zeros((len(chunk_starts),
2))].astype(int)
>> epochs = mne.Epochs(raw, events, dict(chunk=0), tmin=0, tmax=chunk_size
*
>> raw.info['sfreq'], reject=dict(mag=5e-12))
>>
>> Don't forget to check out the artefact correction tutorial:
>>
http://martinos.org/mne/stable/auto_tutorials/plot_artifacts_detection.htm
>>
>> the gallery examples:
>>
>>
http://martinos.org/mne/stable/auto_examples/preprocessing/plot_find_eog_artifacts.html
>>
>>
http://martinos.org/mne/stable/auto_examples/preprocessing/plot_find_ecg_artifacts.html
>>
>>
http://martinos.org/mne/stable/auto_examples/preprocessing/plot_interpolate_bad_channels.html
>>
>> as well as Jas' autoreject repository:
>> https://github.com/jasmainak/autoreject
>>
>> Hope that helps,
>>
>> Jean-R?mi
>>
>>
>>> Is there a way to set parameters for automatic artifact rejection on
>>> continuous data in MNE? I'm especially interested in setting
>>> parameters such as "maximum allowed voltage step" or "maximum and
>>> minimum amplitude". Is there a command that achieves this on raw data?
>>>
>>> _______________________________________________
>>> Mne_analysis mailing list
>>> Mne_analysis at nmr.mgh.harvard.edu
>>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>>>
>>>
>>> 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
>>> http://www.partners.org/complianceline . 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
>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>>
>>
>> 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
>> http://www.partners.org/complianceline . 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
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160727/ae3dbc48/attachment-0001.html

Thanks again!

Is there a way to adjust the info of my raw data? The "reject"
parameter expects certain channel types.
I created an info instance:

     inf =
mne.create_info(12,512,['misc','misc','eog','eog','eeg','eeg','eeg','eeg','eeg','eeg'])

but I don't know how to change this information in my raw variable. I
tried to change it manually like

     raw.info['chs'][2]['kind'] == 'eog'

but then I get an error that this type is not found. Changing the
pick.py file (e.g. line 46 to: elif kind == FIFF.FIFFV_EOG_CH or
'eog') before the command above did not change the kind and is also
not the preferable way I guess. I could not find a solution on the MNE
website.

Quoting Mainak Jas <mainakjas at gmail.com>:

Have you tried:

http://mne-tools.github.io/stable/generated/mne.io.Raw.html#mne.io.Raw.set_channel_types

Eric

This looks exactly like what I'd need, but I get the error

"Cannot change channel type for channel O2 in projector "Average EEG
reference""

I tried:

raw.set_channel_types({'O1':'eog'})

Quoting Eric Larson <larson.eric.d at gmail.com>:

This looks exactly like what I'd need, but I get the error

"Cannot change channel type for channel O2 in projector "Average EEG
reference""

I tried:

raw.set_channel_types({'O1':'eog'})

O2 is considered EEG channel when constructing the SSP projection for
average referencing.
You cannot change it to EOG unless you flush the SSP vector and create
it again from scratch.

you can do something like this:

raw.info['projs'] = # remove all present projs
raw.set_channel_types({'O1':'eog'})
raw.add_proj(make_eeg_average_ref_proj(raw.info, activate=False))

HTH
Alex

This seems to work, thanks! At least when I check via pick_types.
However, when I use the parameter "reject=dict(eeg=200e-06)" in
mne.Epochs, it gives me the error: "No EEG channel found. Cannot
reject based on EEG." I used mne.Epochs with all channels.

Quoting Alexandre Gramfort <alexandre.gramfort at telecom-paristech.fr>:

you surely have a pb of channel types.

print

raw.info

to see what channels are present in your file.

Alex

This gives me:

ch_names : 'list | EMG l, EMG r, E1, E2, F3, F4, C3, C4, O1, O2
chs : 'list | 10 items (STIM: 10)

after typing the following line:
raw.pick_types(eeg=True)

ch_names : 'list | F3, F4, C3, C4, O1, O2
chs : 'list | 6 items (STIM: 6)

So I think channel types are ok and that is not the problem.

Quoting Alexandre Gramfort <alexandre.gramfort at telecom-paristech.fr>: