Hi All…
I am Risa, currently, I am trying to make a plot of TFR contrast between conditions. I want to perform 1 sample permutation t-test. However, I have difficulty adjusting the frequency for the y axes in the plot part. I expect to see a frequency of 3 to 34 with the linespace of 7. I tried to specify in the freqs variable. but the result, still only shows 10,20,30. I am confused how to deal with this.
here is the way I pursue
freqs = np.arange(3, 34, 7)
# run the TFR decomposition
tfr_epochs = tfr_morlet(
group_data_TFA_1,
freqs,
n_cycles=4.0,
decim=decim,
average=False,
return_itc=False)
# Run the analysis
T_obs, clusters, cluster_p_values, H0 = permutation_cluster_1samp_test(
epochs_power,
n_permutations=n_permutations,
tail=tail,
adjacency=adjacency,
out_type="mask",
verbose=True,
)
evoked_data = evoked.data
times = 1e3 * evoked.times
plt.figure()
plt.subplots_adjust(0.12, 0.08, 0.96, 0.94, 0.2, 0.43)
T_obs_plot = np.nan * np.ones_like(T_obs)
for c, p_val in zip(clusters, cluster_p_values):
if p_val <= 0.05:
T_obs_plot[c] = T_obs[c]
# Just plot one channel's data
# use the following to show a specific one:
# ch_idx = tfr_epochs.ch_names.index('MEG 1332')
ch_idx, f_idx, t_idx = np.unravel_index(
np.nanargmax(np.abs(T_obs_plot)), epochs_power.shape[1:]
)
vmax = np.max(np.abs(T_obs))
vmin = -vmax
plt.subplot(2, 1, 1)
plt.imshow(
T_obs[ch_idx],
cmap=plt.cm.gray,
extent=[times[0], times[-1], freqs[0], freqs[-1]],
aspect="auto",
origin="lower",
vmin=vmin,
vmax=vmax,
)
plt.imshow(
T_obs_plot[ch_idx],
cmap=plt.cm.RdBu_r,
extent=[times[0], times[-1], freqs[0], freqs[-1]],
aspect="auto",
origin="lower",
vmin=vmin,
vmax=vmax,
)
plt.colorbar()
plt.xlabel("Time (ms)")
plt.ylabel("Frequency (Hz)")
plt.title(f"Induced power ({tfr_epochs.ch_names[ch_idx]})")
I started to play with the extent parameter. but it just count for first and last length of y frequency. How should I do?