From 45a1161c1c1e3bc1d75dcc2c490c032d1a4b5111 Mon Sep 17 00:00:00 2001 From: dancelestini Date: Fri, 17 Mar 2023 15:21:54 +0100 Subject: [PATCH] Corrected template creation bug --- .gitignore | 2 +- Exp_info.csv | 4 +-- Lumar_GUI.py | 79 ++++++++++++++++------------------------------- Template_184s.osf | 8 ----- 4 files changed, 29 insertions(+), 64 deletions(-) diff --git a/.gitignore b/.gitignore index 20f219c..dff74c4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ Conditions_info.csv Exp_info.csv Trials_info.csv -Exp_info.csv +Template_184s.osf diff --git a/Exp_info.csv b/Exp_info.csv index 7d9107e..0c59a86 100644 --- a/Exp_info.csv +++ b/Exp_info.csv @@ -1,2 +1,2 @@ -Exp_id,Conditions,Condition 1,Condition 2,Condition 3,Condition4,Antennas,Odorant Trials,Trial 1,Trial 2,Trial 3,Trial 4,Trial 5,Trial 6,Trial 7,Trial 8,Remarks Cond 1,Remarks Cond 2,Remarks Cond 3 -1_03172023,3,DmOR1_OR22ab_Boosted Gal4_Knockin_GCaMP7f_F_M_3,DmOR1_OR42b_Gal4_Knockin_GCaMP7f_F_M_3,DmOR1_OR42b_Gal4_Knockin_GCaMP7f_F_M_3,NA,6,4,water 1,"(4R,5R)-5-(1,2-dihydroxyethyl)-3,4-dihydroxy-2-oxolanone_e3",water 2,"(4R,5R)-5-(1,2-dihydroxyethyl)-3,4-dihydroxy-2-oxolanone_e3_2",water 3,"(4R,5R)-5-(1,2-dihydroxyethyl)-3,4-dihydroxy-2-oxolanone_e3_3",water 4,"(4R,5R)-5-(1,2-dihydroxyethyl)-3,4-dihydroxy-2-oxolanone_e3_4",,, +Exp_id,Conditions,Condition 1,Condition 2,Condition 3,Condition4,Antennas,Odorant Trials,Remarks,Trial 1,Trial 2,Trial 3,Trial 4,Remarks Cond 1 +1_03172023,1,DmOR1_OR22ab_Boosted Gal4_Knockin_GCaMP7f_F_M_3,NA,NA,NA,6,2,cond_1_/ diff --git a/Lumar_GUI.py b/Lumar_GUI.py index c1c58cd..78b4c92 100755 --- a/Lumar_GUI.py +++ b/Lumar_GUI.py @@ -246,14 +246,14 @@ def create_CSV(self): transgene_name += "_" else: ### special get for textinput ### - toappend = globals()[f"{self.widgetsName[(((i-1)*self.NumColCondFrame)+col)]}"].get("1.0", "end-1c") - self.row.append(str(toappend)) + remarks = globals()[f"{self.widgetsName[(((i-1)*self.NumColCondFrame)+col)]}"].get("1.0", "end-1c") continue - ### Others ### toappend = globals()[f"{self.widgetsName[(((i-1)*self.NumColCondFrame)+col)]}"].get() self.row.append(str(toappend)) + self.row.append(str(transgene_name)) + self.row.append(str(remarks)) self.rows.append(self.row) ### write the Trials_info.csv file ### @@ -275,6 +275,7 @@ def create_CSV(self): diff_odors = [] id_repeat = dict() self.rows = [] + list_vials = [] ### if no water in between odors ### if(self.OdorantIB.get() == "None"): @@ -308,7 +309,13 @@ def create_CSV(self): odor = odor + "_" + str(id_repeat[odor]) self.row.append(odor) - self.row.append(dilution) + self.row.append(dilution) + + ### List_vials for the template ### + vial_number = int(globals()[f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+5)]}"].get()) + list_vials.append(vial_number) + + ### append the complete line ### self.rows.append(self.row) ### if water in between odors ### @@ -341,11 +348,18 @@ def create_CSV(self): self.row.append(odor) self.row.append(dilution) + + ### List_vials for the template ### + vial_number = int(globals()[f"{self.widgetsNameOD[int(((id-1)*self.NumColODFrame)+5)]}"].get()) + list_vials.append(vial_number) else: water_name = "Water "+ str((int(i/2)+1)) self.row.append(water_name) self.row.append(0) + + + ### append the complete line ### self.rows.append(self.row) ### write the Trials_info.csv file ### @@ -355,10 +369,10 @@ def create_CSV(self): for i in self.rows: writer.writerow(i) - + ### Exp_info.csv creation ### ### Create the header ### self.header = ["Exp_id", "Conditions", "Condition 1", "Condition 2", - "Condition 3", "Condition4", "Antennas", "Odorant Trials"] + "Condition 3", "Condition4", "Antennas", "Odorant Trials","Remarks"] if(self.OdorantIB.get() == "None"): for i in range(int(self.OdorantNum.get())+1): @@ -401,62 +415,21 @@ def create_CSV(self): ### Odorants ### self.row.append(self.OdorantNum.get()) - ### EachTrial ### - IBOD_name = ["%s %d" % (self.OdorantIB.get(), id) - for id in range(1, (int(self.OdorantNum.get())+1))] - list_vials = [] - id_repeat = dict() - - if(self.OdorantIB.get() == "None"): - # if we don't have in between selected we put first odor as water then nothing - self.row.append("Water 1") - for i in range(1, (int(self.OdorantNum.get())+1)): - text = str(globals()[f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+1)]}"].get()) + "_e" + \ - str(globals()[ - f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+3)]}"].get()) - if text in self.row: - if text not in id_repeat.keys(): - id_repeat[text] = 2 - else: - id_repeat[text] = id_repeat[text]+1 - - text = text + "_" + str(id_repeat[text]) - self.row.append(text) - vial_number = int( - globals()[f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+5)]}"].get()) - list_vials.append(vial_number) - else: - # if we do have an ib between odorant just intercal it between testing odors - for i in range(1, (int(self.OdorantNum.get())+1)): - self.row.append(IBOD_name[(i-1)]) - text = globals()[f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+1)]}"].get() + "_e" + \ - str(globals()[ - f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+3)]}"].get()) - - if text in self.row: - if text not in id_repeat.keys(): - id_repeat[text] = 2 - else: - id_repeat[text] = id_repeat[text]+1 - - text = text + "_" + str(id_repeat[text]) - self.row.append(textASDAS) - vial_number = int( - globals()[f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+5)]}"].get()) - list_vials.append(vial_number) - list_vials.append(1) - ### Remarks ### + remark = "" for i in range(1, (int(self.CondNum.get())+1)): - remark = globals()[ + remark += "cond_"+str(i)+"_" + remark += globals()[ f"{self.widgetsName[((i*self.NumColCondFrame)-1)]}"].get("1.0", "end-1c") - self.row.append(remark) + remark += "/" + self.row.append(remark) with open("C:/Users/irlab/gh-repos/Lumar_GUI/Lumar_GUI/Exp_info.csv", "w", encoding='UTF8', newline='') as self.f: writer = csv.writer(self.f, dialect='excel', delimiter=',') writer.writerow(self.header) writer.writerow(self.row) + ### Vial numbers for creating the template ### self.createTemplate(list_vials) self.close(self.master) diff --git a/Template_184s.osf b/Template_184s.osf index bdcbc30..61f277f 100644 --- a/Template_184s.osf +++ b/Template_184s.osf @@ -8,15 +8,7 @@ No Vial 30 1000 2 60 1000 2 60 1000 No Vial 30 1000 -1 30 1000 -1 60 1000 -1 60 1000 -No Vial 30 1000 3 30 1000 3 60 1000 3 60 1000 No Vial 30 1000 -1 30 1000 -1 60 1000 -1 60 1000 -No Vial 30 1000