Class DICOMUtil
java.lang.Object
com.mirth.connect.server.userutil.DICOMUtil
Provides DICOM utility methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.dcm4che2.data.DicomObjectbyteArrayToDicomObject(byte[] bytes, boolean decodeBase64) Converts a byte array into a dcm4che DicomObject.static StringconvertDICOM(String imageType, ImmutableConnectorMessage connectorMessage) Converts merged DICOM data associated with a connector message into a specified image format.static StringconvertDICOM(String imageType, ImmutableConnectorMessage connectorMessage, boolean autoThreshold) Converts merged DICOM data associated with a connector message into a specified image format.static StringconvertDICOM(String imageType, ImmutableConnectorMessage connectorMessage, int sliceIndex) Converts merged DICOM data associated with a connector message into a specified image format.static StringconvertDICOM(String imageType, ImmutableConnectorMessage connectorMessage, int sliceIndex, boolean autoThreshold) Converts merged DICOM data associated with a connector message into a specified image format.static byte[]convertDICOMToByteArray(String imageType, ImmutableConnectorMessage connectorMessage) Converts merged DICOM data associated with a connector message into a specified image format.static byte[]convertDICOMToByteArray(String imageType, ImmutableConnectorMessage connectorMessage, int sliceIndex) Converts merged DICOM data associated with a connector message into a specified image format.static byte[]convertDICOMToByteArray(String imageType, ImmutableConnectorMessage connectorMessage, int sliceIndex, boolean autoThreshold) Converts merged DICOM data associated with a connector message into a specified image format.static byte[]dicomObjectToByteArray(org.dcm4che2.data.DicomObject dicomObject) Converts a dcm4che DicomObject into a byte array.static byte[]getDICOMMessage(ImmutableConnectorMessage connectorMessage) Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a byte array.static byte[]getDICOMRawBytes(ImmutableConnectorMessage connectorMessage) Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a byte array.static StringgetDICOMRawData(ImmutableConnectorMessage connectorMessage) Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a Base64-encoded string.static intgetSliceCount(ImmutableConnectorMessage connectorMessage) Returns the number of slices in the fully-merged DICOM data associated with a given connector message.static StringmergeHeaderAttachments(ImmutableConnectorMessage connectorMessage, List<Attachment> attachments) Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a Base-64 encoded String.static StringmergeHeaderPixelData(byte[] header, List<byte[]> images) Re-attaches DICOM attachments with the given header data and returns the resulting merged data as a Base-64 encoded String.
-
Method Details
-
getDICOMRawData
Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a Base64-encoded string.- Parameters:
connectorMessage- The connector message to retrieve merged DICOM data for.- Returns:
- The merged DICOM data, Base64-encoded.
-
getDICOMRawBytes
Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a byte array.- Parameters:
connectorMessage- The connector message to retrieve merged DICOM data for.- Returns:
- The merged DICOM data as a byte array.
-
getDICOMMessage
Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a byte array.- Parameters:
connectorMessage- The connector message to retrieve merged DICOM data for.- Returns:
- The merged DICOM data as a byte array.
-
mergeHeaderAttachments
public static String mergeHeaderAttachments(ImmutableConnectorMessage connectorMessage, List<Attachment> attachments) throws com.mirth.connect.donkey.model.message.MessageSerializerException, IOException Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a Base-64 encoded String.- Parameters:
connectorMessage- The connector message containing header data to merge DICOM attachments with.attachments- The DICOM attachments to merge with the header data.- Returns:
- The merged DICOM data as a Base-64 encoded String.
- Throws:
com.mirth.connect.donkey.model.message.MessageSerializerException- If a database access error occurs, or the DICOM data could not be parsed.IOException- If Base64 encoding failed.
-
mergeHeaderPixelData
Re-attaches DICOM attachments with the given header data and returns the resulting merged data as a Base-64 encoded String.- Parameters:
header- The header data to merge DICOM attachments with.images- The DICOM attachments as byte arrays to merge with the header data.- Returns:
- The merged DICOM data as a Base-64 encoded String.
- Throws:
IOException- If Base64 encoding failed.
-
getSliceCount
Returns the number of slices in the fully-merged DICOM data associated with a given connector message.- Parameters:
connectorMessage- The connector message to retrieve DICOM data for.- Returns:
- The number of slices in the DICOM data.
-
convertDICOM
public static String convertDICOM(String imageType, ImmutableConnectorMessage connectorMessage, boolean autoThreshold) Converts merged DICOM data associated with a connector message into a specified image format.- Parameters:
imageType- The image format to convert the DICOM data to (e.g. "jpg").connectorMessage- The connector message to retrieve merged DICOM data for.autoThreshold- If true, automatically sets the lower and upper threshold levels.- Returns:
- The converted image, as a Base64-encoded string.
-
convertDICOM
Converts merged DICOM data associated with a connector message into a specified image format.- Parameters:
imageType- The image format to convert the DICOM data to (e.g. "jpg").connectorMessage- The connector message to retrieve merged DICOM data for.- Returns:
- The converted image, as a Base64-encoded string.
-
convertDICOM
public static String convertDICOM(String imageType, ImmutableConnectorMessage connectorMessage, int sliceIndex) Converts merged DICOM data associated with a connector message into a specified image format.- Parameters:
imageType- The image format to convert the DICOM data to (e.g. "jpg").connectorMessage- The connector message to retrieve merged DICOM data for.sliceIndex- If there are multiple slices in the DICOM data, this indicates which one to use (the first slice has an index of 1).- Returns:
- The converted image, as a Base64-encoded string.
-
convertDICOM
public static String convertDICOM(String imageType, ImmutableConnectorMessage connectorMessage, int sliceIndex, boolean autoThreshold) Converts merged DICOM data associated with a connector message into a specified image format.- Parameters:
imageType- The image format to convert the DICOM data to (e.g. "jpg").connectorMessage- The connector message to retrieve merged DICOM data for.sliceIndex- If there are multiple slices in the DICOM data, this indicates which one to use (the first slice has an index of 1).autoThreshold- If true, automatically sets the lower and upper threshold levels.- Returns:
- The converted image, as a Base64-encoded string.
-
convertDICOMToByteArray
public static byte[] convertDICOMToByteArray(String imageType, ImmutableConnectorMessage connectorMessage) Converts merged DICOM data associated with a connector message into a specified image format.- Parameters:
imageType- The image format to convert the DICOM data to (e.g. "jpg").connectorMessage- The connector message to retrieve merged DICOM data for.- Returns:
- The converted image, as a byte array.
-
convertDICOMToByteArray
public static byte[] convertDICOMToByteArray(String imageType, ImmutableConnectorMessage connectorMessage, int sliceIndex) Converts merged DICOM data associated with a connector message into a specified image format.- Parameters:
imageType- The image format to convert the DICOM data to (e.g. "jpg").connectorMessage- The connector message to retrieve merged DICOM data for.sliceIndex- If there are multiple slices in the DICOM data, this indicates which one to use (the first slice has an index of 1).- Returns:
- The converted image, as a byte array.
-
convertDICOMToByteArray
public static byte[] convertDICOMToByteArray(String imageType, ImmutableConnectorMessage connectorMessage, int sliceIndex, boolean autoThreshold) Converts merged DICOM data associated with a connector message into a specified image format.- Parameters:
imageType- The image format to convert the DICOM data to (e.g. "jpg").connectorMessage- The connector message to retrieve merged DICOM data for.sliceIndex- If there are multiple slices in the DICOM data, this indicates which one to use (the first slice has an index of 1).autoThreshold- If true, automatically sets the lower and upper threshold levels.- Returns:
- The converted image, as a byte array.
-
byteArrayToDicomObject
public static org.dcm4che2.data.DicomObject byteArrayToDicomObject(byte[] bytes, boolean decodeBase64) throws IOException Converts a byte array into a dcm4che DicomObject.- Parameters:
bytes- The binary data to convert.decodeBase64- If true, the data is assumed to be Base64-encoded.- Returns:
- The converted DicomObject.
- Throws:
IOException- If Base64 encoding failed.
-
dicomObjectToByteArray
public static byte[] dicomObjectToByteArray(org.dcm4che2.data.DicomObject dicomObject) throws IOException Converts a dcm4che DicomObject into a byte array.- Parameters:
dicomObject- The DicomObject to convert.- Returns:
- The converted byte array.
- Throws:
IOException- If Base64 encoding failed.
-