bmtool 0.4.2__py3-none-any.whl → 0.5.1__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.
@@ -1,550 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: bmtool
3
- Version: 0.4.2
4
- Summary: BMTool
5
- Home-page: https://github.com/tjbanks/bmtool
6
- Download-URL:
7
- Author: Tyler Banks
8
- Author-email: tbanks@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
-
32
- # bmtool
33
- A collection of scripts to make developing networks in BMTK easier.
34
-
35
- [![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/tjbanks/bmtool/blob/master/LICENSE)
36
-
37
- ## Getting Started
38
-
39
- **Installation**
40
-
41
- ```bash
42
- pip install bmtool
43
- ```
44
- For developers who will be pulling down additional updates to this repository regularly use the following instead.
45
- ```bash
46
- git clone https://github.com/tjbanks/bmtool
47
- cd bmtool
48
- python setup.py develop
49
- ```
50
- Then download updates (from this directory) with
51
- ```
52
- git pull
53
- ```
54
-
55
- **Example Use**
56
-
57
- ```bash
58
- > cd your_bmtk_model_directory
59
- > bmtool
60
- Usage: bmtool [OPTIONS] COMMAND [ARGS]...
61
-
62
- Options:
63
- --verbose Verbose printing
64
- --help Show this message and exit.
65
-
66
- Commands:
67
- debug
68
- plot
69
- util
70
-
71
- >
72
- > bmtool plot
73
- Usage: bmtool plot [OPTIONS] COMMAND [ARGS]...
74
-
75
- Options:
76
- --config PATH Configuration file to use, default: "simulation_config.json"
77
- --no-display When set there will be no plot displayed, useful for saving
78
- plots
79
- --help Show this message and exit.
80
-
81
- Commands:
82
- connection Display information related to neuron connections
83
- positions Plot cell positions for a given set of populations
84
- raster Plot the spike raster for a given population
85
- report Plot the specified report using BMTK's default report plotter
86
- >
87
- > bmtool plot positions
88
- ```
89
- ![bmtool](./figures/figure.png "Positions Figure")
90
-
91
- ## Plotting Configuration
92
-
93
- 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:
94
-
95
- ```
96
- bmtool plot --config simulation-config-23.json [FUNCTION]
97
- ```
98
-
99
- ### From python or Jupyter
100
- ```
101
- from bmtool import bmplot
102
- bmplot.plot_3d_positions(config="simulation_config.json")
103
- ```
104
-
105
- ## Ploting Connections
106
-
107
- All connection tools can be customized by supplying additional arguments.
108
-
109
- ```
110
- Options:
111
- --title TEXT change the plot's title
112
- --save-file TEXT save plot to path supplied
113
- --sources TEXT comma separated list of source node types [default:all]
114
- --targets TEXT comma separated list of target node types [default:all]
115
- --sids TEXT comma separated list of source node identifiers
116
- [default:node_type_id]
117
- --tids TEXT comma separated list of target node identifiers
118
- [default:node_type_id]
119
- --no-prepend-pop When set don't prepend the population name to the unique
120
- ids [default:False]
121
- ```
122
-
123
- #### `--sources` and `--targets`
124
- Are supplied as comma separated lists and corrospond with the population name specified in your model. Eg:
125
- ```
126
- #initialize the networks in build_network.py
127
- net = NetworkBuilder('hippocampus')
128
- exp0net = NetworkBuilder('exp0input')
129
- ```
130
- Default behavior is to plot connections between all populations but you can specify only a few to simplify your plots.
131
-
132
- #### `--sids` and `--tids`
133
- 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:
134
-
135
- ```
136
- # Adding nodes in build_network.py
137
- net.add_nodes(N=inpTotal, pop_name='EC',
138
- positions=p_EC,
139
- model_type='biophysical',
140
- model_template='hoc:IzhiCell_EC2',
141
- morphology='blank.swc'
142
- )
143
- ```
144
- We could then use the pop_name to alter the output of our connection plots.
145
-
146
- ```
147
- bmtool plot connection --sids pop_name --tids pop_name [FUNCTION]
148
- ```
149
- #### `--no-prepend-pop`
150
-
151
- 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.
152
-
153
- #### `All together basic`
154
-
155
- Using these optional switches we can see the difference in our plot output below.
156
-
157
- Command line
158
- ```
159
- bmtool plot connection total
160
- ```
161
- Python or Jupyter Notebook
162
- ```
163
- from bmtool import bmplot
164
- import matplotlib.pyplot as plt
165
-
166
- bmplot.connection_matrix(config="simulation_config.json")
167
- ```
168
-
169
- #### `All together advanced`
170
- ```
171
- bmtool plot connection --sources hippocampus --targets hippocampus --sids pop_name --tids pop_name --no-prepend-pop --title 'Hippocampus Total Connections' total
172
- ```
173
-
174
- Python or Jupyter Notebook
175
- ```
176
- from bmtool import bmplot
177
-
178
- 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")
179
- ```
180
-
181
- ![bmtool](./figures/connection.png "Connection Figure")
182
-
183
- ### Plot Total Connections
184
-
185
- To plot the total number of connections between two populations of cells run
186
-
187
- Command line
188
- ```
189
- bmtool plot connection total
190
- ```
191
- Python or Jupyter Notebook
192
- ```
193
- from bmtool import bmplot
194
-
195
- bmplot.connection_matrix(config="simulation_config.json", sources="hippocampus", targets="hippocampus")
196
- ```
197
- Remember to customize the output using the instructions above.
198
-
199
- #### `--synfo`
200
- 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.
201
- 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.
202
- Finally if it is '3', it plots the parameter file (.json) used for the connection.
203
-
204
- ![bmtool](./figures/connection_total.png "Connection Total Figure")
205
-
206
- ### Plot Average Convergence/Divergence
207
-
208
- To plot the average convergence or divergence of a single cell excute one of the following commands:
209
-
210
- Command Line
211
- ```
212
- bmtool plot connection convergence
213
- bmtool plot connection divergence
214
-
215
- Add --method (std, min, or max) for additional function
216
- ```
217
-
218
- Python or Jupyter Notebook
219
- ```
220
- from bmtool import bmplot
221
-
222
- bmplot.convergence_connection_matrix(config="simulation_config.json")
223
- bmplot.divergence_connection_matrix(config="simulation_config.json")
224
-
225
- # OR using methods (min,max,std)
226
- bmplot.convergence_connection_matrix(config="simulation_config.json", method="min")
227
- ```
228
-
229
- ![bmtool](./figures/connection_con.png "Connection Convergence Figure")
230
-
231
- ### Plot Connection Diagram
232
-
233
- To plot a rough sketch of cell type connectivity and the type of synapse used between cells run:
234
-
235
- Command Line
236
- ```
237
- bmtool plot connection network-graph
238
- ```
239
-
240
- Python or Jupyter Notebook
241
- ```
242
- from bmtool import bmplot
243
-
244
- bmplot.plot_network_graph(config="simulation_config.json")
245
- ```
246
-
247
- ![bmtool](./figures/connection_graph.png "Connection Graph Figure")
248
-
249
-
250
- `--edge-property` is an option available to change the synapse name if supplied to `NetworkBuilder.add_edges` when building the network. Default: `model_template`
251
-
252
- ### Edge Property Histograms
253
-
254
- To view the distribution of an edge property between cell types run:
255
-
256
- Command Line
257
- ```
258
- bmtool plot connection property-histogram-matrix
259
- ```
260
-
261
- Python or Jupyter Notebook
262
- ```
263
- from bmtool import bmplot
264
-
265
- bmplot.edge_histogram_matrix(config="simulation_config.json")
266
- ```
267
-
268
- The following figure was generated using
269
- ```
270
- 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
271
- ```
272
-
273
- ```
274
- from bmtool import bmplot
275
-
276
- 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")
277
- ```
278
-
279
- ![bmtool](./figures/connection_hist.png "Connection Histogram Figure")
280
-
281
- 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:
282
- ```
283
- bmtool plot connection property-histogram-matrix --edge-property [PROPERTY]
284
- ```
285
-
286
- #### Plotting edge values during/after runtime
287
-
288
- BMTool is capable of plotting connection properties obtained after runtime from reports. This is useful for synaptic weights that change over time.
289
-
290
- First, you must explicitly record the connection property in your `simulation_config.json`
291
-
292
- ```
293
- "reports": {
294
- "syn_report": {
295
- "cells": "hippocampus",
296
- "variable_name": "W_nmda",
297
- "module": "netcon_report",
298
- "sections": "soma",
299
- "syn_type": "pyr2pyr",
300
- "file_name": "syns.h5"
301
- }
302
- }
303
- ```
304
- 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.
305
-
306
- Once the simulation has been run un the following referencing the report specified above:
307
-
308
- ```
309
- bmtool plot connection property-histogram-matrix --edge-property pyr2pyr_w --report output/syns.h5 --time 9999
310
- ```
311
-
312
- The `--time-compare` option can be be used to show the weight distribution change between the specified times. Eg: ` --time 0 --time-compare 10000`
313
-
314
- See the [BMTK Commit](https://github.com/AllenInstitute/bmtk/pull/67/files) for more details.
315
-
316
- ### Plotting Distance Probability Matrix between cell types
317
-
318
- ![bmtool](./figures/connection_dist.png "Connection Histogram Figure")
319
-
320
- To show the probability of a cell type being connected to another cell type based on distance run:
321
-
322
- ```
323
- bmtool plot connection prob
324
- ```
325
-
326
- Full summary of options:
327
-
328
- ```
329
- > bmtool plot connection prob --help
330
- Usage: bmtool plot connection prob [OPTIONS]
331
-
332
- Probabilities for a connection between given populations. Distance and
333
- type dependent
334
-
335
- Options:
336
- --axis TEXT comma separated list of axis to use for distance measure eg:
337
- x,y,z or x,y
338
- --bins TEXT number of bins to separate distances into (resolution) -
339
- default: 8
340
- --line Create a line plot instead of a binned bar plot
341
- --verbose Print plot values for use in another script
342
- --help Show this message and exit.
343
- ```
344
-
345
- A more complete command (used for image above) may look similar to
346
-
347
- ```
348
- bmtool plot connection --sources hippocampus --targets hippocampus --no-prepend-pop --sids pop_name --tids pop_name prob --bins 10 --line --verbose
349
- ```
350
-
351
- 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.
352
-
353
- All `point_process` cell types will be ignored since they do not have physical locations.
354
-
355
- ### Plot 3d cell location and rotation
356
- Plot the location and rotation of your cells. Plot all of your cells with a single command
357
- ```
358
- bmtool plot cell rotation
359
- ```
360
- ![bmtool](./figures/rotation3d_1.png "3d Rotation Figure")
361
-
362
- Customize your plot by limiting the cells you want or selecting a max number of cells to plot.
363
- ```
364
- 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
365
- ```
366
- ![bmtool](./figures/rotation3d_2.png "3d Rotation Figure")
367
-
368
- Code
369
- ```
370
- from bmtool import
371
- from bmtool import bmplot
372
-
373
- bmplot.cell_rotation_3d(config=config,
374
- populations=populations,
375
- group_by=group_by,
376
- group=group,
377
- title=title,
378
- max_cells=max_cells,
379
- quiver_length=quiver_length,
380
- arrow_length_ratio=arrow_length_ratio)
381
- ```
382
-
383
- ### Plotting Current Clamp and Spike Train Info
384
- To plot all current clamp info involved in a simulation, use the following command (uses 'simulation_config.json' as default)
385
- ```
386
- bmtool plot --config simulation_config_foo.json iclamp
387
- ```
388
-
389
- To plot all spike trains and their target cells,
390
- ```
391
- bmtool plot --config simulation_config_foo.json input
392
- ```
393
-
394
- ### Printing basic cell information involved in a simulation
395
- ```
396
- bmtool plot --config simulation_config_foo.json cells
397
- ```
398
-
399
- ### Simulation Summary
400
-
401
- 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.
402
- ```
403
- bmtool plot --config simulation_config_foo.json summary
404
- ```
405
-
406
- ### Connectors Module
407
-
408
- 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.
409
- ```
410
- from bmtool import connectors
411
- ```
412
-
413
- ## Cell Tuning
414
-
415
- ### Python/Jupyter
416
-
417
- Single Cell Profiler
418
-
419
- ```
420
- from bmtool.singlecell import Profiler
421
-
422
- #Example usage
423
- profiler = Profiler(template_dir='./components/templates', mechanism_dir='./components/mechanisms/modfiles')
424
- profiler.passive_properties('Cell_Cf')
425
- profiler.fi_curve('Cell_Cf')
426
- profiler.current_injection('Cell_Cf', post_init_function="insert_mechs(123)", inj_amp=300, inj_delay=100)
427
- ```
428
-
429
- ### Single Cell Tuning
430
-
431
- From a BMTK Model directory containing a `simulation_config.json` file:
432
- ```
433
- bmtool util cell tune --builder
434
- ```
435
-
436
- For non-BMTK cell tuning:
437
- ```
438
- bmtool util cell --template TemplateFile.hoc --mod-folder ./ tune --builder
439
- ```
440
- ![bmtool](./figures/figure2.png "Tuning Figure")
441
-
442
- ### FIR Curve plotting
443
-
444
- ```
445
- > bmtool util cell fi --help
446
- Usage: bmtool util cell fi [OPTIONS]
447
-
448
- Creates a NEURON GUI window with FI curve and passive properties
449
-
450
- Options:
451
- --title TEXT
452
- --min-pa INTEGER Min pA for injection
453
- --max-pa INTEGER Max pA for injection
454
- --increment FLOAT Increment the injection by [i] pA
455
- --tstart INTEGER Injection start time
456
- --tdur INTEGER Duration of injection default:1000ms
457
- --advanced Interactive dialog to select injection and recording
458
- points
459
- --help Show this message and exit.
460
-
461
- > bmtool util cell fi
462
- ? Select a cell: (Use arrow keys)
463
- » CA3PyramidalCell
464
- DGCell
465
- IzhiCell
466
- IzhiCell_BC
467
- IzhiCell_EC
468
- IzhiCell_EC2
469
- IzhiCell_EC_BIO
470
- IzhiCell_EmoExcitatory
471
- IzhiCell_EmoInhibitory
472
- IzhiCell_OLM
473
- IzhiCell_int
474
- ```
475
-
476
- ![bmtool](./figures/figure3.png "FIR Figure")
477
-
478
- ### VHalf Segregation Module
479
-
480
- Based on the Alturki et al. (2016) paper.
481
-
482
- Segregate your channel activation for an easier time tuning your cells.
483
-
484
-
485
- ```
486
- > bmtool util cell vhseg --help
487
-
488
- Usage: bmtool util cell vhseg [OPTIONS]
489
-
490
- Alturki et al. (2016) V1/2 Automated Segregation Interface, simplify
491
- tuning by separating channel activation
492
-
493
- Options:
494
- --title TEXT
495
- --tstop INTEGER
496
- --outhoc TEXT Specify the file you want the modified cell template
497
- written to
498
- --outfolder TEXT Specify the directory you want the modified cell
499
- template and mod files written to (default: _seg)
500
- --outappend Append out instead of overwriting (default: False)
501
- --debug Print all debug statements
502
- --fminpa INTEGER Starting FI Curve amps (default: 0)
503
- --fmaxpa INTEGER Ending FI Curve amps (default: 1000)
504
- --fincrement INTEGER Increment the FI Curve amps by supplied pA (default:
505
- 100)
506
- --infvars TEXT Specify the inf variables to plot, skips the wizard.
507
- (Comma separated, eg: inf_mech,minf_mech2,ninf_mech2)
508
- --segvars TEXT Specify the segregation variables to globally set,
509
- skips the wizard. (Comma separated, eg:
510
- mseg_mech,nseg_mech2)
511
- --eleak TEXT Specify the eleak var manually
512
- --gleak TEXT Specify the gleak var manually
513
- --othersec TEXT Specify other sections that a window should be
514
- generated for (Comma separated, eg: dend[0],dend[1])
515
- --help Show this message and exit.
516
-
517
- ```
518
-
519
- #### Examples
520
-
521
- Wizard Mode (Interactive)
522
-
523
- ```
524
- > bmtool util cell vhseg
525
-
526
- ? Select a cell: CA3PyramidalCell
527
- Using section dend[0]
528
- ? Show other sections? (default: No) Yes
529
- ? Select other sections (space bar to select): done (2 selections)
530
- ? Select inf variables to plot (space bar to select): done (5 selections)
531
- ? Select segregation variables [OR VARIABLES YOU WANT TO CHANGE ON ALL SEGMENTS at the same time] (space bar to select): done (2 selections)
532
- ```
533
-
534
- Command Mode (Non-interactive)
535
-
536
- ```
537
- bmtool util cell --template CA3PyramidalCell vhseg --othersec dend[0],dend[1] --infvars inf_im --segvars gbar_im --gleak gl_ichan2CA3 --eleak el_ichan2CA3
538
- ```
539
-
540
- Example:
541
-
542
- ![bmtool](./figures/figure4.png "Seg Figure")
543
-
544
- Simple models can utilize
545
- ```
546
- bmtool util cell --hoc cell_template.hoc vhsegbuild --build
547
- bmtool util cell --hoc segmented_template.hoc vhsegbuild
548
- ```
549
- ex: [https://github.com/tjbanks/two-cell-hco](https://github.com/tjbanks/two-cell-hco)
550
-
File without changes