\documentclass[12pt, a4paper]{report}

\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{titlesec}
\usepackage{float}
\usepackage{booktabs}
\usepackage{caption}

\geometry{top=1in, bottom=1in, left=1.25in, right=1in}

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}{0pt}{-30pt}{20pt}

\begin{document}

\begin{titlepage}
    \begin{center}
        \vspace*{0.5cm}
        \begin{figure}[H]
            \centering
            \includegraphics[height=3.5cm]{iitb_logo.png} \hspace{1cm}
            \includegraphics[height=3.5cm]{fossee_logo.png}
        \end{figure}
        
        \vspace{2cm}
        
        {\LARGE \textbf{Summer Fellowship Report}} \\[0.6cm]
        {\small On} \\[0.6cm]
        {\Large \textbf{Scilab Case Studies}} \\[1.8cm]
        
        {\small Submitted by} \\[0.4cm]
        {\large \textbf{Sumat Dhuwariya}} \\
        {\footnotesize Department of Computer Science} \\
        {\footnotesize VIT Bhopal University} \\[1.8cm]
        
        {\small Under the guidance of} \\[0.4cm]
        {\large \textbf{Prof. Prabhu Ramchandran}} \\
        {\footnotesize Aerospace Engineering Department} \\
        {\footnotesize IIT Bombay} \\[1.8cm]
        
        {\small Mentor} \\[0.4cm]
        {\large \textbf{Mrs. Rashmi Patankar}} \\
        
        \vfill
        
        {\footnotesize \textbf{July 1, 2026}}
        \vspace*{1cm}
    \end{center}
\end{titlepage}

\chapter*{Acknowledgment}
\addcontentsline{toc}{chapter}{Acknowledgment}
I would like to express my deepest gratitude to the FOSSEE Team, IIT Bombay, for offering me the invaluable opportunity to participate in the FOSSEE Summer Fellowship 2026. I am immensely grateful to Prof. Prabhu Ramchandran for spearheading this initiative, which plays a pivotal role in promoting free and open-source software in education.

A special note of thanks goes to my mentor, Mrs. Rashmi Patankar, for her unwavering guidance, valuable feedback, and encouragement throughout the fellowship. Her expertise significantly enriched my learning journey and was instrumental in the successful completion of my projects.

I would also like to express my gratitude towards my family, friends and members of VIT Bhopal University, for their kind co-operation and encouragement, which helped me complete this Internship.

\vspace{1cm}
\noindent \textbf{Sumat Dhuwariya} \\
VIT Bhopal University

\tableofcontents
\listoffigures

\chapter{Introduction}
To understand how the brain works, computational neuroscientists must combine biological experiments with the numerical simulation of large-scale neural networks. However, developers and researchers constantly face a strict compromise between biological plausibility and computational efficiency. Biophysically detailed models, such as the Hodgkin-Huxley model, accurately reproduce neural firing patterns but are computationally prohibitive for large-scale network simulations. Conversely, simpler artificial models fail to capture the rich, diverse firing dynamics of real cortical neurons.

The Free and Open Source Software in Education (FOSSEE) initiative promotes the adoption of open-source tools to enhance technical education. Scilab is a prime example of a cross-platform numerical computation environment that provides a robust alternative to proprietary software. With its powerful mathematical engine, Xcos visual simulation environment, and interactive GUI capabilities, Scilab is highly capable of handling advanced neurocomputational physics.

During this fellowship, I successfully completed three progressive case studies bridging Neurobiology and Artificial Intelligence within Scilab:
\begin{itemize}
    \item \textbf{Case Study 1:} Spiking Neural Networks for Handwritten Image Classification using Scilab.
    \item \textbf{Case Study 2:} Continuous-Time Simulation of Neural Synapses Using First-Order Kinetics in Xcos.
    \item \textbf{Case Study 3:} Simulating the Izhikevich Model, Cortical Rhythms, and GUI Dashboard Development in Scilab.
\end{itemize}

These studies demonstrate the versatility of Scilab in modelling biological systems, discrete-time Euler integration, and graphical interface deployment without relying on external machine learning or neuroscience toolboxes.

\chapter{Case Study 1: Spiking Neural Networks for Image Classification}

