Data Calculation

Why need calculation

Some data, such as sleep, cannot be obtained directly from the watch. It needs to be calculated by calling the algorithm interface of the iwown IoT platform. Usually, you need to pre-process some watch data and then use it as a parameter to call the algorithm interface.

Algorithm API

Mainland China Host: https://api1.iwown.com/algoservice

Hong Kong, Macau, Taiwan and countries outside of China Host: https://iwap1.iwown.com/algoservice

return:

{
    "ReturnCode":0,
    "message":"",
    "Data":{}
}

ReturnCode:

  • 0 - Normal

  • 10001/10505 - there is some error when invoke api

  • 10002 - Paramters missing or with wrong value/format

  • 10404 - NO Data

10001/10505/10002 No zero often means you are invoke the api wrongly,if not sure, contact the developer for information. Data field may have or have not, ReturnCode always exist

message: the detail information of why the request failed

Sleep Calculation

URL: /calculation/sleep

Method: POST

Params/json:

{
    "prevDay":"[{\"E\":{\"a\":[0,0,0,22,0]},\"Q\":363,\"T\":[9,2]},{\"E\":{\"a\":[0,0,0,412,0]},\"T\":[9,12]}]",
    "nextDay":"[{\"E\":{\"a\":[1,4,2,0,360]},\"H\":{\"a\":84,\"n\":82,\"x\":89},\"Q\":560,\"T\":[0,1]}]",
    "prevDayRri":[-3,3000,-1,0,-1,844,755,817,830,779,748,648,717],
    "nextDayRri":[815,796,817,851,841,800,819,857,834,808,877,791,825,839,813,822,821,832,829,831,822],
    "recordDate":20240101,
    "device_id":"860132061293908",
    "account":"iwown",
    "password":"iwown2013"
}

prevDay/nextDay: The sleep strings obtained by preprocessing are the sleep strings of the day before and the day of recordDate.

prevDayRri/nextDayRri: The RRI values obtained by preprocessing are the RRI values of the day before and the day of recordDate. Used to calculate rem sleep. Preprocess method refer to RriPreprocessor.

deviceid: the device that data to calculate sleep belongs

account/password: the account and password of the client

Return:

{
    "ReturnCode": 0,
    "message": "操作成功",
    "data": {
        "completed": 1,
        "start_time": "2021-12-01 00:36",
        "end_time": "2021-12-01 08:13",
        "hr": 0,
        "turn_times": 0,
        "respiratory": {
            "avg":7.8,
            "max":7.8,
            "min":7.8
        },
        "sections": [{
            "start": "2021-12-01 00:36",
            "end": "2021-12-01 00:52",
            "type": 4
        }, {
            "start": "2021-12-01 00:52",
            "end": "2021-12-01 00:59",
            "type": 3
        }, {
            "start": "2021-12-01 00:59",
            "end": "2021-12-01 01:05",
            "type": 4
        }, {
            "start": "2021-12-01 01:05",
            "end": "2021-12-01 01:11",
            "type": 6
        }, {
            "start": "2021-12-01 01:11",
            "end": "2021-12-01 01:31",
            "type": 4
        }, {
            "start": "2021-12-01 01:31",
            "end": "2021-12-01 01:35",
            "type": 6
        }, {
            "start": "2021-12-01 01:35",
            "end": "2021-12-01 02:12",
            "type": 4
        }, {
            "start": "2021-12-01 02:12",
            "end": "2021-12-01 02:25",
            "type": 3
        }, {
            "start": "2021-12-01 02:25",
            "end": "2021-12-01 03:33",
            "type": 4
        }, {
            "start": "2021-12-01 03:33",
            "end": "2021-12-01 03:52",
            "type": 3
        }, {
            "start": "2021-12-01 03:52",
            "end": "2021-12-01 05:07",
            "type": 4
        }, {
            "start": "2021-12-01 05:07",
            "end": "2021-12-01 05:19",
            "type": 3
        }, {
            "start": "2021-12-01 05:19",
            "end": "2021-12-01 05:35",
            "type": 4
        }, {
            "start": "2021-12-01 05:35",
            "end": "2021-12-01 05:48",
            "type": 3
        }, {
            "start": "2021-12-01 05:48",
            "end": "2021-12-01 06:10",
            "type": 4
        }, {
            "start": "2021-12-01 06:10",
            "end": "2021-12-01 06:16",
            "type": 3
        }, {
            "start": "2021-12-01 06:16",
            "end": "2021-12-01 08:13",
            "type": 4
        }]
    }
}

completed: When it is 1, it means that the sleep data will not change. When it is 0, it means that the sleep data may still change. The user has not gotten up or is taking a nap.

sections: Segmented sleep data, each sleep segment has a start/end time, sleep type.

hr: sleep heart rate

turn_times: sleep turn times

respiratory: respiratory rate

type:

  • 3 Deep Sleep

  • 4 Light Sleep

  • 6 Awake

  • 7 Rem Sleep

