API Reference¶
Command Line Program¶
- meds_reader_convert [source_meds_path] [destination_path] --num_threads
Convert a MEDS dataset to a meds_reader SubjectDatabase.
See https://github.com/Medical-Event-Data-Standard/meds for the details of the expected input format.
Python Module¶
- class meds_reader.SubjectDatabase(path_to_database: str, num_threads: int = 1)¶
Open a SubjectDatabase. The path must be from convert_to_meds_reader.
- __getitem__(subject_id: int) meds_reader.Subject¶
Retrieve a single subject from the database
- filter(subject_ids: List[int]) meds_reader.SubjectDatabase¶
Filter the database to a list of subjects
- map(map_func: Callable[[Iterator[meds_reader.Subject]], meds_reader.A]) Iterator[meds_reader.A]¶
Apply a function to every subject in the database, in a multi-threaded manner.
map_func is a callable that takes an iterable of subjects.
- map_with_data(map_func: Callable[[Iterator[Tuple[meds_reader.Subject, Sequence[Any]]]], meds_reader.A], data: pandas.core.frame.DataFrame, assume_sorted: bool = False) Iterator[meds_reader.A]¶
Apply a function with associated data to every subject in the database, in a multi-threaded manner.
map_func is a callable that takes an iterable of subjects paired with rows from the provided table for that subject_id.
The provided table must have ‘subject_id’ as an integer index that will be used for mapping rows.
Note
This code requires the input to be sorted by subject_id. It will automatically do that sorting for you, but we also provide assume_sorted to allow people to skip that step for already sorted data.
- class meds_reader.Subject¶
A subject consists of a subject_id and a sequence of Events
- events: Sequence[meds_reader.Event]¶
Items that have happened to a subject
- class meds_reader.Event¶
An event represents a single unit of information about a subject. It contains a time and code, and potentially more properties.
- time: datetime.datetime¶
The time the event occurred