-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from openworm/experimental
Improved Varshney & Witvliet
- Loading branch information
Showing
20 changed files
with
4,593 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
from c302.NeuroMLUtilities import ConnectionInfo | ||
from c302.NeuroMLUtilities import analyse_connections | ||
from openpyxl import load_workbook | ||
|
||
import os | ||
from c302 import print_ | ||
|
||
spreadsheet_location = os.path.dirname(os.path.abspath(__file__))+"/data/" | ||
spreadsheet_name = "NeuronConnect.xlsx" # has old name... | ||
spreadsheet_name = "NeuronConnectFormatted.xlsx" | ||
|
||
READER_DESCRIPTION = """Data extracted from %s for neuronal connectivity"""%spreadsheet_name | ||
|
||
NMJ_ENDPOINT = 'NMJ' | ||
|
||
def read_data(include_nonconnected_cells=False, neuron_connect=True): | ||
|
||
if neuron_connect: | ||
conns = [] | ||
cells = [] | ||
filename = "%s%s"%(spreadsheet_location,spreadsheet_name) | ||
wb = load_workbook(filename) | ||
sheet = wb.worksheets[0] | ||
print_("Opened the Excel file: " + filename) | ||
|
||
for row in sheet.iter_rows(min_row=2, values_only=True): # Assuming data starts from the second row | ||
pre = str(row[0]) | ||
post = str(row[1]) | ||
|
||
if not post==NMJ_ENDPOINT: | ||
syntype = str(row[2]) | ||
num = int(row[3]) | ||
synclass = 'Generic_GJ' if 'EJ' in syntype else 'Chemical_Synapse' | ||
|
||
conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) | ||
if pre not in cells: | ||
cells.append(pre) | ||
if post not in cells: | ||
cells.append(post) | ||
|
||
return cells, conns | ||
|
||
|
||
def read_muscle_data(): | ||
|
||
conns = [] | ||
neurons = [] | ||
muscles = [] | ||
|
||
filename = "%s%s"%(spreadsheet_location,spreadsheet_name) | ||
wb = load_workbook(filename) | ||
sheet = wb.worksheets[0] | ||
|
||
print_("Opened Excel file: "+ filename) | ||
|
||
for row in sheet.iter_rows(min_row=2, values_only=True): # Assuming data starts from the second row | ||
pre = str(row[0]) | ||
post = str(row[1]) | ||
|
||
if post==NMJ_ENDPOINT: | ||
syntype = str(row[2]) | ||
num = int(row[3]) | ||
synclass = 'Generic_GJ' if 'EJ' in syntype else 'Chemical_Synapse' | ||
|
||
conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) | ||
if pre not in neurons: | ||
neurons.append(pre) | ||
if not post in muscles: | ||
muscles.append(post) | ||
|
||
|
||
return neurons, muscles, conns | ||
|
||
|
||
|
||
def main(): | ||
|
||
cells, neuron_conns = read_data(include_nonconnected_cells=True) | ||
neurons2muscles, muscles, muscle_conns = read_muscle_data() | ||
|
||
analyse_connections(cells, neuron_conns, neurons2muscles, muscles, muscle_conns) | ||
|
||
if __name__ == '__main__': | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
from c302.NeuroMLUtilities import ConnectionInfo | ||
from c302.NeuroMLUtilities import analyse_connections | ||
|
||
from openpyxl import load_workbook | ||
import os | ||
from c302 import print_ | ||
|
||
|
||
spreadsheet_location = os.path.dirname(os.path.abspath(__file__))+"/data/" | ||
|
||
def get_old_muscle_name(name): | ||
if name.startswith("BWM-VL"): | ||
return "MVL%s" %name[6:] | ||
elif name.startswith("BWM-VR"): | ||
return "MVR%s" %name[6:] | ||
elif name.startswith("BWM-DL"): | ||
return "MDL%s" %name[6:] | ||
elif name.startswith("BWM-DR"): | ||
return "MDR%s" %name[6:] | ||
|
||
class WitvlietDataReader1: | ||
|
||
def read_data(include_nonconnected_cells=False, neuron_connect=False): | ||
|
||
if neuron_connect: | ||
conns = [] | ||
cells = [] | ||
filename = "%switvliet_2020_7.xlsx"%spreadsheet_location | ||
wb = load_workbook(filename) | ||
sheet = wb.worksheets[0] | ||
print_("Opened the Excel file: " + filename) | ||
|
||
|
||
for row in sheet.iter_rows(min_row=2, values_only=True): # Assuming data starts from the second row | ||
pre = str(row[0]) | ||
post = str(row[1]) | ||
syntype = str(row[2]) | ||
num = int(row[3]) | ||
synclass = 'Generic_GJ' if 'electrical' in syntype else 'Chemical_Synapse' | ||
|
||
|
||
conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) | ||
if pre not in cells: | ||
cells.append(pre) | ||
if post not in cells: | ||
cells.append(post) | ||
|
||
return cells, conns | ||
|
||
else: | ||
conns = [] | ||
cells = [] | ||
filename = "%switvliet_2020_7.xlsx"%spreadsheet_location | ||
wb = load_workbook(filename) | ||
sheet = wb.worksheets[0] | ||
|
||
print_("Opened Excel file..: " + filename) | ||
|
||
known_nonconnected_cells = ['CANL', 'CANR', 'VC6'] | ||
|
||
|
||
for row in sheet.iter_rows(min_row=2, values_only=True): | ||
pre = str(row[0]) | ||
post = str(row[1]) | ||
syntype = str(row[2]) | ||
num = int(row[3]) | ||
synclass = 'Generic_GJ' if 'electrical' in syntype else 'Chemical_Synapse' | ||
|
||
|
||
conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) | ||
if pre not in cells: | ||
cells.append(pre) | ||
if post not in cells: | ||
cells.append(post) | ||
|
||
if include_nonconnected_cells: | ||
for c in known_nonconnected_cells: cells.append(c) | ||
|
||
return cells, conns | ||
|
||
|
||
|
||
|
||
def read_muscle_data(): | ||
|
||
conns = [] | ||
neurons = [] | ||
muscles = [] | ||
|
||
filename = "%switvliet_2020_7.xlsx"%spreadsheet_location | ||
wb = load_workbook(filename) | ||
sheet = wb.worksheets[0] | ||
|
||
print_("Opened Excel file: "+ filename) | ||
|
||
for row in sheet.iter_rows(min_row=2, values_only=True): | ||
pre = str(row[0]) | ||
post = str(row[1]) | ||
syntype = str(row[2]) | ||
num = int(row[3]) | ||
synclass = 'Generic_GJ' if 'EJ' in syntype else 'Chemical_Synapse' | ||
if post.startswith("BWM-"): | ||
post = get_old_muscle_name(post) | ||
else: | ||
continue | ||
|
||
conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) | ||
if pre not in neurons: | ||
neurons.append(pre) | ||
if post not in muscles: | ||
muscles.append(post) | ||
|
||
|
||
return neurons, muscles, conns | ||
|
||
def main1(): | ||
|
||
cells, neuron_conns = WitvlietDataReader1.read_data(include_nonconnected_cells=True) | ||
neurons2muscles, muscles, muscle_conns = WitvlietDataReader1.read_muscle_data() | ||
|
||
analyse_connections(cells, neuron_conns, neurons2muscles, muscles, muscle_conns) | ||
|
||
|
||
class WitvlietDataReader2: | ||
def read_data(include_nonconnected_cells=False, neuron_connect=False): | ||
|
||
if neuron_connect: | ||
conns = [] | ||
cells = [] | ||
filename = "%switvliet_2020_8.xlsx"%spreadsheet_location | ||
wb = load_workbook(filename) | ||
sheet = wb.worksheets[0] | ||
print_("Opened the Excel file: " + filename) | ||
|
||
|
||
for row in sheet.iter_rows(min_row=2, values_only=True): # Assuming data starts from the second row | ||
pre = str(row[0]) | ||
post = str(row[1]) | ||
syntype = str(row[2]) | ||
num = int(row[3]) | ||
synclass = 'Generic_GJ' if 'electrical' in syntype else 'Chemical_Synapse' | ||
|
||
conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) | ||
if pre not in cells: | ||
cells.append(pre) | ||
if post not in cells: | ||
cells.append(post) | ||
|
||
return cells, conns | ||
|
||
else: | ||
conns = [] | ||
cells = [] | ||
filename = "%switvliet_2020_8.xlsx"%spreadsheet_location | ||
wb = load_workbook(filename) | ||
sheet = wb.worksheets[0] | ||
|
||
print_("Opened Excel file..: " + filename) | ||
|
||
known_nonconnected_cells = ['CANL', 'CANR', 'VC6'] | ||
|
||
|
||
for row in sheet.iter_rows(min_row=2, values_only=True): | ||
pre = str(row[0]) | ||
post = str(row[1]) | ||
syntype = str(row[2]) | ||
num = int(row[3]) | ||
synclass = 'Generic_GJ' if 'electrical' in syntype else 'Chemical_Synapse' | ||
|
||
|
||
conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) | ||
if pre not in cells: | ||
cells.append(pre) | ||
if post not in cells: | ||
cells.append(post) | ||
|
||
if include_nonconnected_cells: | ||
for c in known_nonconnected_cells: cells.append(c) | ||
|
||
return cells, conns | ||
|
||
|
||
def read_muscle_data(): | ||
|
||
conns = [] | ||
neurons = [] | ||
muscles = [] | ||
|
||
filename = "%switvliet_2020_8.xlsx"%spreadsheet_location | ||
wb = load_workbook(filename) | ||
sheet = wb.worksheets[0] | ||
|
||
print_("Opened Excel file: "+ filename) | ||
|
||
for row in sheet.iter_rows(min_row=2, values_only=True): | ||
pre = str(row[0]) | ||
post = str(row[1]) | ||
syntype = str(row[2]) | ||
num = int(row[3]) | ||
synclass = 'Generic_GJ' if 'electrical' in syntype else 'Chemical_Synapse' | ||
if post.startswith("BWM-"): | ||
post = get_old_muscle_name(post) | ||
else: | ||
continue | ||
|
||
conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) | ||
if pre not in neurons: | ||
neurons.append(pre) | ||
if post not in muscles: | ||
muscles.append(post) | ||
|
||
|
||
return neurons, muscles, conns | ||
|
||
def main2(): | ||
|
||
cells, neuron_conns = WitvlietDataReader2.read_data(include_nonconnected_cells=True) | ||
neurons2muscles, muscles, muscle_conns = WitvlietDataReader2.read_muscle_data() | ||
|
||
analyse_connections(cells, neuron_conns, neurons2muscles, muscles, muscle_conns) | ||
|
||
if __name__ == '__main__': | ||
main1() | ||
main2() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.7.12' | ||
__version__ = '0.8.0' |
Oops, something went wrong.