Class TIFFToDicom
- java.lang.Object
-
- com.pixelmed.convert.TIFFToDicom
-
public class TIFFToDicom extends java.lang.Object
A class for converting TIFF files into DICOM images of a specified or appropriate SOP Class.
Defaults to producing single frame output unless a multi-frame SOP Class is explicitly requested (e.g., for WSI, request Whole Slide Microscopy Image Storage, which is "1.2.840.10008.5.1.4.1.1.77.1.6".
Supports conversion of tiled pyramidal whole slide images such as in Aperio/Leica SVS format.
Supports creation of dual-personality DICOM-TIFF files using either classic TIFF or BigTIFF, optionally with inclusion of a down-sampled pyramid inside the same file in a private DICOM attribute, in order to support TIFF WSI viewers that won't work without a pyramid.
Uses any ICC profile present in the TIFF file otherwise assumes sRGB.
Uses a JSON summary description file as the source of identification and descriptive metadata as described in
SetCharacteristicsFromSummary
.E.g.:
{ "top" : { "PatientName" : "PixelMed^AperioCMU-1", "PatientID" : "PX7832548325932", "StudyID" : "S07-100", "SeriesNumber" : "1", "AccessionNumber" : "S07-100", "ContainerIdentifier" : "S07-100 A 5 1", "IssuerOfTheContainerIdentifierSequence" : [], "ContainerTypeCodeSequence" : { "cv" : "433466003", "csd" : "SCT", "cm" : "Microscope slide" }, "SpecimenDescriptionSequence" : [ { "SpecimenIdentifier" : "S07-100 A 5 1", "IssuerOfTheSpecimenIdentifierSequence" : [], "SpecimenUID" : "1.2.840.99790.986.33.1677.1.1.19.5", "SpecimenShortDescription" : "Part A: LEFT UPPER LOBE, Block 5: Mass (2 pc), Slide 1: H&E", "SpecimenDetailedDescription" : "A: Received fresh for intraoperative consultation, labeled with the patient's name, number and 'left upper lobe,' is a pink-tan, wedge-shaped segment of soft tissue, 6.9 x 4.2 x 1.0 cm. The pleural surface is pink-tan and glistening with a stapled line measuring 12.0 cm. in length. The pleural surface shows a 0.5 cm. area of puckering. The pleural surface is inked black. The cut surface reveals a 1.2 x 1.1 cm, white-gray, irregular mass abutting the pleural surface and deep to the puckered area. The remainder of the cut surface is red-brown and congested. No other lesions are identified. Representative sections are submitted. Block 5: 'Mass' (2 pieces)", "SpecimenPreparationSequence" : [ { "SpecimenPreparationStepContentItemSequence" : [ { "ValueType" : "TEXT", "ConceptNameCodeSequence" : { "cv" : "121041", "csd" : "DCM", "cm" : "Specimen Identifier" }, "TextValue" : "S07-100 A 5 1" }, { "ValueType" : "CODE", "ConceptNameCodeSequence" : { "cv" : "111701", "csd" : "DCM", "cm" : "Processing type" }, "ConceptCodeSequence" : { "cv" : "127790008", "csd" : "SCT", "cm" : "Staining" } }, { "ValueType" : "CODE", "ConceptNameCodeSequence" : { "cv" : "424361007", "csd" : "SCT", "cm" : "Using substance" }, "ConceptCodeSequence" : { "cv" : "12710003", "csd" : "SCT", "cm" : "hematoxylin stain" } }, { "ValueType" : "CODE", "ConceptNameCodeSequence" : { "cv" : "424361007", "csd" : "SCT", "cm" : "Using substance" }, "ConceptCodeSequence" : { "cv" : "36879007", "csd" : "SCT", "cm" : "water soluble eosin stain" } } ] } ], "PrimaryAnatomicStructureSequence" : { "cv" : "44714003", "csd" : "SCT", "cm" : "Left Upper Lobe of Lung" } } ], "OpticalPathSequence" : [ { "OpticalPathIdentifier" : "1", "IlluminationColorCodeSequence" : { "cv" : "414298005", "csd" : "SCT", "cm" : "Full Spectrum" }, "IlluminationTypeCodeSequence" : { "cv" : "111744", "csd" : "DCM", "cm" : "Brightfield illumination" } } ] } }
- See Also:
SetCharacteristicsFromSummary
,TiledPyramid
,SOPClass
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
TIFFToDicom.BitBuffer
Copied from ij/io/BitBuffer.java A class for reading arbitrary numbers of bits from a byte array.
-
Constructor Summary
Constructors Constructor Description TIFFToDicom(java.lang.String jsonfile, java.lang.String inputFileName, java.lang.String outputFilePrefix, java.lang.String outputFileSuffix, java.lang.String modality, java.lang.String sopClass, java.lang.String transferSyntax, boolean addTIFF, boolean useBigTIFF, boolean alwaysWSI, boolean addPyramid, boolean mergeStrips, java.lang.String channelFile, boolean includeFileName, double spacingrowmm, double spacingcolmm, double thicknessmm)
Read a TIFF image input format file and create an image of a specified or appropriate SOP Class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
lzwUncompress(byte[] input)
Utility method for decoding an LZW-compressed image strip.static void
main(java.lang.String[] arg)
Read a TIFF image input format file consisting of one or more pages or tiles, and create one or more images of a specified or appropriate SOP Class.
-
-
-
Constructor Detail
-
TIFFToDicom
public TIFFToDicom(java.lang.String jsonfile, java.lang.String inputFileName, java.lang.String outputFilePrefix, java.lang.String outputFileSuffix, java.lang.String modality, java.lang.String sopClass, java.lang.String transferSyntax, boolean addTIFF, boolean useBigTIFF, boolean alwaysWSI, boolean addPyramid, boolean mergeStrips, java.lang.String channelFile, boolean includeFileName, double spacingrowmm, double spacingcolmm, double thicknessmm) throws java.io.IOException, DicomException, TIFFException, java.lang.NumberFormatException
Read a TIFF image input format file and create an image of a specified or appropriate SOP Class.
- Parameters:
jsonfile
- JSON file describing the functional groups and attributes and values to be added or replacedinputFileName
-outputFilePrefix
-outputFileSuffix
-modality
- may be nullsopClass
- may be nulltransferSyntax
- may be null, used if multiframe, ignored if single frame (which is always written uncompressed)addTIFF
- whether or not to add a TIFF IFD in the DICOM preamble to make a dual=personality DICOM-TIFF file sharing the same pixel datauseBigTIFF
- whether or not to create a BigTIFF rather than Classic TIFF filealwaysWSI
- whether or not to add WSI-related information even if not WSI SOP Class, e.g., for float converted to parametric mapaddPyramid
- whether or not to add multi-resolution pyramid (downsampled) layers to the TIFF IFD and a corresponding DICOM private data element in the same filemergeStrips
- whether or not to merge an image with more than one strip into a single DICOM image, or to create a separate image or frame for each stripchannelFile
- may be nullincludeFileName
- whether or not to record the original filename in the DICOM outputspacingrowmm
- PixelSpacing 1st value - spacing between adjacent rows (i.e. "y" spacing) (in mm) to use to override base layer spacing in case it is incorrect or not present (may be 0 if not supplied)spacingcolmm
- PixelSpacing 2nd value - spacing between adjacent columns (i.e. "x" spacing) (in mm) to use to override base layer spacing in case it is incorrect or not present (may be 0 if not supplied)thicknessmm
- SliceThickness and ImagedVolumeDepth value (in mm) to use (may be 0 if not supplied)- Throws:
java.io.IOException
DicomException
TIFFException
java.lang.NumberFormatException
-
-
Method Detail
-
lzwUncompress
public byte[] lzwUncompress(byte[] input)
Utility method for decoding an LZW-compressed image strip. Derived from io/ImageReader.java Adapted from the TIFF 6.0 Specification: http://partners.adobe.com/asn/developer/pdfs/tn/TIFF6.pdf (page 61)
-
main
public static void main(java.lang.String[] arg)
Read a TIFF image input format file consisting of one or more pages or tiles, and create one or more images of a specified or appropriate SOP Class.
Options are:
ADDTIFF | DONOTADDTIFF (default)
USEBIGTIFF (default) | DONOTUSEBIGTIFF
ALWAYSWSI | NOTALWAYSWSI (default)
ADDPYRAMID | DONOTADDPYRAMID (default)
MERGESTRIPS (default) | DONOTMERGESTRIPS
ADDDCMSUFFIX (default) | DONOTADDDCMSUFFIX
CHANNELFILE channelfile
SPACINGMM spacingmm
SPACINGROWCOLMM spacingrowmm(y) spacingcolmm(x)
THICKNESSMM thickness
- Parameters:
arg
- three, four, five or six parameters plus options, a JSON file describing the functional groups and attributes and values to be added or replaced, the TIFF inputFile, DICOM file outputFilePrefix, and optionally the modality, the SOP Class, and the Transfer Syntax to use if multi-frame, then various options controlling conversion including an optional channel file describing content of each channel, and spacing and thickness information
-
-