Features and itemids¶
See Features and itemid maps for how presets and maps fit into a BigQuery load.
Feature presets¶
- class ehr2rl.data.FeaturePreset(name, concepts, aggregation='1h')¶
A named set of canonical concepts to use as state features.
- Parameters:
- resolve(itemid_map)¶
Map each concept to its itemid entries.
- Parameters:
itemid_map (
ItemIdMap) – Map to look the concepts up in.- Returns:
Entries for each concept, in preset order.
- Return type:
dict[str,list[ItemIdEntry]]- Raises:
EHRValidationError – If a concept is missing from the map.
- ehr2rl.data.get_feature_preset(name)¶
Return a built-in feature preset by name.
- Parameters:
name (
str) –"vitals_only","sepsis3_core", or"full".- Raises:
EHRValidationError – If the name is unknown.
- Return type:
Itemid maps¶
- class ehr2rl.data.itemid_maps.ItemIdEntry(itemid, source, unit=None, label=None, conversion=None)¶
One raw MIMIC-IV itemid mapped to a canonical concept.
- Parameters:
itemid (
int) – MIMIC-IV itemid.source (
Literal['chartevents','labevents','inputevents']) – Table the itemid comes from:"chartevents","labevents", or"inputevents".label (
str|None) – Expected label ind_itemsord_labitems, checked byvalidate_itemid_mapwhen set.conversion (
str|None) – Name of an intended unit conversion. Informational only; not applied.
- class ehr2rl.data.itemid_maps.ItemIdMap(version, concepts)¶
A versioned mapping from canonical concepts to raw itemids.
- Parameters:
version (
str) – Map version, such as"v3_1", recorded in provenance.concepts (
dict[str,list[ItemIdEntry]]) – Itemid entries for each concept name.
- ehr2rl.data.itemid_maps.load_itemid_map(version='v3_1', path=None)¶
Load a built-in or user-supplied itemid map.
Map files are JSON with a
versionstring and aconceptsobject that maps each concept name to a list of entries withItemIdEntryfields.
- ehr2rl.data.itemid_maps.validate_itemid_map(itemid_map, labels)¶
Check every itemid in a map against live MIMIC-IV labels.
Labels are compared case-insensitively with whitespace collapsed. Entries without an expected
labelonly need to exist.- Parameters:
- Raises:
EHRValidationError – If
labelslacks a required column, an itemid is missing, or a label differs.- Return type: