Hi
As the title descripted, I want to apply the regression-based baseline correction on multi-channels, but the tutorials only show how to use it on one channel. When I copy the code (I changed the variables), the results reported a wrong message.
My code showed as follows:
sha_predictor = epochs.events[:, 2] == epochs.event_id[“shape-s”]
for_predictor = epochs.events[:, 2] == epochs.event_id[“form-s”]
baseline_predictor = (
epochs.copy()
.crop(*baseline)
.pick_channels([‘FP1’, ‘FP2’, ‘F7’, ‘F3’, ‘FZ’, ‘F4’, ‘F8’, ‘T7’, ‘C3’, ‘CZ’, ‘C4’, ‘T8’, ‘M1’, ‘P7’, ‘P3’, ‘PZ’, ‘P4’, ‘P8’, ‘M2’, ‘O1’, ‘O2’, ‘TP8’, ‘TP7’, ‘OZ’, ‘CP4’, ‘FC3’, ‘FT8’, ‘CP3’, ‘FT7’, ‘CPZ’, ‘FC4’, ‘FCZ’])
.get_data() # convert to NumPy array
.mean(axis=-1) # average across timepoints
)
baseline_predictor *= 1e6 # convert V → μV
design_matrix = np.vstack(
[
sha_predictor,
for_predictor,
baseline_predictor,
baseline_predictor * for_predictor,
]
).T
The error message was: “ValueError: operands could not be broadcast together with shapes (280,32) (280,)”
How could I change the code to let it work?
Thanks
------------------------------------------The End line---------------------------------------------------
- MNE version: 1.6.0
- operating system: Windows 10