Skip to main content

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 .wiff files 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 parameterRaw metricDaily summaryWhat it needs
Heart rateMetricActivity (bpm, bpm_q)HeartRateSummaryModel
Respiration rateMetricActivity (respiration_rate, resp_q)RespirationSummaryModel
Steps, activity type, energy expenditureMetricActivity (last_steps, activity_type, energy_exp)StepsSummaryModel
SpO2MetricActivity (spo2, spo2Q)SpO2SummaryModel287-2B
TemperatureMetricTemperatureTemperatureSummaryModel
Blood pressure (NIBP)MetricActivity (nibpSystolic, nibpDiastolic)MetricBloodPressureSummaryNIBP enabled and calibrated, see NIBP
SleepMetricSleepSleepSummaryModel287-2B
RR intervals (HRV)MetricHrvNone
EmoGraphy (EDA, stress)MetricEmographyEmographySummaryModel287-2B, licence with PPG2 raw data, EmoGraphy enabled
Green PPG samplesMetricPpgNoneLicence with PPG (green) raw data
Raw temperature (heat flux)MetricTemperatureRawNone287-2B, licence with raw temperature, raw temperature enabled
Battery level, charging, wearingMetricActivity (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.

METRICANDROIDIOS
- Heart rateHeartRateSummaryModel / HeartRateSlotModelMetricBPMSummery / MetricBPMSummerySlot
- Breathing rateRespirationSummaryModel / RespirationSlotModelMetricBreathSummery / MetricBreathSummerySlot
- StepsStepsSummaryModel / StepsSlotModelMetricStepsSummary / MetricStepsSummarySlot
- SpeedStepsSummaryModel / StepsSlotModelMetricStepsSummary / MetricStepsSummarySlot
- Energy expenditureStepsSummaryModel / StepsSlotModelMetricStepsSummary / MetricStepsSummarySlot
- Activity TypeStepsSummaryModel / StepsSlotModelMetricActivitySummery / MetricActivitySummerySlot
- SleepSleepSummaryModel /SleepSlotModelMetricSleepSummery / MetricSleepSummerySlot
- Skin TemperatureTemperatureSummaryModel / TemperatureSlotModelMetricBodyTempSummery / MetricBodyTempSummerySlot
- Core body TemperatureTemperatureSummaryModel / TemperatureSlotModelMetricCoreBodyTemperatureSummary / MetricCoreBodyTemperatureSummarySlot
- SaturationSpO2SummaryModel / Spo2SlotModelMetricSpo2Summery / MetricSpo2SummerySlot
- EDA (stress)EmographySummaryModel / EmographySlotModelMetricEmographySummary / 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.

Raw data models structure

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.

Summaries data structure

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:

DataKeep at leastWhy
MetricActivity, MetricTemperatureThe last 2 daysThe steps, heart rate, respiration, SpO2, blood pressure and temperature summaries are computed from them
MetricSleepUntil the night has its SleepSummaryModelThe night is built from these rows when the bracelet reports that the wearer got out of bed
MetricEmographyThe current dayThe day average of EmographySummaryModel is computed from the day's rows
MetricPpg, MetricHrv, MetricTemperatureRawNothingThey have no summary. Delete them as soon as your app has used them
SummariesAs long as your app shows themThey 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.

ParameterMeaning
fileTypesThe data to export, see the table below
documentFileThe destination folder: a DocumentFile of a folder the user picked with the system folder picker
from, toThe time range, in milliseconds UTC, both ends included
groupedBySecondsGroup the rows in time buckets, see below. Added in SDK 1.2.0
onDoneCalled when the zip is in the folder
onErrorCalled 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
}
ExportTypeModelCSV fileColumns
ACTIVITYMetricActivityexport-activity-raw-data.csvTIMESTAMP, 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
SLEEPMetricSleepexport-sleep-raw-data.csvTIMESTAMP, DATE, STATE (number), STATE (name), Q
HRVMetricHrvexport-hrv-raw-data.csvTIMESTAMP, DATE, VALUE
TEMPERATUREMetricTemperatureexport-temperature-raw-data.csvTIMESTAMP, DATE, TEMP1, TEMP2, TEMP_ABS
TEMPERATURE_RAWMetricTemperatureRawexport-extended-temperature-raw-data.csvTIMESTAMP, DATE, SKIN_TEMP, HEAT FLUX, ACC_X, ACC_Y, ACC_Z, PULSE RATE, CBT
PPGNot 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.

warning

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.