Skip to main content
NIHPA Author Manuscripts logoLink to NIHPA Author Manuscripts
. Author manuscript; available in PMC: 2019 Dec 18.
Published in final edited form as: Int Conf Comput Netw Commun. 2018 Jun 21;2018:784–788. doi: 10.1109/ICCNC.2018.8390334

Automatic Detection of Opioid Intake Using Wearable Biosensor

Md Shaad Mahmud 1, Hua Fang 1, Honggang Wang 2, Stephanie Carreiro 3, Edward Boyer 4
PMCID: PMC6919269  NIHMSID: NIHMS1057152  PMID: 31853456

Abstract

A plethora of research shows that recreational drug overdoses result in major social and economic consequences. However, current illicit drug use detection in forensic toxicology is delayed and potentially compromised due to lengthy sample preparation and its subjective nature. With this in mind, scientists have been searching for ways to create a fast and easy method to detect recreational drug use. Therefore, we have developed a method for automatic detection of opioid intake using electrodermal activity (EDA), skin temperature and tri-axis acceleration data generated from a wrist worn biosensor. The proposed system can be used for home and hospital use. We performed supervised learning and extracted 23 features using time and frequency domain analysis to recognize pre- and post- opioid health conditions in patients. Feature selection procedures are used to reduce the number of features and processing time. For supervised learning, we compared three classifiers and selected the one with highest accuracy and sensitivity: decision tree, k-nearest neighbors (KNN) and eXtreme Gradient Boosting utilizing modified features. The results show that the proposed method can detect opioid use in real-time with 99% accuracy. Moreover, this method can be applied to identify other use of additional substances other than opioids. The numerical analysis is completed on data collected from 30 participants over a span of 4 months.

Index Terms—: Opioid, Drug, Real-time, Wearable

I. Introduction

Various risks of recreational drugs such as cocaine and opioids differ tremendously. They pose a serious problem that affects health, social and economic state of all societies worldwide. The opioid use has been steadily increasing over the past couple of decades. It is estimated that opioids affect million people in the USA alone and 26.4 million to 36 million around the world. About 67% of these people can be treated with medical therapy. However, 25% of them cannot be treated with these medical resources [1]. The aftermath of opioid abuse is devastating and on the rise. Opioid abuse and misuse is one of major reasons scientists and lawmakers are looking for a reliable and quick solution to detecting drug use and misuse.

As an opioid produces a sense of pleasure and well-being when it affects the brain, monitoring electroencephalography (EEG) or chemical analysis could be an efficient way to observe opioid use in a clinical routine [2]. However, as the EEG recording takes tedious preparation and requires the patient under surveillance to restrict their movement, most patients are reluctant to use the EEG for long periods of time. Furthermore, it requires a complex design and tremendous effort to make a wearable EEG monitoring system capable of fetching a high-quality signal. Hence, it is not practical for continuous patient monitoring. The current drug testing method consists of urine tests and self-reports. The issue with this method is that the self-reports can be biased and are not a real-time solution. Also, the urine tests, although they are the most widely used technique for drug detection in patients, they are not able to deliver satisfactory results since they take almost 72 hours to complete excluding sample preparation protocols.

Aforenebtioed drawbacks are calling for a system that is user friendly, non-evasive and can reliably detect as well as predict opioid use in real-time. We have seen very few studies specifically for the non-evasive detection of opioid use over the past several years [3]-[4]. Most research is based on apps or text-messaging platforms that can detect substance overuse. iMstrong proposed a biosensor based cocaine detection system which can transmit different physiological signals such as electrodermal activity (EDA), temperature and acceleration [5], [16]-[18]. However, automatic identifying and detecting of drug intake remains a challenge in natural environment. Therefore, a real-time detection of opioid use has even greater advantages compared to just observing data. This method has a potential to be useful both in preventing drug overdoses and in improving early treatments. In this paper, we observed changes in the locomotion, temperature and EDA readings of opioid users via a wrist worn wearable sensor with high sensitivity. Accurate information taken from these bio-physiological signs can help us to robustly detect and predict drug use in a real-time manner.

