# Design and Feasibility of a Safe Pill Bottle
## 2 Materials and Methods
### Signal Processing and Feature Selection  
All signals were collected by the embedded controller and stored on the microSD card for postprocessing. All processing was performed off line using Matlab 2017b. A typical example of the change of capacitance on two out of 15 segments during bottle opening is shown in Figure 2. As shown, depending on the contact area between the capacitive segment and the palm or fingers, the capacitance of segments increases from approximately 25 pF to 36-43 pF. A time sequence of contact with different sensor segments can be also seen; in this case, segment seven (S7) is touched first and released later. Segment capacitance fluctuates somewhat during the event, depending on the contact area and pressure. Figure 2 illustrates the change of capacitance for two segments only (S6 and S7); similar patterns of change during bottle handling event can be seen in all 15 segments. Both signals are filtered using a 3-point median filter to remove high frequency noise. Figure 1: Safe bottle prototype. The user's contact pattern can be characterized using the relative change of segment capacitance caused by contact with the palm or fingers. Each segment has a different default capacitance, as shown in Figure 2. Therefore, we calculate the relative change of capacitance \(CR_{i}\) for each segment \(i\) (\(C_{i}\)) using default capacitance (\(Cdef_{i}\)) before the touch, via Equation (1):  
\[CR_{i}=\ \frac{C_{i}-Cdef_{i}}{Cdef_{i}}. \tag{1}\]  
Total capacitance \(C_{t}\) of all \(N\) segments is calculated as:  
\[C_{t}=\sum_{i=1}^{15}CR_{i}. \tag{2}\]  
The start of an event is recognized as a change of total capacitance greater than the threshold, which in our case is 20% higher than the default capacitance \(C_{t}\). The region of interest (ROI) for each touch event is selected as the 500 ms period from the start of touch. We save the relative change of capacitance for each segment and characterize each event using the following parameters:  
* \(tRCC\)--total relative change of capacitance as the sum of all relative changes \(CR_{i}\), \(i=1\dots\ N\)
* \(CRmax=\max(CR_{i})\), \(i=1\dots\ N\)
* \(CRN_{i}\)--normalized change of capacitance  
\[CRN_{i}=\frac{CR_{i}}{CR_{max}}\text{, }i=1..N \tag{3}\]
* \(tRCC\)--normalized total relative change of capacitance, calculated as sum of all normalized changes of capacitance according to Equation (3)
* \(mpsos\)--mid-segment position, calculated as a center of gravity of the sorted set of relative capacitances \(CR_{sorti}\)  
\[mpsos=\frac{\sum_{i}CRsort_{i}*i}{\sum_{i}CRsort_{i}}\text{, }i=1..N. \tag{4}\]  
Since touch capacitance depends on skin properties and current conditions, touch capacitance can be significantly different in the case of wet hands compared with contact with dry hands for the  
Figure 2: Pattern of capacitance change on two segments during bottle opening. same user. Therefore, we use normalized changes according to Equation (3) and \(t\)_RCCN_ to determine parameters that depend on touch area, not skin condition. An example of the absolute change of capacitance (\(C_{i}-\textit{Cdef}_{i}\)) for a child and an adult for each segment is shown in Figure 3. As shown, the smaller child's hand is in contact with a smaller number of segments. Smaller contact area from the child also generated smaller change of capacitance on segments in contact with the palm or fingers. Note that because of the circular pattern of capacitive segments, with no markers on the bottle (as shown in Figure 1), each touch event will have a different distribution of values between segments, even for the same hand contact pattern with the bottle. That is the reason why we use sorted sets of relative changes (\(CR_{\textit{sort}}\)) to generate the pattern, independent of the relative position of the bottle during opening, as defined in Equation (4). Each user generates a specific touch pattern described with our set of parameters (Equations 1-4).