# heartkit.datasets.ppg_synthetic

## heartkit.datasets.ppg_synthetic.logger

`attribute` · `python`

```python
logger = helia.utils.setup_logger(__name__)
```

Source: `heartkit/datasets/ppg_synthetic.py:18`

## heartkit.datasets.ppg_synthetic.PpgSyntheticParams

`class` · `python`

```python
PpgSyntheticParams()
```

PPG Synthetic signal generator parameters

Source: `heartkit/datasets/ppg_synthetic.py:21`

### heartkit.datasets.ppg_synthetic.PpgSyntheticParams.sample_rate

`attribute` · `python`

```python
sample_rate: float = Field(500, description='Signal sample rate (Hz)')
```

Source: `heartkit/datasets/ppg_synthetic.py:24`

### heartkit.datasets.ppg_synthetic.PpgSyntheticParams.duration

`attribute` · `python`

```python
duration: int = Field(10, description='Signal duration in sec')
```

Source: `heartkit/datasets/ppg_synthetic.py:25`

### heartkit.datasets.ppg_synthetic.PpgSyntheticParams.heart_rate

`attribute` · `python`

```python
heart_rate: tuple[float, float] = Field((40, 120), description='Heart rate range')
```

Source: `heartkit/datasets/ppg_synthetic.py:26`

### heartkit.datasets.ppg_synthetic.PpgSyntheticParams.frequency_modulation

`attribute` · `python`

```python
frequency_modulation: tuple[float, float] = Field((0.2, 0.4), description='Frequency modulation strength [0,1]')
```

Source: `heartkit/datasets/ppg_synthetic.py:27`

### heartkit.datasets.ppg_synthetic.PpgSyntheticParams.ibi_randomness

`attribute` · `python`

```python
ibi_randomness: tuple[float, float] = Field((0.05, 0.15), description='IBI randomness in range [0,1]')
```

Source: `heartkit/datasets/ppg_synthetic.py:28`

### heartkit.datasets.ppg_synthetic.PpgSyntheticParams.noise_multiplier

`attribute` · `python`

```python
noise_multiplier: tuple[float, float] = Field((0, 0), description='Noise multiplier range')
```

Source: `heartkit/datasets/ppg_synthetic.py:29`

## heartkit.datasets.ppg_synthetic.PpgSyntheticDataset

`class` · `python`

```python
PpgSyntheticDataset(
    num_pts: int = 250,
    params: dict | None = None,
    path: str = Path(tempfile.gettempdir()) / 'ppg-synthetic',
    **kwargs={},
) -> None
```

PPG synthetic dataset creates 1-lead PPG signal using physioKIT.

Example:

```python
import heartkit as hk

# Create synthetic PPG dataset:
# - 10 patients
# - 500 Hz sample rate
# - 10 sec duration
# - heart rate between 40 and 120 bpm
# - frequency modulation between 0.2 and 0.4
# - IBI randomness between 0.05 and 0.15
# - no noise
ds = hk.datasets.PpgSyntheticDataset(
    num_pts=10,
    params=dict(
        sample_rate=500,
        duration=10,
        heart_rate=(40, 120),
        frequency_modulation=(0.2, 0.4),
        ibi_randomness=(0.05, 0.15),
        noise_multiplier=(0, 0),
    )
)

with ds.patient_data[ds.patient_ids[0]] as pt:
    ppg = pt["data"][:]
    segs = pt["segmentations"][:]
    fids = pt["fiducials"][:]
# END WITH
```

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| num_pts | int | 250 | Number of patients. Defaults to 250. |
| params | dict \| None | None | PPG synthetic parameters (PpgSyntheticParams). Defaults to None. |
| path | str | Path(tempfile.gettempdir()) / 'ppg-synthetic' | Path to dataset. Defaults to Path(tempfile.gettempdir()) / "ppg-synthetic". |

Source: `heartkit/datasets/ppg_synthetic.py:32`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.params

`attribute` · `python`

```python
params = PpgSyntheticParams(**params or {})
```

Source: `heartkit/datasets/ppg_synthetic.py:82`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.name

`attribute` · `python`

```python
name: str
```

Dataset name

Source: `heartkit/datasets/ppg_synthetic.py:85`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.sampling_rate

`attribute` · `python`

```python
sampling_rate: int
```

Sampling rate in Hz

Source: `heartkit/datasets/ppg_synthetic.py:90`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.mean

`attribute` · `python`

```python
mean: float
```

Dataset mean

Source: `heartkit/datasets/ppg_synthetic.py:95`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.std

`attribute` · `python`

```python
std: float
```

Dataset st dev

Source: `heartkit/datasets/ppg_synthetic.py:100`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.patient_ids

`attribute` · `python`

```python
patient_ids: npt.NDArray
```

Get dataset patient IDs

Source: `heartkit/datasets/ppg_synthetic.py:105`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.get_train_patient_ids

`method` · `python`

```python
get_train_patient_ids() -> npt.NDArray
```

Get dataset training patient IDs

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  | npt.NDArray | npt.NDArray: patient IDs |

Source: `heartkit/datasets/ppg_synthetic.py:113`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.get_test_patient_ids

`method` · `python`

```python
get_test_patient_ids() -> npt.NDArray
```

Get dataset patient IDs reserved for testing only

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  | npt.NDArray | npt.NDArray: patient IDs |

Source: `heartkit/datasets/ppg_synthetic.py:122`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.pt_key

`method` · `python`

```python
pt_key(patient_id: int)
```

Get patient key

Source: `heartkit/datasets/ppg_synthetic.py:131`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.load_patient_data

`method` · `python`

```python
load_patient_data(patient_id: int)
```

Source: `heartkit/datasets/ppg_synthetic.py:135`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.build_cache

`method` · `python`

```python
build_cache()
```

Build cache

Source: `heartkit/datasets/ppg_synthetic.py:146`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.patient_data

`method` · `python`

```python
patient_data(patient_id: int) -> Generator[PatientData, None, None]
```

Get patient data

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| patient_id | int | Required | Patient ID |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  | None | Generator[PatientData, None, None]: Patient data |

Source: `heartkit/datasets/ppg_synthetic.py:152`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.signal_generator

`method` · `python`

```python
signal_generator(
    patient_generator: PatientGenerator,
    frame_size: int,
    samples_per_patient: int = 1,
    target_rate: int | None = None,
) -> Generator[npt.NDArray, None, None]
```

Generate frames using patient generator.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| patient_generator | PatientGenerator | Required | Generator that yields patient data. |
| frame_size | int | Required | Frame size |
| samples_per_patient | int | 1 | Samples per patient. Defaults to 1. |
| target_rate | int \| None | None | Target rate. Defaults to None. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
| SampleGenerator | None | Generator of input data of shape (frame_size, 1) |

Source: `heartkit/datasets/ppg_synthetic.py:172`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.download

`method` · `python`

```python
download(num_workers: int | None = None, force: bool = False)
```

Download dataset

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| num_workers | int \| None | None | # parallel workers. Defaults to None. |
| force | bool | False | Force redownload. Defaults to False. |

Source: `heartkit/datasets/ppg_synthetic.py:212`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.close

`method` · `python`

```python
close()
```

Close dataset

Source: `heartkit/datasets/ppg_synthetic.py:221`

### heartkit.datasets.ppg_synthetic.PpgSyntheticDataset.add_noise

`method` · `python`

```python
add_noise(ppg: npt.NDArray)
```

Add noise to PPG signal.

Source: `heartkit/datasets/ppg_synthetic.py:228`
