bmtool 0.6.9.15__py3-none-any.whl → 0.6.9.17__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 = {}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bmtool
3
- Version: 0.6.9.15
3
+ Version: 0.6.9.17
4
4
  Summary: BMTool
5
5
  Home-page: https://github.com/cyneuro/bmtool
6
6
  Download-URL:
@@ -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.15.dist-info/licenses/LICENSE,sha256=qrXg2jj6kz5d0EnN11hllcQt2fcWVNumx0xNbV05nyM,1068
23
- bmtool-0.6.9.15.dist-info/METADATA,sha256=Gfn16YTwe69lfsGLnyJUTUbPd4xBV-sXjJ44J0uLKRI,20479
24
- bmtool-0.6.9.15.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
25
- bmtool-0.6.9.15.dist-info/entry_points.txt,sha256=0-BHZ6nUnh0twWw9SXNTiRmKjDnb1VO2DfG_-oprhAc,45
26
- bmtool-0.6.9.15.dist-info/top_level.txt,sha256=gpd2Sj-L9tWbuJEd5E8C8S8XkNm5yUE76klUYcM-eWM,7
27
- bmtool-0.6.9.15.dist-info/RECORD,,
22
+ bmtool-0.6.9.17.dist-info/licenses/LICENSE,sha256=qrXg2jj6kz5d0EnN11hllcQt2fcWVNumx0xNbV05nyM,1068
23
+ bmtool-0.6.9.17.dist-info/METADATA,sha256=Z4POeFa5fCmHQ7eWOh9RsT6nSIunWdnzpd9TbeELOqs,20479
24
+ bmtool-0.6.9.17.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
25
+ bmtool-0.6.9.17.dist-info/entry_points.txt,sha256=0-BHZ6nUnh0twWw9SXNTiRmKjDnb1VO2DfG_-oprhAc,45
26
+ bmtool-0.6.9.17.dist-info/top_level.txt,sha256=gpd2Sj-L9tWbuJEd5E8C8S8XkNm5yUE76klUYcM-eWM,7
27
+ bmtool-0.6.9.17.dist-info/RECORD,,