J. agric. Engng Res. (2001) 79 (4), 449}457 doi:10.1006/jaer.2001.0719, available online at http://www.idealibrary.com on AP*Animal Production Technology Recognition System for Pig Cough based on Probabilistic Neural Networks A. Chedad; D. Moshou; J. M. Aerts; A. Van Hirtum; H. Ramon; D. Berckmans Laboratory for Agricultural Buildings Research, K.U. Leuven, Kasteelpark Arenberg 30, 3001 Leuven, Belgium; e-mail of corresponding author: daniel.berckmans@agr.kuleuven.ac.be Laboratory for Agro-Machinery and Processing, K.U. Leuven, Kasteelpark Arenberg 30, 3001 Leuven, Belgium; e-mail: dimitrios.moshou@agr.kuleuven.ac.be (Received 12 June 2000; accepted in revised form 6 March 2001; published online 18 May 2001) Until now the use of acoustic bio-responses in bio-environment control as indicators of animal-condition is limited to human perception. Coughing is a frequent symptom of many respiratory diseases a!ecting the airways and lungs of humans and animals. Registration of coughs from di!erent pigs in a controlled test chamber was done in order to analyse the acoustical signal. A new approach is presented to distinguish cough sounds from other sounds, such as grunts, metal clanging and background noise, using neural networks as the classi"cation method. Other signals (such as grunts, metal clanging, etc.) could also be detected. The best performance was obtained with a hybrid classi"er that classi"es coughs and metal clanging separately from the rest, giving better results compared to a probabilistic neural network (PNN) alone. The hybrid classi"er, which consists of a 2- and a 4-class PNN, gave high discrimination performance in the case of grunts, metal clanging and background noise (91)4, 63)9 and 82)6%, respectively) and a performance of (91)9%) for correct classi"cation in the case of coughs. 2001 Silsoe Research Institute 1. Introduction Coughing is one of the body's defence mechanisms, against the entry of materials into the respiratory system. Clinically, coughing is one of the symptoms most frequently present in many diseases a!ecting the airways and lungs, and is an early symptom of some diseases, such as asthma, bronchitis and chronic bronchitis (Hirschberg & Szende, 1982). It involves a natural bio-signal indicating a possible health problem. It is well known that coughing is associated with a sudden expulsion of air, which is accompanied by a typical sound. Changes in the character of the sound of the cough might re#ect pathological conditions in the lungs. The objective registration of cough sound as a diagnostic tool is still absent from current medical and veterinary practice in comparison with the registration of the electro-encephalogram (EEG), electro-myogram (EMG), electro-cardiogram (ECG), etc. 0021-8634/01/080449#09 $35.00/0 The cough sounds are generally classi"ed according to empirical observation. Two possibilities exist for cough sound registration and analysis. One is the registration of the acoustic pressure accompanying in the form of time}amplitude, the tussiphonogram, as in Korpas et al. (1987). The other approach uses frequency analysis, as in Subburaj et al. (1996) and Korpas et al. (1996). The sounds associated with coughing can be registered as a tussiphonogram and analysed with respect to shape, duration, intensity, frequency components, etc. Coughing can indicate to a producer that illness may be present in a pig house. The occurrence of coughing among piglets is shown to depend on air velocity and temperature during transport and housing conditions (Geers et al., 1986). E!ects of environmental variables such as aerial ammonia and dust concentration on the respiratory tract are observed (Urbain et al., 1996). For this reason the amount of coughing and the frequency of 449 2001 Silsoe Research Institute 450 A. C H ED AD E¹ A ¸. occurrence is widely recognized as a natural alarm by experienced herdsmen. Close human attention is not so evident today due to the great number of animals in a potentially harmful environment (Attwood et al., 1986). So, in general, health control and consequently welfare would bene"t from continuous automated, contactless and on-line cough observation in the pig house. Some contactless cough recognizers are presented in literature on pigs. For the early detection of coughs in pig houses, a relatively cheap system is required. Robertson and Benzie (1989) built a system to detect coughs in pig houses based on a "xed template shape of the amplitude of a cough signal in the time domain, after the signal was split into eight frequency channels. The main problem of this technique was the inability of the system to discriminate between coughs and other sounds which produced an audio signal of similar pro"le. Speech processing was performed on some pig vocalizations, including 15 records of coughing of di!erent slaughter pigs, for the detection of stress (Van Compernolle et al., 1992). Analysing the number of formants of the spectrogram within the linear prediction coe$cients (LPC) spectrum results in a 87%$2)8 recognition of pig coughing. The objective of this paper is to describe an algorithm which enables the discrimination of cough sounds from other background noise, such as metal clanging, grunting and other background noise, using advanced classi"cation methods, such as neural networks. The presented algorithm can be implemented in a system for on-line pig cough recognition. The features that are used for classi"cation are the components of the power spectral density (PSD) of the di!erent sounds. The neural architecture that is presented in this work, probabilistic neural networks is used for the classi"cation of the sounds. 2. Materials and methods 2.1. ¹est installation The laboratory installation used, described in Urbain et al. (1993), consists of a metal construction of dimension 2 m long by 0)8 m wide by 0)95 m high covered with transparent plastic in order to control the microenvironment around the animal. A schematic representation that clari"es the interconnections of the measuring apparatus is shown in Fig. 1. As environmental variables may act upon the respiratory tract and so upon the cough signal, it was necessary to control NH concentration, dust concentration, tem perature and air#ow rate in the closed test installation. Experiments were performed at 213C with an NH concentration less than 1 p.p.m., dust particles of size greater than 1 lm "ltered out, and an air#ow rate of 10 m h\. Pigs (Landrace) used in the study were 14}15 weeks old. One of the pigs was a male with a weight of Fig. 1. Schematic representation of the test procedure for recording the sounds; the unidirectional microphone is connected to a standard 16 bit sound card supplemented by appropriate software RE C O G NI T IO N S YS T EM F OR P I G CO U G H approximately 45 kg. The three others were females weighing 40}50 kg. The coughs were chemically induced by an irritating substance (citric acid vapour) produced by an evaporator. A quantity of 50 ml was evaporated during 15 min. The entire procedure is explained in detail in Moreaux et al. (1999). The system used a Pentium II, 200 MHz personal computer, with a standard 16 bit sound card supplemented by appropriate software and an inexpensive unidirectional condenser microphone (Model 16 A, SHURE) with a frequency response of 20}20,000 Hz. The signal-to-noise ratio of the used microphone was 48 at 74 dB sound pressure level (SPL). For reference, 74 dB SPL was the level of a talker 2)5 cm away from the microphone. The system noise was less than 0)01 V, which was low in comparison with the level of any sound signal produced in the test installation. For these reasons the accuracy of the used microphone system was considered as adequate for the sound recording. The microphone was attached and positioned in the cage through an aperture into the plastic cover, placed 0)4}1 m from the animal depending on the position of the animal in the cage. The sample rate chosen was equal to 22,050 Hz, because the frequencies of a typical cough are below 10,000 Hz. The measured signal of a typical pig cough and its PSD is shown in Fig. 2. The central frequency of the PSD is around 1610 kHz. The recordings were done by using the commercially available &Cool edit pro' software (Syntrillium Software Corporation) and captured data were saved in windows wave sound format. The data were stored on a compact disc. Each experiment induced coughing on one individual animal. A whole gamut of sounds was received by recording the full 30 min of each experiment and these sounds can be distinguished in di!erent groups. Firstly, the sounds produced by the laboratory animal itself, besides the coughing sounds, consist mostly of grunting sounds and sounds due to respiration. A second group of sounds is due to the procedure followed for cough induction. On one hand, the interaction of the laboratory animal with the test installation causes noises, typically for the installation material used. In this case, the test installation is of metallic construction, so animal movements may cause metal clanging. On the other hand, the procedure itself includes some noise e.g. the ventilation inside the test installation needed for evaporation of the irritating substance. Finally, there are background noises mainly due to ventilation in the chamber containing the test installation and the presence of researchers (e.g. talking, shutting of doors, etc). The duration of each measurement was about 30 min consuming approximately 80 MB of disc space. During the 30 min of measurements, 57, 49, and 52 coughs and 5, 6 and 5 grunts could be collected, respectively, from the 451 three gilts. Fifty-four coughs and 7 grunts were collected from the barrow. Over the four experiments, 50 metal clanging and 69 background noise sound samples could be collected. 2.2. Collecting samples In order to build a system that is capable of distinguishing coughs from other sounds, a high number of samples had to be collected. For this purpose, a total of 354 sounds were collected, comprising coughs from four di!erent individual pigs (212 samples), metal clanging (50 samples), grunts (23 samples), and background noise (69 samples). Each of the individual sounds is auditively recognized by a human expert as a cough or not. The samples were split into two groups after auditive recognizing; the training set (23 sounds from each class) and the testing set (23 sounds from each class, di!erent than the sounds used for training with the exception of coughs, where 115 coughs were used for testing). Then the power spectra density (PSD) of the sounds was calculated using a fast Fourier transform (FFT) of 128 points. Since the FFT is symmetric, the PSD had 64 components. Speci"c algorithms for calculating PSDs are widely available in many mathematical software for physicists and engineers. For example, the commonly used MATLAB system, contains a toolbox (Matlab, 1998) for signal processing with numerous sound processing routines. A representative spectrum of a cough is presented in Fig. 2. In this way, the problem of classifying sounds was reduced to the problem of classifying vectors with the same number of components i.e. PSD vectors with 64 components. Those vectors are further used for training and testing the neural network. In total, 115 coughs have been used for testing, because of the importance of the correct recognition of cough sounds. The testing set was used for the "nal evaluation of the classi"er. Some representative examples of the spectra of sounds belonging to each class are presented in Fig. 3. The cough sounds from the four di!erent pigs had a similar frequency content (probability p'0)05 by Student's t test for paired comparisons applied to the mean spectra of 120 coughs and more speci"cally 30 coughs from each of the four pigs over the entire frequency range). 2.3. Acoustical signals For the obvious reason of non-"xed animal position with respect to the microphone, the exact amplitude 452 A. C H ED AD E¹ A ¸. Fig. 2. The time signal of a pig cough and its power spectrum density (PSD) value is not suitable for sound characterization. The duration of grunts compared to coughing are generally longer. The average duration of the 212 cough samples is 0)5$0)09 seconds and the average duration of the 23 grunt samples is 1)2$0)15 s. The noise duration was not taken into account because it shows a great variability. 2.4. Probabilistic neural networks A well-known decision rule used to classify patterns uses the minimization of the &expected risk' of misclassi"cation. Such a strategy is called the &Bayes Strategy' and can be applied to problems containing a number of categories. Let us consider a two-category situation in RE C O G NI T IO N S YS T EM F OR P I G CO U G H 453 Fig. 3. The power spectrum density (PSD) of: (a) a pig cough; ( b) metal clanging; (c) grunting and (d) background noise which the state of h is known to be either h or h . Then, the Bayes decision rule g becomes: g(X)"h if h l f (X)*h l f (X) (1) g(X)"h if h l f (X))h l f (X) (2) where g(X) is the decision on test vector X, f (X) and f (X) are probability density functions (PDF) for categories A and B; l represents the loss incurred by misclas sifying a vector of class A to class B; and l represents the loss incurred by misclassifying a vector of class B to A. In the case that the decision is correct, the losses l or l are taken to be equal to zero. The a priori probability of occurrence of a pattern from category A is given by h ; and h de"ned by h "1!h is the a priori probability that h belongs to class h . From the above equations, it follows that when the vector X belongs to the boundary of the classes A and B, the following equation can be written: f (X)"Kf (X) where the coe$cient K is given by (3) K"h l /h l (4) Bayesian classi"cation requires a PDF for each class. It is often di$cult to determine the PDF with a high accuracy. The probabilistic neural network (PNN) is based upon work done in the 1960s (Specht, 1966). It has been used successfully (Specht, 1990) to solve a diverse group of classi"cation problems. The PNN has been applied successfully to a wide range of applications, including the airport &bomb sni!er' of Shea and Lin (1989) that detects explosives in luggage, the vector-cardiogram interpretation (Specht, 1967) and, more recently, the hull-to-emitter correlation on radar hits, as in Maloney and Specht (1989). Fortunately, Parzen (1962) showed how a family of PDFs functions can be expressed as a product of univariate kernels: 1 1 f (X)" (2n). p. n n ; exp [!(X!X )2 (X!X )/2p] (5) G G G where i is the pattern number; n is the total number of training patterns in class A; X is the ith training pattern G from category p ; p is the spread or standard deviation; P is the dimensionality of measurement space; superscript T is the transpose of a vector; and X is the test vector to be classi"ed. The formula may appear complicated but the idea is as follows. Add up the values of the n-dimensional 454 A. C H ED AD E¹ A ¸. weighting C : I hB nA l C "! I I I hA nB lA I I (8) I where nA is the number of training patterns from catI egory A ; and nB is the number of the training patterns I I from category B . I Note that C is the ratio of a priori probabilities, I multiplied by the ratio of losses and multiplied by the ratio of samples in each class. This "nal ratio cannot be determined from the statistic of the training samples, but only from the signi"cance of the decision. If there is no particular reason for biasing the decision, C may simI plify to !1 (an inverter). Fig. 4. Probabilistic neural network (PNN); X1}Xn , input; fA1 ( X) and fB1 ( X) are probability density functions for categories A and B; O1}On , output 3. Results and discussion 3.1. Discrimination of coughs from metal clanging Gaussians, evaluated at the training vector point in an n-dimensional space, and scale the sum to produce the estimated probability density at that point. However, the sum is not limited to being Gaussian. It can, in fact, approximate any smooth density function. Figure 4 shows a neural network organization for the classi"cation of input vector X into two categories. Each part of the input unit is connected to all the pattern units. The set of weightings W "(=R , =R ,2, =R ) asso . 0 ciated with a given pattern neurone represents a training vector. Next, the pattern neurone computes the product XW by subtracting 1 and dividing by p, and applying 0 the non-linear function that results "nally in the term exp [(W X!1)/p]. Assuming that both X and W are 0 0 normalized to unity, this is equivalent to using: exp [!(W !X)2 (W !X)/2p] (6) 0 0 The network is trained by setting the weighting vector W in one of the pattern units equal to each of the 0 patterns in the training set X and then connecting the 0 output of the pattern units to the appropriate summation unit. Each neurone in the summation units sums the inputs from the pattern units associated with a given class. The output of each summation layer neurone becomes nA fA (X)" exp [(XR X!1)/p] (7) G G In the output, or decision units, each neurone forms a comparison, outputting one if fA (X) is greater than I C fB (X), and otherwise zero. They have only a variable I I In the case of the classi"cation of cough sounds and particularly the discrimination of cough sounds from other sounds, the problem of separating the cough sounds from the metal clanging is most di$cult because these sounds have a similar frequency content (p'0)05 over the 0}6)5 kHz frequency range and p(0)05 over the 6)5}10 kHz frequency range by Student's t test for paired comparisons applied to the mean spectra of 48 coughs from 12 coughs of four di!erent pigs and 48 metal clanging). Before training the PNN, the spectra had to be normalized by dividing them by their Euclidean norm. The normalization step is necessary because the spectral power levels exhibit a large variation even inside the same class. This variation is due to the distance and direction between the pigs and the microphone. Due to low system noise (less than 0)01 V as mentioned earlier) the variation in distance and position of the pigs did not a!ect the quality of the recording. For varying spread between 0)001 and 1 in steps of 0)001 the correct recognition percentages are given in Fig. 5. A separate analysis of sounds (15 from each class) was used for testing the classi"cation performance of the PNN. For spreads less than 0)006, the PNN classi"es the cough sounds perfectly (100%) but many metal clanging sounds are misclassi"ed as coughs. For a spread greater than 0)015, the correct recognition percentages converge to the same value of 94%. For this classi"er the spectrum had 64 components. The PNN shows superior performance in the discrimination of cough from metal clanging (100%) while the other classi"ers achieve around 94% for both classes with the minimum distance classi"er achieving 89% on 455 RE C O G NI T IO N S YS T EM F OR P I G CO U G H Fig. 5. Correct recognition percentages of a probabilistic neural network using diwerent spreads: coughs and 94% on metal clanging. The performance of the PNN is better because the boundaries between the di!erent classes are determined by a PDF, which is not the case in a minimum distance classi"er. 3.2. Multiple class classi,er For the case of discrimination between coughs, metal clanging, grunting and background noise, other classi"ers had to be developed. Only probabilistic neural networks were trained to classify the four di!erent types of sounds. For the PNN, the correct classi"cation percentages for di!erent spreads are shown in Fig. 6. It is clear that the 4-class PNN using di!erent spreads gives high discrimination performance (90}100%) in the case of grunts and noise but the performance in the case of coughs and metal clanging is low (60}80%). The confusion matrix describes how many of the sounds whose correct class appears in the "rst column have been misclassi"ed as belonging to another class. The confusion matrix for a 4-class PNN classi"er that has a spread equal to 1 is given in Table 1. It is evident that neither method can give satisfactory results in the case of coughs and metal clanging, while the results are much better for the grunting and noise case classi"cation. This result leads to the consideration of a hybrid scheme where a combination of the 2-class PNN based , coughs; , metal clanging classi"er with the 4-class PNN based classi"er would take place. The hybrid classi"er switches from the 4-class PNN classi"er to the 2-class PNN classi"er when a sound is classi"ed either as a cough or metal clanging from the 4-class classi"er. Only then the 2-class PNN estimates the class of the sound anew, otherwise it remains inactive. This way, a better class prediction is produced since for discriminating between coughs and metal clanging the 2-class PNN is superior compared to the 4-class PNN while the 4-class PNN separates the other sounds with high performance. The confusion matrix for such a scheme is shown in Table 2. The number of sample sounds used for testing was 23 for each class category. However, in the case of cough sounds the number of tested examples was 115, so the results for the coughs are presented as an average value over "ve di!erent groups of coughs containing 23 cough samples each. The rest of the coughs (74) were not used for validating because the results obtained using the 115 cough samples were considered representative enough for testing the performance of the classi"er. The results presented in confusion Table 2 show that the hybrid classi"er performs much better than the 4-class PNN classi"er alone. The positive cough-recognition of 92)2% obtained with the hybrid classi"er is slightly better than the best accuracy found in literature (87% in Van Compernolle et al., 1992). 456 A. C H ED AD E¹ A ¸. Fig. 6. The correct recognition percentages for the 4-class classixer for a spread varying between 0 and 1: grunts; , metal clanging; , background noise Future extension of the proposed method to recognize natural coughs is being planned. A similar extension was presented in Korpas et al. (1996) for human cough sound. According to their results there was no signi"cant di!erence for sound pattern, intensity and duration, but spectrographically chemically induced coughs show a decreased intensity of frequencies above 2000 Hz compared to normal voluntary coughs. 4. Conclusions A new approach is presented for the continuous detection and classi"cation of coughs in pig houses. The , coughs; , accurate detection of coughs is a matter of great economic importance since it can reveal the possibility of an epidemic. If the epidemic is handled early enough, it can be treated e!ectively. The tools for detecting coughs were a standard cheap microphone and a PC equipped with a sound card. Advanced signal processing methods were used for the detection of the sounds from raw recorded signals. For the classi"cation, novel neural network based techniques were used based on probabilistic neural networks. The resulting system for detection and classi"cation of coughs has a rather high performance of 91)9% of correct classi"cation. Future extension of the system to recognize di!erent types of coughs that are related to certain Table 1 Confusion matrix for the 4-class PNN (actual numbers); there are 25 false negative coughs being misclassi5ed into the other categories while there is one false positive cough which is actually a metal clanging sound Actual sound Actual Actual Actual Actual coughs metal clanging grunting background noise Predicted coughs Predicted metal clanging Predicted grunting Predicted background noise 80 1 0 0 15 14 1 1 10 2 21 3 10 6 1 19 457 RE C O G NI T IO N S YS T EM F OR P I G CO U G H Table 2 Confusion matrix for the 4-class hybrid classi5er especially constructed for the current problem (actual numbers); there are 9 false negative coughs being misclassi5ed into the other categories while there are no false positive coughs; false positive errors have been decreased with respect to the results of the PNN classi5er presented in Table 1 Actual sound Actual Actual Actual Actual coughs metal clanging grunting background noise Predicted coughs Predicted metal clanging Predicted grunting Predicted background noise 106 0 0 0 4 15 1 1 2 2 21 3 3 6 1 19 diseases is being planned. This step is important since the origin of certain coughs could be due to other environmental reasons, such as dust and humidity and not due to the presence of a certain viral infection. Acknowledgements The authors are grateful to the Ministry of Small Enterprises and Agriculture (Belgium) for "nancial support. Special thanks are also due to Prof. W. Lauriks of the Laboratory of Acoustics and Thermal Physics (Leuven) for good advice. I would like to express my appreciation to my colleagues D. Moshou and J. Hendriks for their invaluable help. References Attwood P; Versloot P; Heederik D; De Wit R; Boleij J S (1986). Assessment of dust and endotoxin levels in the working environment of Dutch pig farmers: a preliminary study. Annual Occupancy Hygienne, 30, 201}208 Geers R; Goedseels V; De Laet B; Verstegen W A (1986). Relationship between transport conditions and the occurrence of cough in growing pigs. Journal of Thermal Biology, 11, 137}138 Hirschberg J; Szende T (1982). Pathological Cry Stridor and Cough in Infants: A Clinical Acoustic Study. Akademiai Kiado. Budapest Korpas J; Sadlonova J; Salat D; Masarova E (1987). The Origin of Cough Sounds. Clinical Respiratory Physiology, 23(suppl 10), 47}50 Korpas J; Sadlonova J; Vrabec M (1996). Methods of assessing cough and antitussives in man. Pulmonary Pharmacology, 9, 261}268 Maloney S P; Specht D F (1989). The use of probabilistic neural networks to improve solution times for hull-to-emitter correlation problems. International Joint Conferences on Neural Networks, Vol. 1, pp. 289}294, IEEE Press, New Jersey. MATLAB (1998). Signal Processing Toolbox. For use with Matlab, version 4 Moreaux B; Beerens D; Gustin P (1999). Development of a cough induction test in pigs: e!ects of SR 48958 and enalapril. Journal of Veterinary Pharmacology and Therapy, 22, 387}389 Parzen E (1962). On estimation of a probability density function and mode. Annual Mathematical Statistics, 33, 1065}1076 Robertson J F; Benzie J (1989). Assessment of a cough counter for pigs. Farm Building Progress, 95, 25}28 Shea P M; Lin V (1989). Detection of explosives in checked airline baggage using an arti"cial neural system. International Joint Conferences on Neural Networks, 2, 31}34 Specht D F (1966). Generation of polynomial discriminant functions for pattern recognition. PhD Thesis, Stanford University Specht D F (1967). Vectorcardiographic diagnose using the polynomial discriminant method of pattern recognition. IEEE Transactions on Bio-Medical Engineering, 14, 90}95 Specht D F (1990). Probabilistic neural networks. Neural Networks, 3(1), 109}118 Subburaj S; Parvez L; Rajagopalan T G (1996). Methods of recording and analysing cough sounds. Pulmonary Pharmacology, 9, 269}279 Urbain B; Gustin P; Charlier G; Coignoul F; Lambotte J L; Grignon G; Foliguet B; Vidic B; Beerens D; Prouvost J F; Ansay M (1996). A morpometric and functional study of the toxicity of atmospheric ammonia in the extrathoracic airways in pigs. Veterinary Research Communications, 20, 381}399 Urbain B; Gustin P; Prouvost JP; Ansay M; Michel O; Nicks B (1993). Microclimat et composition de l'air dans une enceinte ferme destiner a l'etude de la toxiciteH des polluants atmospheriques chez le porcelet. [Microclimate and the composition of air in an enclosed space to intend the study of the toxicity of atmospheric pollutants around pigs.] Veterinary Research, 24, 503}514 Van Compernolle D; Janssens S; Geers R; Vill H; Oosterlinck A; Goedseels V; Goossens K; Parduyns G; Van Bael J; Bosschaerts L (1992). Welfare monitoring of pigs by automatic speech processing. International Pig Veterinary Society, 2, 570