dicom icon indicating copy to clipboard operation
dicom copied to clipboard

Cannot read dicom while following code

Open abtpst opened this issue 7 years ago • 1 comments

I am trying to follow the tutorial at

https://saravanansubramanian.com/Saravanan/Articles_On_Software/Entries/2014/10/6_DICOM_Basics_-_Extracting_Image_Pixel_Data.html

to read dicom files. Here is some code i run

private static AttributeList list = new AttributeList();
	public static void main(String[] args) {
		String dicomFile = "/path/to/CT1_J2KR.dcm";
		
    	try {
    		list.read(dicomFile);
    		System.out.println("Transfer Syntax:" + getTagInformation(TagFromName.TransferSyntaxUID));
    		System.out.println("SOP Class:" + getTagInformation(TagFromName.SOPClassUID));
    		System.out.println("Modality:" + getTagInformation(TagFromName.Modality));
    		System.out.println("Samples Per Pixel:" + getTagInformation(TagFromName.SamplesPerPixel));
    		System.out.println("Photometric Interpretation:" + getTagInformation(TagFromName.PhotometricInterpretation));
    		System.out.println("Pixel Spacing:" + getTagInformation(TagFromName.PixelSpacing));
    		System.out.println("Bits Allocated:" + getTagInformation(TagFromName.BitsAllocated));
    		System.out.println("Bits Stored:" + getTagInformation(TagFromName.BitsStored));
    		System.out.println("High Bit:" + getTagInformation(TagFromName.HighBit));
    		SourceImage img = new com.pixelmed.display.SourceImage(list);
    		System.out.println("Number of frames " + img.getNumberOfFrames());
    		System.out.println("Width " + img.getWidth());//all frames will have same width
    		System.out.println("Height " + img.getHeight());//all frames will have same height  
    		System.out.println("Is Grayscale? " + img.isGrayscale());
    		System.out.println("Pixel Data present:" + (list.get(TagFromName.PixelData) != null));
    		OtherWordAttribute pixelAttribute = (OtherWordAttribute)(list.get(TagFromName.PixelData));
    		//get the 16 bit pixel data values
    		short[] data = pixelAttribute.getShortValues();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private static String getTagInformation(AttributeTag attrTag) {
		return Attribute.getDelimitedStringValuesOrEmptyString(list, attrTag);
	}

but at

list.read(dicomFile);

i get

    com.pixelmed.dicom.DicomException: No reader for JPEG2000 available for Transfer Syntax 1.2.840.10008.1.2.4.91
	at com.pixelmed.dicom.CompressedFrameDecoder.selectReaderFromCodecsAvailable(CompressedFrameDecoder.java:290)
	at com.pixelmed.dicom.AttributeList.read(AttributeList.java:913)
	at com.pixelmed.dicom.AttributeList.read(AttributeList.java:1166)
	at com.pixelmed.dicom.AttributeList.read(AttributeList.java:1284)
	at com.pixelmed.dicom.AttributeList.read(AttributeList.java:1365)
	at com.pixelmed.dicom.AttributeList.read(AttributeList.java:1333)
	at com.pixelmed.dicom.AttributeList.read(AttributeList.java:1486)
	at com.ibm.whi.breastadvisor.controller.BCADicomParser.parse(BCADicomParser.java:47)
	at com.ibm.whi.breastadvisor.controller.test.BCADicomParserUnitTest.dicomTest(BCADicomParserUnitTest.java:20)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

how do i fix this? Also, here is how i got the pixelmed jar

http://www.dclunie.com/pixelmed/software/20170524_current/

abtpst avatar Mar 09 '18 21:03 abtpst

Sorry, I somehow missed seeing this issue. The most likely cause is that you don't have the runtime dependency libraries installed in addition to PixelMed.jar. I believe you need JAI Image IO Tools. You can download the dependency files available on PixelMed site from here: http://www.dclunie.com/pixelmed/software/20180419_current/ Please look for a file called "pixelmedjavadicom_dependencyrelease.20180419.tar.bz2" and you should find them necessary files there. Thanks!

SaravananSubramanian avatar Jun 18 '18 23:06 SaravananSubramanian