diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/app/time2sec.c wfdb-10.4.18/app/time2sec.c --- wfdb-10.4.17/app/time2sec.c 2003-07-09 07:23:59.000000000 -0400 +++ wfdb-10.4.18/app/time2sec.c 2009-03-14 16:29:25.000000000 -0400 @@ -1,9 +1,9 @@ /* file: time2sec.c G. Moody 9 July 2003 - + Last revised: 14 March 2009 ------------------------------------------------------------------------------- time2sec: Convert a string in WFDB standard time format to time in seconds -Copyright (C) 2003 George B. Moody +Copyright (C) 2003-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 @@ -32,17 +32,27 @@ char **argv; { double t; + int milliseconds; + long seconds; if (argc == 4 && strcmp(argv[1], "-r") == 0) { (void)isigopen(argv[2], NULL, 0); t = strtim(argv[3]); if (t < 0) t = -t; - printf("%g\n", t/sampfreq(NULL)); + seconds = (long)(t/sampfreq(NULL)); + t -= (double)(seconds*sampfreq(NULL)); + milliseconds = (long)((t*1000.)/sampfreq(NULL) + 0.5); + if (milliseconds >= 1000) { seconds++; milliseconds -= 1000; } + printf("%ld", seconds); + if (milliseconds) + printf(".%03d", milliseconds); + printf("\n"); + // printf("%.12g\n", t/sampfreq(NULL)); exit(0); } else if (argc == 2 && argv[1][0] != '-') { setsampfreq(1000.0); - printf("%g\n", strtim(argv[1])/1000.0); + printf("%.12g\n", strtim(argv[1])/1000.0); exit(0); } diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/app/wfdbdesc.c wfdb-10.4.18/app/wfdbdesc.c --- wfdb-10.4.17/app/wfdbdesc.c 2009-01-30 11:25:55.000000000 -0500 +++ wfdb-10.4.18/app/wfdbdesc.c 2009-03-14 16:35:40.000000000 -0400 @@ -1,5 +1,5 @@ /* file: wfdbdesc.c G. Moody June 1989 - Last revised: 26 January 2009 + Last revised: 14 March 2009 ------------------------------------------------------------------------------- wfdbdesc: Describe signal specifications @@ -120,7 +120,7 @@ mstimstr(t), t); } else (void)printf("not specified\n"); - (void)printf("Sampling frequency: %g Hz\n", sampfreq(NULL)); + (void)printf("Sampling frequency: %.12g Hz\n", sampfreq(NULL)); (void)printf("%d signal%s\n", nsig, nsig == 1 ? "" : "s"); if (nsig < 1) exit(2); if (msrec && s[0].nsamp != 0L) { @@ -137,7 +137,7 @@ (void)printf(" Gain: "); if (s[i].gain == 0.) (void)printf("uncalibrated; assume %g", WFDB_DEFGAIN); - else (void)printf("%g", s[i].gain); + else (void)printf("%.12g", s[i].gain); (void)printf(" adu/%s\n", s[i].units ? s[i].units : "mV"); (void)printf(" Initial value: %d\n", s[i].initval); if (s[i].fmt != 0) diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/convert/mit2edf.c wfdb-10.4.18/convert/mit2edf.c --- wfdb-10.4.17/convert/mit2edf.c 2004-05-05 12:34:52.000000000 -0400 +++ wfdb-10.4.18/convert/mit2edf.c 2009-03-14 23:44:35.000000000 -0400 @@ -1,8 +1,8 @@ /* file: mit2edf.c G. Moody 2 November 2002 - Last revised: 5 May 2004 + Last revised: 14 March 2009 ------------------------------------------------------------------------------- Convert MIT format header and signal files to EDF (European Data Format) file -Copyright (C) 2002-2004 George B. Moody +Copyright (C) 2002-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 @@ -155,7 +155,15 @@ bytes_per_block = samples_per_frame * 2 * frames_per_block; } - if (frames_per_block < 1) { + seconds_per_block = frames_per_block / frames_per_second; + + if (frames_per_block < 1 && bytes_per_block < EDFMAXBLOCK/60) { + frames_per_block = strtim("1:0"); /* the number of frames/minute */ + bytes_per_block = 2* samples_per_frame * frames_per_block; + seconds_per_block = 60; + } + + if (bytes_per_block > EDFMAXBLOCK) { fprintf(stderr, "%s: can't convert record %s to EDF\n", pname, record); fprintf(stderr, " EDF blocks cannot be larger than %d bytes, but each input frame requires\n", @@ -166,8 +174,6 @@ exit(5); } - seconds_per_block = frames_per_block / frames_per_second; - /* Calculate the number of blocks to be written. strtim("e") is the frame number of the last frame in the record, and that of the first frame is 0, so the number of frames is strtim("e") + 1. The calculation rounds @@ -367,9 +373,9 @@ blockp[j] = blockp[j-1] + 2 * frames_per_block * si[j-1].spf; for (i = 0; i < frames_per_block; i++) { if (nsig != getframe(v)) { - /* end of input: pad last block with zeroes */ + /* end of input: pad last block with invalid samples */ for (j = 0; j < samples_per_frame; j++) - v[j] = 0; + v[j] = WFDB_INVALID_SAMPLE; } vp = v; for (j = 0; j < nsig; j++) { diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/convert/README wfdb-10.4.18/convert/README --- wfdb-10.4.17/convert/README 2008-07-23 16:03:25.000000000 -0400 +++ wfdb-10.4.18/convert/README 2009-03-14 15:23:06.000000000 -0400 @@ -31,6 +31,13 @@ writing discontinuous EDF+ files using the WFDB library, or for writing an EDF+ annotation stream, either natively or using a converter.) +The popular Matlab application (and the mostly compatible open-source Octave +application) cannot read WFDB files unless they have been prepared specifically +for Matlab. Program `wfdb2mat' does this, converting all or any part of the +samples in a record into a Matlab- and Octave-compatible '.mat' file, and also +creating a new .hea file that allows WFDB applications to read the '.mat' file +directly. + The popular .wav format used for audio files is readable by WFDB applications once a short header (.hea) file that describes the format of the .wav file has been created; 'wav2mit' does this. Note that there are many variants @@ -96,6 +103,7 @@ edf2mit.c Converts an EDF file to a WFDB record mit2edf.c Converts a WFDB record into an EDF file rdedfann.c Converts an EDF+ annotation stream into a WFDB annotation file +wfdb2mat.c Converts a WFDB record into a .mat file wav2mit.c Makes .hea file so that a .wav file is readable as a WFDB record mit2wav.c Converts a WFDB record into a .wav file ahaecg2mit.c Converts an AHA DB DVD file to a WFDB record diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/convert/wfdb2mat.c wfdb-10.4.18/convert/wfdb2mat.c --- wfdb-10.4.17/convert/wfdb2mat.c 2009-03-01 10:47:38.000000000 -0500 +++ wfdb-10.4.18/convert/wfdb2mat.c 2009-03-14 16:42:51.000000000 -0400 @@ -1,5 +1,5 @@ /* file: wfdb2mat.c G. Moody 26 February 2009 - Last revised: 1 March 2009 + Last revised: 14 March 2009 ------------------------------------------------------------------------------- wfdb2mat: Convert (all or part of) a WFDB signal file to Matlab .mat format Copyright (C) 2009 George B. Moody @@ -248,6 +248,15 @@ sprintf(matname, "%sm.mat", record); SUALLOC(orec, strlen(record)+2, sizeof(char)); sprintf(orec, "%sm", record); + /* If the input record is an EDF file, it will have a '.' in its name. + The output record will not be an EDF file, so it may not have a '.' + in its name. Replace any '.' with '_' here. */ + for (p = orec + strlen(orec) - 1; p > orec && *p != '/'; p--) + if (*p == '.') *p = '_'; + /* To avoid confusion, also make this replacement in matname, but leave + the '.' just before 'mat' alone. */ + for (p = matname + strlen(matname) - 5; p > matname && *p != '/'; p--) + if (*p == '.') *p = '_'; /* Determine if we can write 8-bit unsigned samples, or if 16 bits are needed per sample. */ @@ -256,6 +265,8 @@ for (i = 0; i < nosig; i++) { so[i] = si[sig[i]]; so[i].fname = matname; + so[i].group = 0; + so[i].spf = 1; so[i].fmt = (type == 30) ? 16 : 80; if (so[i].units == NULL) SSTRCPY(so[i].units, "mV"); } @@ -320,11 +331,11 @@ nosig, nosig == 1 ? "" : "s", nosig == 1 ? "" : "s", to-from, to == from+1 ? "" : "s", to == from+1 ? "" : "s"); printf("Duration: %s\n", timstr(to-from)); - printf("Sampling frequency: %g Hz Sampling interval: %g sec\n", + printf("Sampling frequency: %.12g Hz Sampling interval: %.10g sec\n", freq, 1/freq); printf("Row\tSignal\tGain\tBase\tUnits\n"); for (i = 0; i < nosig; i++) - printf("%d\t%s\t%g\t%d\t%s\n", i+1, so[i].desc, so[i].gain, + printf("%d\t%s\t%.12g\t%d\t%s\n", i+1, so[i].desc, so[i].gain, so[i].baseline, so[i].units); printf("\nTo convert from raw units to the physical units shown\n" "above, subtract 'base' and divide by 'gain'.\n"); diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/doc/wag-src/edf2mit.1 wfdb-10.4.18/doc/wag-src/edf2mit.1 --- wfdb-10.4.17/doc/wag-src/edf2mit.1 2008-07-23 16:01:24.000000000 -0400 +++ wfdb-10.4.18/doc/wag-src/edf2mit.1 2009-03-07 23:54:15.000000000 -0500 @@ -78,7 +78,7 @@ Note that applications built using version 10.4.5 and later versions of the WFDB library can read EDF files directly, so that the conversion performed by \fBedf2mit\fR is no longer necessary. The native WFDB files produced by -'edf2mit' can be read more efficiently and with lower latency and memory +\fBedf2mit\fR can be read more efficiently and with lower latency and memory requirements than the EDF files; in most cases, however, the difference will not be noticeable. diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/doc/wag-src/wag.ht0 wfdb-10.4.18/doc/wag-src/wag.ht0 --- wfdb-10.4.17/doc/wag-src/wag.ht0 2008-04-09 16:12:21.000000000 -0400 +++ wfdb-10.4.18/doc/wag-src/wag.ht0 2009-03-08 00:14:02.000000000 -0500 @@ -20,7 +20,7 @@ George B. Moody
Harvard-MIT Division of Health Sciences and Technology

-Copyright ©1980-2008 George B. Moody +Copyright ©1980-2009 George B. Moody

The most recent versions of the programs described in this guide may be freely downloaded from PhysioNet. For diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/doc/wag-src/wag.tex wfdb-10.4.18/doc/wag-src/wag.tex --- wfdb-10.4.17/doc/wag-src/wag.tex 2008-10-07 20:36:29.000000000 -0400 +++ wfdb-10.4.18/doc/wag-src/wag.tex 2009-03-08 00:14:55.000000000 -0500 @@ -36,7 +36,7 @@ \pagestyle{empty} \vspace*{\fill} \noindent -Copyright \copyright 1992 -- 2008 George B. Moody +Copyright \copyright 1980 -- 2009 George B. Moody \vspace{1 in} \noindent diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/doc/wag-src/xview.7 wfdb-10.4.18/doc/wag-src/xview.7 --- wfdb-10.4.17/doc/wag-src/xview.7 2000-01-30 04:13:26.000000000 -0500 +++ wfdb-10.4.18/doc/wag-src/xview.7 2009-03-09 23:16:54.000000000 -0400 @@ -1801,7 +1801,7 @@ .TP .B Description This resource takes as a value a list of modifier keys. Any semantic -meaning (mouseless command or keyboard accelerater) that would normally +meaning (mouseless command or keyboard accelerator) that would normally be associated with the listed modifiers when the keyboard focus is in a ttysw or termsw would be removed. .sp diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/doc/wpg-src/wpg0.tex wfdb-10.4.18/doc/wpg-src/wpg0.tex --- wfdb-10.4.17/doc/wpg-src/wpg0.tex 2009-03-03 12:52:08.000000000 -0500 +++ wfdb-10.4.18/doc/wpg-src/wpg0.tex 2009-03-15 08:43:18.000000000 -0400 @@ -21,7 +21,7 @@ @center Harvard-MIT Division of Health Sciences and Technology @page @vskip 0pt plus 1filll -Copyright @copyright{} 1980 -- 2008 George B. Moody +Copyright @copyright{} 1980 -- 2009 George B. Moody @sp 2 The most recent versions of the software described in this guide may be downloaded from @uref{http://www.physionet.org/}. For further @@ -510,6 +510,11 @@ WFDB Software Package distribution, for information on any more recent changes that may not be described here. +@unnumberedsubsec Changes in version 10.4.18 + +The WFDB library no longer reports spurious checksum errors when reading +EDF files, which don't have checksums. + @unnumberedsubsec Changes in version 10.4.17 Internal WFDB library function @code{wfdb_checkname} now allows hyphens @@ -520,7 +525,6 @@ WFDB library function @code{strtim} now rounds rather than truncating when the sampling frequency is not an integer. - @unnumberedsubsec Changes in version 10.4.15 WFDB library function @code{mstimstr} now outputs time to the nearest diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/doc/wpg-src/wpg.ht0 wfdb-10.4.18/doc/wpg-src/wpg.ht0 --- wfdb-10.4.17/doc/wpg-src/wpg.ht0 2008-07-14 11:44:42.000000000 -0400 +++ wfdb-10.4.18/doc/wpg-src/wpg.ht0 2009-03-08 00:15:49.000000000 -0500 @@ -19,7 +19,7 @@ George B. Moody
Harvard-MIT Division of Health Sciences and Technology

-Copyright ©1980-2008 George B. Moody. +Copyright ©1980-2009 George B. Moody.

The most recent versions of the software described in this guide are freely downloadable from PhysioNet. For diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/doc/wug-src/wug0.tex wfdb-10.4.18/doc/wug-src/wug0.tex --- wfdb-10.4.17/doc/wug-src/wug0.tex 2009-01-13 17:14:51.000000000 -0500 +++ wfdb-10.4.18/doc/wug-src/wug0.tex 2009-03-08 00:16:35.000000000 -0500 @@ -57,7 +57,7 @@ \pagestyle{empty} \vspace*{\fill} \noindent -Copyright \copyright 1992 -- 2008 George B. Moody +Copyright \copyright 1992 -- 2009 George B. Moody \vspace{1 in} \noindent diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/lib/signal.c wfdb-10.4.18/lib/signal.c --- wfdb-10.4.17/lib/signal.c 2009-03-04 12:46:25.000000000 -0500 +++ wfdb-10.4.18/lib/signal.c 2009-03-14 23:54:09.000000000 -0400 @@ -1,5 +1,5 @@ /* file: signal.c G. Moody 13 April 1989 - Last revised: 4 March 2009 wfdblib 10.4.17 + Last revised: 14 March 2009 wfdblib 10.4.18 WFDB library functions for signals _______________________________________________________________________________ @@ -721,7 +721,7 @@ hsd[s]->info.adcres = i; if (pmax[s] != pmin[s]) { hsd[s]->info.gain = (dmax[s] - dmin[s])/(pmax[s] - pmin[s]); - hsd[s]->info.baseline = dmax[s] - pmax[s] * hsd[s]->info.gain + 1; + hsd[s]->info.baseline = dmax[s] - pmax[s] * hsd[s]->info.gain + 0.5; } else /* gain is undefined */ hsd[s]->info.gain = hsd[s]->info.baseline = 0; @@ -1471,7 +1471,8 @@ /* Do nothing if there is no more than one input signal group and the input pointer is correct already. */ - if (nigroups < 2 && istime == (in_msrec ? t + segp->samp0 : t)) + if (nigroups < 2 && istime == (in_msrec ? t + segp->samp0 : t) && + igd[g]->start == 0) return (0); /* Find the first signal that belongs to group g. */ @@ -1751,7 +1752,7 @@ } if (--is->info.nsamp == (WFDB_Time)0L && (is->info.cksum & 0xffff) && - !in_msrec && + !in_msrec && !isedf && is->info.fmt != 0) { wfdb_error("getvec: checksum error in signal %d\n", s); stat = -4; diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/lib/wfdb.h wfdb-10.4.18/lib/wfdb.h --- wfdb-10.4.17/lib/wfdb.h 2009-03-05 06:44:39.000000000 -0500 +++ wfdb-10.4.18/lib/wfdb.h 2009-03-15 08:50:05.000000000 -0400 @@ -33,7 +33,7 @@ /* WFDB library version. */ #define WFDB_MAJOR 10 #define WFDB_MINOR 4 -#define WFDB_RELEASE 17 +#define WFDB_RELEASE 18 #define WFDB_NETFILES 1 /* if 1, library includes code for HTTP, FTP clients */ #define WFDB_NETFILES_LIBCURL 1 diff -Naur --exclude Makefile --exclude info wfdb-10.4.17/NEWS wfdb-10.4.18/NEWS --- wfdb-10.4.17/NEWS 2009-03-05 07:10:48.000000000 -0500 +++ wfdb-10.4.18/NEWS 2009-03-15 09:48:22.000000000 -0400 @@ -1,3 +1,10 @@ +10.4.18: + The WFDB library no longer reports spurious checksum errors when reading + EDF files, which don't have checksums. + + WFDB application wfdb2mat now correctly handles EDF input records, so + it is now possible to use it to convert EDF to .mat format directly. + 10.4.17: Internal WFDB library function wfdb_checkname() now allows hyphens (-) within record and annotator names. @@ -17,8 +24,8 @@ 10.4.15: WFDB library function mstimstr() now outputs time to the nearest - millisecond, rather than truncating its calculation to the next - lowest number of milliseconds. + millisecond, rather than truncating its calculation to the nearest + lower number of milliseconds. A new WFDB library function, wfdbputprolog(), can write a prolog at the beginning of a signal file. WFDB applications ignore embedded prologs.