public class TIFFToDicom extends 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", and a Modality of "SM"), or there is information in the TIFF metadata that is recognized as being appropriate for multi-frame conversion (e.g., SVS WSI files) and auto-recognition has not been supressed.
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" } } ] } }Improvements to this class have been funded in part with Federal funds from the National Cancer Institute, National Institutes of Health, under Task Order No. HHSN26110071 under Contract No. HHSN261201500003l (Imaging Data Commons).
SetCharacteristicsFromSummary
,
TiledPyramid
,
SOPClass
Modifier and Type | Class and Description |
---|---|
class |
TIFFToDicom.BitBuffer
Copied from ij/io/BitBuffer.java
A class for reading arbitrary numbers of bits from a byte array.
|
Constructor and Description |
---|
TIFFToDicom(String jsonfile,
String inputFileName,
String outputFilePrefix,
String outputFileSuffix,
String modality,
String sopClass,
String transferSyntax,
boolean addTIFF,
boolean useBigTIFF,
boolean alwaysWSI,
boolean addPyramid,
boolean mergeStrips,
boolean autoRecognize,
String channelFileName,
boolean includeFileName,
double spacingrowmm,
double spacingcolmm,
double thicknessmm,
boolean includeCopyOfImageDescription,
String uidFileName,
boolean addExtendedOffsetTable,
boolean addBasicOffsetTable)
Read a TIFF image input format file and create an image of a specified or appropriate SOP Class.
|
Modifier and Type | Method and Description |
---|---|
static void |
main(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.
|
public TIFFToDicom(String jsonfile, String inputFileName, String outputFilePrefix, String outputFileSuffix, String modality, String sopClass, String transferSyntax, boolean addTIFF, boolean useBigTIFF, boolean alwaysWSI, boolean addPyramid, boolean mergeStrips, boolean autoRecognize, String channelFileName, boolean includeFileName, double spacingrowmm, double spacingcolmm, double thicknessmm, boolean includeCopyOfImageDescription, String uidFileName, boolean addExtendedOffsetTable, boolean addBasicOffsetTable) throws IOException, DicomException, TIFFException, NumberFormatException
Read a TIFF image input format file and create an image of a specified or appropriate SOP Class.
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 stripautoRecognize
- whether or not to try to determine SOP Class and Modality to use from TIFF metadatachannelFileName
- 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)includeCopyOfImageDescription
- whether or not to copy TIFF ImageDescription into ImageCommentsuidFileName
- CSV file mapping filename and IFD number (from 0) to keyword and UID pair, may be nulladdExtendedOffsetTable
- whether or not to add an Extended Offset TableaddBasicOffsetTable
- whether or not to add a Basic Offset TableIOException
DicomException
TIFFException
NumberFormatException
public static void main(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
ADDEXTENDEDOFFSETTABLE | DONOTADDEXTENDEDOFFSETTABLE (default)
ADDBASICOFFSETTABLE | DONOTADDBASICOFFSETTABLE (default)
ALWAYSWSI | NOTALWAYSWSI (default)
ADDPYRAMID | DONOTADDPYRAMID (default)
MERGESTRIPS (default) | DONOTMERGESTRIPS
AUTORECOGNIZE (default) | DONOTAUTORECOGNIZE
ADDDCMSUFFIX (default) | DONOTADDDCMSUFFIX
INCLUDEFILENAME (default) | DONOTINCLUDEFILENAME
INCLUDEIMAGEDESCRIPTION (default) | DONOTINCLUDEIMAGEDESCRIPTION
CHANNELFILE channelfile
SPACINGMM spacingmm
SPACINGROWCOLMM spacingrowmm(y) spacingcolmm(x)
THICKNESSMM thickness
UIDFILE uidfile
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