# Automated Detection of Epileptic Seizures in EEG Signals via Micro-Capsule Networks
## 2 Methods
### Construction of the Micro-Capsule Networks
#### 2.2.1 The Micro-Capsule Network Model Establishment  
To effectively identify dynamic image targets, capsule neural networks preserve spatial relationships between objects. These networks comprise multiple neuron nodes, each encoding instantiation parameters such as pose (position, size, orientation), deformation, velocity, hue, and texture. For example, consider two facial features (the mouth and eyes) to illustrate spatial relationships in detail, as shown in Figure 1.  
As shown in Figure 1, after image data is input into the capsule neural network model, neurons in the primary capsule layer learn to detect visual features (e.g., mouth and eyes) and generate vectors with larger magnitudes in regions matching the target features. These vectors encode the contour, shape, and spatial orientation of detected features. Conversely, smaller vectors with randomized directional patterns are produced in non-matching regions.  
The routing algorithm assesses recognition accuracy for the target graph and its sub-graphs. Output data are directed to capsule structures representing the mouth and eyes. When the eye sub-graph is processed via routing, the mouth features exhibit poor correlation with the target characteristics, reducing their routing weight. Following the mechanism where low-level capsules assess high-level capsules to enhance output receptivity, improved feature alignment with the eye sub-graph increases the routing weight. This prioritizes input signals to the eye capsule structure, while the mouth capsule structure captures fewer relevant signals.  
Assume that the input vectors (**u\({}^{\mathbf{1}}\)**, **u\({}^{\mathbf{2}}\)** and **u\({}^{\mathbf{3}}\)**) received by the capsule originate from three lower-layer capsules. The vector's length represents the probability of features detected by the lower-layer capsules, while its direction encodes the spatial state of detected features (e.g., position or orientation).  
Assume the lower capsule detects specific local features (e.g., eyes, mouth, and nose), while the output capsule recognizes the composite structure (e.g., a face). The vector is multiplied by its corresponding weight matrix \(\mathbf{W}_{\mathbf{ij}}\), which captures spatial and hierarchical connections between low-level features (eyes, mouth, nose) and high-level features (face). This transformation predicts the spatial properties of the high-level features, such as position, orientation, and scale.  
The reconstruction loss method is typically employed to optimize weight parameters within the capsule hierarchy, replicating autoencoder-like functionality. By leveraging this approach, capsule networks explicitly model hierarchical feature relationships. Capsule neurons utilize unique parameters to instantiate specific categories (e.g., objects in an image), with their output values representing the probability of a target's presence, thereby  
Figure 1: Schematic diagram of automatic encoding for micro-capsule networks. The light green and blue arrows represent the pose and rotation vectors of the eyes and mouth, respectively. The deep red and orange arrows represent the pose of the head sculpture with misaligned right eye and mouth.  
enhancing detection accuracy. Moreover, unlike CNNs, which require large volumes of training data, capsule networks achieve state-of-the-art performance with minimal samples.