bmtool 0.5.2__tar.gz → 0.5.3__tar.gz

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.
Files changed (27) hide show
  1. {bmtool-0.5.2/bmtool.egg-info → bmtool-0.5.3}/PKG-INFO +139 -3
  2. bmtool-0.5.2/PKG-INFO → bmtool-0.5.3/README.md +135 -31
  3. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/bmplot.py +76 -1
  4. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/connectors.py +216 -59
  5. bmtool-0.5.3/bmtool/graphs.py +170 -0
  6. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/singlecell.py +4 -4
  7. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/util/util.py +85 -18
  8. bmtool-0.5.2/README.md → bmtool-0.5.3/bmtool.egg-info/PKG-INFO +167 -0
  9. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool.egg-info/SOURCES.txt +1 -0
  10. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool.egg-info/requires.txt +1 -0
  11. {bmtool-0.5.2 → bmtool-0.5.3}/setup.py +5 -4
  12. {bmtool-0.5.2 → bmtool-0.5.3}/LICENSE +0 -0
  13. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/__init__.py +0 -0
  14. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/__main__.py +0 -0
  15. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/debug/__init__.py +0 -0
  16. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/debug/commands.py +0 -0
  17. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/debug/debug.py +0 -0
  18. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/manage.py +0 -0
  19. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/plot_commands.py +0 -0
  20. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/util/__init__.py +0 -0
  21. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/util/commands.py +0 -0
  22. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/util/neuron/__init__.py +0 -0
  23. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool/util/neuron/celltuner.py +0 -0
  24. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool.egg-info/dependency_links.txt +0 -0
  25. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool.egg-info/entry_points.txt +0 -0
  26. {bmtool-0.5.2 → bmtool-0.5.3}/bmtool.egg-info/top_level.txt +0 -0
  27. {bmtool-0.5.2 → bmtool-0.5.3}/setup.cfg +0 -0
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bmtool
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: BMTool
5
5
  Home-page: https://github.com/cyneuro/bmtool
6
6
  Download-URL:
7
- Author: Tyler Banks
8
- Author-email: tbanks@mail.missouri.edu
7
+ Author: Neural Engineering Laboratory at the University of Missouri
8
+ Author-email: gregglickert@mail.missouri.edu
9
9
  License: MIT
10
10
  Classifier: Intended Audience :: Developers
11
11
  Classifier: Intended Audience :: Education
@@ -28,6 +28,7 @@ Requires-Dist: numpy
28
28
  Requires-Dist: pandas
29
29
  Requires-Dist: questionary
30
30
  Requires-Dist: pynmodlt
31
+ Requires-Dist: plotly
31
32
 
32
33
  # bmtool
