# task-related component analysis

**URL:** <https://mne.discourse.group/t/task-related-component-analysis/4329>\
**Category:** Support & Discussions\
**Created:** [January 29, 2022, 9:24am UTC](https://mne.discourse.group/t/task-related-component-analysis/4329 "2022-01-29T09:24:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kirito](https://avatars.discourse-cdn.com/v4/letter/k/4491bb/32.png) [@Kirito](https://mne.discourse.group/u/Kirito)\
**Post date:** [January 29, 2022, 9:24am UTC](https://mne.discourse.group/t/task-related-component-analysis/4329/1 "2022-01-29T09:24:04Z")

</div>

MNE-Python version:0.23.4  
operating system:windows10

Hi,I want to average the data from all channels. But I only find the function that directly draws the picture.  
code:  
mne.viz.plot\_compare\_evokeds(evokeds=evoked, combine=‘mean’)  
Is there any other way to directly get the average processed data of all channels?  
Much appreciated

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [January 30, 2022, 9:51am UTC](https://mne.discourse.group/t/task-related-component-analysis/4329/2 "2022-01-30T09:51:23Z")

</div>

Once you have your [`mne.Epochs`](https://mne.tools/stable/generated/mne.Epochs.html) instance, e.g. `epochs`, you can create the evoked response with `epochs.average()`. This average method creates an [`mne.Evoked`](https://mne.tools/stable/generated/mne.Evoked.html) instance that contains the data averaged by channel.

More information on this tutorial: [The Evoked data structure: evoked/averaged data — MNE 0.24.1 documentation](https://mne.tools/stable/auto_tutorials/evoked/10_evoked_overview.html#sphx-glr-auto-tutorials-evoked-10-evoked-overview-py)

---

<div class="post-metadata">

**Author:** ![Kirito](https://avatars.discourse-cdn.com/v4/letter/k/4491bb/32.png) [@Kirito](https://mne.discourse.group/u/Kirito)\
**Post date:** [February 2, 2022, 12:29pm UTC](https://mne.discourse.group/t/task-related-component-analysis/4329/3 "2022-02-02T12:29:07Z")

</div>

Sorry, I meant to merge data from all channels together. Just like doing TRCA operation on SSVEP data

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [February 2, 2022, 12:39pm UTC](https://mne.discourse.group/t/task-related-component-analysis/4329/4 "2022-02-02T12:39:45Z")

</div>

Oh my bad! I misread the first post.  
I don’t think there is any built-in solution in MNE. You can retrieve the underlying data array with `.get_data()` and then compute the mean across the channel dimension with numpy.

---

<div class="post-metadata">

**Author:** ![mmagnuski](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mmagnuski/32/153_2.png) [@mmagnuski](https://mne.discourse.group/u/mmagnuski)\
**Post date:** [February 4, 2022, 10:27am UTC](https://mne.discourse.group/t/task-related-component-analysis/4329/5 "2022-02-04T10:27:44Z")

</div>

Just to develop on the response of @mscheltienne (assuming your Evoked data are ready and stored in `erp` variable):

```python
erp_chan_avg = erp.data.mean(axis=0)

```

this gives you an array of channel-averages in time. If you want to perform the averaging only on a subset of channels you can use `.pick_channels()` before the command above, for example:

```python
erp.pick_channels(['O1', 'Oz', 'O2'])

```
