bmtool 0.5.9.8__tar.gz → 0.5.9.9__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.
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/PKG-INFO +5 -1
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/README.md +4 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/bmplot.py +51 -83
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/connectors.py +6 -6
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/synapses.py +0 -2
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool.egg-info/PKG-INFO +5 -1
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/setup.py +1 -1
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/LICENSE +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/SLURM.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/__init__.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/__main__.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/debug/__init__.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/debug/commands.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/debug/debug.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/graphs.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/manage.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/plot_commands.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/singlecell.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/util/__init__.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/util/commands.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/util/neuron/__init__.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/util/neuron/celltuner.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool/util/util.py +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool.egg-info/SOURCES.txt +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool.egg-info/dependency_links.txt +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool.egg-info/entry_points.txt +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool.egg-info/requires.txt +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/bmtool.egg-info/top_level.txt +0 -0
- {bmtool-0.5.9.8 → bmtool-0.5.9.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: bmtool
|
3
|
-
Version: 0.5.9.
|
3
|
+
Version: 0.5.9.9
|
4
4
|
Summary: BMTool
|
5
5
|
Home-page: https://github.com/cyneuro/bmtool
|
6
6
|
Download-URL:
|
@@ -401,6 +401,7 @@ net.add_edges(**connector.edge_params())
|
|
401
401
|
### for a demo please see the notebook [here](examples/bmplot/bmplot.ipynb)
|
402
402
|
- [total_connection_matrix](#total_connection_matrix)
|
403
403
|
- [percent_connection_matrix](#percent_connection_matrix)
|
404
|
+
- [connector_percent_matrix](#connector_percent_matrix)
|
404
405
|
- [convergence_connection_matrix](#convergence_connection_matrix)
|
405
406
|
- [divergence_connection_matrix](#divergence_connection_matrix)
|
406
407
|
- [gap_junction_matrix](#gap_junction_matrix)
|
@@ -416,6 +417,9 @@ net.add_edges(**connector.edge_params())
|
|
416
417
|
### percent_connection_matrix
|
417
418
|
#### 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
|
418
419
|
|
420
|
+
### connector_percent_matrix
|
421
|
+
#### 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.
|
422
|
+
|
419
423
|
|
420
424
|
### convergence_connection_matrix
|
421
425
|
#### 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
|
@@ -367,6 +367,7 @@ net.add_edges(**connector.edge_params())
|
|
367
367
|
### for a demo please see the notebook [here](examples/bmplot/bmplot.ipynb)
|
368
368
|
- [total_connection_matrix](#total_connection_matrix)
|
369
369
|
- [percent_connection_matrix](#percent_connection_matrix)
|
370
|
+
- [connector_percent_matrix](#connector_percent_matrix)
|
370
371
|
- [convergence_connection_matrix](#convergence_connection_matrix)
|
371
372
|
- [divergence_connection_matrix](#divergence_connection_matrix)
|
372
373
|
- [gap_junction_matrix](#gap_junction_matrix)
|
@@ -382,6 +383,9 @@ net.add_edges(**connector.edge_params())
|
|
382
383
|
### percent_connection_matrix
|
383
384
|
#### 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
|
384
385
|
|
386
|
+
### connector_percent_matrix
|
387
|
+
#### 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.
|
388
|
+
|
385
389
|
|
386
390
|
### convergence_connection_matrix
|
387
391
|
#### 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
|
@@ -574,16 +574,16 @@ def plot_connection_info(text, num, source_labels,target_labels, title, syn_info
|
|
574
574
|
if syn_info =='2' or syn_info =='3':
|
575
575
|
if num_source > 8 and num_source <20:
|
576
576
|
fig_text = ax1.text(j, i, edge_info,
|
577
|
-
ha="center", va="center", color="
|
577
|
+
ha="center", va="center", color="w",rotation=37.5, size=8, weight = 'semi\bold')
|
578
578
|
elif num_source > 20:
|
579
579
|
fig_text = ax1.text(j, i, edge_info,
|
580
|
-
ha="center", va="center", color="
|
580
|
+
ha="center", va="center", color="w",rotation=37.5, size=7, weight = 'semibold')
|
581
581
|
else:
|
582
582
|
fig_text = ax1.text(j, i, edge_info,
|
583
|
-
ha="center", va="center", color="
|
583
|
+
ha="center", va="center", color="w",rotation=37.5, size=11, weight = 'semibold')
|
584
584
|
else:
|
585
585
|
fig_text = ax1.text(j, i, edge_info,
|
586
|
-
ha="center", va="center", color="
|
586
|
+
ha="center", va="center", color="w", size=11, weight = 'semibold')
|
587
587
|
|
588
588
|
ax1.set_ylabel('Source', size=11, weight = 'semibold')
|
589
589
|
ax1.set_xlabel('Target', size=11, weight = 'semibold')
|
@@ -599,8 +599,7 @@ def plot_connection_info(text, num, source_labels,target_labels, title, syn_info
|
|
599
599
|
else:
|
600
600
|
return
|
601
601
|
|
602
|
-
def connector_percent_matrix(csv_path: str = None,
|
603
|
-
exclude_assembly: bool = False, title: str = 'Percent connection matrix') -> None:
|
602
|
+
def connector_percent_matrix(csv_path: str = None, exclude_strings=None, title: str = 'Percent connection matrix', pop_order=None) -> None:
|
604
603
|
"""
|
605
604
|
Generates and plots a connection matrix based on connection probabilities from a CSV file produced by bmtool.connector.
|
606
605
|
|
@@ -613,123 +612,92 @@ def connector_percent_matrix(csv_path: str = None, exclude_shell: bool = True,
|
|
613
612
|
csv_path : str
|
614
613
|
Path to the CSV file containing the connection data. The CSV should be an output from the bmtool.connector
|
615
614
|
classes, specifically generated by the `save_connection_report()` function.
|
616
|
-
|
617
|
-
|
618
|
-
exclude_assembly : bool, optional, default=False
|
619
|
-
If True, skips appending the assembly ID to the population name in the connection matrix.
|
615
|
+
exclude_strings : list of str, optional
|
616
|
+
List of strings to exclude rows where 'Source' or 'Target' contain these strings.
|
620
617
|
title : str, optional, default='Percent connection matrix'
|
621
618
|
Title for the generated plot.
|
619
|
+
pop_order : list of str, optional
|
620
|
+
List of population labels to specify the order for the x- and y-ticks in the plot.
|
622
621
|
|
623
622
|
Returns:
|
624
623
|
--------
|
625
624
|
None
|
626
625
|
Displays a heatmap plot of the connection matrix, showing the percentage of connected pairs between populations.
|
627
|
-
|
628
|
-
Example:
|
629
|
-
--------
|
630
|
-
connector_percent_matrix('connections.csv', exclude_shell=True, exclude_assembly=False)
|
631
626
|
"""
|
632
627
|
# Read the CSV data
|
633
628
|
df = pd.read_csv(csv_path)
|
634
629
|
|
635
630
|
# Choose the column to display
|
636
|
-
selected_column = "
|
637
|
-
|
638
|
-
# Create an empty dictionary to store connection percentages
|
639
|
-
connection_data = {}
|
631
|
+
selected_column = "Percent connectionivity within possible connections"
|
640
632
|
|
641
|
-
|
633
|
+
# Filter the DataFrame based on exclude_strings
|
634
|
+
def filter_dataframe(df, column_name, exclude_strings):
|
642
635
|
def process_string(string):
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
return None # Mark row for removal
|
650
|
-
else:
|
651
|
-
if match:
|
652
|
-
filtered_string = match.group(1)
|
653
|
-
|
654
|
-
# Conditionally process "assembly" in the string
|
655
|
-
if not exclude_assembly and "assembly" in string:
|
656
|
-
assem_value = int(ints_in_string[0])
|
657
|
-
filtered_string = filtered_string + str(f"-{assem_value}")
|
658
|
-
|
659
|
-
if 'Gap' in string:
|
636
|
+
match = re.search(r"\[\'(.*?)\'\]", string)
|
637
|
+
if exclude_strings and any(ex_string in string for ex_string in exclude_strings):
|
638
|
+
return None
|
639
|
+
elif match:
|
640
|
+
filtered_string = match.group(1)
|
641
|
+
if 'Gap' in string:
|
660
642
|
filtered_string = filtered_string + "-Gap"
|
661
|
-
|
662
|
-
return string # If no match, return the original string
|
643
|
+
return filtered_string # Return matched string
|
663
644
|
|
664
|
-
|
665
|
-
df[column_name] = df[column_name].apply(process_string)
|
645
|
+
return string # If no match, return the original string
|
666
646
|
|
667
|
-
|
647
|
+
df[column_name] = df[column_name].apply(process_string)
|
668
648
|
df = df.dropna(subset=[column_name])
|
669
|
-
|
670
649
|
return df
|
671
650
|
|
672
|
-
df = filter_dataframe(df,'Source')
|
673
|
-
df = filter_dataframe(df,'Target')
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
selected_percentage = row[selected_column]
|
679
|
-
|
680
|
-
# If the selected percentage is an array-like string, extract the first and second values
|
651
|
+
df = filter_dataframe(df, 'Source', exclude_strings)
|
652
|
+
df = filter_dataframe(df, 'Target', exclude_strings)
|
653
|
+
|
654
|
+
# Prepare connection data
|
655
|
+
connection_data = {}
|
656
|
+
for _, row in df.iterrows():
|
657
|
+
source, target, selected_percentage = row['Source'], row['Target'], row[selected_column]
|
681
658
|
if isinstance(selected_percentage, str):
|
682
|
-
selected_percentage = selected_percentage.strip('[]').split()
|
683
|
-
selected_percentage = [float(p) for p in selected_percentage] # Convert to float
|
684
|
-
|
685
|
-
# Store the selected percentage(s) for the source-target pair
|
659
|
+
selected_percentage = [float(p) for p in selected_percentage.strip('[]').split()]
|
686
660
|
connection_data[(source, target)] = selected_percentage
|
687
661
|
|
688
|
-
#
|
662
|
+
# Determine population order
|
689
663
|
populations = sorted(list(set(df['Source'].unique()) | set(df['Target'].unique())))
|
664
|
+
if pop_order:
|
665
|
+
populations = [pop for pop in pop_order if pop in populations] # Order according to pop_order, if provided
|
690
666
|
num_populations = len(populations)
|
667
|
+
|
668
|
+
# Create an empty matrix and populate it
|
691
669
|
connection_matrix = np.zeros((num_populations, num_populations), dtype=float)
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
# Check if there is a bidirectional connection and use the second value
|
708
|
-
if len(connection_probabilities) > 1:
|
709
|
-
connection_matrix[target_idx][source_idx] = connection_probabilities[1]
|
710
|
-
|
711
|
-
# Replace NaN values with 0
|
712
|
-
connection_matrix[np.isnan(connection_matrix)] = 0
|
713
|
-
|
714
|
-
# Plot the matrix
|
670
|
+
for (source, target), probabilities in connection_data.items():
|
671
|
+
if source in populations and target in populations:
|
672
|
+
source_idx = populations.index(source)
|
673
|
+
target_idx = populations.index(target)
|
674
|
+
connection_matrix[source_idx][target_idx] = probabilities[0]
|
675
|
+
if len(probabilities) == 1:
|
676
|
+
connection_matrix[source_idx][target_idx] = probabilities[0]
|
677
|
+
if len(probabilities) == 2:
|
678
|
+
connection_matrix[source_idx][target_idx] = probabilities[0]
|
679
|
+
if len(probabilities) == 3:
|
680
|
+
connection_matrix[source_idx][target_idx] = probabilities[0]
|
681
|
+
connection_matrix[target_idx][source_idx] = probabilities[1]
|
682
|
+
|
683
|
+
# Plotting
|
715
684
|
fig, ax = plt.subplots(figsize=(10, 8))
|
716
685
|
im = ax.imshow(connection_matrix, cmap='viridis', interpolation='nearest')
|
717
686
|
|
718
687
|
# Add annotations
|
719
688
|
for i in range(num_populations):
|
720
689
|
for j in range(num_populations):
|
721
|
-
text = ax.text(j, i, f"{connection_matrix[i, j]:.2f}%",
|
722
|
-
ha="center", va="center", color="w", size=10, weight='bold')
|
690
|
+
text = ax.text(j, i, f"{connection_matrix[i, j]:.2f}%", ha="center", va="center", color="w", size=10, weight='semibold')
|
723
691
|
|
724
692
|
# Add colorbar
|
725
|
-
plt.colorbar(im, label=f'
|
693
|
+
plt.colorbar(im, label=f'{selected_column}')
|
726
694
|
|
727
695
|
# Set title and axis labels
|
728
696
|
ax.set_title(title)
|
729
697
|
ax.set_xlabel('Target Population')
|
730
698
|
ax.set_ylabel('Source Population')
|
731
699
|
|
732
|
-
# Set ticks and labels
|
700
|
+
# Set ticks and labels based on populations in specified order
|
733
701
|
ax.set_xticks(np.arange(num_populations))
|
734
702
|
ax.set_yticks(np.arange(num_populations))
|
735
703
|
ax.set_xticklabels(populations, rotation=45, ha="right", size=12, weight='semibold')
|
@@ -1064,8 +1064,8 @@ class ReciprocalConnector(AbstractConnector):
|
|
1064
1064
|
data = {
|
1065
1065
|
"Source": [src_str],
|
1066
1066
|
"Target": [trg_str],
|
1067
|
-
"
|
1068
|
-
"
|
1067
|
+
"Percent connectionivity within possible connections": [fraction[0]*100],
|
1068
|
+
"Percent connectionivity within all connections": [fraction[1]*100]
|
1069
1069
|
}
|
1070
1070
|
df = pd.DataFrame(data)
|
1071
1071
|
|
@@ -1235,8 +1235,8 @@ class UnidirectionConnector(AbstractConnector):
|
|
1235
1235
|
data = {
|
1236
1236
|
"Source": [src_str],
|
1237
1237
|
"Target": [trg_str],
|
1238
|
-
"
|
1239
|
-
"
|
1238
|
+
"Percent connectionivity within possible connections": [possible_fraction],
|
1239
|
+
"Percent connectionivity within all connections": [all_fraction]
|
1240
1240
|
}
|
1241
1241
|
df = pd.DataFrame(data)
|
1242
1242
|
|
@@ -1336,8 +1336,8 @@ class GapJunction(UnidirectionConnector):
|
|
1336
1336
|
data = {
|
1337
1337
|
"Source": [src_str+"Gap"],
|
1338
1338
|
"Target": [trg_str+"Gap"],
|
1339
|
-
"
|
1340
|
-
"
|
1339
|
+
"Percent connectionivity within possible connections": [fraction_0*100],
|
1340
|
+
"Percent connectionivity within all connections": [fraction_1*100]
|
1341
1341
|
}
|
1342
1342
|
df = pd.DataFrame(data)
|
1343
1343
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: bmtool
|
3
|
-
Version: 0.5.9.
|
3
|
+
Version: 0.5.9.9
|
4
4
|
Summary: BMTool
|
5
5
|
Home-page: https://github.com/cyneuro/bmtool
|
6
6
|
Download-URL:
|
@@ -401,6 +401,7 @@ net.add_edges(**connector.edge_params())
|
|
401
401
|
### for a demo please see the notebook [here](examples/bmplot/bmplot.ipynb)
|
402
402
|
- [total_connection_matrix](#total_connection_matrix)
|
403
403
|
- [percent_connection_matrix](#percent_connection_matrix)
|
404
|
+
- [connector_percent_matrix](#connector_percent_matrix)
|
404
405
|
- [convergence_connection_matrix](#convergence_connection_matrix)
|
405
406
|
- [divergence_connection_matrix](#divergence_connection_matrix)
|
406
407
|
- [gap_junction_matrix](#gap_junction_matrix)
|
@@ -416,6 +417,9 @@ net.add_edges(**connector.edge_params())
|
|
416
417
|
### percent_connection_matrix
|
417
418
|
#### 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
|
418
419
|
|
420
|
+
### connector_percent_matrix
|
421
|
+
#### 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.
|
422
|
+
|
419
423
|
|
420
424
|
### convergence_connection_matrix
|
421
425
|
#### 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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|