Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5421204
feat: Add adaptive frequency bounds for variable sampling rates
Erikpostt Mar 20, 2026
f989ee4
fix: Defer _update_frequency_dependent_params() until after child cla…
Erikpostt Mar 20, 2026
dae1451
chore: Remove development test files and implementation notes
Erikpostt Mar 20, 2026
2cae6b7
fix: Only clamp MFCC bounds when they exceed Nyquist, preserve 25 Hz …
Erikpostt Mar 20, 2026
f6c1700
fix: Clamp MFCC bounds to exactly Nyquist, not 95% of it
Erikpostt Mar 20, 2026
82be156
Enforce resampling below 50 Hz
Erikpostt Mar 21, 2026
45535fe
Merge branch 'main' of github.com:biomarkersParkinson/paradigma into …
Erikpostt Mar 23, 2026
4b0ab86
Merge main into branch
Erikpostt Apr 15, 2026
52d6eb8
Rebuild docs
Erikpostt Apr 16, 2026
cb70384
Ensure automatic resampling always runs
Erikpostt Apr 16, 2026
28999c4
Ensure automatic resampling always runs
Erikpostt Apr 16, 2026
626b8a5
Ensure automatic resampling always runs
Erikpostt Apr 17, 2026
1f0b1be
Removing resampling from data preparation; remove default set to 100 …
Erikpostt Apr 17, 2026
8029454
Fix: Restore auto-segmentation functionality in data preparation
Erikpostt Apr 17, 2026
05b3c6b
Fix: Use separate fields for segment categorization vs summation
Erikpostt Apr 17, 2026
001f231
Refine: Use duration_unfiltered_segment_s field name to match release…
Erikpostt Apr 18, 2026
415e4a9
Remove redundant duration_unfiltered_segment_s from per-segment metadata
Erikpostt Apr 18, 2026
8cb585c
Ensure sampling frequency is integer with correct rounding
Erikpostt Apr 20, 2026
236667f
remove rounding for spectrogram computation
nienketimmermans Apr 23, 2026
a43f0a2
Merge changes from tremor pipeline
Erikpostt Apr 29, 2026
12ceb0a
Merge changes from tremor pipeline
Erikpostt Apr 29, 2026
e6319f3
Add automatic resampling to tutorials
Erikpostt Apr 29, 2026
d27bd5c
Resolve merge conflicts
Erikpostt May 8, 2026
7a456f0
Removed configuration of imu object in gait pipeline; resolved pytest…
Erikpostt May 8, 2026
0224fa9
Resolve imu_config object initialization in gait pipeline
Erikpostt May 8, 2026
d972b07
Updated documentation to specify that sampling is automatic and setti…
Erikpostt May 11, 2026
cb59eb9
Fixed incorrect updating of parameters after explicitly defining resa…
Erikpostt May 18, 2026
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
60 changes: 44 additions & 16 deletions docs/guides/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,54 @@ Configuration classes are organized into two categories:

## Sensor Configurations

### IMUConfig
ParaDigMa supports processing two types of sensors: IMU (accelerometer + gyroscope)
and PPG.

Configuration for inertial measurement unit (IMU) sensors (accelerometer + gyroscope):
### Instantiating a configuration object

To create a configuration object:

```python
from paradigma.config import IMUConfig
from paradigma.config import IMUConfig, PPGConfig

imu_config = IMUConfig()
imu_config.sampling_frequency = 100
ppg_config = PPGConfig()
```

**Parameters**
-
### PPGConfig
### Adaptive Frequency Handling

Configuration for photoplethysmography (PPG) sensors:
The data sampling frequency is automatically detected from your data during
preprocessing and cannot be manually set. This ensures parameters like filter cutoffs
and window sizes always match your actual data. However, you are free to manually change
the input data, thereby affecting the automated sampling frequency detection.

```python
from paradigma.config import PPGConfig
from paradigma.preprocessing import preprocess_imu_data

imu_config = IMUConfig()
df_preprocessed = preprocess_imu_data(df_raw, imu_config)

# After preprocessing, sampling_frequency is auto-detected and available:
print(f"Detected sampling frequency: {imu_config.sampling_frequency} Hz")

ppg_config = PPGConfig()
```

Optionally, to resample to a specific sampling frequency, you can set
`imu_config.resampling_frequency` prior to running `preprocess_imu_data()`. However,
this is not recommended, because it may distort frequency-dependent features and
therefore lead to incorrect classification output.

```python
# To use a different resampling frequency (optional, not recommended):
imu_config.resampling_frequency = 100
```

**Key Behaviors:**
- `sampling_frequency` is **read-only** and auto-detected during preprocessing
- Frequency-dependent parameters (filter cutoffs, tolerance) are automatically calculated
- `resampling_frequency` defaults to `None` (means "use detected sampling_frequency" for uniform sampling)
- Set `resampling_frequency` explicitly only if you need to upsample/downsample to a specific rate. This is not recommended, as ParaDigMa adapts to the detected sampling frequency; validity of outcomes generated by explicitly setting `resampling_frequency` may be incorrect.

## Domain Configurations

