Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/philipdarke/mimic4
Add the MIMIC-IV data to a DuckDB database
https://github.com/philipdarke/mimic4
duckdb mimic-iv
Last synced: about 2 months ago
JSON representation
Add the MIMIC-IV data to a DuckDB database
- Host: GitHub
- URL: https://github.com/philipdarke/mimic4
- Owner: philipdarke
- License: mit
- Created: 2024-08-28T10:01:51.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-04T21:24:06.000Z (5 months ago)
- Last Synced: 2024-10-22T04:20:07.542Z (3 months ago)
- Topics: duckdb, mimic-iv
- Language: Python
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mimic4
Adds the MIMIC-IV data set (including all current concepts) to a DuckDB database using Python.
Based on the scripts at https://github.com/MIT-LCP/mimic-code/tree/main/mimic-iv/buildmimic, however note the following differences:
* Schema names are not prefaced with `mimiciv_`.
* All medication tables have the column `endtime` for the date and time of the end of each period of medication. The official scripts use `endtime` and `stoptime` inconsistently.No constraints are placed on the tables as the focus is [speed](https://duckdb.org/docs/guides/performance/schema#constraints).
Data is available from https://physionet.org/content/mimiciv/3.0/.
The only Python dependency is [duckdb](https://pypi.org/project/duckdb/). Tested using Python 3.10.12, DuckDB 1.0.0 and MIMIC-IV v3.0.
## Instructions
1. Create a Python virtual environment and install DuckDB.
1. Download and save `mimic-iv-3.0.zip` in the `data/` directory.
1. Run `python3 build_database.py` to build the database. It is called `mimic4.db` by default.For example:
```bash
$ python3 -m .venv venv
$ source .venv/bin/activate
(.venv) pip install duckdb==1.0.0
(.venv) $ python3 build_database.py
Creating tables...
Extracting data...
Populating tables:
- data/mimic-iv-3.0/icu/ingredientevents.csv.gz -> icu.ingredientevents...
- data/mimic-iv-3.0/icu/chartevents.csv.gz -> icu.chartevents...
- data/mimic-iv-3.0/icu/outputevents.csv.gz -> icu.outputevents...
- data/mimic-iv-3.0/icu/icustays.csv.gz -> icu.icustays...
- data/mimic-iv-3.0/icu/datetimeevents.csv.gz -> icu.datetimeevents...
- data/mimic-iv-3.0/icu/caregiver.csv.gz -> icu.caregiver...
- data/mimic-iv-3.0/icu/inputevents.csv.gz -> icu.inputevents...
- data/mimic-iv-3.0/icu/procedureevents.csv.gz -> icu.procedureevents...
- data/mimic-iv-3.0/icu/d_items.csv.gz -> icu.d_items...
- data/mimic-iv-3.0/hosp/transfers.csv.gz -> hosp.transfers...
- data/mimic-iv-3.0/hosp/d_labitems.csv.gz -> hosp.d_labitems...
- data/mimic-iv-3.0/hosp/prescriptions.csv.gz -> hosp.prescriptions...
- data/mimic-iv-3.0/hosp/microbiologyevents.csv.gz -> hosp.microbiologyevents...
- data/mimic-iv-3.0/hosp/d_hcpcs.csv.gz -> hosp.d_hcpcs...
- data/mimic-iv-3.0/hosp/labevents.csv.gz -> hosp.labevents...
- data/mimic-iv-3.0/hosp/admissions.csv.gz -> hosp.admissions...
- data/mimic-iv-3.0/hosp/d_icd_diagnoses.csv.gz -> hosp.d_icd_diagnoses...
- data/mimic-iv-3.0/hosp/provider.csv.gz -> hosp.provider...
- data/mimic-iv-3.0/hosp/d_icd_procedures.csv.gz -> hosp.d_icd_procedures...
- data/mimic-iv-3.0/hosp/pharmacy.csv.gz -> hosp.pharmacy...
- data/mimic-iv-3.0/hosp/omr.csv.gz -> hosp.omr...
- data/mimic-iv-3.0/hosp/poe.csv.gz -> hosp.poe...
- data/mimic-iv-3.0/hosp/emar.csv.gz -> hosp.emar...
- data/mimic-iv-3.0/hosp/procedures_icd.csv.gz -> hosp.procedures_icd...
- data/mimic-iv-3.0/hosp/diagnoses_icd.csv.gz -> hosp.diagnoses_icd...
- data/mimic-iv-3.0/hosp/poe_detail.csv.gz -> hosp.poe_detail...
- data/mimic-iv-3.0/hosp/emar_detail.csv.gz -> hosp.emar_detail...
- data/mimic-iv-3.0/hosp/patients.csv.gz -> hosp.patients...
- data/mimic-iv-3.0/hosp/hcpcsevents.csv.gz -> hosp.hcpcsevents...
- data/mimic-iv-3.0/hosp/drgcodes.csv.gz -> hosp.drgcodes...
- data/mimic-iv-3.0/hosp/services.csv.gz -> hosp.services...
Adding concepts:
- sql/demographics/icustay_times.sql...
- sql/demographics/age.sql...
- sql/demographics/icustay_detail.sql...
- sql/demographics/icustay_hourly.sql...
- sql/demographics/weight_durations.sql...
- sql/comorbidity/charlson.sql...
- sql/measurement/bg.sql...
- sql/measurement/blood_differential.sql...
- sql/measurement/cardiac_marker.sql...
- sql/measurement/chemistry.sql...
- sql/measurement/coagulation.sql...
- sql/measurement/complete_blood_count.sql...
- sql/measurement/creatinine_baseline.sql...
- sql/measurement/enzyme.sql...
- sql/measurement/gcs.sql...
- sql/measurement/height.sql...
- sql/measurement/icp.sql...
- sql/measurement/inflammation.sql...
- sql/measurement/oxygen_delivery.sql...
- sql/measurement/rhythm.sql...
- sql/measurement/urine_output.sql...
- sql/measurement/urine_output_rate.sql...
- sql/measurement/ventilator_setting.sql...
- sql/measurement/vitalsign.sql...
- sql/medication/acei.sql...
- sql/medication/antibiotic.sql...
- sql/medication/arb.sql...
- sql/medication/dobutamine.sql...
- sql/medication/dopamine.sql...
- sql/medication/epinephrine.sql...
- sql/medication/milrinone.sql...
- sql/medication/neuroblock.sql...
- sql/medication/norepinephrine.sql...
- sql/medication/nsaid.sql...
- sql/medication/phenylephrine.sql...
- sql/medication/vasopressin.sql...
- sql/medication/vasoactive_agent.sql...
- sql/medication/norepinephrine_equivalent_dose.sql...
- sql/treatment/code_status.sql...
- sql/treatment/crrt.sql...
- sql/treatment/invasive_line.sql...
- sql/treatment/rrt.sql...
- sql/treatment/ventilation.sql...
- sql/firstday/first_day_vitalsign.sql...
- sql/firstday/first_day_urine_output.sql...
- sql/firstday/first_day_bg.sql...
- sql/firstday/first_day_bg_art.sql...
- sql/firstday/first_day_gcs.sql...
- sql/firstday/first_day_height.sql...
- sql/firstday/first_day_lab.sql...
- sql/firstday/first_day_rrt.sql...
- sql/firstday/first_day_sofa.sql...
- sql/firstday/first_day_weight.sql...
- sql/organfailure/kdigo_uo.sql...
- sql/organfailure/kdigo_creatinine.sql...
- sql/organfailure/kdigo_stages.sql...
- sql/organfailure/meld.sql...
- sql/score/apsiii.sql...
- sql/score/lods.sql...
- sql/score/oasis.sql...
- sql/score/sapsii.sql...
- sql/score/sirs.sql...
- sql/score/sofa.sql...
- sql/sepsis/suspicion_of_infection.sql...
- sql/sepsis/sepsis.sql...
(.venv) $ sha256sum mimic4.db
952d893a04e75a4454b35d10e42595bd72e335fdb54ff45848bd30433ab4d90e mimic4.db
```## Licence
Made available under the MIT license. The `create.sql` and concept scripts are adapted from the [`mimic-code`](https://github.com/MIT-LCP/mimic-code) repository and subject to the MIT licence:
```
MIT LicenseCopyright (c) 2019 MIT Laboratory for Computational Physiology
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```