UBC Theses and Dissertations

UBC Theses Logo

UBC Theses and Dissertations

Towards real time EMG analysis Kenward, Gary Wayne 1982

Your browser doesn't seem to have a PDF viewer, please download the PDF to view this item.

Notice for Google Chrome users:
If you are having trouble viewing or searching the PDF with Google Chrome, please download it here instead.

Item Metadata

Download

Media
831-UBC_1982_A7 K46.pdf [ 12.34MB ]
Metadata
JSON: 831-1.0095332.json
JSON-LD: 831-1.0095332-ld.json
RDF/XML (Pretty): 831-1.0095332-rdf.xml
RDF/JSON: 831-1.0095332-rdf.json
Turtle: 831-1.0095332-turtle.txt
N-Triples: 831-1.0095332-rdf-ntriples.txt
Original Record: 831-1.0095332-source.json
Full Text
831-1.0095332-fulltext.txt
Citation
831-1.0095332.ris

Full Text

TOWARDS REAL TIME EMG ANALYSIS by GARY WAYNE KENWARD B.A.Sc, U n i v e r s i t y of B r i t i s h Columbia, A THESIS SUBMITTED IN PARTIAL FULFILMENT THE REQUIREMENTS FOR THE DEGREE OF MASTER OF APPLIED SCIENCE i n THE FACULTY OF GRADUATE STUDIES ( Department of E l e c t r i c a l E n g i n e e r i n g We accept t h i s t h e s i s as conforming to the r e q u i r e d standard. THE UNIVERSITY OF BRITISH COLUMBIA October, 1982 (c) Gary Wayne Kenward, 1 982 In p r e s e n t i n g t h i s t h e s i s i n p a r t i a l f u l f i l m e n t o f t h e r e q u i r e m e n t s f o r an advanced d e g r e e a t t h e U n i v e r s i t y o f B r i t i s h C o l u m b i a , I a g r e e t h a t t h e L i b r a r y s h a l l make i t f r e e l y a v a i l a b l e f o r r e f e r e n c e and s t u d y . I f u r t h e r a g r e e t h a t p e r m i s s i o n f o r e x t e n s i v e c o p y i n g o f t h i s t h e s i s f o r s c h o l a r l y p u r p o s e s may be g r a n t e d by t h e Head o f my Depa r tmen t o r by h i s r e p r e s e n t a t i v e s . I t i s u n d e r s t o o d t h a t c o p y i n g o r p u b l i c a t i o n o f t h i s t h e s i s f o r f i n a n c i a l g a i n s h a l l no t be a l l o w e d w i t h o u t my w r i t t e n p e r m i s s i o n . Depar tmen t The U n i v e r s i t y o f B r i t i s h C o l u m b i a 2075 Wesbrook P l a c e V a n c o u v e r , Canada V6T 1W5 Date Z2. E - 6 B P 7 5 - 5 1 1 E i i ABSTRACT Techniques f o r automatic r e c o r d i n g and a n a l y z i n g s i n g l e motor u n i t a c t i o n p o t e n t i a l s i n r e a l time have been s t u d i e d . A model of the human motor u n i t has been d e r i v e d . The muscle f i b e r s were modelled with c u r r e n t d i p o l e s and randomly d i s t r i b u t e d w i t h i n the motor u n i t c r o s s s e c t i o n a c c o r d i n g to a b i v a r i a t e Gaussian, or binormal, p r o b a b i l i t y d e n s i t y f u n c t i o n . Computer s i m u l a t i o n s were performed with the model using parameters measured f o r the human bic e p s b r a c h i i . The s i n g l e f i b e r a c t i o n p o t e n t i a l s generated by the c u r r e n t d i p o l e s were summed at a r e c o r d i n g s i t e to produce a simulated s i n g l e motor u n i t a c t i o n p o t e n t i a l . A n a l y s i s of the motor u n i t model and the p o t e n t i a l s generated showed that the s i n g l e motor u n i t a c t i o n p o t e n t i a l s of i n t e r e s t were recorded from w e l l w i t h i n the motor u n i t t e r r i t o r y , and that the p o t e n t i a l s formed were i n f l u e n c e d mainly by the nearby f i b e r s . The s i n g l e motor u n i t a c t i o n p o t e n t i a l amplitude and d u r a t i o n were found to have a n o n - l i n e a r dependence upon the ra d i u s of the r e c o r d i n g s i t e from the motor u n i t c e n t e r . The r e l a t i o n s h i p between amplitude and d u r a t i o n was found to be l i n e a r but su b j e c t to random v a r i a t i o n s due to the i n f l u e n c e of nearby f i b e r s . The behaviour of the simulated s i n g l e motor u n i t a c t i o n p o t e n t i a l s agreed with c l i n i c a l o b s e r v a t i o n s . A three stage r e a l time p r o c e s s i n g system was designed. i i i The s i g n a l c h a r a c t e r i s t i c s of c l i n i c a l l y recorded electromyographic a c t i v i t y at low c o n t r a c t i o n l e v e l s were analyzed, and the f i r s t stage of p r e - f i l t e r i n g designed to reduce the r e q u i r e d sampling r a t e , and i n c r e a s e the s i g n a l to n o i s e r a t i o without d i s t o r t i n g the s i n g l e motor u n i t a c t i o n p o t e n t i a l s . The second stage of p r o c e s s i n g was based on an adaptive matched f i l t e r with dual d e t e c t i o n t h r e s h o l d s . The f i n a l stage used f e a t u r e c l a s s i f i c a t i o n of the d e t e c t e d s i n g l e motor u n i t a c t i o n p o t e n t i a l s to remove p o t e n t i a l s not from the s e l e c t e d motor u n i t . A non-real time software implementation of the p r o c e s s i n g system demonstrated that l a r g e ensembles of s i n g l e motor u n i t a c t i o n p o t e n t i a l s c o u l d be a c q u i r e d from r e l a t i v e l y short r e c o r d i n g s of electromyographic a c t i v i t y , with few d e t e c t i o n e r r o r s . i v CONTENTS ABSTRACT i i CONTENTS i v FIGURES v i TABLES ix ACKNOWLEDGEMENTS X I Towards Real Time EMG A n a l y s i s 1 1. 1 I n t r o d u c t i o n 1 1.2 The Motor U n i t 2 1.3 Scope of T h e s i s 4 II M o d e l l i n g of the Human Motor U n i t 5 I I . 1 I n t r o d u c t i o n 5 11.2 The Binormally D i s t r i b u t e d Model 22 11.3 Siz e of the Binormal Motor Unit F i b e r Array 25 11.4 Sampling Near the F i b e r Array Center 30 11.5 SMUAP Amplitude and Duration 40 11.6 SMUAP Amplitude versus Duration 47 11.7 E f f e c t s of A n i s o t r o p i c Conducting Medium 50 11.8 Influence of Nearby F i b e r s 58 11.9 Human Motor Unit Model: Synopsis 62 III Real Time P r o c e s s i n g of EMG S i g n a l s 64 111.1 I n t r o d u c t i o n 64 111.2 Waveform Rec o g n i t i o n Techniques 67 111.3 Proposed Real Time EMG Pr o c e s s i n g System 74 111.4 E s t i m a t i o n of the EMG S i g n a l Spectra 75 111.5 D i g i t a l f i l t e r i n g of the EMG S i g n a l 84 111.6 Adaptive Matched F i l t e r Implementation 89 V 1 1 1 . 7 Adaptive Matched F i l t e r Performance 96 1 1 1 . 8 Real Time EMG P r o c e s s i n g : Synopsis 106 IV C l a s s i f i c a t i o n of SMUAPs 107 IV. 1 I n t r o d u c t i o n 107 IV.2 C l a s s i f i c a t i o n F e a t u r e s 109 IV.3 Stepwise L i n e a r Descriminant A n a l y s i s 115 IV.4 C l a s s i f i c a t i o n of SMUAPs: Synopsis 117 V C o n c l u s i o n s 118 VI Appendices 123 A. The I n t e r - f i b e r D i s t a n c e P r o b a b i l i t y D e n s i t y Function . 124 B. The Free Area P r o b a b i l i t y D i s t r i b u t i o n 128 C. The Optimal L i n e a r Phase FIR D i g i t a l F i l t e r Designs — 134 D. The Narrow Band High Pass F i l t e r Implementation 145 E. Program L i s t i n g s f o r the SMUAP S i m u l a t i o n Study 147 E.1 Binomial Motor U n i t F i b e r Array Generation 147 E.2 SMUAP Si m u l a t i o n 160 E.3 P l o t t i n g of SMUAPs 182 E.4 P l o t t i n g of SMUAP Waveform Features 194 E. 5 P l o t t i n g of PSD E s t i m a t i o n s 217 F. NOVA 840 Program L i s t i n g s 231 F. 1 Reading VGH EMG Data Tapes 231 F.2 PSD E s t i m a t i o n of EMG Data 241 F.3 Adaptive Matched F i l t e r i n g and Feature E x t r a c t i o n .. 261 F.4 M i s c e l l a n e o u s Support Routines 303 G. Terms and D e f i n i t i o n s 315 VII References 318 VI FIGURES I. 2-1 The s i n g l e motor u n i t 3 I I . 1-1 The s i n g l e f i b e r c u r r e n t d i p o l e 6 II.1-2 A u n i f o r m l y d i s t r i b u t e d motor u n i t f i b e r a r r a y 7 II.1-3 Uniformly d i s t r i b u t e d f i b e r a r r a y SMUAPs 9 11.1- 4 Uniformly d i s t r i b u t e d f i b e r a r r a y SMUAPs with a x i a l d i s p e r s i o n 15 11.2- 1 A b i n o r m a l l y d i s t r i b u t e d motor u n i t f i b e r a r r a y 23 11.3- 1 The normal pdf of the c r o s s s e c t i o n a l a r r a y d i s t r i b u t i o n 26 11.3- 2 The p r o b a b i l i t y d i s t r i b u t i o n of i n t e r - f i b e r d i s t a n c e s 29 11.4- 1 The f r e e area p r o b a b i l i t y d i s t r i b u t i o n 32 II.4-2 B i n o r m a l l y d i s t r i b u t e d f i b e r a r r a y SMUAPs with a x i a l d i s p e r s i o n 33 11.4- 3 An i n s i t u s i n g l e motor u n i t a c t i o n p o t e n t i a l 39 11.5- 1 SMUAP l o g peak to peak amplitude vs. l o g r a d i a l d i s t a n c e 41 II.5-2 Cubic s p l i n e L.M.S. f i t to f i g u r e II.5-1 42 II.5-3 SMUAP l o g d u r a t i o n vs. l o g r a d i a l d i s t a n c e 44 11.5- 4 Cubic s p l i n e L.M.S. f i t to f i g u r e II.5-3 45 11.6- 1 SMUAP l o g amplitude vs. l o g d u r a t i o n 48 11.6- 2 L i n e a r L.M.S. f i t s to f i g u r e II.6-1 49 11.7- 1 SMUAP l o g amplitude vs. l o g r a d i a l d i s t a n c e f o r a n i s o t r o p i c media 51 II.7-2 Cubic s p l i n e L.M.S. f i t s t o f i g u r e II.7-1 52 II.7-3 SMUAP l o g d u r a t i o n vs. l o g r a d i a l d i s t a n c e f o r a n i s o t r o p i c media 53 VI 1 II.7-4 Cubic s p l i n e L.M.S. f i t s to f i g u r e II.7-3 54 II.7-5 SMUAP l o g amplitude v s . l o g d u r a t i o n f o r a n i s o t r o p i c media • • • 55 1 1 .7- 6 L i n e a r L.M.S. f i t s t o f i g u r e II.7-3 56 1 1 .8- 1 SMUAP R.M.S. power c o n t r i b u t e d by the nearest f i b e r s . 59 II.8-2 SMUAP amplitude c o n t r i b u t e d by the nearest f i b e r s .... 60 I I . 8-3 SMUAP d u r a t i o n c o n t r i b u t e d by the nearest f i b e r s 61 I I I . 1-1 T y p i c a l segment of recorded EMG a c t i v i t y 65 III.4-1 Estimated PSD f o r recorded EMG a c t i v i t y 77 III.4-2 Estimated PSD f o r the background noi s e from recorded EMG a c t i v i t y 79 III.4-3 Estimated PSD f o r the b a s e l i n e component of recorded EMG a c t i v i t y 80 111 .4- 4 Estimated PSD f o r an averaged SMUAP 82 111 .5- 1 P r e - f i l t e r response to white noise p l u s constant l e v e l input 85 III .5-2 F i l t e r e d SMUAP 88 111 .6- 1 Adaptive matched f i l t e r flow c h a r t 9 1 III.6-2 SMUAP s e l e c t e d as an i n i t i a l matched f i l t e r template 92 1 1 1 .6- 3 Ensemble average of 53 de t e c t e d SMUAPs 95 1 1 1 .7- 1 T y p i c a l m a r g i n a l l y a c c e p t a b l e EMG a c t i v i t y r e c o r d ... 98 III.7-2 p r e - f i l t e r i n g of recorded EMG 99 I I I . 7-3 D e t e c t i o n performance with r e c o r d t7r7 102 IV. 2-1 B i p h a s i c SMUAP waveform 110 IV.2-2 Nine c l a s s i f i c a t i o n f e a t u r e s f o r b i p h a s i c SMUAPs .... 112 VI.B-1 Free area approximation 129 VI.C-1 The 2 KHz Nyquist FIR f i l t e r frequency response 136 v i i i VI.C-2 The 4 KHz Nyquist FIR f i l t e r frequency response 138 VI.C-3 The stage I low pass f i l t e r frequency response 142 VI.C-4 The stage II low pass f i l t e r frequency response 143 VI.C-5 The stage I I I low pass f i l t e r frequency response 144 VI.D-1 The narrow stopband high pass f i l t e r 146 ix TABLES III.7-1 The adaptive matched performance with r e c o r d t7r7 .. 100 III.7-2 The adap t i v e matched f i l t e r performance with records t 7 r 9 , t7r12, t 7 r l 5 and t 8 r 9 103 I I I . 7-3 The adaptive matched f i l t e r performance with r e c o r d t 8 r 9 105 IV. 3-1 The f e a t u r e c l a s s i f i c a t i o n performance with records t 7 r 7 , t 7 r 12 and t 8 r 9 116 VI.C-1 The 2 KHz Nyquist FIR f i l t e r d esign 135 VI.C-2 The 4 KHz Nyquist FIR f i l t e r design 137 VI.C-3 The stage I low pass FIR f i l t e r design 139 140 VI .C-4 The stage II low pass FIR f i l t e r design VI.C-5 The stage III low pass FIR f i l t e r design 141 X ACKNOWLEDGEMENTS My foremost a p p r e c i a t i o n goes to Dr. P.D. Lawrence f o r h i s pa t i e n c e , guidance and good f a i t h d u r i n g the completion of t h i s t h e s i s . I would l i k e to thank Dr. P.J.A. B r a t t y f o r h i s p a r t i c i p a t i o n i n p r e p a r i n g the ideas f o r t h i s work, and i n e v a l u a t i n g the r e s u l t s . The f a c u l t y , s t a f f and students of the department a l s o deserve a thank you f o r making the d u r a t i o n of my graduate work an i n t e r e s t i n g , and rewarding, experience. F i n a l l y , I must acknowledge Merelene J . A u s t i n f o r her e f f o r t s i n d r a f t i n g many of the f i g u r e s , e n t e r i n g t e x t i n t o the computer, and p r o v i d i n g p e r s i s t e n t support. 1 !• Towards Real Time EMG A n a l y s i s I.1 I n t r o d u c t i o n The e a r l y d i a g n o s i s and treatment of neuromuscular d i s o r d e r s has been g r e a t l y f a c i l i t a t e d by the a b i l i t y to r e c o r d and analyze the e l e c t r i c a l a c t i v i t y generated by a c o n t r a c t i n g muscle. The r e c o r d i n g of these s i g n a l s , known as "electromyography" (EMG), allows p h y s i c i a n s t o determine the nature and extent of a motor d i s f u n c t i o n , o f t e n e a r l y enough to i n s t i t u t e e f f e c t i v e treatment. T h i s t h e s i s examines methods f o r enhancing the technology a v a i l a b l e f o r electromyography. The o b j e c t i v e i s to expediate the a c q u i s i t i o n and a n a l y s i s of neuromuscular s i g n a l s , and p r o v i d e r e l i a b l e , q u a n t i t a t i v e I n f o r m a t i o n i n a i d of e a r l y d i a g n o s i s . A review of automatic a n a l y s i s techniques and the g e n e r a l requirements of an automatic EMG p r o c e s s i n g system are given by Boyd, B r a t t y and Lawrence [ 1 ] , and r e f e r e n c e s f o r f u r t h e r i n f o r m a t i o n on electromyography and e l e c t r o d i a g n o s i s are given i n Boyd's t h e s i s [ 2 ] . 2 1.2 The Motor U n i t The primary f u n c t i o n a l u n i t of the neuromuscular system i s the motor u n i t , comprised of a s i n g l e motor neuron, i t s axon and a l l the muscle f i b e r s i t i n n e r v a t e s . The motor neuron c e l l body r e s i d e s i n the s p i n a l c o r d , or the b r a i n , and i t s axon extends to the muscle where i t d i v i d e s i n t o a number of branches, each t e r m i n a t i n g at a s i n g l e muscle f i b e r , as i l l u s t r a t e d i n f i g u r e 1 . 2 - 1 . The j u n c t i o n of a motor neuron branch and a muscle f i b e r i s known as the myoneural j u n c t i o n . The area of a muscle f i b e r immediately under the t e r m i n a l p o r t i o n of the axon i s known as the motor endplate. A s i n g l e f i b e r a c t i o n p o t e n t i a l (SFAP) i s generated when the motor endplate region of a f i b e r i s s t i m u l a t e d , c r e a t i n g a l o c a l i z e d d e p o l a r i z a t i o n that t r a v e l s the l e n g t h of the muscle f i b e r . An e l e c t r o d e p l a c e d very near the f i b e r w i l l r e c o r d the pa s s i n g d e p o l a r i z e d r e g i o n as a time v a r y i n g e l e c t r i c f i e l d . Each f i b e r w i t h i n a motor u n i t c o n t r i b u t e s to an o v e r a l l time v a r y i n g f i e l d c a l l e d a s i n g l e motor u n i t a c t i o n p o t e n t i a l (SMUAP). The nature of the recorded SMUAP — amplitude, d u r a t i o n and shape — i s dependent upon a number of i n t e r r e l a t e d p h y s i o l o g i c a l f a c t o r s : age, temperature and p h y s i o l o g i c a l c o n d i t i o n of the s u b j e c t ; s i z e , number and d i s t r i b u t i o n of f i b e r s w i t h i n the motor u n i t ; and the geometry, m a t e r i a l and o r i e n t a t i o n of the r e c o r d i n g e l e c t r o d e [ 3 , 4 , 5 ] . 3 . SPINAL CORD M U S C L E Fl B R E S F i g u r e 1.2-1 The s i n g l e mo to r u n i t 4 1.3 Scope of T h e s i s S e c t i o n two of t h i s t h e s i s d e s c r i b e s the con t i n u e d computer s i m u l a t i o n s t u d i e s of the formation of s i n g l e motor u n i t a c t i o n p o t e n t i a l s beginning with Boyd's u n i f o r m l y d i s t r i b u t e d d i p o l e a r r a y model [ 2 ] . T h i s work l e d to the development of an improved b i n o r m a l l y d i s t r i b u t e d d i p o l e a r r a y model which p r o v i d e d r e s u l t s i n c l o s e r agreement to c l i n i c a l l y observed phenomena [ 6 ] , and demonstrated s i g n i f i c a n t l y g r e a t e r interdependence between the p h y s i o l o g i c a l and e l e c t r i c a l c h a r a c t e r i s t i c s of the motor u n i t and the recorded p o t e n t i a l than suggested by Boyd. S e c t i o n three d e s c r i b e s the proposed r e a l time EMG p r o c e s s i n g system. Previous p r o c e s s i n g techniques are reviewed, and the adaptive matched f i l t e r a l g o r i t h m i s o u t l i n e d . An a n a l y s i s of c l i n i c a l l y recorded EMG a c t i v i t y i s presented, s e t t i n g the c r i t e r i a f o r the d e t a i l e d design of the p r o c e s s i n g system. The performance of a software implementation of the adaptive matched f i l t e r system i s examined. The f o u r t h s e c t i o n d i s c u s s e s i n g r e a t e r d e t a i l the f i n a l stage of the proposed system. An overview of a f e a t u r e c l a s s i f i c a t i o n technique f o r enhancing the performance of the ada p t i v e matched f i l t e r i s presented. The r e s u l t s of a f e a s i b i l i t y study performed on data from the software adaptive matched f i l t e r of s e c t i o n three are presented. The f i n a l s e c t i o n summarizes the work presented i n t h i s t h e s i s , and proposes s u b j e c t s f o r f u t u r e r e s e a r c h and development. 5 I I . M odelling of the Human Motor Unit II.1 I n t r o d u c t i o n The d i p o l e array model of the human motor u n i t i n the biceps b r a c h i i muscle was developed i n i t i a l l y by Boyd [2,7]. This model i s based on a current d i p o l e approximation to the e x t r a c e l l u l a r a c t i o n p o t e n t i a l f i e l d of a s i n g l e muscle f i b e r , i l l u s t r a t e d i n f i g u r e I I . 1 - 1 . The p o t e n t i a l f i e l d of the current d i p o l e i s given by * { i } : I i s the current source ( s i n k ) magnitude, v i s the c o n d u c t i v i t y of the medium, and 2b i s the d i p o l e l e n g t h . With the a c t i o n p o t e n t i a l conduction v e l o c i t y taken as 4.0 meters/second, a value f o r b of 0.25 mm y i e l d s b i p h a s i c waveforms which approximate s i n g l e f i b e r a c t i o n p o t e n t i a l s (SFAPs) obtained c l i n i c a l l y [ 7 ] . The array of f i b e r s f o r a s i n g l e motor u n i t i s simulated by randomly d i s t r i b u t i n g 163 p a r a l l e l d i p o l e s throughout the area that d e f i n e s the motor u n i t t e r r i t o r y . Boyd used a uniform d i s t r i b u t i o n of d i p o l e s w i t h i n a c i r c u l a r t e r r i t o r y 5.0 mm i n diameter; an example of t h i s motor u n i t model i s presented i n f i g u r e I I . 1 - 2 . The r e s u l t i n g p o t e n t i a l f i e l d i s the a l g e b r a i c sum of the i n d i v i d u a l d i p o l e f i e l d s , according to the Helmholtz theorem: Figure II.1-1 The single fiber current dipole 7. i CO ' i + 4-+ + 4-+ + - 3 . 2 - 2 7 2 . - 3 . 2 4 -J i 4- b + SL 0.8 1.8 _± L + + + + + + 4- + 4-ro o u t O F i g u r e II.1-2 A u n i f o r m l y d i s t r i b u t e d moto r u n i t f i b e r a r r a y 8 Where (x{i),y{i},z{i}) are the coordinates of the i t h dipole, and r = (x J + y 2 ) 1 / / 2 . In the simplest case, a l l SFAPs a r r i v e at the z coordinate of the sampling position simultaneously and thus a l l dipoles are aligned in a common (x,y) plane — z{i} = 0 for a l l i ; example SMUAP potentials for th i s case at increasing recording s i t e r a d i a l distances are given in figure II.1-3 . As Boyd observed, the resulting single motor unit action potential (SMUAP) has a larger amplitude and duration than the SFAP components, and the ef f e c t of volume conduction of the fiber currents generated by the individual dipoles can be seen in the decreased amplitude and increased duration of the SMUAPs with increased r a d i a l distance from the motor unit center, in agreement with c l i n i c a l experience in EMG [7]. Boyd also showed that the eff e c t s of differences in a r r i v a l times of the SFAPs due to motor endplate dispersion and conduction time differences in both the terminal nerve endings and the muscle f i b e r s could be simulated by dispersing the dipoles along the fiber a x i s . This dispersion i s accomplished by treating the z{i} coordinate of a dipole as a random variable with a Gaussian p r o b a b i l i t y density function (pdf). The standard deviation of the Gaussian pdf was determined by Boyd to be about 0.7 mm i f the generated potentials were to agree in F i g u r e I I . 1 - 3 U n i f o r m l y d i s t r i b u t e d f i b e r a r r a y SMUAPs No a x i a l d i s p e r s i o n . 14 shape with c l i n i c a l SMUAPs recorded from normal s u b j e c t s [ 7 ] , SMUAPs generated by t h i s model with a x i a l d i s p e r s i o n s of 0.7 mm fo r i n c r e a s i n g r e c o r d i n g s i t e r a d i a l d i s t a n c e s are shown i n f i g u r e II.1-4. The model implemented by Boyd was thus able to simulate a SMUAP that g e n e r a l l y agreed with c l i n i c a l e x perience. Boyd used the model to demonstrate the e f f e c t of electromyographic j i t t e r on s u c c e s s i v e SMUAPs, and proposed a p o s s i b l e measure of the number of f i b e r s w i t h i n a motor u n i t f o r d i a g n o s t i c purposes [ 8 ] . Continued a n a l y s i s of c l i n i c a l l y recorded data by Mackinnon, Lawrence and B r a t t y have however exposed some d i s c r e p a n c i e s between the s i m u l a t i o n r e s u l t s and c l i n i c a l data, which had otherwise agreed q u i t e w e l l 1 . Boyd had assumed from experiments with h i s model that smooth SMUAPs had to be recorded from s i t e s w e l l o u t s i d e the motor u n i t t e r r i t o r y to a v o i d domination by the e l e c t r i c f i e l d s generated by nearby f i b e r s [ 8 ] . T h i s assumption was the b a s i s of the approximations used by Boyd to equations 1 and 2 i n d e r i v i n g the v a r i a t i o n of SMUAP peak to peak amplitude and peak to peak d u r a t i o n with the sampling r a d i u s : the peak to peak amplitude of a SMUAP i n the f a r f i e l d was to vary i n p r o p o r t i o n to 1/r 2, while the peak to peak d u r a t i o n i n the f a r f i e l d was to vary d i r e c t l y with r . These r e l a t i o n s h i p s were d e r i v e d from the f a r approximation to the p o t e n t i a l f i e l d of a d i p o l e [ 7 ] : 1 P e r s o n a l d i s c u s s i o n s with Mackinnon, Lawrence, and B r a t t y at the Department of E l e c t r i c a l E n g i n e e r i n g , U.B.C. o CO R = 3.5000 ' F i g u r e II..1-4 U n i f o r m l y d i s t r i b u t e d f i b e r a r r a y SMUAPs w i t h a x i a l d i s p e r s i o n a - 0 . 7 m.m. 20 $/.)gf—I—) lb cose ; r;»fe And from the a n a l y s i s by George [ 9 ] , who showed that the p o s i t i o n s of the peaks of the d i p o l e f a r f i e l d p o t e n t i a l were d i r e c t l y r e l a t e d to the r a d i a l d i s t a n c e from the d i p o l e : Z „ - ±JL ; r»b f 4 ! The p o s i t i o n of e i t h e r peak i s denoted by z 0 . Acco r d i n g l y , the r e l a t i o n s h i p between peak to peak amplitude and peak t o peak dur a t i o n f o r SMUAPs recorded i n the far f i e l d of a motor u n i t should a l s o be of the order of 1/x 2. This r e l a t i o n s h i p i s s i g n i f i c a n t i n that both the peak to peak amplitudes and the peak to peak dura t i o n s can be measured from recorded SMUAPs while the r a d i a l p o s i t i o n s of recordings are p r a c t i c a l l y unobtainable. In the c l i n i c a l s i t u a t i o n however, even though smooth SMUAPs were s e l e c t e d and stored, a n a l y s i s of the peak to peak amplitude and the peak to peak d u r a t i o n r e l a t i o n s h i p evinced more of a 1 / x than a 1 / x 2 r e l a t i o n s h i p . Added to t h i s discrepancy were some q u a l i t a t i v e c l i n i c a l observations made while withdrawing the conc e n t r i c needle electr o d e from the muscle t i s s u e : the amplitudes of some of the p o t e n t i a l s observed would decrease, then increase and decrease a few times before dying out a l t o g e t h e r ; the durations of the same p o t e n t i a l s would 21 behave i n an op p o s i t e manner, i n c r e a s i n g and then d e c r e a s i n g and so f o r t h as the needle was withdrawn [ 6 ] , The i m p l i c a t i o n of these c l i n i c a l o b s e r v a t i o n s was that the SMUAPs were recorded c l o s e to the motor u n i t c e n t e r , and the f a r f i e l d approximations Boyd used with h i s model were no longer a p p l i c a b l e . Indeed, the second o b s e r v a t i o n suggests that the r e c o r d i n g e l e c t r o d e was p l a c e d w e l l w i t h i n the motor u n i t t e r r i t o r y , and was moved past f i b e r s of that same motor u n i t , through regions where the p o t e n t i a l f i e l d recorded was dominated by SFAPs. To r e s o l v e the d i s c r e p a n c i e s between Boyd's p r e d i c t i o n s based on the uniform d i p o l e a r r a y model and the c l i n i c a l o b s e r v a t i o n s of MacKinnon et a l , a new s i m u l a t i o n study was undertaken using the UBC Amdahl 470 computing f a c i l i t i e s . The new s i m u l a t o r i n c o r p o r a t e d a r e v i s e d model f o r the motor u n i t f i b e r a r r a y d i s t r i b u t i o n , and had g r e a t e r f l e x i b i l i t y i n v a r y i n g parameters a f f e c t i n g the gener a t i o n of SMUAPs. P a s c a l l i s t i n g s f o r the s i m u l a t o r and v a r i o u s a n a l y s i s programs are given i n Appendix E. 22 II.2 The Bi n o r m a l l y D i s t r i b u t e d Model The c l i n i c a l experience of Mackinnon et a l c o n t r a d i c t e d what Boyd p r e d i c t e d using the f a r f i e l d approximations with the uni f o r m l y d i s t r i b u t e d d i p o l e a r r a y model. I f Boyd's assumption was i n c o r r e c t , and r e c o r d i n g s i t e s s e l e c t e d c l i n i c a l l y are a c t u a l l y near or w i t h i n the motor u n i t t e r r i t o r y , then i t must be demonstrated how smooth b i p h a s i c SMUAPs can be so obtained. SMUAPs have a smooth, b i p h a s i c shape when the r e c o r d i n g s i t e can be placed amongst the f i b e r s of the motor u n i t with none of the f i b e r s being near enough t o e l e c t r i c a l l y dominate the measured p o t e n t i a l f i e l d . The a v a i l a b i l i t y of such " f r e e " l o c a t i o n s w i t h i n the motor u n i t t e r r i t o r y depends on the c r o s s s e c t i o n a l d e n s i t y of the f i b e r d i s t r i b u t i o n — the lower the number of f i b e r s per u n i t area, the grea t e r the amount of open space a v a i l a b l e f o r e l e c t r o d e placement. The uniform c i r c u l a r motor u n i t d i s t r i b u t i o n s used by Boyd can c o n t a i n open areas, some l a r g e enough to allow the r e c o r d i n g of a d e s i r a b l e smooth b i p h a s i c SMUAP, however, most i n v e s t i g a t i o n s i n t o the motor u n i t s i z e and d i s t r i b u t i o n have noted that the f i b e r d i s t r i b u t i o n c o u l d be modelled by a binormal d i s t r i b u t i o n with the uniform model u s u a l l y being chosen f o r i t s s i m p l i c i t y [10,11,12,13]. The b i n o r m a l l y d i s t r i b u t e d f i b e r a r r a y model has the mathematical f l e x i b i l i t y of the normal d i s t r i b u t i o n f u n c t i o n , e n a b l i n g a more d e t a i l e d a n a l y s i s of the motor u n i t t e r r i t o r y , the c r o s s s e c t i o n a l d e n s i t y of the f i b e r s , and thus, the a v a i l a b i l i t y of f r e e areas f o r the r e c o r d i n g of smooth b i p h a s i c SMUAPs ( f i g u r e I I . 2 - 1 ) . t—I o oo ~ • + 4 4 t 4 4 % + o V*, 4 4 . + 4 + % 4 + 4 * + • • + 4 * 1 4 8 .0 + 4 + + * , -+ 4 + q. * 4 - r 4.o + 8.o T 4 + 4 * % + + * • / * + 4 + +  + 4 + 4 4 12.0 -8.0 i i 4 4 I Figure II.2-1 A binormally distributed motor unit fiber array 24 Obviously i t i s t e c h n i c a l l y impossible to be " o u t s i d e " the bi n o r m a l l y d i s t r i b u t e d model of the motor u n i t s i n c e by d e f i n i t i o n the normal p r o b a b i l i t y d i s t r i b u t i o n i s unbounded, however i t can be shown t h a t most SMUAPs with c l i n i c a l l y s i g n i f i c a n t amplitudes and d u r a t i o n s can be recorded from s i t e s w i t h i n one or two standard d e v i a t i o n s of the motor u n i t c e n t e r . F i r s t an estimate of the the motor u n i t s i z e must be made, which can be accomplished by using a v a i l a b l e c l i n i c a l i n f o r m a t i o n to estimate the standard d e v i a t i o n , of the c r o s s s e c t i o n a l d e n s i t y d i s t r i b u t i o n of the f i b e r a r r a y . 2 5 I I . 3 S i z e of the Binormal Motor Unit F i b e r Array The d i s t r i b u t i o n of the f i b e r s i n the binormal model i s given by the Gaussian pdf f o r two random v a r i a b l e s : ~ / \ — r exp 4. o 1 { 6 } The independent random v a r i a b l e s x { i } and y { i } are the c a r t e s i a n coordinates of the i t h f i b e r i n the a r r a y , with the spread of values f o r each coordinate governed by «. This d i s t r i b u t i o n of f i b e r s i s uniform and c i r c u l a r l y symmetric about the c e n t r a l a x i s of the a r r a y . As f i g u r e II.3-1 i l l u s t r a t e s , the de n s i t y of the f i b e r s i s dependent only on the r a d i a l d i s t a n c e from the array center r e l a t i v e to the standard d e v i a t i o n of the d i s t r i b u t i o n , *. To e s t a b l i s h the s i z e of the binormal motor u n i t f i b e r array model i t i s t h e r e f o r e necessary to estimate « from c l i n i c a l measurements of the anatomy of a muscle f i b r e a r r a y . D i r e c t measurements of the f i b e r d i s t r i b u t i o n f o r a s i n g l e motor u n i t are d i f f i c u l t t o o b t a i n , e s p e c i a l l y f o r human muscle t i s s u e , however S t a l b e r g et a l [14] have pu b l i s h e d information on the distances between f i b e r s as 2 7 measured i n s i t u from the human biceps b r a c h i i . These measurements can be used to estimated the s i z e of the binormally d i s t r i b u t e d f i b e r array model. The pdf of the i n t e r - f i b e r d i s t a n c e s i n the array model described by equation 5 i s s t r a i g h t f o r w a r d to d e r i v e f o r the binormal d i s t r i b u t i o n (see Appendix A for the d e r i v a t i o n ) : 411-o-a - d i e ; ! { 7 } Equation 7 i s recognizable as the Weibull d i s t r i b u t i o n of order 2 ( [ 1 5 ] , p . 1 2 8 ) , or as i t i s more commonly known, the Rayleigh d i s t r i b u t i o n ( [ 1 6 ] , pp. 8 1 and 3 1 3 ) . I t s mean i s ( i r ) 1 / 2 * and i t s standard d e v i a t i o n i s U - i r ) 1 ' ' 2 * . The d e f i n i n g parameter « can be estimated by examining the p r o b a b i l i t y of the dist a n c e d { i j } being between two given values: 28 {8} - e x p - exp This p r o b a b i l i t y d i s t r i b u t i o n i s i l l u s t r a t e d f o r various values of « i n f i g u r e I I . 3 - 2 . S t a l b e r g et a l obtained measurements of the i n t e r - f i b e r d i s t a n c e s f o r f i b e r s of the same motor u n i t using a s i n g l e f i b e r m u l t i - e l e c t r o d e [14]. The di s t a n c e s measured ranged from near zero ( f i b e r s s ide by side) up to 9 mm, with most being w i t h i n a much narrower range. They found that 5 out of 48 recordings made had maximum i n t e r - f i b e r d i s t a n c e s of 6 to 7 mm; thus 5/48 or approximately 10% of a l l di s t a n c e s should l i e between d, * 6 mm and d 2 = 7 mm, y i e l d i n g , as i l l u s t r a t e d i n f i g u r e I I . 3 - 2 , an estimate f o r a of 2.6 mm. This a i s admittedly a rough approximation, but the estimated value does generate a f i b e r array model with a t e r r i t o r y w i t h i n the range of motor u n i t s i z e s reported [11,10,12,13]. The m a j o r i t y of f i b e r s (68% t o 95%) are w i t h i n 2.6 mm to 5.2 mm of the motor u n i t center. This i s an acceptable motor u n i t s i z e , not very much l a r g e r i n terms of the d i s t r i b u t i o n of the m a j o r i t y of the f i b e r s than the motor u n i t model chosen by Boyd [7] and others [ 1 8 ] . 30 I I . 4 Sampling Near the F i b e r Array Center There i s no a c t u a l "outside" to the binormally d i s t r i b u t e d f i b e r a r r a y , yet i t i s p o s s i b l e to s e l e c t a recording s i t e f a r enough from a l l d i p o l e s f o r the fa r f i e l d approximations made by Boyd to be a p p l i c a b l e , y i e l d i n g the p r e d i c t e d r e s u l t s . Indeed, f o r r e cording distances greater than three «, i t i s h i g h l y u n l i k e l y that a chosen recording s i t e would be near any f i b e r s (equation 8 gives about a 0.3% p r o b a b i l i t y ) , and the s i t u a t i o n i s e s s e n t i a l l y no d i f f e r e n t than being outside Boyd's uniform c i r c u l a r d i s t r i b u t i o n of f i b e r s . From c l i n i c a l experience however, i t i s apparent that the p r e d i c t i o n s made from the f a r f i e l d approximations are i n c o r r e c t . To be able to record a smooth SMUAP w i t h i n three c of the motor u n i t center i m p l i e s the a b i l i t y to l o c a t e areas free of f i b e r s of a c e r t a i n minimal s i z e i n which to place the recording e l e c t r o d e . Using the binormal d i s t r i b u t i o n , a c l o s e approximation can be made of the p r o b a b i l i t y of f i n d i n g such an area at a given radius from the motor u n i t center (see Appendix B f o r the d e r i v a t i o n ) : NO FIBERS WITHJtV ARB A OF RADIUS 6 / f - 6 exP\-+ret- + 7tt>*] ( JfFr0 L T BO-\ J {9} 6 i s the radius of the free area, r 0 i s the r a d i a l 31 c o o r d i n a t e of the r e c o r d i n g s i t e ( e 0 i s unimportant because of symmetry), N i s the number of f i b e r s i n the motor u n i t ( t y p i c a l l y 163 f i b e r s [7]) and * i s the standard d e v i a t i o n of the motor u n i t d i s t r i b u t i o n (2.6 mm). The graph of f i g u r e II.4-1 i l l u s t r a t e s t h i s p r o b a b i l i t y f u n c t i o n more c l e a r l y . Note the high p r o b a b i l i t y of f i n d i n g f a i r l y l a r g e f r e e areas ( r a d i i of 0.325 mm to 0.650 mm) w i t h i n two c (5.6 mm) of the motor u n i t c e n t e r . These curves represent the p r o b a b i l i t y of f i n d i n g a f r e e area of a c e r t a i n s i z e given the r e c o r d i n g r a d i u s . The a c t u a l s i z e of the f r e e area needed depends on the l o c a l d i s t r i b u t i o n of f i b e r s ; a s i n g l e f i b e r can be much c l o s e r to the r e c o r d i n g s i t e than a group of two or more c l u s t e r e d f i b e r s before the SMUAP becomes dominated by SFAPs. Experience with the s i m u l a t i o n model has shown s u i t a b l e areas are of the order of 1.0 mm i n diameter and can o f t e n be l o c a t e d even at the motor u n i t c e n t e r . F i g u r e II.4-2 shows SMUAPs generated f o r i n c r e a s i n g r e c o r d i n g s i t e r a d i a l d i s t a n c e s using the b i n o r m a l l y d i s t r i b u t e d a r r a y of f i g u r e II.2-1. The r e c o r d i n g s i t e s where chosen to be at f i x e d r a d i a l d i s t a n c e s from the motor u n i t c e n t e r , but the angular c o o r d i n a t e s were chosen so that the s i t e was i n as l a r g e a f r e e area as c o u l d be found. I t was u s u a l l y p o s s i b l e to f i n d such f r e e areas and to r e c o r d smooth b i p h a s i c SMUAPs — SMUAPs not dominated by nearby s i n g l e f i b e r s . In a c t u a l p r a c t i c e the c l i n i c i a n moves the r e c o r d i n g e l e c t r o d e w i t h i n the muscle u n t i l a s u i t a b l e SMUAP i s l o c a t e d ; 3 ^ 0.0 1.3 2.6 3.9 5.2 6.5 7.8 9J 10.4 RADIAL POSITION, r0. FROM Ml) CENTER [mm] F i g u r e I I . 4 - 1 The f r e e a r e a p r o b a b i l i t y d i s t r i b u t i o n F i g u r e I I . 4 - 2 B i n o r m a l l y d i s t r i b u t e d f i b e r a r r a y SMUAPs w i t h a x i a l d i s p e r s i o n o = 0 . 7 m.m. CSJ MSECS ( f ) R = 6.0000 o CD CD ! CO 1 1 1 1 1 1 - 1 0 0 - 6 66 - 3 . 3 3 - 0 . 0 3 . 3 3 6 . 6 6 10.0 MSECS (g) 38 an example of such a SMUAP i s shown i n f i g u r e II.4-3. In comparing i t with the p o t e n t i a l s of f i g u r e II.4-2 i t i s evident that the i n s i t u p o t e n t i a l , with a peak to peak d u r a t i o n of approximately 1.0 msec, would have to have been recorded l e s s than 2.25 mm from the cent e r of the motor u n i t of f i g u r e II.2-1, w e l l " w i t h i n " the motor u n i t t e r r i t o r y . ^ A M P L I T U D E F i g u r e II.4-3 An i n s i t u s i n g l e mo to r u n i t a c t i o n p o t e n t i a l 40 II.5 SMUAP Amplitude and D u r a t i o n F i v e b i n o r m a l l y d i s t r i b u t e d motor u n i t f i b e r a r r a y s were used to generate SMUAPs recorded from s i t e s at ten d i f f e r e n t r a d i a l d i s t a n c e s , 0.5 mm to 12.0 mm from the f i b e r a r r a y c e n t e r . A number of f i b e r a r r a y s were used i n order to average out random v a r i a t i o n s due to f i b e r s nearby a r e c o r d i n g s i t e i n a p a r t i c u l a r a r r a y . In a few unavoidable cases the s e l e c t i o n of a s i t e produced p o t e n t i a l s o b v i o u s l y dominated by SFAPs which had to be d i s c a r d e d . The l o g of the peak to peak amplitude versus the l o g of the sampling r a d i u s f o r the SMUAPs simulated are p l o t t e d i n f i g u r e II.5-1 with three values of a x i a l d i s p e r s i o n (0.0, 0.7, 1.4 mm). F i g u r e II.5-2 shows a l e a s t mean squares cu b i c s p l i n e f i t to these p o i n t s [17] to i l l u s t r a t e the t r e n d i n the SMUAP peak to peak amplitude with i n c r e a s i n g r a d i u s : the curves a s s y m p t o t i c a l l y approach a s t r a i g h t l i n e with a slope of -2 f o r r a d i a l d i s t a n c e s greater than about two a. T h i s l i n e r e p r e s e n t s the 1/x2 r e l a t i o n s h i p between peak to peak amplitude and r a d i u s p r e d i c t e d by the f a r f i e l d approximations. For s m a l l e r r a d i a l d i s t a n c e s (r < 2<t) the peak to peak amplitude versus peak to peak d i s t a n c e r e l a t i o n s h i p can no longer be approximated by the f a r f i e l d r e l a t i o n . As the r e c o r d i n g s i t e i s moved c l o s e r to the cente r of the f i b e r a r r a y , the d e n s i t y of the f i b e r s i n c r e a s e s , and the s i t e comes w i t h i n the f i e l d s of more and more of the f i b e r s . While the sampling s i t e s are chosen so that the p o t e n t i a l s recorded are s t i l l smooth and b i p h a s i c , as i n f i g u r e II.4-2, the peak to peak LOG (P-P AMPLITUDE) VS LOG (RADIAL DISTANCE) MOTOR UNJTlSli 25. 26. 27. 28. 29J VHRJRTJON 6.0 3 11XJAL DISPERSIONS. CD a 3 a. ! o_ D o — o A — 0.7000 + — 3.4000 © CD A CD + + + © + 2 + + 9 -0 .4 1 1 1 1 "I 0 .4 3-2 2.0 LOG IRADIRL DISTANCE] F i g u r e I I . 5 - 1 SMUAP l o g a m p l i t u d e v s . l o g r a d i a l d i s t a n c e Ah LOG IP-P AMPLITUDE) VS LOG (RADIAL DISTANCE) MOTOR UNJTlSJi 25. 26- 27. 2fl. 23; VfRJflnON 6.0 3 AXJflL DJSPERSJONS. CO N"1 U J Qu l 0-O 1 1 r— 0.4 J.2 LOG CRADIAL D I 5 T R N C E ) - l 2.0 -0.4 Figure II.5-2 Cubic spline L.M.S. f i t to figure II.5-1 43 amplitude of the generated SMUAP i s l e s s dependent on the r a d i a l d i s t a n c e between the f i b e r a r r a y c e n t e r and the r e c o r d i n g s i t e . Instead, the SMUAP amplitude i s i n f l u e n c e d mainly by the aggregate of nearby f i b e r s and the d i s t a n c e to each SFAP from the r e c o r d i n g s i t e . The d u r a t i o n of the SMUAPs generated e x h i b i t s s i m i l a r dependencies. The p l o t s of the l o g of the peak to peak d u r a t i o n versus the l o g of the sampling r a d i u s i n f i g u r e s II.5-3 and II.5-4 shows that f o r l a r g e r a d i a l d i s t a n c e s the r e l a t i o n s h i p i s a s s y m p t o t i c a l l y l i n e a r , i n agreement with the f a r f i e l d approximation. Again, as the r e c o r d i n g s i t e s move nearer to the f i b e r a r r a y c e n t e r , the SMUAP d u r a t i o n becomes more independent of the r a d i a l sampling d i s t a n c e and more dependent on the near f i e l d s of the proximal f i b e r s . I t i s s i g n i f i c a n t that smooth b i p h a s i c SMUAPs can be recorded near the center of the f i b e r a r r a y , w i t h i n the near f i e l d s of many of the f i b e r s i n the a r r a y . In t h i s r e g i o n the f a r f i e l d approximations n a t u r a l l y no longer h o l d . I t i s evident that the SMUAPs recorded are i n f l u e n c e d l a r g e l y by the l o c a l d i s t r i b u t i o n of f i b e r s and the SFAPs they generate. The s p l i t t i n g of the curves i n f i g u r e s II.5-2 and II.5-4 exemplify t h i s s i t u a t i o n . For each i n c r e a s e i n the a x i a l d i s p e r s i o n the displacement of the SFAPs along the f i b e r a x i s becomes an i n c r e a s i n g l y more s i g n i f i c a n t component of the r a d i a l d i s t a n c e between the SFAPs and the r e c o r d i n g s i t e s . The SMUAPs thus recorded have lower amplitude and longer d u r a t i o n due to the out of phase c a n c e l l a t i o n of the d i s p e r s e d SFAPs. For SMUAPs o I M * LOG (P-P DURATION) VS LOG (RADIAL DISTANCE) MOTOR UNIT'S]; 25. 26. 21. 28. 23: VHUBTJON 6.0 3 JUJAl DISPERSIONS. © A + 0 0.7000 3 .4)00 D a Q_ t Q_ ID o + A a • i + A CD + © + A A © © -0.4 T 1 " 1— LOG *1RflDIRL DISTANCE) —l 2.0 Figure II.5-3. SMUAP log durat ion v s . log rad ia l d istance 4 £ LOG tP-P DURATION) VS LOG IRAOIFIL DISTANCE] fCTOR UNIT 1531 25. 26. 27. 28. 29; VRRIflHON 6.0 3 flXJtt. DJSPERSJONS. Q D _ i ol CD o I tM ~ i r 1 1 n -0 4 0 .4 J-2 2.0 LOG (RRDJRL DISTANCE) Figure II.5-4 Cubic spline L.M.S. f i t to figure II.5-3 46 recorded at l a r g e r a d i a l d i s t a n c e s , the p o s i t i o n a l d i f f e r e n c e s of SFAPs along the f i b e r a r r a y a x i s are much l e s s s i g n i f i c a n t compared to the o v e r a l l r a d i a l d i s t a n c e of the r e c o r d i n g s i t e — the curves of f i g u r e s II.5-2 and II.5-4 thus converge. 4 7 II.6 SMUAP Amplitude'versus Duration The peak to peak amplitude versus peak t o peak d u r a t i o n r e l a t i o n s h i p f o r SMUAPs generated with the binormal motor u n i t model i s c l o s e r t o that found by Mackinnon et a l i n the c l i n i c a l s i t u a t i o n than the behaviour p r e d i c t e d by Boyd. F i g u r e s II.6-1 and II.6-2 show a l o g - l o g p l o t of the two q u a n t i t i e s from s e c t i o n 5 and l e a s t mean square l i n e a r f i t s to the data f o r each a x i a l d i s p e r s i o n . The data p o i n t s of f i g u r e II.6-1 are average values obtained from f i v e or l e s s SMUAPs. The unweighted l e a s t mean square f i t s of f i g u r e II.6-2 are c a l c u l a t e d from the h i g h l y v a r i a b l e o r i g i n a l data, and are perturbed from the t r e n d of the averages. Even so, the slopes of the f i t s are s i g n i f i c a n t l y smaller than -2.0 f o r the expected a x i a l d i s p e r s i o n of 0.7 mm. LOG CP-P AMPLITUDE) VS LOG CP-P DURATION) MOTOR UNIT'S]i 25. 26. 27. 28. 29i VARIATION 6.0 3 AXIAL DISPERSIONS. CD t\i" fM UJ a 3 a_ t t9 © — 0 A — 0.7000 . — 3.4000 CO o + A 0 + 3 * — r r -3.2 . - o * L Q G I P - P DURATION) - r — 1 1 i 0.4 3.2 F i g u r e II.6-1 SMUAP l o g a m p l i t u d e v s . l o g d u r a t i o n LOG CP-P AMPLITUDE) VS LOG CP-P DURATION) MOTOR UNJTlMt 25. 26. 27 . 28 . 29* VARIATION 6.0 3 flXIft. DISPERSIONS. CD O CM" a 3 Q_ cx Q -l a 9--1.2 LOG CP-P DURATION) F i g u r e I I . 6 - 2 L i n e a r L . M . S . f i t t o f i g u r e I I . 6 -50 II. 7 E f f e c t s of A n i s o t r o p i c Conducting Medium The s i m u l a t i o n r e s u l t s presented so f a r have been generated wit h the assumption that the impedance of the medium surrounding f i b e r s i n the motor u n i t i s homogeneous and i s o t r o p i c . Evidence provided by Rosenfalck [19] suggests that because muscle t i s s u e i s comprised of p a r a l l e l c y l i n d r i c a l f i b e r s , the e x t r a - f i b e r impedance i s a c t u a l l y c y l i n d r i c a l l y a n i s o t r o p i c . A survey by Geddes and Baker [20] reports measured a x i a l to r a d i a l c o n d u c t i v i t y r a t i o s from 1.8 to 14.4 f o r s k e l e t a l muscle. The average r a t i o they report i s 5.6, which i s c l o s e to the value of 5.0 used by Rosenfalck i n d e r i v i n g the f o l l o w i n g equation f o r approximating the e f f e c t of anisotropy on the p o t e n t i a l f i e l d c a l c u l a t e d f o r an i s o t r o p i c medium: ^AHlSOTROPtCK ' 1 ^ISOTROPIC ' {10} Figures II.7-1 I I . 7 - 2 , I I . 7 - 3 , II.7-4, II.7-5 and II.7-6 show the r e s u l t s of the simulated a n i s o t r o p i c medium. The r e l a t i v e decrease i n r a d i a l c o n d u c t i v i t y has the e f f e c t of spreading the e f f e c t i v e r a d i a l d i s t a n c e s between each of the f i b e r s , and between the f i b e r s and the recording s i t e . For l a r g e r a d i a l recording d i s t a n c e s the e f f e c t of the increased r a d i a l c o n d u c t i v i t y i s s m a l l . Closer to the f i b e r array center the increased e f f e c t i v e r a d i a l distances decreases the s i g n i f i c a n c e of the a x i a l d i s p e r s i o n of the SFAPs. The SI LOG CP-P AMPLITUDE) VS LOG CRADIAL DISTANCE) HO TOR UNIT 191• 25. 26 . 27. 28 . 23i VRRIRTJON C J 3 flXJUL DISPERSIONS. o © + — 0 — 0 ."7000 — 3.4000 UJ - I s CE Q_ ! Q_ S + 8 + D I 9 9 -0 .4 9 T 1 7 7 LOG 4lRRDIRL DISTANCE) —l 2.0 F i g u r e I I . 7 - 1 SMUAP l o g a m p l i t u d e v s . l o g r a d i a l d i s t a n c e f o r a n i s o t r o p i c med ia LOG IP-P AMPLITUDE) VS LOG (RADIAL DISTANCE) MOTOR UNJTISD i 25. 26. 27. 28. 29i VARIATION 6.1 3 AXIAL DISPERSIONS. a CM" UJ HI* . 2 : 0 c r Q _ i ol CD o CM - 0 . 4 1 1 r— 0.4 1.2 LOG tRRDIRL DISTANCE) 2.0 F i g u r e I I . 7 - 2 C u b i c s p l i n e L . M . S . f i t t o f i g u r e I I . 7 - 1 LOG CP-P DURATION) VS LOG (RADIAL DISTANCE) MOTOR IMJTISJ-. 25. 26 . 27. 28. 29i VflRJflTJON 6.3 3 JWJHL DISPERSIONS. © + — 0 — 0.1000 — 3.4100 a DC -. Q_ 1 Q_ o + o a . i + O + + 6 © 1 -0 .4 T 0.4 1 — 3.2 -1 2.0 LOG IRRDIRL DJ5TRNCE1 Figure II.7-3 SMUAP log duration vs. log radial distance for anisotropic media LOG (P-P DURATIONJ VS LOG (RADIAL DISTANCE) MOTOR UNJTCSDi 25. 26. 27. 28. 29; VRRJRTJQN 6.3 3 flXJPL D3SPERSJOHS. a : a o_ i ti-cs o o . I CM -1 2.0 T - 0 . 4 1 r -0 4 1-2 LOG CRRDJRL DISTANCE) F i g u r e II.7-4 C u b i c s p l i n e L . M . S . f i t t o f i g u r e II.7-3 LOG (P-P AMPLITUDE) VS LOG (P-P DURATION) NOTOR UNJT13J; 25. 26. 21. 28. 29i VflRJRTJCW 6.3 3 flJCJUL DJSPERSJONS. GO — 0 A — 0.7000 + — 3.4000 UJ ay. o_ l 0_ U J o o i A CD a a 1 1 1 1 1 1 -j 2 -0.4 0- 4 1-2 LOG IP-P DURATION) F i g u r e II.7-5 SMUAP l o g a m p l i t u d e v s . l o g d u r a t i o n f o r a n i s o t r o p i c med ia 5% LOG CP-P AMPLITUDE] VS LOG CP-P DURATION] MOTOR UNIT-IS!'. 25. 26. 27. 28. 29* VARIATION 6.1 3 AXIAL DISPERSIONS. o i Figure II.7-6 Linear L.M.S. f i t to figure II.7-5 5 7 curves of f i g u r e s I I . 7 - 6 and I I . 7 - 5 are thus much c l o s e r together then i n the i s o t r o p i c s i m u l a t i o n s . The sl o p e s of the l e a s t mean squares f i t to the l o g peak t o peak amplitude versus the l o g peak to peak d u r a t i o n r e l a t i o n s h i p are decreased, approaching the 1/x r e l a t i o n s h i p c a l c u l a t e d from c l i n i c a l data with l e s s dependence on the a x i a l d i s p e r s i o n . 58 II.8 I n f l u e n c e of Nearby F i b e r s The r e l a t i v e l y l a r g e t e r r i t o r y covered by the modelled motor u n i t , and the e f f e c t s of a x i a l d i s p e r s i o n and an a n i s o t r o p i c conducting media s i g n i f i c a n t l y lowers the c o n t r i b u t i o n s to the SMUAP of those f i b e r s f a r from the re c o r d i n g s i t e . Depending on the d i s t a n c e between a given f i b e r and the r e c o r d i n g s i t e and, more imp o r t a n t l y , on the number of f i b e r s of the motor u n i t i n between, the c o n t r i b u t i o n made by that f i b e r to a recorded SMUAP can be n e g l i g i b l e . F i g u r e II.8-1 shows the drop o f f i n SMUAP root mean square (R.M.S.) power with e x c l u s i o n of a l l but the N f i b e r s nearest to the r e c o r d i n g s i t e . The a x i a l to r a d i a l c o n d u c t i v i t y r a t i o was 5.0 and the a x i a l was d i s p e r s i o n of 0.7 mm. Up to 45% of the f i b e r s f a r t h e s t from the re c o r d i n g s i t e can be neg l e c t e d with only a 10% decrease i n power, r e g a r d l e s s of the r a d i a l p o s i t i o n of the re c o r d i n g s i t e , and t h e r e f o r e , r e g a r d l e s s of the surrounding f i b e r d e n s i t y . S i m i l a r p l o t s of peak to peak amplitude and peak to peak d u r a t i o n versus the number of c l o s e s t c o n t r i b u t i n g f i b e r s i n f i g u r e s II.8-2 and II.8-3, r e s p e c t i v e l y , show that the 55% of the f i b e r s that are nearest to the r e c o r d i n g s i t e c o n t r i b u t e to over 90% of the SMUAP shape. The SMUAPs recorded are t h e r e f o r e i n f l u e n c e d mainly by the nearest 50% to 60% of the f i b e r s i n the motor u n i t ; a smal l m a j o r i t y of the motor u n i t f i b e r a r r a y d i s t r i b u t i o n . 100i 904 80H 70A 60 cr o o- 50 LO Z or ^ 40 30 20 10 e • e S3 A, • X • • S I x e x RADIAL POSITION OF ELECTRODE x -0.0 mm 0-1.198 mm B - 3.377 mm A-5.708 mm 04 20 AO 60 80 100 120 HO 160 NUMBER OF Fl BERS F i g u r e I I . 8 - 1 SMUAP R . M . S . power c o n t r i b u t e d by t h e n e a r e s t f i b e r s (cO X NUMBER OF FIBERS F i g u r e I I . 8 - 2 SMUAP a m p l i t u d e c o n t r i b u t e d by t h e n e a r e s t f i b e r s 100- e o x 9OH Q D • BO 8 OH 70" z o 2 60-O < UJ 40" o_ 30-20J 10-RADIAL POSITION OF E L E C T R O D E x -0.0 mm o-1.198 mm o - 3.377 mm A- 5.708mm 20 10 60 80 100 NUMBER OF F IBERS 120 U0 F i g u r e II.8-3 SMUAP d u r a t i o n c o n t r i b u t e d by t h e n e a r e s t f i b e r s 62 II.9 Human Motor Un i t Model: Synopsis In electromyography the SMUAPs of i n t e r e s t u s u a l l y have a t o t a l d u r a t i o n of l e s s than 16 m i l l i s e c o n d s . The major reason f o r t h i s l i m i t i s that the amplitude of a p o t e n t i a l r a p i d l y decreases to below the background nois e l e v e l as i t s d u r a t i o n i n c r e a s e s . The b i n o r m a l l y d i s t r i b u t e d motor u n i t f i b e r a r r a y model has shown that the s e l e c t e d SMUAPs are nominally taken from w e l l w i t h i n the d i s t r i b u t i o n of the f i b e r a r r a y . The l a r g e s t c o n t r i b u t i o n to these SMUAPs i s from the nearest 55% of the f i b e r s , some of which can be q u i t e near to the r e c o r d i n g s i t e and yet s t i l l produce a smooth b i p h a s i c recorded SMUAP. The n o n - l i n e a r dependence of both peak t o peak amplitude and peak to peak d u r a t i o n on the sampling r a d i u s excludes e i t h e r from p r o v i d i n g d i r e c t estimates of the d i s t a n c e from the motor u n i t c e n t e r t o the r e c o r d i n g s i t e , except f o r SMUAPs that might be recorded f a r from the motor u n i t f i b e r a r r a y c e n t e r . The r e l a t i o n s h i p of peak to peak amplitude versus peak to peak d u r a t i o n f o r a s e l e c t e d SMUAP i s c l o s e r to a d i r e c t i n v e r s e than an inverse square as p r e d i c t e d by the f a r f i e l d approximations. The exact r e l a t i o n s h i p , however, i s h i g h l y dependent on the a x i a l d i s p e r s i o n of the SFAPs, the a x i a l to r a d i a l c o n d u c t i v i t y r a t i o of the surrounding conducting medium, and the c r o s s s e c t i o n a l d e n s i t y of the f i b e r a r r a y given by the number of f i b e r s i n the ar r a y and the spread of the f i b e r d i s t r i b u t i o n . B e t t e r estimates of the a x i a l d i s p e r s i o n and the a x i a l and r a d i a l c o n d u c t i v i t i e s are needed before q u a n t i t a t i v e r e s u l t s can be a c c u r a t e l y measured from the peak to peak amplitude versus 63 peak to peak d u r a t i o n r e l a t i o n s h i p of s i n g l e motor u n i t a c t i o n p o t e n t i a l s . 64 I I I . Real Time P r o c e s s i n g of EMG S i g n a l s III.1 I n t r o d u c t i o n The p r o c e s s i n g of electromyographic s i g n a l s t o f a c i l i t a t e r e a l time a n a l y s i s of s i n g l e motor u n i t a c t i o n p o t e n t i a l s r e q u i r e s a system that minimizes the volume and complexity of the recorded data. T h i s system must process the EMG s i g n a l i n r e a l time, s e p a r a t i n g ocurrences of the SMUAP of i n t e r e s t to the electromyographer from unwanted EMG a c t i v i t y and system noise and s t o r e the reduced data f o r subsequent a n a l y s i s . To be p r a c t i c a l , t h i s p r e p r o c e s s i n g system must perform the se p a r a t i o n of SMUAPs with a r e c o g n i t i o n accuracy at l e a s t as good as an experienced electromyographer. I t must a l s o operate with a minimum of operator i n t e r a c t i o n , and be co s t e f f e c t i v e to appeal t o both h o s p i t a l s and i n d i v i d u a l p h y s i c i a n s . A c h i e v i n g these c r i t e r i a i n v o l v e s t r a d e o f f s d i c t a t e d mostly by the complex nature of the recorded EMG a c t i v i t y . A t y p i c a l , n o i s y , segment of recorded EMG a c t i v i t y , shown i n f i g u r e I I I . 1 - 1 , c o n s i s t s of a number of SMUAP t r a i n s and a h i g h l y v a r i a b l e l e v e l of background n o i s e . For the purposes of a n a l y s i s , the noise i s c o n s i d e r e d to c o n s i s t of two separable components: white noise of r e l a t i v e l y low power, and a predominantly low frequency component h e r e a f t e r r e f e r r e d to as the " b a s e l i n e " . The b a s e l i n e c o n s i s t s of a d.c. l e v e l due to a m p l i f i e r o f f s e t s i n the r e c o r d i n g apparatus and random l e v e l v a r i a t i o n s due to e l e c t r o d e movement, heart and nerve a r t i f a c t s , and a r t i f a c t s from very d i s t a n t motor u n i t s . T h i s conglomerate noise s i g n a l i s u s u a l l y of n e g l i g i b l e amplitude, but i t can vary 6 6 throughout a r e c o r d i n g s e s s i o n when, f o r example, a s u b j e c t moves to r e l i e v e f a t i g u e . The SMUAPs are normally b i or t r i p h a s i c , though some monophasic and p o l y p h a s i c p o t e n t i a l s do occur, p a r t i c u l a r i l y i n di s e a s e d muscle. SMUAP amplitudes can vary from a few m i c r o v o l t s to gr e a t e r the f i v e m i l l i v o l t s and t h e i r t o t a l d u r a t i o n s can vary from three to s i x t e e n m i l l i s e c o n d s . Nonetheless, the a c t i o n p o t e n t i a l from a s i n g l e motor u n i t does have a d i s t i n c t i v e shape that remains r e l a t i v e l y constant f o r c o n t r o l l e d low l e v e l c o n t r a c t i o n s over s h o r t p e r i o d s of time. At low c o n t r a c t i o n l e v e l s the t r a i n s of SMUAPs have r e p e t i t i o n p e r i o d s of 50 to 200 m i l l i s e c o n d s [ 2 , 3 ] . There i s t h e r e f o r e up to 20 times as much unwanted s i g n a l — the s i g n a l that i s .present between occurrences of the SMUAP — as there are a c t i o n p o t e n t i a l s from a p a r t i c u l a r motor u n i t under the s t a t e d c o n d i t i o n s . In a t t a i n i n g the a q u i s i t i o n and storage of the SMUAPs of i n t e r e s t the f i r s t p r i o r i t y i s to minimize the amount of storage necessary without d i s c a r d i n g any i n f o r m a t i o n c o n t a i n e d i n the SMUAP waveform. T h i s can done by reducing the sampling r a t e , which reduces the amount of data per time i n t e r v a l of r e c o r d i n g that must be s t o r e d , and by e x t r a c t i n g and s t o r i n g o n l y the segments of the EMG s i g n a l c o n t a i n i n g the d e s i r e d SMUAPs. The l a t t e r o p e r a t i o n alone w i l l reduce the amount of data to be s t o r e d on the average by a f a c t o r of about t e n . 67 III.2 Waveform Re c o g n i t i o n Techniques The development of r e c o g n i t i o n techniques f o r b i o e l e c t r i c waveforms has been s e v e r e l y l i m i t e d by the complexity of the s i g n a l s being processed and the short-comings of a v a i l a b l e technology. Many e a r l y attempts were r e s t r i c t e d to o f f - l i n e p r o c e s s i n g , with the hope that the technology would be developed to perform the same p r o c e s s i n g i n r e a l time. To a great extent the necessary t e c h n o l o g i c a l improvements have been made, but at the same time the development of s i g n a l p r o c e s s i n g theory and the i n c r e a s e i n demands on the performance of such systems has made newer approaches more f e a s i b l e . The s i m p l e s t methods i n v o l v e d amplitude t h r e s h o l d d e t e c t i o n , but the e f f e c t s of background noise l i m i t e d the performance of systems based s o l e l y on t h i s c r i t e r i a ; attempts were made to augment the t h r e s h o l d i n f o r m a t i o n , or at l e a s t improve i t s r e l i a b i l i t y . Schmidt [21,22] used two s e t s of upper and lower t h r e s h o l d s — two amplitude "windows" -- on the assumption that the p r o b a b i l i t y of s i m u l t a n e o u s l y t r i g g e r i n g both windows by an i n c o r r e c t s i g n a l would be low. I n t e r a c t i v e s e t t i n g of the i n i t i a l window amplitude l e v e l s and widths, and time spacing improved the r e l i a b i l i t y of Schmidt's system, but only as long as the v a r i a t i o n i n the s i g n a l waveform d u r i n g p r o c e s s i n g was r e l a t i v e l y s m a l l . U t i l i z i n g known c h a r a c t e r i s t i c s of the s i g n a l to be d e t e c t e d , H o l s i n g e r et a l [23] d i f f e r e n t i a t e d e l e c t r o c a r d i o g r a p h i c (ECG) s i g n a l s and searched f o r the occurrence of peaks due to the f a s t r i s i n g edge of the QRS 68 complex. C a r r i e [24] used the second d e r i v a t i v e of e l e c t r o e n c e p h a l o g r a p h (EEG) s i g n a l s to d e t e c t the sharp cur v a t u r e of neuronal s p i k e s . Others combined s i g n a l amplitude and d e r i v a t i v e t h r e s h o l d s , s i g n a l d u r a t i o n and r e p e t i t i o n times [25,26,27,28], onset and o f f s e t times [29,30,31], zero c r o s s i n g r a t e s of both the s i g n a l and the d e r i v a t i v e s of the s i g n a l [31,27,32] or r a t e s of r e p e t i t i o n of the waveform [33,25,34,35] to i n c r e a s e the r e c o g n i t i o n accuracy of t h e i r systems. The frequency domain was a l s o u t i l i z e d to o b t a i n waveform f e a t u r e s . T o t a l s p e c t r a l energy [32], s p e c t r a l moments [36], and peak f r e q u e n c i e s [32,37,38] were used, o f t e n i n combination with f e a t u r e s i n the time domain [32,39]. The number of f e a t u r e s that might be e x t r a c t e d from a given waveform i s l a r g e , but the u s e f u l n e s s of many f e a t u r e s i s l i m i t e d . Two seemingly d i f f e r e n t measurements might p r o v i d e e s s e n t i a l l y the same i n f o r m a t i o n , and c o u l d even be a n a l y t i c a l l y e q u i v a l e n t . For example, H j o r t h [40] d e v i s e d three parameters that he named: " A c t i v i t y " — the mean square s i g n a l power; " M o b i l i t y " — the normalized mean squared power of the s i g n a l ' s d e r i v a t i v e ; and "Complexity" — the mean square power of the s i g n a l ' s second d e r i v a t i v e normalized by the " M o b i l i t y " . He r e l a t e d these three parameters to the even order moments of the power s p e c t r a l d e n s i t y through the even ordered d e r i v a t i v e s of the s i g n a l a u t o - c o r r e l a t i o n f u n c t i o n e v a l u a t e d at zero d e l a y . H i s frequency domain parameters corresponded d i r e c t l y with time domain f e a t u r e s and were r e l a t e d to more h e u r i s t i c f e a t u r e s of the waveform: A c t i v i t y was a measurement of the average waveform 69 amplitude; M o b i l i t y was the average energy of the r e l a t i v e waveform s l o p e s ; and Complexity was a measure of the r e l a t i v e waveform c u r v a t u r e s . These same three parameters were l a t e r shown by S a l t z b u r g and Burch [36] to be o b t a i n a b l e from the frequency of zero c r o s s i n g s of the waveform and i t s f i r s t and second d e r i v a t i v e s . The f e a t u r e s to be used must be s e l e c t e d c a r e f u l l y , e s p e c i a l l y when m u l t i p l e s i g n a l spaces, such as the time and frequency domains, are being c o n s i d e r e d . There i s at present no d e t e r m i n i s t i c method f o r s e l e c t i n g the* best f e a t u r e s f o r r e c o g n i z i n g a waveform; as s t a t e d by McEwen et a l : " i n s e l e c t i n g f e a t u r e s f o r a s p e c i f i c p a t t e r n r e c o g n i t i o n problem experience has shown that a few w e l l chosen h e u r i s t i c a l l y d e r i v e d f e a t u r e s are u s u a l l y b e t t e r than a l a r g e r number chosen randomly ... p r i m a r i l y because p r o c e s s i n g many f e a t u r e s r e q u i r e s more computing time, more storage and more data" ( [ 3 2 ] , p300) Some attempts have been made to d e r i v e a procedure f o r i s o l a t i n g f e a t u r e s of a s i g n a l that would be i n v a r i a n t i n some sense to the c h o i c e of a p p l i c a t i o n . Template matching can be thought of as the g e n e r a l case of t h r e s h o l d d e t e c t i o n . The waveform i n q u e s t i o n was compared to the template and some estimate of the f i t , or more c o n c i s e l y , the m i s f i t , was c a l c u l a t e d and a d e c i s i o n was then made. The degree of m i s f i t was most o f t e n measured using the t o t a l mean square d i f f e r e n c e between the waveform and the template [41,6]. T h i s sum was 70 u n f o r t u n a t e l y s e n s i t i v e t o d i s t o r t i o n of the waveform by background n o i s e and intra-waveform v a r i a t i o n s — an a c c e p t a b l e waveform was too o f t e n r e j e c t e d because of the e f f e c t of small v a r i a t i o n s i n waveshape on the squared d i f f e r e n c e s . A more workable and a p p a r e n t l y more popular method was to use dual templates to provide upper and lower boundaries f o r the t e s t waveform to f i t w i t h i n . An e r r o r i s r e g i s t e r e d when e i t h e r of the boundaries are c r o s s e d [42,43]. These d u a l boundaries allow f o r g r e a t e r v a r i a t i o n i n the shape of the a c c e p t a b l e waveforms. In another technique the template was s t r e t c h e d i n d u r a t i o n and amplitude to f i t a given waveform; the amount of s t r e t c h i n g needed was used to i n d i c a t e the degree of s i g n a l m i s f i t [44,45,46]. The r e s u l t s from such systems e n t a i l e d e i t h e r a small number of recognized waveforms because of a l a r g e number of f a l s e r e j e c t i o n s , or a l a r g e number of recognized waveforms contaminated by many f a l s e acceptances [42,43,44,45,46]. More i n v e s t i g a t i o n i n t o the e v a l u a t i o n of m i s f i t i n these amplitude template matching schemes i s necessary. The c r o s s - c o r r e l a t i o n (CCF) f u n c t i o n a l s o p r o v i d e s i n f o r m a t i o n of the "match" between a template and a t e s t waveform. The c o r r e l a t i o n c o e f f i c i e n t , the magnitude of the CCF at zero d e l a y , i s equal to the mean square c r o s s power between the two s i g n a l s . The c o n v e n t i o n a l matched f i l t e r c o r r e l a t e s a pulse d i s t o r t e d with n o i s e with a template of the expected pulse shape. The r e s u l t a n t c o r r e l a t i o n c o e f f i c i e n t i s then compared to a s i n g l e t h r e s h o l d v a l u e , and a d e c i s i o n made. For the case 71 of d e t e c t i n g the occurrence of a s i n g l e p u l s e shape i n a d d i t i v e white Gaussian n o i s e , the matched f i l t e r can be shown to p r o v i d e the optimal d e t e c t i o n s i g n a l t o n o i s e r a t i o ( [ 4 7 ] , p 3 l l ) and the optimum p r o b a b i l i t y of d e t e c t i o n ( [ 4 7 ] , p314). With two or more pu l s e shapes (waveforms) i n a s i g n a l , a matched f i l t e r implementation i s s t i l l the optimal l i n e a r f i l t e r ( i n the Bayesian sense) f o r d i s t i n g u i s h i n g between occurrences of d i f f e r e n t waveforms when the waveform shapes are known [48]. The major d i f f i c u l t y with matched f i l t e r i n g of b i o l o g i c a l waveforms i s the l a c k of a p r i o r i knowledge of the waveform shape. T h i s has o f t e n been circumvented by using a sample waveform as the f i l t e r t r a n s f e r f u n c t i o n or template [49,50,46,42,51,52,53]. For waveforms that vary with time, an a d a p t i v e matched f i l t e r has been used, with the template .being updated c o n t i n u o u s l y by simple averaging of the d e t e c t e d waveforms [49,50]. Under c e r t a i n s i g n a l c o n d i t i o n s , the d e t e c t i o n accuracy of the a d a p t i v e matched f i l t e r has been re p o r t e d to be near optimum [28]. U n f o r t u n a t e l y , there i s a s i g n i f i c a n t i n c r e a s e i n the computation r e q u i r e d f o r a d a p t i v e matched f i l t e r i n g and most systems have been r e s t r i c t e d to slower software implementations [51,46,52,43,53], or to d i g i t a l hardware implementations r e s t r i c t e d to low sampling r a t e s and low b i t r e s o l u t i o n [49,50,26]. The c o r r e l a t i o n f u n c t i o n can be u t i l i z e d to p r o v i d e other i n f o r m a t i o n : M i cheal and Houchin [54] used the areas underneath the a u t o - c o r r e l a t i o n f u n c t i o n (ACF) curve, b e f o r e the f i r s t zero c r o s s i n g as an a d d i t i o n a l r e c o g n i t i o n f e a t u r e — these areas can 72 be r e l a t e d to the frequency components of the waveform [54,55]. The r a t e of decrease of the ACF was used by Gothman and Gloor [56] as an i n d i c a t o r of the "sharpness" of a g i v e n s i g n a l , to separate EEG s i g n a l s from EMG s i g n a l s and other s l o w l y v a r y i n g a r t e f a c t s . Weinberg and Cooper [52] used the c o r r e l a t i o n c o e f f i c i e n t s from a s i g n a l separated i n t o two frequency bands, thus y i e l d i n g the mean square power of the s i g n a l i n each band. The use of the c o r r e l a t i o n c o e f f i c i e n t to g i v e an i n d i c a t i o n of the r e l a t i o n s h i p between one waveform and another can be extended from simple template matching to the e s t i m a t i o n of the c o e f f i c i e n t s of a b a s i s f u n c t i o n expansion of the waveform [57,58]. Raeside [59] used F o u r i e r s e r i e s r e p r e s e n t a t i o n and obtained 96% r e p r e s e n t a t i o n of echocardiograph waveforms ( i n terms of mean square e r r o r ) with 21 components. Huggins and Young [60] obtained 95% r e p r e s e n t a t i o n of ECG waveforms with e i g h t components of the Kautz b a s i s (orthonormal, e x p o n e n t i a l l y damped s i n u s o i d s ) . Some re s e a r c h e r s have even attempted r e p r e s e n t a t i o n with non-orthogonal components such as Hamming c o s i n e f u n c t i o n s [61] and g e n e r a l e x p o n e n t i a l l y damped s i n u s o i d s [62]. A l l of the r e p r e s e n t a t i o n f u n c t i o n s e t s were h e u r i s t i c a l l y chosen and then t r u n c a t e d u s i n g sub-optimal methods. Before u s i n g a t r u n c a t e d b a s i s expansion r e p r e s e n t a t i o n of waveform, care must be e x e r c i s e d that those f e a t u r e s of the waveform of p h y s i o l o g i c a l s i g n i f i c a n c e are not d i s t o r t e d . C h r i s t e n s e n [63] has d e r i v e d a method to maximize the i n f o r m a t i o n r e t a i n e d by a t r u n c a t e d r e p r e s e n t a t i o n f o r a p a r t i c u l a r waveform f e a t u r e , but only f o r a 73 s i n g l e f e a t u r e and h i s method r e q u i r e s a p r i o r i p r o b a b i l i t i e s . General techniques f o r minimizing the d i s t o r t i o n of a waveform's features, have yet to be p u b l i s h e d . 74 I I I . 3 Proposed Real Time EMG P r o c e s s i n g System Many of the systems d e s c r i b e d f a i l to meet the requirements set out i n s e c t i o n 111.1 , e s p e c i a l l y f o r r e a l time p r o c e s s i n g of the EMG s i g n a l s . The major problems appear to be t h r e e f o l d : removal of background noise components that d i s t o r t the incoming SMUAP waveforms; d e t e c t i o n of the occurrence of SMUAP's to reduce data storage and subsequent p r o c e s s i n g time; and a n a l y s i s of the d e t e c t e d p o t e n t i a l s to c l a s s i f y those from a given s i n g l e motor u n i t . The proposed system design f o r r e a l time EMG s i g n a l p r o c e s s i n g c o n s i s t s of three stages. The f i r s t stage i s a l i n e a r f i l t e r i n g stage to reduce the bandwidth of the incoming s i g n a l , and to remove dominant noise components such as the b a s e l i n e v a r i a t i o n . The reduced bandwidth a l l o w s f o r a lower sampling rate to be used i n d i g i t i z i n g the EMG s i g n a l , thus minimizing the p r o c e s s i n g r a t e s of the subsequent stages. Removal of noise components improves the performance of the subsequent d e t e c t i o n and c l a s s i f i c a t i o n stages [64]. The next stage i s an adaptive matched f i l t e r [49,50] that combines d e t e c t i o n and c l a s s i f i c a t i o n by s e l e c t i n g incoming SMUAPs only i f they c o r r e l a t e w e l l with a template r e p r e s e n t i n g a p o t e n t i a l from a p a r t i c u l a r motor u n i t . To augment the c l a s s i f i c a t i o n of p o t e n t i a l s s e l e c t e d by the adaptive matched f i l t e r , the t h i r d stage i s a p a t t e r n c l a s s i f i e r that c l u s t e r s p h y s i o l o g i c a l l y s i g n i f i c a n t f e a t u r e s of the p o t e n t i a l s , chosen a c c o r d i n g to the c r i t e r i a set out i n [32]. 75 III.4 E s t i m a t i o n of the EMG S i g n a l Spectra Knowledge of the SMUAP waveform s i g n a l spectrum and of the b a s e l i n e n o i s e spectrum f a c i l i t a t e d the design of l i n e a r f i l t e r s to e l i m i n a t e most of the unwanted nois e s p e c t r a . T h i s reduced the background noise components i n the SMUAP waveforms, and allowed the sampling r a t e to be lowered to the Nyquist r a t e ( [ 4 7 ] , p.68). For the s p e c t r a l a n a l y s i s i t was assumed that both the SMUAP waveforms and the b a s e l i n e v a r i a t i o n s were wide sense s t a t i o n a r y (Koopmans [65], Bendat and P i e r s o l [ 6 6 ] ) . For the usual EMG s i g n a l recorded under c o n t r o l l e d c o n d i t i o n s with low l e v e l c o n t r a c t i o n s over short i n t e r v a l s (on the order of ten seconds) t h i s i s a reasonable assumption. The mod i f i e d Blackman-Tukey method, given by Yeun [67] was used to estimate the power s p e c t r a l d e n s i t i e s (PSDs) of the f u l l EMG s i g n a l and the b a s e l i n e n o i s e . The EMG s i g n a l s used i n t h i s p r o j e c t were recorded by Mackinnon [6] from both normal and d i s e a s e d b i c e p s b r a c h i i muscle at low c o n t r a c t i o n l e v e l s . The r e c o r d i n g s were made at Vancouver General H o s p i t a l under the s u p e r v i s i o n of an experienced n e u r o l o g i s t 2 . A standard needle e l e c t r o d e f o r intramuscular r e c o r d i n g (DISA ELEKTRONIK 13L31) was used along with a DISA, 3 channel Electromyograph Type 14A30 [2] to amp l i f y and d i s p l a y the EMG a c t i v i t y . The s i g n a l was b a n d l i m i t e d to between 2 Hz (by f i l t e r s w i t h i n the DISA) and 10 KHz (by a Khronhite f i l t e r , model 3342R), then sampled at 20 KHz using a 2 D r . P.J.A. B r a t t y , C l i n i c a l A s s o c i a t e P r o f e s s o r of Medicine (Neurology), U n i v e r s i t y of B r i t i s h Columbia. 76 PDP 11/20 equipped with an analog to d i g i t a l c o n v e r t e r . The 10 b i t d i g i t i z e d data was s t o r e d i n approximately eleven second records — one f o r each r e c o r d i n g — on nine t r a c k magnetic tape f o r l a t e r a n a l y s i s [ 2 , 6 ] . The eleven second time l i m i t f o r each r e c o r d i n g was due to computer memory c o n s t r a i n t s [ 6 ] . The data tapes prepared were t r a n s p o r t e d to the NOVA 840 computer f a c i l i t y at the U.B.C§. Department of E l e c t r i c a l E n g i n e e r i n g where a n a l y s i s of the EMG data was more convenient. Programs were w r i t t e n f o r reading and p r o c e s s i n g the data tapes i n NOVA F o r t r a n and assembler, and are given i n Appendix F. S p e c t r a l e s t i m a t i o n was f i r s t a p p l i e d to the f u l l eleven second EMG records, p r o v i d i n g a t o t a l power s p e c t r a l d e n s i t y (PSD) f o r the SMUAPs p l u s the background noise (Koopman [65], p.55), an example of which i s shown i n f i g u r e I I I . 4 - 1 . To estimate the PSD of the base l i n e v a r i a t i o n , the EMG s i g n a l was f i r s t band l i m i t e d to 833.33 Hz u s i n g a 127 p o i n t optimal FIR f i l t e r (see Appendix C ) . Band l i m i t i n g the s i g n a l allowed the sampling r a t e to be reduced to 1.6667 KHz 3 and the r e s o l u t i o n of the d i s c r e t e f o u r i e r transform (DFT) used i n the e s t i m a t i o n to be i n c r e a s e d — a DFT of 512 p o i n t s y i e l d e d a s p e c t r a l r e s o l u t i o n of 3.255 Hz. Next, the SMUAP s p e c t r a l component was removed from t h i s estimate by s e g r e g a t i n g and p r o c e s s i n g those s e c t i o n s of EMG s i g n a l t h a t c o n t a i n e d background noi s e o n l y , with no SMUAPs. T h i s was done 3These unusual values r e s u l t e d from an odd sub-sampling r a t i o chosen a c c o r d i n g to i n c o r r e c t i n f o r m a t i o n on the o r i g i n a l sampling r a t e of the data c o l l e c t e d , however they are a c c u r a t e and more then s u f f i c i e n t f o r the a n a l y s i s . CM 78 i n t e r a c t i v e l y using a T e k t r o n i x 4010 g r a p h i c s t e r m i n a l a t t a c h e d to the NOVA 840. According to Koopman ( [ 6 5 ] , p332), the e f f e c t of m i s s i n g data on the estimated PSD can be n e g l e c t e d i f the m i s s i n g segments are small compared to the o v e r a l l l e n g t h of the data sequence used. T h i s i s the case with the EMG s i g n a l s examined, f o r even with three SMUAPs present i n the r e c o r d (the g r e a t e s t number found i n the r e c o r d i n g s obtained from VGH) there was u s u a l l y at l e a s t three times as much s i g n a l c o n t a i n i n g background noise only as there was s i g n a l with d i s t i n c t SMUAPs pre s e n t . F i g u r e III.4-2 shows an example of the background nois e PSD. The white noise spectrum has, by d e f i n i t i o n , a constant PSD v a l u e , given i n f i g u r e III.4-2 by the -145 dB l e v e l at high f r e q u e n c i e s . The b a s e l i n e v a r i a t i o n c o n s i s t s l a r g e l y of the low frequency components between 0 and 20 Hz, more c l e a r l y shown i n f i g u r e I I I . 4 - 3 , an expanded p l o t of the PSD of f i g u r e III.4-2 from 0 to 200 Hz. PSDs f o r the f u l l EMG s i g n a l and f o r the b a s e l i n e noise alone were estimated f o r a number of the EMG data records, and the r e s u l t i n g spectrums a l l i n d i c a t e d that the b a s e l i n e spectrum exceeded the SMUAP spectrum f o r f r e q u e n c i e s l e s s than 30 Hz. Thus, much of the b a s e l i n e v a r i a t i o n power can be f i l t e r e d o f f by a high pass f i l t e r with a c u t o f f frequency of around 30 Hz without a f f e c t i n g the SMUAP waveforms. In order to o b t a i n a s i g n i f i c a n t r e d u c t i o n of the b a s e l i n e , the a t t e n u a t i o n of the f i l t e r below 30 Hz should i d e a l l y be at l e a s t 80 dB by 15 Hz, implying a 250 dB/decade r o l l o f f . TAPE 1 RECORD 1 — BACKGROUND NOISE POWER SPECTRUM (DB) i r 0.0 50.0 100.0 ]S0.0 200.0 251,.. FREQUENCr (HZ) (X! F i g u r e I I I . 4 - 2 E s t i m a t e d PSD f o r b a c k g r o u n d n o i s e f r o m r e c o r d e d EMG a c t i v i t y 450.0 5oo.o r£ TRPE 1 RECORD 1 — BASELINE VARIATION POWER SPECTRUM (DB) o» 20.0 40.0 Figure III.4-3 60.0 60.0 100.0 120.0 FREQUENCY" (HZ) (X)O 1 ) 200.0 Estimated PSD for base line component of recorded EMG activity 81 An i n i t i a l estimate of the upper c u t o f f frequency f o r the SMUAP spectrum was given by Mackinnon as being l e s s than 4.5 KHz [6 ] . T h i s estimate was used f o r a p r e l i m i n a r y implementation of the f i r s t two stages of the EMG processor d e s i g n , and a number of SMUAPs were e x t r a c t e d from s e v e r a l EMG r e c o r d s . The s e t s of SMUAPs obtained from each r e c o r d were averaged and the power s p e c t r a l d e n s i t y estimated by t a k i n g the magnitude squared of a ^  512 p o i n t DFT of each average waveform. In the r e s u l t i n g PSDs, such as the example presented i n f i g u r e I I I . 4-4, the SMUAP spectrum drops below the average n o i s e l e v e l of -40 dB w e l l before 4.5 KHz. Since i t was not known how s i g n i f i c a n t the higher frequency components of the SMUAP spectrum were, the p o i n t where the s i g n a l spectrum meets the noise spectrum was taken as the s a f e s t d e f i n i t i o n of the upper c u t o f f frequency f o r the EMG data p r o c e s s i n g system d e s i g n . The main body of frequency components of the SMUAPs were, however, c o n c e n t r a t e d w e l l below 2 KHz. The bandwidth of the EMG data p r o c e s s i n g system was set from 30 Hz to 4.5 KHz and the sampling r a t e reduced to 10 KHz from the o r i g i n a l sampling rate of 20 KHz. T h i s reduced the number of samples to be subsequently processed and s t o r e d , and in c r e a s e d the time between samples f o r p r o c e s s i n g , each by a f a c t o r of two. TAPE 7 RECORD 7 — AVERAGED POTENTIAL POWER SPECTRUM (DB) ~l 1 1 1 1 1 1 1 1 1 1 0.0 50.0 100.0 *50.0 200.0 250.0 300.0 350.0 400.0 450.0 500 FREQUENCY (HZ) (X)O' ) (a ) F i g u r e 1 1 1 . 4 - 4 E s t i m a t e d , P S D f o r an a v e r a g e d SMUAP TAPE 7 RECORD 7 — AVERAGED POTENTIAL POWER SPECTRUM (DB) Q CM (b) 84 I I I . 5 D i g i t a l f i l t e r i n g of the EMG S i g n a l Implementation of the 4.5 KHz low pass Nyquist or a n t i - a l i a s i n g f i l t e r was accomplished with a 33 p o i n t optimal l i n e a r phase f i n i t e impulse response (FIR) f i l t e r designed with a c u t o f f frequency of 4 KHz and a t r a n s i t i o n bandwidth of 1 KHz (see Appendix C). The design of the 30 Hz highpass f i l t e r f o r removing the b a s e l i n e was not as s t r a i g h t f o r w a r d . In order to achieve the narrow stopband width of 0 to 30 Hz, a d i r e c t implementation of of an FIR f i l t e r would have r e q u i r e d over 3200 p o i n t s " However, the method of decimation and i n t e r p o l a t i o n f o r narrowband f i l t e r i n g from C r o c h i e r e and Rabiner [69,70] y i e l d e d a computional saving by a f a c t o r of 53 f o r t h i s a p p l i c a t i o n . F i r s t a lowpass f i l t e r was implemented i n s i x stages, three for decimation and three f o r i n t e r p o l a t i o n , with a c u t o f f frequency of 20 Hz, a t r a n s i t i o n bandwidth of 10 Hz, and e s s e n t i a l l y l i n e a r phase [69]. The output of t h i s lowpass f i l t e r — an estimate of the low frequency b a s e l i n e noise component — was then s u b t r a c t e d from the EMG s i g n a l (see Appendices C and D). The o v e r a l l response of the lowpass and highpass f i l t e r i n g to a simulated white noise p l u s constant l e v e l input i s shown in f i g u r e I I I . 5 - 1 , and a f i l t e r e d SMUAP i s shown in f i g u r e I I I . 5-2. An eleven second EMG r e c o r d sampled at 20 KHz took about twenty minutes to lowpass f i l t e r , and then n e a r l y two hours to highpass f i l t e r at the reduced sampling r a t e of 10 KHz. "Based on the e s t i m a t i o n formula given by Rabiner [68], AMPLITUDE tl TIME (a ) W h i t e n o i s e p l u s c o n s t a n t l e v e l i n p u t F i g u r e I I I . 5 - 1 P r e - f i l t e r r e s p o n s e t o w h i t e n o i s e p l u s c o n s t a n t l e v e l i n p u t DC (A .AMPLITUDE TIME (b ) P r e - f i l t e r o u t p u t °S 691 • o > -» — z UI Q _ l < cr t— o LU Q_ CO cr LU o CL -91 Jj — — — i 0 0 FREQUENCY [radians] ° ' 5 ( c ) PSD o f w h i t e n o i s e p l u s c o n s t a n t l e v e l i n p u t 37 n >-i— CO z UJ Q < cr t— o LU 0. CO cr LU o 0_ -133 r 00 FREQUENCY [radians] 0 5 (d) PSD o f p r e - f i l t e r o u t p u t FILTERED SIGNAL UNFILTERED SIGNAL F i g u r e I I I . 5 - 2 F i l t e r e d SMUAP 89 I I I . 6 Adaptive Matched F i l t e r Implementation The c l a s s i c a l matched f i l t e r i s the optimum l i n e a r f i l t e r f o r d e t e c t i n g the occurrence of a d e t e r m i n i s t i c waveform d i s t o r t e d by a d d i t i v e white Gaussian n o i s e . The f i l t e r i s matched to the waveform by s e t t i n g i t s t r a n s f e r f u n c t i o n t o the complex conjugate of the waveform's F o u r i e r spectrum. A d e c i s i o n i s made by comparing the f i l t e r output t o a t h r e s h o l d ; the optimum t h r e s h o l d value i s a c t u a l l y the t o t a l energy of the expected waveform as given by the waveform's a u t o - c o r r e l a t i o n c o e f f i c i e n t [47,71]. In adapt i v e matched f i l t e r i n g the waveform to be detected i s known to vary i n shape. The f i l t e r t r a n s f e r f u n c t i o n must t h e r e f o r e adapt to the changes i n the waveform's F o u r i e r spectrum. Performance of an adaptive matched f i l t e r depends on the nature of the waveform v a r i a t i o n , and the updating algorithms f o r the f i l t e r t r a n s f e r f u n c t i o n and the d e t e c t i o n t h r e s h o l d [28,42,28,48,49,50]. The length of the f i l t e r was set at 169 samples, or 16.9 m i l l i s e c o n d s . T h i s l e n g t h allowed f o r a maximum d u r a t i o n of the s e l e c t e d SMUAP of around 16 m i l l i s e c o n d s , l e a v i n g one h a l f of a m i l l i s e c o n d guard time at each end of the waveform 5 . Most normal SMUAPs are much s h o r t e r , being around 10 m i l l i s e c o n d s t o t a l i n d u r a t i o n [2,3], The matched f i l t e r i n g o p e r a t i o n i s a 169 p o i n t c r o s s c o r r e l a t i o n between the template and a moving window s e c t i o n of the data: 5The unusual length of 16.9 m i l l i s e c o n d s was chosen d u r i n g the development f o r i n c o n s e q u e n t i a l reasons: any l e n g t h g r e a t e r than 16 m i l l i s e c o n d s would s u f f i c e . /£<? K - - 8 f • {j} i s the c r o s s - c o r r e l a t i o n c o e f f i c i e n t at the matched f i l t e r output. h{j} i s the 169 point template vector a f t e r j de t e c t i o n s , and x i s the input EMG data sample v e c t o r , where x(n) would be the current sample. If the f i l t e r output, i s found to be greater then a lower t h r e s h o l d T _ { j ) and l e s s than an upper t h r e s h o l d T*{j}, then an occurrence of the s e l e c t e d SMUAP i s assumed and the sec t i o n of data input (x(n-k) : -84 £ k £ 84} i s stored [21,22], Figure III.6-1 shows flow c h a r t s f o r the adaptive matched f i l t e r designed. To obtain the i n i t i a l adaptive matched f i l t e r template, h{0], a sample SMUAP i s s e l e c t e d from the EMG record as i t i s being d i s p l a y e d on the Tektronix.4010 graphics t e r m i n a l , using the 4010's c r o s s h a i r s [49,50]. This i n i t i a l template p o t e n t i a l i s centered i n the 169 point time window by l o c a t i n g the two waveform peaks at equal d i s t a n c e s from the adjacent window boundaries, as i n f i g u r e I I I . 6 - 2 . The thresholds are set i n i t i a l l y to w i t h i n a c e r t a i n percentage above and below the a u t o - c o r r e l a t i o n c o e f f i c i e n t of the i n i t i a l template: 90 {11} 11 Sot "detection m a d e " flag I Set "false detection made " flag I Record magnitude! |and position off maximum. Set delay count to zero • No Increment delay count one sample S e t " f a l s e de tec t ion made" flag Set delay count t 9 ~ Reset "false detection! made" flag de tec t ion flag Set delay count to zero Reset made' Detected Potential. Save position of A . . Y potential Calculate new template Net T~and T+ Set delay count to lerol iReset "detection made" flag Set " f a l s e detection'madej f lag Figure III.6-1 Adaptive matched filter flow chart AMPLITUDE 16.9 MILLISECONDS F i g u r e I I I . 6 - 2 SMUAP s e l e c t e d f o r i n i t i a l matched f i l t e r t e m p l a t e 9 3 (12) The percentage i s set by the operater v i a the f r a c t i o n c so that the i n i t i a l t h r e s h o l d s are ( 1 ± c ) * 1 0 0 % of * { 0 } , where e i s u s u a l l y about 0 . 1 0 . The i n i t i a l template and t h r e s h o l d s remain the same f o r the f i r s t K S M U A P d e t e c t i o n s , ic a l s o being set by the o p e r a t o r . At the (ic + 1 ) d e t e c t i o n , u s u a l l y about the e l e v e n t h , the template i s updated by averaging a l l (K + 1 ) S M U A P S d e t e c t e d with the o r i g i n a l template, y i e l d i n g an ensemble average of the SMUAPs de t e c t e d so f a r . The count K keeps t h i s average from being b i a s e d due to the i n i t i a l small sample s i z e . The t h r e s h o l d s T _ { j } and T*{j} are updated by t r e a t i n g the *{j}'s that y i e l d d e t e c t i o n s as elements of a random sequence with a Gaussian pdf. The estimated mean n' and standard d e v i a t i o n f o r t h i s sequence are c a l c u l a t e d and used to set new t h r e s h o l d s . T { 1 3 } n i s the number of standard d e v i a t i o n s that v a l i d d e t e c t i o n 94 l e v e l s are allowed to vary around the mean c r o s s - c o r r e l a t i o n c o e f f i c i e n t . T h i s parameter i s again set by the op e r a t o r , u s u a l l y to a value of about two. Each time a d e t e c t i o n i s made a f t e r the f i r s t ic d e t e c t i o n s the matched f i l t e r adapts to v a r i a t i o n s i n the SMUAPs d e t e c t e d by updating the template and the d e t e c t i o n t h r e s h o l d s . The waveform of f i g u r e III.6-3 i s the i n i t i a l template of f i g u r e III.6-2 a f t e r 53 SMUAP d e t e c t i o n s . AMPLITUDE AVERAGED TEMPLATE INITIAL TEMPLATE F i g u r e I I I . 6 - 3 Ensemble a v e r a g e o f 5 3 d e t e c t e d SMUAPs 96 III.7 Adaptive Matched F i l t e r Performance The purpose of the t o t a l three stage p r o c e s s i n g system i s to a q u i r e an ensemble of p o t e n t i a l s from a s e l e c t e d motor u n i t for l a t e r a n a l y s i s . The ensemble must be l a r g e and c o n t a i n few erroneous p o t e n t i a l s from other motor u n i t s to permit a s t a t i s t i c a l l y v a l i d a n a l y s i s of the s e l e c t e d SMUAP. Under poor s i g n a l c o n d i t i o n s i t i s p r a c t i c a l l y impossible f o r the matched f i l t e r to be 100% c o r r e c t i n i t s d e t e c t i o n s , however, the purpose of the t h i r d stage of the system i s to improve the d e t e c t i o n accuracy through f e a t u r e c l a s s i f i c a t i o n of the SMUAPs in the ensemble. The matched f i l t e r i s r e q u i r e d to de t e c t a la r g e ensemble of SMUAPs, the m a j o r i t y of which are to be from the same motor u n i t as the s e l e c t e d p o t e n t i a l . T h i s means that some r e j e c t i o n s of v a l i d SMUAPs (type I e r r o r s ) and some acceptances of i n c o r r e c t SMUAPs (type II e r r o r s ) are t o l e r a b l e . If the number of c o r r e c t SMUAPs de t e c t e d i s l a r g e , and the d e t e c t i o n f a i l u r e s are unbiased, then type I e r r o r s are unimportant. Many a c t u a l type I e r r o r s w i l l o f t e n be SMUAPs e x c e s s i v e l y d i s t o r t e d by background noise or o v e r l a p p i n g p o t e n t i a l s and, as such, are not d e s i r e d i n the f i n a l ensemble. These p o t e n t i a l s are not counted as type I e r r o r s . Conversely, some of the v a l i d SMUAPs i n the f i n a l ensemble w i l l be d i s t o r t e d by background noise and other o v e r l a p p i n g p o t e n t i a l s , and t h e r e f o r e u n d e s i r a b l e . However, such p o t e n t i a l s u s u a l l y represent a small sample of the f i n a l matched f i l t e r output ensemble and, being t r u e d e t e c t i o n s , are not counted as type II e r r o r s unless e x c e s s i v e l y d i s t o r t e d . 97 To e v a l u a t e the performance of the matched f i l t e r f i v e data records were processed and the number and type of e r r o r s c a l c u l a t e d by v i s u a l l y scanning the EMG a c t i v i t y . The pr o c e s s i n g of one re c o r d of data through the p r e - f i l t e r s and then the matched f i l t e r took 7 hours of computing time on the NOVA 840; t h i s does not i n c l u d e the time f o r reading the data tapes, s e l e c t i n g the SMUAPs to be e x t r a c t e d and other housekeeping chores; v i s u a l i n s p e c t i o n of the EMG records took an a d d i t i o n a l two hours per r e c o r d . One r e c o r d , r e c o r d t 7 r 7 6 was processed a number of times to study the e f f e c t of v a r y i n g the adaption parameters €, K and n de s c r i b e d i n s e c t i o n I I I . 6 . T h i s r e c o r d was chosen because i t represented a t y p i c a l noisy EMG s i g n a l with extreme b a s e l i n e v a r i a t i o n s , a medium s i g n a l to white n o i s e r a t i o , and p o t e n t i a l s from two nearby, and at l e a s t one d i s t a n t , motor u n i t that o f t e n overlapped each o t h e r . In f i g u r e III .7—1 a s e c t i o n of the u n f i l t e r e d t7r7 r e c o r d i s shown where the b a s e l i n e v a r i a t i o n was so l a r g e that s a t u r a t i o n of the DISA a m p l i f i e r s c l i p p e d a SMUAP. Though the c l i p p i n g cannot be removed once the data i s recorded, high pass f i l t e r i n g , as d e s c r i b e d i n s e c t i o n I I I . 5 , does remove the b a s e l i n e v a r i a t i o n , as shown i n f i g u r e III.7-2, and would have prevented the d i s t o r t i o n i f performed at the time of r e c o r d i n g . The r e s u l t s of the p r o c e s s i n g of re c o r d t7r7 f o r the SMUAP in f i g u r e III.6-2 i s given i n t a b l e III.7-1 and p l o t t e d i n 6tnrm r e f e r s to data tape n, r e c o r d m; from the tapes recorded at V.G.H. by Mackinnon [ 6 ] . ^AMPLITUDE F i g u r e I I I .7-1 T y p i c a l m a r g i n a l l y a c c e p t a b l e EMG a c t i v i t y r e c o r d 0*\ — • TIME F i g u r e I I I . 7 - 2 P r e - f i l t e r i n g o f r e c o r d e d EMG Table III.7-1 The a d a p t i v e matched with r e c o r d t7r7 f i l t e r performance D e t e c t i o n Parameters Number of D e t e c t i o n s D e t e c t i o n E r r o r s _e JC type I type : .15 10 2.5 73 1 3% 5.5% .25 10 2.5 98 4.3% 10% .20 10 2.5 98 4.3% 10% .20 10 2.0 79 18% 5.1% .20 10 1 .5 62 35% 3.2% .20 2 2.0 72 25% 4.2% .20 20 2.0 76 22% 5.3% type I e r r o r s -- f a l s e r e j e c t i o n s type II e r r o r s -- f a l s e acceptances e, K, n — see t e x t f o r e x p l a n a t i o n 101 f i g u r e III.7-3 f o r v a r i o u s v a l u e s of c , it and n . Almost as one would expect, the r e l a t i o n s h i p s between the percent e r r o r s and the adaption parameters are n o n l i n e a r and interdependent. The o v e r a l l l e v e l of type I e r r o r s i s low, w e l l below 10% for most values of the adaption parameters, with the l e v e l of type II e r r o r s behaving p r e d i c t a b l y i n an i n v e r s e r e l a t i o n s h i p to the l e v e l of type I e r r o r s . The s t r i c t e r the t h r e s h o l d range i s made, the grea t e r the number of SMUAPs r e j e c t e d , good and bad. Rough e s t i m a t i o n from the curves of f i g u r e III.7-3 of values f o r €, K and n that should produce l e s s than 10% of both type I and II e r r o r s , y i e l d s 0.15, 10, and 2.25 r e s p e c t i v e l y . For the eleven seconds of EMG a c t i v i t y i n r e c o r d t7r7 use of these v a l u e s r e s u l t e d i n 92 SMUAPs de t e c t e d , with approximately 82 of them from the s e l e c t e d motor u n i t . Four other c l i n i c a l EMG records were processed, the r e s u l t s are given i n t a b l e I I I . 7 - 2 . In the cases with s i n g l e SMUAPs wi t h i n a rec o r d (t7r9 and t 7 r l 5 ) the matched f i l t e r a l g o r i t h m performed p r e d i c t a b l y w e l l . When other p o t e n t i a l s were present in the r e c o r d the performance was l e s s s p e c t a c u l a r . A l a r g e heart a r t i f a c t whose frequency spectrum o v e r l a p s the lower end of the SMUAP spectrum -- i e : above 30 Hz — was present i n one reco r d ( t 7 r l 2 ) , and c o u l d not be removed by l i n e a r h i g h pass f i l t e r i n g . Both the sought a f t e r SMUAP and the other SMUAPs were d i s t o r t e d by t h i s a r t i f a c t , r e s u l t i n g i n weak t h r e s h o l d c r i t e r i a — i e : a l a r g e d i f f e r e n c e between T"{j} and T*{j} and a deformed average template. x - T Y P E I ERRORS, FALSE REJECTIONS o- TYPE II ERRORS, FALSE ACCEPTANCES 15 K=10 h =2.5 20 C 25 40i 30H 20 10 0 1 —r 2 e = 2.o h=2.o 10 K i 20 30i 20 10 1.5 F i g u r e I I I . 7 - 3 D e t e c t i o n p e r f o r m a n c e w i t h r e c o r d t 7 r 7 6=2.0 K=10 2.0 2.5 o Table III.7-2 The a d a p t i v e matched f i l t e r performance with records t 7 r 9 , t7r12, t7r15 and t8r9 Record D e t e c t i o n Number of D e t e c t i o n Parameters D e t e c t i o n s E r r o r s c jt n type I_ type 11 t7r9 .10 10 2.25 76 29% 0% t7r12 .10 10 2.5 45 64% 48% t 7 r l 5 .10 10 2.5 127 3% 0% t8r9 .10 10 2.0 1 12 16% 28% type I e r r o r s — f a l s e r e j e c t i o n s type I I e r r o r s — f a l s e acceptances € , K, n — see t e x t f o r e x p l a n a t i o n 1 0 4 In another record (t8r9) the d e t e c t i o n e r r o r s were the r e s u l t of the s i m i l a r i t y between the c r o s s s p e c t r a l energy of the two SMUAPs present and the s p e c t r a l energy of the d e s i r e d SMUAP. The p o t e n t i a l waveforms themselves are v i s u a l l y d i s t i n c t i v e . To make sure that i t was not the c h o i c e of adaption parameters that degraded performance, t h i s r e c o r d was reprocessed with a few d i f f e r e n t v a l u e s f o r c, K and n ; the r e s u l t s are given i n t a b l e III.7-3. Note that no s i g n i f i c a n t improvement i s achieved. lo S Table III.7-3 The adaptive matched f i l t e r performance with r e c o r d t8r9 D e t e c t i o n Number of D e t e c t i o n Parameters D e t e c t i o n s E r r o r s type I type : .05 10 1.5 33 73% 18% .10 10 2.0 1 12 16% 28% .15 10 2.0 138 2% 28% .20 10 2.0 144 1% 31% type I e r r o r s — f a l s e r e j e c t i o n s type II e r r o r s -- f a l s e acceptances € , K , n — see t e x t f o r e x p l a n a t i o n 106 I I I . 8 Real Time EMG P r o c e s s i n g : Synopsis The p r o c e s s i n g system d e s c r i b e d has been designed f o r d e t e c t i n g s i n g l e motor u n i t a c t i o n p o t e n t i a l s generated with low muscle c o n t r a c t i o n l e v e l s and recorded near or w i t h i n the motor u n i t with a c o n c e n t r i c needle e l e c t r o d e . Proper b a n d l i m i t i n g of the recorded s i g n a l has been shown to s i g n i f i c a n t l y reduce background n o i s e l e v e l s , making the r e c o g n i t i o n of SMUAPs by a p h y s i c i a n or by an automatic p r o c e s s i n g system e a s i e r and l e s s prone to e r r o r . In a d d i t i o n , the reduced EMG bandwidth allowed a lower sampling r a t e to be u t i l i z e d , which decreased the data storage r e q u i r e d f o r a given d u r a t i o n of recorded s i g n a l , and i n c r e a s e d the time a v a i l a b l e between samples for p r o c e s s i n g . Both improvements are extremely important to the design of a low c o s t data a c q u i s i t i o n system. The adaptive matched f i l t e r was shown to perform w e l l under most c o n d i t i o n s , a c h i e v i n g t y p i c a l l y 80% accuracy i n d e t e c t i n g an ensemble of SMUAPs. D i s c u s s i o n s with Dr. P.J.A. B r a t t y have i n d i c a t e d that the few s i t u a t i o n s where the matched f i l t e r performed p o o r l y were a l s o d i f f i c u l t f o r a t r a i n e d electromyographer 7 . N e v e r t h e l e s s , improvement of the matched f i l t e r performance i s p o s s i b l e through the development of more s o p h i s t i c a t e d algorithms f o r choosing the i n i t i a l template and t h r e s h o l d v a l u e s , and f o r subsequent adaptive updates. 'Personal d i s c u s s i o n s with B r a t t y and Lawrence a f t e r demonstration of p r o c e s s i n g system. 107 IV. C l a s s i f i c a t i o n of SMUAPs IV.1 I n t r o d u c t i o n T h i s f i n a l stage of the processor i s i n c l u d e d to improve upon the performance of the ad a p t i v e matched f i l t e r . The ensemble of detected waveforms are reprocessed, and as many f a l s e acceptance e r r o r s as p o s s i b l e are removed without s i g n i f i c a n t l y compounding the f a l s e r e j e c t i o n e r r o r s . While SMUAPs l o s t from the ensemble d u r i n g adaptive matched f i l t e r i n g cannot be recovered, the intermediate ensembles output by the fe a t u r e c l a s s i f i c a t i o n process can be used to enhance the performance of the adapt i v e matched f i l t e r . The accepted c l a s s of p o t e n t i a l s provide a b e t t e r ensemble estimate of the average SMUAP f o r updating the f i l t e r template. The development of a p r a c t i c a l algor-ithm f o r c l u s t e r i n g SMUAP waveforms a c c o r d i n g to p a r t i c u l a r f e a t u r e s i s best approached h e u r i s t i c a l l y [32]. Each f e a t u r e should have a s i g n i f i c a n t r e l a t i o n to the p h y s i o l o g i c a l process being examined the generation of a s i n g l e motor u n i t a c t i o n p o t e n t i a l . I t should be p o s s i b l e to e x t r a c t each f e a t u r e from a de t e c t e d waveform using methods that are i n s e n s i t i v e to system noise and measurement e r r o r . In a d d i t i o n , both the SMUAP f e a t u r e s s e l e c t e d and the c l a s s i f i c a t i o n a l g o r i t h m implemented must be able to account to some extent f o r the v a r i a t i o n of a SMUAP with time and r e c o r d i n g e l e c t r o d e p o s i t i o n . Even though the o v e r a l l p e r t u r b a t i o n s i n the SMUAP waveform may be s m a l l , some f e a t u r e s chosen may be p a r t i c u l a r i l y s e n s i t i v e and vary s i g n i f i c a n t l y . In s h o r t , a proper c h o i c e of f e a t u r e s and methods f o r measuring 1 0 8 and c l a s s i f y i n g those f e a t u r e s must allow r e l i a b l e d i f f e r e n t i a t i o n of the d e s i r e d SMUAP ensemble from the c o l l e c t i o n of p o t e n t i a l s recorded from other SMUAPs and from the i n e v i t a b l e occurances of extremely d i s t o r t e d p o t e n t i a l s , such as those that r e s u l t from the s u p e r p o s i t i o n of two or more SMUAPs. The performance c r i t e r i a i s , again, to generate a f i n a l ensemble that to the experienced electromyographer c o n t a i n s only p o t e n t i a l s generated by a s i n g l e motor u n i t . A proper e v a l u a t i o n of the u s e f u l c l a s s i f i c a t i o n f e a t u r e s and development of robust measurement and c l u s t e r i n g a l g o r i t h m s r e q u i r e s a study of c l a s s i f i c a t i o n performances f o r a l a r g e number of dete c t e d ensembles. T h i s i s most e a s i l y accomplished using a r e a l time (hardware) implementation of the f i r s t two processor stages to c o l l e c t the ensembles. Development of t h i s f a c i l i t y i s c u r r e n t l y i n p r o g r e s s . For t h i s t h e s i s , a f e a s i b i l i t y study was performed of the de s c r i m i n a t o r y p r o p e r t i e s of a f i r s t c h o i c e of SMUAP f e a t u r e s and measurement techniques. 109 IV.2 C l a s s i f i c a t i o n Features The set of f e a t u r e s e v a l u a t e d was s e l e c t e d so that each measure would have s i g n i f i c a n c e i n d e f i n i n g a SMUAP s i g n a l — at l e a s t i n t u i t i v e l y . Since the p r e c i s e r e l a t i o n s h i p s between SMUAP s i g n a l c h a r a c t e r i s t i c s and motor u n i t p h y s i o l o g y i s a sub j e c t s t i l l being researched, some doubt would e x i s t of the p h y s i o l o g i c a l importance of any c l a s s i f i c a t i o n f e a t u r e chosen [2,9,18,8,72,73,74,75,76,35,3,5,14,77,78]. A l s o , i n order to s i m p l i f y the fe a t u r e e x t r a c t i o n a l g o r i t h m s , only f e a t u r e s which were app a r e n t l y simple to measure were i n c l u d e d ; some s i g n i f i c a n t SMUAP s i g n a l c h a r a c t e r i s t i c s , such as the i n t e r - p u l s e i n t e r v a l [35,3] were t h e r e f o r e excluded from c o n s i d e r a t i o n . A l l of these r e s t r i c t i o n s must be taken i n t o account when e v a l u a t i n g the performance of t h i s i n i t i a l t e s t . The f i r s t of the ten f e a t u r e s chosen was a r e v i s e d c o r r e l a t i o n c o e f f i c i e n t f o r each of the waveforms i n the ensemble c o r r e l a t e d with the ensemble average. T h i s measure represents a r e - a p p l i c a t i o n of the matched f i l t e r o p e r a t i o n with a b e t t e r estimate of the SMUAP average taken from a l a r g e r , a p o s t i o r i , ensemble. The remaining nine f e a t u r e s were s e l e c t e d as measures of a b i p h a s i c SMUAP waveform such as shown i n f i g u r e IV.2-1 8 : ( i ) the peak amplitude of the negative phase. ( i i ) the peak amplitude of the p o s i t i v e phase. 8The p o s i t i v e and negative peaks r e f e r r e d to here are with respect to the p o l a r i t y of the recorded p o t e n t i a l s . T h i s p o l a r i t y i s i n v e r t e d from the p h y s i o l o g i c a l waveform by the c l i n i c a l r e c o r d i n g apparatus. ^ A M P L I T U D E F i g u r e IV.2-1 B i p h a s i c SMUAP o 111 ( i i i ) the d u r a t i o n , i n samples, between the minimum peak and the zero c r o s s i n g p o i n t between the two peaks. ( i v ) the d u r a t i o n , i n samples, between the maximum peak and the zero c r o s s i n g p o i n t . (v) the c u r v a t u r e of the negative phase at i t s minimum. ( v i ) the c u r v a t u r e of the p o s i t i v e phase at i t s maximum. ( v i i ) the d u r a t i o n , i n samples, from the p o i n t a t which the negative phase drops below 33% of i t s minimum value to the zero c r o s s i n g . ( v i i i ) the d u r a t i o n , i n samples, from the zero c r o s s i n g t o . the p o i n t where the p o s i t i v e phase drops below 33% of i t s minimum. (i x ) the slope of the waveform at the zero c r o s s i n g p o i n t . These nine f e a t u r e s are i l l u s t r a t e d i n f i g u r e IV.2-2. T h i s f i g u r e a l s o i l l u s t r a t e s the method of measuring the SMUAP f e a t u r e s . F i r s t , to reduce the e f f e c t s of noise each waveform was smoothed using a t h i r d order orthogonal polynomial r e g r e s s i o n ([81], p. 574). At each sample i n the input waveform a polynomial f i t to the nearest ±5 unsmoothed samples was evalu a t e d and the r e s u l t used as the smoothed cente r sample. The eleven p o i n t f i t was chosen on a t r i a l b a s i s to gi v e the best apparent f i t between the o r i g i n a l and smoothed waveforms (compare f i g u r e s IV.2-1 and IV.2-2). 1 113 The measurement of each f e a t u r e was then accomplished as f o l l o w s : ( i ) the minimum and maximum peak v a l u e s and t h e i r l o c a t i o n were found with a simple sample by sample search of the smoothed waveform. ( i i ) two a d d i t i o n a l sample by sample searches of the waveform, t h i s time s t a r t i n g at each end and working towards the c l o s e s t peak, were used to f i n d the l o c a t i o n of the two samples c l o s e s t to the r e s p e c t i v e peak whose valu e s were l e s s than or equal to 0.33 times the magnitude of the peak. ( i i i ) the zero c r o s s i n g p o i n t between the negative and p o s i t i v e peaks was found by s e a r c h i n g sample by sample between the peak l o c a t i o n s , checking f o r a change i n s i g n . Each smoothed sample was again smoothed with a t h i r d order polynomial r e g r e s s i o n of eleven samples in an attempt to remove any double c r o s s i n g s of the zero l i n e . The peak to zero c r o s s i n g d u r a t i o n s and the 33% of the peak to zero c r o s s i n g d u r a t i o n s were taken as the p o s i t i v e d i f f e r e n c e s of the r e s p e c t i v e l o c a t i o n s . ( i v ) the slope at the zero c r o s s i n g was taken as the f i r s t d e r i v a t i v e of the c u b i c polynomial f i t at that p o i n t . (v) the c u r v a t u r e at each peak l o c a t i o n was estimated by performing another t h i r d order orthogonal polynomial f i t to the smoothed waveform u s i n g the 1 1 4 samples between each peak and i t s r e s p e c t i v e 33% value l o c a t i o n . The second d e r i v a t i v e of the c u b i c polynomial was then e v a l u a t e d at the peak l o c a t i o n , and at each of the ±5 samples on each s i d e of the peak; these c u r v a t u r e s were then averaged t o g e t h e r . Thus, the peak amplitudes and d u r a t i o n s , by f a r the the most r e l i a b l y measured v a l u e s , were est i m a t e s l i n e a r l y r e l a t e d to the peak to peak amplitude and the peak to peak d u r a t i o n of a SMUAP d i s c u s s e d i n s e c t i o n I I ; the d u r a t i o n s to the 33% of the peak value samples were measures more i n d i c a t i v e of the " t o t a l " waveform d u r a t i o n , g i v i n g some estimate of the extent of the t a i l s of the b i p h a s i c waveform; and the c u r v a t u r e measurements and zero c r o s s i n g slope r e f l e c t the shape of the p o s i t i v e and negative phases. These a l g o r i t h m s were implemented i n NOVA 840 FORTRAN (see Appendix F) and t r i a l runs were made to e x t r a c t the s e l e c t e d f e a t u r e s from the waveform ensembles generated by the a d a p t i v e matched f i l t e r (see s e c t i o n I I I . 7 ) . V i s u a l examinations of p l o t s such as shown in f i g u r e IV.2-2 were used to determine i f the measured values represented the f e a t u r e s sought. Since t r a d i t i o n a l electromyography r e l i e s on v i s u a l r e c o g n i t i o n of SMUAP f e a t u r e s , t h i s was c o n s i d e r e d a reasonable approach. 115 IV.3 Stepwise L i n e a r Descriminant A n a l y s i s To p r o v i d e a s t r a i g h t f o r w a r d and r e l i a b l e a p p r a i s a l of the u s e f u l l n e s s of the f e a t u r e s chosen f o r s e p a r a t i n g d e s i r e d SMUAPs from erroneous d e t e c t i o n s i n the a d a p t i v e matched f i l t e r output ensemble, a packaged r o u t i n e a v a i l a b l e on UBC's Amdahl 470 computing system [82] was used to perform stepwise l i n e a r d i s c r i m i n a n t a n a l y s i s [29] on the f e a t u r e s e x t r a c t e d from the waveforms. D e t e c t i o n ensembles from records t 7 r 7 , t7r12 and t8r9 were found through v i s u a l c l a s s i f i c a t i o n to c o n t a i n s i g n i f i c a n t l e v e l s of type II e r r o r s , and were t h e r e f o r e s e l e c t e d as good t e s t ensembles (see t a b l e s III.7-1 and III .7-2) . R e s u l t s of t h i s a n a l y s i s showed s i g n i f i c a n t improvement of the d e t e c t i o n ensembles c o u l d be achieved through f e a t u r e c l a s s i f i c a t i o n . Table IV.3-1 shows that on the average h a l f of the f a l s e acceptance e r r o r s can be e l i m i n a t e d with a very small i n c r e a s e i n the number of f a l s e r e j e c t i o n s . In two of the ensembles, the two contaminated the most with erroneous d e t e c t i o n s , the improvement was even more encouraging, with the p r o p o r t i o n of true d e t e c t i o n s i n each ensemble i n c r e a s i n g by over 30%. Table IV.3-1 The f e a t u r e c l a s s i f i c a t i o n performance with records t 7 r 7 , t 7 r l 2 and t 8 r 9 Record Number of D e t e c t i o n s D e t e c t i o n E r r o r s A f t e r  Adaptive A f t e r Feature Matched F i l t e r i n g C l a s s i f i c a t i o n  type I_ type II type I_ type II t7r7 98 t7r12 45 t8r9 144 4.3% 64% 1% 10% 48% 31% 7.6% 67% 1% 8.8% 20% 2% type I e r r o r s — f a l s e r e j e c t i o n s type II e r r o r s — f a l s e acceptances 117 IV.4 C l a s s i f i c a t i o n of SMUAPs: Synopsis An a d d i t i o n a l improvement to the accuracy of the SMUAP ensemble produced by the p r o c e s s i n g system has been shown to be p o s s i b l e with the t e r t i a r y f e a t u r e c l a s s i f i c a t i o n stage. While f u r t h e r a n a l y s i s i s r e q u i r e d to determine a more robust set of waveform f e a t u r e s , b e t t e r methods f o r f e a t u r e s e x t r a c t i o n , and a more e f f i c i e n t c l a s s i f i c a t i o n a l g o r i t h m , the concept has been proven to be worthwhile, with improvements i n the d e t e c t i o n ensemble of up to 30%. 118 V. C o n c l u s i o n s Two important a s p e c t s of the development of r e a l time electromyographic a n a l y s i s have been addressed. U t i l i z i n g mathematical a n a l y s i s and computer s i m u l a t i o n s t u d i e s , the f i r s t p o r t i o n of t h i s t h e s i s has c o n c e n t r a t e d on understanding the b i o p h y s i c s i n v o l v e d i n r e c o r d i n g a s i n g l e motor u n i t p o t e n t i a l with an intra-muscular c o n c e n t r i c needle e l e c t r o d e . The l a t t e r p o r t i o n has d e s c r i b e d the s i g n a l p r o p e r t i e s of c l i n i c a l l y recorded electromyographic a c t i v i t y , and proposed a system f o r r e a l time a q u i s i t i o n of a c t i o n p o t e n t i a l s from a s i n g l e motor u n i t . The a n a l y s i s and s i m u l a t i o n s t u d i e s l e d to the development of a model of the c r o s s - s e c t i o n a l d i s t r i b u t i o n of f i b e r s w i t h i n a s i n g l e motor u n i t . In t h i s model the p o s i t i o n s of the f i b e r s were based on random v a r i a b l e s with a binormal p r o b a b i l i t y d e n s i t y f u n c t i o n . A n a l y s i s showed that a b i n o r m a l l y d i s t r i b u t e d a r r a y of 163 f i b e r s , with a standard d e v i a t i o n of about 2.6 m.m. p r ovided a c l o s e r e p r e s e n t a t i o n of the s i z e and d i s t r i b u t i o n of f i b e r s i n the human biceps b r a e h i i . F u r t h e r a n a l y s i s demonstrated that s i g n i f i c a n t areas f r e e from f i b e r s c o u l d be found with a h i g h p r o b a b i l i t y anywhere w i t h i n the motor u n i t t e r r i t o r y . Computer s i m u l a t i o n of the summation of s i n g l e f i b e r a c t i o n p o t e n t i a l s generated by the b i n o r m a l l y d i s t r i b u t e d f i b e r a r r a y model pr o v i d e d c l i n i c a l l y a c c e p t a b l e s i n g l e motor u n i t a c t i o n p o t e n t i a l s recorded from the p r e d i c t e d f r e e areas w i t h i n the 119 motor u n i t . T h i s l e d to the c o n c l u s i o n that c l i n i c a l l y recorded SMUAPs with peak to peak d u r a t i o n s of one to s i x t e e n m i l l i s e c o n d s a re recorded a t s i t e s w e l l w i t h i n the motor u n i t t e r r i t o r y . I t was then shown that the peak to peak amplitude and peak to peak d u r a t i o n of the simulated SMUAPs have a n o n - l i n e a r dependence on the r a d i a l d i s t a n c e of the r e c o r d i n g s i t e from the motor u n i t c e n t e r . These n o n - l i n e a r dependencies appeared to ca n c e l when the peak to peak amplitudes and peak to peak d u r a t i o n s of the simulated SMUAPs were p l o t t e d a g a i n s t each other. The l i n e a r i t y of the r e l a t i o n s h i p was perturbed by random v a r i a t i o n s due to the i n f l u e n c e of nearby f i b e r s , however, the r e s u l t s i n d i c a t e d a r e l a t i o n s h i p c l o s e to that observed c l i n i c a l l y , with a l e a s t mean squares l i n e a r f i t p r o v i d i n g a slope of about 1.2. T h i s slope decreased when the s i n g l e f i b e r a c t i o n p o t e n t i a l a x i a l d i s p e r s i o n was decreased, or when the r a t i o of a x i a l to r a d i a l c o n d u c t i v i t y was i n c r e a s e d . Experiments with the number of nearest f i b e r s allowed to i n f l u e n c e the simulated SMUAP showed that the p o t e n t i a l s f i e l d s from the c l o s e s t 55% of the f i b e r s c o n t r i b u t e d to 90% of the R.M.S. power. S i m i l a r r e s u l t s were obtained f o r the i n f l u e n c e of nearby f i b e r s on the SMUAP peak to peak amplitude and.peak to peak d u r a t i o n . The c l i n i c a l l y a c c e p t a b l e SMUAPs generated were dominated by the a c t i o n p o t e n t i a l f i e l d s of the f i b e r s nearest to the r e c o r d i n g s i t e . S ince the l o c a l d i s t r i b u t i o n of f i b e r s f o r a given r e c o r d i n g s i t e i s random, the recorded SMUAP has random amplitude and d u r a t i o n components. 120 The q u a l i t a t i v e r e s u l t s o b t a i n e d from the a n a l y s i s and s i m u l a t i o n s t u d i e s provide a b e t t e r understanding of what a s i n g l e motor u n i t a c t i o n p o t e n t i a l recorded with an intra-muscular c o n c e n t r i c needle e l e c t r o d e r e p r e s e n t s . Q u a n t i t a t i v e a n a l y s i s of the recorded p o t e n t i a l s and t h e i r r e l a t i o n s h i p to motor u n i t p h y s i o l o g y r e q u i r e s f u r t h e r r e s e a r c h i n t o motor u n i t anatomy, the gen e r a t i o n and summation of s i n g l e f i b e r a c t i o n p o t e n t i a l s , the conductive c h a r a c t e r i s t i c s of the surrounding t i s s u e , and the e l e c t r i c a l c h a r a c t e r i s t i c s of the re c o r d i n g e l e c t r o d e . The r e s u l t s of the l a t t e r p o r t i o n of t h i s t h e s i s can be a p p l i e d to the a c q u i s i t i o n of SMUAPs from human s u b j e c t s , a l l o w i n g a l a r g e r ensemble of EMG data to c o l l e c t e d and q u a n t i t a t i v e l y a nalyzed. The f i r s t task of the second part of the t h e s i s work has been to analyze the s i g n a l c h a r a c t e r i s t i c s of recorded EMG a c t i v i t y at low muscle c o n t r a c t i o n l e v e l s . The s i g n i f i c a n t bandwidth of the s i n g l e motor u n i t a c t i o n p o t e n t i a l was found to be between 30 Hz. and 4.5 KHz. A p r e - f i l t e r i n g system was designed to band l i m i t recorded EMG a c t i v i t y , which allowed the sampling r a t e to be reduced and i n c r e a s e d the s i g n a l to noise r a t i o without d i s t o r t i n g the recorded SMUAP waveforms. Next, an a l g o r i t h m was proposed f o r d e t e c t i n g SMUAPs from a s e l e c t e d motor u n i t based on an ad a p t i v e matched f i l t e r with a dual t h r e s h o l d d e t e c t i o n c r i t e r i a . A software implementation of the band l i m i t i n g p r e - f i l t e r and ad a p t i v e matched f i l t e r was t e s t e d on c l i n i c a l l y recorded EMG data, and shown t o perform 121 w e l l even with noisy EMG a c t i v i t y c o n t a i n i n g m u l t i p l e SMUAPs. The e x t r a c t i o n of the SMUAPs f u r t h e r reduced the amount of data to be processed by a f a c t o r of about ten, and the d e t e c t i o n e r r o r s were, on the average, around 10% of the r e s u l t a n t ensemble. For those d e t e c t i o n ensembles c o n t a i n i n g a hig h number of f a l s e d e t e c t i o n s of SMUAPs not from the s e l e c t e d motor u n i t , a t e r t i a r y stage of p r o c e s s i n g was proposed based on f e a t u r e c l a s s i f i c a t i o n . A f e a s i b i l i t y study was undertaken using a f i r s t c h o i c e of h e u r i s t i c a l l y chosen waveform f e a t u r e s , simple techniques f o r f e a t u r e e x t r a c t i o n , and a standard software package f o r stepwise l i n e a r d i s c r i m i n a n t a n a l y s i s . The r e s u l t was t y p i c a l l y a 30% r e d u c t i o n i n the number of e r r o r s i n the SMUAP ensemble. E v a l u a t i o n of the performance of the three stage EMG p r o c e s s i n g system showed that ensembles of seventy to over one hundred SMUAPs c o u l d be e x t r a c t e d from approximately eleven seconds of c l i n i c a l l y recorded EMG a c t i v i t y . The p r o p o r t i o n of SMUAPS i n the f i n a l ensemble not from the s e l e c t e d motor u n i t v a r i e d from 0% to 20%, with the average d e t e c t i o n e r r o r being about 6%. The data records that produced the g r e a t e s t number of d e t e c t i o n e r r o r s were observed to be d i f f i c u l t to analyze even f o r the s k i l l e d electromyographer. Refinements to the proposed three stage EMG p r o c e s s i n g system may best be achieved once an i n i t i a l r e a l time system i s implemented and l a r g e r ensembles of SMUAP data are a c q u i r e d and analyzed. A d d i t i o n a l study of the SMUAP frequency spectrum and 122 i t s r e l a t i o n s h i p to p h y s i o l o g i c a l i n f o r m a t i o n may allow f u r t h e r r e d u c t i o n of the data sampling r a t e . The performance of the adapti v e matched f i l t e r may be improved by more s o p h i s t i c a t e d a l g o r i t h m s f o r s e l e c t i n g and updating the matched f i l t e r template and the dual d e t e c t i o n t h r e s h o l d s . F i n a l l y , the fe a t u r e c l a s s i f i c a t i o n a l g o r i t h m f o r SMUAP d i s c r i m i n a t i o n needs to be designed i n d e t a i l : ensembles of SMUAPs from a v a r i e t y of c l i n i c a l s u b j e c t s must be analyzed to d e r i v e p h y s i o l o g i c a l l y s i g n i f i c a n t , robust f e a t u r e s ; robust f e a t u r e e x t r a c t i o n techniques must be developed; and a c l a s s i f i c a t i o n a l g o r i t h m s u i t a b l e f o r r e a l time, or near r e a l time a p p l i c a t i o n must be d e r i v e d . The r e s u l t s of t h i s t h e s i s p r o v i d e s a bases on which to b u i l d a r e a l time EMG p r o c e s s i n g system. T h i s i n i t i a l system would be the beginning of the development of a f u l l y automatic system f o r the a n a l y s i s of EMG to a i d i n d i a g n o s i s of neuromuscular d i s o r d e r s . 123 V I . Appendices 124 A. The I n t e r - f i b e r Distance P r o b a b i l i t y Density Function The binomial p r o b a b i l i t y d e n s i t y f u n c t i o n (pdf) i s given by (equation 5 ) : ikz**Pl (,4) And the distance between two f i b e r s , d { i j } , by: if Ul ' ((xUl-xUtf^Ul-ydtf)* i , 5 ) To d e r i v e the pdf of the i n t e r f i b e r d i s t a n c e , d { i j } , f i r s t d e r i v e the pdf of the random v a r i a b l e s : a * xtcl - x iji { 1 6 } IT r i j i c l - tfjjjj Then, since u and v are independent: ex/> J - (a.* + v-0| L + °"E J 125 {17} W H E R E • E£o.*3 *E£v*3 ' 2 o>* The symbol E { o } denotes the expected v a l u e , or moment, of the random v a r i a b l e o [15,16], From equation 16, the i n t e r f i b e r d i s t a n c e i s thus the square root of the sum of the squares of two Gaussian random v a r i a b l e s , u and v, the pdf of which i s e a s i l y d e r i v e d [16]: UJ - V V2 J U . v ) v = ur Qi V U r W ) t U u. 1*1 & } K / > M > O 6C = t 126 {18} 127 Where the l a s t equation g i v e s the p r o b a b i l i t y of the i n t e r f i b e r d i s t a n c e s , d { i j } , being between two v a l u e s , d, and d 2 , as i l l u s t r a t e d i n f i g u r e II.3-2. 128 B. The Free Area P r o b a b i l i t y D i s t r i b u t i o n A " f r e e area" i s d e f i n e d as a c i r c u l a r area of r a d i u s 6 centered a t the p o l a r c o o r d i n a t e s ( r o , 0 o ) r e l a t i v e to the o r i g i n of the random d i s t r i b u t i o n of f i b e r l o c a t i o n s with a binormal p r o b a b i l i t y d e n s i t y f u n c t i o n (pdf) (equation 5 ) . The area i s s a i d to be f r e e of f i b e r s i f the p r o b a b i l i t y of f i n d i n g any f i b e r s w i t h i n that area i s near z e r o . However, because d i f f i c u l t y a r i s e s i n attempting to i n t e g r a t e the b i v a r i a t e Gaussian pdf over an o f f centered c i r c u l a r r e g i o n , an approximation i s used that i s more t r a c t i b l e and serves to i l l u s t r a t e the a v a i l a b i l i t y of f r e e areas w i t h i n the binormal MU. T h i s approximation i s based on transforming the c i r c u l a r geometry to an increment of e q u i v a l e n t area whose boundaries are d e f i n e d by constant r and e curves as i n f i g u r e V I . B - 1 . The area A 1 approximates the true area A and i s given simply by: F i g u r e V I . B - 1 F r e e a r e a a p p r o x i m a t i o n 130 Note that A' = A, so i f A' i s a " f r e e a r e a " , then so i s A. By adding the a d d i t i o n a l requirement that A' be an area with s i d e s of equal l e n g t h , i t s dimensions are given by: A' = A S E T 2f * r*cc 2 131 {20} To The p r o b a b i l i t y of no f i b e r s being w i t h i n a r a d i u s 6 of the e l e c t r o d e p o s i t i o n ( r 0 f e 0 ) i s the product of the p r o b a b i l i t y that each f i b e r w i l l not be i n the s t a t e d a r e a : t * / *" J 132 {21} VJHE*B N s & FIBERS j/VAAAAY The p r o b a b i l i t y that a f i b e r w i l l be i n A' i s found from equation 6: 133 T h i s p r o b a b i l i t y d i s t r i b u t i o n f u n c t i o n i s p l o t t e d as a f u n c t i o n of r 0 i n f i g u r e I I . 4 - 1 . Note that the f u n c t i o n i s independent of e 0 . 134 C. The Optimal L i n e a r Phase FIR D i g i t a l F i l t e r Designs D i g i t a l f i l t e r s used i n the p r o c e s s i n g of the EMG data were a l l designed using the optimal (Chebyschev) l i n e a r phase f i n i t e impulse response (FIR) f i l t e r d e s i gn program p u b l i s h e d by M a C l e l l a n , Parks and Rabiner [83]. The program was adapted to run on the Amdahl 470 at UBC, with the a d d i t i o n of r o u t i n e s to p l o t the frequency response of the r e s u l t a n t FIR f i l t e r . Table VI.C-1 and f i g u r e VI.C-1 show the r e s u l t s of the 2 KHz low pass Nyquist f i l t e r d esign used to b a n d l i m i t the EMG s i g n a l f o r PSD e s t i m a t i o n (NOVA subroutine BASFLT, f o r the b a s e l i n e PSD e s t i m a t i o n program BASELINE, Appendix F ) . Table VI.C-2 and f i g u r e VI.C-2 show the r e s u l t s of the 4 KHz low pass Nyquist f i l t e r design used to b a n d l i m i t the EMG s i g n a l f o r sub-sampling to 10 KHz (NOVA program LOWEMG, Appendix F ) . Tables VI.C-3, VI.C-4 and VI.C-5 and f i g u r e s VI.C-3, VI.C-4 and VI.C-5 show the r e s u l t s f o r the designs of the three low pass f i l t e r s r e q u i r e d f o r the m u l t i s t a g e narrowband d e c i m a t i o n / i n t e r p o l a t i o n f i l t e r (see Appendix D, and NOVA program HIGHEMG, Appendix F ) . T a b l e V I . C - 1 The 2 KHz N y q u i s t F I R f i l t e r d e s i g n **»***»*•»*****»*' f l B I T E INPOLSE HES'OHSE (TIB) LI REAR PHASE DIGITAL FILTER DESIGS REEEZ EZ HAHGE ALGORITHH BANDPASS FILTER FILTER LENGTH « 127 • • * • * IBPOLSE KESPOMSB • * * * • (FREOOENCI HORHALIZED BT PI) H{ 1) * -0.26138201E-02 « H{ 127) H( 2) * 0.35660211E-02 = H( 126) H( 3) » 0.28944705E-02 = H( 125) B( «) « O.28901380E-02 * B( 120) B( 5) «= 0.31477995E-02 • B( 123) H( 6) « 0.34689152E-02 * H{ 122) H( 7) « 0.374164993-02 = H( 121) H( 8) = 0 .390iaaeiE-02 «= H( 120) H( 9 ) = 0.39041843E-02 * HI 119) B( 10) « 0.37225317E-02 * B( 118) H( 11) • 0.33417791E-02 « H{ 117) H( 12) = 0.27634352E-02 * H( 116) H( 13) « 0.20013712E-02 » H( 115) H( 14) * 0.10846599E-02 « H( 114) H( 15) * 0.55044700E-04 » H( 113) fl( 16) * -0.10321045E-02 « B( 112) H( 17) « -0.21139719E-02 - H( 111) H( 18) « -0.31209271E-02 « B( 110) H( 19) • -0.39827041S-02 * H( 109) B( 20) * -0.46306141E-02 * B( 108) H( 21) « -0.50058253E-02 • B( 107) H( 22) * -0.50609931E-02 * H( 106) B( 23) « -0.47675110E-02 - H( 105) B( 2<t) * -0.41159913E-02 * B( 104) H( 25) • -0.31220857E-02 » H( 103) B( 26) « -0.18237049S-02 » H( 102) H( 27) « -0.28441148E-03 » H{ 101) B( 28) * 0.14124657E-02 * H( 100) fl( 29) * 0.31634327E-02 « H( 9 9 ) H( 30) * 0.48545226E-02 = H( 98) B( 31) « 0.63624270E-02 « H{ 97) fl( 32) « 0.75679496E-02 » B( 96) H( 33) « 0.B3592683E-02 « B( 95) H( 34) « 0.86457767E-02 « H( 94) B( 35) * 0.83567910E-02 « H( 93) H( 36) = 0.74571408E-02 * B( 92) H( 37) « 0.59454814E-02 « B( 91) B( 38) « 0.38672574E-02 • B( 90) B( 39) * 0.13000988E-02 • B( 89) H( 40) « -0.16302131E-02 « H( 88) H( 41) « -0.47683902E-02 « B( 87) fl( 42) » -0.79231486E-02 * H( 86) H( 43) » -0.10884539E-01 * B( 85) B( 44) * -0.13443809E-01 » H( 84) B( 45) » -0.15359666E-01 » H{ 83) B( 46) « -0.16444948E-01 « R( 82) H( 47) s B( 48) « B( 49) B( 50) s B( 51) H( 52) s H( 53) • B( 54) B H( 55) S B( 56) * ' B( 57) B( 58) C B( 59) S H( 60) ts B( 61) 8 B( 62) s B( 63) s B( 64) = BIRD -0.16511135R-01 = H( -0 . 15411194E-01 = fl( -0.13041839E-01 « H( -0.93701854E-02 = R( -0.44100545E-02 = Bf 0.17574180E-02 « B( 0.89949630E-02 = H( 0.17098501E-01 = B( 0.25819138E-01 « B( 0.34862161E-01 * B( 0.43910444E-01 * B( 0.52628368E-01 « H< 0.60687602E-01 = B( 0.67772448E-01 « H( 0.73604405E-01 • H( 0.77946961E-01 » B( 0.80626428E-01 « H( 0.81531286E-01 = H( LOWER BAND EDGE DPPEB BAND EDGE DESIBED VALOE •SIGHTING DEVIATION DEVIATION IN DB 0.0 0.070833325 1.000000000 10.030000000 0.046753958 0.812790453 BAND 2 0.033333313 0.093333313 0.500000000 1.000000000 0.467539549 -6.603632927 81) 80) 79) 78) 77) 76) 75) 74) 73) 72) 71) 70) 69) 68) 67) 66) 65) 64) BAND 3 0.095933302 1.000000000 0.0 50.000000000 0.009350792 -40.533038330 EXTREMAL PREQOENCIFS 0.0 0.0708333 0.1397786 0.2179036 0.2970052 0.3770833 0.4571614 0.5372396 0.6173177 0.6973958 0.7764974 0.8565755 0.9366536 0.0166016 0.0958333 0.1544271 0.2335286 0.3136067 0.3936349 0.4737630 0.5538411 0.6329427 0.7130208 0.7930939 0.8722005 0.9522736 0332031 1007161 1700521 . .2491536 0 .3292317 0.4093099 0.4893880 0.5694661 0.6495442 7286458 8087239 _ 8888021 0.9679036 0. 0. 0. 0498047 1114583 1856771 2657552 3458333 42591 14 0.5050130 5850911 6651692 7452474 8243489 9044271 0.9845052 0. 0. 0. 0. 0. 0.0634766 0.1251302 0. 2013021 0.2813802 0.3614583 0.4415364 0.5216146 0.6016927 0.6807942 0.7608724 0.8409505 0.9200521 1.0000000 B AS D FIR FILTER RF.MF.Z EXCHANGE ALGORITHM Figure VI.C-1 The 2 KHz Nyquist FIR f i l t e r frequency response I 3 1 Table VI.C-2 The 4 KHz Nyquist FIR f i l ter design F I N I T E I M P U L S E B E S P C N S E ( F I R ) L 1 N E A B P H A S E E I U I T A l F I L T E R E E S I G N B E H E Z E X H A N G E A L G C B I T H n B A N E P A S S F I L T E R F I L T E R L E N G T H * 5 1 F I L T E R L E N G T H C E T E B f l l N E D B Y A ? fR O X I f i A T I O N I S P D L S E B E S P C N S E • » • » • ( F B E C O E N C Y H C R H A L I Z E D ET P I ) HI H( H( Hi HI HI HI HI H I H I H I HI HI HI HI B I HI HI H I HI HI HI HI HI HI K I 2) ' 3 ) > 4) 5 ) > 6) 7 ) 8 ) 9 ) 1 0 ) ID 12) 13) 1«) 15) 16 ) 17) 13) 19) 2 0 ) 2 1 ) 2 2 ) 2 3 ) 2 4 ) 2 5 ) 2 6 ) 0 . 2 2 5 2 4 3 3 4 E - C 2 » 0 . 4 I 8 5 7 8 4 6 E - 0 2 < 0 . 1 6 7 9 3 S 7 0 E - 0 2 « - C . 3 1 0 1 2 8 5 5 E - C 2 « - 0 . 3 5 1 3 7 1 8 0 E - 0 2 = 0 . 2 S 6 3 8 9 6 8 E - 0 2 i 0 . 6 C 1 0 3 2 7 5 E - C 2 < - 0 . 1 2 2 9 5 6 7 7 E - 0 2 ' - 0 . 8 9 3 9 4 4 8 7 E - 0 2 < - 0 . 2 1 5 8 9 7 7 1 E - 0 2 0 - 1 1 0 1 4 2 4 5 K - 0 1 0 . 7 7 7 4 3 7 5 4 E - 0 2 > - 0 - 1 1 4 b b 6 6 1 E - 0 1 - 0 . 1 5 2 2 2 4 9 0 E - 0 1 0 . e e i 5 8 9 2 0 E - 0 2 0 . 2 4 2 3 5 7 2 5 E - 0 1 - 0 . I 6 7 4 6 3 7 9 E - 0 2 - 0 . 3 3 7 9 4 0 7 5 E - 0 1 - 0 . 1 2 2 2 4 2 6 1 E - 0 1 0 . « : 9 8 0 5 5 2 E - 0 1 • 0 . 3 7 1 8 7 0 7 0 E - 0 1 •  - 0 . 5 0 5 4 0 1 4 9 E - 0 1 > - 0 . 8 9 0 5 8 6 3 8 E - 0 1 « 0 . 5 5 5 7 3 7 0 2 E - 0 1 « 0 . 2 1 2 4 0 6 9 0 E * 0 0 0 . 4 4 2 6 9 5 1 4 E * 0 0 H H H H a H H H H H H H H H H H H H : H < ri • H H LO'HEB EASE EDGE OFPEB E AND EDGE DESIRED VALUE WEIGHTING EEVIAIICB DEVIATION IB EB BAND 1 0.0 0 . 3 9 9 9 9 9 5 7 6 1 . C 0 0 0 C O 0 0 C 1 . 0 0 C O C O O O O 0 . 0 1 0 9 6 4 1 9 6 0 . 1 9 0 4 4 3 1 2 6 BAND 2 O . 5 0 0 C 0 O O O O 1 . 0 0 0 0 0 3 0 0 0 0 . 0 1 0 . 0 0 0 0 0 0 0 0 0 0 . 0 0 1 C 9 6 U 2 0 - 5 9 . 2 0 0 4 5 4 7 1 2 5 1 ) 5 0 ) 49) 48) 47) 46) 4 5 ) 44) 43) 42) 4 1 ) 4 0 ) 3 9 ) 3 8 ) 3 7 ) 3 6 ) 3 5 ) 3 4 ) 3 3 ) 3 2 ) 3 1 ) 3 0 ) 2 9 ) 2 8 ) 2 7 ) 2 6 ) BAND EXTBEHAI FREQUENCIES _ R\ A ft A 0 . 0 0 . 2 0 1 9 1 9 3 0 . 3 d 7 0 0 7 0 0 . 5 5 7 6 8 9 7 0 . 7 3 5 5 6 6 1 0 . 9 3 7 4 6 0 0 0 . 0 4 0 8 6 5 3 0 . 2 4 2 7 8 2 8 C . 4 0 C 0 0 0 0 0 . 5 9 1 3 4 2 0 0 . 7 7 4 0 2 5 9 1 . 0 0 0 0 0 0 0 0 . 0 8 1 7 3 0 5 0 . 2 8 1 2 4 2 6 0 . 5 0 0 0 0 0 0 0 . 6 2 4 9 9 4 3 0 . 8 1 4 8 8 9 4 0 . 1 2 2 5 9 5 8 0 . 3 1 9 7 0 2 4 0 . 5 0 7 2 1 1 2 0 . 6 6 1 0 5 0 3 0 . 8 5 3 3 4 9 2 C . 1 6 1 0 5 5 8 0 . 3 5 8 1 6 2 2 0 . 5 2 8 8 4 4 8 0 . 6 9 9 5 1 0 1 0 . 8 9 4 2 1 2 7 * » • * « * • * * * * * • * • • • • • • • < F I R F I L T E R REMEZ EXCHANGE ALGORITHM I * 1 T a b l e VJ^C_-_3 The s t a g e I l ow p a s s tj_lt_er d e s i g n • # • • • « • » • • » • • • • • • • • • • • • » • » # # • • • • # * * » » • * • * » » * • • • • * • * » » • • • • » » » * * * » » * * » « » FINITE IHPOLSE RESPONSE (FIB) LIIEAB PHASE DIGITAL FILTEB DESIGN BEflIZ EXBANGE ALGOBITBB BAICPASS FILTEB FILTEB LENGTH - 65 FILTEB LENGTE DETEBHIBED BI APPBOXIflATIOH ••••• IHPOLSE RESPONSE •*»•• (FREQUENCE BOBHALIZED ET PI) LOHEB EAND EDGE OPPEB BAND EDGE DESIBED VALOE WEIGHTING DEVIATION DEVIATION X I DB H( H( HI H( H< H( B< H( BC U( H( B( B( B( H( H( B{ til H( B( H( H( H( B( BC B( B( H( B( H( B( H( H{ 1) 2) 3) 4) 5) 6) 7) 8) 9) 10) ") 12) 13) 1«) 15) 16) 17) 18) 19) 20) 21) 22) 23) 2«) 25) 26) 27) 28) 29) 30) 31) 32) 33) -0.15714928E--0.20990975E--0.33318717E--0.48639439E--0.66441554E--0.85678045E--0.10467125E--0.12106877E--0.13182170E--0.13322316E--0.12097I10E--0.90348162E--0.36424794E-0.45669498E-0. 16048220E-0.31166789E-0.50267316E-O.73442087E-0. 10070622E-0.13186894E-0.1665S333E-0.20418193E-0.24399329E-0.28505836E-0.32631129E-0.36659211E-0.40469199E-0.43941140E-0.46961010E• 0.49426794E" 0.51253051E-0.52375525E-0.52754I94E-03 - B 03 • B 03 * B 03 * B 03 - B 03 - B 02 * B 02 > B 02 * B 02 - B 02 - B 03 • H 03 - B 03 « B 02 « B 02 • B 02 « B 02 « H 01 - B 01 • B 01 - B 01 « B 01 - B 01 * B 01 « B 01 - B 01 - H 01 « B 01 - B •01 * H •01 « B 01 - B •01 - B BAND 1 0.0 0.004000001 1.000000000 1.000000000 0.001577100 BAND 2 0. 119000018 1.000000000 0.0 10.000000000 0.000157710 65) *») 63) 62) 61) 60) 59) 58) 57) 56) 55) 54) 53) 52) 51) 50) • 9) •8) •7) • 6) •5) 44) •3) •2) «!) •0) 39) 38) 37) 36) 35) 3») 33) BAID 0.027383491 -76.042816162 EITBEBAL PBEQDENCIES 0.0 0.0040000 0.1190000 0.1246818 0.1398329 0.1587716 0.2951308 0.4466411 0.5981513 0.7534493 0.9068534 0.1833920 0.3254329 0.4769431 0.6303473 0.7837514 0.9390494 0.2099063 0.3557349 0.5072452 0.6606493 0.8140534 0.9693514 0.2383145 0.3860370 0.5375472 0.6909513 0.8462493 1.0000000 0. 2667227 0.4 163390 0.5678493 0.7212534 0.8765514 FIR FILTER REMEZ EXCHANGE ALGORITHM o Figure VI.C^3 The stage I low pass f i l t e r frequency response T a b l e VI .C-4 The s t a g e I I l ow pass f i l t e r d e s i g n F I N I T E i n P O L S E B E S P O H S E ( F I B ) L I R E A B P f l A S E D I G I T A L F I L T E R D E S I G R B E B E Z E Z B A N G E A L G O B I T B H B A R E P A S S F I L T E B F I L T E R L E N G T B * 2 1 • • • * • I H P O L S E B E S P O B S E • • • • • ( F B E C U E S C I H C S H A L I Z E D ET P I ) B< 1) H< 2 ) B< 3 ) B ( • ) H ( 5 ) B< 6 ) m ' i H ( 8 ) B ( 9 ) H ( 1 0 ) HI 11) - 0 . 5 3 6 7 4 7 9 8 E - 0 3 m H ( 2 1 ) - 0 . 3 0 7 7 9 8 3 9 E - 0 2 M B ( 2 0 ) - 0 . 8 3 0 0 6 7 3 2 E - 0 2 m H ( 1 9 ) - 0 . 1 4 6 7 6 8 6 5 E - 0 1 E H ( 1 8 ) - 0 . 1 6 3 3 6 1 4 3 E - 0 1 m H ( 17 ) - 0 . 4 4 4 9 6 6 1 8 E - 0 2 « H ( 1 6 ) 0 . 2 8 1 8 5 1 8 5 E - 0 1 M H ( 1 5 ) 0 . 8 0 8 5 9 9 0 0 E - 0 1 m U ( 1 4 ) 0 . 1 4 1 7 1 0 0 4 B O 0 m H ( 1 3 ) 0 . 1 9 0 9 2 4 8 8 E * 0 0 * H ( 1 2 ) 0 .20987010E»00 m H ( 11 ) LOWER CADD E D G E D P P E B E A N D E D G E D E S I B E D V A L O E W E I G H T I N G C E V I A T I C B D E V I A T I O N I B DB 8 A B D 1 0 . 0 0 . 0 6 4 0 0 0 0 1 0 1 . 0 0 0 0 0 0 0 0 0 1 . 0 0 0 0 0 0 0 0 0 0 . 0 0 1 5 2 5 5 7 2 0 . 0 2 6 4 9 1 6 4 2 B A R D 2 0 . 4 0 3 9 9 9 9 2 5 1 .OdOOOOOOO 0 . 0 1 0 . 0 0 0 0 0 0 0 0 0 0 . 0 0 0 1 5 2 5 5 7 - 7 6 . 3 3 1 3 4 4 6 0 4 B A N D E I T B E B A L F B E Q O E H C I E S 0 . 0 0 . 0 4 5 4 5 4 5 0 . 0 6 4 0 0 0 0 0 . 4 6 6 4 9 9 2 0 . 5 2 8 9 9 8 5 0 . 6 0 8 5 4 3 0 0 . 6 8 6 9 4 8 9 1 . 0 0 0 0 0 0 0 0 . 4 0 3 9 9 9 9 0 . 6 9 3 7 6 9 3 0 . 4 2 1 0 4 5 2 0 . 7 8 4 6 7 7 4 FIR FILT REMEZ EXCHANGE A ER LG0R1THM a-I UJ a Z3 a . a : 9 i 0.0 - 1 — 0.2 — 1 — 1 r ~ FREQUENCY (NORMALIZED) Figure VI.C -4 The stage I I low pass f i l t e r frequency response T a b l e V I . C . 5 The s t a g e I I I l ow p a s s f i l t e r d e s i g n F I H I T E I H P O L S E B E S P O I S B ( P T E ) L I D E I B P H A S E D I G I T A L F I L T E B D E S I G N B E H E 2 E I H U G E A I G O B I T H H B A H t P A S S F I L T E B F I L T E B L E H G T f l > 6 1 * • • • * I H P O L S E B E S P O B S E • * • • • ( F B B Q U E N C I I O B H I L I Z B D BT F X ) 1 0 N E H EAMD E D G E U P P E B BAND E D G E D E S I B E D V A L U E B E I G B T I B G D E V I A T I O N D E V I A T I O N X B O B H ( B ( B ( B ( B C B ( B ( B ( B ( H ( B ( H ( B ( B ( U ( H ( H ( B ( B ( B ( B ( H ( H ( H ( H< H ( H ( H ( B ( H ( H ( 1) ' 2 ) ' 3 ) 4 ) . 5 ) 6 ) 7 ) 8 ) 9 ) 1 0 ) 11 ) 1 2 ) 13 ) 1 4 ) 1 5 ) 1 6 ) 1 7 ) 1 8 ) 1 9 ) 2 0 ) 2 1 ) 2 2 ) 2 3 ) 2 ft) 2 5 ) 2 6 ) 2 7 ) 2 8 ) 2 9 ) 3 0 ) 3 1 ) - 0 . 4 3 1 0 4 2 8 6 E - 0 4 > 0 . 2 3 4 4 S 0 5 6 B - 0 3 « O . 6 3 3 S 4 6 8 5 B - 0 3 > 0 . 8 0 5 6 3 6 8 7 E - 0 3 • 0 . 2 5 1 9 4 6 5 1 E - 0 3 > - 0 . 9 5 8 9 3 8 8 5 E - 0 3 < - 0 . 1 8 4 0 4 5 5 5 E - 0 2 ' - 0 . 1 1 2 9 5 8 4 2 E - 0 2 ' 0 . 1 2 9 0 0 6 1 3 E - 0 2 > 0 . 3 5 6 1 0 0 8 7 B - 0 2 < 0 . 3 0 0 0 4 7 5 5 E - 0 2 ' - 0 . 1 1 5 5 0 9 2 8 E - 0 2 - 0 . 5 9 3 2 0 2 1 9 E - 0 2 - 0 . 6 3 1 0 1 9 8 5 E - 0 2 - 0 . 4 6 7 5 5 2 1 3 E - 0 5 0 . 8 8 3 6 7 4 6 2 E - 0 2 0 . 1 1 6 3 2 2 0 8 B - 0 1 0 . 3 0 3 8 6 7 8 3 E - 0 2 - 0 . 1 2 0 2 2 0 3 3 B - 0 1 ' - 0 . 1 9 8 5 2 0 4 2 B - 0 1 ' - 0 . 9 3 8 6 5 8 4 2 E - 0 2 • 0 . 1 5 1 2 6 9 4 7 E - 0 I ' 0 . 3 2 9 6 8 2 8 3 E - 0 1 > 0 . 2 2 3 2 6 4 9 9 2 - 0 1 « - 0 . 1 7 7 4 2 1 5 7 E - 0 1 » - 0 . 5 7 9 3 2 8 2 4 E - 0 1 • - 0 . 5 4 1 7 9 0 7 2 E - 0 1 • 0 . 1 9 4 9 0 3 I 7 E - 0 1 > 0 .14507276E»00 • 0 . 2 6 4 3 0 1 1 8 E * 0 0 • 0 . 3 1 3 2 2 7 8 9 E * 0 0 B ( B ( B ( B ( B ( B ( B ( B ( B ( H ( B ( B ( H ( B ( B ( H ( B ( B ( B ( H ( B ( H ( B ( < B ( ' H ( •  H ( • H ( ' B ( ' B { • B ( • H ( 6 1 ) 6 0 ) 5 9 ) 5 8 ) 5 7 ) 5 6 ) 5 5 ) 5 4 ) 5 3 ) 5 2 ) 5 1 ) 5 0 ) 4 9 ) 4 8 ) 4 7 ) 4 6 ) 4 5 ) 4 4 ) • 3 ) 4 2 ) 4 1 ) 4 0 ) 3 9 ) 3 8 ) 3 7 ) 3 6 ) 3 5 ) 3 4 ) 3 3 ) 3 2 ) 3 D B A N D 1 0 . 0 0 . 2 5 5 9 S 9 9 2 3 1 . 0 0 0 0 0 0 0 0 0 1 . 0 0 0 0 0 0 0 0 0 0 . 0 0 1 3 9 2 6 4 2 0 . 0 2 4 1 6 7 2 7 4 B A N D 2 0 . 3 8 3 9 9 9 9 4 4 1 . 0 0 0 0 0 0 0 0 0 0 . 0 1 0 . 0 0 0 0 0 0 0 0 0 0 . 0 0 0 1 3 9 2 6 4 - 7 7 . 1 2 3 1 9 9 4 6 3 B A I D E X T B E H A L F B E Q O E N C I E S 0 . 0 0 . 1 6 9 3 5 3 4 0 . 3 8 3 9 9 9 9 0 . 4 8 0 7 7 1 2 0 . 6 3 8 0 2 4 4 0 . 0 3 4 2 7 4 2 0 . 1 9 9 5 9 4 4 0 . 3 9 0 0 4 8 1 0 . 5 1 1 0 1 2 2 0 . 6 7 0 2 8 1 5 0 . 0 6 8 5 4 8 3 0 . 2 2 7 8 1 9 3 0 . 4 0 4 1 6 0 6 0 . 5 4 1 2 5 3 2 0 . 7 0 2 5 3 8 6 0 . 1 0 2 8 2 2 5 0 . 2 4 7 9 8 0 0 0 . 4 2 6 3 3 7 4 0 . 5 7 3 5 1 0 3 0 . 7 3 4 7 9 5 7 0 . 1 3 5 0 8 0 2 0 . 2 5 5 9 9 9 9 0 . 4 5 2 5 4 6 2 0 . 6 0 5 7 6 7 4 0 . 7 6 9 0 6 8 8 0 . 8 0 1 3 2 5 9 0 . 8 3 3 5 8 3 0 0 . 8 6 7 8 5 6 1 0 . 9 0 0 1 1 3 2 0 . 9 3 4 3 8 6 4 0 . 9 6 6 6 4 3 S 1 . 0 0 0 0 0 0 0 o o COa. O o . •—CN UJ a. <X 10. i a 0.0 0.2 Figure VI.C-5 FIR FILTER REMEZ EXCHANGE ALGORITHM 145 D. The Narrow Band High Pass F i l t e r Implementation F i g u r e VI.D-1 shows the s t r u c t u r e of the narrow band high pass f i l t e r . A high pass f i l t e r was c o n s t r u c t e d by u s i n g a narrowband low pass f i l t e r [69,70] to estimate the b a s e l i n e v a r i a t i o n , and then s u b t r a c t i n g that estimate from the o r i g i n a l s i g n a l (the phase delay was i g n o r e d ) . NARROWBAND LOWPASS FILTER b(n) X(nJ-y(n) (a) Narrow stopband high pass filter x(n)-LPFI 0-595 Hz D 10:1 D 4:1 D 2:1 LPFII 0-126 Hz LPFIII 0-30 Hz I 1:2 I 1:4 I 1:10 LPFIII LPFII LPFI b(n) 0-30 Hz 0-126 Hz 0-595 Hz D - DEC I MATI ON I - INTERPOLATION (b) Narrow band low pass filter Figure VI.D-1 The narrow stopband high pass filter P E. Program L i s t i n g s f o r the SMUAP S i m u l a t i o n Study Binomial Motor U n i t F i b e r Array Generation U B C P A S C A L - Vers ion: November 14,1981 ID=SNAP 21:54 25 JUL 82 PAGE 1 * OPTIONS * ' ALIGN CASEDIST CASENEXT DUMPTABLE IBM370 INDEXCHECK LIST MCCARTHY OBJFILE PRECEDENCE RANGECHECK TITLE 4^ Binormal ly D i s t r i b u t e d Motor Unit F iber Array Generat ion. ID=SNAP 21:54 25 JUL 82 PAGE 2 1 00000 2 OOOOO 3 00000 4 OOOOO 5 OOOOO 6 OOOOO 7 OOOOO 8 OOOOO 9 ooooo 10 00000 1 1 OOOOO 12 OOOOO 13 OOOOO 14 OOOOO 15 OOOOO 16 OOOOO 17 OOOOO 18 OOOOO 19 OOOOO 20 OOOOO 21 OOOOO 22 OOOOO 23 OOOOO 24 OOOOO 25 OOOOO 26 OOOOO 27 OOOOO 28 OOOOO 29 OOOOO 30 OOOOO 31 OOOOO 32 OOOOO 33 OOOOO 34 OOOOO 35 OOOOO 36 OOOOO 37 OOOOO 38 OOOOO 39 OOOOO 40 OOOOO 41 OOOOO 42 OOOOO 43 OOOOO 44 OOOOO 45 OOOOO 46 OOOOO 47 OOOOO 48 OOOOO 49 OOOOO - - $e jec t , t 1 t l e= 'B inorma l ly D i s t r i b u t e d Motor Unit Fiber Array GeneratIon. ' ,under 11ne.upper$ . n___ _ — — — — _ — _ _ _ _ _ _ — 14/10/79 - - G. KENWARD This program computes a random muscle f i b e r array and the distances to var ious points of an e lect rode sur face from each f i b e r . Most of the program Is Involved with I/O to f a c i l i t a t e f l e x i b i l i t y In s e t t i n g up the ar ray , and to provide v isua l checks on the r e s u l t s . INPUT from unit 7: MU_number var1at1on_code No_of_fIbers MU_x_boundary MU_y_boundary No_of_surface_po1nts Surface_po1nts No_of_sampl1ng_pos1t1ons Samp11ng_pos1t1ons • - m o t o r uni t (M.U.) number; •- the v a r i a t i o n code for d is t ingu ish ing the e lect rode and sampling patterns used. •- no. of f i b e r s 1n the M.U. (max. 250); •- standard dev ia t ion of normal d i s t r i b u t i o n of f i b e r s in x d i r e c t i o n ; •- standard dev ia t ion of normal d i s t r i b u t i o n of f i b e r s In y d i r e c t i o n ; •- If MU_x_boundary or MU_y_boundary are less than or equal 0, a uniform c i r c u l a r d ls t rubu t lon with radius of2.50 Is used; •- number of points on e lectrode surface (max. 13); -- the e lect rode point r e l a t i v e pos i t ions ( x . y . z ) ; - - number of e lect rode sampling pos i t ions (max. 10); •- e lect rode sampling p o s i t i o n coordinates ( x , y ) ; from f i l e MU : If v a r i a t i o n code 1s <= O. the M.U. coordinates of the M.U. f i b e r s ; number and the OUTPUT to uni t 6: Program flow Information plus the Input parameters In e a s i l y read form for cross checking and re ference. to uni t 7: The d is tances to each f i b e r for each point on the electrode sur face , and for each sampling p o s i t i o n ; to f i l e MU : If the v a r i a t i o n code Is <= 0. the M.U. number the no of f i b e r s , the x and y M.U. boundaries, and the coordinates of the f i b e r s In th.new a r ray ; to uni t 9: A p lo t of the f i b e r array d i s t r i b u t i o n over x and y, and a p lot of the e lect rode surface points as viewed from three orthogonal d i r e c t i o n s ; Binormal ly D i s t r i b u t e d Motor Unit F iber Array Generat ion. ID=SNAP 21:54 25 JUL 82 PAGE 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 OOOOO OOOOO OOOOO 00100 00100 00100 00100 00100 0010O 00100 OOIOO 00100 00100 0010O 00100 00100 00124 00124 00124 0013C 0013C 001D8 001D8 00228 00228 00868 03108 03108 059B8 059B8 059B8 059B8 059B8 059B8 059B8 059B8 00078 00080 00078 0OO80 00078 00078 00078 00078 00058 00058 OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO $eject$ CONST TYPE X = 1; y = 2; z = 3; VAR s t r i n g = ARRAY (1. .25) OF CHAR; vector = ARRAY (1. .200) OF SHORT; r a d i i = ARRAY (1. .13) OF vector ; MU_number, No_of_fIbers, No_of_surface_po1nts, No_of_sampl1ng_pos1t1ons. varlat1on_code, 1_posn. 1_f1ber, coord, 1_surpt MU_x_boundary, MU_y_boundary, x_coord1nate, y_coord1nate, rad1us_S0R, array_rad1us Surface_po1nts Samp11ng_pos1t1ons x_f Ibers , y_f Ibers radl1_SQR r a d i i f i l e INTEGER; SHORT; ARRAY (x. . 2 ,1 . .13) OF SHORT; ARRAY ( x . . y , 1 . . 1 0 ) OF SHORT; vector ; rad l1 ; FILE OF rad l1 ; INITIAL Surface_po1nts Samp11ng_pos1t1ons array_rad1us = ARRAY (0.0s : 13) : 3 END; = ARRAY (0.0s : 10) : 2 END; » 0 .0s; 11 FUNCTION SYSTEM CLOCK (dummy : SHORT): SHORT ; FORTRAN 'SCLOCK'; 11 FUNCTION INIT NORMAL RANDOM (seed : SHORT): SHORT ; FORTRAN 'RANDN'; 11 FUNCTION NORMAL RANDOM (dummy : SHORT): SHORT ; FORTRAN 'FRANDN'; 11 FUNCTION INIT UNIFORM RANDOM (seed : SHORT): SHORT ; FORTRAN 'RAND'; 11 FUNCTION UNIFORM RANDOM (dummy : SHORT): SHORT ; FORTRAN 'FRAND'; 11 PROCEDURE MTS COMMAND (VAR command : s t r l n a : n: Inteaer) ; FORTRAN 'CMD'; 11 PROCEDURE PLOT (x. y: SHORT; 1: INTEGER) ; FORTRAN; 11 PROCEDURE PLOTND ; FORTRAN; 1- PROCEDURE PLOT TEXT (x .v . height : SHORT; words: s t r l n a : anale: SHORT: -1 n: INTEGER) ; SLINKAGE 'SYMBOL' 1- PROCEDURE PLOT SYMBOL (x .y , heiqht: SHORT; Index: INTEGER: anale: SHORT: -1 n: INTEGER) ; SLINKAGE 'SYMBOL' 1- PROCEDURE SCALE (VAR data: vector ; n: INTEGER: lenath: SHORT: VAR min. -1 d e l t a : SHORT; sk ip : INTEGER) ; SLINKAGE; 1- PROCEDURE AXIS (x o r g l n . v o r q l n : SHORT: words: s t r l n a : n: INTEGER: lenath. -1 angle , min, d e l t a : SHORT) ; SLINKAGE; Binormal ly D i s t r i b u t e d Motor Unit F iber Array Generat ion. ID=SNAP 21:54 25 JUL 82 PAGE 4 103 OOOOO - - $eject$ 104 OOOOO - -105 OOOOO 1- PROCEDURE G e n e r a t e m o t o r u n i t ; 106 OOOOO - -107 OOOOO - - VAR 108 00048 - - i_f1ber : INTEGER; 109 0004C - - seed, tempx, tempy, diameter, rad1us_sqr : SHORT; 110 00060 - - f11e_name : ALFA; 111 0006A - - command : s t r i n g ; 112 00083 - - MU_f11e : TEXT; 113 00095 - - • 114 00095 - -115 00095 2- BEGIN 116 0O05E - -117 0005E - - f i le_name :» " ; 118 00068 - - command := ' ' ; 119 00O72 - -120 00072 - - w r l t e C ' :11 , 'Generat Ing f i b e r array for M.U. * ' ,MU_number :0 . ' . ' ,EOL) ; 121 OOOFC - - wr1testr ( f1 le_name,1. 'MU' .MUnumber:0) ; 122 00166 - - wr i te (' ' : 11 , 'Motor uni t array w i l l be saved 1n f i l e " ' . f 1 l e _ n a m e : - 1 , ' " . ' , E O L . ' ' . E O L ) ; 123 00234 - - wr1testr(command,1,'$CREATE ' , f11e_name:- 1); 124 002A8 - - MTS_COMMAND(command,12); 125 O02BE - - REWRITE(MU_f11e,f11e name); 126 002CC - -127 002CC - - seed := SYSTEMCLOCK(O.Os); 128 002EA - - IF. ( (MUxboundary <= O.Os) OR (MU_y_boundary <= 0.0s)) THEN 129 00306 3- BEGIN 130 00306 - - MU_x_boundary :« array_rad1us; 131 0030E - - MU_y_boundary :« O.Os; 132 00316 - - diameter := 2 * array_rad1us; 133 00324 - - rad1us_sqr := S0R(array_rad1us); 134 0032E wr1te(MU_f11e,No_of_fibers,EOL,MU_x_boundary,MU_y_boundary.EOL); 135 003C8 - -136 003C8 - - seed :» INIT_UNIFORM_RANDOM(seed); 137 003E6 - - 1_f1ber := 1; 138 003EE - - WHILE (1_f1ber <= No_of_f ibers) DO 139 003FA 4- BEGIN 140 O03FA - -141 003FA - - tempx := diameter * (UNIFORM_RANDOM(0.0s) - 0 .5s ) ; 142 0042C - - tempy := diameter • (UNIF0RM_RAND0M(O.Os) - 0 .5s ) ; 143 0045E - - If. ((SOR(tempx) + SOR(tempy)) > rad1us_sqr) THEN LOOP; 144 00478 - - x_f1bers(1_f iber ) := tempx; 145 0049E - - y _ f 1 b e r s ( I f i b e r ) :» tempy; 146 004C4 - -147 004C4 - - wr1te(MU_flie,tempx,tempy); 148 00514 - - INCR(1_fIber); 149 O052O -4 END; 150 00524 -3 END; 151 00524 - -152 00524 - - ELSE 153 00524 3- BEGIN 154 00528 - - write(MU_fi1e,No_of_fIbers,EOL,MU_x_boundary,MU_y_boundary.EOL); 155 005C2 - -156 005C2 - - seed := INIT_N0RMAL_RAND0M(seed); 157 005E0 - - FOR 1 f i b e r :« 1 TO No_of_f ibers DO 158 005F6 4- BEGIN 159 005F6 - - x_f1bers(1_f iber ) := MU_x_boundary * N0RMAL_RAND0M(0.0s); 160 00640 - - y_ f ibers (1_f Iber ) := MU_y_boundary * NORMAL_RAND0M(O.Os) ; Binormal ly D i s t r i b u t e d Motor Unit F iber Array Generat ion. ID = SNAP 21:54 25 JUL 82 PAGE 161 162 163 164 165 166 OO68A 006 8A 007 16 00726 00726 00816 wr1te(MU_f11e,x_f1bers(1_fiber) ,y_f ibe rs (1_ f ibe r ) ) ; -4 END; -3 END; -1 END "Generate motor u n i t " ; Binormal ly D i s t r i b u t e d Motor Unit F iber Array Generat ion. ID=SNAP 21:54 2b JUL 82 PAGE 5 167 00816 168 00816 --169 00816 1-170 00816 --171 00816 --172 00048 --173 0O050 --174 00061 1.75 00061, --176 0O061 2-177 0005C 178 0005C --179 0006A --180 00092 --181 00092 --182 0009C --183 000A 2 --184 000A2 --185 00102 --186 00102 --187 001 1E 3-188 001 IE --189 00128 --190 0013E -3 191 0013E --192 0013E --193 00154 --194 00166 --195 001E6 --196 001E6 --197 001FC --198 001FC --199 001FC --200 00212 --201 00224 --202 002 AC --203 002 AC -1 204 003OC --$eject$ VAR coord , Inc contro l f i l e INTEGER; TEXT; BEGIN RESET(contro l_f11e,7) ; read(control_f1le,MU_number,varlat1on_code); Xf ( v a r l a t l o n c o d e < O) THEN var1at1on_code := 0; read(contro l_ f 1 le,No_of_f Ibers,MU_x_boundary ,MU_y_boundary ,No_of_surf ace_po1nts); IF ((MU_x_boundary <= O.Os) OR (MU_y_boundary <= 0 .0s) ) THEN  BEGIN array_rad1us := ABS(MU_x_boundary); IF (array_rad1us • O.Os) THEN array_rad1us := 2 .5s; END; FOR 1nc : • 1 TO No_of_surface_po1nts DO  FOR coord := x JO 2 DO read (con t ro l_ f1 le ,Sur face_po in ts (coord , Inc ) ) ; read(contro1_f11e,No_of_sampl1ng_pos1t1ons); FOR Inc := 1 TO No_of_sampl1ng_pos1t1ons DO  FOR coord :» x TO y DO read(contro1_f1le.Sampl1ng_pos1t Ions(coord, Inc)) ; END "Read contro l f i l e " ; "l CM Binormal ly D i s t r i b u t e d Motor Unit Fiber Array Generation. ID=SNAP 21:54 25 JUL 82 PAGE 7 205 0030C - -206 0030C - -207 0030C \ -208 0030C - -209 0030C - -210 00048 - -211 0004C - -212 00056 --213 00069. - -214 00069 - -215 00069 2-216 00058 - -217 00058 --218 00062 - -219 OOOCC - -220 OOODA - -221 00128 - -222 00128 - -223 0013E - -224 0013E - -225 00154 - -226 00 IDC - -227 00256 - -228 002F0 - -229 002 FO -1 230 003B4 - -$eject$ PROCEDURE Read MU f i l e ; VAR Inc f11e_name MU f i l e INTEGER; ALFA; TEXT; BEGIN f11e_name := ' ' ; wr1testr( f1lename,1, 'MU',MU_number:0); RESET(MU_f1le,f1le_name); read(MU_f1le,No_of_fIbers,MU_x_boundary,MU_y_boundary); IF (MU_y_boundary = 0.0s) THEN array_rad1us := MU_x_boundary; FOR Inc := 1 TO No_of_fIbers DO read(MU_f1le ,x_f Ibers( Inc) ,y_f Ibers(1nc)) ; wr1te(' ' : 1 1 . ' T h e ' ,No_of_ f Ibe rs :0 , ' (x.y) coordinates for motor unit # wr1te(MU_number:0, ' have been read from f i l e : " ' . f 1 l e _ n a m e : - 1 E O L ) ; END "Read MU_f11e"; ); -A Binormal ly D i s t r i b u t e d Motor Unit F iber Array Generat ion. 231 003B4 - - $eject$ 232 003B4 - -233 003B4 '1- PROCEDURE Create radi i f i l e ; 234 003B4 - -235 003B4 - - VAR 236 00048 - - ftle_name 237 00052 - - command 238 0006B - -239 0006B - -240 0006B 2- BEGIN 241 00044 - -242 00044 - - f i l e n a m e := " ; 243 0004E - - command : • ' ' ; 244 00058 - - wr1testr(f11e_name,1, 'FIBS',MU_number:0, 245 OOOF4 wr1testr(command,1,'$CREATE ',f11e_name: 246 00168 - - MTS_C0MMAND (command,20); 247 0017E - - REWRITE(radi1_f11e,f11e_name); 248 00190 - -249 00190 -1 END "Create_rad11_f11e"; 250 001F8 - -ID=SNAP 21:54 25 JUL 82 PAGE 8 ALFA; s t r ing; . ' , var i at1on_code:0); 1); Binormal ly D i s t r i b u t e d Motor Unit F iber Array Generation. ID=SNAP 21:54 25 JUL 82 PAGE 9 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 001F8 001F8 001F8 001F8 001F8 001F8 00048 0006C 00070 006B0' 006BF 006BF 006BF 00042 00042 0004C 000B6 00120 0013C 001A6 001A6 00214 0022C 00244 00296 002E8 002F4 002FC 002FC 00308 00308 00310 0032C 00334 00350 00350 003CA 00444 00444 0045A 0045A 00488 004B6 004B6 00518 00528 00528 00546 00546 00629 $eject$ t- PROCEDURE Plot motor un i t ; 3-VAR temp, xmln, ymln, dx, dy, o r l g x , o r l g y , x, y Inc dumx, dumy t i t l e SHORT; INTEGER; vector ; ARRAY ( 1 . . 15) OF CHAR; 2- BEGIN t i t l e : = " ; wr1testr(t1t le,1, 'MOTOR UNIT H ',MU_number:0); PLOT_TEXT(1 24s ,7 .08 ,0 .14s . t1 t1e ,O.Os,15) ; I_F ((MU x_boundary > O.Os) AND (MU_y_boundary > O.Os)) THEN PLOT_TEXT(1.78s.6.5s.0.10s,'BINORMAL DISTRIBUTION'.O.Os,21); ELSE PLOT_TEXT(1.28s,6.5s.0.10s.'UNIFORM CIRCULAR DISTRIBUTION',0.0s.29); dumx := x_f Ibers; dumy : • y_f Ibers; SCALE(dumx,No_of_fIbers,6,0s,xmln.dx,1); SCALE(dumy,No~of_f Ibers,6.0s,ymln,dy,1); IF (dy > dx) THEN dx :» dy; ELSE dy := dx; or lgx : • O.Os; IF (xmln < O.Os) THEN or lgx := - xmln / dx; or 1gy :» O.Os; IF (ymln < O.Os) THEN or lgy := - ymln / dy; AXIS(O.Os,or Igy, ' ' , - 1 , 6 . O s , 0 . 0 s , x m l n . d x ) ; AXIS(or Igx.O.Os, ' ' , 1 ,6 .Os,90.Os,ymln,dy) ; FOR Inc : = 1 TO No_of_fIbers DO BEGIN x := (x_f1bers(Inc) - xmln) / dx; := (y_f1bers(Inc) - ymln) / dy; PL0T_SYMBOL(x,y,0.08s,3.O.Os,- 1); 3 END; PLOT(9 .0s ,O .Os , -3 ) ; 1 END "Plot motot u n i t " ; Binormal ly D i s t r i b u t e d Motor Unit F iber Array Generation. ID=SNAP 21:54 25 JUL 82 PAGE 10 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 "328 329 330 331 332 333 334 335 336 337 338 339 340 00629 00629 00629 00629 00629 00048 0OO60 00064 00064 00064 00042 00042 OOOAC 000FE 00150 001A2 001A2 001B0 00232 00240 002C2 002C2 002D0 00352 00360 003E2 003E2 003 FO 00472 00480 00502 00502 00518 00518 005C4 00670 007 2A 007 3A 007 3A 007 A6 3-SHORT; INTEGER; - - $eject$ '1- PROCEDURE P l o t e l e c t r o d e ; - - VAR xmin, dx, ymin, dy, zmin, dz Inc 2- BEGIN PL0T_TEXT(0.Os,9.OS,0.10s.'ELECTRODE SURFACE POINTS'.O.Os.24); SCALE(Surface_po1nts(x ,1) ,No_of_surface_points ,3 .0s,xmin,dx,1) ; SCALE(Surface_points(y ,1) ,No_of_surface_po1nts,3 .Os.ymln.dy,1) ; SCALE(Surface_po1nts(z ,1) ,No_of_surface_po1nts,3 .Os.zmin,dz.1) ; IF (dx > O.Os) THEN A X I S ( 0 . 0 s , 5 . 0 s , ' X ' , - 1 ,3 .0s ,0 .0s ,xmin ,dx) ; IF (dz > O.Os) THEN AX IS (0 .05 .5 .0s , 'Z ' , 1 , 3 .0s ,90 .Os ,zm1n ,dz ) ; IF (dy > O.Os) THEN A X I S ( O . O s , 1 . O s , ' Y ' , 1 , 3 . O s , 9 0 . O s . y m l n . d y ) ; IF (dx > O.Os) THEN A X I S ( O . O s , 1 . O s , ' X ' , - 1 , 3 . 0 s , 0 . 0 s , x m 1 n , d x ) ; IF (dy > O.Os) THEN A X I S ( 4 . 0 s . 1 . O s , ' Y ' , 1 , 3 . O s . 9 0 . O s . y m l n . d y ) ; IF (dz > O.Os) THEN AX I S ( 4 . O s , 1 . O s , ' Z ' , - 1 , 3 . O s , 0 . O s , z m I n , d z ) ; FOR Inc := 1 TO No_of_surface_points DO  BEGIN PL0T_SYMB0L(Surface_po1nts(x,1nc). (Surface_points(z,1nc)+5.0s) ,0.07s,9,O.Os, 1); PLOT SYMBOL(Surface_po1nts(x,1nc),(Surface_po1nts(y,1nc)+1.Os),0 07s .9 ,0 O s , - 1); PLOT SYMBOL((Surface po1nts(y ,1nc)+4 .Os) . (Sur face_points(z ,1nc)+1 .Os) ,0 .07s ,9 ,0 .0s , - 1) END; 1 END "Plot e lect rode" Binormal ly D i s t r i b u t e d ID=SNAP 21:54 25 JUL 82 PAGE 11 34 1 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 007 A 6 007A6 007A6 007 A6 007A6 00048 0004C 0004C 0004C 00044 00044 OOOFO OOOFO 0010C 0010C 0014C 0020E 0024C 002 4C 0024C 00250 00290 00314 00314 00314 00386 003AC 003AC 003C2 003C2 003CE 004 3A 0044C 004E0 004F0 004 FO 00562 005A0 005A0 005B6 005B6 005C2 006 2C 0063E 006DA 006E A 006EA 00706 00706 008AC 3-3-INTEGER; -1 Motor Unit F iber Array Generat ion. $eject$ PROCEDURE Pr1nt_parameters: VAR 1nc BEGIN w r l t e C ' O ' , ' ' : 1 5 , ' T h e r e are ' , N o _ o f _ f I b e r s : 0 , ' f i b e r s In the motor u n i t . ' , E O L ) ; J_F ((MU_x^boundary > O.Os) AND (MU_y_boundary > O.Os)) THEN  BEGIN wr1te( ' ' : 1 6 , ' T h e s e f i b e r s are b lnomla l ly d i s t r i b u t e d with standard devia t ions o f ) ; wr1te(MU_x_boundary:0.' m.m. and ' ,MU_y_boundary:0. ' m.m. ' .EOL, ' ' :16) ; wr1te('1n the x and y d i r e c t i o n s r e s p e c t I v e l y . ' . E O L ) ; END; ELSE  BEGIN wr1te(' ' : 1 6 , ' T h e s e f i b e r s are un l formal ly d i s t r i b u t e d throughout a c l r c l u l a r ' ) ; w r l t e ( ' area with a radius of ' , a r r a y _ r a d 1 u s : 0 , ' m.m. ' .EOL); END; w r 1 t e ( ' - ' , ' ' :15 ,No_of_sur face_po1nts:O, ' po ln t (s ) have been used to simulate ' ) ; wr1te( ' the e lec t rode sur face: ' ) ; FOR Inc :» t JO No_of_surface_po1nts DO  BEGIN IF. (No_of_surface_po1nts > 1) THEN wr1te(E0L. ' ' : 4 0 . ( 1 n c - 1 ) : 2 , ' ' : 10 ) ; FOR coord : ° x TO z DO wr1te(Surface_po1nts(coord, Inc) :15:4 , ' ' : 5 ) ; END; w r 1 t e ( E 0 L , ' O ' , ' ' : 1 5 , ' D i s t a n c e s have been c a l c u l a t e d for ' ) ; wr1te(No_of_samp11ng_pos1tIons:0,' sampling p o s i t i o n s : ' ) ; FOR Inc := 1 TO No_of_sampl1ng_pos1tIons DO  BEGIN IF (No_of_samp11ng_pos1t1ons > 1) THEN wr1te(E0L. ' ' : 4 0 , 1 n c : 2 , ' ' : 10 ) ; FOR coord := x TO y DO wr1te(Samp)1ng_pos11Ions(coord,Inc ) : 15:4, ' ' : 5 ) ; END; wr l te(EOL); END "Prlnt_parameters"; Binormal ly D i s t r i b u t e d Motor Unit F iber Array Generat ion. ID=SNAP 21:54 2b UUL 82 PAGE 12 391 008AC - - $eject$ 392 008AC - -393 008AC "1- BEGIN 394 OOOCA - -395 OOOCA - - REWRITE(OUTPUT.G); 396 00OD8 - - wr1te( ' 1 ' , E O L ) ; 397 0010E - -398 OOIOE - - Read_contro1_f1le; 399 00114 - -400 00114 - - IF. (var1at1on_code <= 0) THEN 401 0011E - - Generate_motor_un1t; 402 00124 ELSE 403 00124 - - Read_MU_f1le; 404 0012E - -405 0012E - - Create_rad11_f1le; 406 00134 407 00134 - - FOR I p o s n : • 1 TO No_of_sampl1ng_pos1tIons DO 408 0014E 2- BEGIN 409 0014E - - FOR 1_surpt := 1 TO No_of_surface_po1nts DO 410 00168 3- BEGIN 411 00168 - - x_coord1nate := Sampl1ng_pos1t1ons(x,1_posn) + Surface_po1nts(x,1_surpt); 412 001B0 - - y_coord1nate := Sampl1ng_pos111ons(y,Iposn) + Surface_po1nts(y.1_surpt) ; 413 001F8 - - FOR 1_f1ber : • 1 TO No_of_f1bers DO 4 14 0O212 4- BEGIN 415 00212 - - rad1us_SQR SOR(x_coord1nate - x_f1bers(1_f Iber)) ; 416 0023E — radl1_SQR(1_surpt.1_fIber) := rad1us_S0R + S0R(y_coord1nate - y_f1bers(1_f Iber) ) ; 417 002B2 - -418 002B2 -4 END; 419 002C6 -3 END; 420 002DA - - wr1te(rad11_f1le.radl1_SQR); 421 00318 -2 END; 422 0032C - -423 0032C - - PLOT(1 .Os .O .Os . -3 ) ; 424 0034A - -425 0034A - - I £ (var1 a t l o n c o d e <« O) THEN Plot_motor_un11; 426 0035A - -427 0035A - - Pr1nt_parameters; 428 0O36O - -429 00360 - - I_F (No_of_surface_po1nts > 1) THEN P lo t_e lec t rode ; 430 00372 - -431 0O372 - - PLOTND; 432 00378 -1 END. * * * * * No e r rors detected * • * » * 0.796 CPU sec . "1 SMUAP Si m u l a t i o n U B C P A S C A L Vers ion: November 14.1981 ID=SNAP 21:54 25 JUL 82 PAGE1 * OPTIONS * ' ALIGN CASEDIST CASENEXT DUMPTABLE IBM370 INDEXCHECK LIST MCCARTHY OBJFILE PRECEDENCE RANGECHECK TITLE ID=SNAP 21:54 25 JUL 82 PAGE 2 S ing le Motor Unit Act ion Potent ia l S imulat ion . $e jec t ,111 le= 'S ing le Motor Unit Act ion Potent ia l SImulat Ion. ' .under 1Ine.upper,opt 1mlze+$ t l _ _ 17/10/79 g . kenward This program simulates the generat ion of a motor un i t a c t i o n p o t e n t i a l . The potent ia l produced represents the sum of a number of s i n g l e f iber ac t ion p o t e n t i a l s generated u t i l i z i n g a current d ipo le model (D.C. Boyd, M.Ap.Sc. t h e s i s . U . B . C . 1976). This s imula t ion program expands on Boyd's o r i g i n a l work, and Incorporates an lsotropy, amplitude J i t t e r , b inormal ly as well as uniformly d i s t r i b u t e d f iber arrays, v a r i a b l e f i b e r numbers, f i n i t e e lect rode surface area and e f f e c t i v e e lectrode sampling rad ius , along with ax ia l d i s p e r s i o n , and ax ia l J i t t e r . The random array of f i b e r s Is generated by the program GEN.O (kenward, 1979). INPUT from uni t 7 (as Inputted to the GEN.O program): 1 OOOOO 2 OOOOO 3 OOOOO 4 OOOOO 5 OOOOO 6 OOOOO 7 OOOOO 8 00000 9 0000Q 10 OOOOO 1 1 00000 12 OOOOO 13 OOOOO 14 OOOOO 15 OOOOO 16 00000 17 00000 18 00000 19 OOOOO 20 OOOOO 21 OOOOO 22 OOOOO 23 OOOOO 24 OOOOO 25 OOOOO 26 OOOOO 27 OOOOO 28 OOOOO 29 OOOOO 30 OOOOO 31 OOOOO 32 OOOOO 33 OOOOO 34 OOOOO 35 OOOOO 36 OOOOO 37 OOOOO 38 OOOOO 39 OOOOO 40 OOOOO 41 OOOOO 42 OOOOO 43 OOOOO 44 OOOOO 45 OOOOO 46 OOOOO 47 OOOOO 48 OOOOO 49 OOOOO 50 OOOOO 51 OOOOO 52 OOOOO 53 OOOOO 54 OOOOO 55 OOOOO 56 OOOOO 57 OOOOO 58 OOOOO MU_number GEN'var la t lon Total_no_of_f Ibers MU_x_boundary MU_y_boundary Tota1_no_of_surface_po1nts Electrode_surface_po1nts Total_no_of_sampl1ng_pos1tIons Samp11ng_pos1t1ons INPUT from the f i l e FIBS . : motor unit (M.U.) number; the v a r i a t i o n code for the sampling p o s l s t l o n s , and the surface points used to ca lcu la ted the r a d i a l d1stances. tota l number of f i b e r s In the M.U. (max. 200); standard dev ia t ion of normal d i s t r i b u t i o n of f i b e r s In x d i r e c t i o n ; standard dev ia t ion of normal d i s t r i b u t i o n of f i b e r s In y d i r e c t i o n ; If MU_x_boundary or MU_y_boundary are less than or equal to O, a uniform c i r c u l a r d i s t r i b u t i o n with a radius of 2.50 Is used; to ta l number of points on electrode surface (max. 13); the e lect rode surface points r e l a t i v e p o s i t i o n s ( x , y , z ) ; number of e lec t rode recording pos i t ions (max. 10); e lect rode recording p o s i t i o n coordinates ( x , y ) ; The f i l e F I B S ' x x ' . ' y y ' Is assigned to uni t 1 by the program. 'xx' Is the motor un i t number, and ' y y ' Is the GEN v a r i a t i o n code, as read from unit 7. f i b e r rad11 SOR - - INPUT from unit 8: the radius from each f ibe r squared, for each e lec t rode surface po in t , at each recording p o s i t i o n . The parameters for ax ia l d i s p e r s i o n , ax ia l J i t t e r , amplitude J i t t e r , anlsotropy and e f f e c t i v e e lec t rode sampling radius can have a number of values, however It Is NOT p o s s i b l e to vary more than one of these values during a simulat ion run. See user documentation for fur ther explanat ion and an example. SIM v a r i a t i o n No_of_d1spers1ons Axia l d ispers ions a code designat ing the simulation run; the f i l e names 'PARS . . ' and 'POTS . . ' are created from the MU number and the GEN and SIM v a r i a t i o n codes. the number of ax ia l d ispers ion to be read 1n. the standard dev la t lon(s ) of the d ipo le ax ia l d l s p e r s l o n ( s ) Single Motor Unit Act ion Potent ia l S imulat ion . ID=5NAP 21:54 2b JUL KAut 3 59 00000 GO OOOOO 61 OOOOO 62 OOOOO 63 OOOOO 64 OOOOO 65 OOOOO 66 OOOOO 67 OOOOO 68 OOOOO 69 OOOOO 70 OOOOO 71 OOOOO 72 OOOOO 73 OOOOO 74 OOOOO 75 OOOOO 76 OOOOO 77 OOOOO 78 OOOOO 79 OOOOO 80 OOOOO 81 OOOOO 82 OOOOO 83 OOOOO 84 OOOOO 85 OOOOO 86 OOOOO 87 OOOOO 88 OOOOO 89 OOOOO 90 OOOOO 91 OOOOO 92 OOOOO 93 OOOOO 94 OOOOO 95 OOOOO 96 OOOOO 97 OOOOO 98 OOOOO 99 OOOOO 100 OOOOO 101 OOOOO 102 OOOOO 103 OOOOO 104 OOOOO 105 OOOOO 106 OOOOO 107 OOOOO 108 OOOOO 109 OOOOO 1 10 OOOOO 1 1 1 OOOOO 1 12 OOOOO 113 OOOOO 114 OOOOO 1 15 OOOOO 1 16 OOOOO No_of_ax1a1_J1tters A x i a l J 1 t t e r s No_of_ampl1tude _J1t te rs Ampl1tude_J1tters No_of_an1sotropy_ratlos An lsot ropy_ra t los No_of_effect1ve_rad11 Ef fect1ve radi1 M1n1mum_samp11ng_range Max1mum_samp11ng_range No_of_fIbers No_of_surface_po1nts No of_potent1als In m.m. (max. 10 va lues ) ; - - the number of ax ia l d ispers ions to be read In. - - the standard dev la t lon(s ) of the d ipo le ax ia l J l t t e r ( s ) In microseconds.(max. 10 va lues ) ; - - the number of amplitude J i t t e r s to be read In. - - the standard dev la t lon(s ) of the amplitude j i t t e r In u n i t s (max. 10 va lues ) ; - - the number of an lsotropy r a t i o s to be read In. - - the r a t l o ( s ) of rad ia l to ax ia l c o n d u c t i v i t i e s squared (max. 10 va lues ) ; - - the number of e f f e c t i v e rad i i to be read In. - - the e f f e c t i v e e lect rode sampling r a d i i In m.m. (max. 10 va lues ) ; a value of I n f i n i t y Is entered as 0; - - the minimum range of e lectrode sampling p o s i t i o n s in m.m. (1 va lue ) ; - - the maximum range of e lectrode sampling p o s i t i o n s In m.m. (1 va lue ) ; - - The number of f i b e r s from the array s imulat ion (1 va lue: 0 < No_of_fIbers <= Total_no_of_f Ibers) ; -•• the number of e lect rode surface points to be used In each s imula t ion (1 va lue: O < No_of_surface_po1nts <= Total_no_of_surface_po1nts); - - the number of p o t e n t i a l s to be produced during each s imula t ion (max. 50). NOTE: The sample p o s i t i o n s and surface po in ts are used 1n the same sequence that they were Inputted to GEN.0. OUTPUT to un i t 6: and thus used A l l the parameters read In on un i ts 7 and 8, In the s imu la t ion . In e a s i l y read format. A l s o , in e a s i l y read format, the fo l lowing c a l c u l a t e d values for the average po ten t ia l c a l c u l a t e d at each e lec t rode sampling p o s i t i o n , for each v a r i a t i o n of the above parameters: samplIng_rad11 L0G_samp1lng_rad1us potent1al_max imum potent ia1_m1nimum pp_amp11tude L0G_pp_ampl1tude zero_cross ing max1mum_zero_crossIng mln1mum_zero_cross1ng pp_duratIon LOG_pp_durat ion RMS_power LOG_RMS_power f i b e r count The sampling d is tance; the LOG of sampl1ng_rad11; the maximum amplitude; the minimum amplitude; the peak to peak amplitude; the LOG of pp_amp1Itude; the zero crossing point ; the distance between the zero c r o s s i n g point and the point of maximum ampli tude; the distance between the zero c r o s s i n g point and the point of minimum amplitude; the peak to peak durat ion; the LOG of pp_durat1on; the R.M.S. power; the LOG of RMS_power; the the number of f ibe rs used In the s imulat ion at each p o s i t i o n - - 1e: t h i s parameter Is a funct ion of the e f f e c t i v e sampling radius. 0^ Sing le Motor Unit Act ion Potent ia l S imulat ion. For use by the p l o t t i n g rout ines: ID=SNAP 21:54 25 JUL 82 PAGE 4 117 OOOOO -118 OOOOO -119 OOOOO -120 OOOOO -121 OOOOO -122 OOOOO -123 OOOOO -124 OOOOO -125 OOOOO. -126 OOOOO -127 OOOOO -128 OOOOO -129 OOOOO -OUTPUT * ° / h « / ; n ^ A ^ - m - e - : f r o m u n , t s ? a n d 8 p , u s t h o s e c a l c u l a t e d values l i s t e d above. ThVaverage potenTiaT' i^d the variance of the po ten t ia ls for each s imula t ion . Both f i l e s are created by the SIMulatlon program. ID=SNAP 21:54 25 JUL 82 PAGE b 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 00000 OOOOO OOOOO 00100 00100 00100 00100 00100 00100 00100' 00100 00100 00100 00100 OOIOO 001O0 OOIOO 00100 001OO OOIOO OOIOO OOIOO OOIOO OOIOO OOIOO OOIOO OOIOO 001OO 00104 001O4 00104 001O4 00104 00104 00104 00104 00104 00148 00148 00148 00158 00158 00290 00290 00330 00330 015FO 015F0 015FO 015F0 017D0 017D0 0180C 0180C 01B3C 01B3C 043EC 043EC $eject$ CONST x y z - - TYPE VAR no_of_z_po1nts mm_per_m1crosec mm_per_m111Isec del ta_z f I r s t z z_secs center B max_no_of_potentlal s no_of_z_pos1t1ons very_h1gh very_low under parameter_vector s t r i n g vector radl1_array = 1; = 2; = 3; = 200; = 0.004; = 4.0; = 0.4; = -40.0; = del ta_z * 1.0e-6 * (no_of_z_po1nts - 1) / mm_per_m1crosec; = 1 ; = 0.25; = 50; = 200; •= 1.0E74; = -1.0E74; « ARRAY (1. .10) OF REAL; = ARRAY (1. .18) OF CHAR; = ARRAY (1. .200) OF SHORT; = ARRAY (1. .13) OF vector ; SIM_var1at1on, GEN_var1atIon No_of_d1spers1ons, No_of_ax1al_J1tters, No_of_ampl1tude_JItters, No_of_an1sotropy_rat1os, No_of_effeet 1ve_radt1, MU_number, Tota l_no_of_f1bers , Total_no_of_surface_po1nts, Total_no_of_sampl1ng_pos1t1ons. No_of_f Ibers, No_of_surface_po1nts, No_of_potent1 a 1s, 1_posn_start, 1_posn_end, Inc. n_sca1e, n_SQR_sca1e MU_x_boundary, MU_y_boundary, M1n1mum_samp11ng_range. Max1mum_sampl1ng_range E1ec t rode_sur f ace_po1n t s Sampl1ng_pos1t1ons z_po1nts, d i s p e r s i o n , zero_vector Ax1al_d1spers1ons, Ax1a1_JIt ters, Ampl1tude_JIt ters, An 1 so t ropy_ra t los , Ef fect1ve_rad11, sampl1ng_rad11 GEN_f1le, SIM_f11e. resul t_f11e p o t e n t l a l s _ f 1 l e radl1_SQR_f l ie INT; INTEGER; SHORT; ARRAY (x ..2 ,1 . .13) OF REAL; ARRAY ( x . . y , 1 . . 1 0 ) OF REAL; ARRAY (1..200) OF REAL; parameter_vector; TEXT; FILE OF vector ; FILE OF radl1_array; 6" Sing le Motor Unit Act ion Potent ia l S imulat ion. 188 043EC --189 043EC --190 043EC i -191 043EC --192 043EC --193 043EC 1 1 194 00078 11 195 00080 1 1 196 00078,, 1 1 197 00078 --198 00078 --INITIAL zero vector = ARRAY 0.0:200 END: FUNCTION SYSTEM_CLOCK (par : SHORT) : SHORT FUNCTION INIT_RANDOM_NORMAL (par : SHORT) : SHORT FUNCTION RANDOM_NORMAL (par : SHORT) : SHORT PROCEDURE MTS COMMAND (command : s t r i n g ; count : INTEGER) ID = 5NAP 21:54 2S» JUL 82 FAUt fa FORTRAN 'SCLOCK'; FORTRAN 'RANDN'; FORTRAN 'FRANDN'; FORTRAN 'CMD'; 0^ Sing le Motor Unit Act ion Potent ia l S imulat ion . The actual m u l t i - l o o p s imula t ion program. ID=SNAP 21:54 25 JUL 82 PAGE 7 199 00078 200 00078 201 00078 202 00O78 203 00078 204 O0O78 205 00078 206 0OO78 207 0O078 208 00078 209 00070 210 00070 211 00088 212 00088 213 00088 214 00088 215 00O88 216 00088 217 00O88 218 00088 219 00088 220 00138 221 00138 222 0013C 223 0013C 224 0013C 225 007 7C 226 007 7C 227 007 7C 228 01A40 229 01A40 230 042EO 231 042EO $eject ,subt1t1e='The actual mu l t i - loop s imulat ion program.'$ PROCEDURE Simulate (Ax la1_d1spersIon. Ax1a1_J1tter, Ampl1tude_J1tter , An1sotropy_rat1o, Effect1ve_rad1us : REAL); "This rout ine simulates a given number of potent ia l f i r i n g s for the given parameters. The r e s u l t s Include the c a l c u l a t e d parameters mentioned prev ious ly , plus the average po ten t ia l and the var iance of the p o t e n t i a l s over the mul t ip le f i r i n g s , 1f any." VAR 1_posn. 1_fIbers, 1_surpts, 1_pots, 1_z, f1ber_count z _ s t a r t , rad1us_SQR. amplitude, potent1a1_max1mum, potent1a1_m1n1mum, RMS_power, z_max1mum, z_m1n1mum, zero_cross1ng, ax1al_J1tter_sca1ed, tempz, tempi temp2, L0G_sampl1ng_rad1us, LOG_RMS_power, pp_ampl1tude, pp_durat1on, LOG_pp_ampl1tude, LOG_pp_duratIon, max1mum_zero_duratIon, m1n1mum_zero_duratIon, e f f e c t 1ve_radtus_SQR seed shor t_average_potent la l , short_var1ance_of_potent la ls p o t e n t i a l , average_potent la l , var1ance_of_potent1a 1s f i b e r radl1_SQR INTEGER; REAL; SHORT; vector ; ARRAY (1. .200) OF REAL; radl1_array; Single Motor Unit Act ion Potent ia l S imulat ion . To p r i n t out a header for c l a r i t y : ID=SNAP 21:54 25 JUL 82 PAGE 8 232 042E0 -- $eJect ,subt1 t le= 'To p r i n t out a header for c l a r i t y : ' $ 233 042E0 "--234 042E0 2- PROCEDURE Pr in t header: 235 OOOOO --236 OOOOO -- TYPE 237 00048 -- number = (ZERO,ONE,TWO,THREE,FOUR,FIVE,SIX,SEVEN,EIGHT,NINE,TEN); 238 00048 --239 00048 -- VAR 240 00048 -- run : number; 241 0004A --242 00O4A 3- BEGIN 243 00040 --244 00040 -- run : «= number(Inc); 245 0005C -- w r l t e C l ' . ' ' :3,'SIMULATION NUMBER ' , r u n : 0 , E O L ) ; 246 000F4 -- w r 1 t e ( ' 0 ' : 4 . ' r a d i a l d i s t a n c e ' , ' ' :3. 'minimum a m p l i t u d e ' , ' ' : 5 , ' p - p ampl i tude' . 247 001A4 -- ' ' : 7 , ' p - p d u r a t i o n ' . ' : 7 , ' R . M . S . power ' , ' ' : 6 , ' z e r o c r o s s i n g ' , ' ' : 7 , 248 0025A -- ' f i b e r c o u n t ' . E O L ) ; 249 00294 -- w r 1 t e ( ' + ' , ' ' : 3 , u n d e r : 1 5 , ' :3 .under :17 , ' ' : 5 . u n d e r : 1 3 , ' ' : 7 ,under :12 , ' ' :7 .under :12 , 250 003BE -- ' ' : 6 , u n d e r : 1 3 , ' ' : 7 , under:11,EOL); 251 0043E -- wr1te(' ' : 9 , ' L 0 G ( . ) ' , ' ' : 7 , maximum ampl1tude' , ' ' : 8 , ' L 0 G ( . ) ' . ' ' : 13 , ' L 0 G ( . ) ' , ' ' : 1 3 . 252 00534 - - ' L 0 G ( . ) ' , ' ' :10 , 'm1n. to z e r o ' , E O L ) ; 253 005A6 -- w r 1 t e ( ' + ' , ' ' : 8 , u n d e r : 6 , ' ' 7 ,under :17 , ' ' : 8 , u n d e r : 6 , ' ' : 1 3 , u n d e r : 6 , ' ' : 13,under:6, 254 006C4 -- ' ' :10 ,under :12 .EOL) ; 255 007 14 -- wr1te( ' ' :101, 'max. to zero ' , E 0 L , ' + ' , ' ' :10O,under:12,EOL); 256 007CE --257 007CE -2 END "Pr1nt_header"; 258 00911 --Single Motor Unit Act ion Potent ia l S imulat ion . To output and p r i n t the resu l tant fea tures: ID=SNAP 21:54 25 JUL 82 PAGE 9 259 0091 1 260 0091 1 - -261 0091 1 2-262 0091 1 --263 0091 1 3-264 0004C --265 0004C --266 OOOCC,. --267 00134 --268 00182 --269 00100 --270 00200 --271 00200 --272 OO204 --273 00392 --274 OO306 --275 0045E --276 004E2 --277 0051A --278 00564 --279 00564 -2 280 005A8 --$eject ,subt1t1e='To output and pr in t the resul tant f ea tu res : ' $ PROCEDURE Output_potent1a1_features; BEGIN wr1te( resul t_ f1 le ,sampl Ingradl1(1_posn) :0:7 ,potent la lmlnlmum:0:7 ,pp_ampl 1tude:0: 7, pp_durat Ion: 0: 7 , RMS_power -.0:7, zero_cross 1ng:0:7 , f 1ber_count, L0G_samp11ng_rad1us:0:7.potent 1 al_maxImum:0:7,L0G_pp_amp11tude :0:7 , LOG_pp_durat1on:0:7,LOG_RMS_power:0:7,m1n1mum_zero_durat 1 on: 0: 7, max1mum_zero_duratIon:0:7,EOL); wr 11 wr1te( ' I t e ( ' 0 ' , ' ' :3 ,sampl1ng_rad11(1_posn):15:3, ' ' :4 ,potent lal_mInImum:15:4.' ' :4,pp_ampl1tude: 15:4, ' ' :4 ,pp_durat Ion:15:4 , ' msecs ',RMS_power: 1 1 : - 4 , ' ' :4 ,zero_cross Ing:15:4 , ' msecs ' , :4 , f1ber_count :2 .EOL); :4,L0G_samp11ng_rad1us:15:4,' ':4.potent1al_maxImum:15:4,' ' :4,LOG_pp_ampl1tude:15:4, ' ' :4 ,L0G_pp_durat1on:15:4, ' ':4,LOG_RMS_power:15:4,' ' :4 ,n»1n1mum_zero_durat Ion:15:4, ' msecs ' ,EOL) ; wr1te(' ':99,max1mum_zero_durat1on:15:4,EOL): END "Output_potent1al_features" ; ID=SNAP 21:54 2b JUL 82 PAUt 1U F i n a l l y , the SIMulatlon loops: 281 005A8 — $ e J e c t , s u b t 1 t l e = ' F 1 n a l l y , the SIMulatlon l o o p s : ' $ 282 0O5A8 *•-283 005A8 2- BEGIN "Simulat ion" 284 0003C - -285 0003C - - RESET(rad11_S0R_f1le); 286 0O04C - - effect1ve_radlus_SQR := SQR(Effect 1ve_rad1us); 287 00056 - - ax1a l_ j1 t te r_sca led :» Ax1al_J1tter * mm_per_m1crosec; 288 00064,, - - Pr1nt_header; 289 0006E - -290 0006E "Start s i m u l a t i o n , f i r s t looping thru the number of sampling p o s i t i o n s : " 291 0006E - -292 0006E - - FOR 1_posn := 1 TO Total_no_of_sampl1ng_pos1t1ons DO 293 00088 3- BEGIN 294 00088 - -295 00088 - - read(radi1_SQR_f1le,f1ber_rad11_S0R); 296 000C4 - -297 000C4 - - IF (1_posn > 1_posn_end) THEN EXIT; 298 00004 - - I £ ( I p o s n < 1_posn_start) THEN LOOP; 299 000E4 - -300 OOOE4 - - f l b e r c o u n t :» O; 301 OOOEA - - average_potent la l := zero_vector ; 302 OOOFC - - var1ance_of_potentla 1s : • zero_vector ; 303 00114 - - RMS_power := 0.0; 304 0011C - - seed : • SYSTEM_CLOCK(O.OS); 305 0013A - - seed := INIT_RANDOM_NORMAL(seed); 306 00150 - -307 00150 - - "Loop thru the number of f i r i n g s for the motor u n i t : " 308 00150 - -309 00150 - - FOR 1_pots :» 1 TO No_of_potent1als DO 310 0016A 4- BEGIN 311 0016A - - po tent ia l : • zero_vector ; 312 0017C - -313 0017C - - "Loop thru the number of f i b e r s In the motor u n i t : " 314 0O17C - -315 0017C - - FOR 1_f1bers := 1 TO No_of_f1bers DO 316 00196 5- BEGIN 317 00196 - - IF. ( (Ef fect ive_rad1us > 0.0) AND ( f Iber rad l1_S0R(center , 1_f Ibers) > 318 00196 - - e f f e c t i v e rad1us_SQR)) THEN LOOP; 319 001DA - - IF. (1_pots - l7 THEN INCR( f Ibercount) - . 320 001F2 - - IF (Ampl1tude_jItter > 0.0) THEN 321 00200 6- BEGIN 322 00200 - - amplitude := Ampl1tude_j1tter * RANDOMNORMAL(O.OS) + 1.0; 323 00232 - - amplitude := MAX(0.0.ampl1tude); 324 00242 -6 END; 325 00242 - - ELSE 326 00242 - - amplitude := 1.0; 327 0024E - -328 0024E - - z_s tar t := Ax1al_d1spers1on * d1spers1on(1_fIbers); 329 00278 - -330 00278 - - "D ispers ion 1s c a l c u l a t e d In INITIALIZE_sImu1 at Ion 1n MAIN." 331 00278 - -332 00278 - - IF (Ax1al_J1tter > 0.0) THEN 333 00286 - - z_star t := z_s tar t + ax 1 a 1 _ J 1 1 t e r s c a l e d * RANDOM_NORMAL( 0. OS): 334 0O2C0 - -335 002C0 - - "Loop thru the number of e lec t rode sur face p o i n t s : " 336 002C0 - - ^ 337 002C0 - - FOR 1_surpts : = 1 TO No_of_surface_po 1 nts DQ Single Motor Unit Ac t ion Potent ia l S imulat ion . F i n a l l y , the SIMulatlon loops: ID=SNAP 21:54 25 JUL 82—PAGE H 338 002DA 6-339 002DA "--340 0032E --341 00358 --342 00358 --343 00358 344 00358 345 0O36A 7-346 0036A --347 003BE --348 0038E --349 0038E — 350 0038E --351 003B8 --352 003E2 --353 00436 -7 354 00442 -6 355 00456 -5 356 0046A --357 0046A --358 0046A --359 0046A --360 0047C 5-361 0047C --362 004D8 --363 00542 -5 364 0054 E -4 365 00562 --366 00562 --367 00562 --368 00562 --369 0056A --370 00572 --371 0057A --372 0057A --373 0058C 4-374 0058C --375 005CC --376 005CC --377 005CC --378 005CC --379 005EE --380 0060A --381 00630 --382 0063C 5-383 0063C --384 00644 --385 0066A -5 386 0066A --387 00676 5-388 00676 --389 0067E --390 006A4 -5 391 006A4 --392 006AC --393 006B2 --394 006BC --BEGIN rad lusSQR := An1sotropy_rat lo * f1ber_rad11_SQR(1_surpts,1_f Ibers); z_star t := z_star t ••• E 1 ectrode_surf ace_po 1 n ts (z , 1_surpts); "Now, generate the po ten t ia l along the 200 point z a x i s : " FOR 1_z := 1 TO no of_z_po1nts DO  BEGIN tempz :» z_po1nts(1_z) + z _ s t a r t ; "z_po1nts(200) Is setup In INITIALI2E_sImulat Ion In MAIN." tempi :« SORT(SQR(tempz - B) + rad1us_SQR): temp2 : = SORT (SOR (tempz + B) + rad1us_SQR); potent ia l (1_z) := potent1a1(1_z) + amplitude * (I.O/tempI - 1.0/temp2); END "z loop"; END "surpts loop"; END " f i b e r s loop"; "Sum the average and var iance :" FOR 1_z : • 1 TO no_of_z_po1nts DO  BEGIN average_potent la l (1_z) := average_potent lal (1_z) + potent1al(1_z); var iance of_potent1als(1_z) := var1ance_of_potentlals(1_z) + S0R(p o t e n t i a l ( 1 _ z ) ) ; END; END "pots loop"; "Now c a l c u l a t e the var ious features of the average p o t e n t i a l : " potent1al_max1mum := very_low; ' potent1a1_m1n1mum :» very_h1gh; temp2 := 0 .0; FOR 1_z : • 1 TO no_of_z_po1nts DO  BEGIN tempi := average_potent1al(1_z) / n_sca1e; "n_scale and n_S0R_sca1e are c a l c u l a t e d In INITIALIZE_s1mulat1on In MAIN.1 short_average_potent la l (1_z) := R0UNDT0SH0RT(tempi); IF. ((tempi >= 0.0) AND (temp2 < 0.0)) THEN zero_cross1ng := z_po1nts(1_z); IF (potent1al_max1mum < tempi) THEN BEGIN potent la1_max1mum :» tempi; z_max1mum := z_po1nts( i_z) ; END; IF (potent1al_m1n1mum > tempi) THEN  BEGIN potent1a1_m1n1mum := tempi; Z_m1n1mum : = z_po1nts(1_z); END; temp2 := temp 1; tempi := SOR(tempi); RMS_power := RMS_power + tempi; tempi := var1ance_of_potentla Is(1_z) / n_SOR_scale - tempi; Sing le Motor Unit Act ion Potent ia l S imulat ion . F i n a l l y , the SIMulatlon loops: 395 00708 - - short_var1ance_of_potent1a1s(1_z) := R0UNDT0SH0RT(tempi) 396 0072C -4 END; 397 00738 - -398 00738 - - "Calcula te the rest of the values use to study the model behaviour 399 00738 - -400 00738 - - RMS_power : * SQRT(RMS_power) / z_secs ; 401 00754 - - z_max1mum := z_max1mum / mm_per_m1111 sec; 402 00762, - _ z_m1n1mum := z_m1n1mum / mm_per_m1111 sec; 403 0076C - - zero_cross1ng := zero_cross1ng / mm_per_m1111 sec; 404 00776 - -405 00776 - - "If a l l works as hoped, these next four values should be p o s i t i v e : 406 00776 - -407 00776 - - pp_amp1Itude := potent1a1_maxImum - potent1al_m1n1mum; 408 00782 - - pp_durat1on := z_max1mum - z_m1n1mum; 409 0078E - - max1mum_zero_duratIon := z_max1mum - zero_cross1ng; 410 00798 - - m1nlmum_zero_durat1on := zero_cross1ng - z_mln1mum; 411 007A0 - -412 007A0 - - IF. (RMS power > 0.0) THEN 413 007AE - - LOG_RMS_power :« LOG10(RMS_power) ; 414 007C4 - - ELSE 415 007C4 - - L0G_RMS_power :» -1 .0e-76; 416 007D0 - - JF. (pp_amplItude <> O.O) THEN 417 007DE - - LOG_pp_amplItude := L0G1O(ABS(pp_ampl1tude)); 418 007FE - - ELSE 419 007FE LOG_pp_ampl1tude := -1 .0e-76; 420 0080A - - If. ( p p d u r a t l o n <> 0.0) THEN 42 1 008 18 - - L0G_pp_durat1on :» L0G1O(ABS(pp_duratIon)); 422 00838 - - ELSE 423 00838 - - LOG_pp_duratIon : - -1 .0e-76; 424 00844 - - IF_ (sampl Ingradl1(1_posn) > 0.0) THEN 425 O0874 - - L0G_sampl1ng_rad1us := LOG10(sampHng_rad11(1_posn)); 426 008AC - - ELSE 427 008AC - - L0G_sampl1ng_rad1us := -1 .0e-76; 428 008B8 - -429 008B8 - - "sample_rad11(10) comes from INITIALIZE_s1mu1atIon In MAIN." 430 008B8 - -431 008B8 - - 0utput_potent1al_features; 432 OOBC2 - - wr1te (potent la ls_f1 le ,shor t_average_potent la l ); 433 00902 - - IF (No_of_potent lals > 1) THEN 434 0090E - - wr1 te (potent la ls_ f1 le ,shor t_var1ance_of_potent la ls ) ; 435 0094E - -436 0094E - -437 0094E - - /f##iy/f###SNAP ; H HH H H H It H H H H U H H H H H H tt H H H H H It B H H" ; 438 0094E - -439 0094E -3 END "posn loop"; 440 00962 -1 END "s imula t ion" ; 441 OOAIO - -Sing le Motor Unit Act ion Potent ia l S imula t ion . To i n i t i a l i z e v a r i a b l e s fo r the s imula t ion . ID=SNAP 21:54 25 JUL 82 PAGE 13 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 OOA10 00A10 00A10 00A10 00A10 OOA10 00A10 00048 0004C" 00O58 0005C 00066 00066 00048 00048 00048 00048 00050 00062 000B2 000B2 OOOB2 000B2 OOOB8 000BC OOOD2 000D2 0011C 00132 00158 00172 0017A 0018E 00196 001A4 001A4 001A4 001A4 OOIBO 001B8 001C4 001CC 001D8 001E0 001EO 001EA 001F2 001 FC 00204 00204 00204 00226 0023C 00256 0026C 002B8 002B8 $e jec t ,subt1 t le= 'To I n i t i a l i z e va r iab les for the s i m u l a t i o n . ' $ PROCEDURE INITIALIZE_s1mulat1on; "This procedure I n i t i a l i z e s the s imulat ion program." VAR 1 ter temp seed f i l e name INTEGER; REAL: SHORT; ALFA; BEGIN " I n i t i a l i z e z point coordinate vec to r : " z_po1nts(1) :» f 1 r s t _ z ; FOR Iter .- * 2 TO no_of_z_po1nts DO z_po1nts( I ter) :» z_potnts(1ter -1) + de1ta_z: "Ca lcu la te sampling r a d i i and def ine sampling range Indices:" 1_posn_end :» 0; 1_posn_start :» 0; FOR Iter : • 1 TO Total_no_of_sampl1ng_pos1t1ons DO  BEGIN temp :» SOR(Sampl1ng_pos111ons(x,1ter)) + SQR(Sampl1ng_pos1t1ons(y, 1 te r ) ) ; temp := SORT(temp); sampl1ng_rad11(1ter) : • temp; IF ((1_posn_start « 0) AND (temp >= M1n1mum_sampl1ng_range)) THEN 1_posn_start I ter; IF (temp > Max1mum_sampl1ng_range) THEN EXIT; 1_posn_end := I ter; END; "To l imi t the number of s imulat ion parameters:" F (No_of_fIbers > Tota1_no_of_fIbers) THEN No_of_fIbers := Tota1_no_of_fIbers; IF (No_of_surface_po1nts > Tota1_no_of_surface_po1nts) THEN No_of_surface_po1nts := Total_no_of_surface_po1nts; F (No_of_potent1als > max_no_of_potent1als) THEN No_of_potent1als := max_no_of_potent1a1s; F (No_of_potent1a1s <= O) THEN No_of_potent la ls : • 1; F (No_of_surface_po1nts <= 0) THEN No_of_surface_po1nts := 1; "To generate the same d i s p e r s i o n for a given motor uni t each s imulat ion:" seed := SHORT(MU_number); seed : = SORT(seed); seed := INIT_RAND0M_N0RMAL(seed); FOR Iter := 1 TO No_of_fIbers DO d1spers1on(Iter) := RAND0M_N0RMAL(O.OS); "Set up s c a l i n g fac to rs for average and variance c a l c u l a t i o n s : " aJ Sing le Motor Unit Act ion Potent ia l S imulat ion . To I n i t i a l i z e v a r i a b l e s for the s imu la t ion . ID=SNAP 21:54 25 JUL 82 PAGE 14 499 002B8 500 002B8 501 002C4 502 002D0 503 002D0 504 002D0 505 002D0 506 002DA, 507 00370 508 00382 509 00382 510 0040C n_scale := No_of_potent1a1s *' No_of_surface_po1nts; n_SQR_scale :« n_sca1e * No_of_surface_po1nts; "To open the f i l e conta in ing the r a d i i to the f i b e r s : " f11e_name := ' ' ; wr l tes t r ( f1 le_name,1 . 'F IBS ' ,MU_number :0 , ' . ' :1 ,GEN_var la t Ion:0 ) ; RESET(radl1_SQR_f11e,f11e_name); END "INITIALIZE s imula t ion" ; Single Motor Unit Ac t ion Potent ia l S imulat ion . To read the parameters from GEN.O. ID = SNAP 21:54 2b JUL B2 H Alat 13 511 0040C 512 0040C 513 0040C 1 -514 0040C --515 004OC --51G 0040C --517 0040C --518 0040C --519 00048 520 00050 521 00050 2 -522 00046 --523 00046 --524 00046 --525 00046 --526 00058 --527 00058 --528 OOOE4 --529 000F6 --530 000F6 --531 0010C --532 001 1E --533 00192 --534 00192 --535 001 AC --536 001C2 --537 001D4 --538 00250 --539 00250 - 1 540 00294 --$eject ,subt1t1e='To read the parameters from GEN.O. '$ PROCEDURE Read_GEN_parameters; "This procedure reads the parameters inputted to the GEN.O program and used by the s imulat ion program" VAR 1 1n, coord INTEGER; BEGIN "Assign uni t 7 to G E N _ f i l e : " RESET(GEN_f11e,7); read(GEN_f1le, MU_number, GEN_varlatIon, Tota l_no_of_ f ibers , MU_x_boundary, MU_y_boundary, Total_no_of_surface_po1nts); FOR 1_1n : • 1 TO Total_no_of_surface_po1nts DO  FOR coord :» x TO z DO read(GEN_f1le, Electrode_surface_po1nts(coord,1_1n)) ; read(GEN_f1le,Total_no_of_samp11ng_pos1t1ons); FOR 1_1n := 1 TO Total_no_of_samp1ing_pos1tions DO  FOR coord :» x TO y DO read(GEN_f1le.Sampling_posit ions(coord,1_1n)) ; END "Read_GEN_parameters"; Single Motor Unit Act ion Potent ia l S imula t ion . To read SIMulatlon parameters. ID=SNAP 21:54 25 JUL 82 PAGE 1G 541 00294 - - $eject ,subt1t1e='To read SIMulatlon parameters. '$ 54 2 00294 "--543 00294 1- PROCEDURE Read_SIM_parameters; 544 00294 - -545 00294 - - "This rout ine reads those parameters that e f fec t the s imulat ion d i r e c t l y . " 546 00294 - -547 0O294 - -548 00294 2- PROCEDURE read n var1ab1es(VAR no : INTEGER; VAR data : parameter_vector); 549 OOOOO - -550 00000 - - VAR 551 00050 - - 1_1n : INTEGER; 552 00054 - -553 00054 3- BEGIN 554 00044 - -555 00044 - - read(SIM_f11e.no); 556 0005E - - FOR 1_1n := 1 TO no DO 557 00078 - - read(SIM_f11e,data(1_1n)); 558 OOOC4 - -559 0OOC4 -2 END "read_n_var1ables"; 560 OOOF8 - -561 000F8 - -562 000F8 2- BEGIN 563 00046 - -564 00046 - - "Assign uni t 8 to SIM_f11e." 565 0O046 - -566 00046 - - RESET(SIM_f11e,8); 567 00058 - - read(SIM_f1le. SIM_var1at1 on); 568 0008C - - SIM_varlatIon := ABS(SIM_var1atIon); 569 000A8 - -570 OOOA8 - - read_n_var1ables(No_of_d1spersIons, Ax1al_d1spers1ons); 571 000C2 - - read_n_var1ables(No_of_ax(al_JI t ters. Ax1a l_J1t ters ) ; 572 OOODC read_n_var1ab1es(No_of_amp11tude_jItters. Ampl1tude_J1tters); 573 0O0F6 - - read_n_var1ab1es(No_of_an1sotropy_rat1os. An 1sotropy_rat los) ; 574 00114 - - read_n_var1ables(No_of_effect1ve_rad11, Effect1ve_rad11); 575 0012E - - read(SIM_f1le.M1n1mum_samp11ng_range, Max1mum_sampl1ng_range, No_of_fIbers, 576 00178 - - No_of_surface_po1nts, No_of_potent la ls ) ; 577 0019C - -578 0019C -1 END "Read_SIM_parameters"; 579 001DA - -Sing le Motor Unit Act Ion Potent la l S imula t ion . To setup up the output of r e s u l t s : ID=SNAP 21:54 25 JUL 82 PAGE 17 580 001DA -- $eject ,subt1t1e='To setup up the output of r e s u l t s : ' $ 581 001DA j _ 582 001DA 1- PROCEDURE Setup output (no of d i s p e r s i o n s , no of ax ia l J i t t e r s , no of ampl1tude J 1 t t e r s , 583 00 IDA -- no_of_an1sotropy_rat los, no_of_effect1ve_rad11 INTEGER); 584 001 DA --585 OOIDA -- "This procedure creates the r e s u l t f i l e s and outputs to them, and to unit 6, the var ious 586 001DA -- parameters before s imula t ion Is I n i t i a t e d . " 587 00 IDA --588 001DA' -- VAR 589 0005C -- no_of_samples, 1_out, coord : INTEGER; 590 00068 -- f11e_name, command • : s t r i n g ; 591 0008C 592 0008C 593 0008C 2- PROCEDURE wri te n v a r i a b l e s (VAR no : INTEGER; VAR data : parameter vec tor ) ; 594 OOOOO --595 OOOOO -- VAR 596 00050 -- 1_out : INTEGER; 597 00054 --598 00054 3- BEGIN 599 00044 --600 00044 -- wr1te(result f l l e . n o ) ; 601 0006 A -- FOR 1_out :» 1 TO no DO 602 00084 -- wr1 te ( resu l t_ f11e ,da ta ( i _ou t ) , ' ' ) ; 603 OOOFA --604 OOOFA -2 END "wr i te_n_var lab les" ; 605 0012C --' 606 0012C --607 0012C 2- BEGIN 608 00040 --609 00040 -- REWRITE(0UTPUT,6); 610 0004 E -- no_of_samples := 1_posn_end - 1_posn_start + 1; 611 0005E -- f11e_name := ' ' ; 612 0OO68 -- command := ' ' ; 613 00072 --614 00072 wr 1 t e s t r ( f 1 le name, 1, ' PARS' : 4 ,MU number : 0 , ' . ' : 1 ,GEN var lat 1on :0, ' . ' : 1. SIM v a r i a t i o n s ) 615 00130 -- wrltestr(command,1,'$CREATE ' : 8 . f 1 l e n a m e : - 1); 616 0019E -- MTS COMMAND*command,18); 617 001AE -- REWRITE(resu1t_f11e,f11e_name); 618 00 ICO --619 001C0 -- wr1testr ( f11e_name,1, 'POTS' : - 1); 620 00208 -- wr 1 test r (command,9 , 'POTS' : -1 ) ; 621 00256 -- MTS COMMAND(command,18); 622 00266 -- REWRITE(potent 1 a 1s_f11e, f11ename); 623 00278 --624 00278 -- wr1te(result_f11e,MU_number,' ' ,GEN_var1a t ion . ' ' ,SIM_var1at1on, ' ' ,No_of_ f Ibers , ' ' , 625 00340 -- No_of_surface_po1nts,E0L); 626 00372 627 00372 -- FOR 1 out := 1 TO No of surface po ints DO 628 00388 3- BEGIN 629 00388 -- FOR coord := x TO 2 DO 630 0039A -- wr1te ( resul t_ f1 le ,E1ect rode_sur face_po1nts(coord ,1_out ) , ' ' ); 631 00428 -- wr1te(resul t f i l e , E O L ) ; 632 00448 -3 END; 633 00458 --634 00458 -- wr1te(result_f11e.no_of_samp1es, ' ' , N o _ o f _ p o t e n t l a l s ) ; 635 004A E -- wr1te_n_var tables(no_of_d1spersIons,Ax1al_d1spers1ons); 636 004C 8 -- wr1te_n_var lab les (no_of_ax la l_J1t ters ,Ax1a l_J1t ters ) ; Sing le Motor Unit Act ion Potent ia l S imulat ion. To setup up the output of r e s u l t s : ID=SNAP 21:54 25 JUL 82 PAGE 18 G37 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 004 E 2 004 FC 0051A 00534 00550 00550 005A A 0068Q 00746 0076A 007 EO 00832 00832 008 AC 0094 E 00986 00986 009F8 00A68 OOB12 00B28 00C0A 00C76 00CE0 OOCEO 00DA4 00DB0 00DC2 00DE8 00DE8 00E2C OOE2C OOE46 00E46 OOEAC OOEOA OOFOO OOFOO OOF 68 OOF78 OOF78 01068 01 128 01 13E 0120C 012CE 012CE 01370 013B0 013BC 013FC 013FC 01416 014CE 014CE 0155A 0157C 3-wr1te_n_var1ables(no_of_ampl1tude_JItters,Ampl1tude_JItters); wr1te_n_var lab les(no_of_an1sotropy_rat los ,Anlsotropy_rat los) ; wr1te_n_var1ables(no_of_effeet 1ve_rad11.Effect 1ve_rad11); wr1 te ( resu l t_ f1 le .EOL) ; w r l t e C l ' . ' ' : 3 7 , ' S i n g l e Motor Unit Act ion Potent ia l S i m u l a t i o n ' , E O L . ' * ' , ' ' : 3 7 . u n d e r : 4 5 , E O L , ' - ' , ' ' : 1 0 , ' R e c o r d l n g var la t Ion ' ,GEN_var1atIon:0, ' of Motor Unit H ' , M U _ n u m b e r : 0 , ' . ' , E O L , ' 0 ' , ' ' : 1 5 . ' T h e Motor Unit Is ' ) ; IF ((MU_x_boundary <«= 0.0) OR (MU_y_boundary <= 0.0)) THEN wr1te( 'a unlf.ormly d i s t r i b u t e d c i r c u l a r array of ' ,No_of_ f Ibe rs :0 . ' f i b e r s ' , E O L , ' ' :16 , 'w1th a radius of 2.5 ml 11 Imeters . ' ,EOL); ELSE wr1te( 'a b inormal ly d i s t r i b u t e d array of ' , N o _ o f _ f I b e r s : 0 , ' f I b e r s , ' , E O L , ' ' : 1 1 , ' w i t h standard dev ia t ions of ' ,MU_x_boundary:0, ' and ',MU_y_boundary:0, ' m i l l imeters In the x and y d i r e c t i o n s r e s p e c t i v e l y . ' , E O L ) ; w r 1 t e ( ' 0 ' , ' ' : 1 5 , ' T h e e lec t rode was simulated with ' ,No_of_surface_po1nts:0, ' of the ' ,To ta l_no_of_sur face p o 1 n t s : 0 , ' e lect rode surface p o l n t ( s ) : ' . E O L ) ; w r 1 t e ( ' 0 ' . ' ' : 3 7 , ' x ' . ' ' : 2 4 , ' y ' , ' ' : 2 4 , ' z ' ) ; FOR 1_out := 1 TO No_of_surface_po1nts DO wr1te(E0L, ' ' : 2 1 , 1 _ o u t : 2 , ' ' :8 ,E1ectrode_surface_po1nts(x ,1_out) :15:3 , ' m . m . ' , ' ' : 5 , E1ectrode_surface_po1nts(y ,1_out) :15:3 , ' m . m . ' , ' ' : 5 , E lectrode_surface_po1nts(z ,1_out ) :15:3 , ' m.m.' ) ; w r 1 t e ( ' ; ' , E O L , ' 0 ' , ' ' : 1 5 , ' A n d with ' ,no_of_ef fect1ve_rad11:0 , ' e f f e c t i v e r a d i i : ' ) ; IF. (no_of_effeet 1ve_rad1i = 1) THEN IF_ (Effect1ve_rad1 1( 1) = 0.0) THEN w r t t e C I n f i n i t y ' ) ; ELSE wr1te(Ef fect1ve_rad11(1) :0:1 , ' m.m. ' ) ; ELSE FOR 1_out :« t JO no_of_effect1ve_rad11 DO  BEGIN w r i t e ( E 0 L , ' ' : 4 0 , 1 _ o u t : 2 , ' ' : 10 ) ; IF (E f fec t1ve_radH(1_out ) = 0.0) THEN w r 1 t e ( ' I n f i n i t y ' ) ; ELSE wr1te(Effect1ve_rad11(1_out) :15:2, ' m.m. ' ) ; END; w r 1 t e ( ' . ' , E O L , ' 0 ' , ' ' : 1 5 , ' T h e r e were ' ,no_of_samples :0 , ' sample(s) recorded a t : ' , E O L , ' 0 ' , ' ' : 2 0 , ' x c o o r d i n a t e ' , ' ' : 1 3 , ' y c o o r d i n a t e ' , ' ' : 2 3 . ' r a d i a l . d i s t a n c e ' , EOL); FOR 1_out := 1_posn_start TO 1_posn_end DO wr1te( ' ' :17,Sampl1ng_pos111ons(x,1_out):15:2, ' m . m . ' , ' ' :5,Sampl1ng_pos111ons(y,1_out): 15:2, ' m . m . ' . ' ' :18,samplIng_rad11(1_out):15:2. ' m.m. ' ,EOL); w r 1 t e ( ' - ' , ' ' : 1 0 , ' F o r s imulat ion v a r i a t i o n ' , S I M _ v a r l a t 1 o n : 0 , ' : ' , E O L ) ; wr1 te ( ' 0 ' : 16 , 'The medium was given r a t l o ( s ) of ax ia l to rad ia l conduct iv i ty squared o f : ' ) ; IF (no_of_an1sotropy_rat1os = 1) THEN wr1te( ' ' ,An lso t ropy_ra t1os (1 ) :O :2 ) ; ELSE FOR 1_out := 1 TO no_of_an1sotropy_rat1os DO wr1te(E0L. ' ' : 4 0 , 1 _ o u t : 2 , ' ' : 10 ,An 1sot ropyrat1os(1_out ) :15:4 ) ; w r 1 t e ( ' , ' , E O L , ' 0 ' , ' ' : 1 5 , ' T h e p o t e n t i a l s were given ax ia l d ispers ion w i t h ' , ' standard dev la t lon (s ) o f : ' ) ; IF (no_of_d1spers1ons = 1) THEN _ J OO Single Motor Unit Act ion Potent ia l S imulat ion. To setup up the output of r e s u l t s : ID 694 01588 wr1te(' ' ,Ax 1al_d1spers1ons(1) :0:2 , ' m.m. ' ) ; 695 015E6 ' - - ELSE 696 015E6 - - FOR 1_out := 1 TO no_of_d1spersIons DO 697 01600 - - wr1te(E0L, ' ' : 4 0 , 1 _ o u t : 2 , ' ' :10,Ax 1 a1_d1spers1ons( lout ) :15: 2, ' m.m 698 016D6 - -699 016D6 - - w r 1 t e ( ' , ' , E 0 L , ' 0 ' , ' ' : 1 5 , ' a x i a l j l t t e r ( s ) o f : ' ) ; 700 01762 - - IF. (no_of_axial_J I t ters = 1) THEN 701 0176E - - w r l t e C ' , A x 1 a l _ J 1 t t e r s ( 1 ) : 0 : 2 , ' u s e e s ' ) ; 702 017CC - - ELSE 703 017CC - - FOR 1_out : - 1 TO no_of_ax1 a1_J1tters DO 704 017E6 - - wr1te(E0L. ' ' : 4 0 , 1 _ o u t : 2 , ' ' : 1 0 . A x 1 a l _ J 1 t t e r s ( i _ o u t ) : 1 5 : 2 , ' u s e e s . ' 705 018BC - -706 018BC - - w r 1 t e ( ' ; ' , E 0 L , ' 0 ' , ' ' : 1 5 , ' a n d amplitude J l t t e r ( s ) o f : ' ) ; 707 01948 — IF. (no_of_ampl 1 tude_J 1 t te rs « 1) THEN 708 01954 - - wr1te( ' ' ,Ampl1tude_J1t ters(1) :0 :2) ; 709 01990 - - ELSE 710 01990 - - FOR 1_out :» 1 TO no_of_ampl1tude_J1tters 00 711 019AA - - wr1te(E0L, ' ' : 4 0 , 1 _ o u t : 2 , ' ' : 10 ,Ampl1 tude_J11ters ( lout ) :15 : 2); 712 01A5E - - w r 1 t e ( ' ; ' . E O L ) ; 713 01A94 - -714 01A94 -1 END "Setup_output"; 715 01E2F - -Single Motor Unit Ac t ion Potent ia l S imula t ion . The main program, for parameter v a r i a t i o n : ID-=SNAP 21:54 25 JUL 82 PAGE 20 716 01E2F --717 01E2F --718 01E2F 1-719 0014A --720 0014A --721 0014A --722 0014A --723 OO150 --724 00156 --725 0015C --726 0015C --727 0015C --728 0015C --729 0015C --730 0015C --731 0015C --732 00168 2-733 00168 --734 00170 --735 0018E --736 001A4 --737 OO10E --738 00204 -2 739 00204 --740 00204 --741 00214 2-742 00214 --743 00236 --744 0024C --745 00284 --746 002AA -2 747 002AA --748 002AA --749 002BA 2-750 002BA --751 002DC --752 002F2 --753 0032A --754 00350 -2 755 00350 --756 00350 757 00360 2 -758 00360 --759 00368 --760 00386 --761 0039C --762 003B8 --763 003FA - 2 764 003FA --765 003FA --766 0040A 2 -767 0040A --768 004 12 --769 00430 --7 70 00446 --77 1 00462 --772 004 A 4 -2 $eJect,subt1t1e='The main program, for parameter v a r i a t i o n : ' $ "Read In a l l the pe r t lna te parameters and I n i t i a l i z e the s imulat ion v a r i a b l e s : 1 Read_GEN_parameters; Read_SIM_parameters; INITIALIZE_s1mu1atIon; "##/C#####/C###########CINF0( TERSARY , FALSE ) ; H HH H N H H » H U HUM It H H It HHHHMHHHHMHMIIItH " "Only one of the parameters can be looped thru dur ing a run :" IF (No_of_d1spers1ons > 1) THEN  BEGIN No of p o t e n t l a l s := 1; 1); Setup_output(No_of_d1spers1ons,1,1,1 FOR Inc := 1 TO No_of_d1spers1ons DO SImulate (Ax1a1_d1spers1ons(Inc) ,Axial_J1tters(1) ,Ampl1tude_j1tters ( 1), An1sotropy_rat1os(1) ,Effect1ve_rad11(1)) ; END; ELSE _F (No_of_ax1al_JItters > 1) THEN  BEGIN Setup_output(1,No_of_ax1a1_J1tters,1,1,1) ; FOR 1nc := 1 TO No_of_ax1al_J1tters DO SImulate (Ax1al_d1spers1ons(1) ,Axlal_J1tters( Inc) ,Ampl1tude_J1tters( 1) An1sotropy_rat1os(1) ,Effect1ve_rad11(1)) ; END; ELSE IF (No_of_amp1Itude J i t t e r s > 1) THEN  BEGIN Setup_output(1,1,No_of_ampl1tude_J1tters,1,1); FOR Inc := 1 TO No_of_ampl1tude_J1tters DO SImulate (Ax1a1_d1spers1ons(1),Ax1al_J1tters(1),Ampl1tude_J1tters(Inc), An1sotropy_rat1os(1) ,Effect1ve_rad11(1)) ; END; ELSE IF (No_of an1sotropy_rat1os > 1) THEN  BEGIN No_of_potent la ls := 1; Setup_output(1,1,1,No_of_an1sotropy_rat l o s , 1); FOR Inc := 1 TO No_of_an1sotropy_ratios DO Simulate (Ax1a1_d1spers1ons(1) ,Axla lJ1t ters(1) ,Ampl1tude_J1tters ( 1), Anlsotropy_rat1os(1nc) .Ef fect1ve_rad11(1) ) ; END; ELSE I_ (No_of_effect1ve_rad11 > 1) THEN  BEGIN No_of_potent la ls := 1 ; Setup_output(1,1,1,1,No_of_effect1ve_rad11); FOR inc .= 1 TO No_of_effeet 1ve_radi1 DO Simulate (Ax1al_d1spersIons(1) ,Ax1al_J1tters(1) ,Ampi1tude_J1tters( 1), Ani sotropy_rat1os(1) ,Ef fect1ve_rad11( Inc) ) ; END; Single Motor Unit Act ion Potent ia l S imulat ion . The main program, for parameter v a r i a t i o n : ID = SNAP 21:54 25 JUL 82 PAGE 21 773 0O4A4 - - ELSE 774 0O4A4 775 004A4 - - "for none of the parameters are to be v a r i e d . " 776 004A4 - -777 004A4 2- BEGIN 778 004A8 - - inc :» 1; 779 004B0 - - No_of_potent1a1s := 1; 780 O04B4 - - Setup_output (1 ,1 ,1 .1 ,1 ) ; 781 004CE' Simulate (Axta l_dispers1ons(1) ,Axla l_ j11ters(1) ,Ampl1tude_j1t ters( 1), 782 O04EA - - An lsot ropy_ra t1os(1 ) ,E f fec t 1ve_radi1(1)); 783 00500 -2 END; 784 00500 - -785 00500 - - "»*ri»*»UHHHH*»H»Htt»»HH#»%Hl>V\»H*KHHHHH 786 00500 - -787 00500 - - w r 1 t e ( E 0 L . ' - ' . ' s i m u l a t i o n s run f i n i s h e d . ' ) ; 788 00558 - -789 00558 -1 END. * * * * * No e r rors detected * * * * * 1.394 CPU sec . 1 8 2 E.3 P l o t t i n g of SMUAPs B C P A S C A L - Vers ion: November 1-1,1981 ID=SNAP 22:21 30 JUL 82 PAGE OPTIONS * • ALIGN CASEDIST CASENEXT DUMPT ABLE IBM370 INDEXCHECK LIST MCCARTHY OBJFILE PRECEDENCE RANGECHECK TITLE Plo t Average and Variances of P o t e n t i a l s . ID=SNAP 22:21 30 JUL 82 PAGE 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 00000 00000 OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO $eject ,11t1e='Plot Average and Variances of Potent 1 a 1s. ' ,under 11ne,upper$ II ' " This program p l o t s the average and variances ca lcu la ted b y the program SIM.O (g. kenward. 1979), INPUT from unit 7: The PARS . . f i l e , from which the fo l lowing are used: MU_number, GEN_variat ion, SIM_variatIon, Noof_samples, No_of_potentla 1s: And, depending on which, i f any, of the fo l lowing were var ied , the number and values of that parameter, l e : e i ther the No_of_dispersIons, and the Axia1_dispers ions, the No_of_ax la l_ j i t t e rs , and the A x i a 1 _ j i t t e r s , the No_of_amplItude_J1tters, and the Amp 1itude_j11ters, the No_of_anisotropy_rat1os, and the Anisot ropy_rat ios , or the No_of_effect1ve_rad1I, and the Effect1ve_rad1I. And then, the Sampling_rad1i and the Fiber_count for each sampling p o s i t i o n and parameter v a r i a t i o n . A l l other values are skipped by the program. INPUT from POTS . . , which 1s opened by the program i t s e l f : The average_potent1al, and - - i f No_of_potentials > 1 each sampling p o s i t i o n and parameter v a r i a t i o n . the variance_of_potent1als for NOTE: for descr ip t ions of P A R S . . and POTS . . see S I M . P . OUTPUT to uni t 9, the p lo ts of: The average_potentI a 1 and the var iance_of_potent ia Is ( i f NO_of_potentI a 1s > 1) for each sampling pos i t ion and each parameter v a r i a t i o n DO NOT run *PRPLOT with th is program, the resu l ts could be d isasterous. CXp Plot Average and Variances of P o t e n t i a l s . ID=SNAP 22:21 30 JUL 82 PAGE 3 46 OOOOO -- $eject$ 47 OOOOO --48 OOOOO -*- CONST 49 00100 -- x_length = 6 .0s; 50 00100 -- y_length = 3.0s; 51 00100 -- y_space = 0 .5s; 52 00100 -- new_x_or1g1n = x_length + 2 .0s; 53 00100 -- mm per_m1111sec = 4 .0s; 54 00100 -- t_m1n = -10 .0s; . 55 00100" -- t_1nc = 20.0s / x_length; 56 00100 - - del ta_t_sca1ed = x_1ength / 200.0s; 57 00100 -- no_of_po1nts = 200; 58 00100 -- sub_start = 5: 59 00100 --60 00100 -- TYPE 61 00100 -- vector = ARRAY (1..200) OF SHORT; 62 00100 -- s t r l n a = ARRAY (1..20) OF CHAR; 63 00100 --64 00100 -- VAR 65 00100 -- MU_number. GEN_var1 at 1 on. SIM_var1at1on, No_of_samp 66 00100 -- No_of p o t e n t i a l s , no_of_var1 at Ions, PARS_flag, 67 00100 -- 1_var1at1on, t1 t le1_len 68 00124 -- • 69 00124 -- SamplIng_rad11, parameters 70 00174 --71 00174 -- F i b e r c o u n t 72 00174 73 00304 --74 00304 -- t Ime 75 00624 --76 00624 -- t l t l e l 77 00638 --78 00638 -- t1 t le2 79 0069C --80 0069C -- POTS_f1le 81 009CC --82 009CC --83 009CC -- INITIAL 84 009CC --85 009CC -- t i t l e 2 = ARRAY 86 009CC -- (' AXIAL DISPERSION = ' 87 009CC -- (' AXIAL JITTER = ' ) , 88 009CC -- (' AMPLITUDE JITTER = ' 89 009CC -- (' ANISOTROPY RATIO = ' 90 009CC -- (' EFFECTIVE RADIUS = ' 91 009CC -- END: 92 009CC 93 009CC PROCEDURE PLOT(x, y : SHORT ; f l a g : INTEGER) 94 009CC 11 95 00078 1 1 PROCEDURE PLOT END 96 00060 1- PROCEDURE PLOT TEXT(x, y, height : SHORT ;VAR labels : st 97 00060 - 1 length : INTEGER) 98 OOOOO 1 1 PROCEDURE DASH LINE(dash1, space 1, dash2, space2 : SHORT) 99 0O080 1 1 PROCEDURE AXIS SCONTROL(option : ALFA; values : SHORT) 100 00078 1 1 PROCEDURE AXIS ICONTROL(opt 1 on : ALFA; values : INTEGER) 101 00078 1 1 PROCEDURE PLOT AXIS(labels : ALFA; angle. S i z e . min. de1t 102 00088 1- PROCEDURE SCALE(VAR data: vector : no: INTEGER: s i r e : SHOR 103 00088 -1 f l a g : INTEGER) INTEGER; ARRAY (1..10) OF SHORT; ARRAY (1 . .10 ,1 . .10 ) OF INTEGER; vector; s t r i ng; ARRAY ( 1 . 5 ) OF s t r i n g : FILE OF vector : angle : SHORT; SHORT) VAR min, FORTRAN; FORTRAN SLINKAGE FORTRAN FORTRAN FORTRAN FORTRAN PLOTNO' ; 'SYMBOL' DASHLN'; AXCTRL': AXCTRL ' ; AXPLOT'; de l ta : SHORT; FORTRAN 'SCALE' OO Plot Average and Variances of P o t e n t i a l s . ID=SNAP 22:21 30 .JUL 82 PAGE 4 104 00090 11 PROCEDURE PL0T_C0NTR0L(opt Ion : ALFA; values : SHORT) ; FORTRAN 'PLCTRL' : 105 00078 - -Plot Average and Variances of Po ten t i a ls To read the parameter f i l e : 106 107 108 109 1 10 111 112 113 114 115 1 16, 117 118 119 120 121 122 123 124 125 126 .127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 00078 00078 00078 00078 00078 00048 00054 00065 00065 00065 00000 00000 0004C 00050 00054 00054 0O03C 00052 00086 000A A 000A A 0O0AA 0005A 0005A 00068 00068 000A2 000B4 OOOCA 000E2 001 OA 0010A 00112 001 18 0012A 0012A 00140 0014C 0015E 0015E 00162 0O16A 00172 00188 001D6 001D6 001E2 001E2 001F8 0020E 0020E 0024C 0025E 002C0 002D2 002 F 2 002 F 2 $e ject ,sunt 111e='To read the parameter f 1 l e : ' $ PROCEDURE Read PARS f i l e ; VAR no. I ter , 1_var1at1on PARS f i l e 2-4-PROCEDURE sk1p_data(n : INTEGER): VAR 1 dummy BEGIN FOR f := 1 TO n DO read(PARS_f1le,dummy); END; BEGIN RESET(PARS_f1le,7); readf PARS_f1le,MU_number,GEN_var iatIon,SIM_var iatIon) sk1p_data(1); read(PARS_f1 le , I ter ) ; sk1p_data(3*1ter) ; read(PARS_f11e,No_of_samples,No_of_potentlals): no_of_varlat Ions := 1; PARS_f1ag := 0; FOR 1ter := 1 TO 5 DO BEGIN iead(PARS_f11e,no): J_F (no = 1) THEN sk1p_data(1): ELSE  BEGIN no_of_varlat Ions := no; PARS_flag := I ter; FOR 1_var1ation : - 1 TO no_of_var1 at1ons DO read(PARS_f He,parameters!1_var1a t ion) ) ; END: END: FOR 1_variat1on := 1 TO no_of_variat 1ons DO  FOR Iter := 1 TO No_of samp 1es DO I- BEGIN r ead(PARS_f 1 le , Sampl i n g r a d i 1 (.1 ter )); sk ip_data(5) ; read!PARS_f1 I e ,F1ber_count (1_var la t lon . l t e r l ) ; sk ip_data(7 ): •3 END; 1 END "Read PARS f i l e " ; ID=SNAP 22:2 1 30 JUL 82 PAGE 5 INTEGER; TEXT ; INTEGER; SHORT; Plo t Average and Variances of P o t e n t i a l s . To read the parameter f i l e : ID=SNAP 22:21 30 JUL 82 PAGE 6 163 00348 --164 00348 * 165 00348 1-166 00348 --167 00348 --168 00348 --169 00348 --170 00O48 --171 00048 --172 00048 --173 00048 --174 00048 --175 0004C --176 00060 --177 00064 --178 00064 --179 00064 2-180 00046 --181 0O046 --182 00046 --183 00046 --184 00050 --185 001 1E --186 0012C .--187 0012C --188 0012C --189 0012C --190 00134 --191 00146 --192 0019C --193 0019C --194 0019C --195 0019C --196 001A6 --197 001AE --198 00284 --199 00284 --200 00284 --201 00284 --202 00284 --203 00284 --204 0028C --205 002BC --206 002DC --207 002EA --208 00308 --209 00308 --210 00308 --211 00308 --212 0032 E 213 0032E - 1 214 003CC --$eject$ CONST - VAR r e _ o r i g l n sca1e_by 1 ter f11e_name sca le fac tor = -3; = 'SCAL' INTEGER: s t r ing; SHORT; BEGIN "Open the f i l e conta in ing the p o t e n t i a l s : " f11e_name := ' ' ; wr1 test r ( f11e_name,1 , 'POTS' ,MU_number:0 . ' . ' .GENvar i at i on :0 , ' . ' ,S IM_var ta t1on:0 ) : RESET(P0TS_fl ie,f1le_name1: "Set up the time values for the p lot ord lnates :" t1me(1) : * O.Os; FDR Iter := 2 TO no_of_po1nts DO t lme( i ter ) := t1me(1ter-1) + deIta_t_sca1ed; "Set up the plot t i t l e s : " t l t l e l : = " ; t i t l e 1 _ l e n := 1; wr t t e s t r l t l t l e l , t 1 t l e 1 _ l e n , ' POTENTIALS "And for p l o t t i n g : " * PLOT(1.Os,0.0s,re_or1g1n);" sca le_ fac to r := 1.0s; wr1teTn('>> S c a l e ? ' ) ; r ead !sea le_ fac to r ) : IF (sca le_ fac tor > O.Os) THEN PL0T_C0NTR0L(sca1e_by,scale_factor); "The var iance p l o t s are to he dashed:" DASH L INE(0 .06s ,0 .06s .0 .06s ,0 .06s) ; ,MU number:0, ' . ' ,GEN_vari a t i on:0. ,SIM var ia t1on:0 ) ; CxO Plot Average and Variances of P o t e n t i a l s . To p lo t the p l o t s : 215 003CC - - $e ject ,subt1 t le= 'To plot the p l o t s : 216 003CC -'-217 003CC 1- PROCEDURE Plot data(1 v a r i a t i o n : It 218 003CC - -219 003CC - -220 003CC — CONST 221 0004C - - X_or1g1n = 'XORI ' 222 0004C.. - - Y_or1g1n = 'YORI ' 223 0004C - - Labels 'LABE ' 224 0004C - - Labels_s1ze 'SYMS' 225 0004C - - D i g i t s 'DIGI ' 226 0004C - - Side 'SIDE' 227 0004C - - bottom = 1 228 0004C - - none = 0 229 0004C - - second = 2 230 0004C - - one = 1 231 0004C - - pen_up = 3 232 0004C - - pen_down = 2 233 0004C - - re_or1g1n = -3 : 234 0004C - - dash_pen = 4 235 0004C - - ccw = 1 236 0004C - - cw -237 0004C - -238 0004C - - VAR 239 0004C - - 1_posn, I ter , count 240 00058 - - y_or lg1n, min, de l ta 241 00064 - - average p o t e n t i a l , variance_o 242 006A4 - - t i t l e 243 006C2 - -ID=SNAP 22:2 1 30 JUL 82 PAGE INTEGER; SHORT: vector; ARRAY (1. .30) OF CHAR; Plot Average and Variances of P o t e n t i a l s . To p lo t the p l o t s : 244 006C2 - - $e jec t * 245 0O6C2 246 006C2 2- PROCEDURE p lot x ax 1 s ( y . o r 1 g i n : SHORT); 247 OOOOO - -248 OOOOO - -249 OOOOO 3- BEGIN 250 0003E - -251 0003E. - - AXIS_IC0NTR0L(S1de,cw); 252 0005C - - AXIS_SC0NTR0L(X_or1gin.0.0s); 253 0007A - - AXIS_SC0NTR0L(Y_or1g1n,y_or1gin); 254 00098 - - AXIS_SCONTROL(Labels_s1ze,0.14s); 255 OOOB6 - -256 000B6 - - AX IS_ICONTROL(Labels,one): 257 000D4 - - PLOTAXISf ' MSECS; ' ,O .Os,x_ length , t_m1n, t 258 0010A - -259 0010A -2 END " p i o t x a x 1 s " ; 260 00181 - -261 00181 - -262 00181 2- PROCEDURE p i o t _ y _ a x 1 s ( x o r 1 g 1 n , min, de l ta 263 00181 - -264 00181 - -265 00181 3- BEGIN 266 . 0003E • - -267 OOOSE AXIS_SCONTROL(X_or1g1n,x_or1g1n); 268 0005C - - AXIS_SCONTROL(Y_or1g1n,y_or1g1n); 269 0007E - - AXIS_ICOMTROL(Labels,one): 270 0009C - - AXIS ICONTROL(S1de,s1de); 271 OOOBA - - PLOT~AXIS ( ' ; ' , 90 .0s ,y_ leng th .mln ,de l ta ) ; 272 OOOEA - -273 OOOEA -2 END "piot_y_ax1s"; 274 00148 - -ID=SNAP 22:21 30 JUL 82 PAGE 8 Inc) : SHORT; side : INTEGER); rC> Plo t Average and Variances of Po ten t ia ls To p lo t the p l o t s : ID = SNAP 22:21 30 JUL 82 PAGE 9 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 00148 00148 00148 00O3C 0003C 00052 00052 00052. 0005A 00O5A 00090 000C6 00008 00102 00102 00124 00136 001 AO 001A0 001 AC 0O1AC 001E2 00218 00242 00242 00264 00276 002E0 002E0 002E0 002EE 002EE 002F8 00300 0039C 0039C 003A8 003A8 003B4 00472 00472 00472 004CC 004CC 004DA 004DA 004E8 004E8 004F2 004 F 2 004 FC 00504 005C6 00620 00620 0062E 0062E 4--4 4--4 $eject$ BEGIN FOR i_posn := 1 TO No_of_samp1es DO  BEGIN y_orIgln := 1.Os; read(POTS_f11e,average_potent1al); SCALE(average_potentla 1 ,no_of_points ,y_length, tn i n , d e 1 t a , 1 ) ; p lot_x_ax1s(y_orIgin): piot_y_axi s(0.Os.mi n ,de l ta .ccw) ; PLOT(t1me(1),(average_potent1al(1) + y_or ig ln ) .pen up): FOR i te r := 1 TO no_of_points DO PLOT(11me(1ter),(average_potent1al(1ter) + y_orig1n ),pen_down); I_F (No_of_potentials > 1) THEN  BEGIN read(POTS_f1le,var1ance_of_potentla Is); SCALE(var1ance_of_potenti a ls ,no_of_poi n ts ,x_ length ,min ,de l ta ,1 ) ; p lo t_y_ax is (x_ length ,min ,de l ta .cw) ; PLOT(time(1),(variance_of_potent1a1s(1) + y_or ig in) ,pen_up); FOR Iter := 1 TO no_of_points DO PLOT(t1me(i ter) , (var1ance_of_potent1 a 1s(1ter ) + y o r i g i n ) . d a s h _ p e n ) ; END; y_or ig in := y_orig1n + y_1ength; t i t l e := ' ' ; count := 1; wr1testr(1111e,count, ' R = '.Sampl1ng_radf1 ( i_posn):0) ; IF (PARS_flag BEGIN 5) THEN INCR(count); wrl t e s t r ( t i t l e , c o u n t , END: tt = , F iber_count(1_vari at ion,1_posn):0): PL0T_TEXT(O.Os,y_or fgtn.O. 10s,t i 11e,0.Os.count) : y _ o r i g i n := y_or igfn *• y_space; y_orig1n := y_or ig in + y_space; IF (PARS_flag > 0) THEN BEGIN t i t l e := " ; count := 1; wr 1 tes t r (t i t le,count,111le2,(PARS_flag):- 1,parameters( i_var iat ion) :0:2 ); PL0T_TEXT(O.0s .y_or ig in .O.14s . t1 t1e ,0 .Os.count ) ; y_or1gin := y_or ig in + 0.30s: END; Plot Average and Variances of Po ten t i a ls To p lo t the p l o t s : ID=SNAP 22:21 30 JUL 82 PAGE 10 332 0062E - - PL0T_TEXT(O.Os,y_or i q i n, 0 . 1 4 s , t l t l e l , O . O s . t l t l e l lent-333 00688 - -334 00688 - - PLOr(new_x_or1g1n.0.Os.re o r i g i n ) -335 006A6 - - ~ 336 006A6 -3 END; 337 0O6B6 - -338 006B6 -1 END " P l o t d a t a " ; 339 0076F - -340 0076F' - -Plo t Average and Variances of P o t e n t i a l s . To p lo t the p l o t s : 341 0O76F - - $eject$ 342 0076F J -343 0076F 1- BEGIN 344 OOOC4 - -345 000C4 - - Read_PARS_f1le; 346 OOOCA - -347 OOOCA - - INITIALIZE_plott ing; 348 OOODO, - -349 OOOOO - - FOR \_var1at1on := 1 TO no 350 000E6 - - Plot_data(1_var lat Ion); 351 00104 - -352 00104 - - PLOT_END; 353 0010A 354 0010A -1 END "main". No e r rors detected * t * * » 0.432 CPU sec . ID=SNAP 22:21 30 JUL 82 PAGE 11 DO P l o t t i n g of SMUAP Waveform Features U B C P A S C A L - Vers ion: November 14, 1981 ID=SNAP 12:51 31 JUL 82 PAGE 1 * OPTIONS * 1 OOOOO 2 OOOOO 3 OOOOO 4 OOOOO 5 OOOOO 6 OOOOO 7 OOOOO 8 OOOOO 9 OOOOO 10 OOOOO 1 1 OOOOO 12 OOOOO 13 OOOOO 14 OOOOO 15 OOOOO 16 OOOOO 17 OOOOO 18 OOOOO 19 OOOOO 20 OOOOO 21 OOOOO 22 OOOOO 23 OOOOO 24 OOOOO 25 OOOOO 26 OOOOO 27 OOOOO 28 OOOOO 29 OOOOO 30 OOOOO 31 OOOOO 32 OOOOO 33 OOOOO 34 OOOOO 35 OOOOO 36 OOOOO 37 OOOOO 38 OOOOO 39 OOOOO 40 OOOOO 41 OOOOO 42 OOOOO 43 OOOOO 44 OOOOO 45 OOOOO 46 OOOOO 47 OOOOO 48 OOOOO 49 OOOOO 50 OOOOO 51 OOOOO 52 OOOOO 53 OOOOO ALIGN CASEDIST CASENEXT DUMPTABLE IBM370 INDEXCHECK LIST MCCARTHY OBdFILE PRECEDENCE RANGECHECK TITLE $t1t1e='Plot SMUAP Waveform Features . ' ,under 11ne.upper,ootimlze+$ II _ _ _ 9/5 /80 . g. kenward. 28/5/80 This program p l o t s the features extracted from the average poten t ia ls generated by SIM.O (g. kenward, 1979). - INPUT from *SOURCE*: In response to prompts by the program (except in batch mode), the numbers of the motor un i ts to be aggregated in the p lo t information, arid the GEN and SIM v a r i a t i o n codes - - le : the information necessary to the program to access the ' P A R S - - . - - . - - ' f i l e s generated when the f i r i n g of each motor u n i t . A number of motor uni ts should be used each time to compensate for the s t a t l s c a l v a r i a t i o n of a s i n g l e motor u n i t . The v a r i a b l e s to be p l o t t e d , and the type of p l o t s to be p l o t t e d : Var iab les : AMP - - the p-p amplitudes of the p o t e n t i a l s . LOG_AMP - - the LOGs of AMP. DUR - - the p-p durations of the p o t e n t i a l s . LOG_DUR - - the LOGs of DUR. POWER - - the R.M.S. powers of the p o t e n t i a l s . LOG_POWER - - the LOGs of POWER. RADIUS - - the r a d i i of the sampling p o s i t i o n . LOG_RADIUS - - the LOGs of RADIUS. Types of p l o t s : POINTS - - a p lot of the po in ts . AVERAG - - a p lo t of the average p o i n t s . / LMS - - a Least Mean Square l inear f i t to the po in ts . POLY - - a Least Mean Square cubic poly f i t to the p o i n t s . - INPUT from PARS . . : The fo l lowing ca lcu la ted values for the average potent ia l c a l c u l a t e d at each e lect rode sampling p o s i t i o n , for each v a r i a t i o n of the parameters: axia l d i s p e r s i o n , axia l j i t t e r , amplitude J i t t e r , antsotropy r a t i o and e f f e c t i v e r a d i i : sampling_radi1 LOG_sampling_rad1us pp_ampli tude LOG_pp_ampli tude pp_durat ion LOG_pp_durat ion RMS_power LOG PMS_power The sampling d is tance; the LOG of sampling_rad11; the peak to peak amplitude; the LOG of pp_amplitude; the peak to peak durat ion; the LOG of pp_duration: the R.M.S. power; the LOG of RMS_power: ot SMUAP Waveform Features ID=SNAP 12:51 31 JUL 82 PAGE 2 54 OOOOO - - OUTPUT to unit 9 (or. I n de fau l t , - p l o t * ) : 55 OOOOO - -56 OOOOO The p lo ts choosen. 57 OOOOO - -58 OOOOO - - OUTPUT to -LMS0: 59 OOOOO - -60 OOOOO - - The r e s u l t s of any IMS l inear f i t s . 61 OOOOO - -62 OOOOQ OUTPUT to -poly/C: 63 OOOOO - -64 OOOOO - - The r e s u l t s of any L.M.S. polynomial f i t s . 65 OOOOO - -66 OOOOO - -67 OOOOO - - " 68 OOOOO - -Plot SMUAP Waveform Features ID=SNAP 12:51 31 JUL 82 PAGE 3 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 -106 107 108 109 1 10 111 112 113 114 115 116 117 1 18 1 "19 120 121 122 123 124 125 126 OOOOO OOOOO OOOOO 00100 00100 0010O OOIOO 00100 00100 00100 00100 00100 00100 00100 00100 00100 00100 00100 00100 00100 00100 OOIOO 00100 00100 00100 00100 0010O 00100 OOIOO 00100 OOIOO 0010O OOIOO OOIOO OOIOO O010O 00100 00100 OOIOO 00100 OOIOO 00100 00120 00120 00138 00138 0013A 0013A 00150 00150 00178 00178 020B8 020B8 05F38 05F38 05F3A 05F3A $eject$ CONST TYPE VAR reor Ig ln = -3 ; symbol_up = - 1 pen up = 3: pen down = 2; pen_dashed = 4 : y_length = 8. Os; x_length = 6. Os; y_head1ng = 9 75s; y_subhead1ng = 9. 50s ; y subsubhead1ng = 9. 25s; head 1ng_ht = 0. 14s; subhead 1ng_ht = 0. 10s ; pt_symbol_ht = 0. 10s; y_or1g1n = 1 . OS; x_table = 6. 1s; x_va1ues - X table + 3.0s * pt_symbol_ht / 2.0s; x_space = 2~. Os; very_low = -1 .OE75s; very_h1gh = 1 0E75s; under = ' vector va1ues v a r i a b l e s e l e c t i o n features p1ot_se lec t ion th i ngs_to_p1ot str1ng pot_numbers rej ects ARRAY (1. .10) OF SHORT; ARRAY ( 1 . . 5 , 1 . . 1 0 ) OF vector ; (STOP, RADIUS, AMP. DUR, POWER, LOG_RADIUS, LOG_AMP, LOG_DUR, LOG_POWER, stop, rad ius , amp, dur, power, log_rad1us, log_amp, log_dur, log power); RADIUS..LOG_POWER; (NEXT, POINTS, AVERAG. LMS. POLY, next, po in ts , averap. 1ms. p o l y ) ; POINTS..POLY; ARRAY ( 1 . . 25 ) OF CHAR; = 0 . . 10 ; = SET OF pot_numbers: no_of_var Iat ions , No_of _sampl es . no_of_motor_i.ini ts . 1_pos_off, PARS_flag, GEN_var1ation. SIM_var1 at ton, no_of_posns x_m1n, y_m i n , dx, dy. r_mi n, r_max new_p1ot MU_nuinbers parameters x_data, y_data, x_datas, y_datas data p iot_type x_var, y_var INTEGER; SHORT; BOOLEAN; ARRAY (1. .5) OF INTEGER; vector; va1ues; ARRAY ( features) OF va lues; piot_selec11 on; var1 able se lec t ion; Plot SMUAP Waveform Features ID=SNAP 12:51 31 JUL 82 PAGE 4 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 05F3E 05F3E 05F48 " 05F48 06O42 06042 06065 06065 06097 06097 060C9 060C9 060C9 060C9 060C9 060C9 060C9 060C9 060C9 060C9 060C9 060C9 060C9 060C9 060C9 060C9 060C9 060C9 060C9 060C9 00078 00060 00060 00098 00098 00000 00080 0O078 00078 00088 00088 00090 11 1 1 1--1 1--1 11 1 1 1 1 11 1--1 r j tpots sub subhead i ngs. pr i n t_head I rigs MU_heading x_1abel , y_label t i t l e INITIAL subsubhead1ngs ARRAY (' END; prInt_head1ngs ARRAY ( 'Ax ia l d i s p e r s i o n = ( 'Ax ia l j I t ter » ' ) , ( 'AmplItude J I t ter = ( 'Anlsotropy r a t i o = ( ' E f f e c t i v e radius = END: ' ) , ' ) . ' ) PROCEDURE PL0T(x, y PROCEDURE PLOT END SHORT f l a g INTEGER) f l a g ARRAY (1. ARRAY (1. ARRAY (1. s t r f ng; ARRAY ( 1 . AXIAL DISPERSIONS.') AXIAL J I T T E R S . ' ) , AMPLITUDE JITTERS . ' ) ANISOTROPY RATIOS.') EFFECTIVE RADII . ' ) INTEGER; angle s t r i n g ; angle PROCEDURE PLOT_SYMBOL(x, y, height : SHORT pen : INTEGER) PROCEDURE PLOT_TEXT(x, y, height : SHORT ;VAR labe ls length : INTEGER) PROCEDURE DASH_LINE(dash 1, space 1, dasli2, space2 : SHORT) PROCEDURE AXIS_SCONTROL(option : ALFA; values : SHORT) PROCEDURE AXIS_ICONTROL(optIon : ALFA; values : INTFGER) PROCEDURE PLOT_AXIS(labels : s t r i n g ; angle , s i z e , min, de l ta : SHORT) INTEGER; s i z e : SHORT; VAR min. INTEGER) SHORT; SHORT; PROCEDURE SCALE(data : vector ; no: de l ta : SHORT : f l a g .5) OF r e j e c t s ; .5) OF s t r i n g : .35) OF CHAR; 50) OF CHAR; FORTRAN; FORTRAN 'PLOTND'; FORTRAN ' SYMBOL'; SLINKAGE 'SYMBOL' FORTRAN 'DASHLN' FORTRAN ' AXCTRL' FORTRAN 'AXCTRL' FORTRAN 'AXPLOT' FORTRAN SCALE' ; c*3 K I O T S M U A H waverorm fea tures . The rout ine to prompt the user and read thetr answers: lU=bN«K 12:51 Jl JUL 82 PAGE 5 169 00090 170 00090 — 171 00090 1 -172 00090 --173 00090 --174 00O9O --175 00048 --176 00050 --177 00052 --178 00052 --179 00052 2-180 00042 --181 00042 --182 00048 --183 0009A --184 0009A 185 0009E 3-186 0009E --187 000A A --188 00ODA -3 189 OOOEE --190 000EE --191 000F6 --192 001 OA --193 001 OA --194 001 12 --195 00186 --196 0019C 3-197 0019C --198 OOIAB --199 00238 -3 200 00248 --201 00254 202 002A 6 --203 002A 6 --204 002 E 4 --205 0030C --206 0030C 3-207 0030C --208 0034A --209 00382 -3 210 0038A --211 0038A --212 003C8 --213 003DE 3-214 003DE --215 00406 --216 00492 --217 00496 4-218 00496 --219 004A 2 --220 004D4 --221 00574 -4 222 00588 -3 223 00598 --224 00598 -1 225 00650 $e ject ,subt111e= 'The rout ine to prompt the user and read thetr answers:'$ PROCEDURE Prompt and_read; VAR 1_mu, count rej ect : INTEGER: : pot_numbers; ',MU numbers!1):0); BEGIN no_of_motor_un1ts := 0; wr1te(E0L,'> Motor uni t number(s)?' ,EOL); 1_mu := 0; REPEAT INCR(1_mu); read(MU_numbers(1_mu)); UNTIL (EOLN OR (t_mu > 5)) ; no_of_motor_un1ts := 1_mu: MU_head1ng := ' ' ; count := 1; wrltestr(MU_head1ng,count, ' Motor u n l t ( s ) FOR 1_mu := 2 TO no_of_motor_un1ts DO BEGIN count : = count •»• 1 ; wr1testr(MU_head1ng.count, ' . ',MU_numbers(i_mu):O): END; count := count + 1; wr1 tes t r (MU_heading ,count . ' : ' ) : wr i te ! '> V a r i a t i o n codes? ' ,EOL) ; read!GEN_varIatIon, SIM_varIatIon): REPEAT wr i te ! '> Sampling range? ' ,EOL) ; read!r_m1n,r_max); UNTIL ( rmax > r_m1n); wr1te('> Rejected potent 1 a I s ? ' , E O L ) ; FOR l_mu := 1 TO no_of_motor_un1ts DO BEGIN rj tpots!1_mu) := ( . . ) : wr1te('> M.U. tt1 ,MUnumbers!1_mu) :0 . ' : ' ,EOL) : count := O; REPEAT INCR(count); read!re j e c t ) ; rjtpots!1_mu) := rjtpots(1_mu) + ( . r e j e c t ) ; UNTIL (EOLN OR (count >= 10)); END; END "Prompt_and_read"; Plot SMUAP Waveform Features. The rout ine to read the feature f i l e s ID=SNAP 12:51 31 JUL 82 PAGE 6 226 00650 -- $eject .subt1t1e='The rout ine to read the feature f i l e s 227 00650 --228 006 50 1- PROCEDURE Read PARS f i l e ; 229 00650 --230 00650 -- VAR 231 00048 -- no, i t e r , i_var, 1_pos, i_mu, f l a g , number 232 00064 -- f i l e name 233 0007D -- PARS_f1le 234 00091 --235 • 00091 --236 00091 2- PROCEDURE sk ip data(n : INTEGER); 237 OOOOO --238 OOOOO -- VAR 239 0004C -- 1 240 00050 -- dummy 241 00054 --242 00054 3- BEGIN 243 0003C --244 0003C -- FOR 1 := 1 TO n DO 245 00052 -- read(PARS_f11e,dummy); 246 00086 --247 00086 -2 END " s k l p d a t a " ; 248 OOOAA 249 OOOAA 250 OOOAA 2- BEGIN 251 0005A --252 0005A -- wr 1te('>> F i l e ( s ) : ' ) ; 253 00080 --254 00080 -- PARS_flag := 0; 255 00086 -- no_of_variat Ions := 1; 256 0008E --257 0008E -- FOR 1 mu := 1 TO no of motor un i ts DO 258 OOOAO 3- BEGIN 259 OOOAO -- f i1e_name := ' ' ; 260 OOOAA -- w r i t e s t r ( f 1 l e name,1,'PARS',MU numbers(1 mu):0, ' 261 0018A -- RESET(PARS_f11e.f11e_name); 262 00198 --263 00198 -- wr1te(f i le_name:- 1,' ' ) : 264 001D4 265 001D4 -- sk ip data(4) ; 266 001E6 -- readfPARS_f1 le ,1 ter ) : 267 001FC -- sk1p_data(3*1ter) ; 268 00214 -- read(PARS_f11e,No_of_samples) ; 269 002 2A -- sk1p_data(1); 270 0023C --271 002 3C -- number := 1; 272 00240 -- f l a g := 0; 273 00244 -- FOR Iter := 1 TO 5 DO 274 00252 4- BEGIN 275 00252 -- iead(PARS f i l e . n o ) : 276 00268 -- IF (no = 1) THEN 277 00274 -- sk ip data(1) ; 278 00286 -- ELSE 279 00286 5- BEGIN 280 0028A -- number := no; 281 00292 -- f1ag := 1ter; 282 0029A -- FOR i var := 1 TO number DO INTEGER; s t r ing; TEXT; INTEGER; SHORT; . G E N var1at ion:0, ,SIM var1at1on:0) ; o o Plot SMUAP Waveform Features. The rout ine to read the feature f i l e s ID = SNAP 12:51 31 JUL 82 PAGE 7 283 002BO --284 002 FA '--285 002 FA --286 003 1E 6-287 003 IE --288 0035C --289 00362 -6 290 00362 --291 00362 6-292 00366 --293 0036E --294 00376 -6 295 00376 -5 296 00376 -4 .297 00382 --298 00382 --299 00398 --3GO 003AE 4-301 003AE --302 00440 --303 00452 --304 0O566 --305 005EE --306 00600 --307 0068C 308 0069A --309 007 A E --310 00836 --311 00844 -4 312 00862 -3 313 00872 --314 00872 --315 008B0 --316 008B0 -1 317 0098A --read(PARS_f11e .parameters! i_var ) ) ; IF ((1_mu > 1) AND ((PARS_flag <> f l ag ) OR (noof_var1 at Ions <> number))) THEN  BEGIN w r i t e ! ' » Input data does not match for a l l M U ' ' s ! ' , E O L ) ; HALT: END; ELSE BEGIN PARS_flag := f l a g ; no_of_var ia t ions : END; number; END; END: FOR 1_var := 1 TO no_of_var1 a t ions DO  FOR 1_pos := 1 TO No_of_samples DO  BEGIN read (PARS_f11e ,da ta !RADIUS , i_mu. Iva r , ipos ) ) ; sk ip_data(1) ; r e a d ( P A R S _ f 1 l e , d a t a ! A M P , i m u , I v a r , I p o s ) . d a t a ( D U R , i m u , I v a r , 1_pos), data!POWER,1_mu.1_var,i_pos)); sk ip_data(2) ; read(PARS_f11e,data(LOG_RADIUS,1_mu, Ivar . ipos) ) : sk i p d a t a ! 1 ) ; read(PARS_flie,data(LOG_AMP,1_mu,i_var , i p o s ),data!LOG_DUR,1_mu.1_var,1_pos), data!LOGPOWER,1_mu,i_var,1_pos)); skip_.data(2); END; END; wr1te('opened and r e a d . ' . E O L ) ; ( END "Read PARS f i l e " : O Plot SMUAP Waveform Features. The rout ine to p lo t the a x i s , t i t l e s etc ID=SNAP 12:51 31 JUL 82 PAGE 8 318 0098A - - Se ject .subt I t1e= 'The rout ine to p lo t the a x i s , t i t l e s e t c . : ' * 319 0098A " - -320 0098A 1- PROCEDURE ax 1s_t111e_etc; 321 0098A - -322 0098A - -323 0098A - - CONST 324 00048 - - Y o r l g l n = 'YORI' ; 325 00048 - - Label_s1ze = 'SYMS': 326 00048 - -327 00O48 - - VAR 328 00048 - - count. I ter , 1_pos, i_mu, 1_var : INTEGER; 329 0005C - - heading : ARRAY (1. .50) OF CHAR; 330 O0O8E - -331 0008E - -332 0008E 2- PROCEDURE v_scale(VAR s c a l e d , unsealed : va lues ; length : SHORT; VAR min, de l ta : SHORT); 333 OOOOO - -334 OOOOO - -335 OOOOO - - VAR 336 0005C - - i m u , 1_var, 1_pos . : INTEGER; 337 00068 - - t_m1n, t_del ta : SHORT; 338 00070 - -339 0OO70 - -340 0OO7O 3- BEGIN 341 0O03A - -342 0003A - - min := v e r y h l g h ; 343 00046 - - de l ta := O.Os; 344 00052 - -345 00052 - - FOR 1_mu := 1 TO noof_motor_un1ts DO 346 00068 - - FOR 1_var := 1 TO no_of var1 a11ons DO 347 0OO7E 4- BEGIN 348 0007E - - SCALE(unscaled(1_mu,1_var) ,no_of_posns.1ength.t_min,t_del ta , 1 ) ; 349 0O104 - - d e l t a := MAX(de l ta , t_de l ta ) : 350 0011E - - m1n := MIN(m1n,t_mtn); 351 00138 -4 END; 352 00158 - -353 00158 - - FOR 1_mu := 1 TO no_of_motor_un1ts DO 354 0016E - - FOR I v a r := 1 TO no_of var1 a11ons DO 355 00184 - - FOR 1_pos := 1 TO n o o f p o s n s DO 356 0O19A - - sea led(1_mu. i_var . i_pos) := (unsca1ed( i_mu,i_var ,1_pos) - min) / d e l t a ; 357 002D2 - -358 0O2D2 -2 END " v s c a l e " ; 359 0030A - -360 0030A 2- FUNCTION se1ect_labe1(var_name : var lab Ie_se1ect1 on): s t r i n g : 361 0030A - -362 0030A 3- BEGIN 363 00040 - -364 00040 - - s e l e c t _ l a b e l := ' ' ; 365 00O4E - -366 0004E 4- CASE varname OF 367 00O56 - - RADIUS, radius : se lec t_ labe l := ' Radial D i s t a n c e ' ; 368 0006E - - AMP, amp : s e l e c t l a b e l := ' P-P Ampl i tude' : 369 00O86 - - OUR, dur : s e l e c t _ l a b e l := ' P-P D u r a t i o n ' ; 370 0009E - - POWER, power : se lec t_ labe l := ' R . M S . Power'; 371 000B6 - - LOG_RADIUS, log_radius : se lec t_ labe l := ' LOG (Radial D i s t a n c e ) ' ; 372 OOOCE - - LOGAMP, 1og_amp : select_1abel := ' LOG (P-P Ampl i tude) ' ; 373 000E6 - - LOG_DUR, 1og_dur : se lec t_ labe l := ' LOG (P-P Dura t ion ) ' ; 374 OOOFE - - L0G_P0WER. log_power : se lec t_ labe l := ' LOG ( R M S . Power)'; Plot SMUAP Waveform Features. The rout ine to p lo t the a x i s , t i t l e s e t c . ID = SNAP 12:51 31 JUL 82 PAGE 9 375 00116 -4 END; 376 0015C ' - -377 0015C -2 END " se1ect_labeI"; 378 0022C - -379 0022C - -380 0022C 2- BEGIN 381 00042 - -382 0004$ - - x_label := se1ect_labe1(x_var) ; 383 00080 - - y_ label := s e 1 e c t _ l a b e 1 ( y v a r ) ; 384 OOOB6 - -385 000B6 t i t l e := " ; 386 OOOCA - - count := 1; 387 OOOD2 - - wr1testr(11 t i e , c o u n t , y _ l a b e l : - 1 , ' v s ' , x _ l a b e l : - 1); 388 0016E - - PL0T_TEXT(0.0s.y_head1ng,head1ng_ht . t i t le ,O.Os.count) : 389 001CC - -390 001CC heading := ' ' ; 391 001DA - - count := 1; 392 001E2 - - wrl testr(headlng,count,MU_head1ng:- 1,' VARIATION ' , GENvar 1 at 1on:0. ' . ' ,SIM_var1 a 1 1 o n : 0 , ' : ' ) ; 393 002BE - - PL0T_TEXT(0.Os,y_subhead1ng,subhead 1ng_ht,head 1ng,0 .0s ,count ) ; 394 0031C - -395 0031C - - I f (PARS_flag > 0) THEN 396 00326 3- BEGIN 397 00326 - - heading := " ; 398 00334 - - count := 1; 399 0033C wr1 tes t r (head ing ,count , ' ' ,no_of_var1at1ons:0,subsubhead1ngs(PARS_f lag) : - 1); 400 003E2 - - PLOT_TEXT(0.Os,y_subsubhead1ng,subhead1ng_ht.headlng,0.Os,count); 401 0043C -3 END; 402 0043C - -403 0043C - - y_label (25) : = ' ; ' ; . 404 00448 - - x_label(25) := ' ; ' ; 405 0044C - - AXIS_SCONTROL(Y_orIgln,yorIgln); 406 0046A - - AXIS_SC0NTR0L(Label_s1ze.O.10s); 407 00488 - -408 00488 - - FOR 1_mu := 1 TO no_of_motor_un1ts Do 409 0049E - - FOR 1_var := 1 TO no_of_var1 at 1ons DO 410 004B4 3- BEGIN 411 004B4 - - Iter := 0: 412 004BA - - I p o s := 1; 413 004C2 - - I p o s o f f := 0; 414 004C6 - -415 004C6 - - WHILE ((1_pos <= No_of_samples ) AND (data(RADIUS.1_mu.1_var,1_pos) <= r_max)) DO 416 00554 4- BEGIN 417 00554 - - I_F (da ta( RADIUS, l_tnu, 1_var, 1_pos) >= r_m1n) THEN 418 005D6 5- BEGIN 419 005D6 - - INCR(l ter) ; 420 005E2 - - x_data(1_mu.1_var,1ter) := data(x_var ,1_mu. Ivar ,1_pos) ; 421 006FC - - y_data(1_mu,t_var,1ter) := data(y_vor , l_mu. i_var ,1_pos) ; 422 00812 -5 END; 423 00812 - - ELSE 424 00812 - - 1_pos_off := I p o s : 425 0081E - -426 0081E - - INCR(1_pos); 427 0082A -4 END; 428 0082E -3 END; 1 ) 429 OOS4E - - ' 430 0084E - - no_of_posns := I ter; 0 431 00856 - - ( l l Plo t SMUAP Waveform Features. T h e rout ine to p lo t the a x i s , t i t l e s etc 432 00856 - - v_sca1e (y_da tas ,yda ta ,y_ length .v_min ,dy ) ; 433 0088C ' - - PL0T_AXIS(y_labe1,90.Os,y_length,y_m1n,dy) 434 008BE - -435 008BE - - v_sca1e(x_datas,x_data,x_length,x_m1n,dx); 436 008F0 - - PL0T_AXIS(x_labe1,0.Os,x_length,x_min,dx); 437 00922 — 438 00922 -1 END "ax 1 s _ t i 1 1 e e t c " ; 439 009E9 - -SNAP 12:51 31 JUL 82 PAGE 10 0 Plot SMUAP Waveform Features. A rout ine to c a p i t a l i z e the Input var iab les for array Indexing ID=SNAP 12:51 31 JUL 82 PAGE 11 440 009E 9 441 009E9 ' - -442 009E9 1-443 009E9 - -444 009E 9 - -445 0004C - -446 0OO5O 447 0005,0 - -448 00050 2-449 0003E - -450 0003E - -451 0O04A - -452 00052 - -453 00072 454 00072 -1 455 00096 - -PROCEDURE c a p i t a l i z e (VAR name : var1ab le_se lec t ion ) ; VAR order BEGIN order := INTEGER(name); IF (order > 8) THEN name := v a r i a b l e se lec t1on (o rder -9 ) ; INTEGER; M 0 Plot SMUAP Waveform Features. Routine to p lo t p o i n t s : ID=SNAP 12:51 31 JUL 82 PAGE 12 456 0OO96 --457 00096 458 00096 1-459 00096 --460 00096 --461 00096 --462 00048 --463 0004.C --464 0005C --465 00075 466 00075 --467 00075 2-468 0003E --469 0003E --470 00046 --471 00046 --472 0005C 3-473 0005C --474 00072 --475 00088 --476 OOOEC --477 001EA --478 00210 --479 00210 --480 002 10 --481 0023A 4-482 0023A --483 0O270 --484 0027A --485 00282 --486 0031A --487 00370 --488 0037E -4 489 0037E -3 490 0038 E -1 491 004 1E --$e ject ,subt1t le= 'Rout Ine to p lo t p o i n t s : ' $ VAR y_table 1_pos, count, 1_mu, 1_var v a r i a t i o n t i t l e SHORT; INTEGER; s t r Ing; BEGIN y_tab1e := y_1ength: FOR 1_var := 1 TO no_of_varlat1ons DO  BEGIN FOR 1_mu := 1 TO no_of_motor_un1ts DO FOR 1_pos := 1 TO no_of_posns DO If ((1_pos + 1_pos_off) NOT IN rjtp"ots( 1 _mu)) THEN PLOT_SYMBOL(x_datas(1_mu,1_var,1_pos),Ty_datas(1_mu,1_var,1_pos)+y_or 1gIn) , pt_symbol_ht ,1_var ,0 .0s,symbol_up); If. (PAR5_flag > O) THEN BEGIN PLOT_SYMBOL(x_table.y_table,pt_symbol_ht.1_var.O.Os.symbol_up): var ia t1on_t1 t le := ' ' ; count := 1; wr1 tes t r (va r la t1on_ t11 le ,count , ' - - ' ,parameters(1_var ) :0 ) ; PLOT_TEXT(x_values,y_table.pt_symbo1_ht,var lat1on_t11le.O.Os,count) ; y_table := y_table - 2.0s * pt_symbol_ht; END: END; END "Po in ts_p lo t " : Plot SMUAP Waveform Features. Routine to p lo t average p o i n t s : ID=SNAP 12:51 31 JUL 82 PAGE 13 492 004 1E --493 004 1E --494 004 1E 1-495 004 IE --- 496 004 1E --497 004 IE --498 00048 --499 00054 --500 00068 --501 00081 --502 00081 503 00081 2-504 0003E --505 0003E --506 00046 507 00046 508 0005C 3-509 0005C 510 00072 4-511 00072 --512 00078 --513 00080 --514 0OO84 --515 0009A --516 OOOFE 5-517 000FE --518 001 OA --519 00188 --520 0020A -5 521 0020A --522 00242 --523 00266 524 0029A -4 525 002AA --526 002AA 527 002 A A --528 002B 4 4-529 002B4 --530 002 E A --531 002 F 4 --532 002 FC --533 00394 --534 003EA 535 0O3F8 -4 536 003F8 -3 537 00408 -1 538 00496 --$eject ,subt i t Ie= 'Rout Ine to plot average p o i n t s : ' $ PROCEDURE Averag_plot: - - VAR y_ tab le , y_mean, x_mean 1_pos, count, t_mu, 1_var, no_mu v a r i a t i o n t i t l e SHORT; INTEGER; s t r1ng; BEGIN y_table : = y_ length; FOR 1_var := 1 TO no_of_var1 at 1ons DO  BEGIN FOR 1 pos := 1 TO no_of_posns DO  BEGIN no_mu := O; x_mean := O.Os; y_mean := O.Os; FOR 1_mu := 1 TO no_of_motor_un1ts DO IJF ((1_pos + I p o s o f f ) NOT IN r j tpotsf t_mu) ) THEN  BEGIN INCR(no_mu); x_mean := x_mean + x_datas(1_mu,1 v a r . 1 _ p o s ) ; y_mean := y_mean + y_da tas (1_mu,1_var , i _pos ) : END; x_mean := x_mean / SHORT(no_mu); y_mean := y_mean / SHORT (no_mu); PLOT_SYMBOL(x_mean,(y_mean+y_orIgln),pt_symbo1_ht.1_var,0.Os,symbol_up); END: IF (PARS_flag > O) THEN  BEGIN PLOT_SYMBOL(x_table,y_table.pt_symbol_ht,1_var,0.Os,symbol_up); var iat1on_t1t1e := ' ' ; count := 1; wr1 tes t r (var Ia t1on_t11 le ,count , ' - - ' .parameters ! l_var ) :0 ) ; PLOT_TEXT(x_va1ues,y_table,pt_symbol_ht ,var i a t i o n t 1 1 1 e , O . O s , c o u n t ) ; y_table := y_table - 2.0s * pt_symbo1_ht; END; END; END "Averag_plot"; O Plot SMUAP Waveform Features. The LMS l inear f i t rou t ine : 539 00496 - -540 00496 541 00496 1-542 00496 - -543 00496 - -544 00496 - -545 O0O48 - -546 00048 - -547 00048 - -548 00048 - -549 0005C - -550 0037C - -551 0037C - -552 0039C - -553 003AD - -$e ject ,subt1t le= 'The LMS l inear f i t r o u t i n e : ' $ PROCEDURE LMS f 1 t s _ p l o t ; TYPE VAR data vector = ARRAY (1..10O) OF SHORT no_of_po1nts, 1_mu, I v a r , 1_pos, Iter x. y s lope , Intercept, rms_error, d e l t a , x_low, x_h y_low, y_h1gh LMS ID=SNAP 12:51 31 JUL 82 PAGE INTEGER: data_vector; SHORT; EXT; Plot SMUAP Waveform Features The LMS l inear f i t rout ine : ID=SNAP 12:51 31 JUL 82 PAGE 15 554 003AD - - $eject$ 555 003AD " - -556 003AD 2- PROCEDURE IInear f1t(VAR x, y : data_vector; no_of_points : INTEGER; VAR s lope. Intercept , 557 OOOOO - - rms_error : SHORT); 558 OOOOO - -559 OOOOO - -560 OOOOO - - VAR 561 00O6O - - Iter : INTEGER; 562 00064 - - y_mean, x_mean, t_ Intercept . t_s lope , temp, numerator, 563 00064 - - denominator : REAL; 564 OOOAO - -565 OOOAO - -566 OOOAO 3- BEGIN 567 00O3E - -568 0003E - - y_mean := O.O; 569 00046 - - x_mean := 0 .0; 570 0004A - - numerator := 0 .0; 571 0004E - - denominator := 0.0; 572 00052 - -573 00052 - - FOR i te r := 1 TO no_of_points DO 574 0OO68 4- BEGIN 575 00068 - - y_mean := y_mean + y (1 te r ) : 576 0009A - - x_mean := x_mean + x (1 ter ) ; 577 OOODO -4 END; 578 OOOEO - -579 OOOEO - - y_mean := y_mean / no_of_po1nts; 580 00108 - - x_mean := x_mean / no_of_po1nts; 581 0012C - -582 0012C - - FOR Iter := 1 TO no_of_po1nts DO 583 0013E 4- BEGIN 584 0013E - - temp := x(1ter) - x_mean; 585 00170 - - numerator := numerator + temp * (y(1ter) - y_mean); 586 001AC - - denominator := denominator + SQR(temp); 587 00186 -4 END; 588 001C6 - -589 001C6 - - t_s lope := numerator / denominator; 590 001D2 - - t_1ntercept := y_mean - t_slope * x_mean; 591 001EO - -592 001E0 - - temp := 0 .0: 593 001E8 - - FDR i te r := 1 TO no_of_polnts DO 594 001FE - - temp := temp + S0R(y(1ter) - t_ intercept - t_slope • x (1 ter ) ) : 595 0027A - -596 0027A - - s lope := SHORT(t_s1 ope); 597 00288 - - Intercept := SHORT(t_intercept); 598 00296 - - r m s e r r o r := SHORT(temp): 599 002A4 - -600 002A4 -2 END " 1 1 n e a r f 1 t " ; 601 002D6 - -u o _ 0 Plo t SMUAP Waveform Features The LMS l inear f i t rou t ine : ID=SNAP 12:51 31 JUL 82 PAGE 16 602 002D6 - - $eject$ 603 002D6 - -604 002D6 2- BEGIN 605 00058 - -606 00058 - - REWRITE(LMS.'-LMS#f* 1 + 1) ' ) : 607 00068 - - wr1te('>> L.M.S. output i n -LMS*. ' , E O L ) : 608 000A6 - - wr1te(LMS. ' 1 ' , ' ' : 1 0 , ' R e s u l t s of a l inear least mean squares f 11' , E O L . ' + ' . ' ' :10,under:40,EOL, 609 0017A - - ' ' : 1 1 , ' F o r v a r i a t i o n ',GEN_var1 a t ion :0 , ' . ' ,S IMvar1 a t i o n : 0 , ' w1th'.MU_head1ng:- 1, 610 00242' - - ' . ' , E O L , ' 0 ' , ' ':10,'>> ' , t 1 t 1 e : - 1 , ' <<'.E0L, 611 00320 - - ' 0 ' , ' ' :10 , 'Sampl ing range of ' , r _ m 1 n : O : 2 , ' m.m. to ' , r_max:0:2 , ' m.m. ' .EOL); 612 00410 - -613 00410 - - FOR i v a r := 1 TO no_of v a r i a t i o n s 00 614 00426 3- BEGIN 615 00426 - -616 00426 - - x l o w := very_high; 617 0042E - - y_low := very_high; 618 00432 - - x_high := very_low; 619 0043A - - y_high : = very_low; 620 0043E - - no_of_points := 0; 621 00444 - -622 00444 - - FOR 1_mu := 1 TO no_of_motor_units DO 623 0045A - - FOR l_pos := 1 TO no_of_posns DO 624 00470 If ((1_pos + 1_pos_off) NOT IN rjtpots(i_mu) ) THEN 625 004D4 4- BEGIN 626 004D4 - - INCR(no_of_po in ts ) ; 627 004E0 - - x(no_of_po1nts) := x_data(1_mu.i_var.1_pos); 628 00578 - - y(no_of_points) := y_data( i_mu,1_var , i_pos); 629 00610 - - x_low := MIN(x_low,x(no_of_po1nts)); 630 00642 - - y l o w :« MIN(y_low,y(noof_po1nts)); 631 00674 - - x h i g h := MAX(xhigh,x(no_of_points) ) ; 632 O06A6 - - y_high := MAX(y_high,y(no_of_po1nts)); 633 006D8 -4 END; 634 006D8 635 006DB - - 11near_f11(x,y,no_of_po1nts,s1 ope,1ntercept , rms_error) ; 636 00732 - -637 00732 - - de l ta := ABS(x_low - x h i g h ) / 100.0s; 638 00746 - -639 00746 - - If (s lope < O.Os) THEN 640 00754 4- BEGIN 641 00754 - - WHILE ( (s lope * x_low + Intercept) > y_high) DO 642 00768 - - x l o w := x l o w + d e l t a ; 643 00778 - -644 00778 - - WHILE ( (s lope * x_high + intercept) < y l o w ) DO 645 0078C - - x h i g h := x high - de1ta; 646 0O79C - -647 0079C y_high := slope • x_high + Intercept; 648 007AC - - y_low := slope * x low + in tercept ; 649 007BC -4 END: 650 007BC - -651 007BC - -652 007BC - - IF (s lope > O.Os) THEN 653 007CA 4- BEGIN 654 007CA - - WHILE ( (s lope + x_low + intercept) < y_!ow) DO 655 007DE - - x_low : - x_1ow + d e l t a ; 656 007EE - -657 007EE - - WHILE ( (s lope * x_h1gh + intercept) > y _ h i g h ) Dg 658 00802 - - x h i g h := x h i g h - d e l t a ; Plo t SMUAP Waveform Features. The LMS l inear f i t rou t ine : ID=SNAP 12:51 31 JUL 82 PAGE 17 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 00812 00812 00822 00832 00832 00832 00842 00852 00862 00872 00872 0088 E 008B2 008B2 008BC 00990 00990 009CA 009CA 00A90 00AE2 00AF2 00AF2 00B10 00B10 00C86 -3 y_1ow : y_h1gh END; slope * x_low + Intercept; = slope * x_hlgh + Intercept; x_low := (x_low - x_m1n) / dx; x_h1gh := (x_h1gh - x_mfn) / dx; y_ 1 ow := (y_1ow - y_m)n) / dy; y_h1gh := (y_Mgh - y_m1n) / dy; PL0T(x_low, (y_lowi-y_or Igln) ,pen_up); PL0T(x_h1gh,(y_h1gh*y_or tgln),pen_down); I f (PARS_flag > 0) THEN w r i t e ( L M S , ' 0 ' , ' ' : 15 .p r1nthead lngs(PARS_f1ag) : - 1 .parameters(Kvar) :0:4 ,EOL); ELSE wrl te(LMS, ' ' . E O L ) ; wr1te(LMS,' ' : 2 1 , ' S l o p e = ' ,s1 o p e : 0 : 3 , ' : Intercept = ' , 1 n t e r c e p t : 0 : 3 . ' : R.M.S. error r m s _ e r r o r : 0 :4 , ' . ' , E O L ) ; END; PL0T(x_low,y_1ow.pen_up); END " L M S f 1 t s _ p l o t " ; Plo t SMUAP Waveform Features L .M.S. polynomial f i t : ID=SNAP 12:51 31 JUL 82 PAGE 18 685 0OC86 - - $ e j e c t . s u b t t t l e = ' L . M . S . polynomial f i t : '$ 686 00C86 ~~ 687 OOC86 1- PROCEDURE Po1y_f1ts_p1ot; 688 OOC86 - -689 00C86 - - TYPE 690 00048 - - Interp =• ARRAY ( 1 . 1 0 0 ) OF SHORT; 691 00048 - - work = ARRAY (1..150) OF REAL; 692 00048 - -693 00048 - - VAR 694 00048 - - I ter, 1_var, 1_pos, 1_mu. no_mu : INTEGER; 695 0005C - - s_no_posns. s_no_mu, ddx, y_var lance, y_mean. sum_of_sqrs, 696 0005C - - x_mean. x_variance, s, s i , s_u : SHORT; 697 00088 - - x, y, y_dev, y f , yd. ydd : vector ; 698 00178 - - xx, yy , yyd, yydd : in terp; 699 007B8 w : work; 700 00C68 - - poly : TEXT; 701 OOC79 - -702 00C79 2- PROCEDURE poly_f1t (VAR x, y, wt : vector ; VAR s : S H O R T ; n : INTEGER; VAR w : work) 703 OOOOO -2 ; FORTRAN 'SPLNFT'; 704 00090 22 PROCEDURE poly_va1ues (VAR xx. yy, yyd, yydd : Interp; m: INTEGER) ; FORTRAN 'SPLN ' ; 705 00090 22 PROCEDURE po1nt_values (VAR x. y, yd, ydd : vector; m: INTEGER) ; FORTRAN ' S P L N ' ; 706 00090 - -to Plo t SMUAP Waveform Features L .M.S. polynomial f i t : ID=SNAP 12:51 31 JUL 82 PAGE 19 707 00090 -- $eject$ 708 00090 _ _ 709 00090 2- PROCEDURE sort(VAR x, y, dy : vector 710 00090 --711 00090 -- VAR 712 00058 -- 1, J 713 00060 -- temp 714 00064 -- swlten 715 00066 --716 00066 --717 00066 3- BEGIN 718 00038 -- FOR 1 := m DOWNTO 2 DO 719 0004A 4- BEGIN 720 0004A -- switch := f a l s e ; 721 00050 FOR j := 1 TO 1-1 DO 722 00064 IF (x(J ) > x(j + 1)) THEN 723 OOOBO 5- BEGIN 724 ' OOOBO -- switch := true; 725 000B8 -- temp := x(J+1); 726 OOODC -- x(J+1) := x ( j ) ; 727 00122 -- x(J) := temp; 728 00146 -- temp := y(J+1): 729 0016E -- y(J-M) := y ( j ) ; 730 001B4 -- y( j ) := temp; 731 001D8 -- temp := dy(j+1); 732 00200 -- dy(j+1) := dy ( j ) ; 733 00248 -- dy( j ) := temp; 734 0026E -5 END; 735 0026E -- IF (NOT switch) THEN EXIT 736 0028C -4 END; 737 00296 -2 END "sor t" ; 738 002C0 --Integer); INTEGER; SHORT; BOOLEAN; Plot SMUAP Waveform Features L .M.S. polynomial f i t : ID=SNAP 12:51 31 uUL 82 PAGE 20 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 '761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 002C0 002C0 002C0 0005A 0005A 00066 00066 00088 000A E 000D6 000E6 OOOEE OOOFA OOOFA 001D2 001F2 00206 00206 002DE 002FE 002FE 002FE 00356 0043C 00504 00622 006BC 006BC 006BC 006D2 006D2 006 E 8 0O6E8 006EE 006F6 006FA 006FE 00702 00718 0077C 0077C 00788 0080A 00888 0090C 0098C 0098C 0098C 009BE 009C6 009C6 009C6 009FE 00A20 00 A 20 00A20 00A4A $eject$ 2- BEGIN 5--5 -4 4-5-If (no_of_posns > 2) THEN BEGIN s_no_posns := SHORT(no_of_posns); s_l := s_no_posns - SORT(s_no_posns*2.Os); s_u := s_no_posns + SQRT(s_no_posns*2.Os); REWRITE (poly , ' -poly#(* 1 + 1) ' ) ; s := O.Os; IF (no of motor un i ts > 1) THEN BEGIN '> Seal ing ( ' , s _ l : 0 , wr1te( ' read(s) ; I_F ((s<s_1) OR (s>s_u)) THEN ,s U :0 . ' ) ? . EOL); > Sca l ing ( ' , s _ l : 0 , ' , ' , s _ u : 0 , ' ) ? ' .EOL) ; BEGIN wr1te(' read(s ) ; END; END; w r l t e C ','>> Polynomial f i t output In - p o l y * . ' . E O L ) wr1te(poly , ' 1 ' , ' ' : 1 0 , ' R e s u l t s of polynomial f11 ' ,EOL 10,under:27,EOL, ' ' : 1 1 , 'For v a r i a t i o n ' ,GEN_var1at1on:0 , ' . ' ,S IM_var1at ion:0 , ' w1th',MU_heading:-1, E O L . ' O ' , ' ':10,'>> ' , t 1 t l e : - 1 , ' < < ' . E O L , ' 0 ' , ' ' :10, 'Sampl1ng range of ' , r m1n:0:2,' m.m. to ' . r max:0:2, ' m.m. ' .EOL); 1 TO no of v a r i a t i o n s DO FOR 1_var BEGIN FOR 1_pos := 1 TO no_of_posns DO BEGIN no_mu x_mean y_mean x_var lance y_varlance = 0; := O.Os; := O.Os; = 0 0 s ; = O.Os; FOR 1_mu := 1 TO no_of_motor_units DO IF ((1_pos + 1_pos_off) NOT JN r j t p o t s ( i m u ) ) THEN  BEGIN INCR(no_mu); x_mean := x_mean + x_data(1_mu.1 var . 1 pos) ; ymean := y_mean + y_da ta (1_mu, iva r , i _pos ) ; x_var1ance y_varlance END; x_variance + SQR(x_data(i_mu,1_var,i_pos)); y_variance + SQR(y_data( imu,1_var , i_pos) ) ; S_no_mu := SHORT(no mu); IF. (no_mu > t ) THEN  BEGIN y_var1ance := SORT(ABS((s_no_mu * y_vaMance - SOR(y_mean)) / (s_no_mu * (s_no_mu - 1.0s))) ) ; y_dev(1_pos) := y_var1ance; END; ELSE y_dev(1_pos) := 1.0s; Plot SMUAP Waveform Features L.M.S. polynomial f i t : ID=SNAP 12:51 31 JUL 82 PAGE 21 796 OOA4A - - x(1_pos) := x_mean / s_no_mu; 797 OOA74 "-- y(1 pos) := y_mean / s_no_mu; 798 00A9E - -799 0OA9E -5 END; 800 OOAAE - -801 OOAAE - - sor t (x ,y .y_dev,no_of_posns) ; 802 00AD8 - -803 OOAD.8 - - FOR 1_pos : = 2 TO n o o f p o s n s DO 804 OOAEE 5- BEGIN 805 OOAEE - - • IF (x(1_pos)=x(1_pos-1 ) ) THEN 806 OOB32 - - IF. ( x ( l p o s ) < O.Os) THEN 807 00B5E - - x(1_pos) := x(1_pos) * 0.999s; 808 00BA8 - - ELSE 809 00BA8 - - x(1_pos) := x(1_pos) * 1.001s; 810 OOBF6 -5 END; 811 00C06 - -812 00C06 - - ddx := (x(no_of posns) - x(1)) / 100.0s; 813 00C36 - - xx(1) := x(1); 814 00C3E - - FOR Iter := 2 TO 100 DO 815 00C50 - - x x ( l t e r ) := x x ( l t e r - l ) + ddx; 816 00C9E - -817 00C9E - - po ly_ f1 t (x ,y ,y_dev ,s ,no_of_posns ,w) ; 818 OOCD8 - - po1nt_va lues(x ,y f .yd .ydd,no_of_posns) ; 819 OOD06 - - po ly_va lues(xx ,yy ,yyd ,yydd,100) ; 820 00D38 - -821 00038 - - IF (PARS_flag > O) THEN 822 OOD42 - - wr11e(po1y, ' O ' , ' ' :15,pr1nt_head1ngs(PARS_f1ag):- 1,parameters(1_var) :0 :4 ,EOL) ; 823 00E|6 - - w r 1 t e ( p o l y , ' 0 ' , ' ' : 2 2 . x _ l a b e l : 2 4 . ' ' : 6 , y l a b e l : 2 4 , ' ' :10 , 824 00EC2 - - ' S l o p e ' , E O L . ' ' : 4 6 , ' A c t u a 1 7 , ' ' :14, ' F 1 t t e d ' , E O L , ' ' . E O L ) ; 825 OOFAE - -826 OOFAE - - FOR Iter := 1 TO no_of posns DO 827 00FC4 - - w r 1 t e ( p o l y . ' " : 1 8 . x ( I t e r ) : 1 5 : 5 , ' ' : 5 , y ( t t e r ) : 1 5 : 5 , ' ' : 5 , 828 01086 - - y f ( I t e r ) : 15:5 . ' ' : 10.yd( I ter) : 15:5,EOL): 829 0113A - - FOR Iter := 1 TO 100 DO 830 0114C 5- BEGIN 831 0114C - - xx ( l t e r ) := (xx(1ter) - x m l n ) / dx; 832 01190 - - y y ( l t e r ) := ( y y ( l t e r ) - y_m1n) / dy •* y_or1g1n: 833 011DE -5 END; 834 011EA - -835 011EA - - PLOT(xx(1 ) ,yy (1 ) .penup) ; 836 01208 - - FOR Iter := 1 TO 100 DO 837 0121A - - PLOT(xx(1ter) ,yy(1ter) .pen_down); 838 01278 - - PLOT(xx(1 ) , y y ( 1 ) . p e n u p ) ; 839 01296 -4 END: 840 012A6 -3 END; 841 012A6 - -842 012A6 -1 END " P o l y _ f 1 t s p 1 o t " ; 843 01425 - -Plot SMUAP Waveform Features The main procedure: ID=SNAP 12:51 31 JUL 82 PAGE 22 844 01425 -- $e jec t ,subt1 t1e= 'The main procedure: '$ 845 01425 846 01425 1- BEGIN 847 OOOBA --848 OOOBA -- " P L O T ( 1 . O s , 0 . O s , r e o r 1 g 1 n ) : " 849 OOOBA --850 OOOBA -- Prompt_and_read; 851 OOOCO --852 OOOCO -- Read_PARS_f1le; 853 000C6 --854 000C6 -- new_p1ot := TRUE: 855 OOOCE 856 OOOCE 2- REPEAT 857 OOOCE -- w r 1 t e ( E O L , ' > P lo ts? (enter new y ancl x v a r 1 a b l e s ) ' . E O L ) ; 858 00122 -- read(y_var) : 859 0015C -- cap i ta l1ze (y v a r ) ; 860 00166 IF (y var = STOP) THEN EXIT; 861 00174 -- ELSE 862 00174 3- BEGIN 863 00178 -- read(x_var) ; 864 001AE -- cap i ta l1ze (x v a r ) ; 865 001B8 -- IF (x var = STOP) THEN EXIT; 866 001C6 -- E L S E 867 001C6 4- REPEAT 868 001CA --' read(p lot_ type) : 869 00204 --870 00204 -- IF new p lo t THEN 871 0020C 5- "BEGIN 872 0020C -- ax 1s_t111e_etc; 873 00212 -- new p lo t := FALSE; 874 00218 -5 END: 875 00218 --876 00218 5- CASE p lo t type OF 877 00224 -- POINTS, points : Po1nts_plot; 878 0022E -- AVERAG, averag : Averag p l o t ; 879 00238 -- L M S , 1ms : L M S _ f 1 t s _ p 1 o t ; 880 00242 -- POLY, pOly : Po1y_f1 ts_p lo t ; 881 0024C 6- NEXT, next : BEGIN 882 0024C -- PLOT((x_length+x_space) ,0 .Os,reor Igln) ; 883 0026A -- new p lo t := TRUE; 884 00272 -6 END; 885 00276 -- <> : w r 1 t e ( ' » Inva l id type. Enter ' 'NEXT ' ' to 886 002B8 -5 END; 887 002E4 -4 UNTIL new p l o t ; 888 002EC -3 END; 889 002EC -2 UNTIL NOT new p l o t ; 890 002F6 --891 002 F 6 -- PLOTEND; 892 002 FC --893 002FC -1 E N D . No e r r o r s detected 1 .362 CPU sec . P l o t t i n g of PSD E s t i m a t i o n s U B C P A S C A L - Vers ion : November 14.1981 ID=SNAP 21:54 25 JUL 82 PAGE 1 * OPTIONS * ' ALIGN CASEDIST CASENEXT DUMPTABLE IBM370 INDEXCHECK LIST MCCARTHY OBJFILE PRECEDENCE RANGECHECK TITLE CO Plot Estimated Power Spectra l D e n s i t i e s . ID=SNAP 21:54 25 JUL 82 PAGE 2 1 OOOOO $eject ,11 t i e - ' P l o t Estimated Power Spectral Dens 111es.' ,under1 2 OOOOO 3 OOOOO --4 OOOOO Program to p lo t estimated Power Spectral Dens i t i es 5 OOOOO --6 OOOOO — 7 OOOOO 8 OOOOO --9 OOOOQ - - CONST 10 00100 m2 • 256; 11 00100 rm2 = REAL(m2); 12 00100 m = 2 * m2; 13 00100 rm = REAL(m); 14 00100 asca le = 1.0e-6 / 1023.0; 15 OOIOO spect_m1n = 1.0e-75; 16 OOIOO spect_range_dB = 200.0; 17 00100 --18 OOIOO - - TYPE 19 OOIOO s t r1ng = ARRAY ( 1 . .80) OF CHAR; 20 O01OO --.m2) OF REAL; 21 00100 vector = ARRAY (0. 22 00100 --.m2) OF SHORT; 23 OOIOO v_shorts » ARRAY (0. 24 OOIOO --.m+1) OF REAL; 25 OOIOO lvector = ARRAY (0. 26 OOIOO --. 27 OOIOO data_record = RECORD 28 OOIOO -- tape no, record no, sec 29 OOIOO -- ml 11Ivolts 30 O010O -- values 31 00100 -- END; 32 OOIOO --33 00100 data_array = ARRAY ( 1 . .18) OF data_record; 34 OOIOO --35 00100 command = (avsp ,avac ,sp ,ac ,susp ,suae ,sea1e , 36 00100 - - VAR 37 OOIOO spectra_f11e 38 00111 39 00111 s p e c t r a , c o r r e l a t i o n s 40 12598 --41 12598 x_t1me, x_frequency 42 12DAO --43 12DA0 fen 44 12DA2 45 12DA2 mp, mst 46 12DB4 --47 12DB4 snos 48 12DFC --49 12DFC t s c a l e , f s c a l e 50 12E04 --51 12E04 f s , psca le 52 12E18 --53 12E18 1, no_spectra . total_ _no_spectra 54 12E24 --55 12E24 --INTEGER; REAL; vector ; FILE OF CHAR; data_array; v_shorts; command; ARRAY (1...2) OF INTEGER; ARRAY (1. .18) OF INTEGER; SHORT; REAL; INTEGER; M Plot Estimated Power Spectra l D e n s i t i e s . ID=SNAP 21:54 25 JUL 82 PAGE 3 56 12E24 -- $eject$ 57 12E24 58 12E24 11 PROCEDURE 59 00070 --60 00070 1 1 PROCEDURE 61 00080 --62 00080 11 PROCEDURE 63 OOOOO --64 OOOOO 11 PROCEDURE 65 00080 --66 00080 1 1 PROCEDURE 67 00078 --68 00078 1 1 PROCEDURE 69 OOOOO 70 OOOOO 1 1 PROCEDURE 71 00088 --72 00088 1 1 PROCEDURE SHORT) s t r i n g ; nx : INTEGER; : SHORT) y : s t r i n g ; ny INTEGER) SHORT; 1 : INTEGER) ht : SHORT; chars : s t r i n g ; theta : SHORT; n : INTEGER) l vec tor ; f i . f 2 . f 3 , f4 : INTEGER) FORTRAN ' A L S I Z E ' ; FORTRAN 'ALSCAL ' : SLINKAGE 'ALAXIS ' ; FORTRAN 'ALGRAF'; FORTRAN ' P L O T ' ; SLINKAGE 'SYMBOL'; FORTRAN 'DF0UR2'; FORTRAN 'PLOTND'; Plot Estimated Power Spectral D e n s i t i e s . 73 00060 - - $eject$ 74 00060 - -75 00060 1- PROCEDURE get_spectra (VAR spectra : data_array); 76 0OO6O - -77 00060 - - VAR 78 0004C - - 1, J 79 00054 - -80 00054 - - vo1ts_sqr 81 0006Q. - -82 00060 2- BEGIN 83 0003E - -84 0003E - - reset (spect ra_f11e ,7 ) ; 85 0004C - -86 0004C - - 1 := 0; 87 00052 - - WHILE ((NOT EOF(spect ra_ f l ie ) ) AND (1 < 18)) DO 88 00066 3- BEGIN 89 00066 - -90 00066 - - INCR(1); 91 00072 - -92 00072 - - WITH spectra(1 ) DO 93 000A4 4- BEGIN 94 000A4 - - read(spectra_f1 le , tape_no,record_no,sect lor 95 000F8 - - vo1ts_sqr : * S0R(m1111 v o l t s * a s c a l e ) ; 96 0010C - - FOR J := 0 TO m2 DO 97 001IC 5- BEGIN 98 0011C - - r ead (spec t ra_ f1 le ,va lues (J ) ) ; 99 0014C - - va lues (J ) : = va lues ( j ) * v o l t s _ s q r : 100 00192 -5 END; 101 0019E - - read ln (spect ra_ f1 le ) ; 102 001AC -4 END; 103 001AC -3 END; 104 001B0 - -105 001B0 - - tota l_no_spectra := 1; 106 001BC - -107 001BC -1 END " g e t s p e c t r a " ; ID=SNAP 21:54 25 JUL 82 PAGE 4 INTEGER; REAL; Plot Estimated Power Spectra l D e n s i t i e s . IU=5NAP 2 1 : 5 4 2 b J U L 8 2 P A G E t> 108 00206 -- $eject$ 109 00206 -- PROCEDURE smooth (VAR spectra : data_array) ; 1 10 00206 1-1 1 1 00206 --1 12 00206 -- VAR 113 0004C -- k, J 1 14 00054 --1 15 00054 2- BEGIN 1 16 0003A --117 0003A -- FOR J := 1 TO tota l no spectra DO 1 18 00054 -- WITH spect ra ( j ) DO 1 19 00086 3- BEGIN 120 00086 -- values(O) : • 0.5 * (values(O) + va lues(O) * p s c a l e ; 121 OOOA4 -- values(m2) :» 0.5 * (values(m2) + va1ues(m2-1)) * p s c a l e ; 122 OOOBA -- FOR k := 1 TO m2-1 DO 123 000CC -- values(k) := (0.25 * ( v a l u e s ( k - l ) + values(k+1)) + 0.5 124 00176 -3 END; 125 00186 --126 00186 -1 END "smooth"; INTEGER; Plot Estimated Power Spectra l D e n s i t i e s . 127 001C8 - - $eject$ 128 001C8 - -129 001C8 1- PROCEDURE sca le_x ; 130 001C8 - -131 001C8 - - TYPE 132 O0O48 - - x_type = ( t Ime , t , f r equency , f ) ; 133 00048 - -134 00048 - - VAR 135 00048 - - space 136 0004A - - low, high 137 00060 - -138 00060 - - 1 139 00062 - -140 00062 2- BEGIN 141 0003A - -142 0003A - - wri teIn (' ','>> Time or f requency? ' ) ; 14 3 O0O84 - - space := frequency; 144 0O08C - - read (space); 145 000C2 - - I f (space IN ( . f r e q u e n c y , f . ) ) THEN 1 := 1; ELSE 146 OOOE6 - - wr l t e ln (' ' , ' » Range?' ) ; 147 00130 . - - read ( low,h igh) ; 148 00158 - - I f 1 - 1 THEN 149 00164 3- BEGIN 150 00164 - - mp(1) := INTEGER(h1gh / f s * m2 + 0 .5 ) ; 151 001C6 - - mst(1) := INTEGER(low / f s * m2 + 0 .5 ) ; 152 00220 -3 END; 153 00220 - - ELSE 154 00220 3- BEGIN 155 00224 - - mp(1) := INTEGER(hlgh); 156 00278 - - mst(1) :» INTEGER(1ow); 157 002CC -3 END; 158 002CC - - mp(1) := mp(1) - mst(1); 159 0033E - - I f (mp(1) < 10) THEN mp(I) := 10: 160 00396 - - IF (mp(1) > m2) THEN mp(1) := m2; 161 003EE - - i f (mst(1) + mp(1) > m2) THEN mst( l ) := m2 - mp( 162 00494 - -163 00494 -1 END "sca le_x" ; =SNAP 21:54 25 JUL 82 PAGE 6 type; real ; 2; Plot Estimated Power Spectra l Dens i t i es ID = SNAP 21:54 25 JUL 82 PAGE 7 164 00520 - - $eject$ 165 00520 - -166 00520 ) - PROCEDURE p lot data (y_data : vector ; VAR x_data : v_shor ts ; f l a g 167 00520 - -168 00520 -- VAR 169 00858 -- sy , sx 170 01060 - - poin ters 171 01060 - -172 01079 - - t i t l e s 173 01078 - -174 010A8 - - comment 175 010F8 - - l abe ls 176 010F8 - -177 01 1 16 - - k, 1p 178 01 120 - -179 01 120 - - INITIAL 180 01 120 - - poin ters = ARRAY 1, 2. 1, 2. 1. 2 END; 181 01 120 - -t i t l e s • ARRAY ('Power Spectrum (dB) ' ) , 182 01 120 - -183 01 120 - - ( ' A u t o c o r r e l a t i o n Funct ion ' ) 184 01 120 - - END; 185 01120 - -186 01120 - - l abe ls « ARRAY ( 'Frequency (Hz ) ' ) . 187 01120 - - ('TIme (msecs) ') 188 01120 - - END; 189 01 120 - -190 01 120 191 01 120 2- BEGIN 192 00064 - -193 O0O64 - - 1p := po1nters ( fen) ; 194 00094 - -195 00094 - - IF ( f l a g = 1) THEN 196 OOOAO 3- BEGIN 197 OOOAO - - LABELS(1abels(1p) ,14, ' ' . 1 ) ; 198 0010A - - SIZE(10 .0s ,7 .Os) ; 199 00120 -3 END; 200 00120 - - ELSE f l a g - 1 ; 201 0012C - -202 0012C -- FOR k := 0 TO mp(1p) DO 203 0016A 3- BEGIN 204 0016A - - sy(k) SHORT(y data(mst(1p)+k)); 205 001CE - - sx(k) := x data(mst(1p)+k); 206 00238 -3 END; 207 00244 - -208 00244 - - GRAPH(sx ,sy , ( f lag * (mp(1p)+1)),0); 209 00296 - -210 00296 - - IF ( f l a g = 1) THEN 211 002A2 3- BEGIN 212 002 A 2 - - comment := ' ' ; 213 002B2 - - wr1teln( ' ','>> Comment? ' ) ; 214 002 FC - - read(comment); 215 0031E - -TITLE(0 .5s ,7 .5s .O.14s,comment ,0 .Os,80) ; 216 003 1E - -217 00384 - - T ITLE(0 .5s ,7 .25s ,0 .14s , t1 t1es (1p ) ,0 .Os .24 ) ; 218 00414 -3 END; 219 00414 --220 00414 -1 END " p l o t d a t a " ; INTEGER); v_shorts; ARRAY (avsp . .suac) OF INTEGER; ARRAY (1 . .2) OF ARRAY (1. .24) OF CHAR; s t r 1 ng; ARRAY (1. .2) OF ARRAY (1. .15) OF CHAR; INTEGER; Plot Estimated Power Spectra l D e n s i t i e s . 221 004A2 -- $eject$ 222 004A2 --223 004 A 2 ' l - FUNCTION true prompt: BOOLEAN: 224 004A2 --225 004A 2 -- VAR 226 0004C -- k 227 0OO50 --228 00050 2- BEGIN 229 0003E --230 0OO3E -- true_prompt := TRUE; 231 0004A -- fen := s t ; 232 00056 233 00056 -- IF (NOT EOF) THEN 234 0005E 3- BEGIN 235 0005E -- wr1teln( ' ','>> Number of spectra = ' , t o t a l _ n o _ s p e c t r a , 236 OOODC -- w r i t e l n ( ' ','>> P l o t ? ' ); 237 00122 -- read( fen) ; 238 0O158 -3 END; 239 00158 --240 00158 -- k := 0; 241 0015E -- WHILE ((NOT EOLN) AND (fen <> st ) AND (k < 18)) DO 242 00182 3- BEGIN 243 00182 -- INCR(k); 244 0018E -- read(snos(k) ) ; 245 001C2 -- WHILE((INPUT* = ' ') AND NOT EOLN) DO GET(INPUT); 246 001E6 -3 END; 247 001EA --248 001EA -- IF ( fen = s t ) THEN true prompt := f a l s e ; 249 00204 -- no_spectra := k; 250 00210 --251 00210 -1 END "true_prompt"; ID=SNAP 21:54 25 JUL 82 PAGE 8 INTEGER; Plot Estimated Power Spectra l D e n s i t i e s . 252 002A5 - - $eject$ 253 002A5 - -254 002A5 ' 1- FUNCTION dB (spectrum : vector ) : vector ; 255 002A5 - -256 002A5 - - VAR 257 00858 - - k 258 0085C - - bound, bound_dB 259 00870 - - femp 260 01078 - -261 01078 2- BEGIN 262 00036 - -263 0OO36 - - bound := -1.0e75; 264 0003E - - FOR k := 0 TO m2 DO 265 00O4E bound := MAX (bound,spectrum(k)); 266 00O84 - -267 00084 - - bound_dB : = 10.0 * LOGIO(bound) - spect_range_dB; 268 000A6 - - FOR k~: = 0 TO m2 DO 269 OOOB6 3- BEGIN 270 0OOB6 - - bound := MAX (spect_m1n,spectrum(k)); 271 OOOEO - - temp(k) := MAX (bound_dB,(10.0 * LOGIO(bound) 272 00124 -3 END; 273 00130 - - dB : = temp; 274 00146 - -275 00146 -1 END "dB"; ID=SNAP 21:54 25 JUL 82 PAGE 9 INTEGER; REAL; vector ; Plot Estimated Power Spectra l D e n s i t i e s . 276 0019E -- $eject$ 277 0019E >-- FUNCTION average (VAR data 278 0019E ' l -279 0O19E --280 0O19E -- VAR 281 00050 -- temp 282 00858 -- n 283 00860 -- k, J , lp 284 0086C --285 0O86C INITIAL 286 OO86C -- temp 287 0086C --288 0086C --289 0086C 2- BEGIN 290 0OO5O -- n := REAL(no_spectra); 291 00050 --292 0OO76 -- FOR k :» 1 TO no spectra 293 0O088 3- BEGIN 294 00088 -- lp := snos(k) ; 295 000A E FOR J := 0 TO m2 DO 296 OOOBE -- temp(J) := temp(J) 297 00156 -3 END; 298 00166 --299 00166 -- average :« temp; 300 0017C --301 0017C -1 END "average"; • ARRAY 0 .0 , O.O : m2 END; ID=SNAP 21:54 25 JUL 82 PAGE 10 vector ; REAL; INTEGER; Plot Estimated Power Spectra l D e n s i t i e s . 302 001BA - - $eject$ 303 001BA - -304 001BA ' l - FUNCTION one_array (VAR data : d a t a a r r a y 305 001BA - -306 OOIBA 2- BEGIN 307 O0O3C - -308 0003C - - one_array := da ta (snos(1 ) ) .va lues ; 309 000A4 - -310 OOOA4 -1 END "one_array": ID=SNAP 21:54 25 JUL 82 PAGE 11 INTEGER) : vector ; Plot Estimated Power Spectra l D e n s i t i e s . 311 OOOD2 -- $eject$ 312 OOOD2 -- FUNCTION ac funct1on(VAR spectra : data_array) : data_array 313 000D2 V 314 00OD2 --315 00OD2 --316 000D2 -- VAR 317 00050 -- temp 318 01O60 -- j . k 319 01068 -- n 320 01070 --321 01070 --322 01070 2- BEGIN 323 0003E --324 0003 E -- ac_funct ion := spect ra ; 325 00058 --326 00058 -- FOR k := 1 TO tota l no_spectra DO 327 00076 3- BEGIN 328 00076 -- FOR J := 0 TO m2 DO 329 00O8A 4- BEGIN 330 0008A -- temp((2*j)+1) := 0.0; 331 000A E -- temp(2*J) :» s p e c t r a ( k ) . v a l u e s ( J ) ; 332 00120 -4 END; 333 0012C -- FFT(temp.m,1.1 , -1 ) ; 334 00156 -- n := REAL(spectra(k) .sect Ions) * rm * rm2; 335 001AE -- FOR J := 0 TO m2 DO 336 001C2 -- ac funct1on(k) .va1ues(J) := temp(J) / n; 337 002 3 E -3 END; 338 00252 -1 END "ac_funct1on"; ID=SNAP 21:54 25 JUL 82 PAGE 12 1 vector ; INTEGER; REAL; K> Plot Estimated Power Spectra l D e n s i t i e s . ID=SNAP 21:54 25 JUL 82 PAGE 13 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 002AA 002AA 002AA OOOBE OOOBE OOOCA OOOCE 000D4 OOOD8.. OOOD8 000F6 000F6 00140 00156 0016A 0017A 00188 00188 0019A 0019A 001D8 00216 002 1E 002 1E 0022C 0025C 00266 00266 00280 00280 00292 00312 0036A 003FO 004 4C 0045C 00476 004 FC 0050C 00526 00582 00582 005C0 005C0 005C4 005C4 005CA 005CA $eject$ BEGIN 2--2 2-mp( 1) := m2 mp(2) : • m2 mst( 1) : = 0 mst(2) := 0 PLOT(1 .Os .O .Os , -3 ) ; wr1teln (' read ( f s ) ; psca le := 1 . 0 / ( fs * rm); f s c a l e := SHORT(fs / rm); t s c a l e >> Sampling f requency? ' ) ; » SHORT(1.Oe3 / f s ) ; 0 TO m2 DO FOR 1 :<• BEGIN x_frequency(1) := SHORT(1) * f s c a l e ; x_t1me(1) := SHORT(1) * t s c a l e ; END; ge t_spect ra (spect ra ) ; c o r r e l a t i o n s :» ac_funct1on(spectra) ; smooth(spectra); WHILE true_prompt DO BEGIN fen I'F « sca le THEN sca le_x ; IF fen » avsp THEN plot_data(dB(average(spectra) ) ,x_frequency,1) ; avac THEN p iot_data(average(corre la t 1ons),x_tIme,1); sp THEN plot_data(dB(one_array(spectra .1) ) .x_frequency.1) ; ac THEN p1ot_data(one_array(correlat Ions,1),x_t1me, 1 ); susp THEN _ = 1 TO no_spectra DO plot_data(dB(one_array(spectra ,1 ) ) ,x_f requency,1) ; I £ fen « suae THEN FOR 1 := 1 TO no_spectra DO plot_data(one_array(corre la t Ions,1 ) .x_t Ime,1) ; IF ( ( fen <> sca le ) AND (fen <> s t ) ) THEN PLOT ( 1 1 . O s , 0 . 0 s . - 3 ) ; IF fen I £ fen I f fen J_F fen FOR 1 -2 END; PLOT_END; -1 END "main". No e r r o r s detected 0.728 CPU s e c . 0 231 F. NOVA 840 Program L i s t i n g s F.1 Reading VGH EMG Data Tapes TRANSFER — program f o r t r a n s f e r r i n g EMG data tapes recorded on the PDP-11 a t VGH to the NOVA 840 at UBCs Department of E l e c t r i c a l E n g i n e e r i n g . HEADERREAD — subroutine f o r readi n g r e c o r d headers. DATAREAD — subroutine f o r reading r e c o r d data f i e l d s . SWITCH — subroutine f o r swapping bytes: PDP-11 to NOVA 840 16 b i t word r e f o r m a t t i n g . N E S S H U t " L O A D I N G TRANSFER DATAREAD HEADERREAD DRERR SWITCH P A G E " : MESSAGE " CHARASM AND T E K P L O T . " _ t 3 2. MESSAGE " D E L E T I N G F I L E ' L I S T ' " D E L E T E / V L I S T RLDR L I S T / E TRANSFER DATAREAD HEADERREAD DRERR SWITCH P A G E * CHARASM T E K P L O T F O R T . L B F S Y S . L B M E S S A G E "DONE WITH LOAD ING <TLOAD) " M E S S A G E " T Y R E L I S T C 9 / 4 , 8 0 • CHANTASK 1 0 , 3 C PARAMETER T C H A N = 6 3 , D C H A N =62 , S T A T C H A N = 6 1 , S P C F W D = 3 8 0 0 0 K , N B L C K S = 8 , TREAD=0K , B0T=7 , R D S T A T = ? 0 O 0 0 K , S T A T E R = 1 5 , EQF=8, RWND=1O000K, N 0 U R I T = 2 , C R T = 1 0 , L P T = 1 2 , KYBD=11 C C T H I S I S THE MA IN R O U T I N E FOR T R A N S F E R I N G ONE RECORD OF E . M . G . C DATA FROM A MAGTAPE C O M P I L E D AT V . G . H . U S I N G R. M A C K I N N O N ' S C E i M . G . P R O C E S S I N G PROGRAM. C THE TAPE AND THE RECORDS HAVE HEADERS WHICH ARE READ ALONG WITH 889 C B L O C K S ( 4 5 0 5 6 0 B Y T E S ) OF DATA. C INTEGER R E C O R D ( 4 0 ) , ERROR, T A P E ( 2 0 ) , S T A T U S , T S T A T U S , RECNUM, L S T R E C L O G I C A L F L T R D E X T E R N A L DATAREAD , HEADERREAD , DRERR, P A G E , SWITCH , B E L L C C NEW PAGE OH CRT. C C A L L P A G E ( C R T , - 1 > TYPE " E . M . G . DATA T R A N S F E R . i C C I N I T I A L I Z E THE DATA D I R E C T O R Y . C C A L L I H I T <"D P O : E M G D A T A " , 0 , ERROR) C C I S THERE AH ERROR, BUT NOT ' D E V I C E A LREADY I N S Y S T E M ' ? C DRERR I S THE WIZZ BANG ERROR P R O C E S S I N G R O U T I N E . USED ONLY IN T H I S C PROGRAM SET . C I F ( ( E R R O R . N E . 1 ) . A N D . ( E R R O R . N E . 4 0 ) ) C A L L D R E R R ( 1 , E R R O R ) C A L L F O P E N ( D C H A H , ' D A T A ' ) C A L L FOPEN<STATCHAN , ' D A T A S T A T S ' ) C C A L L B E L L PAUSE "MOUNT TAPE ON U N I T ZERO WITH WRITE R I N G O U T " , C C I N I T I A L I Z E THE T A P E U N I T . C C A L L I N I T < " M T 0 " , 0 , E R R O R ) C I F ( ( E R R O R . N E . 1 ) . A N D . ( E R R O R . N E . 4 0 ) ) C A L L D R E R R ( 1 , E R R O R ) 5 CONTINUE C C O P E N MT0 ON I---0 CHANNEL " T C H A N " . C C A L L M T O P D ( T C H A N , ' M T 0 : O ' , 0 , E R R O R ) I F ( E R R O R . H E . 1 ) C A L L D R E R R ( 2 , ERROR) C C I S TAPET WRITE D I S A B L E D ? ? IC ,' C A L L M T D I O ( T C H A N , RDSTAT , RECORD, S T A T U S , ERROR) I F ( . NOT. ( I T E S T ( S T A T U S , B O T ) ) ) C A L L M T D 1 0 ( T C H A N , RWND,RECORD, S T A T U S , E R R O R ) C I F ( I T E S T ( S T A T U S , N O W R I T ) ) GOTO 4 C A L L B E L L TYPE " T A P E WRITE I S E N A B L E D . REMOUNT WITH WRITE R I N G O U T ! " C A L L F C L O S ( T C H A N ) C A L L B E L L PAUSE " S T R I K E ANY KEY TO C O N T I N U E . " GOTO 5 4 CONTINUE L S T R E C = 0 C C NO, GO AHEAD AND READ T A P E HEADER . C C A L L H E A D E R R R E A D ( ' T A P E ' , T A P E ) C 3 CONTINUE C C W R I T E . T A P E tt AND TOTAL # OF RECORDS ON CRT . AND PROMPT FOR THE RECORD C TO BE T R A N S F E R R E D . C W R I T E ( C R T , 3 0 ) T A P E ( 1 ) , T A P E ( 2 ) 3 0 FORMAT ( ' 0 ' , ' T A P E NUMBER: ' , 1 2 , ' ; WITH ' , 1 2 , ' RECORD ( S ) . ' , /> ' ) C A L L B E L L ACCEPT "WHICH RECORD? " , R E C N U M C C I F RECORD # I S L E S S THAN ZERO T E R M I N A T E PROGRAM. C I F ( R E C N U M . L E . 0 ) GOTO 999 I F ( R E C N U M . G T . L S T R E C ) GOTO 9 C C I F RECORD D E S I R E D I S BEFORE L A S T RECORD E X A M I N E D , REWIND T A P E . C C A L L MTDIO ( T C H A N , R W N D , R E C O R D , S T A T U S , ERROR) I F ( ERROR . GT. 1) C A L L D R E R R ( 4 , E R R O R ) I F ( I T E S T ( S T A T U S , S T A T E R ) . AND. ( .NOT . I T E S T ( S T A T U S , E O F ) ) ) C A L L D R E R R ( 3 , 1 5 ) C C S K I P THE TAPE HEADER T H I S T I M E . C i C A L L MTDIO ( T C H A N , S P C F W D , R E C O R D , S T A T U S , E R R O R ) L S T R E C = 0 iC I 9 ! CONTINUE C C R|EAD ONLY RECORDS A V A I L A B L E . I F ( R E C N U M . G T . T A P E C 2 ) ) GOTO 3 K I P PAST THE I N T E R V E N I N G RECORDS . THERE 7 T A P E RECORDS FOR EACH EMG C R|ECORD. C LNUM = 7 * (RECNUM - L S T R E C - 1) DO 1 1 = 1 , L N U M C A L L MTD10 (TCHAN , S P C F W D , R E C O R D , S T A T U S , E R R O R ) I F ( E R R O R . G T . l ) C A L L D R E R R ( 4 , E R R O R ) I F ( I T E S T ( S T A T U S , S T A T E R ) . A N D . ( . N O T . I T E S T ( S T A T U S , E O F ) ) ) C A L L D R E R R ( 3 , 1 5 ) 1 I CONTINUE C C READ THE RECORD HEADER . C I C A L L H E A D E R R E A D ( ' R E C D ' , R E C O R D ) c-C AND WRITE TO CRT FOR OPERATOR E X A M I N A T I O N . C W R I T E ( C R T , 1 0 ) ( R E C O R D ( I ) , 1 = 1 , 4 0 ) 10 F O R M A T ( ' @ ' , ' DATE RECORDED: ' , T 4 1 , 5 A 2 , / ' ' , " I D E N T I F I C A T I O N : " , T 4 1 , 3 A 2 , / ' ' , " A M P L I F I E R S E T T I N G " , " ( M I C R O V O L T S ^ D I V ) : " , T 4 1 , 14 , / ' 0 ' , " COMMENT : " , 3 1 A 2 , / " 0 ' ) c C T R A N S F E R T H I S DATA TO RDOS F I L E ? C W R I T E ( C R T ) "DATA TO BE T R A N S F E R E D FROM T H I S RECORD ( Y E S OR N O ) ? " R E A D ( K Y B D , 5 0 ) T S T A T U S I F ( T S T A T U S . E Q . ' N O ' ) GOTO 7 C C READ THE EMG DATA (TO F I L E EMGDATA: D A T A ) . C C A L L DATAREAD C C F L T R D I S A F L A G WHICH I N D I C A T E S THAT U N F I L T E R E D DATA HAS BEED READ I N . C F L T R D = . F A L S E . C C S A V E THE EMG RECORD INFORMAT ION IN F I L E E M G D A T A : D A T A S T A T 5 . C WRITE B I NARY <STATCHAN) T A P E ( 1 ) , RECNUM, ( R E C O R D ( I ) , 1 = 1 , 4 0 ) , F L T R D C A L L B E L L 7 CONT INUE C C A L L B E L L C C R E G A R D L E S S , A HARDCOPY OF THE EMGDATA TRANSFER I S O B T A I N A B L E (ON THE C L I N E P R I N T E R ) . C W R I T E ( C R T ) "HARDCOPY D E S I R E D ( Y E S OR N O ) ? " R E A D ( K Y B D , 5 0 ) STATUS 5 0 : F O R M A T ( A 2 ) I I F ( S T A T U S . EG!. ' NO ' ) GOTO 6 i C A L L P A G E ( L P T , - 1 ) | W R I T E ( L P T , 3 0 ) T A P E ( l ) , T A P E ( 2 ) W R I T E ( L P T , 2 0 ) RECNUM 2 0 F O R M A T C 9 ' , ' RECORD #' , 1 2 , ' : ' ) W R I T E ( L P T , 1 0 ) ( R E C O R D ( I ) , 1 = 1 , 4 0 ) WRITEC L P T , 6 0 ) 6 0 F O R M A T C 1 ' , ' ' , / ' 1 ' , ' ' > C 6 CONTINUE C C I F A TRANSFER HAS BEEN MADE, STOP PROGRAM. I F ( T S T A T U S . E Q . ' Y E ' ) GOTO 999 C C E l S E , S K I P SCRATCH RECORDS (FOR M A C K I N N O N ' S PROGRAM) TO B E G I N N I N G OF C N E K T RECORD, U N L E S S AT THE END OF THE # OF EMG RECORDS . C I F ( R E C N U M . G E . T A P E ( 2 ) ) GOTO 3 L S T R E C = RECNUM j DO S I = 1, 7 C A L L M T D I O ( T C H A N , S P C F W D , R E C O R D , S T A T U S , E R R O R ) I F ( E R R O R . G T . l ) C A L L D R E R R ( 4 , E R R O R ) I F ( I T E S T ( S T A T U S , S T A T E R ) . AND. ( . N O T . I T E S T ( S T A T U S , E O F ) ) ) C A L L D R E R R ( 3 , 1 5 ) 8 CONTINUE C C NEW CRT PAGE , AND GO FOR MORE. C C A L L P A G E ( C R T , - 1 ) GOTO 3 C 999 CONTINUE C A L L R E S E T C A L L R L S E < " E M G D A T A ' S ERROR) C A L L R L S E C " M T 0 " , E R R O R ) STOP TRANSFER END PARAMETER T C H A N = 6 3 , S T A T C H A N - 6 1 , DCHAN=62 , S P C F U D = 3 O 0 0 0 K , PARAMETER ^ H A N ^ = ^ T R E A D = 0 K , B 0 T = 7 , R D S T A T = 7 0 0 0 0 K , S T A T E R = 1 5 EOF=S , RWND=10000K , N 0 W R I T E = 2 , C R T = 1 0 , L P T = 1 2 , KYBD = 1 1 , T B L C K S = 8 8 0 , L B I T S = 3 7 7 K , H B I T S = 1 Q 1 4 0 Q K S U B R O U T I N E H E A D E R R E A D ( H D R T I T , H E A D E R ) T H I S I S R O U T I N E TO READ THE T A P E AND RECORD H E A D E R S OF A MAGTAPE RECORDED AT V . G . H . U S I N G R. M A C K I N N O N ' S E . M . G . P R O C E S S I N G PROGRAMS . T H E TAPE MUST BE P O S I S T I O N E D AT THE B E G I N N I N G OF THE HEADER TO BE R E A D . H D R T I T — FOR R E A D I N G THE T A P E HEADER ==> H D R T I T = ' T A P E ; E L S E , FOR T E A D I H G RECORD HEADERS ==> H D R T I T = ' R E C D ' . HEADER — THE R E S U L T A N T HEADER , I N AN I N T E G E R A R R A Y OF D I M E N S I O N 2 0 FOR THE T A P E HEADER AND 49 FOR THE RECORD HEADER . I N T E G E R J , H E A D E R ( 1 ) , H D R T I T , RDCNT, ERROR, S T A T U S , bJRDCNT, TEMP , SWITCH E X T E R N A L DRERR , SWITCH THE RECORD HEADER I S 48 WORDS LONG: RDCHT = 48 BUT THE T A P E HEADER I S ONLY 28 WORDS LONG: I F ( H D R T I T . E Q . ' T A P E ' > RDCNT = 20 R E A D THE HEADER : C A L L M T D 1 0 ( T C H A N , RDCNT, H E A D E R , S T A T U S , E R R O R , W R D C N T ) I F ( E R R O R . N E . 1 ) C A L L D R E R R ( 7 , E R R O R ) I F C I T E S T ( S T A T U S , S T A T E R ) ) C A L L D R E R R ( 6 , 1 5 ) I F ( W R D C N T . N E . R D C N T ) C A L L D R E R R ( 5 , 1 5 ) A G A I N , THE B Y T E S FROM THE E . M . G . DATA T A P E S ARE R E V E R S E D FOR I N T E G E R DATA (NOT A S C I I D A T A ) , AND T H E R E F O R E MUST BE REORDERED•. I F ( H D R T I T . E Q . ' T A P E ' ) GOTO 3 TEMP = H E A D E R ( 9 ) H E A D E R ( 9 ) = S W I T C H ( T E M P ) GOTO 1 3 CONT INUE DO 1 J = l , 2 0 TEMP = H E A D E R ( J ) H E A D E R ( J ) = S W I T C H ( T E M P ) 1 CONT INUE S P A C E TO THE END OF THE T A P E HEADER F I L E , I F N E C E S S A R Y . I F ( H D R T I T . N E . ' T A P E ' ) GOTO 2 C A L L M T D 1 0 ( T C H A N , S P C F W D , T E M P , S T A T U S , E R R O R ) J _. I F ( E R R O R . G T . l ) C A L L D R E R R ( 9 , ERROR ) 2 3 9 C A L L D R E R R < 8 , 1 5 ) 0 C O N T I N U E RETURN END PARAMETER TCHAN=63 , S T A T C H A N - 6 1 , DCHAN=62 , S P C F W D = 3 0 0 0 0 K , - N B L C K S = 3 , TREAD=9K , B0T=7 , R D S T A T = 7 0 0 0 O K , S T A T E R = 1 5 , ; - E 0 F = 8 , RWND=109O0K, N0WRITE=2 , C R T = 1 0 , L P T = 1 2 , KYBD=11 , T B L C K S = 8 8 0 C C S U B R O U T I N E DATAREAD C C T H I S I S A R O U T I N E TO READ THE E . M . G . DATA FROM THE P O S I S T I O H E D MAGTAPE . C A G A I N , THE ORDER OF THE B Y T E S I S R E V E R S E D W . R . T . I N T E G E R R E P R E S E N T A T I O N C ON THE NOVA 8 4 0 , AND THEREFORE MUST BE CHANGED B E F O R E THE DATA CAN BE C P R O C E S S E D . C THE D I S K F I L E W I L L BE A C C E S S E D V I A CHANNEL € 2 . C THE MAG T A P E W I L L BE A C C E S S E D V I A CHANNEL 6 3 . C C FOR E X P L A I NAT I ON OF MTDIO AND WRDBLK SEE FORTRAN IV U S E R ' S MANUAL . C INTEGER I , J , ERROR, E M G D A T ( 2 0 4 8 ) , TEMP , S W I T C H , S T A T U S , WRDCNT, S B L O C K C E X T E R N A L DRERR, SWITCH C C THE F I L E I S 8 8 0 B LOCKS LONG ( 4 5 0 5 6 0 B Y T E S ) AND I S LOCATED IN C THE P A R T I T I O N " E M G D A T A " . I C C W R I T E TO BLOCK. 0 TO START : C SBLOCK=0 C j DO 1 1 = 1, 110 ! C A L L M T D I O ( T C H A N , T R E A D , E M G D A T , S T A T U S , ERROR ,WRDCNT ) | I F ( E R R O R . N E . l ) C A L L D R E R R ( 1 2 , E R R O R ) ; I F ( I T E S T ( S T A T U S , S T A T E R ) ) C A L L D R E R R ( 1 1 , 1 5 ) I F ( W R D C N T . N E . 2 0 4 8 ) C A L L D R E R R ( 1 0 , 1 5 ) C DO 2 J = l , 2 0 4 8 ! TEMP = E M G D A T ( J ) ! E M G D A T ( J ) = S W I T C H ( T E M P ) 2 CONT INUE C C A L L W R B L K ( D C H A N , S B L O C K , E M G D A T , N B L C K S , E R R O R ) I F ( E R R O R . H E . 1 ) C A L L D R E R R ( 1 3 , E R R O R ) SBLOCK = SBLOCK + N B L C K S 1 CONT INUE C I RETURN 1 END PARAMETER L B I T S = 3 7 7 K , H B I T S = 1 7 7 4 0 0 K C [ 2 . 4 - 0 C INTEGER F U N C T I O N SWITCH <ARG) i C C T H I S ROUTINE S W I T C H E S THE B Y T E S OF THE ARGUMENT ' A R G ' > AND MASKS C O^F THE EXTENDED S I G N . C T H E R E S U L T I S A TWO ' S COMPLEMENT I N T E G E R WITH THE RANGE OF C - | l 0 2 4 TO 1 0 2 3 . C INTEGER ARG, TEMPA, TEMPB C TEMPA = ARG TEMPB = I S H F T < T E M P A , - 8 ) TEMPA = I S H F T < T E M P A , 8 ) TEMPA = I A N D < T E M P A , H B I T S ) TEMPB = I A N D ( T E M P B , L B I T S > SWITCH = TEMPA + TEMPB RETURN END 241 F.2 PSD E s t i m a t i o n of EMG Data FULSPECT10 — program f o r PSD e s t i m a t i o n at the f u l l 10 KHz sampling r a t e . POTSPECT10 — program f o r PSD e s t i m a t i o n of average SMUAP from the adaptive matched f i l t e r a t the f u l l 10 KHz sampling r a t e . BASELINE — program f o r s e l e c t i o n of background noi s e segments and PSD e s t i m a t i o n . BDSPLY — subroutine f o r d i s p l a y i n g a data r e c o r d f o r the manual removal of SMUAP segments. PREPRC -- subroutine f o r PSD e s t i m a t i o n using modified Blackman-Tukey method [67]. BASFLT — subroutine f o r FIR f i l t e r of data to 833 Hz. PLOTSPECTRUMS — program f o r p l o t t i n g PSDs from a data f i l e . DFFT — subroutine to perform double p r e c i s i o n FFT. PRCNIT — subroutine f o r i n i t i a l i z i n g PSD esti m a t e . MESSAGE "LOADING FULSPECT10 DFFT PRCPLT" MESSAGE " PRCNIT PAGE TEKPLOT AND CHARASM. " MESSAGE "OUTPUT TO LIST — LIST WILL BE DELETED FIRST. " DELETE/V LIST RLDR FULSPECT10 PAGE CHARASM TEKPLOT+ | DFFT PRCPLT PRCNIT FORT. LB FSYS. LB LIST/'E MESSAGE "FINISHED LOADING <F10LOAD) TYRE LIST i C 8 0 . 5 . 1 6 C PARAMETER DCHAN=62 , S T T C H A N= 6 1 , CRT= 1 0 , KYBD= 1 1 / 0N=1 , 0 F F = - 1 , CMASK=377, D D I S= 1 5 , Y A L P H A= 2 0 4 , M=512 , MM1=511 , M2=256, SPCHAN=60, R V S = - 1 , FWD=1, M2M1=255 C Q * * * * * * * * * + + * * * * * * * * + + * * * + * * * + * + * + * + + * * + * * * * + + + * * * + + + * * * * * + * * + * + + * + :+::+: + + + +. C C MAIN R O U T I N E " F U L S P E C T 1 0 " C C + + + + + + * + + + + + * + + c • C T H I S PROGRAM I S FOR C A L C U L A T I N G THE E S T I M A T E D POWER SPECTRUM OF C T H E B A S E L I N E V A R I A T I O N P L U S N O I S E . C C IN T E G E R I E M G ( 0 : M M 1 ) , ERROR, SCNT, NO, NOMP, RECORD(40>, TAPNUM, RECNUM, AMP, CMND C DOUBLE P R E C I S I O N S P E C T ( 0 : M 2 ) , ROEMG(2, 0, M2), RSEMG<2, 0 s M M 1 ) DOUBLE P R E C I S I O N COMPLEX CSEMG(0=MM 1 ) , COEMG(0=M2) C COMMON /EMGREC/IEMG X-PRCREC/SPECT, NO, SCNT, CSEMG, COEMG, NOMP E Q U I V A L E N C E ( R S E M G ( 1 , O ) , CSEMG ( 8 ) ) , ( R G E M G d , O ) , C O E M G ( O ) ) C EXTERNAL PRCPLT, P R C H I T , B E L L , PAGE, ERASE, DFFT C A L L P R C N I T C A L L I N I T C D P 0 : E M G D A T A ' , 0, ERROR) C A L L FOPENCDCHAN , ' D A T A ' > C A L L F O P E N ( S T T C H A N , ' D A T A S T A T S ' ) C A L L APPEND < SFCHAN , ' S F U L L 1 0 ' , 3 , E R R O R ) C A L L P A G E ( C R T , 0 ) WRITE-::CRT) "TOTAL ( 0 - 5 K H 2 ) SPECTRUM E S T I M A T I O N " RECNUM = 0 AMP = 1 READ B I N A R Y ( S T T C H A N ) TAPNUM I F ( T A P N U M . L T . 9 ) GOTO 1 READ B I N A R Y ( S T T C H A N ) RECNUM, ( R E C O R D ( I ) , 1 = 1 , 4 8 ) WR I TE ( CRT, 4 9 9 ) TAPNUM, RECNUM, ( R E C O R D ( I ) , 1 = 1 , 4 0 ) 4 9 9 F O R M A T ( ' 0 ' , " TAPE #" , I 2 , T 4 1 , "RECORD # " , 1 2 , / ' ' , " DATE RECORDED: " , T 4 1 , 5 A 2 , / ' ' , " I D E N T I F I C A T I O N : " , T 4 1 , 3 A 2 , / ' ' , " A M P L I F I E R S E T T I N G ( M I C R O V O L T S / D I V ) = " , T 4 1 , I 4 , / " 0 ' , " COMMENT: " , 3 1 A 2 ) AMP = R E C 0 R D ( 9 ) C A L L P A G E ( C R T , 0 ) W R I T E ( C R T ) "TOTAL ( 0 - 5 K H Z ) SPECTRUM E S T I M A T I O N " 1 CONTINUE C A L L F C L O S ( S T T C H A N ) WRITE ( C R T , 4 9 7 ) 4 9 7 FORMAT C 0 ' , 1 0 X , " — HOW MANY B L O C K S ? " , 2 ) READ ( K Y B D ) NBLCKS N B L C K S = MIN0 ( N B L C K S , 4 4 0 ) N B L C K S = MAX0 ( N B L C K S , 2 ) W R I T E ( C R T , 4 9 8 ) NBLCKS 4 9 2 F O R M A T ( ' CH' • 1 ftX. " — _BRI1££SS I NG: " , 1 3 , " Bt OCKS " . / ' ' ) NK = 1 NBLCKS = 2 * N B L C K S - 1 DO 2 I = 0 , N B L C K S , 2 C A L L RDBLK CDCHAN, I , I E M G < 0 ) , 2 , E R R O R ) DO 4 J = O, M2M1 R S E M G < 1 , J ) = D F L 0 A T < I E M G < 2 * J ) > RSEMG<2, J ) = O. ODO CSEMG < MM 1 - J ) = C O . 0 D 0 , 0 . O D O ) CONT INUE C A L L DFFT <CSEMG, M , - 1 ) DO 5 J = 0 , M2 S P E C T C J ) = S P E C T ( J ) + R O E M G d , J ) * * 2 + R 0 E M G C 2 , J ) * * 2 + C - 1 . 0 D O + + J ) + < R O E M G < l , J ) * R S E M G < 1 , J ) + R 0 E M G C 2 , J ) * R S E M G C 2 , J ) ) COEMGCJ ) = C S E M G ( J ) CONT INUE WRITE (.CRT, 5 0 4 ) NK 5 0 4 FORMAT <1X, 13 , I X , Z ) I F C M O D C H K , 1 3 ) . E Q . 0 ) WRITE <CRT) NK = HK. + 1 2 COHTIHUE NO = H B L C K S + 1 C A L L B E L L C A L L B E L L WRITE ( C R T ) " < 1 5 > " C A L L P R C P L T WRITEC C R T , 5 0 0 ) FORMAT<•'0 ' , 1 0X , " — SAVE S P E C T R U M ? Z ) C A L L B E L L READ ( K Y B D , 5 0 1 ) CMND FORMAT < A 2 ) I F (CMND. EQ. •" NO ' ) GOTO 9 9 9 W R I T E C S P C H A H , 5 0 2 ) T A P N U M , R E C H U M , N O , A M P , < S P E C T < J ) , J = 0 , M 2 ) 5 0 2 FORMAT < ' ' , 2 < I 2 , I X ) , 13 , I X , 14 , I X , / , f 3 < G 2 2 . 15 , I X ) ) ) WRITEC CRT, 5 9 3 ) 5 0 3 FORMAT C' ' F 1QX, " - - S PECTRUM SAVED IN ' S F U L L 1 0 ' ! " ) C A L L B E L L CONTINUE C A L L R E S E T STOP F U L L SPECTRUM END dw« ccDNiiiHS aanindww s i lWHriu.. i d s o o y 1 1 3 3 i i y a 3 n N 1 1 H 0 3 60 T 3 0 T 0 1 0 D Hsnyd i i s a i i y o <6>aao33a = duy <, , x ' 3 y i £ ' . , ' 1 N 3 W W 0 3 '<0</ ' f r l ' I t - l ' , , •'(Aia/SilOAOdDIW) 0NI113S a s u i i d w y „', ,/ ' 2 y £ 'I1>1'.. ' N O I I U O I J U H 3 H I </ 'sys 'it»i'.. :a3aao33d 3iya </ . - . '2i'..# a a o o a a . . ' T ^ i ' 3 i ' „ # 3 d y i •, ' , 0 , > i y w a c u esi> c o t ? ' i = i '< i >rj.aoo3a> - wriNosa'wnndyi <66i>'iao>3i iar i 0 0 i 0103 < <3oay 3N wnN33d> ao ' <toay 3 N wnHdyi)•> J I eoyy ' x o a y < e s s = a N 3 ' N W H o a > A a y N i a n . y 3 a CdOddB 'I S S N Q I l I S Q d : XdOPl ^ ' N y H 3 d > N3d0 l i y o cNyHocn s o i o j i i y o c o t ' i = i '< i)aao33d> 'wriHOBd <NyH3 i i :> A a y N i a n y s a 0 0 1 0JL0D ( 0 ' 1 1 wnNdwi> J I w n N d y i c N y H o a > A a y N i a a y 3 d 0 = w r i H 3 3 d 0 = duy < • . ' d W 3 i a s o y a s A y J O wnai33ds asi ' iod,, •'.• ,>iywaoj set> <36t- ' i a 3 > 3 i i a i v i <o ' i a 3 > 3 o y d i i y o <aoaa3 ' i * . s i y i s y i y a , 'NWHoa>N3do i i y o <aoaa3 ' 0 ' . - y iyaoto : o d a ,>IINI n y o /<aa ' 0 * z s 3 x i o 3 d s -von • 0 * i ? 3 0 T / ' i 3 3 d S 3 y i y a l o i d a ' l o i d i - l j j a ' 3 o y d - i i s a ' y H d i y ' i o i d l y n a s i x s 3 3 3 3 < <0>133dS3 '<0 ' I > 133dSd ) 3 3 N 3 i y A I ("103 1 3 3 d S i '133dS '103dS3.-33a3dS^ N0WW03 3 ( IWW : 0 ) 1 3 3 d S 3 X31dW03 H 0 I S I 3 3 d d S i a r i O H . <TWW : 0 '3)133dSa ' SU 'NIWS 'XUHS '<3W : 0 > i 3 3 d S l '<3W :0>i33dS N 0 I S I 3 3 d d 3131100 3 oayi l y o i o o i dwy 'Sloan 'aoaas '<89i :0>dW3i ' tetoaaooaa '33aw 'isyy 'wnnosa 'wriNdyi S 3 D 3 I N I 3 ' II <0 'I >SFIOGNrli. NI a3d01S 31WldW31 3 u.3Dya3,'",y S H I J O wnai03ds 3Hi i o i d ciNy ' s i y i n o i y o 0 1 s i 3Niinoa S I H I 3 3 + * * * + * * * * * + + •¥ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 3 3 0T133dSlOd 3Niinoa 3 3 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 3 3 3 saet't'T 9=3iy3s ' i 9 = N y H o a ' 0 9 = N y H 3 d s 'ii=aaA>i '0 i= ia3 '0t?i=yHdiyA '03=ayix '03i= o a o A '0O3=oaox '3I9=W 'IIS=IWW '000'2IS=13dSU 'SS3=IW2W '9S3=3W asiiwyayd 3 jg.^ 9T S '08 3 1 9 2 C O N T I N U E 1 I F C A M P . L E . 8 > G O T O 9 9 9 R E A D B I N A R Y C D C H A N , E N D = 9 9 9 ) N P O T S , C C A R G 1 , J = l , 2 ) , 1 = 1 , N P O T S ) , < A R G 1 , 1 = 0 , 1 6 8 ) , C T E H P C I ) , 1 = 0 , 1 6 8 ) C A L L F C L O S < D C H A N ) Z c C A L L P A G E < C R T , - 1 ) W R I T E ( C R T , 4 9 S ) C A L L I P L O T C T E M P C 0 ) , 1 ) - C A L L P L O T < 9 , Y A L P H A , 0 ) C A L L A L P H A C A L L B E L L W R I T E C C R T , 5 0 5 ) 5 0 5 F O R M A T C ' 0 ' , 1 0 H , " — D E C I B E L S ? H , 2 ) R E A D C K Y B D , 5 0 4 ) I A R G 5 0 4 F 0 R M A T C A 2 ) T A R G = . F A L S E . I F < I A R G . E Q . ' Y E ' ) T A R G = . T R U E . C C DO 1 3 K = 0 , 1 6 8 1 3 R S P E C T C 1 , K ) = D F L O A T < T E M P ( K ) ) C A L L D F F T C C S P E C T , M , - 1 ) C DO 3 K = 0 , M 2 3 T S P E C T C K ) = D C A B S C C S P E C T C K ) ) * * 2 S M I N = 0 . 0 D 0 S P E C T C O ) = C 8 . 5 D 0 * C T S P E C T C 0 ) + T S P E C T C 1 ) ) / S C A L E ) S P E C T C M 2 ) = C 0 . 5 D 0 * C T S P E C T C M 2 ) + T S P E C T C M 2 M 1 ) ) / S C A L E ) S M A X = D M A X 1C S P E C T C 0 ) , S P E C T < M 2 ) ) DO 4 K = 1 , M 2 M 1 S P E C T < K ) = C C 0 . 2 5 D 8 * < T S P E C T C K - 1 ) + T S P E C T C K + 1 ) ) + 0 . 5 D O * T S P E C T C K ) ) • S C A L E ) I F C S P E C T < K ) . G T . S M A X ) S M A X = S P E C T C K ) 4 C O N T I N U E C D S = S M A X / F L S P C T C I F < . N O T . T A R G ) G O T O 6 S M A X = D M A X 1 C S M A X , 1 . 0 D - 7 8 ) S M A X = 1 0 . 8 D 0 + D L O G 1 0 C S M A X ) S M I N = D M A X 1 C C S M A X - 1 6 0 . 0 D 0 >, - 7 8 0 . 0 D 0 > D S = C S M A X - S M I N ) / F L S P C T C DO 7 K = 0 , M2 S P E C T C K ) = D M A X 1 C S P E C T C K ) , 1 . 0 D - 7 3 ) S P E C T C K ) = 1 0 . 0 D O + D L O G 1 0 C S P E C T C K ) ) S P E C T C K ) = D M A X 1 C S P E C T C K ) , S M I N ) 7 C O N T I N U E C 6 C O N T I N U E DO 5 K. =0,= M 2 5 S P E C T C K ) = C C S P E C T C K ) - S M I N ) / D S ) + 0 . 5 D 0 C C A L L P A G E C C R T , - 1 ) W R I T E C C R T , 5 0 0 ) N P O T S 5 0 0 F O R M A T < ' ' j " P O U J E R S P E C T R U M >JF f i h P L A T E A V E R A G E D F R O M " > 1 3 , " D E T E C T E D P O T E N T I A L S . " ? C C A L L P L O T C X O R G , Y O R G - 1 2 , 0 ) DO 1 K = 0 , M, 3 2 1 C A L L P L O T C X O R G + K , Y O R G - 1 2 , - 1 ) b C COLL PLOT<XORG.YORG*IFIX<SNGL<SPECT<0>>>-e> D 0 C f t L L ; L O T < 3 5 R O + 2 « , Y O R C + I F I X < 8 H C L < 8 P E C T < K » » . 1 > c C A L L P L O T(0i YALPHA.- 0 ) C A L L A LPHA UIRITECCRT, 5 9 1 ) S M I N , SMAX C 1 7 / 3 / 8 0 C PARAMETER D C H A N =62 , S T T C H A N = 6 1 , C R T = 1 0 , K V B D = 1 1 , 0N=1 , 0 F F = - 1 , i - C M A S K = 3 7 7 , D D I S = 1 5 , Y A L P H A = 2 0 4 , M=512 , MM1=511 , M 2 = 2 5 6 , S P C H A N = 6 0 , R V S = - 1 , FWD=1 C C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * c i C MAIN ROUT INE " B A S E L I N E " c ! c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * c ! C T H I S PROGRAM I S FOR C A L C U L A T I N G THE E S T I M A T E D POWER SPECTRUM OF C THE B A S E L I N E V A R I A T I O N P L U S N O I S E . c ! c I ' I NTEGER ERROR, D I S D I R , D P S T A T , L S T S T T , L S T D I R , CMND, ! - VEMGCO: 4 9 3 5 ) , D A T S T T , NOM, NOMP, K, NO, SCNT , R E C O R D ( 4 0 ) , TAPNUM, RECNUM, AMP C DOUBLE PRECISION SPECT (0 :M2) DOUBLE P R E C I S I O N COMPLEX C S E M G ( 0 : M M 1 ) , COEMG<0 :M2 ) C COMMON / D S P D A T / D I S D I R , L S T D I R , D P S T A T , D A T S T T , L S T S T T , N O M , - / E M G R E C V E M G / P R C R E C / S P E C T , N O , S C N T , C S E M G , C O E M G , N O M P .-• T A P R E C / T A P N U M , RECNUM E Q U I V A L E N C E ( R E C O R D , V E M G ) E X T E R N A L B D S P L Y , P R C P L T , P R E P R C , B E L L , E R A S E , P R C N I T DPSTAT = OFF C A L L P R C N I T C A L L I N I T ( •  DP0 : E M G D A T A ' , 0, ERROR ) C A L L FOPEN < DCHAN, • 'DATA ' ) C A L L F O P E N d S T T C H A N , ' D A T A S T A T S ' ) C A L L APPEND<SPCHAN , ' S P E C T R U M S ' , 3 , E R R O R ) C A L L P A G E C C R T , 0 ) W R I T E ( C R T ) " P R E L I M I N A R Y B A S E L I N E P R O C E S S I N G " RECNUM = 0 AMP = 1 READ B I N A R Y ( S T T C H A N ) TAPNUM I F ( T A P N U M . L T . 0 ) GOTO 1 READ B I N A R Y ( S T T C H A N ) RECNUM, ( R E C O R D ( I ) , 1 = 1 , 4 0 ) W R I T E ( C R T , 5 0 0 ) T A P N U M , R E C N U M , ( R E C O R D ( I ) , 1 = 1 , 4 0 ) J00 F0RMAT( ' 0 ' , " TAPE #" , 12 , T 4 1 , "RECORD # " , 1 2 , / ' ' , " DATE RECORDED: " , T 4 1 , 5 A 2 , / ' ' . , " I D E N T I F I C A T I O N : " , T 4 1 , 3 A 2 , / ' ' , " A M P L I F I E R S E T T I N G ( MICRO VOLTS- 'D IV ) : " , T 4 1 , I 4 , - / ' 0 ' , " COMMENT: " , 3 1 A 2 > AMP = R E C O R D ( 9 ) L C O N T I N U E C A L L F C L O S ( S T T C H A N ) 1 W R I T E ( C R T ) " < 1 5 > < 1 5 > " PAUSE GOTO 3 CONTINUE C A L L B E L L C A L L B E L L C A L L A LPHA WR I TE C C R T , 5 0 1 ) 50! 1 FORMATC ' ' , " > Z ) CMND = 0 R E A D C K Y B D , 5 9 2 ) CMND 5@|2 FORMAT C A2 ) C C T|HIS COMMAND ALLOWS THE D I S P L A Y TO C O N T I N U E . C I F CCMND .NE . " C O " ) GOTO 5 3 j CONTINUE I F C D P S T A T . E Q . O N ) GOTO 4 DPSTAT = ON NOM = 0 D I S D I R = FWD L S T D I R = D I S D I R DATSTT = - 1 5 L S T S T T = DATSTT - 1 DO 100 J = 0 , 4 0 9 5 10^0 V E M G C J ) = O C 4 CONT INUE C A L L B D S P L Y GOTO 2 5 I CONTINUE C C T H I S COMMAND R E V E R S E S THE D I R E C T I O N TO THE D I S P L A Y S C A N . I F C C M N D . H E . " R V " ) GOTO 7 I F C D P S T A T . E Q . O H ) GOTO 6 WRITEC C R T , 5 0 3 ) 50|3 FORMAT <' ' , 1 8 X , " - - I G N O R E D ! " ) GOTO 2 6 I CONT INUE D I S D I R = - D I S D I R GOTO 3 7 I CONTIHUE C C T H I S COMMAND C A U S E S THE L A S T DATA P LOT TO BE R E P E A T E D . I F C C M H D . H E . " R E " ) GOTO 9 I F C D P S T A T . E Q . O H ) GOTO 3 WRITEC C R T , 5 0 3 ) GOTO 2 C 8 j CONT INUE DATSTT = DATSTT - D I S D I R * D D I S HOM = NOM - D I S D I R GOTO 3 9 I CONTINUE C C TjHIS COMMAND I N I T I A L I Z E S THE S P E C T R U M E S T I M A T I O N TO ZERO . C , I F C C M H D . N E . " P I " ) GOTO 10 C A L L P R C N I T WR I TE C CRT, 5 0 4 ) - 5 0 4 FORMAT C ' + ' , 1 0 X , " — D O N E ! " ) GOTO 2 C 10 CONTIHUE c C T H I S COMMAND ALLOWS P L O T T I N G OF THE P R E P R O C C E S S I N G DATA AT ANY T I M E . I F ( C M N D . N E . " P C " ) GOTO 11 C A L L P R C P L T GOTO 2 C 11 CONTINUE C C T H I S COMMAND E S S E N T I A L L Y R E S E T S THE D I S P L A Y , AND P R O C E S S ING , •TO THE C B E G I N N I N G OF THE DATA - - " P A G E 1 " . C I F ( C M N D . N E . " D O " ) GOTO 12 DPSTAT = OFF W R I T E ( C R T , 5 0 4 ) GOTO 3 C 12 CONTINUE C C T H I S COMMAND I S FOR S A V I N G THE S P E C T R A L E S T I M A T E S IN THE F I L E C " S P E C T R U M S " . C I F < CMND .NE . " S V " ) GOTO 14 I F ( N O . G E . 2 ) GOTO 13 W R I T E ( C R T , 5 0 3 > GOTO 2 C 13 CONTINUE WRITE ( S P C H A N , 5 0 5 ) TAPNUM, RECNUM, NO, AMP, C S P E C T ( K ) , K = 0 , M 2 ) 5 0 5 FORMAT ( ' ' , 2 ( 1 2 , I X ) , 13 , I X , 14 , I X , / , ( 3 ( G 2 2 . 15 , I X ) ) ) W R I T E ( C R T , 5 0 4 ) GOTO 2 C 14 CONTIHUE I F ( C M N D . E Q . " S T " ) GOTO 9 9 9 C C W R I T E ( C R T , 5 0 7 ) CMND 5 0 7 FORMAT ( ' ' , " ? ? ' " , A 2 , " ' ? ? " ) GOTO 2 C 9 9 9 COHTIHUE C A L L R E S E T C A L L E R A S E STOP P R O C E S S I N G C END C 4 / 3 / 8 0 C PARAMETER DCHAN=62 , Y l = 6 8 6 , Y2=555> Y 3 = 4 2 5 , Y 4 = 2 9 4 , Y A L P H A = 2 0 4 , B A S P R I = 1 0 O , 0 F F = - 1 , 0 N = 1 , FWD=1, R V S = - 1 , C R T = 1 0 , L P T = 1 2 C fj * H < * * * * * * * * * * + :+i + + + + * + ^ : + ^ :f< ^ + >^  % + * ^ >i< + H< :f: H< H< >f- 4= 4:4< >f: >(: 4= 4< * 4< ^ H< H< C S U B R O U T I N E B D S P L Y C C T H I S TASK ALLOWS V I S U A L E X A M I N A T I O N OF THE E . M . G . DATA . C C INTEGER D A T S T T , D P S T A T , NOM, D D I S , ED I S , D I S D I R , L S T D I R , L S T S T T , ERROR , EMG(0= 1 0 2 3 , 4 ) , Y D I S C 4 ) , F W D I S P , R V D I S P COMMON / D S P D A T / D I S D I R , L S T D I R , D P S T A T , D A T S T T , L S T S T T , N O M / E M G R E C / E M G E X T E R N A L P A G E , P L O T , A L P H A , E R A S E , SYMBOL , B E L L , P R E P R C C C Y D I S C 1 ) = Y l YD ISC 2 ) = Y 2 Y D I S C 3 ) = Y 3 YD ISC 4 ) = Y4 CONT INUE C A L L P L O T C O , Y A L P H A , 0 > C A L L A L P H A D D I S = 15 NOM = NOM + D I S D I R DATSTT = D A T S T T + D I S D I R * D D I S C C I F C D A T S T T . L E . 8 7 0 ) GOTO 15 WRITEC CRT, 5 0 1 ) 5 0 1 F O R M A T C ' ' , 1 0 X , " — AT RECORD E N D . " ) GOTO 3 C 15 CONT INUE I F C D A T S T T . G E . O ) GOTO 4 WRITE C CRT, 5 0 2 ) 5 Q 2 FORMATC ' , 1 8 X , " - - AT RECORD S T A R T . " ) C 3 CONTINUE C A L L B E L L ! DPSTAT = OFF GOTO 999 C C 4 ! CONT INUE C | C T H I S NEXT PART I S N E C E S S A R Y TO R E P E A T THE L A S T B LOCK OF C T H E P R E V I O U S D I S P L A Y , E V E N WHEN THE D I R E C T I O N OF THE D I S P L A Y C C I S CHANGED. I F C D A T S T T . E Q . L S T S T T ) GOTO 12 L S T S T T = DATSTT FWDISP = 7 6 8 R V D I S P = 0 I F < D I S D I R . E Q . L S T D I R ) GOTO 14 F W D I S P = 5 1 2 R V D I S P = 2 5 6 L S T D I R = D I S D I R 14 CONT INUE I F C D I S D I R . E Q . R V S ) GOTO 6 E D I S = 2 5 6 DO 5 J = 0 , 2 5 5 5 E M G < J , 1 ) = E M G C F W D I S P + J , 4 ) GOTO 8 C 6 CONT INUE E D I S = O DO 7 J = 8 , 2 5 5 7 E M G < 7 6 8 + J , 4 ) = EMG<•. R V D I S P + J , 1 ) C 8 C O N T I N U E I F ( .DATSTT. N E . 8 7 8 ) GOTO 11 D D I S = 18 DO 9 J = 5 1 2 , 1 8 2 3 9 E M G O J , 3 ) = 0 DO 10 J = 8, 1 0 2 3 10 EMGC J , 4 ) = 8 C 11 CONT INUE C A L L RDBLK < D C H A N , D A T S T T , EMG < ED I S , 1 ) , D D I S , E R R O R ) I F < E R R O R . E Q . 1 ) GOTO 12 WRITE 1 ; CRT, 5 8 3 ) ERROR 5 0 3 FORMAT < ' ' , 1 0 X , " — READ BLOCK E R R O R : " , I 3 ) GOTO 9 9 9 C 12 CONT INUE C A L L P A G E < C R T , N O M ) C C DO 13 J = l , 4 I X = 0 I Y = E M G < I X , J ) s 16 + Y D I S C J ) C A L L P L O T C I X , I Y , 0 ) C DO 13 IX = 2, 1 0 2 3 , 2 I Y = E M G ( I X , J ) • 16 + Y D I S < J ) C A L L PLOT< I X , I Y , 1 ) 13 C O N T I N U E C C A L L P R E P R C < * 9 9 9 ) GOTO 2 C 999 CONT INUE RETURN END C - 6 V 3 / 8 0 C PARAMETER U Y 1 = 7 8 0 , U Y 2 = 6 2 2 , U Y 3 = 4 9 2 , U Y 4 = 3 6 1 , L Y 4 = 2 3 0 , - L Y 3 = 3 6 1 , L Y 2 = 4 9 2 , L Y 1 = S 2 2 , Y A L P H A = 2 0 4 , L P T = 1 2 , CRT = 10 , - M=512, MM1=511 , M2=256 , M2M1=255 , N S K I P = 1 2 , H F I L T = 1 2 7 , - F L T M A X = 4 0 3 2 , R V S = - 1 C c S U B R O U T I N E P R E P R C C C S T A T ) C c C SO FAR T H I S R O U T I N E I S FOR E S T I M A T I N G THE A U T O C O R R E L A T I O N F U N C T I O N C OF THE B A S E L I N E V A R I A T I O N P L U S W . G . N . C C INTEGER L Y < 4 ) , E M G < 0 : 1 0 2 3 , 4 ) , C S T A T , V E M G ( 8 = 4 0 9 5 ) , NO, SCNT , NOMP, CHT, S T X , CEND, C B E G I N , END X, ENDY, I C , CHAR, X, Y, Y L I N E , D I S D I R , L S T D I R , D P S T A T , D A T S T T , L S T S T T , NOM L O G I C A L B E G I N DOUBLE P R E C I S I O N S P E C T < 8 : M2>, R O E M G ( 2 , 0 ; M2) DOUBLE P R E C I S I O N R S E M G < 2 , 0 : M M 1 ) , B A S F L T DOUBLE P R E C I S I O N COMPLEX CSEMG<0 ,MM 1 ) , C O E M G ( 0 : M 2 > COMMON /EMGREC- -EHG / • P R C R E C / S P E C T , NO, SCNT , CSEMG, COEMG, NOMP / D S P D A T / D I S D I R , L S T D I R , D P S T A T , D A T S T T , L S T S T T , NOM E Q U I V A L E N C E <VEMG, EMG>, < R S E M G , C S E M G ) , <ROEMG,COEMG) E X T E R N A L B E L L , CURSOR, S Y M B O L , P LOT , A L P H A , E R A S E , D F F T , B A S F L T L Y < 1 ) = L Y 1 L Y < 2 ) = L Y 2 L Y ( 3 ) = L Y 3 L Y < 4 ) = L Y 4 Y L I N E = Y A L P H A B E G I N = . T R U E . STX = 1 2 3 I F < D A T S T T . E Q . 0 ) S T X = 3 1 9 CEND = STX ENDX = S T X ENDY = L Y 1 1 CONT INUE I F <. NOT. B E G I N ) GOTO 13 . C A L L P L O T < 0 , Y L I N E , 0 ) Y L I N E = Y L I N E - 2 2 C A L L A L P H A WRITE<CRT , 5 0 0 ) NO 5 0 0 FORMAT C ' + ' , 5 0 X , 1 2 , " S E C T I O N S . " ) 13 CONT INUE C A L L B E L L CHAR = 0 C A L L CURSORCX , Y, C H A R ) CHAR = I AND ( C H A R , 1 7 7 4 0 8 K ) I F <CHAR. EQ . ' ' ) GOTO 9 9 9 I F < C H A R . E Q . ' * ' ) GOTO 9 9 8 I F < C H A R . E Q . ' Z ' ) GOTO 3 IF ( C H A R . N E . ' / ' ) GOTO 1 IF ( B E G I N ) GOTO 2 X = 8 9 5 Y = L Y 4 GOTO 3 C O N T I N U E X = ENDX Y = ENDY - CONT INUE I F ( ( N O M P . G T . N O M ) . O R . ( D I S D I R . E Q . R V S ) ) NOMP = NOM I = 1 I F ( Y . G T . U Y 1 ) GOTO 1 I F ( Y . L T . U Y 2 ) I = 2 I F ( Y . L T . U Y 3 ) I = 3 I F ( Y . L T . U Y 4 ) I = 4 I F ( Y . L T . L Y 4 ) GOTO 1 I F ( ( X . L T . S T X ) . A N D . ( I . E Q I F ( ( X . G T . 8 9 5 ) . A N D . ( I . E Q Y = L Y ( I ) IC = 1 9 2 4 * ( I - 1) + X I F ( . N O T . B E G I N ) GOTO 4 I F ( I C . L T . C E N D ) GOTO 1 C B E G I N = ( I C - C E N D ) / N S K I P C B E G I N = C B E G I N * N S K I P + CEND B E G I N = . F A L S E . CHAR = >' GOTO 5 C O N T I N U E I F ( I C . L T . ( C B E G I N + N S K I P ) ) GOTO 1 I F ( I C . G T . F L T M A X ) I C = F L T M A X CEND = ( I C - C B E G I N ) s N S K I P CEND = CEND * N S K I P + C B E G I N ENDX = X ENDY = Y B E G I N = . T R U E . CHAR = ' < ' C O N T I N U E C A L L P L O T ( X , Y , 0 ) DO 6 I = 8 , 1 16 , 8 C A L L P L O T ( X , Y + I , - 1 ) C A L L S Y M B O L ( X , Y + l 1 8 , C H A R ) I F ( . N O T . B E G I N ) GOTO 1 C-NT = C B E G I N CONT INUE I F ( S C N T . G T . M 2 M 1 ) GOTO 12 R S E M G ( 1 , S C N T ) = B A S F L T ( C N T ) SCNT = SCNT + 1 CNT = CNT + N S K I P I F ( C N T . G E . C E N D ) GOTO 1 GOTO 10 CONT INUE C A L L D F F T ( C S E M G , M , - 1 ) . 1 ) ) X = S T X . 4 ) ) X = 8 9 5 SCNT = 0 NO = NO + 1 DO 3 I = 0 , M2 S P E C T < I > = S P E C T ( I > + ROEMG<It I > * * 2 + R O E M G < 2 , I > * * 2 + < - 1 . 0 D 0 * * I > * < R O E M G < l , I > * R S E M G O / I ) + ROEMG< 2 , I ) * R S E M G C 2 , I ) ) COEMG<I ) = CSEMG < I ) CONT INUE DO 11 1 = 9 , MM 1 CSEMG<I> = < 0 . 0 D 0 , 0 . 0 D 0 ) I F < C N T . G E . C E N D > GOTO 1 GOTO 10 CONT INUE C A L L E R A S E RETURN CSTAT CONT INUE RETURN END C 6 / 3 / 3 9 C PARAMETER N F I L T 2 = 6 3 C £ + + + + + + + + + + + ^ C DOUBLE P R E C I S I O N F U N C T I O N B A S F L T < I N D ) C C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * c • I N T E G E R K, V E M G < 0 : 4 0 9 5 ) , IND C DOUBLE P R E C I S I O N F T E M P , H < 0 : N F I L T 2 ) C COMMON / C O E F F S / H / E M G R E C / V E M G C DATA H / . 3 1 5 3 1 2 3 6 D - 1 , . 8 8 6 2 6 4 2 8 D - 1 , . 7 7 9 4 6 9 6 1 D - 1 , . 7 3 6 0 4 4 8 5 D - 1 , . 6 7 7 7 2 4 4 8 D - 1 , . 6 0 6 8 7 6 8 2 D - 1 , | - . 5 2 6 2 8 3 6 8 D - 1 , . 4 3 3 1 0 4 4 4 D - 1 , . 3 4 8 6 2 1 6 1 D - 1 , i - . 2 5 8 1 9 1 3 S D - 1 , . 1 7 8 3 3 5 8 1 D - 1 , . 8 3 3 4 3 6 3 8 D - 2 , I - . 1 7 5 7 4 1 3 0 D - 2 , - . 4 4 1 0 8 5 4 5 D - 2 , - . 9 3 7 8 1 8 5 4 D - 2 , i - - . 1 3 0 4 1 3 3 3 D - 1 , - . 1 541 1 1 9 4 D - 1 , - . 1 6 5 1 1 1 3 5 D - 1 , 1 - - . 1 6 4 4 4 3 4 8 D - 1 , - . 1 5 3 5 9 6 6 6 D - 1 , - . 1 3 4 4 3 8 0 3 D - 1 , - . 1 0 3 8 4 5 3 8 D - 1 , - . 7 S 2 3 1 4 8 6 D - 2 , - . 4 7 6 8 3 3 0 2 D - 2 , - . 1 S 3 0 2 1 3 1 D - 2 , . 1 3 8 0 0 9 8 8 D - 2 , . 3 3 6 7 2 5 7 4 D - 2 , j - . 5 9 4 5 4 3 1 4 D - 2 , . 7 4 5 7 1 4 8 8 D - 2 , . 8 3 5 6 7 3 1 8 D - 2 , . 8 6 4 5 7 7 6 7 D - 2 , . 3 3 5 3 2 6 8 3 D - 2 , . 7 5 6 7 3 4 3 6 D - 2 , . 6 3 6 2 4 2 7 0 D - 2 , . 4 8 5 4 5 2 2 6 D - 2 , ! - . 3 1 6 3 4 3 2 7 D - 2 , . 1 4 1 2 4 6 5 7 D - 2 , - . 2 3 4 4 1 1 4 3 D - 3 , - . 1 8 2 3 7 8 4 9 D - 2 , - . 3 1 2 2 0 8 5 7 D - 2 , - . 4 1 1 5 3 3 1 3 D - 2 , - . 4 7 6 7 5 1 1 0 D - 2 , - . 5 0 6 8 9 3 3 1 D - 2 , - . 5 0 O 5 8 2 5 3 D - 2 , - . 4 6 3 8 6 1 4 1 D - 2 , - . 3 9 8 2 7 0 4 1 D - 2 , - . 3 1 2 0 3 2 7 1 D - 2 , - . 2 1 1 3 3 7 1 3 D - 2 , - . 1 O 3 2 1 0 4 5 D - 2 , . 5 5 0 4 4 7 8 8 D - 4 , . 1 0 8 4 6 5 S 3 D - 2 , . 2 0 0 1 3 7 1 2 D - 2 , . 2 7 6 3 4 3 5 2 D - 2 , . 3 3 4 1 7 7 3 1 D - 2 , . 3 7 2 2 5 3 1 7 D - 2 , . 3 3 8 4 1 8 4 3 D - 2 , . 3 9 8 1 4 4 8 1 D - 2 , . 3 7 4 1 6 4 3 9 D - 2 , . 3 4 6 8 8 1 5 2 D - 2 , . 3 1 4 7 7 3 9 5 D - 2 , . 2 8 9 8 1 3 S 8 D - 2 , . 2 8 3 4 4 7 0 5 D - 2 , . 3 5 6 6 0 2 1 1 D - 2 , - . 2 6 1 3 8 2 8 1 D - 2 / C c FTEMP = DFLOAT<VEMG<IND) ) * H<9> DO 1 K = 1, N F I L T 2 1 FTEMP = FTEMP + DFLOAT ( < VEMG i IND+K) + V E M G < I N D - K ) ) ) * H<K) C C WRITE ( 1 2 ) IND , V E M G < I N D ) , F T E M P B A S F L T = FTEMP C RETURN END MAIN ROUT INE P L O T S P E C T R U M S 8 0 . 5 . 7 PARAMETER M2=256 , M2M1=255 , F L S P C T = 5 1 2 . 0 D 0 , MM1=511 , M=512 , XORG=200 , YORG=180 , X L A B = 2 0 , Y A L P H A = 1 4 0 , CRT=10 , K Y B D = 1 1 , S P C H A N = 6 0 , S C A L E = 1 . 0 2 4 O D 6 C C c c c c I C TjHIS ROUTINE I S TO C A L C U L A T E , AND PLOT THE R E S U L T S OF THE P R O C E S S I N G C DONE ON THE E . M . G DATA. C 1 INTEGER K, TAPNUM, RECNUM L O G I C A L TARG C DOUBLE P R E C I S I O N S P E C T < 8 : M 2 ) , T S P E C T C 8 : M 2 ) , SMAX, S M I N , DS C COMMON / P R C R E C / S P E C T E X T E R N A L P LOT , A LPHA , P A G E , QOPEN TYPE " ENTER F I L E NAME: " C A L L QOPEN ( S P C H A H ) WRITE ( C R T , 5 8 5 ) 5 8 5 FORMAT C ' ' , 1 8 X , " - - SMOOTH S P E C T R U M S ? " , Z > READ ( K Y B D , 5 8 4 ) IARG 5 8 4 F O R M A T ( A 2 ) TARG = . F A L S E . I F ( I A R G . E Q . " Y E " > TARG = . T R U E . NOM = 1 CONTINUE C A L L P A G E ( C R T , N O M ) NOM = NOM + 1 READ ( S P C H A N , 5 8 2 , E H D = 9 9 9 ) TAPNUM, RECNUM, NO, AMP, ( S P E C T < J ) , J = 8 , M 2 ) FORMAT (1 X, 2 ( 12 , 1X ) , 13 , 1 X, 14 , I X , / , ( 3 ( G22 . 15 , I X ) ) ) I F ( T A P N U M . G T . 0 ) W R I T E ( C R T , 5 0 6 ) TAPNUM, RECNUM FORMAT (.' ' , " T A P E # " , I 2 , RECORD # " , I 2 ) I F ( . N O T . T A R G ) GOTO 6 T S P E C T ( 8 ) = ( 8 . 5 D 0 + ( S P E C T O B ) + S F E C T C 1 ) ) / S C A L E ) T S P E C T ( M 2 ) = ( 8 . 5 D 0 * ( S P E C T ( M 2 ) + S P E C T ( M 2 M 1 ) ) / S C A L E ) DO 3 K = 1, M2M1 T S P E C T ( K ) = ( ( 0 . 2 5 D 0 * ( S P E C T ( K - l ) + S P E C T C K + 1 ) ) + O . 5 D 0 * S P E C T ( K ) ) / S C A L E ) 3 ' CONTINUE ' GOTO 9 6 CONTIHUE DO 10 K = 0 , M2 10 T S P E C T ( K ) = S P E C T ( K ) COHTIHUE SMAX = - 1 . 0 D 7 5 SMIN = 0 . 0 D 0 DO 4 K = 0, M2 W R I T E ( 1 2 , 3 3 3 ) K, S P E C T ( K ) , T S P E C T ( K ) FORM AT <' ' , ' K = ' , 1 3 , 5 X , ' S = ' , E 1 2 . 5 , 5 X , ' T= ' . E l 2 . 5 ) TSPECT(K) = D M A X 1 ( T S P E C T ( K ) , @ . 0 D O ) SMAX = DMAX 1 ( T S P E C T C K ) , S M A X ) CONTINUE DS = SMAX > F L S P C T SMAX = D M A X 1 ( S M A X , 1 . 6 D - 7 S ) SMAX = 1 O . O D 0 * D L O G I O ( S M A X ) SMIN = D M A X 1 ( ( S M A X - 1 6 0 . 0 D 8 ) , - 7 8 0 . 0 D 0 ) DS = (SMAX - S M I N ) / F L S P C T DO 7 K = O, M2 TSPECT(K) = DMAX 1 ( TSPECT ( K ) , 1 . 0 D - 7 8 ) TSPECT(K) = 1 0 . 0 D 0 * DLOG10(TSPECT (K) ) TSPECT(K) = DMAX 1 (TSPECT ( K ) , S M I N ) CONT INUE DO 5 K =0, M2 TSPECT(K) = ((TSPECT (K) - S M I N ) / D S ) + 0 . 5D0 W R I T E ( C R T , 5@0) NO F O R M A T ( ' ' , " S M O O T H E D POWER SPECTRUM E S T I M A T E . " , / ' ' , 1 3 , " DATA S E C T I O N S OF 2 5 6 P O I N T S U S E D . " ) C A L L P L O T ( X O R G , Y O R G - 1 2 , 0 ) DO 1 K = 0, M, 3 2 C A L L P L O T ( X O R G + K , Y O R G - 1 2 , - 1 ) C A L L P L 0 T ( X 0 R G - 1 2 , Y O R G , 0 ) DO 8 K = 8, M, 3 2 C A L L P L 0 T ( X 0 R G - 1 2 , Y O R G + K , - 1 ) C A L L P L O T ( X O R G , Y O R G + 1 F I X ( S N G L ( T S P E C T ( 0 ) ) ) , 0 ) DO 2 K = 1, M2 C A L L P L 0 T ( X 0 R G + 2 * K , Y O R G + 1 F I X ( S N G L ( T S P E C T ( K ) ) ) , 1 ) C A L L P L O T ( 0 , Y A L P H A , 0 ) C A L L A LPHA W R I T E ( C R T , 5 0 1 ) S M I N , SMAX F O R M A T ( ' ' , 1 8 X , " — M I N . = " , G 1 1 . 4 , ".; MAX. = " , G 1 0 . 4 , " ( D B ) " ) PAUSE GOTO 11 C 333 CONT INUE STOP PLOT S P E C T R U M S END C 19 /2/-8Q C SUBROUTINE DFFT <X, NN,FLAG) C C T H I S I S A ROUTINE TO DO FFT'S. C I F FLAG I S -1 THEN FFT. C I F FLAG I S 1 THEN INVERSE FFT M U L T I P L I E D BY NN. C INTEGER NN, FLAG DOUBLE P R E C I S I O N X C I ) , TEMPR, TEMPI, WR, WI, THETA C C N = 2 * NN J = 1 DO 5 I = 1, N, 2 I F C I - J ) 1,2,2 1 TEMF'R = X C J ) i TEMPI = XCJ + 1 ) X C J ) = x c n XCJ+1) = X(I+1) X C I ) = TEMP R xci + n = TEMPI 2 M = N /- 2 3 I F CJ-M) 5,5,4 4 J = J - M M = M 2 I F CM-2) 5, 3, 3 5 J = J + M MMAX = 2 6 I F C MMAX-N) 7,9,9 7 I STEP = 2 * MMAX DO S M = 1, MM AX, 2 THETA = 3. 141592S535D0 * DFLOATCFLAG * CM -1 ) ) / DFLOAT<MMAX) WR = DCOSCTHETA) WI = DSIN(THETA) DO 8 I = M, N, I STEP J = I+MMAX TEMPR = WR * X<J) - WI * X C J + 1 ) TEMPI = WR + XCJ+1) + WI * X < J ) X C J ) = X C I ) - TEMPR XCJ+1) = X C I + 1 ) - TEMPI X C I ) = X C I ) + TEMPR 8 X C I+1) = X C I + 1 ) + TEMPI MMAX = I STEP GO TO 6 9 RETURN END 2 1 / 2 / 8 0 PARAMETER M2=256 , MM1=511 , M 2 P 1 = 2 5 7 , CRT=19 S U B R O U T I N E P R C N I T INTEGER NO, SCNT, NOMP, I DOUBLE P R E C I S I O N S P E C T < 0 ; M 2 > DOUBLE P R E C I S I O N COMPLEX CSEMG<0=MM1>, COEMGC0 COMMON / P R C R E C / S P E C T , NO, SCNT , CSEMG, COEMG, NOMP DO 1 I = O, M2 S P E C T C I ) = 0 . 0 D 0 COEMG < I ) = < 0 . 0 D , 0 . 0 D 0 > C S E M G < I ) = < 0 . 0 D 0 , 0 . 0 D 0 > C S E M G C M M l - I > = < 8 . 0 D 0 , 0 . 0 D 0 > CONT INUE NO = 0 NOMP = 0 SCNT = 0 RETURN END 261 F.3 Adaptive Matched F i l t e r i n g and Feature E x t r a c t i o n PROCESS — program f o r t e s t p r o c e s s i n g of EMG data, i n c l u d i n g d i s p l a y of data r e c o r d s , bandpass f i l t e r i n g , segment s e l e c t i o n , c r o s s - and auto- c o r r e l a t i o n of segments, template s e l e c t i o n , adaptive matched f i l t e r i n g , f e a t u r e e x t r a c t i o n , and gen e r a l p l o t t i n g of r e s u l t s . LOWEMG — program f o r low pass FIR f i l t e r i n g of EMG data to 4.5 KHz. HIGHEMG — program f o r high pass FIR f i l t e r i n g of EMG data, to remove b a s e l i n e v a r i a t i o n from 0 to 20 Hz. DISPLY — subr o u t i n e t o d i s p l a y EMG data r e c o r d on Te k t r o n i x 4010 gra p h i c s t e r m i n a l . SELECT — subroutine to s e l e c t a 16.9 m i l l i s e c o n d segment of EMG data f o r a n a l y s i s , or f o r the i n i t i a l matched f i l t e r template. DISWIN — subroutine to p l o t the ten data segments (windows) s e l e c t e d , i n c l u d i n g the matched f i l t e r template. BLOWIN — subroutine to p l o t a blow up of any of the ten data segments s e l e c t e d . DSXCOR — subroutine to c r o s s - c o r r e l a t e two of the s e l e c t e d data segments. XCORR — subroutine to c r o s s - c o r r e l a t e two data a r r a y s . MATCH — subroutine to perform a d a p t i v e matched f i l t e r i n g 262 of EMG data. POTSCN — subroutine to scan the p o t e n t i a l s d e t e c t e d by the ada p t i v e matched f i l t e r . PFEAT — subroutine t o e x t r a c t f e a t u r e s from the p o t e n t i a l s d e t e c t e d by the adapt i v e matched f i l t e r . FITNIT — subroutine t o i n i t i a l i z e c u b i c s p l i n e f i t f o r smoothing detected p o t e n t i a l s . FIT — subroutine t o smooth d e t e c t e d p o t e n t i a l s with a cu b i c s p l i n e f i t . FITCRV — subroutine to estimate the c u r v a t u r e s of each of the p o s i t i v e and negative phases of a p o t e n t i a l . FITSLP -- subroutine to estimate the slope of a de t e c t e d p o t e n t i a l at the zero c r o s s i n g between the two phases. IPLOT — subroutine to p l o t an i n t e g e r data a r r a y on the T e k t r o n i x 4010 g r a p h i c s t e r m i n a l . RPLOT — subroutine to p l o t a r e a l data a r r a y on the Te k t r o n i x 4010 gra p h i c s t e r m i n a l . M E S S A G E " L O A D I N G P R O C E S S MATCH DAOUT D I S P L Y D I S W I N S E L E C T BLOWIN " 2 6 3 M E S S A G E " P O T S C N P F E A T F I T N I T F I T F I T C R V F I T S L P DSXCOR X C O R R " M E S S A G E " CHARASM RAND IRAND P A G E T E K P L O T I P L O T AND R P L O T . " M E S S A G E "OUTPUT TO L I S T . " D E L E T E - ' V L I S T RLDR PROCESS [ D I S P L Y , M A T C H D A O U T , P O T S C N P F E A T F I T N I T F I T F I T C R V F I T S L P 3 + . { -BLOWIN, S E L E C T D I S W I N , DSXCOR X C O R R ] * CHARASM RAND IRAND PAGE T E K P L O T I P L O T * RPLOT M A T H . L B F M T . L B F O R T . L B F S Y S . L B L I S T / E M E S S A G E " F I N I S H E D WITH L O A D I N G C P L O A I O T Y P E L I S T C 8 8 . 5 . 2 3 C CHANTASK 8 , 5 C PARAMETER S T A T C H A N = 6 1 , DCHAN=62 , OCHAN=60 , C R T = 1 0 , K Y B D = 1 1 , ON = 1, O F F = - l , D S P R I 0 = 1 2 5 , C M A S K = 3 7 7 , D D I S = 1 5 , MPOTS=200 , MON=100000K , M O F F = 0 0 0 O 3 2 K C : C ************************ * ******* 4c3fc3fc4:3f:9t:>fcHc4<^ 3te3|e3te4<>|cH<4cHe4<4:»H)f:3te^ 9|«4c9fc>H4< * * * * * * * * * C ' C . MAIN ROUT INE " P R O C E S S " C 1 C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * c C T H I S PROGRAM R E Q U I R E S A LOT OF MEMORY TO E X E C U T E , T H E R E F O R E , USE C A MINIMUM SYSTEM < L I K E S Y S M I N ) . C I N I T I A T E S DATA REV IEW , AND I N T E R P R E T S COMMANDS WHEN C I N P U T T E D . STARTS MATCHED F I L T E R I N G PROGRAM WHEN COMMANDED. C C i INTEGER ERROR, D I S D I R , D P S T A T , DELAY , AMP, CMND, : - WNDOWSC 1 6 9 , O: 5 ) , EMG < 0: 1 6 2 3 , 4 ) , DATSTT , ARG 1, A R G 2 , NOM, TAPNUM, RECNUM, R E C O R D ( 4 0 ) , NPOTS , P O S ( 2 , M P O T S ) L O G I C A L F L T R D , P O T F L G , S E N S E C COMMON - - ' DSPDAT /D ISD IR , D P S T A T , DATSTT , D E L A Y , NOM .•••EMGREC-'EMG, WNDOWS, TAPNUM, RECNUM, AMP / P R C R E C N P O T S , POS , P O T F L G E Q U I V A L E N C E ( R E C O R D , E M G ) C E X T E R N A L D I S P L Y , P A G E , B LOWIN , D I S W I N , B E L L , WTCHAR, S E N S E , DSXCOR, E R A S E , S E L E C T , MATCH, P O T S C N , O D I S P L , OMATCH, OPOTSC , OBLOWI , O S E L E C , ODSXCO C DATA WNDOWS/1014 * 0 / , POS . 'MPOTS*0 , M P O T S + 0 / , P O T F L G / . F A L S E . / C C C T H I S S E C T I O N I N I T I A L I Z E S THE DATA D I R E C T O R Y , OPENS AND READS THE F I L E C ' C O N T A I N I N G THE EMG RECORD I N F O R M A T I O N , AND WRITES THAT INFO ON THE CRT . C C A L L I N I T < ' D P 8 : E M G D A T A ' , O , E R R O R ) C A L L 0 P E N C S T A T C H AN , ' D A T A S T A T S ' , 2 , E R R O R , 2 ) C C A L L P A G E ( C R T , 0 ) W R I T E ( C R T ) " P R E L I M I N A R Y P R O C E S S I N G FOR EMG D A T A . " C FLTRD = . F A L S E . AMP = 1 RECNUM = 0 READ B I N A R Y ( S T A T C H A N ) TAPNUM ,RECNUM , ( R E C O R D ( I ) , 1 = 1 , 4 0 ) , F L T R D I F ( T A P N U M . L T . 0 ) GOTO 1 W R I T E ( C R T , 5 0 0 ) T A P N U M , R E C N U M , ( R E C O R D ( I ) , 1 = 1 , 4 0 ) 5 9 0 F O R M A T ( ' & ' , " TAPE #" , 1 2 , T 4 1 , "RECORD # " , 1 2 , / ' ' , " DATE RECORDED: " , T 4 1 , 5 A 2 , / ' ' , " I D E N T I F I C A T I O N : " , T 4 1 , 3 A 2 , / ' ' , " A M P L I F I E R S E T T I N G ( M I C R O V O L T S / D I V ) = " , T 4 1 , I 4 , / ' 0 ' , " COMMENT: " , 3 1 A 2 ) 1 AMP = R E C 0 R D ( 9 ) CONTINUE I F ( F L T R D ) WRITE ( C R T , 4 9 8 ) 49,8 FORMAT ( ' 0 ' , " D A f A F I L T E R E D . " ) C THE NEXT S E C T I O N OPENS THE F I L E THAT " M I G H T " C O N T A I N THE P O S I T I O N S OF C P O T E N T I A L S S E L E C T E D FROM T H I S EMG RECORD. C C A L L FOPEN ( DCHAN, 'WORK: P O S I T I O N S ' ) C C R I G H T T A P E AND RECORD N U M B E R S ? C READ B I N A R Y C D C H A N , E N D = 1 0 4 ) A R G 1 , ARG2 I F ( ( T A P N U M . N E . A R G 1 ) . O R . ( R E C N U M . N E . A R G 2 ) ) GOTO 194 C C Y E S , THEN READ THE P O S I T I O N S . C READ B I N A R Y ( D C H A N , E N D = 1 0 4 ) NPOTS , ( ( POS ( J , I ) , J = l , 2 ) , 1 = 1, N P O T S ) , (WHDOWS( I , 1 ) , 1 = 1 , 1 6 9 ) , (WNDOWSC I , 9 ) , 1 = 1 , 1 6 9 ) P O T F L G = . T R U E . 1 9 4 CONT INUE C A L L F C L O S ( D C H A N ) C W R I T E ( C R T , 4 9 9 ) 4 9 9 FORMAT C O ' ) P A U S E C C O P E N THE O V E R L A Y CHANNEL " O C H A N " , AND R E - O P E N " D C H A N " , FOR DATA I / O C FROM THE EMG DATA F I L E . C C A L L O V O P N ( O C H A N , ' P R O C E S S . O L ' , E R R O R ) C A L L O P E N ( D C H A N , ' D A T A ' , 2 , E R R O R ) C 2 CONT INUE C C LOAD THE D I S P L A Y O V E R L A Y , AND I N I T I A L I Z E THE D I S P L A Y T A S K . C C A L L O V L O D ( O C H A N , O D I S P L , - 1 , E R R O R ) C A L L F T A S K ( D I S P L Y , $ 9 9 8 , D S P R I O ) C 3 , CONT INUE C C T H I S PROGRAM HAS H IGHER P R I O R I T Y , BUT S U S P E N D S I T S E L F BY R E A D I N G THE C KEYBOARD THROUGH A C A L L TO " W T C H A R " . S T R I K I N G ANY KEY R E L E A S E S THE I / O C S U S P E N S I O N . "WTCHAR" THEN RETURNS TO T H I S PROGRAM TO P R O C E S S COMMANDS. . C I.JJHILE T H I S PROGRAM I S S U S P E N D E D , THE D I S P L A Y PROGRAM W I L L BE E X E C U T I N G . C C A L L WTCHAR(CMND) c i C S U S P E N D THE D I S P L A Y SO THAT I / O C A L L S W I L L NOT R E - A C T I V A T E I T . C 1 , C A L L A S U S P ( D S P R I O ) C A L L A LPHA C A L L B E L L C ; 4 CONT INUE C C PROMPT AND READ THE COMMANDS; SOME COMMANDS T A K E 1 OR 2 I N T E G E R C h lRGUEMENTS IN THE FORM " X X I J " . C ; C A L L B E L L W R I T E ( C R T , 5 0 1 ) 5 0 1 F O R M A T C ' , " > " , Z ) CMND = 0 ARG1 = 0 ARG2 = 9 READCKYBD , 5 0 2 ) CMND, ARG 1, ARG2 5 0 2 F O R M A T ( A 2 , IX/ I I , IX, Il> C C NOTE : THE FOLLOWING CODE HAS B E E N SET UP TO M A N I P U L A T E O V E R L A Y S AND C SWAP SOME PROGRAMS ORDER TO S A V E MEMORY. C C T H I S COMMAND ALLOWS THE D I S P L A Y TO C O N T I N U E . C I F C C M N D . N E . " C O " ) GOTO 5 1 0 8 CONT INUE I F C D P S T A T . E Q . O F F ) GOTO 2 C A L L A R D Y C D S P R I O ) GOTO 3 5 CONT INUE C C T H I S COMMAND R E V E R S E S THE D I R E C T I O N TO THE D I S P L A Y S C A N . C I F C C M N D . N E . " R V " ) GOTO 6 I F C D P S T A T . E Q . O F F ) GOTO 1 0 0 DI S H I R = - D I S D I R C GOTO 188 G CONT INUE C C T H I S COMMAND C A U S E S THE L A S T DATA PAGE P L O T T E D TO BE R E P E A T E D . C I F C C M N D . N E . " R E " ) GOTO 7 I F ( D P S T A T . E Q . O F F ) GOTO 1 0 0 DATSTT = DATSTT - D I S D I R * DD IS NOM = NOM - D I S D I R C GOTO 180 7 CONT INUE C C T H I S COMMAND S T A R T S THE MATCH F I L T E R PROGRAM, BUT ONLY I F THE DATA HAS C B E E N BANDPASS F I L T E R E D . THE ARG I S THE NUMBER OF THE I N I T I A L T E M P L A T E C "WINDOW" S E L E C T E D U S I N G THE " S E " COMMAND CO TO 5 ) . C THE A . M . F T A K E S 4HRS AND 28 M I N S . TO P R O C E S S A COMPLETE EMG RECORD . C I F SWITCH " 8 " I S UP , " P R O C E S S " W I L L STOP WHEN THE F I L T E R I N G I S DONE. C TO STOP THE F I L T E R P R E M A T U R E L Y , S W I T C H E S 0 AND 13 MUST BE " U P " , C AND SWITCHES 4 TO 1 2 , 14 AND 15 MUST EE DOWN. C I F C C M N D . N E . " M T " ) GOTO S I F C C A R G 1 . G T . 5 ) . OR. . N O T . F L T R D ) GOTO 108 I F C D S P S T A T . E Q . O F F ) GOTO 1 0 2 D P S T A T = OFF , C A L L A K I L L C D S P R I O ) C A L L O V R E L C O D I S P L , E R R O R ) 1 0 2 C O N T I N U E C A L L OVLODCOCHAN , OMATCH, 0 , ERROR) C A L L M A T C H C A R G 1 ) . C A L L O V R E L C O M A T C H , E R R O R ) 1 0 3 CONT INUE I F CSENSECMON) ) GOTO 4 GOTO 9 9 9 8 , CONT INUE C C T H I S COMMAND P L O T S A G I V E N DATA WINDOW AT FOUR T I M E S THE USUAL C P L O T S I Z E . THE ARG I S THE "WINDOW" TO BE BLOWN UP . C I F C C M N D . N E . " B L " ) GOTO 9 I F C A R G 1 . G T . 5 ) GOTO 4 C A L L O V L O D C O C H A N , O B L O W I , 8 , E R R O R ) C A L L B L O W I N C A R G 1 ) C A L L O V R E L C O B L O W I , E R R O R ) GOTO 4 9 CONT INUE C C T H I S COMMAND C A L C U L A T E S THE A U T O C O R R E L A T I O N F U N C T I O N OF C THE WINDOW G I V E N BY ARG. C I F < CMND. NE . " A U " ) GOTO 10 ARG2 = ARG1 GOTO 103 18 CONTINUE C C T H I S COMMAND S T O R E S DATA S E Q U E N C E S OF 169 S A M P L E S — C DATA "WINDOWS" . A L L S I X WINDOWS ARE D I S P L A Y E D ON THE CRT C AFTERWARDS . THE ARG S P E C I F I E S WHETHER AUTOMATIC C E N T E R I N G <ARG = 0 ) C OR MANUAL C E N T E R I N G OF THE EMG DATA CARG = 1 ) I S D E S I R E D . C I F C C M N D . N E . " S E " ) GOTO 11 C A L L OVLOD COCHAN, O S E L E C , 8 , E R R O R ) C A L L S E L E C T C A R G 1 ) C A L L D I S W I N • C A L L OVREL < O S E L E C , E R R O R ) GOTO 4 11 CONT INUE C C T H I S COMMAND CROSS C O R R E L A T E S THE TWO DATA "WINDOWS" G I V E N BY ARG1 C AND ARG2 . C I F CCMND. NE . " X C " ) GOTO 12 1 8 3 CONT INUE I F < CARG1 . G T . 5 ) . OR. <ARG2. G T . 5 ) ) GOTO 4 C A L L OVLODCOCHAN, ODSXCO, 8 , ERROR) C A L L D S X C O R C A R G 1 , A R G 2 ) C A L L 0 V R E L C 0 D S X C 0 , E R R 0 R ) GOTO 4 12 CONT INUE C C T H I S COMMAND CHANGES THE P A U S E R A T E OF THE D I S P L A Y S C A N . C T H I S COMMAND HAS L I M I T E D U S E . C I F C C M N D . N E . " R A " ) GOTO 13 DELAY = ARG1 DELAY = D E L A Y + F L O A T C A R G 2 ) 1 8 . 0 ! W R I T E ( C R T , 5 8 3 ) 5 0 3 F O R M A T S ' , 1 0 X , " — D O N E ! " ) GOTO 4 13 CONTINUE C C T H I S COMMAND D I S P L A Y S THE S I X DATA WINDOWS ON THE CRT . C I F C C M N D . N E . " D W " ) GOTO 14 • C A L L O V L O D C O C H A N , O S E L E C , 0 , E R R O R ) C A L L D I S W I N C A L L O V R E L C O S E L E C , E R R O R ) I GOTO 4 14 CONTINUE C C T H I S COMMAND SWAPS IN THE F I L T E R I N G PROGRAMS. " LOWEMG" T A K E S 21 M I N S . C TO C O M P L E T E , " H I G H E M G " T A K E S 2 HRS . TO C O M P L E T E . S E T T I N G SWITCH 0 C " U P " WI L L CAUSE " P R O C E S S " TO STOP WHEN THEY ARE F I N I S H E D . C I F THE DATA HAS B E E N F I L T E R E D C " F L T R D " I S T R U E ) THEN T H I S COMMAND C I S IGNORED . I F ( C M N D . N E . " F L " ) GOTO 15 I F ( D S P T A T . E Q . O F F ) GOTO 106 DPSTAT = OFF C A L L A K I L L ( D S F R I O ) C A L L OVREL (ODISPL . . ERROR) j 1 0 6 CONTINUE I F ( F L T R D ) GOTO 1 0 ? C A L L PAGE ( C R T , - 1 ) C A L L FSWAP ( ' LOWEMG. S V ) C A L L FSWAP ( ' H I G H E M G . S V ) F L T R D = . T R U E . C A L L FSEEK. ( S T A T C H A N , 4 2 ) WRITE B I N A R Y ( S T A T C H A N ) F L T R D 1 0 7 CONT INUE C A L L F C L O S ( S T A T C H A N ) I F ( S E N S E C M O H ) ) GOTO 4 GOTO 9 9 9 15 1 CONTINUE c ! C T H I S COMMAND ALLOWS A SCAN OF THE S E L E C T E D P O T E N T I A L S , C AND A V I S U A L CHECK ON THE NUMBER OF TYPE I I ERRORS . THE ARG S P E C I F I E € WHETHER THE P O T E N T I A L P L O T S ARE TO BE OVERLAYED BY THE O R I G I N A L C T E M P L A T E (ARG = 2 ) , THE F I N A L AVERAGE T E M P L A T E (ARG = 1 ) , OR NOT AT C A L L (ARG = 8 ) . ARG = 3 C A U S E S THE ROUT INE TO E S T I M A T E THE F E A T U R E S 0 C E A C H P O T E N T I A L . C I F ( C M N D . N E . " C H " ) GOTO 16 I F ( ( N P O T S . E Q . 0 ) . O R . ( . H O T . P O T F L G ) ) GOTO 4 I F ( D S P S T A T . E Q . O F F ) GOTO 105 DPSTAT = OFF C A L L A K I L L ( D S P R I O ) C A L L O V R E L ( O H I S P L , ERROR) 1 0 5 CONT INUE C A L L O V L O D ( O C H A N , O P O T S C , 0 , E R R O R ) C A L L POTSCN ( A R G 1 ) C A L L O V R E L ( O P O T S C , E R R O R ) GOTO 4 C 16 CONT INUE jc |C T H I S COMMAND E S S E N T I A L L Y R E S E T S THE D I S P L A Y TO THE C B E G I N N I N G OF THE DATA — " P A G E 1 " . I F ( C M N D . N E . " D O " ) GOTO 17 DPSTAT = OFF C A L L A K I L L ( D S P R I O ) C A L L OVREL ( O D I S P L , E R R O R ) W R I T E ( C R T , 5 8 3 ) GOTO 2 17 CONT INUE C C T r fnS COMMAND STOPS THE PROGRAM. C I F ( C M N D . E Q . " S T " ) GOTO 9 9 9 C C W R I T E ( C R T , 5 0 4 ) CMND, A R G 1 , ARG2 5 0 £ FORMAT ( ' ' , " ' " , A 2 , 1X, I I , I X , I I , " ' " , ' i s U N I D E N T I F I A B L E ! ' ) GOTO 4 C 9 9 8 CONT INUE C C NO TASK CONTROL B L O C K S FOR THE T A S K " D I S P L Y " . C T Y P E "NO T C B ' S ' D I S P L Y ' " C 9 9 9 CONT INUE C A L L R E S E T C A L L A K I L L < D S P R I O > C A L L E R A S E STOP P R O C E S S I N G iC END C 8 9 . 5 . 7 C PARAMETER DCHAN=62 , C R T = 1 0 , L P T = 1 2 , KYBD= 1 1 C £********************************************************************** c C MA IN R O U T I N E LOWEMG C £*** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! c C T H I S ROUT INE F I L T E R S THE DATA I N THE F I L E E M G D A T A : D A T A . C THE LOW P A S S F I L T E R BAND L I M I T S THE S I G N A L TO BELOW C A P P R O X I M A T E L Y 4 K H Z . C C R E A L L P C 0 = 2 5 ) , E M G C - 2 4 : 4 3 5 2 ) , L A S T ( 1 : 2 5 ) , N E X T < - 2 5 : - 1 ) , TEMP INTEGER I E M G C 1 , 4 3 5 2 ) , D A T S T T , ERROR, T T I M E C 3 ) COMMON / E M G R E C / E M G / F L T R E C - ' L P E Q U I V A L E N C E C L A S T C 1 ) , E M G C - 2 4 ) ) , C N E X T ( - 2 5 ) , E M G ( 4 0 7 2 ) ) C C DATA L P / 0 . 4 4 2 6 3 5 1 4 E + 0 0 , 9 . 3 1 2 4 0 6 3 O E + 0 0 , 9 . 5 5 5 7 3 7 9 2 E - 9 1 , - 8 . 8 3 8 5 8 6 3 8 E - 0 1 , - 0 . 5 0 5 4 9 1 4 9 E - 0 1 , 9 . 3 7 1 8 7 9 7 9 E - 9 1 , 9 . 4 2 3 8 8 5 5 2 E - 0 1 , - 9 . 1 2 2 2 4 2 6 1 E - 9 1 , - 9 . 3 3 7 3 4 9 7 5 E - 9 1 , - 0 . 1 6 7 4 6 3 7 9 E - 0 2 , 9 . 2 4 2 3 5 7 2 5 E - 0 1 , 0 . 8 8 1 5 8 9 2 8 E - 8 2 , - 0 . 1 5 2 2 2 4 9 0 E - O 1 , - 0 . 1 1 4 8 8 6 6 1 E - 0 1 , 0 . 7 7 7 4 3 7 5 4 E - 9 2 , 0 . 1 1 0 1 4 2 4 5 E - 9 1 , - 9 . 2 1 5 8 9 7 7 1 E - 9 2 , - 0 . 8 9 3 9 4 4 8 7 E - 0 2 , - 0 . 1 2 2 9 5 6 7 7 E - 8 2 , 0 . 6 0 1 0 3 2 7 5 E - 0 2 , 9 . 2 9 S 3 8 9 6 8 E - 9 2 , - 8 . 3 5 1 3 7 1 8 9 E - 9 2 , - 0 . 3 1 8 1 2 8 5 5 E - 8 2 , 9 . 1 6 7 9 3 9 7 9 E - 9 2 , 9 . 4 1 8 5 7 8 4 6 E - 9 2 , 9 . 2 2 5 2 4 3 3 4 E - 9 2 - ' , L A S T / 2 5 * 9 . 9 / W R I T E C C R T , 4 3 9 ) FORMAT C •' ' , 1 9X , " -C A L L F O P E N C D C H A N , J D A T A ' ) NK = 8 DO 6 D A T S T T = 0 , 8 6 3 , 16 WRI TE C CRT, 5 0 1 ) D A T S T T FORMAT< 1X, 1 3 , I X , Z ) NK = NK + 1 I F C M O D C N K , 1 8 ) . E Q . 9 ) WRITE <CRT) C A L L RDBLK C D C H A N , D A T S T T , I E M G < 1 ) , 1 7 , E R R O R ) DO 7 N = 1, 4 3 5 2 EMGCN) = F L O A T CI EMG CN) ) DO 4 N = 1, 4 0 9 6 , 2 TEMP = EMG < N) + LP CO) DO 3 K = 1, 2 5 3 TEMP = TEMP + C E M G C N - K ) + E M G C N + K ) ) * L P C K ) C I E M G C N ) = I F I X C T E M P ) ' I E M G C N + 1 ) = 0 4 C O N T I N U E C A L L WRBLK C D C H A N , D A T S T T , I E M G C 1 ) , 1 6 , E R R O R ) C DO 5 J * 1. 25 LASTCJ) = NEXT<-J) CONTINUE CALL RDBLK <DCHAN, 864, IEMG< 1 ), 16, ERROR) DO 1 N = 1, 4096 1 EMG < N ) = FLOAT (. I EMG < N ) ) DO 2 N = 4097, 4352 2 EMG< N) = 0 . 0 DO 8 N = 1, 4096, 2 TEMP = EMG ( N) + LP<0) DO 9 K = 1, 25 9 TEMP = TEMP + <EMG<.N-K) + EMGdN+K) ) * LPCK) IE M G < N) = IFIX<TEMP) IEMGCN+1) = 0 8 CONTINUE CALL WRBLK < DCHAN, DATSTT, I EMG < 1), 16, ERROR ) CALL FCLOS<DCHAN) CALL TIME CTTIME,ERROR) WRITE <CRT, 500) (TTI ME C K), K=1,3) 590 FORMAT ts' ' , 10X , " — COMPLETED AT " , I 2, ' : ' , 12, "= " , 12) CALL BACK STOP END 8 0 . 5. 12 PARAMETER DCHAN=62 , C R T = 1 0 , L P T = 1 2 , K Y B D = 1 1 , Y P L T = 4 4 4 , M 2 = 2 0 0 0 0 K , M 3 = 1 0 0 0 0 K , Y A L P H A = 1 7 8 C *# + + + + + + + + + + + + + *•+ c C MAIN R O U T I N E H IGHEMG C C + * + + + + + + + + + + + + + #* + + + + + + ^ c T H I S ROUT INE F I L T E R S THE DATA I N THE F I L E E M G D A T A : D A T A . T H E LOW P A S S F I L T E R C 0 - 2 0 H Z ) E S T I M A T E S THE B A S E L I N E WHICH I S THEN S U B T R A C T E D FROM THE S I G N A L . R E A L FEMG < 0 = 2 5 5 ) DOUBLE P R E C I S I O N L P K 0 s 3 2 > * L P I K 0 : 1 0 ) , L P I I I < 0 : 3 0 ) , F K - 3 2 : 32 ) ' , F I K - 1 0 : 1 8 ) , F 1 1 1 < - 3 0 : 3 0 ) , ' F I V C - 3 0 = 3 8 ) , F V O 1 0 : 1 0 ) , F V I < > 3 2 : 3 2 ) , TEMP , T E M P 5 , T E M P 6 , B A S E S T INTEGER I E M G ( 0 : 2 5 5 ) , R B L K , WBLK, C 2 , C 4 , C 1 6 , ERROR, T T I M E C 3 ) L O G I C A L S E N S E , S K P L T COMMON .-''EMGREC / 1 EMG, FEMG / F LTREC - - ' L P I , L P 1 1 , L P I 1 1 , C 2 , C 4 , c ie X, F I , F I I , F I 1 1 , F I V , F V , F V I , E X T E R N A L P L O T , A L P H A , B E L L , P A G E , S E N S E , RANDOM DATA L P I L P 11 / L P I I I / 0 . 5 2 7 5 4 1 3 4 D - 0 1 , 0 . 4 9 4 2 S 7 9 4 D - 0 1 , 0 . 4 0 4 6 9 1 9 9 D - 0 1 , 0 . 2 8 5 8 5 8 3 6 D - 8 1 , 8 . 1 6 6 5 5 3 3 3 D - 8 1 , 8 . 7 3 4 4 2 8 3 7 1 1 - 8 2 , 8 . 1 6 0 4 8 2 2 8 D - 0 2 , - 0 . 3 8 3 4 8 1 6 2 D - 0 3 , -- O . 1 3 1 8 2 1 7 0 D - 0 2 , -- 0 . 8 5 6 7 8 8 4 5 D - 0 3 , -- 0 . 3 3 3 1 8 7 1 7 D - 0 3 , -0 . 2 0 9 8 7 8 1 O D + 0 0 , 0 . 8 8 8 5 9 9 8 0 D - 0 1 , - 0 . 1 6 3 3 6 1 4 3 D - 0 1 , -- 0 . 3 8 7 7 9 8 3 9 D - 8 2 , -8 . 31 3 2 2 7 8 9 D + 8 8 , 8 . 1 9 4 9 8 3 1 7 D - 0 1 , -- 0 . 1 7 7 4 2 1 5 7 D - 0 1 , O. 1 5 1 2 6 9 4 7 D - 0 1 , -- 0 . 1 2 0 2 2 8 3 3 D - 0 1 , 0 . 8 8 3 6 7 4 6 2 D - 0 2 , -- 0 . 5 3 3 2 0 2 1 9 D - 0 2 , -0 . 3 5 6 1 0 0 8 7 D - 0 2 , - 0 . 1 8 4 0 4 5 5 5 D - 0 2 , -0 . 8 0 5 6 3 6 8 7 D - 0 3 , - 0 . 4 3 1 8 4 2 8 S D - 8 4 - ' , IEMG / 2 5 6 * 0 / , FEMG / 2 5 6 * 0 . 0 / , F I / 6 5 + 0 . D 0 / , F I I / 2 1 + 8 . D 0 / , F i l l . - ' 61*0 . D O / , F I V •-'61+0. D O / , 0 . 5 2 3 7 5 5 2 5 D - 0 1 , 0 . 4 6 9 6 1 0 1 0 D - 0 1 , 0 . 3 6 6 5 9 2 1 1 D - 0 1 , 0 . 2 4 3 9 9 3 2 9 D - 0 1 , 0 . 1 3 1 3 6 8 9 4 D - 0 1 , 0 . 5 0 2 6 7 3 1 6 D - 8 2 , 0 . 4 5 6 6 9 4 9 8 D - 0 3 , 0 . 1 2 0 9 7 1 1 0 D - 0 2 , 0 . 1 2 1 8 6 8 7 7 D - 8 2 , 8 . 6 6 4 4 1 5 5 4 D - 8 3 , 8 . 2 0 9 9 8 3 7 5 1 1 - 8 3 , O . 1 9 8 3 2 4 8 8 D + 8 8 , 8 . 2 8 1 8 5 1 8 5 D - 8 1 , 8 . 1 4 6 7 6 8 6 5 D - 0 1 , 8 . 5 3 6 7 4 7 3 8 D - 0 3 / , 0 . 2 6 4 3 0 1 1 8 D + 0 O , 0 . 5 4 1 7 3 0 7 2 D - 0 1 , 0 . 2 2 3 2 6 4 9 9 D - 8 1 , 8 . 9 3 8 6 5 8 4 2 D - 8 2 , 8 . 3 8 3 8 6 7 8 3 D - 8 2 , 8 . 4 6 7 5 5 2 1 3 D - 8 5 , 8 . 1 1 5 5 8 9 2 8 D - 8 2 , 8 . 1 2 9 0 0 6 1 3 D - 0 2 , 0 . 9 5 8 9 3 8 8 5 D - 0 3 , 0 . 6 3 3 5 4 6 8 5 D - 0 3 , 0 . 5 1 2 5 3 0 5 1 D - 0 1 , 0 . 4 3 9 4 1 1 4 0 D - 0 1 , 0 . 3 2 6 3 1 1 2 9 D - 8 1 , 0 . 2 0 4 1 8 1 9 3 D - 0 1 , 0 . 1 0 0 7 0 6 2 2 D - 8 1 , 0 . 3 1 1 8 6 7 8 3 D - 8 2 , •0. 3 6 4 2 4 7 3 4 D - 8 3 , • 8 . 1 3 3 2 2 3 1 6 D - 8 2 , - 0 . 1 8 4 6 7 1 2 5 D - 8 2 , •8 . 4 8 6 3 9 4 3 9 D - 8 3 , •0 . 1 5 7 1 4 9 2 8 D - 0 3 - - ' , 8 . 1 4 1 7 1 0 8 4 D + 0 0 , •0 . 4 4 4 9 6 6 1 8 D - 8 2 , - 8 . 8 3 8 8 6 7 3 2 D - 0 2 , 8 . 1 4 5 8 7 2 7 6 D + 8 8 , - 8 . 5 7 3 3 2 8 2 4 D - 8 1 , 8 . 3 2 3 6 8 2 8 3 D - 8 1 , • 8 . 1 3 8 5 2 8 4 2 D - 8 1 , 8 . 1 1 6 3 2 2 8 8 D - 8 1 , - 0 . 6 3 1 8 1 9 8 5 D - 8 2 , 8 . 3 0 0 8 4 7 5 5 D - 8 2 , - 8 . 1 1 2 9 5 8 4 2 D - 9 2 , 0 . 2 5 1 3 4 6 5 1 D - 8 3 , 8 . 2 3 4 4 5 8 5 6 D - 8 3 , F V I / 6 5 + 0 . D 0 / , C2 C 1 6 / 0 / WRITE ( C R T , 4 9 9 ) F O R M A T ( ' 0 ' , 1OX, " — H I G H P A S S ( 3 0 H Z ) F I L T E R I N G IN PROGRE C A L L F O P E N ( D C H A N , ' E M G D A T A : D A T A ' ) F I L T E R OUT THE B A S E L I N E ( < 2 0 H Z - 3 O H Z ) •. REWIND DCHAN C A L L F G T I M ( I H R , IM , I R ) IR = IR * 11 + IM * ( I H R + 1 ) NK = 0 DO 50 RBLK = 0, 9 1 2 I F ( R B L K . L T . 8 3 8 ) GOTO 2 DO 1 I = 0, 2 5 5 I E M G ( I ) = 0 GOTO 3 CONT INUE C A L L RDBLK (DCHAN , R B L K , I EMG ( 0 ) , 1, ERROR ) CONTINUE DO 48 I S = 0, 2 5 5 , 2 DO 4 I = - 3 2 , 31 F I ( I ) = F K I + l ) F K 3 2 ) = D F L O A T ( I EMG( I S ) ) C16 = C 1 6 + 1 I F ( C 1 6 . E Q . 1 6 ) GOTO 5 TEMP6 = 0 . D 8 GOTO 19 CONT INUE C16 = 0 TEMP = F I ( 0 ) * L P I ( 0 ) DO 6 K = 1, 3 2 TEMP = TEMP + ( F I ( K ) + F I ( - K ) ) * L P K K ) DO 7 I = - 1 0 , 9 F I I ( I ) = F I I ( I + 1 ) F I K 1 8 ) = TEMP C4 = C4 + 1 I F ( C 4 . E Q . 4 ) GOTO 8 TEMPS = 8 . D O GOTO 16 ! C O N T I N U E C4 = O TEMP = F I K 0 ) * L P I I ( 0 ) DO 9 K = 1, 10 TEMP = TEMP + ( F I I ( K ) + F I I C - K ) ) * L P I I ( K ) ! DO 10 I = - 3 0 , 2 9 10j F I I K I ) = F I I K I + l ) | F i l l ( 3 0 ) = TEMP C2 = C2 + 1 I F ( C 2 . E Q . 2 ) GOTO 11 TEMP = 0 .ODO GOTO 13 CONT INUE C2 = 0 TEMP = F I I K O ) * L P I I K 0 ) DO 12 K = 1, 3 0 TEMP = TEMP + ( F I I I ( K ) + F I I K - K ) ) * L P I I K K ) CONT INUE DO 14 I = - 3 0 , 2 9 F I V C I ) = F I V C I + 1 ) F I V < 3 8 ) = TEMP TEMP5 = F I V ( O ) * L P I I K 0 ) DO 15 K = 1, 3 0 TEMPS = TEMPS + ( F I V ( K ) + F I V ( - K ) ) * L P I I K K ) CONT INUE DO 17 I = - I S , 9 F V ( I ) = F V ( I + 1 ) F V ( 10 ) = TEMPS TEMPS = F V ( O ) * L P 1 1 ( 0 ) DO 18 K = L 10 TEMPS = TEMPS + ( F V ( K ) + F V ( - K ) ) * L P I K K ) CONT INUE DO 28 I = - 3 2 , 31 F V K I ) = F V K I + l ) F V I< 3 2 ) = TEMPS B A S E S T = F V I < 0 ) * L P 1 ( 0 ) DO 21 K = 1, 3 2 B A S E S T = B A S E S T + ( F V K K ) + F V K - K ) ) * L P K K ) FEMG ( I S ) = 1 2 8 . 0 * S N G L ( B A S E S T ) F E M G ( I S + 1 ) = 0 . 0 CONT INUE UIBLK = RBLK - 3 3 I F (UIBLK. L T . 0 ) GOTO 4 5 C A L L RDBLK ( D C H A N , W B L K , I E M G ( 0 ) , 1 , E R R O R ) S K P L T = . T R U E . I F ( . N O T . S E N S E ( M 2 ) ) GOTO 41 I F ( S E N S E ( M 3 ) . A N D . ( R A N D O M ( I R ) . G T . 0 . 0 0 3 ) ) GOTO 41 S K P L T = . F A L S E . C A L L PAGE ( C R T , I.JBLK) C A L L B E L L C A L L P LOT ( 1 0 2 3 , Y P L T , 0 ) C A L L P LOT ( 0 , Y P L T , 1 ) LY = I E M G ( O ) / 4 + Y P L T C A L L P L O T ( 0 , L Y , 0 ) DO 4 3 I = 0, 2 5 5 , 2 LY = I E M G ( I ) / 4 + Y P L T C A L L P LOT < 4 * I , L Y , - 1 ) CONT INUE CONT INUE DO 42 I = 0, 255 42 I E H G ( I ) = I F I X ( F L O A T ( I E M G ( I > > - FEMG(I>> I F < S K P L T ) GOTO 46 LY = I E M G ( O ) • 4 + Y P L T C A L L P L O T ( 0, L Y , 0> DO 44 I = 0, 2 5 5 , 2 LY = I E M G U > / 4 + Y P L T C A L L PLOT ( 4 + 1 , L Y , 1 ) 4 4 CONT INUE C A L L PLOT C O , Y A L P H A , 0 ) C A L L ALPHA I F ( S E N S E ( M 3 ) ) W R I T E ( C R T ) "<33><2?>" C i 4 6 C O N T I N U E C A L L WRBLK (DCHAN , WBLK, I EMG ( 0 ) , 1, ERROR ) C I F < MOD(WBLK, 1 6 ) . N E . 0 ) GOTO 4 5 WRITE ( C R T , 5 0 1 > WBLK 5 0 1 FORMAT C I X , 1 3 , I X , Z > ! NK = NK + 1 j I F < M O D < N K , 1 8 > . E Q . 0 ) WRITE ( C R T ) c i 4 5 CONT INUE 5 8 CONTINUE C C C A L L F C L O S ( D C H A N ) C A L L T I M E ( T T I ME,ERROR) C A L L ALPHA WRITE ( C R T , 5 0 0 ) ( T T I M E ( K ) , K = l , 3 ) 5 0 0 FORMAT (.'•' ',10X, " — COMPLETED AT " , 1 2 , ' : ' , 12, " = " , 1 2 ) C A L L BACK STOP END C 8 8 . 5 . 2 0 C OVERLAY O D I S P L C PARAMETER DCHAN=62 , Y l = 6 9 0 , Y 2 = 5 5 8 , Y 3 = 4 2 4 , Y 4 = 2 9 4 , Y A L P H A = 2 0 4 , P R C P R I = 0 , O F F = - l , ON = l , FWD=1, RVS = - 1 , C R T = 1 0 , L P T = 1 2 , MPOTS = 20O C C *********** * ******************** ************************************** c T A S K D I S P L Y C C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * c C T H I S TASK ALLOWS V I S U A L EXAM I HAT I ON OF THE E . M . G . DATA . C I T ALSO D I S P L A Y S THE P O S I T I O N S OF S E L E C T E D P O T E N T I A L S , AS READ FROM C T H E F I L E " P O S I T I O N S " BY THE MA IN R O U T I N E . C C INTEGER D A T S T T , D P S T A T , D E L A Y , HOM, D D I S , E D I S , E B L C K , D I S D I R , L S T D I R , L S T S T T , ERROR , EMG<0•. 1 0 2 3 , 4 > , Y D I S < 4 ) , F W D I S P , R V D I S P , NPOTS , P O S < 2 , M P O T S ) , I P , B P O S T N , POSTN L O G I C A L P O T F L G C COMMON .•• 'DSPDAT/DISDIR, D P S T A T , DATSTT , D E L A Y , NOM / - E M G R E C E M G / • P R C R E C / H P O T S , POS , P O T F L G C E X T E R N A L P A G E , P L O T , A L P H A , E R A S E , SYMBOL , B E L L C C I P = 1 NOM = 0 DELAY = 0 DPSTAT = ON D I S D I R = F WD L S T D I R = D I S D I R DATSTT = - 1 5 L S T S T T = D A T S T T Y D I S ( 1 > = Y l Y D I S < 2 ) = Y2 Y D I S C 3 ) = Y 3 YD I S ( 4 ) = Y4 C DO 1 J = 7 6 8 , 1 0 2 3 1 E M G < J , 4 ) = 0 C 2 CONT INUE C C QUEUE KEYBOARD I N P U T S DUR ING D I S P L A Y : C C A L L A S U S P < P R C P R I ) C A L L ALPHA DDIS = 15 NOM = HOM + D I S D I R DATSTT = DATSTT + D I S D I R * D D I S C 1 c I F ( D A T S T T . L E . 8 7 0 ) GOTO 15 W R I T E C C R T , 5 0 1 ) 5 0 1 F O R M A T C ' , " A T END OF R E C O R D . " ) GOTO 3 c 2 ~n 15 CONT INUE I F ( D A T S T T . G E . 0 ) GOTO 4 W R I T E ( C R T , 5 0 2 ) 5 0 2 F O R M A T < ' J , " A T S T A R T OF R E C O R D . " ) C 3 CONTINUE C A L L B E L L DPSTAT = OFF C A L L A R D Y ( P R C P R I ) C A L L O V K I L ( O D I S P L ) C C 4 CONT INUE C C T H I S NEXT PART I S N E C E S S A R Y TO R E P E A T THE L A S T B L O C K OF C THE P R E V I O U S D I S P L A Y , E V E N WHEN THE D I R E C T I O N OF THE D I S P L A Y C I S CHANGED. C I F ( D A T S T T . E Q . L S T S T T ) GOTO S L S T S T T = DATSTT FWDISP = 7 6 8 R V D I S P = 0 I F ( D I S D I R . E Q . L S T D I R ) GOTO 14 FWDISP = 5 1 2 R V D I S P = 2 5 6 L S T D I R = D I S D I R I P = I P - PCNT C 14 CONTINUE I F ( D I S D I R . E Q . R V S ) GOTO 6 E D I S = 2 5 6 E B L C K = 1 DO 5 J = 0 , 2 5 5 5 EMG( . J , 1 ) = E M G ( F W D I S P + J , 4 ) GOTO 8 C 6 CONT INUE E D I S = 0 E B L C K = 0 DO 7 J = 0, 2 5 5 7 E M G ( 7 6 S + J , 4 ) = E M G ( R V D I S P + J , 1 ) C 3 CONT INUE C C I F THE D I S P L A Y HAS B E E N R E V E R S E D , OR REDRAWN, THE P O S I T I O N I N D E X C rjlUST BE RESET C I F ( P O S ( l , I P ) . L T . ( D A T S T T - E B L C K ) ) GOTO 18 I P = I P - 1 I F ( I P . L T . 1 ) GOTO 18 GOTO 8 18 C O N T I N U E I P = I P + 1 C I F ( D A T S T T . N E . 8 7 0 ) GOTO 11 D D I S = 10 DO 9 J = 5 1 2 , 1 0 2 3 9 E M G ( J , 3 ) = 0 DO 10 J = 0 , 1 0 2 3 10 E M G ( J , 4 ) = 0 C 11 CONT INUE C A L L RDBLK < D C H A N , D A T S T T , E M G < E D I S , 1 ) , D D I S , E R R O R ) I F ( E R R O R . E Q . 1 ) GOTO 12 C A L L A K I L L < P R C P R I ) STOP ERR 15 CONT INUE C A L L PAGE< C R T , N O M ) •DO 13 J = 1 , 4 I X = 0 IY = E M G < I X , J ) • 16 + Y D I S < J ) C A L L P L O T ( I X , I Y , 0 ) , DO 13 I X = 2 , 1 0 2 3 , 2 | POSTN = I X + C J - 1 ) + 1 0 2 4 B P O S T N = DATSTT + P O S T N 2 5 6 - E B L C K P O S T N = M O D ( P O S T H , 2 5 6 ) I F ( ( I P . GT. N P O T S ) . OR. ( . NOT. P O T F L G ) ) GOTO 16 I F ( ( P O S <1, I P ) . N E . B P O S T N ) . O R . ( P O S ( 2 , I P ) . N E . P O S T N ) ) GOTO 16 C A L L P L O T ( I X , Y D I S C J ) - 6 4 , 0 ) DO 17 I = - 6 4 , 4 8 , 16 17 ' C A L L PLOT C I X , YD I S ( J ) + 1 , - 1 ) C A L L P LOT < I X , Y D I S C J ) + 5 2 , 0 ) C A L L A L P H A WRITE ( C R T , 5 8 3 ) I P 5 0 3 FORMAT ( 1 4 ) C A L L P L O T C I X - 2 , I Y , 0 ) I P = I P + 1 C O N T I N U E I Y = E M G ( I X , J ) / 16 + Y D I S C J ) C A L L P L O T ( I X , I Y , 1) 13 CONT IHUE C C A L L P L O T ( 0 , Y A L P H A , 0 ) C C E N A B L E KEYBOARD I H T E R R U P T S W H I L E D I S P L A Y P A U S E S . C C A L L A R D Y ( P R C P R I ) C A L L W A I T ( D E L A Y , 2 , E R R O R ) GOTO 2 C END cs 'xxiow - x = x 891 - z / <NIUX + xywx) = X <I'3W0ay> J l o 3 0 N I 1 N 0 3 L •CHIWm ' d W 3 l f 1 ) 0 N I W = N i w n I = NIWX <NIWP1 11 dW31Pl > JI cxywn 'dW3if'i>exyw = x y u n i = xywx cxywffi ID dW3ii Ti> J I ( D D W 3 A = dW31f l Z 'A 'X =1 L OH X = N I U X A = XWWX 9 £ £ + X = A L9LZZ = NIWP1 ISIZZ- = xyufi 3 I OlOD <<6 '11 'X> dO " < 8 £ 9 £ 'ID 'X>> J I <z 'x>aow - x = x X + \>ZQ\ * C I - A l ) = X 3 I OlOD Ct-IA 11 A> J I fr = A I O A f l 11 A ) J I £ = A I C£AO '11 A ) J I S = A I <2ACT 11 A) J I I = Al I OlOD (. I AO ID ' A> J I I OlOD < < S ID ' WHO I ) ' dO ' < Z ' 11 ' d y H O I > > J I '3iyidW31 a3Dyd3Ay 3H1 d O J H3Ad3S3d S I I ' lOiINIl' l H10 3H1 3 si? - ayHDi = dyHDi e s - ' a y H 3 ) U H S i = yyHOi see OIOD <, , ' i 3 3 d y H O ) J I c a y H O 'A•x> d o s a n 3 i i y o 1 1 3 8 n y 3 3 i " l H I l N 0 3 £ 3 1?1A = C t O l A £1A = <£>1A 21A = C S i ' l A I 1 A = <T)1A 3 3 l O l d ''103WAS ' d O S d l l O 1 1 3 8 i y N d 3 1 X 3 SI'l0HNI'l •'DW3A/33dDW3HOWW03 duaipi 'NIWPI "Amft 'NIWX 'xywx 'AI 'c t o i A ' • a y ' a y H o i 'ayHO 'A 'X 'cseot? :O>DW3A ' < s s e ' . 6 9 i > s n o a N n a 3 D 3 i n i 3 3 'saosano 3Hi H U M aoiya3do 3Hi AO a s w o n s i s o d < s o 3 s w I > I > noaum 3 i d 6 9 i y m m y i y a JO SNOII33S i 3 3 i 3 S 01 3Nimoa y s i S I H I 3 3 * *:+: # + * * + + + * :+:* + * * * + :+: * + + + * + + * * * * + + * * + # * # + * * * * + * :+: + + **#***** 3 3 <oay> 13313s 3Niinoaans-3 3 3 08I = y H d i y A ' 2 I = l d l 'T9£=£1A 'S6t' = 21A '3S9 = I1A ,0£2=t'iA 'i9£= t -An '26fr=£An 'S39=sAn '08Z=IAO a3i3wyayd 3 3313S0 A y i d 3 A 0 3 QQ/b'bZ 3 I F < X . L T . 0 ) X = 0 I F ( X . G T . 3 6 5 3 ) X = 3 6 5 3 DO 2 I = 1, 169 Y = X + 2 * <I - 1 ) UIHDOWSC I , I CHAR) = VEMG < Y ) CONT INUE IY = <X / 1 0 2 4 ) + 1 X = X - <IY - 1) * 1 0 2 4 Y = Y L < IY ) C A L L P L O T C X , Y , 0 ) DO 4 1=0, 1 1 6 , 3 C A L L P L O T C X , Y + I , - 1 > C A L L S Y M B O L ( X , Y + 1 1 S , C H A R ) KX = X + 3 3 6 KY = Y I F ( K X . L E . 1 0 2 3 > GOTO 5 KX = KX - 1 8 2 3 KY = KY - 131 CONT INUE C A L L P L O T C K X , K Y , 8 ) DO 6 1=8, 1 16 , 3 C A L L P L O T C K X , K Y + I , -GOTO 3 CONT INUE C A L L B E L L GOTO 3 CONT INUE RETURN END C 1 5 / 4 / 8 0 C PARAMETER Y l = 6 9 0 , Y 2 = 5 5 8 , Y 3 = 4 2 4 , Y 4 = 2 9 4 , Y A L P H A = 2 0 4 , CRT=10 C C C • + + + + + * + + + +* + C S U B R O U T I N E D I S W I N C C * * * * + * * * + # + * + * * * * * + * * * + * * + * * + * * : «4t4(«^4i«H<4tH<)i!^^4<^Hc*!t(i4cHeH«>i(ili)ti4<)ft>l<)|:>it4<!|t4:4:)|c*>)(Hc4tHc C T H I S ROUT INE P L O T S THE TEN WINDOWS STORED I N THE ARRAY "WHDOWS". C INTEGER EMG<0 : 1 0 2 3 , 4 ) , WHDOWSC1 6 3 , 0 , 5 > , Y D I S C 0 : 5 ) COMMON /EMGREC/EMG,WNDOWS E X T E R N A L P L O T , E R A S E , A L P H A , SYMBOL c : . c C A L L E R A S E DO 2 I = 0 , 1 Y D I S C I ) = Y l DO 3 I = 2, 3 Y D I S C I ) = Y2 DO 4 I = 4, 5 YD ISC I ) = Y3 DO 1 I = O, 5 I X = 3 4 I F C M O D C I , 2 ) . N E . 0 ) I X = 5 3 0 IY = Y D I S C I ) - 16 C A L L PLOTC I X , I Y , 0 ) IY = Y D I S C I ) +. 16 C A L L PLOTC I X , I Y , 1 ) IY = Y D I S C I ) + 20 ICHAR = 1 + 4 3 ICHAR = I S H F T C I C H A R , 8 ) C A L L S Y M B O L C I X , I Y , I C H A R ) IY = W N D O W S C I , I ) / 16 + Y D I S C I ) C A L L PLOTC I X , I Y , 0 ) DO 1 J = 2, 1 63 IY = W N D0 WS C J , I ) / 16 + Y D I S C I ) I X = IX + 2 C A L L PLOT C I X , I Y , 1 ) CONTINUE C A L L P L O T C 0 , Y A L P H A , 0 ) C A L L ALPHA RETURN END 2 - 3 I C 8 0 . 5 . 1 2 C OVERLAY OBLOWI C PARAMETER Y A L P H A = 1 7 2 , C R T = 1 0 , Y P L T = 4 4 4 C C C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * . S U B R O U T I N E BLOWIN <WIND) C fj * * * * * * * * * :+: * * * * * * * * * * * : + : * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * C C T H I S ROUT INE PRODUCES A L A R G E P LOT OF THE WINDOW " W I N D " ON THE C T E K T R O N I X 4 6 1 0 . . C INTEGER EMG CO: 1 0 2 3 , 4 ) , WNDOWS < 1 6 9 , 0 = 5 ) , WIND COMMON .--EMGREC/EMG, WNDOWS E X T E R N A L P A G E , P L O T , A L P H A C C C A L L PAGE < CRT, - 1 ) C A L L P L O T C 0 , Y P L T , 0 ) C A L L P L O T < 1 0 2 3 , Y P L T , 1 ) I X = 7 IY = WNDOWS<1,WIND) • 4 + Y P L T C A L L P LOT < I X , I Y , 0 ) DO 2 1=2, 169 IX = I X + 6 I Y = WNDOWS<I, WIND) / 4 + Y P L T C A L L PLOT< I X , I Y , 1 ) 2 CONT INUE C C A L L P L O T < 0 , Y A L P H A , 0 ) C A L L A L P H A WRITE <. CRT, 5 0 1 ) WIND 5 0 1 F O R M A T < ' Q ' , " B L O W U P OF WINDOWED S E C T I O N " , I 1 ) C RETURN END C 1 5 / 4 / 8 0 C OVERLAY ODSXCO C PARAMETER C R T = 1 0 , Y A L P H 1 = 6 2 3 , Y A L P H A = 7 2 , L X C 0 R R = 5 1 2 . 0 , Y W I N = 7 0 4 , Y X C O R R = 1 0 0 , XW1=404 , XW2=916 , X X C 0 R R = 8 4 9 C C C * * * * * * * * * + * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * c S U B R O U T I N E DSXCOR CWIN1 , W I H 2 ) C C * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * :+: * * * * * * C C T H I S ROUT INE C A L C U L A T E S THE C O R R E L A T I O N F U N C T I O N BETWEEN THE WINDOWED C S E C T I O N S OF DATA, " W I N 1 " AND " W I N 2 " . C THE WINDOWED S E C T I O N S ARE P L O T T E D ALONG WITH THE R E S U L T A N T C O R R E L A T I O N C AND I T S MAX. AND M I N . V A L U E S OH THE T E K T R O N I X 4 9 1 0 . C < I F " W I N 1 " E Q U A L S " W I N 2 " , THE ONE S E C T I O N I S P L O T T E D , ALONG WITH THE C R E S U L T A N T A U T O C O R R E L A T I O N F U N C T I O N ) ' C REAL R 1 2 ( 3 3 7 ) , RMAX, R M I N , DR INTEGER WIN1 , WIH2 , E M G C 0 : 1 0 2 3 , 4 ) , WHDOWSC 1 6 9 , 0 : 5 ) COMMON / / R 1 2 / E M G R E C / E M G, WN D0 W S E X T E R N A L XCORR, P A G E , P L O T , A LPHA C C C A L L P A G E C C R T , - 1 ) C I X = XW1 C A L L P L O T C I X , Y W I N , O ) IX = IX - 3 3 7 j C A L L P LOT C I X , YWIN, 1 ) C IY = W ND0W S C I , W IN1 ) / 16 + YWIN C A L L P LOT C I X , I Y, 8 ) DO 1 1 = 2 , 1 6 9 I Y = W N D 0 WS C I , W I N 1 ) / 16 + YWIN I X = I X + 2 C A L L PLOTC I X , I Y , 1 ) 1 CONT IHUE C C A L L P L O T C 0 , Y A L P H 1 , 0 ) C A L L A LPHA WRI TEC CRT, 5 0 1 ) WIH1 5 0 1 F O R M A T C ' + ' , "WINDOWED S E C T I O H C S ) " , I 1 ) C I F C W I N I . EQ. W IH2 ) GOTO 3 I X = X W 2 C A L L P L O T C I X , Y W I H , O ) I X = I X - 3 3 7 C A L L P L O T C I X , Y W I H , 1 ) C I Y = WHDOWSC1 ,WIN2 ) / 16 + YWIN C A L L P L O T C I X , I Y , 0 ) DO 2 1 = 2 , 1 6 9 I Y = WHDOWSC I ,W IN2 ) / 16 + YWIN I X = I X + 2 C A L L P LOT C I X , I Y , 1 ) C O N T I N U E C A L L P L 0 T C 8 , Y A L P H 1 , 0 ) C A L L A L P H A W R I T E C C R T , 5 0 2 ) WIN2 F O R M A T C ' + ' , 2 2 X , "AND ",ID CONTINUE C A L L XCORRCWNDOWSC1, W I N D , WNDOWSC1, W I N 2 ) , R 1 2 , 1 6 9 ) RMAX = - 1 . 0 E 7 5 RMIN = 1 . 0 E 7 5 DO 6 I = 1, 3 3 7 IF C R 12 C I ) . GT. RMAM) RMAX = R 1 2 C D IF C R 1 2 C I ) . L T . R M I N ) RMIN = R 1 2 C I ) CONTINUE DR = CRMAX - R M I N ) / LXCORR IX = XXCORR - 6 7 5 I F CRM I N . G T . 0 ) GOTO 4 IY = I F I X C - R M I N / DR + 0 . 5 ) + YXCORR I X = XXCORR C A L L P L O T C I X , I Y , 0 ) I X = IX - 6 7 5 C A L L P L O T C I X , I Y , 1 ) CONT INUE IY = I F I X C C C R 1 2 C 1 ) - R M I N ) / DR) + 0 . 5 ) + YXCORR C A L L PLOT C I X , I Y , 0 ) DO 5 1 = 2 , 3 3 7 IX = IX + 2 IY = I F I X C C C R 1 2 C I ) - R M I N ) / DR) + 0 . 5 ) + YXCORR C A L L P L O T C I X , I Y , 1 ) CONT INUE C A L L P L O T C 0 , Y A L P H A , O ) C A L L ALPHA WRI TE C CRT, 5 0 3 ) RM IN , RM:1X F O R M A T C ' + J , " C O R R E L A T I O N F U N C T I O N RANGES FROM " , G 1 1 . 4 , " M I N . TO " , G i l . 4 , " M A X . " ) RETURN END C 2 4 / 3/88 ^ C* + *+. + + *##+*# + #* ++* + * + * + + ^  C S U B R O U T I N E XCORR <X, Y , RXY , N> C C * * * * + + ** + + + + + * + + + * + * + * + + * + * + * + * + * + + + + * * * * * + * * * * + * * * * * * * + + * * + + + * + + * + + + + C T H I S ROUT INE CROSS C O R R E L A T E S THE DATA I N THE TWO I N T E G E R C A R R A Y S " X " AND " Y " , P L A C I N G THE R E S U L T IN THE I N T E G E R ARRAY • Y R E A L RXY<1> DOUBLE P R E C I S I O N T E M P I , TEMP2 I N T E G E R X U ) , Y<1> M = 1 - N DO 1 K = M , - 1 J = N + K T E M P I = 0 DO 2 1 = 1, J TEMP2 = X U - K > T E M P I = T E M P I + TEMP2 + Y<I> C O N T I N U E R X Y C J ) = T E M P I / D F L O A T C N ) CONT INUE M = N - 1 DO 3 K = 0 , M •J = N + K T E M P I = 0 L = N - K DO 4 1 = 1 , L TEMP2 = Y<I+K> T E M P I = T E M P I + X<I> * T E M P 2 C O N T I N U E R X Y C D = T E M P I / D F L O A T ( N ) CONT INUE RETURN END I A 3 UN '1ININ 'SHSaHl <£8Q ' N W H O W ) 3 1 i a P l ( 2 i '„ # aaoaay,.'X O T ' 2 i'.. # 3dyi..', .oiywaoj t o e wnN03a 'wriNdyi <t-0s'NyHoy> 311 an <1- 'NyHay> soya n y 3 <aasi 'Z ',s3H3iyu :><aopi, 'NyHoy> aN3ddy n y o 3 ' S 3 i a y i a y A . HOiiayay S H I J O ssrnyA 3 H i aNy ' S H o m s o d S H I 3 'sayw s N 0 i i 3 3 i 3 a 3 H I J O aaoosa s i a y a y s a y sniyiNOO ssHoiyw 3 i u 3 H i 3 3 <NyHoy> s o i 3 j my3 A 3 (IN ' 1 I N I N ' O H S d H l < <i66 = a a 3 'Z66 = a N 3 'NWHOy > ay3d < , N o i i d y i i y : ^ d o i ' i , ' N W H O W ) N 3 d o j n y o 3 0 H i a 3 i n u n 3 H 3 i y w 3 A i i d y n y 3 H i J O N o i i y a s a o 3 3 H i ONiinoaiNOO a o j saaiswyaya S H I s N i y i N o o , N 0 i i d y a y , 311 J S H I o 3 NyHoa r i N i P i s a <••' ' 'sssaooad N I O H i a s i i u <i3H0iyw.3Aiidyay„ 'xei ' , 0, > lywaoj 10s c i o s ' i a o ) 3 1 1 a n < 1 - 'iao>3oyd n y 3 woanya ' 3 S N 3 S ' i l i a ' l o i d a ' 3 D « d 'inowa i y N d 3 1 X 3 3 3 C ••. 000£ > DW3A ' < I > 3W111 > ' < < 0003 > DW3 A ' < 831 - > A > ' < < 0081 > 0W3A ' < t-8- ) dWl ) ' < < 0 > 0W3A ' < t>8- ) 3 i y i d W 3 1 > 3 3 N 3 i y A 111(33 3 :3oyds y o y i s 3Ays 01 asaao N I O 3 O U l O d ' SOd ••siodN.--33aoad.--w n N o 3 a • w n N d y 1' s PI o a N PI •' o w 3 A /33a 3 w 3 / N 0 w woo 3 o u i o d ' u s s i y j '3sN3s 'i33i3a n y o i o o i W O N 3 3 a ' w n N d y i 'c:£>3Niii ' . • • • . H I I O J '<S10dW '3>S0d ' 1 I N I N 'XyWd 'XyWdO ' N l S O d O ' N I S O d 'SlOdN ' l X a i '<S :0 't-8 :t>8->SPi0HNPl ' < £681? : 8 "> 0W3A ' l l d W l d3031NI H S d H l H 'xywixa '330Ay '33ayA ' A 3 H N 'sxwns 'xwns ' o s : 8 9 I - > A 'SidNa 'HsaHii '<t-s :i?8->dwi '0Hsam '<t-s :t>8->3iyidU3i 'i x a i y s a 3 3 asorinoad 3 3ay ssidooaayH ' N O S I I I N O 3 H I J I any 'ia3 3Hi N O a s u o i d o 3ay <V.£> S N 0 I 1 3 3 1 3 I 3 3 H 1 JO N 0 I 1 3 3 1 3 S WOUNyd y '»dn„ S I £ H31IPIS J I 3 IdO 3 H 1 NO H S l l O l d S I N 0 I 1 3 3 1 3 i I H 3 y 3 '„dn„ S I Z H31IP1S J I 3 y.-'a 3Hi o i n 3 i i n d i n o o 3ay s n n s 3 a a s i i u 3 Hi any y i y a n y N i o i a o 3 H I '„dn„ s i i H O I i P I S J I 3 y i y r j . 3W3 3 H I J O D N i a s n u asHoiyw 3 A i i d y a y swacuasd 3N i i n o a s i H I o 3 + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * ******* 3 3 <iidwi)H3iyw SNiinoaans 3 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Q 3 SZ38 • i-=Niwiy3a 'Mfroosoo^ais 'M£izzo0=yjs '^08000i = i a i s '»0000t>e=yaw ':H008eie=daw '»800030=dW '8S=NyH3y '803=SlOdW 'S£=NyH3d '£-3S3i£S6 i = 3 i y o s 'ii=aaA» ' 3 i = i d i '0i=ia3 '39=NyH3a asiswyayd 3 Hoiyuo Ayia3A0 3 £3 Q 0 8 3 2 * 1 5 0 3 FORMAT < ' 0 ' , 2 0 X , 1 P G 1 0 . 3 , 5 X , 1 2 , 5X , 1 P G 1 0 . 3 , / " ' ) C C TO SET UP I N I T I A L T H R E S H O L D : C C A L L F G T I M < I H R , I M , I R ) IR = IR * 11 + IM * <IHR + 1 ) NPOTS = 0 POTDLY = 1 DETECT = . F A L S E . F A L S E D = . F A L S E . . RXTMAX = R E A L M IN BPOSTN = 0 POSTN = - 1 7 0 SUMX = 0 . 0 AVGCC = 0 . 0 SUMX2 = 0 . 0 VARCC = 0 . 0 RXT = 0 . 0 DO 1 H= - 3 4 , 8 4 Y < N ) = 0 . 0 TMP<N) = 0 . 0 T E M P L A T E S N ) = F LOAT<WNDOWS<N,TMPLT )> RXT = RXT + T E M P L A T E < N ) + * 2 1 CONT INUE RXT = RXT / 1 6 9 . 0 L T H R S H = C 1 . 0 - THRSHO) * RXT HTHRSH = < 1 . 0 + THRSHO) * RXT C C C T H E MAIN F I L T E R I N G LOOP: C 2 CONT INUE C C I F O, 10 AND 13 ARE THE ONLY S W I T C H E S SET THEN R E T U R N : C I F (. S E N S E < S T R 1 ) . AND. SENSE< S T R 2 ) . AND . . NOT. S E N S E < S F A ) ) GOTO 9 9 8 C C C A L C U L A T E RECORD P O S I S T I O N , S H I F T THE WINDOW VECTOR AND GET Y < 8 4 ) : C POSTN = POSTN + 2 BPOSTN = BPOSTN + POSTN / 2 5 6 POSTN = M O D C P O S T N , 2 5 6 ) C DO 3 N = - 1 6 8 , 8 3 3 Y < N) = Y<N+1) READ B I N A R Y < D C H A N , E N D = 9 9 8 ) I Y , N YCS4> = F L O A T < I Y ) C C C A L C U L A T E THE C O R R E L A T I O N C O E F F I C I E N T : C RXT = 0 . 0 . DO 4 N = - 8 4 , 84 4 RXT = RXT + Y <.N) * T E M P L A T E C N ) RXT = RXT / 1 6 9 . O C C I F SWITCH 1 I S SET OUTPUT THE C . C . AND S I G N A L TO THE D / A ' S : C I F < . N O T . S E N S E C M D A ) ) GOTO 5 I R X T = I F I X C R X T * S C A L E ) I = I F I X ( Y < 0 ) ) C A L L D A O U T < I R X T , I Y ) C 5 C O N T I N U E c C I F AT B E G I N N I N G C O N T I N U E : C I F ( ( B P O S T N . E Q . 8 ) . A N D . ( P O S T N . L T . 1 7 0 ) ) GOTO 2 C C THRESHOLD T E S T : ONCE P A S T THE THRESHOLD THE MAXIMUM OF RXT I S C USED TO F I X THE EPOCH OF THE D E T E C T E D WAVEFORM. C ONCE A D E T E C T I O N I S MADE THE T E M P L A T E AND THRESHOLD ARE U P D A T E D . C C I S C . C . > LOW T H R E S H O L D ? C I F < R X T . G T . L T H R S H ) GOTO 6 C C C . C . I S <= LOW THRESHOLD - - HAS A D E T E C T I O N B E E N MADE? C I F ( . N O T . D E T E C T ) GOTO 2 C C I S THE D E T E C T I O N F A L S E ? C I F ( F A L S E D ) GOTO 7 C C GOOD D E T E C T I O N , SO RECORD: C NPOTS = NPOTS + 1 RNPTS = F L O A T ( N P O T S ) C C ENOUGH D E T E C T I O N S ? C I F ( N P O T S . G T . M P O T S ) GOTO 333 C P O S ( 1 , N P O T S ) = BPMAX P O S ( 2 , N P O T S ) = PMAX C C I F SWITCH 0 I S S E T , PLOT THE D E T E C T I O N S U P E R I M P O S E D OVER THE C T E M P L A T E ON THE CRT: C I F ( . N O T . S E N S E ( M P ) ) GOTO 14 I F ( S E N S E ( M R P ) . A N D . ( R A N D O M ( I R ) . G T . 0 . 0 3 ) ) GOTO 14 C A L L P A G E ( C R T , N P O T S ) C A L L R P L O T ( T E M P L A T E ( - 3 4 ) , 1 ) C A L L R P L O T ( V ( - S 4 - P 0 T D L Y ) , - 1 ) WRITE ( C R T , 5 0 2 ) NPOTS , BPMAX , PMAX, L T H R S H , RXTMAX , HTHRSH , AVGCC , VARCC C A L L B E L L I F ( S E N S E ( M R P ) ) WRITE ( C R T ) " < 3 3 > < 2 7 > " C 14 C O N T I N U E I F ( M O D ( N P O T S , 6 0 ) . E Q . 0 ) WRITE ( A C H A N ) " < 1 4 >" WRITE ( A C H A N , 5 0 2 ) NPOTS , BPMAX , PMAX, L T H R S H , R X T M A X , HTHRSH , A V G C C , V A R C C 5 0 2 FORMAT C ' , 1 3 , ' : ' , 1 3 , ' ' , 1 3 , ' , ' , I P G 1 0 . 3 , ' < ' , I P G 10 . 3 , ' < ' , I PG 1 0 . 3 , ' , ' , I P G 1 0 . 3 , ' ' , I P G 10 . 3 ) C C F I N A L L Y , UPDATE T H R E S H O L D S , T E M P L A T E , E T C . : C SUMX = SUMX + RXTMAX SUMX2 = SUMX2 + RXTMAX++2 RXTMAX = R E A L M I N AVGCC = SUMX / R N P T S I F ( N P O T S . G T . l ) VARCC = S Q R T ( ( R N P T S * SUMX2 - S U M X * * 2 ) / ( R N P T S * ( R N P T S - 1 . 0 ) ) ) C BO 8 N = -84, 84 ^ 3 8 TMP<N) = TMP < N ) + Y < N - P O T D L Y ) C POTDLY = 1 C C T H E THRESHOLDS AND T E M P L A T E UPDATED ONLY I F ENOUGH D E T E C T I O N S C H A V E OCCURED: C I F < N P O T S . L T . N I N I T ) GOTO 13 L T H R S H = AVGCC - NDEV * VARCC HTHRSH = AVGCC + NDEV * VARCC DO 9 H = - 8 4 , 8 4 9 T E M P L A T E S N ) = TMPCN) / RHPTS C 13 C O N T I N U E C C I S NEW LOW THRESHOLD LOWER THEN OLD ONE? C I F < R X T . G T . L T H R S H ) GOTO 10 C C I T I S NOT — C O N T I N U E TO NEXT D E T E C T I O N : C DETECT = . F A L S E . GOTO 2 C C LOWER THRESHOLD — WAIT U N T I L THE C . C . F A L L S BELOW: C 10 C O N T I N U E F A L S E D = . T R U E . GOTO 2 C C C A F A L S E D E T E C T I O N ~ C L E A R TO IGNORE AND C O N T I N U E : C 7 C O N T I N U E D E T E C T = . F A L S E . F A L S E D = . F A L S E . RXTMAX = REALM I N POTDLY = 1 GOTO 2 C C C C . C . I S OVER LOW THRESHOLD — A D E T E C T I O N : C 6 C O N T I N U E DETECT = . T R U E . C C I F C . C E X C E E D S U P P E R THRESHOLD — A F A L S E D E T E C T I O N : C I F < R X T . G T . H T H R S H ) F A L S E D = . T R U E . C C I F D E T E C T I O N I S F A L S E , IGNORE : C I F d F A L S E D ) GOTO 2 C C O T H E R W I S E , LOOK FOR C . C P E A K AND S T O R E L O C A T I O N : C I F < R X T . G T . R X T M A X ) GOTO 11 C C P O T D L Y COUNTS D E L A Y FROM THE P E A K TO NEXT LOW C T H R E S H O L D C R O S S I N G ; I F D E L A Y > 8 4 — A F A L S E D E T E C T I O N . C P O T D L Y = P O T D L Y + 1 I F < P O T D L Y . L E . 8 4 > GOTO 2 2 _ H O F A L S E D = . T R U E . GOTO 2 C C A HEW MAXIMUM: C 11 C O N T I N U E RXTMAX = RXT BPMAX = B P O S T N PMAX = POSTN P O T D L Y = 1 GOTO 2 C C 9 9 7 CONT INUE T Y P E " A D A P T I O N F I L E E R R O R ! " GOTO 9 9 9 C 9 9 8 CONT INUE C C S A V E THE P O S I T I O N S OF THE D E T E C T E D P O T E N T I A L S . C C A L L F O P E N < P C H A N , ' W O R K : P O S I T I O N S ' > WRITE B I N A R Y <PCHAN) TAPNUM, RECNUM, NPOTS , < <POS>'. J , I ) , J = l , 2 ) , 1 = 1, N P O T S ) , ( W N D O W S C I , T M P L T ) , I = - 8 4 , 8 4 ) P O T F L G = . T R U E . C C A L S O SAVE THE F I N A L AVERAGE T E M P L A T E <@), AND THE I N I T I A L T E M P L A T E C 1 ) . C DO 12 N = - 8 4 , 84 IY = I F I X < T E M P L A T E S >) WNDOWSCN,6) = I Y WRITE B I N A R Y <PCHAN) I Y W H D 0 U S < N, 1 ) = W N D 0 W S < N, T M P L T ) 12 CONT INUE C 9 9 9 CONT INUE C : C P U T THE T I M E ON THE CRT, FOR RECORD S A K E . C C A L L T I M E C T T I M E , E R R O R ) WRITE CCRT, 5 0 8 ) < T T I M E < K ) , K = l , 3 ) WR I TE < ACHAN , 5 0 0 > •'. T T I ME < K ) , K= 1 , 3 ) 5 8 0 FORMAT C • O ' , 18X , " — C O M P L E T E AT " , 12 , ' = ' , 1 2 , " •. " , 1 2 ) C C A L L F C L O S <ACHAN) C A L L F C L O S <PCHAN) RETURN END C 8 9 . 5 . 2 9 2 .^ I C O V E R L A Y O P O T S C C P A R A M E T E R D C H A N = 6 2 , F C H A N = 5 9 , C R T = 1 0 , K Y B D = 1 1 , L P T = 1 2 , M P O T S = 2 0 0 , Y P L T = 4 4 4 , Y A L P H A = 1 7 2 , M 3 = 0 1 0 O 0 0 K , M 4 = 0 0 4 0 8 0 K C C * * * * * # + * * +• * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * C S U B R O U T I N E P O T S C N < A R G ) C C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * c R E A L T E M P I N T E G E R P O T S C 0 : 7 6 7 ) , N P O T S , P O S < 2 , M P O T S ) , T Y P E I I , C M N D , B P O S T N , P O S T N , E M G < 0 : 4 8 9 5 ) , W N D O W S < - 8 4 : 8 4 , 0 : 5 ) , I P C - 1 0 0 : 1 6 0 ) , A R G , T A P N U M , R E C N U M , L Z D U R , H Z D U R , X Z M I N , X Z M A X , Z E R O L O G I C A L S T E P , O V L A Y , S E N S E , S C A N C C O M M O N / E M G R E C - ' E M G , W N D O W S , T A P N U M , R E C N U M • ' ' P R C R E C / N P O T S , P O S . - F E A T R S / R C C , L Z D U R , P M I N , X Z M I N , C R V M I N , H Z D U R , P M A X , X Z M A X , C R V M A X , Z E R O , S L O P E C C T O R E D U C E R E Q U I R E D S T A C K S P A C E : E Q U I V A L E N C E < P O T S < 0 ) , E M G (. Q ) ) , < I P C - 1 0 0 ) , E M G C 7 9 9 ) ) C C C C E X T E R N A L P A G E , I P L O T , S E N S E , P F E A T D A T A I P - - - 2 0 1 + 0 . - ' C R E W I N D D C H A N I F <. A R G . N E . 3 ) G O T O 1 0 C A L L F 0 P E N < . F C H A N , •' W O R K : F E A T U R E S ' ) W R I T E C F C H A N , 5 0 5 ) T A P N U M , R E C N U M , N P O T S 5 0 5 F O R M A T C ' , 2 X , 1 2 , 1 X , 1 2 , 1 X , I 3 ) 1 9 C O N T I N U E S C A N = . F A L S E . O V L A Y = . F A L S E . S T E P = . T R U E . T Y P E I I = 0 N D L Y = 1 I P E N = 1 DO 1 1 = 0 , N P O T S I A = 1 I F < O V L A Y ) G O T O 6 C A L L F A C E ( C R T , I ) WR I T E <. C R T , 5 8 0 ) N P O T S 5 0 0 F O R M A T < •• " S C A N N I N G " , I 3 , " D E T E C T E D P O T E N T I A L S . " Z ) I F < T Y P E 1 1 . G T . O ) W R I T E < C R T , 4 9 9 ) T Y P E I I 4 9 9 F O R M A T X 1 3 , " F A L S E D E T E C T I O N S . " , Z ) W R I T E C C R T ) I F C I . G T . 0 ) G O T O 6 C A L L I P L O T ( W N D O W S < - 8 4 , 1 ) , - 1 ) C A L L I P L O T < WNDOWS <. - 8 4 , 0 ) , 1 ) I F < A R G . N E . 3 ) G O T O 4 DO 9 J = - 8 4 , 8 4 I P C J ) = W N D O W S C J , O ) C A L L P F E A T C I P < - 1 0 0 ) , 0 ) GOTO 4 CONTINUE BPOSTN = POS<1,I) POSTN = P0S(2,I) NB = 2 IF (BPOSTN.EQ.0) GOTO 3 BPOSTN = BPOSTN - 1 POSTN = POSTN + 256 HB = 3 IF (BPOSTN.EQ.879> NB = 2 CONTINUE CALL RDBLKCDCHAN, BPOSTN, POTSC0), NB, ERROR) . MB = -ISO ME = 100 IF ((BPOSTN.NE.0).AND.(BPOSTN.NE.379)) GOTO 3 DO 7 J = 85, 100 IP ( J ) = 8 I P ( - J ) = 0 7 CONTINUE IF ((BPOSTN.EQ.8).AND.(POSTN.LT.288)) MB = -84 IF ((BPOSTN.EQ.879).AND.(POSTN.GT.54)) ME = 84 8 CONTINUE DO 2 J = MB, ME 2 I P ( J ) = P0TSCP0STN+2+J) IF (STEP.AND. (ARG.EQ. 1)) CALL I PLOT (WNDOWS(-34,0), 1) IF (STEP. AND. (ARG.EQ. 2)) CALL I PLOT (UNDOUS(-84, 1), 1) CALL I PLOT(IP(-34), I PEN) IF (ARG.EQ.3) CALL PFEAT(IP(-100) , I) IF (STEP.OR.SENSE(M4)) GOTO 4 CALL WAIT(NDL Y, 2, C M HD) GOTO 12 4| CONTINUE ; CALL PLOT(0,YALPHA,0) j CALL ALPHA CALL BELL CMND = " ! OVLAY = .FALSE, i SCAN = .FALSE. STEP = .TRUE. IF ((ARG.HE.O).AND.(ARG.NE.3)) IPEN = -1 WRITE (CRT,502) 502 FORMAT(' ' , ' > ' , Z ) READ (KYBD,503) CMND 583 FORMAT(Al) - IF (CMND.HE."R ") GOTO 11 TYPE 11 = TYPE 11 + 1 IA = 2 GOTO 4 CONTINUE IF CCMND.EQ."* ") GOTO 999 IF CCMND.EQ."S ") SCAN = .TRUE. IF CCMND.EQ."0 ") OVLAY = .TRUE. IF (OVLAY) NDLY = 0 IF (OVLAY) IPEN = -1 IF (OVLAY.OR.SCAN) STEP = .FALSE. 3 C C GET C C i C AND , C I F < < - N . G T . I M A X ) . A N D . < R P O T < - N ) . L E . A H I G H ) ) MHIGH = - N I F ( ( N . L T . I M I N ) . A N D . < R P O T ( N > . G E . A L O W ) ) MLOW = N CONTINUE JERO C R O S S I N G : ZERO = I MAX C A L L F I T N I T ( l l ) C A L L F I T S L P ( I P , Z E R O , I M I N , S L O P E ) THE C O R R E L A T I O N C O E F F I C I E N T (WITH THE AVERAGED T E M P L A T E ) RCC = 9 . 0 DO 4 N = - 8 4 , 84 RCC = RCC + F L O A T ( P O T ( N ) ) * F L O A T ( W N D O W S ( N , 0 ) ) RCC = RCC / 1 6 9 . 0 C C GET C c C SOME C LZDUR = ZERO - MLOW HZDUR = MHIGH - ZERO XZMIN = ZERO - I M I N XZMAX = I MAX - ZERO THE CURVATURES AT THE P E A K S (AND SOME V A L U E S TO P L O T ) : M = LZDUR I F ( M O D ( M , 2 ) . E Q . O ) M = M - 1 N = MLOW + (M - 1) / 2 C A L L F I T N I T ( M ) TEMP = F I T < I P , N ) CRVMIN = F I T C R V ( N , I M I N ) M = HZDUR I F ( M 0 D ( M , 2 ) . EQ. 0 ) M = M - 1 N = MHIGH - (M - 1 ) / 2 C A L L F I T N I T ( M ) TEMP = F I T ( I P , N ) CRVMAX = F I T C R V ( N , I MAX) P L O T T I N G R O U T I N E S FOR C H E C K I N G : I F ( . N O T . S E N S E ( M 2 ) ) GOTO 9 9 9 X ( 1 ) = MLOW + 8 4 X ( 2 ) = MHIGH + 84 Y ( 1 ) = I F I X ( A L O W ) Y ( 2 ) = I F I X ( A H I G H ) X ( 3 ) = I M I N + 84 X ( 4 ) = I MAX + 8 4 Y ( 3 ) = I F I X ( P M I N ) Y ( 4 ) = I F I X ( P M A X ) X ( 5 ) = ZERO + 84 Y ( 5 ) = - 1 6 X ( 6 ) = ZERO + 84 Y ( 6 ) = 16 10 DO 10 I ' = 1, 6 I F F = I S I G N ( 3 2 I XX = I X ( I ) * C A L L P L O T ( I X X , I YY = I Y ( I ) / C A L L P L O T ( I X X , CONT INUE , I Y ( I ) ) 6 + 6 ( Y P L T - I F F ) , 0 ) 4 + Y P L T + I F F I Y Y , 1 ) I YY = - I F I X ( S L O P E + X Z M I N ) / 4 + Y P L T I XX = 6 * ( I M I N + 8 4 ) + 6 C A L L P LOT < I X X , I Y Y , 0 ) 2 ^ 4 -I YY = I F I X ( S L O P E * X Z M A X ) / 4 + Y P L T I XX = 6 + ( I MAX + 8 4 ) + 6 C A L L P LOT < I X X , I YY , 1 ) C C A L L P LOT ( 8 , Y A L P H A , 0 > C A L L A L P H A W R I T E ( C R T , 5 0 1 ) NPOT, RCC , L Z D U R , P M I N , X Z M I N , C R V M I N , H Z D U R , PMAX, XZMAX , CRVMAX, ZERO , S L O P E 5 0 1 FORMAT( ' ' , 1 3 , 3 X , E 1 2 . 5 , I X , 1 3 , 3X , E l 1 . 4 , I X , 1 3 , I X , E l 1. 4> / " ' , 5X , 1 3 , I X , E l 1. 4 , I X , 13 , I X , E l 1. 4 , 3X , 1 3 , I X , E l 1. 4 ) C C 9 9 9 CONT INUE RETURN END ! t?S 't>8- = N £ Oil 0 t>8 = H3IHW XWWd * ££ "0 = H D I H H fr8- = PIOIW N l W d * ££ '0 = I'lOiy 0 ! N O i i y a n a „ i y i o i . . 130 o 3 c i - ' c t > 8 - > i o d a > i o i d a n y o <<3w>3SN3s> J I a o d N ' i d 3 ) 3 o y d mwo cc£w>3SN3s> J I 3 3 f l H I l N 0 3 2 N = NIWI <H>10dd = N l k l d Z 0100 CNIWd "10 " OJ>10dd> J I x y w i • • t '3 - = H z o a 3 3 f l H I l H 0 3 I N = xywi d W 3 i = x y w d I 0 1 0 3 CXyWd ' 3 1 dW31> J I C d W 3 1 > X U I = <N ) d I dW31 = CN>10dd CN ' 1 0 d >11J = dW31 t-8 't>8- = N I OH C I O I I N I I J i i y o 3 3 S Z 3 0 i - = x y w d S Z 3 8 • I = N l W d t>s = x y w i t?3- = NIWI 3 : S N 0 i i y 3 0 i a n y - s d w y » y 3 d ' i s a u 3 3 • 0 * i 0 2 / - d i y i y a 3 l O l d l ' 3 S N 3 S ' 3 3 y d ' l o a w A S - l o i d ' y H d i y 'loida ' d i s i u ' A a 3 i u ' i u ' I I N I U l y n a s i x s 3 3 CC66I2>0W3'C001->dl > 'C <00fr2)DW3 '<t-8-> 10dd) 33N3iyA1003 3d01S '0d3Z 'XyWAdO •xywzx - xywd 'armzH 'NiwAao 'NIWZX 'Niwd ' a n a z i ' 3 3 a / s a i y 3 J / S P10 a N Pi ' • W 3 / 3 3 d 3 W 3 / N 0 W W 0 3 3 3SN3S l y o i o o i xywzx 'NIWZX 'oasz 'annzH 'anazi 'COOT : 0 0 1 - ) d i 'C3>AI '<9>XI 'CS :0 't-8 :fcS-)SPlOiINPi 'CS60fr :0)OW3 ' C 001 :001 - > lOd d3D31NI c t > 8 : t s - ) i o d a i y 3 a o :+: + + + :+=:+:+: :f-:+:+ + + + + * + + + + * * + * * # *:+: * * * * + * :+: + :+;:+:+• + + :+: + :+::+::+.••+ s|c+ + + + + + 3 3 cio d N ' i o d ) i y 3 J d 3Niinoaans 3 :+::+:+.* * * + + . + '+.+.* + '+ + + + 4 ^ + *: + * + + :+: + * * Q 3 6S=NyH3J '00S = SlOdW '^000300 = SW ')»000020 = 2W '>i0000I0 = £W '•t?*t?=iidA 'ss=yHdiyA '2i=idi 'ii=aaA» '0i=iao asiswyaya 3 t>"9'08 3 I F ( S C A N ) I P E N = 1 C 12 CONTINUE I F ( A R G . N E . 3 ) GOTO 1 WRI TE ( F C H A N , 501 ) I , RCC , L Z D U R , P M I N , X Z M I N , C R V M I N , HZDUR, P M A X , X Z M A X , C R V M A X , ZERO , S L O P E , I A 5 8 1 FORMAT( ' ' , 13 , I X , E l 2 . 5 , I X , 1 3 , I X , E l 2 . 5 , I X , 1 3 , I X , E l 2 . 5 , ' , 13 , I X , E l 2 . 5 , I X , 1 3 , I X , E l 2 . 5, I X , 1 3 , 1X, E 1 2 . 5 , 1X , 1 2 ) C 1 CONTINUE •TEMP = F L O A T ( T Y P E I I ) / F L O A T ( N P O T S ) * 1 0 0 . 0 I F ( S T E P ) GOTO 5 C A L L P L O T ( 0 , Y A L P H A , 0 ) C A L L A L P H A C 5 CONT INUE W R I T E ( C R T , 5 0 4 ) T Y P E I I , NPOTS , TEMP 5 8 4 FORMAT ( ' 0 ' ' , 1 0X , " - - F I N I S H E D ! " , I 3 , " OF THE " , I 3 , " D E T E C T I O N S ( " , F 6 . 2 , " * ) WERE R E J E C T E D ! " , / • ' ' ) C 333 CONT INUE I F ( A R G . E Q . 3 ) C A L L F C L O S ( F C H A N ) RETURN END C 8 9 . 5 . 2 7 C PARAMETER DCHAN=62, CRT=10, KYBD=11, LPT=12, MPOTS=200, M1=100000K, M2=020000K C C SUBROUTINE FITNIT CM) C C INTEGER T l , T2, T3, EMGCO:4095) REAL PlC-84:84>, P2C-84:84), P3C-84:84) C COMMON /EMGREC/EMG /FITREC/M12, NM12, T3, GO, Gl, G2, G3, DO, DI, D2, D3 C EQUIVALENCE CP1C-84),EMGC108O)), CP2C-84),EMGC14O0)), CP3C-84). , EMGC1800) ) M12 = (M-l) / 2 NM12 = -M12 RM = FLOAT CM) RMSQ = RM .* RM RMM1 = RM - 1.0 T2 = CRMSQ - 1.0) / 12. 0 T3 = C3.0 + RMSQ - 7 .0) / 20.0 DO = RM DI = CRMM1++3 / 12.0 + RMM1++2 D2 = 0. 0 D3 = 0 . 0 DO 1 I = NM12, Ml 2 RI = FLOAT CI) c RI2 = RI + RI - T2 RI3 = RI + CRI * RI - T3) D2 = D2 + RI2 * RI2 D3 = D3 + RI3 * RI3 P1CI) = RI P2CI) = RI2 P3CI) = RI3 1 CONTINUE RETURN END C 8 0 . 5 . 2 7 C PARAMETER DCHAN=62 , C R T = 1 0 , K Y B D = 1 1 , L P T = 1 2 , MPOTS=200 , M 1 = 1 0 0 0 0 0 K , M 2 = 0 2 0 0 0 0 K , M 5 = 0 0 2 0 0 0 K C fj * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * C FUNCT ION F I T <POT, K> C C * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * c : INTEGER P O K - 1 0 0 : 1 0 0 ) , T 3 , EMG<0=4095> C REAL P l < - 8 4 : 8 4 > , P 2 0 8 4 : 8 4 > , P 3 < - 8 4 : 8 4 > C COMMON /EMGREC' - 'EMG .•••"FITREC'"M 1 2.. NM12, T 3 , GO, G l , G2 , G 3 , DO, D I , D2 , D3 C EQUI V A L E N C E < P 1 < - 8 4 ) , E M G < 1 0 0 0 > ) , iP2 < - 8 4 ) , E M G <1400>>, CP3 < - 3 4 ) , E M G <1300 > > C C C GO = 0 G l = 0 G2 = 0 G3 = 0 DO 1 I = NM12 , M12 TPOT = FLOAT<POT< I+K>> GO = GO + TPOT G l = G l + P K I ) * TPOT G2 = G2 + P 2 < I ) * TPOT G3 = G3 + P 3 < I ) * TPOT 1 CONT INUE C C GO = G9 / DO G l = G l •-' DI G2 = G2 / D2 G3 = G3 D3 F I T = GO + G c RETURN END C 8 8 . 5 . 2 9 C PARAMETER M2=0200O0K, YPLT=444, M5=082000K C + + + + + + + + + + + + +:+: :+: :+i + ^ :+: + :+::+: >f: +^: * + + + * +: + + + + + + * * Jf: ^  + >f: ;f: + C FUNCTION FITCRV <N, M> C Q** * + + * + + + >(c + + + + + * + + + + + + * + + + + + * + + + c 1 INTEGER T3, EMG<0:4095) REAL P l<-84:84) , P2<-84:34), P3<-84:84) C COMMON /EMGREC/EMG /FITRECVM12, NM12, T3, GO, G l , G2, G3 LOGICAL SENSE C EQUIVALENCE «C P 1<-84 ), EMG < 1000 ) ) , < P2 C-84 ), EMG < 1400 ) ), < P3 <-84),EMG <1800 ) > EXTERNAL SENSE, PLOT C C ACRV = 2.0 * G2 + 6.0 * G3 * FLOAT<M-N> I = M - N J = M - N RM = 0. 0 J CONTINUE 1 = 1 + 1 J = J - 1 IF < <I.GT.M12 ) .OR. < J . LT.NM12 >) GOTO 2 AT = 2.0 * G2 + 6.0 * G3 * FLOAT<I) BT = 2.0 * G2 + 6.0 * G3 * FLOAT<J) IF <SENSE<M5)) WRITE <12) I, J , RM, AT, BT, ACRV IF < < < AT.LE.O.O ) .OR. < BT.LE.&. O ) ) .AND. <ACRV.GE.0.8)) GOTO 1 IF < C (AT. GE. O. 0> . OR. <BT. GE. O. 0) ) . AND. (ACRV. LE.xO. 0> ) GOTO 1 RM = RM + l.O ACRV = ACRV + AT + BT GOTO 1 C 2 CONTINUE IF (.NOT.SENSE<M2)) GOTO 4 IFF = 0 DO 3 J = NM12, M12 IY = IFIXCGO + Gl * P K J ) + G2 * P2<J) + G3 * P3<J)) IY = IY / 4 + YPLT IX = (.J + N + 84 > * 6 + 6 CALL PLOT< IX, IY, IFF) IFF = 1 3 CONTINUE C 4 CONTINUE F.ITCRV = ACRV / <2.0 * RM + 1.0) C RETURN END C 8Q.6.4 C PARAMETER DCHAN=62, CRT=10, KYBD=11, LPT=12, MPOTS=200> M1=100000K, M2=020000K C Q*************** ************* ****************************************** r C SUBROUTINE FITSLP U P , ZERO, ZMIN, SLOPE ) C £**********************************************************************; C INTEGER T3, EMG (0:4095), IP(-100 s 100), ZERO, ZMIN REAL Pl<-34:84), P2C-84-. 84), P3<-34:84) C COMMON /EMGREC/EMG /F ITREC/M12, NM12, T3, GO, G l , G2, G3 C EQUI VALENCE ( P1 <. -84 ), EMG < 1000 ) ), < P2 < -84 ), EMG C 1400) ), <P3<-84),EMG<1800)) C EXTERNAL FIT YNEW = -1.0E75 CONTINUE YOLD = YNEW YNEW = FITCIP,ZERO) IF < (. <YOLD. GE. O. ) . AND. < YNEW . LT. 0. ) ) . OR. (ZERO. LE. ZM IN)) GOTO 2 ZERO = ZERO - 1 GOTO 1 CONTINUE SLOPE = Gl - G3 * T3 RETURN END C 8 0 . 5 . 1 2 C C C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * c S U B R O U T I N E R P L O T ( V , I P E N ) C Q * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * : C C T H I S R O U T I N E P R O D U C E S A L A R G E P L O T OF T H E R E A L D A T A IN A R R A Y • " V " ON T H E C T E K T R O N I X 4 0 1 0 . . C R E A L V < 1 : 1 6 9 ) I N T E G E R I V < 1 , 1 6 9 ) C E X T E R N A L I P L O T C C DO 1 I = 1, 169 1 I V U ) = I F I X < V < I ) ) C C A L L I P L O T < I V , I P E N ) C R E T U R N END C 1 2 0 . 5 . 9 B02. C c PARAMETER YALPHA=172, CRT=10, YPLT=444 C C | + + + + + * + + + + + + + c SUBROUTINE IPLOT (IV,IPEN) C C C THIS ROUTINE PRODUCES A LARGE PLOT OF THE INTEGER DATA IN ARRAY "IV" ON THE C TEKTRONIX 401O. . C | INTEGER IV< 1 •. 169) C C C EXTERNAL PAGE, PLOT, ALPHA, BELL CALL PLOT<1023,YPLT, O) CALL PLOTCO,YPLT,1) IX = 6 IY = IVC1) / 4 + YPLT CALL PLOT C IX, IY, 0) DO 2 1=1,169 IY = IVCI) / 4 + YPLT CALL PLOT<IX,IY,IPEN) IX = IX + 6 2 CONTINUE CALL PLOTC0,YALPHA,O) CALL ALPHA RETURN END C 303 F.4 M i s c e l l a n e o u s Support Routines PAGE -- subroutine to "page" the output d e v i c e , and wr i t e a heading at the top of the new "page". WTCHAR — subroutine t o input one c h a r a c t e r from T e k t r o n i x 4010 gr a p h i c s t e r m i n a l . SENSE — subroutine to sense the p o s i t i o n s of the NOVA 840 f r o n t panel switches. DAOUT -- subroutine f o r w r i t i n g b i n a r y data to A/Ds attach e d to the NOVA 840. TEKPLT — sub r o u t i n e s f o r p l o t t i n g on the T e k t r o n i x 4010 gr a p h i c s t e r m i n a l . DRERR -- subroutine f o r p r o c e s s i n g run-time e r r o r s . EMG.ER -- l i s t i n g of e r r o r message f i l e . S U B R O U T I N E P A G E ( C H A N , N O ) T H I S ROUT INE P A G E S THE D E V I C E A S S I G N E D TO CHANNEL ' C H A N ' * AND WRITES A HEADER . INTEGER T D A T E ( 3 ) , T T I M E C 3 ) , ERROR, I , CHAN, NO COMMON / D A D A T A / T D A T E , T T I M E E X T E R N A L E R A S E DATA TDATE /3*©/ -I F ( C H A N . E Q . 1 0 ) C A L L E R A S E I F ( T D A T E C 3 ) . E Q . 0 ) C A L L D A T E ( T D A T E , E R R O R > C A L L T I M E ( T T I M E , ERlROR) I F ( N O . L T . O ) GOTO 1 W R I T E ( C H A N , 1 0 ) ( T T I M E ( I ) , I = 1, 3 ) , T D A T E ( 2 ) , T D A T E ( 1 ) , T D A T E ( 3 ) , NO GOTO 2 CONT INUE WRI TEC CHAN, 1 0 ) ( T T I M E ( I ) , 1 = 1 , 3 ) , TDATE ( 2 ) , TDATE ( 1 ) , TDATE ( 3 ) CONT INUE FORMAT ( ' 1 ' , ' TOWARDS R E A L T I M E E . M . G . A N A L Y S I S . ' , 5 X , 12 , ' .- ' , 1 2 , 12 , 5X , 1 2 , ' • • " , 1 2 , '•••", 12 , T 6 9 , 1 3 ) RETURN END . T I T L E . E N T . E X T D . N R E L C H A R A S M WTCHAR, S E N S E . C P Y L , . F R E T , V A R I O U S C H A R A C T E R I / O R O U T I N E S . F A R L ; F O R T R A N C A L L A B L E R O U T I N E S . S U B R O U T I N E WTCHAR <CHAR) T H I S ROUT INE I N P U T S ONE CHARACTER FROM C O N S O L E . T H E CHARACTER READ I S RETURNED V I A THE I N T E G E R ' C H A R ' . . F S O . = 1 CHAR = - 1 6 ? U T C H A R : FSO . J S R SUB . S Y S T E M .GCHAR JMP STA JMP 0 . C P Y L 0, 0 UERR O, 0CHAR , 3 @ . FRET GET CHARACTER . S U S P E N D TASK U N T I L . RETURN C H A R A C T E R . i F U N C T I O N S E N S E ( M A S K ) > T H I S ROUT INE READS THE FRONT P A N E L S W I T C H E S , AND RETURNS ' . T R U E . ' i I F THE SWITCHES I N D I C A T E D BY MASK ARE UP . F S 1 . F L A G MASK 2 - 1 6 7 F LAG+1 S E N S E : T R U E : FS1 . J S R SUB LDA READS AND LDA STA JMP 1 7 7 7 7 7 @ . F A R L 2, 2 1, 0MASK , 3 0 1, 0, SZR 2, TRUE 2, O F L A G , 3 0 . F R E T ' 0 0 0 0 0 0 ' = ' . F A L S E . ' . GET B I T MASK. READ S W I T C H E S . C H E C K ' I F B I T S ARE S E T . B I T S ARE S E T => RETURN ' . T R U E . RETURN F L A G . ' . T R U E . ' . UERR : . S Y S T E M . ERTN ERROR R E T U R N . RETURN TO NEXT L E V E L WITH ERROR CODE. END . T I T L DAOUT .ENT DAOUT .EXTD .FRET* .CPYL .TXTM 1 . NREL WRITTEN BY GARY KENWARD AND F R A N C I S OMORUTO, UBC/ 1 9 8 8 F E B DAOUT - T H I S R O U T I N E I S C A L L E D TO OUTPUT THE I N T E G E R S I X AND I Y TO THE D/A'S X AND Y R E S P E C T I V E L Y . C A L L D A O U T C I X , I Y ) X=-167 Y = X+1 F S 1 . = 2 D A O U T : F S 1 . J S R LDA LDA DOA DOB J S R . END @.CPYL 8, @X, 3 1, @Y, 3 0, 4 4 1, 44 0.FRET ; GET X JGET Y ; OUTPUT X TO D/A CONV. X. ; OUTPUT Y TO D/A CONV. Y. ;RETURN. .TITL TEKPLT .ENT CURSOR,PLOT, ALPHA, ERASE,SYMBOL,BELL .EXTD .FRET,.CPYL .TXTM 1 . NREL RELEASE 2 7 2 - M A Y - l l COPYRIGHTED BY TEKTRONIX, INC. 1972 CHANGED BY BERT PIEKE, UBC, SEPT. 1972 CHANGED BY GARY KENWARD AND FRANCIS OMORUTU, UBC, SEPT. 1979. ALPHA - SUBROUTINE TO FORCE THE TEKTRONIX 4010 DISPLAY TO ALPHA NUMERICS MODE. THE ROUTINE IS FORTRAN CALLABLE VIA THE NORMAL FORTRAN CALL SEQUENCE. THERE ARE NO STACK PARAMETERS PASSED TO ALPHA. 0 JSR 0. CPYL I N I T I A L I Z E FORTRAN STACK ETC LDA O, ALMO JSR CHOUT .; SEND <37> (US) TO TEKTRONIX JSR 0.FRET i ERASE - SUBROUTINE TO ERASE THE TEKTRONIX 4O10 DISPLAY SCREEN. THE ROUTINE IS FORTRAN CALLABLE VIA THE NORMAL FORTRAN CALL SEQUENCE. THERE ARE NO STACK PARAMETERS PASSED TO ERASE. 0 JSR 0.CPYL ; I N I T I A L I Z E FORTRAN CALL LDA 0,EEE JSR CHOUT ;SEND <33> AND <14> TO TEKTRONIX JSR 0.FRET iRETURN TO FORTRAN .TXT "<33><14>" BELL - TO RING THE BELL ON THE TEKTRONIX, THIS ROUTINE IS FORTRAN CALLABLE VIA THE NORMAL FORTRAN CALLING . SEQUENCE THERE ARE NO STACK PARAMETERS PASSED TO BELL. JSR fJ.CPYL ; INIT CALL FROM FORTRAN LDA 0,BEL JSR CHOUT ; SEND ( 7 ) (BEL) (CONTROL G) TO TEK. JSR 0.FRET , RETURN TO FORTRAN. .TXT "<7><?>" SYMBOL - SUBROUTINE TO WRITE ASCII TEXT ON THE TEKTRONIX DISPLAY SCREEN AT A SPECIFIED X,Y LOCATION ON THE SCREEN. THE X CO-ORDINATE MUST BE WITHIN THE RANGE OF 0 - 1023 AND THE Y CO-ORDINATE WITHIN THE RANGE OF 0 - 780. THE ROUTINE AT EXIT LEAVES THE AND P A S S E S 3 P A R A M E T E R S V I A THE R U N T I M E S T A C K . 3 e>¥ C A L L S Y M B O L C X , Y , S T R I N G ) X AND Y MUST BE I N T E G E R S AND S T R I N G , ALTHOUGH C O N T A I N I N G A S C I I T E X T , I S AN I N T E G E R T Y P E V A R I A B L E . X X = - 1 6 7 YY=XX+1 P ? = YY+1 r 3 . =3 . 'MBOL: J SR e.C P Y L ; I N I T I A L I Z E FORTRAN C A L L LDA O, 0 X X , 3 ; G E T X C O - O R D I N A T E STA 0 , T P T X LDA 0 , @YY, 3 ; G E T Y C O - O R D I N A T E STA 0, T P T Y SUB 0 , O ; F O R C E TO DARK VECTOR STA 0 , TPMOD LDA 1, BP , 3 C A L C U L A T E B Y T E P O I N T E R STA 1, B Y T P J SR T P L O T ; P L O T DARK VECTOR TO X , Y LDA 0, ALMO J SR CHOUT ; P U T INTO A L P H A MODE. UNPAC -U N P A C ; LDA LDA I S Z LDA AND* AND J SR LDA AND J SR S U B R O U T I N E TO UNPAC A S C I I T EXT FROM A T E X T B U F F E R . UNPAC R E Q U I R E S THE I N I T I A L I Z A T I O N OF B Y T F , THE B Y T E P O I N T E R B E F O R E ENTRY . AT E X I T , CHARACTER W I L L BE I N AC0 2 , B Y T P 0 , 0, 2 B Y T P i 1, U P B Y T E 0 , 1, SNR 1, O CHOUT 1 , L W B Y T E 1, 0, SNR 0 . F R E T ; G E T B Y T E P O I N T E R ; G E T DATA WORD i INC B Y T E P O I N T E R LOAD MASK FOR UPPER B Y T E . MASK AND S K I P ON N O N - Z E R O R E S U L T . MASK OFF LOWER B Y T E FOR NULL OUTPUT . LOAD MASK FOR LOWER B Y T E . MASK AND S K I P ON N O N - Z E R O R E S U L T . RETURN WHEN NULL B Y T E ENCOUNTERED . JMP UNPAC ALMO .• . T X T U P B Y T E : 1 7740O L W B Y T E : 3 7 7 B Y T P : O CHOUT - A S S E M B L E R S U B R O U T I N E TO OUTPUT A CHARACTER TO THE T E K T R O N I X D I S P L A Y . THE C H A R A C T E R S TO BE OUTPUT ARE I N THE ACCUMULATOR . THE H IGHER BYTE I S OUTPUT F I R S T . .ERRT: MOVS 0, 0 .3YSTM .PCHAR JMP 0.ERRT MOVS 0, 0 .SYSTEM .PCHAR JMP 0.ERRT LDA 3,CCAC3 jRESTORE A C 3 JMP 0,3 ; RETURN ERRET ; SWAP FOR U P P E R B Y T E O U T P U T F I R S T . ; W R I T E CHAR ' AND, NOW FOR THE N E G L E C T E D LOWER B Y T E . "5 0<\ PLOT - T H I S ROUTINE I S C A L L E D TO PLOT I N L I N E A R I N T E R P O L A T E ( V E C T O R ) , P O I N T PLOT MODE DEPENDING ON THE V A L U E OF THE I P E N PARAMETER I F I P E N = 0 I N I T I A L I Z E AND DARK VECTOR TO X,Y > O B R I G H T VECTOR TO X,Y < 0 P O I N T PLOT TO X,Y C A L L PLOT< I X , IY, I P E N ) X=-1S7 Y = X+1 I=Y+1 F S 1 . = 3 F S 1 . PLOT : TPLOT: TPTDV: T P T N R : J S R 0 . C P Y L LDA 0, @X, 3 ; GET X ST A 0, T P T X LDA 0, @Y, 3 ;GET Y STA 0, TPTY LDA 0, 0 1 , 3 J G E T I P E N STA 0,TPMOD J S R TPLOT ;GO PLOT I T J S R @.FRET ;RETURN TO FORTRAN STA 3, P L R T N ;SAVE RETURN ADDRESS MOV 0, 0, SNR ; I P E N = 0 ? JMP TPTDV ; Y E S MOVZL# 0, 0, SNC i I P E N >0? JMP TPTNR > YES, B R I G H T VECTOR LDA 0, GRM i SET G R A P H I C S MODE. J S R CHOUT JMUST BE DARK VECTOR LDA 0, T P T X MOVL# Q,-0, SZC SUB 0/0 LDA 3 , D 1 0 2 3 SUBL# 3, 0, SNC MOV 3, 8 STA 0, TPTX LDA 0, TPTY /GET Y MOVLtt 0, 0, SZC ; S K P I F + SUB 0, 0 M A K E 0 LDA 3 , D 7 8 0 ;UPPER Y BOUND SUBLtt 3, O, SNC ; S K P I F ON S C R E E N MOV 3 , O > S E T T O E D G E S T A 0 , T P T Y ; S A V E G O O D Y M O V Z L 0 , 0 ; U S E U P P E R 5 B I T S M O V Z L 0 , 0 M O V Z L 0 , 0 L D A 2, C 1 7 4 AND 2 , 0 L D A 2 , B 2 0 K A D D 2, 0 L D A 1 , T P T Y ; G E T Y L D A 3 , C 3 7 J M A S K A N D 3 , 1 ; L E A V E L O U Y 5 L D A 3 , B 1 4 0 J L O W Y T A G A D D 3 , 1 J S E T I N C H A R A D D 1, 0 J SR C H O U T ; S H I P L O U Y L D A O , T P T X > G E T X V A L U E M O V Z L 0 , O J A N D DO L I K E Y M O V Z L 0 , O M O V Z L 0 , O L D A 2 , C 1 7 4 A N D 2 , 8 L D A 3.. B 2 0 K ; H I X T A G A D D 3 , O J A D D I N T A G L D A 1 , T P T X G E T X L D A 3 .i C 3 7 J G O O D I E M A S K A N D 3 , 1 L E A V E L O U X 5 L D A 3 , B 1 O 0 LOW X T A G A D D 3 , O J P U T IN TAG A D D 1 , 0 J SR C H O U T L D A O, T P M O D ; P O I N T P L O T M O D E ? MOVLtt O, O , S N C JMP 0 P L R T N J D O N E , R E T U R N S U B Z L 0 , 0 ; S E T F O R B R I G H T VI S T A 0.. T P M O D JMP T P T N R CONSTANTS AND V A R I A B L E S C C A C 0 : C C A C 3 : P L R T N : C 3 7 : C 1 7 4 : 0 0 0 3 7 1 7 4 0 0 B 2 0 K : B 1 0 0 : B 1 4 0 : 2 0 0 0 0 1 8 8 1 4 8 D 7 3 0 : D 1 0 2 3 : 1 4 1 4 1 7 7 7 T P A C 3 : T P T A D : T P T X : TPjTY : TPMOD: 0 0 0 0 0 CURSOR - T H I S R O U T I N E I S USED FOR G R A P H I C S INPUT. CURSOR F I R S T S E T S T H E 4 9 1 8 TO A L P H A MODE, THEN TO G R A P H I C S I N P U T MODE, AND TURNS ON T H E CURSOR. WHEN A CHARACTER I S T Y P E D THE P O S I T I O N OF THE X,Y COO R D I N A T E S ARE RETURNED ALONG WITH THE CHARACTER. C A L L C U R S O R ? I X , I Y , CHAR) X C 0 = - 1 6 7 YCO=XCO+l CHAR=YCO+l F S 2 . = 3 F S 2 . CURSOR: J S R MOV LDA J S R LDA J S R J S R MOVS STA J S R STA J S R STA J S R 0. C P Y L 3, 2 0, ALM CHOUT 0, CURS CHOUT C H I N 0, 0 0, 0CHAR, 2 CLIRLP 0, @XCO, 2 CU R L P 0, 0YCO, 2 0 . F R E T SE T TO A L P H A TURN ON CURSOR JG E T CHARACTER. SWAP FOR DOS ALM: C U R L P : . TXT STA J S R STA J S R LDA AND STA LDA AND MOVS MOVZR MOVZR MOVZR LDA ADD LDA JMP "<'3?><37>" 3, T P A C 3 C H I N ,• GET H I COORD ;STORE. G E T LOW COORD ; MASK JMASK OFF GARBAGE ;SAVE FOR L A T E R J H I COORD ;MASK OFF SWAP 0, TPT C H I N 3, C 3 7 3, 0 0, T P T Y 0, T P T X 3, 0 0, O 0, O 0, 8 0, 0 3, T P T Y 3, 0 3, T P A C 3 0, 3 ;LOW COORD ••ADD I N LOW COORD •TXT "< 3 5 X 3 5 >" •TXT "<33><32>" i CURSOR TURN ON!! C H I N - A S S E M B L E R R O U T I N E TO R E C E I V E A CHARACTER FROM T E K T R O N I X 4 0 1 0 KEYBOARD. THE R O U T I N E I S C A L L E D FROM CURSOR. C H I N : E R R E T S T A 3 , C C A C 3 ;SAVE A C S . S Y S T M . G C H A R JMP E R R E T LDA 3 , C C A C 3 JMP 6 , 3 ;RETURN TO C A L L + 2 . S Y S T E M . E R T N JMP . - 2 END C, 5/3/89 P A R A M E T E R E R C H N 1 = 6 0 , E R C H N 2 = 5 9 , C R T = 1 0 C C S U B R O U T I N E D R E R R ( P R G E R R , R D O S E R ) C C T H I S I S T H E E R R O R H A N D L I N G R O U T I N E F O R T H E E . M . G . P R O C E S S I N G R O U T I N E S . C C P R G E R R - - R O U T I N E E R R O R C O D E . C R D O S E R — F O R T R A N E R R O R C O D E C R D O S E R R O R C O D E + 3 ) C C C C C C C 7 I N T E G E R T E X T C 3 6 ) , P R G E R R , R D O S E R , I E X T E R N A L B E L L , A L P H A , E R A S E C A L L R E S E T C A L L A L P H A C A L L F O P E N C E R C H N 2 , ' W O R K : E M G . E R ' ) C A L L F O P E N C E R C H H 1 , ' W O R K : U C L I . E R ' ) W R I T E C C R T , 5 ) 5 F O R M A T C ' 0 ' , ' E R R O R A T T E H T I O N ! ' , / ' ' ) I P R G E R = P R G E R R - 1 I R D O S R = R D O S E R - 3 DO 1 1 = 1 , I R D O S R R E A D C E R C H N 1 , 1 0 , E N D = 3 ) T E X T C I ) 1 C O N T I N U E R E A D C E R C H N 1 , 1 0 , E N D = 3 > C T E X T C I ) , 1 = 1 , 3 6 ) UP. I T E C C R T , 2 0 ) R D O S E R , C T E X T C I ) , 1 = 1 , 3 6 ) G O T O 4 C 3 C O N T I N U E T Y P E " U N D E F I N E D F O R T R A N E R R O R C O D E : " , R D O S E R C 4 C O N T I N U E C C DO 2 1 = 1 , I P R G E R R E A D C E R C H N 2 , 1 0 , E N D = 6 ) T E X T C 1 ) 2 C O N T I N U E C R E A D C E R C H N 2 , 1 0 , E N D = 6 ) C T E X T C I ) , 1 = 1 , 3 6 ) WRI T E C C R T , 2 0 ) P R G E R R , C T E X T C I ) , 1 = 1 , 3 6 ) G O T O 7 C 1 0 F O R M A T C 3 6 A 2 ) 2 0 F O R M A T C ' ' , ' C ' , 1 3 , ' 3', 2 X , 3 6 A 2 ) C 6 C O N T I N U E T Y P E " U N D E F I N E D U S E R E R R O R C O D E : " , P R G E R R C O N T I N U E C A L L R E S E T W R I T E C C R T ) "< 7 X 7 >< 7 >< 7 X 7 >< 7 >" C A L L E X I T R E T U R N E N D M T 0 / D P 8 : E M G D A T A I N I T I A L I Z I N G ERROR I N R O U T I N E ' T R A N S F E R ' T A P E CHANNEL OPEN ERROR I N R O U T I N E ' T R A N S F E R ' T A P E STATUS ERROR DUR ING S P A C E FORWARD IN R O U T I N E ' T R A N S F E R ' F O R T R A N TAPE ERROR DUR ING S P A C E FORWARD I N R O U T I N E ' T R A N S F E R ' I N C O R R E C T WORD COUNT DURING HEADER READ IN R O U T I N E ' H E A D E R R E A D ' T A P E STATUS ERROR DUR ING HEADER READ IN R O U T I N E ' H E A D E R R E A D ' F O R T R A N TAPE ERROR DUR ING HEADER READ IN R O U T I N E ' H E A D E R R E A D ' T A P E STATUS ERROR DUR ING S P A C E FORWARD IN R O U T I N E ' H E A D E R R E A D ' F O R T R A N TAPE ERROR DUR ING S P A C E FORWARD IN R O U T I N E ' H E A D E R R E A D ' WORD COUNT ERROR DUR ING DATA READ I N ROUT INE ' D A T A R E A D ' T A P E STATUS ERROR DUR ING DATA READ I N ROUT INE ' D A T A R E A D ' F O R T R A N TAPE ERROR DUR ING DATA READ I N R O U T I N E ' D A T A R E A D ' F O R T R A N D I S K WRITE ERROR I N R O U T I N E ' D A T A R E A D ' DPO :EMGDATA I N I T I A L I Z I N G ERROR IN R O U T I N E ' P R O C E S S ' F O R T R A N D I S K READ ERROR I N R O U T I N E ' D I S P L Y ' 

Cite

Citation Scheme:

        

Citations by CSL (citeproc-js)

Usage Statistics

Share

Embed

Customize your widget with the following options, then copy and paste the code below into the HTML of your page to embed this item in your website.
                        
                            <div id="ubcOpenCollectionsWidgetDisplay">
                            <script id="ubcOpenCollectionsWidget"
                            src="{[{embed.src}]}"
                            data-item="{[{embed.item}]}"
                            data-collection="{[{embed.collection}]}"
                            data-metadata="{[{embed.showMetadata}]}"
                            data-width="{[{embed.width}]}"
                            data-media="{[{embed.selectedMedia}]}"
                            async >
                            </script>
                            </div>
                        
                    
IIIF logo Our image viewer uses the IIIF 2.0 standard. To load this item in other compatible viewers, use this url:
https://iiif.library.ubc.ca/presentation/dsp.831.1-0095332/manifest

Comment

Related Items