(self, X)
return y_pred
Make predictions on unseen data with the asociated probabilities.

        The new data observation X will be filtered
        with weights previously extracted and compared to the templates to assess
        similarity with each of them and select a class based on the maximal value.

        Parameters
        ----------
        X : ndarray of shape (n_trials, n_channels, n_samples)
            Testing data. This will be divided in self.n_fbands using the filter-bank approach,
            then it will be transformed by the different spatial filters and compared to the
            previously fit templates according to the selected method for analysis (ensemble or
            not). Finally, correlation scores for all sub-bands of each class will be combined,
            resulting on a single correlation score per class, from which the maximal one is
            identified as the predicted class of the data.

        Returns
        -------
        y_pred : ndarray of shape (n_trials,)
            Prediction vector in respect to X.
Make predictions on unseen data with the asociated probabilities.
Make predictions on unseen data with the asociated probabilities .
def predict_proba(self, X):
        """Make predictions on unseen data with the asociated probabilities.

        The new data observation X will be filtered
        with weights previously extracted and compared to the templates to assess
        similarity with each of them and select a class based on the maximal value.

        Parameters
        ----------
        X : ndarray of shape (n_trials, n_channels, n_samples)
            Testing data. This will be divided in self.n_fbands using the filter-bank approach,
            then it will be transformed by the different spatial filters and compared to the
            previously fit templates according to the selected method for analysis (ensemble or
            not). Finally, correlation scores for all sub-bands of each class will be combined,
            resulting on a single correlation score per class, from which the maximal one is
            identified as the predicted class of the data.

        Returns
        -------
        y_pred : ndarray of shape (n_trials,)
            Prediction vector in respect to X.
        """

        # Check is fit had been called
        check_is_fitted(self)

        # Check if X is a single trial or not
        if X.ndim == 2:
            X = X[np.newaxis, ...]

        # Downsample data
        X = X[:, :, :: self.downsample]

        # Get test data shape
        n_trials, _, _ = X.shape

        # Initialize pred array
        y_pred = np.zeros((n_trials, len(self.peaks)))

        for trial_n in range(n_trials):
            # Pick trial
            X_test = X[trial_n, :, :]

            # Initialize correlations array
            corr_array = np.zeros((self.n_fbands, self.n_classes))

            # Filter the data in the corresponding band
            for band_n in range(self.n_fbands):
                X_filter = filterbank(X_test, self.sfreq, band_n, self.peaks)

                # Compute correlation with all the templates and bands
                for class_idx in range(self.n_classes):
                    # Get the corresponding template
                    template = np.squeeze(self.templates_[class_idx, band_n, :, :])

                    if self.is_ensemble:
                        w = np.squeeze(
                            self.weights_[band_n, :, :]
                        ).T  # (n_class, n_channel)
                    else:
                        w = np.squeeze(
                            self.weights_[band_n, class_idx, :]
                        ).T  # (n_channel,)

                    # Compute 2D correlation of spatially filtered testdata with ref
                    r = np.corrcoef(
                        np.dot(X_filter.T, w).flatten(),
                        np.dot(template.T, w).flatten(),
                    )
                    corr_array[band_n, class_idx] = r[0, 1]

            normalized_coefs = self.fb_coefs / (np.sum(self.fb_coefs))
            # Fusion for the filterbank analysis
            rho = np.dot(normalized_coefs, corr_array)

            rho /= sum(rho)
            y_pred[trial_n] = rho

        return y_pred
def predict_proba ( self , X ) : # Check is fit had been called check_is_fitted ( self ) # Check if X is a single trial or not if X . ndim == 2 : X = X [ np . newaxis , ... ] # Downsample data X = X [ : , : , : : self . downsample ] # Get test data shape n_trials , _ , _ = X . shape # Initialize pred array y_pred = np . zeros ( ( n_trials , len ( self . peaks ) ) ) for trial_n in range ( n_trials ) : # Pick trial X_test = X [ trial_n , : , : ] # Initialize correlations array corr_array = np . zeros ( ( self . n_fbands , self . n_classes ) ) # Filter the data in the corresponding band for band_n in range ( self . n_fbands ) : X_filter = filterbank ( X_test , self . sfreq , band_n , self . peaks ) # Compute correlation with all the templates and bands for class_idx in range ( self . n_classes ) : # Get the corresponding template template = np . squeeze ( self . templates_ [ class_idx , band_n , : , : ] ) if self . is_ensemble : w = np . squeeze ( self . weights_ [ band_n , : , : ] ) . T # (n_class, n_channel) else : w = np . squeeze ( self . weights_ [ band_n , class_idx , : ] ) . T # (n_channel,) # Compute 2D correlation of spatially filtered testdata with ref r = np . corrcoef ( np . dot ( X_filter . T , w ) . flatten ( ) , np . dot ( template . T , w ) . flatten ( ) , ) corr_array [ band_n , class_idx ] = r [ 0 , 1 ] normalized_coefs = self . fb_coefs / ( np . sum ( self . fb_coefs ) ) # Fusion for the filterbank analysis rho = np . dot ( normalized_coefs , corr_array ) rho /= sum ( rho ) y_pred [ trial_n ] = rho return y_pred