def individual_plot(ax, info_idx, names_idx): """ """ ch_name = ch_names[names_idx] for color_idx, (key, psd) in enumerate(sorted(data.items())): if log_transformed: curve = 10 * np.log10(psd[names_idx]) else: curve = psd[names_idx] ax.plot(freqs, curve, color=colors[color_idx], label=key) title = ' '.join([name, ch_name]) ax.figure.canvas.set_window_title(title.replace(' ', '_')) ax.figure.suptitle(title) ax.set_title('') ax.legend() ax.set_xlabel('Frequency (Hz)') ax.set_ylabel('Power ({})'.format( get_power_unit(mne.io.pick.channel_type(info, info_idx), log_transformed))) plt.show()
def individual_plot(ax, info_idx, names_idx): """ """ ch_name = ch_names[names_idx] title = ' '.join([tfr_name, ch_name]) ax.figure.canvas.set_window_title(title.replace(' ', '_')) ax.figure.suptitle(title) ax.set_title('') for color_idx, (key, tse) in enumerate(sorted(tses.items())): times, tse = _crop_and_correct_to_baseline(tse, blmode, blstart, blend, tmin, tmax, meggie_tfr.times) ax.plot(times, tse[names_idx], color=colors[color_idx], label=key) ax.axhline(0, color='black') ax.axvline(0, color='black') ax.legend() ax.set_xlabel('Time (s)') ax.set_ylabel('Power ({})'.format( get_power_unit(mne.io.pick.channel_type(info, info_idx), False))) plt.show()
def plot_spectrum_averages(experiment, name, log_transformed=True): """ """ subject = experiment.active_subject subject_name = subject.name spectrum = subject.spectrum.get(name) data = spectrum.content freqs = spectrum.freqs ch_names = spectrum.ch_names channel_groups = experiment.channel_groups info = subject.get_raw().info colors = color_cycle(len(data)) logging.getLogger('ui_logger').info('Plotting spectrum channel averages..') averages = {} for idx, (key, psd) in enumerate(data.items()): data_labels, averaged_data = average_to_channel_groups( psd, info, ch_names, channel_groups) if not data_labels: raise Exception('No channel groups matching the data found.') averages[key] = data_labels, averaged_data shape = averaged_data.shape for ii in range(shape[0]): fig, ax = plt.subplots() for color_idx, key in enumerate(averages.keys()): ax.set_xlabel('Frequency (Hz)') ax.set_ylabel('Power ({})'.format( get_power_unit(averages[key][0][ii][0], log_transformed))) if log_transformed: curve = 10 * np.log10(averages[key][1][ii]) else: curve = averages[key][1][ii] ax.plot(freqs, curve, color=colors[color_idx], label=key) ax.legend() ch_type, ch_group = averages[key][0][ii] title = 'spectrum_{0}_{1}_{2}'.format(name, ch_type, ch_group) fig.canvas.set_window_title(title) fig.suptitle(title) plt.show()
def plot_fun(ax_idx, ax): ch_group = ch_groups[ax_idx] ax.set_title(ch_group) ax.set_xlabel('Time (s)') ax.set_ylabel('Power ({})'.format(get_power_unit(ch_type, False))) for color_idx, (key, times, curve) in enumerate(averages[(ch_type, ch_group)]): ax.plot(times, curve, color=colors[color_idx], label=key) ax.axhline(0, color='black') ax.axvline(0, color='black')
def plot_fun(ax_idx, ax): ch_group = ch_groups[ax_idx] ax.set_title(ch_group) ax.set_xlabel('Frequency (Hz)') ax.set_ylabel('Power ({})'.format( get_power_unit(ch_type, log_transformed))) for color_idx, (key, curve) in enumerate(averages[(ch_type, ch_group)]): if log_transformed: curve = 10 * np.log10(curve) ax.plot(freqs, curve, color=colors[color_idx])
def plot_tse_averages(experiment, subject, tfr_name, blmode, blstart, blend, tmin, tmax, fmin, fmax): """ """ meggie_tfr = subject.tfr.get(tfr_name) times, tses = _compute_tse(meggie_tfr, fmin, fmax, tmin, tmax, blmode, blstart, blend) ch_names = meggie_tfr.ch_names info = meggie_tfr.info colors = color_cycle(len(tses)) channel_groups = experiment.channel_groups logging.getLogger('ui_logger').info('Plotting TSE channel averages..') averages = {} for idx, (key, tse) in enumerate(tses.items()): data_labels, averaged_data = average_to_channel_groups( tse, info, ch_names, channel_groups) if not data_labels: raise Exception('No channel groups matching the data found.') averages[key] = data_labels, averaged_data shape = averaged_data.shape for ii in range(shape[0]): fig, ax = plt.subplots() for color_idx, key in enumerate(averages.keys()): ax.set_xlabel('Time (s)') ax.set_ylabel('Power ({})'.format( get_power_unit(averages[key][0][ii][0], False))) ax.plot(times, averages[key][1][ii], color=colors[color_idx], label=key) ax.axhline(0) ax.legend() ch_type, ch_group = averages[key][0][ii] title = 'TSE_{0}_{1}_{2}'.format(tfr_name, ch_type, ch_group) fig.canvas.set_window_title(title) fig.suptitle(title) plt.show()
def individual_plot(ax, info_idx, names_idx): """ """ ch_name = ch_names[names_idx] title = 'TSE_{0}_{1}'.format(tfr_name, ch_name) ax.figure.canvas.set_window_title(title) ax.figure.suptitle(title) ax.set_title('') for color_idx, (key, tse) in enumerate(tses.items()): ax.plot(times, tse[names_idx], color=colors[color_idx], label=key) ax.axhline(0) ax.axvline(0) ax.legend() ax.set_xlabel('Time (s)') ax.set_ylabel('Power ({})'.format( get_power_unit(mne.io.pick.channel_type(info, info_idx), False))) plt.show()