DICOM: Transfer Syntax: A Query of transmission semantics GE Private TS and dicomsyntax

Source: Internet
Author: User
Tags dicom viewer

DICOM: Transfer Syntax: A Query of transmission semantics GE Private TS and dicomsyntax
Background:

Before the columnTransfer Syntax(Tentative Chinese translation isTransmission Semantics,The DICOM3.0 standard Chinese Version open-source book program mentioned in the blog in early August was successfully launched, and many specialized terms translation work will be faced in the future. You are welcome to give your comments.In DICOM medical image processing: Abstract Syntax and Transfer Syntax are different in DICOM network transmission: the difference between C-STORE services in dcmqrscp.exeand storescu.exe describes the role of Transfer Syntax in network services. In the previous article DICOM: How to compress the dcm file in the dcm4che Toolkit (Continued Article), we will introduce the JPEG LossLess compression semantics and Implicit VR Little Endian mentioned when compressing the dcm file.
Transfer Sytanx plays an important role in the DICOM standard. It is written as a necessary element to the MetaInformation of the DCM file, it is also a prerequisite for data transmission between the two parties in DICOM network services (such as Bowen DICOM medical image processing: DICOM network transmission description TransferSyntaxx is a required element of PresentationContext ).

Question:

Recently, I received data from a GE device. The StoreSCP service provided by dcm4che3 cannot be identified at first."-Accept-known"But the image is "distorted" after the data is turned on, which is completely different from the original image. Therefore, we specifically studied the GE private Transfer Syntax, that is1.2.840.113619.5.2. Let's take a look at this wonderful private protocol.

StoreSCP of dcm4che3:

The StoreSCP service provided by dcm4che3 is not enabled"-Accept-known"Option, only the standards in the sop-classes.properties file are supported, and other unknown protocols can be accepted when enabled. By viewing the StoreSCP. java source code, you can see that the unknown protocol is also directly stored in the file.

    private void storeTo(Association as, Attributes fmi,         PDVInputStream data, File file) throws IOException  {    LOG.info("{}: M-WRITE {}", as, file);    file.getParentFile().mkdirs();    DicomOutputStream out = new DicomOutputStream(file);    try {        out.writeFileMetaInformation(fmi);        data.copyTo(out);    } finally {        SafeClose.close(out);    }    }

"-Accept-known"After the option is enabled, the data of the GE device is successfully received locally and stored in the file as shown in the above Code. However, the image display result is distorted.

Image Distortion:

Use DICOM Viewer to open data. The result is as follows:

Even if the window width is adjusted, various organizations cannot be displayed smoothly. The problem is not found by viewing DICOM information.

Similarly, you can directly view the binary data and locatePixelData ElementThe actual pixel data value isFA 24According to the description of GE Private TransferSyntax = 1.2.840.113619.5.2, the Private syntax isImplicit VR-Big Endian (G.E Private)If the pixel data is resolved to 0xFA24 =-1500 by using Big Endian, if the pixel data of Little Endian is 0x24FA = 9466, the background data displayed in Sante Editor is 9466.ProblemAppears inPixelData reading error, that is, the Sante EditorGE Private TransferSyntax = 1.2.840.113619.5.2Incorrect understanding.

GE Private TS:

Wireshark is used to capture data packets sent from GE devices to StoreSCP. According to the prompt of DICOM protocol data packets in Wireshark, it is found that GE Private TransferSyntax is really amazing, as shown below:

Implication,GE Private TransferSyntaxPrivate transmission semantics only processes PixelData elements using Big Endian. For other non-PxielData elements, Implicit VR Little Endian is still used, that isGE Private TransferSyntaxStandardImplicit VR Little EndianModifications to semantics are limited to PixelData data.

According to the source code in StoreSCP. java, dcm4che3 StoreSCP is enabled"-Accept-known"The options are acceptable.GE Private TransferSyntaxPrivate semantics, but does not really understand the meaning, but simply writes 1.2.840.113619.5.2 to the MetaInformation metadata, and directly copies PixelData to the file stream. In addition, most DICOM Viewer cannot understand it smoothly.GE Private TransferSyntaxAs a result, when parsing PixelData, follow the method of most of the previous elements directlyImplicit VR Little EndianSemantic read,Cause image distortion.

Solution:

Refer to GE's instructions for more information.GE Private TransferSyntaxAfter the private semantics, we can see that the storage order of PixelData is Big Endian.Implicit VR Little EndianThere is no difference in the standard default semantics. Therefore, considering the compatibility of DICOM ViewerGE Private TransferSyntaxPrivate semantics can be processed separately, and PixelData can be processed in ascending order. After the Big Endian of PixelData is converted to Little Endian, Transfer Syntax can be directlyGE Private TransferSyntaxChangeImplicit VR Little Endian. The Demo code is as follows:

Private void storeTo (Association as, Attributes fmi, PDVInputStream data, File file) throws IOException {LOG.info ("{}: M-WRITE {}", as, file); file. getParentFile (). mkdirs (); boolean bExchange = false; // TransferSyntax = 1.2.840.113619.5.2, is GE Private TS, // Implicit VR Little Endian for all elements partition t pixel Data, which is Big Endian if (fmi. getString (Tag. transferSyntaxUID) = "1.2.840.113619.5.2") {fmi. setString (Tag. transferSyntaxUID, VR. UI, "1.2.840.10008.1.2"); bExchange = true;} DicomOutputStream out = new DicomOutputStream (file); try {out. writeFileMetaInformation (fmi); data. copyTo (out);} finally {SafeClose. close (out); if (bExchange) {// here we should separately judge GE Private, convert Pixel Data from Big Endian to Little Endian try {DicomInputStream input = new DicomInputStream (file); Attributes attrs = input. readDataset (-1,-1); byte [] bytes = attrs. getBytes (2145386512); byte [] newBytes = new byte [bytes. length]; for (int I = 0; I <bytes. length/2; ++ I) {newBytes [2 * I] = bytes [2 * I + 1]; newBytes [2 * I + 1] = bytes [2 * I];} // or directly exchange // for (int I = 0; I <bytes. length; I + = 2) // {// byte swap = bytes [I]; // bytes [I] = bytes [I + 1]; // bytes [I + 1] = swap; //} attrs. setBytes (2145386512, VR. OW, newBytes); File file2 = new File ("c: \ GE2.dcm"); DicomOutputStream out2 = new DicomOutputStream (file2); out2.writeDataset (input. getFileMetaInformation (), attrs); input. close (); out2.close ();} catch (IOException e) {// TODO Auto-generated catch block e. printStackTrace ();}}}}

After modification, open the new received data again. The correct image is shown as follows:

So far,GE Private TransferSyntaxThe odd problem of private semantics is solved.




By zssure@163.com
Time: 2015/08/03

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.