Background: Epilepsy is a severe disorder of the central nervous system that predisposesÂ the person to recurrent seizures. Fifty million people worldwide suffer fromÂ epilepsy; after Alzheimerâ€™s and stroke, it is the third widespread nervous disorder.Objective: In this paper, an algorithm to detect the onset of epileptic seizuresÂ based on the analysis of brain electrical signals (EEG) has been proposed. 844 hoursÂ of EEG were recorded form 23 pediatric patients consecutively with 163 occurrencesÂ of seizures. Signals had been collected from Childrenâ€™s Hospital Boston with a samplingÂ frequency of 256 Hz through 18 channels in order to assess epilepsy surgery. ByÂ selecting effective features from seizure and non-seizure signals of each individual andÂ putting them into two categories, the proposed algorithm detects the onset of seizuresÂ quickly and with high sensitivity.Method: In this algorithm, L-sec epochs of signals are displayed in form of a thirdorderÂ tensor in spatial, spectral and temporal spaces by applying wavelet transform.Â Then, after applying general tensor discriminant analysis (GTDA) on tensors and calculatingÂ mapping matrix, feature vectors are extracted. GTDA increases the sensitivityÂ of the algorithm by storing data without deleting them. Finally, K-Nearest neighborsÂ (KNN) is used to classify the selected features.Results: The results of simulating algorithm on algorithm standard dataset showsÂ that the algorithm is capable of detecting 98 percent of seizures with an average delayÂ of 4.7 seconds and the average error rate detection of three errors in 24 hours.Conclusion: Today, the lack of an automated system to detect or predict the seizureÂ onset is strongly felt.