The contributions of this paper are as follows:

  • Use wearable biosensor collects raw data and monitor physiological changes.

  • Extract features using time and frequency domain analysis and reduce the number of features.

  • Apply machine learning algorithm to distinguish pre- and post-opioid use in real-time.

In addition, the moving average is implemented to reduce motion artifacts, environmental and other noises. Finally, we compared the results with three classification methods to select the best performance output.

II. Literature Review

Recently, with the advancement of sensor technologies, wireless communication, and longer battery life in electronics, a new generation of constant health monitoring has been created for patients. In the case of substance detection, qualitative analysis of urine tests and self-reports are most popular for observing drug intake [5]. Although they are still considered the golden standard for testing drug use in patients, studies show that other vital signs such as EDA also have a correlation to the sympathetic nervous system (SNS) and thus provide a powerful tool to study the physical reactions to substance use [6]. Although ample studies have started to develop illicit drug use detection, most of them involve either chemical tests or mobile applications and both have the deterrent of lacking the ability to detect drug use in patients instantly.

An innovative approach was designed to detect opioid usage using a chemical based sensor. For example, in [7], authors claim to identify opioid glucuronides using a urine drug screening. they proposed a new technique to identify opioids in patients systems in a cost-effective way. Utilizing direct sample analysis of mass spectrograms on the chemical structures of illicit drugs to help identify if any were present in the patients. Danni et al. proposed a method to detect illcit drug overdose using dry urine specimens [8]. Which is also a time consuming procedure and takes laboratory setup. Above mentioned methods are still unable to serve the purpose of real-time detection of drugs and they require forensic laboratories as well as an extra set of skills to help interpret the data received from the sample analysis of each patient.

As of now, wearable sensors have proven to be new potential candidates to detect drug overuse in patients. One of the advantages of these wearable devices is that they can monitor physiological information continuously throughout the daily activity of the wearers. Also, the sensors can be used wirelessly and they do not hamper the daily activity of the patients. Autosense is a project to detect stress and other human behavior based on heart rate, EDA, skin temperature and acceleration. They developed a chest band using six wireless sensors to monitor vital signs. Nijsen et al. uses a 3-axis accelerometer on both legs and arms to observe a drug use pattern in 2005 [9]. They studied patterns for simple motor seizures based on visual data inspection with an accuracy of 48%. In their later work, they described a method for automatic detection of myoclonic seizures based on linear discrimination analysis using the time domain features of the accelerometer [10]. Dalton et al. proposed a study of false alarms during the daily activities of wearable devices [11]. They combined accelerometer and EMG data to extract features and performed decision tree classification. They claimed to have 98% accuracy in their data sets consisting of 48 hours of patient information. In [12], they utilized a Wii remote to detect motion based drug use detection. The remote was attached to the forearms, and they performed experiments on three patients with 100% sensitivity and 88% specificity. Natarajan et al. investigated a 2-dimensional accelerometer attached to the left and right arms for the detection of motor behavior of human body during drug use [14]. Also, they developed wearable ECG sensor to extract features of heart rate for cocaine detection. The wireless system was capable of detecting alcohol in the patients systems using an artificial neural network (ANN) with an accuracy of 85%. They used time and frequency analysis to feature extraction and applied shifting dataset method to evaluate the model. iHeal is a biomedical system which utilizes artificial intelligence to assess its patients through continuous monitoring [15]. However, it uses a Dynamic Bayesian Network (DBN), which has high computational complexity. Drug & Alcohol Impairment Detection Services (DAIDS) is a mobile app that can detect drug use based on eye scanning. Though it is still in the testing phase, they have reported that their app has an accuracy of more than 80%. They observed 62 events among 32 users, which was recorded wearable sensors. The system recorded 81 false positives, but almost 50% of them were manually canceled by the users. Use of combined sensor data has also been researched in recent years. The use of both acceleration and EDA data is reported in [16] to attempt to be able to detect substance overuse. It has also been reported that changes in sweat glands during a drug overdose is also thought to relate to EDA and skin temperature changes. The use of EDA, skin temperature and acceleration data to detect cocaine use has shown promising results [17]. This research group have conducted experiments on four patients and the system they have established can distinguish cocaine use. However, the detection of real-time drug use is still a challenge.

