Close
About
FAQ
Home
Collections
Login
USC Login
Register
0
Selected
Invert selection
Deselect all
Deselect all
Click here to refresh results
Click here to refresh results
USC
/
Digital Library
/
University of Southern California Dissertations and Theses
/
Cross-correlation methods for quantification of nonlinear input-output transformations of enural systems using a Poisson random test input
(USC Thesis Other)
Cross-correlation methods for quantification of nonlinear input-output transformations of enural systems using a Poisson random test input
PDF
Download
Share
Open document
Flip pages
Contact Us
Contact Us
Copy asset link
Request this asset
Transcript (if available)
Content
CROSS-CORRELATION METHODS FOR QUANTIFICATION OF NONLINEAR INPUT-OUTPUT TRANSFORMATIONS OF NEURAL SYSTEMS USING A POISSON RANDOM TEST INPUT by W illiam Anthony Searinge A thesis presented to the FA CU LTY O F TH E SC H O O L OF EN G IN EER IN G of the UN IV ERSITY O F SO U TH ERN CA LIFO R N IA in partial fulfillment of the requirements for the degree of M ASTER OF SCIENCE IN BIO M ED IC A L EN G IN EERIN G August 1W5 Copyright 1SW5 by W illiam Anthony Searinge This thesis, written by k l i l i i a s r i S c a r i s . under the guidance of )n'\&Faculty Committee and approved by all its members, has been presented to and accepted by the School of Engineering in partial fulfillment of the re quirements for the degree of M a s J e c S c y & n c e . m B t B r y q w e e n r u ^ K / d J q . S ......... [•'acuity C ijh m itte e To June, Zachary, and Timmy. ii A C 'K N O W L K IX fK M K N T S I gratefully acknowledge the valuable input and support of Dr. l et! Berger and Dr. Vasilis Marmarelis, my advisors. W e spent many interesting and fruitful hours discussing the methods and issues presented in this paper . I thank the other graduate students and post-doctoral researchers in Dr. Berger’s lab for listening to me think aloud about this research and offering stimulating comments. I acknowledge Brian Dowry for helping with the code to interface with Neuroscope, our data collection software. I especially thank my wife. Jane, for supporting this endeavor. In addition to her love and encouragement, she also offered writing style suggestions which helped with readability. CONTENTS I . INTRODUCTION........................................................................................................I 1.1 Objective............................................................................, ................................. I 1.2 Background......................................................................................................... 2 1. 2 . 1 The System Functional and System Identification...............................2 1.2.2 External M o d e ls.................................................................................................2 1.2.3 Event Input S ystem s........................................................................................ 1 1.2.4 Output Data O p tio n s........................................................................................1 1.2.5 Functional Power Series (E P S ).................................................................. 4 1.2.0 The Volterra Functional Power Series.......................................................4 1.2.7 Orthogonal Functional Power S e rie s ........................................................ 5 1.2.X The Poisson Random Event Sequence (PRES) In p u t.......................5 1.22) The Poisson Orthogonal Series ( P O S ) .....................................................h 1.2.10 Quantifying the Input-Output Transform ation....................................... 7 1.3 Summary............................................................................................................... 7 2 . THE DISCRETE TIME VOI.TERRA SERIES (DVS) REPRESENTATION FOR EVENT INPUT SY STEM S...................... II 2.1 Kernel Symmetry............................................................................................12 2 .2 Interval Notation............................................................................................13 2 .3 DVS Completeness........................................................................................14 2 .4 Discrete Event Input Systems.................................................................14 2.4.1 Discrete Input Representation......................................................................14 2.4.2 DVS Kernel Interpretation......................................................................... 15 2.4.3 DVS Kernel D iagonals................................................................................If> 3 . THE DISCRETE TIME POISSON OKTHOCONAL SERIES (l)POS) REPRESENTATION FOR EVENT INPUT SYSTEMS. .1 7 ' 3 . 1 Orthogonality................................................................................................... 17 3 .2 The Poisson Random Event Sequence (PRES) Test Input. . 17 3 .3 The Discrete Poisson Orthogonal Series (DPOS)........................ IK IV 4 . ESTIMATING THE DPOS KERNELS.........................................................19 4. I The Cross-correlation M ethod............................................................19 4 .2 The DPOS Kernel Formula....................................................................20 5. THE RELATIONSHIP BETWEEN DPOS AND DVS KERNELS.............................................................................2 1 5.1 Relation of Cross-correlation to the D V S......................................2 1 5.1.1 E xplanation......................................................................................................22 5.2 Relation Between DPOS and DVS Kernels....................................2 4 5 .5 Conditions for Approximate DPOS-DVS Kernel Equality . . 25 5.5.1 The Event Probability is S m a ll................................................................ 25 5.5.2 Contaminated Data is Not U s e d ...............................................................27 5 .5.5 Average Values of Actual DVS Kernels are S m a ll.............................2X 6 . PRACTICAL CROSS-CORRELATION ESTIMATION.....................29 6.1 Cross-correlation Algorithm for the PRES Test Input 50 6 .2 Interstimulus Interval (ISI) Input Representation.................... 51 6 .5 Estimation Errors to be C orrected.....................................................52 6.5.1 Variation of Instance Count About the M e a n ......................................55 6 .5.2 Systematic Instance Count Decrease...................................................... 55 6.5.5 Correction.........................................................................................................54 6 .4 Practical DPOS Kernel Form ula.........................................................54 6 .5 Estimation Errors that do Not Require Correction..................55 6 .6 Estimating the Mean Test Duration...................................................56 6.6.1 Reducing the Test Duration by B inning ................................................56 6 .6 .2 Mean Test Duration Form ulas.................................................................. 56 v 7 . A OFNKRAL MKTHOI) FOR KSTIMATINO THK DVS KKRNFLS........................................................................................... 4 8 7.1 A (ienerul Sequential M ethod.............................................................. 4(1 7.1.1 Formula for Sequential Kernel Estim ation..........................................40 7.1.2 Formulated as a Linear Set of E quations............................................. 42 7.1.4 The Cross-correlation V ector...................................................................44 7 .2 Effect of Small Kvent Probabilities....................................................44 X. niFFKKKNCKS BETWEEN DPOS AND DVS KERNELS DEMONSTRATED BY SIMULATION.......................................................45 X .l Simulating a Second Order System................................................... 45 8 .2 The Actual DVS Kernels of the Simulated System.................. 46 8 .4 Simulation Parameters ....4 8 8.4 R esu lts...............................................................................................................48 X.4.1 First Order Kernel R esu lts........................................................................ 4K X.4.2 Second Order Kernel R esults................................................................... 51 «>. C O N C L U S IO N ......................................................................................................57 B IB L IO O R A P H Y ......................................................................................................... 6 1 vi APFKNDK KS APPKNIHX A: DKRIVATION OF THK DISCKKTK TIMK FOISSON ORTHOOONAL SKRIKS (I)FOS).................................63 APPKNDIX B: DKRIVATION OF THK FORMULA FOR KSTIMATINO THK DISCKKTK TIMK FOISSON ORTHOCONAL SKRIKS (DPOS) KKKNKLS BY CROSS-CORK FLAT I O N .....................................................7S AFFKNDIX C: DKRIVATION OF THK RKLATIONSHIPS BKTWKKN INPUT-OUTPUT CROSS- CORRKLATIONS AND THK DVS KKKNKLS 9.1 AFFKNDIX I): COMPIJTKK PROGRAMS IN C FOR KKKNKL KSTIMATION AND SYSTKM SIMULATION . . . I« I I). I Kernel Kstimation.......................................................................................101 D. I . I kernels d p n s .c ............................................................................................ 101 D. 1.2 kernel d e fs .h ................................................................................................ 124 D. 1.3 n d s j t e f s . h .......................................................................................................124 D. 1.4 read data.c.......................................................................................................125 D. 1.5 get isis.c .......................................................................................................... 132 D. 1.6 nscope util.c................................................................................................... 134 I).2 System Simu‘ " 146 D.2.1 sim .c................................................................................................................. 146 D.2.2 sini util.c........................................................................................................ 155 VII 6 FIOFKFS Figure I: Estimated P' Order DPOS Kernel vs. Hvent Rate for C — ( I .......................................................................................................... 4N Figure 2: Estimated P! Order DPOS Kernel vs. Fvent Rate for ( ’ = 5 m V ..................................................................................................40 Figure 3: Estimated 2'"1 Order DPOS Kernel and Delta Histogram for R = 0.2 H z ...................................................................................52 Figure 4: Estimated 2"'1 Order DPOS Kernel and Delta Histogram for R = 2 H z........................................................................................53 Figure 5: Estimated 21 1 ,1 Order DPOS Kernel and Delta Histogram for R = 5 H z ........................................................................................54 Figure ft: Estimated 2 "1 1 Order DPOS Kernel and l>elta Histogram for R = 10 H z .................................................................................... 55 Figure 7: Aetual 2"‘' Order DVS Kernel.............................................................................. 5ft viii ABSTRACT Wi- show that input-output cross-correlation cun identity the nonlinear input-output transformation of a system hy estimating the kernels of the Discrete Volterra Series (DVS). The DVS kernels have a simple interpretation and provide a useful characterization of the system nonlinearities. W e present two complementary m ethods for computing the DVS kernels. The first method uses the formula for the Discrete Poisson Orthogonal Series (DPOS) kernels. W e derive the DPOS hy orthogonulizing the DVS for the Poisson Random hvent Sequence (PRPS) test input. Although we show that the DPOS kernels contain com ponents involving all the DVS kernels, we also show that we can isolate a single DVS kernel if at least one of three conditions is satisfied. The second method is a general method that involves solving a set of simultaneous linear equations to isolate each DVS kernel from other system nonlinearities. W e use simulations to demonstrate our theoretical results. IX 1. INTRODUCTION 1.1 Objective The genera) objective of this research is to develop and compare methods for quantifying the nonlinear input-output transformation of an unknown system. The specific objective of this paper is to investigate methods bused on cross correlation of input-output data for systems whose inputs are sequences of discrete events. Although the methods we develop are general, we describe them by using exam ples from the field of Neuroscience. 1.2 Background 1.2.1 The System Functional and System Identification The input-output transformation of a system is called the "system functional" 113,17.231 . The problem of estimating the system functional from input-output data is called the “system identification" problem. Here, we investigate system identification methods that are based on cross correlation of input-output data. W e derive the estimation formulas for these methods, offer intuitive interpretations of the results, and cover issues involved in practical implementation. 1.2.2 Kxternal Models The system functional is also called an “external model" since it does not explicitly model the underlying physical processes of the system. This feature is a major advantage; the accuracy of this representation does not depend on hypotheses about unknown processes. An external model can accurately characterize the input- output transformation of a system even if we have only a poor understanding of its inner workings. Thus, one use of an external model is as a system characterization tool that quantifies the linear and nonlinear functional properties of the system in terms of a dynamic nonlinear input-output transformation (e.g., as for the catfish retina 110-12|, for muscle receptors [ 151 , for the somatosensory system 11X|, or for the hippocampal formation 111). A second use of an external model is in combination with analytical and experimental nonlinear system decomposition techniques to characterize parts of the system that are difficult to observe experimentally (e.g., interneurons in the hippocampal formation |2,4,20|). A third use of an external model is as an efficient model for simulating the system since it can extract the essential functional properties of the system into an efficient mathematical representation. 1.2.3 Kvent Input Systems In this paper, we investigate solutions to the system identification problem for systems whose inputs can he m odeled as sequences of identical discrete events. In this case, the information in the input signal is the timing of the events, not the detailed structure of each event. For neural systems, the classic event is the action potential. For event input systems, the nonlinearities of the system are manifested in the synergistic effects of multiple events. For example, the second order nonlinearity describes the change in the system response to a given input event due to the m em ory of the system for a previous event. An example of this synergistic effect in neural systems is the comm on phenomenon of paired pulse facilitation |3|. 1.2.4 Output Data Options The output data used for system identification can be continuously sampled data or discrete events'. For example, suppose the input events to a neural system are current pulses applied to an afferent bundle of axons". Then, for the output data, we can use the continuously sampled m em brane potential measured intracellulurly at the soma of an efferent neuron, or we could extract the firing events of the neuron. If we are interested in a population of neurons, we could continuously sample the extracellular field potential or extract the population spike amplitude Because we want the most com plete characterization of the system, we use continuously sampled output data in this paper. We can always extract discrete events from this continuous representation but not vice-versa. 1.2.5 Functional Power Series (FPS) The system identification methods investigated here use a functional power series (FPS), a universal function approxim ator, to represent the nonlinear system functional. A FPS is a generalization of static series like the Taylor series | 17 1 . W hile a Taylor series can only represent a static function, a FPS can also represent a dynamic function. A FPS is a series of dynam ic terms called functionals. Kach functional is a function of a kernel. The kernels are the descriptors of the linear and nonlinear dynam ics of the system. Thus, the system identification problem boils dow n to estimating the kernels. 1.2.6 The Vollerra Functional Power Series The Volterra FPS 12 2 1 is a useful FPS for quantifying the nonlinear input- output transformation of a system since each term in the series represents an isolated order of nonlineurity. For discrete event input systems, the Volterru kernels have a particularly simple and useful interpretation. The first order kernel specifies the average response to a single input event, the second order kernel specifies the average change in the response due to the synergistic effects of pairs of input events, the third order kernel specifies the average change in the response due to the synergistic effects of triplets of input events, etc. Thus, the Volterra FPS quantifies the input-output transformation of the system in terms of the memory of the system lor past events and the synergistic effects of multiple events in a seq ue nee. 1.2.7 Orthogonal Functional Power Series The advantages of an orthogonal FPS representation are well known: an orthogonal FPS truncated to the J 1 ' order is guaranteed to provide the best J 1 1 ' order fit to the actual system functional1 ' ; the kernels of an orthogonal FPS can he isolated hy cross-correlation with instrumental functionals of the input |K|; and additional higher order terms can be added sequentially to the series to reduce the estimation error without changing the lower order kernels which have already been computed. Although the functionals of the Volterra FPS are not generally orthogonal, they can be orthogonalim i using the Gram-Schm idt orthogonalization procedure. However, because the functionals depend on the input, they must be orthogonalized for the specific statistics of the input. I.2.K The Poisson Random Fvent Sequence (PRKS) Input To identify a system, we must probe it with a test input that spans the range of relevant inputs. However, we usually do not know all the relevant inputs. In this case, we must probe the system with a broad range of possible inputs. One 4 might consider probing the system systematically with various inputs. However, to avoid bias in the choice of inputs, a random input is preferred. A random input can be thought of as a series of inputs by imagining it divided into segments of duration equal to the memory of the system. An important property of a random input is that any two samples are statistically independent. This property facilitates system identification hy a cross-correlation procedure |X|, For the identification of continuous input nonlinear systems, several investigators have used a continuous white noise test input |X -15.22,231. I'or the identification of discrete event input systems, a Poisson random sequence of events has been suggested and used as the random test input J5 -7 ,16 , Id,2 1 1 . We also use this discrete event input and we call it the Poisson Random Fvent Sequence (PRFS) test input. 1.2.9 The Poisson Orthogonal Series (POS) Krausz and Sclabassi [5-ft. IX-19,211 applied the continuous theory of Volterra to discrete event input systems by using Dirac-delta functions1 to represent the input events and orthogonalizing the Volterra FPS for the PRKS test input. We call this orthogonalized series the Poisson Orthogonal Series (POS). Ogura and Kroeker |7 ,lh | developed a more general method for representing the system functional of event input systems with a FPS of orthogonal Poisson-Charlier functionals. In their m ethod, the input is divided into nonoverlapping time bins and the number of events that occur in each bin is represented by the values of a Poisson random v a r i a b l e 'T h e output is also represented as a sequence of values of a random variable. The output random variable represents either the number of events in successive time bins of the output or samples of the continuous output. The limiting case where the time bins become short enough so that they can contain no more than one event is a special case of the Poisson-Pharlier series of Ogura and Kroeker ((). & K.) that is equivalent to the POS of Krausz and Sciubaxsi (K. & S.). The special case of K. & S. should be used when preserving the exact timing of each event is desired. The general case of O. & K. is useful for reducing the computational burden when the exact timing of individual events is less important (e.g., as they recede into the past). Here, we follow the approach of K. & S., but use a discrete time derivation to develop a Discrete Poisson Orthogonal Series (DPOS). From the general method of O. & K., we borrow the concept of binning which we use (in a different way) to reduce the computational and data requirements. 1.2.10 Quantifying the Input-Outpul Transformation The Volterra FPS. rather than an orthogonalized FPS, should be used to quantify the nonlinear functional properties of a system for two important reasons: ( I ) its kernels have a simple interpretation which makes them useful for characterizing the nonlinearities of a system, and (2) the kernels of the Volterra FPS are invariant with respect to the test input statistics. An orthogonalized FI’S has neither of these properties. Because the functionals of the Volterra FPS are not generally orthogonal, cross-correlation of input-output data will not isolate the kernels. Here, we present two complimentary methods for estimating the Volterra kernels for an event input system . ft 1.3 Summary Section 2 presents a discrete time version of the Volterra theory. We call the discrete time version of the Volterra FPS the Discrete Time Volterra Series (DVS). Then. Section 3 and Appendix A orthogonalize the DVS for the PRES test input. W e call this orthogonalized series the Discrete Time Poisson Orthogonal Series (DPOS), Section 4 and Appendix B derive the formulas for estimating the DPOS kernels hy cross-correlating output data with input data. Our derivations in discrete tune are different in several ways from those of K raus/ |5 | and Sclabassi [2 11 in continuous time. First, our derivations are more direct since we use the actual test input, not a demeaned test input. This direct approach does not make our derivations unduly lengthy since we make use of a special notation and a general relationship that we develop at the outset. Second, the discrete time analysis is more easily related to practical experimentation'". Third, our derivations are more complete since we give the general formulas for a DPOS representation up to any order. Fourth, our results for discrete time are slightly different than those of Krausz and Sclabassi for continuous time. Section 5 and Appendix ( ' derive the relationship between input-output cross-correlation and the DV S kernels. W e find that cross-correlation gives a result which contains a term involving each and every order of nonlinearity that occurs in the system. The magnitude of each term is proportional to the input event probability raised to a power equal to the order of nonlinearity. Our result is analogous to that found by Murmarelis |S>) for continuous input systems probed with a white noise test input. In the continuous input case, the difference between the kernels of the orthogonalized series (the W iener series) and the Volterra FPS depends on the white noise power. The input event probability in the discrete case 7 is analogous to the white noise power in the continuous case. In the discrete case, however, the input event probability m ust always be less than one. Using this tact, we show that the nonlinear com ponents become less significant with increasing order of nonlinearity. Section 5 shows that the DPOS kernels are fundamentally different from the DVS kernels. Any DPOS kernel will contain components involving all the actual DVS kernels of the system. However, Section S also shows that if at least one of three conditions is satisfied, then the DPOS kernels are approximately equal to the DVS kernels: ( I ) the event probability of the PRES test input is small enough so that the higher order nonlinearities will be insignificant, (2) only output data that is not contam inated by higher order nonlinearities is used in the cross-correlation estimate, or (3) the average of each higher order nonlinearity is insignificant. Section (> presents an algorithm for practical estimation of input-output cross-correlations. It gives a modification to the theoretical formula that com pensates for variations in the num ber of instances of a particular event sequence as a function of the event intervals of the sequence. Section 6 also gives a formula for relating mean lest duration, event probability, and estimation variance' Finally, Section 6 describes the technique of binning which reduces the test duration required for a given event probability and estimation variance. Section 7 concludes our consideration of the cross-correlation method for DVS kernel estimation by presenting a general method for computing the DVS kernels that does not assum e any of the conditions listed above. This method requires that the unknown system be probed with multiple PRES test inputs with different input event probabilities. By using test inputs with J different event probabilities, we can com pute the DVS kernels up to the J"’ order and compensate each kernel estimate for contamination hy higher order system nonlinearities up to the J th order. The method involves solving a set of sim ultaneous linear equations to isolate each DVS kernel from other system nonlinearities of order less than or equal to J. Section 8 uses simulations to show the similarity and difference between the DPOS and DV S kernels when the conditions listed above are and are not satisfied. Simulated data is generated for a simple second order system and used to compute the first and second order DPOS kernels. The computed first order DPOS kernel is com pared to the actual first order DVS kernel. The difference is clearly shown to depend 011 the event probability of the test input and 011 the shape of the actual second order DVS kernel. The simulations also demonstrate the tradeoffs involved in the choice of test input event probability. The discrete events would he extracted from the continuous res|mnsc. " Assume the pulse amplitude is huge enough to initiate action potentials in the axons. A population spike is a discrete response event that provides a measure of the number o f cells in a imputation that fired in response to the most recent stimulus event | ld|. ' In the mean squared error sense. The functionals of ;ui orthogonal FPS are onhogonali/ed lor the specific statistics of the lest input and will not he orthogonal for ;ui input with different statistics. Thus, the best fit advantage of the orthogonal series may not be* realized in practice. ' Also known as impulses. 1 1 Also called the Poisson random measure. For example, in the continuous time analysis. Kraus/ and Sclabassi jure forced to use (he Dirac della (unction to represent input events. The Dirac-della function is a mathematical entity that can not exist in the real world and may be a diff icult concept to grasp for those not well versed in its theory Hie formula is jriven in terms of the number o f instances of a p;irticul;u event sequence instead of Ihc estimation v;uiancc. Specifying Ihe number of instances used in the cross-correlation estimate is a way ol specilvilli* the variance ol the estimate since ihc variance is inversely proportional In ihc number of insbuiccs. HI 2. THK DISLRKTK TIMK VOLTKKKA SKRIKS (l)VS) RKPRKSKNTATION FOR KVKNT INPUT SYSTKMS Volterra showed that we can represent the system functional of a nonlinear system by a functional power series expansion' |2 2 |. Here, we are interested in discrete event input systems. Therefore, we will use a discrete time version of the Volterra FPS which we call the Discrete Time Volterra Series (DVS). The DVS through order J is y(n) = k, + £ k , ( m ) x ( n - m ) ih + ^ ^ k ,(m,,m, )x(n - m, )x(n - 111.) HI | 111 i + X X Z ' t | ( m l’m " m 1))((ii - m,)x(n - m,)x(n - m , ) (2- 1) fn, in , m t + L - 2 > i ( m , m . M n - m , ) • x ( n - m , ) 111 | HI , which can be written more compactly as y(") = i X " X ki(m> - • ’m,)nx(n - m,) (2-2) t = U m , ill ( i - 1 where x(n) and y(n) are the n th samples of the system input and output, respectively, and the function k j i n , , m j is the j'1 ' order DVS kernel. 2.1 Kernel Symmetry A kernel is symmetrical if and only if its value is the same for any permutation of its indices. W e will denote kernels that must be symmetrical by a superscript s. W hen the kernels are symmetrical, we take advantage of the symmetry hy restricting the summations in the DVS to one symmetric part and then multiplying hy the num ber of symmetric parts. For the j'1 ' order functional of (2- I ), we restrict the summations to one symmetric part hy sum m ing only over the region where m < m , < * < m W e use this ordering (instead of the opposite) so that a larger subscript represents an input farther into the past with respect to a given response sample at n. W e multiply the restricted j'1 ' order functional by j! w hich is the num ber of symmetric parts. 2.2 Interval Notation It is convenient to represent the intervals between consecutive indices m and m ltl as symmetric region, we sum over the region where all A, are positive. Using this notation, the DVS is A, = in, t — m, (2-3) and to replace in, with m |1K|. Thus, instead of the indices |m , , m , , ..., m ,}. we will sometimes use the indices jm .A , A i }. Then, to sum only over one + b ^ l^ ^ rk",(m,At, A, )x{n - m )x(n - m - A, )x{n - m - A, - A , ) (2-4) m \, A , v,)n m A. A. . i=l m A, A, , x n - m - j A h h -1 / which can he written more compactly as m A, A,, x n - in - 52 A„ V where k '(m , A , , .... A M ) is a shorthand notation for the j"’ order D V S kernel ilefi ned hy = k ^(m >",)■ 2.3 DVS ( ’nmpleteness '[’he terms in the DVS are called DVS functionals and each term represents a particular order of nonlinearity of the system. The j o r d e r functional is the j1 1 ’ DVS kernels are the descriptors of the linear and nonlinear dynamics of the system. the simple case where the system functional is linear, only the first order kernel will be non-zero and the DVS reduces to the familial linear convolution integral. For a linear system, knowing the first order kernel allows us to determine the exact output for any given input. For a nonlinear system, the "com plete" set of DVS kernels must be known to lie able to determine the exact output. The complete set of kernels is the set through the actual order of the system functional. In practice, however, using only the first few kernels in the series will often provide a reasonable approximation of the system functional. order convolution of the input with the j ,h order kernel. In this representation, the Specifically, the j1 '1 order kernel describes the j'1 ' order dynam ics of the system. In 13 2.4 Discrete Fvent Input Systems 2.4.1 Discrete Input Representation For the special case of identical discrete event input systems, the information in the input signal is the timing of the events, not the detailed structure of each event. In our analytical derivations, we use the Kronecker-delta function to mark the time of an input event. An event at sample number n, (at time n,T where T is the sampling period) is represented by b(n - n ) where the Kronecker-delta function S(n) is defined by This representation is equivalent to a binary discrete time input where a value of I represents the occurrence of an event. It is the discrete time analog of the continuous time Dirac-delta function used by Krausz |5 | and Sclabassi (21). This mathematical impulse function is only a representation of the timing of the input events, not the events themselves. It is not necessary to assum e that an action potential is approximated by a mathematical impulse function and we do not make this assumption. 2.4.2 1)VS Kernel Interpretation For discrete event input systems, the DVS kernels have a simple interpretation: the first order kernel specifies the average response to a single input event, the second order kernel specifies the average change in the response due to the synergistic effects of pairs of input events, the third order kernel specifies the average change in the response due to the synergistic effects of triplets of input events, etc. Thus, the DVS kernels describe the system nonlinearities in terms of (2-7 > 14 the interaction between input events. This simple interpretation makes the DVS kernels ideal tor characterization o f the system nonlinearities and is a major advantage of the DVS over othogonalized series whose kernels do not have this interpretation. 2.4.3 DVS Kernel Diagonals With the above interpretation of the DVS kernels in mind, consider the meaning of the diagonal values. If each kernel index represents the time of occurrence of one input event, then cases where any two indices are the same (the kernel diagonals) represent cases where two events occur at the same time. In practice, however, two input events can not occur at the same time. Therefore, we can only consider the kernel diagonals to represent the contributions of an input event amplitude raised to a power equal to the number of identical kernel indices, fo r example, when m = m, = m , in (2-1), the second order functional reduces to ^ k ( m, 1 1 1 )x (n - m ) and the kernel diagonal is seen to represent the contribution ■it of the input event amplitude squared. However, because the input events are assumed to be identical and are represented by an input sample value of I, we do not need to account for any nonlinear response of the system to changing event amplitude. Thus, we can ignore the kernel diagonals. Mathematically, we can show that the kernel diagonal values will be redundant with lower order kernels since I, the input sample value that marks an event, raised to any pow er is still I. Using our example, we see that since x(n) can only be I) or 1, then x ’{n) = x(n). Therefore, k ,( m ,m ) x J(n - in) = ^ k , ( m , m ) x ( n - m) and we see that k ,(m .m ) is r N pit 15 redundant witli the lower order kernel k,(m ). For u mathematical argument in continuous time theory for ignoring the kernel diagonals, the reader may consult Krausz |5 |. In the following derivations, we assum e that the input events are identical. Thus, we define the kernel diagonal values to be zero. In some applications, however, it may be desirable to model the input events as having a variable amplitude. To account for the effects of the changing event amplitude in those ; cations, the derivations herein would have to be modified to include the kernel diagonals. Strictly speaking, the Volterra series expansion exists only it the system functional is analytic (which, however, is the case tor any real system) and it the series converges. See Marmarelis j 1 t| lor live specific conditions of convergence. 55 3. THE DISCRETE TIME POISSON ORTHOGONAL SERIES (l)POS) REPRESENTATION FOR EVENT INPUT SYSTEMS In this section, we use the Gram-Schm idt orthogonalizution procedure to orthogonalize the DVS for the Poisson random event sequence (PRES) test input to obtain the Discrete Time Poisson Orthogonal Series (DPOS). .Cl Orthogonality Two functionals are orthogonal when their inner'-product, defined as the expected value of their product over the sample index (i.e., the covariance), is zero. We use the nverhar notation to indicate the expected value taken over the sample index 1 1. .1.2 The Poi.s.son Random Event Sequence (PRES) Test Input W e define the samples of the PRES test input as independent samples of a binary random variable X such that fl with probability X I X = . <3-1) [0 with probability (1 - A.)J where a value of 1 represents the occurrence of an input event. Thus, the mean event rate of the PRES test input, which we will denote by R, is R = \ t; (3-2) where f is the data sampling frequency. The j lh order moment of this random variable is given by X 7 = ( I ) ,A . + (U),{ I - * .) = *. for j>l. (3-3) The orthogonalization procedure will make extensive use of two properties of the PRES test input: different input samples are statistically independent and all 17 the moments have the same value, X . Thus, the expected value of the product of any num ber of input samples is just X raised to the num ber of different input samples in the product. 3.3 The Discrete Poisson Orthogonal Series (DPOS) In Appendix A, we use the above listed properties of the PRES test input to derive the DPOS up through arbitrary order ,!: S I y(n) = p,. + £ p {m )|x(n - m) - X| in I M VI + £ ^ ' ( m , , ! ! ! , )[x(n - in, )x(n - m , ) - 2Xx(n - m , ) + X ] M S I M + ill | - 1 m , = I ill , - I x(n - m, )x(n - in ,)x(n - m ,) -3X x(n - m, )x(n - 111,) +3X x(n - m ,) - X( (3-4) + 2 - 5>H'”i mi ) z f . \ i .... i i. \ J n } , i i, ■ I m l w hich can Ik* written more com p actly as y(»>= X X 5Lp.(m' — m .) X i-< i m, = 1 m = I li =1 1 t h (— X) 1~J x(n - m , } (3-4) where p^ is the symmetric j"' order kernel of the DPOS, as defined in Appendix A, and x(n) and y(n) are the system input and output, respectively. The notation / J U j - h indicates the binomial coefficient and ,i ~ h. ( j - h ) ! h! (3-5) IK 4. KSTIMATINtJ THK l)POS KKKNKLS 4.1 The C ross-correlation Method T o solve the system identification problem for the DPOS representation, we need a method for estimating the DPOS kernels. Since the DPOS functionals are orthogonal, individual DPOS kernels can be isolated by taking the cross-correlation of the output with known "instrum ental’' functionals of the input |K ,n |. In our discrete time formulation, the j 1 order instrumental functional, which we denote by I i s equal to the j"1 order DPOS functional with the j th order kernel equal to the j,h order product of Kronecker-deltu functions. The diagonal values of the instrumental kernels are defined to be zero for the reasons discussed in Section 2. The key point to note here is that the DPOS functionals are orthogonal to each other for any kernel functions including the instrumental kernels. Thus, the j'1 ’ order instrumental functional will he orthogonal to all functionals of the DPOS except the j"’ order functional. In Appendix B, we use this property to isolate the l"’ order kernel by equating the system output to the DPOS and taking the cross correlation of both sides with the jlh order instrumental functional. 4.2 t he DPOS Kernel Formula The estimation formula for the symmetric j"1 order DPOS kernel is 19 p '(m m '} = ] j i ^ y (n )n x | n - m ' ) ">,}„) (4-D .1 * li ~ I 1 j ! ( l - X ) P" tor j > I. The zeroth order kernel is jziven hy p„ = y(n). The notation p f i {j ni | . .... in } J indicates the summation over the h 1 order kernel values where the indices are all combinations in ascending order taken h at a time from the set I I j! I m m } where h < j. There are ------: ---------such combinations. 1 1 1 h!( j - h )! 5. THK KKLATIONSHIP BETYVKKN DPOS AN1) DVS KERNELS Id this section, we derive the relationship between input-output cross correlation and the actual DVS kernels of the system and give an intuitive explanation. This relationship shows that cross-correlation of the output data with the input data does not isolate the DVS kernels, as expected since the functionals of the DVS are not orthogonal. W e then compare this relationship to the DPOS kernel formula to quantify the difference between the DPOS and DVS kernels. Pina M y. we present three conditions under any one of which the DPOS kernels will provide a good estimate of the DVS kernels. 5.1 Relation of O oss-correlation to the DVS By equating the system output to the DVS and taking the cross-correlation of both sides with the product of j samples of the system input, we derive a relationship between the j'1 ' order input-output cross-correlation and the first J kernels of the DVS ( J > j ). 'Phis derivation is performed in Appendix ( ’ and the result is T 7 y ( n ) r i * ( n - m -) = X h !k h({m l, m } J i ) j I X*"" h_rf i - |t + I I * ' h = r M M — -— V * y'k ffni, m ] ,ru t r ) (i “ h )! U ,/h 1 1 = 1 + 1 I (i - h - I)! M M 2 • 2 k1 i m m l„. n i i,r ...........r ) (5-1) 21 where the notation k ^ j i n , m. J , , rhfl, . . r, j indicates the summation over the i,h order kernel values where the first h indices are all combinations in ascending order taken h at a time from the set | m . . .. .. m } where h < j. There are ------- ------ 1 ' J h ! ( j - h ) ! such combinations. If we let the DVS kernels on the right hand side of <5-1) represent the actual nonlinearities of the system anti let .1 be the actual order of the system, then these equations show that inputoutput cross-correlation gives a result which contains a term involving each and every order of nonlinearity that occurs in the system. 5.1.1 Explanation W e offer the following intuitive explanation of (5 -1). The j'j’ order cross- con elation for a specific set of indices { n ^ .m , m ( j is the expected value of response samples that occur after a sequence of j events m ,. m , . through in sample points in the past. We will refer to the j events of this specific sequence as the “fixed" events. Som e instances of this specific event sequence in the PRES test input will include additional random events before, intermixed with, or after the fixed events. W e will refer to these additional events of the PRES test input as “ random " events since they will occur at random times with respect to the fixed events. The effects of these random events are accounted for by the terms in the square brackets of <5-1). Consider the first term in the square brackets of (5 -1): This term gives the effect of nonlinear interaction between any combination of h of the fixed events and i - h of the random events, where 0 < h < j and h < i < J . Assuming that the actual order of the system is J, we expect to observe nonlinear interaction between up to .1 events. Thus, the summation over the index i goes to J. The factor A" 1 ,1 is in (5-2) since it is the theoretical probability of i - h random events occurring in any particular sequence (see Section 3) in addition to the j fixed events. W hen h = (I and i = I. (5-2) gives the linear response of a single random event summ ed over all possible event times. W hen h = 0 and 2 < i < J, (5-2) gives the effect of nonlinear interaction between i random events summ ed over all possible event times. The term ------ T' • finV - 1 1 1 1 . r( +,,..., r) (5-3 ( i - h - l ) ! , " , ~ '> is in (5-2) to account for the fact that random events can not occur at the same time as any of the fixed events. Note that the dum m y indices {rh+ r,} in (5-2). which represent the times of the random events, are summ ed over all values. The values | m f, ... m j correspond to the times of the fixed events, however, and should not be included in the summations over the dum m y indices. A little combinatorial analysis confirms that (5-3) is the correction required to rem ove these values (see Appendix A). The second term in the square brackets is J f m M V I 7— 3 r.) I I ' JT ! ',1 - i+i (5-4) This term gives the effect of nonlinear interaction between any combination of j (all) of the fixed events and i - j of the random events. No correction term like (5-3) is needed to account for the fact that random events can not occur at the same time as any of the fixed events since when any of the dum m y indices --■> 1 | in (5-4) is equal to any of the values jm,, .... m }, the kernel is defined to lx* zero'. 5.2 Relation Between DPOS and DVS Kernels The general cross-correlation relationship given by (5 -1) can he manipulated to give a formula for the j ’1 ’ order DVS kernel: K ( n\ m ,) = — y< 1 1 i n *(" - >»,) - ^ I h! K ( { e , (5-S) I M V I 5 > ' S ' S e ( r . 0 f, - I l t = I J I +i x x * 1 J * h = I i = h + I -h ! i! M M n - h ) ! ,i=l W ith this manipulation, we have quantified the difference between the DPOS and DVS kernels since the part of (5-5) outside the square brackets is identical to the j'1 ’ order DPOS kernel formula of ( 4 - 1) (except for the different kernel notation). Hence, the difference between the j'1 ’ order DPOS and DVS kernel is given by the bracketed terms in (5-5). 24 5.3 C onditions for Approximate l)PO S-l)VS Kernel Kquality If there are conditions under which the bracketed terms in (5*5) are insignificant, then under those conditions, we can use the DPOS kernel formulas of (4-1) to estimate the DVS kernels. W e end this section by discussing three such conditions. 5.3.1 The Event Probability is Small The first condition involves the event probability of the PKFS test input, denoted by X . ('onsider the summ ations in the square brackets over the index i . The index i indicates the order of system nonlinearity as represented by the actual i"1 order DVS kernel. The terms in these sum m ations are multiplied by X to the power one or higher. Thus, all these terms decrease with decreasing X . Furtherm ore, the pow er of X increases as the order increases. Since X < 1. the nonlinear terms become less significant with increasing order. Intuitively, these effects make sense. As X decreases, nonlinearities of the system, especially higher order nonlinearities, are stimulated to a lesser extent. For small enough X, all the terms in the summ ations in the square brackets of (5-5) become insignificant and the difference between the DPOS and DVS kernels can be ignored. W e can always ensure this condition by decreasing X but not without cost. One cost is that higher order nonlinearities which may actually exist in the system will not be stimulated and so w ill be essentially invisible. By probing the system with a test input with a very small X, we will protect our lower order kernel estimates from contamination by higher order nonlinearities but we will not be able to identify those higher order nonlinearities. Another cost is that to maintain a given estimation variance for the lower order kernels, we will have to increase the test duration, a change that is usually undesirable from an experimental point of view, if we do not increase the test duration, then as we decrease the event probability, the num ber of instances of the various event intervals will decrease and the variance of the estimate will increase. The reader may have observed that, according to (3-2), we can make X as small as we like for any desired mean event rate, K, simply by choosing the appropriate sampling frequency, f . Thus, at first glance, it seems that we can always satisfy the above condition by increasing the sampling frequency. Specifically, suppose f is increased by a factor of u . Then, if R is held constant, X must be reduced by a factor of —. However, increasing the sampling frequency a also has the effect of increasing the magnitude of each kernel sum in the bracketed terms of (5-5). For every kernel index summ ed o v e r , the num ber of samples will be increased by a factor of « . Assum ing the original sampling rate was reasonable", then the magnitude of the sum will be increased by approximately a factor of u for each index summ ed over. Now note that the all the kernel sums in the bracketed terms of (5-5) are multiplied by a power of X that is equal to the num ber of kernel indices that are sum m ed over. Thus, changing the sampling frequency has no net effect on the magnitude of these terms. 5.3.2 Contaminated Data is Not Used The second condition is that only output data that is not contaminated by higher order nonlinearities is used in the cross-correlation estimate. Above, we stated that the terms in the square brackets in (5-5) appear because some instances of a specific event sequence in the PRES test input will include additional random events before, intermixed with, or after the fixed events. If we select only instances where there are no random events in the vicinity of the fixed events, then we could ignore the terms in the square brackets. This selection method has u major drawback. If we discard alt instances that are contaminated by random events, then the available instances for estimation o f the cross-correlation will be greatly reduced. For exam ple, consider the estimation of the second order cross-correlation. The probability of a pair of events occurring at any separation regardless of the presence of other events is X'. If we select only instances where there are no events at any of B samples before the first event, at any of I) samples between the events, or at any of A samples after the second event, then the probability of these selected instances is X ’(\ - A.)llltl>+A,1 Since X < I. we see that the ratio of selected instance probability to total probability, (1 - X ) ll,+ l>tAI, can be very small. Thus, using this technique with the PRHS test input is usually not practical since we would have to discard too much of the data. W e would be better off abandoning the use of a random test input altogether and stimulating the system with a set of deterministic sequences designed for the system. O f course, the fact that we usually would not know how to design a complete set of such deterministic test input sequences is a major reason for using a random test input. 5.3.3 Average Values of Actual DVS Kernels are Small The third condition under which the difference between the DPOS and DVS kernels can be ignored is more subtle. Note that the terms in the summations in the square brackets of (5-5) indicate the summation of random events at all possible locations'". Above, we described two related conditions where these random 27 events either would he so rule that they could be ignored (small A.) or instances where they occur would not be selected. Here we note that the contributions from these random events could be ignored if we could show that they cancel each other in the summations. Whether or not they cancel depends on the shape of the actual DVS kernels. Specifically, if the average over all indices of the actual DVS kernels is insignificant, then the DPOS and DVS kernels will be approximately the same. To use neuroscience terminology, we can say loosely that if the actual DVS kernels of the system have about equal amounts of facilitation and suppression, then the difference between the DPOS and DVS kernels will he small. Unfortunately, we can not ensure this condition since it depends on the nonlinear properties of the system, which we can not control. Furthermore, there is no method for proving that this condition is met without already knowing the actual DVS kernels. Rec;UI that diagonal v;dues ul the kernel ;ire defined to be zero " We assume that the kernel v;tries slowly with resfiecl to the sample i>criod. In practice, only contributions from random events that actually occurred in the PRES lest input would be present in the cross-correlation result. 2X 6. PRACTICAL CROSS-CORRELATION KSTIMATION In the previous sections, we derived the theoretical values of cross- correlations of samples of a Poisson random event sequence (P R E S ) test input. In these theoretical derivations, we have implicitly assumed an infinite test sequence. In practice, we will have a finite test sequence and the cross-correlation estimate will differ from the theoretical expected value. In this section, we specify the algorithm tor practical estimation of the j"' order input output cross-correlation estimate. Then, we discuss the estimation errors that occur for a finite test sequence. W e give a modification that will compensate lor variations in the number of instances of a particular event sequence as a function of the event intervals of the sequence. Next, we derive a formula for relating mean test duration, event probability, and estimation variance1 . Finally, we describe the technique of binning w hich reduces the test duration required for a given event probability and estimation variance. 6.1 Cross-correlation Algorithm for the PRKS Test Input W e begin by deriving the cross-correlation estimation formula for the PRES test input. Recall from Section 2 that we represent the input event sequence by a sum of Kronecker-delta functions: where n, is the sample number of event i . and I is the total num ber of input events. Using this input representation and the properties of the Kronecker-delta function, we find that the cross-correlation of the output with j samples of the input is estimated by ( 6 - 1) y ( n )J 7 x ( n - in ,) = ^r j y ( n ) f l ^ b j n - m , , = j N | 1 n - in, - n (6 - 2 ) where we use the sample average to estimate the expected value operation (denoted by the overbar notation) and N is the num ber of data samples. that a larger subscript represents an input farther into the past with respect to a given response sample at n, By using this ordering, only positive values of the interstimulus interval (n, - n, ) will give a non-zero result. Thus, we can restrict the summ ations to the region where i, < i ,<■•■< i r 6.2 Interstimulus Interval < I S I > Input Representation Next, we define a more practical input representation for our algorithm and use the kernel notation of (2-3). On a general purpose computer, it is inefficient to store the input as a sequence of (I’s and 1 ’s, especially when the probability of an event is small. Instead, we can simply store a list of the intervals between input events. For this purpose, we define the interstimulus interval (ISI) in sample points from the input event at sample n, to the input event at ; , 'e n us Using this definition and the notation of (2-3), the cross-correlation estimation formula can be written as W e order the indices j m ,, m m t j such that m, < m < ■ ■ < m so (6-3) 16 y ( n ) F h n - m - ^ A ' = I V h - 1 In words, this equation states that to estimate the cross-correlation for a set sequence of j input events where the ISIs of the j input events are equal to the farther into the past with respect to a given response sample at n. fo r each of these instances, we add in the m h response sample after the j 1 input event. Then, we divide the sum by N, the total num ber of data points. For example, the third order cross-correlation estimate is computed using In words, to estimate the third order cross-correlation for argum ents {111, A,, A,}, we sum up all output samples for which input events occurred m. m + A,, and m + ■ A, + A , samples in the past and divide by N. Although we will make a further modification below, we now have an algorithm, defined by (fS-4). for estimating the jlh order input-output cross correlation. This formula can be used for either continuously sampled data or for "epoch data". The epoch data recording paradigm is useful for experimental situations where the mean interstimulus interval is much longer than the response of the system. In these cases, continuous data sampling of the output would result in the recording of many insignificant sample points after the response has died out. of indices {m .A , A, j , we search for response instances" that occur after a indices {A , .... A, , J . A larger subscript on the index A indicates an interval y(n)x(n - m)x(n - m - A )x(n - m - A, - A , ) 31 To avoid this inefficiency, a finite epoch of data is recorded after each stimulus event and the input is represented simply by the intervals between events. To use (6-4) for epoch data, we could simply replace y ( (n) with y(n + tnj to indicate the m lh sample of the i * response epoch. 6.3 Estimation Errors to be ( ’orrected We will now elucidate the estimation error in the theoretical expected values that we derived in the previous sections. Consider the relationship between the |' order input-output cross-correlation and the DVS kernels given by <5-1). or the DPOS kernel formula given by (4-1). If we use (6-4) to compute the cross correlation in (5-1) or (4-1), we will find the factor NX1 in the equation. This factor, which we call the weighting factor, is the theoretical expected num ber of instances of j events in the PRES test input with any particular set of lSIs"1 . Note that the weighting factor includes instances where there are additional events before, intermixed with, or after these events. For a finite test input (finite N). the actual number of instances may differ from the theoretical value NA.' for two reasons. 6.3.1 Variation of Instance Count About the Mean First, the num ber of instances will have a random variation with a non-zero variance around the theoretical value. For some sets of ISI values, the num ber of instances will lie Sower, and for others, it will lie higher. The variance will be inversely proportional to the length of the test input and can be a significant source of error. 6.3.2 Systematic Instance Count Decrease The second reason that the number of instances will differ from the theoretical value when the test input is finite is that some ISIs become impossible. Specifically, there will be no input events that occur more than n, samples before the event at n, so the probability that another event occurs before the event at n, with an ISI greater than n i must be zero. Thus, the expected num ber of pairs of input events with an ISI of A,, for example, is actually given by f N - A t )V instead In general, the expected num ber of instances of | input events with ISIs of number of instances will tend to systematically decrease as the sum of the ISI values increases. This source of error will usually be negligible since N will usually he much larger than the sum of the m axim um ISIs of interest. 6.3.3 Correction W e will correct for both the random variation and the systematic decrease in the number of instances by replacing NA.1 with the actual instance count for a particular set of ISI values. W hen we implement the algorithm, we will simply keep a count of the instances for a particular set of indices {a , A ,}. We denote this count by I1 (A .,A ,....,A | . 6.4 Practical DPOS Kernel Formula W e can now modify the DPOS kernel formula given by (4 -1) for practical computation of the DPOS kernels. Using the cross-correlation algorithm defined 33 o f NA.'. A i is actually given by N - ^ A , A .1 instead of NA.1 . Thus, the hy (6-4), the actual instance count defined by I ,(X, A , .., A : , j . and the notation defined by (2-3) and (2-6) in (4-1) gives p;(m > A , A, .,)= I 1 / j n . M a , ) ( i - x ) £ ~ 7 L h! is. ( { '" • A...........A . '},.) I* h - I (6-5) indicates the summation over the h order kernel values pj,(r,, .... rh) where the indices {r,,.... r:i} are all combinations in a see 1 Jer taken h at a time from the j values in the set combinations. 6.5 Estimation Errors that do Not Require Correction The terms in the square brackets of (.V I ) also have theoretical coefficients that are a function of X . For example, the first bracketed term contains the factor X which is the theoretical probability of i random events occurring in addition to the j fixed events with any particular set of ISIs. If we move NX' to right side of the equation to combine it with this factor, we see that NX'X' is the weighting factor for this term. It is the theoretical number of instances of j fixed events and i random events with any particular set of ISIs. For a finite test input, the actual number of instances for a particular set of ISIs may differ from this theoretical value due to v- j! m .m + A ,m + A. + A . . ., m + > A, > where h < j. There are --: -------- such 1 litf.-hV h!(j-h)! ^ random variations and a systematic decrease, as discussed above. However, if we assum e that the kernels vary slowly relative to the sample period, then the random variations will tend to cancel out in the summations. Also, as discussed above, the systematic error is usually insignificant. Furthermore, these errors will be irrelevant for the DVS kernel estimation m ethod that we present in the next section. In that method, the kernel sum for each value of i in the square brackets of r i » j i By defining the bin width in seconds as h, = -y-, we can write the formula for the mean test duration as I I, T = -------- ^ — = ------— — seconds (6-6) ( f » ' r i b , R T i b . f - I i =\ where we have used (3-2), the definition of the mean event rate of the PRKS test input. ' The Innnula is given in terms of the number of instances of a particular event sequence instead of the estimation viirianec. Specifying the number of instances used in the eross-correlution estimate is a way of specifying the variance of the estimate since the varuuice is inversely proportional to the number of insumccs. " Note that the matching input events do not have to be sequential; there can be intervening events as explained in Section 3, 36 " Recall Iront Section 3 that the probability ol an event occurring at ;tlty input sample is X;uul is iHlependenl ol the occurrence ol events at other input s;uuples. 37 7. A GENERAL METHOD FOR ESTIMATING THE DVS KERNELS In Section 5, we found that input-output cross-correlation gives a result that in general contains all the nonlinearities of the system 1 . W e showed that under any one of three conditions, the higher order components will be insignificant and the DPOS kernel formula can be used to estimate the DVS kernels. However, if none of these conditions is met, then we need a more general method, For example, we can ensure the first condition by using a small enough event probability to prevent contamination of low order kernel estimates by higher order nonlinearities. However, those higher order nonlinearities (i.e., the higher order DVS kernels) may be of interest and we will not he able to identify them with this test input. To identify the higher order nonlinearities, we must stimulate the system with an event probability that is large enough to activate them significantly. W e need a method for estimating all the DVS kernels of interest that either prevents or corrects for contamination of lower order kernel estimates by higher order nonlinearities. Consider a procedure where the DVS kernels are estimated sequentially in ascending order using multiple test input sequences with successively increasing values of X . Based on our previous insights, we would attempt to choose the X values such that the j'1 ' order nonlinearity is significantly activated by the j'h test input but higher order nonlinearities are not. Assum ing we could find such values, then we could estimate the DVS kernels sequentially in ascending order. To compute the j'h order DVS kernel, we would simply subtract the lower order 3N nonlinearities, which were determined previously in the sequential procedure, fro in the j"’ order cross-correlation. Thus, if we want to estimate the DVS kernels up through order J, we would need to probe the system using J test input sequences with J different values of X . A major problem with the above ad-hoc method is that it may be difficult to find X values that significantly activate the nonlinearity of interest but do not significantly activate higher order nonlinearities. Using this method for estimating k, and k, (m), the constant and linear kernels, is reasonable since choosing the appropriate X values for these kernels is easy ( X = 0 for k, and X very small for k, (m ) ). For estimating the nonlinear DVS kernels, however, we need a more general method that does place such a tight constraint on the X values. 7.1 A (Jeneral Sequential Method We now present a general method that uses data taken with multiple values of X to estimate the nonlinear com ponents that are contained in the cross-correlation result. W e w'rite the relationship between the cross-correlation and the DVS kernels such that the cross-correlation is expressed as a linear combination of unknowns. The first of these unknow ns is the DVS kernel of the same order as the cross- correlation. The other unknowns are higher order DVS kernels sum m ed over one or more of their indices. W e use multiple test data sets with different values of X to form a set of linear equations which we can then solve for the unknowns. W e can still try to choose the X values such that the j'1 ' order nonlinearity is significantly activated by 39 the j"' test input hut higher order nonlineurities are not. However, because this general method does not require that the higher order nonlinear com ponents he negligible, the choice of X values is not critical. The method will work even if the j 1 ' choice of X does significantly activate nonlineurities higher than the j"1 order, 7.1 1 Formula for Sequential Kernel Estimation W e begin development of the algorithm by manipulating (5-5) into a form where the known terms, including those that will be known from previous calculations in the sequential procedure, are on the left hand side and unknown terms are on the right hand side: 1 y(n)l | x ( n - m , j - ^ ' V 'i - i [ , - 1 ■ y ( n ) f ] x { n - m , ) - ^ ^ £ • £ k'( r< r,) i = i i-1 i M M -o- mX " h - I i - - h ii A , y > i! M V 1 (i-h)! , £ • £ k;({m m j h’r.,o ■,) i ■ i \ r , - 1 M M (7-1) (i- I)! W e now define the sum of the i" order DVS kernel over i - h of its indices as jj M M s4 m > r') ,7 -21 :l r — l where the notation k ^ j m , , . . .. m ( ,rli + l, . . .. r J indicates the summation over the i 1 ' order kernel values where the first h indices are all combinations in ascending order taken h at a time from the set jin ^ .... m j where h < j. If i = h, (7-2) simplifies to sh h (m,, .... m j = h! ks h| | m , , .... J . If i = h = j, (7-2) simplifies 40 to x ^ m , m J = j! k'jfm,, ..., m j . Thus, if we solve for s )|( m !. . , mj. we have the j"' order DVS kernel. Using (7-2), we can write (7-1 > as (7-3) I = o - (in mj. There are .1 - j + I unknowns in sum over the index i on the right hand side of this the desired j,h order DVS kernel. The other unknowns are higher order DVS kernels summ ed over i - j of their indices where i is the kernel order. There are at most J + 1 unknowns in (7-3) {when j = 0). Thus, if we measure input-output data using at least J + I different values of A, then we can use linear algebraic techniques to estimate the unknowns. Since the kernels are com puted sequentially in ascending order, all the terms on the left hand side of (7-3) are known. 7.1.2 Formulated as a Linear Set of F^quations W e now caste the problem in linear algebraic form for data taken with D + I different input event probabilities which we denote by {A.,,,A.,,A,,.... Au}. Since the m axim um order of nonlinearity we will compute will be J, we must choose D > J . Using vector-matrix notation and the kernel index notation defined by (2-3) and (2-6). we can write (7-3) for D + I values of A as equation. The first unknown is sM (m ) = j! k ,(ni ) which contains (7-4) 41 where and An = 1 X,, 1 X, I X, K ■ ■ ■ V K ■ • K X'n • ■ *J „ A„ » (i-x„) (1 (i-x„>x;, ( i - x j x 1 (i-x,) (i-x,)x, (i-x,)x-; (i-Ajx (i-x„) (i-xjx,, (i-xjx;, - ( i - x j x ; i i< r i' I h A . l , ) s h !k u({m. A A, , } J * h . l i * I ( J 1 1 ’ A ( , ■ ' A , . i ) sh.hf:(m- AI A,.,) sh.i(»i- A, A, ,) y ,(m - a , a , ,) = I ( I I > T 7 y ( ^ - ,l) r i x - m - ^ A , ■ -I V ____________h-1 / (7-5) (7-7) (7-H) The notation x(X,,n)and y(X,,,n) indicates the input and output data, respectively, for the test input sequence with event probability X,,. The notation k ^ j n i . A , , A p , J J which appears in the vector k h(jni. A ,,.... A, , J( J indicates the summation over the h"‘ order kernel values k ^ , .... rh) where the indices {r, rh} are all combinations in ascending order taken h at a time from the j I--S values in the set < m .m + A, ,111 + A, + A , . . m + ^ A , where h < j. There are J- sueh combinations. h!( | -h)! 7.1.3 The Cross-correlation Vector IJ sing our cross-correlation algorithm <ft-4) anti replacing the theoretical weighting factor NX’ with the actual instance count I (A, A,. . . . A ,), as discussed in Section (1. we can write (7-S) as y,(m. A,. . 1 l,(X„.A,. 1 - a h ) 1 - A , , ) < 1 - A , , ) ■ | T I I 1- 1 * 1 I Xy(A,.n, +m)]~[t>(A , - ISI,' , ) — 1 1 | + I f - I + m ) f ] f i ( A , - I S I ‘ , ,) T 1 , , 0 (7-4) where ISI1 indicates the interval from event i - I to event i for the test input sequence with event probability X,, and must have the same units as A,. 7.2 Kffect of Small Kvent Probabilities In Section 5, we showed that the higher order kernel sums can be ignored if A is small enough. We can now see this result from the perspective of linear algebra theory. Consider the matrix A, in (7-4). As the values {A^A^A, Ah} approach zero. A ( approaches a rank one matrix with all ones in the first column and all zeros in the other columns. Thus, as the values {Xn,X,,X.,.... X,,} 43 approach zero, only the first element of k ((m, A,,. . A t., J , defined by (7-7) with h = j, remains significant. The other elements, which are the higher order kernel sums, become irrelevant since they are multiplied by zero. The behavior of the matrix A as the values of X become small is problematic since we need A to have a rank of at least J - j + 1 to be able to solve (7-4) which has that m any unknowns. ' In practice, only those nonlineanlies ol the system that are activated hy the test input would he present in the cross-'Correlation result. 44 8. DIFFERENCES BETWEEN UFOS AND DVS KERNELS DEMONSTRATED BY SIMULATION In this section, we use simulations to verify the theoretical results of Section 5. We simulate a simple second order system to clearly demonstrate that the difference between the DPOS kernels computed using (6-5) and the actual DVS kernels of the system depends on the event probability of the test input and on the shape of the actual DVS kernels. 8.1 Simulating a Second Order System For a second order system, the DVS of (2-4) reduces to y(n) = k + ^ k^mjxfn - m) + 2 ^ ^ k ' , ( m , A ( )x(n - m)x(n - m - A,), (X-1) m in A, For the PRES test input, we can use our input definition given by (6-1) to write (X- I ) as y(n) = k + ^ k ,( m ) ^ 8 (n - m - n,) in .-I + 2 S S k -'(m ' A l ) 5 i X fi(,1- m - n .:)8(Al - ISI., , )■ iii A | 11 _ | i, - 11 + | Then, using the properties of the Kronecker-delta function, we can further simplify (X-I) to y(n)= kr + £ k , ( n - i 0 + 2 j 5 X ’(n “ ll.;:' ISI. )• <x ‘2> 1 -1 I , = I I ; = I, + I To generate epoch data, we can replace the absolute sample number n with n h + m to indicate the m"’ sample of the h'1 ’ response epoch: 45 I I I y(nh + m) = k„ + ^ k t((nll -n,) + m) + 2 ^ £ k : ( K ~ 'V,) + lslh ) -I 'i=l 1 : - 1 1 + I and then we can use our ISI definition of (6-.^) to give y(«h + m) = k„ + X k.(ISI,h + m ) + 2L S k : ( l s , .;.i. + i-l 11 =1 i,-ij + J W e are now ready to simulate a second order system using either (X-2) or (X-4). S.2 The Actual l>VS kernels of the Simulated System hoi this dem onstration, we chose k „ = 0. M m ) = A| I - — M 0 < m < M 0 , otherwise (X-4) (S-.S) and k. ( 111, A ) = 1 2m + A, 2M + A ( ’ + Bsiii(m(m + A, )<xjt}]. 0, 0 < m < M and <>< A, < A.... otherwise tX-fi) where A, M, C, B, a . and Am iv are constants. W e chose a very simple first order kernel, a ramp, so that the effects of the second order nonlinearity on the first order DPOS kernel estimate will he ohvious. W e chose the second order kernel, a rump multiplied by a constant plus a sinusoid, to demonstrate the effect of second order kernel shape on the amount of contamination of the first order kernel estimate'. Specifically, a non-zero value of C 4h will cause the integral of the second order kernel over A, to he non-zero which will cause more contamination of the first order kernel estimate. Even if C = 0, the integral over A, will he exactly zero only if there is an integer number of periods of the sinusoid in the range O < A, < Alim. For ( periods, this requirement is satisfied only when If large values of / are required to satisfy this equation for the interesting range of m (i.e.. the second order kernel has many periods over the range of m), then the integral will he near zero for any value of m since any partial period will he only a small part of the kernel. However, if small values of ( allow (K-7) to be satisfied, then we can expect a sinusoidal variation in the contamination of the first order DPOS kernel estimate. We can expect the most contamination when m has values near that given by (X-7) with 1 - hi addition, due to the ramp in (K-0). the contamination will tend to decrease as 111 increases. 8.3 Simulation Parameters We performed simulations using a PRES test input with 4(164 events. The number of events for all simulations was always the same. For different event probabilities, the test duration changed according to (6-6). We used kernels defined by (X-4) through (H-6) with M = 150, A = 10 mV. B = 5 mV, < x = 5 x 10 J', and Ami^ = 5000. We ran simulations at mean event rates of 0.2. 2, 5, and 10 events per second (corresponding to event probabilities of 0.00002, 0.0002, 0.0005, and 0.001, respectively) with C = 0 and C = 5 mV. We generated epoch data with an 47 epoch of 20 ins and a sample period of T = 0.1 ms. We estimated the DPOS kernels using (0-5). In the results shown below, we plot the kernel indices in milliseconds'1 and the kernel amplitudes in millivolts. 8.4 Results 8.4.1 First Order Kernel Results Figure I compares the estimated first order DPOS kernels for the four mean event rates when 0 = 0. Figure I: Estimated I'1 Order DPOS Kernel vs. Event Rate for 0 = 0 20 (rates in units of events/second) 0.2 20 tau (milliseconds) 48 The actual first order DVS kernel is not shown hut is simply a ramp from 10 mV at 0 ms to 0 mV at 15 ms, as defined hy (X-5). Figure 2 gives the same comparison as Figure 1 except with C = 5 mV. Figure 2: F stim a ted I 1 O rd er D P O S K ern el vs. Hvent Kale for ( ' = S m V 4 5 4 0 {rates in units of events/second) 3 5 3 0 0.2 20 tau (milliseconds) 49 Figures I and 2 show that the first order DPOS kernel estimated using a mean event rate of P.2 is very close to the actual DVS kernel. This result is expected since the mean event interval is ten times larger than the memory of the second order nonlinearity. However, as the test input event rate increases, the difference between the DPOS kernel estimate and the actual DVS kernel progressively increases. Furthermore, we see that the kernel shape has an effect on the difference since the difference varies as a function of m ( T in the figures). The largest difference occurs at about 4 ms, which is the value we would predict using ' = in (X-7). This variation over in is explained by the fact that the second order nonlinearity varies with m (see (X-6)). Comparing Figures I and 2, we see the effect of a constant offset added to the sinusoid in the second order nonlinearity. As expected, the offset increases the difference between the DPOS kernel estimates and the actual DVS kernel. Furthermore, the increase becomes progressively larger for progressively larger event rates. X.4.2 Second Order Kernel Results Figures 3 through 6 show the estimated second order DPOS kernels for the tour mean event rates when C = 0 (top graph). For comparison. Figure 7 shows the actual second order DVS kernel. The bottom graph in Figures 3 - ft is a histogram of the event deltas that actually occurred in the test input. From (6-6), we know that the theoretical expected number of instances in any delta bin is given 50 by I, = T R 'b,. Because we have a fixed I, for all simulations, I = — and the R theoretical expected number of instances in any delta bin is given by \ , - I,R h,. (K-8) For our simulations, we used I = 4064 and a bin width of h; = ID ms. Hence, the theoretical expected number of instances are X, X1, 203, and 406 for the event rates 0.2, 2, 5, and 10 events per second, respectively. The histograms show significant variation about these mean values across delta bins. Thus, in practice, it is important to use the actual instance counts instead of the theoretical mean value in the calculations, as discussed in Section 6. Comparing the second order DPOS kernel estimates, we observe two opposing effects of changes in the test input event rate. For larger event rates, there are proportionally more instances in each delta bin. as (X-X) predicts and as shown by the histograms. As with any averaging method, the variance of the estimate decreases and the suppression of uncorrelated noise increases as the number of instances increases. From this perspective, larger event rates are more desirable. However, as we discussed above, larger event rates cause more emir in the first order kernel estimate. This error is then reflected in the second order kernel estimate when the first order kernel is subtracted"1 . It is most apparent for small values of delta. Thus, we have a tradeoff between the two types of error. 5\ Figure .V . Estimated 2'"{ Order D PO S Kernel and Delta Histogram for R = 0 .2 H z 6'-, delta (ms), bin= 10.0 tau (milliseconds) 25 20 S 15 o c (0 w -E 10 5 0 0 100 200 300 400 500 delta (msl. bin width = 10.0 ms 52 Figure 4: Estimated 2'"1 O rder D PO S Kernel and Delta Histogram for R = 2 H z 100 delta (ms), bin= 10.0 0 0 tau (milliseconds) 120 100 ■ w CD O c ra to c 100 200 300 400 delta (ms), bin width = 10.0 ms 500 53 A7$^./+^+:+^7A Figure 5: Estimated 2 "1 O rder D PO S Kernel and Delta Histogram tor R = 5 H z 100 delta (ms), bin= 10.0 0 0 tau (milliseconds) 2 5 0 200 Si 1 5 0 .E 100 50 i 200 delta (ms). bin width = 10.0 ms 300 400 500 100 54 instances a . . amplitude (mV) Figure (r. Estimated 2 m l O rder DPO S Kernel and Delta Histogram for R - Id H z elta (ms), bin= 10.0 0 0 tau (milliseconds) 500 400 300 200 100 400 500 200 300 delta fmsl. bin width = 10.0 ms 100 Figure 7: Actual 2 '" 1 Order D V S Kernel 6 1 delta (ms), bin= 10.0 tau (milliseconds) Note that the second order kernel is symmetric (symmetry requires that Ihc kernel he identical alter ini enduing inn the indices m , and i n , , which correspond to m and m + A , in the notation here). " Instead ol the index m. we use T, where X = mT„. " See the DPOS kernel lorm ula ( 4 - 1) or <6A). 9. CONCLUSION We have shown that input-output data cross-correlation can he used to identity the nonlinear input-output transformation of a system. This system identification is accomplished by estimating the kernels of the Discrete Volterra Series (DVS). The DVS representation of the system is used because its kernels have a simple interpretation which provides a useful characterization of the system nonlinear ilies. We presented two complimentary methods for computing the DVS kernels. The first method is to estimate the DVS kernels using the formula for the Discrete Poisson Orthogonal Series (DPOS) kernels. The DPOS is the result of orthogonalizing the DVS for the Poisson Random Event Sequence (PRES) test input. Since the functionals in the DPOS are orthogonal, its kernels can he isolated by input-output cross-correlation. Although we showed that any DPOS kernel will contain components involving all the actual DVS kernels of the system, we also showed that we can isolate a single DVS kernel from the DPOS kernel if the higher order nonlinear components are negligible. Furthermore, we showed that the higher order components will be negligible if at least one of three conditions is satisfied: ( I ) the event probability of the PRES test input is small, (2) only output data that is not contaminated by higher order nonlinearities is used in the cross-correlation estimate, or (3) the averages over all indices of the actual DVS kernels of the system are insignificant. We showed by simulation that we cun always ensure the first condition by using a small enough event probability such that the mean event interval is much 57 larger than the memory of the higher order nonlinearities. However, decreasing the event probability has a cost. For the same test duration, the estimation variance will be larger for a smaller event probability since there will be fewer instances available for the cross-correlation estimate. Alternatively, a longer test duration would have to be used to maintain the same estimation variance. Thus, choosing the event probability involves a tradeoff between estimation variance (or test duration) and contamination by higher order nonlinearities. The second method that we presented for estimating the DVS kernels is a general method that does not depend on any of the conditions listed above. This method requires that the unknown system be probed with multiple PRES test inputs with different input event probabilities. By using test inputs with J different event probabilities, we can compute the DVS kernels up to the J lh order and compensate each kernel estimate for contamination by higher order system nonlinearities up to the J'1 ' order. The method involves solving a set of simultaneous linear equations to isolate each DVS kernel from other system nonlineurities of order less than or equal to J. Which method is better depends on the properties of the particular system being investigated and whether or not we want to characterize high order nonlinearities. If we only want to characterize lower order nonlinearities (e.g., the first and second order kernels) and the system is stable1 over a relatively long period of time, then the first method is probably preferable. We can use a small event probability so that we do not activate high order nonlinearities and we can use a long test duration so that we have a small estimation variance. On the other hand, if we are interested in high order nonlinearities, then the second method is more appropriate. One might argue that a disadvantage of the 5K second method is that its total test duration is larger than that of the first method since multiple test inputs are required. However, we would tend to use higher event probabilities in the second method, so the input test durations needed for a given estimation variance would be shorter. Thus, which method has the shorter total duration depends on the specific event probabilities used. If the first method is chosen, we can improve its performance with a little extra effort by using the concept of the second method. We would first estimate I lie first order kernel by taking a number of measurements of the response to a single isolated input event. By "isolated”, we mean that the interval between input events is larger than the memory of the system nonlineurities. We can always find such an intervalFurtherm ore, it is reasonable to expect that we will have enough knowledge of the system so that we can confidently choose such an interval. Using this approach, we would be confident that the first order kernel estimate is not contaminated by higher order system nonlinearities. Furthermore, it will not introduce such error into the nonlinear kernel estimates'". Following the first method, we would then probe the system with a PRHS test input to identify the low order system nonlinearities (e.g., the second and third order nonlinearities). With only one test input, our nonlinear kernel estimates will be contaminated by higher order nonlinear components. We would attempt to chose the event probability such that the test input significantly activates only the low order nonlinearities, although it is not reasonable to assume that we will be completely successful. Future work should compare the results of these methods for real systems. The comparison will be difficult because we will not know the correct answers. From a modeling perspective, we can judge a FPS representation of a system by .V ) how well it predicts the system output. However, predicting the system output is not the same as characterizing the system nonlinearities. An orthogonal FPS such as the DPOS is usually the best" representation for predicting the output. It provides a useful “black box" model of the system but it does not characterize the system nonlinearities because we can not interpret its kernels. (July a Volterra FPS provides a interpretable representation that characterizes the system nonlinearities. 1 Bv siahlc. we mean llial the kernels ol the system do not change over lime independent of ;uiy input or due to some input other than the lest input. " Here, we make the reasonable assumption that the memory of the system nonlinearities is finite. Any em ir in the first order kernel is introduced into the higher order kernel estimates when the first order kernel is subtracted from the lusher order cross correlations in the sequential procedure indicated by (4 -1) or (6-S). " An orthogonal FPS predicts the output with ihe least mean squared error tor a pivcn number ol terms in the .series. BIBLIOGRAPHY 1. Berger, T.W., G. Barrionuevo, S.P. Levitan, D.N. Krieger, and R.J. Selabassi. 1 WO, Nonlinear-systems analysis of network properties of the hippocampal formation. In: F o u n d a tio n s o f A d a p tiv e N e tw o r k s . M. Gabriel and J. Moore, ed. MIT Press: Massachusetts. 2X3-352. 2. Berger, T.W., T.P. Harty, G. Barrionuevo, and R.J. Selabassi. 19X4. Mixieling of neuronal networks through experimental decomposition. In: A d v a n c e d M e th o d s o f P h y s io lo g ic a l S y s te m M o d e lin g : V o lu m e 2. V.Z. Marmarelis, ed. Plenum: New York. 1 I3-12X. 3. del Castillo, J., and B. Kat/. 1954. Quanta! components of the end plate potential. ./. P h y s io l. 124: 500-573. 4. Kosanovic, B.R. 1992. T h e o r e tic a l a n d e x p e r im e n ta l d e c o m p o s itio n o f n e u r o n a l s tr u c tu r e s . Master of Science. University of Pittsburgh. 5. Kraus/.. H.l. 1975. Identification of nonlinear systems using random impulse train inputs. B io l, ( 'y h e r n e tic s 19: 217-230. 0. Kruusz, H.I., and W.O. Friesen. 1977. The analysis of nonlinear synaptic transmission. J o u r n a l o f G e n e r a l P h y s io lo g y 70: 243 - 205. 7. Kroeker, J.P. 1977, Wiener Analysis of Nonlinear Systems Using Poisson- C’harlier Crosscorrelation. B io l, ( 'y h e r n e tic s 27: 22 1-227. X. Lee, Y.W., and M. Schetzen. 1905. Measurement of the Wiener kernels of a nonlinear system by cross-correlation. I n t. ./. C o n tr o l 2: 237-254. 9, Marmarelis, P.Z., and V.Z. Marmarelis, A n a ly s is o f P h y s io lo g ic a l S y s te m s : T h e W h ite -N o is e A p p r o a c h . I97X, New York: Plenum Press. 10. Marmarelis, P.Z.. and K.l. Naka. 1973a. Nonlinear analysis and synthesis of receptive field responses in the catfish retina. I. Horizontal cell chain../. N e u r o p h y s io lo g y 30: 605-01X. I 1. Marmarelis, P.Z., and K.l. Naka. 1973b. Nonlinear analysis and synthesis of receptive field responses in the catfish retina. II. One-input white noise analysis../. N e u r o p h y s io lo g y 30: 019-633. 12. Marmarelis, P.Z., and K.l. Naka. 1973c. Nonlinear analysis and synthesis of receptive field responses in the catfish retina. III. Two-input white noise analysis. ./. N e u r o p h y s io lo g y 36: 634-64X. 61 I 3. Marmarelis, V.Z. 19X7. Nonlinear and nonstationary modeling of physiological systems: an overview. In: A d v a n c e d M e th o d s o f P h y s io lo g ic a l S y s te m M o d e lin g : V o lu m e I. V.Z. Marmarelis, ed. Biomedical Simulations Resource, University of Southern California: Los Angeles. 1-24. 14. Marmarelis, V.Z. 1993. Identification of nonlinear biological systems using Luguerre expansions of kernels. A n n a ls O f B io m e d ic a l E n g in e e r in g 2 1: 573- 89. 15. Moore, G.P., D.G. Stuart, E.K. Stauffer, and R. Reinking. White-noise analysis of mammalian muscle receptors, in F ir s t S y m p o s iu m o n T e s tin g a n d Id e n tific a tio n o f N o n lin e a r S y s te m s . 1975. California Institute of Technology, Pasadena, ('A: 1 6. Oguru. H. 1972. Orthogonal functionals of the Poisson process. IE E E T ra n s. In fo r m . T h e o r y IT-IK: 473 - 481. 17. Schelzen, M., T h e V o lte r r a a n d W e in e r T h e o r ie s o f N o n lin e a r S y ste m s . 1980, New York: Wiley. 531. 18. Selabassi, R.J., D.N. Krieger, and T.W. Berger. 1987. Nonlinear systems analysis of the somatosensory system. In: A d v a n c e d M e th o d s o f P h y s io lo g ic a l S y s te m M o d e lin g : V o lu m e /. V.Z. Marmarelis, ed. Biomedical Simulations Resource. University of Southern California: Los Angeles. 104- 127. 19. Selabassi, R.J., D.N. Krieger, and T.W. Berger. 1988. A systems theoretic approach to the study of C’NS function. A n n a ls o f B io m e d ic a l E n g in e e r in g lb: 17 - 34. 20. Selabassi, R.J., D.N. Krieger, J. Solomon, J. Samosky, S. Levitan, and T.W. Berger. 1989. Theoretical decomposition of neuronal networks. In: A d v a n c e d M e th o d s o f P h y s io lo g ic a l S y s te m M o d e lin g : V o lu m e 2 . V.Z. Marmarelis, ed. Plenum: New York. 129-146. 21. Selabassi, R.J., J.M. Solomon, T. Biedka. S. Levitan. D.N. Krieger, and (S. Barrionuevo. 1992. A p r o g r e s s r e p o r t o n th e th e o r e tic a l s tu d ie s in s u p p o r t o f A F O S R g r a n t S9-0/97. A s y s te m s th e o r e tic in v e s tig a tio n o f n e u r o n a l n e tw o rk p r o p e r tie s o f th e h ip p o c a m p a l fo r m a tio n . University of Pittsburgh. 22. Volterra, V., T h e o r y o f F u n c tio n s a n d o f In te g r a l a n d In te g r a -D iffe r e n tia l E q u a tio n s . 1930, New York: Dover Publications. 23. Wiener, N„ N o n lin e a r P r o b le m s in R a n d o m T h e o r y . 1958, New York: The Technology Press of MIT and Wiley. 62 APPENDIX A: DERIVATION OF THK DISCRETE TIME POISSON ORTHOGONAL SERIES (DPOS} In this appendix, we use the (irum-Schmidt orthogonulizution procedure to derive the Discrete Time Poisson Orthogonal Series (DPOS). We denote the j ,h order functional and kernel of the DPOS by Q t and p , respectively. Two functionals are orthogonal when their inner-product, defined as the expected value of their product over the sample index (i.e., the covariance), is zero. We use the over bar notation to indicate the expected value taken over the sample index 1 1. Since the expected value is taken over the sample index, not the kernel indices, we can move the expected value operation inside summations over the kernel indices. Since we do not know the form of the DPOS apriori, we can not assume that the kernels of the series are symmetric or that they can be made symmetric, as we can for the Volterra FPS 117|. Due to the multiple possible permutations of the kernel indices, the derivations can become quite long. For the sake of brevity, we will first define an efficient notation and a general relation that will considerably shorten the derivations that follow. Consider the permutations of j„ of the indices of the j lh order kernel ( j,, < j ) when L of these indices ( L < j(, ) are fixed and chosen from a set of i possible values ( i > L ) and the remaining j - 1. indices are summed over their entire non-zero range. We will represent the summation of the kernel values over the complete set of these permutations by the shorthand notation P' (A,B) where A is a set that contains the index values of the desired j(, of the indices of the j"1 order kernel to be permutated and B is a set that contains the i jn • i- possible values. There are — ---------^-----;---------permutations. If j n = j, we will (jo — LpL!(i - L)! use the simplified notation P ’ B, and if L - 0 we will use the simplified notation P^. For the second order kernel, some examples of the use of this notation are P ; ’ = X X M m : r m v) ill . i lit *' p ' {™} = Z p.’ (ni’ )+ Z p ' (m ' ’ni) 111 1J t i l l , = Z P - ’(mi-m ’.') + Z P 111.; Pll ; , p (n i ' ,n ) + Z i1 (,n 1 ■i n ’) nil. in., p; ({i }, {m ,. m }) = X i1 (1 1 1 <'m v ) + Z p ■ (1 1 1 - •m ■) 1 1 1 m:: P‘ (j 2 1, { m ,. m _,}) = Z P .- (m :i • m i) + Z P-’ (m ■''111. ’) nt.j in., P, {iiipm,} = p .( m l, m ,) + p ^ m . j n , ) P: {m l. m . , m l| = p ,( m |1in,) + p , ( m „ m l) + p ,(n il,m ,) + p , ( m „ m 1) + p: (m ,,m ,) + p .( m „ m ,) . Now', we will derive a general relation that will he used in the derivations that follow . Consider the operation Z ‘"ZP.(r> r> ) ( x-l0 " ‘(x-rh l„ )(x-,ui)'(x - 1 1 1 ) 'i ri where j„ < j, h, * h, *■■ ■ * h , , I < | h , h } < j, and m, * m, m ,. Let IJ = MAX[ j„.i] (I) for "Upper"), L = MIN[j„, i] (L for "Lower"), A = j h , h } j, and B = {m ,....,m }. The expected value operation above will have L different values in the summation. It will evaluate to a power of X where the power is equal to the number of different indices in the expected value. The number of different indices ranges from U, when I. of the r values match L of the m 64 values, to j , + i, when none of the r values match m values. The permutations of the points in the summations where L of the r values match L of the m values (the maximum possible) are given by P' {A.B}. Fo. .'.II these permutations, the expected value evaluates to V . The permutations where L - I of the r values mutch an m value are contained in PH n{ A.B). Recall, however, that this notation represents the summation of the non fixed indices over their entire range, which includes the fixed m values. To obtain only the permutations w here L - I of the r values match an m value, we must remove the permutations w here L values match. Thus, the permutations where only L - I of the r values match an m value are given hy P^1 " ( A . B ) - P 1 (A,B). For these permutations, the expected value evaluates to * ' Similarly, the permutations where L - 2 of the r values match an m value are obtained from the set P 1 1 (A.B) by removing the permutations where L - I and I. values match: p;[ :,{a . b ) - [ p ; ' " ( a . b j - p , 1 (a , b ) ] - p ; ( a , b > = P,1 1 : '(A,B) - P," " ( A, B). For these permutations, the expected value evaluates to +Jt. In general, we can show that the permutations where L t of the r values match an m value ( I < i < L ) are given by P1 ',- M( A , B ) - P |'t- < + l'(A,B). Thus, our general relation to be used for the derivations is 65 X ' " S P i ( ri r )(X _ ,'|- )(x-m,) • ( x - m ) (A-1) = \ ' P l (A,B) + ^ X 1' +''[p,1 1 '( A .B ) - p;1 ,+n(A,B)] / - I where j, < j, A = j h , h N }. h, * h, h, , I < j h , h ] J < j, B = {m, rn } , m, * m_, m ,, U ~ M A X [},,i], and L = M IN [j,,i]. We now proceed with the orthogonali/ation process. The zeroth order Poisson functional is hy definition y „ = p„- < A- 2 ) Using a dummy zeroth order kernel variable, denoted by g ]M , we can write a general first order f unctional as Qi(n) = X P l( m )x(n IA-3) The value of the dummy variable is found from the requirement that the first order functional be orthogonal to the zeroth order functional: 0 = 0, .Udn) = P, £ p , ( m ) x ( n - m ) + g , £ p , ( n i ) x ( n - m ) + g ](1 ill P n \ ^ K + ^ > \ g i „ = - < . (A-4> Thus, using (A-4) in (A-3). we find that the orthogonal first order functional is Q,(n) = £ p ,{ m ) x { n - m )-^ P ," (A-5) or bb which can be written as Qi(n) = £ p , ( m ) ( x ( n - t n ) - \ ] in-i where the summation is taken over the range M, Similarly, using dummy first and zeroth order kernels, we can write a general second order functional as U.'(n) = (ni i’,n ” )x(n — ni.., )x(n - 111,.) in ,t in )X( n ” rn ) + y.-" (A -h ) (A-7) where the notation g M indicates the i1 1 ’ order dummy kernel for the j,h order general functional, the notation m,, indicates the i"' index of the j'1 ’ order DPOS kernel (two subscripts are used when necessary to distinguish between different indices), and the notation r , indicates the ilh index of the j"’ order dummy kerne). Again, we determine the dummy kernels from the orthogonality requirements. For orthogonality of the second order functional to the zeroth order functional, we require = Q.,Qj(n) = Pm X S p - ( m -o ,n:->)x(n -in ,,} I. = p „ [e p :, + u r , + g„ i g.„ = - x 'p ;- C o 1 :,. (A-Ki For orthogonality of the second order functional to the first order functional, we require or b7 < ) = Q (n )Q : (n ) = X p ,(" 0 + X S - ’i(ro )x(n _ rn)*(n _ m) + - m) - * I I P >(m,,,in_,,)x(n - m :i )x(n - in,,) or XP:{in} + X’|p. -P.!{m}| = X P i * 111^ + *■'[(i ’ ( ; ' J in }] ilk -Vp: — a ( i', = M 1 - *-)£ P, (m){ A .P ,1 {in} + Ci',, {111 f} in ^ ( 111) = Ci', = -A.P,' {m}. In (A-S), we need Cl", whieh we can now find: (A 10) Thus, using tA-K>, (A-0) and {A-10) in tA-7>, we find that the orthogonal second order functional is Q : {») = X X p . K i-111:: )x(n - m :i)x(n - ill,,} l i t i l l >: + £ [ “ W i 'r" ! M n - r,,) - k- p: - x[-2>lp; ] or <*Mn ) = X L P ; ( nV m - ) x( n _ m j x f n - in,) H i I 1 11 2 P' ] in }x(a - m) + X' P! (A-1 1) OS which can he written as x(n - ni, )x(n - m , ) y.-(i') - X X M m i-1 1 V')< -^ [* (n - in ) + x(n - 111, )J tll< ti l : +V By taking the summations are over the same range M, we cun write x(n - m, )x(n - m , n 1111 iti I (A -12) p, (in,, in,) + p , ( m , , m t ) \ 1 M 11 1 , -• I 1 1 1 , “ J ^ P :(m i' 1 1 1 ) + p , ( i l l , . I l l , ) -X[x(n - m , )+ \(n - in,)] +V x(n - in )x(n - i n ,) -2Xx(n - 11 1,) + X: Now, we see that we can define a symmetric second order DPOS kernel as P > {1 i1 1 - in:) = \ [P: (m ,. m ,) + p, (m ,, m ,)] such that our orthogonal second order functional can he written as (A-13) M \f x(n - in, }x(n - i n , ) -2A.x(n - m , ) + X (A -14) i n | i i l l I Next, we can write a general third order functional using dummy second, first, and zeroth order kernels: Q,<n > = X I I p l(m „ . m ^ ' n j x f n - m j x f n - m,, )x(n - 111,,) m , i m 4v m , t +X X > - (r i •r w n - r-1 )x(n - 1 ") = Q„Q,(n> = P„ I S S p i(m ,]. m , , , m n )x(n - m u )x(n - m,,)x(n - m,,) m ,, tn ,s m , + £ £ t? < J (r- ' i ’ 0 : )x(n “ r.' i )x(n “ 1::) + £ ^ ' ( ,n W n - r n) + ^M < 1 1 = p1 1 [A .,p;, + v'(i,;,+A.(i,;l +*:,„] or g„, - — X.P, — X.'( 1 — XCi’ ,1. (A-lfi) For orthogonality of the third order functional to the first order functional, we require £ £ £ p * ( m *i'm e - m o )x(n — m», )x(n - m , ; )x(n - m „)x(n - in) in i | ni m u + S X ^ -’(r'i'r j )x( 1 1 - r I )x(n - r .v )x( 1 1 - 1 1 1 ) + i ( ri I ) X( n “ r n ) x 0 l - m ) + g tll x( 1 1 - M l ) in tl m ,, ni . K o (r- O r- ’- ’ )X(n “ r^ > )X(n “ T 2 2 ) “ * - L y M (ri 1 )X(n “ ri I ) “ = X p , ( ,n > v p ; { m } + A j [ p ;'-p ;{ m } ] +A:G',,{m) + A'[G'^ - C.i',j -j m [J +A G | {m } + A: [Ci", - G , {m \] + Ag, -a[ a p ; ] - a[a’g ( ;: ] - a [ a g ; ] - Ag, 70 29 MI - A.) £ Pi(1 1 1 1 (*■'’P ' t 1 1 1 \ + X c’ \ . I m \ + G u { m }| or g,,(ni) = Ci',]m} = - A :’P|{ m f - AX. i m}. (A-17) For orthogonality of the third order functional to the second order functional, we require 71 < > = Q:(n)U,(n) = Z , £ P : K . nl:) ' 111 t 1 11 . 2 2 2 P < ( m ) r:i +2L ) x(n ~ r n)x(n - 'ii,)x(n - m;) + i!(1 ,x(ii - in, )x( 1 1 - in.) I j j ^ S S S p i(m ,J-ni l, . m ll).v(n - in )xf 1 1 - n i(, )x( 1 1 - i n (l)x(n - in, ) I I I . | 111,. !H | y )x(n ~ r'i)x(|1 - r'' )x(n - ■».) r , | is. )x(n - r,, )x(n - n i,) - Xg„,x(n - i n , ) 'li - ^ 2 2 2 r P ,(m ,i'ni,- ’,lll' ^ x(n _ m ’i)x(n - ” 1 )x(n - 1 11 ,,)x(n - ill,) rn ij m m M “ *■ 2 £ M r:i )x(» ~ r:i )x(n ~ r: : ) * ( n ~ m ' ) “ * 2 y n (ri )x(n - | )x(n - m - Xy # 1 x(ll - ill.) ■ l I +x X 2 2 P ‘(ni(i’m i-' -1 1 1 u )x(n — m ,, )x(n - in,, )x(n - 111,,) m M m in 2 2 ^ ’-fr’i-r' ’)xfn _ r -1 W n _ ) r:; + ^ 2 ^ ' (rn ) x(n “ r. i ) + ^ « . = X £ p - ’(m i’m .’) ni i m : X'P,’{iti,, m , } + X4[pJ {nipin,} - P, {m ,111, }] + X'[P" - P' {in,,in . }j +X G ,,{111, ,111,} + X-'JCi',,{nipin,} - CJ{, {in ,,m ,}] + X4[G'j, - C i {111, ,111, }J +X~GI ,I {m ,,in ,} + X '[G n - G 1 ,,{ in, ,m ,} ]+ V g lM -X[X’P!{in,} + XJ[p;' - P!{m,}]J -X[VCil ,,{m 1} + A.,[Ci,; , - C i l l,{m l }|] > l[ A.CI, {ill,} + X [ d ‘; - ci1 ,, {ill,}]] - X'y - x j x p j {in,} + v [p ;' - p; {m, }|] — X[X‘G',, {111, J + X [g ^ , - Cl1 ,, {m , }]] -x [x c;', { m ,} + x'Jci;1 , - u '„ { m ,} ] |- x-’y „ + xJ [x'p;1) + x-’[x:g ; , ] + x:[x g ;, ] + x:y = ( 1- ^ ) X S p - ' ( m >*ni:) ■ 1 1 1 , nii X'P; {in,, 111,} + XjG ’,{in,, 111,} +X'[p;{ni1,m ,} - P| {in,} - Pt {m }] < +X [ G , {111 ,111,} - ( i , {111,} - C i , {i n ,} ] +XJ [G ', {111,, 111,} - C i , {111,} - G ', {111,} ] Now, note that p!{m i} + p '{m .’} = P! { " V '” :} so we have 0 = X‘(1 - X ) ^ ^ p : (m|,in,)[XP,: {in,,111,} + G {,{m l,111,}] 111, HI; or g,: (m l,m ,) + g ,,( m ,,in 1 ) = G{, {m,,!!!,} = - X P ^ i n ^ m , } . (A-IX) 7 3 Now, we eun write the second term in (A -15) as = \ X X s < - ( ’ ’ I ’ 1 ” ) X ( n " r - - i ) x ( 1 1 " ) + \ X X t ? ( r - ’ r - 1 ) x ( n “ Wn “ r) = \ X X U (1 r :i •r- ” ) + 8 e (: r : : < r: i )lx (1 1 " r i )x (1 1 “ r” ) < A ‘1 > = \ X X (5 1 { r-1 -1 ' }x (1 1 ~ 1 )x (" ~ 1 / ) = “ t X X 1’ i' ■' ! x l " " r i)x(" - In (A-lfi) and (A 17), we need Cj',\ and C»\>(ni), respectively, which we can now find: ClL ,: •{m^ = -A^jT P,: {m ,m ,} = -2AP,'{m} (A-20) rn : ilk: and (i,, = = - A ^ F ^ m } = -AF^. (A-21) ^ in m In (A -lfi). we also need Ci ’, , which we can now find: <Xj = (A-22) = ^‘X P 'W = • m Thus, using i U;(H) = I I I p ,(m ,,in -.i n t)x( 1 1 - m, }\(n - m )x(n in, n i | m ' i i i , ■ ^ 7 X X P ''{m ,,m ,}x(n — n i , ) x ( h - m , ) ^ in | in +X ^ P | {m)x(n - in ) - XlP" rn which can be written as Q ,(n) = III p,(m , in: ,m ,) iii | r n . i n . x(n - in, )x(n - in ,)x(n - in ,) x(n - in, )x{n - i n , ) -X +x(n - m, )x(n - i n ,) +x(n - m , ) x ( n - in,) x(n - m,) +X: + x ( n - m : ) - X ' +x(n - in,) By taking the summations are over the same range M, we can write J IA-2.M (A-24) 75 M M M y , m ) = £ 2 £ i m I =J ni i =1 m 4 - I p ,( 0 1,.Ill,,m,) +p,(ml,m,,in,) + p ,( m „ m l, m 1) + p,(m ,,m ,,m l) +p,(in,,m,.m; ) x(n - m, )x(n - in, )x(n - in,) — 3Xx(n - in, )x(n - i n ,) +3X:x(n - m ,) - X' Now, we sec that we can def ine a symmetric third order DPOS kernel as p ,(111, ,m ,.tn() + p ,(in,,in ,,m ,) +p,(ni_.,iii|.ni,)+ p ,(ni_,.in,,iii,) + p ,(m l,in!,in,)+ p,(in,.in,.m,) such that our orthogonal third order functional can lie written as p ,(111,, m,, in,) = | n (A-25) M M M p\(ni,, in,, m,) i n , - I ill % - I rn , - I x(n - in )x(n - in , )x(n - in ,) ~3Xx(n - in, )x(n - i n ,) +3A'x(n ~ in ,) - X’ We can now infer a formula for the j lh order functional. We define the symmetric j'h order DPOS kernel as P>( in.,. . m K p ; { '" ......... (A-27) J! Then, the j '1 order functional of the DPOS is given hy M M ^ S n) = X XP^(m m J X , : , h=" VJ 1 1 j i-ii (A-2K) where f 1 1 L i - h , is the binomial coefficient and 7b J 1 - j! J - h ; ( j - h)! h! 77 APPENDIX B: DERIVATION OF THE FORMULA FOR ESTIMATING THE DISCRETE TIME POISSON ORTHOGONAL SERIES (DPOS) KERNELS BY ( ROSS-CORRELATION In this appendix, we derive the estimation formula for the j"1 order DPOS kernel using the property that the j'1 ’ order instrumental functional is orthogonal to all functionals of the DPOS except the j,h order functional. This property can he stated mathematically as n j _ I1 1__ 1 ]Q ,i, where 0 is the i'1 ' order functional of the DPOS and l : is the j"' order instrumental functional. By equating the system output to the DPOS and taking the cross-correlation of both sides with the j,h order instrumental functional, we have = = -X.x{n - r.) + X x(n - m, )x(n - m , ) -A.x(n - m , ) - \x (n - i n , ) + X2 0 for in, = m . for in. * m , and applying relation ( B - l ) with j= 2 gives (B-3) (B 4) 7lJ y(n)l, = Q ,I, y(n)[x(n - m, )x(n - i n ,) - Xx{n - ni,) - Xx(n - in,) + X: ] x(n - r, )x(n - r ,) \{n - in )x(n - m , ) Z X p o . - ' ) -Xx(n - r,) - Xx(n - r , ) ► -Xx(n - in ,) - Xx(n - i n ,) 11 i ■ + A / +A. x(n - r, )x(n - r, )x(n - ni, )x(n - rn ,) Xx(n - r, )x(n - r. )x(n - in ,) Xx(n - r, )x(n - i , )x{ 1 1 in ,) +X x(n - r )x(n - v,) -X x(n - r, )x(n - m, )x(n - i n ,) = 2 - 2 - P :( l' ' r-) ,-------------------------------------------------------------------- ,------------ , ' +X'x(n - r, )x(n - in ,)+ X " x(n - r, )x(n - 111, ) - X'x(n - v,) -Xx(n - r, )x{n - rn, )x(n - rn ,) + X" x(ri - r, )x(n - m , ) + X x(n - r, )xfn - n i .) - X!x(n - r ,) +X: x(n - m ,) x (n - m : ) -X 'x (n - r n ^ - X ’xfn -m_, ) + XJ = X P, {in,,in,} + Xl[P!{m, . 111,} - P; (ni!, in, }| + X*[ Pi - P , 1 {ni,,ni,}] - x[V h!{iii,) + v [h:' - p : jm, III - x [ x i> ! {m.) + x ‘[p :'- p '{ m , }|| + xjxp: | P I [.{.n, . 1" }) + - ! ' ' ( { I (.{in,,m }}|] +x [xp; « 11- {■»,})+xj ( p:1 - p ‘ ({n. {m , })]] + x-[x p:(i i |.{m , } )+ x-[p :' - p.: ( ( i (.{in,})]] - x'[x p: ] -x [ x ’p!({2}.{in,, 111,})+ X'[p:’ - P,'(|2(.{m ,.m ,})]] + v '[x p :(( 2 ).{ml} ) + x j p ; - p ! ( i : } .{ i n l })]] +x [xpi {12}. {1.1,})+X’ [ p; - p;« 2 (. {.11,}) ]] - X'[ xp; ] + x [x:p : ] - x'[xp;] - x’[x p: ] + x v : = X'(l - X)P;{m ,,m ,} +X'(I -X)[pJ{ni , m , } - Pi1 { m ,} - P!{m_,}] - V ( l - ^-)[P.'(( 1 >.{■>),.in } ) - P '( { l( .{ in ,} |- P '( |ll,{ m , - X ‘(l-X )jP !({2}.{m l, m J} ) -P ! ( { 2 1 ,(m l} ) - P : ( ) 2 |. { r a .})]. Now, note thut P ,(A .{m 1} |+ P|,(A .{m J } ) = P i '(A .{n,,. , » } ) no we have y{n) x(n - ni 9 )x(n - m ,) -Xx(n - m ,) - Xx(n - m ,) + X: X (I - X)P; {111 ,, 111,}. Using (A-27) for this ease gives P;{m , 111,} = 2p',(in,,ni,) and the formula for the symmetric second order kernel is then " X W i T n y(ll)x(n “ 1 1 1 Jx(n “ 111' ) 2 X (I - X) 1 2 X (I-X ) I 2 (1 - X ) [y(n)x(n - m , ) + y(n)x(n - m. ) J (B-5) y(n) or, using (B-2> and (B-4), SI I 2V(1 -X) y(n)x(n - m, }xfn - m ,) -X[X.(1 -X ) p ,(in l)+ A.pri] -X[X(\ -X ) p ,(m ,) +Ap„] +A.'p„ 2 X: ( I - X ) p ,(m , 111,) = 1 2 A . (I - X) y(n)x(n - m,)x(n - in,) -X (I - X)[p,(m|)+ p ,( m 7)] P . y (1 1 )x( 1 1 - in, )x(n in ,) -[pi(ni|) + p {m,)| I 2 (l-M P. .. The third order instrumental functional is | i |') = £ X X 8(ri - m, )fi(r, - in, )fi(i, m J (B h) x(n - r, )x(n - r )x(n - r,) - \ x ( n - r, )x(n - r ,) -X,x{n - r, )x(n - i ,) -Xx(n - r, )x(n - i ,) +A. x(n - r,) +A.’x(n - r,) +X:x(n ~ r,) = x(n - m, )x(n - m, )x(n - m ,) -A.x(n - in, )x(n - in,) - Xx(n - in, )x(n - in,) - X.x(n - in, )x(n - 111,) +Vx(n - m ,) + A , x(n - in,) + Vx{n - 1 1 1 J - V and applying relation (B-l) with j= 3 gives 82 y(n)],=Q,l, y(n) x(n - in, )x{n - m, }x(n - m ,) -Xx(n - ni, )x( 1 1 - i n ,) - Xx{n - m, )x(n - m ,) - Xx(n - 111, )x(n - 111,) +X'x(n - m ,)+ X'x{» - in,) + X x(n - m ,) - X' X X £ p t('i-'< 0 x(n - r,)x(n - r, )x(n - r,) xfn - mj)x(n - m,)x(n - in,) -Xx(n - r , )x(n - r,) I [ * — I -Xx(n - r, )x(n - i .) -Xx(n - in, )x(n - in ,) i \ * i -Xx(n - in )x (n - mj i + +X x(n - in,) +X x(n - r,) +X x(n - ni,) +X‘ x(n - r,) +X‘\(n - ni,) -X' = Z £ £ P i { ri - r: - 0 r, i . i t x(n - r, )x(n - r, )x(n - r,)x(n - in, )x( 1 1 - in, )x(n - m , ) -Xx(n - r, )x(n - i\ )x(n - r,)x(n - in, )x(n - m , ) -Xx{n - rt )x(t\ - r, )x(n - r,)x{n - m, )x(n - m ,) -Xx(n - r, )x(n - r, )x(n - r,)x(n - m,)x(n - m,) +X’x(n - r )x(n - r, )x(n - r,)x(n - 111 ) +XJ x(n - r, )x(n - r, )x(n - r,)x(n - in , ) +X* x{n - r , )x(n - r,)x{n - r,)x(n - m , ) -X'x(n - r, )x(n - r, )x(u - r,) -Ax(n -Ax(n - -Ax(n - +A: x{n +A: x(n +A' x(n +A: x(n +Vx(n - +A: x(n +A: x(n +A: x{n +AJ x( n — + S X Z P ' ( ri’r: ’r') i, r» i, - A ’x{n - )x(n - r, )x{n - m, )x{n - m, )x{n - m ,) )x(n - r,)x(n - m L )x(n - m, )x{n - m ,) )x(n - r,)x(n - m, )x(n - m, )x(n - in,) )x{n - r,)x(n - ni, )x(n - in,) )x( 1 1 - r,)x(n -m ,)x(n - m j )x(n - r, )x(n - 111, )x(n - in,) )x(n - i , )x(n - in, )x(n - in ,) )x(n - r,}x(n - in )x(n - in,‘ )x(n - r,)x(n - in, )x(n - in,) :)x{n -r,)x(n - m l)x{» - m , ) ,)x(n - r,)x(n - in, )x(n - in,) ,)x(n - r,)x(n - in, )x(n - in,) )x(n - r, )x(n - in,) -A'x(n - r, )x(n - r, )x{n - m ,) -A'x(n - r, )x(n - r. }x(n - in,) — A.1 x( u —r, )xf n - r, )x(n - in ) -A x(n - r, )x(n - r,)x(n - m: ) l c 1 ri )x(n - r,)x(n - m,) -A'x{n - r ,)x ( n - r ,)x ( n - m ,) -A'x(n - r, )x(n - r,)x(n - m_,) - A ’ x(n - r: )x{n - r,)x(n - i d ,) +A4 x(n - rt)x(n - r,) + A4 x{n - +A4 x(n - r,)x(n-r,) A’x(n - r,)x(n - m,)x(n - m,)x{n - m,) +A' x(n - r,)x(n - m, )x(n - m , )x(n — m ,) +A:x{n - r,)x(n - m, )x(n - in, )x(n - m,) -A*x(n - r, )x(n - in, )x(n - m , ) -A*x(n -r,)x(n - m,)x(n - m,) -A'x(n - r, )x(n - in, )x(» - in,) -A' x(n - i , )x( 1 1 - in, )x( 1 1 m ,) - A ’x(n - r.)x(n m,)x(n - m,) -A'x(n - r, )x(n - m: )x(n -111,) -X' x(n - r, )x(n - in, )x(» - 111,) -A' x(n - r, )x(n - m t )x(n — in ,) - A ‘x(n - r,)x(n - m,)x(n - in,) + X X X P ' ( ri ' r- ’-r')' A4 x(n - r,}x(n - m ,) + A . 4 x(n - r, )x(n - in,}+ A4 x(n - r,)x(n - m ,) +A4 x(n - r, )x(n - 1 1 1 ) + A4 x(n - i, )x{n - m , ) + A4 x(n - r, )x(n - in,) +A4 x(n - r,)x(n - m,) + A4 x(n - r,)x(n - m,) + A4 x(n - r,)x(n - in,) -A'x(n - r,) - A \( n - r,) - A^xfn - r,) - A'x(n - m jxfn - m,)x(n - m,) +A4 x(n - in, )x(n - in,) + A4 x(n - in, )x(n - m , ) + AJx(n - in,)x(n - in,) -X x(n - in,) - Asx(n - m,) - A%(n - in,) + A' K5 = X 'P,'{iiipni,.in,} + X 4|P,’{in,, 111, . n i,} - P,'{mr niJtin,}j +X'[P} {iiipiii ,,m ,} - P '{ in j,m , , i n ,}] + V'[P" - Pj{nipin,,in,}j -X 4 P h ilip i n , } - X'[p|{nipiii,} - P( {ni| , 111.}] ~ X jp" - P , 1 { n i p m , }j -X 4P; {nip in ,} - V[ P {inp n i,} - P,: {m p m ,}] - X jp;' - P , 1 {ni,. i n ,}J -X 4 P; {m ,, i n ,} - X1 } P| { m ,, m ,} - P,: {m ,. m ,}] - X'[ Pi' - P| {in .. 111,} ] + VP,’ { 111, } + V'lP',' - Pi {in,}] + V P j {111.} + V f Pi - P| {ni,}] + X !’i {111,} + X [p, - Pj{m,}| - X ' P, - X ’P,'({ 1-2 J.{nipin,,n i ,}) — X [pi({ l,2},{niptn_,,m,}) - P" ({l,2},{nipin ,, in, })| -X' [p; - P!({l.2},{mpin,,ni,})] -X 4P;{{ l,3},{iiipiii,,m,})- X'[p|{{ 1, 3 },{inpin,,in,}) - P( {{l,3 },{m,.in ,,m ,})] -X'jp;' - Pi({ 1, 3},{in,,in,,in,})] — X*P, ( { 2 , 3 {nipin: , i n ,}) - X'[Pi({2.3},{ n i p m - P'(-j2,3},{nipiii , . m ,})] -x[p;’ - p|({2.3},{iiipiii,,ni,})] +X’P; (j l,2},{m ,m ,}) + X''[P,5({ 1,2},{in, ,ni: }) - P; (j 1,2},{mpiii_.})] +X [p; - P,’({ l. 2 },{mt.n i,})] +X4P,; ({l.2},{nipin,}) + X'[p,'({ l,2}.{nipin,})- P;’({l,2},{mt,n i,})] +X‘[p;’ - p ; ( { l . 2 },{m,,m,})| +X4P,: ({ l. 2 }.{m,.m,}) + X'[pj({ 1. 2 }.{m ,.m ,} )- P ^ j l, 2 [,{m ,,ni,})] +X [Pi - P '(-! P 2 ^.{m,,in,})] + r [ p ; - p ; ( { u } , { n i 1,m ; })| +VP;({],3}.{mr m i}) + X'[pJ({l 13}.{mr m ,} ) - P ; ( { l ,3 ^ { m r m t})| +X' [p;’ - Pj({l,3},{m,,m4})] +VP;({l,3},{m ;, m l}) + Xs[pj({],3},{m,,m4} ) - P;({l.3}.{m,,m,})] +X"[p;' - P!({ 1.3},{in; ,in,})] +X4P; (!2.3}. jm . 111..}) + X’jp.'fp. .}) p;'({ 2.3}.{m,.m; })] +X' [p; - P:({2.3},{ml.m ,})) +X4P;(}2.3},{m,,ni,}) + X'[p,‘({ 2.3}.{m,,ni,}) - P;({ 2.3},{ml.in t})] +X'jpi' - Pj({2.3}.{ni,,in(}}J + V P ) : ({2,3},{m: ,m,}) + X'Jp,,({2.3}.{m: .in,})- P;({2.3}.{m.,in,})] +X [p; - P'({2,3}.{ni:,m,})j V |p ; - p ; ( ^ })] -X'P|({l.2},{m : } ) - V [P; - P ! ( { I ,2 },{iii })] -X'p;({l,3}.{m l } ) -X '[p ;'-P l({ l,3 } .{ m 1})| -^P ;({1.3}.{m : } ) - X '[ p ; - P i( { l.3 } ,{ m : })] - V p ;H l.3 } .{ n ii} ) - X f,[p;, -P!({1.3},{m,})| -X'P;({2.3},{nil} ) - X [ p ; -P;f{2.3},{m })) “■X s P) ({ 2 ,3}, {ni j }) - V [ P" - P[ ({ 2 ,3}, {m , })J - Xs P| ({2,3}. {in ,}) - Xf‘[ P" - P , 1 ( { 2 ,3}, {m t})] + 3V P1 ; K7 +VPi({3K{m1.m:,m l}) + X,’[p;, -P;({3[,{m1.m>.m(})] -^Pj({n,{ml,m f})-V'[p;i -P;({lK{nirn1(})j - v p :(m > v ■'»•})- ^ | p ' -X p; ({2}. {rn,, in ,}) - K\p; ~ ^ ({2 }.{m,, in, })| -X p;({2^{m1..n,})-X' [P; - ^2 M m ,,m ,})] -X p;({2l,{m ,.m ,})-V [p;' -p:({2},{ni,,m i})] -X'P!(PMmi-,M ) - X '1P' -P;({3K{m,.'m:})) -X.'P:({.M.{ml.m,})-X,'[p;, -P!({3K{m1.m,})| - VPiO3 J,{m,.m,} ) - XT-[PV -P!(W.{<n.,«i,})] +xp;(^i}.{m1})+x'jp;i -pJ({iM'«,})| + V P !({ U ,{ m ,}) + Xr'lPV - 1 M m , Ml +x'p!({a{ini} ) + v [ p ; - p ; ( m , { i,i 1})] +Xp;({2K{m1}) + X[p;, -P;({2},{ml})] +VPj({2l,{m:}) + r|p;, -P!({2},{m:})] +>.SfJ!({2},{m,}) + V‘[p;-P:({2K{ni(})] +xp;({3}1{ni1})+v[p;, -p;(|3^{nnl})] +VPi({.n.{m;})+Xh[p;, -P:({3M m;})] +XP!({-M-{mt})+X[pr - P^-M ^m ,})]-3 X p ;’ = X ' ( 1 +X(1 + X {1 ■M X )P ,1 { m !, in , - i} _ P< ({I'2 J-,{m,.i n , n i,}) — P,’({1.3},{in,,in,, 111,}) -P;({2,3}.{m ,, 111,. m,}) P [{ m ,,m ,,m ,} + Pl{m, }+ Pl{m,} + Pl{m,} -P i } - Pflnii.m ,} - Pj {m ,,ni,} P !({],2 [.{m ,.m ,.m ,})+ P !({l.2 [,{in l }) + P ;({ l,2 } .{ m ,} )+ P ^ I .2 K { n » 1}) -p ;H l,2 } .{ in l.m , } ) - P , 1({l,2},(m 1.m,}) - P m i , 2 }.{ m ,.m 4}) Pj ({l'-^}’{ni|. in: , in i}) + Pl({ 1.3},{ni, }) + P!({l,3J.{inJ })+P !({l,.^,{m ,}) -P!(]1.3},{in|,in: } ) - P ^ 1 . . ^ . { m ,. 111,}) - P ( '({1.3},{m ; , m (}) p;({2,3},{nil. m ; . m 1})+ P!{{2..^,{ni,}) + P j ( ] 2 ,3 [ .{ m ,l) + P ! ( { 2 .^ .{ m 1}) -p;({2,3},{,n , , m ,} )-P !({2 .3 }.{m , 111,}) - P ^ 2 , 3 } , { m : ,in,)) - V ( l - X ) + + + t },{m, .m ,,m ,} ) + P^({ I ^ { 0 1,}) + P;({!},{m: })+p;({l},{m 1}) — ({1 {«n,, n i,}) Pj({2},{ml, m , , m i})+ Pt l({2[.{ml }) +P|({2J,{m ,}) + P !H 2 [.{ m l}) - p ; 2 }.{m .. Ill,}) - I*! 2 >.{1 1 1 ,. , n ,}) _-P:({2}.{m ,.m ,)) Pi({3[,{m ,.m ,,m ,}) + P;({3|,{m,}) -P,l({3[,{inp m ,} )- P ] ({ 3 [ ,{ m 1,m ,}) It m n readily be shown that all the terms in the square brackets are zero, so the right side of the expression becomes A.'(l - X ) P t'{ni,.m P in,}. Using (A-27) for this case gives P,' {nil, m , . iiuJ = bp'^tn, , m „ n i |) and the right side of the expression cun be written in terms of the symmetric kernel as 6 X'( 1 - A . )p",(ill,, 111,,111 (). Thus, the formula for the symmetric third order DPOS kernel is do P i( m | , m_,, m ,) 6 V ( t - X ) + - ftX-’( l - X ) I rl\(l-A .) I y(n)x(n - m j x f n - m : )x{n - 111,) y(n)x(n - m, )x(n - in,) +y(n)x(n - in, )x(n - in,) +y(n)x(n - in: )x{n - m ,) [y( n)x(n - in,) + y( n }x(n - i n ,) + y( 1 1 )x(n - i n ,)] (B-7) ■y(n) 6 ( 1 - X ) nr, using (B-2), I ) of the DPOS is given hy p;(m,, .... m ) = T I - | S h! p»(lm mi ) (B-di h = I where the notation p ^ j m , , i n j J indicates the summation over the hll> order kernel values where the indices are all combinations in ascending order taken h at a dl time from the set {m m , ] ■ where h < j. There are ------- ------such 1 J h!( j - h)! combinations. APPENDIX C: DERIVATION OF THE RELATIONSHIPS BETWEEN INPUT-OUTPUT C ROSS-CORRELATIONS AND THE l)VS KERNELS To derive a relationship between the j U l order input-output cross-correlation and the kernels of the DVS. we equate the system output to the DVS, as in (2-1), and take the cross-correlation of both sides with the product of j samples of the system input. As discussed previously, the DVS kernels are defined to be zero on all diagonals (when any two or more of the indices match). Also, K 1 B has the same definition for DVS kernels as I’ 1 B had for DPOS kernels in Appendix A ami we will make use of relation ( A - l ) with p and P replaced by k and K. First, we take the expected value of (2-1) by itself: y(n) = k„ + £ k , ( r ) x ( n - r) + X X M rt’r’W n _ r ')x(n _ r ’) Z X k»(ri' r- •r > )x(n - ri )x(n - r )*(n - 1 1) i. r, tL + E " l > i ( r l ri )x(n - L ) - x(n - r,) • i ii — k,, + X , K | + \ K , + A . K , + ■ ■ ■ + AJ K , which can be written compactly as y(n) = k n + (C'-l) 1 = 1 93 where J equals the actual order of the system. Defining the symmetric i o r d e r DVS kernel the same way as we defined the symmetric i'1 ’ order DPOS kernel in (A -27). we note that Next, we cross-correlate (2 1) with one sample of the input: + £ £ X M rr r-•r')x(n - r,)x(n - r,)x(n - r,)x(n - 111) + X " ' £ k i(ri ri )x(n “ r ) x(n - ri )x(n — m) 'i ri = Xk„ +XK |{m } + V(K; - K j j m j ] +V'K',|m} + V j K 1 : - Kljm }] +XlK',{m} + V [K " - K\{m}] +AlK',{m[ + A .| 1Hi[k'; - K',{m[] k :' = x - Z r :('i o lor i £ " ' h = I f. - I Thus, we can write y(n)= k + ] ^k'(r,------ r ) (C-2) y(n )x(n - m) = k„ x(n - m) + ^ k , ( r ) x ( n - r)x(n - m) which can be written compactly as -y(n)x(n - m) = k„ + K[{n 4 Now note that . = i i-j ,} p « 'i - S ' Z k ^,n-r o , o r ' - 1 (i Thus, we ean write I ■y(n}x{n - m) = k„ + k,(m} M V I ;t M M X * X - " X k^(r 0 - 7 — T-^X ■ X k '( m ’r: .........0 1=1 V t . - l 1=1 t 1 ■ / - , , =1 , =. | i! S 1 M 5 > " " ....... \ (C-3) (C-4) Similarly, if we cross-correlate (2-1) with two samples of the input, we get y(n)x(n - m, )x(n - nt: ) k„x(n - m, )x(n - m, }-t- ^ k , ( r ) x ( n - r)x(n - m, )x(n - m , } + X X M r* 'r; )x( n ~ r< W n ~ r )x( n _ n li M n “ 1 1 1:) +XXX Mr '* -'r'Mn _ ri Mn “ Wn “ r')x (n “ m i )x (n “ m - > ) r, is r, +X" X k» ( r 0 x(n _ 0 ‘x (n - ri)x( n - m,)x(n - m , ) i i r , = X’k (( + A :K ]{m l,m ,} + V [ k '' - K [{m |tm,}] +A/K; {m ,, n i>} + A.'[kI - K ’{ m , m , }| + V [ K '! - K 1 , {nip n i ,}] +X K"<{ml, m , } + X 4[K'{ ni,, in.} — K'J {nir 111, }]+ v | k ; - +V K ; {ni,, 111,} + X . 11 *1'[K j{m ,, m _,} - Ki’{m l, m : }] + X J+''1[K'll - K {nis. m , }J which can he written compactly as — y< n )x( n - m )x(n - in.) = X K !!im i’m .-} A L , ,, I I X "'(K ^ {ni,, n i . } - K ^ ' I n v m . ^ + J X '''K;’{in,, m ,} J i - " i - I n I i - < Now note that K ! {m, } = 7— 5 <r-5) M I r , - 1 W X r t = i k"(m]tr........ r ) + k ;( m .,r ,....... r) M X VI X k"({m,,m,}],r: . ... r ] for i > and I.-I r, -I W V1 K 0 ,u[ V 1 '-)• t,^| I where we have defined the notation k '^ jm ,, . . m ^ , r(l+l. . , r, J to indicate the summation over the i 1 order kernel values where the first h indices are all combinations in ascending order (i.e., only one permutation per combination) taken i i j! h at a time from the set ! m m f where h < j. There are ------:---------such 1 1 S h!(j — h)! combinations. Thus, we can write % 4 ry (n )x (n - m )x{n - m ,) = k,, + k 1({ml.niJ}!) + 2 k s ,(m l.n i: ) (C -6 ) + I I*' h - ^ i - J + h - h ) f i! n ( i - h , . S I M K - U o i! M M % X' [<l : | ; E • X k 1 ,1 •' O j It we cmss-correlate (2 I ) with three samples ot the input, we get y(n)x(n - m, )x(n - m, )x(n - in,) = k x(n - m,)x(n - m,)x{n - in,) + £ k , ( r ) x ( n - r)x(n - in, )x(n - in. )xfn - m ,) + k , ( r , r. )x(n - r, )x(n - r, )x(n - in, )x(n - m, )x(n - i n ,) 11 r • + Z Z X M r- r.” r*) x ( n - r )x(n - r,)x(n - r,) x(n - in, )x(n - m ,)x(n - in,) + £ X £ £ M ri.rj.r„ r1) x(n - r, )x(n - r,)x(n - r,)x(n - r4) ■x(n - m, )x(n - m ,)x(n - in,) + X " S M h 0 x(n —r,) - x(n - r , ) ■x(n - in, )x(n - m, )x{n - in,) 9 7 = Vk,, + XiKj{m 1 ,ni,,m,} + ^[K '/ - Kj{m,,m: ,n i(}] + V K ‘ ’{nil,m ,,m ,} + [ K , {in,, m ,, n i , j — K^jiripm,.!!!,}] + V [ K - K l,{in,,m ,.ni,}] + V K J{ni^ni , , m ,} + A .4[K ({m,.!!!,,!!!,} - K Jjm, , 111, ,ivt, }j +A.'[Kl,{ m ,,m ,,in v}- K{{m 1,m : , m l}] + X '[K',' - K i j n v m i . m , } ] +X4K j{ m l, 111,, 111,} + V [K j{ n ir m , , i n ,} - K { { m , } ] +X'j K ,{111,, m ,.111; J - K , {m,. m ,.m ( }j +X [ K , - K {in,, 111,, 1 1 1 , }| + V K | {ni,, 111,, 111,} + X ' +1'[ K j [ in,, 111,, m ,} - K | {111,. m ,. i n ,} j +A. 11 * '[K 1 ,{in,, 111,, 1 11J - K, {in ,,1 1 1 ,1111} |+ X"* ' [ k - K 1 ,{in, .ni , 111,}| which can he written compactly as 7 y(n)x(n - m ^ n - m : )x{n - 111,)= 2 ,Kj;{ni,, 111; , in ,} |,_.t j h {K]’{m,, 111., 111!} — K|,+ 1 {m,. 1111,1111}) h - i i 1 = h ■* I 1K ' { ni,, 111,, 111,} Now note that i! k — I X M m i’r: .........O + k '( m ,,r , r ) + k^(ni r r, r ) \ \ M ((’ 7) { i-D ! 5L S k ({m i 'ni n i'}i r r< ) tor 1 - it « J i l and K ’{in,,in,,ni,} (i - n t i! M S 1 ^ ^ k ( m ,ni .n r .r ,. .. . r ) for i ^ V Thus, we can write y(n)x(n - m,)x(n - m ,)x(n - in,) = k „ + k l({m l , in,,in , ^ } + 2k' ^{m,, n i, , i n (J ,) 4- hk',(m , m , , m ,) (T-X) + I ! > • (i h ) I . : | l + ( VI M {i-h + X * it M M V 1 1 — Y ■ Y k'(inl,ni,,in„r, i,} We can now infer that if we cross-correlate (2-1) with j samples of the input, the result can he written as T T y O O f H 1 1 - nO = Z K h{ni! 111,} A <-| hlTtt X lo( K ! ’{fllt m } - K , htl{m ’ h = <> i = h + l + X * " ,K1 '{m mj .. rn 1) Now we note that K -{m i m ' ) = ^ T h ) ! ^ " S k '({m m l / r ''■) tor i s where the notation k ^ j m , , . .. m,} , rhH r ) indicates the summation over the i 1 ' order kernel values where the first h indices are all combinations in ascending order (i.e., only one permutation per combination) taken h at a time from the set f 1 I' { m n i n } where h S i. There are — -------such combinations. Usim* this 1 h!( | - h)! relationship and definition, we can write I ' y ( n ) f l x ( n - m 1) = ^ h ! k ; i({m 1 m | ) + t i i I I* It " " i - h + I i x" I i - h ) Column l i Column 2i column 3 j column 4i . . . Last columni i n te r p u ls e v a l u e ( v o l t s ) v a l u e ( v o i t s ) v a l u e ( v o l t s ) . . . number o f i n te r v a l fo r fo r for < . . in ts ta n c e * (msec) tau - T tau ■ 2T tau - 3T . . . *** A s c i i Table output F i l e Format fo r THIRD order Kernel •** For EACH f i r s t - t o - s e c o n d i n t e r p u l s e I n t e r v a l the f i l e c o n t a in s a ta b le a s follow *! F ir s t Rowi f i r e t - t o - a e c o n d I n t e r p u ls e i n t e r v a l , then the tau index (msec*) F ollow ing Rowe arranged in Columns as f o l lo w s (T - sample period ) i Column 1* column 2i Column 3i Column 4i . . . Last columnj s a c - t o - t h i r d v t l u e ( v o l t s ) v a l u e ( v o l t • J v a l u e ( v o l t e ) . . . number of ih te r p u ls e for for for . . . i n s t a n c e s in te r v a l tau ■ T tau ■ 2T tau ■ 3T . . . (msec s ) *** Example Output F i l e Nam* *** .01 .20.. c 2 . a . r 2 . p3. 3 0 .m A * A * * A A A A \ \ \ \ \ v\ \ \ V \ \ \ \ \\ v ----------- --------------- i n d i c a t e s p l o t f l l e t y p e \ \ \ \ \ w \ (m - matlab p l o t t i n g ro utine) \ \ \ \ \ \\ — - - f i r s t- to * s * c o h d p u ls e i n t e r v a l \ V \ V V \ \ for k3 s l i c e f i l e ONLY \ V \ \ \ \ -------* k ern el order (0-3) \ \ \ \ ----------------------------- -------- kernel type? p-DPOS kernel 101 \ \ \ \ ------------------------------- p u ls* _ r a t * /la l_ * c a l* roundsd \ \ V \ to n sa r s s t i n t s g s r \ \ \ ---------------------------in d i c a t e s th a t stim ulu s a r t i f a c t \ \ \ was smoothad \ \ ------------------- ------------------------ channsl numbsr ( i f not channal 1) \ _ ---------------------------- Last sagmsnt u>«d f i r s t sagmsnt ussd i i n c l u d * flinclud* Nlnclud* Finelud* # in c lu d s < s t d lo ,h > < s t r i n g . h > "nds d s f s . h" “k s r n s l d afs-h" i d s f i n * MAX SEGMENTS 2 0 i d s f l n * MAX..WIDTH 3 #d *fln » MAX R3 SLICKS 10 /* Global V a r ia b ls s */ int dsbug-0, smoothad-0, varbo**»0? /• Cqmmand l i n s o p tio n s . */ B*ln( i r g c , argv ) lnt argc; char * a r g v ( J j ( /* Main •/ /* Global V a r ia b lss • / • x t s r n l n t dsbug, smoothad. varboss; /* command l i n s o p tio n s . */ /* Charactar V a r ia b ls s */ char k p a th [254]; /* Ksrnal output f i l s nama path. */ char l i n s (12*); /* For ussr input. */ char #num *ufflxU * ( " . 0 1 ", ".02", - .03 " ," .0 4 " . ".05", ".06", *.07", ".00", -.0 9 " , " .10", " . 11", " . 12" . " . 1 3 * , " . 1 4 * , " . 1 5 " , " , 1 6 * , " . 1 7 " , " , 1 0 " , " . 1 9 * , " . 2 0 " ) char out I n f o [256]; /* Output f i l s inform ational root. */ char pathnam*[256); / • Ussr in p u t » in p ut/ou tp u t pathnam* r o o t. */ char u**rpath(25ti ); /* Optional u ssr output f i l s pathnam* root. */ /♦ R s g ls t s r V a r ia b ls s */ r s g l s t s r unaignsd Long 1{ r s g l s t s r unaignsd long j, j l . j2, 13; I * r ia g s */ ln t bin k f ll* « 0 ; /* Flag for binary ksrnal f i l s o p tio n . */ ln t display_*pocha»0t ln t mak* hlitogr*m*oj /* Mumarlc V a r ia b ls s +/ f l o a t amp_gain*looo.0/ /* fl o a t bln_ms j /* f l o a t bln_m*_dai /• ln t channal*1; /• f l o a t dsl_ms; /* f l o a t d _ t o . a convi /* f Loat apoch_m*r / * unaignsd long spoch pt s ■Q j J* f loat c p H , e _pl0 j /* f l o a t c p22, c _p22a; f l o a t c _p21, c p2 0; /* f l o a t c p33 , c .. p33a , c _p3 2; f l o a t c _p31, C p30j /* f l o a t c .f c ll, c _kl3 f /* f l o a t C_k23t / * ln t t l l s t y p s j /* ln t f i r s t sag, Last s a g / /< unaignsd long 12 i f l o a t i s l _ s c a l * ; /* f l o a t I5Z[WDfl_MAX_«VEHTS]j t unslgnsd long Idls^ml; /• f l o a t t f i l n a x t s u * ; / * F r s a m p lifis r gain . Kin width fo r i n t s r p u l s s l n t s r v a l s . bin ms / 2-Q Data channal numbar. Msmory fo r 2nd & hlghar ordsr karnal*. Convarsion fa c to r . Kpoch langth in m l l l l s s c o n d s . tfumbar o f aampL# p o in ts ussd par ap och . M u ltip lyin g f a c to r s for pi computation. M u ltip ly in g f a c t o r s for p2 Computation- M u ltip ly in g f a c to r s for p3 computation. M u ltip ly in g f a c t o r s for kl computation. M u ltip ly in g fa c to r for k2 computation. F ll a ty ps op tio n . * Ussr Inputi f i r s t / l a s t sagmant numbar. d ea ls fa c to r fo r I s i s . */ /* Iflls fo r a l l avantSi a l l ssgm ants(m sac) . * / num.xsis - l . */ * Running Ifil sum for naxt l n t s r v a l s . */ 102 f loat f l o a t f loat f l o a t in t int short unsigned long unsigned long ln t unsigned long f l o a t f l o a t f l o a t f l o a t flo a t f l o a t int f l o a t f loat unsigned long f loat i s i p r e v sum ZSI_*uml; tstmuml; JSI_eum_tot; k a d t l p t u Jc3_dt2 pt*; /* Running ISI sum fo r previous i n t e r v a l s . /* Running ISI sum fo r d t l . /* Running ISI « u b for dta. /* Sum o f a l l ISI* in m i l l i s e c o n d s . /* Humber of k2 ln te r p u ls * i n t e r v a l* . / • Number of k3 i s t - t o - 2 n d puls* i n t e r v a l s . num_pulses[MAX. 5ROMBNT6Ji/* Total number o f pul*** par segment. nu*_puliM _tot>Of / • num_ISI*j /* numk; / num_ptsj / ’ pO i / pO_dy / 1 pu lse.p rob ; /* p u ls e _ r a t e * o . Q; /' ■amp per«O.Q; /' ■amp par d ai / • segment; /* ■lice*(MAX K3 SL I C E S) ; tau a*; /' tau p t •; /■ t o t a*; t* Total numbar of p u ls e s . Total numbar of ISI*. * User inputt i k e r n e l s to compute. 1 Numbar o f p o in t* u n t i l naxt s tim u lu s . b Zeroth order P olsson kernel va lu e. 1 pO d iv id e d by acme con stan t. Stimulus pula* p r o b a b i l it y . Naan etlmulu* rat* (pule** per s a c ) . Sample period in m illis e c o n d * . ■amp.per/2 .0 Train segment number. /* kl s l i c e * to b* p l o t t e d . Memory for kl In mi 11 ls e c o n d * . Memory for kl in number of p o in ts . Total time In m i l 11 secon d*. /* Pointer a */ /* The binary nscope data f i l e u se s 2 Thi* program assumes that the six * short short f l o a t f l o a t f l o a t f loat f loat float f loat M ata topaNULL; •epoch p t r ; •ISI next ptrj • i s i prev ptr; •pi.top*NULL; •p i ptrj •val ptr; *val_ptr2i •val ptr3; bytea per sample, of short i s 2 b y te s . •/ / • Pointer to s t a r t o f raw data v a lu e s. /• P ointer for current epoch. / • i s i array p o in te r . / * i s i array p o in te r . /* S tar t f i r s t order p o lsso n kernel v a l i /• Running p o in ter fo r Polsson k ern el. ■truct ■ t r uc t s t r u c t k2 data k2 data k2.data *k2 p tr ; /* Running p o in te r for k2 data. •k2 top>NULL; / • Pointer to top of k.2 data. *k2 bot-NULL; /* Pointer to bottom o f k2 data. s t r u c t str u c t • t r u c t s t r u c t st r u c t st r u c t st r u c t st r u c t k2 data k2. data k2 data k2 _d*ta k2 _ data k2 data k2 _data k2 data *k2_newj /■ For new a l l o c a t i o n . •k 2 .p rev p tr ; / • for backward lin k in g . M t l p t r ; / • Running p o in ter fo r tau2 - tau l i s t , • d t l new; /* Tor new a l l o c a t i o n . • d t l p r a v p t r ; / • For backward lin k in g . •k2 ptr d t l ; / • Running p o in te r for k2 data. •k2 p tr _ d t 2; / • Running p o in te r for k2 data. •k2 p t r .l p 2 ; / • Running p o in ter for k2 data. s t r u c t k3_data • tr u c t k3 .d ata s t r u c t kl data • t r u c t kl .data s tr u c t k3 data *k3 ptr? /• * k 3 _ t o p " M U L L i / •kl_bot»NULL; / •kJ.new; /• *k3 prev p t r ; / Running p o in ter for k3 data. * Pointer to top of k3 data. * P ointer to bottom of k3 data. Por new a l l o c a t i o n . ' Por backward lin k in g . >• F i l e Pointer* •/ FILE *X tp, •tpt output f i l e p o in te r s . /* Function D e c la r a t io n s . */ e x te r n int ReadDatat); / e x te r n void ISIK istogram (); /* extern void showBpochO; /* e x te r n int sm oothArtifa c t ( ) ; / ' Read segment data (in r e a d .d a t a .c }. */ Hakes a histogram o f the ISXe. •/ D isp lay data for one epoch. */ smooth the stim ulus a r t i f a c t . •/ e x te r n lnt w r i t e .k B in a r y (), / • Write binary kernel f i l e (in b ln k u t i l . c ) * / The fo llo w in g are in k p l o t _ u t l l . c ex te r n lnt ex te r n ln t ex te r n lnt ex tern in t e x te r n lnt e x te r n int P lo t k l T a b l e (); /< P lo t k l_ m a tla b (); /* P lot_k 2_T ab le{ ) ; /■ Plot _k2__matlab () ; /* P lo t_ k J _ T * b l* (\; n P lot k l .m a t l a b (); f * Make RI ASCII ta b le output r i l e . Make RI matlab ready m f i l e . Make R2 ASCII ta b le output f i l e . Make R2 matlab ready m f i l e . Make R3 ASCII t a b l e output f i l e . Hake R3 matlab ready m f i l e . /* START 0F CODS FOR MAIM */ 103 /* Qat command l i n s o p tio n s */ 1 - 11 w h ila ( i < argc ) t I f ( strcm p( H-d" dabug - Xi It ( strcmpI m a k s h lsto g r a m a r g v l i ) ) - - 0 ) * - a “, ■ I f * r j v [ i | ) 0 ) " -h", - I f * r o v [ i] ) — D ) • r p v d ] ) - - 0 ) H _ y h • r g v t i l 1 — 0 > 1 li n a option* i f th*y •BOQth«d m 1; * l« * i f { strcmp| varbosa ■ 1 j 1 + ♦ ■ ; ) /* prompt for coumh< If ( Idabug I I id is p la y apochs I I tiulc* histogram I I Ismoothad l | j v a r b o s a ) (void) p r i n t f i "\nA ddltlonal coniund l i n a o p tio n s s r a : ” ); i f ( jdabug ) (void) p r i n t f ( u\nd » debugging mods" )? i f ( id is p la y . apochs ) (void) p r i n t f f “\na - l i s t sa la c ta d spoch data* )j i f ( tmake histogram ) (void) p r i n t f ( *\nh - mak# a histogram of tha in te r s t im u lu s i n t « r v « l i H j; i f ( ismoothad ) (void) p r i n t f ( H\n s * smooth tha stim ulus a r t i f a c t in tha raw data" ],- I f ( ivarboss ) (void} p r i n t £( ■\nv - varbosa - l i s t a d d i t i o n a l inform ation \n~ i; If ( i dabug I I i d is p la y apochs I I imaka histogram I I Ismoothad JI ivarbosa } < (void) p r i n t f i "VnEntar a l l c h o lc a s now on on* ll n a i * >; (void) get si l i n a 1: I f < s t r c h r i l i n a , 'd') ) dabug - 1 j l r ( s t r c h r i l i n a , ’a ’ ) > d i s p l a y apochs - 1; i f ( s t r c h r i l i n a , 'h 1> ) mak*.histogram - lj i f I s t r c h r i l i n a , ’s ' ) ) smoothad * 1/ i f I s t r c h r i l i n a , 'v ') ) varbosa ■ 1; ) ,* * • • * * START OF U5ER INPUT SECTION *“ •**/ /* oat tha Input pathnama */ (void) p r i n t f i "\nEntar tha NauroScopa filanam a without ■ •gssnt#* ) ; (void) p r i n t f { * \ n ( e . g . r w ithout , 0 1 ) i “ )r (void) g a t s ( pathnama )i / • oat tha s t a r t i n g and andlng segments • / do ( (void) p r i n t f i - \ n F i r s t segment l l - * d ) : *, MAX.. SEGMENTS ); (void) g a t s i l i n a )t (void) s s c a n fl l i n a , "Vd", t f i r s t . s a g )? ) w hila ( ( f i r s t sag < 1) fl ( f i r s t sag > MAX SEGMENTS) J j do ( (void) p r i n t f i “\nLast Segment (VI - V i ) j *, f i r s t sag, MAE segments ); (void) g a t s ( li n a )j (void) s s c a n f l l in a , "Vt", fcla st.sa g ); > whlla ( ( l a s t . s a g < f l r s t _ s s g ) || ( l a s t sag > MAX SEGMENTS) ); /* Gat tha ISI s e a l * f a c to r . • / (void) p r i n t f i H\nBntar s e a l s f a c to r for I5 la t " )i (void) g a t s ( l i n a )j (void) ss c a n f( l i n a , ”\ f ” t f c i s i . s c a l a )t >* Gat tha t r a i n data and ZSZs. */ 1(14 i f < J JtsadData ( pathnama, f l r s t s a g , la s t _ s a g , is i_ i c t l * , / * Inputs * / num^pulsas, 4num_pulaas_tot, ISI, b i s i iu n t o t , 4 d a ta ,t o p , /* outputs 4apoch__pta, i i M B p j x r , fcamp_gain, t p u l s a . r a t a , 4chsnnal ) / • outputs */ ) raturn; u i p p«c d2 - sam p.par/2 . Q; num i s i s - num p u lsa s t o t - 1; /* Tha numbsr of IS I s . */ /* l s i * u m _ t o t i s ths t o t a l of a l l ISIs for a l l sagmsnts, but not in c lu d in g tha lntarsagmant pauaa. Tha lntarsagmant pausa i s assumad to ba much largar than tha maan i n t a r v a l so th a t i t doaa not a f f a c t tha karnal computations. */ /* Oomputa tha apoch langth and tha t o t a l t r a in tima in m l ll a s a c o n d s . */ spoch .ms •* (f lo a t)s p o c h p ts * a amp pari to t ms ■ ISI.sum t o t + apoch ms; /* Hava uaar v a r l f y a m p lifia r gain (sin e# I hava found that form atting to sac tha u n i t s in tha nscopa program Is a common arror > */ (void; p r i n t f i "\nData f i l a says amp gain - %t amp gain ; (void) p r i n t f i “\ n p l s a s s V arlfy (y or n) t H )j (void) g a t s ( l i n a ); i f ( j s t r c h r ( lin a , 'y ') > i (void) p r i n t f i H\nBntar A m plifiar Oaim * ); (void) g a t s f l i n a ); (void) s s c a n f ( lin a , M Sf", fcamp.gain ) j (void) p r i n tf { “NnAmpliflsr Gain sat t o “ f amp g a in t; > d t o . a . c o n v * nds_vcal/amp gain; i* o p t i o n a l l y maka an ISI histogram . */ i f { maka.histogram ) iSlHistogramt ISI , num_pulsas t o t ) ; /* in p u ts */ / • O p tio n a lly viaw soma apoch data. */ i f ( d i s p l a y ..apochs ) ShowBpoch( data top,num. p u ls a s t o t,a p o c h p t s rsamp par,am p.gain m / ‘ Inputs*/ /* o p t i o n a l l y smooth tha stim ulu s a r t i f a c t . */ i f ( smoothad ) ( i t { s m o o th A r tifa c t( data top, num p u ls a s t o t, ISI, apoch p ts , samp pari ) ( I f ( d is p la y apochs ) showBpoch(data top,num p u ls a s t o t,a p o c h pts,sam p par,amp g a i n j ; / * In p u ts*/ ) • la s ( smoothad * 0; > ) /* Oat tha numbar of karnals t o computa V do t (void) p r i n t f ( "^nftntar numbar of karnals to computa ( 0 - 3 ) H ); (void) p r i n t f ( *\n0 fo r pO* )/ (void) p r i n t f ( ‘ \ n l for pO, p i 1 ); (void) p r i n t f ( "\n2 for pO, p i, p2" )/ (void) p r i n t f ( ~\n3 for pO, pi, p2, p3" )/ (void) p r i n t f ( *\n[ antar any nag a tiv a valua to g u l t program)\ti" ); (void) g a t s f l i n a )j (void) sa c a n f( U n a , "Hd1, 4 nurnk )j i f ( nurnk < 0 ) g oto claanup; ) w hila ( (numk t 0) II (nurnk > 3 ) ); i f ( (numk >» 1} 44 (num_pul»as_tot > 0 ) ) /* oat usar Inputs for *i /* f i r s t ordar karnal. •/ ( do /* Oat tha maximum daairad f i r s t ordar karnal la g . */ ( (void) p r i n t f ( " \n ln ta r tau in m illia a c o n d s (Hf to %f) i 105 *4>P J>«r, *poch_ms) i (void) gat*( l i n a ); (void) s s c a n f { l in a , " \ f M , 6tau_*s )j ) whila ( (tau_ms < sam ppar) || (tau.ms > t p o c h . u > ); tau p ts - < in t)( tau_ms/samp ..par + 0.5 } j i f ( dabug ) (void) p r i n t f ( "\ntau p ts - \ n M , tau p ts ); ) If ( (numk >■ 2) 66 (num_.pulsas to t > l> ) /+ Oat usar Inputs for */ /* sacond and third ordar karn als. •/ ( do / • Oat tha maximum dasirad ln ts r p u l s a d a l t a for tha sacond ordar k a r n a l.* / ( (void) p r i n t f ( " \nln ta r tha MAXIMUM 1NTRRPULSI INrut VAL to u«aH )j (void) p r i n t f ( - \ n f o r tha sacond ordar karnal c a l c u l a t i o n (m illis a c o n d a )s (void) gats{ l i n a ); (void) s s c a n f { l in a , " \ f ", 6dal as ); } whila ( dal as < . samp par ) ; do /* Gat tha in tarpulaa ln ta r v a l bin width. */ ( (void) p r i n t f i "Vnlntar tha XNTIRPULSE INTERVAL BIN WIDTH to usa" }; (void) p r i n t f < “\n fo r tha sacond ordar karnal c a l c u l a t i o n ( a i l l i s a c o n d s ) t ") ,• (void) g a t s i l i n a >; (void) s s c a n f ( l in a , H ^ f M , abln.ms ); ) whila ( (bln. k i < D) | | (bin a* > dal as) )s i f ( b in u < saap.par ) b i n a i ■ samp par; b l n n * d 2 - bln_.ms/2.0; (void) p r i n t f ( *\nTha mamory for sacond and th ir d ordar k arnals * ); (void) p r i n t f ( " \n w lll ba computad out to ^ . 3 f m lllis a c o n d s *, d a l a s ); (void) p r l n t f f H\nw ith an in tar pu laa l n t a r v a l bin width o f \.it a i l l i s a c o n d s . \ n \ b l n u ) ; ) /* Oat tha output p lo t f l l a typa for tha Karnals. */ do < (void) p r i n t f ( H\nchooss an output p lo t f l l a typa fo r tha karnals (0-3)* ); (void) p r in tf { M \n0 fo r binary karnal f l l a o n ly (fo r input to p r a d lc tlo n program)." ); (void) p r i n t f ( " \n l for ASCII ta b la f l l a * - " )j (void) p r i n t f ( HVn2 for matlab raady n f i l a s . ” )? (void) p r i n t f ( ~\n( antar any n agatlva valu a to q uit program )\nH J; (void) g a ts ( l i n a ); (void) s s c a n f ( l in a , H ^dH, 6 f i l a typa )> i f ( f l l a typa < 0 ) goto claanup; ) w hila ( f i la _ t y p a > 2 ) i i f ( f l l a typa > 0 ) { (void) p r i n t f ( "VnAlso sava a i l tha k arnals t o a binary f l l a fo r tha p r a d lc tlo n program? (void) p r i n t f ( "\n(y or n )i " ); (void) g a t s ( li n a }; i f ( * t r c h r ( li n a , '¥ ') 66 I s t r c h r (li n a , 'n') ) b l n _ k f i l a - It ) • I s a i f ( f l l a _ t y p a -» 0 ) b i n . k f l l a * 1) /* Oat tha th ir d ordar karnal s l l c a a to ba p l o t t a d . +/ i f ( ( f l l a _ t y p a > 1 ) 66 (numk >■ 1) ) { (void) p r i n t f { "VnKhtar f ir s t ~ t o - s a c o n d pulsa l n t a r v a l s to usa ■ )j (void) p r i n t f ( “\n fo r th ir d ordar karnal s l l c a a ( m illls a c o n d s ) " )j (void) p r i n t f ( " \n (a n tsr n a g atlva valua t o q u it) \nn ); for ( i » 0 j 1 < KAX_K3_SLIC1& !+♦ ) i I O ft do < (void) p r i n t f i “\ n 8 l i c a Xd (m illla a c o n d a )t M , i + i }; (void) g a ta( lin a ); (void) a a c a n f( l i n a , m \tm , fca lic* a [l) )i ) w h ila ( a l l c a a ( l ] > d a l m a ); 1C < a l i c a a l i ] c 0.0 ) braak; l f ( 1 UAX_,K3 r SLICKS - 1 ) (void) p r i n t f ( "\nNo mor* a l l c a a allow ed. \ n “ )r ) ) /* Construct tha output f i l a path. */ (void) s tr c p y ( (char * )o u tin fo , (char *)pathnam* )/ (void) i t r c « t ( (char * ) o u t in fo , n u a i u f f i x ( f i r a t aag-1] ); (void) i t r c i t ( (char * ) o u t l n f o r n u a a u f f i x [ l a s t a * g - l | ); if ( channal I• 1 I ( (void) i t r c a t ( (char • j o u t l n f o , " . c H ); (void) * p r ln tf( lin a . ”S-d", channal ); (void) i t r c i t ( (char M o u t in f o , li n a ); ) i f ( smoothad ) (void) a tr c a t{ (char * ) o u t l n f o ( ".a" )/ (void) f t r c « t ( (char •J o u tin fo , M . r M ); (void) a p r i n t f ( l i n a , *%&* r ( l n t ) ( p u l a * r a t a / i a i sc a la + 0 .5 ) ) ; (void) a t r c a t ( (char * )o u tin fo , li n a )? (void) atrcpy( (char * )uaarpath, (char * ) o u t in fo )j i f ( f l l a typa » 2 ) ( /* Oat an o p tio n a l output t i l * pathnam*. */ (void) p r i n t f i **\hOutput f l l a root w i l l ba [ \ i ) . Hf uaarpath ); (void) p r i n t f ( -\nP o you want to changa it? (y or n>: H )j (void) g a t s ( li n a }; i f ( s t r c h r i l i n a , 'V') ) { (void) p r i n t f ( "\nEntar tha naw output f l l a root) N i t (void) o « t i ( uaarpath ); ) > / * * • • • • end or USER INPUT SECTION ♦***•*/ /* Computa pulaa p r o b a b i l i t y from tha pulaa rata and aampla pariod. •/ pu laa.pr ob ■ pulaa_rata * (**mp_par/1 0 0 0 .0) / i a i a c a l a ; (void) p r i n t f ( "\nPulaa t r a i n p a r i H t t r i a p a c ifia d in data f l l s i * ); (void) p r i n t f ( "\n pulaa rata » \ t pulaaa/aacond *, pulaa_rata >; (void) p r i n t f ( " \n aampla parlod - \ t m lllis a c o n d a *, aamp par >; (void) p r i n t f i "\n pulaa p r o b a b i l it y « p u la a . rat**a*mp_par/Jai acala - \t ", pulaa prob)j (void) p r i n t f ( "\n numbar of pulaaa • %ld in*, num_pul*aa t o t ) t (void) p r i n t f i *\nComputad pulaa t r a in param ataraiH ); (void) p r i n t f i “\n t o t a l ta a t tima - \ . 2 t mlnutaa H, t o t m s/60000, o ); (void) p r i n t f ( - \ n t o t a l numbar of data aamplaa - VI ", (in t) (tot_ma/aamp_par ♦ 0 .5 )); (void) p r i n t f ( "\n a c t u a l pulaa p r o b a b i l it y - Spulaas/tfaamplaa ■ \ f \ n H, ( f lo a t )n u m p u la a a _ t o t / (tot_rna/aamp_par) ]* /****** START OF ZEROTH ORDER KERNEL CONFUTATION /* Tha sar oth ordar karnal la Juat tha avaraga output ovar tha a n t l r a du ration of tha output. Thu*r tha coda balow •im ply add* up a l l tha maaaurad output aamplaa and d lv ld a a by tha t o t a l numbar of aamplaa. Tha t o t a l numbar of aamplaa ia tha numbar of aamplaa that would hava baan takan i f tha output waa maaaurad c o n tin u o u s ly from tha d a llv a r y o f tha 107 f i r s t stim ulu s u n t i l a f t a r tha l a s t s tim u lu s . S ines tha output i s not a c t u a l l y H t i u r * d co n tin u o u sly , thosa v alu as that war# not M t i u r s d a r t a n u a t d t o ba la ro . Dua to tha u s u a lly larga numbar of saro v alu as ( a s p a c l a l l y i f tha intar-sagm snt pausa i s lo n g ), tha pO valua w i l l u s u a lly ba vary sm all. */ (void) p r i n t f ( "\nDolng saroth ordar DPOS Carnal c om p utation . . . \ n “); pO - 0.0; I S X n a x t p tr ■ ISI; for ( 1*0; j < num ISIs; j + + f ISI_naxt__ptr44 ) /* Loop ovar a l l I S I s. */ ( i f { apoch_ms <- * l s i naxt p tr > /* i f anothar stim u lu s o ccu rs bafora */ num_pts * apoch_pts; / • tha and of tha apoch, than add tha */ • I s # /* p o in ts on ly up to tha stim ulus tim s. */ num pea - ( l n t ) ( +XSI.naxc p tr / samp par ); apoch p tr * data top + j*apoch pts; for ( 1*0; 1 < num p ts; i + + , apoch ptr-** ) /* Loop ovar a l l sampla */ /* p o in ts of aach apoch. */ pO ♦ - ( f l o a t ) *apoch ptr; ) apoch .ptr * data top ♦ {num p u ls a s t c t - l ) * a p o c h p t s ; / * Add In tha l a s t ap o ch .* / for t 1*0; 1 < apoch p ts; i*4, spoch ptr** ) pO ♦ ■ ( f l o a t ) * apoch ptr; pO - p O /(to t ms/samp par) * d . t o a conv; /* Complata avaraga by d i v i d in g by */ /* t o t a l numbar of p o in ts , and apply c a l and g ain tarm s. */ (void) p r i n t f i “ vnZaroth ordar DPOS karnalt pO ■ \ a Vn*. pO); /* * * • * • END or ZEROTH ORDBR KEANEL COMPUTATION • • * * * • / / * • • • • * START OF FIRST ORDER POlSSON KERNEL COMPUTATION ••* * * * / i f { (numk >■ l) fefc (num..pulsas t o t > 0 ) ) < /* A llo c a ta nwsory for tha f i r s t ordar karnal v alu as and l n i t l a l i s a t o s a r o .* / pi top * ( f l o a t * > e a llo c ( (unsignad l n t ) t a u p ts , s i s a o f (f l o a t ) >? i f ( ip i top ) /* v a r l f y s u c c a s s fu l a l l o c a t i o n . */ { {void) p r i n t f i "\nC0ULD NOT ALLOCATE MEMORY FOR pi I \n* ); goto claanup; ) (void) p r i n t f i H\nDolng f i r s t ordar DPOS karnal c o m p u t a t io n ... \n*J; /* Tha f i r s t ordar karnal i s }ust tha avaraga rasponsa. */ fo r ( }*0; j < num_pulsaa_ t o t ; j++ ) /* Loop ovar a l l r aspon sas. */ ( • p o c h p t r ■ d a t a .t o p 4 j * a p o c h p t s ; p l_ p tr « p i .to p ; /* For aach lag, add tha currant rasponsa t o tha t o t a l . */ for ( i«0; i < tau_pts; i44, pl_ptr4+, apoch. ptr** > * p i.p tr 4 ■ ( f l o a t ) *apoch ptr; ) /* computa tha w alghting f a c t o r s . */ c p H ■ d . t o a conv / ( f l o a t ) num_pulsas t o t / {1 . 0 -pulsa prob) ; c piQ - 1.0 / ( l . 0 -pulsa_prob )/ pO d - c.plO * pO j i f ( varbosa I I dabug ) ( (void) p r i n t f i “\ n F ir s t ordar DPOS karnal formula w alghting f a c t o r s * ■); (void) p r l n t f ( H\n fo r f i r s t ordar componant* *a *, c _ p l l ) ; (void) p r i n t f ( “\n fo r saroth ordar componanti Aa \ n H, c _ p i0 ); ) /* F in is h f i r s t ordar P olsson karnal computation */ for ( 1*0, p l_ p tr -p l..to p ; 1 < tau^ pts; i**, pi_ptr+* ) #Pl_ptr ■ *pi_ptr * c . p l l - p0_d; /* by a p p ly ing m u lt ip ly in g f a c to r and */ mx ) /* su b tr a c tin g zeroth ord*r kern el product. */ /*«*«*• or p iu st ORDER POISSON KERNEL COMPUTATION *•■*•*/ /****** START CP SECOND ORDER DPOS KERNEL COMPUTATION •****•/ /* Th* M cond or . */ i f { (numk >- 2) Alt (num_pulses. t o t > 1 ) ) { (void) p r i n t f ( "\nDolag second order DPOS kernel c o m p u t a t io n ... \ n H > k.2 d t l pt a * Of t* Begin the Mumming algorithm . •/ for ( 1«0; i < num ISI*; )*♦ | /* Loop over a l l ISI*. */ < i s i euml - o.O; k2 ptr * k3 top; for ( J l * i ; j l < num ISI*; jl++ ) /* Loop over a l l eucceedlng ISI*. */ { 251 euml + - f i f ( ISI suml > d*l m* ) /* Stop i f max i n t e r v a l exceeded. */ break; /* rind the p o s i t i o n for t h i s i n t e r - p u l e e In te r v a l in th e l i e t . *t w h ile ( 1 2 ptr ) ( i f ( XSI.suml < (k2._ptr->dtl - bin_a* d?) ) ( /* i f ISI euml le * * than current d t l , then */ /* t h i * in t e r - p u l e e i n t e r v a l le not in the l i * t , *o •/ /* a l l o c a t e memory for i t . */ k2 new - (a tru ct kl data * )m alloc( e l i e o f (s t r u c t kl data) ); If ( tk2 new ) /* v e r i f y *ucce**ful a l l o c a t i o n . */ ( (void) p r l n t f f H\nCOULD NOT ALLOCATE MEMORY FOR NEW DELTA1 FOR p2I Vn" ); goto cleanup; ) k2 d ti.p t» + + j /* A l l o c a t e memory fo r the tau value* and i n i t i a l i z e to zero. */ k 2_n ew ->k val..top « ( f l o a t * > c a llo c ( (unsigned i n t ) t » u p t i , ■ i l e o f (f l o a t ) ); i f ( ik 2 n * v -> k v a l top > /* V e r ify lu c c e a a f u l a l l o c a t i o n . • / ( (void) p r i n t f ( H \nCOULD NOT ALLOCATE MEMORY FOR NEW TAU LIST FOR p 2 ( goto cleanup; > i f ( 13 p tr *• k2 top J /* If current d t l 1* f i r e t in l i s t , */ ( /* then add new d t l to top. */ k2 new->next ptr ■ k2_top; k2 top • k2_new; > e l i e < k2__pr*v_ptr->ne*t ..ptr - k2_new; /* Otherwise, I n s e r t in l i s t * / ka.new->n*xt_ptr ■ k 2 _ p tr ; / "between p r e v i o u s , curren t v a l u e s . * / ) i f ( bih_ms„d2 > samp_p*r_d2 ) k2_new->dtl - ( f l o a t ) ( (ln t ) (lsi_*um l / bin_ms + l . o ) > • bln.ma - bln._m*_d2; l(W als* k2 n#w->dtl - xsx_suml; k2_n*w~>num ■ 0/ /* i n l t l a l l s a th* number of ln sta n c a s */ /* in t h i s bin to s«ro. */ k2_ptr - k2 naw; braak; } /■ and i f { ISI suml < (k2 p t r - > d t l - bin_ms_d2] ) */ i f ( I S I s u m l <• <k3_ptr->dtl + bln_ms d2j ) /* braak out of loop */ braak; / • i f sam* in t e r v a l found. */ k2_prav ptr - k 2 .p tr; /* Rasp track of praviou* addrass. */ k2 ptr ■ k2 ptr-^ naxt ptr; } / • and w hila ( k2 ptr } */ if ( Jk2 ptr ) /* If naw ln ta r v a l i s largar than currant imximum. */ ( >* i t i s i fu a l largar than max d t l In l i s t , than */ /* a l l o c a t * mamory for i t and add to tha bottom. */ k? naw - [stru ct k2 data * )malloc( s i x a o f ; g oto claanup; I k2_dtl pts++; /* A llo c a t * mamory for tha tau valuaa and l n i t i a l i x a to xaro. */ k2 naw->k val top » ( f l o a t * ) c a l l o c ( (unsignad ln t) t a u p ts , s i i a o f ( f l o a t ) If ( Mk2..n*w->k v a l top) ) /* V arlfy s u c c a a s fu l a l l o c a t i o n . */ { (void) p r i n t f ( "\nC0ULD NOT ALLOCATE MEMORY FOR NEW TAU LIST rOA p 2 1 \n" ); g oto claanup; ) i f ( k2 top j < k2 bot->naxt ptr k2 bot - k2 naw; > alma ( k 2 .to p - k2_n#w; k2 bot m k2_naw; > I f ( b in .m*_d2 > samp .par d2 ) k2 n*w->dtl ■ ( f l o a t ) ( (in t) (1ST anal / bin a s + 1.0 ) ) * bln ma - b i n m s d2; • l a * k2 _n*w->dtl * i s i suai; k2 naw->num - 0/ k2_n*w->n*xt ptr - NULL; /* Sat naxt polntar to n u l l to */ /* mark as bottom valua. */ k2_ptr * k3_n*w; ) /* and I f ( ik3_ptr ) */ /* Now, add tha naw v a lu a s . */ (k 2 _ptr->num)+ + > /* Incramant tha numbar of lnstancaa in t h i s b ln . */ •poch ptr ■ dat*_top + (jl+ l)* a p o c h p ts ; v « l_ p tr * ka_ptr->k_ val_ to p; /* Add th* valuas from */ for ( 1*0; 1 < t a u p t s ; i*+ ) /* tha SECOND rasponsa. •/ I m - k2 naw? /* I f l i s t not ampty, •/ /* than add to bottom. •/ /* If l i s t was amptyr */ t + l n i t i a l i x a top and bottom of l i s t . +/ *(val_ptr+4) 4* ( f l o a t ) *(*poch ptr++); ) /* and Cor ( j l « j ; j l < h u m ISI*; jl4 + i */ ) /* and Cor ( j-0 ; j < . num ISI*j J*4 ) */ /* Comput* th* w eig h tin g fa c to r * . */ c p22 - d to « conv / ( a .0 * ( l . o - p u l * * prob) )? c p21 - 1.0 / 3 . Of c pao - l . o } [ 3.0 * { l*o-pul**^prob) )i pO d ■ c _p20 4 pQ; I f ( V*rbo** | | dabug ) { (void) p r i n t f ( " \nS*cond ord*r DPOS k*rn*l w eigh ting f i c c o r n ' h (void) p r l n t f { H\n M « n v a lu * Cor sacond ord*r coapon«nt t % * d t o • conv / (tot.ms/aamp p*r) / ( 2 .0 * p u ls s prob*puls* prob*{ 1 . 0 - p u l ** prob) ) ); (void) p r i n t f i "\n Cor f l r * t ord*r cottpoiivnt t -w M , c p 2 U ; (void) p r l n t f ( "Vn Cor i* r o th ord*r componant: V# \n " r c p20); > f* F in is h th* DPos k«rn*l computation by ap plying tha w e ig h tin g fa c to r * and s u b tr a c tin g th* lowar ordar karnal*. V k3 p tr - fc2 top/ w h ll* < k2 ptr ) ( c p33a » c p22/k2 p t r - >num? /* Actual 2nd ordar w alghtlng f a c to r . */ val ptr ■ k 3 p t r > k v a l t o p ? pi ptr * pi..top/ f * Apply c on stan t fa c to r * , */ Cor ( 1*0; 1 < t a u p t s / I++, p l p t r + 4 . v a l ptr**) / 4*ubtract f i r s t ordar*/ *val_.ptr - *val ptr * c p22a /* rasponsa pi (tau) "c p31, and */ - *p 1 p tr * c p21 - pD. d/ /* su b tract 0th ordar r s i p o m t */ /* pO d. * / v a l p tr ■ k2 ptr->k..val t o p / 12 ■ ( i n t ) ( k2 p tr -> d tl/s a m p par 4 0 .5 j / pi ptr - pi top 4 12/ fo r ( 1*12; 1 < t a u .p t * / i 44, pi p tr*4, v a l ptr*+ ) *val .ptr - * *pl..ptr * c p21; /* s u b tr a c t p i ttau + d t i ) *c p21. *} kj ptr ■ k2 p tr-> n*xt p tr / > ) /* and If ( (numk >• 2 ) fcfc (hum pul*** t o t > l) ) *i /****** end OF SKCOND ORDER FOISSON KEfctftb COMPUTATION ** * « ••/ ;****** START OF THIRD ORD*R POISSON KftRNEL COMPUTATION /* Th* t h ir d ordsr k#rn*l computation ln volv** computing th* av*rag* rasponsa to th* th ir d of any t r l p l a t of stlm ulu* pul*** (r*gard l**s of th* pr***hc* of any ln t* r v * n in g pul***) Cor *ach d i f f a r a n t combination of f i r s t pul** t o sacond puls* and s*cond pula* to t h ir d p u ls* in t a r - p u l s * ln ta r v a l* in th* glv*n input stim u lu s t r a i n . Th* cod* b*low avaraga* th* r**pon**s for aach combination of f i r s t puls* to **cond pu ls* ln ta r v a l and sacond puls* t o t h ir d puls* l n t a r v a l wh*r* th* th* sum of th* ln ta r v a l* i s las* than th* * p * c ifi* d maximum (d*l ms). Warning - p o s s l b l* sourca of c o n f u s i o n » In th* l i t a r a t u r * of Bargar, S c l a b a s s l, a t . a l . , th* f i r s t puls* to sacond pu ls* ln ta r v a l i s glvan th* l* b * l D a l t a l . In th* f o llo w in g cod*, howsvsr, v a r la b l* * p a r t s ln ln g t o t h i s f i r s t in t e r v a l ar* lab *l*d w ith th* numbar 2 ( * . g . , d t 2 ) . s i m i l a r l y , th* sacond to th ir d puls* ln ta r v a l 1* c * l l * d D*lta2 in th* l i t a r a t u r * , whll* in th* cod* b*low, v a r i a b l s s p a r t a ln ln g t o t h i s sacond l n t a r v a l ar* l*b*l*d with th* numbar 1 ( * . g . r d t l ) . Th* r***on for t h i s r*v*r**d numbering i s t o allow th* us* o f lowar k*rn*l data atructura* through m u lt ip l* p o in tin g . For *xampl*, w* usa th* k2 data s tr u c tu r * to ator* th* d t l <D*lta2) valua* fo r kl and th* corr**pondlhg valua* v*. tau. in summary i B * r g * r ,S c la b a s s i ln ta r v a l Nomanclatur* Cod* Varlabl* 111 F ir s t -t o - S a c o n d P ulM D « lt« l k3_ptr->dt2 se co n d-to -T h ir d P uls* D*lt*3 k 3 _ p tr -> d tl_ p tr -> d tl I f ( (numk >* 3) kit (num_.pula*s t o t > a) ) ( (void) p r i n t f ( “Vnpoing th ir d ord#r DPOS karnal c o m p u ta tio n ... \ n M >; k3 d t i p t i - 0; /* Bagin tha summing a lgorithm . */ ISI* ml ■ num. ISI* - 1; for ( j-Oj j < . I S I 1 1 I 1 j + * ) /* Loop ovar a l l ISI® axcapt l a s t */ ( /* s in c a at laaat on* ln ta r v a l must */ ISI sum? ■ 0.0; /* ba savad for tha s a c o n d -to -th ir d */ JtJ ptr - kl top; /* pulaa ln t a r v a l. */ /* Loop for f i r s t - to-sacond pulaa ln ta r v a l. •/ for ( J2-1; J2 v ISI* ml; 12 + * ) /* Loop ovar a l l succaadlng tsts */ /* axcapt l a s t , */ i ISI SU A 2 + * 1S I (j 2 J/ /* rind th* p o s i t i o n for t h i s f i r s t - t o - a a c o n d p u ls* ln ta r v a l in th* l i s t , */ w h ila ( ki ptr ) ( i f ( ISI *um2 ^ (k3 p tr-> d t2 - bin ms d3) ) [ /* If t h i s i n t a r - p u l s * ln ta r v a l i s not In th* l i s t , than */ /* a l l o c a t * mamory fo r tha naxt t h i r d ordar karnal va lu a . */ k3 naw * (s tr u c t k3 data " }m alloc( s i s a o f (s t r u c t k3 data) ); i f ( LkJ naw > /* V arlfy s u c c a s s f u l a l l o c a t i o n . */ ( (void) p r i n t f ( -\TiCOULD NOT XLLOCATB H1MORY FOP NEW DT2 FOR p31 \ n H ); goto claanup; ) k3 dt2 p t*+ + ; i f ( kl p tr - - k3 top ) /* i f currant d t l i s f i r s t in l i s t , */ ( /* than add n*w valu* to top, */ k3 n*w->naxt ptr * k3 top; k3 top » k3 n*w; ) a Isa < k3_pr*v p t r - > n axt.ptr ■ k3 naw; /* otharw is*. i n s s r t in l i s t * / k3.n*w->n*xt ptr ■ k3 ptr;/*batwaan p r a v lo u s,c u r r a n t v a l u a s . * / ) i f ( bin_ms_d2 > samp_pard2 ) k3_n*vr->dt2 ■ ( fl o a t ) { (ln t) (I5I_sum2 / b in ms + 1.0 ) ) * bin. ms - bln m* d2j a la* k3_n*w->dt3 - ISIsum S; k3. naw->dtl_top - NULL; k3_naw->dtl. pt* - 0; /* i n i t i a l i i * num of d t l valu** In t h i s dt2 bin to i* ro , */ It3 p tr - k3 n*w; braak; > /* and i f ( ISI sum2 < (k3 .ptr->dt3 - b ln m s _ d 3 ) ) */ i f ( I s I * u m 3 <■ (k3_ptr->dt2 + bln_ms_d2) ) /* Braak out of loop*/ braak; /* i f sama ln ta r v a l found. */ k 3 _ p r * v p tr * k3_ptr; /* Rasp track of pravlous addrass. */ k3_ptr ■ k3_ptr->naxt_ptrj I 12 > /* and whila ( k3_ptr ) */ i f ( tk3_ptr ) /* I f fiaw l n t a r v a l la la rg a r than currant u x i a u a . */ { f* If X5i »ub2 largar than max dta In H a t , than */ /* a l l o c a t # mamory for i t and add to tha bottom. */ *3 naw ■ ^struct k3 data * jmallocr s l i a o f (s t r u c t k3 data) ); i f ( ik3 naw ) / • V arlfy auccaaaful a l l o c a t i o n - */ 1 (void) p r i n t f ( "\nCOULD HOT ALLOCATE MEMORY POR HEW DT2 FOR p2l VnH }j g oto claanup/ > 13 . d t l p t s * * ; I f { k3 top ) ( k3 bot->n#xt ptr 13 bot » k3 naw; } a ls a ( k3 top ■ kJ naw; k3 bot • k3 naw; ) If ( bln jpa d2 > lanp par d2 ) k3 naw->dtl - ( fl o a t ) ( [lnt] (ISI sum 2 / bin m* + 1.0 ) ) 4 bin ms - b l n .ms d2; a ls a k3 naw->dt2 - t s t . *ua2t k 3 _ n a w -> d t lto p - HULL; k 3.n aw -> d tl_pts « 0; /* I n i t l a l i i a nua o f d t l valuas in t h i s dt2 bln t o ta r o . V k3 naw->naxt ptr * HULL; /* Sat naxt p o ln ta r to n u l l to */ /* mark a s bottom valua- */ k3_ptr • k3naw; > /* i f ( tk3 ptr ) V ISI sUlal - 0 .0; d t l ptr ■ k3 p tr - > d t l top; /« Loop for sa c o n d -to -th ir d pulsa l n ta r v a l. */ for < J l - j 2 + l j j i < nua ISIs; )/* Loop ovar a l l succaadlng I S I s .* / 1 i ISI I linl 4m ISI [ j l J ; I f [ ( I S I s u m l + isi_*um2} > dal_Bi ) /* stop i f aax ln t sxcaadad.*/ ( i f ( Jdtl_.ptr ) /* Don't count i t I f no d t l ln ta r v a l found. */ k3 _dt2 p t s - -; braak; ) /* Find p o s i t i o n for t h i s s a c o n d -to -th ir d pu lsa int in tha l i s t . */ whila ( d t l p tr ) { i f ( 1s t a m i < (d t l. p t r - > d t i - bln ms..d2) ) < /* i f t h i s i n t a r - p u l s a l n t a r v a l i s not in tha l i s t , than */ /* a l l o c a t a mamory fo r tha naxt th ir d ordar karnal valua. */ d t l n a w - (s t r u c t kl data * ) a a l lo c ( s l s a o f ( s t r u c t k2_data) ); i f ( t d t 1 naw > /* v a r l f y s u c c a s s f u l a l l o c a t i o n . */ ( (void) p r i n t f ( - \nCOULD NOT ALLOCATE MEMORY FOR NEW DTI FOR p3I \n" >; goto claanup; ) (k3...ptr->dtl_pts)++; / • incraMant numbar of d t l valuas in t h i s d t 2 bln. */ 113 ki naw; /* If l i s t was not ampty, than * / /* add naw valua to bottom. */ /* I f l i s t was ampty, than */ /* i n i t l a l i i a top and bottom. */ /* A llo c a ta M a o r y for tha tau valuaa and i n l t t o i i r o . */ d t i n*w->lt.vtl_tqp - ( f l o a t * )c a llo c < (unalgnad l n t ) t a u pta, a l t a o f ( f l o a t ) ) f If ( Id tl naw->k v a l top ) /* V e r ify auccaaaful a l l o c a t i o n - •/ ( (void) p r i n t f ( "VOCOULD NOT ALLOCATE MEMORY FOR NEW p3 TAU LIST i VnH ); g oto claanup; ) I f ( d t l ptr -■ k 3 > d t l _top ) /* i f currant d t l la */ ( /* f i r a t In l i a t , than add naw valua to top. */ d t l naw->naxt _ptr « * lt3 ptr-><ltl top; k 3 _ p tr -> d tl top ■ d t l hawj ) alaa /* Otharwiaa, lnaart in H a t batwaan */ ( / • pravloua and currant valuaa. •/ d t l prav ptr->naxt ptr - d t l naw; d t l haw->naxt ptr * d t l ptr; ) If { bln ms d2 > aanp par d2 ) d t l naw->d t l - ( f l o a t ) ( ( i n t ) ( ISI auml / bln ma + 1 . 0 ) ) * bln ma - bln ma d2; a la a d t l naw >dtl - 351 auul; d t l n«w->nua * 0 ; /* I n l t i a i l i a nuabsr of inatancaa In t h la d t l bln. */ d t l p tr ■ d t l haw; braafc; > i f ( ISI.auml <* (d tl p t r - > d t i + bin ma d2) ) /* Braak out */ braak; /* of loop i f aama in ta r v a l found. */ d t l prav ptr ■ d t l p tr ; /* Kaap track of pravloua addraaa. */ d t l p tr * d t l p t r ^ n a x t ptr; > I f ( I d t l p t r ) /* If naw int la largar than currant max. •/ ( / ' If ISI auml largar than M t d t l in l i a t , than */ /* a l i o c a t a mamory for i t and add to tha bottom. */ d tl.n a w ■ (str u c t k2 data * )malloc( a l i a o f (a tr u c t k2 data) ); i f ( idti_naw ) / • v a r l f y auccaaaful a l l o c a t i o n . */ < (void) p r i n t ! ( ■\nCQUI*D NOT ALLOCATE MEMORY FOR NEW DTI FOR p3 I \ n H ); goto olaanup; > (k3__ptr->dtl pt*)++j /* Inc num d t l v a ia in t h la d t l bln. */ /* A lio c a t a mamory fo r tha tau valuaa and i n l t i a l l s * to i * r o . */ d t l naw->k_val top ■ ( f l o a t * J c a llo c i (unaignad i n t ) t a u p t a r a l i a o f (f l o a t ) ); If < i d t l naw->k v a l top ) /* v a r l f y auccaaaful a l l o c a t i o n . */ ( (void] p r i n t f ( "VnCOULD NOT ALLOCATE MEMORY FOR NEW p3 TAU LIST) \ n H ); g oto claanup; ) i f ( k3_ptr*>dtl_ top ) /* i f l i a t wta not ampty, than */ { /* add naw valua to bottom. */ k3 p tr -> d ti_ b o t-> n a x t_ p tr ■ d t l n t w i k J _p tr-> d tl bot ■ dtl_navr; ) a la a /* i f l i a t waa ampty. than •/ ( /* i n i t i a l ! * # top and bottom. ■/ I 14 k3 _ptr->dtl..top « d t l n*wi IcJ _ptr->dti bot ■ d t l n v w i > i f ( bin_ma_d2 > aamppar 42 ) d tl_ n a w -> d tl - {f l o a t ) ( (int) (ISI t u a l t bin mm + i . o ) | bin ma - bin Ma <12; alaa d t l n#w->dtl - ISI .sualf dtl__naw->num a 0 ; /* I n lt nua in*tancaa in th la d t l bin. */ d t l n « - > n « * t ptr - NULL; /* 8mt nazt p o in te r t o n u l l to */ / ' Mark aa b o t t dm valua. */ d tl_ p t r • d t l .naw; ) /* Now, add tha naw valuaa. */ ( d t l p t r - >nuv)++; /* Incranant nun instancaa in thla d t l bin. */ apoch ptr - data top + (j i t l ) ••poch pta; val ptr - d t l p tr -> k val top; /* Add tha valuaa from •/ for { 1*0; i < tau pta; 1++ ) /* tha THIfeD raaponaa- */ * (val ptr+*j +■ { f lo a tj *{*poch ptr++); ) /• and for ( 1 i - j 2 ; j l < nua i s i * j jl++ ), for loop for a a c o n d -to -th ir d pulaa in ta r v a l */ i f ( (151 auml + • ISI auml) > d « l m ) /* stop i f mas Int axcaadad, */ braak; } /* and for ( 32■ }; 33 < ISIa_mlj 32 + + ), for loop fo r f i r a t t o - a a c o n d pulaa in ta r v a l */ } j * and for ( j -0 ; j < ISI* Ml; J + + ) */ I* Computa tha w alghting f a c to r * . */ c p3 3 • d to a conv / ( 6.0 * (1 .0 -p u la a prob) ); C p31 - 1 . 0 / 6 . 0 ; c p32 - 1.0 t 3.0 j c p3 0 - 1.0 / { 6.0 * ( 1 . 0-pUlaa prob) ); pO d - C p30 * pO; i f ( varboaa I \ dabug > { (void) p r l n t f ( “\nThird ordar Polaaon karnal formula m u ltip ly in g f a c t o r a t " ); {void} p r l n t f ( H\n maan valua fo r thir d ordar coaponant: ^a b, d_to a conv I ( tot_m*/aamp.par) / ( 6 . 0*pulaa prob+pulaa_prob+pul*a p rob *( 1 . 0 -pulaa prob) ) ); (void) p r l n t f ( “\n for aacond ordar componantt %m M . c p32); (void) p r l n t f ( *\n fo r f l r a t ordar coapontnti \ a *, c p 3 l); (void) p r l n t f ( N\n for xaroth ordar componantt Sa \n". c p30); ) }* P inlah tha DPos karnal computation by ap p lying tha w aighting fa c to r * and Su btracting tha lowar ordar karnal*. */ k3_ptr - k3 top; k2_ptr d t 2 - kJ.top; w hila { k3 ptr ) /* Loop ovar a l l dt2 valua*. */ < /* plnd tha k2 p o in ta r fo r th l* dt2 valua from tha K2 H a t which 1* aortad in aacandlng ordar. V w hila ( k2_ptr_dt2 ) < i t ( ( k 2 p t r d t 2 - > d t l > ( k 3 p t r - > d t 2 - bin_m*_d2) ) 46 ( k 2_p tr_d t2->d tl <■ (k3_ptr->dt2 + bin m*_d3) ) ) braak; k2 p tr dta - k2_ptr_ d t 2 - >naxt. ptr; > k2_ptr_lp2 » k2_top; k2_ptr _dtl * k2 .t o p ; d t l p tr • k3_.ptr->dtl top; 115 whll« ( d t l p t r ) I /* Find tha ha p o in ta r for th ia d t l valua. */ w h ila ( fc2_ptr d t l j ( i f ( ( k a .p tr d t l - > d t l > ( d t l _ p t r - > d t l - b l n n d 3 ) ) 66 ( ka p t r _ d t l - > d t l <« {dtl.. ptr - >dtl + b in ■■ da) ) ) braak; k2 _ptr_dtl • k2_ptr d t l - >naxt _ptr; } /* rin d tha k2 p o in ta r fo r t h i * d t l + d t l v a lu a . */ /* Jfota: Adding two b in valuaa w i l l always giva a r a a u lt on a bin odgat {i * b in .* * + bin mi..42) * (j * bin ma ♦ bin a s d 2 ) - {i + ■ j + l) • bin na, ainca bln »■ d2 + bin na da ■ bin n a . Ws naad t o choosa tha lowar bln, ainca tha highar ona may not a x i s t . • / whila ( K2 ptr lp2 j { If (i, k.2 p tr lp2 - * dt l > ( d tl p t r - > d t l + k3 p t r - > d t 2 - bin mi )> 66 ( U ptr lp2 - >dt 1 <- { d t l p t r - » d t l + k3 p tr -> d t2 j ) ) braak; k2 ptr lp2 - k2 ptr lp2->noxt ptr; ) c_p33a m c p l i / d t l ptr->nuB; v a l ptr » d t l . p t r - » k v a l top; p l_ p tr * pl_top; v a l ptr2 - k2_ptr dtl->k_.val top; v a l . p t r J ■ k2 p t r .I p 2 - > k v a l top; for ( i - 0 ; 1 < t a u . p t s ; 1+ * , pi _ p tr+ + , v a l_ p tr 4- + , v a l _ptr2 + + , v a l ptr3++) • v a l . p t r - •v a l. ptr * c ,p33a /* Apply c o n sta n t f a c to r , * ~ *pl_ptr • c p l l /• su b tr a c t p i (tau) *c p31, * - *val ptr2 * c p32 / • p 2 {t a u ,t a u + d t l ) * c _ p 3 2 , • • v a l . p t r l • c_p32 / * p2 (tau, tau4-dtl 4-dt 2) *c p32 * - pO_d; /* and su b tra ct pO d- * i2 ■ ( i n t ) ( d t l _ p t r - >dt1 / saap_par + 0.5 ); /* su b tr a c t */ v a l_ p tr ■ d tl_ p t r - > k v a l top; /* p 2 (t a u + d t l ,t a u + d t l * d t 2 ) * c p32. */ v a l_ p tr 2 - k2 p tr _ d ta -> k v a l top + 12; fo r { 1 - 1 2 ; 1 < tau_pta; i++, v a l ptr*-*, v a l p t r 24- + > •v a l ptr - - *val ptr2 • c p32; v a l ptr - d t l .ptr->k_ va l .top; 12 - ( I n t ) ( d t 1 p t r - >dt1 / aanp par + 0.5 ); pi ptr * pi top * 12; for < 1 *1 2 ; 1 < tau pt«; 14-*, p i ptr**, v a l ptr** ) • v a l ptr - - *pl p t r * c p21; / • Subtract pi (ta u + d ti)* c p 2 l . • / v a l ptr ■ d t l p tr - > k . v a l top; i2 > (i n t ) [ ( d t l _ p t r - > d t 1 + k 3 _ p tr -> d t2 ) / >amp_p*r * 0.5 ); p l p t r ■ pi top * 12; for ( 1*12; i < t a u .p t a ; i++, pl_ptr++, val_ptr++ ) • v a l . p t r -a • p l . p t r • c . p 2 l ; /■ Subtract p i ( t a u + d t l + d t 2 ) • c p 2 l ■ */ d t l p tr * dtl_ptr->noxt._ptr; ) /* and w hila ( d t l _ p t r ) •/ k3_ptr ■ k3 p tr -> n * x t . p t r ? > and w h ila ( k3_ptr ) */ ) / • and I f { (numk > * 3 ) 64 {nuM_pulso*.. t o t > 2) ) •/ /**«*«* AND OF THIRD OFDM FOlSSON KERNEL COMPUTATION................ /* Wo d o n 't naad tha raw data anytooro - so froa tha asaorY* • / I f ( data top ) fraa ( data top ); / • • » • • • stAFT OF KERNEL DATA OUTPUT * * •* •* / / • • • • • • START OF BINARY KERNEL DATA FILE OUTPUT *•* * * •/ I Ift If < bin k f l l * ) i f ( I Writ#__k_Binary ( uaerpath, numk, po, a am pper, tau p c i, pi cop, b i n u , k J d t i p t # , k2__top, k i d t s p t i , k a.top ) j g oto cleanup; /****** END or BINARY RIRN1L DATA FILE OUTPUT *■*••*/ f ****** START o r KERNEL PLOT FILE OUTPUT * * •* •* / /* Writ* the aeroth order kernel output f i l e . */ i f ( f i l * type > 0 ) { /* open th* output f i l * for th* geroth order k ern el, */ [void) «trcpy( (char *)kpath, {char +)ua*rp*th ); (void) s t r e e t ( (char *}kpath, ".- ); (void) i t r c * t ( (char Mkpath, “p o . t b l - j? i f ( (k fp«fop*n( kpath, "W )) - - NULL ) { (void) p r l n t f ( “MiCAN’T OPEN OUTPUT FILE: l * a | \ n M , kpath ) ; goto cleanup; ) / * Writ* th* aeroth order kern el to th* output f i l * . */ (void) f p r l n t f f k fp, "\EW , po )t t c l o a * { k fp ) ; (void) p r l n t f ( “\n\aO w r it te n to a s c i i f i l * [%b ] \ n H, "p", kpath .1 ; (void) p r l n t f ( H\nSsO • SE \n". “p'*, po )j I /* i f f i l * type > o */ /* Writ* th* f l r * t through t h i r d order kernel output f i l e * , */ If ( f i l e type ■■ 1 ) I i f ( numk >■ 1 ) If I i P lo t ,kl_Tablet uaerpath, pi top, "p**, ta u _ p ts, samp per ) ) g oto cleanup; I f ( numk >■ 2 ) l f ( I Plot_k2 T a b l e ( u**rp«th, k2 top, "p” , tau pta, a amp per ) ) g o to cleanup; i f ( numk »• 1 ) if< I P lot kl Tablet u**rpath, k3 top, “S>*. tau pta, samp per ) ) goto cleanup; ) *1 a* i f ( f i l e type -- 2 > < I f ( numk >■ I f l f ( iFlot..kl._matlab( o u tin f o , uaerpath, p i cop, "p", tau..pta. aam pp er)) go to cleanup; i f ( numk >■ 2 ) i f ( lP lo t k 2_m atlab(outinfo, uaerpath, k2 top, H p*r tau_pta, samp per, bin m*._d2, d e l ma) ) g o to cleanup; i f ( numk >- 3 ) i f ( I P l o t _k3 .matlab( o u tin f o , uaerpath, 13 top, “P", tau pta, aamp per, bln ma d2, del m a .a lic e a ) » g o to cleanup; > / * * * * * * e n d o r k e r n e l p l o t f i l e o u t p u t * • * • * * / /**+**• END o r KERNEL DATA OUTPUT ******/ /• • # # # * START OF INFORMATION OUTPUT FILE SECTION ***•*■/ /* w r it* an in fo f i l e , but p re s e r v e old v e r s i o n s . */ (void) atrcpyf (char * ) kpath, (char *)uaerpath ); (void) s t r c a t ( (char M kpeth, * . k e r n * l _ i n f o “ ); I 17 II ( fopani kpath, -r" ) ) ( 1-0, d o ( 1 + + , (void) atrcpyl (char Mkpath. (char •) uaarpath ), (void) a tr c a t{ (char • ] kpath, ); (void) a p r ln tf ( ll n a , "'kd", 1 1, (void) a t r c a t l (char * ) kpath, l l n a ), (void) a t r c a t ( (char *)kpath, ■ .karnal info* ), ) w hila ( to pa n ( kpath, "r* ) ), ) I f ( ( fp .fo p a n ( kpath, "w“ )) • • NULL ) ( (void) p r i n t f ( "VnCAN'T op*n OUTPUT INFO FILE: (^a)vn*, kpath ), g oto claanup, ) (void) f p r l n t f ( f p , "INFORMATION riLI for DPOS karnal f l l a a with root [Ha). Vn" , uaarpath I ,- (void) f p r i n t f f f p , "Vnltarnala computad from data f l l a a with root l%a], ", pathnama i; (void) f p r l n t f i f p , -vnF lrat Saguant■ vd f l r a t aag ), (void) f p r l n t f ( f p , "\nLaat Sagmants Vi \ n “, la a t tag ), (void) f p r l n t f ( f p , "VnlSI Scala F actor, \ t \n", i a i a ca la ), (void) f p r l n t f i f p , "VnAmpllflar Gain: ’t . l f \n", amp g a in ), (void) f p r l n t f ( f p . "\nPulaa t r a in paramatara a p a c lf la d In data f l l a i " ), (void) f p r l n t f ( f p , -Vn pulaa rata • SI pulaaa/aacond ", pulaa rata ), (void) f p r l n t f i f p , "\n aampla pariod - \ t m lllla a c o n d a ", aamp.par ), (void) f p r l n t f i f p , "Vn pulaa p r o b a b i l it y ■ pulaa rata'aamp p a r / l a 1 a c a la . S.! ” , pulaa prob ), (void) f p r l n t f i f p , "In numbar of pulaaa • x ld Vn". num pulaaa t o t ), (void) f p r l n t f i f p , “Vncoaputad pulaa t r a in paramatara:" ), (void) f p r l n t f i f p , "In t o t a l t a a t tlma . " ,.1 1 mlnutaa ", tot ma/60000.0 ), (void) f p r l n t f i f p , "Vn t o t a l numbar of data aamplaa . Sd ", (in t) (t o t .ma/aamp par * 0.5 ) }j (void) f p r l n t f i f p , "Vn a c t u a l pulaa p r o b a b i l it y ■ Kpulaaa/Naamplaa - SC \n", (float)num pulaaa t o t / ( to t ma/aamp par) ), (void) f p r l n t f ( f p , "VnNumbar of karnala computad • VI in", numk), (void) f p r l n t f i f p , "Vnzaroth ordar DPOS karnal: po . \ a Vn", pD); If ( numk >- 1 ) ( (void) f p r l n t f ( f p , "VnDPOS karnal formula w aighting f a c t o r a : \n " ), (void) f p r l n t f i f p , "VnFlrat ordar Dpos karnal formula w a igh tin g f a c t o r a : " ) , (void) f p r l n t f i f p , "\n tor f i r a t ordar componantt Va ■, c p l i ) , (void) f p r l n t f i f p , "In fo r aaroth ordar componant: Vn \n", c p l o ) , ) i f ( numk 2 ) ( (void) f p r l n t f i f p , "VnSncond ordar DPOS karnal w aighting f a c t o r a : - ), (void) f p r i n t f ( f p , "Vn maan valua for aacond ordar componantt Va ", d_.to a._eonv / ( to t ma/aamp.par) / ( 2 ,0*pulaa__prob"pulaa prob* (1. 0 -pulaa_prob| ) ), (void) f p r i n t f ( f p , "Vn fo r f i r a t ordar componant: %a ", c . p l l ) , (void) f p r l n t f i f p , "Vn for aaroth ordar componant: %a Vn", c j ) 0 | , ) i f ( numk >• 3 ) ( (void) f p r l n t f i f p , "VnThlrd ordar Polaaon karnal formula m u ltip ly in g f a c t o r a : * ) , (void) f p r i n t f ( f p , "Vn maan valua for th ir d ordar componant: \ a ", d t o a. conv / (to t ma/aamp j a r ) / IIS f 6 .O'pul*# _prob*pula#_prob*pul*#_prob*( l . 0 -pul**.prob) ) ) j (void) £ p r i n t f ( f p , “Vn for *«cond ord#r component i V* ", c p 3 2 ) j (void) f p r l n t f i f p , - \ n for f i r * t ord*r component; '**# ", c p 3 i ) j (void) f p r l n t f i f p , "Vn fo r s«r oth ord#r coapontnti \m \ n " , c p 3 0 ) ; fc lo * # ( fp ) t /* c lo a # Information output f i l # , */ (void) p r l n t f 1 * VnlNFORMATION f i l s w r itt# n to [ \ * 1. Vn", kpath )i /* •* •* * |HD OF INFORMATION OUTPUT FIL* SECTION ••****/ claanupi i f ( data top ) fro# ( data top )i i f ( p i t o p ) f r # # ( p i t o p ) ; w h i l # ( Jc2 t o p I ( k 2 p t r - k 2 t o p ; k 2 t o p ■ k 2 p t r - > n * x t p t r ; i f ( )c2 p t r - > k val t o p ) f r # # { k i p t r - > k V * 1 t o p >; f r # # ( k 2 p t r ) ; w hll* ( k3 top ) { k3 p tr * k3_top/ k3 top ■ k 3 _ p tr -> n # x t,p tr / w hil# ( k 3 _ p tr -> d tl top ) < d t l p tr » k 3 _ p tr -> d tl top; k3 _ p tr -> d tl top « d t l p tr -> n #xt ptr/ i f { d t l . ptr->k__val. top ) fr## ( d t l ptr->k v a l top ); fr#« ( d t 1 ptr i ; ) fr#* ( k3 ptr )? /* E xit +} raturn; ) /* ulii */ void lslH latogr*m ( I S I . t o p , num. pul*#* t o t ) /* Input* •/ f l o a t * i s ! top; /* ISI# for a l l #v#nt* of *11 **gm#hta. unsigned long nun pula** t o t ; /* Total numbar of *poch*. */ /* M*k# * histogram of th# ln t# r -« tlm u lu * I n t a r v a l* . */ ( r * g i* t# r unsigned long l , j ; char lin # ( 1 3 8 ) i char ou tp ath (25< )j /* output f i l * pathnam*. */ unsigned long num_blna; /* Numbar of histogram b in *. V un*lgn#d long n u s ^ is i s ; /* Numbar of isi*. */ f l o a t b in _ * ix a ; /* Bin s i s # In m i ll i s e c o n d s . */ f l o a t bin s t a r t ; /* Bin s t a r t time in m illis e c o n d * . • / f l o a t h l a t m a x ; /* L argest ISI t o in clud* In histogram . */ f l o a t maxISX; /* Maximum IBI a l t # . */ f l o a t n a x t i s i ; /* S#cond la r g * * t ISI a i t * . •/ i w unsigned short * b l n t o p r /* p o in ter t o top o f bln array. */ f l o a t *181.ptr; /* Running p o in ta r fo r ISI array. */ HI** *fp; /* Histogram output f i l e p o in ta r . */ /* Function D e c la r a tio n s */ •* t* r n void ShowHistogram() j /" D isp lay tha histogram •/ {void) p r l n t f ( M \nDo you want a h istogram of tha in ta r -s tim u lu s in te r v a l s ? (y or n ) ; " ); (void) g a ta( ll n a ); i f ( l s t r c h r (l l n a r 'y ') ) return; n u i i s i a ■ num..pulses_tot - 1; / * The number of t s i s . •/ /* rind the l a r g e s t and second l a r g e s t i s i . */ earISI - 0 . o ; ISI ptr « ISI top; for ( i - 0 ; 1 < num I s i s ; 1++, ISI ptr + + ) IF ( *ISI ptr > inaxISI ) maxISI - *I s i ptr; n e x t i s i * n.O; ISI ptr - ISI top; for { i-0 ; 1 < num ISls* i+ + r ISI ptr++ ) i f ( ( *151 ptr > next ISI > 64 ( *ISI ptr * . maxISI ) ) n e x t lS I - * i s I ptr; do ( {void) p r l n t f ( "\nThe l a r g e s t ISI - %t m i l i i s e c o n d s . \ n M . maxISI )i (void) p r l n t f ( "The second l a r g e s t ISI ■ %f m i l l i s e c o n d * . \ n * , next IS I l; do ( (void) p r i n t f t MnKntsr th e maximum ISI t o be included in the histogram ( m i l l i s e c o n d * ) j M ); (void) g e t s ( l i n e )j (void) s s c s n f ( l i n e . *%(•', t h i s t max ); ) w h ile ( ( h i s t max < 0.0) M ( h i s t max > maxISI) ); do { (void) p r l n t f { M \nEnter tha histogram b in s i z e ( m il l i s e c o n d s ) : ); (void) g e t s ( l i n e ); (void) s s c a n f ( l i n e , “%fM , t b l n . s i z e ); ] w hila ( (bln s i z e < 0.0) I I (bin e l s e > h i s t max) ); num bins - (in t ) ( h i s t max/bin a i s e + 0.5 ); /* A llo c a t e memory fo r the bin v a lu e s . */ bin_top - (unsigned short * ) c a l l o c { (unsigned int)mim..binSj s l s e o f ( u n s i g n e d short) ); i f ( i b ln .to p ) /* V e r ify s u c c e s s f u l a l l o c a t i o n . •/ ( (void) p r l n t f { “\nCOULD NOT ALLOCATE MEMORY FOR HISTOORAM BINS I \h" ); return; > /* Compute th e histogram. * / fo r ( i - 0 ; 1 < num bins; 144-} ( bln s t a r t - ( f l o a t ) 1 B bin s i z e ; ISI p tr • I S I _top; fo r ( 1-0; j < num_lsle; I S I p t r + + ) ( i f < ( *ISI_ptr >» b in _ s t a r t ) 44 ( * IS I ,p tr < (bln .st a r t 4 bin s l z e ) ) ) ( *{bin_top 4 1) 4- 1; ) ) > /* D isp la y th e Histogram */ 120 showHistogramt b ln .c o p , num_bins, b l n . s i i * ); (void) p r l n t f ( "\n\nDo you want to chang* th* max i s i or bln *ls* ? (y or n)j ")? (void) g * t s ( l i n * ); I f { s t r c h r (l i n * , ' y > ) fr**( b i n t o p )j ) u h il* ( B t r c h r d l n * . y > ); /* Sav* th* Histogram to * f i l * . */ (void) pr l n t f (** \nDo you w«nt to sav* th* histogram to * a s c i i f i i * 7 (y or n) i M )j (void) g a ts < li n * ); i f ( J Btrchr ( l in * , ’ Y ’.> ) g o t o cl*anup; (void) p r l n t f ( *\nHistogram Pilanam*: * )t (void) g *t*( outpach )j i f ( ( fp - fop*n( outp*th, ’ w“ )) - - NULL } ( (void) p r l n t f ( “ \ nCAN1 T OPEN OUTPUT PI LE r IVsJVn”, outpath )/ g o to cleanup? ) for ( i ■ o; i c nu* bln®; !♦ + ) (void) f p r l n t f ( fp, "%f %d \n", ( flo * t )1 * bin i l l * + b ln ■1■ * / 2 -o J ' ( b i n top + 1) >; f d o ® * < fp ) ; cl*anupi I f ( b in top ) fr«*( b ln top }; r*turnj ) /* XSIKlatogram *i . void showHlatogram( bin top, turn bln*, b in s i* * > /* Inputs */ unsignad short *bin top,- /* Pointer to b in s. */ unsignad long num bin*; / * Numbar of histogram b ln *. */ f l o a t bln s i s * ; /* Bln s i s * In m l l l l s * c o n d s . */ /* Crud* ASCII D isp lay of a Histogram */ { •x t * r n in t d*bug; /* Command lin * o p tio n s . */ unslgn*d short max; / • Maximum bin va lu * . */ unslgnad short 1; unslgn*d long 1; f l o a t se a l* ; /* Seal* valu*. */ /* rind th* max valu* */ max - a / for ( 1**0? 1 * num_bln*} 1 + + ) ( i f < *(bln top « • 1) > max ) max - *(bln top ♦ 1); ) i f ( max - - 0 ) ( (void) p r l n t f { "\nUROAi A ll histogram bin valua* ar* i * r o . Vn"); raturn; ) /* Seal* th* valu** i f max l a r g s r than 50. V i f ( max > 5 0 ) ( s e a l * ■ 5 0 .0 I ( f l o a t ) i 21 { S cale ■ 1 . 0 ; > /* D isp la y th e histogram V (void} p r l n t f ( "VnHistgram w ith Vd b in s o f Sf m i l l i s e c o n d s - , num.blns, b l n t l a e ) ; (void) p r l n t f ( "MiMaxlmum bln value - Xd M , max >; (void} p r l n t f ( "VnEealei * ■ %f \ n M . 1 , 0 / s c a l e ); for ( 1 *0 ; 1 < n u m b in s ; 1 + + ) ( (void) p r l n t f ( * \n * 1 0 .1 f *, ( f l o a t ) i * bln s i t e * b in s l i e / 2 . 0 ); for [ }«0; j < (Int) ( ( fl o a t ) *(bin_top + 1) • s c a le ♦ 0.5 )i (void) p r l n t f { ); ) r e t u r n ; ) /* showHlstogram •/ v o i d Showfpocbf data p tr , qua pulaaa t o t , epoch pta, aamp par, amp gain) /* Tha bin ary nacopa data f i l e uaaa 2 bytaa par eample. Thla program aaaumaa that tha s i x e of ahort 1* 2 bytaa. ahort unsigned long unsigned long f l o a t f l o a t *data ptr; num_puleea t o t; epoch_pta; samp._per; amp ..gain; D isp lay epochs o f d a ta . */ /* P oin ter to s t a r t o f raw data v a lu e s . /* Total number of epochs. /* Number of sample p o in ts used per epoch, /• sample period in m i ll i s e c o n d s . f* p r e a m p lifie r g ain char unsigned long short w hile (1} { l i n e (120 1/ i j •epoch ptr; /* Epoch p o in te r . •/ /* Have the user s e l e c t an epoch to d i s p la y . do (void) p r l n t f ( (void) p r l n t f { (void) p r l n t f ( (void) p r l n t f ( (void) p r l n t f ( (void) p r l n t f ( (void) p r in t ft "\nDate D isp la y O p tlo n n \n" }; "0 * Quit \ n “ ); “1 - D isp la y Epoch 41 \ n H ); ' * Vn"); * vn-); ■ * \ n * ) ; "Vid ■ D isp la y Epoch #%ld \n", num_pulsee t o t , num. p u l s e s . t o t ); (void) p r l n t f ( "Vnselect Option i t * ); (void) g eta ( l i n e ); (void) ss c a n f ( l i n e , -^ld", 6 i ); If { i • • 0 ) return; ) w h ile ( (1 < 0) | | (1 > n u m p u l a e s t o t ) >; Print the epoch data to the standard output. */ e p o c h p t r ■ data ptr (i 1) e p o c h p t s ; /* Oo t o s t a r t of s e l e c t e d epoch. (void) p r l n t f ( "VnData for Epoch# Hid \ n H, i ); (void) p r l n t f (- MSEC MILLIVOLTS AtoD Value Vn" ); for (i » l ; i <■ epoch p t s ; 1++ > { (void) p r l n t f ( “H lO .lf H lO .lf ( f l o a t > *epoch_ptr epoch, .ptr* +; ) \10hd\n", ( f l o a t ) 1 * aam pper, hds_vcal * 1000.0/amp gain , ‘epoch p tr ); ShowKpoch() I 22 / / in t SmoothArtifact ( d ata_p tr, nu» p u la * » _ to t, X Sl.top, apoch p t i , samp. ptr ) ahort unsigned long f l o a t unaignad long f l o a t * d t t i ptrr / nua pulaaa t o t j /* • i S J .t o p j / apoch_.pt a ; / samp par; / * Pointar t o s t a r t of raw data valuaa. Total nujabar of apoch*. h IS la for a l l avanta of a l l aagmsnt*. 1 Numbar of aampla pointa uaad par apoch. ' Sampla pariod in m lllis a c o n d s . /* smooth* tha stim u lu s a r t i f a c t by l i n a a r l y i n t a r p o l a t l n g batwaan tha p o in ts immadiataly bafora and a f t a r tha a r t i f a c t . r a g la ta r unaignad long r a g ia ta r unaignad long i.kj J ; char unaignad long unaignad long s h o r t s h o r t f l o a t float f loat f loat l l n a [1261; art pta; num ISla; •apoch ptr; bafora, art a t; d a lta ; apoch as; ISIsum AS; /* Numbar of p o in ts to smooth. /* Numbar of ISI*. /* Pointar to currant apoch. a f t a r ; / * P oin ts b a fo r a /a ft a r ©action to ba smoothsd. /* Duration of stim ulus a r t i f a c t (m s a cs). /* Por l n t a r p o l a t t o n . /* Epoch duration la ml11ls a c o n d s . /* Running sum of x s i s . r / • / ■ / * / ' f ‘/ */ */ /* <3st tha d uration of tha stim ulu s a r t i f a c t in m illls a c o n d a */ do ( (void; p r l n t f ( "\nstlmulu* smoothing Routins; \tim }; (void) p r l n t f ( "kntar duration o f stim ulus a r t i f a c t in m l ll i s s c o n d s \ n “ ) t (void) p r l n t f < "from s t a r t of apoch to and of a r t i f a c t , or \ n H ); (void) p r l n t f ( *antsr nag a tiv a valu a for no smoothing. \ n u ); (void) gats{ ll n a ); (void) s s c a n fl l l n a , " \ f M , ta r t ms ); i f ( art_ma < 0 . 0 ) raturnf 0 )j /* Fore* tha usar to v a r l f y vary sm all or vary la r g s valuaa. */ i f ( (art ms < 0.1) I I (art ma > 2 . 0 ) ) ( (void) p r l n t f ( *\nVERJFY* Stimulus a r t i f a c t la %t MILLISECONDS lo n g ? H, * rt ma) j (void) p r i n t f t H\n (y or n )i ■ >? (void) g a ts ( l l n a ); i f ( J s t r c h r(1ina, (n'> ) If ( s t r c h r ( l l n a , ’y ' ) ) braak; a r t ms - - 1 . 0 ; > ) w h ila ( art ms < 0.0 ); / • computa tha numbar o f sampla p o in ts t o smooth. */ art .pts * (in t ) (art_ms/samp._par + 0.5 ) ♦ h / • Tha apoch langth In m l l l l a a c o n d s . */ apoch ms ■ (f l o a t ) ( apoch Pts - 1) * samp.parr nua. ISla - num .pulsas t o t - 1; /• Now. smooth tha a r t i f a c t at tha s t a r t of aach apoch. */ for ( i - 0 ; i < num p u laa*_tot; i>+) { apoch p tr - data._ptr 4 i*apoch. p ts ; bafora • *apoch p tr ; a f t a r • *(apoch_ptr 4 a r t p t a ) ; d a lta - (f l o a t ) ( a ft a r - b a fo r a ) / ( f l o a t ) a r t _ p t s ; fo r ( 1-1; j < a r t p t a ; j++ ) * ( 4 + a p o c h p t r ) ■ (int) ( ( f l o a t ) j * d a lta 4 (f l o s t } b a f o r a + 0.5 ); 123 /* If th* ISI la l a s s than th* apoch langth, thara w i l l ba a stim ulu s a r t i f a c t in th* middl* of th* apoch of data. Now, smooth thoa* a r t i f a c t * . */ is ls u m m * ■ 0 .0; for { k -lj k < hum. tsx*; k+ + ) { ISIsum. a* +• * ( t s i top + K) ; i f { i s i i u a u < (apoch b i + art ma) ) { *poch_ptr - data p tr * i * « p o c h p t i + ( l n t ) ( (f l o a t ) *( ISI _ top * k ) / aamp.par 4 - 0.5 ); b*for* » **poch_ptr; a f t a r - *(apoch._ptr ♦ a r t_ p ta ); d a lta ■ (f l o a t ) { a fta r - b a f o r a ) / ( f l o a t ) a r t pta; for ( j -1 ; j < a r t . p t a ; ) * [t + «poch ptr) » (in t) ( ( f l o a t ) j * d a lta + ■ {f l o a t )b*fora 4 0.5 >; ) • la* i braak; ) ) ) raturn ( 1 > ; ) /* Sm o o th A rtifa ct<) */ /* *nd of f i l a */ I). 1.2 kcrnel dcfs.h /* s t r u c t u r a l fo r Karnal* */ a tru ct k2_data ( f l o a t f l o a t int a tr u c t k2 data ); /* for llnkad l i a t of k2 data d t l ; / • t a u l - tau ( m i llia a c o n d a ) . * k v a l _ t o p ; /* P o ln ta r to a*t of k*rn*l v a l a ( v o lt a ) nun; /* Numbar of caaaa of th ia d t l . •n*xt_ptr; /* Pointar t o naxt data p o in t. a truct k3 data /* for llnkad l i a t of k3 data. f lo a t atruct a tr u c t k2 data k2 data a tr u c t k3 data Int dt2; /* t a u l - t*u2 (ml11iaacond*). • d t l top; /* Pointar t o top of tau2 - tau l i a t . • d t l bot; /* Point*r to bottom of tau2 - tau l i s t . *n*xt ptr; /* Folnt*r t o naxt data p o in t, d t l pta; / • Numbar of d t l point*. I).1.3 n d sd efs.h /* Pang** */ Id* f in * ad*_.Max_chaan*l* ia Id a fln a n d a m a x i a t l m 5 /* sampi* a o d t i • / Id a fln a nds.trlgg*r_*poch_mod* 0 Id a fln a nda a ln g la apochmoda 1 / • Trlggar mod** */ Id a fln a nda auto t r l g g a r o Id a fln a nda a x ta r n a l t r lg g a r 1 /* D laplay mod*a */ I d a f ln a nd*_r**pon*a_mod* 0 Id a fln a nd*_contlnuou*_moda 1 I d a f ln a n d s_h aad*r_var*lon_sls* a Id a fln a n d s_ o s _ v * r slo n _ a li* a Id a fln a n d a _ n o d * * i i # a Id a fln * ndi_us*r_nima..aiia 12 id * f i n * n d s _ a l t _ u n lt _ a t r „ a ls * 2 Id a fln a n d a _ t* a t_ fll* _ n a m * _ a iia BO 124 id a f l n a nda c o u * n c . a l i a 60 0 4 a fin* nda_chann*l nam*_l*ngth t typadaf a truct i \ char nda varalon[nda haadar varalon a lla + 1 ); char nda_OS.varalon[nda OS varalon a l i a * 1]» char nda nod*(nda nod* a l« * + i]j char nda uaar.nama[nda uaar nama a l s * + l ] j long nda f i l * .a lia ; f loat nd*_*poch_aix*; ahort rvdanum.channala j ahort nds_num„pula a a j f loat n d * _ i a i p f r a q r h a n ; f l o a t n da_alt u n i t c o n v j c h a r nda,*lt__unit_atr [nda _«lt u nit *tr_.*lx#+lj; ahort nda to ta l_ r * c o r d a ; ahort nda int_traln_pauaa; char n d a .ta a t f i l a nama[nda ta a t f i l * nama « i s * + l | ; ahort nda ta a t f i l * langth; char nda commant l[nd« commant s i x * ) ; c hat nda commant 2[nda c o m m a n t a l t * ] ; a h o r t nda aampla mod*; a h o r t nda d la p la y mod*,: ahort nda t r lg g a r mod*; f loat nda c h i n n a l gain*[nda max channala]; ahort nda latlm tnda max. l a t i m ) ; char nda.channal nama*[nda max channala)(nda channal nama l*ngth+L) unaignad char nda HIT fla g ; unaignad char nd« t a a t . f i l * fla g ; > nda par*m_blk t; Nd*fina NDS MAX BVfcNTS 10000 typadaf a tr u c t { long avant[NDSMAX IVENTS J; long ISIIHDS_MAX*VEMTS)j i* a c tu a l tlm* at amp w i l l raplac* i s i */ Int num. avanta; ) nda a v a n t.t a b l * tj } * * Veal 1* tha c a l i b r a t i o n fa c to r batwaan a known amplltuda wav*form * and tha intagar valuaa producad by tha N lcroatar board. * th* fa c to r la 5 , O v o l t * / 32769 */ id a f l n a nda v e a l 1 . 5 3 E ~ D 4 id a f l n a NDS DATAOFPsiT 1034 id a fln a MOS PYTI5..9AHPLS 2 /* tha numbar of bytaa par aampla */ 1). 1,4 read d ata.c /* * r**d_d*ta.c • * Modiflad by B i l l scarin g*, 3 / 9 4 r from * mkraa.c w r ltta n by Brian Lowry, * * Aaada a l l apoch data from a l l a alactad RIT aagmanta Into * a a agu an tlal block of mamory- ■ */ • Include <std io.h> • In clu d e * * t r l n g .h ' • Include ( i t d l l b h : . •I n c lu d e "nds.dafs.h" • d e f i n e ISI PII^ " R IT .In tervals.ascllV O - )* RIT ISI t a b l e f i l e . */ Int ReadDataf pathname, f i r a t sag, l a s t _ s * g , l a l a ca la , /* In p u t, */ m i « j u l M * _ p t r , n u > _ p u ls e s _ t o t_ p t r , l s i _ t o p , ISI _*u * .to t _ p tr . d a t a . p t r ..ptr, e p o ch _ p ta _ p tr, saap per p tr . sap._galn_ptr,pulaa r a t e ptr , chan..ptr) I* Outputs char int f l o a t abort unaignad long f l o a t f l o a t abort unaignad long f l o a t f l o a t f l o a t int *pathnama; f i r s t . s a g , l a s t . s a g ; i a l _ a c a l « ; "num_pulsas_ptr; *num _pulsas_tot_ptr; •IS I top; •ISI_sum._tot_.ptr/ **data_ptr ptr; •apoch.pt* _ptrj • samp_par _j>tr; • amp_gain_ptr7 •p u l* a _ r a ta _ p tr ; •chan .ptr; /* Uaar Input 1 in p ut/o u tp u t pathnams r o o t. * / • F i r s t / l a s t aagmant numbar. /■ i a i acala va lu a . /* Array o f ip u la a a in aach aagmant. /* Total numbar of pulaaa. /* Top of i s i array fo r a l l aagmanta. /* Sub of a l l ISla in a i l l i s a c o n d s . /* Pointar to a ta rt of raw data valuaa. /* Numbar of aaapla p o i n ts uaad par apoch. /* Sampla pariod in m i ll i a a c o n d a . / • p raam plifiar gain . /* Maan stimulu.) rata (pulaaa par ate) . /* Data ohannal. ( /* RaadPata */ /* a lo b a l V ariablaa */ axtarn int dabug, vsrbosa; command lln a o p tio n s . /* charactar V ariablaa */ char * n u n iu ffl x [1 - { M ,01", ".02" “ .1 0 -, -.11", ' M r . M S " , char lnpath[256J; char *t, 1ina 112®) ; " . 0 3 - , ■ ■ . 04 M r " . OS" , M . 06 - , « , 07 H f " . 0 & " , " . 0 S “ ‘ . X4* , ■ ' . 15" , - . 16“ , - . 17" , ■ . lflh, * ■ . 19" , " . 20” ) /* Input f i l a pathnama root. */ /* R aglstar V ariablaa */ r a g la ta r in t 1; /* Kumar: in t Int Int f loat short unaignad unaignad unaignad •gmant. */ unaignad c V ariablaa */ num chan; /* r a t . v a l * ! ; /* aagmant; / - tpauaa; / l a s t _ v a l ; /* long t o t pta/ /• long raad_pta; /* long g a t_ p ts ; / i long cut apocha; Total numbar of channala. Raturn valua. Train aagmant numbar. * Intar-aagmant pauaa in mi 1 l i s a c o n d s . Last raad valua; for padding. Total Haamplas in a l l aagmanta. Numbar o f p o in ts a c t u a l l y raad. 1 Numbar o f apoch sampla p o in ts t o raad for currant To count numbar of apocha raad. */ / • P ointar* */ ahort *apoch_ptr; / • P oin tar to s t a r t of data fo r currant apoch. */ short *buf_ptr-NULL; /* B u ffa r p o in ta r fo r raadlng m u ltip la chan d a ta -" / f l o a t * i s i _ p t r j /* Running poin tar for ISI array. */ /* T y p a d a f * from n d a d a f s . h */ nda. pa ram blk. t ands p tr ; nda avant t a b l a t *avant t a b l * p tr ; /* r l l a pointar* */ PILE *fp/ /* Function D a c l a r a t l o n s . */ axtarn in t AllocataMamoryf) t I* A llo c a ta mamory for a l l data. ♦/ axtarn void FraaMamory()/ /* Fra* tha data mamory. */ axtarn Int a a t z s i a f ); /• in g a t ..la ia .c */ axtarn FILE • I n l t i a l i x a P i l s (); /* in nacopa u t i l . c */ axtarn v o id n d s_cloaa f i l a O ; /* in nacopa. u t i l . c */ axtarn void n d s _ l i a t in fo (); axtarn long nds__gat .avant (> j t* in nscopa . u t i l .c */ axtarn unaignad long RaadEpoch (> 7 /* Raad data for ona apoch. */ /* START OP CODE FOR RaadData •/ / • A llo c a t a mamory for tha nds parasm ta r block and avant t a b l a . */ nds_ptr » <nds_param„blk_t * )m a llo c( s l i a o f (nds param_blk._t) >; i f ( I n d s r ) /* V a r lfy auccaaaful a l l o c a t i o n . •/ ( (void) p r l n t f < "SnCOULD NOT ALLOCATE MEMORY FOR NDS PARAMETER BLOCKJ \ n “ ); go to claanup; ) avant _ t a b l a . p t r • { n d « * v * n t t u b l a . t * ) am 1 loc ( s la a o f (nds. avant ta b la _ t} ); i f ( l a v a n t . t a b l a . p t r ) /* V arlfy auccaaaful a l l o c a t i o n . */ 1 2 0 < (Void) p r l n t f ( “\neoULD NOT ALLOCATE MEMORY FOR NDS event TABLE I \ n H ); g o to cleanup; > /* Open th# f i r s t segment f i l * . */ (void) str c p y f {char * ) inpath, (char *) pathname ); (void) * t r c a t ( {char M ln p a th , n u m a u ffix [£i r * t . s * g - l ] ); I f ( debug ) (void) p r l n t f ( *\nop*nlng Segment F il # [H*) \ n “ , inpath )/ fp ■ I n i t l a l i s * F i l * ( inp*th, ad* _ptr, * v * n t_ ta b l* p tr , l*l._«c*l* ); I f ( fp «« NULL ) ( (void) p r l n t f { “*** CAN'T OPEN NDS FILEi [H*]\nM . lnp*th \, r e t u r n ( o ); > /* L ist in fo on th* NDS f i l # */ nd* l i a t i n f a ( nda ptr. Inpath 5; /* Have th* uaar pick a channel numbar (If nor* than X). */ num chan - nda ptr->nd» num channala; i f ( num chan > 1 ) ( do { (void) p r i n t f ( "\nThara ar* Hd data ch a n n els. Pick ONEi ", num chan ); (void) 0 *t*( l i n * ); (void) * * c * n f ( lin * . M Hdwr chan ptr j; {void) p r l n t f ( "You picked channel Hd. \n", *ch«n p t r ) ; ) w h ile { ( ' c h in p tr < 1) It (*chan p tr > num chan) ); ) • l a * +chan ptr - 1; i f ( debug ) (void) p r l n t f ( “ \nu*ing data from channal Hd. \n " , *chan ptr ); / * g e t th* aampl* p e r io d , a m p lif i* r gain , m*an atimulua rat*. and i n t * r - a*gm*nt paua*. */ ♦■amp p a r .p tr • l , o / n d * p tr -> n d i aamp_fr*q chan; / • m lllia a c o n d a */ ♦ i i p g t l n . p t r - l . o/nda. p tr - >nd*. a l t u n it conv; *pula* r* t* _ p tr » ( f l o a t ) n d s p t r - >nda 1 s t im [1); /* Maan a t l a rat* ( p u l / a * c ) . * / tpauaa - { f l o a t ) nd*.ptr->nda int t r a i n paua* * 1 0 0 0 . 0 ; /* m lllia a c o n d a */ /* o e t th* 1 st* for th* a « l* c t* d a*gm*nt«. th* t o t a l numb*r of apocha, and th* aum of th* IS la . */ / • iS I.iu m t o t la th* t o t a l o f a l l IS la for a l l **gm*nta. but not Including th* lnt*r*#gm*nt paua* (tpauaa). Th* int*ra*gm*nt paua* la assumed to b* much la rg a r than th* maan In ta r v a l *o that I t do** not a f f e c t th* k*rn*l com p utatlona. */ i f { JO *tlSX *{fir*t_**g, l a s t .sag, tpauaa, *pul«* ..rat* p tr . 1*1 a c a la , / * Input *•/ ISI. top, 1st sum .tot p t r , num pulaaa p t r , num .pul*** t o t p tr ) / ‘o u t* / ) r*turn ( o ) j /* A l l o c a t e mamory for a l l th* data p o i n ts . */ **poch_pt»_ptr - ( i n t ) (nda pt r - >nd# * p o c h ..s is * #nda p tr - >nd* samp f r*q chan-tO . 5) ; t o t pta * (unaignad long) ( *num pula**..tot p tr * **poch_.pta ptr it i f ( debug ) (void) p r l n t f ("\n A llo c a tin g \ l d byt*e o f mamory fo r Hid data p o in t* i *, s l t e o f ( s h o r t > * t o t p t * , t o t p t i ); i f { IAllocat*Memory< data p tr _ p tr , t o t_ p t * ) ) < (Void) p r l n t f ( H\n *** NOT ENOUGH MEMORY FOR DATA \n" ); (void) p r l n t f ( “\nNe*d*d M d b y te s of mamory for Hid data p o i n t s . \n H, 127 return( o )i ) s i s e o f ( short) * t o t j ) t i , t o t p t i ); I f ( debug ) (void) p r l n t f ( " \ n Don* a l l o c a t i n g M t o t y . \ n m ); / • I f th* data f l l a a c o n ta in more than on* channel, c raat* a temporary b u ffa r fo r r**ding in th* a l t e r n a t i n g data, */ If ( nun. chan > 1 J < I f ( IA llocs t*Memory( 4buf p tr . #*poch_pts p tr * nua chan ) ) < (void) p r l n t f ( * \ n *** not enough memory for multichannel buffer (void) p r l n t f < "\nN**d*d Sid byt*» of aaaory for S id data p o ln ts t ", a l i a o f ( a h o r t ) * *epoch._pts p tr * hum chan. **poch pta ptr * nua chan}; r e t .val ■ 0 / goto claanupi ) /* Loop for *ach segment. */ apoch ptr - ‘data ptr .per; /* i n i t l a l l i a tha apoch p o i n t e r . */ cut epochs - 0; / • i n i t i a l i s e apoch count«r. */ t o t p t i * 0 ; /* I n i t i a l i s e tha data p oin t cou n te r. */ ISI ptr ■ i s i top; /* m l t i a l i i a th* X&I array p o in te r . */ fo r ( s e g m e n t - f i r s t sag; aagm *nt<-last sag; segment**) ( /* D isp lay i n f o on the currant segment. */ (void) p r l n t f ( “\nlteadlng Data for segment #Sd\n", segment ); (void) p r l n t f ( - Number o f epochs - V l\n", nds. ptr->nds. num puls** ); g * t_ p ts • (i n t ) (nd#_ptr->nds e p o c h s l i e * nds p t r - >nds. samp freg chan + 0 .5 ); (void) p r l n t f ( H Data P o in ts per Epoch - \ n " , g e t p ts ); i f ( got p ts > ‘epoch p ts _ p tr ) ( (void) p r l n t f ( "(more epoch p o in ts than for f i r s t segment.\n* ); (void) p r l n t f ( M o n ly f i r s t t l d p o in ts w i l l be u s e d - ) \ n H. ‘ epoch p ts ptr ); g e t p ts - ‘ epoch p t a . p t r ; ) e l s e If ( g a t p t s < ‘epoch p ts ptr } ( (void) p r i n t f ( " ( fewer apoch p o in ts than for f i r s t segment,\n" ); (void) p r l n t f ( H w i l l pad with se ros up to t l d p o i n t s . } \ n H. ‘ epoch p ts p tr }; > / • For each epoch in th e NDS f i l e , read the data. */ fo r t 1-0; l<nd*_ptr->nds. num_pul**s; 1 + + ) ( I f ( debug 44 verbose ) ( (void) p r l n t f ( “\n»poch % d f , 1*1 »j i f ( 1 < (nd s_p tr- >nds_num._puls*s - 1} ) (void) p r l n t f ( H\nArray ISI: Vf, Event Table ISIi %ld -, * lst_p tr ++ , event t*bl*_p t r ~ >I S I [1 + 1] ); (void) p r l n t f ( "VnReading from p o s i t i o n \ l d i ", •v en t t a b l* _ p t r - > e v * n t [1] ); ) r*ad_pte - HeadEpoch( fp, e v e n t _ t a b l e _ p t r - >e v e n t (i ], g e t p ts , epoch_ptr, ‘ chan_ptr, bum_chan, buf_ptr ); to t..p ts *- raad p ts; I f ( debug 44 verbose ) ( (Void) p r i n t f <“\ l d p ts read, Vld t o t a l . \ n “, read_pts, t o t . p t s ); ) i f ( r*ad_pts I- g e t p t s ) 12X { (void) p r i n tf { *\nNAMfZHO fo r apoch \ d o f aagmant %di\nM , 1*1, aagmant}; (void) p r l n t f ( "Raad %ld p o in ts . Expactad \ l d point*I H. r**d._pt*, gat .pt* ) ; i f ( raad_.pt* -* o ) ( rat v a l ■ 0* go to claanup; > (void) p r l n t f ( -L**t M d p oin t* **t to l a s t raad va lu a . \ n H, gat_pt*-raad_pt» >i ) cnt _*poch*++/ /* InciftMitt th* apoch p o in ta r bayond tha raad data fo r tha currant apoch.*/ apoch ptr +* raad pta; /" Pad with la*t raad valu* i f numbar of p o in ts raad i s smallar than apoch * ls * of f i r s t aagmant. Also lncramant apoch poin tar and t o t p t s a cc o r d in g ly . */ l a s t v a l ■ * (apoch p tr 1); for ( } raad p ts < "apoch p ts ptr; raad pt*++ > ( "apoch ptr « l a s t v a l; apoch ptr++; to t pt*++; } ) /* for a l l rasponsas */ /* Cloaa tha c u r r a n tly opan NDS f l l a */ i f ( fp !■ NULL ) n d * _ c lo * * _ f11*( fp ); /* opan th* Input f l l a for tha n a i t aagmant. */ i f (aagmant I- l a s t sag) ( (void) *trcpy( (char • ) inpath, (char ")pathn*m* ); (void) * t r c * t ( (char *)lnp ath , numauffix(aagmant] ); i f ( dabug } (void) p r l n t f ( "\nOpaning Sagmant F il * t^s] \n", lnpath >; fp - I n l t l a l l a a P i l a ( inpath, nd* per, avant t a b l a p tr , l a i s e a l s i f < fp - - NULL ) ( (Void) p r l n t f ( CAN'T OPEN NDS FILEj [ \ * ] \ n H, inpath ); rat v a l ■ 0 ; goto claanup; ) /* L iat ( o p t io n a lly ) Info on th* NDS f l l a */ i f ( varbosa ) n d * _ l i * t _ i n f o ( nds_ptr, inpath ); > ) /* End of aagmant loop. */ /* Chack i f numbar of raad apocha was a s arpactad. ■/ i f ( cn t.apoc ha *■ "num.pulsas t o t p tr ) ( (void) p r l n t f ( "\iVSld apoch* raad, a* axpactad. \ n p, "num p u ls a s t o t ptr }; ) alts ( (void) p r l n t f ( "\nWARNXNOt M d t o t a l apoch* raad. ", cnt apoch* ); (void) p r l n t f ( "\n Xld t o t a l apoch* axpactad a ccording to ISI t a b l a .v n - , *t\um_pul*as . t o t _ p t r ) $ i t ( c n t a p o c h s > "num_pul***_tot_ptr ) ( (void) p r l n t f ( * \n MEMORY ALLOCATION EXCEEDED - E x itin g \n- ); ra t_ v * l ■ Oj goto claanup; 129 > *num_pulsaa_tot p tr - c n t a p o c h a ? (void) p r i n t f (*\nlpoch count ha* baan raducad to ^ ld.\n",*num pulaaa t o t p tr ); ) (void) p r l n t f ( M \nXld data p o in t# loadad in to mamory. \n", t o t pt*>; / • Exit */ c L*«nupt i f ( i rat val ) t FraaXamoryt *data..ptr ptr )/ > If ( nd* p tr ) f r « a { nda p t r ) ; i f ( avant ta b la p tr ) fraa ( avant ta b la ptr I; Fra*Mamory( but ptr >; r a t u r n ( rat va l >; > /* HsadData */ /**•*•****• ********** .. int AllocataHamory( data p tr _ p tr , t o t pta ) /* Tha binary nacopa data f i l a uaaa 3 bytaa par aampla. Thla program aaaunas that tha a l i a of ahort la 2 bytaa. */ ahort **data _ptr__ptr * /* pointar t o s t a r t o f raw data valuaa. *i unaignad long t o t_ p ta j /* * A llo c a t a a chunk of mamory for tha data valuaa. * An ln ta g a r atatua la raturnad. */ ( /* AllocataHamory • / ♦data ptr ptr * HULL/ *data p t r . p t r - (ahort * ) c a l l o c ( (unaignad Long)tot pta. a l i a o f (a h o r t > ); i f ( i M ata p t r . p t r ) r a tu r n { 0 > j a laa r a t u r n ( 1 )j > /* AllocataHamory */ void FraaHamory( d ata_ptr j ahort M a ta .p tr * /* pointar to s t a r t o f raw data v alu aa. */ / * * D a l l o c a t s a chunk of mamory. */ ( /* FraaXamory */ / • Fraa storaga */ If ( data_ptr l» HULL ) fraa( data__ptr }j ) /* FraaHamory */ ........ unaignad long RaadKpoch( fp, poa, apoch„pta, apoch_ptr, channal, num chan. buf_ptr ) 130 FILE * fp ; long po*; i* Epoch data o f f s e t p o s i t i o n in 111*. unsigned long * p o c h p t i f / • Number of sa s ^ la p o in ts in on* epoch, short "epoch,ptr; /* p o in ter t o memory lo c a t io n to put epoch data. int channel/ /* channel number t o read. in t num_chan; /* T otal number of channels. short "buf ptr; /* P o in ter t o temporary b u ffer lo c a t io n . / * * ReadEpoch() reads the channel data and * put* I t In to the p r e - a l l o c a t e d b u ffe r . * If s u c c e s s f u l , the nuaber o f p o i n ts read-In * i s returned. «/ { /* ReadEpoch */ unsigned long j; unsigned long read pts-ci; unsigned long chan p ts; / * * Move t o the c o r r e c t p o s i t i o n in th* f i l * and * do a b u ffered read * / If { nua chan *• 1 ) ( i f ( lfs**k ( fp, s i * * o f ( short )* postNDS DATA OFFSET, SEEK. SET > ) r e a d .p t s * frea d l e p o c h p t r , # l i e o f ( short ), e p o ch .p ta , fp I; ) e l s e ( i f { lf s s e k ( fp, e i s e o f f short >*pos*nua chan ♦ nds .DATA OFFSET, SEEK set { r e a d p t s ■ fr*ad( buf p tr , a l> e o f{ short ), epoch pts*nua chan, fp ); chan p ts ■ read p ts /n u a .ch a n; for ( j«0; j < chan p ts ; + ) • (epoch ptr**> - *(buf p tr * ■ j+num_chan * channel 1 ); read p ts * chan p ts; > i return* read p t s ); /+ ReadBpoch *f /• * Write t o atdout soae of th* nds f i l e header in fo V void n d s _ l i s t . i n f o ( n d s p t r , pathnaae ) nda p a r a a .b lk t *nde ptr; char pathname!!; { /* nds. l i s t . i n f o */ int j j /* Return I f a f i l e has not been s e l e c t e d */ i f ( nde__ptr *- NULL ) return; /* Maks a slew of inform ation s t r in g * */ (void) p r l n t f ( * \ n l n f ormation for f i l e |V sJ \n N, pathname ); (void) p r l n t f { "Owner ( \ s ) \ n * , nds_ptr->nde_.user_name }; (void) p r l n t f ( "Nod* name l \ * ] \ n " , nde_ptr->nd*_node ); (void) p r l n t f ( pos v e r s io n (* e )\n * , n d s _ p t r - > n d s O S v e r * i o n ); (void) p r l n t f < "F ile a l e e \ d \ n \ n ”, n d s . p t r - > n d a _ f i l s s i i e ); (void) p r l n t f ( "Epoch len gth %5.if meecVn", nds_ptr->nds .epoch, a l i e )j (void) p r l n t f ( H S ta p lin g frequency/chen x s . i f kHa\nH, nd*_ptr- >nds_**ep_freq_ch*n }; (void) p r l n t f ( "Channel* \ d \ n " , nds_ptr->nd«_num_channels )j {void) p r l n t f ( "Pulses Xhd\n", n d sp tr -> n d * _ n u m .p u lse s )j If ( nds p tr->nds t o t a l records < 0 } { (void) p r l n t f ( "*The f i l s Is an everageVn" s l s s { (void) p r l n t f ( "Records Xd\n“ , nds p tr -> n d s t o t a l record* ); ) (void) p r i n t f t " I n t e r - tr a in pauss %d s e c o n d s \ n - r nd* _pt r - >nd* Int ,.train_paus« > j (void) p r l n t f ( "Osin X 6 .2 fx \n" , 1 ,0/nd* ptr->nd* a l t u n it conv ); (void) p r l n t f ( "Actual u n i t s e r e [ X s ) \ n \n * r nds ptr->nds a l t u n it s t r ); If ( nds ptr->nds KIT f l a g ) { (void) p r l n t f i "RIT data, segment Xd\n", nds ptr->nds lstimtO] ); (void) p r l n t f ( H Msan stim ulus frequency xd nds ptr->nds is tim li.) ); a la a If { nd* p tr-> nds t e s t f i l * f l a g { > • Isa < (void) p r l n t f ( uTa*t f i l s (Xsjv.n", nds ptr->nd* t e s t f i l e nan (void) p r l n t f ( "User d efine d s t l n u l u s i \ n " ); for ( j - l r j<-nd* p t r > n d s n u n _ p u l * s s ; J* + ) (void) p r l n t f ( X SI[\ld] i s Xd m»ec\n“ r j, nds ptr->nd» i * t l » f j ) )j ) ) (void) p r l n t f ( " \ s \ n * J nds_ptr->nds c o n i n t 1 ) /* nds l i s t Info */ /* end or f i l * */ I). 1.5 fjel isisx' / * * get I s i s . c « * by B i l l S earings, 4 /9 4 . * •/ *in c lu d e ca td io .h ? S includ* < *tr ln g.h > • i n c l u d e < * td llb .h > • in c l u d e “nd*_defa.h* •da fin * I S I P I L 1 "HIT. I n t e r v a l * . a * c l l \ 0" / • RIT ISI t a b l e f i l * . int O etlSI* ( fir a t_ a * g , la a t sag, tpauaa, pul**_.rata, 1*1 se a l* , /* Input* */ ISI ..ptr, isi_*uB__tot p t r , num pul*** ptr,num._pul***_tot. p t r ) / * Out Int f l o a t f l o a t f l o a t f l o a t f l o a t ahort unaignad long f l r a t a e g , la a t sag; /* r l r * t / l a * t segment nuab*r. tpaua*j pul** rate; 1*1 * c a l*i • is i_ p t r » •IS I *ub t o t_ p tr j • nua_pu 1 a • ■ ..pt r i •num_pul»**_tot,ptrj / • Inter-segm ent pau** in B i l l i s e c o n d * . /* Mean s t i a u l u * rat* {pula** par aec J . / • ISI s e a l* fa c to r . / • ISI* for a l l *v*nt* of a l l *egB*nt*. / • sub of a l l ISla in B i l l i s e c o n d * . /* Array of nua pulaa* In each **gB*nt. / • T otal number of pul***, a l l **gB*nt* 1 Raad tha ISI* for tha s p a c if ia d aagmanta and put a l l in ona array, in c lu d in g tha intar^aagmant pauaa batwaan aach aagmant. Inputi Tha input ISI ta b la f l l a i* axpactad to c o n ta in tha IS la in m illla a c o n d * in a column for aach aagmant. Bach column 1* axpactad to ba paddad with at la a a t ona saro at tha and of tha column. Tha t a b l a la axpactad to co n ta in i s i * for a p u l a a r a t * (maan atimulua rata) of 2. If tha a c t u a l p u la a .r a ta 1* d i f f a r a n t , tha IS la w i l l ba modifiad a c c o r d in g ly a« thay ara raad In. o utputi Tha Z s is for a l l aagmant* ara put i n t o a tha a a g u a n tla l array c a l l a d i s i . Tha lntar-aagm ant pauaa la lncludad a i an ISI valu a batwaan tha laat atimulua of ona aagmant and tha f i r a t atimulua of tha naxt aagmant. Th# f i r a t 1st (array lndax * 0 ) la tha ISI from th# f i r a t atimulua to th* aacond atimulua. Tha laat ISI in tha array la th* Xsx from th* aacond to la a t atimulua to tha la a t stim u lu s . */ axtarn int dabug j / * Command lin * o p tio n s . */ FILE *Cpi / * input f l l a p ointar. V char l n p a th (2561; / * Input f l l a p tth n a ss root. */ char *t, 11n a [126}; Int 1*1 val; /* ISI valua from ta b la . •/ Int J; int aagmant; /* Sagmsnt numbar. */ /* opan tha f i l * c o n ta in in g th* IS la . */ (void) atrcpy( (char *) inpath, i s i r i L l >; i f { (fp -fo p a n i lnpath, Hr * H )) -- Null ) ( (void) p r l n t f { "\nCANT OPEN i s i FILE i [%a]\n", inpath ); r a t u r n ( 0 ) j 1 i f ( dabug ) (void) p r l n t f ( ■\nOp*nad i s i f i l * i%*].\n", lnpath ); /* Raad tha ISX*. */ /* ISI aum_tot la th* t o t a l o f a l l ISla for a l l aagmant*. but not in c lu d in g tha lntaraagmant paua*. */ *I s I sum t o t p tr - 0 . 0 ; /* I n l t i a l l i a tha countar for tha t o t a l numbar of apocha in aach aagmant. Not# that tha count s t a r t * at 1 ainca th* numbar of apocha w i l l ba ona mor* than th# numbar of ISla (th# l a s t spoch has no i s i ) , */ *num.pul**a t o t p tr - 1 ; for ( a a g m a n t -f lr it **gj **gm#nt<-laat_a*g; s#gm*nt++ ) ( i f ( dabug ) (void) p r l n t f ( "\nR**ding IS la fo r sagmant % d . . ", aagmant ); * (num..pul***._ptr * ■ aagmant - f i r s t .sag) * It (void) r#wind( fp ); do ( fg*ta< lin * , a l i a o f (l i n * ) , fp ); t - (char • ) s t r to k ( l ln a , “ “ )j fo r ( } - l j 1<aagmanti } + * ) t ■ (char * ) s t r to k ( NULL, " " ) ; I s i . v a l ■ a t o l ( t )* i f ( t l s i _ v a l ) ( If (aagmant \ - laat..sag > ( ( *num_pul*a*_tot_ptr)♦ • 1 s t p tr ■ tpauaa* /* Includa intar-aagmant pauaa. */ i s i _ p t r *♦i ) i • 1 » * ( < * (num_pul**a p tr * **®»*nt - f i r a t **g) )*+} ( *nui pul •* ■ t o t _ p t r ) o ; *ISI ptr - ( f l o * t l l * i v * l * l * l . * c a l « * 2 , 0 /pul**_.r*t* f f* Hot* pul** r * t* . */ • I s i _ » u * _ t o t p t r *• • i S I . p t r ; isi_ptr++? ) ) W h l l * < 1 * 1 V * i ) ; If ( 4*bug ) (void) p r l n t f ( *%d i s i * r * * d . - , +(num.pul*•* ptr * **?a*nt - f l r * t »*g) ); > /* d o * # th* i s i f i l * . */ f c l o * * ( f p )} r a tu r n { 1 ); I /* 0* t i s i * ( > */ . /* *nd of f i l * */ I). 1.6 nscopeutil.c / * * m a . c * A*«d H*uroScop* f i l * * * A aiftpl*. p o r ta b l* , c a l l l ib r a r y for NDS f l l a * . * */ • In clu d * < a td io.h » • Includ* < a td llb .h > • in c lu d * < a t r l n g . h > /* Th* fo llo w in g includ** *r* ANSI but ar* not u**d In t h la cod*, and thua hav* b**n c o n t n t a d out ■ • i n c l u d * < *lgnal.h> */ /* Th* f o llo w in g Includ** hav* b**n c o u n t * ! out •In c* tb*y ar* not ASCII atandard and ar* not n**d*di • i n c l u d * < a y a /ty p * a . h> # ln c lu d * < aya/u lo.h > • In clu d e < * y * / f l l * . h > */ • ln c lu d a " n d a d * f a .h - / • Boolean valuaa •/ • da fin * ON 1 •d*fIn* orr o •d *fIn * TRUK i •d a fln * PALsa o Ndafln* KAX(A.B) ((A) < IB) T (B) i {A]) • d a fl n * NIN(A.B) ((A) < (B) 1 (A) i (B) ) .............. Int cg*t ( fp, poa, ptr, n ) Int n I 134 FILE *£p> long poij v oid *ptr/ / * * Raad n bytaa from p o s i t i o n po* * in f i l * fp, p la c in g in to addraaa * pointad to by ptr */ ( /* cgat */ /* Mova t o a p o s i t i o n */ i£( fa**k{ fp, po*, SEEK^SET > 0 ) ( r«turn{ fr*ad( ptr, 1, n, fp ) ); ) ) /* cg*t */ long lg * t{ fp, poa ) FILE *fp; long po»; / * * Raturn a longword from p o s i t i o n pot * in f i l * fp. * / { /• lg * t */ long lv a l; i f ( f***k( fp. POI, SEER SET | 0 ) ( fr*ad( {■lval, a l i a o f (l v a l | , 1, fp W r a t u r n ( l v a l >/ 1 } /* lg a t */ .... ahort *g*t( fp, poa } FILE *fp; long po*; / * * Raturn a shortword from p o s i t i o n po* * in f l l a fp. * / ( /* *gat V short aval; lf£ f***k( fp, po*, SEER SET ) - - 0 ) { fraadf fcaval, a l i a o f ( a v a l ), 1, fp )/ r a t u r n < aval ); ) } /* agat •/ f l o a t fg a t( fp, po* ) FILE * f p t long potj /* * Raturn a f l o a t i n g p oin t valu* from * p o s i t i o n poa In f l l a fp. */ ( /* fgat •/ f l o a t fv a l; i f ( f*aa)t( fp, PO*, B>EK_SET ) ■- 0 ) ( fr**d< fcfval, a l i a o f (f v a l }, 1, fp )j raturn< f v a l ); > } /* Cgat */ nd* g*t_.h*ad*r ( fp, nda p tr ) FILE *f p ; nd* param blfc t *nd* ptr; / * * QIvan a s t r t a n po in ta r, raturn a p oin tar to “ an NDS format f l l a haadar. */ ( t* nda gat haadar */ long poii /* Cila o f f a a t */ Int 1, unaignad ahort bval? /* Oat tha haadar varalon , p r in t, mova to naxt f i a l d */ poa » 0/ If 4 c g a t ( fp, poa, nd* ptr-> n d i varalon , nda haadar varalon alxa ) ) ( nd*_ptr->nda var»ion(nds_hatdar v a r t lo n a l i a ] - f\ 0 '; poa ♦ - nda.h*«dar_v*r*ion_aisaj > /* CHECK VERSION HERE . . . I F NOT OR RETURN V /■ oat tha OS varalon, p r in t, mova to naxt Ciald */ i f ( c g a t( fp, poa, nda p tr -> n d i OS.varalon, nda os v a r a lo n .a lx a > > ( nda .p t r - >nd*_0S var*ion(nda OS. varalon. a ls o ) - ^ O 1; poa +* nda.OS varalon alxa; ) f* Oat tha noda ID, p r in t, mova to naxt f l a l d */ I f ( c g a t ( fp, poa, nda ptr->nd* noda. nda noda alxa ) ) ( nd#. ptr-»nd*_nod*{nda nod* a l i a ] - ' \ o f ; poa nda.nod* a l i a ; ) / • oat tha uaar nama. p r in t, mova t o naxt f i a l d */ i f ( c g a t( fp, poa, nda..ptr-> n d a.u aar nama, nda uaar.nam* alxa ) ) < nd* ptr->nd#._u**r nama[nda uaar nama . a l x a ] * ' \0 '/ poa ♦ • nda uaar nama.alxa; ) /* oat tha f l l a alxa, p r in t, mova to naxt f l a l d •/ nda ptr->nd* f i l a a i x a « l g a t ( fp, poa )t poa ♦ • a l i a o f ( nd*_ptr->hd#_f11*. s ix * /* oat tha apoch a l i a , p r in t, mova t o naxt f i a l d */ nd*_ptr->nd* a p o c h a i x a * fg a t( fp, poa ); poa ♦ * # lx * o t{ nd* p t r - >nd*_*poch. s i x * ); / • oat tha numbar o f channala, p r in t, mova t o naxt f i a l d +/ nda ptr->nd*_num_.chann*la ■ ag*t( fp, poa j; poa *• a l i a o £ ( n d »_p tr- >nd*_numch*nnal» ); /* Gat th* numbar of pulaaa, p r in t, mova to naxt f l a l d •/ nd*_ptr->nd*_num_pul**a ■ *g*t( fp, poa )/ poa ♦ - a lx a o f { nda..ptr->nda_num_pulaaa )t /* Gat tha aampllng fraquancy, p r in t, mova to naxt f i a l d */ nda_ptr->nd*.a«mp_frag. chan - fg a t( fp, poa )/ lift poa +- a lx a o f( nda_ptr->nds f4B p _ tr*q c h « n ); / • o a t tha a l t a r n a ta u n it* , p r in t, mova t o naxt f l a l d */ nda ptr-»nda_alt_unit._conv - f g a t ( fp, poa poa 4 - a l i a o f ( nds p tr-> nds a l t u n l t conv )j /* Oat tha a lt a r n a ta u n it s t r i n g , p r i n t , aov* to naxt l l a l d */ i f ( c g a t ( fp, poa, nda_ptr-»nda..alt unit s t r , n d a . a l t u nit i t r a l i a ) ) { n d a p tr - > n d a a l t _ u n l t a tr [nda a l t . u n i t atr alxa] * ‘\ 0 ’i poa 4 a nda a l t u n i t . s t r a li a ; ) /* Oat tha numbar o f t o t a l racorda, p r in t, nova to naxt f i a l d */ nda p tr - > n ds_ to t* l_ rsco rd a - agat( fp, poa ); poa 4 - a l x a o f ( n d s _ p t r - > n d s .t o ta l racorda )? /* oat tha i n t a r - t r a i n pauaa, p r in t, nova t o naxt f i a l d */ nda ptr->nda i n t . t r a i n pauaa ■ sgat < fp, poa )j poa 4■ a l i a o f ( nda ptr->nda in t t r a in pauaa j; /* aat tha a lt a r n a ta u nit a trln g , p r in t, mova to naxt f l a l d */ If i c g a t ( fp, poa, nda ptr->nda taat f l l a nama. nda ta a t f l l a nama alxa ) J i nda ptr->nda ta a t f l l a namatnds ta a t f l l a nama alxa) ■ ' \ 0 '; poa 4- nda ta a t f l l a nama a ita ; ) /* aat tha ta a t f l l a nama langth , p r in t, mova t o naxt f i a l d *{ nda ptr->nda t a a t f l l a lan gth * a g a t ( fp, poa ); poa 4- a ix a o f( nda p tr -> n d s ta a t f l l a langth ); /* aat commant It l, p r i n t , mova to naxt f i a l d */ If ( c g a t ( fp, poa, nda. p t r - >nda_commant_1, nda commant a l i a ) > { nda per->nd*.commant. 1 (nda coamsnt alxa) - *10'; poa 4* nd*_commsnt_slxs; ) /* aa t commant # 2, p r in t, mova to naxt f l a l d */ i f ( cgat ( fp, poa, nda ptr-^nda commant 2, nda commant alxa ) ) ( nda.ptr->nda commant 2 (nda commant alxa] « \ 0 ' ; poa 4■ nda commant alxa; ) /* Qat tha sampla moda , p r in t, mova to naxt f l a l d */ nda ptr->nda .sampla moda ■ a g a t ( fp, poa ); poa 4* a l x a o f ( nda ptr->nda aampla moda )/ /* aat tha d i s p l a y moda , p r in t, mova to naxt f l a l d */ nda ptr->nda..dlsplay_moda - sgat< fp, poa ) ; poa +- a ia a o f ( nda ,ptr->nda dlaplay.moda ) r l* aat tha t r l g g a r moda, p r i n t , mova to naxt f i a l d */ nda_ptr->nda_trlggar_moda ■ a g a t ( fp, poa )j poa 4- a l x a o f ( nda_ptr«>nds_trlggar moda )j / • aat tha channal galna, p r in t, mova t o naxt f l a l d */ for { 1-0? i<ndi_max channalai 144 ) ( nda ptr~*nds_chantial_galna (1) - fg a t ( fp, poa ); poa 4* a l x a o f { nds_ptr->nds channal g a i n s ( l ) ); > /♦ Oat tha atimulua valuaa, p r in t, mova to naxt f l a l d */ for ( i - 0 ; i*nds_max. latlm ; 144 ] ( nda_ptr->nda_.latlmli] - agat( fp, poa >j poa 4• a l i a o f ( nda_ptr*>nda_latlm (1] ); ) /+ Oat channal namaa, p r in t, mova t o naxt f i a l d for ( 1 * 0 ; l<nd* jxax_channals; 1 + + ) ( I f ( c g a t( f p , poa, n d s .p tr->nds_channsl_nam sa[1], nda channal_nama la n g th )) ( 137 nd* ptr - >nd* channal nama* 11 ] (nd* channal r i m len g th J - ' \ 0 ■ ; po* +» nd* channal_nam#_langth; ) ) /* Oat RIT f l a g , p r in t, *ovt to naxt f i a l d */ bval ■ (unsigned s h o r t ) a g a t { fp, po* ); I f ( b val > 25« ) nd*._ptr->nd* KIT f l a g - ONi • 1** nd*__ptr->nda_RlT_fl*g • OFF; po* +- siaaof(nds_ptr-> nda_R X T _flap); /* Oat t a a t f i l * f l a g , p r in t, aov* t o naxt f l a l d */ bval - (unsignad a h o r t ) a g a t ( fp, po* ); i f { bv*l > 254 i nds__ptr->nda_ta*t _ f i la _ f lag » ON; * 1* * nd* ptr->nd* ta a t f l l a f l* g - OFF; po* +« a iz a o f fn d s ptr->nd* ta a t f i l * f l a g ) ; ) /* nd* gat haadar */ . void nd* r a a d .t a a t f i l # ( t « « t flla .n a m a , nd* p tr , a v a n t . t a b l a ) char t a a t f l l a nan*[]; nda param blK t * n d » p t r j n d*.avant t a b l a _t *avant. t a b la ; / * * Raad tha ta a t f l l a and par** aach lln a , * f i l l i n g in th* av*rit_.tabl*, ISI atructur*- * Tha o n ly in form ation th a t i* raquirad from th# * ta a t f l l a ara tha IS la (atimulua d a a c r i p t l o n ) . */ i d a fln a KM TOK1NS 120 ltd*fin* MAX TOKEN LENGTH 3 2 ( /* nd* raad ta a t f l l a • / FILE * t f p / char f u l l p a t h ( 1 0 2 4 ] j int linanum; char in b u f [512]; char commant - ' int in ta r v a l^ d a ta ; char *t-NULL; in t 1, j, k, ntokan*; S t a t i c Char tokan* [MAX_TOKENS ] [MAX TOKEN LENGTH ] ; Int lv a l; doubla fv a l; in t num_*tim, num._raca; /• * Build tha complata ta a t f l l a nama from th* + nama vtorad In th* haadar and tha XNS..TE5T_FILE_PATH * anvironmanta1 v a r ia b l* . */ *trcpy( f u l l p a t h , t * * t _ f l l a . nama )t If ( {t£p-fop*n< f u l l p a t h , "r*H )) l* MULL ) ( / • Rasat v a rla b la * */ i n t a r v a l d a t a - FALSE; num_*tlm » n u a .r tc a • linanum ■ Gj navi w h ila ( i f a o f ( t f p ) ) < /* Raad a lln a */ £gat*< inbuf, 512, tfp ); linanum** > 138 / • sk ip ov*r c o i M n t */ i f < in b u([0] ia coatoaftt ) contlnu*^ / * * Para* tha lln a i * tokans c on tain* p o in ta r s t o mil tokans * ntokahs 1* tha numbar of tokans in tha lin a */ nt cleans * Or t . (char • )NULL> t ■ (char * ) s t r t o k ( inbuf, " " ) r do ( s tr c p y ( tokan s(n tok an s4+ ], t »; t * (char * ) strtok< MULL, - " )i > w hlla < (tJ-NULL) ** (ntok*ns<MAX. TOKENS) ), ntokani - HXN( ntokana, M AX TOXINS /* raad m racord ( r a p a tit io n ) of data */ i f i i n t e r v a l data ) ( / * * Tha f l r a t i s i in aach record la always xero * ainca tha f i r s t event is not preceeded by a * d a fin s d i s i . */ avant t a b l a ->I S I (n u a r a c * * n u a s t i a ) ■ 0; for ( i - l j 1 <■ (t»um_st!■-1) ; i* + ) { avant_t*bla->X SI[nua_rscs*nua_*tiB +l} * a t o i ( t o k a n s ( i - l ] ); /* If a l l tha ISI* war* not a p a c ifla d , * sat tha* aqual t o tha valu a of tha f i r s t noniaro ISI */ i f ( (nua a t l s - 1 ) > ntokahs ) I fo r ( J*2; ^ (n u m a t i a - l ) ; J++ ) ( avant t a b l a - >ISIfnu» rece*nus a t i» + j ] ■ avant t a b l a - > IS I( r ub. raca*nua s t i a + l j ; ) > ) nu* recs + + ; ) /* * do through aach of tha tokans */ for ( 1-0; i«ntok*nsj 1*+ ) ( i f ( s t r a t r ( t o k a n s ( i ] , - s a t - ) I- NULL ) { for { j * l e l ; j<ntokaha* j+* 1 ( i f ( str s tr < t o k a n s ( j | , "pau" ) I- NULL ) { l v a l * a t o l ( to k * n a [j+ l) ) , g o to new; ) ♦ l e a i f ( s t r a t r ( t o k a n s [ j j , *apo" ) I- NULL ) ( for ( k - j f l ; kcntokana; k++ ) K i f ( a t r e t r ( toka n s(k ], "sin" > J- NULL ) ( goto new; ) a l s a i f ( s t r a t r ( tok a n stk ], “t r i" ) l* NULL ) ( g oto nawr ) a ls a ( l.U) fv a l a i t o f ( tok*n*[k] j; goto n*w; > ) ) e l a e 12 ( i t r * t r ( t o k e n e l j j . “ch a H ) I- HULL. ) < i v a l « a t o i ( t o k « n s [j a il ); goto n*wi ) • l a * 12 ( i t r a t r l tok*n a(jJ, "aan" ) l« HULL ) C f v a l ■ *to2( tok*n a[j+l] )? g oto n*wj ) • 1** i f i. ( * t r i t r ( tofc*n*[i|, "d*f" ) i> MULL } 64 ( ( in t* r v a l data ■ TRUK; for i j -i+ 1 ; j<ntok*ns; ) { /* * If n u m .itln l * nda p tr -jn d * nuA channels * than th* t e a t f l l * ha* b**n a lt e r e d * iaau* « warning neaaag*. */ 12 ( a t r * tr ( token* M l, "atlm” ,i i- MULL ) I / * noop */ i • I s * I f ( a tr * tr ( tok*naM 1 , “ain" > t« NULL ( Tt\UL at in - 1} g o to now; > • l a * 12 ( i t t i t r ( token*[JJ. "twl" ) i - null ( num.at i n ■ 2; g o to new; ) • la * I f ( i t r B t r i token* M l. Ht r l" } i - NULL < nun at In * 3 7 g oto new; > • l a * i f ( i t r a t r l t o k e n * M ] . M g u a “ ) I- NULL { nun., at In * 4; g o t o naw; > • l a * I f ( * t r * tr ( to k o n a tj], -gul" > i- NULL ( nun a t i n - 5; g o to n*w; ) • l a * /* aaaune an lnt*g«r */ i nun. at in - a t o l l token* M*l] ); goto n*w; ) J > • l a * 12 (( * t r * tr ( t o k e n * ( l ) r "*ndM ) I* NULL > 64 ( t In te r v a l data ■ fXLSEj goto n«w; ) ) f c l o a * ( t fp ) i I in te r v a l data ) J ) ) > ) ) i n t e r v a l . d a t a )) 140 s i as { f p r l n t f ( a tdsrr, “c tn n o t opsn f i l s I * s ]\n * . fu llp a t h n > /* nds.r««d t a i t f i l « */ void nd* u k * * v * n t _ t i b l « ( n d a p t r , *v*nt tA k U , i s i s e a l s ) n d i _ p » r » i » b l k t *nds_ptr7 n d s .s v s n t . t a b l s . t +sv*nt__tabls j f l o a t i s l _ s c a l s ; Qlvsn an nds p o in ts r , c o n stru ct t h s avant t a b l s for that f i l s . Tha s v s n t t a b l s Is simply a str u c tu r e that c o n t a in s * l i s t of o f f s s t v a lu s s for sach sv sn t In ths f i l s , as w s ll as ths ISI ( If t h s r s i s on* > for that s v s n t . / ( / * nds mak* s v s n t t a b l s */ int i s i val; /* ISI v s l u s from t s b l s . */ long nsamp, nun s«&pl*»; f l o a t lsngth covsrsd; lnt rsdundant, sagmant-O; lnt short count, i, m, k, j; f l o a t in t s r v a l , rnuaij riLB *fp; char l b u f (128 | ; char * t ; /* * Zf th s f i l s la avsragad, ths numbsr of rscorda Is * s s t t o -1. * I i f ( nds._ptr~>nds t o t a l rscord s <■ 0 ) nds ptr->nda t o t a l rscorda * 1; f+ s s t HIT f l a g and a s s o c l a t s d HIT param stsrs • / i f ( nds ptr->nds HIT f l a g ) ( nds ptr->nds t o t a l r sco rd s * 1; ssgmsnt ■ nds p t r - >nds . 1 s t lm (0}; i f [ nds ptr->nds l s t l m [ l ] > 0 ) i s i s e a l s *- 2 . 0 / ( f l o a t )nds p t r *>nds i s t l m [ l ] ; ) /* Figurs out th s numbsr of samplss */ i f (nds._ptr- >nds. d i s p l a y mods ■■ nda contlnuous. nods) num_aamplss - nds_ptr~>nda_»poch s l s s * nds ptr->nd*. sa m p.frsg.chani s l s s num.,samplss - nda_ptr->nds s p o c h _ s i i s * nds j>tr->nds. samp fr s g chan * ndaptr->nda_num _pulsssj nsamp - num_samplss; i f ( ( nds._ptr->hds_ sampls_mods n d s t r i g g s r spoch.mods ) tfc t inds ptr->nds_HIT..flag ) ) nsamp - num. samplas/nds ptr->nds_num_pulsssr / * * Qat i s i * for ALL s v s n t s . * Thsrs a r s th r s s sourcsa fo r th s IS I si * l . u a a r -d s fin s d t r a i n s ars s to r s d in th s f i l s hsadsr * 2. HIT* ars sto rsd In a f i x s d format f i l s * 3. Tsst f i l s runs r s q u ir s that th s t s s t f i l s * bs r s a d - in and parasd. Ths t s s t f i l s nama la * sto r s d in t h s f i l s hsadsr. * Ths t a l a for a l l s v s n t s a r s put In to ths sv sn t t a b l s . 162 a tr u c tu r s . * * >> Ths f i r s t i £ l for sach rscord la u n d sfla sd and l a ast to i s r o . << * V I f {{ n d » _ p tr ~ > n d s _ t s s t _ f i l s _ f l a g ) 46 ( n d s p t r - > n d s . t s a t _ f i l s l s n g t h > o n 141 ( nd* r*ad_ta*t f i l * ( nd* p t r > n d * t * s t _ f l l a m a t , nd* prr, c v t n t t i b i t ); ) • l a * i f ( nd* p t r - >nd* RIT. f l * g > ( I f ( (fp«fop*n{ “RIT. intarv* 1 » < a i c 1 1 \ d h , “ r + " >> i « HULL ) { avant t* b l* -> lS I (OJ - 0; 1 • If do < t - (char * )NULL; Cg*t*( lbuf, s l s a o f (l b u f ), fp ); t - (char * )*trtok< lb u f, " * ); tor ( j *1; j<*ag»*ht; j + + ) t • (char * )*trtok< NULL * H “ ); 1*1 v a l * a t o l ( t ); avant t a b l a - > i s i [1j « 1*1 v al; 1 + +j ) whila ( 1*1 va 1 ) f c l o a a ( f p )} > a l i a ( fo r ( 1 *0 ; j<nd* ptr->nd» t o t a l racorda; j+4 >j ( avant t a b l a - >t s i ( } *nda ptr->nd* nu* pul*#*) * 0 ? for ( i - l j 1 < - < fid* pt r >nd*_nu»_pul*a*- 1 ) ; i*+ >; t a v a n t_t a b l a - > i s i 1J*nd» _ptr- >nd» n u * p u l * a * + i ) »nd* ptr->nd* l * t l n ( 1 - 1]; > > > /* Maks tha avant ta b la */ fo r ( a*0; &<nd* ptr->nd* t o t a l racords; a+4 ) I j ■ a*nds pt r - >nd* . niu* pul***; short count ■ 0; radundant - 0; ln ta r v a l ■ 0; for ( 1 - 0 ? l<nd* ptr->nd» tiua pul***; 1 + 4 ) i i f i i -» 0) a v a n t _t a b l a - > a v a n t (1+j ] ■ num.saaplas * k; a ls a ( rnutt ■ (*hort count + l-radundant ) *n*aap/nd*_ ptr-'>nda_aanp Craq chan; langth covarad • M U ( nd*_ptr->nd*_apoch_sl*ai r n u i >j I f ( * h o r t c o u n t < 1 ) l n ta r v a l - l * i _*c*l* * * v a n t _ t a b l a - > I S I (j + i ]; a l s a i f (abort count »■ i> ( l n ta r v a l 1*1 acala * a v a n t t a b l a ->i s i ( j ♦i j ; i f ( ( ln t a r v a l * nd* ptr->nd* apoch *iz*} < - langth covarad ) radundant 4+; ) I f ( ln ta r v a l > l a n g th c o v a r a d ) { If (sh o rt.co u n t - - 0) a v a n t_ t a b la -> * v * n t [1+1] • ava n t_ ta b la * > * v * n t( 1 - i f j | 4 naaap; a ls a ( * v * n t_ ta b la -> a v a n t(14j ) - avant t a b l a - > * v a n t [ i - l - s h o r t . c o u n t 4 jj 4 n sa a p *(*h ort_c oun t4i-r adu n d an t); short_count * radundant ■ 0; ) ) a l s a If ( l n t a r v a l <- l a n g th c o v a r a d > 142 { a v a n t . ta b la -> a v a n t f i + j ] * •v»f»t t * b U - >avant [ 1 - l-a b o r t count+ j ] + (lntarval*nda p tr -> n d a . aaap frag chan}; ahort counc++; > > ) / • t o nua pulaaa */ ) /* ovar A ll racord* •/ /* Sat tha t o t a l nuabar of avanta fo r tha f i l a */ avant tabla->nuB_avanta • ndi. ptr-> n « J * _ to C * lr* co rd i * nda_.pt r - >nda nua pulaaa; /* DBBUGCJINQ LIMBS . . . for ( 1-Q; i< tv « n t ta b l« -> n u a avanta; 14-4- ) p r in tf r -\1 i s i |1] , avant ta b la - >avant (1 ] ); •/ > /* nda baka avant ta b la V - - - « - - - * / unalgnad long nda gat avant ptr< nda p t r r record, avant ) nda paran bIk t *nda ptr; unalgnad long racord; unalgnad long avant; / * * divan an nda p oln tar, tha currant racord, and tha * currant avant, raturn tha avant p o ln ta r . */ ( /* nd a .g a t avant p tr */ raturn( (racord*nda ptr->nda n u * .p u la a a ) +avant )j } /* nda gat avant ptr */ f l o a t nda ga t v a lu a t fp. nda p tr , o f f a a t ) PILB * fp; nda paraa b ik t *nda ptr; long o ffa a t ; / * * OIvan a atraa* p o ln ta r, an o f f a a t valua, and an nda ptr * p o ln ta r, raturn an a c t u a l volta g a V { /* nda_gat_valua */ raturn( n d a v c a l * a g a t ( fp, offaat+NDS_DATA_OFPSBT ) ); > /* nda g a t v a l u a */ ........ long nda gat l s l [ avant ta b la , avant ) nda_avant t a b l a t *avant t a b la ; unalgnad long avant; i * * aIvan an nda p o ln ta r and tha avant ta b la , * raturn tha ISI for that avant */ { /* nda ..gat _ISI V r a t u r n ( avan t_tab la-> I6X [avan t] >; > /* nda..gat _ISI */ --- 143 long nda gat avsntt nd#_ptr, avant ta b la , avant, channal ) n d i . p a r m . blk_ t *nds_ptrj n d i . a v a n t t a b l * t * avan t_tab la; unalgnad long avant; unalgnad long channal; * divan an nda p o ln ta r and tha avant ta b la , * raturn tha o f f a a t p o a itlo n fo r that avant V ( /* nds. gat avant */ r a t u r n < avant _ta b la -> a v a n t (avant J ( c h a n n a l-1) ); > /* nda gat avant •/ *. . ... . Long nda naxt a van ti nda p tr , avant ta b la , avant ) nds param blk t *nda ptr; nds avant ta b la t *avant t a b la ; unsignad long avant; /* RETURNED */ i * * divan an nda p o ln ta r, tha currant avant nuabar, * and tha avant ta b la for th a t f i l a , * raturn tha o f f s a t to tha naxt avant; V < /* nds naxt avant */ a v a n t♦♦; r a t u r n{ avant ta b la -> a v a n t(a v a n tI ); 3 /* nds naxt avant */ ........ long nda p rio r a v a n t < nds p tr , avant ta b la , avant ) n d s.p a r a * .b lk t *nda.ptr; n d s.a v a n t t a b l a . t *avant t a b la ; unalgnad long avant; / • RETURNED */ / • * alvan an nda p o ln ta r , tha currant avant nuBbar, * and tha avant ta b la for that f l l a , * raturn tha o f f s a t to tha p rior avant; */ { /* nds_prlor_.avant */ a v a n t- -; r a t u r n ( avant . t a b l a - > a van t(avan t] ); ) /* nds p r io r avant */ long nds_naxt v a l u a ( nds p tr , o f f s a t ) nd*_par*m b lk t *nds.ptr; long o f fa a t ; * Qivan a straam p o ln ta r and tha currant o f f a a t p o s i t i o n , * raturn tha o f f a a t t o tha naxt data valua; */ ( /* nds_naxt valu a */ raturn ( of f s a t + ( s l s a o f (s h o r t ) *nds_ptr->nd*_nuB_channal*) ) /* nda.naxt valua */ / • . - ■ - - - - ■ ' - a . - * - . - . - . - . - . - . - . - . - . - . - . - . - . - . . . . - . - . * / FIL* * nda op#n f i l a l path > char p a t h []; / • * olvan a path nama, raturn a atraaa * p oln tar to tha f l l a . */ ( / * nda opan f l l a */ r e t u r n ( fop*n( path. "r+w > ); } /* nd* opan f l l a */ void nda c lo a a f i l a { fp J FILS *fp; t* HITUHH1D */ / * " olvan a atraam po ln ta r, clo a a * tha f l l a and raturn tha NULL polntar; */ ( /* nd* c lo a a fiLa */ f c l o a a ( fp ); fp - NULL; ) /* nda cloaa. f l l a */ / * « - . - */ FILS * I n i t i a l l i a F l l a { pathname, nd* ptr, avant ta b la , i a l acala char pathnamaU; nd* param b lk t *nda ptr; nda avant ta b la t *avant t a b le j flo a t i a i scala; I * * I n i t i a l l i a F l l a (} 1* a convanlanca function * th a t opan* an NDS f l l a , gat* tha haadar Info, * make* tha avant ta b la , and raturn* a atream * p o ln ta r t o tha f lla * * A NULL p o ln ta r la raturnad I f tha f l l a cannot ba * opened. ( f* I n l t l a l i s a P i l a */ FILS * fp»NULLj /* atraaa p o ln ta r •/ /* opan tha f l l a * f I f ( (fpsnda o p a n .f i l a t pathname )) ■■ n u l l ) r e t u r n ( (FILI * /* oa t tha f l l a paranatara */ nd*.flat haadar( fp, nd* p tr ); / • oat *11 avanta */ hd* H k a av«nt ta b la ( nd* p tr . avant ta b la , i a l aca la ); /* Raturn atraaa p o ln ta r */ return! fp ); ) /* I n i t i a l l i a F l l a */ ) NULL >; /* and of f l l a */ D.2 System Simulation D.2.1 sim.c * II ■ ia u la csd data aac to t a a t karnala _dpoa . c . • by B i l l Scaring*, 7 /9 5 . Mluclud* < itd lo .h > *1 nclud* < «trlng.h> Ifinclud# - * t d l i b .h > Ninclud* <n«th.h> k lncluda "nd* dafs.h" ttdaflna MAX SEGMENTS 20 ttdaf ina MAX WIDTH 3 fdaCin* SHORT MIN -32760 /* Min of Sdafln* SHORT MAX 32767 V* Ha* of /* Global V arlabla* "/ lnt dabugvO, qulck»0/ m*ln( ttrgcj argv > lnt argc; char *a rg v []? { /• Main */ short in ta g a r . */ ahort in ta g a r . */ f* Command iln a opt Iona. /* Global V arlabla* */ axtarn ln t dabug, guick; /* ch a ra cter Varlablaa */ /« command ll n a op tio n * . char *num *ufflx(] - ( " , 0 1*, -. io", H. i r , " . i 2 H " . 02* r * * . 0 3 “ , " . 04 “ , * . 05" . ", 06" i M . 07 " , ".08", “ .09", r H.13",**,14"#,,. l 5 ,,, ,,.16*t , t*.17,,, H.l f t" ,“ . 1 9 " , M .20"), char outpath £256 ]; /* output f l l a pathnam*. •/ char p a t h r o o t [256] \ /* Output f l l a pathnam* r o o t. * / char l i n * ( 1 2 S ] , /* For u*ar input. */ char nul_char • 0 ; char u s a r p a th [256 3/ /* Optional u*ar output f l l a pathnam* root. */ / • Raglatar Varlablaa */ r a g la ta r unalgnad long j; r a g la ta r lnt i , 12; /* Numar f l o a t ln t ln t f l o a t f l o a t f loat unalgnad f l o a t lnt long f l o a t f l o a t f l o a t f l o a t f l o a t f l o a t f l o a t f l o a t f l o a t f l o a t lnt float ahort ahort 0 ; ic V arlablaa */ amp_gain- 1 000 c l i p . c n t _ h l J e lip _ c n t_ l o ; d ti; dti; apoch i s ; • p o c h p t * ; f a c t o r , f a c t o r s ; f I r i t M g , laat haadar _*ixa; l* l_ * c * l* ; ISZ[NDS_KAX_ EVENTS) t long lsl_*um _tot; k l amp; kl .duration; ka^ampi k2 .alpha; k3offaatj k2 _max_d*lta, pulaa rata; nolaa._opt; naa_atd; /* F raam pllfiar gain . i* Count* pta c llp p a d at h i la v a l by AtoO. / • count* pt* c lip p a d at lo l a v a l by AtoD. /* Zntarpulaa ln ta r v a l 1. I* tntarpulaa ln ta r v a l 2. /* Epoch langth in m lll i « * c o n d * . /* Numbar o f aampla po ln ta uaad par apoch. /* M u ltip lyin g fa c to r * , sag; /* Uaar input; f l r a t / l a a t *agm*nt numba /* Bytas in haadar inform ation. /* Seal* fa c to r fo r ISZ*. /* ISI* for a l l avanta of a l l aagmant*. /* Sum of a l l ISIa in m ill l a a c o n d * . /* kl paramatar ( v o l t * ) . /* k l paramatar ( m i l i l s a c o n d * ) . /* k2 paramatar ( v o l t * ) . /* k2 paramatar (l/m***3). /* k2 paramatar ( v o l t * ) . /* k2 paramatar ( m illla a c o n d * ). /* Maan atlmulu* rata (pul*a* par * a c). / • Noiaa o p tio n . /* Mhlta nol*a standard d a v la tio n . num..pul*** (MAX_SB0MSMT£J j /* T otal numbar of apoch* par sags num pulaa*_m*x; /* Max Ipulsa* In any sagmant. i n t .* / */ 146 147 /• auojjdo •u ft p u im o o /* Function D eclaration*. */ extern lnt <3etXSIft()j /* In get_ leia .c - get ISI# from ta ble . •/ extern void Fill Headert); /* In ale u til.c - aet u p a dueey header. */ extern long W rite,H eader{)} /* In ale u tll.c - write a nda header. */ extern void nda a*he event ta b le t); /* In nacope u tll.c -get epoch p o i n t e r * . * / 3 2 o, ft • a a * 5 5 SSI * B J. ft !T « & £" *- - e < * n , « s 3 • * ft • 3 a < * • a ft s, • it ^ ** r» a rt in * a - = ■ u o 3 r? • p- rr i- i- *- 0 0 0 o 0 in t * > a r * r t i P- E T 0 ► * • I- • 2 O ' j t) W - • *1 a * o f t * I Q i- t f < * a B 3 * * - - • ■ I : e a ■ • ! i ? 3 3 ft r * a a tr rr 0 o *t n if ft V ft ft o * 1 *J ~ ■ z * r * * ■ * _ m » n I C A M 0 * M a W „ c * * 1 » ” » » rt rr a cr a r* ft H > h- f t # 3 a c a a a ► - a tJ ft rt 0 * 1 V § • ! P o « * ^ S J ft o o * H ► - 3 P ft rr ■ ft 0 * 0 A - k 9 0 i * 1 0 3 if a § S’ a 0 2 9 0 o , ? 0 H S 1 It ft 0 h a 3 0 * - * s 11 a - 9 rt f t o £>; . ft £ a m c h fc a a C ► *p %► “ If t* 3 3 k- 3 M 3 3 3 3 t- a K - h- a 0 0 a 0 0 0 o a rt 0 rr 0 0 0 ► 1 ft H- ft ft •1 f »• ft ft ft ft o ft f t c if ft ft ft o if ft ft If 3 ft ft 3 ft ft « f t J r t f t a ^ a j j W v 0 0 « s L f • B^ 1 i « £ ■ i • • S I ^ • 5 • > a ^ * * * n « ■ y o f • o ' • * n « * ft * ■ " s ^ s s : l i M S 1 * * 7^4 - o S S « " . ( O O I ^ s i ^ • < 3 E I ■ # ? 5 | t* K ft ft ft J • • s o o o £ ft 3 9 • £ 3 | * a ■ ■ ■ • * ft ft £ H - • ► * S ► - o It if ^ S’ H 0 * • t i M -a ► t 0 w a o. M * * > E. o o w i £ t+ o • ** M 9 £w ft - ■ O f t O a ► * • ’ 0 2 o J 3 • & ’ s s f * ft ft 4 9 5 ? ■ ft a 0 ft ft N f * 1 - ft ft (t a ft ft a • * * < < 3 ft * • -7 ? “ “ - ffs * 1 ? ■ ■ p i S 0 & rt a ■ = r-* J 3 n ; | n c ‘ - 5 <0 z H - 0 ft It h- t* a oo# P 3 c . I 3 n - § 2 p - £ s ? ^ouanberj uvfpw •/ J« « vbeao i?ou a^Tjevfiea TT» ‘a^oode jo jwptiu T»7ioi */ r 30)~a»e7nd~iBnu btio-f peudjaun (void) p r i n t f { "\nftnt*r th* output filename root t " ); (void) g * t*( p athroot ); /* o*t th* s t a r t i n g and •tiding segments •/ do [ (void) p r i n t f f " \n F lr s t Segment <1 VI): ", MAX_sCQMENTS }; (void) g e t s ( li n * )j (void) «acanf ( l i n * , "Vi". fcfirst s*g ); ) w hil* ( ( f i r s t . s a g < 1) II { f i r s t „s*g > M ax_segments) )/ do ( (void) p r l n t f t "VnLast Segment (\d * VI) : ", f i r s t sag. M AX .SEGMENTS ); (void) g*t*( l i n * )t (void) s s c * n f ( l i n * , “Vi", fcl*st_s*g >; ) w h il* ( (la * t_ e * g < f lr st_ s* g > II ( la * t_ s * g > MAX.segments) >1 i* a*t th* intersegm ent peus*. • / (void) p r l n t f f "\nEnter th* Intersegment pause (sacon d a): “ ); (void) g * t* ( l i n * ); (void) s n c a n f ( l i n e , "‘Vf", fctpaus* J; tpaua* * tpaue* * 1000.0; /* convert to m i l l i s e c o n d s . */ /* a*t th* w a n stim ulus r a ta . */ d o { (void) p r i n t f ( "\nCnt*r th* mean stim ulus p u ls* r a t * H ); (void) p r i n t f ( "\nin p u ls e s /s e c o n d i H }; (void) g * t « { 1 in* ); (void) s*c anf( l in * , “%f", fcpuls* rare ); I f ( [puls* rat* i« 1.0) At (puls* rat* j» 2,0) a (void) p r l a t f f “\n l , 2, 5. or 10 p u l* « s/s* c o nd . \ n H>; (void) p r ln t£ ( HVnYou en tered : %f p u ls « s /* * c o n d . ", p u ls* r a t* ); (void) p r l n t f ( -\nus* t h i s puls* rat*r (y or n) » ); (void) g * t s ( li n * ); ) ) w hil* ( s t r c h r f l i n a , n ’ > ); /* <J*t th* i s i s e a l* f a c t o r . */ (void) p r l n t f f "\nEnter s e a l * fa c to r for ISI*: “ ); (void) g « t s ( lin * }j (void) a a c a n f ( li n * , "tf". f c i a l .s c a l * )/ /* Oet th* epoch len g th, •/ (void) p r i n t f i " \n tn te r th* *poch len gth ( m il l i s e c o n d s ) ! " ); (void) g * t s ( l i n * Jt (void) ss c a n f( l i n * , "\f", fc*poch,m* )j /* Oat th* sample p erio d . •/ (void) p r i n t f ( ‘ \nEnter th* sampl* p*riod ( m i l l i s e c o n d s ) ; M ); (void) g * t s ( li n * ); (void) s s c a n f( l i n * , " \ f “ , 6s*mp_p*r ); /* Compute th* *poch p o i n ts . Not*! Th* f i r s t data sampl* of each epoch occurs at tim* ■ tim* of stim ulus puls* * samp .p ar. */ epoch pt* » (ln t ) ( *poch ms / samp p*r + 0,5 ); /* o*t th* kernel parameters. V (void) p r l n t f t “\nXnter XI amplltud* ( m i l l i v o l t s ) i H ij (void) g * t s ( 11ns ); (void) s s c a n ft l i n e , * \ t a, fcki.amp ); k l a m p / « 1000.0; / • convert to v o l t s */ do ( (void) p r i n t f ( "\nBnter kl du ration <* \ . 2 t ( m i l l i s e c o n d s ) i ", epoch ms m (void) g * t s ( l i n * ); (void) #scanf{ l i n * , * S f , fckl.duration ) t ) w h il* ( k l.d u r a tio n > «poch_ms )t !4X (void) p r l n t f ( ”\n l n t * r k2 amplltud* ( n l l l i v o l t s > 3 - }; (void) g * t*( li n * ); (void) s s c a n f ( l in * , "%f", 4k2.amp ); k2 amp /m 10 0 0 , 0 ; /* convert to v o l t s */ (void) p r l n t f { "\nEnt*r k2 o f f s * t ( m i l l i v o l t s ) i “ ); (void) g * ta( li n * ); (void) **c*nf{ l i n * , u\ t mr 4k2 o f fs w t ); k 2 _ o ff» * t /» 1000.0; /* convert to v o l t s */ (void) p r l n t f ( * \n ln t* r k2 maz d * lt* (m illis a c o n d s ) i " ); (void) g * t* ( l i n * )i (void) s s c a n f ( li n * , “\ f “, 4k2 u z _ d « l t a )? (void) p r l n t f ( "\nliit«r k2 alpha valu* (sugg*st*ds \ t (i/m a * * 2 ])t ", 2 0 . 0 / (kl d u r a tio n * (k l duratlon+k2 maz d * l t a ) ) i; {void) g*ts< l i n * ); (void) s s c a n f ( l in * , " \ t m, 4k2 alpha ); /* G*t th* n o li* option- */ do ( (void) p r l n t f ( ■ ■ \nchoos* * Noise OPTION (1-4)" ); (void) p r l n t f ( "Mil for no n o ls* ." ); (void) p r l n t f ( "\ n 2 for whit* no!**," }? (void) p r l n t f ( u\n3 for o s c i l l a t o r y n o ls* s i g n a l (*Ln« w a v * ) .1 1 ); (void) p r l n t f ( M \n4 for o i c l l U t o r y n o ls* s ig n a l plu s whit* n o ls * ." ); (void) p r l n t f ( N\n( *nt*r any n *gatlv* valu* to quit p r o g r a a )\n H )/ (void) g*t*( l i n * ); (void) sscanf ( li n * , H Sd", 4nol**__opt >; i f ( noi«* opt < . 0 ) goto claanup; ) whil* ( (no ls* opt < 1) H ( n o i s s o p t > 4 ) ); i f ( (no ls* .opt 2) It (no ls* opt • - 4) ) /* 0*t whit* nols* std d*v. ( (void) p r l n t f { "\nEnt*r th* whit* noi** standard d a v la tio n ( m i l l i v o l t s ) ; (void) g«t*( li n * ); (void) s s c a n f { l in * , " \ t H, 4ns* std }; na« s td - m s std / 1000.0; /* Convsrt t o V o lt s . */ > i f ( (nols* opt 1) II {nols* opt »■ 4) ) ( (void) p r l n t f ( "VnEntsr th* o s c i l l a t i o n n o ls* amplltud* ( m i l l i v o l t s ) : " (void) g * t*( l i n * ); (void) s s c a n f i l i n * , “^ f H, 4osc sap ); o i c amp - o sc amp / looo.Q; / * c o n v sr t to v o l t * . */ (void) p r l n t f ( "\nBnt*r th* o s c i l l a t i o n n o ls* fr«qu*ncyt <Ki ) i H )j (void) g a t s ( l i n * }; (void) s s c a n f i l i n * , m\ t " , 4osc fr*q ); om*ga _ms ■ 2 . 0 * pi * o * e _ f r * q / l o o o . o ; ) /* o*t th* a m p lifi* r g a in . */ do ( (void) p r l n t f < "\nEnt*r A m p lifier o « i m H >/ (void) g * ts( li n * ); (void) s s c a n f i li n * , *^f", lamp gain ); (void) p r l n t f ( "VnA-to-D rang* w i l l b* V i f to ^ . 3 f m i l l i v o l t * vn", - 5 , 0 *1 0 0 0 . o/amp gain , 5 . o * 1 0 0 0 . o/amp gain ij If ( iquick ) ( (void) p r l n t f ( "\nUs* t h i s gain? (y or n ) j h ); (void) g * t s ( lin * )/ > > w hil* < s t r c h r ( l i n * , ‘n ’) 44 jqulck ); / * • • • • • EMD o r USEE INPUT SECTION i /* a* t th* 1 s i ■ for th* * * l* c t* d itgBMnci */ i f ( d*bug > (void) p r l n t f ( -'v na*t t lug 1 6 1 * ... \ n “ )? i f ( JQ*11SI * ( f i r s t ** g r l n t tag, tpau**, p u l s a r a t * , i a l i c a l t , / • input* */ ISI, fclSI sum t o t , n u i pula**, Anum pul*** t o t ) /* output* */ > r*turn ( 0 ) ; i f ( d*bug ) (void) p r l n t f { -Got i s i * . \n* )i /* put * dummy ISI at th* *nd of th« la * t aagmant, *o th a t th* alg o rithm */ /* b*low w i l l not think th«r* 1* an ov*rlapplng pul**. m t i s i [nua pulaaa t o t - 11 - apoch a* + LOQ.Q; / * * * * •• STAFT OF SXMUUTID DATA OUTPUT FILE SECTION ••****/ I f ( i ) ( /* D*t*rmln* th* maximum numbar of pul*** in any «*gm*nt~ */ nun pulaaa max * 0; fo r ( a«gm *nt*flrst sag; **gm*nt<-last sag? s*gm*nt++) i f ( nun pul**a[ **gm*nt - f i r s t . * * g ) > num. pul*** max ) nun pula** max - num pula**( **gm*nt f l r * t sag ]; /* A llo c a t* f l o a t i n g point mamory for on* **gm*nt of data. */ aagmant top ■ ( f l o a t * ) c a l l o c ( (unalgnad lnt) ( num pul*** max * apoch p t s ) , * l * * o f (f l o a t ) ) j i f ( i**gmant top ) /* V arlfy aucc***ful a l l o c a t i o n . */ ( (void) p r i n t ! ( "\nCOULD NOT ALLOCATE MEMORY FOR ONE SEGMENT OP FLOATING POINT DATAJ \ n “ ); goto claanup; ) /* A llo c a t * short lnt mamory for on* a«gm*nt of data. */ aagmant ahort top - (ahort * ) c a l l o o ( (unalgnad ln t) ( num pul*** max * a p o c h . p t * j r a l x * o f {a h o r t) >; If ( i**gm*nt short top ) /* v a r l f y aucoaasful a l l o c a t i o n . */ { (void) p r i n t f ( "SnCOULD NOT ALLOCATE MEMORY FOR OffE SEGMENT OF SHORT INT DATA I \ n N ) ; g o to cl*anupr ) /* s*t up moat o f th* h*ad«r inform ation for a l l **gmanta. */ F i l l H*ad*r(amp g a i n r apoch_m*t p u l s a r a t * , samp p*r, tpau**, n d s .p tr , 1 ); /* s*t up for loop ov*r a*gm*nt*. */ f a c to r ■ * m p g * in /n d * _ v c a l; /* Conv«r*lon fa c to r for Nauroacop*. */ factor ? ■ k.2 alpha*pl; / • s a t up th* noia* standard d a v l a tl o n . */ i f f (n o ia * .o p t - - 2) II (noia* opt ■ ■ 4) } ( i f ( (n«* std * fa c to r ) > ( f l o a t ) SHORT MAX ) ( (void) p r i n t f ( “\nERRORt Noia* larg*r than A - t o D dynamic rang*." )> (void) p r l n t f ( H\nR«duc* nol** or d*cr*aa* g a ln .\n " }; goto clasnup/ ) std .ahort • (short) ( (n**_atd * factor ) -* • 0.5 )/ atdj ahort - s t d . s h o r t * 2; > /* Loop ov*r *«gmanta. •/ I S I .p tr * ISI/ is n num.pul*#* t o t - 1; 181 « w _ t o t > 0.0; fo r ( a a g m a n t - f i r a t a a g ; aagmant<-laat_aag> aagmant**) /* Complata tha haadar i n f o for th la aagmant. */ nda_ptr->nda.iatlm(QJ ■ (ahort) aagmant; nda_ptr->nds _nujn pulaaa - num.pulaaal aagmant - f i r s t . a a g J; n d a _ p t r - > n d a _ f i l a a l a a a (long) < NDflDATAorrsiT ♦ nda_ptr->ndanum_pulaaa * a p o c h p t a * s i t a o f f ahort ) )/ /* Kaka avant ta b la for th la sag. Tha avant ta b la contalna a p oln tar to tha l o c a t io n whara aach data apoch ahould ba addad In. */ nd*_maka avant cabla( nda p tr , a v a n t.t a b la , i a l i c a l a ); /- computa tha t o t a l numbar of data po ln ta In th la aagmant. +/ aagmant pta - avant tabla->avantInda ptr->nda num p u la a a -i] + apoch pta; /* I n l t i a l i s a tha aagmant data valuaa to saro, * > ' aagmant ptr - aagmant top; for (1*0; j < aagmant pta; j++. aagmant ptr**) *aagmant ptr - 0.0; /* Loop ovar pulaaa t o maka raaponaa data for aach. */ for { p ulaa..cnt- 1 j pulaa cnt <- nd*.ptr->nds num pulaaa; pulaa. c n t + ♦, num pulaaa t o t *♦, ISI ptr+* ) { /* Datarmina tha numbar of polnta to computa. •/ l f { pulaa cnt - - nd»„ptr~>nda num pulaaa ) /* i f la a t pulaa */ < w r ltta n pta * apoch_pta; ) a la a /* w rlta p a r t i a l or whola apoch */ ( w r ltta n p ta ■ avant_ ta b la -> a v a n t(p u la a cnt] - avant tabla -> a v a n t(p u la a c n t - l ] ; i f ( w r lt ta n pta > apoch .pta ) w rlttan pta » apoch pta; ) /* computa tha raaponaa apoch valuaa. */ i f { pulaa cnt > 1 > 1ST sum t o t *- *(ISI p t r -1 )/ t ma ■ ISI aum.tot; aagmant. ptr - aagmant top * avant t a b l a - >avant(pulaa c n t - l ] / fo r ( ! - l ; j <« writtan_.pt*; !*♦, aagm ant.ptr*♦) { /* Add In tha f l r a t ordar c o n t r ib u t io n . +/ d t l ■ (f l o a t ) ! * aamp_par; i f ( d t l <• kl_.durati.on } +«agmant_ptr ■ kl_amp * ( 1 . 0 - d t w k l d u ra tio n ); alaa *aagmant ptr ■ 0 . 0 ; for ( ! • ! ;! < num_pulaaa_tot; 1*- + ) { d t l ♦ - *(isi p t r * i > / l f ( d t l > kl..duration ) braak; /* stop i f out of karnal ranga. */ * aagmant p tr *- kl amp * ( 1 . 0 - dt 1 /k i durat ion j ? } /* Add in tha aacond ordar c o n tr ib u tio n . */ d t l - [f l o a t ) j * *amp_par; for ( 1 2 - 1 ; 12 < num_pulaaa.t o t ; 12**) ( 151 i f { d t l > k l_duratlon ) b r u k ; d t l - 0 .0 , lo r ( i - 12; 1 < num_pula#a t o t; 14 + ) ( d t 2 ** •(161 p t r - 1 ) , 1 dta > ka.max.dait* ) brask; / • stop of out of karnal rsnga. */ ‘ ■ •g w n t p tr ♦- 2 . 0 * (1 .0 - (dt 1 +<3tl+dt2) / ( It 1 d u r stio n 4 k 1. durationsk2 u x . d a lta ) ) * (k2 .o ffa a t 4 k2_smp*aln(dt 1* <dtl+dt3) *factor?) | ; ) l f ( d t 2 > k l . u i d a lta ) braak; d t l 4- * ( ISI p t r -12 >; ) /* Add in tha o s c i l l a t o r y h o l e * . */ l f ( ( n o i t * o p t -- 3 ) || ( n o l s a o p t -■ 4) > < t a* 4« u a p p«C| ■ssgmant ptr 4» o*c «mp * ain[ oiwgi ms ■ t a* ); ) ) / • and fo r ( J*l; J ■■ w r ltta n pta; }44, aagmant ptr++) •/ } /* fcnd of loop ovar pulaaa to maka raaponaa data for aach. */ /* Do A n a lo g -t o - D i g i t a l Convarilon fo r t h l a aagmant. */ c l i p cn t_hi ■ 0; c l i p cnt lo ■ 0; aagmant p tr - *agmant_top; aagmant ah ort_ptr - aagmant ahort top; for 0 - 0 ; j •: aagmant pta; j+ + , aagmant ptr + + ( aagmant .ahort ptr+ + ) ( *aagmant ptr * * factor ; ■aagmant p tr 4- 0 .5; If ( *aagmant ptr > {f l o a t ) short.MAX ) < ■aagmant short ptr ■ SHORT.MAX; c l i p cnt h144 ; } a la a i f ( *aagmant ptr * (flost)SHORT MIN ) f *sagmsnt_ahort_ptr * SHORT MIN; c l i p _ c n t . I 0 4 4; } alaa ‘ aagmant .short..ptr • (ahort) ( *sagmsht_ptr 4 0.5 ); ) /* and for loop for A-to-D convaraion */ /* Add whita nolaa to t h i s aagmant. +/ l f ( (noia* opt ■■ 2) H (nolaa..opt • • 4) ) ( c l i p cn t_hi - 0; c l i p . c n t _ lo ■ 0; aagmant_ahort .ptr * aagmant short..top; /* Loop ovar aagmant po ln ta for whita nolaa tarm. */ for (J-Q; j < a a g m a n tp ta ; j44, aagmant a h o r t_ p tr 4 4 ) ( whlta_nsa * (rand() \ std2_ahort) - s t d a h o r t ; 152 i f ( ( ( f l o a t ) ‘ sagmant short .ptr + (f l o a t ) w h i t * . na* } > (float)SHORT_MAX > { *a«9Mtit ih o r t p tr * sHORT.NAXj c l i p cnt hi**} > • i s * If ( ( (f l o a t ) ‘ sagmant short ptr * ■ ( flo a t )w h i t * na« ) < ( f l o a t )SHORT„ktIN > t ‘ s a g m a n t.sh o r t.p tr ■ SHOAT_MtN; c l i p _ c n t lo++; ) *s*gmant_short_ptr +* v h it« n » i ) > /* If c l i p p i n g occurad, print a warning. < If ( c l i p cnt hi II c l i p cnt lo ) < (void) p r l n t f ( ”\nWARNJNa: A-to-D c lip p in g occurad in sagmant %d. sagmant )j (void) p r l n t f < - \n Dacraaaa gain t o f l r . \ n " ); I If ( c l i p cut hi ) (void) p r l n t f ( H %A p o in ts clip p ad to ^ .3 f m i l l i v o l t s . \n ", c l i p c n t . h i , 5 . 0 • 1 0 0 0 . D/amp gain ); i f ( c l i p . .cnt lo ) (void) p r l n t f ! ■ %& p o in ts c lip p a d t o i f m i l l i v o l t s . \n ” , c l i p cnt lo, - 5 .0 * 1 0 0 0 .O/amp gain ); /* opan th* output f i l * for t h i s aagmant. */ (void) s tr c p y f (char *)outpath, (char M pathroot ); (void) s t r c a t ( (char outpath, “.r it " ); (void) s t r c a t ( (char *}outpath, n u a a u ffix Iaagmant- 1 ) ); i f ( (fp«fop*n( outpath, H w" )) mm NULL ) ( (void) p r l n t f ( "CAN'T OPEN OUTPUT SEQUENT FILE r [^s]\n". outpath ); goto claanup; > /* Writ* tha haadar information- •/ l f ( 1 (haadar s i t * - w rit* .H a a d a r( fp, nds p tr ) ) > ( (void) p r i n t f ( "\nERAOR w r itin g haadar for aagmant . \n", aagmant ) f - goto claanup; 1 /* V arify haadar s i i * . */ i f < h * * d * r _ sll* > WDS_DATA_OFFSET > ( (void) p r l n t f ( “\nERRORr sagmant Sd haadar ^ld bytas largar than NDS_DATA OFFSET. \ n M , sagmant, haadar a ls a - NDS DATA OFFSET >; goto claanup; ) a la a i f ( haadar.aixa < nds DATA OFFSET ) [ i f { dabug ) (void) p r l n t f ( "\nSagmant %d haadar paddad by *W ld b y ta s of n u l l c h a r a c t a r s , \ n “, sagmant, NDS_DATA_OFFSET - h a a d a r .s l i * >/ for ( l«haadar_slaa; 1 < NDS_DATA_orrsET; i++) fw rit* (4 n u l_ ch a r, 1, 1, fp )/ } /* Writ* a l l th* sagmant data to th* output f l l a . */ i f ( f*a*k{ fp, NDSDATA_orr8KTr SIIF_flET ) ) 153 ( (void) p rln tf* "\nEXROR) Could not w rit* data fo r sagmant \ d . \n ", i t ^ a i n t ); goto claanup; ) i f ( ( w r ltta n pta ■ fw rlt* ( {void * ) sagmant ahort top, s l i a o f i ■ sagmant pta i ( (void) p r l n t f ( “\tiRRRORi Sid a c t u a l p ta w r ltta n l n s t s a d of H, w rltt#n_pt* )/ (void) p r ln tf* H\n Sid daalrad M , aagmant_pts ); (void) p r ln tf* "\n to aagmant Sd. \n ", aagmant ); g oto claanup; > f c lo s a * fp ) i /* Cloaa tha aagmant f l l a . */ (void) p r ln tf* “\nSagmant Sd w r ltta n t o f l l a * s s ) . \ n M , aagmant, outpath ) ; ) /* End of sagmant loop. */ ) /* and i f ( 1 ) */ } ****** fcND OF SIMULATED DATA OUTPUT FILE SECTION * * •* •* / /****** START OF INFORMATION OUTPUT FILE SECTION ******/ /* Writ* «n In fo f l l a , but praaarva old v sr a lo n a . •/ (void) a trcpyt (char • )o u tp * th , (char *)pathroot ); (void) s t r c a t * (char "joutpsth, " .in fo * ); i f ( fopan* outpath, "r" ) ) ( 1 - 0 , do < 1 + *; (void) strcpy* (char * ) outpath, (char +)pathroot ); (void) str c a t* (char *)outpath, ); (void) a p r ln tft 11ns, K Sd", i ); (void) s t r c a t ( (char *}outpath, li n * ); (void) strca t* {char M outpath, " .in fo * )j ) whil# * fo pa n ( outpath, "r" > ); ) i f * ifp .fo p # n { outpath, *wH )) - - NULL ) ( (void) p r l n t f ( M \nCAN'T OPEN OUTPUT INFO FILE* (SsJ\n*\ outpath ) ; goto claanup; ) (void) f p r l n t f ( f p , "INFORMATION FILE fo r SIK1 data with root [Sa). \ n " .p a th r o o t ); (void) f p r l n t f ( f p , "\nFirat Sagmant: VI *, f i r s t sag ); (void) f p r l n t f ( f p , "\nLast Sagmantt sd ", l a s t s a g )j (void) f p r l n t f ( f p , “\nlntarsagmant Pauaa: \ . 3 f aaconds ", t p a u s a /1 0 0 0 .0 ); (void) f p r l n t f ( f p , "\nA mpllflar Qalm s . i f ", amp_gain )j (void) f p r l n t f ( f p , "\nMaan Stimulus Rata* Sf p u ls a a /* * c o n d H. pulaa rata ); (void) f p r i n t f ( f p , " \n lS l Seal# Factor: S f ", i s i s e a l * }j (void) f p r l n t t ( f p , ■AnEpoch Duration * S . 3 f m l ll la a c o n d s " apoch ms j; (void) f p r l n t f (fp, "\nsampla Farlod * S . 3 f m i ll i s a c o n d s “ samp par ); (void) f p r l n t f (fp, "\hSampls P olnta * Sid \n", apoch._pta >j (void) f p r i n t f d p , "\nFIRST ORDER KERNEL Inform ation! " ); {void) f p r l n t f ( f p , "\n Amplltud*: S . 3 f m i l l i v o l t s " , k l amp*1000,0 ); (void) f p r l n t f ( f p , "\n Duration! S . 3 f m i l l l a a c \ n H, kl duration ); (void) f p r l n t f ( f p , “NnEBCOND order KERNEL Information! " )j (void) f p r l n t f f f p , "\n Amplltud*: S . J f m i l l i v o l t s " , k2_amp+100Q. 0 >; (void) f p r l n t f (fp, "Vn O ffaati S . 3 f m i l l i v o l t s ", k 2 _ o ff s a t* 1 0 0 0 *0 (void) f p r l n t f ( f p , - \n Max D altai s . 3 f m i l l l s a c " , k2_max_dalta ); (void) f p r l n t f ( f p , *\n alphai Sf i / m l l l l a a c + * 2 \n * , k2_alpha ); ) t (void) f p r l n t f ( f p , "NnNOlSE Infor i f * n o i s a o p t ■■ l ) (void) f p r l n t f ( f p , " \n o p tlo m ttlo h t ) ; 1. No n o ls a . \ n M ); 154 • l a * If < n o is e opt mm 2 } ( (v o i d ) (v o i d ) f p r l n t f ( f p r "\nOption: 2 f p r l n t f ( f p , “\n ) e l s e If « n o is e opt >* 3 ) ( (void I (void) (void) > e l s e i f ( ( (void) f p r l n t f ( f p r H\nOptiont 3 f p r l n t f (fp, - \n f p r l n t f ( f p , *\n n o lse_ o p t 4 ) fp r in t f (fp, "Srioptiont 4. < void) f p r l n t f ( f p r w\n (void) f p r l n t f l f p , " \n (void) fp r in tf< fp , M \n White N o ia * . " ) } standard D e v ia tio n ■ 3f mV. \ n H, n n o s c i l l a t o r y N oise ( l i n e wave). “ }; Amplitude - % .it mV. *, otc amp ); Frequency ■ **.Jf Hi. \ n Hr oac freq )j O e c i l l a t o r y Nolae (alne wave) plua White N o ise . * ) > white Nolee Standard D eviation ■ \ , 3 f mV. *, nee etd O s c i l l a t i o n Amplitude ■ 3f ev. H, oec amp | ; o e c i l l a t i o n Frequency - ^ .3 f Hr • \n"( m e freq j; f c l o e e ( fp ) ,* /* Close Information output f i l e . •/ (void) p r l n t f I"\nINFORMATION f i l e w r itte n to [%*]. \n* END OF INFORMATION OUTPUT FILE SECTION outpath >; c l e a n u p : i f ( nda ptr > free ( nde ptr ) > I f ( event t a b le ) f r e e { event t a b le ) t If ( segment top ) fr e e ( segment top ); i f ( segment ahort top ) f r e e ( segment ahort top J ; /* Exit */ r e t u r n; ) /* END OF MAIN */ / • end of f i l e */ I >.2.2 sim utiLc /* * u t l l . c • * u t i l i t i e s fo r aim ula tio n program*i * void F l l 1 . Header() * long Write Header() * * by B i l l Scaring*, 4/94- * */ i i n c l u d * <*tdlo.h> Ninelude < *tring.h> i l n c l u d e < s t d l i b .h » Nlnclude “n d s d e f * . h “ / void F i l l . H e a d e r (amp.g ain,epoch^ m *, p u l e * _ r a t e r aaip p a r , t p a u s e rnds .p tr , numchan) f l o a t amp_0 alnj /* P r e a m p lifie r g a in . */ f l o a t epoch_m*/ /* Epoch length in m i llis e c o n d * . •/ f l o a t pul*e_rat*j /* Mean s tim u lu s rate (pulse* per s e c ) . ■/ f l o a t *amp_per/ /* Sample period in m i ll i s e c o n d s . •/ f l o a t tpauae; /* Intar-segm ent pause in m i llis e c o n d * . •/ * t d ) i ) ; / 155 ■ h o r t n u a c h a n ; /* N uabar o f c h a n n e l * . * / nd*.paras blk t *nd* ptr; / * Sat up Boat of tha haadar information for a duaay haadar for alaulatlon run*. *, ( / * rill Haadar() */ lnt 11 atrcpy( nd* per->nd*_v*r*lon, -vl.0 . 0 " ); ■trcpy( nd* ptr->nda os_v*r*ion, "10.3.0.0" ); atrcpy( nd* ptr - >nd* node, "1B D 61 H ); •trcpyl nda ptr-ml* uaat nut. "Bearings " ); nd*_ptr-»nd* *poch_*lia • apoch s*j nda _ptr->nd*_nua_channal* - nuachan; nd* ptr->nd*..**Bp fraq chan « 1.0 / * * B p par; /* *aaplaa par nllllaacond */ nda ptr »nd*_alt.unit conv - 1.0 / a B p gain; ■trcpy( nda ptr->nda alt unit atr, "m V " ); nda ptr->nd* total record* • 1; nd* ptr->nd* lnt train pauaa - (»hort) ^ tpau** / iooq.o ■ * 0.5 j ; atrcpyi; nda ptr->nda teat file nau, ) I nd* ptr->nd» ta*t file length - 0 ; atrcpyi nda ptr->nd» consent 1, ) I •trcpyl nda ptr-.nd* coaaent 2 . > ; nd* ptr->nd* aaapla mod* - 0; nd* ptr->nd* d i s p l a y soda - 1; nd* ptr *nd*_triggar_aoda - 0; for ( 1*0; lend* Bax. channel*; 1 + + > ( nda ptr->nda channel gain*[1] - 0.0; ■ trcp y l nd*_ptr-»nd* channel naaa*( 1 1, " " ); ) nd* ptr->nd*. l*tia|l] - (ahort) < pulaa rat* t 0.5 ); nda ptr->nd* iatlB(2] - 0; nda ptr-ind* latiB[3) ■ 0; nda p tr - > n d * _ l * t l B [4] ■ 0 ; nd*_ptr->nda r it f l a g » l; nd* ptr->nd* Cast f l l a . fla g • 0 ; ) /• rill Haadar() */ .......... long H r It* Haadar< fp, nd*_ptr ) FILE *fp; nd*_par*B blk t *nd* ptr; /* * olvan a atra a a poln tar and a p o ln ta r to * an NDS f o r a a t f l l a haadar, w rit* tha haadar * and raturn th* haadar alia. V ( /• write haadar •/ long poii /» flla offaat */ lnt 1 j /* Function* •/ axtarn lnt cput () aitarn lnt lput(); axtarn lnt aput(I; axtarn lnt fput(); / • rut tha haadar v e r s io n , aov* to naxt f i e l d */ poa • 0; If ( cput( fp, poa, nd*_ptr->nd* varaion, nd*_haadar.version *lia ) ) po* +■ n d * _ h « a d « r .v « n io n a ll* ; ala* goto arror; /* Put th* OB varalon, nov* to naxt f i a l d *J 1C ( c p u t ( f p r poi, n d * p t r - ? n d * OS varaion, nda os varaion f i x * ) ) poa 4- nd* os v a r s io n alsa; *1** g oto arror; /* Put th* nod* ID, b o v * to n*xt Clald */ i f ( c p u t ( fp, po*. nd* ptr->nda noda, nd* nod* alx* } \ poa 4- nd*_nod* a l i a ; alaa goto arror; / • put tha u*«r n i H , *ov« to naxt f i a l d */ I f ( cput ( tp, po*. nda ptr->nda uaar nun*, nda u**r m sw a l i a } ) poa +■ nda uaar nan* six*; a l a a goto arror; /* Put tha f l l a a l i a , nova to naxt f i a l d */ i f ( I p u t ( fpj poa, nda ptr->nda f l l a a l i a } ) poa a i x a o f ( nda ptr->nd* f l l a a l t * )i ala* g oto arror; /* put tha apoch a lsa , nova to naxt f i a l d */ 1C ( fput{ Cp, poa, nd* ptr->nd* apoch alx* ) > poa +* a i x a o f < nda ptr->nd* apoch alx* }; a laa goto arror; /* Put tha nunbar of channala, nova t o naxt f i a l d */ I f < a p u t ( fp, poa, nd*_ptr'>nd* ,nun_channala ) j poa 4-- a ix * o f( nda ptr->nd* nun channala ); alaa goto arror; /* put th* nunbar of pula**, nova to naxt f l « l d */ i f ( *put( Cp, poa, nd*._ptr->nd* numpul*** > ) poa 4* a i x a o f ( nda ptr->nda nun pula** ); a la * g oto arror; /* Put tha aanpllng fr*qu*ncy, xov* to naxt f i a l d */ i f ( fput ( fp, poa, nd*_ptr->nda aanp. frag, chan ) ) poa 4* aixaof ( nda ptr->nd* a a tap frag chan ); ala* goto arror; /* Put tha a lt a r n a t* u n it* , nov* to naxt f i a l d •/ i f ( fput( fp, poa, nd*__ptr->nda._*lt unit_conv > ) po* 4 ■ a i x a o f ( nd*_ptr~>nd*_alt_unit conv ); • la* goto arror; /* put th* « l t * r n a t * u n it a tr in g , nov* to n*xt f i a l d */ i f { cput < fp, poa, nda_ptr->nd* _*lt ..unit a t r , n d a _ a l t .u n i t _ * t r a l i a ) > poa 4« nd#_*lt u n it_ * t r alx*; alaa goto arror; /* Put tha numbar o f t o t a l racorda, nov* to naxt f i a l d •/ I f { aput{ fp, poa, nd*_ptr->nd#_total_r#cord* ) ) poa 4 • a i x a o f ( nda p tr~>nda_total_r«cord* ); ala* g oto arror; /* Put th* i n t a r * t r a i n pauaa, nov* t o n*xt f i a l d */ i f ( aput( fp, poa, nd*_ptr->nd*_int_tr*lh_paua* ) ) po* 4« * l i * o f ( nda p tr -> n d * _ in t_ tr a ln p*uaa ); *1** goto arror; /» Put th* a lt v r n a t* u n it a tr in g , nov* to naxt f i a l d •/ 157 i f ( cput( fp, po*, nda_ptr->nda ta a t_ f lla _ n a n a , ndi t* * t f l l a .nan* s ix * ) j po* nd* t * s t _ f l i a _ n * n a _ a l i a ; • l a * 9 o to arror; /* Put th* ta a t f l l a nan* i*ngth, aov« t o naxt f i a l d */ i f { a p u t < fp, poa, nda_ptr->nda t* a t_ f1 1 a l*ngth ) ) poa +■ a i i a o f ( nda_ptr- >nds taat f l l a langth ); alaa g oto a r r o r ; /* Put coaaant N 1, nova t o naxt f i a l d *f i f ( cput < fp, poa, nda_ptr-»nda _coM*ant_i, ndi c o a u n t alaa ) ) poa nda conn*nt_aisa; alaa goto arror; /* put coaatnt N a, to naxt f i a l d */ If ( cput ( fp, poa. nda ptr->nd* commaat 2, nda comment alaa ) ) poa +■ tida coDMnt a lia ; a 1 a* goto arror; / • put tha sampl* moda, nova t o naxt f i a l d */ i f ( a p u t ( fp, poa, nda ptr->nd* aanpla nod* ) ) poa 4-m aix a o f ( nda ptr->nda aanpla noda ) ; alaa g oto arror; /* Put tha d is p la y noda. nova to naxt f i a l d */ I f ( *put{ fp, poa, nda ptr->nda display.m oda > ) poa +■ a i x a o f ( nda p t r - >nda d ia p la y noda jj alaa goto arror; /* Put tha t r lg g a r noda, nova t o naxt f i a l d */ If < aput ( fp, poa, nda _ptr->nda. t r ig g e r , nod* ) ) poa *» a i x a o f ( nda ptr->nda t r lg g a r noda ); alaa g oto arror; / • Put tha channal gain*, nov* to naxt f i a l d */ fo r ( i * 0 ; l<nda nax_channala; 1*4 > ( I f ( fput{ fp, poa, nd*_ptr->nda channal g a i n s f i j ) i poa 4* a ls a o f { nds.ptr->nda channal g a ln * (l] ); alaa goto arror; > /* Put th* stim u lu s valuaa, nov* to naxt f i a l d */ for ( 1-0; i<nd* max l a t i n ; 1*4 ) { I f < a p u t( fp, poa, n d a _ p tr -> n d a _ la tin [i ] > ) poa *■ a i x a o f ( nda_ptr->nda l a t l m d ) ); a la * g oto arror; ) / • Put tha channal nanaa, nova t o naxt f i a l d */ fo r ( 1*0 ; l<nd*_n*x_ch*nn*la; 1++ \ ( If (cput( fp, poa, nda_ptr-?nda.channel nanaa[1J. nda channal nan* le n g th )) poa 4- nda channal nan* langth; alaa g o to arror; > /* Put KIT f l a g , nova to naxt f i a l d */ If ( nda ptr->nda_KXT_flag > { i f ( aput( fp, poa, OxPPOO ) ) poa 4- aixaof(nda p t r *>nd*_KIT_flag)/ alaa goto arror; ) alaa I5S < i f ( aput ( fp, poa, 0 } ) poa *•* ai» a o f(n d a ptr->nda kit f l a g ) ; a la * goto arror; ) /* Put t a a t f i l a f l a g , aov* t o naxt f i a l d */ If { nda ptr->nda taat f l l a f l a g ) { i f ( a p u t ( fp, poa, OxFFOO ) ) poa +- ali*o f(n d * _ p tr* > n d a _ ta a t_ f1 1 a f l a g ) / a la a goto arror; > alaa ( I f ( a p u t ( fp, poa, 0 ) ) poa + ■ ■ a isa o ffn d a ptr->nda ta a t f l l a f l a g ); a laa goto arror; > r»turn< poa )/ /* Raturn poa If haadar w rlttan a u c c a s a f u i l y , */ arror s r a t u r n ( OL )/ /* Raturn 0 If a rro r. */ ) /* Writ* Haadar */ « - . * / ln t eput< fp, poa, ptr, n ) Fli,* *fp; long poa; v oid *ptr; lnt n # i * * Wrlta n bytaa from addraaa polntad to by ptr * t o p o a ltio n poa In f l l a fp, * */ { /* cput */ Iff faaak! (p, poa, SEEK SET ) o ) ( 11 { tw r lta ( p tr , 1, n, (p ) ■ - n ) r a t u r n ( n ), a la a raturn( 0 ); 1 a la a r a t u r n ( u ), ) /* cput / * . - lnt lput( : FILF •fp; long poa; long l v a l ; /* * Writa « lungwort) to p o a ltio n poa • in f l l a fp. •/ ( f * lput */ i f f f a a a k ( fp, poa, SEEK_SET ) »- 0 J i.v; INFORMATION TO USERS This manuscript has been reproduced from the microfilm master. UMI films the text directly from the original or copy submitted. Thus, some thesis and dissertation copies are in typewriter face, while others may be from any type of computer printer. The quality of this reproduction is dependent upon the quality of the copy submitted. Broken or indistinct print, colored or poor quality illustrations and photographs, print bleedthrough, substandard margins and improper alignment can adversely affect reproduction. » In the unlikely event that the author did not send UMI a complete manuscript and there are missing pages, these will be noted. Also, if unauthorized copyright material had to be removed, a note will indicate the deletion. Oversize materials (e.g., maps, drawings, charts) are reproduced by sectioning the original, beginning at the upper left-hand corner and continuing from left to right in equal sections with small overlaps. Each original is also photographed in one exposure and is included in reduced form at the back of the book. Photographs included in the original manuscript have been reproduced xerographically in this copy. Higher quality 6" x 9" black and white photographic prints are available for any photographs or illustrations appearing in this copy for an additional charge. Contact UMI directly to order. A Ben & Howell information Company 300 North Zeeb Road Ann Arbor M l 48106-1346 USA 313/761-4700 800.S21-0600 UMI Number: I376S09 DMI Microform 1376509 Copyright 1995, by UMI Company. All rights reserved. This aicrofora edition is protected against unauthorized copying under Title 17, United States Code. UMI 300 North Zeeb Road Ann Arbor, MI 48103
Linked assets
University of Southern California Dissertations and Theses
Conceptually similar
PDF
Auditory brainstem responses (ABR): quality estimation of auditory brainstem responsses by means of various techniques
PDF
Auditory brainstem responses (ABR): variable effects of click polarity on auditory brainstem response, analyses of narrow-band ABR's, explanations
PDF
Fault tolerant characteristics of artificial neural network electronic hardware
PDF
Estimation of upper airway dynamics using neck inductive plethysmography
PDF
Three-dimensional functional mapping of the human visual cortex using magnetic resonance imaging
PDF
A physiologic model of granulopoiesis
PDF
Respiratory system impedance at the resting breathing frequency range
PDF
Decomposition Of Neuronal Function Using Nonlinear Systems Analysis
PDF
Design of a portable infrared spectrometer: application to the noninvasive measurement of glucose
PDF
A computational model of NMDA receptor dependent and independent long-term potentiation in hippocampal pyramidal neurons
PDF
A kinetic model of AMPA and NMDA receptors
PDF
Functional water MR spectroscopy of stimulated visual cortex using single voxel
PDF
Comparisons of deconvolution algorithms in pharmacokinetic analysis
PDF
Parallel STAP benchmarks and their performance on the IBM SP2
PDF
Disha: a true fully adaptive routing scheme
PDF
Comparison of evacuation and compression for cough assist
PDF
Propofol Effects On Eeg And Levels Of Sedation
PDF
A novel network for nonlinear modeling of neural systems with arbitrary point-process inputs
PDF
Pulse oximetry failure rates
PDF
Design and synthesis of novel second order nonlinear optical materials
Asset Metadata
Creator
Scaringe, William Anthony
(author)
Core Title
Cross-correlation methods for quantification of nonlinear input-output transformations of enural systems using a Poisson random test input
School
School of Engineering
Degree
Master of Science
Degree Program
Biomedical Engineering
Degree Conferral Date
1995-08
Publisher
University of Southern California
(original),
University of Southern California. Libraries
(digital)
Tag
artificial intelligence,computer science,engineering, biomedical,OAI-PMH Harvest
Language
English
Contributor
Digitized by ProQuest
(provenance)
Advisor
Berger, Theodore W. (
committee chair
), Khoo, Michael Chee-Kuan. (
committee member
), Marmarelis, Vasilis A. (
committee member
)
Permanent Link (DOI)
https://doi.org/10.25549/usctheses-c18-4596
Unique identifier
UC11357575
Identifier
1376509.pdf (filename),usctheses-c18-4596 (legacy record id)
Legacy Identifier
1376509-0.pdf
Dmrecord
4596
Document Type
Thesis
Rights
Scaringe, William Anthony
Type
texts
Source
University of Southern California
(contributing entity),
University of Southern California Dissertations and Theses
(collection)
Access Conditions
The author retains rights to his/her dissertation, thesis or other graduate work according to U.S. copyright law. Electronic access is being provided by the USC Libraries in agreement with the au...
Repository Name
University of Southern California Digital Library
Repository Location
USC Digital Library, University of Southern California, University Park Campus, Los Angeles, California 90089, USA
Tags
artificial intelligence
computer science
engineering, biomedical