@@ -697,7 +697,7 @@ def multi_to_single(self, physical, return_res=64):
697
697
Create a Record object from the MultiRecord object. All signal
698
698
segments will be combined into the new object's `p_signal` or
699
699
`d_signal` field. For digital format, the signals must have
700
- the same storage format, baseline, and adcgain in all segments.
700
+ the same storage format, baseline, and adc_gain in all segments.
701
701
702
702
Parameters
703
703
----------
@@ -722,7 +722,7 @@ def multi_to_single(self, physical, return_res=64):
722
722
del (fields [attr ])
723
723
724
724
# Get the formats, signal names and units from the first segment
725
- for attr in ['fmt' , 'adcgain ' , 'baseline' , 'units' , 'sig_name' ]:
725
+ for attr in ['fmt' , 'adc_gain ' , 'baseline' , 'units' , 'sig_name' ]:
726
726
fields [attr ] = getattr (self .segments [0 ], attr )
727
727
728
728
# Figure out attribute to set, and dtype.
@@ -742,8 +742,10 @@ def multi_to_single(self, physical, return_res=64):
742
742
# pass the test.
743
743
if self .layout == 'variable' :
744
744
for seg in self .segments [1 :]:
745
- segment_channels = get_wanted_channels (fields ['sig_name' ], seg , pad = True )
746
- for attr in ['fmt' , 'adcgain' , 'baseline' , 'units' , 'sig_name' ]:
745
+ segment_channels = get_wanted_channels (fields ['sig_name' ],
746
+ seg .sig_name ,
747
+ pad = True )
748
+ for attr in ['fmt' , 'adc_gain' , 'baseline' , 'units' , 'sig_name' ]:
747
749
for ch in range (self .n_sig ):
748
750
# Skip if the signal is not contained in the segment
749
751
if segment_channels [ch ] is None :
@@ -752,7 +754,10 @@ def multi_to_single(self, physical, return_res=64):
752
754
raise Exception ('This variable layout multi-segment record cannot be converted to single segment, in digital format.' )
753
755
754
756
sig_attr = 'd_signal'
755
- dtype = ???
757
+ # Figure out the largest required dtype
758
+ dtype = _signal .npdtype (_signal .wfdbfmtres (fields ['fmt' ],
759
+ maxres = True ),
760
+ discrete = True )
756
761
nan_vals = _signal .digi_nan (fields ['fmt' ])
757
762
758
763
combined_signal = np .zeros ([self .sig_len , self .n_sig ], dtype = dtype )
@@ -780,15 +785,16 @@ def multi_to_single(self, physical, return_res=64):
780
785
# Get the segment channels to copy over for each
781
786
# overall channel
782
787
segment_channels = get_wanted_channels (fields ['sig_name' ],
783
- seg , pad = True )
788
+ seg .sig_name ,
789
+ pad = True )
784
790
for ch in range (self .n_sig ):
785
791
# Fill with invalids if segment does not contain
786
792
# signal
787
793
if segment_channels [ch ] is None :
788
794
combined_signal [start_samps [i ]:end_samps [i ], ch ] = nan_vals [ch ]
789
795
# Copy over relevant signal
790
796
else :
791
- combined_signal [start_samps [i ]:end_samps [i ], ch ] = getattr (seg , sig_attr )
797
+ combined_signal [start_samps [i ]:end_samps [i ], ch ] = getattr (seg , sig_attr )[:, segment_channels [ ch ]]
792
798
793
799
# Create the single segment Record object and set attributes
794
800
record = Record ()
0 commit comments