Skip to content

Commit

Permalink
Witvliet_DataReaders
Browse files Browse the repository at this point in the history
  • Loading branch information
yasinthanvickneswaran committed Feb 9, 2024
1 parent 7faa93e commit 5fde766
Show file tree
Hide file tree
Showing 7 changed files with 767 additions and 0 deletions.
110 changes: 110 additions & 0 deletions c302/W7_SpreadsheetDataReader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
from c302.NeuroMLUtilities import ConnectionInfo
from c302.NeuroMLUtilities import analyse_connections

from openpyxl import load_workbook
import os

spreadsheet_location = os.path.dirname(os.path.abspath(__file__))+"/data/"


from c302 import print_

def read_data(include_nonconnected_cells=False, neuron_connect=False):

if neuron_connect:
conns = []
cells = []
filename = "%switvliet_2020_7_adult.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_adult.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_adult.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'

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 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()

109 changes: 109 additions & 0 deletions c302/WL1_SpreadsheetDataReader1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
from c302.NeuroMLUtilities import ConnectionInfo
from c302.NeuroMLUtilities import analyse_connections

from openpyxl import load_workbook
import os

spreadsheet_location = os.path.dirname(os.path.abspath(__file__))+"/data/"


from c302 import print_

def read_data(include_nonconnected_cells=False, neuron_connect=False):

if neuron_connect:
conns = []
cells = []
filename = "%switvliet_2020_1_L1.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_1_L1.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_1_L1.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'

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 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()
109 changes: 109 additions & 0 deletions c302/WL1_SpreadsheetDataReader2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
from c302.NeuroMLUtilities import ConnectionInfo
from c302.NeuroMLUtilities import analyse_connections

from openpyxl import load_workbook
import os

spreadsheet_location = os.path.dirname(os.path.abspath(__file__))+"/data/"


from c302 import print_

def read_data(include_nonconnected_cells=False, neuron_connect=False):

if neuron_connect:
conns = []
cells = []
filename = "%switvliet_2020_2_L1.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_2_L1.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_2_L1.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'

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 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()
Loading

0 comments on commit 5fde766

Please sign in to comment.