Domain configurations are defined for each analysis pipeline and correspond to processing steps:
Expand All @@ -54,26 +79,29 @@ Example with gait analysis:

```python
from paradigma.config import IMUConfig, GaitConfig
from paradigma.pipelines import run_paradigma
from paradigma.orchestrator import run_paradigma

imu_config = IMUConfig()
imu_config.sampling_frequency = 100
imu_config = IMUConfig() # sampling_frequency will be auto-detected
gait_config = GaitConfig()

results = run_paradigma(
dfs={'data': df},
pipelines=['gait'],
watch_side='left',
imu_config=imu_config,
gait_config=gait_config
)
```

## Best Practices

1. **Validation**: Ensure your sensor `sampling_frequency` matches your actual data
2. **Column Names**: Verify that your DataFrame column names match the configuration
1. **Frequency Detection**: `sampling_frequency` is automatically detected from your
data during preprocessing. No manual configuration needed.
2. **Column Names**: Verify that your DataFrame column names match the configuration, or
map your column names using the parameter `column_mapping`.
3. **Units**: Confirm that sensor data is in correct physical units (see [Sensor Requirements](https://biomarkersparkinson.github.io/paradigma/guides/sensor_requirements.html))
4. **Documentation**: Document any custom configurations in your analysis code
4. **Documentation**: Document any custom configurations (e.g., custom resampling rates)
in your analysis code

## See Also

Expand Down
5 changes: 1 addition & 4 deletions docs/guides/input_formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ results = run_paradigma(

## Data Preparation Parameters

If your data needs preparation (unit conversion, resampling, etc.), ParaDigMa can handle it automatically:
If your data needs preparation (unit conversion, changing watch orientation, etc.), ParaDigMa can handle it automatically:

```python
results = run_paradigma(
Expand All @@ -171,9 +171,6 @@ results = run_paradigma(
accelerometer_units='m/s^2', # Auto-converts to 'g'
gyroscope_units='rad/s', # Auto-converts to 'deg/s'

# Resampling
target_frequency=100.0,

# Time handling
time_input_unit='relative_s', # Or 'absolute_datetime'

Expand Down
12 changes: 8 additions & 4 deletions docs/guides/sensor_requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ All pipelines require data from a wrist-worn sensor with:
- **Data Quality**: Strictly increasing timestamps
- **Orientation**: Standardized coordinate system (see [Coordinate System Guide](coordinate_system.md))

## Sampling Frequency Flexibility

ParaDigMa is designed to work with various sampling frequencies. The orchestrator `run_paradigma` estimates the current sampling frequency and adjusts frequency-dependent parameters accordingly. For best results, use native sensor data without upsampling beforehand.

## Pipeline-Specific Requirements

### Arm Swing during Gait
Expand All @@ -19,8 +23,8 @@ All pipelines require data from a wrist-worn sensor with:

| Specification | Minimum Requirement |
|---------------|-------------------|
| **Accelerometer** | Sampling rate ≥ 100 Hz<br>Range ≥ ± 4 g |
| **Gyroscope** | Sampling rate ≥ 100 Hz<br>Range ≥ ± 1000 degrees/sec |
| **Accelerometer** | Sampling rate ≥ 50 Hz<br>Range ≥ ± 4 g |
| **Gyroscope** | Sampling rate ≥ 50 Hz<br>Range ≥ ± 1000 degrees/sec |

#### Physical Units

Expand Down Expand Up @@ -53,7 +57,7 @@ For reliable weekly measures:

| Specification | Minimum Requirement |
|---------------|-------------------|
| **Gyroscope** | Sampling rate ≥ 100 Hz<br>Range ≥ ± 1000 degrees/sec |
| **Gyroscope** | Sampling rate ≥ 50 Hz<br>Range ≥ ± 1000 degrees/sec |

#### Physical Units

Expand Down Expand Up @@ -130,6 +134,6 @@ results = run_paradigma(
## Important Notes on Validation

> [!NOTE]
> The specifications above represent **minimally validated requirements**. For example, while ParaDigMa works with accelerometer and gyroscope data sampled at 50 Hz, the effect on processing accuracy has not been empirically validated.
> The specifications above represent **validated requirements**. ParaDigMa has been tested and verified to work correctly with sampling frequencies as low as 50 Hz.

---
4 changes: 3 additions & 1 deletion docs/tutorials/_static/data_preparation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ ParaDigMa requires the sensor data to be of a specific format. This tutorial pro
* Triaxial gyroscope (x, y, z) in _deg/s_
* Photoplethysmography (PPG)

The final dataframe should be resampled to 100 Hz, have the correct units for the sensor columns, and the correct format for the time column. Also note that the _gait_ pipeline expects a specific orientation of sensor axes, as explained in [Coordinate system](../guides/coordinate_system).
The final dataframe should have the correct units for the sensor columns and the correct format for the time column. Also note that the _gait_ pipeline expects a specific orientation of sensor axes, as explained in [Coordinate system](../guides/coordinate_system).

Note that ParaDigMa automatically calculates the actual sampling frequency and resamples this to a uniform format, which happens _after_ data preparation.

## Import required modules

Expand Down
Loading
Loading