@@ -25,7 +25,7 @@ def wrdats(self, expanded):
25
25
26
26
if expanded :
27
27
# Using list of arrays e_d_signals
28
- self .checkfield ('e_d_signals' )
28
+ self .checkfield ('e_d_signals' , channels = 'all' )
29
29
else :
30
30
# Check the validity of the d_signals field
31
31
self .checkfield ('d_signals' )
@@ -43,10 +43,9 @@ def checksignalcohesion(self, writefields, expanded):
43
43
44
44
# Using list of arrays e_d_signals
45
45
if expanded :
46
-
47
46
# Set default sampsperframe
48
47
spf = self .sampsperframe
49
- for ch in range (nsig ):
48
+ for ch in range (len ( spf ) ):
50
49
if spf [ch ] is None :
51
50
spf [ch ] = 1
52
51
@@ -133,7 +132,7 @@ def set_p_features(self, do_dac = False, expanded=False):
133
132
134
133
if expanded :
135
134
if do_dac == 1 :
136
- self .checkfield ('e_d_signals' )
135
+ self .checkfield ('e_d_signals' , channels = 'all' )
137
136
self .checkfield ('fmt' , 'all' )
138
137
self .checkfield ('adcgain' , 'all' )
139
138
self .checkfield ('baseline' , 'all' )
@@ -143,7 +142,7 @@ def set_p_features(self, do_dac = False, expanded=False):
143
142
self .e_p_signals = self .dac (expanded )
144
143
145
144
# Use e_p_signals to set fields
146
- self .checkfield ('e_p_signals' )
145
+ self .checkfield ('e_p_signals' , channels = 'all' )
147
146
self .siglen = int (len (self .e_p_signals [0 ])/ self .sampsperframe [0 ])
148
147
self .nsig = len (self .e_p_signals )
149
148
else :
@@ -186,7 +185,7 @@ def set_d_features(self, do_adc = False, singlefmt = 1, expanded=False):
186
185
if expanded :
187
186
# adc is performed.
188
187
if do_adc == True :
189
- self .checkfield ('e_p_signals' )
188
+ self .checkfield ('e_p_signals' , channels = 'all' )
190
189
191
190
# If there is no fmt set
192
191
if self .fmt is None :
@@ -214,7 +213,7 @@ def set_d_features(self, do_adc = False, singlefmt = 1, expanded=False):
214
213
self .d_signals = self .adc (expanded )
215
214
216
215
# Use e_d_signals to set fields
217
- self .checkfield ('e_d_signals' )
216
+ self .checkfield ('e_d_signals' , channels = 'all' )
218
217
self .siglen = int (len (self .e_d_signals [0 ])/ self .sampsperframe [0 ])
219
218
self .nsig = len (self .e_d_signals )
220
219
self .initvalue = [sig [0 ] for sig in self .e_d_signals ]
@@ -399,7 +398,7 @@ def wrdatfiles(self, expanded=False):
399
398
# Write the dat files
400
399
if expanded :
401
400
for fn in filenames :
402
- wrdatfile (fn , datfmts [fn ], None , datoffsets [fn ], True , [self .e_d_signals [ch ] for ch in datchannels [fn ]])
401
+ wrdatfile (fn , datfmts [fn ], None , datoffsets [fn ], True , [self .e_d_signals [ch ] for ch in datchannels [fn ]], self . sampsperframe )
403
402
else :
404
403
# Create a copy to prevent overwrite
405
404
dsig = self .d_signals .copy ()
@@ -1443,17 +1442,19 @@ def wfdbfmtres(fmt):
1443
1442
# Write a dat file.
1444
1443
# All bytes are written one at a time
1445
1444
# to avoid endianness issues.
1446
- def wrdatfile (filename , fmt , d_signals , byteoffset , expanded = False , e_d_signals = None ):
1445
+ def wrdatfile (filename , fmt , d_signals , byteoffset , expanded = False , e_d_signals = None , sampsperframe = None ):
1447
1446
f = open (filename ,'wb' )
1448
1447
1449
1448
# Combine list of arrays into single array
1450
1449
if expanded :
1450
+ nsig = len (e_d_signals )
1451
+ siglen = int (len (e_d_signals [0 ])/ sampsperframe [0 ])
1451
1452
# Effectively create MxN signal, with extra frame samples acting like extra channels
1452
- d_signals = np .zeros ((self . siglen , sum (self . sampsperframe )), dtype = 'int64' )
1453
+ d_signals = np .zeros ((siglen , sum (sampsperframe )), dtype = 'int64' )
1453
1454
# Counter for channel number
1454
1455
expand_ch = 0
1455
- for ch in range (self . nsig ):
1456
- spf = self . sampsperframe [ch ]
1456
+ for ch in range (nsig ):
1457
+ spf = sampsperframe [ch ]
1457
1458
for framenum in range (spf ):
1458
1459
d_signals [:, expand_ch ] = e_d_signals [ch ][framenum ::spf ]
1459
1460
expand_ch = expand_ch + 1
0 commit comments