Plotting a spectrogram for baseline-corrected data

To follow up on this… I plan on applying baseline correction to a hilbert transformed data.

  1. Apply hilbert transform
hilbert_raw=raw_tmp.apply_hilbert()
  1. Epoch the data
epochs = mne.Epochs(raw=hilbert_raw, events=events, tmin=-2.0, tmax=1.0, event_id=event_dict,
                    baseline=None, preload=True)
  1. Average the epochs as I want to apply baseline correction to averaged data
epochs_averaged = epochs.average()
epochs_baseline_corrected=epochs_averaged.apply_function(fun=mne.baseline.rescale,times=epochs.times,baseline=(-2.0, 0),mode='zscore')
  1. I need to plot a spectrogram for this baseline corrected data. The matplotlib library uses this function pcolormesh – how do I extract frequencies (n_freqs) to be used for pcolormesh? For the hilbert transform function, I dont see any returns as n_freqs (unlike pwelch ).
plt.pcolormesh(times, freq, data, shading='auto')
plt.rcParams['pcolor.shading'] ='nearest'
plt.ylabel('Frequency [Hz]')
plt.xlabel('Time [sec]')
plt.pcolormesh(times,freq,data)

@apoorva6262 I moved this to a new topic. Please always start new topics for new questions. Thanks!

1 Like

what do you mean the freqs of the hilbert transform?

to have frequency based hilbert you would need to filter your data in frequency bands and then apply hilbert to all of these filtered data.

Alex