[Mne_analysis] Mne_analysis Digest, Vol 147, Issue 58

S.P.H. Speer speer at rsm.nl
Sat Apr 18 11:19:45 EDT 2020
Search archives:

        External Email - Use Caution        

Thanks for the quick response. Sure I will open an issue on Github.

Best,

Sebastian

-----Original Message-----
From: mne_analysis-bounces at nmr.mgh.harvard.edu <mne_analysis-bounces at nmr.mgh.harvard.edu> On Behalf Of mne_analysis-request at nmr.mgh.harvard.edu
Sent: zaterdag 18 april 2020 17:13
To: mne_analysis at nmr.mgh.harvard.edu
Subject: Mne_analysis Digest, Vol 147, Issue 58

Send Mne_analysis mailing list submissions to
	mne_analysis at nmr.mgh.harvard.edu

To subscribe or unsubscribe via the World Wide Web, visit
	https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fmailman%2Flistinfo%2Fmne_analysis&amp;data=02%7C01%7Cspeer%40rsm.nl%7C552829f85e594f08dc6f08d7e3ab0fd2%7C715902d6f63e4b8d929b4bb170bad492%7C0%7C0%7C637228196156781958&amp;sdata=zQTg%2BKx4jCuQY%2BtEVaiLhgw%2Ftwzq3N%2B3%2FOeOZfLTFD0%3D&amp;reserved=0
or, via email, send a message with subject or body 'help' to
	mne_analysis-request at nmr.mgh.harvard.edu

You can reach the person managing the list at
	mne_analysis-owner at nmr.mgh.harvard.edu

When replying, please edit your Subject line so it is more specific than "Re: Contents of Mne_analysis digest..."


Today's Topics:

   1. Error with load epochs after cropping after baseline
      correction (S.P.H. Speer)
   2. Re: Error with load epochs after cropping after baseline
      correction (Alexandre Gramfort)


----------------------------------------------------------------------

Message: 1
Date: Sat, 18 Apr 2020 15:06:49 +0000
From: "S.P.H. Speer" <speer at rsm.nl>
Subject: [Mne_analysis] Error with load epochs after cropping after
	baseline	correction
To: "mne_analysis at nmr.mgh.harvard.edu"
	<mne_analysis at nmr.mgh.harvard.edu>
Message-ID:
	<AM0PR02MB57297DD673D0EA47EC7E5725CBD60 at AM0PR02MB5729.eurprd02.prod.outlook.com>
	
Content-Type: text/plain; charset="us-ascii"

        External Email - Use Caution        

Dear MNE team,

I've recently started preprocessing some EEG data with the MNE toolbox and it has been a great experience so far.

I did my baseline correction on a period of 1s which is 6s prior to the onset of the event of interest (due to unfortunate experimental design), so I initially epoched my data to -7 to 3s . After epoching the data I then cropped the data to -0.3 to 3s, as I no longer needed the 7 seconds prior to the data after the baseline correction was done. When I then save the epoched data and load it again somewhere else and error occurs because the baseline parameters are outside the epoched data.
To my understanding the baseline correction is already applied during epoching so I the decided to just set the baseline parameters to (0,0) after baseline correction has been done and data has been cropped. If I do that I can load the epoched data without no problem. My question is now: Will I run into problem later in my analysis pipeline because I set the baseline parameters to (0,0) even though baseline correction was done on another time window?
Is there a better way to solve this issue?

See below the code:

    decision_epochs = mne.Epochs(eeg_data_interp_ref_ica, events, tmin=-7, tmax=3,baseline=(-7,-6),
                        #reject=reject_criteria,  flat=flat_criteria, # commented beause we're using autoreject here
                        event_id = decision_events_of_interest,
                        reject_by_annotation=False, preload=True)

    decision_epochs_cropped = decision_epochs.copy().crop(tmin=-0.3, tmax=3, include_tmax=True)


    # drop epochs after cropping

    ar = AutoReject(verbose='tqdm_notebook', n_jobs=n_jobs, consensus=np.linspace(0, 1, 20), n_interpolate = np.array([1,4,8,16,32]) )
    decision_epochs_cropped_clean_ar = ar.fit_transform(decision_epochs_cropped)

    out_dir='/data/sebastian/EEG/neural_analysis/'

    # This version can't be loaded after
    decision_epochs_cropped_clean_ar.save(opj(out_dir,task,sub+'-TEST_'+str(cutoff_l)+'_HP_'+str(cutoff_h)+'_'+reference+'.fif'), overwrite=True)

    # This version can't be loaded after
    decision_epochs_cropped_clean_ar.baseline=(0,0)
    decision_epochs_cropped_clean_ar.save(opj(out_dir,task,sub+'-TEST2_'+str(cutoff_l)+'_HP_'+str(cutoff_h)+'_'+reference+'.fif'), overwrite=True)


Thank you very much for your help,

Sebastian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fpipermail%2Fmne_analysis%2Fattachments%2F20200418%2F8739f301%2Fattachment-0001.html&amp;data=02%7C01%7Cspeer%40rsm.nl%7C552829f85e594f08dc6f08d7e3ab0fd2%7C715902d6f63e4b8d929b4bb170bad492%7C0%7C0%7C637228196156791953&amp;sdata=%2BUkkmYCq0kdRnAWKvulEyQqKJuqtExKXFH2VRfHv%2Buo%3D&amp;reserved=0 

