comparison saitools/findintervals_sai.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 /*------------------------------------------------------------------------*/
27
28 /* findintervals_sai.c
29 * -----------------------
30 *
31 * M.Akeroyd. Summer 1993. Revised Winter 1994.
32 */
33
34
35 #include <stdio.h>
36 #include <string.h>
37 #include <stdlib.h>
38
39 #include "tip.h"
40
41
42
43 extern struct Peak peak[MAX_PEAKS]; /* all channels */
44 extern short interval[MAX_CHANNELS][MAX_DATA];
45 extern short clip[MAX_CHANNELS];
46
47 extern int weightflag;
48
49
50
51 /*------------------------------------------------------------------------*/
52
53
54 void find_intervals(int total_peaks, int channel, int maximum_interval)
55 {
56 /* WARNING! Reverse */
57
58 int gap_samples;
59 int n;
60
61
62 for(n=2; n <= total_peaks; n++){
63
64 gap_samples = peak[n-1].sample - peak[n].sample;
65 if (gap_samples >= maximum_interval)
66 gap_samples = maximum_interval -1;
67 interval[channel][gap_samples]++;
68
69 /*---------------------------------*/
70 /* weighting options */
71
72 if (weightflag == OFF)
73 interval[channel][gap_samples]++;
74 else if (weightflag == NORMAL_WEIGHTING)
75 interval[channel][gap_samples] += (short) (peak[n-1].mag + peak[n].mag) / 2 ;
76 else if (weightflag == LOG_WEIGHTING)
77 interval[channel][gap_samples] += (short) log((peak[n-1].mag + peak[n].mag)/2)/log(10.0);
78
79 /*---------------------------------*/
80 /* clip check */
81 if ((interval[channel][gap_samples] > 32765) ||
82 (interval[channel][gap_samples] < 0)){
83 if (clip[channel] == OFF) {
84 fprintf(stderr, " \nclipping: channel %i, interval %i samples.\n ", channel, gap_samples);
85 clip[channel] = ON;}
86 interval[channel][gap_samples] = 32765;
87 }
88 }
89 }
90
91
92
93 /* The End */
94 /*------------------------------------------------------------------------*/
95
96
97
98
99