@@ -423,6 +423,31 @@ def metadata(self, metadata, verbose=None):
423423 self ._metadata = metadata
424424
425425
426+ def _check_decim (info , decim , offset , check_filter = True ):
427+ """Check decimation parameters."""
428+ if decim < 1 or decim != int (decim ):
429+ raise ValueError ('decim must be an integer > 0' )
430+ decim = int (decim )
431+ new_sfreq = info ['sfreq' ] / float (decim )
432+ offset = int (offset )
433+ if not 0 <= offset < decim :
434+ raise ValueError ('decim must be at least 0 and less than %s, got '
435+ '%s' % (decim , offset ))
436+ if check_filter :
437+ lowpass = info ['lowpass' ]
438+ if decim > 1 and lowpass is None :
439+ warn ('The measurement information indicates data is not low-pass '
440+ 'filtered. The decim=%i parameter will result in a sampling '
441+ 'frequency of %g Hz, which can cause aliasing artifacts.'
442+ % (decim , new_sfreq ))
443+ elif decim > 1 and new_sfreq < 3 * lowpass :
444+ warn ('The measurement information indicates a low-pass frequency '
445+ 'of %g Hz. The decim=%i parameter will result in a sampling '
446+ 'frequency of %g Hz, which can cause aliasing artifacts.'
447+ % (lowpass , decim , new_sfreq )) # > 50% nyquist lim
448+ return decim , offset , new_sfreq
449+
450+
426451class EpochsTimesMixin (object ):
427452 """Class to handle times, tmin, tmax and decimation for epochs."""
428453
@@ -481,8 +506,11 @@ def decimate(self, decim, offset=0, verbose=None):
481506 ----------
482507 .. footbibliography::
483508 """
484- from ..evoked import _check_decim
485- decim , offset , new_sfreq = _check_decim (self .info , decim , offset )
509+ # if epochs have frequencies, they are not in time (EpochsTFR)
510+ # and so do not need to be checked whether they have been
511+ # appropriately filtered to avoid aliasing
512+ decim , offset , new_sfreq = _check_decim (
513+ self .info , decim , offset , check_filter = hasattr (self , 'freqs' ))
486514 start_idx = int (round (- self ._raw_times [0 ] * (self .info ['sfreq' ] *
487515 self ._decim )))
488516 self ._decim *= decim
0 commit comments