tomwalters@0
|
1 /*
|
tomwalters@0
|
2 Copyright (c) Applied Psychology Unit, Medical Research Council. 1993
|
tomwalters@0
|
3 ===========================================================================
|
tomwalters@0
|
4
|
tomwalters@0
|
5 Permission to use, copy, modify, and distribute this software without fee
|
tomwalters@0
|
6 is hereby granted for research purposes, provided that this copyright
|
tomwalters@0
|
7 notice appears in all copies and in all supporting documentation, and that
|
tomwalters@0
|
8 the software is not redistributed for any fee (except for a nominal
|
tomwalters@0
|
9 shipping charge). Anyone wanting to incorporate all or part of this
|
tomwalters@0
|
10 software in a commercial product must obtain a license from the Medical
|
tomwalters@0
|
11 Research Council.
|
tomwalters@0
|
12
|
tomwalters@0
|
13 The MRC makes no representations about the suitability of this
|
tomwalters@0
|
14 software for any purpose. It is provided "as is" without express or
|
tomwalters@0
|
15 implied warranty.
|
tomwalters@0
|
16
|
tomwalters@0
|
17 THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
tomwalters@0
|
18 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
tomwalters@0
|
19 THE A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
|
tomwalters@0
|
20 OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
tomwalters@0
|
21 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
tomwalters@0
|
22 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
tomwalters@0
|
23 SOFTWARE.
|
tomwalters@0
|
24 */
|
tomwalters@0
|
25
|
tomwalters@0
|
26 /*-------------------------------------------------------------------------*/
|
tomwalters@0
|
27
|
tomwalters@0
|
28 /* matrix.c
|
tomwalters@0
|
29 * ----------
|
tomwalters@0
|
30 *
|
tomwalters@0
|
31 * Writes an interal histogram matrix in two pretty (ascii) formats.
|
tomwalters@0
|
32 *
|
tomwalters@0
|
33 * M. Akeroyd. Summer 1993. Revised Winter 1994.
|
tomwalters@0
|
34 */
|
tomwalters@0
|
35
|
tomwalters@0
|
36
|
tomwalters@0
|
37 #include <stdio.h>
|
tomwalters@0
|
38 #include <string.h>
|
tomwalters@0
|
39 #include <stdlib.h>
|
tomwalters@0
|
40 #include "tip.h"
|
tomwalters@0
|
41
|
tomwalters@0
|
42 extern char progname[MAX_STRING_LENGTH];
|
tomwalters@0
|
43 extern int verboseflag;
|
tomwalters@0
|
44 extern short interval[MAX_CHANNELS][MAX_DATA];
|
tomwalters@0
|
45 extern short summation[MAX_CHANNELS];
|
tomwalters@0
|
46 extern int summationflag;
|
tomwalters@0
|
47
|
tomwalters@0
|
48 extern int frameheight;
|
tomwalters@0
|
49
|
tomwalters@0
|
50
|
tomwalters@0
|
51
|
tomwalters@0
|
52 /*-------------------------------------------------------------------------*/
|
tomwalters@0
|
53
|
tomwalters@0
|
54
|
tomwalters@0
|
55
|
tomwalters@0
|
56 void write_matrix_hori_freq(int framewidth, FILE *outputfigurefp)
|
tomwalters@0
|
57 {
|
tomwalters@0
|
58 /* Format of matrix:
|
tomwalters@0
|
59 *
|
tomwalters@0
|
60 # (Info on file, inclduing name, pwdith, nwidth, mincf etc goes here)
|
tomwalters@0
|
61 # Rows = channels. Columns = intervals (samples)
|
tomwalters@0
|
62 #
|
tomwalters@0
|
63 # Time Interval (samples)
|
tomwalters@0
|
64 # 0 1 2 3 4 5 6 7 8 9 ..... (framewidth-1)
|
tomwalters@0
|
65 # .......................................................................
|
tomwalters@0
|
66 c frameheight
|
tomwalters@0
|
67 h ...
|
tomwalters@0
|
68 a ...
|
tomwalters@0
|
69 n ...
|
tomwalters@0
|
70 n 4
|
tomwalters@0
|
71 e 3
|
tomwalters@0
|
72 l 2
|
tomwalters@0
|
73 s 1
|
tomwalters@0
|
74
|
tomwalters@0
|
75 # ......................................................................
|
tomwalters@0
|
76
|
tomwalters@0
|
77 * ALL comment lines have '#' in them.
|
tomwalters@0
|
78 *
|
tomwalters@0
|
79 * The entries are raw numbers: at the moment, no normalisation has taken
|
tomwalters@0
|
80 * place. So the longer the .sai, the bigger the numbers.
|
tomwalters@0
|
81 *
|
tomwalters@0
|
82 * If the '-s' flag is set, then the row (=channel) sums are printed at
|
tomwalters@0
|
83 * the end of each ROW.
|
tomwalters@0
|
84 *
|
tomwalters@0
|
85 * This version prints "." instead of zeros.
|
tomwalters@0
|
86 */
|
tomwalters@0
|
87
|
tomwalters@0
|
88
|
tomwalters@0
|
89 int channel, sample;
|
tomwalters@0
|
90
|
tomwalters@0
|
91 /* rest of header ... */
|
tomwalters@0
|
92 fprintf(outputfigurefp,"# Rows = channels Columns = intervals (samples)\n");
|
tomwalters@0
|
93 fprintf(outputfigurefp, "# \n");
|
tomwalters@0
|
94
|
tomwalters@0
|
95 /* Top line */
|
tomwalters@0
|
96 fprintf(outputfigurefp, "# ");
|
tomwalters@0
|
97 for (sample=0; sample<framewidth; sample++)
|
tomwalters@0
|
98 fprintf(outputfigurefp, "%5i ", sample);
|
tomwalters@0
|
99 if (summationflag == ON)
|
tomwalters@0
|
100 fprintf(outputfigurefp, " : Sum");
|
tomwalters@0
|
101 fprintf(outputfigurefp, "\n");
|
tomwalters@0
|
102
|
tomwalters@0
|
103
|
tomwalters@0
|
104 /* top tabulation line */
|
tomwalters@0
|
105 fprintf(outputfigurefp, "# ");
|
tomwalters@0
|
106 for (sample=0; sample<framewidth; sample++)
|
tomwalters@0
|
107 fprintf(outputfigurefp, "......");
|
tomwalters@0
|
108 if (summationflag == ON)
|
tomwalters@0
|
109 fprintf(outputfigurefp, "........");
|
tomwalters@0
|
110 fprintf(outputfigurefp, "\n");
|
tomwalters@0
|
111
|
tomwalters@0
|
112 /* Main body: NOTE REVERSE ... */
|
tomwalters@0
|
113 for (channel=frameheight; channel >=1; channel --) {
|
tomwalters@0
|
114 fprintf(outputfigurefp, " %2i: ", channel);
|
tomwalters@0
|
115 for (sample = 0; sample < framewidth; sample++){
|
tomwalters@0
|
116 if (interval[channel][sample] == 0)
|
tomwalters@0
|
117 fprintf(outputfigurefp, " . ");
|
tomwalters@0
|
118 else
|
tomwalters@0
|
119 fprintf(outputfigurefp, "%5i ", interval[channel][sample]);
|
tomwalters@0
|
120 }
|
tomwalters@0
|
121
|
tomwalters@0
|
122 if (summationflag == ON)
|
tomwalters@0
|
123 fprintf(outputfigurefp, " : %5i", summation[channel]);
|
tomwalters@0
|
124
|
tomwalters@0
|
125 fprintf(outputfigurefp, "\n");
|
tomwalters@0
|
126 }
|
tomwalters@0
|
127
|
tomwalters@0
|
128 /* bottom tabulation line */
|
tomwalters@0
|
129 fprintf(outputfigurefp, "# ");
|
tomwalters@0
|
130 for (sample=0; sample<framewidth; sample++)
|
tomwalters@0
|
131 fprintf(outputfigurefp, "......");
|
tomwalters@0
|
132 if (summationflag == ON)
|
tomwalters@0
|
133 fprintf(outputfigurefp, "........");
|
tomwalters@0
|
134 fprintf(outputfigurefp, "\n");
|
tomwalters@0
|
135
|
tomwalters@0
|
136 }
|
tomwalters@0
|
137
|
tomwalters@0
|
138
|
tomwalters@0
|
139
|
tomwalters@0
|
140
|
tomwalters@0
|
141 /*-------------------------------------------------------------------------*/
|
tomwalters@0
|
142
|
tomwalters@0
|
143
|
tomwalters@0
|
144
|
tomwalters@0
|
145
|
tomwalters@0
|
146 void write_matrix_hori_time(int framewidth, FILE *outputfigurefp)
|
tomwalters@0
|
147 {
|
tomwalters@0
|
148 int channel, sample;
|
tomwalters@0
|
149
|
tomwalters@0
|
150 /* Format of matrix:
|
tomwalters@0
|
151 *
|
tomwalters@0
|
152 # (Info on file, inclduing name, pwdith, nwidth, mincf etc goes here)
|
tomwalters@0
|
153 # Rows = intervals. Columns = channels
|
tomwalters@0
|
154 #
|
tomwalters@0
|
155 # Channels
|
tomwalters@0
|
156 # 1 2 3 4 5 6 7 8 ... .... (frameheight)
|
tomwalters@0
|
157 # ..................................................................
|
tomwalters@0
|
158 T
|
tomwalters@0
|
159 i 0
|
tomwalters@0
|
160 m ( 1
|
tomwalters@0
|
161 e s 2
|
tomwalters@0
|
162 a 3
|
tomwalters@0
|
163 I m
|
tomwalters@0
|
164 n p ...
|
tomwalters@0
|
165 t l
|
tomwalters@0
|
166 e e ...
|
tomwalters@0
|
167 r s
|
tomwalters@0
|
168 v ) ...
|
tomwalters@0
|
169 a
|
tomwalters@0
|
170 l (framewidth-1)
|
tomwalters@0
|
171 # .................................................................
|
tomwalters@0
|
172
|
tomwalters@0
|
173 * ALL comment lines have '#' in them.
|
tomwalters@0
|
174 *
|
tomwalters@0
|
175 * The entries are raw numbers: at the moment, no normalisation has taken
|
tomwalters@0
|
176 * place. So the longer the .sai, the bigger the numbers.
|
tomwalters@0
|
177 *
|
tomwalters@0
|
178 * If the '-s' flag is set, then the row (=channel) sums are printed at
|
tomwalters@0
|
179 * the end of each ROW.
|
tomwalters@0
|
180 *
|
tomwalters@0
|
181 * This version prints "." instead of zeros.
|
tomwalters@0
|
182 */
|
tomwalters@0
|
183
|
tomwalters@0
|
184
|
tomwalters@0
|
185 /* rest of Header ... */
|
tomwalters@0
|
186 fprintf(outputfigurefp, "# Rows = intervals (samples) Columns = channels\n");
|
tomwalters@0
|
187 fprintf(outputfigurefp, "# \n");
|
tomwalters@0
|
188
|
tomwalters@0
|
189
|
tomwalters@0
|
190 /* Top line */
|
tomwalters@0
|
191 fprintf(outputfigurefp, "# ");
|
tomwalters@0
|
192 for (channel=1; channel<=frameheight; channel++)
|
tomwalters@0
|
193 fprintf(outputfigurefp, "%5i ", channel);
|
tomwalters@0
|
194 fprintf(outputfigurefp, "\n");
|
tomwalters@0
|
195
|
tomwalters@0
|
196 /* top tabulation line */
|
tomwalters@0
|
197 fprintf(outputfigurefp, "# ");
|
tomwalters@0
|
198 for (channel=1; channel<=frameheight; channel++)
|
tomwalters@0
|
199 fprintf(outputfigurefp, "......");
|
tomwalters@0
|
200 fprintf(outputfigurefp, "\n");
|
tomwalters@0
|
201
|
tomwalters@0
|
202 /* Main body: NOTE forward ... */
|
tomwalters@0
|
203 for (sample = 0; sample < framewidth; sample++) {
|
tomwalters@0
|
204 fprintf(outputfigurefp, " %4i: ", sample);
|
tomwalters@0
|
205 for (channel=1; channel<=frameheight; channel++)
|
tomwalters@0
|
206 if (interval[channel][sample] == 0)
|
tomwalters@0
|
207 fprintf(outputfigurefp, " . ");
|
tomwalters@0
|
208 else
|
tomwalters@0
|
209 fprintf(outputfigurefp, "%5i ", interval[channel][sample]);
|
tomwalters@0
|
210 fprintf(outputfigurefp, "\n");
|
tomwalters@0
|
211 }
|
tomwalters@0
|
212
|
tomwalters@0
|
213 /* bottom tabulation line */
|
tomwalters@0
|
214 fprintf(outputfigurefp, "# ");
|
tomwalters@0
|
215 for (channel=1; channel<=frameheight; channel++)
|
tomwalters@0
|
216 fprintf(outputfigurefp, "......");
|
tomwalters@0
|
217 fprintf(outputfigurefp, "\n");
|
tomwalters@0
|
218
|
tomwalters@0
|
219 if (summationflag == ON) {
|
tomwalters@0
|
220 fprintf(outputfigurefp, "#\n");
|
tomwalters@0
|
221 fprintf(outputfigurefp, "# Sum: ");
|
tomwalters@0
|
222 for (channel=1; channel<=frameheight; channel++)
|
tomwalters@0
|
223 fprintf(outputfigurefp, "%5i ", summation[channel]);
|
tomwalters@0
|
224 fprintf(outputfigurefp, "\n");
|
tomwalters@0
|
225 }
|
tomwalters@0
|
226 }
|
tomwalters@0
|
227
|
tomwalters@0
|
228
|
tomwalters@0
|
229
|
tomwalters@0
|
230
|
tomwalters@0
|
231 /* The End */
|
tomwalters@0
|
232 /*-------------------------------------------------------------------------*/
|
tomwalters@0
|
233
|
tomwalters@0
|
234
|
tomwalters@0
|
235
|
tomwalters@0
|
236
|