Galit
Galit

Reputation: 67

error in reading a DICOM file using readDICOM in R

I am trying to read multiple DICOM files from a directory. I installed the oro.dicom package and I use readDICOM function for this purpose:

dicom_file <- readDICOM("3_TR2000_300VOLUMES")

But I get this error:

Error in names(hdr) <- c("group", "element", "name", "code", "length",  :
'names' attribute [7] must be the same length as the vector [6]

Does anyone know what the problem might be and how to solve it?

Thank you.

Upvotes: 1

Views: 582

Answers (1)

Galit
Galit

Reputation: 67

I looked into the source of the readDICOM function. Apparently this function reads an additional file called Icon\r, which causes the error. I don't see this file in the directory, but R reads it anyway. I downloaded the source and edited it such that the Icon\r file is removed (by simply deleting the last file in the list). I used my edited version of the function, and now it works.

I'm not sure why the Icon\r file is there in the first place, but searching for it I saw something about it here.

If anyone has a different solution I'd be happy to hear!

A different solution that does not require editing functions - simply add the following command before executing the readDICOM function:

if (file.exists("Icon\r")) {file.remove("Icon\r")}

Upvotes: 2

Related Questions