apply baseline with variable interval over trials

Dear list,
I have a problem resulting from varying trial durations.
I would like to baseline correct my epochs with an event that is different
from the one I used for time-locking the epochs. The epochs are time-locked
to a target event which is preceded by a cue event with a variable SOA. The
baseline should be taken from before the cue.

I could think of two ways to do this, but neither of them seemed to work:
a) epoch to cue, apply baseline, re-epoch to target event
(mne.epoch wants raw data)
b) epoch to target, apply baseline with different interval for each trial
(epochs.apply_baseline takes only two time points)

Do you have any hints on how to achieve this other than subtracting the
mean of the desired baseline-interval by hand? Could the apply_baseline
function be extended to take another event to use for the baseline?

Thank you,
Sophie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180328/b4f14971/attachment.html

hi Sophie,

I am afraid you will have to do this by hand with numpy by modifying
the epochs._data attribute.

let us know if you need help. You will need to use the selection attribute
of Epochs to make sure you subtract the correct epoch.

Best,
Alex