Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One-Click Installation Universal Script for MIMIC-III Clinical Database CareVue subset with PostgreSQL on MAC OS, Windows, and Linux #1471

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
129 changes: 129 additions & 0 deletions mimic-iii-carevue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# One-Click Installation Universal Script for MIMIC-III Clinical Database CareVue subset on MAC OS, Windows, and Linux

[README](README.md) | [中文文档](README_zh.md)

## 1 About this script

A one-click installation universal script for MIMIC-III Clinical Database CareVue subset, no matter what operating system(MAC OS, Windows, and Linux), you can complete the installation of MIMIC-III Carevue database and related concepts in the fastest and most convenient way. A life-saving series tool for installation of critical care database.

## 2 Before installation

### 2.1 Install [Git](https://git-scm.com/download/win) (only for Windows user)

In this script, `sed` would be used to configure **pg_hba.conf** (Reset the mode of local connection as `trust` with `sed` , for automatically and silently installation of the database with the shell script later). Mac OS terminals have ` sed`of `FreeBSD version` built in by default (of course you can also use `Homebrew` to install the `sed` of `GNU version` , namely `gsed`, not required), this script automatically recognizes the version of `sed` in MAC OS and executes the corresponding commands. The `sed` built in Linux distributions and [Git software](https://git-scm.com/download/win) for Windows is `gsed`. Since the shell scripts cannot be executed with `Command Prompt` on Windows (also unable to excute `sed` command), we would run shell scripts in `Terminal` provided by `Git`.

#### ① After installation of [Git](https://git-scm.com/download/win), double click `BashHere.reg` to create shortcut of `bash Terminal`.

Download the latest version of Git and install it with the default settings(**Install Git in `C:\Program Files\Git`**). Because the script will utilize the pipe operator for redirection, and terminal provided by `Git bash here` will cause the parameter passing failure of pipe operator, so we use the terminal provided by `bash.exe` in `C:\Program Files\Git\bin` to ensure successful execution of script. Next we would create shortcut of `bash Terminal ` to the right mouse menu by double-clicking `BashHere.reg` in the `code` subfolder.

<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/02.png" width="90%" height="90%" />
</p>

#### ② Open the `bash Terminal`.

Right-click in the `mimic-iii-carevue` folder and select `Bash Here` to open `bash Terminal`, which supports piping and redirection.

<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/03.png" width="90%" height="90%" />
</p>

### 2.2 Ensure Postgresql was installed and `psql` bin directory path was added to the environment variable (required)

Open the `Terminal`(For Windows user, Right-click in the `mimic-iii-carevue` folder and select `Bash Here` to open `bash Terminal`, which mentioned in section 2.1). The environment variable was set correctly if a specific installation path (Postgresql ) is returned after type the following command in the `Terminal`.

```shell
which psql
```
- On Windows 10
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/04.png" width="90%" height="90%" />
</p>

- On Ubuntu
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/05.png" width="90%" height="90%" />
</p>

- On MAC OS
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/06.png" width="90%" height="90%" />
</p>

### 2.3 Operating System User Name and Database User name (required)

#### ① Ensure operating system user name does not contain any special characters and Spaces

In order to facilitate the installation and maintenance of the database, the shell script will create the database user and database with the same name as the operating system user name. Then the `psql` command can be used directly in the terminal without any user name and database parameters (namely `-U` and `-d`). Therefore, the script first checks whether the operating system user name contains any special characters, such as Spaces, Chinese alphabets, Japanese alphabets, korean alphabets and so on. If the user name meet the preceding conditions, the installation will be automatically terminated unless creating a new user name that meets the conditions (preferably any combination of `English alphabets`, `numbers`, and`_`) and log in.

#### ② Ensure the default database user name `postgres` is available
After installing Postgresql with the default setting, the database will have an administrator user named `postgres`. The `psql` commands would be used in this one-click installation script, so make sure that the status of the database user `postgres` is available. Generally speaking, whether on MAC OS, Windows, or Ubuntu, the `postgres` administrator user status is available as long as the default settings were not changed. Run the following command in the terminal to check whether the `postgres`administrator user exists. If the terminal displays a message starting with `postgres`, it indicates that the `postgres` is available (The following figure for MAC OS as an example).

```shell
psql -U postgres;
```
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/07.png" width="90%" height="90%" />
</p>


## 3 Installation of MIMIC-III CareVue

### 3.1 Load path of database files

Decompress the `mimic-iii-clinical-database-carevue-subset-1.4.zip` database file and then move to the **database folder** (The following figure for MAC OS as an example).

<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/08.png" width="90%" height="90%" />
</p>
### 3.2 One click installation in the `Terminal`

Open the the `Terminal` (for Windows users, you need to right-click the mouse and choose `git bash here` to open the `Terminal` provided by `Git`) and enter **the path of install shell script**, type and run the following command, and select the corresponding option to complete the automatic installation of the MIMIC-III CareVue database.

```shell
bash install.sh
```
- Install database with one command
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/09.png" width="90%" height="90%" />
</p>

- Install basic tables
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/10.png" width="90%" height="90%" />
</p>

- Install basic tables
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/11.png" width="90%" height="90%" />
</p>

- Install concepts
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/12.png" width="90%" height="90%" />
</p>

- Check data
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/13.png" width="90%" height="90%" />
</p>

- Check data
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/14.png" width="90%" height="90%" />
</p>

- DBeaver
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/15.png" width="90%" height="90%" />
</p>

## 4 P.S.

* [MIMIC-III Clinical Database CareVue subset official website](https://physionet.org/content/mimic3-carevue/1.4/)
* Related issue: [Are there duplications between patients in CareVue part of MIMIC III and patients in MIMIC IV ?](https://github.com/MIT-LCP/mimic-code/issues/1331)
* SQL codes were edited based on the the base of [MIMICIII-V1.4](https://github.com/ningyile/mimic-code/tree/main/mimic-iii). Code blocks related to MetaVision (MV) were removed (including [echo_data.sql](https://github.com/ningyile/mimic-code/blob/main/mimic-iii/concepts/echo_data.sql)).
* Sepsis3 has been added to the Concepts, which was edited based on [A Comparative Analysis of Sepsis Identification Methods in an Electronic Database](https://www.ncbi.nlm.nih.gov/pubmed/29303796). [sepsis3-mimic](https://github.com/alistairewj/sepsis3-mimic) created by[Alistair Johnson](https://github.com/alistairewj)。
* Charlson Comorbidity Index has been added to the Concepts, which was edited based on[Charlson in Concepts of MIMICIV](https://github.com/MIT-LCP/mimic-code/blob/main/mimic-iv/concepts_postgres/comorbidity/charlson.sql)。
* If you want to add a new feature, please create an issue first to describe the new feature.
* Sorry for my poor English. Improvements for this document are welcome, even some typo fixes.
127 changes: 127 additions & 0 deletions mimic-iii-carevue/README_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# MIMIC-III CareVue数据库全平台通用(MAC OS、Windows、Linux)一键安装脚本

[README](README.md) | [中文文档](README_zh.md)

## 1 关于此脚本

一键式安装MIMIC-III CareVue数据库。无论什么操作系统(MAC OS、Windows、Linux),以最快、最方便的方式完成MIMIC-III CareVue数据库及相关Concepts的安装。此重症数据库系列安装脚本可节省你大量时间。

## 2 安装前需要核对

### 2.1 Windows用户请安装[Git软件](https://git-scm.com/download/win)(仅Windows用户必须)

本脚本中需要使用`sed`命令**配置pg_hba.conf**(使用`sed`命令重置数据库的本地连接模式为`trust`,以便后期使用shell脚本自动静默安装数据库)。MAC OS终端默认`sed`版本为`FreeBSD`(当然你也可以使用`Homebrew`安装`GNU版本sed`,即`gsed`,非必须选项),此脚本可自动识别MAC OS终端`sed`版本并执行相应的命令。大多数Linux发行版以及Windows下[Git软件](https://git-scm.com/download/win)中内置的`sed`版本为`gsed`。由于Windows系统中`Command Prompt`没有`sed`命令且**无法运行shell脚本**,所以我们需要借用`Git终端`以确保脚本可以自动运行。

#### ① 安装[Git软件](https://git-scm.com/download/win)后,双击 `BashHere.reg` 以创建 `bash`终端快捷键。

下载最新版本的Git,然后使用默认设置进行安装(**确保安装到`C:\Program Files\Git`目录下**)。由于脚本中会使用到Unix的管道符的重定向进行操作,而Git软件默认的`Git bash here`会导致管道符传参失败,故我们使用`C:\Program Files\Git\bin`目录下的`bash.exe`作为终端确保脚本的顺利运行。接下来在`code`子文件夹中双击`BashHere.reg`添加`bash终端`的快捷键至鼠标右键。
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/02.png" width="90%" height="90%" />
</p>

#### ② 右键打开 `bash`终端。

在`mimic-iii-carevue文件夹`单击鼠标右键,选择`Bash Here`,即可打开支持管道符重定向的`bash终端`。
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/03.png" width="90%" height="90%" />
</p>

### 2.2 确保Postgresql安装且环境变量已经配置(必须)

打开 `终端`( **Windows用户单击鼠标右键,选择`Bash Here`**,使用2.1中提到的**`bash终端`**) ,输入以下代码,如返回一串具体的安装路径则证明`Postgresql环境变量`设置正常。

```shell
which psql
```

- On Windows 10
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/04.png" width="90%" height="90%" />
</p>

- On Ubuntu
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/05.png" width="90%" height="90%" />
</p>

- On MAC OS
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/06.png" width="90%" height="90%" />
</p>

### 2.3 操作系统用户名及数据库用户名(必须)

#### ① 确保操作系统用户名不要含有汉字、空格等特殊字符

为方便日后数据库安装及维护,脚本会一键式设置与操作系统用户名同名的数据库用户及数据库,此后在终端可直接使用`psql`命令而无需附带任何用户名及数据库参数(即`-U`和`-d`)。因此脚本首先会判断操作系统用户名是否含有空格、汉字、日文、韩文等特殊字符,如符合上述条件,则安装将会自动终止,除非在操作系统下新建一个符合规范(尽量使用`英文字母`、`数字`以及`_`等字符任意组合)的用户名并以此登录。
#### ② 确保默认的数据库用户`postgres`可用
一般来说使用默认设置安装Postgresql之后,数据库会存在一个名为`postgres`的管理员用户。在这个一键安装脚本中会使用`终端`和`psql`命令进行一些操作,因此请确保`postgres管理员用户`的状态为可用。一般来说,无论在MAC OS、Windows或者Ubuntu,只要未修改默认设置,`postgres管理员用户`的状态都是可用的。在终端中输入以下命令即可检测`postgres管理员用户`是否存在(以MAC OS为例),当终端出现以`postgres`为开头的信息即表示可用。

```shell
psql -U postgres;
```
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/07.png" width="90%" height="90%" />
</p>


## 3 数据库一键安装

### 3.1 数据库文件加载路径

完成上述工作后,将`MIMIC3-Carevue-V1.4`数据库文件**解压后**放在**database文件夹**(以MAC OS为例)。
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/08.png" width="90%" height="90%" />
</p>
### 3.2 一键安装

在shell脚本文件路径下进入终端(对于Windows用户需要单击鼠标右键,选择`git bash here`,即可打开`Git终端`),输入并运行如下命令,选择相应的选项后即可完成数据库的自动安装。

```shell
bash install.sh
```
- 一键安装
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/09.png" width="90%" height="90%" />
</p>

- 安装基础表单
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/10.png" width="90%" height="90%" />
</p>

- 安装基础表单
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/11.png" width="90%" height="90%" />
</p>

- 安装concepts
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/12.png" width="90%" height="90%" />
</p>

- 数据核对
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/13.png" width="90%" height="90%" />
</p>

- 数据核对
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/14.png" width="90%" height="90%" />
</p>

- Dbeaver展示
<p align="center">
<img src="https://raw.githubusercontent.com/ningyile/mimic-code/main/mimic-iii-carevue/img/15.png" width="90%" height="90%" />
</p>

## 4 附言

* [MIMIC-III Clinical Database CareVue subset official website](https://physionet.org/content/mimic3-carevue/1.4/)
* 相关问题请参考:[Are there duplications between patients in CareVue part of MIMIC III and patients in MIMIC IV ?](https://github.com/MIT-LCP/mimic-code/issues/1331)
* 安装代码修改自[MIMICIII-V1.4的sql代码](https://github.com/ningyile/mimic-code/tree/main/mimic-iii),移除了其中关于MetaVision(MV)相关数据源的安装代码(包括[echo_data.sql](https://github.com/ningyile/mimic-code/blob/main/mimic-iii/concepts/echo_data.sql))。
* Concepts中增加了Sepsis3标准,其sql代码修改自[A Comparative Analysis of Sepsis Identification Methods in an Electronic Database](https://www.ncbi.nlm.nih.gov/pubmed/29303796)。[sepsis3-mimic](https://github.com/alistairewj/sepsis3-mimic) 由[Alistair Johnson](https://github.com/alistairewj)创立。
* Concepts中增加了Charlson评分,其sql代码修改自[MIMICIV的Concepts中Charlson评分代码](https://github.com/MIT-LCP/mimic-code/blob/main/mimic-iv/concepts_postgres/comorbidity/charlson.sql)。
* 如果您想添加一个新特性,请先创建一个问题来描述新特性。
* 水平有限,欢迎对该文档进行改进,即使是一些拼写错误也可以。
* 安装出现任何问题,欢迎通过[email protected]或者微信(`ningyile`)、推特(`ningyile`)联系(请备注来意)。
21 changes: 21 additions & 0 deletions mimic-iii-carevue/code/BashHere.reg
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Git Bash Here]

"icon"="C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico"

@="Bash Here"

[HKEY_CLASSES_ROOT\Directory\shell\Bash Here\command]

@="C:\\Program Files\\Git\\bin\\bash --login -i"

[HKEY_CLASSES_ROOT\Directory\Background\shell\Bash Here]

"icon"="C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico"

@="Bash Here"

[HKEY_CLASSES_ROOT\Directory\Background\shell\Bash Here\command]

@="C:\\Program Files\\Git\\bin\\bash --login -i"
Loading