III. Method

The data collection and experimental protocol for this project has already been discussed in our previous work [17]. The observational study was performed on patients admitted as for a painful condition being treated with opioid analgesics. The protocol including the informed consent process was approved by the University of Massachusetts Medical School Institutional Review Board A Q-sensor (Affectiva) was used as a biosensor [5]. After informed consent was obtained, data sets were acquired from 30 patients as described previously [17]. After the enrollment the Q-sensor was placed on the patient’s non-dominant wrist and continuous physiological data was collected at baseline, during administration of an opioid medication and for 30–60 minutes after administration. Participants were then given detailed instructions on how to wear and recharge the biosensor. Also, they were requested to wear the biosensor on their non-dominant wrist and recharge the Q-sensor while they were sleeping.

A complete description of the Q-sensor is described in [6]. Briefly, it measures EDA which is also known as the patient’s Galvanic Skin Response (GSR). EDA is known to vary depending on the state of the patient’s sweat glands, which are controlled by the Sympathetic Nervous System. Hence, EDA is a good indicator of physiological arousal. In addition, the Q-sensor consists of a tri-axis accelerometer and a temperature sensor. The sensor measures EDA in microsiemens, temperature in Celsius and 3-dimensional acceleration in g, including wireless data transmittance capability. All parameters for each measured bio-signals were recorded in the device on board memory and uploaded upon completion of the recording. The sampling frequency of the system is 8 Hz. Figure 1 shows a complete block diagram of the proposed architecture of the system.

Fig. 1.

Fig. 1.

Complete architecture of data analysis procedure.

The continuous monitoring of physiological information generates an ample amount of data, whereas the behavioral changes due to an opioid use event lasts only minutes. Due to this reason, there was a plethora of unwanted data that needed to be processed which made the computational processing very tedious and complex. Hence, pre-processing is required to reduce the workload and degree of the data for machine learning. We first trimmed the data into a myriad of overlapping segments of the same length. As mentioned above the sampling frequency was 8Hz and we used a window of 16 seconds with 25 samples of repeated overlapping. Also, the sampling rate can be slightly changed during data recording due to hardware and wireless limitation. Interpolation could be applied in order to disrupt the uniformity of the sampled data. This helped to extract features and classification performance. Figure 2 shows the skin temperature, acceleration and EDA changes with overlapping windows. The output signals break down into different noise components such as noise from the environment, noise from the body, gravitational acceleration, noises from motion etc. We filtered out these noises and extracted a desired signal, however we encountered a dilemma caused by the complex filter architecture since it had the ability to slow down the real-time preprocessing. The proposed method in this research utilizes a moving average filter for preprocessing the raw data. The equation for the moving average is given below:

X0=X(i)LLX(i+1)2L+1 (1)

Fig. 2.

Fig. 2.

Time series data of EDA, Skin temperature and locomotion with overlapping windows.

Where X (i) is the received signal, Xo(i) is the output signal, 2L+1 is the size of the sliding window [8].

As this is a real-time detection, the feature selection is made based on a simpler algorithm, and at the same time avoiding overfitting. Over fitting causes bad output in generalization with new features, although fits well in the training dataset.

