{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Overview\n", "This is a short introduction to sinaps for new users.\n", "\n", "The primary data structures of sinaps are:\n", "\n", "* `Section` wich aims to represent a segment of a neuron with uniform physicals values\n", "* `Neuron` wich aims to represent a complete neuron is a directed graph whose edges are of `Section` type.\n", "* `Channels` wich aim to represent ionic channels with various dynamics. Several channels are already implemented, such as Hodgkin-Huxley channels, Pulse currents or AMPA receptors. \n", "\n", "The outputs of a simulation are:\n", "\n", "* Electric potential, at each position in the neuron, for each time point\n", "* Electric currents computed from channels defined in the neuron, each postion, each time point\n", "* Concentration of species, at each position in the neuron, for each time point\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The package can be imported as follows:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import sinaps as sn" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Object creation\n", "Creating an empty `Neuron`:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "nrn = sn.Neuron()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Creating a `Section`, letting sinaps setting default attribute:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sec = sn.Section()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Adding `HodgkinHuxley` [channels](https://en.wikipedia.org/wiki/Hodgkin%E2%80%93Huxley_model) (sodium, potassium and leak) to the newly created section:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sec.add_channel(sn.channels.Hodgkin_Huxley())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Adding a Hodgkin-Huxley type calcium channel:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sec.add_channel(sn.channels.Hodgkin_Huxley_Ca())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "Adding a `PulseCurrent` channel with a current of `200` pA, between t =`2` and t=`5` ms, at the beginning of the section (position `0`):" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sec.add_channel(sn.channels.PulseCurrent(200,2,5),0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Adding the section `s` to the neuron `nrn` as an edge between nodes `0` and `1` :" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "nrn.add_section(sec,0,1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Adding two new sections\n", "* `sec2` with a radius of `2` μm\n", "* `sec3` with a length of `200` μm" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sec2 = sn.Section(a = 2)\n", "sec3 = sn.Section(L = 200)\n", "nrn.add_sections_from_dict({\n", " sec2:(1,2),\n", " sec3:(1,3)\n", "})\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plotting the neuron structure:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "nrn.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Adding calcium ions in the model:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "nrn.add_species(sn.Species.Ca,C0=2E-4, D=100) # For the sake of the example, we increase the calcium diffusion coefficient to speed-up its dynamics, in order to observe variations within 50 ms. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Running simulation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Creating a `Simulation` of neuron `nrn` with spatial resolution `10` μm:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim = sn.Simulation(nrn,dx=10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Running the simulation for timespan `0` to `50` ms. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.run((0,50))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Results of the simulation are stored as [pandas](https://pandas.pydata.org/) Dataframe:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.V" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Viewing results" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plotting up to 10 curves distributed evenly on the neuron:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plotting the Hodgkin-Huxley currents:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.plot.I(sn.channels.Hodgkin_Huxley)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Getting a field view of the potential:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.plot.V_field()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Running the electrodiffusion part:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.run_diff(max_step=1) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plotting the calcium concentration dynamics" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.plot.C(sn.Species.Ca)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.plot.C_field(sn.Species.Ca)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 4 }