@@ -25,7 +25,7 @@ def wrdats(self, expanded):
2525
2626 if expanded :
2727 # Using list of arrays e_d_signals
28- self .checkfield ('e_d_signals' )
28+ self .checkfield ('e_d_signals' , channels = 'all' )
2929 else :
3030 # Check the validity of the d_signals field
3131 self .checkfield ('d_signals' )
@@ -43,10 +43,9 @@ def checksignalcohesion(self, writefields, expanded):
4343
4444 # Using list of arrays e_d_signals
4545 if expanded :
46-
4746 # Set default sampsperframe
4847 spf = self .sampsperframe
49- for ch in range (nsig ):
48+ for ch in range (len ( spf ) ):
5049 if spf [ch ] is None :
5150 spf [ch ] = 1
5251
@@ -133,7 +132,7 @@ def set_p_features(self, do_dac = False, expanded=False):
133132
134133 if expanded :
135134 if do_dac == 1 :
136- self .checkfield ('e_d_signals' )
135+ self .checkfield ('e_d_signals' , channels = 'all' )
137136 self .checkfield ('fmt' , 'all' )
138137 self .checkfield ('adcgain' , 'all' )
139138 self .checkfield ('baseline' , 'all' )
@@ -143,7 +142,7 @@ def set_p_features(self, do_dac = False, expanded=False):
143142 self .e_p_signals = self .dac (expanded )
144143
145144 # Use e_p_signals to set fields
146- self .checkfield ('e_p_signals' )
145+ self .checkfield ('e_p_signals' , channels = 'all' )
147146 self .siglen = int (len (self .e_p_signals [0 ])/ self .sampsperframe [0 ])
148147 self .nsig = len (self .e_p_signals )
149148 else :
@@ -186,7 +185,7 @@ def set_d_features(self, do_adc = False, singlefmt = 1, expanded=False):
186185 if expanded :
187186 # adc is performed.
188187 if do_adc == True :
189- self .checkfield ('e_p_signals' )
188+ self .checkfield ('e_p_signals' , channels = 'all' )
190189
191190 # If there is no fmt set
192191 if self .fmt is None :
@@ -214,7 +213,7 @@ def set_d_features(self, do_adc = False, singlefmt = 1, expanded=False):
214213 self .d_signals = self .adc (expanded )
215214
216215 # Use e_d_signals to set fields
217- self .checkfield ('e_d_signals' )
216+ self .checkfield ('e_d_signals' , channels = 'all' )
218217 self .siglen = int (len (self .e_d_signals [0 ])/ self .sampsperframe [0 ])
219218 self .nsig = len (self .e_d_signals )
220219 self .initvalue = [sig [0 ] for sig in self .e_d_signals ]
@@ -399,7 +398,7 @@ def wrdatfiles(self, expanded=False):
399398 # Write the dat files
400399 if expanded :
401400 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 )
403402 else :
404403 # Create a copy to prevent overwrite
405404 dsig = self .d_signals .copy ()
@@ -1443,17 +1442,19 @@ def wfdbfmtres(fmt):
14431442# Write a dat file.
14441443# All bytes are written one at a time
14451444# 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 ):
14471446 f = open (filename ,'wb' )
14481447
14491448 # Combine list of arrays into single array
14501449 if expanded :
1450+ nsig = len (e_d_signals )
1451+ siglen = int (len (e_d_signals [0 ])/ sampsperframe [0 ])
14511452 # 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' )
14531454 # Counter for channel number
14541455 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 ]
14571458 for framenum in range (spf ):
14581459 d_signals [:, expand_ch ] = e_d_signals [ch ][framenum ::spf ]
14591460 expand_ch = expand_ch + 1
0 commit comments