From 6b5c0cb89672a252fda0e3851c90656b34ab910f Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Thu, 4 Jan 2024 17:34:54 -0600 Subject: [PATCH] move copy to base class, fix docstrings, work on iter_evoked --- mne/time_frequency/spectrogram.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/mne/time_frequency/spectrogram.py b/mne/time_frequency/spectrogram.py index 844ab50b411..25ef69b01e1 100644 --- a/mne/time_frequency/spectrogram.py +++ b/mne/time_frequency/spectrogram.py @@ -392,7 +392,7 @@ def apply_baseline(self, baseline, mode, verbose): Returns ------- - inst : instance of AverageTFR + inst : instance of RawTFR, EpochsTFR, or AverageTFR The modified instance. """ self.baseline = _check_baseline( @@ -401,6 +401,16 @@ def apply_baseline(self, baseline, mode, verbose): rescale(self.data, self.times, self.baseline, mode, copy=False) return self + def copy(self): + """Return copy of the TFR instance. + + Returns + ------- + inst : instance of RawTFR, EpochsTFR, or AverageTFR + A copy of the object. + """ + return deepcopy(self) + def crop(self, tmin=None, tmax=None, fmin=None, fmax=None, include_tmax=True): """Crop data to a given time interval in place. @@ -422,7 +432,7 @@ def crop(self, tmin=None, tmax=None, fmin=None, fmax=None, include_tmax=True): Returns ------- - inst : instance of AverageTFR + inst : instance of RawTFR, EpochsTFR, or AverageTFR The modified instance. """ super().crop(tmin=tmin, tmax=tmax, include_tmax=include_tmax) @@ -928,16 +938,6 @@ def _get_instance_data(self, reject_by_annotation): # prepend a singleton "epochs" axis return data[np.newaxis] - def copy(self): - """Return copy of the RawTFR instance. - - Returns - ------- - RawTFR : instance of RawTFR - A copy of the object. - """ - return deepcopy(self) - class EpochsTFR(BaseTFR, GetEpochsMixin): """Data object for spectrotemporal representations of epoched data. @@ -1125,14 +1125,14 @@ def iter_evoked(self, copy=False): while True: try: data = self.__next__() - except StopIteration: + except StopIteration: # TODO this is never raised break if copy: state["info"] = deepcopy(self.info) state["data"] = data.copy() else: state["data"] = data - yield AverageTFR(state) + yield AverageTFR(state, method=None, freqs=None) def plot(self): """Plot EpochsTFR as a 2D image.""" @@ -1226,9 +1226,6 @@ def __init__( **method_kw, ) - # TODO are there other properties of `inst` we should propagate here? - self._nave = inst.nave - @property def nave(self): return self._nave