Working with DICOM objects and dcmtk, issue reading/writing files, Ubuntu

Hi all,

I'm trying to work with DICOM image datasets (CT and MRI scans etc), using the dcmtk and oro.dicom/oro.nifti packages.

I have a load of publically available datasets that I had trouble getting to load in the past as they have JPEG compression on (which oro.dicom doesn't like!). I got round that with dcmdjpeg in the dcmtk package previously.

However, I've now moved from Windows 10 to Ubuntu 18.04, and when I run the code below (which worked ok under Win 10), I'm getting "Permission denied" during the for... loop while trying to load in the files.

I've sorted permissions (all the folders are on a seperate drive) so that they have full read-write permissions, and my later code (for setting up a decompressed image folder) works fine.

I'm afraid this is a bit of a niche package (and dcmtk is a wrapper for using dcmtk tools in R, so it's not even native or partiularly helpfully documented...)

'''r
library(ANTsR)
#> Loading required package: ANTsRCore
#> 
#> Attaching package: 'ANTsRCore'
#> The following objects are masked from 'package:stats':
#> 
#>     sd, var
#> The following objects are masked from 'package:base':
#> 
#>     all, any, apply, max, min, prod, range, sum
library(oro.dicom)
#> oro.dicom 0.5.3
library(oro.nifti)
#> oro.nifti 0.10.1
#> 
#> Attaching package: 'oro.nifti'
#> The following objects are masked from 'package:ANTsRCore':
#> 
#>     origin, origin<-
library(devtools)
#> Loading required package: usethis
library(divest)
library(dcmtk)
library(RNiftyReg)
#> 
#> Attaching package: 'RNiftyReg'
#> The following objects are masked from 'package:oro.nifti':
#> 
#>     pixdim, pixdim<-

setwd("/media/jim/DATA/CT Data/Qure AI head CT/CQ500CT2 CQ500CT2/Unknown Study/CT 5mm")


#readDICOMFile(Folderpath)

### Create character vector of all DICOM files in WD
Work_data <- list.files(pattern = "*.dcm",
                        include.dirs = FALSE)
files <- c(1:(length(Work_data)))

### Decompress a block of files!! (NOTE- Original files will remain!)
for (i in files){
  name <- Work_data[i]
  outname <- paste("D",i,".dcm", sep ="")
  dcmdjpeg(name,
           outfile = outname)
}
#> /home/jim/R/x86_64-pc-linux-gnu-library/3.4/dcmtk/bin/dcmdjpeg  NA 'D1.dcm'
#> Warning in dcmdjpeg(name, outfile = outname): Result was not 0 from command, may
#> not execute properly
#> /home/jim/R/x86_64-pc-linux-gnu-library/3.4/dcmtk/bin/dcmdjpeg   'D0.dcm'
#> Warning in dcmdjpeg(name, outfile = outname): Result was not 0 from command, may
#> not execute properly
'''r

Hi @JimHughes,

It looks like the R code cannot access the dcmdjpeg binary.

Can you manually verify the binary file is located at the path provided: /home/jim/R/x86_64-pc-linux-gnu-library/3.4/dcmtk/bin/dcmdjpeg?

Hi @mattwarkentin
The file is there, but when I clicked on it I'm getting an error saying "There is no application installed for "excecutable" files.

I'm wondering if I've downloaded the wrong version of dcmtk now...

Have you tried using the install_dcmtk() function in the dcmtk package to install/re-install DCMTK?

dcmtk::install_dcmtk(type = 'windows', force = TRUE)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.