Skip to content

Commit 06bcd59

Browse files
committed
address @kingjr 's comments
1 parent 42f32bc commit 06bcd59

File tree

5 files changed

+43
-42
lines changed

5 files changed

+43
-42
lines changed

doc/whats_new.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Changelog
5353

5454
- Add new class :class:`mne.decoding.EMS` to transform epochs with the event-matched spatial filters and add 'cv' parameter to :func:`mne.decoding.compute_ems`, by `Jean-Remi King`_
5555

56-
- Added :class:`mne.time_frequency.EpochsTFR` and average parameter in :func:`mne.time_frequency.tfr_morlet` and :func:`mne.time_frequency.tfr_multitaper` to compute time frequency transforms on epochs without averaging, by `Jean-Remi King`_ and `Alex Gramfort`_
56+
- Added :class:`mne.time_frequency.EpochsTFR` and average parameter in :func:`mne.time_frequency.tfr_morlet` and :func:`mne.time_frequency.tfr_multitaper` to compute time frequency transforms on single trial epochs without averaging, by `Jean-Remi King`_ and `Alex Gramfort`_
5757

5858

5959
BUG
@@ -142,8 +142,7 @@ API
142142

143143
- Added :class:`mne.decoding.UnsupervisedSpatialFilter` providing interface for scikit-learn decomposition algorithms to be used with MNE data, by `Jean-Remi King`_ and `Asish Panda`_
144144

145-
- Deprecated :func:`mne.time_frequency.cwt_morlet` and :func:`mne.time_frequency.single_trial_power` in favour of :func:`mne.time_frequency.tfr_morlet` with parameter average=False,
146-
by `Jean-Remi King`_ and 'Alex Gramfort'_
145+
- Deprecated :func:`mne.time_frequency.cwt_morlet` and :func:`mne.time_frequency.single_trial_power` in favour of :func:`mne.time_frequency.tfr_morlet` with parameter average=False, by `Jean-Remi King`_ and 'Alex Gramfort'_
147146

148147

149148
.. _changes_0_12:

mne/time_frequency/tfr.py

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""A module which implements the time frequency estimation.
1+
"""A module which implements the time-frequency estimation.
22
33
Morlet code inspired by Matlab code from Sheraz Khan & Brainstorm & SPM
44
"""
@@ -172,7 +172,7 @@ def _cwt(X, Ws, mode="same", decim=1, use_fft=True):
172172
mode : {'full', 'valid', 'same'}
173173
See numpy.convolve.
174174
decim : int | slice, defaults to 1
175-
To reduce memory usage, decimation factor after time frequency
175+
To reduce memory usage, decimation factor after time-frequency
176176
decomposition.
177177
If `int`, returns tfr[..., ::decim].
178178
If `slice` returns tfr[..., decim].
@@ -183,7 +183,7 @@ def _cwt(X, Ws, mode="same", decim=1, use_fft=True):
183183
Returns
184184
-------
185185
out : array, shape (n_signals, n_freqs, n_time_decim)
186-
The time frequency transform of the signals.
186+
The time-frequency transform of the signals.
187187
"""
188188
if mode not in ['same', 'valid', 'full']:
189189
raise ValueError("`mode` must be 'same', 'valid' or 'full', "
@@ -252,7 +252,7 @@ def _compute_tfr(epoch_data, frequencies, sfreq=1.0, method='morlet',
252252
n_cycles=7.0, zero_mean=None, time_bandwidth=4.0,
253253
use_fft=True, decim=1, output='complex', n_jobs=1,
254254
verbose=None):
255-
"""Computes time frequency transforms.
255+
"""Computes time-frequency transforms.
256256
257257
Parameters
258258
----------
@@ -263,7 +263,7 @@ def _compute_tfr(epoch_data, frequencies, sfreq=1.0, method='morlet',
263263
sfreq : float | int, defaults to 1.0
264264
Sampling frequency of the data.
265265
method : 'multitaper' | 'morlet', defaults to 'morlet'
266-
The time frequency method. 'morlet' convolves a Morlet wavelet.
266+
The time-frequency method. 'morlet' convolves a Morlet wavelet.
267267
'multitaper' convolves DPSS tapers.
268268
n_cycles : float | array of float, defaults to 7.0
269269
Number of cycles in the Morlet wavelet. Fixed number
@@ -278,11 +278,13 @@ def _compute_tfr(epoch_data, frequencies, sfreq=1.0, method='morlet',
278278
use_fft : bool, defaults to True
279279
Use the FFT for convolutions or not.
280280
decim : int | slice, defaults to 1
281-
To reduce memory usage, decimation factor after time frequency
281+
To reduce memory usage, decimation factor after time-frequency
282282
decomposition.
283-
If `int`, returns tfr[..., ::decim].
284-
If `slice` returns tfr[..., decim].
285-
.. note: Decimation may create aliasing artifacts.
283+
If `int`, returns tfr[..., ::decim],
284+
if `slice` returns tfr[..., decim].
285+
.. note:
286+
Decimation may create aliasing artifacts, yet decimation
287+
is done after the convolutions.
286288
output : str, defaults to 'complex'
287289
288290
* 'complex' : single trial complex.
@@ -400,7 +402,7 @@ def _compute_tfr(epoch_data, frequencies, sfreq=1.0, method='morlet',
400402
def _time_frequency_loop(X, Ws, output, use_fft, mode, decim):
401403
"""Aux. function to _compute_tfr.
402404
403-
Loops time frequency transform across wavelets and epochs.
405+
Loops time-frequency transform across wavelets and epochs.
404406
405407
Parameters
406408
----------
@@ -507,7 +509,7 @@ def cwt_morlet(X, sfreq, freqs, use_fft=True, n_cycles=7.0, zero_mean=False,
507509
zero_mean : bool
508510
Make sure the wavelets have a mean of zero.
509511
decim : int | slice
510-
To reduce memory usage, decimation factor after time frequency
512+
To reduce memory usage, decimation factor after time-frequency
511513
decomposition.
512514
If `int`, returns tfr[..., ::decim].
513515
If `slice` returns tfr[..., decim].
@@ -521,7 +523,7 @@ def cwt_morlet(X, sfreq, freqs, use_fft=True, n_cycles=7.0, zero_mean=False,
521523
522524
See Also
523525
--------
524-
tfr.cwt : Compute time frequency decomposition with user-provided wavelets
526+
tfr.cwt : Compute time-frequency decomposition with user-provided wavelets
525527
"""
526528
mode = 'same'
527529
# mode = "valid"
@@ -555,7 +557,7 @@ def cwt(X, Ws, use_fft=True, mode='same', decim=1):
555557
Convention for convolution. 'full' is currently not implemented with
556558
`use_fft=False`. Defaults to 'same'.
557559
decim : int | slice
558-
To reduce memory usage, decimation factor after time frequency
560+
To reduce memory usage, decimation factor after time-frequency
559561
decomposition.
560562
If `int`, returns tfr[..., ::decim].
561563
If `slice` returns tfr[..., decim].
@@ -565,11 +567,11 @@ def cwt(X, Ws, use_fft=True, mode='same', decim=1):
565567
Returns
566568
-------
567569
tfr : array, shape (n_signals, n_frequencies, n_times)
568-
The time frequency decompositions.
570+
The time-frequency decompositions.
569571
570572
See Also
571573
--------
572-
mne.time_frequency.cwt_morlet : Compute time frequency decomposition
574+
mne.time_frequency.cwt_morlet : Compute time-frequency decomposition
573575
with Morlet wavelets
574576
"""
575577
decim = _check_decim(decim)
@@ -590,7 +592,7 @@ def cwt(X, Ws, use_fft=True, mode='same', decim=1):
590592
def single_trial_power(data, sfreq, frequencies, use_fft=True, n_cycles=7,
591593
baseline=None, baseline_mode='ratio', times=None,
592594
decim=1, n_jobs=1, zero_mean=False, verbose=None):
593-
"""Compute time frequency power on single epochs
595+
"""Compute time-frequency power on single epochs
594596
595597
Parameters
596598
----------
@@ -626,7 +628,7 @@ def single_trial_power(data, sfreq, frequencies, use_fft=True, n_cycles=7,
626628
times : array
627629
Required to define baseline
628630
decim : int | slice
629-
To reduce memory usage, decimation factor after time frequency
631+
To reduce memory usage, decimation factor after time-frequency
630632
decomposition.
631633
If `int`, returns tfr[..., ::decim].
632634
If `slice` returns tfr[..., decim].
@@ -654,7 +656,7 @@ def single_trial_power(data, sfreq, frequencies, use_fft=True, n_cycles=7,
654656

655657
parallel, my_cwt, _ = parallel_func(cwt, n_jobs)
656658

657-
logger.info("Computing time frequency power on single epochs...")
659+
logger.info("Computing time-frequency power on single epochs...")
658660

659661
power = np.empty((n_epochs, n_channels, n_frequencies, n_times),
660662
dtype=np.float)
@@ -741,18 +743,18 @@ def tfr_morlet(inst, freqs, n_cycles, use_fft=False, return_itc=True, decim=1,
741743
use_fft : bool, defaults to False
742744
The fft based convolution or not.
743745
return_itc : bool, defaults to True
744-
Return intertrial coherence (ITC) as well as averaged power.
746+
Return inter-trial coherence (ITC) as well as averaged power.
745747
Must be ``False`` for evoked data.
746748
decim : int | slice, defaults to 1
747-
To reduce memory usage, decimation factor after time frequency
749+
To reduce memory usage, decimation factor after time-frequency
748750
decomposition.
749751
If `int`, returns tfr[..., ::decim].
750752
If `slice` returns tfr[..., decim].
751753
.. note: Decimation may create aliasing artifacts.
752754
n_jobs : int, defaults to 1
753755
The number of jobs to run in parallel.
754756
picks : array-like of int | None, defaults to None
755-
The indices of the channels to plot. If None all available
757+
The indices of the channels to plot. If None, all available
756758
channels are displayed.
757759
zero_mean : bool, defaults to True
758760
Make sure the wavelet has a mean of zero.
@@ -770,7 +772,7 @@ def tfr_morlet(inst, freqs, n_cycles, use_fft=False, return_itc=True, decim=1,
770772
power : AverageTFR | EpochsTFR
771773
The averaged power.
772774
itc : AverageTFR | EpochsTFR
773-
The intertrial coherence (ITC). Only returned if return_itc
775+
The inter-trial coherence (ITC). Only returned if return_itc
774776
is True.
775777
776778
See Also
@@ -798,7 +800,7 @@ def tfr_multitaper(inst, freqs, n_cycles, time_bandwidth=4.0,
798800
n_cycles : float | ndarray, shape (n_freqs,)
799801
The number of cycles globally or for each frequency.
800802
The time-window length is thus T = n_cycles / freq.
801-
time_bandwidth : float, (optional), default is 4.0 (3 good tapers).
803+
time_bandwidth : float, (optional), defaults to 4.0 (3 good tapers).
802804
Time x (Full) Bandwidth product. Should be >= 2.0.
803805
Choose this along with n_cycles to get desired frequency resolution.
804806
The number of good tapers (least leakage from far away frequencies)
@@ -808,17 +810,17 @@ def tfr_multitaper(inst, freqs, n_cycles, time_bandwidth=4.0,
808810
use_fft : bool, defaults to True
809811
The fft based convolution or not.
810812
return_itc : bool, defaults to True
811-
Return intertrial coherence (ITC) as well as averaged power.
813+
Return inter-trial coherence (ITC) as well as averaged power.
812814
decim : int | slice, defaults to 1
813-
To reduce memory usage, decimation factor after time frequency
815+
To reduce memory usage, decimation factor after time-frequency
814816
decomposition.
815817
If `int`, returns tfr[..., ::decim].
816818
If `slice` returns tfr[..., decim].
817819
.. note: Decimation may create aliasing artifacts.
818820
n_jobs : int, defaults to 1
819821
The number of jobs to run in parallel.
820822
picks : array-like of int | None, defaults to None
821-
The indices of the channels to plot. If None all available
823+
The indices of the channels to plot. If None, all available
822824
channels are displayed.
823825
average : bool, defaults to True
824826
If True average accross Epochs.
@@ -832,7 +834,7 @@ def tfr_multitaper(inst, freqs, n_cycles, time_bandwidth=4.0,
832834
power : AverageTFR | EpochsTFR
833835
The averaged power.
834836
itc : AverageTFR | EpochsTFR
835-
The intertrial coherence (ITC). Only returned if return_itc
837+
The inter-trial coherence (ITC). Only returned if return_itc
836838
is True.
837839
838840
See Also
@@ -857,7 +859,7 @@ def ch_names(self):
857859
return self.info['ch_names']
858860

859861
def crop(self, tmin=None, tmax=None):
860-
"""Crop data to a given time interval
862+
"""Crop data to a given time interval in place
861863
862864
Parameters
863865
----------
@@ -914,7 +916,7 @@ def apply_baseline(self, baseline, mode='mean', verbose=None):
914916
class AverageTFR(_BaseTFR):
915917
"""Container for Time-Frequency data
916918
917-
Can for example store induced power at sensor level or intertrial
919+
Can for example store induced power at sensor level or inter-trial
918920
coherence.
919921
920922
Parameters
@@ -1114,7 +1116,7 @@ def _onselect(self, eclick, erelease, baseline, mode, layout):
11141116
fmax = min(self.freqs, key=lambda x: abs(x - fmax))
11151117
if tmin == tmax or fmin == fmax:
11161118
logger.info('The selected area is too small. '
1117-
'Select a larger time frequency window.')
1119+
'Select a larger time-frequency window.')
11181120
return
11191121

11201122
types = list()
@@ -1150,7 +1152,7 @@ def plot_topo(self, picks=None, baseline=None, mode='mean', tmin=None,
11501152
Parameters
11511153
----------
11521154
picks : array-like of int | None
1153-
The indices of the channels to plot. If None all available
1155+
The indices of the channels to plot. If None, all available
11541156
channels are displayed.
11551157
baseline : None (default) or tuple of length 2
11561158
The time interval to apply baseline correction.
@@ -1257,7 +1259,7 @@ def plot_topo(self, picks=None, baseline=None, mode='mean', tmin=None,
12571259
return fig
12581260

12591261
def _check_compat(self, tfr):
1260-
"""checks that self and tfr have the same time frequency ranges"""
1262+
"""checks that self and tfr have the same time-frequency ranges"""
12611263
assert np.all(tfr.times == self.times)
12621264
assert np.all(tfr.freqs == self.freqs)
12631265

@@ -1306,7 +1308,7 @@ def save(self, fname, overwrite=False):
13061308
class EpochsTFR(_BaseTFR):
13071309
"""Container for Time-Frequency data on epochs
13081310
1309-
Can for example store induced power at sensor level or intertrial
1311+
Can for example store induced power at sensor level or inter-trial
13101312
coherence.
13111313
13121314
Parameters
@@ -1603,7 +1605,7 @@ def read_tfrs(fname, condition=None):
16031605
if condition not in tfr_dict:
16041606
keys = ['%s' % k for k in tfr_dict]
16051607
raise ValueError('Cannot find condition ("{0}") in this file. '
1606-
'I can give you "{1}""'
1608+
'The file contains "{1}""'
16071609
.format(condition, " or ".join(keys)))
16081610
out = AverageTFR(**tfr_dict[condition])
16091611
else:

tutorials/plot_stats_cluster_1samp_test_time_frequency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
extent=[times[0], times[-1], frequencies[0], frequencies[-1]],
117117
aspect='auto', origin='lower', vmin=vmin, vmax=vmax)
118118
plt.colorbar()
119-
plt.xlabel('time (ms)')
119+
plt.xlabel('Time (ms)')
120120
plt.ylabel('Frequency (Hz)')
121121
plt.title('Induced power (%s)' % ch_name)
122122

tutorials/plot_stats_cluster_time_frequency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
extent=[times[0], times[-1], frequencies[0], frequencies[-1]],
126126
aspect='auto', origin='lower', cmap='RdBu_r')
127127

128-
plt.xlabel('time (ms)')
128+
plt.xlabel('Time (ms)')
129129
plt.ylabel('Frequency (Hz)')
130130
plt.title('Induced power (%s)' % ch_name)
131131

tutorials/plot_stats_cluster_time_frequency_repeated_measures_anova.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
times[-1], frequencies[0], frequencies[-1]], aspect='auto',
162162
origin='lower')
163163
plt.colorbar()
164-
plt.xlabel('time (ms)')
164+
plt.xlabel('Time (ms)')
165165
plt.ylabel('Frequency (Hz)')
166166
plt.title(r"Time-locked response for '%s' (%s)" % (effect_label, ch_name))
167167
plt.show()
@@ -210,7 +210,7 @@ def stat_fun(*args):
210210
plt.imshow(f_image, cmap=cmap, extent=[times[0], times[-1],
211211
frequencies[0], frequencies[-1]], aspect='auto',
212212
origin='lower')
213-
plt.xlabel('time (ms)')
213+
plt.xlabel('Time (ms)')
214214
plt.ylabel('Frequency (Hz)')
215215
plt.title("Time-locked response for 'modality by location' (%s)\n"
216216
" cluster-level corrected (p <= 0.05)" % ch_name)
@@ -228,7 +228,7 @@ def stat_fun(*args):
228228
frequencies[0], frequencies[-1]], aspect='auto',
229229
origin='lower')
230230

231-
plt.xlabel('time (ms)')
231+
plt.xlabel('Time (ms)')
232232
plt.ylabel('Frequency (Hz)')
233233
plt.title("Time-locked response for 'modality by location' (%s)\n"
234234
" FDR corrected (p <= 0.05)" % ch_name)

0 commit comments

Comments
 (0)