Exceptions¶
All exceptions inherit from ECGDataKitError.
Import: from ecgdatakit import ECGDataKitError, UnsupportedFormatError, ...
ECGDataKitErrorBase exception for all ECGDataKit errors.
UnsupportedFormatErrorFile format not recognized by any parser, or a recognized format variant that is not supported. It also subclasses
ValueError.CorruptedFileErrorFile is truncated or structurally invalid.
MissingElementErrorRequired element or field is missing from the file.
ChecksumErrorChecksum or CRC validation failed.
RawSamplesErrorOperation 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¶
ChecksumWarningStored checksum does not match the computed one. The file is still parsed and
raw_metadata["checksum_valid"]is set toFalse. Some devices never write a real checksum, so in batch processing you can silence it withwarnings.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:
ExceptionBase exception for all ecgdatakit errors.
- exception ecgdatakit.exceptions.UnsupportedFormatError[source]¶
Bases:
ECGDataKitError,ValueErrorFile format is not recognized or not supported.
Also a
ValueError, whichFileParser.parse()raised for unknown files before this exception existed.
- exception ecgdatakit.exceptions.CorruptedFileError[source]¶
Bases:
ECGDataKitErrorFile appears corrupted or truncated.
- exception ecgdatakit.exceptions.MissingElementError[source]¶
Bases:
ECGDataKitErrorExpected XML element or binary field is missing.
- exception ecgdatakit.exceptions.ChecksumError[source]¶
Bases:
ECGDataKitErrorFile checksum validation failed.
- exception ecgdatakit.exceptions.RawSamplesError[source]¶
Bases:
ECGDataKitErrorOperation requires physical-unit samples but samples are still raw ADC.
Call
Lead.to_physical()orECGRecord.to_physical()first.
- exception ecgdatakit.exceptions.ChecksumWarning[source]¶
Bases:
UserWarningStored checksum does not match the computed one.
Silence it in batch processing with
warnings.filterwarnings("ignore", category=ChecksumWarning).