Abstract
Physical activity has a wide range of effects on glucose concentrations in type 1 diabetes (T1D) depending on the type (ie, aerobic, anaerobic, mixed) and duration of activity performed. This variability in glucose responses to physical activity makes the development of artificial pancreas (AP) systems challenging. Automatic detection of exercise type and intensity, and its classification as aerobic or anaerobic would provide valuable information to AP control algorithms. This can be achieved by using a multivariable AP approach where biometric variables are measured and reported to the AP at high frequency. We developed a classification system that identifies, in real time, the exercise intensity and its reliance on aerobic or anaerobic metabolism and tested this approach using clinical data collected from 5 persons with T1D and 3 individuals without T1D in a controlled laboratory setting using a variety of common types of physical activity. The classifier had an average sensitivity of 98.7% for physiological data collected over a range of exercise modalities and intensities in these subjects. The classifier will be added as a new module to the integrated multivariable adaptive AP system to enable the detection of aerobic and anaerobic exercise for enhancing the accuracy of insulin infusion strategies during and after exercise.
Keywords
Physical activity has significant effects on blood glucose (BG) concentration in persons with type 1 diabetes (T1D). 1 Regular physical activity has several positive contributions on management of diabetes such as improving insulin sensitivity, controlling body mass, and lipid profiles, and boosting self-esteem. 2 Most artificial pancreas (AP) control systems regulate BG concentrations in persons with T1D by using information from a continuous glucose monitor with little or no regard to physical activity levels.3-12 Physical activity challenges the AP system as a disturbance that can lead to unsafe conditions such as hypoglycemia or hyperglycemia.13,14 There have been limited studies where additional physiological signals are used in an AP system for the prevention of exercise-induced hypoglycemia.10-12,15 In all of these studies, the classification of exercise type (ie, aerobic, anaerobic, mixed) was not considered.
Compared to resting conditions, aerobic exercise increases glucose uptake anywhere from 1.5 to 10-fold, depending on the intensity of the activity. The dramatic increase in glucose needs of the working skeletal muscle is normally matched precisely by increased hepatic glucose production in individuals without T1D by a complex orchestration of feedforward and feedback mechanisms. 16 In contrast, during intense aerobic exercise 17 and during anaerobic work, 18 hepatic glucose production can exceed muscle glucose utilization and glucose levels can rise dramatically. Thus, one of the key determinates of the glycemic response to exercise is the general classification of the exercise type and intensity (ie, continuous vs circuit, aerobic vs anaerobic). The somewhat unpredictable effects on the BG concentrations due to physical exercise cause fear in persons in T1D and this fear may be a barrier to exercise. 19
Exercise modalities and intensities that are dominantly by aerobic metabolism increase insulin sensitivity, which subsequently increases glucose uptake from the blood stream to tissue cells. This type of exercise is often of longer duration and with lower rates of muscular contractions compared to anaerobic exercise (see Figure 1 for examples). When the aerobic exercise is prolonged or its intensity is increased, BG concentrations can drop significantly, causing serious consequences in performance 20 and eventually lack of coordination, dizziness, loss of consciousness, and seizures if left untreated. 21

