{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 0: Introduction to the Brain Modeling Toolkit\n",
    "\n",
    "The Brain Modeling ToolKit (bmtk) was developed at the Allen Institute for Brain Science to assist with modeling, simulation and analysis of large-scale networks. It was developed in python and is open-source. The bmtk also provides a unified interface across different level of representations of brain models: supporting everything from biophysically detailed models of indvidual neurons and synapses, to high level representation of connection dynamics between different regions of the brain.\n",
    "\n",
    "Included in the bmtk:\n",
    "* **The Network Builder** - python API that allows modelers to build large-scale network models with a minimal amount of coding.\n",
    "* A [standarized format](https://github.com/AllenInstitute/sonata) for representing networks across a range of different levels of resolution, that is both efficient in memory and read-time, but also allows users to quickly adjust parameters before and during simulations.\n",
    "* A collection of simulator interfaces to run network simulations on a variety of different simulators.\n",
    "* **Analysis Toolkit** - An set of tools for visualizing and analyzing networks and simulation results.\n",
    "\n",
    "<img src=\"_static/_tutorial_images/levels_of_resolution.png\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## About This Guide\n",
    "\n",
    "### General Guides\n",
    "High level overviews of the bmtk.\n",
    "\n",
    "[Quick guide to building networks](NetworkBuilder_Intro.ipynb)  \n",
    "[Setting up and running simulations](Simulation_Intro.ipynb)\n",
    "\n",
    "### Workflow tutorials \n",
    "A collection of tutorials for building and simulating different types of networks using the bmtk. These tutorials are only very loosely in order and can for the most part be skipped around.\n",
    "\n",
    "[Tutorial 1: Single cell with current stimulation (with BioNet)](01_single_cell_clamped.ipynb)  \n",
    "[Tutorial 2: Single cell with external synaptic stimulation (with BioNet)](02_single_cell_syn.ipynb)  \n",
    "[Tutorial 3: Single population recurrent network (with BioNet)](03_single_pop.ipynb)  \n",
    "[Tutorial 4: Multi-population recurrent network (with BioNet)](04_multi_pop.ipynb)  \n",
    "[Tutorial 5: Point-neuron simulation (with PointNet)](05_pointnet_modeling.ipynb)  \n",
    "[Tutorial 6: Population-level simulation (with PopNet)](06_population_modeling.ipynb)  \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Other Resources\n",
    "BMTK tutorials and lectures previously used at various workshops and conferences. _**WARNING - these materials are not guareenteed to be up-to-date, use at your own risk!**_\n",
    "\n",
    "[bmtk tutorial at CNS (June 2018)](https://github.com/AllenInstitute/CNS_2018_Tutorial)  \n",
    "[bmtk tutorial at the Summer Workshop on the Dynamic Brain (August 2018)](https://github.com/AllenInstitute/SWDB_2018)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Prerequisites:\n",
    "\n",
    "### Running with Docker\n",
    "\n",
    "If you have Docker installed on your machine then there is a Docker Image with all the prerequists installed - including a jupyter notebook server with the tutorials installed. Just run:\n",
    "```bash\n",
    "$ docker pull alleninstitute/bmtk\n",
    "$ docker run -v /path/to/local/directory:/home/shared/workspace -p 8888:8888 alleninstitute/bmtk jupyter\n",
    "```\n",
    "and then open a browser to **127.0.0.1:8888/**. The _tutorials_ folder will contain the jupyter notebook tutorials for you to follow along and modify. However, if you want to save the work permentately make sure to save it in the _workspace_ folder. The _tutorials_ and _examples_ folder will be deleted once the docker container has stopped.\n",
    "\n",
    "you can also use the Docker image to run bmtk build and run scripts. Just replace the ```python <script>.py <opts>``` command with ```docker run alleninstitute/bmtk -v /path/to/local/directory:/home/shared/workspace python <script>.py <opts>```\n",
    "\n",
    "\n",
    "### Running from source\n",
    "\n",
    "The bmtk requires at minimum python 2.7 and 3.6+, as well as additional libraries to use features like building networks or running analyses. To install the bmtk it is best recommending to pull the latest from github.\n",
    "```bash\n",
    " $ git clone https://github.com/AllenInstitute/bmtk.git\n",
    " $ cd bmtk\n",
    " $ python setup.py install\n",
    "```\n",
    "\n",
    "However, to run a simulation on the network the bmtk uses existing open-source simulatiors, which (at the moment) needs to be installed separately. The different simulators, which run simulations on different levels-of-resolution, will require different software. So depending on the type of simulation to be run\n",
    "* biophysically detailed network (BioNet) - Uses [NEURON](https://www.neuron.yale.edu/neuron/download).\n",
    "* point-neuron network (PointNet) - Uses [NEST](http://www.nest-simulator.org/installation/).\n",
    "* population-level network (PopNet) - Uses [DiPDE](https://github.com/nicain/dipde_dev).\n",
    "* filter models of the visual field (FilterNet) - Uses LGNModels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "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.6.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
