From 3385be0b211eee466e571953705d5faba446f6b1 Mon Sep 17 00:00:00 2001 From: yasinthanvickneswaran Date: Mon, 12 Feb 2024 15:39:31 +0000 Subject: [PATCH] witvliet --- c302/W00_SpreadsheetDataReader.py | 94 ++++++++++++++++++ c302/W0_SpreadsheetDataReader.py | 76 ++++++++++++++ c302/W_SpreadsheetDataReader.py | 7 +- ...et_2020_1_L1.xlsx => witvliet_2020_1.xlsx} | Bin ...et_2020_2_L1.xlsx => witvliet_2020_2.xlsx} | Bin ...et_2020_3_L1.xlsx => witvliet_2020_3.xlsx} | Bin ...et_2020_4_L1.xlsx => witvliet_2020_4.xlsx} | Bin ...et_2020_5_L2.xlsx => witvliet_2020_5.xlsx} | Bin ...et_2020_6_L3.xlsx => witvliet_2020_6.xlsx} | Bin ...2020_7_adult.xlsx => witvliet_2020_7.xlsx} | Bin ...2020_8_adult.xlsx => witvliet_2020_8.xlsx} | Bin 11 files changed, 173 insertions(+), 4 deletions(-) create mode 100644 c302/W00_SpreadsheetDataReader.py create mode 100644 c302/W0_SpreadsheetDataReader.py rename c302/data/{witvliet_2020_1_L1.xlsx => witvliet_2020_1.xlsx} (100%) rename c302/data/{witvliet_2020_2_L1.xlsx => witvliet_2020_2.xlsx} (100%) rename c302/data/{witvliet_2020_3_L1.xlsx => witvliet_2020_3.xlsx} (100%) rename c302/data/{witvliet_2020_4_L1.xlsx => witvliet_2020_4.xlsx} (100%) rename c302/data/{witvliet_2020_5_L2.xlsx => witvliet_2020_5.xlsx} (100%) rename c302/data/{witvliet_2020_6_L3.xlsx => witvliet_2020_6.xlsx} (100%) rename c302/data/{witvliet_2020_7_adult.xlsx => witvliet_2020_7.xlsx} (100%) rename c302/data/{witvliet_2020_8_adult.xlsx => witvliet_2020_8.xlsx} (100%) diff --git a/c302/W00_SpreadsheetDataReader.py b/c302/W00_SpreadsheetDataReader.py new file mode 100644 index 00000000..9e124685 --- /dev/null +++ b/c302/W00_SpreadsheetDataReader.py @@ -0,0 +1,94 @@ +from c302.NeuroMLUtilities import ConnectionInfo, analyse_connections +from openpyxl import load_workbook +import os +from c302 import print_ + +class Witvliet: + def __init__(self, file_prefix, num_files=8): + self.file_prefix = file_prefix + self.num_files = num_files + self.spreadsheet_location = os.path.dirname(os.path.abspath(__file__)) + "/data/" + + def read_data(self, include_nonconnected_cells=False, neuron_connect=False): + all_cells = [] + all_conns = [] + + for i in range(1, self.num_files + 1): + cells = [] + conns = [] + filename = f"{self.spreadsheet_location}{self.file_prefix}_{i}.xlsx" + 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): + 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: + known_nonconnected_cells = ['CANL', 'CANR', 'VC6'] + for c in known_nonconnected_cells: + cells.append(c) + + all_cells.append(cells) + all_conns.append(conns) + + return all_cells, all_conns + + def read_muscle_data(self): + all_neurons = [] + all_muscles = [] + all_conns = [] + + for i in range(1, self.num_files + 1): + neurons = [] + muscles = [] + conns = [] + + filename = f"{self.spreadsheet_location}{self.file_prefix}_{i}.xlsx" + 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) + + all_neurons.append(neurons) + all_muscles.append(muscles) + all_conns.append(conns) + + return all_neurons, all_muscles, all_conns + + def main(self): + all_cells, all_neuron_conns = self.read_data(include_nonconnected_cells=True) + all_neurons2muscles, all_muscles, all_muscle_conns = self.read_muscle_data() + + for cells, neuron_conns in zip(all_cells, all_neuron_conns): + analyse_connections(cells, neuron_conns, [], [], []) # Adjust the parameters accordingly + + for neurons, muscles, muscle_conns in zip(all_neurons2muscles, all_muscles, all_muscle_conns): + analyse_connections([], [], neurons, muscles, muscle_conns) # Adjust the parameters accordingly + + +if __name__ == '__main__': + excel_reader = Witvliet(file_prefix='witvliet_2020', num_files=8) + excel_reader.main() diff --git a/c302/W0_SpreadsheetDataReader.py b/c302/W0_SpreadsheetDataReader.py new file mode 100644 index 00000000..ce886339 --- /dev/null +++ b/c302/W0_SpreadsheetDataReader.py @@ -0,0 +1,76 @@ +from c302.NeuroMLUtilities import ConnectionInfo, analyse_connections +from openpyxl import load_workbook +import os +from c302 import print_ + +class ExcelDataReader: + def __init__(self, file_prefix, num_files=8): + self.file_prefix = file_prefix + self.num_files = num_files + self.spreadsheet_location = os.path.dirname(os.path.abspath(__file__)) + "/data/" + + def read_data(self, include_nonconnected_cells=False, neuron_connect=False): + cells = [] + conns = [] + + for i in range(1, self.num_files + 1): + filename = f"{self.spreadsheet_location}{self.file_prefix}_{i}.xlsx" + 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): + 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: + known_nonconnected_cells = ['CANL', 'CANR', 'VC6'] + for c in known_nonconnected_cells: + cells.append(c) + + return cells, conns + + def read_muscle_data(self): + neurons = [] + muscles = [] + conns = [] + + for i in range(1, self.num_files + 1): + filename = f"{self.spreadsheet_location}{self.file_prefix}_{i}.xlsx" + 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(self): + cells, neuron_conns = self.read_data(include_nonconnected_cells=True) + neurons2muscles, muscles, muscle_conns = self.read_muscle_data() + analyse_connections(cells, neuron_conns, neurons2muscles, muscles, muscle_conns) + + +if __name__ == '__main__': + excel_reader = ExcelDataReader(file_prefix='witvliet_2020', num_files=8) + excel_reader.main() diff --git a/c302/W_SpreadsheetDataReader.py b/c302/W_SpreadsheetDataReader.py index a0f9bf56..8e38011e 100644 --- a/c302/W_SpreadsheetDataReader.py +++ b/c302/W_SpreadsheetDataReader.py @@ -14,7 +14,7 @@ def read_data(include_nonconnected_cells=False, neuron_connect=False): if neuron_connect: conns = [] cells = [] - filename = "%switvliet_2020_8_adult.xlsx"%spreadsheet_location + filename = "%switvliet_2020_8.xlsx"%spreadsheet_location wb = load_workbook(filename) sheet = wb.worksheets[0] print_("Opened the Excel file: " + filename) @@ -38,7 +38,7 @@ def read_data(include_nonconnected_cells=False, neuron_connect=False): else: conns = [] cells = [] - filename = "%switvliet_2020_8_adult.xlsx"%spreadsheet_location + filename = "%switvliet_2020_8.xlsx"%spreadsheet_location wb = load_workbook(filename) sheet = wb.worksheets[0] @@ -73,7 +73,7 @@ def read_muscle_data(): neurons = [] muscles = [] - filename = "%switvliet_2020_8_adult.xlsx"%spreadsheet_location + filename = "%switvliet_2020_8.xlsx"%spreadsheet_location wb = load_workbook(filename) sheet = wb.worksheets[0] @@ -107,4 +107,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/c302/data/witvliet_2020_1_L1.xlsx b/c302/data/witvliet_2020_1.xlsx similarity index 100% rename from c302/data/witvliet_2020_1_L1.xlsx rename to c302/data/witvliet_2020_1.xlsx diff --git a/c302/data/witvliet_2020_2_L1.xlsx b/c302/data/witvliet_2020_2.xlsx similarity index 100% rename from c302/data/witvliet_2020_2_L1.xlsx rename to c302/data/witvliet_2020_2.xlsx diff --git a/c302/data/witvliet_2020_3_L1.xlsx b/c302/data/witvliet_2020_3.xlsx similarity index 100% rename from c302/data/witvliet_2020_3_L1.xlsx rename to c302/data/witvliet_2020_3.xlsx diff --git a/c302/data/witvliet_2020_4_L1.xlsx b/c302/data/witvliet_2020_4.xlsx similarity index 100% rename from c302/data/witvliet_2020_4_L1.xlsx rename to c302/data/witvliet_2020_4.xlsx diff --git a/c302/data/witvliet_2020_5_L2.xlsx b/c302/data/witvliet_2020_5.xlsx similarity index 100% rename from c302/data/witvliet_2020_5_L2.xlsx rename to c302/data/witvliet_2020_5.xlsx diff --git a/c302/data/witvliet_2020_6_L3.xlsx b/c302/data/witvliet_2020_6.xlsx similarity index 100% rename from c302/data/witvliet_2020_6_L3.xlsx rename to c302/data/witvliet_2020_6.xlsx diff --git a/c302/data/witvliet_2020_7_adult.xlsx b/c302/data/witvliet_2020_7.xlsx similarity index 100% rename from c302/data/witvliet_2020_7_adult.xlsx rename to c302/data/witvliet_2020_7.xlsx diff --git a/c302/data/witvliet_2020_8_adult.xlsx b/c302/data/witvliet_2020_8.xlsx similarity index 100% rename from c302/data/witvliet_2020_8_adult.xlsx rename to c302/data/witvliet_2020_8.xlsx