Skip to content

Instantly share code, notes, and snippets.

@kmader
Created August 17, 2017 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmader/37b026d7ed9498e5d62d24e75f7114b3 to your computer and use it in GitHub Desktop.
Save kmader/37b026d7ed9498e5d62d24e75f7114b3 to your computer and use it in GitHub Desktop.
Read Dicom Headers in KNIME
library(tidyverse)
library(oro.dicom)
knime.in$Location %>%
plyr::ldply(function(in_path) {
readDICOMFile(as.character(in_path), pixelData = F)$hdr %>%
group_by(name) %>% summarize_all(funs(first)) %>% # remove duplicate names
select(name, value) %>% spread(name, value) %>% # reformat as a table
head(1)
}
) -> all_header
cbind(knime.in, all_header) -> knime.out
# knime complains about duplicate columns
names(knime.out)<-make.unique(names(knime.out))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment