Exceptions

All exceptions inherit from ECGDataKitError.

Import: from ecgdatakit import ECGDataKitError, UnsupportedFormatError, ...

ECGDataKitError

Base exception for all ECGDataKit errors.

UnsupportedFormatError

File format not recognized by any parser, or a recognized format variant that is not supported. It also subclasses ValueError.

CorruptedFileError

File is truncated or structurally invalid.

MissingElementError

Required element or field is missing from the file.

ChecksumError

Checksum or CRC validation failed.

RawSamplesError

Operation requires physical-unit samples but the lead still contains raw ADC values. Call to_physical() first.

A missing optional dependency (for example pydicom for DICOM files) raises ImportError with the install command.

Warnings

ChecksumWarning

Stored checksum does not match the computed one. The file is still parsed and raw_metadata["checksum_valid"] is set to False. Some devices never write a real checksum, so in batch processing you can silence it with warnings.filterwarnings("ignore", category=ChecksumWarning).

Example

from ecgdatakit import FileParser, UnsupportedFormatError

try:
    record = FileParser().parse("unknown.bin")
except UnsupportedFormatError as e:
    print(f"Format not supported: {e}")
from ecgdatakit.exceptions import RawSamplesError

try:
    lead.convert_units("mV")
except RawSamplesError:
    lead = lead.to_physical().convert_units("mV")

Full API

exception ecgdatakit.exceptions.ECGDataKitError[source]

Bases: Exception

Base exception for all ecgdatakit errors.

exception ecgdatakit.exceptions.UnsupportedFormatError[source]

Bases: ECGDataKitError, ValueError

File format is not recognized or not supported.

Also a ValueError, which FileParser.parse() raised for unknown files before this exception existed.

exception ecgdatakit.exceptions.CorruptedFileError[source]

Bases: ECGDataKitError

File appears corrupted or truncated.

exception ecgdatakit.exceptions.MissingElementError[source]

Bases: ECGDataKitError

Expected XML element or binary field is missing.

exception ecgdatakit.exceptions.ChecksumError[source]

Bases: ECGDataKitError

File checksum validation failed.

exception ecgdatakit.exceptions.RawSamplesError[source]

Bases: ECGDataKitError

Operation requires physical-unit samples but samples are still raw ADC.

Call Lead.to_physical() or ECGRecord.to_physical() first.

exception ecgdatakit.exceptions.ChecksumWarning[source]

Bases: UserWarning

Stored checksum does not match the computed one.

Silence it in batch processing with warnings.filterwarnings("ignore", category=ChecksumWarning).