Compare commits
3 Commits
v1.1.1
...
87073fb218
| Author | SHA1 | Date | |
|---|---|---|---|
| 87073fb218 | |||
| 3d0fbd5c5e | |||
| 3f38f5a978 |
39
flares.py
39
flares.py
@@ -50,12 +50,12 @@ 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 (
|
||||
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,
|
||||
@@ -1108,7 +1111,7 @@ def epochs_calculations(raw_haemo, events, event_dict):
|
||||
evokeds3 = []
|
||||
colors = []
|
||||
conditions = list(epochs.event_id.keys())
|
||||
cmap = plt.cm.get_cmap("tab10", len(conditions))
|
||||
cmap = plt.get_cmap("tab10", len(conditions))
|
||||
|
||||
for idx, cond in enumerate(conditions):
|
||||
evoked = epochs[cond].average(picks="hbo")
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user