Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Erik Proposal Final

232 views

Published on

  • Be the first to comment

  • Be the first to like this

Erik Proposal Final

  1. 1. Development of MATLAB Software to Control Data Acquisition from a Multichannel Systems Multi-Electrode Array Erik Messier, Behnaz Ghoraani∗, Ph.D. Abstract— A Multichannel Systems (MCS) microelectrode ar- ray data acquisition (DAQ) unit is used to collect multichannel electrograms (EGM) from a Langendorff perfused rabbit heart system to study sudden cardiac death (SCD). MCS provides software through which data being processed by the DAQ unit can be displayed and saved, but this software’s combined utility with MATLAB is not very effective. MCSs software stores recorded EGM data in a MathCad (MCD) format, which is then converted to a text file format. These text files are very large, and it is therefore very time consuming to import the EGM data into MATLAB for real-time analysis. Therefore, customized MATLAB software was developed to control the acquisition of data from the MCS DAQ unit, and provide specific laboratory accommodations for this study of SCD. The developed DAQ unit control software will be able to accurately: provide real time display of EGM signals; record and save EGM signals in MATLAB in a desired format; and produce real time analysis of the EGM signals; all through an intuitive GUI. Index Terms— Data Acquisition, Perfused Rabbit Heart, Multichannel EGM, MATLAB, Sudden Cardiac Death, MAT- LAB I. INTRODUCTION To study sudden cardiac death (SCD) using a Lagendorff perfused rabbit heart system, hardware and software needed to be developed. This paper discusses the development of the software required for this study. To acquire electro- gram (EGM) data from the perfused heart a Multichannel Systems (MCS) 32-channel microelectrode array data ac- quisition (DAQ) unit is utilized in conjunction with other developed hardware. MCS provides software through which data acquired by the MCS DAQ unit can be displayed and saved, but this software stores data in a MathCad (MCD) format, which is very time consuming to import into MATLAB for further analysis. In order to provide a more convenient way of storing and accessing the acquired data, and preforming real-time analysis on the data, MATLAB software was developed to control the acquisition of data from the MCS DAQ unit. The development of the MATLAB DAQ software was accomplished through a collaboration between functions offered by MCS, in a dynamic link library (DLL), and orignally produced functions and algorithms. The originally produced functions and algorithms provide: 1) formatting of the recorded data, 2) storage of the formattted data, 3) real-time display and analysis of the data, 4) an intuitive graphical user interface (GUI) through which the entire developed software can be packaged. Rochester Institute of Technology, Biomedical Engineering Department. ∗Corresponding Author: Rochester, 160 Lomb Memorial Drive Rochester, NY 14623-5604. Email: bghoraani@ieee.org II. METHODS In this section, user interface, recording and handling of data, and real-time data display and analysis are discussed. A. Structure of developed GUI Fig. 1. The developed GUI has the ability to adapt the handling of data depending on the selected CHANNELS and MODE as needed by the user. Fig. 1 shows the GUI for the developed software. First, the user selects the GUI parameters, MODE and CHANNELS whose data will have a real time display. Then, Record is selected, and all GUI objects and handles are finalized. The software then initiates operation of the MODE that has been selected, Manual, Automated, or Viewer mode. MCS functions: create necessary DAQ unit objects; check the status of the MCS DAQ unit, whether there is a MCS DAQ unit attached to the computer or not; and initialize FIFO queues. The MCS functions then begin acquisition from the DAQ unit into each channels respective queue. In a continuous loop: a defined amount of data is read from each queue, stored in a Buffer, and is formatted and processed; data from channels that were selected to have a display is then plotted; and heart rate and time elapsed are calculated and displayed on the GUI window. This loop continues until the user has stopped recording, un-toggled the Record button. Once the loop has been terminated, the signal data and other peripheral data, which will be identified later, is stored as an object and saved to a user input filename and directory. B. Data Recording and Handling Fig. 2 is a high level representation of EGM data flow acquired from a perfused rabbit heart through the MCS DAQ unit. The sections, marked with numbers on Fig. 2,
  2. 2. Fig. 2. High level representation of data acquisition control software operation. indicate the main operations, which will be described in the following. Steps 2-4 only show one iteration of data acquisition for one channel, the nth channel. In order to proceed to step 5, steps 1-4 must be completed for all recording channels in the MCS DAQ unit. Multiple iterations of steps 2-6 must be preformed to provide real-time data for display and analysis, because this software creates a continuous signal by appending shorter, subsequent, signals together which are referred to as Buffers. Each subsequent Buffer is a set of data that corresponds to the signal data recorded from the MCS DAQ unit for the resulting amount of time since the last Buffer was produced. B.1) Initialization and Formatting of FIFO Queues: MCS functions are used to create and format a FIFO queue for each channel, and to start acquiring data from the DAQ unit and placing each channels acquired data into its respective queue. FIFO queues are useful for real time display and analysis, because data is stored chronologically; the first data to enter the FIFO queue is the first data to exit. For this software’s purpose, the queues were preallocated with zeroes to a size of 500,000 elements to prevent data from overflowing from the DAQ unit causing a loss of excess data. The sampling rate from the MCS DAQ unit into the queues was set to 2,000 Hz; this rate was chosen, because it is not too high such that the software’s data handling would be slowed down by the large sets of data being processed, but is also not too low such that features of the recorded data are being missed, refer to Nyquist Frequency. For more information about the functions used to preform this operation, refer to MCS DLL [1]. B.2) Reading From FIFO Queues: A specific amount of signal data, 2,000 elements, is read from each channels FIFO queue, in the form of unsigned 16 bit integers (i.e., uint16), and is stored in a Buffer for that channel. This is operation is performed in a serial manner. In a loop, all channels are read sequentially using the MCS function ChannelBlock ReadFramesUI16 [1]. A simple algorithm is used to make the loop wait until enough data is present in the FIFO queue that is being read from before the Buffer is parsed from it. For detailed information refer to ”Reading Data from FIFO Queues” Algorithm below. Algorithm 1: Reading Data from FIFO Queues Given: ChannelBlock ReadFrames: MCS function that returns how much data is in the FIFO queue. Input: Channel: the channel that is being read from. Frequency: rate at which data was sampled from the MCS DAQ unit. Ready = 0; while Ready = 0 do DataAmount = ChannelBlock ReadFrames(Channel); if DataAmount is greater than or equal to Frequency then Ready = 1; end end Output: Proceed to read data from channel’s FIFO queue B.3) Reformatting Buffer: The Buffer produced from pre- vious step is reformatted from uint16 to double (i.e., signed 64 bit integers) format, and the data is gain compensated, so that it is scaled at the level of micro volts using Eq. (1). Buffer = double (Buffer) − 32768 1.5720 (1) The value of 32,768 is subtracted from the Buffer data to correct the data’s zero. Since the data is delivered from the queue in uint16 form, the data ranges between the values 0 and 65,535. To correct the zero of the data, 32,768 must be subtracted so that the new range of the data is from negative 32,768 to positive 32,768. From Eq. (1), 1.5720 is divided from the data to compensate for the gain of the system, this
  3. 3. will be further elaborated upon in the experiment discussion portion of the paper. B.4) Data Storage: Proceeding B.3, depending on the selected MODE the data Buffer is either stored or is not stored. There are three MODEs Manual, Viewer, and Auto- mated (Auto). Manual MODE is used to continuously record data. Viewer MODE is used only to visualize the data, and not record it. Auto MODE utilizes both Manual and Viewer MODEs, Auto-Record and Auto-View respectively, to continuously record multiple trials of data. Manual MODE stores data in a one row array, because only one trial is preformed. Auto-Record stores data in a multiple row array, each row corresponds to the trial number (i.e. the first row is the trials recorded data and the ith row is the ith trial). In Fig. 2, For Manual MODE, 6 iterations of data acquisition have occurred before the latest signal Buffer was appended. In Auto-Record, i trials have been recorded and 6 iterations on the most recent trial had been recorded until the most recent signal Buffer was appended to the ith row of the stored signal. This stored data array, at the termination of the function, for both Auto and Manual MODEs, will be saved in an object format which will also contain: timestamps (ts) for the beginning of each trial, the sampling rate (F) of the recordings, the calculated heart rates (HR) for the recordings, and the time interval (Tint) for each trial. B.5) Data Display and Analysis: Once steps B.1-B.4 have been completed for all the channels, then real time display and analysis of the EGM signals is performed as will be explained in the following. C. Real-Time Display and Analysis of Data C.1) Real-Time Display: The most recent signal buffer pro- duced, the signal buffer for that iteration of data acquisition, is used to plot the signal received for each channel that is selected to be plotted from Channels. Each selected channel is sub plotted on the same MATLAB figure; to optimize the area of plots on the figure for a variable number of plots, conditions were made such that subplots are added to a column until four subplots are in that column. Once there are four subplots in a column any additional subplots are added to the next column. C.2) Real-Time Analysis: The heart rate of the elec- trocardiogram (ECG) signals, derived from EGM, is then calculated with a commonly practiced method; refer to Heart Rate Calculation algorithm. Kurtosis is the measure of the ”peakedness” of a probabil- ity distribution [2]. Kurtosis is greater when there are more infrequent, extreme amplitude, deviations from the mean of a set of data; and vice versa [2]. Therefore kurtosis is used to differentiate between channels experiencing a lot of noise, and channels that arent experiencing a lot of noise. Noise has more frequent deviations from the mean of a set of signal data, therefore its distribution is more Gaussian [2]. An ECG signal has more infrequent deviations from the mean of a set of signal data, therefore its distribution is Super-Gaussian [2]. Only data from one channel is used to calculate heart rate, therefore the channel whose data has the greatest kurtosis is used. Algorithm 2: Heart Rate Calculation Input: ChannelRate: Buffer of channel that was calculated to have the maximum kurtosis of all channels. Frequency: rate at which data was sampled from the MCS DAQ unit. 1) Calculate Daubechie’s wavelet transform of ChannelRate using MATLAB function cwt; 2) Square calculated wavelet transform; 3) Find maximum peak of squared transform; 4) Find all peaks, and if a peak is within a 50 percent thrshold of max then add 1 to number of peaks; 5) Divide length of ChannelRate by frequency to find the time duration of the buffer; 6) Divide number of peaks by time duration; Output: Calculated heart rate Wavelet transforms, of the signal being used to calculate heart rate, are applied to reduce noise of the signal and to furthermore exaggerate the R-peaks of the ECG from the rest of the signal [3], [4]. The following continuous wavelet transform (CWT) equation, Eq. (2 )was used if the form of the MATLAB native function [1], [3]. CWT (a, τ) = 1 √ a s (t) Ψ t − τ a dt (2) In Eq. (2): a is the scaling factor used to strech and compress the mother wavelet (ψ), τ is the translation factor, which translates the mother wavelet along the axis of the signal, and s(t) is the signal [3]. The mother wavelet used to accomplish this wavelet transform was a Daubechies (db10) wavelet [3], [4]. This wavelet was chosen because of its relatable morphology to the ECG waveform. The scaling factor imposed in this wavelet transform was 3, which allowed for QRS extraction from the ECG. Once the signals have been plotted, HR and the time elapsed for the recording has been calculated and displayed on the GUI, the function returns to step 2 on Fig. 2, if Record on the GUI has not been turned off. Throughout the entire process previously described data was continuously being read from the MCS DAQ and added to the FIFO queues. In returning to step 2, the new data that has been added to the FIFO queues must simply be read, and the entire process described is performed again. If Record is turned off the functions stops at the termination of its current iteration of the process described, and saves the data to the user input filename and directory. III. EXPERIMENTS AND RESULTS Three experiments were performed to test the reliability of the data being acquired, and the real-time analysis being preformed through the developed DAQ software: a Delay Test, an MCS software comparison test; and a test of the calculated HR. Delay Test: To investigate delay in signals recorded between different channels a cross correlation (xcorr) analysis was preformed. The results of this xcorr analysis are shown in Fig. 3. The lag positions were calculated using the native MATLAB xcorr function. Lag refers to the amount of displacement of one signal along the time domain required to
  4. 4. be most correlated, synchronized, to another signal. In Fig. 3 an MCS Me/W-SG signal generator was used to produce a 12.5 Hz sinusoid. All of the calculated lag positions were 0, which indicates that all of the signals are lined up on the time domain. 15 trials were preformed on the 12.5 Hz sinusoid, and other generated signals (i.e., ECG, Hippocampal Slice, and other sinusoids), and all trials had the same results. Fig. 3. Delay Test: Test preformed on 12.5 Hz sinusoid. channel numbers are in orange, and calculated lag positions of max correlation between signals are in blue. A signal was only generated on 8 of 32 channels, all of the odd channel numbers from 15-29 including channels 15 and 29. MCS Comparison: The MCS DAQ software, MC Rack, was considered to be the precedent for the developed soft- ware’s acquired data. In this experiment morphology, fre- quency, and amplitude of generated signals acquired through both MATLAB and MC Rack were compared. This experi- ment consisted of 10 trials in which a 1 Hz, 2.0 mV ECG was generated using an MCS Me/W-SG signal generator. The re- sults of one trial are shown in Fig. 4. The signals recorded in Fig. 4 relate to 3 seconds of data, over which both MC Rack and MATLAB had recorded 3 waves resulting in an effective calculated frequency for each signal of 1 Hz. The signals in Fig. 4 have the same frequency and relatable morphology, but the amplitudes of the signal recorded through MATLAB are greater than MC Rack’s. This amplitude difference is a result of a gain discrepancy between the two recording medium. The amplitudes of the signal recorded through the developed MATLAB software were calculated to be a factor of 1.5720 ± 0.0457 greater than the amplitudes produced by MC Rack. To account for gain discrepancy the signal recorded through MATLAB is divided by 1.5720. After gain compensation, both media produce the same signal, therefore the signals recorded through MATLAB are reliable, since the signals recorded through MC Rack are considered reliable. Fig. 4. MCS Comparison: In BLUE is a generated ECG acquired through MATLAB. In RED is the same generated ECG acquired through MC Rack. Signals are out of phase, because they were recorded separately. HR Test: As mentioned earlier, a commonly practiced method is used to calculate HR. However, to test the accuracy of this calculation, the following experiment was preformed. ECG data was acquired from a Langendorff perfused rat heart in which all electrodes were placed relatively in the same location, and data was acquired using MC Rack. Chan- nel 9 was calculated to have the signal with the max kurtosis and channel 25 had the least kurtosis. Fig. 5 shows the recorded signals from the max and min kurtosis channels above and below respectively. Fig. 5 illustrates the impor- tance of using kurtosis; channel 10’s signal is noticeably less noisy, which makes it easier to extract ECG features for a HR calculation. Via manual calculation for channel 10’s signal, there are 25 waves over 5 seconds therefore the HR is 300 beats per minute. Using the developed HR calculation algorithm the output was calculated to be 300 beats per minute, as shown in Fig. 6. Therefore the HR calculation algorithm is accurate. Fig. 5. Above, in RED, is the rat heart ECG signal recorded on channel 9. Below, in GREEN, is the rat heart ECG signal recorded on channel 25. Fig. 6. HR output of the HR calculation algorithm created in MATLAB IV. CONCLUSIONS The developed software is able to accurately: provide real time display of ECG signals; record and save ECG signals in MATLAB in a desired format; and produce real time analysis of the ECG signals; and all through an intuitive GUI. The methodology and process used to achieve these capabilities has been discussed and explained. Important functions and algorithms used within the software have been summarized and provided. The reliability of the signals recorded and real-time analysis preformed through the software has been discussed: there is no delay in recorded signals between dif- ferent channels, the signals recorded through the developed software are equivalent to signals recorded through MCS’s DAQ software, and the HR calculation is accurate. This software provides a more convenient means through which to analyze signals from the MCS DAQ unit in MATLAB, and is an intuitive and useful tool in the laboratory for the real-time analysis, display, and recording of ECG signals. REFERENCES [1] M. Systems, “Mcsusbnet.dll for mcs usb devices,” http://www.multichannelsystems.com/applications. [2] L. Sharma, S. Dandapat, and A. Mahanta, “Kurtosis based multichannel ecg signal denoising and diagnostic distortion measures,” in TENCON 2009-2009 IEEE Region 10 Conference. IEEE, 2009, pp. 1–5. [3] G. Cornelia and R. Romulus, “Ecg signals processing using wavelets,” in IEEE, proceedings of the fifth laserd International conference May, 2005. [4] C. Saritha, V. Sukanya, and Y. N. Murthy, “Ecg signal analysis using wavelet transforms,” Bulg. J. Phys, vol. 35, no. 1, pp. 68–77, 2008.

×