From 98c749477c8a4bf91eda5c237adf2b3f3abd3d87 Mon Sep 17 00:00:00 2001 From: tyler Date: Fri, 30 Jan 2026 15:38:12 -0800 Subject: [PATCH] preferences --- changelog.md | 3 +++ main.py | 31 +++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/changelog.md b/changelog.md index 1f19785..b7bc2f0 100644 --- a/changelog.md +++ b/changelog.md @@ -19,6 +19,9 @@ - Fixed an issue where the dropdowns in the Viewer windows would immediately open and close when using a trackpad - glover and spm hrf models now function as intended without crashing. Currently, group analysis is still only supported by fir - Revamped the fold channels viewer to not hang the application and to better process multiple participants at once +- Added a Preferences menu to the navigation bar +- Currently, there is only one preference allowing to bypass the warning of 2D data +- Fixed [Issue 8](https://git.research.dezeeuw.ca/tyler/flares/issues/8), [Issue 9](https://git.research.dezeeuw.ca/tyler/flares/issues/9), [Issue 30](https://git.research.dezeeuw.ca/tyler/flares/issues/30), [Issue 31](https://git.research.dezeeuw.ca/tyler/flares/issues/31), [Issue 34](https://git.research.dezeeuw.ca/tyler/flares/issues/34), [Issue 36](https://git.research.dezeeuw.ca/tyler/flares/issues/36) # Version 1.1.7 diff --git a/main.py b/main.py index 69a7b08..21dbad6 100644 --- a/main.py +++ b/main.py @@ -188,11 +188,11 @@ SECTIONS = [ {"name": "RESAMPLE_FREQ", "default": 1, "type": int, "help": "The frequency the data should be resampled to."}, {"name": "HRF_MODEL", "default": ["fir"], "type": list, "options": ["fir", "glover", "spm", "spm + derivative", "spm + derivative + dispersion", "glover + derivative", "glover + derivative + dispersion"], "exclusive": True, "help": "Specifies the hemodynamic response function."}, - {"name": "STIM_DUR", "default": 0.5, "type": float, "help": "The length of your stimulus."}, - {"name": "DRIFT_MODEL", "default": "cosine", "type": str, "help": "Specifies the desired drift model."}, + {"name": "STIM_DUR", "default": 0.5, "type": float, "help": "The length of your stimulus. If your HRF_MODEL is fir, this dictates how wide a bin should be."}, + {"name": "DRIFT_MODEL", "default": ["cosine"], "type": list, "options": ["cosine", "polynomial"], "help": "Specifies the desired drift model."}, {"name": "HIGH_PASS", "default": 0.01, "type": float, "help": "High-pass frequency in case of a cosine model (in Hz)."}, {"name": "DRIFT_ORDER", "default": 1, "type": int, "help": "Order of the drift model (in case it is polynomial)"}, - {"name": "FIR_DELAYS", "default": "None", "type": range, "help": "In case of FIR design, yields the array of delays used in the FIR model (in scans)."}, + {"name": "FIR_DELAYS", "default": "None", "type": range, "depends_on": "HRF_MODEL", "depends_value": "fir", "help": "In case of FIR design, yields the array of delays used in the FIR model (in scans)."}, {"name": "MIN_ONSET", "default": -24, "type": int, "help": "Minimal onset relative to frame times (in seconds)"}, {"name": "OVERSAMPLING", "default": 50, "type": int, "help": "Oversampling factor used in temporal convolutions."}, {"name": "REMOVE_EVENTS", "default": "None", "type": list, "help": "Remove events matching the names provided before generating the Design Matrix"}, @@ -4342,6 +4342,7 @@ class MainApplication(QMainWindow): self.folder_paths = [] self.section_widget = None self.first_run = True + self.is_2d_bypass = False self.files_total = 0 # total number of files to process self.files_done = set() # set of file paths done (success or fail) @@ -4590,6 +4591,13 @@ class MainApplication(QMainWindow): if i == 1 or i == 3: # after the first 2 actions (0,1) options_menu.addSeparator() + preferences_menu = menu_bar.addMenu("Preferences") + preferences_actions = [ + ("2D Data Bypass", "Ctrl+B", self.is_2d_bypass_func, resource_path("icons/info_24dp_1F1F1F.svg")) + ] + for name, shortcut, slot, icon in preferences_actions: + preferences_menu.addAction(make_action(name, shortcut, slot, icon=icon, checkable=True, checked=False)) + terminal_menu = menu_bar.addMenu("Terminal") terminal_actions = [ ("New Terminal", "Ctrl+Alt+T", self.terminal_gui, resource_path("icons/terminal_24dp_1F1F1F.svg")), @@ -4670,6 +4678,8 @@ class MainApplication(QMainWindow): self.top_left_widget.paste() # Trigger paste self.statusbar.showMessage("Pasted from clipboard") # Show status message + def is_2d_bypass_func(self, checked): + self.is_2d_bypass = checked def about_window(self): if self.about is None or not self.about.isVisible(): @@ -5290,13 +5300,14 @@ class MainApplication(QMainWindow): ) if is_2d: - QMessageBox.critical(None, "Error - 2D Data Detected - FLARES", f"Error: 2 dimensional data was found in {i}. " - "It is not possible to process this file. Please update the coordinates " - "using the 'Update optodes in snirf file...' option from the Options menu or by pressing 'F6'.") - self.button1.clicked.disconnect(self.cancel_task) - self.button1.setText("Process") - self.button1.clicked.connect(self.on_run_task) - return + if self.is_2d_bypass == False: + QMessageBox.critical(None, "Error - 2D Data Detected - FLARES", f"Error: 2 dimensional data was found in {i}. " + "Please update the coordinates using the 'Update optodes in snirf file...' option from the Options menu or by pressing 'F6'. " + "You may also select the '2D Data Bypass' option from the Preferences menu to ignore this warning and process anyway. ") + self.button1.clicked.disconnect(self.cancel_task) + self.button1.setText("Process") + self.button1.clicked.connect(self.on_run_task) + return self.files_total = len(snirf_files) self.files_done = set()