Skip to content

Commit f78b64b

Browse files
committed
Produces EDF file from WFDB format
Introduces the conversion of WFDB files to EDF format. All data was written to the EDF file using struck.pack() so no outside packages were introduced. This implementation conserves the -h option which can now be used with help(wfdb.wfdb2edf) as well as the -o option which is now a parameter that the user must enter to specify their desired EDF file name. Further, the -v option was conserved and is no longer an option so all content will be printed to screen to help the user see what is going on and the specifications of their EDF file.
1 parent c698f03 commit f78b64b

File tree

4 files changed

+404
-6
lines changed

4 files changed

+404
-6
lines changed

wfdb/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from wfdb.io.record import (Record, MultiRecord, rdheader, rdrecord, rdsamp,
2-
wrsamp, dl_database, edf2mit, wav2mit, wfdb2mat, sampfreq, signame)
2+
wrsamp, dl_database, edf2mit, wfdb2edf, wav2mit, wfdb2mat, sampfreq, signame)
33
from wfdb.io.annotation import (Annotation, rdann, wrann, show_ann_labels,
44
show_ann_classes, ann2rr)
55
from wfdb.io.download import get_dbs, get_record_list, dl_files, set_db_index_url

wfdb/io/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from wfdb.io.record import (Record, MultiRecord, rdheader, rdrecord, rdsamp, wrsamp,
2-
dl_database, edf2mit, wav2mit, wfdb2mat, sampfreq, signame, SIGNAL_CLASSES)
2+
dl_database, edf2mit, wfdb2edf, wav2mit, wfdb2mat, sampfreq, signame, SIGNAL_CLASSES)
33
from wfdb.io._signal import est_res, wr_dat_file
44
from wfdb.io.annotation import (Annotation, rdann, wrann, show_ann_labels,
55
show_ann_classes, ann2rr)

wfdb/io/_signal.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def adc(self, expanded=False, inplace=False):
432432
for ch in range(self.n_sig):
433433
# NAN locations for the channel
434434
ch_nanlocs = np.isnan(self.e_p_signal[ch])
435-
ch_d_signal = self.e_p_signal.copy()
435+
ch_d_signal = self.e_p_signal[ch].copy()
436436
np.multiply(ch_d_signal, self.adc_gain[ch], ch_d_signal)
437437
np.add(ch_d_signal, self.baseline[ch], ch_d_signal)
438438
ch_d_signal = ch_d_signal.astype(intdtype, copy=False)
@@ -704,9 +704,14 @@ def convert_dtype(self, physical, return_res, smooth_frames):
704704
if current_dtype != return_dtype:
705705
self.p_signal = self.p_signal.astype(return_dtype, copy=False)
706706
else:
707-
for ch in range(self.n_sig):
708-
if self.e_p_signal[ch].dtype != return_dtype:
709-
self.e_p_signal[ch] = self.e_p_signal[ch].astype(return_dtype, copy=False)
707+
if self.e_p_signal is not None:
708+
for ch in range(self.n_sig):
709+
if self.e_p_signal[ch].dtype != return_dtype:
710+
self.e_p_signal[ch] = self.e_p_signal[ch].astype(return_dtype, copy=False)
711+
else:
712+
for ch in range(self.n_sig):
713+
if self.p_signal[ch].dtype != return_dtype:
714+
self.p_signal[ch] = self.p_signal[ch].astype(return_dtype, copy=False)
710715
else:
711716
return_dtype = 'int'+str(return_res)
712717
if smooth_frames is True:

0 commit comments

Comments
 (0)