Skip to content

Commit

Permalink
created template for TFMDataset
Browse files Browse the repository at this point in the history
  • Loading branch information
richrobe committed Feb 7, 2024
1 parent 61eed06 commit 5322df2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/biopsykit/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Module providing input/output functions."""
from biopsykit.io import carwatch_logs, ecg, eeg, nilspod, saliva, sleep, sleep_analyzer
from biopsykit.io import carwatch_logs, ecg, eeg, nilspod, saliva, sleep, sleep_analyzer, tfm
from biopsykit.io.io import (
convert_time_log_datetime,
convert_time_log_dict,
Expand Down Expand Up @@ -33,4 +33,5 @@
"saliva",
"sleep",
"sleep_analyzer",
"tfm",
]
34 changes: 34 additions & 0 deletions src/biopsykit/io/tfm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from typing import Dict, Optional

Check failure on line 1 in src/biopsykit/io/tfm.py

View workflow job for this annotation

GitHub Actions / test_lint (3.9)

Ruff (D100)

src/biopsykit/io/tfm.py:1:1: D100 Missing docstring in public module

Check failure on line 1 in src/biopsykit/io/tfm.py

View workflow job for this annotation

GitHub Actions / test_lint (3.10)

Ruff (D100)

src/biopsykit/io/tfm.py:1:1: D100 Missing docstring in public module

import pandas as pd


class TFMDataset:
"""Class for loading and processing Task Force Monitor (TFM) data."""

CHANNEL_MAPPING = {}

_tz: str

def __init__(
self, data_dict: Dict[str, pd.DataFrame], sampling_rate_dict: Dict[str, float], tz: Optional[str] = None
):
"""Initialize a TFM dataset.
Parameters
----------
data_dict : dict
Dictionary containing TFM data. Keys are channel names, values are dataframes with the TFM data.
tz : str, optional
Timezone of the data. Default: None
"""
self._data = data_dict
self._sampling_rate = sampling_rate_dict
for name, data in data_dict.items():
setattr(self, name, data)
for name, sampling_rate in sampling_rate_dict.items():
setattr(self, f"sampling_rate_hz_{name}", sampling_rate)
setattr(self, "channels", list(self._data.keys()))

self._tz = tz

0 comments on commit 5322df2

Please sign in to comment.