Class JDialogAnonymizeDirectory.AnonymizeDicomDirectories
- All Implemented Interfaces:
Runnable
- Enclosing class:
JDialogAnonymizeDirectory
When one directory is chosen as the source, all anonymized Dicom files in source are placed directly in the destination. Any images in any subdirectories (when chkChildren is selected) are sent into the children of the sub-directories.
More than one submitted source directory will be placed into discrete child directories of the submitted destination directory. As as example, /images/a, /images/b are selected, and /dest is the selected destination directory. They would get put into /dest/a, and /dest/b.
Naming can change the way the destination is made. Selecting a top-level randomisation, will randomate the output directory ofthe selected image directory. This isalong the lines in the above example as /images/a becoming /dest/abcde; and /images/b becoming /dest/12345. Selecting only one input directory will notmakea difference for top-level randomising. Child-directory randomising will give a random name when processing child direcories. this amounts to selecting /images (and recursive processing) and the destination directory /dest,and getting /images/a becoming /dest/abcde, and /images/b becoming /dest/12345.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate JDialogAnonymizeDirectoryDOCUMENT ME!private StringDOCUMENT ME!private booleanDOCUMENT ME!private File[]DOCUMENT ME!private FileDOCUMENT ME!private booleanDOCUMENT ME!private Stringportion of the file name for all anonymized images.private FileIODOCUMENT ME!private StringDOCUMENT ME!private ModelImageDOCUMENT ME!DOCUMENT ME!private StringDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private File[]DOCUMENT ME!private booleanDOCUMENT ME!private FileWriteOptionsDOCUMENT ME!Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionAnonymizeDicomDirectories(File[] src, File dest, String aname, int startseq, int toprand, boolean do_rename) sets up the anonymizer thread. -
Method Summary
Modifier and TypeMethodDescriptionvoida list of JTextAreas to be notified when a change in the process/output log is made. this permits almost-real-time updates to output devices this method adds the selected list of JTextAreas to receieve the output logs.private booleananonymizeImage(File imageFile, File destinationDirectory, int[] randomSuffixList, int numberOfSuffices) actually does the grunt-work of reading the designaated image-file, anonymizing it, and writing the file to the deisgnated destination directory.private booleanexists(int rnum, int[] rlist, int rnumptr) Checks for the existance of the numberrnumin the unsorted array rlist.private Stringcreates a string to use as a name out of the generic name, and the sequence.provides the string key of translations between source filename and destination filename.provides the string key of translations between source filename and destination filename.private Vector<FileDicomSQItem> getSequenceTags(ModelImage image) private voidlogWriting(File f) convienience method to add the filename to the log-string.private voidnotifyProcessLogs(String logtext) called when an update is made to the output log, this method updates all the process logging JTextAreas.private voidprocessMainDirectory(File sourceDirectory, File destinationDirectory) opens top-level image directory. anonymizes the images in the top directory, when the class has been set to dig in recursively, anonymizes the top directories and calls openSubDirectory(...) to anonymize the files below.private voidprocessSubDirectory(File destParentDirectory, File sourceParentDirectory) traverses the directory, anonymizing as it goes. the child directories are named after the source child-directory, and attempted to traverse (by calling processSubDirectory(File dest, File src)).voidrun()Specified by Thread. processes each directory selected directory, pausing after processing each selected directory to allow other threads run.voidsetCheckChildren(boolean chk) tells the anonymizer to check and anonymize the child directories of the selected source directories.voidno real need for complete listener capabilities, so this is to take its place.private voidsetGenericName(String aname, int seqStart) sets the genericname, and the start sequence to use when generating the anonymousname.voidstopping a thread prematurely is a co-operative process where the Thread checks for a stop-flag periodically, and stops itself by coming to the end of itsrun()method early.private voidwriteToKey(String original, String newKey) appends the original string, then two tabs then the newKey, followed by a newline to the keylog. old keylog is not overwritten.private voidwriteToLog(String anon_name) appends the name string, in between parens trailed by a colon.private voidwriteToLog(String logappendage, boolean completeString) Method to append the string to the log, adding a newline to the end, if requested, and appending a colon when not adding a newline.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
anonDialog
DOCUMENT ME! -
anonymousName
DOCUMENT ME! -
checkChildren
private boolean checkChildrenDOCUMENT ME! -
destDirs
DOCUMENT ME! -
destStub
DOCUMENT ME! -
doRename
private boolean doRenameDOCUMENT ME! -
genericName
portion of the file name for all anonymized images. -
io
DOCUMENT ME! -
keyLog
DOCUMENT ME! -
mi
DOCUMENT ME! -
notifierList
DOCUMENT ME! -
outputLog
DOCUMENT ME! -
randomizeTopLevelDir
private int randomizeTopLevelDirDOCUMENT ME! -
sequence
private int sequenceDOCUMENT ME! -
sequenceStart
private int sequenceStartDOCUMENT ME! -
srcDirs
DOCUMENT ME! -
stopThreadRequest
private boolean stopThreadRequestDOCUMENT ME! -
writeOpts
DOCUMENT ME!
-
-
Constructor Details
-
AnonymizeDicomDirectories
AnonymizeDicomDirectories(File[] src, File dest, String aname, int startseq, int toprand, boolean do_rename) sets up the anonymizer thread.- Parameters:
src- the list of directories to anonymize. this may be as large or as small as neededdest- the output directory. when the source-list lists but one file, the destination is the directory provided. If the list is more than one, then the destination is the root of the output directorues. How the output directories are named depends on the boolean, toprand.aname- the name to use for all images processed.startseq- number to start the sequence for all names in the sequence of anonymousnames.toprand- determines which directory to anonymize, if any. When processing a list of more than one source, the top-level directory can be randomized (as if the selected list were the image-directories themselves), or the first sub-directory level of directories (as if the selected directories had held lists of patient directories).NO_RANDOM_NAMESindicates no directory names are to be changed.RANDOM_DIRECTORY_NAMEindicates the top-level is to be randomised,RANDOM_SUBDIRECTORY_NAMEindicates the first sub-directory level to be randomised.
There is (true has??) no effect when only one level randomised.
do_rename- DOCUMENT ME!
-
-
Method Details
-
addProcessLoggingNotifier
a list of JTextAreas to be notified when a change in the process/output log is made. this permits almost-real-time updates to output devices this method adds the selected list of JTextAreas to receieve the output logs.- Parameters:
jta- DOCUMENT ME!
-
getKeyLog
provides the string key of translations between source filename and destination filename. The string is formatted with newlines and tabs seperating the filenames.- Returns:
- String the translation Strin as formatted by the anonymizer
-
getProcessLog
provides the string key of translations between source filename and destination filename. The string is formatted with newlines and tabs seperating the filenames.- Returns:
- String the translation Strin as formatted by the anonymizer
-
run
public void run()Specified by Thread. processes each directory selected directory, pausing after processing each selected directory to allow other threads run. Notifies the 'anonDialog' of completion. -
setCheckChildren
public void setCheckChildren(boolean chk) tells the anonymizer to check and anonymize the child directories of the selected source directories. Default is false;- Parameters:
chk- whether or not to check the child directories.
-
setFinishNotification
no real need for complete listener capabilities, so this is to take its place.- Parameters:
jsa- the anonimizer dialog to notify of the anonymization being complete
-
stopProcess
public void stopProcess()stopping a thread prematurely is a co-operative process where the Thread checks for a stop-flag periodically, and stops itself by coming to the end of itsrun()method early. This co-operative method of premature Thread stop permits the Thread to close any open system resources it needed, and will use the natural death procedures.In this case, in order to accept death, the Thread must close its open files; it will then back out of its recursion.
-
anonymizeImage
private boolean anonymizeImage(File imageFile, File destinationDirectory, int[] randomSuffixList, int numberOfSuffices) actually does the grunt-work of reading the designaated image-file, anonymizing it, and writing the file to the deisgnated destination directory. Note that the anonymous-name is class-public. don't overwrite it! This method contains a list to all the random numbers used in making the image destination due to problems in making File.exists() work correctly without a SecurityManager. (haven't tried WITH a SecurityManager).- Parameters:
imageFile- a File that could be a DICOM image. Non-DICOM images should fail and simply return out of this method without another thought. DIMC images will be processed and saved into the destination directory.destinationDirectory- a File which is the directory where a processed DICOM image file will be saved.randomSuffixList- array of ints, which are filled from 0 to max lengh of an unsorted numbers. each of which becomes the random name for the file.numberOfSuffices- current number of used slots in randomSuffixList. not to be larger than randomSuffixList.length returns boolean if the given image file was properly written to the destination directory, this method returnstrue.falsegets returned if the file either did not get written correctly (which would generate an exception), or if the file was non-DICOM, and was therefor ignored.- Returns:
- DOCUMENT ME!
- Throws:
IllegalArgumentException- when destinationDirectory.isDirecrtory() returnsfalse
-
exists
private boolean exists(int rnum, int[] rlist, int rnumptr) Checks for the existance of the numberrnumin the unsorted array rlist. The elements ofrlistexist fromrlist[0]torlist[rnumptr-1]. Of course, ifrnumptris greater than torlist.length, anArrayIndexOutOfBoundsExceptionwill be thrown. Check for it. This of course means thatrnumis not in the full array. This method does not check the array against the length of the array, but rather the number of assigned members, because only a partially-full list would return unpredicatable results.- Parameters:
rnum- number we are interested in finding.rlist- unsorted array of integers at the bottom elements.rnumptr- index into the array to stop searching; also, indicates the number of elements with an assigned value.- Returns:
truewhenrnumis found betweenrlist[0]andrlist[rlistptr-1].falsewhenrnumis not in the array.
-
generateAnonymousName
creates a string to use as a name out of the generic name, and the sequence. When processed, the anonymous name will be genericname_[seq]. the following name will be genericname_[seq+1].- Returns:
- the anonymous name.
-
getSequenceTags
-
logWriting
convienience method to add the filename to the log-string.Appends a newline to the file.
- Parameters:
f- -- file to note the conversion of the file to log.
-
notifyProcessLogs
called when an update is made to the output log, this method updates all the process logging JTextAreas.- Parameters:
logtext- DOCUMENT ME!
-
processMainDirectory
opens top-level image directory. anonymizes the images in the top directory, when the class has been set to dig in recursively, anonymizes the top directories and calls openSubDirectory(...) to anonymize the files below.- Parameters:
sourceDirectory- DOCUMENT ME!destinationDirectory- DOCUMENT ME!
-
processSubDirectory
traverses the directory, anonymizing as it goes. the child directories are named after the source child-directory, and attempted to traverse (by calling processSubDirectory(File dest, File src)).- Parameters:
destParentDirectory- parent directory is the parent directory tree for the destination;sourceParentDirectory- source name is the name of the source directory name- See Also:
-
setGenericName
sets the genericname, and the start sequence to use when generating the anonymousname. When processed, the anonymous name will be genericname_[seq]. the following name will be genericname_[seq+1].- Parameters:
aname- the name to use for all images processed.seqStart- number to start the sequence for all names in the sequence of anonymousnames.- See Also:
-
writeToKey
appends the original string, then two tabs then the newKey, followed by a newline to the keylog. old keylog is not overwritten.- Parameters:
original- DOCUMENT ME!newKey- DOCUMENT ME!
-
writeToLog
appends the name string, in between parens trailed by a colon. Eg., (anon_name:)". To be used before filtering the tags out of images (as those actions are logged in sequence.)- Parameters:
anon_name- DOCUMENT ME!
-
writeToLog
Method to append the string to the log, adding a newline to the end, if requested, and appending a colon when not adding a newline. The log is not replaced by the incoming string.- Parameters:
logappendage- string to write to the logcompleteString-truewrites a newline to the log.falsemakes this an unfinished string.
-