mne-tools/mne-python — pull request #1352 by rgoj (2014-06-15 10:41:34+00:00)
Title: WIP/ENH/FIX Improve comments in TF Multitaper examples and clarify baseline specification

After implementing #1346 I found that values of maxima in the plots slightly change depending on the range in which we choose time windows in the tf_lcmv example. That is when computations are done from -550ms to 750 ms the results are different compared to when the computations are done from -300ms to 500ms. This is because the baselines for noise and data covariance calculations weren't explicitly specified to be 300 ms and could be 550ms, depending on tmin specified.

These commits improve how the baseline is specified and improve the comments to make it more explicit that there are separate time ranges for plotting and computation purposes.

There's one more bug I found, which turned out to be a problem in stc.crop. When running calculations from -550ms all the bins were shifted to the left (see the maximum in the plot below, it should be at 50-100 ms, instead it's at 0 to 50 ms). It turns out that stc.crop removed a time point at -0.3 s, because stc.times contained a value which was -0.30000000000000004. This is fairly easy to reproduce:

In: -0.55 + 5 * 0.05
Out: -0.30000000000000004

In : -0.55 + 5 * 0.05 >= -0.3
Out: False

I ended up augmenting stc.crop to include using np.isclose

In : (-0.55 + 5 * 0.05 >= -0.3) | np.isclose(-0.55 + 5 * 0.05, -0.3)
Out: True