BackgroundA motor imagery (MI) based brain computer interface (BCI) is a challenging nonmuscular connection system used to independently perform movement-related tasks. It is gaining increasing prominence in helping paralyzed individuals communicate with the real world. Achieving better classification accuracy is the major concern in the field of motor imagery-based BCI. To upgrade the classification performance, relevant features play a vital role. The relevant features can be selected by the extreme gradient Bayesian optimization (XGBO) method. MethodsIn this paper, a combination of time-, frequency-, and spatial-related MI features are extracted to design a reliable MI-BCI system. The proposed method incorporates the XGBO algorithm for feature selection and the random forest for the classification of EEG signals. The potency of the proposed system was investigated using two public EEG datasets (BCI Competition III dataset IIIa and dataset IVa). A novel XGBO algorithm increases the accuracy and reduces the time consumption by reducing the dimensionality of features. The proposed algorithm selects the minimum number of features that increase the computational efficacy for MI-based BCI systems. Comparison with existing methodsThe proposed method is compared with ANOVA, sequential forward selection, recursive feature elimination, and LASSO methods and the accuracy rate is increased with the lowest computation time. ResultsThe proposed method achieves mean accuracies of 94.44% and 88.72% and classification errors of 5.56% and 11.28% for Datasets IIIa and IVa, respectively. It outperforms four state-of-art methods with 0.87% and 0.59% increases in the accuracy for Datasets IIIa and IVa, respectively.