bmtool


Namebmtool JSON
Version 0.4.1 PyPI version JSON
download
home_pagehttps://github.com/tjbanks/bmtool
SummaryBMTool
upload_time2023-06-15 00:32:48
maintainer
docs_urlNone
authorTyler Banks
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # bmtool
A collection of scripts to make developing networks in BMTK easier.

[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/tjbanks/bmtool/blob/master/LICENSE) 

## Getting Started

**Installation**

```bash
pip install bmtool
```
For developers who will be pulling down additional updates to this repository regularly use the following instead.
```bash
git clone https://github.com/tjbanks/bmtool
cd bmtool
python setup.py develop
```
Then download updates (from this directory) with
```
git pull
```

**Example Use**

```bash
> cd your_bmtk_model_directory
> bmtool
Usage: bmtool [OPTIONS] COMMAND [ARGS]...

Options:
  --verbose  Verbose printing
  --help     Show this message and exit.

Commands:
  debug
  plot
  util

>  
> bmtool plot 
Usage: bmtool plot [OPTIONS] COMMAND [ARGS]...

Options:
  --config PATH  Configuration file to use, default: "simulation_config.json"
  --no-display   When set there will be no plot displayed, useful for saving
                 plots
  --help         Show this message and exit.

Commands:
  connection  Display information related to neuron connections
  positions   Plot cell positions for a given set of populations
  raster      Plot the spike raster for a given population
  report      Plot the specified report using BMTK's default report plotter
>
> bmtool plot positions
```
![bmtool](./figures/figure.png "Positions Figure")

## Plotting Configuration

BMTool utilizes the default `simulation-config.json` file to know which data files built by BMTK to read. to change this, specify the config after the `plot` command. Eg:

```
bmtool plot --config simulation-config-23.json [FUNCTION] 
```

### From python or Jupyter
```
from bmtool import bmplot
bmplot.plot_3d_positions(config="simulation_config.json")
```

## Ploting Connections

All connection tools can be customized by supplying additional arguments. 

```
Options:
  --title TEXT      change the plot's title
  --save-file TEXT  save plot to path supplied
  --sources TEXT    comma separated list of source node types [default:all]
  --targets TEXT    comma separated list of target node types [default:all]
  --sids TEXT       comma separated list of source node identifiers
                    [default:node_type_id]
  --tids TEXT       comma separated list of target node identifiers
                    [default:node_type_id]
  --no-prepend-pop  When set don't prepend the population name to the unique
                    ids [default:False]
```

#### `--sources`  and `--targets`
Are supplied as comma separated lists and corrospond with the population name specified in your model. Eg:
```
#initialize the networks in build_network.py
net = NetworkBuilder('hippocampus')
exp0net = NetworkBuilder('exp0input')
```
Default behavior is to plot connections between all populations but you can specify only a few to simplify your plots.

#### `--sids` and `--tids`
Comma separated lists of node identifiers replace the default `cell_id` automatically given to a cell population by BMTK. Any parameter passed to `NetworkBuilder.add_nodes` is stored in network `.h5` files and can be used to identify cells while connecting or producing plots. Eg:

```
# Adding nodes in build_network.py
net.add_nodes(N=inpTotal, pop_name='EC',
    positions=p_EC,
    model_type='biophysical',
    model_template='hoc:IzhiCell_EC2',
    morphology='blank.swc'
    )
```
We could then use the pop_name to alter the output of our connection plots.

```
bmtool plot connection --sids pop_name --tids pop_name [FUNCTION]
```
#### `--no-prepend-pop`

Default behavior of bmtool is to print the population name before the cell id (or sid/tid) followed by an underscore. Eg: `hippocampus_100`. By supplying `--no-prepend-pop` the cell name becomes `100` unless specified otherwise.

#### `All together basic`

Using these optional switches we can see the difference in our plot output below.

Command line
```
bmtool plot connection total
```
Python or Jupyter Notebook
```
from bmtool import bmplot
import matplotlib.pyplot as plt

bmplot.connection_matrix(config="simulation_config.json")
```

#### `All together advanced`
```
bmtool plot connection --sources hippocampus --targets hippocampus --sids pop_name --tids pop_name --no-prepend-pop --title 'Hippocampus Total Connections' total
```

Python or Jupyter Notebook
```
from bmtool import bmplot

bmplot.connection_matrix(config="simulation_config.json", sources="hippocampus", targets="hippocampus", sids="pop_name", tids="pop_name", no_prepend_pop=True, title="Hippocampus Total Connections")
```

![bmtool](./figures/connection.png "Connection Figure")

### Plot Total Connections

To plot the total number of connections between two populations of cells run 

Command line
```
bmtool plot connection total
```
Python or Jupyter Notebook
```
from bmtool import bmplot

bmplot.connection_matrix(config="simulation_config.json", sources="hippocampus", targets="hippocampus")
```
Remember to customize the output using the instructions above.

