Skip to content

Additional functions to take the "average" of EpochsTFR? #8878

Closed

Description

@adam2392

Describe the new feature or enhancement

In https://mne.tools/stable/generated/mne.time_frequency.EpochsTFR.html#mne.time_frequency.EpochsTFR.average one can currently compute the average of the TFR over all Epochs. This simply calls the numpy.mean function.

Would it be possible to add additional combination possibilities, such as np.median, np.percentile, such that average(func) is now possible, with the list of funcs being possible are numpy functions that operate along the epochs axis.

Describe possible alternatives

One can always compute this themselves, I suppose, but then they lose access to AverageTFR api functionality.

Activity

  1. agramfort commented on Feb 16, 2021

    @agramfort
    SponsorMember
  2. adam2392 commented on Feb 16, 2021

    @adam2392
    MemberAuthor

    I can then adjust these lines accordingly?

    def average(self):
    """Average the data across epochs.
    Returns
    -------
    ave : instance of AverageTFR
    The averaged data.
    """
    data = np.mean(self.data, axis=0)
    return AverageTFR(info=self.info.copy(), data=data,
    times=self.times.copy(), freqs=self.freqs.copy(),
    nave=self.data.shape[0], method=self.method,
    comment=self.comment)

    • Should I keep the average() function name as is and just allow optional kwarg func?

    • Should I also specify how the "average" was taken in the AverageTFR.comments? So if I use np.median instead of np.mean, i'll pass in AverageTFR(..., comments=self.comment + ' - took average via np.median')?

  3. agramfort commented on Feb 16, 2021

    @agramfort
    SponsorMember
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions