nan_common_denom¶
- nan_common_denom(array: LabeledArray, sort: bool = True, trials_ax: int = 1, min_trials: int = 0, ch_ax: int = 0, crop_trials: bool = True, verbose: bool = False) LabeledArray[source][source]¶
Remove trials with NaNs from all channels.
- This function processes a LabeledArray to remove trials containing NaN
- values, with options for sorting, specifying axes, and setting minimum
trial counts.
- Parameters:
array (
LabeledArray) – The input array to process.sort (
bool, optional) – Whether to sort trials by NaN presence, by default True.trials_ax (
int, optional) – The axis containing trials, by default 1.min_trials (
int, optional) – Minimum number of trials to keep, by default 0.ch_ax (
int, optional) – The axis containing channels, by default 0.crop_trials (
bool, optional) – Whether to crop trials to the minimum number, by default True.verbose (
bool, optional) – Whether to print verbose output, by default False.
- Returns:
The processed array with NaN trials removed.
- Return type:
LabeledArray
Examples
>>> import numpy as np >>> from ieeg.arrays.label import LabeledArray >>> data = np.array([[1, 2, np.nan], [4, 5, 6], [7, np.nan, 9]]) >>> labels = [['ch1', 'ch2', 'ch3'], ['trial1', 'trial2', 'trial3']] >>> array = LabeledArray(data, labels) >>> processed_array = nan_common_denom(array, sort=True, trials_ax=1, ... ch_ax=0, min_trials=3, crop_trials=True, verbose=True) Lowest trials 2 at ch1 Channels excluded (too few trials): ['ch1', 'ch3']