From 339b93a15cc236bf1ed41d42a2fc0f6017fd7e5f Mon Sep 17 00:00:00 2001 From: Simon Meske Date: Wed, 20 Dec 2023 15:27:21 +0100 Subject: [PATCH] =?UTF-8?q?Icons=20auf=20der=20Main=20Seite=20angepasst=20?= =?UTF-8?q?Physiological=20Pipeline=20->=20Beschreibungen=20verbessert=20P?= =?UTF-8?q?anel=20Version=20auf=20die=20aktuellste=20erh=C3=B6ht=20Unn?= =?UTF-8?q?=C3=B6tige=20Tests=20entfernt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Icons/Physiological.svg | 2 +- assets/Icons/Psychological.svg | 2 +- assets/Icons/Questionnaire.svg | 2 +- assets/Icons/Saliva.svg | 2 +- assets/Icons/Sleep.svg | 2 +- poetry.lock | 8 +- pyproject.toml | 2 +- src/Physiological/PHYSIOLOGICAL_CONSTANTS.py | 35 ++++-- src/Physiological/PhysiologicalBase.py | 105 ------------------ src/Physiological/file_upload.py | 4 +- src/Physiological/physiological_pipeline.py | 2 +- src/Questionnaire/questionnaire_pipeline.py | 2 +- src/Saliva/saliva_pipeline.py | 2 +- src/Sleep/sleep_pipeline.py | 2 +- tests/test_physiological/test_file_upload.py | 4 +- .../test_set_sleep_data_parameters.py | 63 +++++------ 16 files changed, 79 insertions(+), 160 deletions(-) diff --git a/assets/Icons/Physiological.svg b/assets/Icons/Physiological.svg index 1246b1c..4096527 100644 --- a/assets/Icons/Physiological.svg +++ b/assets/Icons/Physiological.svg @@ -1 +1 @@ -ecg-monitoring \ No newline at end of file + \ No newline at end of file diff --git a/assets/Icons/Psychological.svg b/assets/Icons/Psychological.svg index bf5e1fe..f4c3db7 100644 --- a/assets/Icons/Psychological.svg +++ b/assets/Icons/Psychological.svg @@ -1 +1 @@ -psychology \ No newline at end of file + \ No newline at end of file diff --git a/assets/Icons/Questionnaire.svg b/assets/Icons/Questionnaire.svg index eb4937f..d923e26 100644 --- a/assets/Icons/Questionnaire.svg +++ b/assets/Icons/Questionnaire.svg @@ -1 +1 @@ -online-survey \ No newline at end of file + \ No newline at end of file diff --git a/assets/Icons/Saliva.svg b/assets/Icons/Saliva.svg index 8b2b972..72ece3d 100644 --- a/assets/Icons/Saliva.svg +++ b/assets/Icons/Saliva.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/assets/Icons/Sleep.svg b/assets/Icons/Sleep.svg index 1fde204..f4c3db7 100644 --- a/assets/Icons/Sleep.svg +++ b/assets/Icons/Sleep.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index dfce74c..ef50805 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2262,13 +2262,13 @@ files = [ [[package]] name = "panel" -version = "1.3.2" +version = "1.3.5" description = "The powerful data exploration & web app framework for Python." optional = false python-versions = ">=3.9" files = [ - {file = "panel-1.3.2-py2.py3-none-any.whl", hash = "sha256:da1e6c8c41e88c728a89b8119da03ac13870e32759e401c2ecc0a7ba47ea74c3"}, - {file = "panel-1.3.2.tar.gz", hash = "sha256:0b8907726ffaee97e2f0c89f047519ab511266cdbaeef1574d5eb5b327b0a30d"}, + {file = "panel-1.3.5-py2.py3-none-any.whl", hash = "sha256:d49cde574958e5b766357c456f0bc832530dde4c02e9ae7b5065cc82003a15a8"}, + {file = "panel-1.3.5.tar.gz", hash = "sha256:fdf8db8cd1a1fa96f86cecb2dfb83b8792e9e8088f284d4d5163fd787602a2b6"}, ] [package.dependencies] @@ -4011,4 +4011,4 @@ mne = ["mne"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<3.11" -content-hash = "ce545c35f149864641e2c592f23b9ce16fbe0406304bd52f30159a3aca0e89e4" +content-hash = "63cf9d1685ac1a173f72652a9129655533a2662aabc7c3c17b32da36a4229bd4" diff --git a/pyproject.toml b/pyproject.toml index 3194311..e1a29ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ license = "MIT" [tool.poetry.dependencies] python = ">=3.9,<3.11" biopsykit = "^0.9.0" -panel = "^1.3.1" +panel = "^1.3.5" nilspodlib = "3.6.0" pandas = "1.5.2" numpy = "1.23.5" diff --git a/src/Physiological/PHYSIOLOGICAL_CONSTANTS.py b/src/Physiological/PHYSIOLOGICAL_CONSTANTS.py index af6d50c..ef3c574 100644 --- a/src/Physiological/PHYSIOLOGICAL_CONSTANTS.py +++ b/src/Physiological/PHYSIOLOGICAL_CONSTANTS.py @@ -23,7 +23,11 @@ "while multiple Sessions describe that two or more sensors are used. \n" ) -SIGNAL_TYPE_TEXT = "# Selecting Physiological Signal Type" +SIGNAL_TYPE_TEXT = ( + "# Selecting Physiological Signal Type \n" + "Below you can select the Physiological Signal Type you want to analyse.\n" + "You may choose between: ECG, RSP, EEG. \n" +) SELECT_CFT_TEXT = ( "# Select CFT Sheet \n\n" "This step allows you to select a CFT sheet from a list " @@ -64,7 +68,13 @@ "hit the process button, and then proceed. " "Otherwise, you can skip this step and go to the next stage. \n \n" ) -ASK_DETECT_OUTLIER_TEXT = "# Do you want to check for outliers?" +ASK_DETECT_OUTLIER_TEXT = ( + "# Do you want to check for outliers? \n" + "If you want to check for outliers," + 'you can click the "Yes" button, otherwise click "Skip". In the following ' + "step are the different kinds of outlier detection methods you can apply" + "to your data.\n" +) OUTLIER_DETECTION_TEXT = ( "# Outlier Detection \n\n" @@ -94,11 +104,16 @@ FILE_UPLOAD_TEXT = ( "# Upload your session File \n" - "## The supported File formats are .bin, .csv, and you can also choose Folders.\n" + "## The supported File formats are .bin, .csv you can also upload Folders," + "but these have to be zipped before.\n" "After your upload your file will also be checked if it contains the necessary columns.\n" ) -DOWNLOAD_RESULT_TEXT = "# Download Result \n" +DOWNLOAD_RESULT_TEXT = ( + "# Download Result \n" + "You can download the result of the analysis here. In the downloaded file you " + "you can find the analysed data as .xslsx files." +) DATA_ARRIVED_TEXT = ( "# Files uploaded successfully \n" "Below is a short summary of the files which you uploaded." @@ -114,12 +129,18 @@ ASK_ADD_TIMES_TEXT = ( "# Do you want to add Phases for your Data?\n" "If you want to upload an Excel oder CSV File, or if you want to manually add Phases " - "to your data then click on the Add Times Button otherwise skip" + "to your data then click on the Add Times Button otherwise skip." +) +ADD_TIMES_TEXT = ( + "# Select Times\n" + "In this step you can add Phases for your data. \n" + "You can either upload an Excel or CSV File or you can manually add " + "Phases for the different subjects. \n" ) -ADD_TIMES_TEXT = "# Select Times" PRESTEP_PROCESSING_TEXT = ( "# Processing \n" - "Im nächsten Schritt werden die Daten verarbeitet, dieser Schritt dauert einen Moment :)." + "In the following step your data will be processed with the parameters you provided" + "in the previous steps." ) SET_RSP_PARAMETERS_TEXT = ( diff --git a/src/Physiological/PhysiologicalBase.py b/src/Physiological/PhysiologicalBase.py index b738114..413ebc0 100644 --- a/src/Physiological/PhysiologicalBase.py +++ b/src/Physiological/PhysiologicalBase.py @@ -24,11 +24,6 @@ class PhysiologicalBase(param.Parameterized): estimate_rsp = param.Boolean(default=False) estimate_rsp_method = param.String(default="peak_trough_mean") freq_bands = param.Dynamic(default=None) - hardware = param.Selector( - label="Select the Hardware with which you recorded your data", - objects=PHYSIOLOGICAL_HW_OPTIONS, - default="NilsPod", - ) hr_data = None hrv_types = param.List(default=None) hrv_index_name = param.Dynamic(default=None) @@ -97,106 +92,6 @@ def get_progress(step) -> pn.indicators.Progress: def set_progress_value(self, step): self.progress.value = int((step / self.max_steps) * 100) - def select_vp_changed(self, _, event): - self.subject = str(event.new) - - def dict_to_column(self): - if self.session == "Single Session" and len(self.subject_time_dict.keys()) > 1: - self.select_vp.options = list(self.subject_time_dict.keys()) - self.select_vp.visible = True - self.select_vp.link( - "subject", - callbacks={"value": self.select_vp_changed}, - ) - self.subject = list(self.subject_time_dict.keys())[0] - self.ready = True - timestamps = [] - for subject in self.subject_time_dict.keys(): - col = pn.Column() - for condition in self.subject_time_dict[subject].keys(): - cond = pn.widgets.TextInput(value=condition) - cond.link( - (subject, condition), - callbacks={"value": self.change_condition_name}, - ) - btn_remove_phase = pn.widgets.Button( - name="Remove Phase", button_type="danger" - ) - btn_remove_phase.link( - (subject, condition), - callbacks={"value": self.remove_btn_click}, - ) - col.append(pn.Row(cond, btn_remove_phase)) - for phase, time in self.subject_time_dict[subject][condition].items(): - row = pn.Row() - phase_name_input = pn.widgets.TextInput(value=phase) - phase_name_input.link( - (subject, condition, phase), - callbacks={"value": self.change_phase_name}, - ) - row.append(phase_name_input) - dt_picker = pn.widgets.DatetimePicker(value=time) - dt_picker.link( - (subject, condition, phase), - callbacks={"value": self.timestamp_changed}, - ) - row.append(dt_picker) - remove_btn = pn.widgets.Button(name="Remove", button_type="danger") - remove_btn.link( - (subject, condition, phase), - callbacks={"value": self.remove_btn_click}, - ) - row.append(remove_btn) - col.append(row) - btn_subphase = pn.widgets.Button( - name="Add Subphase", button_type="primary" - ) - btn_subphase.link( - (subject, condition), - callbacks={"value": self.add_subphase_btn_click}, - ) - row = pn.Row(pn.layout.HSpacer(), pn.layout.HSpacer(), btn_subphase) - col.append(row) - btn = pn.widgets.Button(name="Add Phase", button_type="primary") - btn.link( - (subject,), - callbacks={"value": self.add_phase_btn_click}, - ) - col.append(btn) - timestamps.append((subject, col)) - self.times.objects = [pn.Accordion(objects=timestamps)] - - def add_phase_btn_click(self, target, _): - new_phase_name = "New Phase" - self.subject_time_dict[target[0]][new_phase_name] = pd.Series( - {"New Subphase": datetime.datetime.now()} - ) - active = self.times.objects[0].active - self.dict_to_column() - self.times.objects[0].active = active - - def add_subphase_btn_click(self, target, event): - new_phase_name = "New Subphase" - if new_phase_name in list( - self.subject_time_dict[target[0]][target[1]].index.values - ): - i = 1 - new_phase_name = new_phase_name + " " + str(i) - while new_phase_name in list( - self.subject_time_dict[target[0]][target[1]].index.values - ): - i += 1 - new_phase_name = new_phase_name + " " + str(i) - self.subject_time_dict[target[0]][target[1]] = pd.concat( - [ - self.subject_time_dict[target[0]][target[1]], - pd.Series(data=[datetime.datetime.now()], index=[new_phase_name]), - ] - ) - active = self.times.objects[0].active - self.dict_to_column() - self.times.objects[0].active = active - def get_outlier_params(self): if self.skip_outlier_detection: self.outlier_params = None diff --git a/src/Physiological/file_upload.py b/src/Physiological/file_upload.py index c48ef65..4ef7e94 100644 --- a/src/Physiological/file_upload.py +++ b/src/Physiological/file_upload.py @@ -47,7 +47,6 @@ def __init__(self, **params): self.update_step(4) self.select_timezone.link(self, callbacks={"value": self.timezone_changed}) self.select_hardware.link(self, callbacks={"value": self.hardware_changed}) - self._select_hardware = pn.widgets.Select.from_param(self.param.hardware) self.file_input.link( self, callbacks={ @@ -77,6 +76,9 @@ def timezone_changed(self, _, event): self.ready = True def hardware_changed(self, _, event): + if event.new not in self.select_hardware.options: + self.select_hardware.value = self.select_hardware.options[0] + return self.hardware = event.new if self.hardware == "NilsPod": self.file_input.accept = ".csv,.bin, .zip" diff --git a/src/Physiological/physiological_pipeline.py b/src/Physiological/physiological_pipeline.py index 93f6271..0c9de5f 100644 --- a/src/Physiological/physiological_pipeline.py +++ b/src/Physiological/physiological_pipeline.py @@ -22,7 +22,7 @@ class PhysiologicalPipeline: pipeline = None name = "Physiological" - icon_svg = "https://tabler-icons.io/static/tabler-icons/icons/wave-saw-tool.svg" + icon_svg = "https://github.com/mad-lab-fau/biopsykit-dashboard/raw/development/assets/Icons/Physiological.svg" icon_name = "wave-saw-tool" def __init__(self): diff --git a/src/Questionnaire/questionnaire_pipeline.py b/src/Questionnaire/questionnaire_pipeline.py index aa4096d..9570207 100644 --- a/src/Questionnaire/questionnaire_pipeline.py +++ b/src/Questionnaire/questionnaire_pipeline.py @@ -18,7 +18,7 @@ class QuestionnairePipeline: pipeline = None name = "Questionnaire" - icon_svg = "https://tabler-icons.io/static/tabler-icons/icons/clipboard-check.svg" + icon_svg = "https://github.com/mad-lab-fau/biopsykit-dashboard/raw/development/assets/Icons/Questionnaire.svg" icon_name = "clipboard-check" def __init__(self): diff --git a/src/Saliva/saliva_pipeline.py b/src/Saliva/saliva_pipeline.py index 0fd7c08..0ac3959 100644 --- a/src/Saliva/saliva_pipeline.py +++ b/src/Saliva/saliva_pipeline.py @@ -13,7 +13,7 @@ class SalivaPipeline: pipeline = None name = "Saliva" - icon_svg = "https://tabler-icons.io/static/tabler-icons/icons/test-pipe.svg" + icon_svg = "https://github.com/mad-lab-fau/biopsykit-dashboard/raw/development/assets/Icons/Saliva.svg" icon_name = "test-pipe" def __init__(self): diff --git a/src/Sleep/sleep_pipeline.py b/src/Sleep/sleep_pipeline.py index cdfae9a..ff0735b 100644 --- a/src/Sleep/sleep_pipeline.py +++ b/src/Sleep/sleep_pipeline.py @@ -15,7 +15,7 @@ class SleepPipeline: name = "Sleep" - icon_svg = "https://tabler-icons.io/static/tabler-icons/icons/bed.svg" + icon_svg = "https://github.com/mad-lab-fau/biopsykit-dashboard/raw/development/assets/Icons/Sleep.svg" icon_name = "bed" def __init__(self): diff --git a/tests/test_physiological/test_file_upload.py b/tests/test_physiological/test_file_upload.py index d04f93d..d7e368f 100644 --- a/tests/test_physiological/test_file_upload.py +++ b/tests/test_physiological/test_file_upload.py @@ -39,8 +39,8 @@ def test_change_selected_hardware(self, file_upload): assert file_upload.file_input.accept == ".acq" file_upload.select_hardware.value = "NilsPod" assert file_upload.file_input.accept == ".csv,.bin, .zip" - with pytest.raises(Exception): - file_upload.select_hardware.value = "False Hardware" + file_upload.select_hardware.value = "False Hardware" + assert file_upload.select_hardware.value != "False Hardware" def test_extract_simple_zip(self, file_upload, script_dir): file_name = "Archiv.zip" diff --git a/tests/test_sleep/test_set_sleep_data_parameters.py b/tests/test_sleep/test_set_sleep_data_parameters.py index 4b45342..da7b549 100644 --- a/tests/test_sleep/test_set_sleep_data_parameters.py +++ b/tests/test_sleep/test_set_sleep_data_parameters.py @@ -43,34 +43,35 @@ def test_set_sleep_data_parameters_show_parameters(self, set_sleep_data_paramete col, "Withings", set_sleep_data_parameters ) - def test_set_sleep_parameters_select_all_parameters( - self, set_sleep_data_parameters - ): - possible_devices = POSSIBLE_DEVICES - for device in possible_devices: - set_sleep_data_parameters.selected_device = device - set_sleep_data_parameters.panel() - for input_widget in set_sleep_data_parameters.parameter_column.objects: - if isinstance(input_widget, pn.widgets.Select): - input_widget.value = input_widget.options[0] - assert ( - set_sleep_data_parameters.selected_parameters[ - "Polysomnography" - ][input_widget.name] - == input_widget.options[0] - ) - elif isinstance(input_widget, pn.widgets.Checkbox): - input_widget.value = True - assert ( - set_sleep_data_parameters.selected_parameters[ - "Polysomnography" - ][input_widget.name] - == input_widget.value - ) - input_widget.value = False - assert ( - set_sleep_data_parameters.selected_parameters[ - "Polysomnography" - ][input_widget.name] - == input_widget.value - ) + # + # def test_set_sleep_parameters_select_all_parameters( + # self, set_sleep_data_parameters + # ): + # possible_devices = POSSIBLE_DEVICES + # for device in possible_devices: + # set_sleep_data_parameters.selected_device = device + # set_sleep_data_parameters.panel() + # for input_widget in set_sleep_data_parameters.parameter_column.objects: + # if isinstance(input_widget, pn.widgets.Select): + # input_widget.value = input_widget.options[0] + # assert ( + # set_sleep_data_parameters.selected_parameters[ + # "Polysomnography" + # ][input_widget.name] + # == input_widget.options[0] + # ) + # elif isinstance(input_widget, pn.widgets.Checkbox): + # input_widget.value = True + # assert ( + # set_sleep_data_parameters.selected_parameters[ + # "Polysomnography" + # ][input_widget.name] + # == input_widget.value + # ) + # input_widget.value = False + # assert ( + # set_sleep_data_parameters.selected_parameters[ + # "Polysomnography" + # ][input_widget.name] + # == input_widget.value + # )