# Pass condition from Epoch to Evoked structure by adding .condition attribute to Evoked?

**URL:** <https://mne.discourse.group/t/pass-condition-from-epoch-to-evoked-structure-by-adding-condition-attribute-to-evoked/11343>\
**Category:** Support & Discussions\
**Tags:** feature-request, evoked, epochs\
**Created:** [July 4, 2025, 3:20am UTC](https://mne.discourse.group/t/pass-condition-from-epoch-to-evoked-structure-by-adding-condition-attribute-to-evoked/11343 "2025-07-04T03:20:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdbenning](https://avatars.discourse-cdn.com/v4/letter/s/8dc957/32.png) [@sdbenning](https://mne.discourse.group/u/sdbenning)\
**Post date:** [July 4, 2025, 3:20am UTC](https://mne.discourse.group/t/pass-condition-from-epoch-to-evoked-structure-by-adding-condition-attribute-to-evoked/11343/1 "2025-07-04T03:20:42Z")

</div>

As I’ve been working to plot and score Evoked objects in MNE version 1.9.0, I’ve run across a labeling issue. Currently, the .comment attribute yields a very long description of how each Evoked object was created from weighted proportions of events. However, the Evoked object does not retain the .condition attribute of the Epoched data from which the Evoked object was generated, which makes it challenging to remember what .

```python
# Set dictionary of trigger numbers: CasE SenSItiVe!
# Responses only
event_dict = { 'Response/Alone/AF/Lower/Yellow/Incorrect': 201,
                'Response/Alone/AF/Lower/Yellow/Correct': 202,
                'Response/Alone/AF/Lower/Blue/Incorrect': 203,
                'Response/Alone/AF/Lower/Blue/Correct': 204,
                'Response/Alone/AF/Upper/Yellow/Incorrect': 206,
                'Response/Alone/AF/Upper/Yellow/Correct': 207, 
                'Response/Alone/AF/Upper/Blue/Incorrect': 208,
                'Response/Alone/AF/Upper/Blue/Correct': 209,

                'Response/Alone/TF/Lower/Yellow/Incorrect': 211,
                'Response/Alone/TF/Lower/Yellow/Correct': 212,
                'Response/Alone/TF/Lower/Blue/Incorrect': 213,
                'Response/Alone/TF/Lower/Blue/Correct': 214,
                'Response/Alone/TF/Upper/Yellow/Incorrect': 216,
                'Response/Alone/TF/Upper/Yellow/Correct': 217, 
                'Response/Alone/TF/Upper/Blue/Incorrect': 218,
                'Response/Alone/TF/Upper/Blue/Correct': 219,

                'Response/Friend/AF/Lower/Yellow/Incorrect': 221,
                'Response/Friend/AF/Lower/Yellow/Correct': 222,
                'Response/Friend/AF/Lower/Blue/Incorrect': 223,
                'Response/Friend/AF/Lower/Blue/Correct': 224,
                'Response/Friend/AF/Upper/Yellow/Incorrect': 226,
                'Response/Friend/AF/Upper/Yellow/Correct': 227, 
                'Response/Friend/AF/Upper/Blue/Incorrect': 228,
                'Response/Friend/AF/Upper/Blue/Correct': 229,

                'Response/Friend/TF/Lower/Yellow/Incorrect': 231,
                'Response/Friend/TF/Lower/Yellow/Correct': 232,
                'Response/Friend/TF/Lower/Blue/Incorrect': 233,
                'Response/Friend/TF/Lower/Blue/Correct': 234,
                'Response/Friend/TF/Upper/Yellow/Incorrect': 236,
                'Response/Friend/TF/Upper/Yellow/Correct': 237, 
                'Response/Friend/TF/Upper/Blue/Incorrect': 238,
                'Response/Friend/TF/Upper/Blue/Correct': 239}

# List of all possible combinations of experiment conditions for which
# average waveforms are desired
evoked_dict = ['Incorrect', 'Correct']

```

After creating a series of epochs using the above `event_dict` as the input to events\_from\_annotations, I seek to create a list of Evoked objects that has my original, human-readable condition labels of ‘Incorrect’ and ‘Correct’. I know that MNE doesn’t do that natively, so I tried writing a bit of code to accomplish that.

```python
# Create evoked dataset to average all relevant epochs together 
evokeds = [epochs[name].average() for name in evoked_dict]

# Put condition into each average within evokeds
for evoked in range(len(evokeds)):
    evokeds[evoked].condition = evoked_dict[evoked]
                
    # Save evoked data
    mne.write_evokeds(processedPath + outPrefix + sNumber + outSuffix + "-ave.fif", evokeds, overwrite=True)

```

I saw in [mne-python/mne/evoked.py at maint/1.9 · mne-tools/mne-python · GitHub](https://github.com/mne-tools/mne-python/blob/maint/1.9/mne/evoked.py#L2033-L2035) that the reason my .condition attribute wasn’t saved is because \_write\_evokeds has no method of including a separately written .condition, as is done for .comment in lines 2033-2035. However, I couldn’t figure out quite how event\_id.keys was parsed to generate the comment in [mne-python/mne/epochs.py at maint/1.9 · mne-tools/mne-python · GitHub](https://github.com/mne-tools/mne-python/blob/maint/1.9/mne/epochs.py#L1108-1117) until I looked at [mne-python/mne/epochs.py at maint/1.9 · mne-tools/mne-python · GitHub](https://github.com/mne-tools/mne-python/blob/maint/1.9/mne/epochs.py#L1206-1245) lines 1206-1245.

I wonder if \_get\_name could be altered so that above line 1225 would be a new line

```python
condition = next(iter(self.event_id.keys()))

```

to match how comment is generated with only one matching event, with that line also pasted above line 1244, and line 1245 altered to read

```python
return condition, comment

```

Alas, I know nothing of github to even try making this work. I also don’t know if that would represent a fundamental change to the Evoked data structure that would cause more problems than I anticipate.
