bmtool 0.6.9.16__py3-none-any.whl → 0.6.9.18__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
bmtool/bmplot.py CHANGED
@@ -35,7 +35,17 @@ python -m bmtool.plot
35
35
 
36
36
  def is_notebook() -> bool:
37
37
  """
38
- Used to tell if inside jupyter notebook or not. This is used to tell if we should use plt.show or not
38
+ Detect if code is running in a Jupyter notebook environment.
39
+
40
+ Returns:
41
+ --------
42
+ bool
43
+ True if running in a Jupyter notebook, False otherwise.
44
+
45
+ Notes:
46
+ ------
47
+ This is used to determine whether to call plt.show() explicitly or
48
+ rely on Jupyter's automatic display functionality.
39
49
  """
40
50
  try:
41
51
  shell = get_ipython().__class__.__name__
@@ -48,18 +58,42 @@ def is_notebook() -> bool:
48
58
  except NameError:
49
59
  return False # Probably standard Python interpreter
50
60
 
51
- def total_connection_matrix(config=None,title=None,sources=None, targets=None, sids=None, tids=None,no_prepend_pop=False,save_file=None,synaptic_info='0',include_gap=True):
61
+ def total_connection_matrix(config=None, title=None, sources=None, targets=None, sids=None, tids=None, no_prepend_pop=False, save_file=None, synaptic_info='0', include_gap=True):
52
62
  """
53
- Generates connection plot displaying total connection or other stats
54
- config: A BMTK simulation config
55
- sources: network name(s) to plot
56
- targets: network name(s) to plot
57
- sids: source node identifier
58
- tids: target node identifier
59
- no_prepend_pop: dictates if population name is displayed before sid or tid when displaying graph
60
- save_file: If plot should be saved
61
- synaptic_info: '0' for total connections, '1' for mean and stdev connections, '2' for all synapse .mod files used, '3' for all synapse .json files used
62
- include_gap: Determines if connectivity shown should include gap junctions + chemical synapses. False will only include chemical
63
+ Generate a plot displaying total connections or other synaptic statistics.
64
+
65
+ Parameters:
66
+ -----------
67
+ config : str
68
+ Path to a BMTK simulation config file.
69
+ title : str, optional
70
+ Title for the plot. If None, a default title will be used.
71
+ sources : str
72
+ Comma-separated string of network names to use as sources.
73
+ targets : str
74
+ Comma-separated string of network names to use as targets.
75
+ sids : str, optional
76
+ Comma-separated string of source node identifiers to filter.
77
+ tids : str, optional
78
+ Comma-separated string of target node identifiers to filter.
79
+ no_prepend_pop : bool, optional
80
+ If True, don't display population name before sid or tid in the plot.
81
+ save_file : str, optional
82
+ Path to save the plot. If None, plot is not saved.
83
+ synaptic_info : str, optional
84
+ Type of information to display:
85
+ - '0': Total connections (default)
86
+ - '1': Mean and standard deviation of connections
87
+ - '2': All synapse .mod files used
88
+ - '3': All synapse .json files used
89
+ include_gap : bool, optional
90
+ If True, include gap junctions and chemical synapses in the analysis.
91
+ If False, only include chemical synapses.
92
+
93
+ Returns:
94
+ --------
95
+ None
96
+ The function generates and displays a plot.
63
97
  """
64
98
  if not config:
65
99
  raise Exception("config not defined")
