# decoding with unbalance design

**URL:** <https://mne.discourse.group/t/decoding-with-unbalance-design/3858>\
**Category:** Support & Discussions\
**Tags:** eeg, machine-learning, epochs\
**Created:** [October 26, 2021, 9:45am UTC](https://mne.discourse.group/t/decoding-with-unbalance-design/3858 "2021-10-26T09:45:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![weixing10423](https://avatars.discourse-cdn.com/v4/letter/w/f04885/32.png) [@weixing10423](https://mne.discourse.group/u/weixing10423)\
**Post date:** [October 26, 2021, 9:45am UTC](https://mne.discourse.group/t/decoding-with-unbalance-design/3858/1 "2021-10-26T09:45:21Z")

</div>

Hi all, I have recently started learning how to decode using mne. Suppose my experiment has two conditions and 150 trials. Participants need to evaluate whether they feel the “AHA” during the each trial. I know that each participant needs to ensure that the number of times they feel “aha” is the same as the number of times they do not feel “aha” for decoding analysis. Is it necessary to ensure that all participants have the same number of “aha” when conducting the analysis?

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [October 26, 2021, 11:24am UTC](https://mne.discourse.group/t/decoding-with-unbalance-design/3858/2 "2021-10-26T11:24:55Z")

</div>

Hello @weixing10423 and welcome to the forum!

> [@weixing10423](#):
>
> I know that each participant needs to ensure that the number of times they feel “aha” is the same as the number of times they do not feel “aha” for decoding analysis. Is it necessary to ensure that all participants have the same number of “aha” when conducting the analysis?

You don’t need to have perfectly balanced classes (neither within, nor between participants) if the calculated performance score is the area under the ROC curve (“ROC AUC”). You can achieve this e.g. during time-by-time decoding by passing `scoring='roc_auc'` to the `SlidingEstimator`, as demonstrated in this tutorial example:

[https://mne.tools/stable/auto\_tutorials/machine-learning/50\_decoding.html#decoding-over-time](https://mne.tools/stable/auto_tutorials/machine-learning/50_decoding.html#decoding-over-time)

Best wishes,

Richard

---

<div class="post-metadata">

**Author:** ![weixing10423](https://avatars.discourse-cdn.com/v4/letter/w/f04885/32.png) [@weixing10423](https://mne.discourse.group/u/weixing10423)\
**Post date:** [October 26, 2021, 11:41am UTC](https://mne.discourse.group/t/decoding-with-unbalance-design/3858/3 "2021-10-26T11:41:03Z")

</div>

(post deleted by author)

---

<div class="post-metadata">

**Author:** ![weixing10423](https://avatars.discourse-cdn.com/v4/letter/w/f04885/32.png) [@weixing10423](https://mne.discourse.group/u/weixing10423)\
**Post date:** [October 26, 2021, 11:41am UTC](https://mne.discourse.group/t/decoding-with-unbalance-design/3858/4 "2021-10-26T11:41:52Z")

</div>

Thank you very much for your reply, I was curious if the results would be affected if each participant had a different number of trials. At the same time, I was confused about how to do the group-analysis, and the tutorials all seemed to be for one participant.  
Best wishes，  
wx

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [October 26, 2021, 11:44am UTC](https://mne.discourse.group/t/decoding-with-unbalance-design/3858/5 "2021-10-26T11:44:40Z")

</div>

> [@weixing10423](#):
>
> I was curious if the results would be affected if each participant had a different number of trials.

No, this should not be the case unless the number of trials is very small.

> [@weixing10423](#):
>
> At the same time, I was confused about how to do the group-analysis

I usually follow the common 2-level approach here: first, get some statistics for each individual participant, and then use these stats to perform a group analysis.

So: You first run decoding on each participant individually. To get the “group performance”, you can average the individual scores. In the same manner, you can also get the spread (e.g., SD or CI) for your group.

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![weixing10423](https://avatars.discourse-cdn.com/v4/letter/w/f04885/32.png) [@weixing10423](https://mne.discourse.group/u/weixing10423)\
**Post date:** [October 26, 2021, 12:35pm UTC](https://mne.discourse.group/t/decoding-with-unbalance-design/3858/7 "2021-10-26T12:35:40Z")

</div>

Thank you very much for your kind help, it has helped me a lot!  
Best wishes，  
wx
