Added the plotting option for log-scaling of the tf spectrum

This commit is contained in:
2021-03-29 16:25:38 +02:00
parent c6a6fd7012
commit d09480c5bb
2 changed files with 17 additions and 6 deletions

View File

@@ -56,7 +56,7 @@ def plot_grand_average(dataset):
linestyles=['solid', 'solid', 'dotted', 'dotted'])
def plot_tf_cluster(F, clusters, cluster_p_values, freqs, times):
def plot_tf_cluster(F, clusters, cluster_p_values, freqs, times, scaling='lin'):
"""
Plot the F-Statistic values of permutation clusters with p-values <= 0.05 in color and > 0.05 in grey.
Currently only works well for the linear scaling. For the logarithmic scaling a different x-axis has to be chosen
@@ -66,6 +66,7 @@ def plot_tf_cluster(F, clusters, cluster_p_values, freqs, times):
:param cluster_p_values: p-values of the clusters
:param freqs: frequency domain
:param times: time domain
:param scaling: default 'lin' for linear scaling, else can be 'log' for logarithmic scaling
"""
good_c = np.nan * np.ones_like(F)
for clu, p_val in zip(clusters, cluster_p_values):
@@ -75,12 +76,19 @@ def plot_tf_cluster(F, clusters, cluster_p_values, freqs, times):
bbox = [times[0], times[-1], freqs[0], freqs[-1]]
plt.imshow(F, aspect='auto', origin='lower', cmap=cm.gray, extent=bbox, interpolation='None')
a = plt.imshow(good_c, cmap=cm.RdBu_r, aspect='auto', origin='lower', extent=bbox, interpolation='None')
if scaling == 'log':
ticks = [1, 4, 8, 12, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50]
labels = [round(freqs[i], 2) for i in range(len(freqs)) if i + 1 in ticks]
plt.yticks(ticks, labels)
plt.colorbar(a)
plt.xlabel('Time (s)')
plt.ylabel('Frequency (Hz)')
plt.show()
def plot_oscillation_bands(condition):
"""
Plot the oscillation bands for a given condition in the time from 130ms to 200ms