knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
This work references data from the Medical Information Mart for Intensive Care MIMIC-IV database. MIMIC-IV is a large, freely-available database comprising de-identified health-related data from patients who were admitted to the critical care units of the Beth Israel Deaconess Medical Center from 2008-2019. Detailed information can be obtained on the MIMIC-IV website.
MIMIC4db provides a tightly bound set of routines to reference the Google BigQuery version of the MIMIC-IV v1.0 database using base access routines from the DBI R package with an appropriate bigrquery DBIConnection.
You can install MIMIC4db from GitHub with:
# install.packages("devtools") devtools::install_github("hdshea/MIMIC4db")
These are basic examples which show you how to solve a common problem.
Connecting to the database:
library(MIMIC4db) con <- bigrquery::dbConnect( bigrquery::bigquery(), project = bigrquery::bq_test_project(), quiet = TRUE )
library(MIMIC4db) # To connect to the database, you must provide an appropriate project (in the `your-project` # slot below) which has billing set up and to which you have write access. This project # must be approved to access the PhysioNet BigQuery MIMIC schemas. con <- bigrquery::dbConnect( bigrquery::bigquery(), project = "your-project", quiet = TRUE )
Using the meta data functions:
core <- m4_meta_data() core <- core[core$module == "mimic_core", ] for(i in 1:length(core)) { cat(stringr::str_c("select * from physionet-data.", core[i,"module"], ".", core[i,"table"], "\n")) } neuro <- m4_service_decsriptions() neuro <- neuro[startsWith(neuro$short_description, "Neurologic"), ] neuro[,c("service", "short_description")]
Using the two base functions:
d_items <- m4_select_data( con, "select * from physionet-data.mimic_icu.d_items order by itemid limit 5" ) d_items d_items <- m4_get_from_table(con, "d_items", where = "where itemid <= 220048") d_items
Using the tables specific data access functions:
tab <- m4_chartevents_items(con) tab[c(1:5), ] pat <- m4_patients(con, cohort = 16904137) pat svs <- m4_services(con, cohort = 16904137) svs evt <- m4_procedureevents(con, cohort = 16904137) evt[c(1:5), ]
Using the common pattern data access functions:
# Combined and preprocessed patient and admission data patadm <- m4_patient_admissions(con, cohort = 16904137) patadm[, c(1:6)] patadm[, c(7:10)] patadm[, c(11:14)] patadm[, c(15:19)] # Combined and preprocessed patient, admission and icustay data icudet <- m4_patient_icustays(con, cohort = 16904137) icudet[, c(1:6)] icudet[, c(7:10)] icudet[, c(11:14)] icudet[, c(15:19)] icudet[, c(20:22)] icudet[, c(23:25)]
Disconnecting from the database:
bigrquery::dbDisconnect(con)
Johnson, A., Bulgarelli, L., Pollard, T., Horng, S., Celi, L. A., & Mark, R. (2021). MIMIC-IV (version 1.0). PhysioNet. https://doi.org/10.13026/s6n6-xd98.
PhysioNet: Goldberger, A., Amaral, L., Glass, L., Hausdorff, J., Ivanov, P. C., Mark, R., ... & Stanley, H. E. (2000). PhysioBank, PhysioToolkit, and PhysioNet: Components of a new research resource for complex physiologic signals. Circulation [Online]. 101 (23), pp. e215–e220.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.