Overview
The Data SDK stores what it downloads from the bracelet in three forms:
- Raw metrics: the bracelet's records, one row per record. See Raw data models.
- Summaries: one summary per day and per vital parameter, computed by the SDK from the raw metrics. See Summaries.
- Raw files: the high-rate signals (PPG2, accelerometer, BioZ, ECG), kept as
.wifffiles and not in the database. See Raw Files.
Each value comes with a quality index where the bracelet gives one. See Quality.
From SDK 3.0.0 the models are plain classes; every model a repository returns is a copy. Changing a model does not change the database. See Migrating to 3.0.
CardioWatch data dictionary available here (scroll down to Data dictionary)
What you get and where it arrives
You read the data from the repositories of the manager, DataSdk.getInstance().getManager(), and you are told about new data by its *Updated listeners. This table shows where each vital parameter is. The two model pages give the repository and the listener of each model.
| Vital parameter | Raw metric | Daily summary | What it needs |
|---|---|---|---|
| Heart rate | MetricActivity (bpm, bpm_q) | HeartRateSummaryModel | |
| Respiration rate | MetricActivity (respiration_rate, resp_q) | RespirationSummaryModel | |
| Steps, activity type, energy expenditure | MetricActivity (last_steps, activity_type, energy_exp) | StepsSummaryModel | |
| SpO2 | MetricActivity (spo2, spo2Q) | SpO2SummaryModel | 287-2B |
| Temperature | MetricTemperature | TemperatureSummaryModel | |
| Blood pressure (NIBP) | MetricActivity (nibpSystolic, nibpDiastolic) | MetricBloodPressureSummary | NIBP enabled and calibrated, see NIBP |
| Sleep | MetricSleep | SleepSummaryModel | 287-2B |
| RR intervals (HRV) | MetricHrv | None | |
| EmoGraphy (EDA, stress) | MetricEmography | EmographySummaryModel | 287-2B, licence with PPG2 raw data, EmoGraphy enabled |
| Green PPG samples | MetricPpg | None | Licence with PPG (green) raw data |
| Raw temperature (heat flux) | MetricTemperatureRaw | None | 287-2B, licence with raw temperature, raw temperature enabled |
| Battery level, charging, wearing | MetricActivity (battery, isCharging, wearing) | None |
Before any of this arrives, the bracelet must be initialized with a plan and sampling rates, and the data transfer must be set up. Retrieve the Data explains the repositories and the listeners in general. Which raw data your licence includes is explained in The licence and raw data.
Summaries comparison
The summary models of the Android SDK and of the iOS SDK, for apps built on both.
| METRIC | ANDROID | IOS |
|---|---|---|
| - Heart rate | HeartRateSummaryModel / HeartRateSlotModel | MetricBPMSummery / MetricBPMSummerySlot |
| - Breathing rate | RespirationSummaryModel / RespirationSlotModel | MetricBreathSummery / MetricBreathSummerySlot |
| - Steps | StepsSummaryModel / StepsSlotModel | MetricStepsSummary / MetricStepsSummarySlot |
| - Speed | StepsSummaryModel / StepsSlotModel | MetricStepsSummary / MetricStepsSummarySlot |
| - Energy expenditure | StepsSummaryModel / StepsSlotModel | MetricStepsSummary / MetricStepsSummarySlot |
| - Activity Type | StepsSummaryModel / StepsSlotModel | MetricActivitySummery / MetricActivitySummerySlot |
| - Sleep | SleepSummaryModel /SleepSlotModel | MetricSleepSummery / MetricSleepSummerySlot |
| - Skin Temperature | TemperatureSummaryModel / TemperatureSlotModel | MetricBodyTempSummery / MetricBodyTempSummerySlot |
| - Core body Temperature | TemperatureSummaryModel / TemperatureSlotModel | MetricCoreBodyTemperatureSummary / MetricCoreBodyTemperatureSummarySlot |
| - Saturation | SpO2SummaryModel / Spo2SlotModel | MetricSpo2Summery / MetricSpo2SummerySlot |
| - EDA (stress) | EmographySummaryModel / EmographySlotModel | MetricEmographySummary / MetricEmographySummarySlot |
On Android the speed is not filled: StepsSlotModel.speed is deprecated and always null (0 before 3.0.0). The Android SDK also has a blood pressure summary, MetricBloodPressureSummary / MetricBloodPressureSummarySlot.
Summary vs Raw Metrics
Raw metrics
The raw metrics are the data coming from the bracelet. The SDK decodes the bracelet's files and stores the records in its database.
How often the bracelet records a raw metric depends on the plan and the sampling rates that you set in the bracelet initialization. See Bracelet Plans.
It is 60 seconds by default.
If the interval is set to 60 seconds, for example, a MetricActivity comes for every 60 seconds, containing the steps of the last 60 seconds, the average bpm of the 60 seconds, etc.
The rows reach the phone when the SDK downloads them from the bracelet, not one by one as they are recorded.
Summaries
Summaries are data calculated from the raw metrics, one summary per day.
For example the StepsSummaryModel contains the total steps and calories of the day.
A summary contains the values of the day (an average or a sum) and periodic slots.
The slot interval is set in the initialization of the Data SDK. It is 60 seconds by default, which is also the minimum.
For example if the slot interval is set to 10 minutes, the StepsSummaryModel has a slot for 00:00-00:10, then 00:10-00:20, etc. A slot holds the raw metrics of its interval as one value: a sum for steps and energy, an average for heart rate, respiration, SpO2 and temperature.
The SDK computes the summaries by itself after each download, and computes the current day again as new data arrives.
Data deletion and clean up
The SDK does not delete data automatically. Your app must do it.
Delete data regularly, because the bracelet generates a lot of it.
For raw metrics with a summary calculation (activity, respiration, temperature, SpO2, heart rate), it is important to keep the current day of data in the database, as the summary calculation is based on the full day of raw metrics.
Keep the last 2 days to make sure the summary calculation is correct in all usecases.
The reason: when the bracelet delivers older records, for example after a day without a connection, the SDK computes the summaries again from the day of the oldest new record on. A day whose raw metrics are partly deleted gets a summary computed from what is left.
What to keep, per model:
| Data | Keep at least | Why |
|---|---|---|
MetricActivity, MetricTemperature | The last 2 days | The steps, heart rate, respiration, SpO2, blood pressure and temperature summaries are computed from them |
MetricSleep | Until the night has its SleepSummaryModel | The night is built from these rows when the bracelet reports that the wearer got out of bed |
MetricEmography | The current day | The day average of EmographySummaryModel is computed from the day's rows |
MetricPpg, MetricHrv, MetricTemperatureRaw | Nothing | They have no summary. Delete them as soon as your app has used them |
| Summaries | As long as your app shows them | They are small |
For raw metrics without summaries (PPG), the data can be deleted anytime.
Deletion of Raw metrics and Summaries
Every repository has deleteByTimestampRange(startTimestamp, endTimestamp, onSuccess, onError). For a raw metric it deletes the rows whose timestamp is in the range. For a summary it deletes the summaries whose startTimestamp is in the range.
import android.util.Log
import com.corsano.sdk.data.DataSdk
val manager = DataSdk.getInstance().getManager()
val day = 24 * 60 * 60 * 1000L
val now = System.currentTimeMillis()
// raw activity rows older than 2 days
manager.metricActivityRepository.deleteByTimestampRange(
0L,
now - 2 * day,
{ Log.d("Corsano-SDK", "Old MetricActivity rows deleted") },
{ error -> Log.e("Corsano-SDK", "Delete failed: $error") },
)
// steps summaries older than 7 days
manager.stepsSummaryRepository.deleteByTimestampRange(0L, now - 7 * day)
A complete code sample is available in the Sample App:
SampleApp.kt > fun dataCleanUp()
It runs when the app starts. It keeps 2 days of MetricActivity and MetricTemperature, 10 days of MetricSleep, 4 hours of MetricPpg, MetricHrv, MetricEmography and MetricTemperatureRaw, and 7 days of summaries. Note that 4 hours of
MetricEmography is less than the table above asks for: if you use the EmoGraphy summary, keep
the current day.
Raw metrics take much more space in the database than summaries, so delete them often.
Summaries need to be deleted as well, but they take less space.
The .wiff raw files are deleted from the phone when your app exports them. See Raw File Transfer & Export.
CSV Data export
Available from SDK 1.1.2
exportData writes raw metrics to CSV files, zips them and copies the zip into a folder the user has chosen.
fun exportData(
fileTypes: List<ExportType>,
context: Context,
documentFile: DocumentFile,
from: Long,
to: Long,
groupedBySeconds: Int,
onDone: () -> Unit,
onError: (Throwable) -> Unit,
)
A second exportData has the same parameters without groupedBySeconds. It exports every row.
| Parameter | Meaning |
|---|---|
fileTypes | The data to export, see the table below |
documentFile | The destination folder: a DocumentFile of a folder the user picked with the system folder picker |
from, to | The time range, in milliseconds UTC, both ends included |
groupedBySeconds | Group the rows in time buckets, see below. Added in SDK 1.2.0 |
onDone | Called when the zip is in the folder |
onError | Called when the export failed. Nothing is written to the folder |
import android.util.Log
import androidx.documentfile.provider.DocumentFile
import com.corsano.sdk.data.DataSdk
import com.corsano.sdk.data.external.realm.models.ExportType
val manager = DataSdk.getInstance().getManager()
// uri: the folder the user picked with Intent.ACTION_OPEN_DOCUMENT_TREE
val folder = DocumentFile.fromTreeUri(context, uri) ?: return
val to = System.currentTimeMillis()
val from = to - 24 * 60 * 60 * 1000L // the last 24 hours
manager.exportData(
fileTypes = listOf(ExportType.ACTIVITY, ExportType.SLEEP, ExportType.HRV, ExportType.TEMPERATURE),
context = context,
documentFile = folder,
from = from,
to = to,
onDone = { Log.d("Corsano-SDK", "Export finished") },
onError = { error -> Log.e("Corsano-SDK", "Export failed: $error") },
)
Example available in the Sample App.
The result is one file in the folder, named sdk-export- followed by the time of the export and .zip. It contains one CSV file per data type. A CSV file always has its header line, also when the range has no rows.
Data types available for export:
enum class ExportType {
ACTIVITY, SLEEP, HRV, PPG, TEMPERATURE, TEMPERATURE_RAW
}
ExportType | Model | CSV file | Columns |
|---|---|---|---|
ACTIVITY | MetricActivity | export-activity-raw-data.csv | TIMESTAMP, DATE, BPM, BPM_Q, STEPS, ACTIVITY TYPE, ENERGY EXP (filtered), RESP RATE (filtered), RESP RATE Q, WEARING, BATTERY, CHARGING, SPO2, SPO2 Q, NIBP SYS, NIBP DIA |
SLEEP | MetricSleep | export-sleep-raw-data.csv | TIMESTAMP, DATE, STATE (number), STATE (name), Q |
HRV | MetricHrv | export-hrv-raw-data.csv | TIMESTAMP, DATE, VALUE |
TEMPERATURE | MetricTemperature | export-temperature-raw-data.csv | TIMESTAMP, DATE, TEMP1, TEMP2, TEMP_ABS |
TEMPERATURE_RAW | MetricTemperatureRaw | export-extended-temperature-raw-data.csv | TIMESTAMP, DATE, SKIN_TEMP, HEAT FLUX, ACC_X, ACC_Y, ACC_Z, PULSE RATE, CBT |
PPG | Not exported. The SDK skips this type |
onError receives an IllegalArgumentException when fileTypes holds no type that can be exported, for example PPG alone.
The export writes the files on the thread of your callbacks, which is the main thread unless you changed the SDK's callback scheduler. Export long periods in several shorter ranges.
The parameter groupedBySeconds: Int was added in SDK 1.2.0.
With it, the data samples are returned in fixed-size time chunks:
Example: groupedBySeconds = 5 * 60 returns the raw data in 5-minute chunks.
Each chunk is an average of the raw samples in the window — a weighted average when a quality factor is available.
Use groupedBySeconds for ExportType.ACTIVITY only. For SLEEP, HRV and TEMPERATURE the chunks are groupedBySeconds milliseconds long, not seconds, and a grouped sleep export has one sleep state per chunk, its most frequent one. The CSV files have no column for the grouped activityCount, movementLevel, hrm and rmssd. TEMPERATURE_RAW is never grouped. See Grouping rows.
To export the raw .wiff files (PPG2, accelerometer, BioZ, ECG), see Raw File Transfer & Export.
Verification protocol
The Corsano Verification protocol is part of the agreement between Corsano and our SDK partners. Indeed, to maintain data integrity, Corsano must be able to compare the data transmitted by the CardioWatch bracelet with the data displayed to the end user (HCP & Patient). Clients are asked to provide data to facilitate this comparison. Please use the CSV Data export to share the data.