The feature selection plays a vital role for most detection algorithms. Therefore, out feature selection was design based on physiological phenomena from opioid intake. A total of 17 features was calculated from each epoch of locomotion and additional 3 time domain features were gathered from each skin temperature and EDA readings. The time domain features are mean, standard deviation and root mean square. These features and their descriptions are listed in Table 1. Time domain features such as mean, standard deviation and median were calculated from the magnitude of the total acceleration. For frequency domain features, the majority of the energy band lies between 0 to 5 Hz.

TABLE I.

List of All The Features Extracted From Each Epoch of The Signal

S/N Name Description
1 Mean The mean value of the time series signal
2 Median The median value of the time series signal
3 RMS The root mean square value of the time series signal
4 Max Maximum value of the signal
5 Min Minimum value of the signal
6 SD Standard deviation of the signal
7 MedFreq The median value of the frequency
8 FreqPX1 Cutoff value of the first peak
9 FreqPX2 Cutoff value of the second peak
10 FreqPY1 Ordinate of the first peak
11 FreqPY2 Ordinate of the second peak
12 PFreq Peak value of frequency
13 NPeak Number of peaks in a spectrum
14 IntFreq Integral of the frequency spectrum
15 Avg Average value of the sample points
16 SqrMag25 The square sum of the magnitude below 25%
17 SqrMag75 The square sum of the magnitude below 75%

Three classification methods were utilized to detect opioid use: the decision tree, support vector machine and K-Nearest Neighbor (KNN). Decision tree classifier is widely used in machine learning; it uses a decision tree as a predictive model to map observation on items until it reaches the conclusion with the highest probability. It can be compared to a flow chart, where a non-leaf node represents a test on an attribute and each leaf denotes a label. There are different algorithms to determine the split on the root node. This method is well suitable for a series of Boolean comparisons. eXtreme Gradient boosting follows the principle of gradient boosting. This maximizes the limit of the computational resources for boosted tree algorithm. This method is highly customizable base on the needs of application, for example learning with regards to different loss function.KNN uses a memory-based approach and is usually used for pattern recognition. It classifies based on the nearest training data in a featured space.

IV. Results and Discussion

We evaluated 30 patients in this study over a period of four months. To compare the results from our previous paper we used the same dataset as [12]. The demography of the patients is given in Table 2, and most of the patients were right-hand dominant. The observation time for patients varied from 5–48 minutes with an average of 16.5 minutes. This work is implemented with the help of piSpark and the configuration of the machine as follows: Windows 7 platform with Intel(R) Core(TM) i7–3520M 2.9 GHz CPU and 8 G memory [b16].

TABLE II.

Classification Accuracy and Latency Using All Features

Decision Tree eXtreme Gradient Boosting KNN
Accuracy 98.5% 99.4% 89.4%
Speed (Sec) 21 9 23

In the present work, detecting an opioid use event was affected by a small number of false positives and false negatives. We implemented a multilayer perceptron classifier for classifying opioid use events in patients. The modified features of each class were randomly divided into the training and test datasets in an estimate ratio of 70% and 30% respectively. Table 2 shows the accuracy and the latency for each applied classifier using all features to train the model. Decision tree and eXtreme Gradient Boosting shows the best result compare to KNN classifier. The correlation analysis has also been performed on EDA and skin temperature. The results show that locomotion has high correlation with EDA and skin temperature for opioid intake. We further evaluated EDA, skin temperature and locomotion before we applied it to the classification.

It would be possible to use all the features reported in Table 1 for the classification of the data sets, however, this can reduce the performance of the output. Thus, a feature selection method is important due to the curse of dimensionality. The WEKA tool was used to evaluate and select the attributes. The exhaustive search method was used, and the subsets that had the highest total classification accuracy were selected. With WEKA, we narrowed down the attributes to 10 features from locomotion to temperature to EDA. This feature reduction method reduces the computational time. It is different from dimension reduction, as it does not create new attributes, instead was able to omit irrelevant features. This method also helped to avoid over fitting, however only locomotion and skin temperature were evaluated. Our previous research showed that EDA does not change extensively during opioid administration. So by not collecting EDA data the degree of computation was automatically reduced. Hence, the latency of the detection for opioid intake was at a minimum.Table 3 shows the output of the classifier with modified features.

