Skip to content

Commit f739ae9

Browse files
committed
make target test file smaller
1 parent 1527ea6 commit f739ae9

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

sampledata/p10143.dat

-37.4 MB
Binary file not shown.

sampledata/p10143.hea

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
p10143 2 500 10260010
2-
p10143.dat 61 200 16 0 0 0 0 FECG
3-
p10143.dat 61 200 16 0 0 0 0 UC
1+
p10143 2 500 450000
2+
p10143.dat 61 200 16 0 -20863 18173 0 FECG
3+
p10143.dat 61 200 16 0 12175 9780 0 UC

wfdb/_signals.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,6 @@ def rddat(filename, dirname, pbdir, fmt, nsig,
428428
else:
429429
sigbytes = getdatbytes(filename, dirname, pbdir, fmt, startbyte, nreadsamples)
430430

431-
432-
433431
# Read the required bytes from the dat file.
434432
# Then continue to process the read values into proper samples
435433
if fmt == '212':
@@ -512,15 +510,17 @@ def rddat(filename, dirname, pbdir, fmt, nsig,
512510
elif fmt == '160':
513511
sigbytes = sigbytes - 32768
514512

513+
515514
# No extra samples/frame. Obtain original uniform numpy array
516515
if tsampsperframe==nsig:
517516

518517
# Reshape into multiple channels
519-
sig = sigbytes.reshape(-1, nsig).astype('int')
518+
sig = sigbytes.reshape(-1, nsig)
520519

521520
# Skew the signal
522521
sig = skewsig(sig, skew, nsig, readlen)
523522

523+
524524
# Extra frames present to be smoothed. Obtain averaged uniform numpy array
525525
elif smoothframes:
526526

@@ -700,7 +700,8 @@ def getdatbytes(filename, dirname, pbdir, fmt, startbyte, nsamp):
700700
fp.seek(startbyte)
701701

702702
# Read file using corresponding dtype
703-
sigbytes = np.fromfile(fp, dtype=np.dtype(dataloadtypes[fmt]), count=elementcount)
703+
# Cast to int64 for further processing
704+
sigbytes = np.fromfile(fp, dtype=np.dtype(dataloadtypes[fmt]), count=elementcount).astype('int')
704705

705706
fp.close()
706707

@@ -743,7 +744,7 @@ def bytes2samples(sigbytes, nsamp, fmt):
743744
sig[sig > 2047] -= 4096
744745
sig[sig > 2047] -= 4096
745746

746-
elif fmt == '310':
747+
elif fmt == '310':
747748
pass
748749

749750
elif fmt == '311':
@@ -752,7 +753,7 @@ def bytes2samples(sigbytes, nsamp, fmt):
752753

753754

754755
# Skew the signal and shave off extra samples
755-
def skewsig(sig, skew, nsig, readlen, sampsperframe):
756+
def skewsig(sig, skew, nsig, readlen, sampsperframe=None):
756757

757758
if max(skew)>0:
758759

@@ -797,7 +798,7 @@ def checksigdims(sig, readlen, nsig, sampsperframe):
797798
if len(sig) != nsig:
798799
raise ValueError('Samples were not loaded correctly')
799800
for ch in range(nsig):
800-
if len(sig[ch]) != sampsperframe[ch] * readlen
801+
if len(sig[ch]) != sampsperframe[ch] * readlen:
801802
raise ValueError('Samples were not loaded correctly')
802803

803804

wfdb/downloads.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def streamdat(filename, pbdir, fmt, bytecount, startbyte, datatypes):
5858
sigbytes = r.content
5959

6060
# Convert to numpy array
61-
sigbytes = np.fromstring(sigbytes, dtype = np.dtype(datatypes[fmt]))
61+
# Cast to int64 for further processing
62+
sigbytes = np.fromstring(sigbytes, dtype = np.dtype(datatypes[fmt])).astype('int')
6263

6364
return sigbytes
6465

0 commit comments

Comments
 (0)