Package com.pixelmed.convert

## 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`

- - ### 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 addPyramid, boolean mergeStrips)`

    Read a TIFF image input format file and create an image of a specified or appropriate SOP Class.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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 addPyramid,
                             boolean mergeStrips)
                      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 replaced
        `inputFileName` -
        `outputFilePrefix` -
        `outputFileSuffix` -
        `modality` - may be null
        `sopClass` - may be null
        `transferSyntax` - may be null
        `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 data
        `useBigTIFF` - whether or not to create a BigTIFF rather than Classic TIFF file
        `addPyramid` - whether or not to add multi-resolution pyramid (downsampled) layers to the TIFF IFD and a corresponding DICOM private data element in the same file
        `mergeStrips` - 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 strip
      Throws:
        `java.io.IOException`
        `DicomException`
        `TIFFException`
        `java.lang.NumberFormatException`

  - ### Method Detail

    - #### 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

      ADDPYRAMID | DONOTADDPYRAMID (default)

      MERGESTRIPS (default) | DONOTMERGESTRIPS

      Parameters:
        `arg` - three, four or five 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, then various options controlling conversion