\section{Abstract}
This project presents handwritten digit classification using a single-layer Spiking Neural Network (SNN), implemented from scratch within Scilab. An $8 \times 8$ image dataset (3823 images) was used with an 80-20 train-test split. Static pixels were translated into stochastic spike sequences using Poisson encoding, processed via the Leaky Integrate-and-Fire (LIF) model. A supervised Spike-Perceptron learning rule was deployed with momentum-assisted weight updates and L2 regularization. The model achieved a final, reproducible classification accuracy of 91.90\%.

\section{Problem Statement}
While Artificial Neural Networks (ANNs) excel in cognitive tasks, they utilize continuous activation functions requiring significant computational resources. Spiking Neural Networks (SNNs), the third generation of neural networks, offer energy-efficient discrete spike processing. The challenge lies in mathematically translating static images into time-series spike data and updating synaptic weights to train the network without utilizing specialized Python machine learning libraries.

\section{Methodology}
\begin{itemize}
    \item \textbf{Poisson Spike Encoding:} Pixels are converted into spikes based on normalized brightness probability over 100 ms simulation windows.
    \item \textbf{LIF Integration:} The discrete-time Euler integration solves the membrane leakage differential equation:
    \begin{equation}
        V[t+1] = V_{rest} + \beta_{decay} (V[t] - V_{rest}) + \frac{I_{inj}[t] \cdot R_m \cdot dt}{\tau_m}
    \end{equation}
    \item \textbf{Spike-Perceptron Weight Update:} Updating all 640 connections in a single matrix calculation using learning rate $\eta$ and Error Transpose ($E^T$):
    \begin{equation}
        \Delta W = \eta (Inputs \times E^T)
    \end{equation}
    \item \textbf{Momentum Optimization:} Accumulated past weight updates prevent the network from stalling in local minima.
\end{itemize}
\section{Flowchart}
\begin{figure}[H]
    \centering
    \includegraphics[width=0.7\textwidth]{flowchart1.png}
    \label{fig:flowchart-1}
\end{figure}
\section{Results and Statistical Analysis}
The model processed the test dataset achieving an accuracy of 91.90\%. The proximity of the Macro F1-Score (92.03\%) to the Global Accuracy proves the network learned highly balanced geometric representations across all ten digit classes without overfitting.

\begin{figure}[H]
    \centering
    \includegraphics[width=0.7\textwidth]{fig2_1.png}
    \caption{Confusion Matrix Heatmap showing accurate classification across digits 0-9.}
    \label{fig:confusion_matrix}
\end{figure}

\begin{figure}[H]
    \centering
    \includegraphics[width=0.8\textwidth]{fig2_2.png}
    \caption{Raster plot of Poisson-encoded input spikes over the 100 ms timeframe.}
    \label{fig:raster_plot}
\end{figure}

\chapter{Case Study 2: Continuous-Time Simulation of Neural Synapses in Xcos}

\section{Abstract}
This project simulates both inhibitory and excitatory chemical synapses using the fundamental potential and current equations of the Hodgkin-Huxley (HH) model. The simulation was built entirely within base Scilab/Xcos using a modular, continuous-time block architecture and superblocks. To accurately model synaptic transmission, first-order kinetic equations were implemented rather than artificial square-wave pulse generators. By adjusting the synaptic reversal potential, we successfully demonstrated both Excitatory Post-Synaptic Potentials (EPSP) that actively drive target neurons to spike and Inhibitory Post-Synaptic Potentials (IPSP) that suppress firing.

\section{Problem Formulation}
The standard Leaky Integrate-and-Fire (LIF) model simplifies the neuronal membrane into a basic RC circuit, lacking the dynamic memory elements found in real biology. To replicate biological functions, the Hodgkin-Huxley (HH) model utilizes voltage-gated channels to control the flow of current. When information is transferred from one neuron to another, it occurs through a complex chemical connection that either spikes the target neuron (EPSP) or suppresses it (IPSP). This case study models these complex connections by injecting a synaptic current ($I_{syn}$) governed by first-order kinetics inside Xcos.

