ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 [IEvolution] Reading dicom data using dcm4che3
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

karthikvadla16

USA
1 Posts

Posted - Aug 15 2016 :  18:48:18  Show Profile  Reply
Hi All,

I have a requirement to create a matrix for each .dcm image using pixel data. I tried below code using dcm4che in scala. I keep getting EOF exception when i specify ds.readDataset(-1,-1).

Can anyone help me with this.
Really appreciate your help.

Code:
---------

import java.io.{ByteArrayInputStream}
import org.dcm4che3.data.Tag
import org.dcm4che3.imageio.plugins.dcm.{DicomMetaData}
import org.dcm4che3.io.{BulkDataDescriptor, DicomInputStream}
import org.dcm4che3.io.DicomInputStream.IncludeBulkData
import org.scalatest.Matchers

class DicomTest extends TestingSparkContextWordSpec with Matchers {

"dicom folder" should {
"contain 9 files" in {

//dicomimages folder is within spark-rk/core
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 =>
dis.setIncludeBulkData(IncludeBulkData.URI);
dis.setBulkDataDescriptor(BulkDataDescriptor.PIXELDATA);
dis.setURI("java:iis"); // avoid copy of pixeldata to temporary file
val fmi = dis.readFileMetaInformation();
val ds = dis.readDataset(-1, -1);
new DicomMetaData(fmi, ds)
}

dm.map(m => m.getAttributes.getValue(Tag.PixelData)).foreach(println)
}
}

}



Error: (Please see attachment for complete error stack)
-------------
Caused by: 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)
at org.dcm4che3.io.DicomInputStream.readAttributes(DicomInputStream.java:497)

Karthik

Download Attachment: 2016815184739_eof_exception.txt

xequte

38610 Posts

Posted - Aug 15 2016 :  21:35:08  Show Profile  Reply
I'm afraid this forum is just for users of ImageEn and IEvolution.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: