MIMIC-IV
Functions for reading from downloaded MIMIC-IV (v2.2) data.
get_notes_population(adm_notes, admit_last, use_lazy=False)
Gets population of unique ED patients with existing note history.
Source code in src/utils/mimiciv.py
get_population_with_measures(events, admit_last, use_lazy=False)
Gets population of unique ED patients with recorded measurements.
Source code in src/utils/mimiciv.py
merge_events_table(vitals, labs, omr, use_lazy=False, verbose=True)
Merges vitals, labevents, and omr tables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vitals |
LazyFrame | DataFrame
|
Vitals table. |
required |
labs |
LazyFrame | DataFrame
|
Labevents table. |
required |
omr |
LazyFrame | DataFrame
|
Omr table. |
required |
Returns:
Type | Description |
---|---|
LazyFrame | DataFrame
|
pl.LazyFrame | pl.DataFrame: Merged events table. |
Source code in src/utils/mimiciv.py
read_admissions_table(mimic4_path, use_lazy=False, verbose=True, ext_stay_threshold=7)
Reads in admissions.csv.gz table and formats column types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mimic4_path |
str
|
Path to directory containing downloaded MIMIC-IV hosp module files. |
required |
use_lazy |
bool
|
Whether to return a Polars LazyFrame or DataFrame. Defaults to False. |
False
|
Source code in src/utils/mimiciv.py
read_diagnoses_table(mimic4_path, admissions_data, adm_last, verbose=True, use_lazy=False)
Reads in diagnoses_icd.csv.gz table and formats column types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mimic4_path |
str
|
Path to directory containing downloaded MIMIC-IV hosp module files. |
required |
use_lazy |
bool
|
Whether to return a Polars LazyFrame or DataFrame. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
LazyFrame | DataFrame
|
pl.LazyFrame | pl.DataFrame: Diagnoses table. |
Source code in src/utils/mimiciv.py
read_icu_table(mimic4_ed_path, admissions_data, use_lazy=False, verbose=True)
Reads in icustays.csv.gz table and parses ICU admission outcome.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mimic4_path |
str
|
Path to directory containing downloaded MIMIC-IV hosp module files. |
required |
admissions_data |
DataFrame | LazyFrame
|
Admissions table. |
required |
use_lazy |
bool
|
Whether to return a Polars LazyFrame or DataFrame. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
LazyFrame | DataFrame
|
pl.LazyFrame | pl.DataFrame: ICU stays table. |
Source code in src/utils/mimiciv.py
read_labevents_table(mimic4_path, admits_last, include_items='../config/lab_items.csv')
Reads in events.csv.gz tables from MIMIC-IV and formats column types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table |
str
|
Name of the events table. Currently supports 'vitalsign' or 'labevents' |
required |
mimic4_path |
str
|
Path to directory containing events |
required |
include_items |
list
|
Filepath for itemid values to filter. Defaults to None. |
'../config/lab_items.csv'
|
Returns:
Type | Description |
---|---|
LazyFrame
|
pl.LazyFrame : Long-format events table. |
Source code in src/utils/mimiciv.py
read_medications_table(mimic4_path, admits_last, use_lazy=False, top_n=50)
Gets medication table from online administration record containing orders data.
Source code in src/utils/mimiciv.py
read_notes(admissions_data, admits_last, mimic4_path, verbose=True, use_lazy=False)
Read in discharge summary and preprocessed BHC segments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mimic4_path |
str
|
description |
required |
use_lazy |
bool
|
Whether to return a Polars LazyFrame or DataFrame. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
LazyFrame | DataFrame
|
pl.LazyFrame | pl.DataFrame: description |
Source code in src/utils/mimiciv.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
|
read_omr_table(mimic4_path, admits_last, use_lazy=False, vitalsign_uom_map=None)
Reads in omr.csv.gz table and formats column types. Sets measures for blood pressure and BMI in long format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mimic4_path |
str
|
Path to directory containing downloaded MIMIC-IV hosp module files. |
required |
use_lazy |
bool
|
Whether to return a Polars LazyFrame or DataFrame. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
LazyFrame | DataFrame
|
pl.LazyFrame | pl.DataFrame: Omr table. |
Source code in src/utils/mimiciv.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
|
read_patients_table(mimic4_path, admissions_data, age_cutoff=18, use_lazy=False, verbose=True)
Reads in patients.csv.gz table and formats column types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mimic4_path |
str
|
Path to directory containing downloaded MIMIC-IV hosp module files. |
required |
use_lazy |
bool
|
Whether to return a Polars LazyFrame or DataFrame. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
LazyFrame | DataFrame
|
pl.LazyFrame | pl.DataFrame: Patients table. |
Source code in src/utils/mimiciv.py
read_specialty_table(mimic4_path, admits_last, use_lazy=False)
Collects specialty-grouped count features from secondary care order history.
Source code in src/utils/mimiciv.py
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 |
|
read_vitals_table(mimic4_ed_path, admits_last, use_lazy=False, vitalsign_column_map=None, vitalsign_uom_map=None)
Reads in vitalsign.csv.gz table and formats column types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mimic4_path |
str
|
Path to directory containing downloaded MIMIC-IV hosp module files. |
required |
use_lazy |
bool
|
Whether to return a Polars LazyFrame or DataFrame. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
LazyFrame | DataFrame
|
pl.LazyFrame | pl.DataFrame: Vitals table. |
Source code in src/utils/mimiciv.py
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 |
|
save_multimodal_dataset(admits_last, events, notes, use_events=True, use_notes=True, output_path='../outputs/extracted_data')
Saves multimodal data to be used in feature selection and training modules.