msqms.qc.statistic_metrics module#

Statistics Domain quality control metric.

Summary#

Classes:#

StatsDomainMetric

Compute statistical domain quality metrics for MEG data.

Reference#

class msqms.qc.statistic_metrics.StatsDomainMetric(raw, data_type, origin_raw=None, n_jobs=-1, verbose=False)[source]#

Bases: Metrics

Compute statistical domain quality metrics for MEG data.

Includes baseline offset, skewness, kurtosis, and identification of bad channels, segments, and flat signals.

compute_metrics(meg_type)[source]#

Compute statistical quality metrics for MEG data(all_channels * all_timepoints).

Parameters:

meg_type (MEG_TYPE) – The MEG channel type (‘mag’, ‘grad’, or ‘eeg’).

Returns:

DataFrame containing average and standard deviation of the metrics.

Return type:

pd.DataFrame

identify_bad_channels()[source]#

Identify bad channels using multiple methods and create a mask.

Returns:

  • float – Ratio of bad channels.

  • list – List of bad channel names.

  • np.ndarray – Mask indicating bad channels.

compute_skewness(data)[source]#

Skewness: measure the shape of the distribution

# skewness = 0, normally distributed # skewness > 0, more weight in the left tail of the distribution. # skewnees < 0, more weight in the right tail of the distribution.

compute the ratio of left tail of the distributrion.[by channels] compute the mean of skewness.

compute_kurtosis(data)[source]#

Kurtosis: # It is also a statistical term and an important characteristic of frequency distribution. # It determines whether a distribution is heavy-tailed in respect of the distribution. # It provides information about the shape of a frequency distribution. # Kurtosis for normal distribution is equal to 3. # For a distribution having kurtosis < 3: It is called playkurtic. # For a distribution having kurtosis > 3, It is called leptokurtic # and it signifies that it tries to produce more outliers rather than the normal distribution.

compute mean kurtosis by channel. compute the playkurtic ratio by channel.

find_bad_channels_by_prep()[source]#
find_bad_channels_by_psd()[source]#

Calculate the PSD (power spectral density) of all channels. find the ones that exceed the mean plus 3*standard deviation, and determine them as bad channels.

find_bad_channels_by_osl()[source]#

Find the bad channels by OSL Library.

find_bad_segments_by_osl()[source]#
find_zero_values(data)[source]#

Detect zero values. :param data:

Returns:

  • zero_mask (np.ndarray) – the mask of zero values.

  • zero_ratio (float) – the ratio of zero values.

find_NaN_values(data)[source]#

Detect NaN values :param data:

Returns:

  • NaN mask matrix

  • NaN ratio, accounts for all data points.

find_flat(flat_thres)[source]#

detect flat channels or constant channels.

compute_mag_field_change(data)[source]#

Calculate the Mag Field Change,and record the degree of magnetic field change. Calculate the maximum value of the magnetic field change, and the mean value and variance of the magnetic field change by channel.

compute_baseline_offset(data)[source]#

Baseline offset: Calculate the baseline drift of each channel (mean, median); Calculate the average deviation degree of the channel data mean relative to the population mean and population median.