From 2334e9cf27f9d1e709fed22589400a9845c5f9ab Mon Sep 17 00:00:00 2001 From: HarryVasanth Date: Thu, 12 Feb 2026 10:04:24 +0000 Subject: [PATCH 1/3] chore(codebase): fmt & lint --- physiological_data/lib/biosignals.py | 1 - physiological_data/lib/novainstrumentation/peakdelta.py | 1 - 2 files changed, 2 deletions(-) diff --git a/physiological_data/lib/biosignals.py b/physiological_data/lib/biosignals.py index 5cd9f270..12968b67 100644 --- a/physiological_data/lib/biosignals.py +++ b/physiological_data/lib/biosignals.py @@ -8,7 +8,6 @@ import biosignalsnotebooks as bsnb import abc - END_BASELINE = "End of Baseline" BEGIN_BASELINE = "Begin of Baseline" N_BACK = "N-back" diff --git a/physiological_data/lib/novainstrumentation/peakdelta.py b/physiological_data/lib/novainstrumentation/peakdelta.py index b24c20a2..93a460ab 100644 --- a/physiological_data/lib/novainstrumentation/peakdelta.py +++ b/physiological_data/lib/novainstrumentation/peakdelta.py @@ -9,7 +9,6 @@ from numpy import NaN, Inf, arange, isscalar, array, asarray - ############################################################################## ########################### Peaks Detection ################################## ############################################################################## From f3d25927347a50c8120b511a339475674a554157 Mon Sep 17 00:00:00 2001 From: rodrigolima6 Date: Tue, 13 Jan 2026 14:36:12 +0000 Subject: [PATCH 2/3] feat(Project): organize project into sub-modules --- loop_system/Baseline.py | 10 +++++----- loop_system/Manager.py | 20 ++++++++------------ loop_system/Training_Model.py | 8 +++----- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/loop_system/Baseline.py b/loop_system/Baseline.py index 67549921..8aba133a 100644 --- a/loop_system/Baseline.py +++ b/loop_system/Baseline.py @@ -7,12 +7,14 @@ warnings.filterwarnings("ignore") - def select_file(title, filetypes): root = tk.Tk() root.withdraw() # hide the main Tkinter window - file_path = filedialog.askopenfilename(title=title, filetypes=filetypes) + file_path = filedialog.askopenfilename( + title=title, + filetypes=filetypes + ) if not file_path: print("No file selected. Exiting...") @@ -20,12 +22,11 @@ def select_file(title, filetypes): return file_path - def main(): start_time = time.time() # Prompt user to select the XDF file - file_path = select_file("Select the Baseline data file", [("XDF files", "*.xdf")]) + file_path = select_file("Select the Baseline data file",[("XDF files", "*.xdf")]) # Extract folder and condition name from the file path folder = os.path.dirname(file_path) @@ -70,6 +71,5 @@ def main(): except Exception as e: print(f"An error occurred saving the Baseline Dataframe: {e}") - if __name__ == "__main__": main() diff --git a/loop_system/Manager.py b/loop_system/Manager.py index af4b2419..fea7aa70 100644 --- a/loop_system/Manager.py +++ b/loop_system/Manager.py @@ -58,9 +58,7 @@ def run(self): modelTrainer = ModelTrainer() """Load and Select Baseline Data file""" - baseline_file = select_file( - "Select the Baseline data file.", [("CSV files", "*.csv")] - ) + baseline_file = select_file("Select the Baseline data file.", [("CSV files", "*.csv")]) if not baseline_file: print("No baseline file selected. Exiting...") @@ -78,9 +76,7 @@ def run(self): """Load and Select Training Data file""" - training_data = select_file( - "Select the training data file.", [("CSV files", "*.csv")] - ) + training_data = select_file("Select the training data file.", [("CSV files", "*.csv")]) if not training_data: print("No training data file selected. Exiting...") @@ -118,9 +114,7 @@ def run(self): os.makedirs(log_folder, exist_ok=True) # Ensure directory exists log_file_path = os.path.join(log_folder, "output.txt") - print( - "Logging output to {log_file_path}...".format(log_file_path=log_file_path) - ) + print("Logging output to {log_file_path}...".format(log_file_path=log_file_path)) log_file = open(log_file_path, "w") sys.stdout = TeeLogger(log_file) @@ -245,8 +239,11 @@ def run(self): pass finally: try: - model_path = os.path.join(base_dir, f"model_v{self.model_version}.pkl") - joblib.dump(self.model, model_path) + model_path = os.path.join(base_dir, f"model_v{self.model_version}.pkl" ) + joblib.dump( + self.model, + model_path + ) print(f"Model saved successfully to {model_path}") except Exception as e: print(f"Error saving the model: {e}") @@ -265,7 +262,6 @@ def run(self): data_sender.join() print("Closed all processes.") - if __name__ == "__main__": multiprocessing.freeze_support() manager = Manager() diff --git a/loop_system/Training_Model.py b/loop_system/Training_Model.py index d7084558..22a088d7 100644 --- a/loop_system/Training_Model.py +++ b/loop_system/Training_Model.py @@ -9,7 +9,6 @@ warnings.filterwarnings("ignore") - def main(): start_time = time.time() @@ -20,9 +19,7 @@ def main(): """Load Baseline Data file""" - baseline_file = select_file( - "Select the Baseline data file", [("CSV files", "*.csv")] - ) + baseline_file = select_file("Select the Baseline data file", [("CSV files", "*.csv")]) """Baseline Dataframe""" try: @@ -61,6 +58,7 @@ def main(): print(f"An error occurred loading the N-Back data: {e}") sys.exit(1) + """Signals Processing""" signals = getSignals( data, "OpenSignals", "PsychoPy Markers", "PsychoPy Ratings", sensors=sensors @@ -106,6 +104,7 @@ def main(): print("Performing GridSearchCV to find the best models...") best_models = gridSearchCV(X, Y) + print("GridSearch completed.") # Sort the models by their best score in descending order sorted_models = sorted( @@ -138,6 +137,5 @@ def main(): print(f"Elapsed time = {(time.time()-start_time)/60:.2f} minutes") - if __name__ == "__main__": main() From 74dc90cf6c2d52f23be33c91b830669b2f34451d Mon Sep 17 00:00:00 2001 From: HarryVasanth Date: Thu, 12 Feb 2026 10:04:24 +0000 Subject: [PATCH 3/3] chore(codebase): fmt & lint --- loop_system/Baseline.py | 10 +++++----- loop_system/Manager.py | 20 ++++++++++++-------- loop_system/Training_Model.py | 8 +++++--- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/loop_system/Baseline.py b/loop_system/Baseline.py index 8aba133a..67549921 100644 --- a/loop_system/Baseline.py +++ b/loop_system/Baseline.py @@ -7,14 +7,12 @@ warnings.filterwarnings("ignore") + def select_file(title, filetypes): root = tk.Tk() root.withdraw() # hide the main Tkinter window - file_path = filedialog.askopenfilename( - title=title, - filetypes=filetypes - ) + file_path = filedialog.askopenfilename(title=title, filetypes=filetypes) if not file_path: print("No file selected. Exiting...") @@ -22,11 +20,12 @@ def select_file(title, filetypes): return file_path + def main(): start_time = time.time() # Prompt user to select the XDF file - file_path = select_file("Select the Baseline data file",[("XDF files", "*.xdf")]) + file_path = select_file("Select the Baseline data file", [("XDF files", "*.xdf")]) # Extract folder and condition name from the file path folder = os.path.dirname(file_path) @@ -71,5 +70,6 @@ def main(): except Exception as e: print(f"An error occurred saving the Baseline Dataframe: {e}") + if __name__ == "__main__": main() diff --git a/loop_system/Manager.py b/loop_system/Manager.py index fea7aa70..af4b2419 100644 --- a/loop_system/Manager.py +++ b/loop_system/Manager.py @@ -58,7 +58,9 @@ def run(self): modelTrainer = ModelTrainer() """Load and Select Baseline Data file""" - baseline_file = select_file("Select the Baseline data file.", [("CSV files", "*.csv")]) + baseline_file = select_file( + "Select the Baseline data file.", [("CSV files", "*.csv")] + ) if not baseline_file: print("No baseline file selected. Exiting...") @@ -76,7 +78,9 @@ def run(self): """Load and Select Training Data file""" - training_data = select_file("Select the training data file.", [("CSV files", "*.csv")]) + training_data = select_file( + "Select the training data file.", [("CSV files", "*.csv")] + ) if not training_data: print("No training data file selected. Exiting...") @@ -114,7 +118,9 @@ def run(self): os.makedirs(log_folder, exist_ok=True) # Ensure directory exists log_file_path = os.path.join(log_folder, "output.txt") - print("Logging output to {log_file_path}...".format(log_file_path=log_file_path)) + print( + "Logging output to {log_file_path}...".format(log_file_path=log_file_path) + ) log_file = open(log_file_path, "w") sys.stdout = TeeLogger(log_file) @@ -239,11 +245,8 @@ def run(self): pass finally: try: - model_path = os.path.join(base_dir, f"model_v{self.model_version}.pkl" ) - joblib.dump( - self.model, - model_path - ) + model_path = os.path.join(base_dir, f"model_v{self.model_version}.pkl") + joblib.dump(self.model, model_path) print(f"Model saved successfully to {model_path}") except Exception as e: print(f"Error saving the model: {e}") @@ -262,6 +265,7 @@ def run(self): data_sender.join() print("Closed all processes.") + if __name__ == "__main__": multiprocessing.freeze_support() manager = Manager() diff --git a/loop_system/Training_Model.py b/loop_system/Training_Model.py index 22a088d7..d7084558 100644 --- a/loop_system/Training_Model.py +++ b/loop_system/Training_Model.py @@ -9,6 +9,7 @@ warnings.filterwarnings("ignore") + def main(): start_time = time.time() @@ -19,7 +20,9 @@ def main(): """Load Baseline Data file""" - baseline_file = select_file("Select the Baseline data file", [("CSV files", "*.csv")]) + baseline_file = select_file( + "Select the Baseline data file", [("CSV files", "*.csv")] + ) """Baseline Dataframe""" try: @@ -58,7 +61,6 @@ def main(): print(f"An error occurred loading the N-Back data: {e}") sys.exit(1) - """Signals Processing""" signals = getSignals( data, "OpenSignals", "PsychoPy Markers", "PsychoPy Ratings", sensors=sensors @@ -104,7 +106,6 @@ def main(): print("Performing GridSearchCV to find the best models...") best_models = gridSearchCV(X, Y) - print("GridSearch completed.") # Sort the models by their best score in descending order sorted_models = sorted( @@ -137,5 +138,6 @@ def main(): print(f"Elapsed time = {(time.time()-start_time)/60:.2f} minutes") + if __name__ == "__main__": main()