# SlicerRT dose volume object

**URL:** https://discourse.slicer.org/t/slicerrt-dose-volume-object/17985
**Category:** Development
**Created:** [June 7, 2021, 1:06am UTC](https://discourse.slicer.org/t/slicerrt-dose-volume-object/17985 "2021-06-07T01:06:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![edwardwang1](https://avatars.discourse-cdn.com/v4/letter/e/858c86/32.png) [@edwardwang1](https://discourse.slicer.org/u/edwardwang1)
#### Post date: [June 7, 2021, 1:06am UTC](https://discourse.slicer.org/t/slicerrt-dose-volume-object/17985/1 "2021-06-07T01:06:47Z")

</div>

Hi there,

I am doing some work where I am creating radiation dose distributions for simulated tumours from scratch (rather than exporting from a RT planning software). In Python I generate a 3D numpy array which I convert to a _vtkMRMLScalarVolumeNode_. How do I convert my scalar volume node into a dose volume node that is used by the Dose Volume Histogram module in SlicerRT?

I am able to successfully load in dose volumes from DICOM data. When I investigate those volumes, I find that they are also _vtkMRMLScalarVolumeNodes_. What differentiates a dose volume node from other Scalar Volume Nodes (besides the unit).

Thank you,  
Ed

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [June 7, 2021, 4:03am UTC](https://discourse.slicer.org/t/slicerrt-dose-volume-object/17985/2 "2021-06-07T04:03:37Z")

</div>

Yes, it is mainly about setting the unit, but you also need to have the dose volume under a proper DICOM hierarchy. You can find all the necessary steps in the implementation of the right-click menu action (in Data module) that converts a regular volume to a dose volume:

> <https://github.com/SlicerRt/SlicerRT/blob/5bd54b56750621a31d02c17161dea2d1d88ad4c3/DicomRtImportExport/SubjectHierarchyPlugins/qSlicerSubjectHierarchyRtDoseVolumePlugin.cxx#L298-L393>

---

<div class="post-metadata">

### Author: ![edwardwang1](https://avatars.discourse-cdn.com/v4/letter/e/858c86/32.png) [@edwardwang1](https://discourse.slicer.org/u/edwardwang1)
#### Post date: [June 7, 2021, 4:47pm UTC](https://discourse.slicer.org/t/slicerrt-dose-volume-object/17985/3 "2021-06-07T16:47:05Z")

</div>

Thank you, this is exactly what I was looking for!

---

<div class="post-metadata">

### Author: ![edwardwang1](https://avatars.discourse-cdn.com/v4/letter/e/858c86/32.png) [@edwardwang1](https://discourse.slicer.org/u/edwardwang1)
#### Post date: [June 7, 2021, 6:40pm UTC](https://discourse.slicer.org/t/slicerrt-dose-volume-object/17985/4 "2021-06-07T18:40:26Z")

</div>

In case this is useful for others, here is my Python code to achieve this:

```auto
sh = slicer.util.getNodesByClass("vtkMRMLSubjectHierarchyNode")[0]
itemID = sh.GetItemByDataNode(MmNode)
sh.SetItemParent(itemID, sh.GetItemParent(sh.GetItemByDataNode(volumeNode)))
sh.SetItemAttribute(itemID, 'DoseUnitName', "Gy")
sh.SetItemAttribute(itemID, 'DoseUnitValue', "1.0")
MmNode.SetAttribute("DicomRtImport.DoseVolume", "1")
sh.RequestOwnerPluginSearch(itemID)
sh.ItemModified(itemID)

```
