msqms.qc.visual_inspection module#

Visual Inspection

Summary#

Classes:#

Reference#

class msqms.qc.visual_inspection.VisualInspection(raw, output_fpath='imgs')[source]#

Bases: object

visualize_heatmap(data, bad_mask, filename, width=700, height=500, label='', adaptive=True, downsample_dim=1000)[source]#

Visualize the positions of NaN values in a multi-channel brain data matrix and display the percentage of label values.(NaN/bad segments etc.)

This function is implemented based on Plotly.

Parameters:
  • data (numpy.ndarray) – Multi-channel brain data matrix.

  • bad_mask (numpy.ndarray) – Matrix containing indices of bad values (NaN, bad segments, zeros, constant values, etc.).

  • filename (string) – Name of the image file (*.html)

  • width (float) – Width of the image

  • height (float) – Height of the image

  • label (str) – The label of the heatmap.

  • adaptive (bool) – Whether to handle long time problems when plotting the heatmap.

  • downsample_dim (int) – The heatmap dimensions displayed by default are set according to downsample_dim. No matter how long the data is, it is compressed to downsample_dim and its data is summed.

  • title (str) – The title of the heatmap.

Return type:

None

visual_psd(width=700, height=500)[source]#

Visualize the Power Spectral Density (PSD) of the MEG data using Plotly.

Parameters:
  • width (int) – Width of the output plot.

  • height (int) – Height of the output plot.

visual_heatmap_grid(data, bad_mask, adaptive=True, downsample_dim=1000, filename='')[source]#

Visualize the bad segments in a grid heatmap using seaborn.

Parameters:
  • data (numpy.ndarray) – The multi-channel brain data matrix.

  • bad_mask (numpy.ndarray) – A binary mask indicating the positions of bad values.

  • adaptive (bool) – Whether to downsample the mask for long data series.

  • downsample_dim (int) – The target dimension for downsampling.

  • filename (str) – The name of the saved heatmap image.

visualize_nan_values(nan_mask)[source]#

Visualize the positions of NaN values in multi-channel brain data matrix and display the percentage of NaN values.

Parameters:
  • data (numpy.ndarray) – Multi-channel brain data matrix.

  • nan_mask (numpy.ndarray) – matrix containing indices of NaN values.

Returns:

None

visualize_bad_segments(bad_segment_mask)[source]#

Visualize the positions of bad segments in multi-channel brain data matrix and display the percentage of bad segments.

Parameters:
  • data (numpy.ndarray) – Multi-channel brain data matrix.

  • bad_segment_mask (numpy.ndarray) – 2D binary mask indicating the positions of bad segments.

Returns:

None

visualize_zero_values(zero_mask)[source]#

Visualize the positions of zero values in multi-channel brain data matrix and display the percentage of zero values.

Parameters:
  • data (numpy.ndarray) – Multi-channel brain data matrix.

  • zero_mask (numpy.ndarray) – Matrix containing indices of zero values.

Returns:

None

plot_multivariate_time_series()[source]#

Plot the mean, standard deviation, and variance of a multivariate time series using barplot.

Parameters: data (ndarray): Multivariate time series data with shape (samples, channels).

Returns: None, directly plots the barplot.

visual_bad_channel_topomap(bad_channels, show_names=True, filename='Bad_channels_distribution.png')[source]#

Plot the topomap of bad channels on the MEG sensor array.

Parameters:
  • bad_channels (list) – List of bad channel names to be marked.

  • show_names (bool, optional) – Whether to display channel names on the topomap (default is True).

  • filename (str, optional) – The output file name for the topomap image (default is ‘bad_channels_topomap.png’).

Return type:

None

visual_bad_channels_distribution(ch_names, mode, fontsize=10)[source]#

Visualize the distribution of bad channels using a bar plot.

Parameters:
  • bad_mask (pandas.DataFrame) – A DataFrame containing binary values indicating whether a channel is bad (1) or good (0).

  • ch_names (list) – List of channel names corresponding to the bad_mask.

  • mode (str, optional) – The visualization mode. Options are ‘squid’ for a horizontal bar plot or ‘default’ for a vertical bar plot (default is ‘squid’).

  • fontsize (int, optional) – The font size for channel labels (default is 10).

  • filename (str, optional) – The name of the output file where the figure will be saved (default is ‘bad_channels_distribution.png’).

Return type:

None

plot_average_psd()[source]#

Power Spectral Density average on time.

plot_power_on_ts()[source]#
plot_chan_variance_ts()[source]#

channel variance time series.

plot_average_freq()[source]#
plot_constant_dist()[source]#

constant value time series.

plot_bad_channel_topo()[source]#

The bad channels topomap.

plot_bad_channel_dist()[source]#
plot_bad_segment_dist()[source]#