#### `--synfo`
This is an additional flag that can be used in the total connections plot. By default it is set to '0' which plots total connections. 
If it is specified as '1', it plots the mean and standard deviation number of connections. If it is '2', it plots the .mod files used for that connection type.
Finally if it is '3', it plots the parameter file (.json) used for the connection.

![bmtool](./figures/connection_total.png "Connection Total Figure")

### Plot Average Convergence/Divergence

To plot the average convergence or divergence of a single cell excute one of the following commands:

Command Line
```
bmtool plot connection convergence
bmtool plot connection divergence

Add --method (std, min, or max) for additional function
```

Python or Jupyter Notebook
```
from bmtool import bmplot

bmplot.convergence_connection_matrix(config="simulation_config.json")
bmplot.divergence_connection_matrix(config="simulation_config.json")

# OR using methods (min,max,std)
bmplot.convergence_connection_matrix(config="simulation_config.json", method="min")
```

![bmtool](./figures/connection_con.png "Connection Convergence Figure")

### Plot Connection Diagram

To plot a rough sketch of cell type connectivity and the type of synapse used between cells run:

Command Line
```
bmtool plot connection network-graph
```

Python or Jupyter Notebook
```
from bmtool import bmplot

bmplot.plot_network_graph(config="simulation_config.json")
```

![bmtool](./figures/connection_graph.png "Connection Graph Figure")


`--edge-property` is an option available to change the synapse name if supplied to `NetworkBuilder.add_edges` when building the network. Default: `model_template`

### Edge Property Histograms

To view the distribution of an edge property between cell types run:

Command Line
```
bmtool plot connection property-histogram-matrix
```

Python or Jupyter Notebook
```
from bmtool import bmplot

bmplot.edge_histogram_matrix(config="simulation_config.json")
```

The following figure was generated using 
```
bmtool plot connection --sources hippocampus --targets hippocampus --sids pop_name --tids pop_name --no-prepend-pop --title 'Synaptic Weight Distribution between Cell Types' property-histogram-matrix
```

```
from bmtool import bmplot

bmplot.edge_histogram_matrix(config="simulation_config.json", sources="hippocampus", targets="hippocampus", sids="pop_name", tids="pop_name", no_prepend_pop=True, title="Synaptic Weight Distribution between Cell Types")
```

![bmtool](./figures/connection_hist.png "Connection Histogram Figure")

By default the `property-histogram-matrix` looks at the `syn_weight` value specified in the `NetworkBuilder.add_edges` function when building your network. You can change this by specifying the `--edge-property`. Eg: 
```
bmtool plot connection property-histogram-matrix --edge-property [PROPERTY]
```

#### Plotting edge values during/after runtime

BMTool is capable of plotting connection properties obtained after runtime from reports. This is useful for synaptic weights that change over time. 

First, you must explicitly record the connection property in your `simulation_config.json`

```
  "reports": {
    "syn_report": {
      "cells": "hippocampus",
      "variable_name": "W_nmda",
      "module": "netcon_report",
      "sections": "soma",
      "syn_type": "pyr2pyr",
      "file_name": "syns.h5"
    }
  }
```
Where `pyr2pyr` is the `POINT_PROCESS` name for the synapse you're attempting to record, and the `variable_name` is a `RANGE` variable listed int the `NEURON` block of the synapse `.mod` file.

Once the simulation has been run un the following referencing the report specified above:

```
bmtool plot connection property-histogram-matrix --edge-property pyr2pyr_w --report output/syns.h5 --time 9999
```

The `--time-compare` option can be be used to show the weight distribution change between the specified times. Eg: ` --time 0 --time-compare 10000`

