more boris implementation

This commit is contained in:
2025-10-15 10:00:44 -07:00
parent 3d0fbd5c5e
commit 87073fb218
2 changed files with 611 additions and 28 deletions

View File

@@ -55,7 +55,7 @@ import pyvistaqt # type: ignore
# External library imports for mne
from mne import (
EvokedArray, SourceEstimate, Info, Epochs, Label,
EvokedArray, SourceEstimate, Info, Epochs, Label, Annotations,
events_from_annotations, read_source_spaces,
stc_near_sensors, pick_types, grand_average, get_config, set_config, read_labels_from_annot
) # type: ignore
@@ -132,6 +132,8 @@ ENHANCE_NEGATIVE_CORRELATION: bool
SHORT_CHANNEL: bool
REMOVE_EVENTS: list
VERBOSITY = True
# FIXME: Shouldn't need each ordering - just order it before checking
@@ -179,6 +181,7 @@ REQUIRED_KEYS: dict[str, Any] = {
"PSP_THRESHOLD": float,
"SHORT_CHANNEL": bool,
"REMOVE_EVENTS": list,
# "REJECT_PAIRS": bool,
# "FORCE_DROP_ANNOTATIONS": list,
# "FILTER_LOW_PASS": float,
@@ -1470,9 +1473,15 @@ def resource_path(relative_path):
def fold_channels(raw: BaseRaw) -> None:
# if getattr(sys, 'frozen', False):
path = os.path.expanduser("~") + "/mne_data/fOLD/fOLD-public-master/Supplementary"
logger.info(path)
set_config('MNE_NIRS_FOLD_PATH', resource_path(path)) # type: ignore
# Locate the fOLD excel files
set_config('MNE_NIRS_FOLD_PATH', resource_path("../../mne_data/fOLD/fOLD-public-master/Supplementary")) # type: ignore
# # Locate the fOLD excel files
# else:
# logger.info("yabba")
# set_config('MNE_NIRS_FOLD_PATH', resource_path("../../mne_data/fOLD/fOLD-public-master/Supplementary")) # type: ignore
output = None
@@ -1534,8 +1543,8 @@ def fold_channels(raw: BaseRaw) -> None:
"Brain_Outside",
]
cmap1 = plt.cm.get_cmap('tab20') # First 20 colors
cmap2 = plt.cm.get_cmap('tab20b') # Next 20 colors
cmap1 = plt.get_cmap('tab20') # First 20 colors
cmap2 = plt.get_cmap('tab20b') # Next 20 colors
# Combine the colors from both colormaps
colors = [cmap1(i) for i in range(20)] + [cmap2(i) for i in range(20)] # Total 40 colors
@@ -1611,6 +1620,7 @@ def fold_channels(raw: BaseRaw) -> None:
for ax in axes[len(hbo_channel_names):]:
ax.axis('off')
plt.show()
return fig, legend_fig
@@ -2935,6 +2945,19 @@ def process_participant(file_path, progress_callback=None):
logger.info("14")
# Step 14: Design Matrix
events_to_remove = REMOVE_EVENTS
filtered_annotations = [ann for ann in raw.annotations if ann['description'] not in events_to_remove]
new_annot = Annotations(
onset=[ann['onset'] for ann in filtered_annotations],
duration=[ann['duration'] for ann in filtered_annotations],
description=[ann['description'] for ann in filtered_annotations]
)
# Set the new annotations
raw_haemo.set_annotations(new_annot)
design_matrix, fig_design_matrix = make_design_matrix(raw_haemo, short_chans)
fig_individual["Design Matrix"] = fig_design_matrix
if progress_callback: progress_callback(15)