Hello All,
I'm trying to get the pixel data using dcm4che3 in scala. I want to create a matrix out of pixel data to do some transformations.
Before reading pixel data, i tried to get file metadata. I have End of file exception .
Can you please help me with this.
My code snippet in scala:
-----------------------------------
val dicomRdd = sparkContext.wholeTextFiles("dicomimages")
val printbytes = dicomRdd.map { case (filepath, filedata) => filedata.getBytes().length }
printbytes.foreach(println)
val disRdd = dicomRdd.map { case (filepath, filedata) => new DicomInputStream(new ByteArrayInputStream(filedata.getBytes())) }
val dm = disRdd.map {
case dis =>
val fmi = dis.getFileMetaInformation
val data = dis.readDataset(-1, -1)
data
}
dm.foreach(println)
Error:
--------
Job aborted due to stage failure: Task 0 in stage 1.0 failed 1 times, most recent failure: Lost task 0.0 in stage 1.0 (TID 1, localhost): java.io.EOFException
at org.dcm4che3.util.StreamUtils.readFully(StreamUtils.java:63)
at org.dcm4che3.io.DicomInputStream.readFully(DicomInputStream.java:383)
at org.dcm4che3.io.DicomInputStream.readValue(DicomInputStream.java:711)
at org.dcm4che3.io.DicomInputStream.readValue(DicomInputStream.java:536)
Please see attachment for complete error.
Thanks
Karthik