quick bug fixes

This commit is contained in:
2025-10-21 18:05:30 -07:00
parent a4bbdb90c8
commit 45c6176dba
3 changed files with 47 additions and 21 deletions

View File

@@ -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: