MIT-LCP / MIT-LCP/wfdb-python

HeaderSyntaxError encountered when processing the PTB-XL+ database

Đang mở
#528 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Jupyter Notebook
Star
853
Fork
322
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

WFDB version: 4.1.2
header file: https://physionet.org/content/ptb-xl-plus/1.0.1/median_beats/12sl/00000/00001_medians.hea
header file content:

ge_median_beats_wfdb/00001_medians 12 500 600
ge_median_beats_wfdb/00001_medians.dat 32 6344117.125(-1842966025)/mV 32 0 -1995224836 10742 0 I
ge_median_beats_wfdb/00001_medians.dat 32 9481164.0(-2062153171)/mV 32 0 -1882011055 51500 0 II
ge_median_beats_wfdb/00001_medians.dat 32 12413200.271062272(1241320027)/mV 32 0 1775087638 10624 0 III
ge_median_beats_wfdb/00001_medians.dat 32 7809031.442164179(2038157206)/mV 32 0 2038157206 33835 0 aVR
ge_median_beats_wfdb/00001_medians.dat 32 9004124.293103449(-1625244438)/mV 32 0 -1931384663 20616 0 aVL
ge_median_beats_wfdb/00001_medians.dat 32 26843545.555555556(-1905891737)/mV 32 0 -993211188 39013 0 aVF
ge_median_beats_wfdb/00001_medians.dat 32 5577879.601744186(1690097519)/mV 32 0 1667786000 62231 0 V1
ge_median_beats_wfdb/00001_medians.dat 32 2425165.043971631(1271999065)/mV 32 0 1167716968 11832 0 V2
ge_median_beats_wfdb/00001_medians.dat 32 4021504.95543672(108580633)/mV 32 0 124666652 16354 0 V3
ge_median_beats_wfdb/00001_medians.dat 32 5302428.75409836(-853691031)/mV 32 0 -779457028 41525 0 V4
ge_median_beats_wfdb/00001_medians.dat 32 7110873.0(-2047931425)/mV 32 0 -1877270473 53744 0 V5
ge_median_beats_wfdb/00001_medians.dat 32 8323580.0(-2072571427)/mV 32 0 -1956041307 23344 0 V6

error message:

/opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages/wfdb/io/record.py:1853: in rdheader
    record_fields = _header._parse_record_line(header_lines[0])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

record_line = 'ge_median_beats_wfdb/00001_medians 12 500 600'

    def _parse_record_line(record_line: str) -> dict:
        """
        Extract fields from a record line string into a dictionary.
    
        Parameters
        ----------
        record_line : str
            The record line contained in the header file
    
        Returns
        -------
        record_fields : dict
            The fields for the given record line.
    
        """
        # Dictionary for record fields
        record_fields: Dict[str, Any] = {}
    
        # Read string fields from record line
        match = rx_record.match(record_line)
        if match is None:
>           raise HeaderSyntaxError("invalid syntax in record line")
E           wfdb.io.header.HeaderSyntaxError: invalid syntax in record line

/opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages/wfdb/io/_header.py:1021: HeaderSyntaxError

I think this is caused by the mismatch of the wfdb.io.header.rx_record with the first line of header file ge_median_beats_wfdb/00001_medians 12 500 600. rx_record is as follows:

rx_record = re.compile(
    r"""
    [ \t]* (?P<record_name>[-\w]+)
           /?(?P<n_seg>\d*)
    [ \t]+ (?P<n_sig>\d+)
    [ \t]* (?P<fs>\d*\.?\d*)
           /*(?P<counter_freq>-?\d*\.?\d*)
           \(?(?P<base_counter>-?\d*\.?\d*)\)?
    [ \t]* (?P<sig_len>\d*)
    [ \t]* (?P<base_time>\d{,2}:?\d{,2}:?\d{,2}\.?\d{,6})
    [ \t]* (?P<base_date>\d{,2}/?\d{,2}/?\d{,4})
    """,
    re.VERBOSE,
)

On can resolve this by changing the first line of rx_record from [ \t]* (?P<record_name>[-\w]+) to [ \t]* (?P<record_name>[-\w\/]+).

@briangow @bemoody

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với biểu thức rx_record trong wfdb/io/header.py và theo dõi cách rdheader trong wfdb/io/record.py phân tích dòng header đầu tiên. Tái hiện lỗi bằng header PTB-XL+ được hiển thị trong issue, sau đó xác minh rằng header được chấp nhận mà không làm hỏng việc phân tích các dòng record hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
55/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.