According to the segmented sleep, the duration of deep sleep/light sleep/wakefulness can be calculated.

Ecg Analyze

URL: /calculation/ecg

Method: POST

Params/json:

{
    "ecg_list":[74825,11003,5622,3103,280,-217,-650,-947,-1223],
    "device_id":"860132061293908",
    "account":"iwown",
    "password":"iwown2013"
}

ecg_list: The raw data of a single ECG measurement is merged in the order in which the data is received

deviceid: the device that data to calculate ecg belongs

account/password: the account and password of the client

Return:

{
    "ReturnCode": 0,
    "message": "操作成功",
    "data": {
        "result": 1,
        "hr": 86,
        "effective": 0,
        "direction": -1
    }
}

hr: heart rate effective: Effective value, 0 is effective, -1 means the signal is too weak, 1 means there is interference direction: Direction; -1 means the data is reversed, and a minus sign is added before all data points

result:

  • 0 No results, interference or abnormal data

  • 1 Sinus rhythm

  • 2 Sinus bradycardia

  • 3 Sinus tachycardia

  • 4 Irregular heartbeats (premature heart beats)

  • 5 Irregular heartbeat (atrial fibrillation)

  • 6 Fast heart rate (supraventricular tachycardia)

Atrial fibrillation analyze

URL: /calculation/af

Method: POST

Params/json:

{
    "rri_list":[-3,3000,-1,0,-1,365,356,531,388,533,390,616,352,448,424,626,546,663,664,-2,-1,-1,-2,-1,-1,-2,324,327,326,329,-2,-1,-1,-2,1018,1024,1036,1037,1099,1074,1085,1035,1072,1098,1089,1071,1117,1157,1212,1083],
    "device_id":"860132061293908",
    "account":"iwown",
    "password":"iwown2013"
}

rri_list: The original data of atrial fibrillation within the time period to be analyzed are merged in the order in which the data is received

deviceid: the device that data to calculate af belongs

account/password: the account and password of the client

Return:

{
    "ReturnCode": 0,
    "message": "操作成功",
    "data": {
        "result": 1
    }
}

result:

  • 0 No results, interference or abnormal data

  • 1 Sinus rhythm

  • 2 Sinus bradycardia

  • 3 Sinus tachycardia

  • 4 Irregular heartbeats (premature heart beats)

  • 5 Irregular heartbeat (atrial fibrillation)

  • 6 Fast heart rate (supraventricular tachycardia)

Continuous blood oxygen analysis

URL: /calculation/spo2

Method: POST

Params/json:

{
    "spo2_list":[98,98,97,98,96,99,98,98,98,98,97,98,98,99],
    "device_id":"861389060095234",
    "account":"iwown",
    "password":"iwown2013"
}

spo2_list: The continuous spo2 data within the time period to be analyzed, merged in order at when the data is received

deviceid: the device that data to calculate spo2 belongs

account/password: the account and password of the client

Return:

{
    "ReturnCode": 0,
    "message": "操作成功",
    "data": {
        "spo2_score": 100,
        "osahs_risk": 0
    }
}

spo2_score: score osahs_risk: snoring risks

Data preprocessing

Sleep

For the processing method, refer to the data preprocessing part in the sample API code. Take the Java code as an example, in the DataPrepare method in the SleepPreprocessor class. The sleep string obtained after each data preprocessing is saved with the time of this data, and the sleep string of this day is spliced ​​to obtain a json array format string, completing the preprocessing of one day’s data. The splicing method is in the CombineSleepRawData method in the SleepPreprocessor class. The sleep algorithm interface needs to pass the sleep string of the current day and the previous day.

ECG

For the processing method, refer to the data preprocessing part in the sample API code. Take the Java code as an example, in the DataPrepare method in the EcgPreprocessor class. The raw data obtained after each data preprocessing is saved with the time of this data, and all the raw data with the same time are merged in the order of receiving the data to obtain the ECG data of a single measurement, and then the ECG analysis interface is called.

Atrial fibrillation

For the processing method, refer to the data preprocessing part in the sample API code. Take the Java code as an example, in the DataPrepare method in the RriPreprocessor class. Save and merge all the RRI data in the time interval you want to calculate, and then call the atrial fibrillation analysis interface

continuous spo2

For the processing method, refer to the data preprocessing part in the sample API code. Take the Java code as an example, in the DataPrepare method in the RriPreprocessor class. Save and merge all the contious spo2 data in the time interval you want to calculate, and then call the spo2 analysis interface

API Sample Program

Java(springboot): [java sample download](http://api8.iwown.com/dist/4gdata-java.zip)

Golang(echo): [golang sample download](http://api8.iwown.com/dist/4gdata-golang.zip)

python(flask): [python sample download](http://api8.iwown.com/dist/4gdata-python.zip)

c#(asp.net): [python sample download](http://api8.iwown.com/dist/4gdata-csharp.zip)

php(lumen): [python sample download](http://api8.iwown.com/dist/4gdata-php.zip)