TABLE III.

Classification Accuracy and Latency Using Modified Features

Decision Tree eXtreme Gradient Boosting KNN
Accuracy 98.5% 99.4% 77.8%
Speed (Sec) 21 9 6

The confusion matrix is shown in figure 3, the detection rate of decision tree and extreme Gradient boosting is 99.3% and 99.8% respectively. The performance of these two classifiers is reasonably good. But the computation time for eXtreme Gradient boosting is relatively lower than the decision tree. In case of KNN we tested the variable with K equal to 1 and the detection rate is 77.8%.

Fig. 3.

Fig. 3.

Performance of a) Decision Tree b) eXtreme Gradient Boosting and c)KNN classifier for detecting opioid use event.

As shown, our method can identify the opioid use event with the accuracy of 99%. These results demonstrate the effectiveness of the developed algorithm to classify the pre- and post-opioid use. We also evaluated this method with all features however modified features shows higher accuracy with low latency. Specifically, using the reduced features increased the accuracy and sensitivity of drug detection. The use of modified features also lowers the training time of the proposed method, making it fit for real-time.

The main findings of this study fit the description of a fully automatic detection of an opioid use event. The identification relies on only two parameters; the Z-axis movement and the skin temperature of patients, consistent with our previous finding in cocaine detection [5]. The development of the algorithm, which goes through a time series of the locomotion and skin temperature data with a 15 second epoch, allows it to quickly detect the drug use event making it suitable for a real-time solution. Data with long recordings can be analyzed using the proposed algorithm, which has the ability to detect substances other than just opioids.

The skin temperature and magnitude of the motion data changes abruptly after opioid administration, opposite to the findings from our cocaine study [5]. Although, there were no noticeable changes of EDA during and pre- and post-opioid use, this could be an indicator for other drug usage. Rise in skin temperature was noted during sleep time, which was to be expected.

V. Conclusion

Accurate detection of opioid use allows caregivers to observe the severity of a patient’s drug use and deliver timely intervention. Wearable biosensors present a consistent result to identify instances of opioid use based on our previous and current findings. Moreover, patients undergoing drug abuse treatment can be applied to gather the episodes of drug use. Above mentioned results have indicated that the proposed method can automatically detect opioid use fast and reliably. Initially we extracted 23 features from acceleration, EDA and temperature. In order to improve the performance and run time we reduced the number of features. Beyond the sensors uses in continuous monitoring and patient care, they can also allow increased granularity of neurological disease data, thereby improving the risk assessment and predictive analysis of drug use. Although, the experiment was done on 30 patients, the results are still promising and they have the ability to distinguish opioid use in real-time.

The study was performed on a limited number of patients. Therefore, in the future we expect to add more subjects to assess pre- and post-drug administration. We would also like to improve the wearable biosensor because the core temperature of the body may be different than the wrist temperature. Also, in the next phase of our research, we would like to add heart rate measurement data and observe the changes due to substance overdose.

Acknowledgment

This research was supported by NIH grant RO1DA033323-01A1, 1UL1RR031982-01 Pilot Project to Dr. Fang, NIH R01DA033769-01 to Dr. Boyer, NIH KL2TR001454 to Dr. Carreiro, and NSF CCSS1407882, IIS1401711 and 1429120 to Dr. Wang.

