def execute_button_action(self): if len(self.files)<1: tkinter.messagebox.showwarning("No Source Files", "No Source files were found in selected location.") elif self.destination_file is None: tkinter.messagebox.showwarning("No Destination File selected", "You have not specified a save location.") else: self.start = time.time() self.window_size=0.2 self.threshold=None try: self.window_size=float(self.spinbox_window.get()) except: tkinter.messagebox.showerror('Window Size Error', 'Could not cast Window Size as number') try: if self.combo_threshold.current()==1: self.threshold = self.spinbox_threshold.get() if self.threshold != '' or len(str(self.threshold))>1: self.threshold = float(self.threshold) else: self.threshold=None else: self.threshold=None except: tkinter.messagebox.showerror('Threshold Error', 'Could not cast Threshold as number') self.out_data = [] if self.combo_output.current()==0: self.out_data.append(["Source File", "Mass/Charge", "Intensity"]) elif self.combo_output.current()==1: self.out_data.append(["Source File", "Mass/Charge", "Intensity", "Peak of Interest"]) elif self.combo_output.current()==2: self.out_data.append(["Source File", "Mass/Charge", "Intensity", "Maximum", "Inflection", "Peak of Interest"]) else: self.out_data.append(["Source File", "Mass/Charge", "Intensity", "Maximum", "Inflection", "Peak of Interest"]) #add other Elifs for output headers self.current_progress=0 for f in self.files: test = IO.CSVFileReader(f, hasHeaders=bool(self.state_headers.get())) test.read() data = Data.DataSet(test) data.window_max(window_size=float(self.window_size)) if self.combo_id_column.current()==0: column_a=data.path elif self.combo_id_column.current()==1: column_a=data.name else: column_a=data.name #Threshold Settings if self.combo_threshold.current()==0: self.threshold=data.average_non_inflections elif self.combo_threshold.current()==1: self.threshold=float(self.spinbox_threshold.get()) elif self.combo_threshold.current()==2: self.threshold=data.base_median elif self.combo_threshold.current()==3: self.threshold=data.base_average else: self.threshold=None #Factor if self.state_factor.get()==True: data.max_nearest_greater_factor(float(self.spinbox_factor.get())) if self.combo_output.current()==0: data.max_points.sort(reverse=True) for row in data.max_points: if self.threshold is None and row.y>data.average_non_inflections and row.max_at_x and row.active and row.inflection: self.out_data.append([str(column_a), str(row.x), str(row.y)]) elif not self.threshold is None: if row.y>self.threshold and row.max_at_x and row.active and row.inflection: self.out_data.append([str(column_a), str(row.x), str(row.y)]) elif self.combo_output.current()==1: data.max_points.sort(reverse=True) for row in data.max_points: if self.threshold is None: self.out_data.append([str(column_a), str(row.x), str(row.y), str(row.max_at_x and row.active and row.inflection and row.y>data.average_non_inflections)]) elif not self.threshold is None: self.out_data.append([str(column_a), str(row.x), str(row.y), str(row.max_at_x and row.active and row.inflection and row.y>self.threshold)]) elif self.combo_output.current()==2: data.data.sort(reverse=True) for row in data.data: if self.threshold is None: self.out_data.append([str(column_a), str(row.x), str(row.y),str(row.max_at_x), str(row.inflection), str(row.max_at_x and row.active and row.inflection and row.y>data.average_non_inflections)]) elif not self.threshold is None: self.out_data.append([str(column_a), str(row.x), str(row.y),str(row.max_at_x), str(row.inflection), str(row.max_at_x and row.active and row.inflection and row.y>self.threshold)]) else: data.data.sort(reverse=True) for row in data.data: if self.threshold is None: self.out_data.append([str(column_a), str(row.x), str(row.y),str(row.max_at_x), str(row.inflection), str(row.max_at_x and row.active and row.inflection and row.y>data.average_non_inflections)]) elif not self.threshold is None: self.out_data.append([str(column_a), str(row.x), str(row.y),str(row.max_at_x), str(row.inflection), str(row.max_at_x and row.active and row.inflection and row.y>self.threshold)]) self.current_progress+=1 self.current_progress_var.set((self.current_progress/len(self.files))*100) self.master.update_idletasks() out = IO.CSVFileWriter(pathlib.Path(self.destination), self.out_data) out.write() self.stop = time.time() tkinter.messagebox.showinfo("Complete!", "Processed {} files, exported {} rows of data, in {:.1f} seconds".format(len(self.files), len(self.out_data)-1, self.stop-self.start))