@@ -596,7 +630,7 @@ def edge_histogram_matrix(config=None,sources = None,targets=None,sids=None,tids
596
630
  report : str, optional
597
631
  Name of the report to analyze.
598
632
  title : str, optional
599
- Custom title for the plot. If None, defaults to "{edge_property} Histogram Matrix".
633
+ Custom title for the plot.
600
634
  save_file : str, optional
601
635
  Path to save the generated plot.
602
636
 
bmtool/connectors.py CHANGED
@@ -17,7 +17,21 @@ report_name = 'conn.csv'
17
17
 
18
18
  # Utility Functions
19
19
  def num_prop(ratio, N):
20
- """Calculate numbers of total N in proportion to ratio"""
20
+ """
21
+ Calculate numbers of total N in proportion to ratio.
22
+
23
+ Parameters:
24
+ -----------
25
+ ratio : array-like
26
+ Proportions to distribute N across.
27
+ N : int
28
+ Total number to distribute.
29
+
30
+ Returns:
31
+ --------
32
+ numpy.ndarray
33
+ Array of integers that sum to N, proportionally distributed according to ratio.
34
+ """
21
35
  ratio = np.asarray(ratio)
22
36
  p = np.cumsum(np.insert(ratio.ravel(), 0, 0)) # cumulative proportion
23
37
  return np.diff(np.round(N / p[-1] * p).astype(int)).reshape(ratio.shape)
@@ -25,9 +39,20 @@ def num_prop(ratio, N):
25
39
 
26
40
  def decision(prob, size=None):
27
41
  """
28
- Make single random decision based on input probability.
29
- prob: scalar input
30
- Return bool array if size specified, otherwise scalar
42
+ Make random decision(s) based on input probability.
43
+
44
+ Parameters:
45
+ -----------
46
+ prob : float
47
+ Probability threshold between 0 and 1.
48
+ size : int or tuple, optional
49
+ Size of the output array. If None, a single decision is returned.
50
+
51
+ Returns:
52
+ --------
53
+ bool or numpy.ndarray
54
+ Boolean result(s) of the random decision(s). True if the random number
55
+ is less than prob, False otherwise.
31
56
  """
32
57
  return rng.random(size) < prob
33
58
 
@@ -35,8 +60,17 @@ def decision(prob, size=None):
35
60
  def decisions(prob):
36
61
  """
37
62
  Make multiple random decisions based on input probabilities.
38
- prob: iterable
39
- Return bool array of the same shape
63
+
64
+ Parameters:
65
+ -----------
66
+ prob : array-like
67
+ Array of probability thresholds between 0 and 1.
68
+
69
+ Returns:
70
+ --------
71
+ numpy.ndarray
72
+ Boolean array with the same shape as prob, containing results of
73
+ the random decisions.
40
74
  """
41
75
  prob = np.asarray(prob)
42
76
  return rng.random(prob.shape) < prob
@@ -130,26 +164,36 @@ def gaussian(x, mean=0., stdev=1., pmax=NORM_COEF):
130
164
 
131
165
  class GaussianDropoff(DistantDependentProbability):
132
166
  """
133
- Object for calculating connection probability following a Gaussian function
134
- of the distance between cells, using spherical or cylindrical distance.
135
-
167
+ Connection probability class that follows a Gaussian function of distance.
168
+
169
+ This class calculates connection probabilities using a Gaussian function
170
+ of the distance between cells, with options for spherical or cylindrical metrics.
171
+
136
172
  Parameters:
137
- mean, stdev: Parameters for the Gaussian function.
138
- min_dist, max_dist: Distance range for any possible connection,
139
- the support of the Gaussian function.
140
- pmax: The maximum value of the Gaussian function at its mean parameter.
141
- ptotal: Overall probability within distance range. If specified, ignore
142
- input pmax, and calculate pmax. See calc_pmax_from_ptotal() method.
143
- ptotal_dist_range: Distance range for calculating pmax when ptotal is
144
- specified. If not specified, set to range (min_dist, max_dist).
145
- dist_type: 'spherical' or 'cylindrical' for distance metric.
146
- Used when ptotal is specified.
147
-
148
- Returns:
149
- A callable object. When called with a single distance input,
150
- returns the probability value.
151
-
152
- TODO: Accept convergence and cell density information for calculating pmax.
173
+ -----------
174
+ mean : float, optional
175
+ Mean parameter of the Gaussian function, typically 0 for peak at origin.
176
+ stdev : float, optional
177
+ Standard deviation parameter controlling the width of the Gaussian.
178
+ min_dist : float, optional
179
+ Minimum distance for connections. Below this distance, probability is zero.
180
+ max_dist : float, optional
181
+ Maximum distance for connections. Above this distance, probability is zero.
182
+ pmax : float, optional
183
+ Maximum probability value at the peak of the Gaussian function.
184
+ ptotal : float, optional
185
+ Overall connection probability within the specified distance range.
186
+ If provided, pmax is calculated to achieve this overall probability.
187
+ ptotal_dist_range : tuple, optional
188
+ Distance range (min_dist, max_dist) for calculating pmax when ptotal is provided.
189
+ dist_type : str, optional
190
+ Distance metric to use, either 'spherical' (default) or 'cylindrical'.
191
+
192
+ Notes:
193
+ ------
194
+ When ptotal is specified, the maximum probability (pmax) is calculated to achieve
195
+ the desired overall connection probability within the specified distance range,
196
+ assuming homogeneous cell density.
153
197
  """
154
198
 
155
199
  def __init__(self, mean=0., stdev=1., min_dist=0., max_dist=np.inf,
bmtool/graphs.py CHANGED
@@ -4,12 +4,24 @@ import bmtool.util.util as u
4
4
  import pandas as pd
5
5
 
6
6
 
7
- def generate_graph(config,source,target):
7
+ def generate_graph(config, source, target):
8
8
  """
9
- returns a graph object
10
- config: A BMTK simulation config
11
- source: network name
12
- target: network name
9
+ Generate a NetworkX graph from BMTK network configuration.
10
+
11
+ Parameters:
12
+ -----------
13
+ config : str
14
+ Path to a BMTK simulation config file.
15
+ source : str
16
+ Network name for source nodes.
17
+ target : str
18
+ Network name for target nodes.
19
+
20
+ Returns:
21
+ --------
22
+ nx.DiGraph
23
+ A directed graph representing the network with nodes containing
24
+ position and population information.
13
25
  """
14
26
  nodes,edges = u.load_nodes_edges_from_config(config)
15
27
  nodes_source = nodes[source]
@@ -131,11 +143,24 @@ def generate_graph(config,source,target):
131
143
 
132
144
  def export_node_connections_to_csv(Graph, filename):
133
145
  """
134
- Generates a CSV file with node type and all outgoing connections that node has.
146
+ Generate a CSV file with node type and all incoming connections that node has.
135
147
 
136
148
  Parameters:
137
- Graph: a DiGraph object (directed graph)
138
- filename: A string for the name of output, must end in .csv
149
+ -----------
150
+ Graph : nx.DiGraph
151
+ A directed graph object from NetworkX.
152
+ filename : str
153
+ Path and filename for the output CSV file (must end in .csv).
154
+
155
+ Returns:
156
+ --------
157
+ None
158
+ The function saves the results to the specified CSV file.
159
+
160
+ Notes:
161
+ ------
162
+ The resulting CSV file will have the node label as the first column,
163
+ followed by columns for each type of incoming connection.
139
164
  """
140
165
  # Create an empty dictionary to store the connections for each node
141
166
  node_connections = {}
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: bmtool
3
+ Version: 0.6.9.18
4
+ Summary: BMTool
5
+ Home-page: https://github.com/cyneuro/bmtool
6
+ Download-URL:
7
+ Author: Neural Engineering Laboratory at the University of Missouri
8
+ Author-email: gregglickert@mail.missouri.edu
9
+ License: MIT
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Education
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.6
16
+ Classifier: Topic :: Software Development :: Libraries
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Operating System :: OS Independent
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: bmtk
22
+ Requires-Dist: click
23
+ Requires-Dist: clint
24
+ Requires-Dist: h5py
25
+ Requires-Dist: matplotlib
26
+ Requires-Dist: networkx
27
+ Requires-Dist: numpy
28
+ Requires-Dist: pandas
29
+ Requires-Dist: questionary
30
+ Requires-Dist: pynmodlt
31
+ Requires-Dist: xarray
32
+ Requires-Dist: fooof
33
+ Requires-Dist: requests
34
+ Requires-Dist: pyyaml
35
+ Requires-Dist: PyWavelets
36
+ Requires-Dist: numba
37
+ Dynamic: author
38
+ Dynamic: author-email
39
+ Dynamic: classifier
40
+ Dynamic: description
41
+ Dynamic: description-content-type
42
+ Dynamic: home-page
43
+ Dynamic: license
44
+ Dynamic: license-file
45
+ Dynamic: requires-dist
46
+ Dynamic: summary
47
+
48
+ # bmtool
49
+ A collection of modules to make developing [Neuron](https://www.neuron.yale.edu/neuron/) and [BMTK](https://alleninstitute.github.io/bmtk/) models easier.
50
+
51
+ [![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/cyneuro/bmtool/blob/master/LICENSE)
52
+
53
+ ## In depth documentation and examples can be found [here](https://cyneuro.github.io/bmtool/)
54
+
55
+ ## Getting Started
56
+
57
+ **Installation**
58
+ ```bash
59
+ pip install bmtool
60
+ ```
61
+ For developers who will be pulling down additional updates to this repository regularly use the following instead.
62
+ ```bash
63
+ git clone https://github.com/cyneuro/bmtool.git
64
+ cd bmtool
65
+ python setup.py develop
66
+ ```
67
+ Then download updates (from this directory) with
68
+ ```bash
69
+ git pull
70
+ ```
71
+
72
+ BMTool provides several modules to simplify the development of computational neuroscience models with NEURON and the Brain Modeling Toolkit (BMTK). It offers functionality for:
73
+
74
+ - **Single Cell Modeling**: Analyze passive properties, current injection, FI curves, and impedance profiles
75
+ - **Synapse Development**: Tools for tuning synaptic properties and gap junctions
76
+ - **Network Construction**: Connectors for building complex network structures
77
+ - **Visualization**: Plot connection matrices, network positions, and more
78
+ - **Simulation Management**: Run simulations on SLURM clusters with parameter sweeps
79
+ - **Analysis**: Process simulation results efficiently
@@ -1,9 +1,9 @@
1
1
  bmtool/SLURM.py,sha256=PST_jOD5ZmwbJj15Tgq3UIvdq4FYN4EkPuDt66P8OXU,20136
2
2
  bmtool/__init__.py,sha256=ZStTNkAJHJxG7Pwiy5UgCzC4KlhMS5pUNPtUJZVwL_Y,136
3
3
  bmtool/__main__.py,sha256=TmFkmDxjZ6250nYD4cgGhn-tbJeEm0u-EMz2ajAN9vE,650
4
- bmtool/bmplot.py,sha256=TPkdqenzY_ovAISSiGFk98pmoe6Q5_2WoZg9o7nKNWI,61873
5
- bmtool/connectors.py,sha256=hWkUUcJ4tmas8NDOFPPjQT-TgTlPcpjuZsYyAW2WkPA,72242
6
- bmtool/graphs.py,sha256=K8BiughRUeXFVvAgo8UzrwpSClIVg7UfmIcvtEsEsk0,6020
4
+ bmtool/bmplot.py,sha256=gJY1frsYXiR5XxbSDdzHpIfnE1TPFuuknmUBsl6Bohs,62714
5
+ bmtool/connectors.py,sha256=7IKsUZNEiiojzTzNL67zqQCMrQEk_qKE7x_u4SqqsbM,73495
6
+ bmtool/graphs.py,sha256=ShBgJr1iZrM3ugU2wT6hbhmBAkc3mmf7yZQfPuPEqPM,6691
7
7
  bmtool/manage.py,sha256=_lCU0qBQZ4jSxjzAJUd09JEetb--cud7KZgxQFbLGSY,657
8
8
  bmtool/plot_commands.py,sha256=Tqujyf0c0u8olhiHOMwgUSJXIIE1hgjv6otb25G9cA0,12298
9
9
  bmtool/singlecell.py,sha256=imcdxIzvYVkaOLSGDxYp8WGGssGwXXBCRhzhlqVp7hA,44267
@@ -19,9 +19,9 @@ bmtool/util/commands.py,sha256=zJF-fiLk0b8LyzHDfvewUyS7iumOxVnj33IkJDzux4M,64396
19
19
  bmtool/util/util.py,sha256=00vOAwTVIifCqouBoFoT0lBashl4fCalrk8fhg_Uq4c,56654
20
20
  bmtool/util/neuron/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  bmtool/util/neuron/celltuner.py,sha256=xSRpRN6DhPFz4q5buq_W8UmsD7BbUrkzYBEbKVloYss,87194
22
- bmtool-0.6.9.16.dist-info/licenses/LICENSE,sha256=qrXg2jj6kz5d0EnN11hllcQt2fcWVNumx0xNbV05nyM,1068
23
- bmtool-0.6.9.16.dist-info/METADATA,sha256=Zmwi4JuYibdyYvc9l8RLeiKPiFqrRU-XAf850kY_cx4,20479
24
- bmtool-0.6.9.16.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
25
- bmtool-0.6.9.16.dist-info/entry_points.txt,sha256=0-BHZ6nUnh0twWw9SXNTiRmKjDnb1VO2DfG_-oprhAc,45
26
- bmtool-0.6.9.16.dist-info/top_level.txt,sha256=gpd2Sj-L9tWbuJEd5E8C8S8XkNm5yUE76klUYcM-eWM,7
27
- bmtool-0.6.9.16.dist-info/RECORD,,
22
+ bmtool-0.6.9.18.dist-info/licenses/LICENSE,sha256=qrXg2jj6kz5d0EnN11hllcQt2fcWVNumx0xNbV05nyM,1068
23
+ bmtool-0.6.9.18.dist-info/METADATA,sha256=spdS9_tiyimQL_IyZT52Osm15hNSWPqa6LLWiVW0j44,2769
24
+ bmtool-0.6.9.18.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
25
+ bmtool-0.6.9.18.dist-info/entry_points.txt,sha256=0-BHZ6nUnh0twWw9SXNTiRmKjDnb1VO2DfG_-oprhAc,45
26
+ bmtool-0.6.9.18.dist-info/top_level.txt,sha256=gpd2Sj-L9tWbuJEd5E8C8S8XkNm5yUE76klUYcM-eWM,7
27
+ bmtool-0.6.9.18.dist-info/RECORD,,
@@ -1,610 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: bmtool
3
- Version: 0.6.9.16
4
- Summary: BMTool
5
- Home-page: https://github.com/cyneuro/bmtool
6
- Download-URL:
7
- Author: Neural Engineering Laboratory at the University of Missouri
8
- Author-email: gregglickert@mail.missouri.edu
9
- License: MIT
10
- Classifier: Intended Audience :: Developers
11
- Classifier: Intended Audience :: Education
12
- Classifier: Intended Audience :: Science/Research
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.6
16
- Classifier: Topic :: Software Development :: Libraries
17
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
- Classifier: Operating System :: OS Independent
19
- Description-Content-Type: text/markdown
20
- License-File: LICENSE
21
- Requires-Dist: bmtk
22
- Requires-Dist: click
23
- Requires-Dist: clint
24
- Requires-Dist: h5py
25
- Requires-Dist: matplotlib
26
- Requires-Dist: networkx
27
- Requires-Dist: numpy
28
- Requires-Dist: pandas
29
- Requires-Dist: questionary
30
- Requires-Dist: pynmodlt
31
- Requires-Dist: xarray
32
- Requires-Dist: fooof
33
- Requires-Dist: requests
34
- Requires-Dist: pyyaml
35
- Requires-Dist: PyWavelets
36
- Requires-Dist: numba
37
- Dynamic: author
38
- Dynamic: author-email
39
- Dynamic: classifier
40
- Dynamic: description
41
- Dynamic: description-content-type
42
- Dynamic: home-page
43
- Dynamic: license
44
- Dynamic: license-file
45
- Dynamic: requires-dist
46
- Dynamic: summary
47
-
48
- # bmtool
49
- A collection of modules to make developing [Neuron](https://www.neuron.yale.edu/neuron/) and [BMTK](https://alleninstitute.github.io/bmtk/) models easier.
50
-
51
- [![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/cyneuro/bmtool/blob/master/LICENSE)
52
-
53
- ## Table of Contents
54
- - [Getting Started](#getting-started)
55
- - [CLI](#cli)
56
- - [Single Cell](#single-cell-module)
57
- - [Synapses](#synapses-module)
58
- - [Connectors](#connectors-module)
59
- - [Bmplot](#bmplot-module)
60
- - [Analysis](#analysis-module)
61
- - [SLURM](#slurm-module)
62
- - [Graphs](#graphs-module)
63
-
64
- ## Getting Started
65
-
66
- **Installation**
67
- ```bash
68
- pip install bmtool
69
- ```
70
- For developers who will be pulling down additional updates to this repository regularly use the following instead.
71
- ```bash
72
- git clone https://github.com/cyneuro/bmtool.git
73
- cd bmtool
74
- python setup.py develop
75
- ```
76
- Then download updates (from this directory) with
77
- ```bash
78
- git pull
79
- ```
80
-
81
- ## CLI
82
- #### Many of modules available can be accesed using the command line
83
- ```bash
84
- > cd your_bmtk_model_directory
85
- > bmtool
86
- Usage: bmtool [OPTIONS] COMMAND [ARGS]...
87
-
88
- Options:
89
- --verbose Verbose printing
90
- --help Show this message and exit.
91
-
92
- Commands:
93
- debug
94
- plot
95
- util
96
-
97
- >
98
- > bmtool plot
99
- Usage: bmtool plot [OPTIONS] COMMAND [ARGS]...
100
-
101
- Options:
102
- --config PATH Configuration file to use, default: "simulation_config.json"
103
- --no-display When set there will be no plot displayed, useful for saving
104
- plots
105
- --help Show this message and exit.
106
-
107
- Commands:
108
- connection Display information related to neuron connections
109
- positions Plot cell positions for a given set of populations
110
- raster Plot the spike raster for a given population
111
- report Plot the specified report using BMTK's default report plotter
112
- >
113
- ```
114
-
115
- ## Single Cell Module
116
- - [Passive properties](#passive-properties)
117
- - [Current injection](#current-clamp)
118
- - [FI curve](#fi-curve)
119
- - [ZAP](#zap)
120
- - [Tuner](#single-cell-tuning)
121
- - [VHalf Segregation](#vhalf-segregation-module)
122
- #### Jupyter Notebook for how to use passive properties, current injection, FI curve, and ZAP can be found [here](examples/single_cell/). There are versions with example how to use single cells in HOC format and in the Allen Database format.
123
-
124
- #### The single cell module can take any neuron HOC object and calculate passive properties, run a current clamp, calculate FI curve, or run a ZAP. The module is designed to work with HOC template files and can also turn Allen database SWC and json files into HOC objects and use those. The examples below uses "Cell_Cf" which is the name of a HOC templated loaded by the profiler. E
125
-
126
- #### First step is it initialize the profiler.
127
-
128
-
129
- ```python
130
- from bmtool.singlecell import Profiler
131
- profiler = Profiler(template_dir='templates', mechanism_dir = 'mechanisms', dt=0.1)
132
- ```
133
-
134
- #### Can provide any single cell module with either name of Hoc template or a HOC object. If you are wanted to use Allen database SWC and json files you can use the following function
135
-
136
-
137
- ```python
138
- from bmtool.singlecell import load_allen_database_cells
139
- cell = load_allen_database_cells(path_to_SWC_file,path_to_json_file)
140
- ```
141
-
142
- ### Passive properties
143
- #### Calculates the passive properties(V-rest, Rin and tau) of a HOC object
144
-
145
-
146
- ```python
147
- from bmtool.singlecell import Passive,run_and_plot
148
- import matplotlib.pyplot as plt
149
- sim = Passive('Cell_Cf', inj_amp=-100., inj_delay=1500., inj_dur=1000., tstop=2500., method='exp2')
150
- title = 'Passive Cell Current Injection'
151
- xlabel = 'Time (ms)'
152
- ylabel = 'Membrane Potential (mV)'
153
- X, Y = run_and_plot(sim, title, xlabel, ylabel, plot_injection_only=True)
154
- plt.gca().plot(*sim.double_exponential_fit(), 'r:', label='double exponential fit')
155
- plt.legend()
156
- plt.show()
157
- ```
158
-
159
- Injection location: Cell_Cf[0].soma[0](0.5)
160
- Recording: Cell_Cf[0].soma[0](0.5)._ref_v
161
- Running simulation for passive properties...
162
-
163
- V Rest: -70.21 (mV)
164
- Resistance: 128.67 (MOhms)
165
- Membrane time constant: 55.29 (ms)
166
-
167
- V_rest Calculation: Voltage taken at time 1500.0 (ms) is
168
- -70.21 (mV)
169
-
170
- R_in Calculation: dV/dI = (v_final-v_rest)/(i_final-i_start)
171
- (-83.08 - (-70.21)) / (-0.1 - 0)
172
- 12.87 (mV) / 0.1 (nA) = 128.67 (MOhms)
173
-
174
- Tau Calculation: Fit a double exponential curve to the membrane potential response
175
- f(t) = a0 + a1*exp(-t/tau1) + a2*exp(-t/tau2)
176
- Constained by initial value: f(0) = a0 + a1 + a2 = v_rest
177
- Fit parameters: (a0, a1, a2, tau1, tau2) = (-83.06, -3306.48, 3319.33, 55.29, 55.15)
178
- Membrane time constant is determined from the slowest exponential term: 55.29 (ms)
179
-
180
- Sag potential: v_sag = v_peak - v_final = -0.66 (mV)
181
- Normalized sag potential: v_sag / (v_peak - v_rest) = 0.049
182
-
183
-
184
-
185
-
186
-
187
- ![png](readme_figures/output_8_1.png)
188
-
189
-
190
-
191
- ### Current clamp
192
- #### Runs a current clamp on a HOC object
193
-
194
-
195
- ```python
196
- from bmtool.singlecell import CurrentClamp
197
- sim = CurrentClamp('Cell_Cf', inj_amp=350., inj_delay=1500., inj_dur=1000., tstop=3000., threshold=-15.)
198
- X, Y = run_and_plot(sim, title='Current Injection', xlabel='Time (ms)',
199
- ylabel='Membrane Potential (mV)', plot_injection_only=True)
200
- plt.show()
201
- ```
202
-
203
- Injection location: Cell_Cf[1].soma[0](0.5)
204
- Recording: Cell_Cf[1].soma[0](0.5)._ref_v
205
- Current clamp simulation running...
206
-
207
- Number of spikes: 19
208
-
209
-
210
-
211
-
212
-
213
- ![png](readme_figures/output_10_1.png)
214
-
215
-
216
-
217
- ### FI curve
218
- #### Calculates the frequency vs current injection plot for a HOC object
219
-
220
-
221
- ```python
222
- from bmtool.singlecell import FI
223
- sim = FI('Cell_Cf', i_start=0., i_stop=1000., i_increment=50., tstart=1500.,threshold=-15.)
224
- X, Y = run_and_plot(sim, title='FI Curve', xlabel='Injection (nA)', ylabel='# Spikes')
225
- plt.show()
226
- ```
227
-
228
- Injection location: Cell_Cf[21].soma[0](0.5)
229
- Recording: Cell_Cf[21].soma[0](0.5)._ref_v
230
- Running simulations for FI curve...
231
-
232
- Results
233
- Injection (nA): 0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95
234
- Number of spikes: 0, 1, 10, 12, 15, 16, 17, 19, 20, 20, 21, 21, 22, 23, 23, 24, 25, 25, 26, 27
235
-
236
-
237
-
238
-
239
-
240
- ![png](readme_figures/output_12_1.png)
241
-
242
-
243
-
244
- ### ZAP
245
- #### Runs a ZAP on a HOC object
246
-
247
-
248
- ```python
249
- from bmtool.singlecell import ZAP
250
- sim = ZAP('Cell_Cf')
251
- X, Y = run_and_plot(sim)
252
- plt.show()
253
- ```
254
-
255
- Injection location: Cell_Cf[22].soma[0](0.5)
256
- Recording: Cell_Cf[22].soma[0](0.5)._ref_v
257
- ZAP current simulation running...
258
-
259
- Chirp current injection with frequency changing from 0 to 15 Hz over 15 seconds
260
- Impedance is calculated as the ratio of FFT amplitude of membrane voltage to FFT amplitude of chirp current
261
-
262
-
263
-
264
-
265
-
266
- ![png](readme_figures/output_14_1.png)
267
-
268
-
269
-
270
- ### Single Cell Tuning
271
-
272
- #### From a BMTK Model directory containing a `simulation_config.json` file:
273
- ```bash
274
- bmtool util cell tune --builder
275
- ```
276
-
277
- #### For non-BMTK cell tuning:
278
- ```bash
279
- bmtool util cell --template TemplateFile.hoc --mod-folder ./ tune --builder
280
- ```
281
- ![bmtool](./figures/figure2.png "Tuning Figure")
282
-
283
- ### VHalf Segregation Module
284
-
285
- #### Based on the Alturki et al. (2016) paper.
286
-
287
- #### Segregate your channel activation for an easier time tuning your cells.
288
-
289
-
290
- ```bash
291
- > bmtool util cell vhseg --help
292
-
293
- Usage: bmtool util cell vhseg [OPTIONS]
294
-
295
- Alturki et al. (2016) V1/2 Automated Segregation Interface, simplify
296
- tuning by separating channel activation
297
-
298
- Options:
299
- --title TEXT
300
- --tstop INTEGER
301
- --outhoc TEXT Specify the file you want the modified cell template
302
- written to
303
- --outfolder TEXT Specify the directory you want the modified cell
304
- template and mod files written to (default: _seg)
305
- --outappend Append out instead of overwriting (default: False)
306
- --debug Print all debug statements
307
- --fminpa INTEGER Starting FI Curve amps (default: 0)
308
- --fmaxpa INTEGER Ending FI Curve amps (default: 1000)
309
- --fincrement INTEGER Increment the FI Curve amps by supplied pA (default:
310
- 100)
311
- --infvars TEXT Specify the inf variables to plot, skips the wizard.
312
- (Comma separated, eg: inf_mech,minf_mech2,ninf_mech2)
313
- --segvars TEXT Specify the segregation variables to globally set,
314
- skips the wizard. (Comma separated, eg:
315
- mseg_mech,nseg_mech2)
316
- --eleak TEXT Specify the eleak var manually
317
- --gleak TEXT Specify the gleak var manually
318
- --othersec TEXT Specify other sections that a window should be
319
- generated for (Comma separated, eg: dend[0],dend[1])
320
- --help Show this message and exit.
321
-
322
- ```
323
-
324
- ### Examples
325
-
326
- #### Wizard Mode (Interactive)
327
-
328
- ```bash
329
- > bmtool util cell vhseg
330
-
331
- ? Select a cell: CA3PyramidalCell
332
- Using section dend[0]
333
- ? Show other sections? (default: No) Yes
334
- ? Select other sections (space bar to select): done (2 selections)
335
- ? Select inf variables to plot (space bar to select): done (5 selections)
336
- ? Select segregation variables [OR VARIABLES YOU WANT TO CHANGE ON ALL SEGMENTS at the same time] (space bar to select): done (2 selections)
337
- ```
338
-
339
- #### Command Mode (Non-interactive)
340
-
341
- ```bash
342
- bmtool util cell --template CA3PyramidalCell vhseg --othersec dend[0],dend[1] --infvars inf_im --segvars gbar_im --gleak gl_ichan2CA3 --eleak el_ichan2CA3
343
- ```
344
-
345
- Example:
346
-
347
- ![bmtool](./figures/figure4.png "Seg Figure")
348
-
349
- #### Simple models can utilize
350
- ``` bash
351
- bmtool util cell --hoc cell_template.hoc vhsegbuild --build
352
- bmtool util cell --hoc segmented_template.hoc vhsegbuild
353
- ```
354
- ex: [https://github.com/tjbanks/two-cell-hco](https://github.com/tjbanks/two-cell-hco)
355
-
356
- ### Synapses Module
357
- -[SynapticTuner](#synaptictuner)
358
- -Gap Junction tuner
359
-
360
- #### SynapticTuner - Aids in the tuning of synapses by printing out synaptic properties and giving the user sliders in a Jupyter notebook to tune the synapse. For more info view the example [here](examples/synapses/synaptic_tuner.ipynb)
361
- #### GapJunctionTuner - Provides jupyter sliders to tune for coupling coefficient in a similar style to the SynapticTuner. The Gap junction tuner also has an optimizer which can find the best resistance for the desired coupling coefficient. an example can be viewed [here](examples/synapses/gap_junction_tuner.ipynb)
362
-
363
- ### Connectors Module
364
- - [UnidirectionConnector](#unidirectional-connector---unidirectional-connections-in-bmtk-network-model-with-given-probability-within-a-single-population-or-between-two-populations)
365
- - [ReciprocalConnector](#recipical-connector---buiilding-connections-in-bmtk-network-model-with-reciprocal-probability-within-a-single-population-or-between-two-populations)
366
- - [CorrelatedGapJunction](#correlatedgapjunction)
367
- - [OneToOneSequentialConnector](#onetoonesequentialconnector)
368
-
369
- #### 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 more notes on usage.
370
-
371
- #### All connector example below use the following network node structure
372
- ```python
373
- from bmtk.builder import NetworkBuilder
374
- net = NetworkBuilder('example_net')
375
- net.add_nodes(N=100, pop_name='PopA',model_type = 'biophysical')
376
- net.add_nodes(N=100, pop_name='PopB',model_type = 'biophysical')
377
-
378
- background = NetworkBuilder('background')
379
- background.add_nodes(N=300,pop_name='tON',potential='exc',model_type='virtual')
380
- ```
381
-
382
- #### Unidirectional connector - Object for building unidirectional connections in bmtk network model with given probability within a single population (or between two populations).
383
- ```python
384
- from bmtool.connectors import UnidirectionConnector
385
- connector = UnidirectionConnector(p=0.15, n_syn=1)
386
- connector.setup_nodes(source=net.nodes(pop_name = 'PopA'), target=net.nodes(pop_name = 'PopB'))
387
- net.add_edges(**connector.edge_params())
388
- ```
389
- #### Recipical connector - Object for building connections in bmtk network model with reciprocal probability within a single population (or between two populations)
390
- ```python
391
- from bmtool.connectors import ReciprocalConnector
392
- connector = ReciprocalConnector(p0=0.15, pr=0.06767705087, n_syn0=1, n_syn1=1,estimate_rho=False)
393
- connector.setup_nodes(source=net.nodes(pop_name = 'PopA'), target=net.nodes(pop_name = 'PopA'))
394
- net.add_edges(**connector.edge_params())
395
- ```
396
- #### CorrelatedGapJunction - Object for building gap junction connections in bmtk network model with given probabilities within a single population which could be correlated with the recurrent chemical synapses in this population.
397
- ```python
398
- from bmtool.connectors import ReciprocalConnector, CorrelatedGapJunction
399
- connector = ReciprocalConnector(p0=0.15, pr=0.06, n_syn0=1, n_syn1=1, estimate_rho=False)
400
- connector.setup_nodes(source=net.nodes(pop_name='PopA'), target=net.nodes(pop_name='PopA'))
401
- net.add_edges(**connector.edge_params())
402
- gap_junc = CorrelatedGapJunction(p_non=0.1228,p_uni=0.56,p_rec=1,connector=connector)
403
- gap_junc.setup_nodes(source=net.nodes(pop_name='PopA'), target=net.nodes(pop_name='PopA'))
404
- conn = net.add_edges(is_gap_junction=True, syn_weight=0.0000495, target_sections=None,afferent_section_id=0, afferent_section_pos=0.5,
405
- **gap_junc.edge_params())
406
- ```
407
-
408
- #### OneToOneSequentialConnector - Object for building one to one correspondence connections in bmtk network model with between two populations. One of the population can consist of multiple sub-populations.
409
- ```python
410
- from bmtool.connectors import OneToOneSequentialConnector
411
- connector = OneToOneSequentialConnector()
412
- connector.setup_nodes(source=background.nodes(), target=net.nodes(pop_name = 'PopA'))
413
- net.add_edges(**connector.edge_params())
414
- connector.setup_nodes(target=net.nodes(pop_name = 'PopB'))
415
- net.add_edges(**connector.edge_params())
416
- ```
417
-
418
- ## Bmplot Module
419
- - [total_connection_matrix](#total_connection_matrix)
420
- - [percent_connection_matrix](#percent_connection_matrix)
421
- - [connector_percent_matrix](#connector_percent_matrix)
422
- - [convergence_connection_matrix](#convergence_connection_matrix)
423
- - [divergence_connection_matrix](#divergence_connection_matrix)
424
- - [gap_junction_matrix](#gap_junction_matrix)
425
- - [connection_distance](#connection_distance)
426
- - [connection_histogram](#connection_histogram)
427
- - [plot_3d_positions](#plot_3d_positions)
428
- - [plot_3d_cell_rotation](#plot_3d_cell_rotation)
429
- ### for a demo please see the notebook [here](examples/bmplot/bmplot.ipynb)
430
-
431
- ### total_connection_matrix
432
- #### Generates a table of total number of connections each neuron population recieves
433
-
434
-
435
- ### percent_connection_matrix
436
- #### Generates a table of the percent connectivity of neuron populations.Method can change if you want the table to be total percent connectivity, only unidirectional connectivity or only bi directional connectvity
437
-
438
- ### connector_percent_matrix
439
- #### Generates a table of the percent connectivity using the output from bmtool.connector. By default will generate the percent connectivity of the possible connections meaning factoring in distance rules.
440
-
441
-
442
- ### convergence_connection_matrix
443
- #### Generates a table of the mean convergence of neuron populations. Method can be changed to show max, min, mean, or std for convergence a cell recieves
444
-
445
-
446
- ### divergence_connection_matrix
447
- #### Generates a table of the mean divergence of neuron populations. Method can be changed to show max, min, mean or std divergence a cell recieves.
448
-
449
-
450
- ### gap_junction_matrix
451
- #### While gap junctions can be include in the above plots, you can use this function to only view gap junctions. Method can be either 'convergence' or 'percent' connections to generate different plots
452
-
453
-
454
- ### connection_distance
455
- #### Generates a 3d plot with the source and target cells location along with a histogram showing connection distance
456
-
457
- ### connection_histogram
458
- #### Generates a histogram of the distribution of connections a population of cells give to individual cells of another population
459
-
460
-
461
- ### plot_3d_positions
462
- #### Generates a plot of cells positions in 3D space
463
-
464
-
465
- ### plot_3d_cell_rotation
466
- #### Generates a plot of cells location in 3D plot and also the cells rotation
467
-
468
-
469
- ### Plot Connection Diagram
470
-
471
-
472
- ```python
473
- bmplot.plot_network_graph(config='config.json',sources='LA',targets='LA',tids='pop_name',sids='pop_name',no_prepend_pop=True)
474
- ```
475
-
476
-
477
-
478
- ![png](readme_figures/output_35_0.png)
479
-
480
-
481
- ## Analysis Module
482
- ### A notebook example of how to use the spikes module can be found [here](examples/analysis/using_spikes.ipynb)
483
-
484
- ## SLURM Module
485
- ### This is an extremely helpful module that can simplify using SLURM too submit your models. There is also features to enable doing a seedSweep. This will vary the parameters of the simulation and make tuning the model easier. An example can be found [here](examples/SLURM/using_BlockRunner.ipynb)
486
-
487
-
488
- ## Graphs Module
489
- - [Generate graph](#generate-graph)
490
- - [Plot Graph](#plot-graph)
491
- - [Connectioon table](#generate-graph-connection-table)
492
-
493
- ### Generate Graph
494
-
495
- ```python
496
- from bmtool import graphs
497
- import networkx as nx
498
-
499
- Graph = graphs.generate_graph(config='config.json',source='LA',target='LA')
500
- print("Number of nodes:", Graph.number_of_nodes())
501
- print("Number of edges:", Graph.number_of_edges())
502
- print("Node labels:", set(nx.get_node_attributes(Graph, 'label').values()))
503
- ```
504
-
505
- Number of nodes: 2000
506
- Number of edges: 84235
507
- Node labels: {'SOM', 'PNc', 'PNa', 'PV'}
508
-
509
-
510
- ### Plot Graph
511
- #### Generates an interactive plot showing nodes, edges and # of connections
512
-
513
-
514
- ```python
515
- graphs.plot_graph(Graph)
516
- ```
517
-
518
-
519
-
520
- ### Generate graph connection table
521
- #### Generates a CSV of all cells and the number of connections each individual cell receives
522
-
523
-
524
- ```python
525
- import pandas as pd
526
- graphs.export_node_connections_to_csv(Graph, 'node_connections.csv')
527
- df = pd.read_csv('node_connections.csv')
528
- df.head()
529
- ```
530
-
531
-
532
-
533
-
534
- <div>
535
- <style scoped>
536
- .dataframe tbody tr th:only-of-type {
537
- vertical-align: middle;
538
- }
539
-
540
- .dataframe tbody tr th {
541
- vertical-align: top;
542
- }
543
-
544
- .dataframe thead th {
545
- text-align: right;
546
- }
547
- </style>
548
- <table border="1" class="dataframe">
549
- <thead>
550
- <tr style="text-align: right;">
551
- <th></th>
552
- <th>Unnamed: 0</th>
553
- <th>Node Label</th>
554
- <th>PNc Connections</th>
555
- <th>PV Connections</th>
556
- <th>SOM Connections</th>
557
- <th>PNa Connections</th>
558
- </tr>
559
- </thead>
560
- <tbody>
561
- <tr>
562
- <th>0</th>
563
- <td>0</td>
564
- <td>PNa</td>
565
- <td>15</td>
566
- <td>11</td>
567
- <td>9</td>
568
- <td>6</td>
569
- </tr>
570
- <tr>
571
- <th>1</th>
572
- <td>1</td>
573
- <td>PNa</td>
574
- <td>24</td>
575
- <td>25</td>
576
- <td>6</td>
577
- <td>21</td>
578
- </tr>
579
- <tr>
580
- <th>2</th>
581
- <td>2</td>
582
- <td>PNa</td>
583
- <td>27</td>
584
- <td>28</td>
585
- <td>12</td>
586
- <td>25</td>
587
- </tr>
588
- <tr>
589
- <th>3</th>
590
- <td>3</td>
591
- <td>PNa</td>
592
- <td>19</td>
593
- <td>27</td>
594
- <td>15</td>
595
- <td>35</td>
596
- </tr>
597
- <tr>
598
- <th>4</th>
599
- <td>4</td>
600
- <td>PNa</td>
601
- <td>25</td>
602
- <td>11</td>
603
- <td>8</td>
604
- <td>16</td>
605
- </tr>
606
- </tbody>
607
- </table>
608
- </div>
609
-
610
-