Class DeidentifyAndRedact

java.lang.Object
com.pixelmed.apps.DeidentifyAndRedact
Direct Known Subclasses:
DeidentifyAndRedactWithOriginalFileName

public class DeidentifyAndRedact extends Object

A class to implement bulk de-identification and redaction of DICOM files.

Development of this class was supported by funding from MDDX Research and Informatics.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected class 
    A protected class that actually does all the work of finding and processing the files.
    protected class 
    A protected class to store sets of rectangular redaction regions indexed by a String classname.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Set<String>
     
    protected static String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DeidentifyAndRedact(String inputPathName, String outputFolderName, String redactionControlFileName, boolean decompress, boolean keepAllPrivate)
    Read DICOM format image files, de-identify them and apply any specified redactions to the Pixel Data.
    DeidentifyAndRedact(String inputPathName, String outputFolderName, String redactionControlFileName, boolean decompress, boolean keepAllPrivate, boolean addContributingEquipmentSequence)
    Read DICOM format image files, de-identify them and apply any specified redactions to the Pixel Data.
    DeidentifyAndRedact(String inputPathName, String outputFolderName, String redactionControlFileName, boolean decompress, boolean keepAllPrivate, boolean addContributingEquipmentSequence, AttributeList replacementAttributes)
    Read DICOM format image files, de-identify them and apply any specified redactions to the Pixel Data.
    DeidentifyAndRedact(String inputPathName, String outputFolderName, String redactionControlFileName, boolean decompress, boolean keepAllPrivate, AttributeList replacementAttributes)
    Read DICOM format image files, de-identify them and apply any specified redactions to the Pixel Data.
  • Method Summary

    Modifier and Type
    Method
    Description
    Get file names that failed to import.
    static void
    main(String[] arg)
    Read DICOM format image files, de-identify them and apply any specified redactions to the Pixel Data.
    protected String
    makeOutputFileName(String outputFolderName, String inputFileName, String sopInstanceUID)
    Make a suitable file name to use for a deidentified and redacted input file.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ourCalledAETitle

      protected static String ourCalledAETitle
    • failedSet

      protected Set<String> failedSet
  • Constructor Details

    • DeidentifyAndRedact

      public DeidentifyAndRedact(String inputPathName, String outputFolderName, String redactionControlFileName, boolean decompress, boolean keepAllPrivate, boolean addContributingEquipmentSequence, AttributeList replacementAttributes) throws DicomException, Exception, IOException

      Read DICOM format image files, de-identify them and apply any specified redactions to the Pixel Data.

      Searches the specified input path recursively for suitable files.

      If Baseline (sequential 8 bit) JPEG, can either redact without affecting other JPEG blocks or decompress JPEG entirely, redact and recompress (lossy)

      For details of the processing, see DeidentifyAndRedact.OurMediaImporter.doSomethingWithDicomFileOnMedia(String,String,String).

      For specification of the contents of the redaction control file, see DeidentifyAndRedact.RedactionRegions.

      Parameters:
      inputPathName - the path to search for DICOM files
      outputFolderName - where to store all the processed output files
      redactionControlFileName - which regions to redact in all the processed files
      decompress - decompress JPEG rather than try to avoid loss in unredacted blocks
      keepAllPrivate - retain all private attributes, not just known safe ones
      addContributingEquipmentSequence - whether or not to add ContributingEquipmentSequence
      replacementAttributes - additional attributes with values to add or replace during de-identification
      Throws:
      DicomException
      IOException
      Exception
    • DeidentifyAndRedact

      public DeidentifyAndRedact(String inputPathName, String outputFolderName, String redactionControlFileName, boolean decompress, boolean keepAllPrivate, AttributeList replacementAttributes) throws DicomException, Exception, IOException

      Read DICOM format image files, de-identify them and apply any specified redactions to the Pixel Data.

      Searches the specified input path recursively for suitable files.

      If Baseline (sequential 8 bit) JPEG, can either redact without affecting other JPEG blocks or decompress JPEG entirely, redact and recompress (lossy)

      For details of the processing, see DeidentifyAndRedact.OurMediaImporter.doSomethingWithDicomFileOnMedia(String,String,String).

      For specification of the contents of the redaction control file, see DeidentifyAndRedact.RedactionRegions.

      Adds ContributingEquipmentSequence by default.

      Parameters:
      inputPathName - the path to search for DICOM files
      outputFolderName - where to store all the processed output files
      redactionControlFileName - which regions to redact in all the processed files
      decompress - decompress JPEG rather than try to avoid loss in unredacted blocks
      keepAllPrivate - retain all private attributes, not just known safe ones
      replacementAttributes - additional attributes with values to add or replace during de-identification
      Throws:
      DicomException
      IOException
      Exception
    • DeidentifyAndRedact

      public DeidentifyAndRedact(String inputPathName, String outputFolderName, String redactionControlFileName, boolean decompress, boolean keepAllPrivate, boolean addContributingEquipmentSequence) throws DicomException, Exception, IOException

      Read DICOM format image files, de-identify them and apply any specified redactions to the Pixel Data.

      Searches the specified input path recursively for suitable files.

      If Baseline (sequential 8 bit) JPEG, can either redact without affecting other JPEG blocks or decompress JPEG entirely, redact and recompress (lossy)

      For details of the processing, see DeidentifyAndRedact.OurMediaImporter.doSomethingWithDicomFileOnMedia(String,String,String).

      For specification of the contents of the redaction control file, see DeidentifyAndRedact.RedactionRegions.

      Parameters:
      inputPathName - the path to search for DICOM files
      outputFolderName - where to store all the processed output files
      redactionControlFileName - which regions to redact in all the processed files
      decompress - decompress JPEG rather than try to avoid loss in unredacted blocks
      keepAllPrivate - retain all private attributes, not just known safe ones
      addContributingEquipmentSequence - whether or not to add ContributingEquipmentSequence
      Throws:
      DicomException
      IOException
      Exception
    • DeidentifyAndRedact

      public DeidentifyAndRedact(String inputPathName, String outputFolderName, String redactionControlFileName, boolean decompress, boolean keepAllPrivate) throws DicomException, Exception, IOException

      Read DICOM format image files, de-identify them and apply any specified redactions to the Pixel Data.

      Searches the specified input path recursively for suitable files.

      If Baseline (sequential 8 bit) JPEG, can either redact without affecting other JPEG blocks or decompress JPEG entirely, redact and recompress (lossy)

      For details of the processing, see DeidentifyAndRedact.OurMediaImporter.doSomethingWithDicomFileOnMedia(String,String,String).

      For specification of the contents of the redaction control file, see DeidentifyAndRedact.RedactionRegions.

      Adds ContributingEquipmentSequence by default.

      Parameters:
      inputPathName - the path to search for DICOM files
      outputFolderName - where to store all the processed output files
      redactionControlFileName - which regions to redact in all the processed files
      decompress - decompress JPEG rather than try to avoid loss in unredacted blocks
      keepAllPrivate - retain all private attributes, not just known safe ones
      Throws:
      DicomException
      IOException
      Exception
  • Method Details

    • makeOutputFileName

      protected String makeOutputFileName(String outputFolderName, String inputFileName, String sopInstanceUID) throws IOException

      Make a suitable file name to use for a deidentified and redacted input file.

      The default is the UID plus "_Anon.dcm" in the outputFolderName (ignoring the inputFileName).

      Override this method in a subclass if a different file name is required.

      Parameters:
      outputFolderName - where to store all the processed output files
      inputFileName - the path to search for DICOM files
      sopInstanceUID - the SOP Instance UID of the output file
      Throws:
      IOException - if a filename cannot be constructed
    • getFilePathNamesThatFailedToProcess

      public Set<String> getFilePathNamesThatFailedToProcess()

      Get file names that failed to import.

      Returns:
      file names that failed to import (empty if did not fail)
    • main

      public static void main(String[] arg)

      Read DICOM format image files, de-identify them and apply any specified redactions to the Pixel Data.

      Searches the specified input path recursively for suitable files If Baseline (sequential 8 bit) JPEG, can either redact without affecting other JPEG blocks or decompress JPEG entirely, redact and recompress (lossy)
      Parameters:
      arg - three, four or more parameters, the inputPath (file or folder), outputFolder, redactionControlFile, optionally the redaction method BLOCK|DECOMPRESS (default is BLOCK), optionally whether or not to keep all or just known safe private data elements KEEPALLPRIVATE|KEEPSAFEPRIVATE (default is KEEPSAFEPRIVATE), optionally whether or not to add ContributingEquipmentSequence ADDCONTRIBUTINGEQUIPMENT|DONOTADDCONTRIBUTINGEQUIPMENT (default is ADDCONTRIBUTINGEQUIPMENT), followed by optional pairs of keyword and value attribute replacements (e.g., PatientName "Doe^Jane")