# Real-Time Localization of Epileptogenic Foci EEG Signals: An FPGA-Based Implementation
## 3 Hardware Implementation and Computational Method
### Computation of the RT-EPI Algorithm
#### 3.4.1 Algorithm Description
Obviously, this slight variation has been achieved thanks to the pipelined design. \begin{table}
\begin{tabular}{l l l} \hline \hline  & \multicolumn{2}{c}{**Data Type**} \\ \hline
**Resources** & **Double** & **Float** \\ \hline DSP48E & 137 & 133 \\ \hline BRAM & 185 & 95 \\ \hline FF & 45,240 & 39,921 \\ \hline LUT & 52,571 & 46,302 \\ \hline DSP48E & 4.0\% & 4.1\% \\ \hline BRAM & 4.9\% & 2.5\% \\ \hline FF & 3.2\% & 2.8\% \\ \hline LUT & 7.4\% & 6.5\% \\ \hline Clock Period (ns) & \(5.35\pm 0.5\) & 5.21 \(\pm\) 0.5 \\ \hline Max. Clock Frequency (MHz) & 186.9 & 191.9 \\ \hline Clock cycles & 73,999,901 & 53,996,354 \\ \hline Max. Classification Frequency (Hz) & 2.53 & 3.55 \\ \hline Accuracy (MAE) & 3.9428 \(\times 10^{-15}\) & 1.0005 \(\times 10^{-6}\) \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Resource usage, performance and precision of the FPGA implementation as a function of the data type (“float” is for 32-bit floating-point arithmetic precision, and “double” for 64 bit floating-point arithmetic precision). Resource usage is indicated by the number of required slices and the percentage of occupation of a Xilinx XC7 VX1140T FPGA. Figure 3: Classification accuracy of the neural network as a function of the number of hidden neurons in the hidden layer. The required number of flip-flops (FF) and look up tables (LUT) were not high, presenting only small variations between designs. On the other hand, as is natural, the amount of block RAM doubled for double arithmetic precision with respect to single arithmetic precision. That is due to the use of 64-bit representation of double precision and 32-bit of single precision. Then, block RAM requirement halves according the amount of memory needed for its representation. ### Hardware Performance and Accuracy

Mean absolute error (MAE) was used to measure the accuracy of the results of each design with respect to the Matlab implementation. MAE measures the average magnitude of the errors without considering the direction of its deviation, taking into account the absolute differences between them. The accuracy shown in Table 4 is the maximum of the accuracy obtained for the results of each output neuron. As it can be seen, the accuracy for the single design is very low, but the accuracy for the double design is so low that, in practice, it indicates that results in this case are similar to the results obtained in its Matlab implementation. It is natural, because both implementations use double precision data types. In turn, the number of clock cycles shows a strong dependency of the data type (Table 4), and the numbers of minimum allowable cycles reported for both designs were similar. The maximum frequency of operation is obtained from the minimum clock period and the required number of clock cycles. It is represented in Table 4 for both data type designs. As it can be seen, the computation of all the classification procedure, from accepting raw signals to the delivery of the classification output can be done at a rhythm of 2.53 Hz for the \"double\" design and 3.55 Hz for the \"single\" designs (3.55 classification outputs by second). ## 5 Discussion

The analysis described in this paper was carried out using the Bern-Barcelona dataset. Thus, all related works in the bibliography, selected for the sake of comparison, use the same database. That provides a more comparable framework, given that the use of works using other datasets may expose significant differences when performing the same classification method. As an example, [PERSON] et al. [25] shows that the focal-nonfocal (F-NF) classification accuracy may differ more than 20% when the same methods applies to the Bern-Barcelona dataset [7] and the Epileptic Seizure Recognition dataset [46]. In this example, the nature of the signals in the dataset, mainly the difference between signal lengths (only 1s for the latter), makes the difference.