\section{Basic Concepts}
\begin{itemize}
    \item \textbf{Membrane Voltage ($V_{mem}$) Integrator:} Acts as the "memory" of the cell's electrical state. It continuously integrates the rate of change:
    \begin{equation}
        \frac{dV}{dt} = \frac{I_{in} - I_{Na} - I_{K} - I_{L}}{C_{M}}
    \end{equation}
    \item \textbf{Gating Kinetics ($n, m, h$):} The flow of electricity is governed by the opening and closing of ion channels, modeled by differential equations (e.g., Potassium Activation $n$):
    \begin{equation}
        \frac{dn}{dt} = \alpha_n(1 - n) - \beta_n n
    \end{equation}
    \item \textbf{Neurotransmitter Release ($T$):} Modeled using a continuous sigmoidal function to mimic a physical wave of neurotransmitters:
    \begin{equation}
        T = \frac{1}{1 + \exp(-(V_{pre} - V_{th}) / K_p)}
    \end{equation}
    \item \textbf{Synaptic Current ($I_{syn}$):} The final current injected into the post-synaptic neuron depends on the reversal potential ($E_{syn}$). Setting $E_{syn} = 115$ mV creates an Excitatory synapse (EPSP), while $E_{syn} = -12$ mV creates an Inhibitory synapse (IPSP).
\end{itemize}
\section{Flowchart}
\begin{figure}[H]
    \centering
    \includegraphics[width=0.7\textwidth]{flowchart2.png}
    \label{fig:flowchart-2}
\end{figure}

\section{Xcos Simulation Architecture}
The Neuron superblock relies on a continuous feedback loop between algebraic calculators (\texttt{sci\_func}) and integrators. The Synapse superblock acts as a bridge connecting two independent HH neurons.

\begin{figure}[H]
    \centering
    \includegraphics[width=0.8\textwidth]{fig3_1.png}
    \caption{Xcos block diagram showing continuous-time integration of HH neurons and synaptic superblocks.}
    \label{fig:xcos_diagram}
\end{figure}

\section{Results and Discussion}
The simulation was executed over a 100 ms timeframe. In the EPSP configuration, the wave of neurotransmitters opened post-synaptic channels, depolarizing the target neuron and actively forcing it past the 20 mV threshold to trigger an action potential. 

In the IPSP configuration, each time the pre-synaptic neuron fired, inhibitory channels opened, injecting a negative current that dragged the target neuron's membrane potential into a hyperpolarized state, continuously suppressing its firing.

\begin{figure}[H]
    \centering
    \begin{minipage}{0.48\textwidth}
        \centering
        \includegraphics[width=\linewidth]{fig3_2.png}
        \caption{Excitatory Synapse (EPSP)}
    \end{minipage}\hfill
    \begin{minipage}{0.48\textwidth}
        \centering
        \includegraphics[width=\linewidth]{fig3_3.png}
        \caption{Inhibitory Synapse (IPSP)}
    \end{minipage}
\end{figure}

\chapter{Case Study 3: Simulating the Izhikevich Model and Cortical Rhythms in Scilab}

\section{Abstract}
This study recreates both single-cell membrane and large-scale cortical network behaviors based on Eugene M. Izhikevich's 2003 "Simple Model of Spiking Neurons." We implemented eight key cortical and thalamic firing patterns with a 0.1 ms Euler integration step. For real-time experimentation, we developed an interactive Graphical User Interface (GUI) dashboard offering live mathematical feedback. Additionally, a 1,000-neuron pulse-coupled neural network (PCNN) was built using a $1000 \times 1000$ synaptic weight matrix. Using a 0.5 ms split-step integration method and stochastic thalamic noise, the simulated network successfully self-organized to replicate mammalian alpha (10 Hz) and gamma (40 Hz) brain rhythms.

\section{The Izhikevich Model}
The model reduces Hodgkin-Huxley dynamics into a 2-D system of ordinary differential equations:
\begin{align}
    v' &= 0.04v^2 + 5v + 140 - u + I \\
    u' &= a(bv - u)
\end{align}
with the after-spike resetting condition:
\begin{equation}
    \text{if } v \ge 30 \text{ mV, then } v \leftarrow c, \; u \leftarrow u + d
\end{equation}

\section{GUI Dashboard Architecture}
A robust, professional UI was constructed in Scilab. The dashboard prevents invalid handle crashes and handles real-time parameter tuning with dynamic equation substitutions directly rendered onto the axis titles.

