def export_experiment(self): self.info_logfile_dict['roi'].append(self.roi_list) self.info_logfile_dict['exposure time'].append(self.exposure_time_value.value()) self.info_logfile_dict['binning'].append(self.bin_size) self.info_logfile_dict['fps'].append(self.internal_frame_rate) self.info_logfile_dict['fov'].append((self.x_init, self.x_dim, self.y_init, self.y_dim)) jsonFunctions.write_to_json(self.info_logfile_dict, self.info_logfile_path)
def set_main_path_from_user_input(self): """ Set the path_init variable from user input and save it in the path_init config file """ self.path_init = QFileDialog.getExistingDirectory(None, 'Select the folder you want the path to change to:', 'C:/', QFileDialog.ShowDirsOnly) jsonFunctions.write_to_json(self.path_init, 'OPTIMAQS/config_files/path_init.json')
def change_folder(self): """ Change the folder defined as self.path """ self.path = QFileDialog.getExistingDirectory(None, 'Select the folder you want the path to change to:', 'C:/', QFileDialog.ShowDirsOnly) self.path = self.path.replace('/','\\') self.path_raw_data = self.path + '\\raw_data' self.current_folder_label_2.setText(str(self.path)) jsonFunctions.write_to_json(self.path, 'OPTIMAQS/config_files/last_experiment.json')
def initialize_experiment(self): """ Initialize/Reinitilize experiment logfiles and variables """ ## reinitilize JSON files self.init_log_dict() self.images = [] self.image_list = [] self.image_reshaped = [] self.ephy_data = [] ## init perf_counter for timing events self.perf_counter_init = time.perf_counter() jsonFunctions.write_to_json( self.perf_counter_init, 'OPTIMAQS/config_files/perf_counter_init.json') ## generate folder to save the data self.path = self.path_init self.path_raw_data = self.path + '\\raw_data' date = time.strftime("%Y_%m_%d") self.path = os.path.join(self.path, date) if not os.path.exists(self.path): os.makedirs( self.path ) ## make a folder with the date of today if it does not already exists n = 1 self.path_temp = os.path.join( self.path, 'experiment_' + str(n) ) ## in case of multiple experiments a day, need to create several subdirectory while os.path.exists( self.path_temp): ## but necesarry to check which one aleady exists n += 1 self.path_temp = os.path.join(self.path, 'experiment_' + str(n)) self.path = self.path_temp self.path_raw_data = self.path + '\\raw_data' os.makedirs(self.path) os.makedirs(self.path + '\\dlp_images') os.makedirs(self.path + '\\raw_data') jsonFunctions.write_to_json(self.path, 'OPTIMAQS/config_files/last_experiment.json') ## generate log files self.info_logfile_path = self.path + "/experiment_{}_info.json".format(n) experiment_time = time.asctime(time.localtime(time.time())) self.info_logfile_dict['experiment creation date'] = experiment_time # with open(self.info_logfile_path,"w+") as file: ## store basic info and comments # json.dump(self.info_logfile_dict, file) jsonFunctions.write_to_json(self.info_logfile_dict, self.info_logfile_path) self.timings_logfile_path = self.path + "/experiment_{}_timings.json".format( n) # with open(self.timings_logfile_path, "w+") as file: # json.dump(self.timings_logfile_dict, file) jsonFunctions.write_to_json(self.timings_logfile_dict, self.timings_logfile_path) self.current_folder_label_2.setText(str( self.path)) ## show current directory in the GUI
def saving_images(self, images, times): if self.saving_check.isChecked(): ## saving images save_images_worker = Worker(self.save, self.image_list, self.path_raw_data) save_images_worker.signals.result.connect( save_images_worker.print_output) save_images_worker.signals.finished.connect( save_images_worker.thread_complete) #save_images_worker.signals.progress.connect(self.progress_fn) self.threadpool.start(save_images_worker) ## saving images times jsonFunctions.update_timings_to_json(self.timings_logfile_dict, self.timings_logfile_path) ## saving experiment info #self.info_logfile_dict['roi'].append(self.roi_list) ##this is doe in export roi self.info_logfile_dict['exposure time'].append( self.exposure_time_value.value()) self.info_logfile_dict['binning'].append(self.bin_size) self.info_logfile_dict['fps'].append(self.internal_frame_rate) self.info_logfile_dict['fov'].append( (self.x_init, self.x_dim, self.y_init, self.y_dim)) jsonFunctions.write_to_json(self.info_logfile_dict, self.info_logfile_path)
def save_main_path_to_config_file(self): """ Save the path_init variable in the path_init config file """ return jsonFunctions.write_to_json(self.path_init, 'OPTIMAQS/config_files/path_init.json')
def export_roi(self): self.info_logfile_dict['roi'].append(self.roi_list) jsonFunctions.write_to_json(self.info_logfile_dict, self.info_logfile_path) print('roi exported')