diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/app/rdsamp.c wfdb-10.4.13/app/rdsamp.c --- wfdb-10.4.12/app/rdsamp.c 2009-01-07 13:36:00.000000000 -0500 +++ wfdb-10.4.13/app/rdsamp.c 2009-02-15 22:56:51.000000000 -0500 @@ -1,5 +1,5 @@ /* file: rdsamp.c G. Moody 23 June 1983 - Last revised: 7 January 2009 + Last revised: 15 February 2009 ------------------------------------------------------------------------------- rdsamp: Print an arbitrary number of samples from each signal @@ -28,30 +28,13 @@ #include #include -/* Define the default WFDB path for CD-ROM versions of this program (the MS-DOS - executables found in the `bin' directories of the various CD-ROMs). This - program has been revised since the appearance of these CD-ROMs; compiling - this file will not produce executables identical to those on the CD-ROMs. - Note that the drive letter is not included in these WFDB path definitions, - since it varies among systems. - */ -#ifdef MITCDROM -#define WFDBP ";\\mitdb;\\nstdb;\\stdb;\\vfdb;\\afdb;\\cdb;\\svdb;\\ltdb;\\cudb" -#endif -#ifdef STTCDROM -#define WFDBP ";\\edb;\\valedb" -#endif -#ifdef SLPCDROM -#define WFDBP ";\\slpdb" -#endif -#ifdef MGHCDROM -#define WFDBP ";\\mghdb" -#endif - /* values for timeunits */ -#define SECONDS 1 -#define MINUTES 2 -#define HOURS 3 +#define SECONDS 1 +#define MINUTES 2 +#define HOURS 3 +#define TIMSTR 4 +#define MSTIMSTR 5 +#define HHMMSS 6 char *pname; @@ -59,46 +42,17 @@ int argc; char *argv[]; { - char *record = NULL, *prog_name(); + char *record = NULL, *search = NULL, *prog_name(); int highres = 0, i, isiglist, nsig, nosig = 0, pflag = 0, s, *sig = NULL, timeunits = SECONDS, vflag = 0; - long from = 0L, maxl = 0L, to = 0L; + WFDB_Frequency freq; WFDB_Sample *v; WFDB_Siginfo *si; + WFDB_Time from = 0L, maxl = 0L, to = 0L; void help(); -#ifdef WFDBP - char *wfdbp = getwfdb(); - if (*wfdbp == '\0') - setwfdb(WFDBP); -#endif - pname = prog_name(argv[0]); - - /* Accept old syntax. */ - if (argc >= 2 && argv[1][0] != '-') { - record = argv[1]; - i = 2; - if (argc > 2 && argv[2][0] != '-') { - from = 2; - i = 3; - } - if (argc > 3 && argv[3][0] != '-') { - to = 3; - i = 4; - } - if (argc > 4) { - isiglist = 4; - while (i < argc && argv[i][0] != '-') { - i++; - nosig++; - } - } - } - else - i = 1; - - for ( ; i < argc; i++) { + for (i = 1 ; i < argc; i++) { if (*argv[i] == '-') switch (*(argv[i]+1)) { case 'f': /* starting time */ if (++i >= argc) { @@ -130,9 +84,13 @@ } record = argv[i]; break; + case 'P': /* output in high-precision physical units */ + ++pflag; /* (fall through to case 'p') */ case 'p': /* output in physical units specified */ ++pflag; - if (*(argv[i]+2) == 'h') timeunits = HOURS; + if (*(argv[i]+2) == 'd') timeunits = TIMSTR; + else if (*(argv[i]+2) == 'e') timeunits = HHMMSS; + else if (*(argv[i]+2) == 'h') timeunits = HOURS; else if (*(argv[i]+2) == 'm') timeunits = MINUTES; else timeunits = SECONDS; break; @@ -148,6 +106,16 @@ exit(1); } break; + case 'S': /* search for valid sample of specified signal */ + if (++i >= argc) { + (void)fprintf(stderr, + "%s: signal name or number must follow -S\n", + pname); + exit(1); + } + search = argv[i]; + break; + case 't': /* end time */ if (++i >= argc) { (void)fprintf(stderr, "%s: time must follow -t\n",pname); @@ -185,16 +153,13 @@ if (si[i].gain == 0.0) si[i].gain = WFDB_DEFGAIN; if (highres) setgvmode(WFDB_HIGHRES); + freq = sampfreq(NULL); if (from > 0L && (from = strtim(argv[from])) < 0L) from = -from; if (isigsettime(from) < 0) exit(2); if (to > 0L && (to = strtim(argv[to])) < 0L) to = -to; - if (maxl > 0L && (maxl = strtim(argv[maxl])) < 0L) - maxl = -maxl; - if (maxl && (to == 0L || to > from + maxl)) - to = from + maxl; if (nosig) { /* print samples only from specified signals */ #ifndef lint if ((sig = (int *)malloc((unsigned)nosig*sizeof(int))) == NULL) { @@ -223,13 +188,40 @@ sig[i] = i; } + /* Reset 'from' if a search was requested. */ + if (search && + ((s = findsig(search)) < 0 || (from = tnextvec(s, from)) < 0)) { + (void)fprintf(stderr, "%s: can't read signal '%s'\n", pname, search); + exit(2); + } + + /* Reset 'to' if a duration limit was specified. */ + if (maxl > 0L && (maxl = strtim(argv[maxl])) < 0L) + maxl = -maxl; + if (maxl && (to == 0L || to > from + maxl)) + to = from + maxl; + /* Print column headers if '-v' option selected. */ if (vflag) { char *p, *r, *t; int j, l; - if (pflag == 0) (void)printf("samp #"); - else (void)printf("time"); + if (pflag == 0) (void)printf(" sample #"); + else if (timeunits == TIMSTR || timeunits == HHMMSS) { + p = timstr(0L); + if (*p != '[') + timeunits = HHMMSS; + if (timeunits == HHMMSS) + printf(" Elapsed time"); + else { + if (freq > 1.0) { + timeunits = MSTIMSTR; + (void)printf(" "); + } + (void)printf(" Time Date "); + } + } + else (void)printf(" Elapsed time"); if ((t = malloc((strlen(record)+30) * sizeof(char))) == NULL) { fprintf(stderr, "%s: insufficient memory\n", pname); exit(2); @@ -253,9 +245,14 @@ p = t; } l = strlen(p); - if (l > 7) p += l - 7; - /* Print the last 7 characters of each signal description. */ - (void)printf("\t%s%s", pflag > 1 ? " " : "", p); + if (pflag > 1) { + if (l > 15) p += l - 15; + (void)printf("\t%15s", p); + } + else { + if (l > 7) p+= l - 7; + (void)printf("\t%7s", p); + } } (void)printf("\n"); } @@ -263,29 +260,44 @@ /* Print data in physical units if '-p' option selected. */ if (pflag) { char *p, *fmt = pflag > 1 ? "\t%15.8lf" : "\t%7.3f"; - double freq = sampfreq(NULL); if (timeunits == HOURS) freq *= 3600.; else if (timeunits == MINUTES) freq *= 60.; /* Print units as a second line of column headers if '-v' selected. */ if (vflag) { - if (timeunits == HOURS) (void)printf("(hrs)"); - else if (timeunits == MINUTES) (void)printf("(min)"); - else if (timeunits == SECONDS) (void)printf("(sec)"); + if (timeunits == TIMSTR) (void)printf("(hh:mm:ss dd/mm/yyyy)"); + else if (timeunits == MSTIMSTR) + (void)printf("(hh:mm:ss.mmm dd/mm/yyyy)"); + else if (timeunits == HHMMSS) (void)printf(" hh:mm:ss.mmm"); + else if (timeunits == HOURS) (void)printf(" (hours)"); + else if (timeunits == MINUTES) (void)printf(" (minutes)"); + else if (timeunits == SECONDS) (void)printf(" (seconds)"); for (i = 0; i < nsig; i++) { + char ustring[16]; + p = si[sig[i]].units; if (p == NULL) p = "mV"; - if ((int)strlen(p) > 5) p[5] = '\0'; - /* Print the first 5 characters of each signal units string. */ - (void)printf("\t%s(%s)", pflag > 1 ? " " : "", p); + if (pflag > 1) + sprintf(ustring, "%14s", p); + else + sprintf(ustring, "%6s", p); + for (p = ustring+2; *p == ' '; p++) + ; + *(p-1) = '('; + (void)printf("\t%s)", ustring); } (void)printf("\n"); } while ((to == 0L || from < to) && getvec(v) >= 0) { - (void)printf("%7.3lf", (double)(from++)/freq); + if (timeunits == TIMSTR) (void)printf("%s", timstr(-from)); + else if (timeunits == MSTIMSTR) (void)printf("%s", mstimstr(-from)); + else if (timeunits == HHMMSS) (void)printf("%15s", from == 0L ? + "0:00.000" : mstimstr(from)); + else (void)printf("%15.3lf", (double)from/freq); + from++; for (i = 0; i < nsig; i++) { if (v[sig[i]] != WFDB_INVALID_SAMPLE) (void)printf(fmt, @@ -299,9 +311,9 @@ else { while ((to == 0L || from < to) && getvec(v) >= 0) { - (void)printf("%6ld", from++); + (void)printf("%15ld", from++); for (i = 0; i < nsig; i++) - (void)printf("\t%5d", v[sig[i]]); + (void)printf("\t%7d", v[sig[i]]); (void)printf("\n"); } } @@ -337,9 +349,17 @@ " -H read multifrequency signals in high resolution mode", " -l INTERVAL truncate output after the specified time interval (hh:mm:ss)", " -p print times and samples in physical units (default: raw units)", - " (use -p -p for greater precision; use -ph, -pm, or -ps to", - " print times in hours, minutes, or seconds respectively", + " -P same as -p, but with greater precision", + " -p and -P may be followed by a character to choose a time", + " format; choices are:", + " -pd (or -Pd) print time of day and date if known", + " -pe (or -Pe) print elapsed time as ::", + " -ph (or -Ph) print elapsed time in hours", + " -pm (or -Pm) print elapsed time in minutes", + " -ps (or -Ps) print elapsed time in seconds", " -s SIGNAL [SIGNAL ...] print only the specified signal(s)", + " -S SIGNAL search for a valid sample of the specified SIGNAL at or after", + " the time specified with -f, and begin printing then", " -t TIME stop at specified time", " -v print column headings", NULL diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/app/sortann.c wfdb-10.4.13/app/sortann.c --- wfdb-10.4.12/app/sortann.c 2009-01-20 14:29:48.000000000 -0500 +++ wfdb-10.4.13/app/sortann.c 2009-02-04 10:54:28.000000000 -0500 @@ -1,5 +1,5 @@ /* file sortann.c G. Moody 7 April 1997 - Last revised: 20 January 2009 + Last revised: 4 February 2009 ------------------------------------------------------------------------------- sortann: Rearrange annotations in canonical order Copyright (C) 1997-2009 George B. Moody @@ -284,7 +284,7 @@ if (newp->next = ap->next) (newp->next)->prev = newp; else lastp = newp; if ((ap->annotation).aux) free((ap->annotation).aux); - free(ap); + if (ap != &annlist) free(ap); } else { /* insert newp immediately after ap */ newp->prev = ap; @@ -297,10 +297,9 @@ void cleanup() /* free the memory used for the annotation list */ { - while (lastp != &annlist) { + while (lastp != NULL && lastp != &annlist) { if ((lastp->annotation).aux) free((lastp->annotation).aux); - lastp = lastp->prev; - free(lastp->next); + if (lastp = lastp->prev) free(lastp->next); } } diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/app/wfdbdesc.c wfdb-10.4.13/app/wfdbdesc.c --- wfdb-10.4.12/app/wfdbdesc.c 2009-01-15 12:30:25.000000000 -0500 +++ wfdb-10.4.13/app/wfdbdesc.c 2009-01-30 11:25:55.000000000 -0500 @@ -1,9 +1,9 @@ /* file: wfdbdesc.c G. Moody June 1989 - Last revised: 6 January 2008 + Last revised: 26 January 2009 ------------------------------------------------------------------------------- wfdbdesc: Describe signal specifications -Copyright (C) 1989-2008 George B. Moody +Copyright (C) 1989-2009 George B. Moody This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -76,7 +76,7 @@ (void)printf("----------------------------------------------"); } } - else if (info = getinfo((char *)NULL)) { + if (info = getinfo((char *)NULL)) { (void)printf("\nNotes\n=====\n"); do { puts(info); diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/app/wrsamp.c wfdb-10.4.13/app/wrsamp.c --- wfdb-10.4.12/app/wrsamp.c 2008-07-15 15:41:37.000000000 -0400 +++ wfdb-10.4.13/app/wrsamp.c 2009-01-20 23:07:42.000000000 -0500 @@ -1,8 +1,8 @@ /* file: wrsamp.c G. Moody 10 August 1993 - Last revised: 15 July 2008 + Last revised: 20 January 2009 ------------------------------------------------------------------------------- wrsamp: Select fields or columns from a file and generate a WFDB record -Copyright (C) 1993-2008 George B. Moody +Copyright (C) 1993-2009 George B. Moody This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -199,7 +199,6 @@ (void)fprintf(stderr, "%s: insufficient memory\n", pname); exit(2); } - /* open output file */ if (record == NULL) (void)sprintf(ofname, "-"); @@ -219,6 +218,7 @@ si[i].units = ""; si[i].group = 0; si[i].fmt = 16; + si[i].spf = 1; si[i].bsize = 0; si[i].adcres = WFDB_DEFRES; si[i].adczero = 0; @@ -238,7 +238,6 @@ while (*scale != '\0' && *scale != ' ') scale++; } - if (osigfopen(si, nf) < nf || setsampfreq(freq) < 0) exit(2); @@ -285,8 +284,8 @@ else { v *= scalef[i]; if (dflag) v += DITHER; - if (v >= 0) vout[i] = (int)(v + 0.5); - else vout[i] = (int)(v - 0.5); + if (v >= 0) vout[i] = (WFDB_Sample)(v + 0.5); + else vout[i] = (WFDB_Sample)(v - 0.5); } } if (putvec(vout) < 0) break; @@ -310,7 +309,6 @@ } else *cp++ = c; } while (c != EOF); - if (record != NULL) (void)newheader(record); wfdbquit(); diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/checkpkg/expected/rdsamp.out wfdb-10.4.13/checkpkg/expected/rdsamp.out --- wfdb-10.4.12/checkpkg/expected/rdsamp.out 2001-09-09 23:42:45.000000000 -0400 +++ wfdb-10.4.13/checkpkg/expected/rdsamp.out 2009-02-15 23:54:58.000000000 -0500 @@ -1,362 +1,362 @@ -time MLII V5 -(sec) (mV) (mV) - 10.000 -0.390 -0.275 - 10.003 -0.395 -0.265 - 10.006 -0.390 -0.285 - 10.008 -0.405 -0.300 - 10.011 -0.405 -0.305 - 10.014 -0.400 -0.285 - 10.017 -0.375 -0.270 - 10.019 -0.380 -0.280 - 10.022 -0.390 -0.275 - 10.025 -0.395 -0.290 - 10.028 -0.395 -0.280 - 10.031 -0.390 -0.290 - 10.033 -0.390 -0.280 - 10.036 -0.385 -0.280 - 10.039 -0.405 -0.285 - 10.042 -0.400 -0.285 - 10.044 -0.405 -0.285 - 10.047 -0.395 -0.295 - 10.050 -0.390 -0.275 - 10.053 -0.395 -0.280 - 10.056 -0.390 -0.290 - 10.058 -0.400 -0.295 - 10.061 -0.405 -0.295 - 10.064 -0.405 -0.285 - 10.067 -0.390 -0.275 - 10.069 -0.390 -0.295 - 10.072 -0.395 -0.305 - 10.075 -0.400 -0.305 - 10.078 -0.400 -0.320 - 10.081 -0.395 -0.305 - 10.083 -0.380 -0.295 - 10.086 -0.370 -0.300 - 10.089 -0.380 -0.300 - 10.092 -0.385 -0.320 - 10.094 -0.395 -0.320 - 10.097 -0.390 -0.310 - 10.100 -0.380 -0.305 - 10.103 -0.380 -0.315 - 10.106 -0.385 -0.330 - 10.108 -0.390 -0.345 - 10.111 -0.390 -0.355 - 10.114 -0.400 -0.340 - 10.117 -0.400 -0.335 - 10.119 -0.405 -0.350 - 10.122 -0.415 -0.370 - 10.125 -0.420 -0.380 - 10.128 -0.430 -0.380 - 10.131 -0.430 -0.375 - 10.133 -0.425 -0.385 - 10.136 -0.420 -0.405 - 10.139 -0.430 -0.405 - 10.142 -0.445 -0.420 - 10.144 -0.465 -0.430 - 10.147 -0.455 -0.415 - 10.150 -0.440 -0.410 - 10.153 -0.425 -0.415 - 10.156 -0.435 -0.425 - 10.158 -0.450 -0.425 - 10.161 -0.440 -0.425 - 10.164 -0.445 -0.405 - 10.167 -0.425 -0.385 - 10.169 -0.425 -0.390 - 10.172 -0.425 -0.385 - 10.175 -0.430 -0.385 - 10.178 -0.430 -0.380 - 10.181 -0.415 -0.350 - 10.183 -0.415 -0.320 - 10.186 -0.385 -0.315 - 10.189 -0.375 -0.315 - 10.192 -0.385 -0.305 - 10.194 -0.370 -0.305 - 10.197 -0.360 -0.270 - 10.200 -0.350 -0.250 - 10.203 -0.335 -0.235 - 10.206 -0.335 -0.235 - 10.208 -0.325 -0.245 - 10.211 -0.320 -0.240 - 10.214 -0.325 -0.235 - 10.217 -0.305 -0.215 - 10.219 -0.295 -0.220 - 10.222 -0.300 -0.220 - 10.225 -0.290 -0.225 - 10.228 -0.295 -0.220 - 10.231 -0.290 -0.215 - 10.233 -0.290 -0.205 - 10.236 -0.285 -0.215 - 10.239 -0.285 -0.215 - 10.242 -0.285 -0.225 - 10.244 -0.290 -0.225 - 10.247 -0.290 -0.215 - 10.250 -0.285 -0.190 - 10.253 -0.270 -0.195 - 10.256 -0.270 -0.210 - 10.258 -0.280 -0.205 - 10.261 -0.290 -0.205 - 10.264 -0.285 -0.200 - 10.267 -0.275 -0.205 - 10.269 -0.275 -0.205 - 10.272 -0.275 -0.205 - 10.275 -0.290 -0.215 - 10.278 -0.305 -0.210 - 10.281 -0.305 -0.210 - 10.283 -0.300 -0.200 - 10.286 -0.280 -0.200 - 10.289 -0.290 -0.205 - 10.292 -0.305 -0.220 - 10.294 -0.315 -0.210 - 10.297 -0.310 -0.200 - 10.300 -0.295 -0.200 - 10.303 -0.290 -0.195 - 10.306 -0.300 -0.215 - 10.308 -0.305 -0.215 - 10.311 -0.305 -0.220 - 10.314 -0.310 -0.210 - 10.317 -0.300 -0.210 - 10.319 -0.295 -0.210 - 10.322 -0.305 -0.215 - 10.325 -0.305 -0.225 - 10.328 -0.315 -0.230 - 10.331 -0.310 -0.215 - 10.333 -0.310 -0.215 - 10.336 -0.295 -0.215 - 10.339 -0.300 -0.220 - 10.342 -0.305 -0.230 - 10.344 -0.310 -0.220 - 10.347 -0.305 -0.205 - 10.350 -0.305 -0.200 - 10.353 -0.295 -0.220 - 10.356 -0.300 -0.225 - 10.358 -0.315 -0.240 - 10.361 -0.325 -0.230 - 10.364 -0.320 -0.230 - 10.367 -0.320 -0.215 - 10.369 -0.315 -0.225 - 10.372 -0.310 -0.220 - 10.375 -0.325 -0.235 - 10.378 -0.335 -0.225 - 10.381 -0.330 -0.225 - 10.383 -0.320 -0.210 - 10.386 -0.320 -0.225 - 10.389 -0.310 -0.225 - 10.392 -0.330 -0.225 - 10.394 -0.330 -0.230 - 10.397 -0.325 -0.220 - 10.400 -0.310 -0.210 - 10.403 -0.305 -0.220 - 10.406 -0.305 -0.215 - 10.408 -0.320 -0.230 - 10.411 -0.330 -0.235 - 10.414 -0.325 -0.215 - 10.417 -0.300 -0.210 - 10.419 -0.310 -0.215 - 10.422 -0.305 -0.225 - 10.425 -0.315 -0.225 - 10.428 -0.330 -0.235 - 10.431 -0.330 -0.230 - 10.433 -0.330 -0.215 - 10.436 -0.320 -0.225 - 10.439 -0.325 -0.220 - 10.442 -0.325 -0.230 - 10.444 -0.335 -0.225 - 10.447 -0.325 -0.220 - 10.450 -0.315 -0.210 - 10.453 -0.310 -0.215 - 10.456 -0.315 -0.220 - 10.458 -0.320 -0.220 - 10.461 -0.325 -0.225 - 10.464 -0.315 -0.210 - 10.467 -0.310 -0.205 - 10.469 -0.305 -0.215 - 10.472 -0.310 -0.225 - 10.475 -0.315 -0.230 - 10.478 -0.320 -0.240 - 10.481 -0.315 -0.225 - 10.483 -0.310 -0.205 - 10.486 -0.295 -0.215 - 10.489 -0.295 -0.215 - 10.492 -0.305 -0.220 - 10.494 -0.310 -0.230 - 10.497 -0.300 -0.225 - 10.500 -0.280 -0.215 - 10.503 -0.275 -0.225 - 10.506 -0.265 -0.220 - 10.508 -0.275 -0.220 - 10.511 -0.275 -0.225 - 10.514 -0.260 -0.195 - 10.517 -0.240 -0.195 - 10.519 -0.240 -0.205 - 10.522 -0.235 -0.200 - 10.525 -0.240 -0.200 - 10.528 -0.235 -0.195 - 10.531 -0.225 -0.190 - 10.533 -0.215 -0.170 - 10.536 -0.205 -0.170 - 10.539 -0.205 -0.180 - 10.542 -0.210 -0.180 - 10.544 -0.215 -0.185 - 10.547 -0.220 -0.170 - 10.550 -0.220 -0.165 - 10.553 -0.215 -0.180 - 10.556 -0.220 -0.175 - 10.558 -0.220 -0.185 - 10.561 -0.230 -0.175 - 10.564 -0.230 -0.170 - 10.567 -0.240 -0.150 - 10.569 -0.210 -0.150 - 10.572 -0.220 -0.155 - 10.575 -0.230 -0.180 - 10.578 -0.255 -0.180 - 10.581 -0.235 -0.170 - 10.583 -0.210 -0.175 - 10.586 -0.190 -0.180 - 10.589 -0.205 -0.190 - 10.592 -0.225 -0.195 - 10.594 -0.260 -0.200 - 10.597 -0.275 -0.190 - 10.600 -0.280 -0.185 - 10.603 -0.285 -0.200 - 10.606 -0.305 -0.195 - 10.608 -0.320 -0.215 - 10.611 -0.315 -0.210 - 10.614 -0.335 -0.200 - 10.617 -0.325 -0.195 - 10.619 -0.335 -0.205 - 10.622 -0.320 -0.220 - 10.625 -0.325 -0.215 - 10.628 -0.320 -0.225 - 10.631 -0.325 -0.225 - 10.633 -0.325 -0.210 - 10.636 -0.310 -0.205 - 10.639 -0.305 -0.210 - 10.642 -0.320 -0.225 - 10.644 -0.320 -0.230 - 10.647 -0.330 -0.215 - 10.650 -0.320 -0.200 - 10.653 -0.320 -0.215 - 10.656 -0.330 -0.220 - 10.658 -0.330 -0.225 - 10.661 -0.360 -0.210 - 10.664 -0.355 -0.210 - 10.667 -0.330 -0.200 - 10.669 -0.325 -0.210 - 10.672 -0.325 -0.215 - 10.675 -0.335 -0.225 - 10.678 -0.350 -0.235 - 10.681 -0.340 -0.240 - 10.683 -0.345 -0.255 - 10.686 -0.355 -0.290 - 10.689 -0.385 -0.310 - 10.692 -0.425 -0.335 - 10.694 -0.450 -0.360 - 10.697 -0.470 -0.350 - 10.700 -0.485 -0.285 - 10.703 -0.510 -0.175 - 10.706 -0.515 -0.050 - 10.708 -0.455 0.075 - 10.711 -0.325 0.190 - 10.714 -0.165 0.315 - 10.717 0.010 0.430 - 10.719 0.250 0.545 - 10.722 0.515 0.655 - 10.725 0.740 0.655 - 10.728 0.885 0.505 - 10.731 0.935 0.210 - 10.733 0.835 -0.090 - 10.736 0.525 -0.275 - 10.739 0.120 -0.290 - 10.742 -0.230 -0.265 - 10.744 -0.425 -0.250 - 10.747 -0.455 -0.255 - 10.750 -0.420 -0.230 - 10.753 -0.380 -0.230 - 10.756 -0.360 -0.250 - 10.758 -0.365 -0.255 - 10.761 -0.375 -0.255 - 10.764 -0.380 -0.250 - 10.767 -0.355 -0.235 - 10.769 -0.355 -0.250 - 10.772 -0.370 -0.250 - 10.775 -0.375 -0.265 - 10.778 -0.385 -0.255 - 10.781 -0.380 -0.250 - 10.783 -0.365 -0.240 - 10.786 -0.370 -0.245 - 10.789 -0.370 -0.255 - 10.792 -0.365 -0.255 - 10.794 -0.380 -0.265 - 10.797 -0.370 -0.240 - 10.800 -0.375 -0.240 - 10.803 -0.365 -0.255 - 10.806 -0.370 -0.255 - 10.808 -0.380 -0.265 - 10.811 -0.375 -0.260 - 10.814 -0.365 -0.250 - 10.817 -0.360 -0.255 - 10.819 -0.360 -0.255 - 10.822 -0.355 -0.255 - 10.825 -0.355 -0.255 - 10.828 -0.370 -0.250 - 10.831 -0.365 -0.245 - 10.833 -0.355 -0.225 - 10.836 -0.350 -0.230 - 10.839 -0.350 -0.245 - 10.842 -0.350 -0.255 - 10.844 -0.360 -0.260 - 10.847 -0.360 -0.245 - 10.850 -0.360 -0.245 - 10.853 -0.350 -0.245 - 10.856 -0.355 -0.240 - 10.858 -0.365 -0.250 - 10.861 -0.370 -0.245 - 10.864 -0.360 -0.245 - 10.867 -0.350 -0.240 - 10.869 -0.355 -0.240 - 10.872 -0.350 -0.250 - 10.875 -0.355 -0.265 - 10.878 -0.370 -0.255 - 10.881 -0.375 -0.240 - 10.883 -0.360 -0.240 - 10.886 -0.350 -0.240 - 10.889 -0.345 -0.255 - 10.892 -0.350 -0.260 - 10.894 -0.370 -0.260 - 10.897 -0.370 -0.255 - 10.900 -0.355 -0.255 - 10.903 -0.350 -0.250 - 10.906 -0.345 -0.260 - 10.908 -0.360 -0.275 - 10.911 -0.370 -0.280 - 10.914 -0.365 -0.280 - 10.917 -0.360 -0.270 - 10.919 -0.350 -0.265 - 10.922 -0.355 -0.285 - 10.925 -0.365 -0.290 - 10.928 -0.365 -0.280 - 10.931 -0.370 -0.280 - 10.933 -0.365 -0.275 - 10.936 -0.350 -0.295 - 10.939 -0.350 -0.305 - 10.942 -0.360 -0.310 - 10.944 -0.360 -0.310 - 10.947 -0.355 -0.320 - 10.950 -0.345 -0.305 - 10.953 -0.350 -0.320 - 10.956 -0.345 -0.345 - 10.958 -0.355 -0.350 - 10.961 -0.370 -0.355 - 10.964 -0.365 -0.355 - 10.967 -0.355 -0.350 - 10.969 -0.360 -0.350 - 10.972 -0.365 -0.360 - 10.975 -0.365 -0.380 - 10.978 -0.380 -0.385 - 10.981 -0.385 -0.380 - 10.983 -0.375 -0.380 - 10.986 -0.370 -0.375 - 10.989 -0.375 -0.385 - 10.992 -0.385 -0.395 - 10.994 -0.395 -0.380 - 10.997 -0.375 -0.390 + Elapsed time MLII V5 + (seconds) (mV) (mV) + 10.000 -0.390 -0.275 + 10.003 -0.395 -0.265 + 10.006 -0.390 -0.285 + 10.008 -0.405 -0.300 + 10.011 -0.405 -0.305 + 10.014 -0.400 -0.285 + 10.017 -0.375 -0.270 + 10.019 -0.380 -0.280 + 10.022 -0.390 -0.275 + 10.025 -0.395 -0.290 + 10.028 -0.395 -0.280 + 10.031 -0.390 -0.290 + 10.033 -0.390 -0.280 + 10.036 -0.385 -0.280 + 10.039 -0.405 -0.285 + 10.042 -0.400 -0.285 + 10.044 -0.405 -0.285 + 10.047 -0.395 -0.295 + 10.050 -0.390 -0.275 + 10.053 -0.395 -0.280 + 10.056 -0.390 -0.290 + 10.058 -0.400 -0.295 + 10.061 -0.405 -0.295 + 10.064 -0.405 -0.285 + 10.067 -0.390 -0.275 + 10.069 -0.390 -0.295 + 10.072 -0.395 -0.305 + 10.075 -0.400 -0.305 + 10.078 -0.400 -0.320 + 10.081 -0.395 -0.305 + 10.083 -0.380 -0.295 + 10.086 -0.370 -0.300 + 10.089 -0.380 -0.300 + 10.092 -0.385 -0.320 + 10.094 -0.395 -0.320 + 10.097 -0.390 -0.310 + 10.100 -0.380 -0.305 + 10.103 -0.380 -0.315 + 10.106 -0.385 -0.330 + 10.108 -0.390 -0.345 + 10.111 -0.390 -0.355 + 10.114 -0.400 -0.340 + 10.117 -0.400 -0.335 + 10.119 -0.405 -0.350 + 10.122 -0.415 -0.370 + 10.125 -0.420 -0.380 + 10.128 -0.430 -0.380 + 10.131 -0.430 -0.375 + 10.133 -0.425 -0.385 + 10.136 -0.420 -0.405 + 10.139 -0.430 -0.405 + 10.142 -0.445 -0.420 + 10.144 -0.465 -0.430 + 10.147 -0.455 -0.415 + 10.150 -0.440 -0.410 + 10.153 -0.425 -0.415 + 10.156 -0.435 -0.425 + 10.158 -0.450 -0.425 + 10.161 -0.440 -0.425 + 10.164 -0.445 -0.405 + 10.167 -0.425 -0.385 + 10.169 -0.425 -0.390 + 10.172 -0.425 -0.385 + 10.175 -0.430 -0.385 + 10.178 -0.430 -0.380 + 10.181 -0.415 -0.350 + 10.183 -0.415 -0.320 + 10.186 -0.385 -0.315 + 10.189 -0.375 -0.315 + 10.192 -0.385 -0.305 + 10.194 -0.370 -0.305 + 10.197 -0.360 -0.270 + 10.200 -0.350 -0.250 + 10.203 -0.335 -0.235 + 10.206 -0.335 -0.235 + 10.208 -0.325 -0.245 + 10.211 -0.320 -0.240 + 10.214 -0.325 -0.235 + 10.217 -0.305 -0.215 + 10.219 -0.295 -0.220 + 10.222 -0.300 -0.220 + 10.225 -0.290 -0.225 + 10.228 -0.295 -0.220 + 10.231 -0.290 -0.215 + 10.233 -0.290 -0.205 + 10.236 -0.285 -0.215 + 10.239 -0.285 -0.215 + 10.242 -0.285 -0.225 + 10.244 -0.290 -0.225 + 10.247 -0.290 -0.215 + 10.250 -0.285 -0.190 + 10.253 -0.270 -0.195 + 10.256 -0.270 -0.210 + 10.258 -0.280 -0.205 + 10.261 -0.290 -0.205 + 10.264 -0.285 -0.200 + 10.267 -0.275 -0.205 + 10.269 -0.275 -0.205 + 10.272 -0.275 -0.205 + 10.275 -0.290 -0.215 + 10.278 -0.305 -0.210 + 10.281 -0.305 -0.210 + 10.283 -0.300 -0.200 + 10.286 -0.280 -0.200 + 10.289 -0.290 -0.205 + 10.292 -0.305 -0.220 + 10.294 -0.315 -0.210 + 10.297 -0.310 -0.200 + 10.300 -0.295 -0.200 + 10.303 -0.290 -0.195 + 10.306 -0.300 -0.215 + 10.308 -0.305 -0.215 + 10.311 -0.305 -0.220 + 10.314 -0.310 -0.210 + 10.317 -0.300 -0.210 + 10.319 -0.295 -0.210 + 10.322 -0.305 -0.215 + 10.325 -0.305 -0.225 + 10.328 -0.315 -0.230 + 10.331 -0.310 -0.215 + 10.333 -0.310 -0.215 + 10.336 -0.295 -0.215 + 10.339 -0.300 -0.220 + 10.342 -0.305 -0.230 + 10.344 -0.310 -0.220 + 10.347 -0.305 -0.205 + 10.350 -0.305 -0.200 + 10.353 -0.295 -0.220 + 10.356 -0.300 -0.225 + 10.358 -0.315 -0.240 + 10.361 -0.325 -0.230 + 10.364 -0.320 -0.230 + 10.367 -0.320 -0.215 + 10.369 -0.315 -0.225 + 10.372 -0.310 -0.220 + 10.375 -0.325 -0.235 + 10.378 -0.335 -0.225 + 10.381 -0.330 -0.225 + 10.383 -0.320 -0.210 + 10.386 -0.320 -0.225 + 10.389 -0.310 -0.225 + 10.392 -0.330 -0.225 + 10.394 -0.330 -0.230 + 10.397 -0.325 -0.220 + 10.400 -0.310 -0.210 + 10.403 -0.305 -0.220 + 10.406 -0.305 -0.215 + 10.408 -0.320 -0.230 + 10.411 -0.330 -0.235 + 10.414 -0.325 -0.215 + 10.417 -0.300 -0.210 + 10.419 -0.310 -0.215 + 10.422 -0.305 -0.225 + 10.425 -0.315 -0.225 + 10.428 -0.330 -0.235 + 10.431 -0.330 -0.230 + 10.433 -0.330 -0.215 + 10.436 -0.320 -0.225 + 10.439 -0.325 -0.220 + 10.442 -0.325 -0.230 + 10.444 -0.335 -0.225 + 10.447 -0.325 -0.220 + 10.450 -0.315 -0.210 + 10.453 -0.310 -0.215 + 10.456 -0.315 -0.220 + 10.458 -0.320 -0.220 + 10.461 -0.325 -0.225 + 10.464 -0.315 -0.210 + 10.467 -0.310 -0.205 + 10.469 -0.305 -0.215 + 10.472 -0.310 -0.225 + 10.475 -0.315 -0.230 + 10.478 -0.320 -0.240 + 10.481 -0.315 -0.225 + 10.483 -0.310 -0.205 + 10.486 -0.295 -0.215 + 10.489 -0.295 -0.215 + 10.492 -0.305 -0.220 + 10.494 -0.310 -0.230 + 10.497 -0.300 -0.225 + 10.500 -0.280 -0.215 + 10.503 -0.275 -0.225 + 10.506 -0.265 -0.220 + 10.508 -0.275 -0.220 + 10.511 -0.275 -0.225 + 10.514 -0.260 -0.195 + 10.517 -0.240 -0.195 + 10.519 -0.240 -0.205 + 10.522 -0.235 -0.200 + 10.525 -0.240 -0.200 + 10.528 -0.235 -0.195 + 10.531 -0.225 -0.190 + 10.533 -0.215 -0.170 + 10.536 -0.205 -0.170 + 10.539 -0.205 -0.180 + 10.542 -0.210 -0.180 + 10.544 -0.215 -0.185 + 10.547 -0.220 -0.170 + 10.550 -0.220 -0.165 + 10.553 -0.215 -0.180 + 10.556 -0.220 -0.175 + 10.558 -0.220 -0.185 + 10.561 -0.230 -0.175 + 10.564 -0.230 -0.170 + 10.567 -0.240 -0.150 + 10.569 -0.210 -0.150 + 10.572 -0.220 -0.155 + 10.575 -0.230 -0.180 + 10.578 -0.255 -0.180 + 10.581 -0.235 -0.170 + 10.583 -0.210 -0.175 + 10.586 -0.190 -0.180 + 10.589 -0.205 -0.190 + 10.592 -0.225 -0.195 + 10.594 -0.260 -0.200 + 10.597 -0.275 -0.190 + 10.600 -0.280 -0.185 + 10.603 -0.285 -0.200 + 10.606 -0.305 -0.195 + 10.608 -0.320 -0.215 + 10.611 -0.315 -0.210 + 10.614 -0.335 -0.200 + 10.617 -0.325 -0.195 + 10.619 -0.335 -0.205 + 10.622 -0.320 -0.220 + 10.625 -0.325 -0.215 + 10.628 -0.320 -0.225 + 10.631 -0.325 -0.225 + 10.633 -0.325 -0.210 + 10.636 -0.310 -0.205 + 10.639 -0.305 -0.210 + 10.642 -0.320 -0.225 + 10.644 -0.320 -0.230 + 10.647 -0.330 -0.215 + 10.650 -0.320 -0.200 + 10.653 -0.320 -0.215 + 10.656 -0.330 -0.220 + 10.658 -0.330 -0.225 + 10.661 -0.360 -0.210 + 10.664 -0.355 -0.210 + 10.667 -0.330 -0.200 + 10.669 -0.325 -0.210 + 10.672 -0.325 -0.215 + 10.675 -0.335 -0.225 + 10.678 -0.350 -0.235 + 10.681 -0.340 -0.240 + 10.683 -0.345 -0.255 + 10.686 -0.355 -0.290 + 10.689 -0.385 -0.310 + 10.692 -0.425 -0.335 + 10.694 -0.450 -0.360 + 10.697 -0.470 -0.350 + 10.700 -0.485 -0.285 + 10.703 -0.510 -0.175 + 10.706 -0.515 -0.050 + 10.708 -0.455 0.075 + 10.711 -0.325 0.190 + 10.714 -0.165 0.315 + 10.717 0.010 0.430 + 10.719 0.250 0.545 + 10.722 0.515 0.655 + 10.725 0.740 0.655 + 10.728 0.885 0.505 + 10.731 0.935 0.210 + 10.733 0.835 -0.090 + 10.736 0.525 -0.275 + 10.739 0.120 -0.290 + 10.742 -0.230 -0.265 + 10.744 -0.425 -0.250 + 10.747 -0.455 -0.255 + 10.750 -0.420 -0.230 + 10.753 -0.380 -0.230 + 10.756 -0.360 -0.250 + 10.758 -0.365 -0.255 + 10.761 -0.375 -0.255 + 10.764 -0.380 -0.250 + 10.767 -0.355 -0.235 + 10.769 -0.355 -0.250 + 10.772 -0.370 -0.250 + 10.775 -0.375 -0.265 + 10.778 -0.385 -0.255 + 10.781 -0.380 -0.250 + 10.783 -0.365 -0.240 + 10.786 -0.370 -0.245 + 10.789 -0.370 -0.255 + 10.792 -0.365 -0.255 + 10.794 -0.380 -0.265 + 10.797 -0.370 -0.240 + 10.800 -0.375 -0.240 + 10.803 -0.365 -0.255 + 10.806 -0.370 -0.255 + 10.808 -0.380 -0.265 + 10.811 -0.375 -0.260 + 10.814 -0.365 -0.250 + 10.817 -0.360 -0.255 + 10.819 -0.360 -0.255 + 10.822 -0.355 -0.255 + 10.825 -0.355 -0.255 + 10.828 -0.370 -0.250 + 10.831 -0.365 -0.245 + 10.833 -0.355 -0.225 + 10.836 -0.350 -0.230 + 10.839 -0.350 -0.245 + 10.842 -0.350 -0.255 + 10.844 -0.360 -0.260 + 10.847 -0.360 -0.245 + 10.850 -0.360 -0.245 + 10.853 -0.350 -0.245 + 10.856 -0.355 -0.240 + 10.858 -0.365 -0.250 + 10.861 -0.370 -0.245 + 10.864 -0.360 -0.245 + 10.867 -0.350 -0.240 + 10.869 -0.355 -0.240 + 10.872 -0.350 -0.250 + 10.875 -0.355 -0.265 + 10.878 -0.370 -0.255 + 10.881 -0.375 -0.240 + 10.883 -0.360 -0.240 + 10.886 -0.350 -0.240 + 10.889 -0.345 -0.255 + 10.892 -0.350 -0.260 + 10.894 -0.370 -0.260 + 10.897 -0.370 -0.255 + 10.900 -0.355 -0.255 + 10.903 -0.350 -0.250 + 10.906 -0.345 -0.260 + 10.908 -0.360 -0.275 + 10.911 -0.370 -0.280 + 10.914 -0.365 -0.280 + 10.917 -0.360 -0.270 + 10.919 -0.350 -0.265 + 10.922 -0.355 -0.285 + 10.925 -0.365 -0.290 + 10.928 -0.365 -0.280 + 10.931 -0.370 -0.280 + 10.933 -0.365 -0.275 + 10.936 -0.350 -0.295 + 10.939 -0.350 -0.305 + 10.942 -0.360 -0.310 + 10.944 -0.360 -0.310 + 10.947 -0.355 -0.320 + 10.950 -0.345 -0.305 + 10.953 -0.350 -0.320 + 10.956 -0.345 -0.345 + 10.958 -0.355 -0.350 + 10.961 -0.370 -0.355 + 10.964 -0.365 -0.355 + 10.967 -0.355 -0.350 + 10.969 -0.360 -0.350 + 10.972 -0.365 -0.360 + 10.975 -0.365 -0.380 + 10.978 -0.380 -0.385 + 10.981 -0.385 -0.380 + 10.983 -0.375 -0.380 + 10.986 -0.370 -0.375 + 10.989 -0.375 -0.385 + 10.992 -0.385 -0.395 + 10.994 -0.395 -0.380 + 10.997 -0.375 -0.390 diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/conf/version.def wfdb-10.4.13/conf/version.def --- wfdb-10.4.12/conf/version.def 2008-11-19 13:35:00.000000000 -0500 +++ wfdb-10.4.13/conf/version.def 2009-02-15 12:49:16.000000000 -0500 @@ -1,5 +1,5 @@ # file: version.def G. Moody 24 May 2000 -# Last revised: 19 November 2008 +# Last revised: 15 February 2009 # Each release of the WFDB Software Package is identified by a three-part # version number, defined below. Be sure to leave a single space before # and after the "=" in each of the next three lines! @@ -17,6 +17,6 @@ VDEFS = -DWFDB_MAJOR=$(MAJOR) -DWFDB_MINOR=$(MINOR) -DWFDB_RELEASE=$(RELEASE) # WAVEVERSION is the WAVE version number. -WAVEVERSION = 6.8 +WAVEVERSION = 6.9 # _____________________________________________________________________________ diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/doc/wag-src/rdsamp.1 wfdb-10.4.13/doc/wag-src/rdsamp.1 --- wfdb-10.4.12/doc/wag-src/rdsamp.1 2009-01-07 15:06:49.000000000 -0500 +++ wfdb-10.4.13/doc/wag-src/rdsamp.1 2009-02-15 23:24:14.000000000 -0500 @@ -1,4 +1,4 @@ -.TH RDSAMP 1 "7 January 2009" "WFDB 10.4.12" "WFDB Applications Guide" +.TH RDSAMP 1 "15 February 2009" "WFDB 10.4.13" "WFDB Applications Guide" .SH NAME rdsamp \- read WFDB signal files .SH SYNOPSIS @@ -34,14 +34,42 @@ \fB-p\fR Print times in seconds and milliseconds, and values in physical units. By default, \fBrdsamp\fR prints times in sample intervals and values in A/D units. -Use \fB-p -p\fR to obtain higher precision in the sample values -(8 decimal places rather than 3). Use \fB-pm\fR or \fB-ph\fR to print times -in minutes or hours respectively. +.TP +\fB-P\fR +Same as \fB-p\fR, but yields higher precision in the sample values +(8 decimal places rather than 3). +.IP +A single character can be attached to either \fB-p\fR or \fB-P\fR to choose the +format for the printed times in the first column of output. The choices are: +.TP +\fB-pd\fR (or \fB-Pd\fR) +Print time of day and date if known, as [hh:mm:ss DD/MM/YYYY]. The base time +and date must appear in the header file for the record; otherwise, this format +is equivalent to "e" format (below). +.TP +\fB-pe\fR (or \fB-Pe\fR) +Print the elapsed time from the beginning of the record, as hh:mm:ss. +.TP +\fB-ph\fR (or \fB-Ph\fR) +Print the elapsed time in hours. +.TP +\fB-pm\fR (or \fB-Pm\fR) +Print the elapsed time in seconds. +.TP +\fB-ps\fR (or \fB-Ps\fR) +Print the elapsed time in seconds. This is the default format when using +\fB-p\fR or \fB-P\fR. .TP \fB-s\fR \fIsignal-list\fR Print only the signals named in the \fIsignal-list\fR (one or more input signal -numbers or names, separated by spaces; default: print all signals). This option -may be used to re-order or duplicate signals. +numbers or names, separated by spaces; default: print all signals). This +option may be used to re-order or duplicate signals. +.TP +\fB-S\fR \fIsignal\fR +Search for the first valid sample of the specified \fIsignal\fR (a signal name +or number) at or following the time specified with \fB-f\fR (or the beginning of +the record if the \fB-f\fR option is not present), and begin printing at that +time. .TP \fB-t\fR \fItime\fR Stop at the specified \fItime\fR. By default, \fBrdsamp\fR stops at the end @@ -53,13 +81,6 @@ .PP It may be necessary to set and export the shell variable \fBWFDB\fR (see \fBsetwfdb\fR(1)). -.SH CD-ROM Versions -The first edition of the MIT-BIH Arrhythmia Database CD-ROM, the first and -second editions of the European ST-T Database CD-ROM, and the first edition of -the MIT-BIH Polysomnographic Database CD-ROM contain versions of \fBrdsamp\fR -that use an older command syntax (still supported by the current version but -not described here). Refer to \fIbin.doc\fR in the CD-ROM directory that -contains \fBrdsamp\fR for further information. .SH SEE ALSO \fBrdann\fR(1), \fBsetwfdb\fR(1), \fBwrsamp\fR(1) .SH AUTHOR diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/doc/wpg-src/wpg0.tex wfdb-10.4.13/doc/wpg-src/wpg0.tex --- wfdb-10.4.12/doc/wpg-src/wpg0.tex 2009-01-20 19:47:07.000000000 -0500 +++ wfdb-10.4.13/doc/wpg-src/wpg0.tex 2009-02-16 22:22:42.000000000 -0500 @@ -510,6 +510,27 @@ WFDB Software Package distribution, for information on any more recent changes that may not be described here. +@unnumberedsubsec Changes in version 10.4.13 + +A new WFDB library function, @code{tnextvec()}, finds the next valid sample +from a chosen signal, occurring at or after a specified time. This +function is particularly useful when reading variable-layout +multi-segment records that may have lengthy gaps in signals of interest. + +For portability, the WFDB library has always stored parameters such as +sampling frequency and gain as strings rather than as floating-point +numbers. Although the resultant loss of precision has been almost +always negligible, it has been observable in the specific case of +converting very large time intervals from sample intervals to seconds, +when the sampling frequency in Hz cannot be represented exactly in +binary (e.g., if the sampling frequency is once per minute, or 1/60 +Hz). This situation cannot be wholly avoided, but it can be +minimized. Changes in this release, in @code{setheader()} and in functions +that record time units in annotation files, increase the precision +with which non-integer parameters are recorded, so that loss of +precision as a result of converting them to and from strings should +almost never be observable. + @unnumberedsubsec Changes in version 10.4.12 The rule for sorting annotations within a file has been changed to allow a much @@ -3018,6 +3039,7 @@ @menu * isigsettime:: Setting time of next samples read. * isgsettime:: As above, but for one signal group only. +* tnextvec:: Finding the next valid sample in a signal. * iannsettime:: Setting time of next annotations read. * sample:: A random access interface to input signals. @end menu @@ -3058,7 +3080,7 @@ for illustrations of the use of @code{isigsettime}. @c @group -@node isgsettime, iannsettime, isigsettime, non-sequential +@node isgsettime, tnextvec, isigsettime, non-sequential @unnumberedsubsec isgsettime @findex isgsettime @cindex signals (non-sequential access) @@ -3084,7 +3106,37 @@ one record is open simultaneously (@pxref{Multiple Record Access}). @c @group -@node iannsettime, sample, isgsettime, non-sequential +@node tnextvec, iannsettime, isgsettime, non-sequential +@unnumberedsubsec tnextvec +@findex tnextvec +@cindex signals (non-sequential access) +@cindex finding valid samples +@cindex skipping gaps in signals +@cindex invalid samples (skipping) +@cindex valid samples (searching for) + +@example +WFDB_Time tnextvec(WFDB_Signal @var{s}, WFDB_Time @var{t}) +@end example +@noindent +@strong{Return:} +@table @asis +@item @t{>= 0} +Time of the next valid sample of signal @var{s} at or after @var{t} +@item @t{-1} +Failure: EOF reached or improper seek +@end table +@c @end group + +@noindent +This function resets the input signal file pointers so that the next +samples read by @code{getvec} from each input annotation file will +include the next valid sample of the specified signal @var{s} +occurring at or after @var{t}. Use @code{tnextvec} to skip lengthy +gaps in a signal of interest efficiently. + +@c @group +@node iannsettime, sample, tnextvec, non-sequential @unnumberedsubsec iannsettime @findex iannsettime @cindex annotations (non-sequential access) @@ -4744,7 +4796,7 @@ if (sps = sampfreq("100s") while (info = getinfo(NULL)) puts(info); -@dots +@dots{} @end example (This function was first introduced in WFDB library version 4.0.) diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/lib/annot.c wfdb-10.4.13/lib/annot.c --- wfdb-10.4.12/lib/annot.c 2009-01-20 15:07:58.000000000 -0500 +++ wfdb-10.4.13/lib/annot.c 2009-02-16 22:14:51.000000000 -0500 @@ -1,5 +1,5 @@ /* file: annot.c G. Moody 13 April 1989 - Last revised: 20 January 2009 wfdblib 10.4.12 + Last revised: 16 February 2009 wfdblib 10.4.13 WFDB library functions for annotations _______________________________________________________________________________ @@ -130,7 +130,7 @@ WFDB_Frequency afreq; /* time resolution, in ticks/second */ unsigned word; /* next word from the input file */ int ateof; /* EOF-reached indicator */ - char auxstr[AUXBUFLEN]; /* aux string buffer */ + unsigned char auxstr[AUXBUFLEN]; /* aux string buffer */ unsigned index; /* next available position in auxstr */ double tmul, ptmul; /* tmul * annotation time = sample count */ WFDB_Time tt; /* annotation time (MIT format only). This @@ -171,8 +171,8 @@ if (annot.aux == NULL || *annot.aux < 1) continue; if (*(annot.aux+1) == '#') { - if (strncmp(annot.aux + 1, "## time resolution: ", 20) == 0) { - sscanf(annot.aux + 20, "%lf", &(iad[i]->afreq)); + if (strncmp((char *)annot.aux+1, "## time resolution: ", 20) == 0) { + sscanf((char *)annot.aux + 20, "%lf", &(iad[i]->afreq)); if (iad[i]->afreq) { WFDB_Frequency sf = getifreq(); @@ -182,7 +182,7 @@ } continue; } - p1 = strtok(annot.aux+1, " \t"); + p1 = strtok((char *)annot.aux+1, " \t"); a = atoi(p1); if (0 <= a && a <= ACMAX && (p1 = strtok((char *)NULL, " \t"))) { SSTRCPY(s1, p1); @@ -227,7 +227,7 @@ annot.time = 0L; annot.anntyp = NOTE; annot.subtyp = annot.chan = annot.num = 0; - annot.aux = buf; + annot.aux = (unsigned char *)buf; for (a = 0; a <= ACMAX; a++) if (modified[a]) { if (flag == 0) { /* mark the beginning of the table */ @@ -247,7 +247,7 @@ } if (oafreq != oad[i]->afreq && oafreq > 0.) { - (void)sprintf(buf+1, "## time resolution: %g", oafreq); + (void)sprintf(buf+1, "## time resolution: %.12g", oafreq); buf[0] = strlen(buf+1); oad[i]->afreq = oafreq; if (putann(i, &annot) < 0) return (-1); @@ -547,7 +547,7 @@ FINT putann(WFDB_Annotator n, WFDB_Annotation *annot) { unsigned annwd; - char *ap; + unsigned char *ap; int i, len; long delta; WFDB_Time t; @@ -560,12 +560,12 @@ t = annot->time; if (oa->ann.time == (WFDB_Time)0 && oafreq != oa->afreq && oafreq > 0.) { static WFDB_Annotation tra; - char buf[30]; + char buf[40]; oa->afreq = oafreq; tra.anntyp = NOTE; - tra.aux = buf; - (void)sprintf(buf+1, "## time resolution: %g", oafreq); + tra.aux = (unsigned char *)buf; + (void)sprintf(buf+1, "## time resolution: %.12g", oafreq); buf[0] = strlen(buf+1); if (putann(n, &tra) < 0) return (-1); tra.anntyp = 0; diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/lib/Makefile.tpl wfdb-10.4.13/lib/Makefile.tpl --- wfdb-10.4.12/lib/Makefile.tpl 2008-11-19 16:03:59.000000000 -0500 +++ wfdb-10.4.13/lib/Makefile.tpl 2009-02-03 16:04:59.000000000 -0500 @@ -1,9 +1,9 @@ # file: Makefile.tpl G. Moody 24 May 2000 -# Last revised: 19 November 2008 +# Last revised: 3 February 2009 # This section of the Makefile should not need to be changed. -INCLUDES = $(INCDIR)/wfdb/wfdb.h $(INCDIR)/wfdb/ecgcodes.h \ - $(INCDIR)/wfdb/ecgmap.h +INCLUDES = $(INCDIR)/wfdb/wfdb.h $(INCDIR)/wfdb/wfdblib.h \ + $(INCDIR)/wfdb/ecgcodes.h $(INCDIR)/wfdb/ecgmap.h HFILES = wfdb.h ecgcodes.h ecgmap.h wfdblib.h CFILES = wfdbinit.c annot.c signal.c calib.c wfdbio.c OFILES = wfdbinit.o annot.o signal.o calib.o wfdbio.o @@ -63,6 +63,8 @@ # Rules for installing the include files $(INCDIR)/wfdb/wfdb.h: $(INCDIR)/wfdb wfdb.h cp -p wfdb.h $(INCDIR)/wfdb; $(SETPERMISSIONS) $(INCDIR)/wfdb/wfdb.h +$(INCDIR)/wfdb/wfdblib.h: $(INCDIR)/wfdb wfdblib.h + cp -p wfdblib.h $(INCDIR)/wfdb; $(SETPERMISSIONS) $(INCDIR)/wfdb/wfdblib.h $(INCDIR)/wfdb/ecgcodes.h: $(INCDIR)/wfdb ecgcodes.h cp -p ecgcodes.h $(INCDIR)/wfdb $(SETPERMISSIONS) $(INCDIR)/wfdb/ecgcodes.h diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/lib/signal.c wfdb-10.4.13/lib/signal.c --- wfdb-10.4.12/lib/signal.c 2009-01-16 13:09:20.000000000 -0500 +++ wfdb-10.4.13/lib/signal.c 2009-02-15 12:31:51.000000000 -0500 @@ -1,5 +1,5 @@ /* file: signal.c G. Moody 13 April 1989 - Last revised: 27 October 2008 wfdblib 10.4.12 + Last revised: 14 February 2009 wfdblib 10.4.13 WFDB library functions for signals _______________________________________________________________________________ @@ -65,6 +65,7 @@ putvec (writes a sample to each output signal) isigsettime (skips to a specified time in each signal) isgsettime (skips to a specified time in a specified signal group) + tnextvec [10.4.13] (skips to next valid sample of a specified signal) setibsize [5.0](sets the default buffer size for getvec) setobsize [5.0](sets the default buffer size for putvec) newheader (creates a new header file) @@ -276,6 +277,7 @@ } **igd; static WFDB_Sample *tvector; /* getvec workspace */ static WFDB_Sample *uvector; /* isgsettime workspace */ +static WFDB_Sample *vvector; /* tnextvec workspace */ static int tuvlen; /* lengths of tvector and uvector in samples */ static WFDB_Time istime; /* time of next input sample */ static int ibsize; /* default input buffer size */ @@ -1950,10 +1952,18 @@ for (si = framelen = 0; si < nisig; si++) framelen += isd[si]->info.spf; - /* Allocate workspace for getvec and isgsettime. */ + /* Allocate workspace for getvec, isgsettime, and tnextvec. */ if (framelen > tuvlen) { SREALLOC(tvector, framelen, sizeof(WFDB_Sample)); SREALLOC(uvector, framelen, sizeof(WFDB_Sample)); + if (nvsig > nisig) { + int vframelen; + for (si = vframelen = 0; si < nvsig; si++) + vframelen += vsd[si]->info.spf; + SREALLOC(vvector, vframelen, sizeof(WFDB_Sample)); + } + else + SREALLOC(vvector, framelen, sizeof(WFDB_Sample)); } tuvlen = framelen; @@ -2193,8 +2203,14 @@ } /* Otherwise, p is either an integer too large to be a signal number or a string containing a non-digit character. Assume it's a signal name. */ - for (s = 0; s < nisig; s++) - if ((q = isd[s]->info.desc) && strcmp(p, q) == 0) return (s); + if (need_sigmap) { + for (s = 0; s < nvsig; s++) + if ((q = vsd[s]->info.desc) && strcmp(p, q) == 0) return (s); + } + else { + for (s = 0; s < nisig; s++) + if ((q = isd[s]->info.desc) && strcmp(p, q) == 0) return (s); + } /* No match found. */ return (-1); } @@ -2489,6 +2505,61 @@ return (stat); } +FSITIME tnextvec(WFDB_Signal s, WFDB_Time t) +{ + int stat = 0; + WFDB_Time tf; + + if (in_msrec && need_sigmap) { /* variable-layout multi-segment record */ + if (s >= nvsig) { + wfdb_error("nextvect: illegal signal number %d\n", s); + return ((WFDB_Time) -1); + } + /* Go to the start (t) if not already there. */ + if (t != istime && isigsettime(t) < 0) return ((WFDB_Time) -1); + while (stat >= 0) { + char *p = vsd[s]->info.desc, *q; + int ss; + + tf = segp->samp0 + segp->nsamp; /* end of current segment */ + /* Check if signal s is available in the current segment. */ + for (ss = 0; ss < nisig; ss++) + if ((q = isd[ss]->info.desc) && strcmp(p, q) == 0) + break; + if (ss < nisig) { + /* The current segment contains the desired signal. + Read samples until we find a valid one or reach + the end of the segment. */ + for ( ; t <= tf && (stat = getvec(vvector)) > 0; t++) + if (vvector[s] != WFDB_INVALID_SAMPLE) { + isigsettime(t); + return (t); + } + if (stat < 0) return ((WFDB_Time) -1); + } + /* Go on to the next segment. */ + if (t != tf) stat = isigsettime(t = tf); + } + } + else { /* single-segment or fixed-layout multi-segment record */ + /* Go to the start (t) if not already there. */ + if (t != istime && isigsettime(t) < 0) return ((WFDB_Time) -1); + if (s >= nisig) { + wfdb_error("nextvect: illegal signal number %d\n", s); + return ((WFDB_Time) -1); + } + for ( ; stat=getvec(vvector) > 0; t++) + /* Read samples until we find a valid one or reach the end of the + record. */ + if (vvector[s] != WFDB_INVALID_SAMPLE) { + isigsettime(t); + return (t); + } + } + /* Error or end of record without finding another sample of signal s. */ + return ((WFDB_Time) stat); +} + FINT setibsize(int n) { if (nisig) { @@ -2564,11 +2635,11 @@ } /* Write the general information line. */ - (void)wfdb_fprintf(oheader, "%s %d %g", record, nsig, ffreq); + (void)wfdb_fprintf(oheader, "%s %d %.12g", record, nsig, ffreq); if ((cfreq > 0.0 && cfreq != ffreq) || bcount != 0.0) { - (void)wfdb_fprintf(oheader, "/%g", cfreq); + (void)wfdb_fprintf(oheader, "/%.12g", cfreq); if (bcount != 0.0) - (void)wfdb_fprintf(oheader, "(%g)", bcount); + (void)wfdb_fprintf(oheader, "(%.12g)", bcount); } (void)wfdb_fprintf(oheader, " %ld", nsig > 0 ? siarray[0].nsamp : 0L); if (btime != 0L || bdate != (WFDB_Date)0) { @@ -2597,7 +2668,7 @@ ogd[osd[s]->info.group]->start); else if (prolog_bytes) (void)wfdb_fprintf(oheader, "+%ld", prolog_bytes); - (void)wfdb_fprintf(oheader, " %g", siarray[s].gain); + (void)wfdb_fprintf(oheader, " %.12g", siarray[s].gain); if (siarray[s].baseline != siarray[s].adczero) (void)wfdb_fprintf(oheader, "(%d)", siarray[s].baseline); if (siarray[s].units && (p = strtok(siarray[s].units, " \t\n\r"))) @@ -2703,11 +2774,11 @@ } /* Write the first line of the master header. */ - (void)wfdb_fprintf(oheader,"%s/%u %d %g", record, nsegments, nsig, msfreq); + (void)wfdb_fprintf(oheader,"%s/%u %d %.12g", record, nsegments, nsig, msfreq); if ((mscfreq > 0.0 && mscfreq != msfreq) || msbcount != 0.0) { - (void)wfdb_fprintf(oheader, "/%g", mscfreq); + (void)wfdb_fprintf(oheader, "/%.12g", mscfreq); if (msbcount != 0.0) - (void)wfdb_fprintf(oheader, "(%g)", msbcount); + (void)wfdb_fprintf(oheader, "(%.12g)", msbcount); } (void)wfdb_fprintf(oheader, " %ld", msnsamples); if (msbtime != 0L || msbdate != (WFDB_Date)0) { diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/lib/wfdb.h wfdb-10.4.13/lib/wfdb.h --- wfdb-10.4.12/lib/wfdb.h 2009-01-20 23:15:10.000000000 -0500 +++ wfdb-10.4.13/lib/wfdb.h 2009-02-16 22:23:04.000000000 -0500 @@ -1,5 +1,5 @@ /* file: wfdb.h G. Moody 13 June 1983 - Last revised: 19 January 2009 wfdblib 10.4.12 + Last revised: 13 February 2009 wfdblib 10.4.13 WFDB library type, constant, structure, and function interface definitions _______________________________________________________________________________ @@ -33,7 +33,7 @@ /* WFDB library version. */ #define WFDB_MAJOR 10 #define WFDB_MINOR 4 -#define WFDB_RELEASE 12 +#define WFDB_RELEASE 13 #define WFDB_NETFILES 1 /* if 1, library includes code for HTTP, FTP clients */ #define WFDB_NETFILES_LIBCURL 1 @@ -254,6 +254,7 @@ extern FINT putann(WFDB_Annotator a, WFDB_Annotation *annot); extern FINT isigsettime(WFDB_Time t); extern FINT isgsettime(WFDB_Group g, WFDB_Time t); +extern FSITIME tnextvec(WFDB_Signal s, WFDB_Time t); extern FINT iannsettime(WFDB_Time t); extern FSTRING ecgstr(int annotation_code); extern FINT strecg(char *annotation_mnemonic_string); @@ -343,7 +344,7 @@ extern FSAMPLE muvadu(), physadu(), sample(); extern FSTRING ecgstr(), annstr(), anndesc(), timstr(), mstimstr(), datstr(), getwfdb(), getinfo(), wfdberror(), wfdbfile(); -extern FSITIME strtim(); +extern FSITIME strtim(), tnextvec(); extern FDATE strdat(); extern FVOID setafreq(), setgvmode(), wfdbquit(), wfdbquiet(), dbverbose(), setdb(), wfdbflush(), setcfreq(), setbasecount(), flushcal(), diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/lib/wfdb.h0 wfdb-10.4.13/lib/wfdb.h0 --- wfdb-10.4.12/lib/wfdb.h0 2009-01-19 16:24:37.000000000 -0500 +++ wfdb-10.4.13/lib/wfdb.h0 2009-02-13 17:08:29.000000000 -0500 @@ -1,5 +1,5 @@ /* file: wfdb.h G. Moody 13 June 1983 - Last revised: 19 January 2009 wfdblib 10.4.12 + Last revised: 13 February 2009 wfdblib 10.4.13 WFDB library type, constant, structure, and function interface definitions _______________________________________________________________________________ @@ -254,6 +254,7 @@ extern FINT putann(WFDB_Annotator a, WFDB_Annotation *annot); extern FINT isigsettime(WFDB_Time t); extern FINT isgsettime(WFDB_Group g, WFDB_Time t); +extern FSITIME tnextvec(WFDB_Signal s, WFDB_Time t); extern FINT iannsettime(WFDB_Time t); extern FSTRING ecgstr(int annotation_code); extern FINT strecg(char *annotation_mnemonic_string); @@ -343,7 +344,7 @@ extern FSAMPLE muvadu(), physadu(), sample(); extern FSTRING ecgstr(), annstr(), anndesc(), timstr(), mstimstr(), datstr(), getwfdb(), getinfo(), wfdberror(), wfdbfile(); -extern FSITIME strtim(); +extern FSITIME strtim(), tnextvec(); extern FDATE strdat(); extern FVOID setafreq(), setgvmode(), wfdbquit(), wfdbquiet(), dbverbose(), setdb(), wfdbflush(), setcfreq(), setbasecount(), flushcal(), diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/NEWS wfdb-10.4.13/NEWS --- wfdb-10.4.12/NEWS 2009-01-20 23:49:17.000000000 -0500 +++ wfdb-10.4.13/NEWS 2009-02-16 22:48:37.000000000 -0500 @@ -1,3 +1,28 @@ +10.4.13: + A new WFDB library function, tnextvec(), finds the next valid sample + from a chosen signal, occurring at or after a specified time. This + function is particularly useful when reading variable-layout + multi-segment records that may have lengthy gaps in signals of interest. + + For portability, the WFDB library has always stored parameters such as + sampling frequency and gain as strings rather than as floating-point + numbers. Although the resultant loss of precision has been almost + always negligible, it has been observable in the specific case of + converting very large time intervals from sample intervals to seconds, + when the sampling frequency in Hz cannot be represented exactly in + binary (e.g., if the sampling frequency is once per minute, or 1/60 Hz). + This situation cannot be wholly avoided, but it can be minimized. + Changes in this release, in setheader() and in functions that record + time units in annotation files, increase the precision with which + non-integer parameters are recorded, so that loss of precision as + a result of converting them to and from strings should almost never + be observable. + + Several options have been added to rdsamp, which can now print the + time of each sample in a variey of formats, and can use the new + tnextvec() function (see above) to search for valid samples of a + signal of interest. + 10.4.12: The rule for sorting annotations within a file has been changed to allow a much larger number of simultaneous annotations (i.e., diff -Naur --exclude Makefile --exclude info wfdb-10.4.12/wave/mainpan.c wfdb-10.4.13/wave/mainpan.c --- wfdb-10.4.12/wave/mainpan.c 2005-06-10 10:32:11.000000000 -0400 +++ wfdb-10.4.13/wave/mainpan.c 2009-02-15 13:00:31.000000000 -0500 @@ -1,5 +1,5 @@ /* file: mainpan.c G. Moody 30 April 1990 - Last revised: 10 June 2005 + Last revised: 15 February 2009 Functions for the main control panel of WAVE ------------------------------------------------------------------------------- @@ -110,7 +110,7 @@ record_item = xv_create(load_panel, PANEL_TEXT, XV_HELP_DATA, "wave:file.load.record", PANEL_LABEL_STRING, "Record: ", - PANEL_VALUE_DISPLAY_LENGTH, 8, + PANEL_VALUE_DISPLAY_LENGTH, 32, PANEL_NOTIFY_PROC, disp_proc, PANEL_VALUE, record, 0); @@ -754,8 +754,36 @@ display_start_time = 0L; cache_time = -1L; break; - case ']': /* Find next occurrence of specified annotation. */ + case ']': /* Find next occurrence of specified annotation or signal. */ case '[': /* Find previous occurrence of specified annotation. */ + if (1) { + char *fp = (char *)xv_get(find_item, PANEL_VALUE); + + if ((i = findsig(fp)) >= 0) { + WFDB_Time tnext = tnextvec(i, display_start_time + nsamp); + + if (tnext >= 0L) { + display_start_time = tnext; + cache_time = -1L; + break; + } + else { +#ifdef NOTICE + Xv_notice notice = xv_create((Frame)frame, NOTICE, + XV_SHOW, TRUE, +#else + (void)notice_prompt((Frame)frame, (Event *)NULL, +#endif + NOTICE_MESSAGE_STRINGS, + "No match found!", 0, + NOTICE_BUTTON_YES, "Continue", 0); +#ifdef NOTICE + xv_destroy_safe(notice); +#endif + break; + } + } + } if (annotator[0]) { char *fp = (char *)xv_get(find_item, PANEL_VALUE); static char auxstr[256];