eth-mds / ricu

🏥 ICU data with R 🏥
https://eth-mds.github.io/ricu/
GNU General Public License v3.0
37 stars 10 forks source link

Dataset is not attached #54

Closed xinyuejohn closed 7 months ago

xinyuejohn commented 8 months ago

Thanks for your amazing work! I downloaded MIMIC-IV datasets from physionet myself. And then I was trying to import mimic4 dataset using ricu. Here are my steps: I used import_src to load the data and attach_src to attach the source. However, when I tried to run the last line cohort <- load_concepts(static_features, "miiv", verbose = TRUE), I got an error:

> cohort <- load_concepts(static_features, "miiv", verbose = TRUE)
Error in `assert_that()`:
! miiv was not found among the provided options. Did you possibly mean mimic_demo instead?
Backtrace:
    ▆
 1. ├─ricu::load_concepts(static_features, "miiv", verbose = TRUE)
 2. └─ricu:::load_concepts.character(static_features, "miiv", verbose = TRUE)
 3.   ├─ricu::load_concepts(...)
 4.   └─ricu::load_dictionary(src, x, name = dict_name, cfg_dirs = dict_dirs)
 5.     └─ricu:::assert_that(are_in(src, avail))

Could you help check if I missed some steps? Thanks!

Here's my code:

library(ricu)
library(dplyr)
import_src("miiv", 'physionet.org/files/mimiciv/2.2')
attach_src("miiv")
table_concepts <- explain_dictionary()
static_features <- table_concepts$name[table_concepts$category == "demographics"]
cohort <- load_concepts(static_features, "miiv", verbose = TRUE)
prockenschaub commented 7 months ago

Hi Xinyue,

Could you quickly confirm if you have the RICU_DATA_PATH set? You can check by running Sys.getenv("RICU_DATA_PATH") within your R session? If it returns "", you can set it with

Sys.getenv(RICU_DATA_PATH = "/path/to/where/you/want/your/ricu/datasets/to/live")

For me, the data path points to a folder in which each dataset has it's own subfolder (i.e., a mimic folder, a miiv folder, ...). I get the same error as you do if my path is not set. ricu doesn't know where to look for your data. During import_src, the fst files are generated in the same folder as the MIMIC IV source files but attach_src does not know where that is. Unfortunately, attach_src doesn't seem to throw an error in this case (@dplecko and @nbenn: probably worth considering throwing an error or a "X out of Y tables attached" kind of message?)

If you do not want to set an environment variable, you can pass the path to attach_src. In your case, this should be

attach_src("miiv", data_dir = 'physionet.org/files/mimiciv/2.2')

Hope this helps!

mlondschien commented 7 months ago

Also, which version of ricu are you using?

> packageVersion("ricu")
xinyuejohn commented 7 months ago

Also, which version of ricu are you using?

> packageVersion("ricu")

I'm using 0.6.0.

xinyuejohn commented 7 months ago

@prockenschaub Thanks for your reply!

I tried to run attach_src("miiv", data_dir = 'physionet.org/files/mimiciv/2.2'), and it solved the issue. Thanks!