Full text
Final Degree Thesis Development of a Software Application Suite for Electrical Bioimpedance Data Analysis By ALEJANDRO RODRÍGUEZ PORTERO FINAL DEGREE THESIS 30 ECTS, ERASMUS 2009-10 SWEDEN THESIS Nº 1/2010, COMMUNICATION AND SIGNAL PROCESSING
ii Development of a Software Application Suite for Electrical Bioimpedance Data Analysis. Alejandro Rodríguez Portero Master Degree Thesis Subject Category: Medical Technology, Signal Processing University of Borås School of Engineering SE- 501 90 BORAS Phone number: +46 33 435 4640 Examiner: Fernando Seoane Martínez Supervisor: Fernando Seoane Martínez Date: 2010 April 22nd Keywords: Electrical Bioimpedance Spectroscopy, Cole Model, Hook Effect, Signal Analysis.
iii ABSTRACT Measurements of Electrical Bioimpedance (EBI) have been shown to be a valid method for characterising biological tissue non-invasively. The technologies used for implementing this measurement system are relatively simple when compared to other type of medical instrumentation. This has contributed to the proliferation of developing EBI systems but more focused in specific applications than in a generic approach and therefore the available analysis software tools are application specific completely close to user modifications and usually bounded to a specific measurement device. In this thesis an application suite has been implemented enabling the access to several analysis tools. The programming environment has been Matlab and the functions implemented are focused in spectroscopy and Cole model analysis. In order to offer a broad versatility of use to study EBI measurements this software application includes tools for plotting, correcting artefacts, performing Cole fittings, spectral and BIVA analysis.
iv ACKNOWLEDGEMENTS En primer lugar me gustaría agradecer a todas aquellas personas que me han apoyando en todo momento y han estado animándome para que pueda sacar adelante este proyecto con la mayor ilusión y dedicación posibles. Es por ello que primero quiero brindar este momento a toda mi familia. Sobre todo por haber hecho posible que llegue hasta aquí, por ayudarme a poder alcanzar cualquiera de mis metas, escuchándome, animándome, apoyándome, comprendiéndome y siempre respetando cualquiera de mis decisiones. Sin vosotros esto no habría sido posible. También me gustaría agradecer este trabajo a mi novia por estar a mi lado aún en la distancia, animarme y apoyarme durante todo este proyecto, valorando siempre todo lo que he hecho y las decisiones que he tomado. A mis amigos y a mis compañeros por hacer más ameno mi trabajo diario y por hacer que esta sea una de las mejores experiencias de mi vida, tanto a nivel profesional como personal. Y por supuesto agradecer sinceramente a mi supervisor, Dr. Fernando Seoane Martínez, por haber estado en todo momento ayudándome en el desarrollo del proyecto, mostrando su apoyo y dedicación diaria con paciencia y comprensión. Dedicado en especial a toda mi familia. Alejandro Rodríguez Portero
v TABLE OF CONTENTS Abstract ................................................................................................................................... iii Acknowledgements .................................................................................................................. iv Table of Contents ..................................................................................................................... v List of Acronyms ...................................................................................................................... 8 CHAPTER 1. Introduction .................................................................................................... 9 1.1. Introduction ....................................................................................................................... 9 1.2. Motivation .......................................................................................................................... 9 1.3. Goal ..................................................................................................................................... 9 1.4. Work done .......................................................................................................................... 9 1.5. Structure of the Thesis Report ....................................................................................... 10 1.6. Out of Scope ..................................................................................................................... 10 CHAPTER 2. Electrical Bioimpedance Background ......................................................... 11 2.1. Properties of Electrical Bioimpedance .......................................................................... 11 2.1.1. Electrical Bioimpedance definition ............................................................................................. 11 2.1.2. Electrical properties of tissue ...................................................................................................... 11 Cell Electrical Conductance .................................................................................................................. 12 2.1.3. Frequency dependency. The Dispersion Windows ..................................................................... 13 α-dispersion........................................................................................................................................... 14 β-dispersion ........................................................................................................................................... 14 δ-dispersion ........................................................................................................................................... 14 γ-dispersion ........................................................................................................................................... 14 2.1.4. Representing Electrical Bioimpedance (Cole Equation) ............................................................. 15 2.2. Applications of EBI ......................................................................................................... 16 2.2.1. Clinical use of Electrical Bioimpedance ..................................................................................... 16 Body Composition ................................................................................................................................ 16 Hypoxic Cellular Damage ..................................................................................................................... 16 Cancer Screaning .................................................................................................................................. 17 2.2.2. Non-medical applications ........................................................................................................... 17 2.3. EBI Analysis ..................................................................................................................... 18 2.3.1. Body composition ....................................................................................................................... 18 Total Body Water (TBW) ..................................................................................................................... 18 Intracellular Water (ICW) ..................................................................................................................... 19 Extracellular Water (ECW) ................................................................................................................... 19 Fat Free Mass (FFM) ............................................................................................................................ 19 Fat Mass (FM) ...................................................................................................................................... 19 2.3.2. Spectral Features ......................................................................................................................... 19 2.3.4. Bioelectrical Impedance Vector Analysis (BIVA)...................................................................... 19 CHAPTER 3. Electrical Bioimpedance Analysis Suite ...................................................... 21 3.1. Need for Analysis Tools to EBI Data Analysis .............................................................. 21 3.1.1. Artefacts in Measurements ......................................................................................................... 21 3.2. Toolbox ............................................................................................................................. 22
vi 3.3. Graphical User Interface ................................................................................................ 23 CHAPTER 4. Electrical Bioimpedance Analysis Toolbox ................................................ 25 4.1. General Overview ............................................................................................................ 25 4.2. Files Structure.................................................................................................................. 25 4.2.1. Reading tools .............................................................................................................................. 25 4.2.2. Load & Save tools....................................................................................................................... 27 4.3. Graphics Plot tools .......................................................................................................... 29 4.3.1. Frequency plot ............................................................................................................................ 29 4.3.2. Cole plot...................................................................................................................................... 30 4.3.3. Rejection plot .............................................................................................................................. 31 4.4. Preprocessing tools .......................................................................................................... 32 4.4.1. Td Compensation ........................................................................................................................ 33 4.4.2. Correction Function .................................................................................................................... 34 4.4.3. Correction Factor ........................................................................................................................ 35 4.4.4. Mean ........................................................................................................................................... 36 4.4.5. Standard deviation ...................................................................................................................... 37 4.5. Processing tools ................................................................................................................ 37 4.5.1. Cole fitting .................................................................................................................................. 37 RXfit function ....................................................................................................................................... 39 Circular Fit function .............................................................................................................................. 41 4.6. Analysis tools.................................................................................................................... 42 4.6.1. Spectral features .......................................................................................................................... 43 Spectral Centroid .................................................................................................................................. 43 Spectral Rolloff ..................................................................................................................................... 43 Spectral Flux ......................................................................................................................................... 44 Spectral Flatness Measure ..................................................................................................................... 45 Low Short-Time Energy Ratio .............................................................................................................. 46 4.6.2. Impedance Index ......................................................................................................................... 46 4.6.3. BIVA ............................................................................................................................................... 47 CHAPTER 5. GUI Manual ................................................................................................. 48 5.1. Main Panel ....................................................................................................................... 48 5.2. Files management ............................................................................................................ 49 5.2.1. Opening files ............................................................................................................................... 49 5.2.2. Opening a folder ......................................................................................................................... 49 5.2.3. Loading a mat ............................................................................................................................. 50 5.2.4. Save as, Close and Exit ............................................................................................................... 51 5.3. Plotting tools .................................................................................................................... 51 5.3.1. Frequency plot ............................................................................................................................ 51 5.3.2. Cole plot & Rejection plot .......................................................................................................... 52 5.4. Methods for preprocessing ............................................................................................. 52 5.4.1. Correction Function .................................................................................................................... 52 5.4.2. Factor Correction ........................................................................................................................ 53 5.4.3. Td Compensation ........................................................................................................................ 54 5.4.4. Mean & Standard Deviation ....................................................................................................... 54 5.5. Processing ......................................................................................................................... 55 5.5.1. Cole Fitting ................................................................................................................................. 55 5.5.2. Rejection ..................................................................................................................................... 56
vii 5.6. Analysis ............................................................................................................................ 57 5.6.1. Spectral Features ......................................................................................................................... 57 5.6.2. Impedance Index ......................................................................................................................... 58 5.6.3. BIVA .......................................................................................................................................... 59 Evaluation BIVA panel ......................................................................................................................... 59 BIVA application .................................................................................................................................. 60 CHAPTER 6. Discussion ..................................................................................................... 61 CHAPTER 7. Conclusion & Future Work ......................................................................... 62 REFERENCES ...................................................................................................................... 63 APPENDIX ............................................................................................................................ 64
viii LIST OF ACRONYMS EBI - Electrical Bioimpedance BIA - Bioelectrical Impedance Analysis EBIS - Electrical Bioimpedance Spectroscopy GUI - Graphical User Interface TBW - Total Body Water ICW - Intracellular Water ECW - Extracellular Water FFM - Fat Free Mass FM - Fat Mass NLLS - Non-Linear Least Squares BIVA - Bioelectrical Impedance Vector Analysis STE - Short Time Energy LSTE - Low Short Time Energy MIX - Magnitude Index PIX - Phase Index RIX - Real-part Index IMIX - Imaginary-part Index
9 CHAPTER 1. INTRODUCTION 1.1. Introduction Electrical Bioimpedance (EBI) is a measure of the opposition to the flow of electrical charges through biological tissue, and its value depends on the structure and the intrinsic composition of tissue. The electrical properties of tissue depend on its structure and composition. Some changes occur on biological tissue due to pathophysiological processes modifying the electrical properties of tissue and therefore such changes can be detected by measurements of EBI. This project is going to focus in the development of some Matlab tools with the purpose of facilitating the analysis of EBI data obtained through EBI spectroscopy (EBIS) measurements. 1.2. Motivation EBI technology is in constant evolution and several different methods and some spectroscopy instruments have been and are being developed for EBI measurements and analysis. With proper signal analysis methods, EBI measurements could be used as brain monitoring, skin or breath cancer detection between other applications. On the other hand, the EBI instruments have a close analysis software which is limited to the specific task that performs the instrument. The decision of developing a software tool in order to work with EBI measurements was basically focusing in these two statements. 1.3. Goal The main goal of this thesis is to implement a software tool in Matlab for the study of EBIS data. This application should provide a wide range of tools in order to analyze EBI data in the Spectrum domain as well as Cole model analysis. The functions implemented will have the source code open and fully accessible for the user/scientist. The analysis tool will accept EBI data in several formats obtained from several EBI instruments. 1.4. Work done A software tool has been developed using the graphical interface layout tool GUIDE of Matlab. The application is capable to read a wide range of formats and load the read data in a workspace. Several tools have been implemented in the software with different purposes like artifact correction, Cole fitting and EBI spectral data analysis.
16 The value represented by the Cole Equation is complex, with a non-linear relation with the angular frequency. In the impedance plane of Cole plot, a semicircle is represented with the center below the resistance axes; see Figure 2.6. 2.2. Applications of EBI 2.2.1. Clinical use of Electrical Bioimpedance Body Composition Several techniques have been described for assessing body composition in clinical practice but most are invasive, costly and difficult to apply in day to day. EBI non-invasively acquires and evaluates measurements allowing monitoring of hydration status and nutrition, not only in healthy subjects but in certain populations with a determinate pathology. Electrical bioimpedance has a wide range of utilities on a clinical setup. Among many other utilities, are usually measures the body composition of human. The major component of the human body is water. Proteins and fat components are relatively small and the rest are primarily bones and minerals. Hypoxic Cellular Damage The cell has a capacity to achieve a new altered state to preserve its viability when subjected a pathological stimulus or excessive physiological stress. This process acquires the name of cellular adaptation with the peculiarity that when overcomes adaptation limits cell injury occurs. Depending of the duration and severity of the stimuli, cell injury can be irreversible and lead to cell death. Figure 2.6. Impedance spectrum for biological tissue with a depressed semicircle.
17 Actually the most common and important causes of cell injury is hypoxia. This directly impacts to the aerobic oxidative respiration mechanism of the cell, involving oxidative phosphorylation and production of ATP. One of the most common effects of hypoxia is the lost of blood supply known with name of ischaemia, also lead an anemia, the lost of the oxygen-carrying capacity of blood. Different types of cells and tissues react in a different way to hypoxia. Brain tissue is especially vulnerable to lack of oxygen. Thus cells are much more susceptible to hypoxia than most types of cells (Kumar, 2005; Acker and Acker, 2004)( There are 2 important diseases that occur due to hypoxia in brain. Perinatal Asphyxia is the lack of oxygen before, during or after birth. It has a special robustness against hypoxic because of the amount of synapses in the Perinatal brain is smaller, consequently oxygen demand is lower. On the other hand, Brain stroke or also named ischaemic stroke, caused by arterial embolism or thrombosis, causes a reduction of cerebral blood flow thereby hampering oxygen supply, causing hypoxia. During the cellular adaptation and the reversible injury phase, the ionic redistribution in the cellular environment, the accumulation of catabolites in the intracellular space, the cell swelling and the consequent shrinking of the extracellular space modify the conductivity of the intracellular and extracellular fluids, affecting the total impedance of the tissue (Seoane, 2007). Cancer Screaning Cancerous cells presents an increased nucleus to cytoplasm ratio characterised by increased a nuclear size, enlarged nucleoli and irregular chromatin distribution. Flatness along the growth surface and a highly structured brick are presented in cancer cells. One of the most important kinds of cancer is Breast cancer. Moreover the most used method for breast cancer detection is X-ray mammography. However biopsy is needed for a definitive diagnosis. Therefore a new non-invasive method is necessary for detect it. The T-Scan developed by (Assenheimer et al., 2001) and subsequently approved by the Food and Drug Administration. This method can create 2 dimensional maps of Breast cancer through electrical currents at the surface of the mentioned tissue. Changes in tissue impedance are detected using an electrode array. The measured changes are a result of bulk spatial inhomogeneities and may be used to discriminate between various pathological states. 2.2.2. Non-medical applications Other applications with bioimpedance can be used focused to a different target groups. In the 1920 impedance measurements were used for oil exploration by Schlumberger and also are used for monitoring volcanic activity. Fingerprint detection in humans, monitoring of fermentation processes, the study of plant tissue and the estimation of meat quality are some applications used nowadays through bioimpedance measurements.
18 2.3. EBI Analysis Bioelectrical impedance analysis (BIA) is a method which measures the electrical impedance in different tissues of the human body to perform an estimation of the body composition. To achieve it the body is assumed like a cylinder. The electrical properties of the impedance of a conductor depends on the material, shape and orientation respect the electrical field. In case of a cylindrical volume, the resistance of uniform cross sectional area on a homogenous conductive material is proportional to its length and inversely to its cross sectional area (2.5); see Figure 2.7; 𝑅= 𝜌𝐿2 𝐴 [Ω] Equation (2.5) Where R is the resistance, 𝜌 is the resistivity, L is the conductive length and A is the cylinder cross sectional area. 2.3.1. Body composition EBI analysis is a very widespread method for assessment of body composition. There are 5 compartments where are grouped different components of human body. Total Body Water (TBW) The entire amount of water content in human body is defined as TBW. It can be divided in intra (ICW) and extra cellular water (ECW) defined as a new compartments. It‟s used for evaluating basic hydration status. This compartment is part of 60% of human body weight, varying in 40% to 75% depending of the quantity of body fat. 𝑇𝐵𝑊=𝑘𝐻𝑡2 𝑅 Equation (2.6) Figure 2.7. Parameters of a cylinder model for resistance calculate.
19 Where k is a coefficient which matches the real cylinder to the real geometry and it depends on sex, age, weight or other anthropometric values. 𝐻𝑡is the height and R the resistance of the body or segment. Intracellular Water (ICW) As name defines this compartment contents all the water inside human body cells and it represents around 2/3 of the TBW. Extracellular Water (ECW) All the water outside the cells is termed extracellular water and it represents around 1/3 of the TBW. Fat Free Mass (FFM) Also named lean body mass, is referred to the non-fat component of body composition whereas primarily exists as the main structural and functional component of human body. Skeletal muscle, bone and water are all examples of fat-free mass. Fat Mass (FM) This compartment is defined as all the extractable lipids situated in adipose tissue, part of which protects internal organs in the chest and abdomen. Fat mass consists of subcutaneous fat and visceral fat. Subcutaneous fat is located under the skin whereas serve as insulation against col. On the other hand, visceral fat is located deeper within the body and it‟s used as a cushion between organs. Either can serve as energy reserves. 2.3.2. Spectral Features Since impedance is a spectral signal, extraction of features can be used as a method for characterize a biological system. In order to choose spectral features, amongst many others, we have focused on timbale features. These are usually applied for music speech discrimination and speech recognition. The selected ones are detailed below and will be discussed on other chapter. Spectral Centroid Spectral Rolloff Spectral Flux Spectral Flatness Measure Low Short-Time energy Ratio 2.3.4. Bioelectrical Impedance Vector Analysis (BIVA) BIVA is a method for monitoring body fluid variation and body analysis developed by (PICCOLI et al., 2002). An impedance measurement at 50 KHz is considered a bivariate vector Z with two correlated components, resistance (R) and reactance (Xc) resulting a point in the R- Xc plane. This method not depends on assumptions about body geometry. Thus is only affected by the measurement impedance error and the biological viability of suspects.
20 Impedance points are plotted in an RXc graph comparing with the tolerance reference ellipses at 50%, 75% and 95% extracted from the healthy population of the same gender and race; see Figure 2.8. The ellipses may vary depending on age and body size of suspects. An interpretation about the position of vector can be done when the impedance is situated outside the 75% tolerance ellipse. Figure 2.8. BIVA represented with the RXc graph.
21 CHAPTER 3. ELECTRICAL BIOIMPEDANCE ANALYSIS SUITE 3.1. Need for Analysis Tools to EBI Data Analysis Nowadays there are software applications created for the purpose of analysing EBI data. Most often a given application target EBI data obtained with a specific device and/or work for a specific application. In addition the core functions implemented in those limited software applications are completely inaccessible to the user/scientist. A batch processing is a very convenient feature for any EBI data analysis when several spectroscopy EBI measurements have been obtained. Batch processing reduces the time required to perform the EBI analysis. Furthermore the abundance of file formats creates the need to be able to read EBI data from several types of formats. 3.1.1. Artefacts in Measurements Measurement errors might be presented on EBI data and might influence on the data analysis. Very common artifacts presented in measurements are produced by parasite capacitances especially at high frequencies. The Hook Effect is one of the artefacts caused by capacitance at high frequencies and it is identifiable by hook-a-like deviation on the EBI data produced on the impedance plot, the Reactance and Phase (Buendia, 2009); see Figure 3.1. The reason behind the Hook Effect appearing at high frequencies is due to the creation of a current divider by an impedance measurement load in parallel with a parasitic capacitor Figure 3.1. Module of reactance and phase of impedance showing the hook effect.
22 (Buendia, 2009). At low frequencies the parasitic capacitance behaves like an open circuit due to the impedance of the capacitor is very high. The impedance of the capacitor is very low at high frequencies with which the behavior of the current has an opposite effect to previous. 3.2. Toolbox The software is developed in Matlab because this environment offers an easy way to maintain and update the mathematical functions produced in this software application. Moreover the presence of one toolbox in Matlab with many useful algorithms and a high speed of calculation help to implement the functions. The process and functional diagram of the implemented function toolbox is shown in Figure 3.2. The idea of creating an application suite toolbox arises from the need to facilitate access to functions in order to analyze EBI data. Functions can be organized in different categories depending on the actions that get executed. File tools: responsible for reading the EBI data files and create a .mat extension file. This file has different variables, mainly a variable labeled DataArray which contains all the EBI data read from the source files in a third dimensional matrix. Furthermore in this category we implement the loading tool with the purpose of making the data available to be processed or analyzed. Plotting tools: Graphic visualization of the components of EBI is necessary in order to conduct a more comprehensive study about the measurement. The tool allows to choose a set of graphs based on the type of data to plot. Frequency plot, Cole plot and rejection plot are implemented tools in the software application. Preprocessing tools: this category of tools contain all the necessary actions are undertaken in order to correct, if need it, measurement artifacts with three different functions and the calculation of the mean or standard deviation of the file dataset. The tools of the category are focused on removing the effect of capacitive leakage caused by the parasitic capacitance. Fitting tools: the Cole Fitting and the Rejection Cole are the developed functions because of the need to assist the realization of a spectroscopic analysis. Analysis tools: many tools are developed in this category in order to perform the analysis of the measurements of a file dataset contain certain number of files. Moreover the EBI data can be analyzed in the field of frequency, BIVA or Colemodelling.
23 3.3. Graphical User Interface The software is developed in Matlab using the graphical user interface GUI for the programming environment. We choose this way with the purpose of utilizing all the advantages of working in Matlab and ease of handling in the user interface interaction. Consistence appearance and intuitive controls like pushbuttons, slider, list boxes and menus are the very important when designing a graphical Matlab application. However usability methods have been applied for improving the relation within interface-user (Jansen, 1998).The following is show an introduction to the basic elements of the Matlab GUIs. In order to create a Matlab Graphical User Interface three main elements are need. They are detailed below. Components: Pushbuttons, labels and edit boxes are graphical components of Matlab. Composing these elements we can make a division between the components which functionality are graphic controls, statics, menus and axes. First of all, graphical controls and static elements are created by the function uicontrol, and secondly menus are created by the functions uimenu and uicontextmenu. In third place, in order to display graphical data, axes are created through axes functions. Figure 3.2. Scheme with the structure of the toolbox.
24 Figures: A figure is necessary to realize a GUI, basically because figures are the windows where all the components are presented and managed. Empty figures can be created with the function figure and can be used to hold any combination of components. Call-backs: This is the most important component since it produces the function to call a specific function when an event occurs. A mouse click or a key press are type events, and Matlab must respond to each event performing a specific function. This component is the code executed in response to an event is known. For the implementation of a GUI we need the combination of two files, an executable .m and a graphical .fig. The first is developed in order to program all the functions to be executed when a specific event occurs. The second, the figure is where all the components are placed and labelled. Finally both files are joined by call-back subroutines.
25 CHAPTER 4. ELECTRICAL BIOIMPEDANCE ANALYSIS TOOLBOX 4.1. General Overview In this chapter we will detail all the different tools developed in this software application suite, including the functions. These functions have been organized according to the category that they belong to. How to use the software application will be explained in the following chapter 5. 4.2. Files Structure With the use of the functions detailed in this category, the user can proceed to the lecture of the EBI measurements. These measurements are contained in files with different formats as: SFX, MFU, S3B and EDF. Once relevant data is extracted from files, a .mat extension file is created in the application suite workspace with the purpose of any function is capable to perform a faster use of the EBI data. 4.2.1. Reading tools Two functions have been developed for reading files, the first one, named “readfile”, is used for multi-selection of EBI data files; see Code 4.1. And the other, named “readfolder”, is used for reading files through the selection of a folder, which contains several EBI data files. The last function makes possible a batch-processing of the data; see Code 4.2. function[] = readfile(pathoriginal) %Get file with the option Multiselect ON% [x, PATHNAME] = uigetfile({'*.mfu';'*.sfx';'*.s3b';'*.edf'},'Open a file', 'MultiSelect', 'on'); if PATHNAME ~= 0 y = cellstr(x); cd(PATHNAME); numfiles = size(y,2); %Extract the extension and the vector with the namefiles% for i=1:numfiles namesource(i) = y(1,i); temp = char(y(1,i)); [a,b] = size(temp); end for j=1:3 ext(j) = char(temp(1,j+b-3)); end %Extract data from files% if ext == 'mfu' for i=1:numfiles namesource(i) = y(1,i); temp = char(y(1,i)); DataArray(:,:,i) = csvread(temp, 13, 0); DataArray(:,3,i) = -DataArray(:,3,i);
32 parameters are DataArray and namesource. The first one contains the original values and reject EBI data. The second one is a vector with the names of the EBI data files; see Code 4.9. This algorithm is based on the idea of neglecting the correct data from cole fitting using only the values inside the range [𝑅𝑚𝑎𝑥 - 𝑅𝑚𝑖𝑛] and [ 𝑋𝑚𝑎𝑥 - 𝑋𝑚𝑖𝑛]. An iteration of this method is applied until arrange a good quality on the correct data. 4.4. Preprocessing tools In this category the necessary functions for the correction of measurement artefacts are available, the calculation of the mean and standard deviation of a set of read files. As it was explained above there are some methods for correct measurement artifacts. The software focuses on correcting the Hook Effect caused by the parasitic capacitance through three different compensation and correction methods. The three implemented methods are: the 𝑇𝑑 Compensation, Correction Factor and Correction Function. function[] = RejectionPlot(DataArray,namesource) Rmeas = DataArray.DataArraycole.Data_in(:,2); Xmeas = DataArray.DataArraycole.Data_in(:,3); f = DataArray.DataArraycole.Data_in(:,1); RCole = real(DataArray.DataArraycole(1).Impedance(:,1)); XCole = real(DataArray.DataArraycole(1).Impedance(:,1)); RValueMax = DataArray.RValueMax; RValueMin = DataArray.RvalueMin; XValueMax = DataArray.XValueMax; XValueMin = DataArray.XvalueMin; Rrejection = DataArray.Rrejection; Xrejection = DataArray.Xrejection; r2 = DataArray.r2; i2 = DataArray.r2; freq = DataArray.freq; namesource = char(namesource); if DataArray.num == 1 figure('name',namesource); hold on; plot(f,Rmeas,'*'); plot(f,RCole,'g'); plot(f,RValueMax,'r'); plot(f,RValueMin,'y'); hold off; legend('R Original','RCole','RColeValueMax', 'RColeValueMin'); title('Resistance first round'); xlabel('freq(Hz)'); ylabel('R(Ohm)'); figure('name',namesource); hold on; plot(f,Xmeas,'*'); plot(f,XCole,'g'); plot(f,XValueMax,'r'); plot(f,XValueMin,'y'); hold off; legend('X Original','XCole','XColeValueMax', 'XColeValueMin'); title('Reactance first round'); xlabel('freq(Hz)'); ylabel('X(Ohm)'); ... Code 4.7. Code for Cole rejection plotting “RejectionPlot”.
33 4.4.1. Td Compensation This function compensates the Hook Effect in the module of the impedance through multiplying the measured EBI data by a complex exponential; see Code 4.10. 𝑍𝑐𝑜𝑟𝑟 𝜔 = 𝑍𝑚𝑒𝑎𝑠 𝜔 ∗𝑒−𝑗𝜔𝑇𝑑 Equation (4.1) Where Zcorr ω is the corrected impedance, Zmeas ω is the measured impedance and e−jωTd is the exponential factor which uses the scalar Time Delay Td. Equation (4.1) has been used for develop the code for the Td compensation. The input parameters are the main variables contained in a .mat extension file and the string variable Td which contains the value of the correction factor. The code extracts the resistance and reactance data from the variable DataArray and then it applies the equation (4.1). The code detailed above is used for applying an automatic Td compensation through calling the same function five times for each value of Td. Another function which is called “Tdfactormanual” has been developed in order to apply a manual Td compensation. function[namefile,pathtemp] = Tdfactor(DataArray,ext,namefile,namesource, pathsourcefile,type,tracing,Td) switch Td case '1ns' td = 1E-9; case '5ns' td = 5E-9; case '10ns' td = 10E-9; case '15ns' td = 15E-9; case '20ns' td = 20E-9; end for i=1:numfiles %Number of files for j=1:rows %Number of rows Rmeas(j,i) = DataArray(j,2,i); Xmeas(j,i) = DataArray(j,3,i); Zmeas(j,i) = Rmeas(j,i)+(sqrt(-1)*Xmeas(j,i)); Ymeas(j,i) = 1./Zmeas(j,i); Smeas(j,i) = imag(Ymeas(j,i)); Wmeas(j,i) = 2*pi*(DataArray(j,1,i))*1000; end end for i=1:numfiles %Number of files for j=1:rows Zfactor(j,i) = Zmeas(j,i)*exp(-(sqrt(-1)*Wmeas(j,i)*td)); Rfactor(j,i) = real(Zfactor(j,i)); DataArray(j,2,i) = Rfactor(j,i); Yfactor(j,i) = 1./Zfactor(j,i); Xfactor(j,i) = imag(Zfactor(j,i)); DataArray(j,3,i) = Xfactor(j,i); end end Code 4.8. Code for the algorithm of Td “Tdfactor”.
34 4.4.2. Correction Function A code for the correction function, named “Fcorrection” has been implemented with the purpose of correcting the EBI data for all the frequency range; see Code 4.11. The input parameters are the main variables of the loaded file adding two new, which are introduced by the user. These variables receive the name of Fmin and Fmax in order to use correction function in a desired frequency range. function[namefile,pathtemp]=Fcorrection(DataArray,ext,namefile,namesource, pathsourcefile,type,tracing,Fmin,Fmax) type = 'preprocessing'; tracing = strcat(tracing,' + Fcorrection'); numfiles = size(DataArray,3); [rows,columns] = size(DataArray); for i=1:numfiles %Number of files for j=1:rows %Number of rows Rmeas(j,i) = DataArray(j,2,i); Xmeas(j,i) = DataArray(j,3,i); Zmeas(j,i) = Rmeas(j,i)+(sqrt(-1)*Xmeas(j,i)); Ymeas(j,i) = 1./Zmeas(j,i); Smeas(j,i) = imag(Ymeas(j,i)); Wmeas(j,i) = 2*pi*(DataArray(j,1,i))*1000; end end for i=1:numfiles %Number of files %Choose start and final samples for linealize N = frecrow(Fmin,rows,DataArray); M = frecrow(Fmax,rows,DataArray); for j=N:M Smeascorr(j-N+1,i) = Smeas(j,i); Wmeascorr(j-N+1,i) = Wmeas(j,i); if j==M y = polyfit(Wmeascorr(:,i),Smeascorr(:,i),1); Cstray(i) = y(1); end end for j=1:rows Fcorr(j,i)=(log(1-(sqrt(-1)*Wmeas(j,i)*Cstray(i)*Zmeas(j,i))))./(sqrt(-1)* Wmeas(j,i)); Tdcorr(j,i) = real(Fcorr(j,i)); Zcorr(j,i) = Zmeas(j,i)*exp(-(sqrt(-1)*Wmeas(j,i)*Fcorr(j,i))); Rcorr(j,i) = real(Zcorr(j,i)); DataArray(j,2,i) = Rcorr(j,i); Xcorr(j,i) = imag(Zcorr(j,i)); DataArray(j,3,i) = Xcorr(j,i); Ycorr(j,i) = 1./Zcorr(j,i); Scorr(j,i) = imag(Ycorr(j,i)); end end fmin = num2str(Fmin); fmax = num2str(Fmax); pathtemp = strcat(pathsourcefile,'\',type,'\Fcorrection',' (',fmin,'-',fmax,')'); mkdir(pathtemp); cd(pathtemp); save(namefile,'DataArray','namesource','ext','type','namefile','pathsourcefile','tr acing'); Code 4.9. Code for the correction function “Fcorrection”.
35 First of all the code updates all the parameters and subsequently saves in new variables all the data from the .mat extension file. Next another loop is used calling the developed function “frecrow” which finds the position number of a frequency inside the matrix DataArray. Later the code proceeds to estimate the parasitic capacitance Cstray through the Matlab function “polyfit”. This function is used only at high frequencies and creates a polynomial of a desired degree, in our case first degree. Moreover the function extracts the slope of the polynomial coinciding with the value of Cstray. 𝐶𝑠𝑡𝑟𝑎𝑦 = 𝐼𝑚 𝑆𝑚𝑒𝑎𝑠 𝜔 |𝜔→∞ 𝜔 Equation (4.2) Once is estimated the value of the parasitic capacitance we can proceed with the construction of the function correction as is detailed in the next equation. 𝐹𝑐𝑜𝑟𝑟 𝜔 = 𝑙𝑜𝑔 1−𝑗𝜔𝐶𝑠𝑡𝑟𝑎𝑦𝑍𝑚𝑒𝑎𝑠(𝜔) 𝑗𝜔 Equation (4.3) Where 𝐹𝑐𝑜𝑟𝑟 𝜔 is the Correction Function, 𝜔 is the frequency in radians, the parasitic capacitance 𝐶𝑠𝑡𝑟𝑎𝑦 (4.2), and finally 𝑍𝑚𝑒𝑎𝑠 𝜔 is the measured impedance. Finally all the variables are saved in a new .mat extension file inside the folder pathtemp. It contains the vector DataArray with the corrected values of resistance and reactance. 4.4.3. Correction Factor For developing this function we have used the correction function for a specific frequency introduced by the user. The code uses the same method for estimating the correction Function with the exception that the correction is applied only for a single frequency; see figure 4.12. function[namefile,pathtemp] = Ffactor(DataArray,ext,namefile,namesource, pathsourcefile,type,tracing,Freq) for i=1:numfiles %Number of files for j=1:rows %Number of rows Rmeas(j,i) = DataArray(j,2,i); Xmeas(j,i) = DataArray(j,3,i); Zmeas(j,i) = Rmeas(j,i)+(sqrt(-1)*Xmeas(j,i)); Ymeas(j,i) = 1./Zmeas(j,i); Smeas(j,i) = imag(Ymeas(j,i)); Fmeas(j,i) = DataArray(j,1,i); Wmeas(j,i) = 2*pi*(DataArray(j,1,i))*1000; end end
36 4.4.4. Mean The purpose of this code is to calculate the mean of a number of data files. First of all the code initialize three vectors and later calculates the mean through the Matlab function called “mean”; see Code 4.13. for i=1:numfiles %Number of files %Choose start and final samples for linealize N = frecrow(Fmeas(1,i),rows,DataArray); M = frecrow(Fmeas(rows,i),rows,DataArray); for j=N:M Smeascorr(j-N+1,i) = Smeas(j,i); Wmeascorr(j-N+1,i) = Wmeas(j,i); if j==M y = polyfit(Wmeascorr(:,i),Smeascorr(:,i),1); Cstray(i) = y(1); end end for j=1:rows Fcorr(j,i) = (log(1-(sqrt(-1)*Wmeas(j,i)*Cstray(i)*Zmeas(j,i)))) ./(sqrt(-1)*Wmeas(j,i)); end for j=1:rows Tdcorr(j,i) = real(Fcorr(N,i)); Zcorr(j,i) = Zmeas(j,i)*exp(-(sqrt(-1)*Wmeas(j,i)*Fcorr(N,i))); Rcorr(j,i) = real(Zcorr(j,i)); DataArray(j,2,i) = Rcorr(j,i); Xcorr(j,i) = imag(Zcorr(j,i)); DataArray(j,3,i) = Xcorr(j,i); Ycorr(j,i) = 1./Zcorr(j,i); Scorr(j,i) = imag(Ycorr(j,i)); end end function[namefile,pathtemp] = DataMean(DataArray,ext,namefile, namesource,pathsourcefile,type,tracing) type = 'preprocessing'; tracing = strcat(tracing,' + Data Mean'); [rows,columns] = size(DataArray); meanfrec = zeros(1,length(DataArray(:,1,1)))'; meanresi = zeros(1,length(DataArray(:,1,1)))'; meanreact = zeros(1,length(DataArray(:,1,1)))'; for i=1:1:rows Mean.meanfrec(i) = mean(DataArray(i,1,:)); Mean.meanresi(i) = mean(DataArray(i,2,:)); Mean.meanreact(i) = mean(DataArray(i,3,:)); end clear('DataArray'); DataArray(:,1) = Mean.meanfrec(:); DataArray(:,2) = Mean.meanresi(:); DataArray(:,3) = Mean.meanreact(:); Code 4.10. Code for the function “Ffactor”. Code 4.11. Code for the function “DataMean”.
37 4.4.5. Standard deviation This function is similar to the previously explained function. The structure and the input variables are the same; see Code 4.14. This Code calculates the standard deviation for all the files contained in DataArray through the Matlab function “std”. 4.5. Processing tools This point will detail the selected methods for developing the code of Cole fitting and rejection cole functions. 4.5.1. Cole fitting This tool is implemented in the code of the function named “Fitting_planes” which calculates a fitted theoretical curve in four different models; see Code 4.15. Three of these models are developed by the function RXfit and the other in Circularfit. This function was developed by (Ayllón et al., 2009). function[namefile,pathtemp] = DataMean(DataArray,ext,namefile, namesource,pathsourcefile,type,tracing) type = 'preprocessing'; tracing = strcat(tracing,' + Data Stdev'); [rows,columns] = size(DataArray); stdevfreq=zeros(1,length(DataArray(:,1,1)))'; stdevresi=zeros(1,length(DataArray(:,1,1)))'; stdevreact=zeros(1,length(DataArray(:,1,1)))'; for i=1:1:rows Stdev.stdevfreq(i) = DataArray(i,1,1); Stdev.stdevresi(i) = std(DataArray(i,2,:)); Stdev.stdevreact(i) = std(DataArray(i,3,:)); end clear('DataArray'); DataArray(:,1) = Stdev.stdevfreq(:); DataArray(:,2) = Stdev.stdevresi(:); DataArray(:,3) = Stdev.stdevreact(:); Code 4.12. Code for the function “Stdev”. function [DataArray]= Fitting_planes(finput,Rmeas,Xmeas,displayON,If_freq_range,Arrayfreq,namesource) if(If_freq_range==1) A=Arrayfreq'; low_f_limit=min(A); % selecting frequency range to use in the fitting. high_f_limit=max(A); for i=1:length(finput) % eliminates the low frequencies if finput(i) >= low_f_limit flow_Index = i; break else flow_Index = 1; end end
38 for j=1:length(finput)% eliminates the high frequencies if finput(j) >= high_f_limit fhigh_Index = j-1; break else fhigh_Index = j; end end % Resize arrays with the frequency limits zn=Rmeas+sqrt(-1)*Xmeas; Rmeas_lim=Rmeas(flow_Index:fhigh_Index); Xmeas_lim=Xmeas(flow_Index:fhigh_Index); zn=Rmeas_lim+sqrt(-1)*Xmeas_lim; Rdata=real(zn); Xdata=-imag(zn); f=finput(flow_Index:fhigh_Index); %new frequency array else zn = Rmeas + sqrt(-1)*Xmeas; Rdata = real(zn); Xdata = -imag(zn); f=finput; end %Estimate starting values startingVals = coleStartValues2(zn,f); %calculate fittings (in 4 different planes) [coefZ,rmseZ,sseZ,Zest] = Circularfit(f,zn); [cfR,gnR,outR,cfX,gnX,outX,cfRX,gnRX,outRX]=RXfit(f,Rdata,Xdata, startingVals, displayON,Zest,namesource); %coeficients estimated coefR=[cfR.a, cfR.b, cfR.c, cfR.d]; %Fitting in R-w plane coefX=[cfX.a, cfX.b, cfX.c, cfX.d]; %Fitting in X-w plane coefRX=[cfRX.a, cfRX.b, cfRX.c, cfRX.d]; %Fitting in R+X-w plane coef=[coefR;coefX;coefRX;coefZ]; coefM=mean(coef); zcoleR= coefR(2) + (coefR(1)-coefR(2))./(1+(sqrt(-1)*f*coefR(3)).^coefR(4)); zcoleX= coefX(2) + (coefX(1)-coefX(2))./(1+(sqrt(-1)*f*coefX(3)).^coefX(4)); zcoleRX= coefRX(2) + (coefRX(1)-coefRX(2))./(1+(sqrt(-1)*f*coefRX(3)).^coefRX(4)); zcoleZ= coefZ(2) + (coefZ(1)-coefZ(2))./(1+(sqrt(-1)*f*coefZ(3)).^coefZ(4)); fcR=1/coefR(3)/2/pi; %coef(3)= tau fcX=1/coefX(3)/2/pi; fcRX=1/coefRX(3)/2/pi; fcZ=1/coefZ(3)/2/pi; if displayON==1 figure; hold on; plot(Rdata, Xdata, '*') %cole with real data plot(real(zcoleR), -imag(zcoleR), 'r') %cole with parameter estimated from R plot(real(zcoleX), -imag(zcoleX), 'og') %cole with parameter estimated from X plot(real(zcoleRX), -imag(zcoleRX), '*y') %cole with parameter estimated from R+X plot(real(zcoleZ), -imag(zcoleZ), 'm') %cole with parameter estimated from R+X hold off legend('Real Cole','Estimated Cole from R','Estimated Cole from X','Estimated Cole from R+X', 'Estimated Cole from Z') title('Cole function estimation') xlabel('R') ylabel('-X') end DataArray.Coefs(1,:) = [coefR(1), coefR(2), coefR(3), coefR(4)]; DataArray.Coefs(2,:) = [coefX(1), coefX(2), coefX(3), coefX(4)]; DataArray.Coefs(3,:) = [coefRX(1), coefRX(2), coefRX(3), coefRX(4)]; DataArray.Coefs(4,:) = [coefZ(1), coefZ(2), coefZ(3),coefZ(4)]; DataArray.Coefs(5,:) = [coefM(1), coefM(2), coefM(3), coefM(4)]; DataArray.Impedance = [zcoleR,zcoleX,zcoleRX,zcoleZ]; DataArray.CentralFreqs = [fcR,fcX,fcRX,fcZ]; DataArray.Data_in(:,1) = finput; DataArray.Data_in(:,2) = Rmeas; DataArray.Data_in(:,3) = Xmeas; Code 4.13. Code for “Fitting_planes” function.
39 The first three input parameters of the function are designed to introduce the desired EBI data for applying the cole fitting. Furthermore the user/scientist can choose a frequency range giving the value true “1” to the variable If_freq_range and introducing the desired range in the vector Arrayfreq = [fmin,fmax] situated in the header of the function. Another variable which is called display_ON is used with the purpose of plotting the different fitting models. The output structure of the function DataArray contains the characteristic Cole coefficients, the impedance estimation and the central frequencies for each plane. Moreover the original values are stored with the frequency, resistance and reactance. The first lines of code have been developed in order to establish a frequency range for the fitting. Later the impedance vectors are reconverted for the selected range of frequency. The sign of the reactance Xdata was changed to make the Cole plots concave. Two important functions are used in this code for calculating the four fitting models. Three models are implemented in “RXfit” function and the other in “Cirularfit” function. Another function which is called “ColeStartValues2” is used in order to calculate the initial values of the “RXfit” function. This function presents some problems due to the performance of the Matlab function fit. These problems are further detailed in the thesis of (Ayllón et al., 2009). RXfit function This function is responsible for fitting the EBI data to the R(ω), jX(ω) and R(ω) + jX(ω) models. These models have been calculated using the equations (4.4) and (4.5) and applying the Non-Linear Least Squares (NLLS) method. Further information about the performance of these methods can be found in the (Ayllón et al., 2009). 𝑅 𝜔 =𝑅∞+ 𝑅0−𝑅∞ 1 + 𝜔𝜏 𝛼cos 𝛼𝜋 2 1 + 2 𝜔𝜏 𝛼cos 𝛼𝜋 2 + 𝜔𝜏 2𝛼 Equation (4.4) 𝑋 𝜔 =−𝑗+ R0−R∞ ωτ αsin(απ 2) 1 + 2 ωτ αcos απ 2 + ωτ 2α Equation (4.5) The input parameters of this function are, respectively, the EBI data variables (w, Rdata and Xdata), st_ which is referred to the starting values and is extracted from the “StartingValues2” function, displayON acquires the value true “1” in case of displaying a Cole plot and finally Zest which is the estimation of the impedance and belongs to the “Circularfit” function which is detailed next. The output variables are the four Cole coefficients (R0, R∞, τ and α) referred to each plane. These coefficients are contained in the variables cfR, cfX and cfRX; see Code 4.16.
40 function [cfR,goodnessR,outputR,cfX,goodnessX,outputX,cfRX,goodnessRX,outputRX] = RXfit(w,Rdata,Xdata, st_, displayON,Zest,namesource) RXdata = Rdata + Xdata; if displayON==1 namesource=char(namesource); f_ = figure('name',namesource); set(f_,'Units','Pixels','Position',[-3 35 1280 642]); xlim_ = [Inf -Inf]; % limits of x axis ax_ = axes; set(ax_,'Units','normalized','OuterPosition',[0 0 1 1]); set(ax_,'Box','on'); axes(ax_); hold on; % --- Plot data originally in dataset "Rdata vs. w" w = w(:); Rdata = Rdata(:); h_ = line(w,Rdata,'Parent',ax_,'Color','y','LineStyle','-', 'LineWidth',1,'Marker','o', 'MarkerSize',12); xlim_(1) = min(xlim_(1),min(w)); xlim_(2) = max(xlim_(2),max(w)); % --- Plot data originally in dataset "Xdata vs. w" Xdata = Xdata(:); h_ = line(w,Xdata,'Parent',ax_,'Color','r', 'LineStyle','-', 'LineWidth',1,'Marker','x', 'MarkerSize',12); xlim_(1) = min(xlim_(1),min(w)); xlim_(2) = max(xlim_(2),max(w)); % --- Plot data originally in dataset "RXdata vs. w" RXdata = RXdata(:); h_ = line(w,RXdata,'Parent',ax_,'Color','m', 'LineStyle','-', 'LineWidth',1,'Marker','x', 'MarkerSize',12); xlim_(1) = min(xlim_(1),min(w)); xlim_(2) = max(xlim_(2),max(w)); % --- Plot data originally in dataset "Zdata vs. w" Zdata= Rdata(:)-sqrt(-1)*Xdata(:); plot(w,Zdata,'Parent',ax_,'Color','b', 'LineStyle','-', 'LineWidth',1,'Marker','*', 'MarkerSize',12); xlim_(1) = min(xlim_(1),min(w)); xlim_(2) = max(xlim_(2),max(w)); % Nudge axis limits beyond data limits if all(isfinite(xlim_)) xlim_ = xlim_ + [-1 1] * 0.01 * diff(xlim_); set(ax_,'XLim',xlim_) end end % FITTING taumax=1.5*st_(3); romax=1.5*st_(1); rimax=1.5*st_(2); fo_ = fitoptions('method','NonlinearLeastSquares','MaxFunEvals', 6000,'MaxIter', 400,'Lower',[0 0 0 0.5 ], 'Upper', [romax rimax taumax 1]); %limit values ok_ = ~(isnan(w) | isnan(Rdata)); set(fo_,'Startpoint',st_); %Fit model R fitModelR = fittype('b + ((a-b)+(ab)*cos(d*pi/2)*(w*c)^d)/(1+2*cos(d*pi/2)*(w*c)^d+(w*c)^(2*d))',... 'dependent',{'Rfit'},'independent',{'w'},... 'coefficients',{'a', 'b', 'c', 'd'}); %Fit model X fitModelX= fittype('((ab)*sin(d*pi/2)*(w*c)^d)/(1+2*cos(d*pi/2)*(w*c)^d+(w*c)^(2*d))',... 'dependent',{'Xfit'},'independent',{'w'},... 'coefficients',{'a', 'b', 'c', 'd'}); %Fit model R+X fitModelRX= fittype('b + ((a-b)+(ab)*cos(d*pi/2)*(w*c)^d)/(1+2*cos(d*pi/2)*(w*c)^d+(w*c)^(2*d))+((ab)*sin(d*pi/2)*(w*c)^d)/(1+2*cos(d*pi/2)*(w*c)^d+(w*c)^(2*d))',... 'dependent',{'RXfit'},'independent',{'w'},... 'coefficients',{'a', 'b', 'c', 'd'});
41 Circular Fit function This function is responsible for fitting the EBI data in the impedance plane considering that the Cole plot is a perfect semicircle with the centre depressed below the resistance axis and estimates its complex centre and radius by an approach based in a geometrical fitting to obtaining a complex centre C and radius R that produces a set of semicircular points which its variance of its squared distance to each point from the measurement set is minimum. This function is detailed with more properly in the thesis of (Ayllón et al., 2009). We are going to talk about the main content of the code. First of all the code calculates the frequency central for subsequently call the function “CentroRadio”. The last function calculates the centre C and radius R of the semicircle; see Code 4.17. With these variables we can proceed to estimate the coefficients using the next equations. Code 4.14. Matlab code of “RXfit” function. % R Fitting [cfR,goodnessR,outputR,warnstr,errstr,convmsg]=fit(w(ok_),Rdata(ok_),fitModelR,fo_); if displayON==1 % Plot R fit h_ = plot(cfR,'fit',0.95); legend off; % turn off legend from plot method call set(h_(1),'Color','g', 'LineStyle','-', 'LineWidth',2,'Marker','none', 'MarkerSize',6); end % X Fitting ok_ = ~(isnan(w) | isnan(Xdata)); [cfX,goodnessX,outputX] = fit(w(ok_),Xdata(ok_),fitModelX,fo_); if displayON==1 % Plot X fit h_ = plot(cfX,'fit',0.95); legend off; % turn off legend from plot method call set(h_(1),'Color','y','LineStyle','-', 'LineWidth',2,'Marker','none', 'MarkerSize',6); end %R+X Fitting ok_ = ~(isnan(w) | isnan(RXdata)); [cfRX,goodnessRX,outputRX] = fit(w(ok_),RXdata(ok_),fitModelRX,fo_); if displayON==1 % Plot R+X fit h_ = plot(cfRX,'fit',0.95); legend off; % turn off legend from plot method call set(h_(1),'Color','k','LineStyle','-', 'LineWidth',2,'Marker','none', 'MarkerSize',6); end %Z Fitting if displayON==1 % Plot Z fit plot(w,Zest,'Color','r','LineStyle','-', 'LineWidth',2,'Marker','none', 'MarkerSize',8); legend off; % turn off legend from plot method call hold off; title (' Z data fitting') LEGEND('R data', 'X data', 'R+X data', 'Z data','R fit', 'X fit', 'R+X fit','Zfit') end
48 CHAPTER 5. GUI MANUAL 5.1. Main Panel Main Panel is the first window displayed when the GUI program file is executed; see Figure 5.1. This panel has been developed in order to improve the user-interface interaction, providing access to all functions through labels that are located on the top of the main window. From here, the user can manage the complete application and visualize the parameters of loaded files. The figure shows the labels where different tools are grouped according to the type of process to which they belong. On the other hand, the main panel has shown parameters that are referred to the loaded file through the function “Load” in the submenu “File”. These parameters are detailed below. Name: name of the loaded .mat extension file. Number of files: number of EBI data files contained in the .mat extension loaded file. Type: depending on the kind of process, the .mat extension file can acquire different types labelled as read, preprocessing, cole-processing and reject-processing. Extension: this parameter is referred to the extension of the sources EBI data files. Tracing: during the data processing process of the .mat extension file data, different functions are applied. This property shows all the applied methods orderly. Path: as its name suggest, this parameter shows the path of the loaded .mat extension file. Figure 5.1. Main panel
49 5.2. Files management Under the label named “File” on the horizontal toolbar it is possible to find the application functions responsible for reading, loading, saving and closing files. In order to do any measurement or data processing it is necessary to read a measurement file or load a .mat extension file containing the data from a measurement files. Such Matlab file to be loaded with the function Load has been previously created with the function Open File, also under the File Menu. Currently, the file formats for EBI measurements accepted by the application are: sfx, mfu, s3b and edf. The last one only can be used for BIVA application as defined by (Ibáñez and Seoane, 2008). Two different ways of reading may be possible in this software. Exists the possibility of use multiselect read or realize a lecture of an entire folder. Therefore a .mat extension file is saved with different variables as DataArray which contains the values of EBI measurements and others variables like sourcepath, namesource, type, etc... 5.2.1. Opening files Clicking on the function Open File will show a window that gives the user the possibility to choose the files to be read. The selection mode accepts multiselection in order to make a lecture of one or more files. These files must be located in the same folder and share the same source file extension. A .mat extension file is saved with the read EBI data after selecting the desired reading files. The default behaviour of the software consists on creating a new folder placed in the current project path, named “Workspace\Measurements\read” with the purpose of saving the .mat extension file extension. In any case, the user has the possibility to select any path for saving the file; see Figure 5.2. After a successful measurement file reading, an information box will appear with the message “File read successfully”. If this message fails to appear, make sure that the reading files are in the correct format. 5.2.2. Opening a folder With the use of this tool, the user has opportunity to read a great quantity of EBI data files situated in a folder attainment. This function “Open Folder” can help in order to realize a batchprocessing analysis due to the abundant quantity of read EBI data files resulting from the taking of spectroscopy measurement. First of all, make sure the target folder only contains another folders or EBI data files which types are accepted by the application. Clicking on the tool, the software ask us about the desired folder to read and just after the path for save. The default behaviour of the software consists on create a recommended folder situated in the current project path which is named “Workspace\Measurements\”. The application will create a .mat extension file for each folder found which contains EBI data files. The .mat extension file
50 acquires a named referred to the name of the read folder. Finally all the resulting extension files are stored in the default folder preserving the original folder structure; see Figure 5.2. A box is shown during the lecture with the message “Wait for reading...” consecutively appears a box with the message “All files have been read successfully” when the reading process is finished. In the case that this message doesn‟t appear, you could have the same error that has been commented in the previous point or maybe exists an incorrect files contained in the folder. 5.2.3. Loading a mat The application asks us about the desired extension file for load after clicking on the function “Load” inside the label “File”. After a file is loaded will be seen on the main panel the parameters associated to the extension file. This file is stored in a temporal directory named “Temp” contained in the workspace. This folder has been created with the aim that all functions share the same load file and thus can prevent possible directory errors. Moreover as can be seen, depending on the type of loaded file some labels are activated while others remain off. Make sure that the desired file for apply a method is loaded through the preview of all the parameters shown in the main window. Figure 5.2. Folder structure of Open file function.
51 5.2.4. Save as, Close and Exit These functions are developed with the purpose of saving or closing the loaded extension file from the application at any time of use. Exit is used to close the application through a warning message. 5.3. Plotting tools In this tab we can find a wide range of tools designed to show different types of plots. Furthermore these graphs make use of all the functionalities of Matlab that are not detailed in this manual and can be very useful when analyzing a graph. 5.3.1. Frequency plot This tool has been developed in the pursuit of representing a plot of immitance components as a function of frequency. Moreover is possible to draw, at the same time, graphs which come from different EBI data files with the purpose of drawing an analogy between them. The names of the displayed EBI data files are shown in the plot panel and in the labels of the graphs windows; see Figure 5.3. Figure 5.3. Frequency plot panel
52 Activating the check box will appear a window displaying the plot of the desired parameter. With the button “Clear” the user will delete all the plotted graphs. Make sure that the type of the loaded file is read or preprocessing. During the use of the software, this panel can appears in order to help you to choose some parameters needed for apply corrections on the measurements. 5.3.2. Cole plot & Rejection plot This tool is similar at the previous with the particularity that only can be used by loaded files which type is processing-cole or processing-reject. A slider has been developed with the purpose of choosing the desired file for plotting. Three action buttons are displayed in the main panel; see Figure 5.4. With the button “Clear” the user proceeds to delete all the shown graphs, clicking on the “Plot” button the desired plot of the selected file is displayed. Finally the button “Exit” closes the tool. 5.4. Methods for preprocessing All the correction tools have been developed with the purpose of eliminating the Hook effect and are included inside this label together with two tools designed for calculate the mean and the standard deviation of a set of files. Anyway all of these tools can be used only for files which type is preprocessing or read. 5.4.1. Correction Function A new panel is opened after clicking on the function. This tool is used for correct the artifacts produced by the parasitic capacitance, better known as hook effect. At the same time the frequency plot panel is displayed in order to know exactly the frequency range where the hook effect is present. Figure 5.4. Cole Plot panel
53 Once the frequency range is detected, the user will introduce the values of minimum and maximum frequency in the panel in KHz. The allowed range values of frequency are shown in the panel depending on the frequency range available in the EBI data files; see Figure 5.5. Clicking on the “Start” button, the user will apply the function correction to all the EBI data contained in the loaded extension file. Finally a message with the saving address of the resulting file is shown. The file is saved in the path that the original file was located, adding two new folders which are “\preprocessing\Fcorrection (Fmin-Fmax)\”. 5.4.2. Factor Correction Also this function has been developed with the purpose of deleting the hook effect. As well as the frequency plot panel is shown in order to detect the frequency value which starts to take effect the parasitic impedance. Figure 5.5. Correction Function panel Figure 5.6. Factor Correction Panel
54 After clicking on the tool, a panel is shown asking for the desired frequency for calculate the Function Factor in KHz; see Figure 5.6. When “Start” button is pressed the correction will apply to the loaded file. A message box appears later showing the saved path. The destiny is common to all functions of preprocessing, adding to the original path the descriptive folders “\preprocessing\Ffactor(Freq)\”. 5.4.3. Td Compensation This is the last tool designed with the purpose of correcting the hook effect. A different panel appears together the frequency plot panel after clicking on the tool. This function corrects the data in two different ways. Clicking on the “Automatic” button the software corrects the data using the following values of Td: 1, 5, 10, 15, 20ns. Moreover, the user can choose a value of Td introducing it in the panel and after clicking on the “Manual” button. All the values are saved preserving the same folder structure which consists of adding the descriptive folders “\preprocessing\Tdfactor\” in the original path. 5.4.4. Mean & Standard Deviation This functions are implemented for calculate the mean and the standard deviation of EBI data. As result of this treatment only one file is saved on the extension file because of the mean or the standard deviation is calculated for all the files included in the source .mat extension file. When the user calls this kind of tools, a similar panel is opened only with two buttons; see Figure 5.8. One is used for proceed to calculate the desired factor “Yes” and the other is for exit the application “No”. Figure 5.7. Td Compensation Panel
55 As all the different tools in this category, a message box with the information about the saved path is shown. The default adding path is “\preprocessing\Mean\” or “\preprocessing\Stdev\”. 5.5. Processing The functions incorporated in this category are used with the purpose of obtaining the Cole Fitting and the Rejection Cole parameters of the EBI loaded data. A batch processing of all the files belonging to the loaded extension file can be possible. The supported types are read or preprocessing. 5.5.1. Cole Fitting The panel ask to the user if a frequency range is necessary through a text box. In case of activate the check box, the frequency plot panel appears in order to choose exactly the desired range for Cole Fitting; see Figure 5.9. Figure 5.8. Mean panel Figure 5.9. Cole Fitting panel
56 The values of minimum and maximum frequency should be introduced before clicking on the “Start” button. Also is possible to use the function without a range. Depending on the frequency selection of Cole Fitting a different file is obtained. If the user chooses a frequency values, the software saves the file in the adding path “\processingcole\ColeFitting\With range(Fmin-Fmax)\” otherwise the file will be saved on “\processingcole\ColeFitting\Without range\”. This function can fail depending on the number of files and the quality of the measurements. Concretely the error is committed by the function “fit” contained in the toolbox of Matlab. In that case, a message appears warning of this error. Otherwise a message is shown with the destiny path when the file is saved correctly. 5.5.2. Rejection This panel was developed in order to apply the Cole Rejection to the EBI measurements. Moreover this function accepts a batch processing, with the particularity that only the cole rejection is applied only one time during the batch processing due to the problems with the standard Matlab function “fit”. Otherwise the user can choose the number of rejections in a range of one to five. The utilization of the interface is very simple because of the user only has to introduce the rejection value and click on the button “Start”; see Figure 5.10. This function uses the cole fitting function as the main code. Therefore an error can appear as a result of using the function “fit” contained in the cole fitting function. In that case, a message appears warning of this error. Otherwise a message is shown with the destiny path when the file is saved named with the format of “\processing-reject\Cole Rejection (Number_of_rejects- Value#)”. Figure 5.10. Cole Rejection panel
57 5.6. Analysis Four tools have been designed in order to make a faster analysis of many EBI data files at the same time. With the use of these tools the user can realize a frequency and cole analysis through an extraction of parameters. 5.6.1. Spectral Features The accepted type files for the use of this tool are read or preprocessing. A study of a wide range of immitance parameters on the EBI measurements can be done. The panel shows all the parameters inside edit texts corresponding to the labels on the left. A pop-up menu is shown with the purpose of choosing the kind of immitance components in order to proceed for the calculation of their parameters. The desired file for the analysis can be Figure 5.11. Spectral Features panel
64 APPENDIX In order to run the implemented software, the user has the possibility to select two alternatives. The first one is through the general use of Matlab, in this case the user has to open the folder project and run the script on the file with .m extension called “start.m”. The folder project is located in the folder called “EBI_suite (files)”. The second alternative has been implemented with the purpose of running the software in a computer without a Matlab installation. For running the application, the user has to open the folder called “EBI_suite (exe)”. Inside this folder there are two subfolders. One of them is called “src” which contains the source files of the software. And the other folder called “distrib” which contains the executable file, called “EBI_suite.exe” and a file package with the Matlab runtime compiler in “EBI_suite_pkg.exe”. For the installation of the Matlab library, the user must proceed running the executable package file named “EBI_suite_pkg.exe”. After that, a MS-DOS screen will appear asking for replacing certain files and after allowing the operation the compiler is installed. After that the suite can be started running the file “EBI_suite.exe”.