Is this still not possible?
i.e. is the solution still through Epochs.apply_function() ?
If so, is there any tutorial/guidance for this I can find in the documentation?
just posting an update here (with a follow up question for @drammock):
I have use the Epochs.apply_function() to create a baseline, but I am getting an error because the dimensions donβt match. The exact error is "ValueError: operands could not be broadcast together with shapes (827,44,548) (44,) "
creating and applying the baseline (to epoched data)
baseline = raw_rest.get_data().mean(axis=-1) # get avg value in each channel;
epochs.apply_function(lambda x: x - baseline, channel_wise=False)
But this gives the value error I added above.
I found a fix online, but I am not sure if itβs a good solution. If I apply this, I am just left with a flat line. I have added it, just in case it is a solution but Iβve made a mistake somewhere. The resulting graph is below.
Suggested fix:
(old line) baseline = raw_rest.get_data().mean(axis=-1) # get avg value in each channel;
Looks like you have 827 epochs, 44 channels, and 548 time points. to subtract an array with shape (44,) you need to add an extra empty time axis so that the baseline has shape (44, 1). The suggestion you found online should work but is more complicated than necessary. There are two simpler ways that come to mind:
baseline = raw_rest.get_data().mean(axis=-1, keepdims=True) This will avoid collapsing the time dimension entirely, resulting shape is (44,1)
baseline = raw_rest.get_data().mean(axis=-1) followed by baseline = baseline[:, np.newaxis] (this has the identical result to option 1)