Skip to content

Commit

Permalink
ENH: Fix absent ReferencedUID for DoseVolume
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Polkovnikov authored and cpinter committed Oct 17, 2023
1 parent 411b5fc commit 66e5887
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion DicomRtImportExport/SubjectHierarchyPlugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(${KIT}_EXPORT_DIRECTIVE "Q_SLICER_${MODULE_NAME_UPPER}_SUBJECT_HIERARCHY_PLU
set(${KIT}_INCLUDE_DIRECTORIES
${SlicerRtCommon_INCLUDE_DIRS}
${vtkSlicerPlanarImageModuleLogic_INCLUDE_DIRS}
${vtkSlicerBeamsModuleMRML_INCLUDE_DIRS}
${vtkSlicerSubjectHierarchyModuleLogic_INCLUDE_DIRS}
${qSlicerSubjectHierarchyModuleWidgets_INCLUDE_DIRS}
${MRMLCore_INCLUDE_DIRS}
Expand Down Expand Up @@ -61,4 +62,4 @@ SlicerMacroBuildModuleQtLibrary(
TARGET_LIBRARIES ${${KIT}_TARGET_LIBRARIES}
RESOURCES ${${KIT}_RESOURCES}
WRAP_PYTHONQT
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <vtkMRMLNode.h>
#include <vtkMRMLScene.h>
#include <vtkMRMLScalarVolumeNode.h>
#include <vtkMRMLRTPlanNode.h>

// VTK includes
#include <vtkObjectFactory.h>
Expand Down Expand Up @@ -331,6 +332,30 @@ void qSlicerSubjectHierarchyRtDoseVolumePlugin::convertCurrentNodeToRtDoseVolume
std::string doseUnitNameInStudy = shNode->GetItemAttribute(studyItemID, vtkSlicerRtCommon::DICOMRTIMPORT_DOSE_UNIT_NAME_ATTRIBUTE_NAME);
std::string doseUnitValueInStudy = shNode->GetItemAttribute(studyItemID, vtkSlicerRtCommon::DICOMRTIMPORT_DOSE_UNIT_VALUE_ATTRIBUTE_NAME);

bool referencedInstanceIsSet = false;
std::vector< vtkIdType > studyChildrenIDs;
shNode->GetItemChildren(studyItemID, studyChildrenIDs);
// find RTPlan node and get InstanceUID of that plan to use it as ReferencedInstanceUID for converted RTDose
for (int childItemID : studyChildrenIDs)
{
vtkMRMLRTPlanNode* planNode = vtkMRMLRTPlanNode::SafeDownCast(shNode->GetItemDataNode(childItemID));
if (planNode)
{
std::string planInstanceUID = shNode->GetItemUID(childItemID, vtkMRMLSubjectHierarchyConstants::GetDICOMInstanceUIDName());
if (!planInstanceUID.empty())
{
shNode->SetItemAttribute(currentItemID, vtkMRMLSubjectHierarchyConstants::GetDICOMReferencedInstanceUIDsAttributeName(), planInstanceUID.c_str());
referencedInstanceIsSet = true;
}
}
}
// no RTPlan Instance UID, use Study series instance UID instead
if (!referencedInstanceIsSet)
{
std::string studyInstanceUID = shNode->GetItemAttribute(studyItemID, vtkMRMLSubjectHierarchyConstants::GetDICOMStudyInstanceUIDAttributeName());
shNode->SetItemAttribute(currentItemID, vtkMRMLSubjectHierarchyConstants::GetDICOMReferencedInstanceUIDsAttributeName(), studyInstanceUID.c_str());
}

// Show dialogs asking about dose unit name and value
bool ok;
QString defaultDoseUnitName(!doseUnitNameInStudy.empty() ? doseUnitNameInStudy.c_str() : "Gy");
Expand Down

0 comments on commit 66e5887

Please sign in to comment.