@@ -900,7 +900,7 @@ def _rd_segment(file_name, dir_name, pn_dir, fmt, n_sig, sig_len, byte_offset,
900900 sampto : int
901901 The final sample number to be read from the signals.
902902 smooth_frames : bool
903- Whether to return the result as a two-dimensional array .
903+ Deprecated. Must be set to False .
904904 ignore_skew : bool
905905 Used when reading records with at least one skewed signal.
906906 Specifies whether to apply the skew to align the signals in the
@@ -920,16 +920,14 @@ def _rd_segment(file_name, dir_name, pn_dir, fmt, n_sig, sig_len, byte_offset,
920920
921921 Returns
922922 -------
923- signals : ndarray, list
924- The signals read from the dat file(s). A 2d numpy array is
925- returned if `smooth_frames` is True. Otherwise a list of 1d
926- numpy arrays is returned.
923+ signals : list
924+ The signals read from the dat file(s). Each signal is returned as a
925+ one-dimensional numpy array.
927926
928927 Notes
929928 -----
930- 'channels', 'sampfrom', 'sampto', 'smooth_frames', and 'ignore_skew'
931- are user desired input fields. All other parameters are
932- specifications of the segment.
929+ 'channels', 'sampfrom', 'sampto', and 'ignore_skew' are user desired
930+ input fields. All other parameters are specifications of the segment.
933931
934932 """
935933 # Check for valid inputs
@@ -993,61 +991,35 @@ def _rd_segment(file_name, dir_name, pn_dir, fmt, n_sig, sig_len, byte_offset,
993991 r_w_channel [fn ] = [c - min (datchannel [fn ]) for c in w_channel [fn ]]
994992 out_dat_channel [fn ] = [channels .index (c ) for c in w_channel [fn ]]
995993
996- # Signals with multiple samples/frame are smoothed, or all signals have 1 sample/frame.
997- # Return uniform numpy array
998994 if smooth_frames :
999- # Figure out the largest required dtype for the segment to minimize memory usage
1000- max_dtype = _np_dtype (_fmt_res (fmt , max_res = True ), discrete = True )
1001- # Allocate signal array. Minimize dtype
1002- signals = np .zeros ([sampto - sampfrom , len (channels )], dtype = max_dtype )
1003-
1004- # Read each wanted dat file and store signals
1005- for fn in w_file_name :
1006- datsignals = _rd_dat_signals (
1007- file_name = fn ,
1008- dir_name = dir_name ,
1009- pn_dir = pn_dir ,
1010- fmt = w_fmt [fn ],
1011- n_sig = len (datchannel [fn ]),
1012- sig_len = sig_len ,
1013- byte_offset = w_byte_offset [fn ],
1014- samps_per_frame = w_samps_per_frame [fn ],
1015- skew = w_skew [fn ],
1016- init_value = w_init_value [fn ],
1017- sampfrom = sampfrom ,
1018- sampto = sampto ,
1019- smooth_frames = smooth_frames ,
1020- no_file = no_file ,
1021- sig_data = sig_data )
1022- signals [:, out_dat_channel [fn ]] = datsignals [:, r_w_channel [fn ]]
995+ raise ValueError ('smooth_frames=True is not supported' )
1023996
1024997 # Return each sample in signals with multiple samples/frame, without smoothing.
1025998 # Return a list of numpy arrays for each signal.
1026- else :
1027- signals = [None ] * len (channels )
1028-
1029- for fn in w_file_name :
1030- # Get the list of all signals contained in the dat file
1031- datsignals = _rd_dat_signals (
1032- file_name = fn ,
1033- dir_name = dir_name ,
1034- pn_dir = pn_dir ,
1035- fmt = w_fmt [fn ],
1036- n_sig = len (datchannel [fn ]),
1037- sig_len = sig_len ,
1038- byte_offset = w_byte_offset [fn ],
1039- samps_per_frame = w_samps_per_frame [fn ],
1040- skew = w_skew [fn ],
1041- init_value = w_init_value [fn ],
1042- sampfrom = sampfrom ,
1043- sampto = sampto ,
1044- smooth_frames = smooth_frames ,
1045- no_file = no_file ,
1046- sig_data = sig_data )
1047-
1048- # Copy over the wanted signals
1049- for cn in range (len (out_dat_channel [fn ])):
1050- signals [out_dat_channel [fn ][cn ]] = datsignals [r_w_channel [fn ][cn ]]
999+ signals = [None ] * len (channels )
1000+
1001+ for fn in w_file_name :
1002+ # Get the list of all signals contained in the dat file
1003+ datsignals = _rd_dat_signals (
1004+ file_name = fn ,
1005+ dir_name = dir_name ,
1006+ pn_dir = pn_dir ,
1007+ fmt = w_fmt [fn ],
1008+ n_sig = len (datchannel [fn ]),
1009+ sig_len = sig_len ,
1010+ byte_offset = w_byte_offset [fn ],
1011+ samps_per_frame = w_samps_per_frame [fn ],
1012+ skew = w_skew [fn ],
1013+ init_value = w_init_value [fn ],
1014+ sampfrom = sampfrom ,
1015+ sampto = sampto ,
1016+ smooth_frames = smooth_frames ,
1017+ no_file = no_file ,
1018+ sig_data = sig_data )
1019+
1020+ # Copy over the wanted signals
1021+ for cn in range (len (out_dat_channel [fn ])):
1022+ signals [out_dat_channel [fn ][cn ]] = datsignals [r_w_channel [fn ][cn ]]
10511023
10521024 return signals
10531025
@@ -1088,7 +1060,7 @@ def _rd_dat_signals(file_name, dir_name, pn_dir, fmt, n_sig, sig_len,
10881060 sampto : int
10891061 The final sample number to be read from the signals.
10901062 smooth_frames : bool
1091- Whether to return the result as a two-dimensional array .
1063+ Deprecated. Must be set to False .
10921064 no_file : bool, optional
10931065 Used when using this function with just an array of signal data
10941066 and no associated file to read the data from.
@@ -1099,15 +1071,13 @@ def _rd_dat_signals(file_name, dir_name, pn_dir, fmt, n_sig, sig_len,
10991071 Returns
11001072 -------
11011073 signal : ndarray, list
1102- The signals read from the dat file(s). A 2d numpy array is
1103- returned if `smooth_frames` is True. Otherwise a list of 1d
1104- numpy arrays is returned.
1074+ The signals read from the dat file(s). Each signal is returned as a
1075+ one-dimensional numpy array.
11051076
11061077 Notes
11071078 -----
1108- 'channels', 'sampfrom', 'sampto', 'smooth_frames', and 'ignore_skew'
1109- are user desired input fields. All other parameters are
1110- specifications of the segment.
1079+ 'channels', 'sampfrom', 'sampto', and 'ignore_skew' are user desired
1080+ input fields. All other parameters are specifications of the segment.
11111081
11121082 """
11131083 # Check for valid inputs
@@ -1209,46 +1179,21 @@ def _rd_dat_signals(file_name, dir_name, pn_dir, fmt, n_sig, sig_len,
12091179 # At this point, dtype of sig_data is the minimum integer format
12101180 # required for storing the final digital samples.
12111181
1212- # No extra samples/frame. Obtain original uniform numpy array
1213- if smooth_frames and tsamps_per_frame == n_sig :
1214- # Reshape into multiple channels
1215- signal = sig_data .reshape (- 1 , n_sig )
1216- # Skew the signal
1217- signal = _skew_sig (signal , skew , n_sig , read_len , fmt , nan_replace )
1218- # Extra frames present to be smoothed. Obtain averaged uniform numpy array
1219- elif smooth_frames :
1220- # Allocate memory for smoothed signal.
1221- signal = np .zeros ((int (len (sig_data ) / tsamps_per_frame ) , n_sig ),
1222- dtype = sig_data .dtype )
1223-
1224- # Transfer and average samples
1225- for ch in range (n_sig ):
1226- if samps_per_frame [ch ] == 1 :
1227- signal [:, ch ] = sig_data [sum (([0 ] + samps_per_frame )[:ch + 1 ])::tsamps_per_frame ]
1228- else :
1229- if ch == 0 :
1230- startind = 0
1231- else :
1232- startind = np .sum (samps_per_frame [:ch ])
1233- signal [:,ch ] = [np .average (sig_data [ind :ind + samps_per_frame [ch ]]) for ind in range (startind ,len (sig_data ),tsamps_per_frame )]
1234- # Skew the signal
1235- signal = _skew_sig (signal , skew , n_sig , read_len , fmt , nan_replace )
1182+ if smooth_frames :
1183+ raise ValueError ('smooth_frames=True is not supported' )
12361184
1237- # Extra frames present without wanting smoothing. Return all
1238- # expanded samples.
1239- else :
1240- # List of 1d numpy arrays
1241- signal = []
1242- # Transfer over samples
1243- sig_frames = sig_data .reshape (- 1 , tsamps_per_frame )
1244- ch_start = 0
1245- for ch in range (n_sig ):
1246- ch_end = ch_start + samps_per_frame [ch ]
1247- ch_signal = sig_frames [:, ch_start :ch_end ].reshape (- 1 )
1248- signal .append (ch_signal )
1249- ch_start = ch_end
1250- # Skew the signal
1251- signal = _skew_sig (signal , skew , n_sig , read_len , fmt , nan_replace , samps_per_frame )
1185+ # List of 1d numpy arrays
1186+ signal = []
1187+ # Transfer over samples
1188+ sig_frames = sig_data .reshape (- 1 , tsamps_per_frame )
1189+ ch_start = 0
1190+ for ch in range (n_sig ):
1191+ ch_end = ch_start + samps_per_frame [ch ]
1192+ ch_signal = sig_frames [:, ch_start :ch_end ].reshape (- 1 )
1193+ signal .append (ch_signal )
1194+ ch_start = ch_end
1195+ # Skew the signal
1196+ signal = _skew_sig (signal , skew , n_sig , read_len , fmt , nan_replace , samps_per_frame )
12521197
12531198 # Integrity check of signal shape after reading
12541199 _check_sig_dims (signal , read_len , n_sig , samps_per_frame )
0 commit comments