Skip to content

Commit

Permalink
Bug fixing: Klassen angepasst und toml Datei angepasst (mne)
Browse files Browse the repository at this point in the history
  • Loading branch information
shMeske committed Oct 20, 2023
1 parent e0b95b4 commit 694e698
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
25 changes: 15 additions & 10 deletions src/Physiological/add_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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(
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion src/Physiological/processing_and_preview.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import datetime

import param
import panel as pn
import biopsykit as bp
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down
19 changes: 10 additions & 9 deletions tests/test_physiological/test_add_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
1 change: 1 addition & 0 deletions tests/test_physiological/test_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 694e698

Please sign in to comment.