RadioLogicCreator.cpp - mbarnig/RadioLogic GitHub Wiki

The RadioLogicCreator.cpp file is located in the folder /RadioLogicCreator/Plugin/, together with its associated header file RadioLogicCreator.h.

The RadioLogicCreator code contains the class RadioLogicCreator with private and public member variables and seven public methods:

OrthancPluginJobStepStatus Step()
void Stop()
void Reset()
bool CustomizeClinicalCaseInstances()
bool CustomizeClinicalCaseObservationInstance()
bool CustomizeClinicalCaseAnswerInstance()
void setParameters()

RadioLogicCreator::Step()

The Step() function works in the following three states by checking and incrementing the value of the member variable counter:

  • counter == 0 : the member variable maxSteps is set to the number of instances to process. The anonymization and customization of the instances is prepared and the function CustomizeClinicalCaseInstances() is called a first time. The job information content is initialized. The counter is incremented and the Step() function returns with "continue".
  • counter > 0 and < maxSteps : the function CustomizeClinicalCaseInstances() is called at each step by passing the related instanceId. The job content is regularly updated. If the CustomizeClinicalCaseInstances() returns an error, the Step() function returns with "stop" (failure), otherwise with "continue".
  • counter == maxSteps : the function CustomizeClinicalCaseInstances() is called a last time, followed by calling the functions CustomizeClinicalCaseObservationInstance() and CustomizeClinicalCaseAnswerInstance(). If everything works fine, the Step() function returns with "success".

RadioLogicCreator::Stop()

Currently the Stop() function only adds a message to the log file why the job has been stopped. This is done with a switch statement.

RadioLogicCreator::Reset()

Currently the Reset() function only adds a message to the log file that the job has been reset.

LOG(INFO) << "*** RadioLogicCreator Job " << jobName_ << " Reset()";

RadioLogicCreator::CustomizeClinicalCaseInstances()

The CustomizeClinicalCaseInstances() function generates new unique identifiers based on the RadioLogic DICOM UID prefix for the studies, series and SOP UID's for each instance. Then the REST API /instances/[resourceID]/anonymize is called to delete, replace and keep specific DICOM tags. The transferSyntax of the file is retrieved to check if the image is compressed. If not, the returned processed DICOM file is saved into a temporary folder and the function CompressAndScaleDicomImage() is called. If yes, the processed file is stored to the Orthanc server with new name, ID's and UID's, by using the SDK function OrthancPluginRestApiPost().

RadioLogicCreator::CustomizeClinicalCaseObservationInstance()

The task of the function CustomizeClinicalCaseObservationInstance() consist in adding the possible diagnoses as private tags into the stored DICOM file including the observation picture. Due to issue 140 with Orthanc core it is not possible to insert or modify private tags inside the Orthanc REST API's /tools/create-dicom or /instances/[resourceID]/modify. As a workaround a DICOM template with empty private tags is used, the pixels in the template are replaced with the data of the observation-image-file and the DICOM file is modified with a system call to the Offis DCMTK tool dcmodify. The process ends by storing the modified template as a new observation DICOM instance to the Orthanc server and deleting the original observation DICOM instance. The whole procedure is rather complex and needs writing and reading files in a temporary folder which must be removed before the function returns.

CustomizeClinicalCaseAnswerInstance()

The function CustomizeClinicalCaseAnswerInstance() is similar to the function described above and has the same complexity due to issue 140. The answer image has been scrambled with javascript before the upload to the server. This prevents that a clever user inspects the image preview on Orthanc to see the results with the correct diagnosis before submitting his own diagnosis in the RadioLogicTutor. The correct diagnosis is also written in scrambled text into a private DICOM tag. Other private tags are used to store the name of the clinical case author and the scramble key which is required by the RadioLogicTutor application to decode the image and the answer text. The whole scrambling process is not hacker proof, but encrypting the answers with public-key cryptography would be design-overkill.

In the next chapter we will look inside the RadioLogicTools.