Code Monkey home page Code Monkey logo

swcsimulator's Introduction

SWC Simulator

A Python simulator for neuron models specified in the SWC format.

Installation

First clone the repository to a local directory, and navigate to the directory. Install the package with the following command,

python setup.py install

Usage

Load SWC

The first step is to load a SWC file,

from swcsim import SWCNeuron
neuron = SWCNeuron('neuron.swc')

The SWC file is converted to a Networkx graph, in which each node represents a segment in the original SWC file, and each edge represents the link between two segments. A node has three required attributes:

  • morphology: the raw data from the SWC file.
  • model: a python class implementing a neural computational model, ex. Hodgkin-Huxley model.
  • params: parameters of the computational model. If not specified, the default set of parameter will be used.
  • states: states variables of the computational model. states must have at least two fields, I and V.

Setup Simulator

The second step is to create a simulator by calling create_simulator,

simulator = neuron.create_simulator(
    dt,
    group_1, stimulus_1,
    group_2, stimulus_2,
    ...,
    steps = 1000)

The function create_simulator takes variable pairs of group_i and stimulus_i as positional arguments. group_i is a set or an iterator of identifiers of nodes that receive input from stimulus_i. stimulus_i is a python iterator (ex. a numpy.ndarray or a generator) that will be directly injected into nodes as external current. create_simulator also takes keyword arguments steps or durations that corresponds to number of steps to run.

The function create_simulator creates a generator that updates all nodes and yields its caller SWCNeuron instance at each iteration.

Run Simulator

Once the simulator is created by calling create_simulator, running simulation is as simple as looping through the resultant generator,

simulator = neuron.create_simulator(...)
for i,_ in enumerate(simulator):
    # record voltage value for a particular node[x]
    V[i] = neuron.graph.node[x]['states'].V

Contributors

This repository is maintained by following people:

swcsimulator's People

Contributors

chungheng avatar mkturkcan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.