# Error: DICOMSegmentationPlugin is not defined

**URL:** <https://discourse.slicer.org/t/error-dicomsegmentationplugin-is-not-defined/22624>\
**Category:** Support\
**Tags:** segmentation, extensions-manager, dicom, python\
**Created:** [March 21, 2022, 5:31pm UTC](https://discourse.slicer.org/t/error-dicomsegmentationplugin-is-not-defined/22624 "2022-03-21T17:31:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Liu\_Lance](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/liu_lance/32/14386_2.png) [@Liu\_Lance](https://discourse.slicer.org/u/Liu_Lance)\
**Post date:** [March 21, 2022, 5:31pm UTC](https://discourse.slicer.org/t/error-dicomsegmentationplugin-is-not-defined/22624/1 "2022-03-21T17:31:29Z")

</div>

Hi  
I try with the segmentation export to file function. It does not work for the line “import DICOMScalarVolumePlugin”,

> **[Script repository — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#export-a-volume-to-dicom-file-format)**

in the python console in 3d slicer, the error is like  
Traceback (most recent call last):  
File “”, line 1, in   
NameError: name ‘DICOMSegmentationPlugin’ is not defined

Does this package still work. How can I install this ?  
the code snippet is as follow:

### Export a volume to DICOM file format[¶](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#export-a-volume-to-dicom-file-format)

volumeNode = getNode(“CTChest”) outputFolder = “c:/tmp/dicom-output” # Create patient and study and put the volume under the study shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene) # set IDs. Note: these IDs are not specifying DICOM tags, but only the names that appear in the hierarchy tree patientItemID = shNode.CreateSubjectItem(shNode.GetSceneItemID(), “test patient”) studyItemID = shNode.CreateStudyItem(patientItemID, “test study”) volumeShItemID = shNode.GetItemByDataNode(volumeNode) shNode.SetItemParent(volumeShItemID, studyItemID) import DICOMScalarVolumePlugin exporter = DICOMScalarVolumePlugin.DICOMScalarVolumePluginClass() exportables = exporter.examineForExport(volumeShItemID) for exp in exportables: # set output folder exp.directory = outputFolder # here we set DICOM PatientID and StudyID tags exp.setTag(‘PatientID’, “test patient”) exp.setTag(‘StudyID’, “test study”) exporter.export(exportables)

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [March 21, 2022, 8:19pm UTC](https://discourse.slicer.org/t/error-dicomsegmentationplugin-is-not-defined/22624/2 "2022-03-21T20:19:42Z")

</div>

Yes for that example to work you have to have a Slicer extension installed. See the following thread about this:

> [@Import DICOMSegmentationPlugin does not work in preview release](https://discourse.slicer.org/t/import-dicomsegmentationplugin-does-not-work-in-preview-release/22289/6):
>
> Are you trying to replicate this example? [https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#export-a-segmentation-to-dicom-segmentation-object](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#export-a-segmentation-to-dicom-segmentation-object) According to this statement in Slicer core, the “DICOMSegmentationPlugin” comes from a Slicer extension. You would need to install Quantitative Reporting before being able to import DICOMSegmentationPlugin. [image] @pieper This probably brings up a point that the Script Repository needs to make mentions of any dependent ex…

---

<div class="post-metadata">

**Author:** ![Liu\_Lance](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/liu_lance/32/14386_2.png) [@Liu\_Lance](https://discourse.slicer.org/u/Liu_Lance)\
**Post date:** [March 22, 2022, 1:16am UTC](https://discourse.slicer.org/t/error-dicomsegmentationplugin-is-not-defined/22624/3 "2022-03-22T01:16:55Z")

</div>

> [@Liu\_Lance](#):
>
> DICOMSegmentationPlugin

Thanks so much,  
It looks like the problem is solved. the icon of the dicomQR doesn’t work anyway  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/f/6f2b557b3f71206184b983fa6cd3ab9dbfaba39b.png)