See the [BMTK Commit](https://github.com/AllenInstitute/bmtk/pull/67/files) for more details.

### Plotting Distance Probability Matrix between cell types

![bmtool](./figures/connection_dist.png "Connection Histogram Figure")

To show the probability of a cell type being connected to another cell type based on distance run:

```
bmtool plot connection prob
```

Full summary of options:

```
> bmtool plot connection prob --help
Usage: bmtool plot connection prob [OPTIONS]

  Probabilities for a connection between given populations. Distance and
  type dependent

Options:
  --axis TEXT  comma separated list of axis to use for distance measure eg:
               x,y,z or x,y
  --bins TEXT  number of bins to separate distances into (resolution) -
               default: 8
  --line       Create a line plot instead of a binned bar plot
  --verbose    Print plot values for use in another script
  --help       Show this message and exit.
```

A more complete command (used for image above) may look similar to

```
bmtool plot connection --sources hippocampus --targets hippocampus --no-prepend-pop --sids pop_name --tids pop_name prob --bins 10 --line --verbose
```

This will plot cells in the `hippocampus` network, using the `pop_name` as the cell identifier. There will be `10` bins created to group the cell distances. A `line` plot will be generated instead of the default `bar` chart. All values for each plot will be printed to the console due to the `verbose` flag.

All  `point_process` cell types will be ignored since they do not have physical locations.

### Plot 3d cell location and rotation
Plot the location and rotation of your cells. Plot all of your cells with a single command
```
bmtool plot cell rotation
```
![bmtool](./figures/rotation3d_1.png "3d Rotation Figure")

Customize your plot by limiting the cells you want or selecting a max number of cells to plot.
```
bmtool plot --config simulation_configECP.json cell rotation --group-by pop_name --group CR --max-cells 100 --quiver-length 100 --arrow-length-ratio 0.25
```
![bmtool](./figures/rotation3d_2.png "3d Rotation Figure")

Code
```
from bmtool import
from bmtool import bmplot

bmplot.cell_rotation_3d(config=config,
                     populations=populations,
                     group_by=group_by,
                     group=group,
                     title=title,
                     max_cells=max_cells,
                     quiver_length=quiver_length,
                     arrow_length_ratio=arrow_length_ratio)
```

### Plotting Current Clamp and Spike Train Info
To plot all current clamp info involved in a simulation, use the following command (uses 'simulation_config.json' as default)
```
bmtool plot --config simulation_config_foo.json iclamp
```

To plot all spike trains and their target cells,
```
bmtool plot --config simulation_config_foo.json input
```

### Printing basic cell information involved in a simulation
```
bmtool plot --config simulation_config_foo.json cells
```

### Simulation Summary

Using previous functions, plots connection probability as a function of distance, total connections, cell information, current clamp information, input spike train information, and a 3D plot of the network if specified. 
```
bmtool plot --config simulation_config_foo.json summary
```

### Connectors Module

This module contains helper functions and classes that work with BMTK's NetworkBuilder module in building networks. It facilitates building reciprocal connections, distance dependent connections, afferent connections, etc. See documentation inside the script `connectors.py` for usage.
```
from bmtool import connectors
```

## Cell Tuning

### Python/Jupyter

Single Cell Profiler

```
from bmtool.singlecell import Profiler

#Example usage
profiler = Profiler(template_dir='./components/templates', mechanism_dir='./components/mechanisms/modfiles')
profiler.passive_properties('Cell_Cf')
profiler.fi_curve('Cell_Cf')
profiler.current_injection('Cell_Cf', post_init_function="insert_mechs(123)", inj_amp=300, inj_delay=100)
```

### Single Cell Tuning

From a BMTK Model directory containing a `simulation_config.json` file:
```
bmtool util cell tune --builder
```

For non-BMTK cell tuning:
```
bmtool util cell --template TemplateFile.hoc --mod-folder ./ tune --builder
```
![bmtool](./figures/figure2.png "Tuning Figure")

### FIR Curve plotting

```
> bmtool util cell fi --help
Usage: bmtool util cell fi [OPTIONS]

  Creates a NEURON GUI window with FI curve and passive properties

Options:
  --title TEXT
  --min-pa INTEGER   Min pA for injection
  --max-pa INTEGER   Max pA for injection
  --increment FLOAT  Increment the injection by [i] pA
  --tstart INTEGER   Injection start time
  --tdur INTEGER     Duration of injection default:1000ms
  --advanced         Interactive dialog to select injection and recording
                     points
  --help             Show this message and exit.

> bmtool util cell fi
? Select a cell:  (Use arrow keys)
 » CA3PyramidalCell
   DGCell
   IzhiCell
   IzhiCell_BC
   IzhiCell_EC
   IzhiCell_EC2
   IzhiCell_EC_BIO
   IzhiCell_EmoExcitatory
   IzhiCell_EmoInhibitory
   IzhiCell_OLM
   IzhiCell_int
```

![bmtool](./figures/figure3.png "FIR Figure")

### VHalf Segregation Module

Based on the Alturki et al. (2016) paper.

Segregate your channel activation for an easier time tuning your cells.


```
> bmtool util cell vhseg --help

Usage: bmtool util cell vhseg [OPTIONS]

  Alturki et al. (2016) V1/2 Automated Segregation Interface, simplify
  tuning by separating channel activation

Options:
  --title TEXT
  --tstop INTEGER
  --outhoc TEXT         Specify the file you want the modified cell template
                        written to
  --outfolder TEXT      Specify the directory you want the modified cell
                        template and mod files written to (default: _seg)
  --outappend           Append out instead of overwriting (default: False)
  --debug               Print all debug statements
  --fminpa INTEGER      Starting FI Curve amps (default: 0)
  --fmaxpa INTEGER      Ending FI Curve amps (default: 1000)
  --fincrement INTEGER  Increment the FI Curve amps by supplied pA (default:
                        100)
  --infvars TEXT        Specify the inf variables to plot, skips the wizard.
                        (Comma separated, eg: inf_mech,minf_mech2,ninf_mech2)
  --segvars TEXT        Specify the segregation variables to globally set,
                        skips the wizard. (Comma separated, eg:
                        mseg_mech,nseg_mech2)
  --eleak TEXT          Specify the eleak var manually
  --gleak TEXT          Specify the gleak var manually
  --othersec TEXT       Specify other sections that a window should be
                        generated for (Comma separated, eg: dend[0],dend[1])
  --help                Show this message and exit.

```

#### Examples 

Wizard Mode (Interactive)

```
> bmtool util cell vhseg

? Select a cell:  CA3PyramidalCell
Using section dend[0]
? Show other sections? (default: No)  Yes
? Select other sections (space bar to select):  done (2 selections)
? Select inf variables to plot (space bar to select):   done (5 selections)
? Select segregation variables [OR VARIABLES YOU WANT TO CHANGE ON ALL SEGMENTS at the same time] (space bar to select):  done (2 selections)
```

Command Mode (Non-interactive)

```
bmtool util cell --template CA3PyramidalCell vhseg --othersec dend[0],dend[1] --infvars inf_im --segvars gbar_im --gleak gl_ichan2CA3 --eleak el_ichan2CA3
```

Example:

![bmtool](./figures/figure4.png "Seg Figure")

Simple models can utilize 
``` 
bmtool util cell --hoc cell_template.hoc vhsegbuild --build
bmtool util cell --hoc segmented_template.hoc vhsegbuild
```
ex: [https://github.com/tjbanks/two-cell-hco](https://github.com/tjbanks/two-cell-hco)


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tjbanks/bmtool",
    "name": "bmtool",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Tyler Banks",
    "author_email": "tbanks@mail.missouri.edu",
    "download_url": "https://files.pythonhosted.org/packages/3a/5c/a662526383b301087607165f61d411ad46f52bbdd2f4817f33e8ac76eab4/bmtool-0.4.1.tar.gz",
    "platform": null,
    "description": "# bmtool\r\nA collection of scripts to make developing networks in BMTK easier.\r\n\r\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/tjbanks/bmtool/blob/master/LICENSE) \r\n\r\n## Getting Started\r\n\r\n**Installation**\r\n\r\n```bash\r\npip install bmtool\r\n```\r\nFor developers who will be pulling down additional updates to this repository regularly use the following instead.\r\n```bash\r\ngit clone https://github.com/tjbanks/bmtool\r\ncd bmtool\r\npython setup.py develop\r\n```\r\nThen download updates (from this directory) with\r\n```\r\ngit pull\r\n```\r\n\r\n**Example Use**\r\n\r\n```bash\r\n> cd your_bmtk_model_directory\r\n> bmtool\r\nUsage: bmtool [OPTIONS] COMMAND [ARGS]...\r\n\r\nOptions:\r\n  --verbose  Verbose printing\r\n  --help     Show this message and exit.\r\n\r\nCommands:\r\n  debug\r\n  plot\r\n  util\r\n\r\n>  \r\n> bmtool plot \r\nUsage: bmtool plot [OPTIONS] COMMAND [ARGS]...\r\n\r\nOptions:\r\n  --config PATH  Configuration file to use, default: \"simulation_config.json\"\r\n  --no-display   When set there will be no plot displayed, useful for saving\r\n                 plots\r\n  --help         Show this message and exit.\r\n\r\nCommands:\r\n  connection  Display information related to neuron connections\r\n  positions   Plot cell positions for a given set of populations\r\n  raster      Plot the spike raster for a given population\r\n  report      Plot the specified report using BMTK's default report plotter\r\n>\r\n> bmtool plot positions\r\n```\r\n![bmtool](./figures/figure.png \"Positions Figure\")\r\n\r\n## Plotting Configuration\r\n\r\nBMTool utilizes the default `simulation-config.json` file to know which data files built by BMTK to read. to change this, specify the config after the `plot` command. Eg:\r\n\r\n```\r\nbmtool plot --config simulation-config-23.json [FUNCTION] \r\n```\r\n\r\n### From python or Jupyter\r\n```\r\nfrom bmtool import bmplot\r\nbmplot.plot_3d_positions(config=\"simulation_config.json\")\r\n```\r\n\r\n## Ploting Connections\r\n\r\nAll connection tools can be customized by supplying additional arguments. \r\n\r\n```\r\nOptions:\r\n  --title TEXT      change the plot's title\r\n  --save-file TEXT  save plot to path supplied\r\n  --sources TEXT    comma separated list of source node types [default:all]\r\n  --targets TEXT    comma separated list of target node types [default:all]\r\n  --sids TEXT       comma separated list of source node identifiers\r\n                    [default:node_type_id]\r\n  --tids TEXT       comma separated list of target node identifiers\r\n                    [default:node_type_id]\r\n  --no-prepend-pop  When set don't prepend the population name to the unique\r\n                    ids [default:False]\r\n```\r\n\r\n#### `--sources`  and `--targets`\r\nAre supplied as comma separated lists and corrospond with the population name specified in your model. Eg:\r\n```\r\n#initialize the networks in build_network.py\r\nnet = NetworkBuilder('hippocampus')\r\nexp0net = NetworkBuilder('exp0input')\r\n```\r\nDefault behavior is to plot connections between all populations but you can specify only a few to simplify your plots.\r\n\r\n#### `--sids` and `--tids`\r\nComma separated lists of node identifiers replace the default `cell_id` automatically given to a cell population by BMTK. Any parameter passed to `NetworkBuilder.add_nodes` is stored in network `.h5` files and can be used to identify cells while connecting or producing plots. Eg:\r\n\r\n```\r\n# Adding nodes in build_network.py\r\nnet.add_nodes(N=inpTotal, pop_name='EC',\r\n    positions=p_EC,\r\n    model_type='biophysical',\r\n    model_template='hoc:IzhiCell_EC2',\r\n    morphology='blank.swc'\r\n    )\r\n```\r\nWe could then use the pop_name to alter the output of our connection plots.\r\n\r\n```\r\nbmtool plot connection --sids pop_name --tids pop_name [FUNCTION]\r\n```\r\n#### `--no-prepend-pop`\r\n\r\nDefault behavior of bmtool is to print the population name before the cell id (or sid/tid) followed by an underscore. Eg: `hippocampus_100`. By supplying `--no-prepend-pop` the cell name becomes `100` unless specified otherwise.\r\n\r\n#### `All together basic`\r\n\r\nUsing these optional switches we can see the difference in our plot output below.\r\n\r\nCommand line\r\n```\r\nbmtool plot connection total\r\n```\r\nPython or Jupyter Notebook\r\n```\r\nfrom bmtool import bmplot\r\nimport matplotlib.pyplot as plt\r\n\r\nbmplot.connection_matrix(config=\"simulation_config.json\")\r\n```\r\n\r\n#### `All together advanced`\r\n```\r\nbmtool plot connection --sources hippocampus --targets hippocampus --sids pop_name --tids pop_name --no-prepend-pop --title 'Hippocampus Total Connections' total\r\n```\r\n\r\nPython or Jupyter Notebook\r\n```\r\nfrom bmtool import bmplot\r\n\r\nbmplot.connection_matrix(config=\"simulation_config.json\", sources=\"hippocampus\", targets=\"hippocampus\", sids=\"pop_name\", tids=\"pop_name\", no_prepend_pop=True, title=\"Hippocampus Total Connections\")\r\n```\r\n\r\n![bmtool](./figures/connection.png \"Connection Figure\")\r\n\r\n### Plot Total Connections\r\n\r\nTo plot the total number of connections between two populations of cells run \r\n\r\nCommand line\r\n```\r\nbmtool plot connection total\r\n```\r\nPython or Jupyter Notebook\r\n```\r\nfrom bmtool import bmplot\r\n\r\nbmplot.connection_matrix(config=\"simulation_config.json\", sources=\"hippocampus\", targets=\"hippocampus\")\r\n```\r\nRemember to customize the output using the instructions above.\r\n\r\n#### `--synfo`\r\nThis is an additional flag that can be used in the total connections plot. By default it is set to '0' which plots total connections. \r\nIf it is specified as '1', it plots the mean and standard deviation number of connections. If it is '2', it plots the .mod files used for that connection type.\r\nFinally if it is '3', it plots the parameter file (.json) used for the connection.\r\n\r\n![bmtool](./figures/connection_total.png \"Connection Total Figure\")\r\n\r\n### Plot Average Convergence/Divergence\r\n\r\nTo plot the average convergence or divergence of a single cell excute one of the following commands:\r\n\r\nCommand Line\r\n```\r\nbmtool plot connection convergence\r\nbmtool plot connection divergence\r\n\r\nAdd --method (std, min, or max) for additional function\r\n```\r\n\r\nPython or Jupyter Notebook\r\n```\r\nfrom bmtool import bmplot\r\n\r\nbmplot.convergence_connection_matrix(config=\"simulation_config.json\")\r\nbmplot.divergence_connection_matrix(config=\"simulation_config.json\")\r\n\r\n# OR using methods (min,max,std)\r\nbmplot.convergence_connection_matrix(config=\"simulation_config.json\", method=\"min\")\r\n```\r\n\r\n![bmtool](./figures/connection_con.png \"Connection Convergence Figure\")\r\n\r\n### Plot Connection Diagram\r\n\r\nTo plot a rough sketch of cell type connectivity and the type of synapse used between cells run:\r\n\r\nCommand Line\r\n```\r\nbmtool plot connection network-graph\r\n```\r\n\r\nPython or Jupyter Notebook\r\n```\r\nfrom bmtool import bmplot\r\n\r\nbmplot.plot_network_graph(config=\"simulation_config.json\")\r\n```\r\n\r\n![bmtool](./figures/connection_graph.png \"Connection Graph Figure\")\r\n\r\n\r\n`--edge-property` is an option available to change the synapse name if supplied to `NetworkBuilder.add_edges` when building the network. Default: `model_template`\r\n\r\n### Edge Property Histograms\r\n\r\nTo view the distribution of an edge property between cell types run:\r\n\r\nCommand Line\r\n```\r\nbmtool plot connection property-histogram-matrix\r\n```\r\n\r\nPython or Jupyter Notebook\r\n```\r\nfrom bmtool import bmplot\r\n\r\nbmplot.edge_histogram_matrix(config=\"simulation_config.json\")\r\n```\r\n\r\nThe following figure was generated using \r\n```\r\nbmtool plot connection --sources hippocampus --targets hippocampus --sids pop_name --tids pop_name --no-prepend-pop --title 'Synaptic Weight Distribution between Cell Types' property-histogram-matrix\r\n```\r\n\r\n```\r\nfrom bmtool import bmplot\r\n\r\nbmplot.edge_histogram_matrix(config=\"simulation_config.json\", sources=\"hippocampus\", targets=\"hippocampus\", sids=\"pop_name\", tids=\"pop_name\", no_prepend_pop=True, title=\"Synaptic Weight Distribution between Cell Types\")\r\n```\r\n\r\n![bmtool](./figures/connection_hist.png \"Connection Histogram Figure\")\r\n\r\nBy default the `property-histogram-matrix` looks at the `syn_weight` value specified in the `NetworkBuilder.add_edges` function when building your network. You can change this by specifying the `--edge-property`. Eg: \r\n```\r\nbmtool plot connection property-histogram-matrix --edge-property [PROPERTY]\r\n```\r\n\r\n#### Plotting edge values during/after runtime\r\n\r\nBMTool is capable of plotting connection properties obtained after runtime from reports. This is useful for synaptic weights that change over time. \r\n\r\nFirst, you must explicitly record the connection property in your `simulation_config.json`\r\n\r\n```\r\n  \"reports\": {\r\n    \"syn_report\": {\r\n      \"cells\": \"hippocampus\",\r\n      \"variable_name\": \"W_nmda\",\r\n      \"module\": \"netcon_report\",\r\n      \"sections\": \"soma\",\r\n      \"syn_type\": \"pyr2pyr\",\r\n      \"file_name\": \"syns.h5\"\r\n    }\r\n  }\r\n```\r\nWhere `pyr2pyr` is the `POINT_PROCESS` name for the synapse you're attempting to record, and the `variable_name` is a `RANGE` variable listed int the `NEURON` block of the synapse `.mod` file.\r\n\r\nOnce the simulation has been run un the following referencing the report specified above:\r\n\r\n```\r\nbmtool plot connection property-histogram-matrix --edge-property pyr2pyr_w --report output/syns.h5 --time 9999\r\n```\r\n\r\nThe `--time-compare` option can be be used to show the weight distribution change between the specified times. Eg: ` --time 0 --time-compare 10000`\r\n\r\nSee the [BMTK Commit](https://github.com/AllenInstitute/bmtk/pull/67/files) for more details.\r\n\r\n### Plotting Distance Probability Matrix between cell types\r\n\r\n![bmtool](./figures/connection_dist.png \"Connection Histogram Figure\")\r\n\r\nTo show the probability of a cell type being connected to another cell type based on distance run:\r\n\r\n```\r\nbmtool plot connection prob\r\n```\r\n\r\nFull summary of options:\r\n\r\n```\r\n> bmtool plot connection prob --help\r\nUsage: bmtool plot connection prob [OPTIONS]\r\n\r\n  Probabilities for a connection between given populations. Distance and\r\n  type dependent\r\n\r\nOptions:\r\n  --axis TEXT  comma separated list of axis to use for distance measure eg:\r\n               x,y,z or x,y\r\n  --bins TEXT  number of bins to separate distances into (resolution) -\r\n               default: 8\r\n  --line       Create a line plot instead of a binned bar plot\r\n  --verbose    Print plot values for use in another script\r\n  --help       Show this message and exit.\r\n```\r\n\r\nA more complete command (used for image above) may look similar to\r\n\r\n```\r\nbmtool plot connection --sources hippocampus --targets hippocampus --no-prepend-pop --sids pop_name --tids pop_name prob --bins 10 --line --verbose\r\n```\r\n\r\nThis will plot cells in the `hippocampus` network, using the `pop_name` as the cell identifier. There will be `10` bins created to group the cell distances. A `line` plot will be generated instead of the default `bar` chart. All values for each plot will be printed to the console due to the `verbose` flag.\r\n\r\nAll  `point_process` cell types will be ignored since they do not have physical locations.\r\n\r\n### Plot 3d cell location and rotation\r\nPlot the location and rotation of your cells. Plot all of your cells with a single command\r\n```\r\nbmtool plot cell rotation\r\n```\r\n![bmtool](./figures/rotation3d_1.png \"3d Rotation Figure\")\r\n\r\nCustomize your plot by limiting the cells you want or selecting a max number of cells to plot.\r\n```\r\nbmtool plot --config simulation_configECP.json cell rotation --group-by pop_name --group CR --max-cells 100 --quiver-length 100 --arrow-length-ratio 0.25\r\n```\r\n![bmtool](./figures/rotation3d_2.png \"3d Rotation Figure\")\r\n\r\nCode\r\n```\r\nfrom bmtool import\r\nfrom bmtool import bmplot\r\n\r\nbmplot.cell_rotation_3d(config=config,\r\n                     populations=populations,\r\n                     group_by=group_by,\r\n                     group=group,\r\n                     title=title,\r\n                     max_cells=max_cells,\r\n                     quiver_length=quiver_length,\r\n                     arrow_length_ratio=arrow_length_ratio)\r\n```\r\n\r\n### Plotting Current Clamp and Spike Train Info\r\nTo plot all current clamp info involved in a simulation, use the following command (uses 'simulation_config.json' as default)\r\n```\r\nbmtool plot --config simulation_config_foo.json iclamp\r\n```\r\n\r\nTo plot all spike trains and their target cells,\r\n```\r\nbmtool plot --config simulation_config_foo.json input\r\n```\r\n\r\n### Printing basic cell information involved in a simulation\r\n```\r\nbmtool plot --config simulation_config_foo.json cells\r\n```\r\n\r\n### Simulation Summary\r\n\r\nUsing previous functions, plots connection probability as a function of distance, total connections, cell information, current clamp information, input spike train information, and a 3D plot of the network if specified. \r\n```\r\nbmtool plot --config simulation_config_foo.json summary\r\n```\r\n\r\n### Connectors Module\r\n\r\nThis module contains helper functions and classes that work with BMTK's NetworkBuilder module in building networks. It facilitates building reciprocal connections, distance dependent connections, afferent connections, etc. See documentation inside the script `connectors.py` for usage.\r\n```\r\nfrom bmtool import connectors\r\n```\r\n\r\n## Cell Tuning\r\n\r\n### Python/Jupyter\r\n\r\nSingle Cell Profiler\r\n\r\n```\r\nfrom bmtool.singlecell import Profiler\r\n\r\n#Example usage\r\nprofiler = Profiler(template_dir='./components/templates', mechanism_dir='./components/mechanisms/modfiles')\r\nprofiler.passive_properties('Cell_Cf')\r\nprofiler.fi_curve('Cell_Cf')\r\nprofiler.current_injection('Cell_Cf', post_init_function=\"insert_mechs(123)\", inj_amp=300, inj_delay=100)\r\n```\r\n\r\n### Single Cell Tuning\r\n\r\nFrom a BMTK Model directory containing a `simulation_config.json` file:\r\n```\r\nbmtool util cell tune --builder\r\n```\r\n\r\nFor non-BMTK cell tuning:\r\n```\r\nbmtool util cell --template TemplateFile.hoc --mod-folder ./ tune --builder\r\n```\r\n![bmtool](./figures/figure2.png \"Tuning Figure\")\r\n\r\n### FIR Curve plotting\r\n\r\n```\r\n> bmtool util cell fi --help\r\nUsage: bmtool util cell fi [OPTIONS]\r\n\r\n  Creates a NEURON GUI window with FI curve and passive properties\r\n\r\nOptions:\r\n  --title TEXT\r\n  --min-pa INTEGER   Min pA for injection\r\n  --max-pa INTEGER   Max pA for injection\r\n  --increment FLOAT  Increment the injection by [i] pA\r\n  --tstart INTEGER   Injection start time\r\n  --tdur INTEGER     Duration of injection default:1000ms\r\n  --advanced         Interactive dialog to select injection and recording\r\n                     points\r\n  --help             Show this message and exit.\r\n\r\n> bmtool util cell fi\r\n? Select a cell:  (Use arrow keys)\r\n \u00c2\u00bb CA3PyramidalCell\r\n   DGCell\r\n   IzhiCell\r\n   IzhiCell_BC\r\n   IzhiCell_EC\r\n   IzhiCell_EC2\r\n   IzhiCell_EC_BIO\r\n   IzhiCell_EmoExcitatory\r\n   IzhiCell_EmoInhibitory\r\n   IzhiCell_OLM\r\n   IzhiCell_int\r\n```\r\n\r\n![bmtool](./figures/figure3.png \"FIR Figure\")\r\n\r\n### VHalf Segregation Module\r\n\r\nBased on the Alturki et al. (2016) paper.\r\n\r\nSegregate your channel activation for an easier time tuning your cells.\r\n\r\n\r\n```\r\n> bmtool util cell vhseg --help\r\n\r\nUsage: bmtool util cell vhseg [OPTIONS]\r\n\r\n  Alturki et al. (2016) V1/2 Automated Segregation Interface, simplify\r\n  tuning by separating channel activation\r\n\r\nOptions:\r\n  --title TEXT\r\n  --tstop INTEGER\r\n  --outhoc TEXT         Specify the file you want the modified cell template\r\n                        written to\r\n  --outfolder TEXT      Specify the directory you want the modified cell\r\n                        template and mod files written to (default: _seg)\r\n  --outappend           Append out instead of overwriting (default: False)\r\n  --debug               Print all debug statements\r\n  --fminpa INTEGER      Starting FI Curve amps (default: 0)\r\n  --fmaxpa INTEGER      Ending FI Curve amps (default: 1000)\r\n  --fincrement INTEGER  Increment the FI Curve amps by supplied pA (default:\r\n                        100)\r\n  --infvars TEXT        Specify the inf variables to plot, skips the wizard.\r\n                        (Comma separated, eg: inf_mech,minf_mech2,ninf_mech2)\r\n  --segvars TEXT        Specify the segregation variables to globally set,\r\n                        skips the wizard. (Comma separated, eg:\r\n                        mseg_mech,nseg_mech2)\r\n  --eleak TEXT          Specify the eleak var manually\r\n  --gleak TEXT          Specify the gleak var manually\r\n  --othersec TEXT       Specify other sections that a window should be\r\n                        generated for (Comma separated, eg: dend[0],dend[1])\r\n  --help                Show this message and exit.\r\n\r\n```\r\n\r\n#### Examples \r\n\r\nWizard Mode (Interactive)\r\n\r\n```\r\n> bmtool util cell vhseg\r\n\r\n? Select a cell:  CA3PyramidalCell\r\nUsing section dend[0]\r\n? Show other sections? (default: No)  Yes\r\n? Select other sections (space bar to select):  done (2 selections)\r\n? Select inf variables to plot (space bar to select):   done (5 selections)\r\n? Select segregation variables [OR VARIABLES YOU WANT TO CHANGE ON ALL SEGMENTS at the same time] (space bar to select):  done (2 selections)\r\n```\r\n\r\nCommand Mode (Non-interactive)\r\n\r\n```\r\nbmtool util cell --template CA3PyramidalCell vhseg --othersec dend[0],dend[1] --infvars inf_im --segvars gbar_im --gleak gl_ichan2CA3 --eleak el_ichan2CA3\r\n```\r\n\r\nExample:\r\n\r\n![bmtool](./figures/figure4.png \"Seg Figure\")\r\n\r\nSimple models can utilize \r\n``` \r\nbmtool util cell --hoc cell_template.hoc vhsegbuild --build\r\nbmtool util cell --hoc segmented_template.hoc vhsegbuild\r\n```\r\nex: [https://github.com/tjbanks/two-cell-hco](https://github.com/tjbanks/two-cell-hco)\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "BMTool",
    "version": "0.4.1",
    "project_urls": {
        "Homepage": "https://github.com/tjbanks/bmtool"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d86b82a954271d5082b2b4fd51df975bb747e929ef54a2c270955ededb405a20",
                "md5": "acf5332c870d27e2fae1366fde176b46",
                "sha256": "9238cd75eb181fccda2491659466f19c0c502ef1640426fef9fd6e7ef4f1c7eb"
            },
            "downloads": -1,
            "filename": "bmtool-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "acf5332c870d27e2fae1366fde176b46",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 143979,
            "upload_time": "2023-06-15T00:32:43",
            "upload_time_iso_8601": "2023-06-15T00:32:43.038339Z",
            "url": "https://files.pythonhosted.org/packages/d8/6b/82a954271d5082b2b4fd51df975bb747e929ef54a2c270955ededb405a20/bmtool-0.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3a5ca662526383b301087607165f61d411ad46f52bbdd2f4817f33e8ac76eab4",
                "md5": "bdc8bb2fa5e83a1b2dea9f0418da30e0",
                "sha256": "5e25e763cfba818520e4d45180571a91b94103dbda56eb87083d6ef7feca0c84"
            },
            "downloads": -1,
            "filename": "bmtool-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "bdc8bb2fa5e83a1b2dea9f0418da30e0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 84647,
            "upload_time": "2023-06-15T00:32:48",
            "upload_time_iso_8601": "2023-06-15T00:32:48.797796Z",
            "url": "https://files.pythonhosted.org/packages/3a/5c/a662526383b301087607165f61d411ad46f52bbdd2f4817f33e8ac76eab4/bmtool-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-15 00:32:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tjbanks",
    "github_project": "bmtool",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "bmtool"
}
        
Elapsed time: 0.10688s