From 694e6983f756e7b1f6444138d3098d1d2dcf77b3 Mon Sep 17 00:00:00 2001 From: Simon Meske Date: Fri, 20 Oct 2023 16:15:27 +0200 Subject: [PATCH] Bug fixing: Klassen angepasst und toml Datei angepasst (mne) --- pyproject.toml | 2 +- src/Physiological/add_times.py | 25 ++++++++++++--------- src/Physiological/processing_and_preview.py | 5 ++++- tests/test_physiological/test_add_times.py | 19 ++++++++-------- tests/test_physiological/test_processing.py | 1 + 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8e1c161..c5afc13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ memory_profiler = "^0.57.0" coverage-badge = "^1.0.1" sphinx-copybutton = "^0.4.0" nbsphinx = "^0.8.7" -mne = {version = "^1.2.1", optional = true} +mne = {version = "^1.2.3", optional = true} [tool.poetry.extras] mne = ["mne"] diff --git a/src/Physiological/add_times.py b/src/Physiological/add_times.py index eb773ff..27f5fca 100644 --- a/src/Physiological/add_times.py +++ b/src/Physiological/add_times.py @@ -72,8 +72,6 @@ class AddTimes(PhysiologicalBase): name="Select Subject", visible=False, ) - select_subject = pn.widgets.Select(name="Select Subject column", visible=False) - select_condition = pn.widgets.Select(name="Select Condition column", visible=False) next = param.Selector( default="Do you want to detect Outlier?", objects=["Do you want to detect Outlier?", "Frequency Bands"], @@ -89,6 +87,21 @@ def __init__(self, **params): self.datetime[0][0], self.datetime[0][1], self.add_button ) self.times_to_subject = TimesToSubject([]) + self.select_subject = pn.widgets.Select( + name="Select Subject column", visible=False + ) + self.select_condition = pn.widgets.Select( + name="Select Condition column", visible=False + ) + self.select_condition.visible = True + self.select_condition.link( + self, + callbacks={"value": self.condition_column_changed}, + ) + self.select_subject.link( + self, + callbacks={"value": self.subject_column_changed}, + ) pane = pn.Column(self.header) pane.append( pn.Row( @@ -135,17 +148,9 @@ def ask_for_additional_infos(self): if "subject" not in self.df.columns: self.select_subject.options = cols self.select_subject.visible = True - self.select_subject.link( - "subject", - callbacks={"value": self.subject_column_changed}, - ) if "condition" not in self.df.columns: self.select_condition.options = cols self.select_condition.visible = True - self.select_condition.link( - "condition", - callbacks={"value": self.condition_column_changed}, - ) self.pane.append(row) def parse_file(self, file_name, file_content) -> pd.DataFrame: diff --git a/src/Physiological/processing_and_preview.py b/src/Physiological/processing_and_preview.py index d6dbedc..5b5a21c 100644 --- a/src/Physiological/processing_and_preview.py +++ b/src/Physiological/processing_and_preview.py @@ -1,3 +1,5 @@ +import datetime + import param import panel as pn import biopsykit as bp @@ -8,11 +10,11 @@ from nilspodlib import Dataset import plotly.express as px import matplotlib.pyplot as plt +from pandas import Timestamp from src.Physiological.PHYSIOLOGICAL_CONSTANTS import ( PROCESSING_PREVIEW_TEXT, PRESTEP_PROCESSING_TEXT, - HRV_METHODS, ) from src.Physiological.PhysiologicalBase import PhysiologicalBase from src.Physiological.custom_components import SubjectDataFrameView, PlotViewer @@ -44,6 +46,7 @@ def __init__(self, **params): params["HEADER_TEXT"] = PROCESSING_PREVIEW_TEXT super().__init__(**params) self.update_step(9) + self.subject_time_dict = {} self.result_view = SubjectDataFrameView({}) self.result_graph = PlotViewer(None, None, None) self._view = pn.Column( diff --git a/tests/test_physiological/test_add_times.py b/tests/test_physiological/test_add_times.py index a62702c..7c62687 100644 --- a/tests/test_physiological/test_add_times.py +++ b/tests/test_physiological/test_add_times.py @@ -43,14 +43,18 @@ def test_add_times_btn(self, ask_to_add_times): assert ask_to_add_times.ready == True assert ask_to_add_times.next == "Add Times" - def test_upload_perfect_file(self, add_times, script_dir): - file_name = "ecg_time_log.xlsx" + def test_upload_subject_time_file_all_missing(self, add_times, script_dir): + file_name = "ecg_time_log_changed_all.xlsx" abs_file_path = os.path.join(script_dir, file_name) with open(abs_file_path, "rb") as f: add_times.time_upload.filename = file_name add_times.time_upload.value = f.read() + assert add_times.ready == False + add_times.select_subject.value = "versuchspersonen" + assert "subject" in add_times.df.columns.to_list() + assert add_times.ready == False + add_times.select_condition.value = "cas" assert add_times.ready == True - assert add_times.next == "Do you want to detect Outlier?" keys = ["Vp01", "Vp02"] for key in keys: assert key in add_times.subject_time_dict.keys() @@ -68,17 +72,14 @@ def test_upload_subject_time_file_missing_subject(self, add_times, script_dir): for key in keys: assert key in add_times.subject_time_dict.keys() - def test_upload_subject_time_file_all_missing(self, add_times, script_dir): - file_name = "ecg_time_log_changed_all.xlsx" + def test_upload_perfect_file(self, add_times, script_dir): + file_name = "ecg_time_log.xlsx" abs_file_path = os.path.join(script_dir, file_name) with open(abs_file_path, "rb") as f: add_times.time_upload.filename = file_name add_times.time_upload.value = f.read() - assert add_times.ready == False - add_times.select_subject.value = "versuchspersonen" - assert add_times.ready == False - add_times.select_condition.value = "cas" assert add_times.ready == True + assert add_times.next == "Do you want to detect Outlier?" keys = ["Vp01", "Vp02"] for key in keys: assert key in add_times.subject_time_dict.keys() diff --git a/tests/test_physiological/test_processing.py b/tests/test_physiological/test_processing.py index 82dc78d..798de43 100644 --- a/tests/test_physiological/test_processing.py +++ b/tests/test_physiological/test_processing.py @@ -9,6 +9,7 @@ from biopsykit.io.eeg import MuseDataset from nilspodlib import Dataset +from src.Physiological.PhysiologicalBase import PhysiologicalBase from src.Physiological.add_times import AddTimes from src.Physiological.processing_and_preview import ProcessingAndPreview