Skip to content
Kwang Soo Jeong edited this page Dec 27, 2018 · 12 revisions

Extraction Sequence

Use the library function to include the RadETL package.

library(RadETL)
  1. Use the DcmFileModule class to extract metadata from a DICOM image file into an RDS file

    # Example
    DFM <- DcmFileModule$new(path, savePathRoot, core)
    res <- DFM$dcmToRDS(rootPathCount = 4, verbose = FALSE)
    
    # If you want to see the saving status..
    View(res)  # List

    tutorial-rds

  2. Read the extracted metadata RDS file using the Radiology CDM generation function. (Using createRadiology family function)

    # Example 
    
    # Create Radiology_Occurrence table for rds Path
    rdsPath <- "/home/ohdsi/Radiology/rdsfiles"
    
    # Create RadDB object,,
    # If using pararell, require pararell package
    RDB <- RadDB$new(core = parallel::detectCores() - 1)
    
    # Get Radiology_Occurrence table
    occur <- RDB$createRadiologyOccurrence(path = rdsPath)
    
    # Create Radiology_Image table for read RDS file
    rdsFile <- "/home/ohdsi/DICOM-header/header.rds"
    data <- readRDS(file = rdsFile)
    
    # Get Radiology_Image table
    img <- RDB$createRadiologyImage(data = data)

    tutorial-rcdm

  3. Loads data from the RDS file into the RDBMS. (Using DBMSIO Class. Option A)

    # Example
    dbms <- "sql server"
    user <- Sys.getenv("user")
    pw <- Sys.getenv("pw")
    server <- Sys.getenv("dbServer")
    
    # Connect DBMS...
    db <- DBMSIO$new(server = server, user = user, pw = pw, dbms = dbms)
    
    # df is radiology Data frame,,
    db$insertDB(dbS = databaseSchema, data = df)
    db$finalize()

    tutorial-db

  4. Loads data from the RDS file into the RDBMS. (Using DatabaseConnector and SqlRender, Option B)

    # Example
    dbms <- "sql server"
    user <- Sys.getenv("user")
    pw <- Sys.getenv("pw")
    server <- Sys.getenv("dbServer")
    
    # Write connect information
    conDetails <- DatabaseConnector::createConnectionDetails(dbms = dbms, user = user, password = pw, server = server)
    
    # Connect DBMS
    con <- DatabaseConnector::connect(connectionDetails = conDetails)
    
    # insert tables...
    DatabaseConnector::insertTable(connection = con, tableName = paste0(databaseSchema, tbSchema), data = df)
    
    # if want disconnect
    DatabaseConnector::disconnect(connection = con)