comparison saitools/findintervals_nap.c @ 0:5242703e91d3 tip

Initial checkin for AIM92 aimR8.2 (last updated May 1997).
author tomwalters
date Fri, 20 May 2011 15:19:45 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:5242703e91d3
1 /*
2 Copyright (c) Applied Psychology Unit, Medical Research Council. 1993
3 ===========================================================================
4
5 Permission to use, copy, modify, and distribute this software without fee
6 is hereby granted for research purposes, provided that this copyright
7 notice appears in all copies and in all supporting documentation, and that
8 the software is not redistributed for any fee (except for a nominal
9 shipping charge). Anyone wanting to incorporate all or part of this
10 software in a commercial product must obtain a license from the Medical
11 Research Council.
12
13 The MRC makes no representations about the suitability of this
14 software for any purpose. It is provided "as is" without express or
15 implied warranty.
16
17 THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
18 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
19 THE A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
20 OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
22 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
23 SOFTWARE.
24 */
25
26 /* findintervals_nap.c
27 *
28 * Part of the temporal interval stuff.
29 * M.Akeroyd Summer 1993. Revised Winter 1994. */
30
31
32 #include <stdio.h>
33 #include <string.h>
34 #include <stdlib.h>
35
36 #include "tip.h"
37
38
39
40
41 extern struct Peak peak[MAX_PEAKS]; /* all channels */
42 extern short interval[MAX_CHANNELS][MAX_DATA];
43 extern short clip[MAX_CHANNELS];
44
45 extern struct Peak peak_nap_right[MAX_CHANNELS];
46 extern struct Peak peak_nap_left[MAX_CHANNELS];
47
48 extern short freqdata[MAX_CHANNELS];
49 extern short previousfreqdata[MAX_CHANNELS];
50 extern short previouspreviousfreqdata[MAX_CHANNELS];
51
52
53
54
55 void find_intervals_nap(int channel, int maximum_interval, int sample)
56 {
57 /* What this code does ..
58 *
59 * It looks at the current .nap point. If it's < the previous point,
60 * AND the previous point is >= the one before that, then the PREVIOUS
61 * point is marked as a peak: peak_nap_right[channel].sample = previous
62 * peak_nap_left[channel] = peak_nap_right ..
63 * Then it measures the interval between these two points.
64 * If they are less than the maximum interval, then yippee ...
65 *
66 * The peaks so defined are neither "simple" or "complex", but an
67 * amalgam. A real "complex" peak has its true top interpoltaed. None
68 * of that goes on here. The right-most edge of the plateau
69 * is used ...
70 *
71 * Finally, it moves the columns one notch leftwards.
72 */
73
74 int gap_samples;
75
76
77
78
79 if ((freqdata[channel] < previousfreqdata[channel]) &&
80 (previousfreqdata[channel] >= previouspreviousfreqdata[channel])) {
81
82 /* this is a peak */
83 peak_nap_left[channel].sample = peak_nap_right[channel].sample;
84 peak_nap_right[channel].sample = sample-1;
85 /* -1 beacuse its the prevoius point */
86
87 /* don't want to do any of this if this is the FIRST peak of any
88 * channeL; ie, ...left[].sample == 0
89 */
90 if (peak_nap_left[channel].sample != 0 ) {
91 gap_samples = peak_nap_right[channel].sample - peak_nap_left[channel].sample;
92 if (gap_samples >= maximum_interval)
93 gap_samples = maximum_interval -1;
94 interval[channel][gap_samples]++;
95
96 /* clip check */
97 if (interval[channel][gap_samples] > 32760) {
98 if (clip[channel] == OFF) {
99 fprintf(stderr, " \nclipping (%i %i) ", channel, gap_samples);
100 clip[channel] = ON;}
101 interval[channel][gap_samples] --;
102 }
103 }
104 } /* is this a peak? 'if' */
105
106 /* move everything across anyway */
107 previouspreviousfreqdata[channel] = previousfreqdata[channel];
108 previousfreqdata[channel] = freqdata[channel];
109
110 }
111
112
113
114
115
116
117 /* The End ................................................................*/
118 /*.........................................................................*/
119