Skip to content

Commit ea29e8f

Browse files
committed
improve readability
1 parent 348c09f commit ea29e8f

File tree

5 files changed

+248
-163
lines changed

5 files changed

+248
-163
lines changed

wfdb/io/_header.py

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import datetime
22
import os
33
import re
4+
import pdb
45

56
import numpy as np
67
import pandas as pd
78

89
from . import download
910
from . import _signal
1011

11-
import pdb
1212
int_types = (int, np.int64, np.int32, np.int16, np.int8)
1313
float_types = (float, np.float64, np.float32) + int_types
1414

@@ -672,14 +672,37 @@ def wfdb_strptime(time_string):
672672
return datetime.datetime.strptime(time_string, time_fmt).time()
673673

674674

675-
def get_header_lines(record_name, pb_dir):
675+
def _read_header_lines(base_record_name, dir_name, pb_dir):
676676
"""
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.
678699
679700
"""
701+
file_name = base_record_name + '.hea'
702+
680703
# Read local file
681704
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:
683706
# Record line followed by signal/segment lines if any
684707
header_lines = []
685708
# Comment lines
@@ -701,12 +724,13 @@ def get_header_lines(record_name, pb_dir):
701724
header_lines.append(line)
702725
# Read online header file
703726
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)
705729

706730
return header_lines, comment_lines
707731

708732

709-
def _read_record_line(record_line):
733+
def _parse_record_line(record_line):
710734
"""
711735
Extract fields from a record line string into a dictionary
712736
@@ -753,7 +777,7 @@ def _read_record_line(record_line):
753777
return record_fields
754778

755779

756-
def _read_signal_lines(signal_lines):
780+
def _parse_signal_lines(signal_lines):
757781
"""
758782
Extract fields from a list of signal line strings into a dictionary.
759783

0 commit comments

Comments
 (0)