Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,19 @@ poetry run poe <command name>
If you use `Eargait` in your work, please report the version you used in the text. Additionally, please also cite the corresponding paper:

```
[1] Seifer et al., "EarGait: estimation of temporal gait parameters from hearing aid
integrated inertial sensors." Sensors 23(14), 2023. https://doi.org/10.3390/s23146565.
[1] A. Seifer, E. Dorschky, A. Küderle, H. Moradi, R. Hannemann, and B. Eskofier,
"EarGait: Estimation of Temporal Gait Parameters from Hearing Aid Integrated Inertial Sensors",
in Sensors, vol. 23, no. 14, article 6565, 2023, doi: 10.3390/s23146565.

[2] PREPRINT Seifer et al., (2023). Step length and gait speed estimation using a hearing aid
integrated accelerometer: A comparison of different algorithms.

[2] A. Seifer, A. Küderle, E. Dorschky, H. Moradi, R. Hannemann, and B. Eskofier,
"Step Length and Gait Speed Estimation Using a Hearing Aid Integrated Accelerometer: A Comparison
of Different Algorithms", in IEEE Journal of Biomedical and Health Informatics, vol. 28, no. 11,
pp. 6619-6628, 2024, doi: 10.1109/JBHI.2024.3454824.
```
Links: <br />
[[1] Seifer et al., (2023), Temporal Parameter Paper](https://doi.org/10.3390/s23146565) <br />
[[2] Seifer et al., (2023); Spatial Parameter Paper](https://www.techrxiv.org/articles/preprint/Step_length_and_gait_speed_estimation_using_a_hearing_aid_integrated_accelerometer_A_comparison_of_different_algorithms/24182496) --> PREPRINT
[[2] Seifer et al., (2024); Spatial Parameter Paper](https://doi.org/10.1109/JBHI.2024.3454824) <br />


## Acknowledgement
Expand Down
243 changes: 0 additions & 243 deletions eargait/event_detection/mixed_event_detection.py

This file was deleted.

53 changes: 28 additions & 25 deletions eargait/gait_sequence_detection/gait_sequence_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,45 +65,42 @@ class GaitSequenceDetection(Algorithm):
minimum_seq_length: int

model_path: Path
labels = LABELS
_trained_model: None

labels = LABELS
_window_length_samples: int

sequence_list_: Union[pd.DataFrame, Dict[str, pd.DataFrame]]
activity_df: pd.DataFrame = None

activity_df: pd.DataFrame
data: SensorData
activity: str

WINDOW_LENGTH = 3

def __init__(
self,
sample_rate: int = 50,
sample_rate: int,
strictness: int = 0,
minimum_seq_length: int = 1,
criteria_order: str = "strictness_first",
):
if sample_rate is None:
raise ValueError("Sample Rate Parameter needs to be set by User!") # when set to None, otherwise type error bc sample rate is req argument for gsd
self.sample_rate = sample_rate
self.strictness = strictness
self.minimum_seq_length = minimum_seq_length
self.criteria_order = criteria_order

# Defaults, possibly overrriden after loading of hyperparamterfile of used Model
self.selected_coords = ["x", "y", "z"] # Default coordinates
self.window_length_in_ms = 3000 # Default window length
self.step_size_in_ms = 1500 # Default step size
self.body_frame_coords = False
self._trained_model = None

self.model_path = self._get_model()
self._load_trained_model()

self._window_length_samples = sample_rate * self.WINDOW_LENGTH
self.activity_df = pd.DataFrame()
self.data = pd.DataFrame()
self.activity = ""
super().__init__()

def _ensure_model_loaded(self):
"""Load model only if haven't been loaded before."""
if self._trained_model is None:
self.model_path = self._get_model()
self._load_trained_model()

def detect(self, data: SensorData, activity: Union[str, List[str]] = "walking") -> Self:
"""Find gait sequences or activity sequence in data.

Expand All @@ -130,6 +127,8 @@ def detect(self, data: SensorData, activity: Union[str, List[str]] = "walking")
Where x is the vertical acceleration, y is the ML acceleration (left-right), and z is the forward acceleration.

"""
self._ensure_model_loaded()
self._window_length_samples = self.sample_rate * self.WINDOW_LENGTH
self.data = data

if isinstance(activity, str):
Expand All @@ -144,12 +143,8 @@ def detect(self, data: SensorData, activity: Union[str, List[str]] = "walking")
"the following activities: "
"jogging, biking, walking, sitting, lying, jumping, stairs up, stairs down, stand or transition. \n"
)
# load model
self.model_path = self._get_model()
self._load_trained_model()

dataset_type = is_sensor_data(data, check_acc=True, check_gyr=False)
# (dataset_type)
if dataset_type == "single":
results = self._detect_single(data)
else:
Expand Down Expand Up @@ -231,7 +226,7 @@ def _detect_single(self, data):
sequence = self._ensure_minimum_length(sequence)
if self.strictness != 0:
sequence = self._ensure_strictness(sequence)

sequence.index = sequence.index.astype(np.int64)
return sequence

def _ensure_strictness(self, seq: pd.DataFrame):
Expand Down Expand Up @@ -327,10 +322,18 @@ def _load_trained_model(self):
self.sample_rate = hyperparams.get(
"hz", self.sample_rate
) # either hz value in models .yaml file or default = 50
self.selected_coords = hyperparams.get("selected_coords", self.selected_coords)
self.window_length_in_ms = hyperparams.get("window_length_in_ms", self.window_length_in_ms)
self.step_size_in_ms = hyperparams.get("step_size_in_ms", self.step_size_in_ms)
self.body_frame_coords = hyperparams.get("body_frame_coords", self.body_frame_coords)
self.selected_coords = hyperparams.get("selected_coords")
if self.selected_coords is None:
self.selected_coords = ["x", "y", "z"] # Fallback to default if no coords available in yaml
self.window_length_in_ms = hyperparams.get("window_length_in_ms")
if self.window_length_in_ms is None:
self.window_length_in_ms = 3000 # Fallback to default if w length is not available in yaml
self.step_size_in_ms = hyperparams.get("step_size_in_ms")
if self.step_size_in_ms is None:
self.step_size_in_ms = 1500 # Fallback to default if step size is not available in yaml
self.body_frame_coords = hyperparams.get("body_frame_coords")
if self.body_frame_coords is None:
self.body_frame_coords = False # Fallback to False aka no body frame / gravity alignment is no value is given in Yaml)

input_channels = hyperparams["input_channels"]
checkpoint_path = list(self.model_path.joinpath("checkpoints").glob("*.ckpt"))
Expand Down
Loading