Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
yasinthanvickneswaran committed Jan 31, 2024
1 parent 463c540 commit c4f97c5
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
104 changes: 104 additions & 0 deletions c302/W_SpreadsheetDataReader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
from c302.NeuroMLUtilities import ConnectionInfo
from c302.NeuroMLUtilities import analyse_connections

from xlrd import open_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 = "%s8_adult.xlsx"%spreadsheet_location
rb = open_workbook(filename)
print_("Opened the Excel file: " + filename)

for row in range(1,rb.sheet_by_index(0).nrows):
pre = str(rb.sheet_by_index(0).cell(row,0).value)
post = str(rb.sheet_by_index(0).cell(row,1).value)
syntype = rb.sheet_by_index(0).cell(row,2).value
num = int(rb.sheet_by_index(0).cell(row,3).value)


conns.append(ConnectionInfo(pre, post, num, syntype))
if pre not in cells:
cells.append(pre)
if post not in cells:
cells.append(post)

return cells, conns

else:
conns = []
cells = []
filename = "%s8_adult.xlsx"%spreadsheet_location
rb = open_workbook(filename)

print_("Opened Excel file..: " + filename)

known_nonconnected_cells = ['CANL', 'CANR', 'VC6']


for row in range(1,rb.sheet_by_index(0).nrows):
pre = str(rb.sheet_by_index(0).cell(row,0).value)
post = str(rb.sheet_by_index(0).cell(row,1).value)
syntype = rb.sheet_by_index(0).cell(row,2).value
num = int(rb.sheet_by_index(0).cell(row,3).value)

conns.append(ConnectionInfo(pre, post, num, syntype))
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 = "%s8_adult.xlsx"%spreadsheet_location
rb = open_workbook(filename)

print_("Opened Excel file: "+ filename)

sheet = rb.sheet_by_index(1)

for row in range(1,sheet.nrows):
pre = str(sheet.cell(row,0).value)
post = str(sheet.cell(row,1).value)
syntype = 'Send'
num = int(sheet.cell(row,2).value)

conns.append(ConnectionInfo(pre, post, num, syntype))
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()

Binary file removed c302/data/8_adult.xlsx
Binary file not shown.

0 comments on commit c4f97c5

Please sign in to comment.