FigureExporter
Namespace: DISPLIB · Library: Display Library · Source: disp/plots/helpers/figureexporter.h
#include <disp/figureexporter.h>
class DISPLIB::FigureExporter
Writes captioned figures to MNE_CPP_FIGURE_DIR.
// Written only when MNE_CPP_FIGURE_DIR names a directory
FigureExporter::save(line, "line_plot", "LinePlot: one period of a sine wave.");
Static Methods
directory()
Returns the directory figures are written to.
Returns:
- QString — The value of
MNE_CPP_FIGURE_DIR, or an empty string when figures are not written.
save(widget, name, caption, size)
Renders widget offscreen at size and writes it as the next figure.
Parameters:
-
widget : QWidget & The widget to render; it is resized and never shown on screen.
-
name : const QString & File name stem; characters other than letters, digits, '-' and '' become ''.
-
caption : const QString & Caption shown below the figure.
-
size : const QSize & Logical size of the figure in pixels.
Returns:
- QString — The path of the written PNG, or an empty string when figures are not written or writing failed.
save(image, name, caption)
Writes image as the next figure.
Parameters:
-
image : const QImage & The figure.
-
name : const QString & File name stem; characters other than letters, digits, '-' and '' become ''.
-
caption : const QString & Caption shown below the figure.
Returns:
- QString — The path of the written PNG, or an empty string when figures are not written or writing failed.
Example
- Start here: ex_disp_plots — Disp plots: colour maps, bar and spline histograms, line plots, image and time-frequency maps.
- Full source:
src/examples/ex_disp_plots/main.cpp - Build target:
ex_disp_plots(runs under CTest)
Used in examples
ex_disp_plots
Disp plots: colour maps, bar and spline histograms, line plots, image and time-frequency maps.
// Written only when MNE_CPP_FIGURE_DIR names a directory
FigureExporter::save(line, "line_plot", "LinePlot: one period of a sine wave.");
FigureExporter::save(bar, "bar", "Bar: counts of four amplitude classes.");
FigureExporter::save(spline, "spline", "Spline: the same histogram as a smooth curve with three threshold markers.");
FigureExporter::save(image, "image_sc", "ImageSc: a left-to-right ramp in the viridis colour map.");
FigureExporter::save(tfPlot, "tf_plot", "TFplot: power confined to the 20-29 Hz bins.");
ex_disp
Disp library widgets: image map, line plot and time-frequency plot of raw data.
FigureExporter::save(imagesc, "image_sc", QString("ImageSc of %1 MEG channels from %2 s to %3 s.").arg(data.rows()).arg(from).arg(to));
FigureExporter::save(plot, "plot", QString("Plot of %1 over the same segment.").arg(raw.info.ch_names[picks(0)]));
FigureExporter::save(tfplot, "tf_plot", QString("TFplot: spectrogram (0-100 Hz) of %1.").arg(raw.info.ch_names[picks(0)]));
if (!FigureExporter::directory().isEmpty()) {
return 0;
}
imagesc.show();
plot.show();
tfplot.show();
ex_spectral
Multitaper spectra, power spectral density and cross-spectral density of random test signals.
FigureExporter::save(plotWindow, "hanning", "The single Hanning taper applied before the FFT.");
FigureExporter::save(plotPsd, "psd", "PSD of channel 0 (sines at 0.46, 4.6 and 9.2 Hz) from the tapered spectrum, by hand and as the CSD of the signal with itself: the three curves coincide.");
FigureExporter::save(plotCsd, "csd", "Real part of the cross-spectral density of channels 0 and 1: only their shared 4.6 Hz sine remains.");
if (!FigureExporter::directory().isEmpty()) {
return 0;
}
plotWindow.show();
plotPsd.show();
plotCsd.show();
Also used in ex_connectivity_metrics, ex_dsp_spectral, ex_dsp_filter, ex_histogram, ex_tf_plot, ex_averaging, ex_inverse_cmne, ex_inverse_mne, ex_read_epochs, ex_read_evoked, ex_read_raw.
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>