# Import labelmap to segmentation node - in batch processing

**URL:** <https://discourse.slicer.org/t/import-labelmap-to-segmentation-node-in-batch-processing/2360>\
**Category:** Development\
**Created:** [March 19, 2018, 2:10pm UTC](https://discourse.slicer.org/t/import-labelmap-to-segmentation-node-in-batch-processing/2360 "2018-03-19T14:10:58Z")\
**Posts on this page:** 1\
**Showing post:** 10

<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:** [April 11, 2018, 2:20am UTC](https://discourse.slicer.org/t/import-labelmap-to-segmentation-node-in-batch-processing/2360/10 "2018-04-11T02:20:22Z")

</div>

There were a couple of problems:

- It is not enough to create the segmentation node but you need to also add to the scene. You can use `slicer.mrmlScene.AddNewNodeByClass` to create a node and add it to the scene in one step.
- `slicer.util.loadVolume` loads file as scalar volume, while `ImportLabelmapToSegmentationNode` expects a labelmap volume; you need to use `slicer.util.loadLabelVolume` instead
- Relative path was used for the input image. I’m not sure what is the working directory of Slicer. It is safer to use absolute path.

After fixing these issues, a full working example:

```
[success, labelmapVolumeNode] = slicer.util.loadLabelVolume(r"c:\Users\msliv\OneDrive\Projects\SlicerTesting3\20180410-StartupSegmentation\Segmentation-label.nrrd", returnNode=True)
segNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentationNode")
slicer.modules.segmentations.logic().ImportLabelmapToSegmentationNode(labelmapVolumeNode, segNode)
```

---

_[View the full topic](https://discourse.slicer.org/t/import-labelmap-to-segmentation-node-in-batch-processing/2360)._
