initial upload

This commit is contained in:
tom.hempel
2025-09-24 16:58:38 +02:00
commit 4e6a6c999d
124 changed files with 23976 additions and 0 deletions

64
README.md Normal file
View File

@ -0,0 +1,64 @@
## Overview
- Data source: `SingleRecordings/<id>/{hr.csv, rr.csv, timestamps.csv}`
- Scripts:
- `plot_meditation_data.py`: per-recording plots (raw + moving averages + segment boxplots)
- `aggregate_segments_analysis.py`: aggregate metrics/plots across recordings with exactly 4 marks (conditions)
## How calculations are done
- HR and RR loading
- Read `timestamp` (ms) → convert to datetime; set as index.
- HR column: `hr` (beats per minute). RR column: `rr_ms` (milliseconds).
- Moving averages (per recording)
- Time-based rolling means over irregular timestamps using windows: 5 s, 10 s, 30 s, 60 s.
- X-axis is seconds from each recordings start.
- Mark handling (per recording)
- Vertical lines at marks from `timestamps.csv`.
- Segment boxplots use values in: each interval between consecutive marks and the final interval (last mark → end).
- RMSSD (HRV)
- Definition: RMSSD = sqrt(mean(diff(RR_ms)^2)) using successive RR intervals (ms).
- Aggregate per-condition RMSSD: computed over all RR samples within each conditions time window (recording-level); requires ≥2 RR samples.
- Aligned time-series RMSSD: first compute a 30 s time-based rolling RMSSD per recording, then align and average across recordings (see below).
- Aggregate metrics across recordings (exactly 4 marks)
- Conditions (English labels):
- Breathing Scene 1 (pre-first mark)
- Spring Scene (1st2nd mark)
- Summer Scene (2nd3rd mark)
- Autumn Scene (3rd4th mark)
- Breathing Scene 2 (post-last mark)
- Per recording: compute medians for HR and RR within each condition; compute RMSSD within each condition.
- Summary CSV aggregates these per-recording values; boxplots show distributions. The mean of each condition is marked by a black dot on the boxplots.
- Aligned average curves (HR, RR, RMSSD)
- Only recordings with exactly 4 marks are used.
- For each recording, durations of the five segments are measured; median segment proportions across recordings define a normalized 01 time axis with aligned boundaries.
- Each recordings series is piecewise-linearly time-normalized to this axis, interpolated to a common grid, and then averaged (mean ± 1 SD). For RMSSD, a 30 s rolling RMSSD is used before alignment.
# Results
| Condition | HR (bpm) | RR (ms) | RMSSD (ms) |
|-------------------|----------|---------|------------|
| Breathing Scene 1 | 72.61 | 843.33 | 52.70 |
| Spring Scene | 72.33 | 860.78 | 56.95 |
| Summer Scene | 72.50 | 862.00 | 41.15 |
| Autumn Scene | 72.89 | 850.44 | 41.89 |
| Breathing Scene 2 | 73.78 | 839.94 | 42.59 |
## Plots
### Aggregate Boxplots
![HR Boxplot Across Conditions](Plots/Aggregate/HR_boxplot_conditions.png)
![RR Boxplot Across Conditions](Plots/Aggregate/RR_boxplot_conditions.png)
![RMSSD Boxplot Across Conditions](Plots/Aggregate/RMSSD_boxplot_conditions.png)
### Aligned Average Curves
![Aligned Average Heart Rate (HR)](Plots/Aggregate/HR_average_aligned.png)
![Aligned Average RR Interval](Plots/Aggregate/RR_average_aligned.png)
![Aligned Average RMSSD](Plots/Aggregate/RMSSD_average_aligned.png)