diff --git a/logics.py b/logics.py index 977addb..502456d 100644 --- a/logics.py +++ b/logics.py @@ -28,14 +28,15 @@ class DiffractionLimitedAnalysis: - def __init__(self, data_path): + def __init__(self, data_path, parameters): self.error = 1 # When this value is 1, no error was detected in the object. self.path_program = os.path.dirname(__file__) self.path_data_main = data_path + self.parameters = parameters # Construct dirs for results - self.path_result_main = data_path + '_results' + self.path_result_main = data_path + '_results' + self.parameters if os.path.isdir(self.path_result_main) != 1: os.mkdir(self.path_result_main) self.path_result_raw = os.path.join(self.path_result_main, 'raw') @@ -144,8 +145,8 @@ def call_ComDet(self, size, threshold, progress_signal=None, IJ=None): print('No spot found in FoV: ' + field) else: img_dimensions = Image.open(imgFile).size - df = df.loc[(df['X_(px)'] >= img_dimensions[0] * 0.05) & (df['X_(px)'] <= img_dimensions[0] * 0.95)] - df = df.loc[(df['Y_(px)'] >= img_dimensions[1] * 0.05) & (df['Y_(px)'] <= img_dimensions[1] * 0.95)] + df = df.loc[(df['X_(px)'] >= img_dimensions[0] * 0.02) & (df['X_(px)'] <= img_dimensions[0] * 0.98)] + df = df.loc[(df['Y_(px)'] >= img_dimensions[1] * 0.02) & (df['Y_(px)'] <= img_dimensions[1] * 0.98)] # Remove particles detected in the 5% pixels from the edges df = df.reset_index(drop=True) df.to_csv(saveto + '_results.csv') @@ -368,7 +369,15 @@ def generate_reports(self, progress_signal=None): }) summary_report = pd.concat([summary_report, df_sum]) except pd.errors.EmptyDataError: - pass + df_sum = pd.DataFrame.from_dict({ + 'Well': [well], + 'NoOfFoV': [len(self.wells[well])], + 'ParticlePerFoV': [0], + 'MeanSize': [0], + 'MeanIntegrInt': [0], + 'MeanIntPerArea': [0] + }) + summary_report = pd.concat([summary_report, df_sum]) if progress_signal == None: pass else: diff --git a/main.py b/main.py index 0d3dc46..f0734fc 100755 --- a/main.py +++ b/main.py @@ -156,11 +156,11 @@ def clickDFLSPRun(self): def clickDFLSPGenerateReports(self): data_path = self.window.DFLSP_pathEntry.text() - self.data_path = data_path.replace('_results', '') + self.data_path = data_path.replace('_results' + self.parameters, '') self.window.DFLSP_pathEntry.setText(self.data_path) guard = self._checkDFLSPParameters() if guard == 1: - if os.path.isdir(self.data_path + '_results') ==False: + if os.path.isdir(self.data_path + '_results' + self.parameters) ==False: self.showMessage('w', 'This dataset has not been analysed. Please run analysis.') else: @@ -170,11 +170,11 @@ def clickDFLSPGenerateReports(self): def clickDFLSPReadTaggedResults(self): data_path = self.window.DFLSP_pathEntry.text() - self.data_path = data_path.replace('_results', '') + self.data_path = data_path.replace('_results' + self.parameters, '') self.window.DFLSP_pathEntry.setText(self.data_path) guard = self._checkDFLSPParameters() if guard == 1: - if os.path.isdir(self.data_path + '_results') ==False: + if os.path.isdir(self.data_path + '_results' + self.parameters) ==False: self.showMessage('w', 'This dataset has not been analysed. Please run analysis.') else: self.updateLog('Data path set to '+data_path) @@ -194,6 +194,9 @@ def _checkDFLSPParameters(self): self.window.DFLSP_pathEntry.setText(self.data_path) self.updateLog('Data path set to '+data_path) + # Get the method for analysis + self.method = self.window.DFLSP_methodSelector.currentText() + # Check input: threshold try: self.threshold = int(self.window.DFLSP_thresholdEntry.text()) @@ -218,7 +221,8 @@ def _checkDFLSPParameters(self): else: self.updateLog('Estimated particle size set as '+str(self.size)+' pixels.') - self.project = DiffractionLimitedAnalysis(self.data_path) # Creat DiffractionLimitedAnalysis object + self.parameters = '_' + self.method + '_' + str(self.threshold) + '_' + str(self.size) + self.project = DiffractionLimitedAnalysis(self.data_path, self.parameters) # Creat DiffractionLimitedAnalysis object if self.project.error == 1: return 1 else: @@ -231,7 +235,7 @@ def _runDFLSPAnalysis(self): # Create a QThread object self.PFThread = QThread() # Create a worker object - self.particleFinder = toolbox.DFLParticleFinder(self.window.DFLSP_methodSelector.currentText(), self.project, self.size, self.threshold, self.IJ) + self.particleFinder = toolbox.DFLParticleFinder(self.method, self.project, self.size, self.threshold, self.IJ) # Connect signals and slots self.PFThread.started.connect(self.particleFinder.run)