@@ -229,11 +229,11 @@ def load_rhs(folder: str, file_expr: str):
229229
230230 Example:
231231 # Read data
232- >>> signals, time = load_rhs("/home/inbox/organoids21/032520_US_885kHz_sham", file_expr="amp*dat")
232+ >>> rhs_data = load_rhs("/home/inbox/organoids21/032520_US_885kHz_sham", file_expr="amp*dat")
233233
234234 # Plot data
235- >>> for signal in signals:
236- >>> plt.plot(time, signal)
235+ >>> for signal in rhs_data[" signals"] :
236+ >>> plt.plot(rhs_data[" time"] , signal)
237237 >>> plt.xlabel("Time (s)")
238238 >>> plt.ylabel("Signal (microvolts)")
239239 >>> plt.show()
@@ -243,8 +243,10 @@ def load_rhs(folder: str, file_expr: str):
243243 file_expr (str): regex pattern of the file names to be read.
244244
245245 Returns:
246- signals (np.array_like): Signal amplitudes in microvolts
247- time (np.array_like): Time stamps in seconds
246+ rhs_data (dict): RHS data.
247+ rhs_data["header"] (dict): Header.
248+ rhs_data["signals"] (np.array_like): Signal amplitudes in microvolts.
249+ rhs_data["timestamps"] (np.array_like): Relative timestamps in seconds.
248250 """
249251
250252 header_filepath = next (Path (folder ).glob ("info.rhs" ))
@@ -253,16 +255,17 @@ def load_rhs(folder: str, file_expr: str):
253255
254256 time_file = next (Path (folder ).glob ("time.dat" ))
255257
256- time = (
258+ timestamps = (
257259 np .memmap (time_file , dtype = np .int32 )
258260 / header ["frequency_parameters" ]["amplifier_sample_rate" ]
259261 )
260262
261263 file_paths = list (Path (folder ).glob (file_expr ))
262- signals = np .empty ([len (file_paths ), len (time )])
264+ signals = np .empty ([len (file_paths ), len (timestamps )])
263265
264266 for i , file_path in enumerate (file_paths ):
265267 signals [i , :] = np .memmap (file_path , dtype = np .int16 )
266268 signals = signals * 0.195 # Convert to microvolts
267269
268- return signals , time
270+ rhs_data = dict (header = header , signals = signals , timestamps = timestamps )
271+ return rhs_data
0 commit comments