Added the plotting option for log-scaling of the tf spectrum
This commit is contained in:
@@ -183,7 +183,7 @@ def create_tfr(raw, condition, freqs, n_cycles, response='induced', baseline=Non
|
||||
return power
|
||||
|
||||
|
||||
def time_frequency(dataset, filename, compute_tfr=True):
|
||||
def time_frequency(dataset, filename, scaling='lin', compute_tfr=True):
|
||||
"""
|
||||
Runs time frequency analysis
|
||||
|
||||
@@ -191,10 +191,13 @@ def time_frequency(dataset, filename, compute_tfr=True):
|
||||
:param filename: Filename of either the file from which the TFRs will be loaded
|
||||
or to which they will be saved
|
||||
:param compute_tfr: If True the TFRs will be created, else the TFRs will be loaded from a precomputed file
|
||||
:param scaling: default 'lin' for linear scaling, else can be 'log' for logarithmic scaling
|
||||
"""
|
||||
# Parameters
|
||||
# freqs = np.linspace(0.1, 50, num=50) # Use this for linear space scaling
|
||||
freqs = np.logspace(*np.log10([0.1, 50]), num=50)
|
||||
if scaling == 'lin':
|
||||
freqs = np.linspace(0.1, 50, num=50) # Use this for linear space scaling
|
||||
else:
|
||||
freqs = np.logspace(*np.log10([0.1, 50]), num=50)
|
||||
n_cycles = freqs / 2
|
||||
cond1 = []
|
||||
cond2 = []
|
||||
@@ -245,11 +248,11 @@ def time_frequency(dataset, filename, compute_tfr=True):
|
||||
F, clusters, cluster_p_values, h0 = mne.stats.permutation_cluster_test(
|
||||
[mne.grand_average(cond1).data, mne.grand_average(cond2).data], n_jobs=4, verbose='INFO',
|
||||
seed=123)
|
||||
plot_tf_cluster(F, clusters, cluster_p_values, freqs, times)
|
||||
plot_tf_cluster(F, clusters, cluster_p_values, freqs, times, scaling)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
mne.set_log_level(verbose=VERBOSE_LEVEL)
|
||||
ds = 'N170'
|
||||
decoding(ds, 'faces_vs_cars', True)
|
||||
time_frequency(ds, 'face_intact_vs_all_0.1_50hz_ncf2', True)
|
||||
time_frequency(ds, 'face_intact_vs_all_0.1_50hz_ncf2', 'log', False)
|
||||
|
||||
Reference in New Issue
Block a user