The effects of different types of exercise.
On the other hand, exercise modalities and intensities that become more reliant on anaerobic metabolism may increase BG concentration that could lead to hyperglycemia (Figure 1), the release of catecholamines that increase glucose production and limit glucose uptake into muscle. 17 Typically, anaerobic exercise is commonly characterized by high rates of muscular contractions for short durations and subsequent relatively long periods of recovery, which may contribute to the significant increases in BG concentrations. 2
In this study, a discrimination method is proposed for exercise type and intensity identification, and classification of the reliance of the exercise on aerobic or anaerobic metabolism in real time as new information to be used in the integrated multivariable adaptive AP (IMA-AP) system.
12
The identification method is developed based on k-nearest neighbors (KNN) classification algorithm. The KNN algorithm belongs to the family of unsupervised instance-based, competitive learning and lazy learning algorithms. Lazy learning refers to the fact that the algorithm does not build a model until the time that a prediction is required. The model for KNN is the entire training dataset. When a prediction is required for a new data instance, the KNN algorithm will search through the
Participants and Methods
Study Participants
The experimental protocol conformed to the standards set by the Declaration of Helsinki and approved by York University’s Research Ethics Board. Five participants with T1D were recruited from the greater Toronto area (2 males, 3 females). Three participants without T1D were recruited from student volunteers at Illinois Institute of Technology. The inclusion criteria indicated that participants must be over the age of 16 and have been living with T1D > 1 year. All participants with T1D were using insulin pump therapy and were classified as having a moderate to high physical activity level based on a self-reported questionnaire. Participants were all in good to fair glycemic control (last HbA1c ≤ 8.0%). Participants were all provided with an informed consent and the 2015 Physical Activity Readiness Questionnaire (2015 PAR-Q+ www.eparmed.com) to determine eligibility and risk stratify the study participants which would participate in a range of physical activity intensities from light to maximum, safely. 22 Pre-exercise heart rate (HR) and blood pressure (BP) were measured using the BpTRU (Surgo Surgical Supplies, Toronto, Ontario) automated BP device to ensure participants were within an acceptable range prior to the initiation of the exercise protocols; BP < 160/90 mmHg. 23 The participants had their BP and HR measured on the right and left arm while seated in a relaxed position, feet flat on the ground and legs uncrossed. Six measurements were taken consecutively with a 1-minute rest interval in between, and averaged. The average values were obtained and used in the analysis.
Experimental Protocol
Participants reported to the York University Human Performance Laboratory on 4 separate occasions. The first visit consisted of a graded (progressive) treadmill test of maximal aerobic power (VO2max), lasting from 10-12 minutes, while the next 3 visits involved 40-minute exercise sessions: 2 vigorous to maximum intensity circuit based protocols and 1 continuous, light to moderate intensity steady state aerobic protocol. A further description of the visits and the types of exercise performed are found below. All 4 visits were conducted at the same time within each subject (either 11:00
Visit 1
Anthropometric measurements were conducted on all participants during visit 1 including height (cm), body mass (kg), body fat percentage, sum of 5 skin folds, and waist circumference (WC) (cm). Standardized protocols were used to measure height, weight and WC. Height was measured without shoes using a stadiometer (Fitness Precision, Toronto Ontario). Body mass was measured using a digital scale (Seca Alpha, Germany) with no shoes and light clothing. WC was measured using the National Institutes of Health (NIH) protocol; the measuring tape was placed on the skin at the level of the iliac crest. Body fat percentage was determined through bioelectrical impedance analysis instrument (Tanita Scale, model TBF-612, Arlington Heights, IL).
Participants wore a physiological monitoring module (Bioharness-3, Zephyr Technology, Annapolis MD) to monitor various physiological variables including HR, breathing rate (BR), posture, activity level, peak acceleration (PA), speed, and distance moved (see Figure 2). Participants were fitted with a Fitmate Pro Metabolic Unit (COSMED, Italy, Image Monitoring Mississauga, Ontario) for the determination of VO2 during the continuous light to moderate intensity (L-MI) plus vigorous to maximum intensity (V-MI) circuit exercise sessions and during the determination of VO2. An incremental to maximum effort treadmill protocol was used to determine VO2max and peak or maximum exercise HR. During the incremental to maximal test, the protocol consisted of 2-minute work stages that increased in intensity (treadmill speed and/or elevation) at every stage. The participants were instructed to remain on the treadmill until they reached volitional fatigue at which point they received a 2-minute low-intensity active recovery. Following the recovery period, the participants continued the test for another stage, and then were given another 2-minute recovery after completing the workload. This discontinuous portion of the graded exercise test was used to ensure the attainment of VO2max. The attainment of VO2max was determined by applying the following criteria; a plateau in VO2 with increasing workloads where VO2 does not increase more than 1.5 mL of O2∙kg-1∙min-1 or 150 mL∙min-1, a respiratory exchange ratio (RER) value greater than 1.15, and no increase in HR with an increase in workload. 24

Bioharness-3 (Zephyr Technology, Annapolis MD).
Visits 2-4: Circuit/Intermittent Vigorous to Maximum Intensity (V-MI) Exercise Protocol
Basal rate reductions were customized per subject for the V-MI exercise sessions. Participants began by walking on a treadmill at 3.5 MPH and 2% incline for 4 minutes followed by the circuit. The circuit began with 45 seconds of marching on the spot with high knees and swinging the arms with 5-8 lb dumbbells in each hand (5 lb for females, 8 lb for males). Next, participants were asked to complete a squat with a front sweep and 4 kg medicine ball swinging between the legs and over the head for 60 seconds. Four jumping jacks followed by a quadruped motion (palms flat on the floor, extending 1 arm and opposite leg simultaneously) for 30 seconds and then 2 jumping jacks, 4 push-ups, and a 20-second forearm plank. The next exercise was marching on the spot with high knees for 30 seconds, followed by squats with an 8 kg medicine ball placed on a high shelf each time for 60 seconds. The circuit finished with 4 push-ups and a 20-second forearm plank. Participants were then asked to cycle on a cycle ergometer (Monark 874 E, Sweden) for 4 minutes at 60 RPM with 2.5 kg of resistance and then completed the circuit 2 more times. In between the second and last circuit, participants walked on the treadmill again for 4 minutes at 3.5 MPH and 2% incline. Participants completed the intermittent high-intensity exercise (IHE) protocol by cycling at 60-70 RPM for ~ 10 minutes until 40 minutes of exercise was reached. During 1 of the 2 circuit exercise sessions, basal rate adjustments were made every 10 minutes for all participants with T1D. The basal adjustment patterns varied between some participants; however, the total percentage reduction was always the same during the 40-minute exercise session (Table 1). Basal rates were at 100% for all participants 10 minutes prior to exercise until the onset of exercise. Once the circuit exercise began, basal rates were adjusted in a random pattern.
Percentage of Basal Rate Adjustment for Each Participant (1-5) With T1D From 10 Minutes Prior to Exercise to 40 Minutes through the Circuit Exercise Session.
Basal rates were adjusted every 10 minutes in different patterns for all participants. The total combined percentage reduction was the same between participants.
Continuous Light to Moderate Intensity (L-MI) Exercise Protocol
One visit involved continuous, steady state L-MI aerobic exercise where basal insulin was set to zero for the entire exercise protocol and resumed to 100% immediately following the cessation of exercise. During the treadmill protocol, participants were fitted with the same measurement equipment as the V-MI protocol. Participants exercised at 3.5 MPH and 2% incline for 40 minutes.
Real-Time Classification of Exercise Based on Reliance on Aerobic or Anaerobic Metabolism
The identification of the type and intensity of exercise and its reliance on aerobic or anaerobic metabolism is made by KNN classification algorithm. KNN classification is one of the most popular classification methods used when there is little or no prior knowledge about the distribution of the data. 25 In contrast to most concept learning systems, KNN classification does not formulate a generalized conceptual model from the training instances at the training stage. Rather, a simple and intuitive rule is used to make decisions at the classification stage: instances close in the input space are likely to belong to the same class. An object is classified by a majority vote of its neighbors, with the object being assigned to the class most common among its KNN.
Defining
where
Compute the distance
Select
Select
If there are outliers in training data, the KNN algorithm may have some wrong classification just like all other data-based classification algorithms. Condensed nearest neighbors (CNN) rule 26 was proposed to decrease the size of training data to a minimum such that the reduced size data is still able to describe all training data. The CNN algorithm is:
The first sample
The second sample If If
Repeat step-2 for all
Use All elements of No elements of
The final contents of the
Results
Data from 8 subjects are tested (5 with T1D, 3 without T1D). Demographic information of subjects is listed in Table 2. Three volunteers without T1D wore the Bioharness-3 chest band while they were performing the same exercise protocol (Section 2) at Illinois Institute of Technology. The HR, BR, and PA signals from the Bioharness-3 chest band are defined to be features of the
Demographic Information of Study Participants.
Participants without T1D.
Descriptive Statistics for Feature Variables in
For each subject, 75% of data are randomly selected to be training data, and the rest of data are used as testing data. The CNN algorithm is performed for each training data to remove outliers and reduce the size of the training data. The
Figure 3 shows the real-time exercise identification results for all 8 subjects. The algorithm is able to identify each exercise session correctly except some switching points between the 2 sessions (aerobic vs anaerobic). The results for subject 1 are zoomed in Figure 4.

Identification of exercise type in real time.

Identification of exercise type in real time for subject 1.
Table 4 shows the performance analysis of the proposed algorithm. Overall 28 324 seconds (aerobic: 14 982, anaerobic: 13 342) of exercise session are performed. The overall training data size is decreased from 17 943 seconds to 1278 seconds after performing the CNN algorithm. This speeds up the KNN algorithm by almost 14 fold. Out of 7081 testing samples, 6997 seconds are classified correctly (%98.8) with the KNN algorithm when the reduced size training data are used. The algorithm was not able to classify %1.2 of the testing data due to complexity in data at the time switching between aerobic and anaerobic activity.
Performance Analysis of the Exercise Classifier.
Discussion of Results
The BG response to exercise in persons with T1D varies considerably both between and within individuals, likely depending on several factors including the type and intensity of exercise performed, the duration of the activity, and the level of circulating “on board” insulin during and after the exercise. Even if all of these variables are taken into consideration, the BG response differs markedly between individuals but has some reproducibility within an individual. 27 The body responds differently when it is undergoing varying exercise modalities and intensities, more specifically, the interplay between aerobic and anaerobic metabolism imposes unique metabolic challenges. 28
Exercise sessions are one of the most challenging periods for an AP system to regulate BG concentrations. People with T1D have adopted a range of precautions such as modifying their insulin intake or changing their food consumption before and during an exercise. For a fully automated AP system, no information should be manually entered or manual interventions be made.10,12,29,30 The proposed algorithm is developed as a new module for the IMA-AP system to enable the IMA-AP system to distinguish between predominant aerobic and anaerobic exercise metabolism, since these 2 distinct forms of exercise can have different effects on glucose concentrations.
The results show that the proposed algorithm is able to distinguish aerobic and anaerobic exercise with a high level of accuracy. With only 159 (±91) seconds of a carefully selected training data, the KNN algorithm is able develop a classifier to identify aerobic and anaerobic exercise, based on HR, BR, and PA information from the Bioharness-3 chest band. The classifier was able to track very accurately the switching between aerobic and aerobic exercise during an exercise session for both groups of study participants (individuals with and without T1D) as they alternate between sustained aerobic and circuit exercises.
We are currently conducting clinical experiments with the IMA-AP system where the proposed algorithm is used to provide real-time feedback information about the type of exercise without any manual announcements.
Conclusions
The proposed algorithm is able to differentiate and classify exercise modalities and the reliance of an exercise on aerobic or anaerobic metabolism with high accuracy. Use of biometric information and classification of exercise intensity and type in real time can provide valuable information to an AP for prevention of exercise-induced hypoglycemia and hyperglycemia.
Footnotes
Abbreviations
AP, artificial pancreas; BG, blood glucose; BP, blood pressure; BR, breathing rate; CNN, condensed nearest neighbors; HR, heart rate; IMA-AP, integrated multivariable adaptive artificial pancreas; KNN, k-nearest neighbors; L-MI, light to moderate intensity; NIH, National Institutes of Health; PA, peak acceleration; RER, respirator exchange rate; T1D, type 1 diabetes; V-MI, vigorous to maximum intensity; WC, waist circumference.
Declaration of Conflicting Interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work was supported by the National Institutes of Health NIH/NIDDK 1DP3 DK101077.