References

  • [1].[Online]. Available: http://drugabuse.com/library/drug-abuse-statistics/
  • [2].Poh M-Z et al. “Convulsive seizure detection using a wrist-worn electrodermal activity and accelerometry biosensor,” Epilepsia, vol. 53, no. 5, 2012. [DOI] [PubMed] [Google Scholar]
  • [3].Fang H, Johnson C et al. , “A new look at quantifying tobacco exposure during pregnancy using fuzzy clustering,” Neurotoxicol Teratol, vol. 33, no. 1, pp. 155–65, 2011. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [4].Wang J, Fang H, Carreiro S et al. , “Detecting real-time substance use from wearable biosensor data stream,” Section on Statistical Learning, Joint Statistical Meetings, American Statistical Association, 2016. [Google Scholar]
  • [5].Carreiro S, Fang H et al. , “imstrong: Deployment of a biosensor system to detect cocaine use” Journal of Medical System, vol. 39, no. 12, p. 186, 2015. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [6].Carreiro S et al. , “Real-Time Mobile Detection of Drug Use with Wearable Biosensors: A Pilot Study,” Journal of Medical Toxicology, vol. 11, no. 1, pp. 73–79, 2014. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [7].Milone MC, “Laboratory Testing for Prescription Opioids,” Journal of Medical Toxicology, vol. 8, no. 4, pp. 408–416, 2012. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [8].Meany DL and Clarke W, “Opiate DAU screening using dried urine specimens,” Clinica Chimica Acta, vol. 401, no. 1–2, pp. 188–189, 2009. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [9].Nijsen TM, Arends JB, Griep PA, and Cluitmans PJ, “The potential value of three-dimensional accelerometry for detection of motor seizures in severe epilepsy.,” Epilepsy & behavior : E and B, August-2005. [DOI] [PubMed] [Google Scholar]
  • [10].Nijsen TME, Aarts RM, Arends JBAM, and Cluitmans PJM, “Automated detection of tonic seizures using 3-D accelerometry,” SpringerLink, January-2008. [Google Scholar]
  • [11].Dalton A, Patel S, Chowdhury AR, Welsh M, Pang T, Schachter S, Olaighin G, and Bonato P, “Development of a Body Sensor Network to Detect Motor Patterns of Epileptic Seizures,” IEEE Transactions on Biomedical Engineering, vol. 59, no. 11, pp. 3204–3211, 2012. [DOI] [PubMed] [Google Scholar]
  • [12].Schulc E, Unterberger I, Saboor S, Hilbe J, Ertl M, Ammenwerth E, Trinka E, and Them C, “Measurement and quantification of generalized tonic-clonic seizures in epilepsy patients by means of accelerometry-An explorative study,” Epilepsy Research, vol. 95, no. 1–2, pp. 173–183, 2011. [DOI] [PubMed] [Google Scholar]
  • [13].Fang H, Johnson C et al. , “A new look at quantifying tobacco exposure during pregnancy using fuzzy clustering,” Neurotoxicol Teratol, vol. 33, no. 1, pp. 155–65, 2011. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [14].Natarajan A, Angarita G, Gaiser E, Malison R, Ganesan D, and Marlin BM, “Domain adaptation methods for improving lab-to-field generalization of cocaine detection using wearable ECG,” Proceedings of the 2016 ACM International Joint Conference on Pervasive and Ubiquitous Computing - UbiComp 16, 2016. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [15].Boyer E, Fletcher R et al. ,” Preliminary efforts directed toward the detection of craving of illicit substances: the iHeal project,” Journal of Medical Toxicol, vol. 8, pp. 5–9, 2012. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [16].Wang J, Fang H, Carreiro S, Wang H, and Boyer E, “A new mining method to detect real time substance use events from wearable biosensor data stream,” 2017 International Conference on Computing, Networking and Communications (ICNC), 2017. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [17].Carreiro S, Wittbold K, Indic P, Fang H, Zhang J, and Boyer EW, “Wearable Biosensors to Detect Physiologic Change During Opioid Use,” Journal of Medical Toxicology, vol. 12, no. 3, pp. 255–262, 2016. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [18].Fang H, Zhang Z, Wang CJ, Daneshmand M, Wang C, and Wang H, “A survey of big data research,” IEEE Network, vol. 29, no. 5, pp. 6–9, 2015. [DOI] [PMC free article] [PubMed] [Google Scholar]

RESOURCES