Skip to content

ls-javier/stimuli-codification-task

Repository files navigation

# Stimuli Codification Task using Full-FORCE RNNs

This repository implements a **Spiking Recurrent Neural Network (sRNN)** trained to classify temporally structured tactile stimuli. The project replicates biological encoding strategies found in the somatosensory cortex using the **Full-FORCE** learning algorithm.

The model is implemented in **MATLAB** and achieves high-precision binary classification of "Grouped" vs. "Extended" stimuli patterns.

## 🔬 Scientific Context

The architecture and task design are grounded in computational neuroscience. The goal is to simulate how the brain processes sequential sensory inputs.

* **Cortical Regions:** The study models the interaction between regions that represent stimulus timing faithfully (like S1) and those where working memory and decision-making codes emerge (like S2 or DPC).
* **Stimuli:** The task replicates the experimental setup of *Rossi-Pool et al. (2016)*, distinguishing between two vibrotactile patterns:
    1.  **Grouped (A):** Three central pulses are temporally clustered.
    2.  **Extended (E):** Pulses are evenly distributed.

## 🧠 Model Architecture & Algorithm

The network is trained using the **Full-FORCE** algorithm, which utilizes Recursive Least Squares (RLS) to modify plastic weights. The workflow consists of three distinct stages:

1.  **Demean:** The network is initialized with a current ($I_{mu}$) to set the RNN into an irregular spiking regime.
2.  **Train:** The core learning phase. An auxiliary rate-based network generates the target dynamics, which the main Leaky Integrate-and-Fire (LIF) network learns to replicate via RLS.
3.  **Test:** The weights are frozen, and the network is evaluated on new data to generate activity analysis files.

### The Encoding Task
To distinguish between the **Grouped (A)** and **Extended (E)** stimuli, the network is trained to output two specific targets:
* **Target 1 (Attractor):** A signal (red) that remains active to define the total duration of the stimuli (present in both A and E).
* **Target 2 (Bump):** A "bump" (magenta, generated via a beta distribution) that appears **only** when the stimulus is **Grouped (A)**.

## 📂 Repository Structure

    ├── src/
    │   ├── demo_SN.m             # Main entry point: Calls functions and sets input variables
    │   ├── Trial_Codificacion.m  # Helper script for checking task schema and stimuli generation
    │   └── ...                   # Auxiliary functions for Full-FORCE implementation
    ├── data/                     # Generated analysis files
    └── README.md

## 🚀 Usage

### Prerequisites
* MATLAB (R2020b or later recommended).
* Statistics and Machine Learning Toolbox.

### Running the Simulation
1.  Clone the repository:
    ```bash
    git clone [https://github.com/ls-javier/StimuliCodificationTask.git](https://github.com/ls-javier/StimuliCodificationTask.git)
    ```
2.  Open MATLAB and navigate to the repository folder.
3.  Run the main script:
    ```matlab
    demo_SN
    ```

## 📊 Results

The network was evaluated on four permutation classes of stimuli pairs: **E-E, E-A, A-E, and A-A**.

### Accuracy
A trial is considered correct if the correlation between the network output $z(t)$ and the target $F^{out}(t)$ exceeds 0.5 (Ingrosso et al., 2019).

| Class Sequence | Trials Correct | Total Trials | Accuracy |
| :--- | :---: | :---: | :---: |
| **E - E** | 1063 | 1063 | **100%** |
| **E - A** | 996 | 996 | **100%** |
| **A - E** | 972 | 972 | **100%** |
| **A - A** | 969 | 969 | **100%** |

*Table data derived from experimental results (see 'Accuracy.txt' in output).*

The network successfully replicates the targets, producing the specific "bump" only for Grouped stimuli, effectively enabling binary classification.

## 🔮 Future Work

* **Temporal XOR:** Implementation of a temporal Exclusive-OR mechanism to explicitly differentiate if the two stimuli presented in a sequence are identical or different.
* **Sigmoidal Targets:** Replacing step-function attractors with sigmoidal functions to smoothen transitions and potentially reduce noise.

## 📚 References

This project is based on the following literature:

1.  **Parga, N., Serrano, L., & Falcó, A. (2022).** *Emergent Computations in Trained Artificial Neural Networks and Real Brains.* arXiv:2212.04938v2.
2.  **Rossi-Pool, R., et al. (2016).** *Emergence of an abstract categorical code enabling the discrimination of temporally structured tactile stimuli.* PNAS, E7966-E7975.
3.  **Ingrosso, A., & Abbott, L. F. (2019).** *Training dynamically balanced excitatory-inhibitory networks.* PLOS ONE.
4.  **DePascuale, B., Churchill, C. J., & Abbott, L. F. (2016).** *Using Firing-Rate Dynamics to Train Recurrent Networks of Spiking Model Neurons.* arXiv:1601.07620.

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

About

Internship Project in the Computational Neuroscience Group of Autonomous University of Madrid.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors