From 45c6176dba9e0334c9129c739996b63232211e91 Mon Sep 17 00:00:00 2001 From: Tyler Date: Tue, 21 Oct 2025 18:05:30 -0700 Subject: [PATCH] quick bug fixes --- changelog.md | 7 +++++++ flares.py | 56 +++++++++++++++++++++++++++++++++------------------- main.py | 5 ++++- 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/changelog.md b/changelog.md index 58a7d53..4dad5e5 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,10 @@ +# Version 1.1.6 + +- Fixed Process button from appearing when no files are selected +- Fix for instand child process crash on Windows +- Added L_FREQ and H_FREQ parameters for more user control over low and high pass filtering + + # Version 1.1.5 - Fixed Windows saves not being able to be opened by a Mac (hopefully the other way too!) diff --git a/flares.py b/flares.py index c3ae374..a4265a0 100644 --- a/flares.py +++ b/flares.py @@ -50,8 +50,8 @@ from scipy.spatial.distance import cdist # Backen visualization needed to be defined for pyinstaller import pyvistaqt # type: ignore -# import vtkmodules.util.data_model -# import vtkmodules.util.execution_model +import vtkmodules.util.data_model +import vtkmodules.util.execution_model # External library imports for mne from mne import ( @@ -130,6 +130,9 @@ TDDR: bool ENHANCE_NEGATIVE_CORRELATION: bool +L_FREQ: float +H_FREQ: float + SHORT_CHANNEL: bool REMOVE_EVENTS: list @@ -186,7 +189,9 @@ REQUIRED_KEYS: dict[str, Any] = { "SHORT_CHANNEL": bool, "REMOVE_EVENTS": list, "TIME_WINDOW_START": int, - "TIME_WINDOW_END": int + "TIME_WINDOW_END": int, + "L_FREQ": float, + "H_FREQ": float, # "REJECT_PAIRS": bool, # "FORCE_DROP_ANNOTATIONS": list, # "FILTER_LOW_PASS": float, @@ -1069,9 +1074,17 @@ def filter_the_data(raw_haemo): fig_filter = raw_haemo.compute_psd(fmax=2).plot( average=True, xscale="log", color="r", show=False, amplitude=False ) - + + if L_FREQ == 0 and H_FREQ != 0: + raw_haemo = raw_haemo.filter(l_freq=None, h_freq=H_FREQ, h_trans_bandwidth=0.02) + elif L_FREQ != 0 and H_FREQ == 0: + raw_haemo = raw_haemo.filter(l_freq=L_FREQ, h_freq=None, l_trans_bandwidth=0.002) + elif L_FREQ != 0 and H_FREQ == 0: + raw_haemo = raw_haemo.filter(l_freq=L_FREQ, h_freq=H_FREQ, l_trans_bandwidth=0.002, h_trans_bandwidth=0.02) + #raw_haemo = raw_haemo.filter(l_freq=None, h_freq=0.4, h_trans_bandwidth=0.2) - raw_haemo = raw_haemo.filter(0.05, 0.7, h_trans_bandwidth=0.2, l_trans_bandwidth=0.02) + #raw_haemo = raw_haemo.filter(l_freq=None, h_freq=0.7, h_trans_bandwidth=0.2) + #raw_haemo = raw_haemo.filter(0.005, 0.7, h_trans_bandwidth=0.02, l_trans_bandwidth=0.002) raw_haemo.compute_psd(fmax=2).plot( average=True, xscale="log", axes=fig_filter.axes, color="g", amplitude=False, show=False @@ -1517,7 +1530,6 @@ def fold_channels(raw: BaseRaw) -> None: # Format the output to make it slightly easier to read if True: - num_channels = len(hbo_channel_names) rows, cols = 4, 7 # 6 rows and 4 columns of pie charts fig, axes = plt.subplots(rows, cols, figsize=(16, 10), constrained_layout=True) @@ -2277,21 +2289,25 @@ def brain_landmarks_3d(raw_haemo: BaseRaw, show_optodes: Literal['sensors', 'lab if show_brodmann:# Add Brodmann labels - labels = cast(list[Label], read_labels_from_annot("fsaverage", "PALS_B12_Brodmann", "rh", verbose=False)) # type: ignore + labels = cast(list[Label], read_labels_from_annot("fsaverage", "PALS_B12_Brodmann", "lh", verbose=False)) # type: ignore label_colors = { - "Brodmann.39-rh": "blue", - "Brodmann.40-rh": "green", - "Brodmann.6-rh": "pink", - "Brodmann.7-rh": "orange", - "Brodmann.17-rh": "red", - "Brodmann.1-rh": "yellow", - "Brodmann.2-rh": "yellow", - "Brodmann.3-rh": "yellow", - "Brodmann.18-rh": "red", - "Brodmann.19-rh": "red", - "Brodmann.4-rh": "purple", - "Brodmann.8-rh": "white" + "Brodmann.1-lh": "red", + "Brodmann.2-lh": "red", + "Brodmann.3-lh": "red", + "Brodmann.4-lh": "orange", + "Brodmann.5-lh": "green", + "Brodmann.6-lh": "yellow", + "Brodmann.7-lh": "green", + "Brodmann.17-lh": "blue", + "Brodmann.18-lh": "blue", + "Brodmann.19-lh": "blue", + "Brodmann.39-lh": "purple", + "Brodmann.40-lh": "pink", + "Brodmann.42-lh": "white", + "Brodmann.44-lh": "white", + "Brodmann.48-lh": "white", + } for label in labels: @@ -2944,7 +2960,7 @@ def process_participant(file_path, progress_callback=None): # Step 11: Get short / long channels if SHORT_CHANNEL: - short_chans = get_short_channels(raw_haemo, max_dist=0.015) + short_chans = get_short_channels(raw_haemo, max_dist=0.02) fig_short_chans = short_chans.plot(duration=raw_haemo.times[-1], n_channels=raw_haemo.info['nchan'], title="Short Channels Only", show=False) fig_individual["short"] = fig_short_chans else: diff --git a/main.py b/main.py index ce60d82..bf305c1 100644 --- a/main.py +++ b/main.py @@ -123,7 +123,10 @@ SECTIONS = [ { "title": "Filtering", "params": [ + {"name": "L_FREQ", "default": 0.005, "type": float, "help": "Any frequencies lower than this value will be removed."}, + {"name": "H_FREQ", "default": 0.7, "type": float, "help": "Any frequencies higher than this value will be removed."}, #{"name": "FILTER", "default": True, "type": bool, "help": "Calculate Peak Spectral Power."}, + ] }, { @@ -4044,7 +4047,7 @@ class MainApplication(QMainWindow): self.button2.setMinimumSize(100, 40) self.button3.setMinimumSize(100, 40) - # self.button1.setVisible(False) + self.button1.setVisible(False) self.button3.setVisible(False) self.button1.clicked.connect(self.on_run_task)