1
1
import datetime
2
2
import os
3
3
import re
4
+ import pdb
4
5
5
6
import numpy as np
6
7
import pandas as pd
7
8
8
9
from . import download
9
10
from . import _signal
10
11
11
- import pdb
12
12
int_types = (int , np .int64 , np .int32 , np .int16 , np .int8 )
13
13
float_types = (float , np .float64 , np .float32 ) + int_types
14
14
@@ -672,14 +672,37 @@ def wfdb_strptime(time_string):
672
672
return datetime .datetime .strptime (time_string , time_fmt ).time ()
673
673
674
674
675
- def get_header_lines ( record_name , pb_dir ):
675
+ def _read_header_lines ( base_record_name , dir_name , pb_dir ):
676
676
"""
677
- Read a header file to get comment and non-comment lines
677
+ Read the lines in a local or remote header file.
678
+
679
+ Parameters
680
+ ----------
681
+ base_record_name : str
682
+ The base name of the WFDB record to be read, without any file
683
+ extensions.
684
+ dir_name : str
685
+ The local directory location of the header file. This parameter
686
+ is ignored if `pb_dir` is set.
687
+ pb_dir : str
688
+ Option used to stream data from Physiobank. The Physiobank
689
+ database directory from which to find the required record files.
690
+ eg. For record '100' in 'http://physionet.org/physiobank/database/mitdb'
691
+ pb_dir='mitdb'.
692
+
693
+ Returns
694
+ -------
695
+ header_lines : list
696
+ List of strings corresponding to the header lines.
697
+ comment_lines : list
698
+ List of strings corresponding to the comment lines.
678
699
679
700
"""
701
+ file_name = base_record_name + '.hea'
702
+
680
703
# Read local file
681
704
if pb_dir is None :
682
- with open (record_name + ".hea" , 'r' ) as fp :
705
+ with open (os . path . join ( dir_name , file_name ) , 'r' ) as fp :
683
706
# Record line followed by signal/segment lines if any
684
707
header_lines = []
685
708
# Comment lines
@@ -701,12 +724,13 @@ def get_header_lines(record_name, pb_dir):
701
724
header_lines .append (line )
702
725
# Read online header file
703
726
else :
704
- header_lines , comment_lines = download .stream_header (record_name , pb_dir )
727
+ header_lines , comment_lines = download ._stream_header (file_name ,
728
+ pb_dir )
705
729
706
730
return header_lines , comment_lines
707
731
708
732
709
- def _read_record_line (record_line ):
733
+ def _parse_record_line (record_line ):
710
734
"""
711
735
Extract fields from a record line string into a dictionary
712
736
@@ -753,7 +777,7 @@ def _read_record_line(record_line):
753
777
return record_fields
754
778
755
779
756
- def _read_signal_lines (signal_lines ):
780
+ def _parse_signal_lines (signal_lines ):
757
781
"""
758
782
Extract fields from a list of signal line strings into a dictionary.
759
783
0 commit comments