Visualizing An Image From DICOM File

Read an DICOM file

This is example to read a DICOM file and display an image , by using this example code you must be install package oro.dicom first.

Download a DICOM file from Neurohacking_data repository

library(oro.dicom)

url <- "https://raw.githubusercontent.com/muschellij2/Neurohacking_data/master/BRAINIX/DICOM/T1/IM-0001-0001.dcm"
destfile <- "IM-0001-0001.dcm"
name <- file.path(getwd(), destfile)
download.file(url, destfile,mode="wb") # DICOM is binaryfile format
dcm <- readDICOMFile(destfile)

Show Manufacturer from file header by call extractHeader

extractHeader(dcm$hdr, "Manufacturer", numeric=FALSE)
## [1] "Philips Medical Systems"

Read an DICOM file

image(t(dcm$img), col=grey(0:64/64), axes=FALSE, xlab="", ylab="",
                main="Example image from DICOM file")

Leave a Reply

Your email address will not be published. Required fields are marked *