# How is the baseline correction calculated?

**URL:** <https://mne.discourse.group/t/how-is-the-baseline-correction-calculated/1078>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [September 5, 2016, 12:48pm UTC](https://mne.discourse.group/t/how-is-the-baseline-correction-calculated/1078 "2016-09-05T12:48:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [September 5, 2016, 12:48pm UTC](https://mne.discourse.group/t/how-is-the-baseline-correction-calculated/1078/1 "2016-09-05T12:48:01Z")

</div>

Hi,

I am comparing the evoke data of one subject between my script in Python  
with mne package and the script in IGOR pro that my lab used so far.

I gave the following time interval for baseline correction to both:  
baseline = (-0.060, 0.040). I noticed that the values of the average  
change: for each electrode there is always the same difference (between  
Python and IGOR) across data points.

How come? Can I have a more detailed explanation of how the baseline  
correction is applied?

Many thanks,  
Emanuela Liaci  
-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20160905/19965511/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160905/19965511/attachment.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [September 5, 2016, 2:14pm UTC](https://mne.discourse.group/t/how-is-the-baseline-correction-calculated/1078/2 "2016-09-05T14:14:45Z")

</div>

Hi Emanuela,

I assume you do the baselining when constructing the epochs  
(mne.Epochs(..., baseline=baseline))? It simply subtracts the mean over the  
baseline period. So the effective lines of code boil down to:

mean = np.mean(data[..., imin:imax], axis=-1)[..., None]  
data -= mean

, where the baseline runs from imin to imax. And yes this should be  
documented better. I'll make the issue to github.

-Jaakko

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [September 5, 2016, 2:44pm UTC](https://mne.discourse.group/t/how-is-the-baseline-correction-calculated/1078/3 "2016-09-05T14:44:43Z")

</div>

Hi Jaakko,

thanks for the enlightenment. Yes of course, now I understand the problem.  
But then since I have to apply the correction after the emerging, how can I  
do it?

Here my code:

epochs\_noRef = mne.EpochsArray(ElectrodeArray, info=info,tmin=-0.06)  
&nbsp;&nbsp;&nbsp;&nbsp;# baseline = (-0.06, 0.04)  
epochs\_Ref,\_= mne.io.set\_eeg\_reference(epochs\_noRef, ['TP9', 'TP10'])  
evoked=epochs\_Ref.average()

thanks a lot for your help,  
Emanuela

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [September 5, 2016, 2:45pm UTC](https://mne.discourse.group/t/how-is-the-baseline-correction-calculated/1078/4 "2016-09-05T14:45:30Z")

</div>

Hi Jaakko,

thanks for the enlightenment. Yes of course, now I understand the problem.  
But then since I have to apply the correction after the averaging, how can  
I do it?

Here my code:

epochs\_noRef = mne.EpochsArray(ElectrodeArray, info=info,tmin=-0.06)  
&nbsp;&nbsp;&nbsp;&nbsp;# baseline = (-0.06, 0.04)  
epochs\_Ref,\_= mne.io.set\_eeg\_reference(epochs\_noRef, ['TP9', 'TP10'])  
evoked=epochs\_Ref.average()

thanks a lot for your help,  
Emanuela

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [September 6, 2016, 5:17am UTC](https://mne.discourse.group/t/how-is-the-baseline-correction-calculated/1078/5 "2016-09-06T05:17:13Z")

</div>

In the development version there is a new method just for that  
[http://mne-tools.github.io/dev/generated/mne.Evoked.html?highlight=apply\_baseline#mne.Evoked.apply\_baseline](http://mne-tools.github.io/dev/generated/mne.Evoked.html?highlight=apply_baseline#mne.Evoked.apply_baseline)  
.  
You can also access the evoked data directly (evoked.data) and manipulate  
it to your liking,

-Jaakko
