Skip to content

Commit

Permalink
fixes for offline_analysis
Browse files Browse the repository at this point in the history
TODO something is wrong between matplotlib and pyqt6
  • Loading branch information
tab-cmd committed Oct 10, 2024
1 parent 3d003bc commit 7223a58
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
4 changes: 3 additions & 1 deletion bcipy/gui/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def confirm(message: str) -> bool:
-------
users selection : True for selecting Ok, False for Cancel.
"""
app = QApplication(sys.argv)
app = QApplication(sys.argv).instance()
if not app:
app = QApplication(sys.argv)
dialog = alert_message(message,
message_type=AlertMessageType.INFO,
message_response=AlertMessageResponse.OCE)
Expand Down
11 changes: 6 additions & 5 deletions bcipy/gui/intertask_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ def __init__(
tasks: List[str],
exit_callback: Callable,
):
# check if IntertaskGUI in tasks, if so, remove it
self.tasks = tasks
tasks = [task for task in tasks if task != self.action_name]
self.total_tasks = len(tasks)
self.current_task_index = next_task_index
self.next_task_name = tasks[self.current_task_index]
self.task_progress = next_task_index - 1
tasks = [task for task in tasks if task != self.action_name]
self.total_tasks = len(tasks)

self.callback = exit_callback
super().__init__("Progress", 800, 150)

Expand All @@ -38,10 +39,10 @@ def app(self):

progress_container = QHBoxLayout()
progress_container.addWidget(
QLabel(f"({self.current_task_index}/{self.total_tasks})")
QLabel(f"({self.task_progress}/{self.total_tasks})")
)
self.progress = QProgressBar()
self.progress.setValue(int(self.current_task_index / self.total_tasks * 100))
self.progress.setValue(int(self.task_progress / self.total_tasks * 100))
self.progress.setTextVisible(False)
progress_container.addWidget(self.progress)
self.contents.addLayout(progress_container)
Expand Down
2 changes: 1 addition & 1 deletion bcipy/signal/evaluate/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DefaultArtifactParameters(Enum):
"""

# Voltage
PEAK_THRESHOLD = 100e-7
PEAK_THRESHOLD = 75e-7
PEAK_MIN_DURATION = 0.005
FLAT_THRESHOLD = 0.5e-6
FLAT_MIN_DURATION = 0.1
Expand Down
2 changes: 1 addition & 1 deletion bcipy/signal/model/offline_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def offline_analysis(
figure_handles.extend(et_figure_handles)

if alert_finished:
results = [f"\n {model.name}: {model.auc} \n" for model in models]
results = [f"{model.name}: {model.auc}" for model in models]
confirm(f"Offline analysis complete! \n Results={results}")
log.info("Offline analysis complete")
return models, figure_handles
Expand Down
4 changes: 2 additions & 2 deletions bcipy/task/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def execute(self) -> TaskData:
"""
logger.info("Running offline analysis action")
try:
cmd = f"bcipy-train --parameters {self.parameters_path} -v"
cmd = f"bcipy-train --parameters {self.parameters_path}"
if self.alert_finished:
cmd += " --alert"
response = subprocess.run(
Expand Down Expand Up @@ -132,7 +132,7 @@ def __init__(
self.save_folder = save_path
self.parameters = parameters
assert progress is not None and tasks is not None, "Either progress or tasks must be provided"
self.next_task_index = progress - 1 # progress is 1-indexed, tasks is 0-indexed so we can use the same index
self.next_task_index = progress # progress is 1-indexed, tasks is 0-indexed so we can use the same index
assert self.next_task_index >= 0, "Progress must be greater than 1 "
self.tasks = tasks
self.task_name = self.tasks[self.next_task_index].name
Expand Down
3 changes: 2 additions & 1 deletion bcipy/task/orchestrator/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,11 @@ def execute(self) -> None:
# Visualize session data and fail silently if it errors
try:
visualize_session_data(data_save_location, self.parameters)
pass
except Exception as e:
self.logger.info(f'Error visualizing session data: {e}')

initialized_task = None

except Exception as e:
self.logger.error(f"Task {task.name} failed to execute")
self.logger.exception(e)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ SoundFile==0.12.1
scipy==1.10.1
scikit-learn==1.2.2
seaborn==0.9.0
matplotlib==3.7.2
matplotlib==3.7.5
pylsl==1.16.2
pandas==2.2.3
pandas==2.0.3
psutil==5.7.2
Pillow==9.4.0
py-cpuinfo==9.0.0
Expand Down

0 comments on commit 7223a58

Please sign in to comment.