Skip to content

Commit

Permalink
Try again
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrnr committed Nov 26, 2024
1 parent 68d5c04 commit afbf542
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions wfdb/io/convert/edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,25 +399,27 @@ def read_edf(
}

sig_data = np.empty((sig_len, n_sig))
temp_sig_data = np.fromfile(edf_file, dtype=np.int64)
temp_sig_data = np.fromfile(edf_file, dtype=np.int16)
temp_sig_data = temp_sig_data.reshape((-1, sum(samps_per_block)))
temp_all_sigs = np.hsplit(temp_sig_data, np.cumsum(samps_per_block)[:-1])
for i in range(n_sig):
# Check if `samps_per_frame` has all equal values
if samps_per_frame.count(samps_per_frame[0]) == len(samps_per_frame):
sig_data[:, i] = (
temp_all_sigs[i].flatten() - baseline[i]
temp_all_sigs[i].flatten().astype("int64") - baseline[i]
) / adc_gain_all[i]
else:
temp_sig_data = temp_all_sigs[i].flatten()
if samps_per_frame[i] == 1:
sig_data[:, i] = (temp_sig_data - baseline[i]) / adc_gain_all[i]
sig_data[:, i] = (
temp_sig_data.astype("int64") - baseline[i]
) / adc_gain_all[i]
else:
for j in range(sig_len):
start_ind = j * samps_per_frame[i]
stop_ind = start_ind + samps_per_frame[i]
sig_data[j, i] = np.mean(
(temp_sig_data[start_ind:stop_ind] - baseline[i])
(temp_sig_data[start_ind:stop_ind].astype("int64") - baseline[i])
/ adc_gain_all[i]
)

Expand Down

0 comments on commit afbf542

Please sign in to comment.