\begin{figure}[H]
    \centering
    \includegraphics[width=1\textwidth]{fig4_1.png}
    \caption{The Interactive Scilab Spiking Neurons Master Dashboard.}
    \label{fig:dashboard}
\end{figure}
\end{itemize}
\section{Flowchart}
\begin{figure}[H]
    \centering
    \includegraphics[width=0.7\textwidth]{flowchart3.png}
    \label{fig:flowchart-3}
\end{figure}
\section{Results and Validation}
\subsection{Single Neuron Firing Modes}
\begin{itemize}
    \item \textbf{Regular Spiking (RS) \& Chattering (CH):} Fine-tuning the recovery reset parameter ($d = 2.1$) for the Chattering profile reproduced its characteristic high-frequency multi-spike bursting pattern. The modified reset step acted as an internal recovery mechanism that sustained bursting under constant current injection without altering the baseline input.
    \item \textbf{Thalamo-Cortical (TC) Firing:} Initializing the membrane potential at the calculated resting equilibrium ($-64.4$ mV) reduced transient startup artifacts before stimulus delivery. Applying a hyperpolarizing current ($-29.51$) drove the neuron to approximately $-87$ mV, producing a clear post-inhibitory rebound burst upon current removal.
    \item \textbf{Resonator (RZ) Dynamics:} A holding current of $0.26$ positioned the model just below the calculated Hopf bifurcation threshold ($0.2625$), allowing sustained subthreshold oscillations with minimal damping. A brief 2 ms, $+1.0$ trigger pulse pushed the system beyond the bifurcation threshold and initiated persistent repetitive spiking within the simulated time window, demonstrating the expected bistable behavior.
    \item \textbf{Intrinsically Bursting (IB):} Using a higher reset voltage ($c = -55$ mV) and moderate recovery reset ($d = 4$) reproduced an initial burst of closely spaced spikes followed by tonic spiking. Accumulation of the recovery variable ($u$) provided the negative feedback responsible for the transition from bursting to regular firing.
    \item \textbf{Fast Spiking (FS):} A rapid recovery rate ($a = 0.1$) enabled the recovery variable to closely track membrane dynamics. Under sustained depolarization, the neuron produced a high-frequency spike train with minimal spike-frequency adaptation, consistent with fast-spiking cortical interneurons.
    \item \textbf{Low-Threshold Spiking (LTS):} Increasing the sensitivity parameter ($b = 0.25$) lowered the effective firing threshold. Under depolarization, the neuron generated a rapid spike train exhibiting pronounced spike-frequency adaptation, with progressively increasing inter-spike intervals over time.
    \begin{figure}[H]
    \centering
    \includegraphics[width=0.8\textwidth]{fig4_2.png}
    \caption{All 8 firing patterns}
    \label{fig: 8-figures}
\end{figure}
\end{itemize}

\subsection{Pulse-Coupled Neural Network}
We executed a 1,000-neuron model (800 excitatory, 200 inhibitory) utilizing a 0.5 ms dual split-step integration loop inside the 1.0 ms timeline for numerical stability. Driven by feedback loops and stochastic thalamic noise, the network successfully self-organized, producing dense vertical alignment bands in the raster plot corresponding to 10 Hz and 40 Hz synchronization.

\begin{figure}[H]
    \centering
    \includegraphics[width=0.8\textwidth]{fig4_3.png}
    \caption{Network raster plot of 1,000 neurons self-organizing into rhythmic bands.}
    \label{fig:network_raster}
\end{figure}
\chapter{Learnings}
During this fellowship, I gained practical experience in using Scilab and Xcos for solving engineering problems through simulation, modelling, graphical analysis, and GUI development. The work helped me understand how theoretical concepts can be converted into computational case studies using open-source software.

From the first case study, I learned about Euler’s integration and the basics of LIF equations. I learned about converting static pixels into firing probabilities and the target learning approach.

From the second case study, I learned more about biological concepts, such as neuron classes and gating variables. The HH model is more biologically accurate than LIF, but slower. I also learned about the superblock concept in Xcos.

From the third case study, Izhikevich’s model introduces the interesting mathematical concept of bifurcations and treats neurons as a type of bifurcation. The GUI concepts inside Scilab were worth exploring, which could help in better simulation.