33
34
  A collection of modules to make developing [Neuron](https://www.neuron.yale.edu/neuron/) and [BMTK](https://alleninstitute.github.io/bmtk/) models easier.
@@ -40,6 +41,7 @@ A collection of modules to make developing [Neuron](https://www.neuron.yale.edu/
40
41
  - [Single Cell](#Single-Cell-Module)
41
42
  - [Connectors](#Connectors-Module)
42
43
  - [Bmplot](#bmplot-Module)
44
+ - [Graphs](#graphs-module)
43
45
 
44
46
  ## Getting Started
45
47
 
@@ -391,6 +393,7 @@ net.add_edges(**connector.edge_params())
391
393
  - [Percent connections](#Percent-connection-plot)
392
394
  - [Convergence connnections](#convergence-plot)
393
395
  - [Divergence connections](#divergence-plot)
396
+ - [Gap Junction connections](#gap-junction-plot)
394
397
  - [connection histogram](#connection-histogram)
395
398
  - [probability connection](#probability-of-connection-plot)
396
399
  - [3D location](#3d-position-plot)
@@ -452,6 +455,17 @@ bmplot.divergence_connection_matrix(config='config.json',sources='LA',targets='L
452
455
 
453
456
  ![png](readme_figures/output_25_0.png)
454
457
 
458
+ ### Gap Junction plot
459
+ #### While gap junctions can be include in the above plots, you can use this function to only view gap junctions.Type can be either 'convergence' or 'percent' connections to generate different plots
460
+
461
+
462
+ ```python
463
+ bmplot.gap_junction_matrix(config='config.json',sources='LA',targets='LA',sids='pop_name',tids='pop_name',no_prepend_pop=True,type='percent')
464
+ ```
465
+
466
+
467
+
468
+ ![png](output_gap.png)
455
469
 
456
470
 
457
471
  ### Connection histogram
@@ -776,5 +790,127 @@ bmplot.plot_basic_cell_info(config_file='config.json')
776
790
 
777
791
 
778
792
  'LA'
793
+ ## Graphs Module
794
+ - [Generate graph](#generate-graph)
795
+ - [Plot Graph](#plot-graph)
796
+ - [Connectioon table](#generate-graph-connection-table)
797
+
798
+ ### Generate Graph
799
+
800
+
801
+ ```python
802
+ from bmtool import graphs
803
+ import networkx as nx
804
+
805
+ Graph = graphs.generate_graph(config='config.json',source='LA',target='LA')
806
+ print("Number of nodes:", Graph.number_of_nodes())
807
+ print("Number of edges:", Graph.number_of_edges())
808
+ print("Node labels:", set(nx.get_node_attributes(Graph, 'label').values()))
809
+ ```
810
+
811
+ Number of nodes: 2000
812
+ Number of edges: 84235
813
+ Node labels: {'SOM', 'PNc', 'PNa', 'PV'}
814
+
815
+
816
+ ### Plot Graph
817
+ #### Generates an interactive plot showing nodes, edges and # of connections
818
+
819
+
820
+ ```python
821
+ graphs.plot_graph(Graph)
822
+ ```
823
+
824
+
825
+
826
+ ### Generate graph connection table
827
+ #### Generates a CSV of all cells and the number of connections each individual cell receives
828
+
829
+
830
+ ```python
831
+ import pandas as pd
832
+ graphs.export_node_connections_to_csv(Graph, 'node_connections.csv')
833
+ df = pd.read_csv('node_connections.csv')
834
+ df.head()
835
+ ```
836
+
837
+
838
+
839
+
840
+ <div>
841
+ <style scoped>
842
+ .dataframe tbody tr th:only-of-type {
843
+ vertical-align: middle;
844
+ }
845
+
846
+ .dataframe tbody tr th {
847
+ vertical-align: top;
848
+ }
849
+
850
+ .dataframe thead th {
851
+ text-align: right;
852
+ }
853
+ </style>
854
+ <table border="1" class="dataframe">
855
+ <thead>
856
+ <tr style="text-align: right;">
857
+ <th></th>
858
+ <th>Unnamed: 0</th>
859
+ <th>Node Label</th>
860
+ <th>PNc Connections</th>
861
+ <th>PV Connections</th>
862
+ <th>SOM Connections</th>
863
+ <th>PNa Connections</th>
864
+ </tr>
865
+ </thead>
866
+ <tbody>
867
+ <tr>
868
+ <th>0</th>
869
+ <td>0</td>
870
+ <td>PNa</td>
871
+ <td>15</td>
872
+ <td>11</td>
873
+ <td>9</td>
874
+ <td>6</td>
875
+ </tr>
876
+ <tr>
877
+ <th>1</th>
878
+ <td>1</td>
879
+ <td>PNa</td>
880
+ <td>24</td>
881
+ <td>25</td>
882
+ <td>6</td>
883
+ <td>21</td>
884
+ </tr>
885
+ <tr>
886
+ <th>2</th>
887
+ <td>2</td>
888
+ <td>PNa</td>
889
+ <td>27</td>
890
+ <td>28</td>
891
+ <td>12</td>
892
+ <td>25</td>
893
+ </tr>
894
+ <tr>
895
+ <th>3</th>
896
+ <td>3</td>
897
+ <td>PNa</td>
898
+ <td>19</td>
899
+ <td>27</td>
900
+ <td>15</td>
901
+ <td>35</td>
902
+ </tr>
903
+ <tr>
904
+ <th>4</th>
905
+ <td>4</td>
906
+ <td>PNa</td>
907
+ <td>25</td>
908
+ <td>11</td>
909
+ <td>8</td>
910
+ <td>16</td>
911
+ </tr>
912
+ </tbody>
913
+ </table>
914
+ </div>
779
915
 
780
916
 
@@ -1,34 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: bmtool
3
- Version: 0.5.2
4
- Summary: BMTool
5
- Home-page: https://github.com/cyneuro/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
1
  # bmtool
33
2
  A collection of modules to make developing [Neuron](https://www.neuron.yale.edu/neuron/) and [BMTK](https://alleninstitute.github.io/bmtk/) models easier.
34
3
 
@@ -40,6 +9,7 @@ A collection of modules to make developing [Neuron](https://www.neuron.yale.edu/
40
9
  - [Single Cell](#Single-Cell-Module)
41
10
  - [Connectors](#Connectors-Module)
42
11
  - [Bmplot](#bmplot-Module)
12
+ - [Graphs](#graphs-module)
43
13
 
44
14
  ## Getting Started
45
15
 
@@ -391,6 +361,7 @@ net.add_edges(**connector.edge_params())
391
361
  - [Percent connections](#Percent-connection-plot)
392
362
  - [Convergence connnections](#convergence-plot)
393
363
  - [Divergence connections](#divergence-plot)
364
+ - [Gap Junction connections](#gap-junction-plot)
394
365
  - [connection histogram](#connection-histogram)
395
366
  - [probability connection](#probability-of-connection-plot)
396
367
  - [3D location](#3d-position-plot)
@@ -452,6 +423,17 @@ bmplot.divergence_connection_matrix(config='config.json',sources='LA',targets='L
452
423
 
453
424
  ![png](readme_figures/output_25_0.png)
454
425
 
426
+ ### Gap Junction plot
427
+ #### While gap junctions can be include in the above plots, you can use this function to only view gap junctions.Type can be either 'convergence' or 'percent' connections to generate different plots
428
+
429
+
430
+ ```python
431
+ bmplot.gap_junction_matrix(config='config.json',sources='LA',targets='LA',sids='pop_name',tids='pop_name',no_prepend_pop=True,type='percent')
432
+ ```
433
+
434
+
435
+
436
+ ![png](output_gap.png)
455
437
 
456
438
 
457
439
  ### Connection histogram
@@ -776,5 +758,127 @@ bmplot.plot_basic_cell_info(config_file='config.json')
776
758
 
777
759
 
778
760
  'LA'
761
+ ## Graphs Module
762
+ - [Generate graph](#generate-graph)
763
+ - [Plot Graph](#plot-graph)
764
+ - [Connectioon table](#generate-graph-connection-table)
765
+
766
+ ### Generate Graph
767
+
768
+
769
+ ```python
770
+ from bmtool import graphs
771
+ import networkx as nx
772
+
773
+ Graph = graphs.generate_graph(config='config.json',source='LA',target='LA')
774
+ print("Number of nodes:", Graph.number_of_nodes())
775
+ print("Number of edges:", Graph.number_of_edges())
776
+ print("Node labels:", set(nx.get_node_attributes(Graph, 'label').values()))
777
+ ```
778
+
779
+ Number of nodes: 2000
780
+ Number of edges: 84235
781
+ Node labels: {'SOM', 'PNc', 'PNa', 'PV'}
782
+
783
+
784
+ ### Plot Graph
785
+ #### Generates an interactive plot showing nodes, edges and # of connections
786
+
787
+
788
+ ```python
789
+ graphs.plot_graph(Graph)
790
+ ```
791
+
792
+
793
+
794
+ ### Generate graph connection table
795
+ #### Generates a CSV of all cells and the number of connections each individual cell receives
796
+
797
+
798
+ ```python
799
+ import pandas as pd
800
+ graphs.export_node_connections_to_csv(Graph, 'node_connections.csv')
801
+ df = pd.read_csv('node_connections.csv')
802
+ df.head()
803
+ ```
804
+
805
+
806
+
807
+
808
+ <div>
809
+ <style scoped>
810
+ .dataframe tbody tr th:only-of-type {
811
+ vertical-align: middle;
812
+ }
813
+
814
+ .dataframe tbody tr th {
815
+ vertical-align: top;
816
+ }
817
+
818
+ .dataframe thead th {
819
+ text-align: right;
820
+ }
821
+ </style>
822
+ <table border="1" class="dataframe">
823
+ <thead>
824
+ <tr style="text-align: right;">
825
+ <th></th>
826
+ <th>Unnamed: 0</th>
827
+ <th>Node Label</th>
828
+ <th>PNc Connections</th>
829
+ <th>PV Connections</th>
830
+ <th>SOM Connections</th>
831
+ <th>PNa Connections</th>
832
+ </tr>
833
+ </thead>
834
+ <tbody>
835
+ <tr>
836
+ <th>0</th>
837
+ <td>0</td>
838
+ <td>PNa</td>
839
+ <td>15</td>
840
+ <td>11</td>
841
+ <td>9</td>
842
+ <td>6</td>
843
+ </tr>
844
+ <tr>
845
+ <th>1</th>
846
+ <td>1</td>
847
+ <td>PNa</td>
848
+ <td>24</td>
849
+ <td>25</td>
850
+ <td>6</td>
851
+ <td>21</td>
852
+ </tr>
853
+ <tr>
854
+ <th>2</th>
855
+ <td>2</td>
856
+ <td>PNa</td>
857
+ <td>27</td>
858
+ <td>28</td>
859
+ <td>12</td>
860
+ <td>25</td>
861
+ </tr>
862
+ <tr>
863
+ <th>3</th>
864
+ <td>3</td>
865
+ <td>PNa</td>
866
+ <td>19</td>
867
+ <td>27</td>
868
+ <td>15</td>
869
+ <td>35</td>
870
+ </tr>
871
+ <tr>
872
+ <th>4</th>
873
+ <td>4</td>
874
+ <td>PNa</td>
875
+ <td>25</td>
876
+ <td>11</td>
877
+ <td>8</td>
878
+ <td>16</td>
879
+ </tr>
880
+ </tbody>
881
+ </table>
882
+ </div>
779
883
 
780
884
 
@@ -3,7 +3,6 @@ Want to be able to take multiple plot names in and plot them all at the same tim
3
3
  https://stackoverflow.com/questions/458209/is-there-a-way-to-detach-matplotlib-plots-so-that-the-computation-can-continue
4
4
  """
5
5
  from .util import util
6
-
7
6
  import argparse,os,sys
8
7
 
9
8
  import numpy as np
@@ -267,6 +266,82 @@ def divergence_connection_matrix(config=None,title=None,sources=None, targets=No
267
266
  plot_connection_info(syn_info,data,source_labels,target_labels,title, save_file=save_file)
268
267
  return
269
268
 
269
+ def gap_junction_matrix(config=None,title=None,sources=None, targets=None, sids=None,tids=None, no_prepend_pop=False,save_file=None,type='convergence'):
270
+ """
271
+ Generates connection plot displaying gap junction data.
272
+ config: A BMTK simulation config
273
+ sources: network name(s) to plot
274
+ targets: network name(s) to plot
275
+ sids: source node identifier
276
+ tids: target node identifier
277
+ no_prepend_pop: dictates if population name is displayed before sid or tid when displaying graph
278
+ save_file: If plot should be saved
279
+ type:'convergence' or 'percent' connections
280
+ """
281
+ if not config:
282
+ raise Exception("config not defined")
283
+ if not sources or not targets:
284
+ raise Exception("Sources or targets not defined")
285
+ if type !='convergence' and type!='percent':
286
+ raise Exception("type must be 'convergence' or 'percent'")
287
+ sources = sources.split(",")
288
+ targets = targets.split(",")
289
+ if sids:
290
+ sids = sids.split(",")
291
+ else:
292
+ sids = []
293
+ if tids:
294
+ tids = tids.split(",")
295
+ else:
296
+ tids = []
297
+ syn_info, data, source_labels, target_labels = util.gap_junction_connections(config=config,nodes=None,edges=None,sources=sources,targets=targets,sids=sids,tids=tids,prepend_pop=not no_prepend_pop,type=type)
298
+
299
+
300
+ def filter_rows(syn_info, data, source_labels, target_labels):
301
+ new_syn_info = syn_info
302
+ new_data = data
303
+ new_source_labels = source_labels
304
+ new_target_labels = target_labels
305
+ for row in new_data:
306
+ row_index = -1
307
+ try:
308
+ if((np.isnan(row).all())): #checks if all of a row is nan
309
+ row_index = np.where(np.isnan(new_data)==np.isnan(row))[0][0]
310
+ except:
311
+ row_index = -1
312
+ finally:
313
+ if(all(x==0 for x in row)): #checks if all of a row is zeroes
314
+ row_index = np.where(new_data==row)[0][0]
315
+ if row_index!=-1: #deletes corresponding row accordingly in all relevant variables.
316
+ new_syn_info = np.delete(new_syn_info,row_index,0)
317
+ new_data = np.delete(new_data,row_index,0)
318
+ new_source_labels = np.delete(new_source_labels,row_index)
319
+ return new_syn_info, new_data,new_source_labels,new_target_labels
320
+
321
+ def filter_rows_and_columns(syn_info,data,source_labels,target_labels):
322
+ syn_info, data, source_labels, target_labels = filter_rows(syn_info, data, source_labels, target_labels)
323
+ transposed_syn_info = np.transpose(syn_info) #transpose everything and put it in to make sure columns get filtered
324
+ transposed_data = np.transpose(data)
325
+ transposed_source_labels = target_labels
326
+ transposed_target_labels = source_labels
327
+ syn_info, data, source_labels, target_labels = filter_rows(transposed_syn_info, transposed_data, transposed_source_labels, transposed_target_labels)
328
+ filtered_syn_info = np.transpose(syn_info) #transpose everything back to original order after filtering.
329
+ filtered_data = np.transpose(data)
330
+ filtered_source_labels = target_labels
331
+ filtered_target_labels = source_labels
332
+ return filtered_syn_info,filtered_data,filtered_source_labels,filtered_target_labels
333
+
334
+ syn_info, data, source_labels, target_labels = filter_rows_and_columns(syn_info, data, source_labels, target_labels)
335
+
336
+ if title == None or title=="":
337
+ title = 'Gap Junction'
338
+ if type == 'convergence':
339
+ title+=' Syn Convergence'
340
+ elif type == 'percent':
341
+ title+=' Percent Connectivity'
342
+ plot_connection_info(syn_info,data,source_labels,target_labels,title, save_file=save_file)
343
+ return
344
+
270
345
  def connection_histogram(config=None,nodes=None,edges=None,sources=[],targets=[],sids=[],tids=[],prepend_pop=True,synaptic_info='0',
271
346
  source_cell = None,target_cell = None,include_gap=True):
272
347
  """