java.lang.Object
com.framed.communicator.driver.protocol.mimic.WfdbHeader

public final class WfdbHeader extends Object
A parsed WFDB header (.hea) file, covering the three header flavours used by the MIMIC-III Waveform Database:
  • Master (multi-segment) header — its record line carries a /numSegments suffix and it lists one WfdbHeader.Segment per line instead of signal specifications. Segments whose name is "~" are gaps (WfdbHeader.Segment.gap()); the _layout segment has zero length and points at the layout header.
  • Layout header — a single-segment header whose signal lines use the placeholder file "~" and format 0; it establishes the canonical signal order, gains and names for a variable-layout record.
  • Segment header — a single-segment header whose signal lines reference a real .dat file; this is the source of truth for decoding that segment.

The parser is deliberately lenient: comment lines (starting with #) and blank lines are skipped, and trailing optional numeric fields on a signal line may be omitted.

  • Method Details

    • parse

      public static WfdbHeader parse(Path path) throws IOException
      Parses the header file at path.
      Parameters:
      path - the .hea file to read
      Returns:
      the parsed header
      Throws:
      IOException - if the file cannot be read
      IllegalArgumentException - if the record line is malformed
    • parse

      public static WfdbHeader parse(List<String> rawLines)
      Parses header content already read into lines. Exposed for testing without touching the file system.
      Parameters:
      rawLines - the lines of a .hea file, in order
      Returns:
      the parsed header
      Throws:
      IllegalArgumentException - if no valid record line is present
    • recordName

      public String recordName()
      Returns:
      the record identifier (without any /numSegments suffix)
    • isMultiSegment

      public boolean isMultiSegment()
      Returns:
      true if this is a master multi-segment header (has segments())
    • samplingFrequency

      public double samplingFrequency()
      Returns:
      the sampling frequency in Hz (WFDB default 250 if the field was absent)
    • numSamplesPerSignal

      public long numSamplesPerSignal()
      Returns:
      the declared number of samples per signal (0 if unspecified)
    • baseTime

      public String baseTime()
      Returns:
      the base time string (HH:MM:SS[.fff]) from the record line, or null
    • segments

      public List<WfdbHeader.Segment> segments()
      Returns:
      the ordered segment list for a master header (empty for single-segment headers)
    • signals

      public List<WfdbSignal> signals()
      Returns:
      the ordered signal specifications for a single-segment/layout header (empty otherwise)