------------------------------

Message: 2
Date: Sat, 18 Apr 2020 17:12:49 +0200
From: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Subject: Re: [Mne_analysis] Error with load epochs after cropping
	after baseline correction
To: Discussion and support forum for the users of MNE Software
	<mne_analysis at nmr.mgh.harvard.edu>
Message-ID:
	<CADeotZo_6s=ysRWgDOd87BnWBxXTey43NRHYx7mMPNLZBac8eA at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

        External Email - Use Caution        

hi Sebastian,

your hack should not cause any problems down the road but I could consider this a bug in mne-python.

Can you open an issue on github so we can fix?

Alex


On Sat, Apr 18, 2020 at 5:08 PM S.P.H. Speer <speer at rsm.nl> wrote:

>         External Email - Use Caution
>
> Dear MNE team,
>
>
>
> I?ve recently started preprocessing some EEG data with the MNE toolbox 
> and it has been a great experience so far.
>
>
>
> I did my baseline correction on a period of 1s which is 6s prior to 
> the onset of the event of interest (due to unfortunate experimental 
> design), so I initially epoched my data to -7 to 3s . After epoching 
> the data I then cropped the data to -0.3 to 3s, as I no longer needed 
> the 7 seconds prior to the data after the baseline correction was 
> done. When I then save the epoched data and load it again somewhere 
> else and error occurs because the baseline parameters are outside the epoched data.
>
> To my understanding the baseline correction is already applied during 
> epoching so I the decided to just set the baseline parameters to (0,0) 
> after baseline correction has been done and data has been cropped. If 
> I do that I can load the epoched data without no problem. My question is now:
> Will I run into problem later in my analysis pipeline because I set 
> the baseline parameters to (0,0) even though baseline correction was 
> done on another time window?
>
> Is there a better way to solve this issue?
>
>
>
> See below the code:
>
>
>
>     decision_epochs = mne.Epochs(eeg_data_interp_ref_ica, events, 
> tmin=-7, tmax=3,baseline=(-7,-6),
>
>                         #reject=reject_criteria,  flat=flat_criteria, 
> # commented beause we're using autoreject here
>
>                         event_id = decision_events_of_interest,
>
>                         reject_by_annotation=False, preload=True)
>
>
>
>     decision_epochs_cropped = decision_epochs.copy().crop(tmin=-0.3,
> tmax=3, include_tmax=True)
>
>
>
>
>
>     # drop epochs after cropping
>
>
>
>     ar = AutoReject(verbose='tqdm_notebook', n_jobs=n_jobs, 
> consensus=np.linspace(0, 1, 20), n_interpolate = 
> np.array([1,4,8,16,32]) )
>
>     decision_epochs_cropped_clean_ar =
> ar.fit_transform(decision_epochs_cropped)
>
>
>
>     out_dir='/data/sebastian/EEG/neural_analysis/'
>
>
>
>     # This version can't be loaded after
>
>
> decision_epochs_cropped_clean_ar.save(opj(out_dir,task,sub+'-TEST_'+st
> r(cutoff_l)+'_HP_'+str(cutoff_h)+'_'+reference+'.fif'),
> overwrite=True)
>
>
>
>     # This version can't be loaded after
>
>     decision_epochs_cropped_clean_ar.baseline=(0,0)
>
>
> decision_epochs_cropped_clean_ar.save(opj(out_dir,task,sub+'-TEST2_'+s
> tr(cutoff_l)+'_HP_'+str(cutoff_h)+'_'+reference+'.fif'),
> overwrite=True)
>
>
>
>
>
> Thank you very much for your help,
>
>
>
> Sebastian
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail
> .nmr.mgh.harvard.edu%2Fmailman%2Flistinfo%2Fmne_analysis&amp;data=02%7
> C01%7Cspeer%40rsm.nl%7C552829f85e594f08dc6f08d7e3ab0fd2%7C715902d6f63e
> 4b8d929b4bb170bad492%7C0%7C0%7C637228196156791953&amp;sdata=PUXCMeOwWB
> e15SRldmulLGRo%2FHjGcfRzvxVzOJYzyJ0%3D&amp;reserved=0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fpipermail%2Fmne_analysis%2Fattachments%2F20200418%2F0013c460%2Fattachment.html&amp;data=02%7C01%7Cspeer%40rsm.nl%7C552829f85e594f08dc6f08d7e3ab0fd2%7C715902d6f63e4b8d929b4bb170bad492%7C0%7C0%7C637228196156791953&amp;sdata=XyequQ3Zi5Krhb%2F7ioHyGTgZH8YgPuQ9phSyxsn%2B68Y%3D&amp;reserved=0 

------------------------------

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fmailman%2Flistinfo%2Fmne_analysis&amp;data=02%7C01%7Cspeer%40rsm.nl%7C552829f85e594f08dc6f08d7e3ab0fd2%7C715902d6f63e4b8d929b4bb170bad492%7C0%7C0%7C637228196156791953&amp;sdata=PUXCMeOwWBe15SRldmulLGRo%2FHjGcfRzvxVzOJYzyJ0%3D&amp;reserved=0

End of Mne_analysis Digest, Vol 147, Issue 58
*********************************************




More information about the Mne_analysis mailing list