Skip to content

Commit a830870

Browse files
authored
Merge pull request #1537 from stefanhgm/main
Streamlining and updating Postgres building process for mimic-iv, mimic-iv-notes, mimic-iv-ed
2 parents 308d406 + 64c74ac commit a830870

File tree

3 files changed

+18
-32
lines changed

3 files changed

+18
-32
lines changed

mimic-iv-ed/buildmimic/postgres/README.md

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,21 @@
11
# Load MIMIC-IV-ED into a PostgreSQL database
22

33
The scripts in this folder create the schema for MIMIC-IV-ED and load the data into the appropriate tables for PostgreSQL v10+.
4+
If you are having trouble, take a look at the common issues in the FAQ at the bottom of this page.
45

5-
<!--
6-
* You can follow the tutorial to run each file individually. Windows users can follow along [here](https://mimic.physionet.org/tutorials/install-mimic-locally-windows/), while *nix/Mac OS X users can follow along [here](https://mimic.physionet.org/tutorials/install-mimic-locally-ubuntu/)
7-
8-
If following the tutorials, be sure to download the scripts locally and the MIMIC-IV-ED files locally. If you choose the makefile approach, see the below section.
9-
10-
-->
11-
12-
First ensure that Postgres is running on your computer. For installation instructions, see: [http://www.postgresql.org/download/](http://www.postgresql.org/download/)
13-
14-
Once Postgres is installed, clone the [mimic-code](https://github.com/MIT-LCP/mimic-code) repository into a local directory. We only need the contents of the `mimic-iv-ed/buildmimic/postgres/` directory, but it's useful to have the repository locally. You can clone the repository using the following command:
15-
16-
``` bash
17-
git clone https://github.com/MIT-LCP/mimic-code.git
18-
```
19-
20-
Change to the `mimic-iv-ed/buildmimic/postgres/` directory. Create the schemas and tables with the following psql command. **This will delete any data present in the schemas.**
6+
## Quickstart
217

228
```sh
23-
psql -f create.sql
24-
```
25-
26-
Afterwards, we need to load the MIMIC-IV-ED files into the database. To do so, we'll specify the location of the local CSV files (compressed or uncompressed).
27-
Note that this assumes the folder `mimic_data_dir` contains all the `csv` or `csv.gz` files. If using compressed files (`.csv.gz`), use the `load_gz.sql` script instead of the `load.sql` script.
28-
29-
Once you have verified all data files are present, run:
30-
31-
```sh
32-
psql -v ON_ERROR_STOP=1 -v mimic_data_dir=<INSERT MIMIC FILE PATH HERE> -f load.sql
9+
# clone repo
10+
git clone https://github.com/MIT-LCP/mimic-code.git
11+
cd mimic-code
12+
# download data
13+
wget -r -N -c -np --user <USERNAME> --ask-password https://physionet.org/files/mimic-iv-ed/2.2/
14+
mv physionet.org/files/mimiciv-iv-ed mimiciv && rmdir physionet.org/files && rm physionet.org/robots.txt && rmdir physionet.org
15+
# if mimiciv not exists
16+
# createdb mimiciv
17+
psql -d mimiciv -f mimic-iv-ed/buildmimic/postgres/create.sql
18+
psql -d mimiciv -v ON_ERROR_STOP=1 -v mimic_data_dir=mimiciv/2.2/ed -f load_gz.sql
3319
```
3420

3521

mimic-iv-note/buildmimic/postgres/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ git clone https://github.com/MIT-LCP/mimic-code.git
1010
cd mimic-code
1111
# download data
1212
wget -r -N -c -np --user <USERNAME> --ask-password https://physionet.org/files/mimiciv/2.2/
13-
mv physionet.org/files/mimiciv mimiciv && rmdir physionet.org/files && rm physionet.org/robots.txt && rmdir physionet.org
13+
mv physionet.org/files/mimiciv-iv-note mimiciv && rmdir physionet.org/files && rm physionet.org/robots.txt && rmdir physionet.org
1414
# if mimiciv not exists
1515
# createdb mimiciv
1616
psql -d mimiciv -f mimic-iv-note/buildmimic/postgres/create.sql
17-
psql -d mimiciv -v ON_ERROR_STOP=1 -v mimic_data_dir=mimiciv/2.2 -f mimic-iv-note/buildmimic/postgres/load_gz.sql
17+
psql -d mimiciv -v ON_ERROR_STOP=1 -v mimic_data_dir=mimiciv/2.2/note -f mimic-iv-note/buildmimic/postgres/load_gz.sql
1818
```

mimic-iv/buildmimic/postgres/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ If following the tutorials, be sure to download the scripts locally and the MIMI
1717
git clone https://github.com/MIT-LCP/mimic-code.git
1818
cd mimic-code
1919
# download data
20-
wget -r -N -c -np --user <USERNAME> --ask-password https://physionet.org/files/mimiciv/2.0/
20+
wget -r -N -c -np --user <USERNAME> --ask-password https://physionet.org/files/mimiciv/2.2/
2121
mv physionet.org/files/mimiciv mimiciv && rmdir physionet.org/files && rm physionet.org/robots.txt && rmdir physionet.org
2222
createdb mimiciv
2323
psql -d mimiciv -f mimic-iv/buildmimic/postgres/create.sql
24-
psql -d mimiciv -v ON_ERROR_STOP=1 -v mimic_data_dir=mimiciv/2.0 -f mimic-iv/buildmimic/postgres/load_gz.sql
25-
psql -d mimiciv -v ON_ERROR_STOP=1 -v mimic_data_dir=mimiciv/2.0 -f mimic-iv/buildmimic/postgres/constraint.sql
26-
psql -d mimiciv -v ON_ERROR_STOP=1 -v mimic_data_dir=mimiciv/2.0 -f mimic-iv/buildmimic/postgres/index.sql
24+
psql -d mimiciv -v ON_ERROR_STOP=1 -v mimic_data_dir=mimiciv/2.2 -f mimic-iv/buildmimic/postgres/load_gz.sql
25+
psql -d mimiciv -v ON_ERROR_STOP=1 -v mimic_data_dir=mimiciv/2.2 -f mimic-iv/buildmimic/postgres/constraint.sql
26+
psql -d mimiciv -v ON_ERROR_STOP=1 -v mimic_data_dir=mimiciv/2.2 -f mimic-iv/buildmimic/postgres/index.sql
2727
```
2828

2929
## Detailed guide

0 commit comments

Comments
 (0)