[Mne_analysis] Fwd: epochs baseline problem (pandas dataframe indexing?)
Nakagawa Tristan T
nakagawa-t at ifrec.osaka-u.ac.jp
Fri Apr 15 00:43:13 EDT 2016
Ah, yes, also the typo, thanks (see my other post)!
On 2016年04月14日 15:27, Jaakko Leppäkangas wrote:
> Hi Tristan,
> seems like a typo. You have baseline defined as `(-1, -.05)`, but in
> the function call you use `baseline=(-.5,.05)`. Just change that to
> `baseline=baseline`.
>
>
> On 14 April 2016 at 03:27, Nakagawa Tristan T
> <nakagawa-t at ifrec.osaka-u.ac.jp
> <mailto:nakagawa-t at ifrec.osaka-u.ac.jp>> wrote:
>
>
> Hi,
>
> is the baselining limited to certain kinds of channels?
> I can't get it to work right for physiology (emg,ecg), the means
> aren't
> 0 for the baseline period.
>
> Here the details:
> I have this raw file:
> https://www.dropbox.com/s/6t4z52tno5tl228/raw.fif?dl=0 (1GB!)
> and I create epochs with the below code, baseline correcting it.
>
> It may also be related to a possible bug or something I'm doing
> wrong in
> pandas dataframe indexing, see here:
> http://stackoverflow.com/questions/36589702/pandas-dataframe-row-multiindex-skip-one/36590006#36590006
>
> Thanks for any input.
> best,
> Tristan
>
> -----------------------------------
>
> import pandas as pd
> import numpy as np
> import matplotlib.pyplot as plt
> import mne
> import scipy.signal as signal
>
> # load data
> raw = Raw('raw.fif', preload = True) #load Data
> raw._first_samps[0]=0 # From my older question, I still need this..
> mne.channels.rename_channels(raw.info
> <http://raw.info>,{'BIO003':'emg1','BIO004':'emg2',
>
> 'BIO005':'emg3','BIO006':'emg4',
>
> 'BIO007':'emg5','BIO008':'ecg'})
> raw.set_channel_types({'emg1':'emg','emg2':'emg','emg3':'emg','emg4':'emg','emg5':'emg','ecg':'ecg'})
> picks_emg = mne.pick_types(raw.info <http://raw.info>,emg=True)
> # preprocess emg signals: hilbert envelope!
> raw.filter(10, 150, picks=picks_emg)
>
> # For viewability, I put the events below, load them first!
>
> # Create & save Epochs
> event_id = dict(CS=1, OS=2, NS=3)
> tmin = -1.1 # start of each epoch
> tmax = 6 # end of each epoch
> baseline = (-1, -.05) # in seconds
> epochs = mne.Epochs(raw,events, event_id, tmin=tmin, tmax=tmax,
> proj=False, picks=[0,1,2,3,4,5],
> baseline=(-.5,.05), preload=True,reject=None)
>
> # Confirm that mean for baseline period is 0:
> test=epochs['CS'].to_data_frame()
> # mean=test.loc[idx['CS',:, -1000:-50], :].mean() # doesn't work, see
> stackoverflow link!
> mean=test.loc[idx['CS',test.index.levels[1], -1000:-50], :].mean()
> print(mean)
>
> # events
> events=np.array([[ 11527, 0, 1],
> [ 22344, 0, 2],
> [ 31541, 0, 3],
> [ 42542, 0, 2],
> [ 52757, 0, 3],
> [ 61972, 0, 1],
> [ 71586, 0, 3],
> [ 81785, 0, 3],
> [ 92786, 0, 3],
> [103803, 0, 3],
> [113000, 0, 3],
> [124001, 0, 2],
> [135018, 0, 2],
> [145016, 0, 2],
> [155616, 0, 2],
> [164830, 0, 3],
> [174629, 0, 2],
> [185629, 0, 1],
> [196245, 0, 3],
> [207246, 0, 2],
> [217645, 0, 1],
> [226659, 0, 1],
> [237459, 0, 2],
> [248476, 0, 1],
> [258875, 0, 1],
> [269475, 0, 1],
> [280091, 0, 1],
> [289890, 0, 3],
> [300289, 0, 1],
> [309503, 0, 2],
> [319903, 0, 1],
> [328900, 0, 1],
> [338515, 0, 3],
> [347512, 0, 2],
> [356726, 0, 2],
> [367526, 0, 3],
> [377926, 0, 2],
> [387540, 0, 2],
> [398557, 0, 3],
> [407571, 0, 3],
> [417370, 0, 1],
> [427168, 0, 2],
> [437784, 0, 1],
> [448384, 0, 3],
> [457782, 0, 1],
> [467797, 0, 1],
> [477596, 0, 1],
> [488012, 0, 2],
> [498411, 0, 3],
> [509011, 0, 3],
> [518626, 0, 2],
> [529025, 0, 3],
> [539425, 0, 3],
> [548639, 0, 2],
> [557836, 0, 2],
> [567835, 0, 3],
> [578852, 0, 1],
> [588450, 0, 1],
> [598666, 0, 1],
> [608064, 0, 2]])
>
>
>
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> <mailto: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.
>
>
--
Tristan T. Nakagawa, Ph.D.
Laboratory for Brain-Immune Interaction,
iFReC, Osaka University
3-1 Yamadaoka, Suita, Osaka, Japan
Tel: 0668789710
Office: CiNet R 2B6-2
http://seymourlab.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160415/493c0b0b/attachment-0001.html
More information about the Mne_analysis
mailing list