Skip to content

Commit

Permalink
move copy to base class, fix docstrings, work on iter_evoked
Browse files Browse the repository at this point in the history
  • Loading branch information
drammock committed Jan 4, 2024
1 parent 8846e81 commit 6b5c0cb
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions mne/time_frequency/spectrogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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.
Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6b5c0cb

Please sign in to comment.