Overall, the fellowship improved my skills in Scilab programming, Xcos modeling, numerical simulation, GUI-based engineering computation, result interpretation, and technical documentation.
\chapter{Conclusion}
This summer fellowship provided an enriching opportunity to explore and implement advanced neurocomputational concepts using base Scilab. Across the three progressive case studies, the versatility of Scilab as a free and open-source platform for modelling, simulation, continuous-time integration, and GUI development has been unequivocally demonstrated.

By beginning with custom supervised learning in Spiking Neural Networks, progressing to continuous-time biological first-order kinetics in Xcos, and finally building an interactive real-time dashboard for the canonical Izhikevich model, the theoretical mechanics of computational neuroscience were practically realized. These studies emphasize the impact of FOSS tools in bridging biological theory and mathematical practice, providing a cost-effective platform for advanced education and research without the need for proprietary software.

% ---------------------------------------------------------
% CHAPTER 6: REFERENCES
% ---------------------------------------------------------
\renewcommand{\bibname}{References}
\begin{thebibliography}{11}

% --- References from Case Study 1 (SNN) ---
\bibitem{maass1997}
W. Maass, ``Networks of spiking neurons: The third generation of neural network models,'' \textit{Neural Networks}, vol. 10, no. 7, pp. 1659-1671, 1997.

\bibitem{diehl2015}
P. U. Diehl and M. Cook, ``Unsupervised learning of digit recognition using spike-timing-dependent plasticity,'' \textit{Frontiers in Computational Neuroscience}, vol. 9, art. no. 99, 2015.

\bibitem{gerstner2002}
W. Gerstner and W. M. Kistler, \textit{Spiking Neuron Models: Single Neurons, Populations, Plasticity}. Cambridge, U.K.: Cambridge University Press, 2002.

\bibitem{ponulak2010}
F. Ponulak and A. Kasiński, ``Supervised learning in spiking neural networks with ReSuMe: sequence learning, classification, and spike shifting,'' \textit{Neural Computation}, vol. 22, no. 2, pp. 467-510, 2010.

\bibitem{rumelhart1986}
D. E. Rumelhart, G. E. Hinton, and R. J. Williams, ``Learning representations by back-propagating errors,'' \textit{Nature}, vol. 323, no. 6088, pp. 533-536, 1986.

\bibitem{turrigiano2008}
G. G. Turrigiano, ``The self-tuning neuron: synaptic scaling of excitatory synapses,'' \textit{Cell}, vol. 135, no. 3, pp. 422-435, 2008.

% --- References from Case Study 2 (Xcos HH Synapses) ---
\bibitem{yu2011}
T. Yu, T. J. Sejnowski, and G. Cauwenberghs, ``Biophysical neural spiking, bursting, and excitability dynamics in reconfigurable analog VLSI,'' \textit{IEEE Transactions on Biomedical Circuits and Systems}, vol. 5, no. 5, pp. 420-429, Oct. 2011.

\bibitem{natarajan2018}
A. Natarajan and J. Hasler, ``Hodgkin-Huxley neuron and FPAA dynamics,'' \textit{IEEE Transactions on Biomedical Circuits and Systems}, vol. 12, no. 4, pp. 918-926, Aug. 2018.

\bibitem{natarajan2019}
A. Natarajan and J. Hasler, ``Implementation of synapses with Hodgkin Huxley neurons on the FPAA,'' in \textit{2019 IEEE International Symposium on Circuits and Systems (ISCAS)}, Sapporo, Japan, May 2019, pp. 1-5.

\bibitem{hodgkin1952}
A. L. Hodgkin and A. F. Huxley, ``A quantitative description of membrane current and its application to conduction and excitation in nerve,'' \textit{J. Physiol.}, vol. 117, pp. 500-544, 1952.

% --- References from Case Study 3 (Izhikevich Model & GUI) ---
\bibitem{izhikevich2003}
E. M. Izhikevich, ``Simple Model of Spiking Neurons,'' \textit{IEEE Transactions on Neural Networks}, vol. 14, no. 6, pp. 1569-1572, Nov. 2003.

\end{thebibliography}

\end{document}