Update readme.md
Browse files
readme.md
CHANGED
@@ -1,165 +1,65 @@
|
|
1 |
-
#
|
2 |
-
|
3 |
-
Below are the instructions to create a valid configuration file.
|
4 |
-
|
5 |
-
## Configuration File Structure
|
6 |
-
|
7 |
-
The configuration file should be in YAML format (.config file) and follow the structure outlined below for **ICU Data**:
|
8 |
-
|
9 |
-
```yaml
|
10 |
-
disease_label: <disease_label> mandatory only if the prediction task is Phenotype
|
11 |
-
timePrediction: <timePrediction>
|
12 |
-
timeWindow: <timeWindow>
|
13 |
-
timebucket: <timebucket>
|
14 |
-
radimp: <radimp>
|
15 |
-
predW: <predW>
|
16 |
-
diagnosis: <diagnosis>
|
17 |
-
output: <output>
|
18 |
-
chart: <chart>
|
19 |
-
proc: <proc>
|
20 |
-
meds: <meds>
|
21 |
-
disease_filter: <disease_filter>
|
22 |
-
icu_no_icu: <icu_no_icu>
|
23 |
-
groupingDiag: <groupingDiag>
|
24 |
-
select_diag: <select_diag>
|
25 |
-
select_med: <select_med>
|
26 |
-
select_proc: <select_proc>
|
27 |
-
select_out: <select_out>
|
28 |
-
select_chart: <select_chart>
|
29 |
-
outlier_removal: <outlier_removal>
|
30 |
-
outlier: <outlier>
|
31 |
-
left_outlier: <left_outlier>
|
32 |
-
```
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
```yaml
|
37 |
-
disease_label: <disease_label> mandatory only if the prediction task is Phenotype
|
38 |
-
timePrediction: <timePrediction>
|
39 |
-
timeWindow: <timeWindow>
|
40 |
-
timebucket: <timebucket>
|
41 |
-
radimp: <radimp>
|
42 |
-
predW: <predW>
|
43 |
-
diagnosis: <diagnosis>
|
44 |
-
lab: <lab>
|
45 |
-
proc: <proc>
|
46 |
-
meds: <meds>
|
47 |
-
disease_filter: <disease_filter>
|
48 |
-
icu_no_icu: <icu_no_icu>
|
49 |
-
groupingDiag: <groupingDiag>
|
50 |
-
groupingProc: <groupingProc>
|
51 |
-
groupingMed: <groupingMed>
|
52 |
-
select_diag: <select_diag>
|
53 |
-
select_med: <select_med>
|
54 |
-
select_proc: <select_proc>
|
55 |
-
select_lab: <select_lab>
|
56 |
-
outlier_removal: <outlier_removal>
|
57 |
-
outlier: <outlier>
|
58 |
-
left_outlier: <left_outlier>
|
59 |
-
```
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
##
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
- For Phenotype task: 30
|
68 |
-
- For Mortality task: 0
|
69 |
-
- For Length of Stay task: Between 1 and 10 (inclusive)
|
70 |
-
- For Readmission task: Between 10 and 150 (inclusive), multiple of 10
|
71 |
-
- `timeWindow` (string): Specifies the time window. Valid values:
|
72 |
-
- For Phenotype or Readmission task: Last X hours (with 24 <= X >= 72)
|
73 |
-
- For Mortality or Length of Stay tasks: First X hours (with 24 <= X >= 72)
|
74 |
-
- `timebucket` (integer): Specifies the time bucket. Valid values: Between 1 and 6 (inclusive).
|
75 |
-
- `radimp` (string): Specifies the imputation method. Valid values:
|
76 |
-
- No Imputation
|
77 |
-
- forward fill and mean
|
78 |
-
- forward fill and median
|
79 |
-
- `predW` (integer): Specifies the prediction window. Valid values depend on the task:
|
80 |
-
- For Phenotype, Length of Stay, or Readmission tasks: 0
|
81 |
-
- For Mortality task: Between 2 and 8 (inclusive)
|
82 |
-
- `diagnosis`, `output`, `chart`, `proc`, `meds`, `lab` (boolean): Specifies whether to include each respective feature. Valid values: True or False.
|
83 |
-
- `disease_filter` (string): Specifies the disease filter if focusing on a cohort with a specific chronic disease. Valid values:
|
84 |
-
- Heart Failure
|
85 |
-
- COPD
|
86 |
-
- CKD
|
87 |
-
- CAD
|
88 |
-
- No Disease Filter
|
89 |
-
- `icu_no_icu` (string): Specifies the dataset type. Valid values: ICU.
|
90 |
-
- `groupingDiag` (string): Specifies the grouping ICD option for diagnosis. Valid values:
|
91 |
-
- Convert ICD-9 to ICD-10 and group ICD-10 codes
|
92 |
-
- Keep both ICD-9 and ICD-10 codes
|
93 |
-
- Convert ICD-9 to ICD-10 codes
|
94 |
-
- `groupingMed`: Specifies if grouping Medication codes should be done to use Non propietary names : Valid values : Yes, No
|
95 |
-
- `groupingProc` : Specifies the ICD codes version to perform grouping for procedures : Valid values :
|
96 |
-
- ICD-9 and ICD-10
|
97 |
-
- ICD-10
|
98 |
-
- `select_diag`, `select_med`, `select_proc`, `select_out`, `select_chart`,`select_lab` (boolean): Specifies whether to do features selection as describe in https://github.com/healthylaife/MIMIC-IV-Data-Pipeline benchmark. Valid values: True or False.
|
99 |
-
- `outlier_removal` (string): Specifies the outlier removal method. Valid values:
|
100 |
-
- No outlier detection
|
101 |
-
- Impute Outlier (default:98)
|
102 |
-
- Remove outliers (default:98)
|
103 |
-
- `outlier` (integer): Specifies the outlier threshold. Valid values: Between 90 and 99 (inclusive).
|
104 |
-
- `left_outlier` (integer): Specifies the left outlier threshold. Valid values: Between 0 and 10 (inclusive).
|
105 |
-
|
106 |
-
## Example Configuration File
|
107 |
-
|
108 |
-
Here's an example of a valid configuration file for **ICU Data**:
|
109 |
-
|
110 |
-
```yaml
|
111 |
-
disease_label: CAD
|
112 |
-
timePrediction: 30
|
113 |
-
timeWindow: Last 72 hours
|
114 |
-
timebucket: 2
|
115 |
-
radimp: forward fill and mean
|
116 |
-
predW: 0
|
117 |
-
diagnosis: True
|
118 |
-
output: True
|
119 |
-
chart: True
|
120 |
-
proc: True
|
121 |
-
meds: True
|
122 |
-
disease_filter: No Disease Filter
|
123 |
-
icu_no_icu: ICU
|
124 |
-
groupingICD: Convert ICD-9 to ICD-10 and group ICD-10 codes
|
125 |
-
select_diag: False
|
126 |
-
select_med: False
|
127 |
-
select_proc: False
|
128 |
-
select_out: False
|
129 |
-
select_chart: False
|
130 |
-
outlier_removal: Impute Outlier (default:98)
|
131 |
-
outlier: 98
|
132 |
-
left_outlier: 0
|
133 |
-
```
|
134 |
-
Here's an example of a valid configuration file for **Non-ICU Data**:
|
135 |
-
|
136 |
-
```yaml
|
137 |
-
timePrediction: 0
|
138 |
-
timeWindow: First 48 hours
|
139 |
-
timebucket: 2
|
140 |
-
radimp: forward fill and mean
|
141 |
-
predW: 2
|
142 |
-
diagnosis: True
|
143 |
-
lab: True
|
144 |
-
proc: False
|
145 |
-
meds: False
|
146 |
-
disease_filter: CKD
|
147 |
-
icu_no_icu: ICU
|
148 |
-
groupingDiag: Convert ICD-9 to ICD-10 and group ICD-10 codes
|
149 |
-
select_diag: False
|
150 |
-
select_med: False
|
151 |
-
select_proc: False
|
152 |
-
select_lab: False
|
153 |
-
outlier_removal: Impute Outlier (default:98)
|
154 |
-
outlier: 98
|
155 |
-
left_outlier: 0
|
156 |
-
groupingMed: Yes
|
157 |
-
groupingProc: ICD-10
|
158 |
```
|
159 |
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
-
|
|
|
1 |
+
# Dataset Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
## Description
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
The `load_dataset` function is a powerful tool to efficiently load and prepare the Mimic-IV dataset for various healthcare analysis tasks. It offers a wide range of options for encoding data and generating cohorts, allowing for seamless integration into your research or application.
|
6 |
+
|
7 |
+
## Function Signature
|
8 |
+
|
9 |
+
```python
|
10 |
+
load_dataset('thbndi/Mimic4Dataset', task, mimic_path=mimic_data, config_path=config_file, encoding=encod, generate_cohort=gen_cohort, val_size=size, cache_dir=cache)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
```
|
12 |
|
13 |
+
## Arguments
|
14 |
+
|
15 |
+
1. `task` (string, default="Mortality"):
|
16 |
+
- Description: Specifies the task you want to perform with the dataset.
|
17 |
+
- Default: "Mortality"
|
18 |
+
- Note: Possible Values : 'Phenotype', 'Length of Stay', 'Readmission', 'Mortality'
|
19 |
+
|
20 |
+
2. `mimic_path` (string):
|
21 |
+
- Description: Complete path to the Mimic-IV raw data on user's machine.
|
22 |
+
- Note: You need to provide the appropriate path where the Mimic-IV data is stored.
|
23 |
+
|
24 |
+
3. `config_path` (string) optionnal:
|
25 |
+
- Description: Path to the configuration file for the cohort generation choices (more infos in '/config/readme.md').
|
26 |
+
- Default: Configuration file provided in the 'config' folder.
|
27 |
|
28 |
+
4. `encoding` (string, default="concat"):
|
29 |
+
- Description: Data encoding option for the features.
|
30 |
+
- Options: "concat", "aggreg", "tensor", "raw", "text"
|
31 |
+
- Default: "concat"
|
32 |
+
- Note: Choose one of the following options for data encoding:
|
33 |
+
- "concat": Concatenates the one-hot encoded diagnoses, demographic data vector, and dynamic features at each measured time instant, resulting in a high-dimensional feature vector.
|
34 |
+
- "aggreg": Concatenates the one-hot encoded diagnoses, demographic data vector, and dynamic features, where each item_id is replaced by the average of the measured time instants, resulting in a reduced-dimensional feature vector.
|
35 |
+
- "tensor": Represents each feature as an 2D array. There are separate arrays for labels, demographic data ('DEMO'), diagnosis ('COND'), medications ('MEDS'), procedures ('PROC'), chart/lab events ('CHART/LAB'), and output events data ('OUT'). Dynamic features are represented as 2D arrays where each row contains values at a specific time instant.
|
36 |
+
- "raw": Provide cohort from the pipeline without any encoding for custom data processing.
|
37 |
+
- "text": Represents diagnoses as text suitable for BERT or other similar text-based models.
|
38 |
+
|
39 |
+
5. `generate_cohort` (bool, default=True):
|
40 |
+
- Description: Determines whether to generate a new cohort from Mimic-IV data.
|
41 |
+
- Default: True
|
42 |
+
- Note: Set it to True to generate a cohort, or False to skip cohort generation.
|
43 |
+
|
44 |
+
6. `val_size`, 'test_size' (float):
|
45 |
+
- Description: Proportion of the dataset used for validation during training.
|
46 |
+
- Default: 0.1 for validation size and 0.2 for testing size.
|
47 |
+
- Note: Can be set to 0.
|
48 |
+
|
49 |
+
7. `cache_dir` (string):
|
50 |
+
- Description: Directory where the processed dataset will be cached.
|
51 |
+
- Note: Providing a cache directory for each encoding type can avoid errors when changing the encoding type.
|
52 |
+
|
53 |
+
## Example Usage
|
54 |
+
|
55 |
+
```python
|
56 |
+
from your_module import load_dataset
|
57 |
+
|
58 |
+
# Example 1: Load dataset with default settings
|
59 |
+
dataset = load_dataset('thbndi/Mimic4Dataset', task="Mortality")
|
60 |
+
|
61 |
+
# Example 2: Load dataset with custom settings
|
62 |
+
dataset = load_dataset('thbndi/Mimic4Dataset', task="Phenotype", mimic_path="/path/to/mimic_data", config_path="/path/to/config_file", encoding="aggreg", generate_cohort=False, val_size=0.2, cache_dir="/path/to/cache_dir")
|
63 |
+
```
|
64 |
|
65 |
+
Please note that the provided examples are for illustrative purposes only, and you should adjust the paths and settings based on your actual dataset and specific use case.
|