Operating system: Windows 10 Education
Slicer version: 5.0.2
Expected behavior:
I have a set of segmented slices in a directory. It has 2 classes (0 and 255). The image format is .bmp. I want to load them as a segmentation.
Actual behavior:
I was following the official docs. However, when I load as a volume and select LabelMap it gives the following error.
UpdateFromSeries: Unsupported number of components: 1 != 3
vtkMRMLVolumeArchetypeStorageNode::ReadDataInternal: Cannot read file as a volume of type LabelMapVolume [fullName = D:/roi_1_resampled/labelled/masks/dilate_roi_1_resampled_0476.bmp]: FileFormatError. Number of files listed in the node = 0. File reader says it was able to read 816 files. File reader used the archetype file name of D:/roi_1_resampled/labelled/masks/dilate_roi_1_resampled_0476.bmp [reader 0th file name = D:/roi_1_resampled/labelled/masks/dilate_roi_1_resampled_0476.bmp].
vtkMRMLStorageNode::ReadData: Failed to read node dilate_roi_1_resampled_0476_2 (vtkMRMLLabelMapVolumeNode1) from filename='D:/roi_1_resampled/labelled/masks/dilate_roi_1_resampled_0476.bmp'
Labelmap conversion from image sequences is a two step process: IMport then convert. I don’t think you can directly import an image stack as a labelmap. (Instructions you shared are for volumes that are already in NRRD or other Slicer compatible volumetric formats like NRRD or NIFTI).
The simplest solution is to use the ImageStacks from SlicerMorph extension as @pieper indicated. Once you import the volume, right click on it in the Data module, and choose “edit properties”, which wil take you to the volumes module. Expand the Volume Information tab, and click the button that says Convert.
.
Slicer does not use labelmaps for segmentations anymore. If you want to continue your segmentation in slicer (or create models out of these segmentations). You have one more step where you convert the labelmap to segmentation object. You can easily do that by right clicking the new labelmap object in the data module and choosing “Convert labelmap to Segmentation Node”.
Remember to save these so that you don’t have to keep repeating these stesp.
Thanks for point it out. That probably needs to be corrected, Slicer treats JPG/PNG/BMP as vector (RGB) images, whereas a labelmap is a scalar image. I expect that was the reason for the error you posted:
UpdateFromSeries: Unsupported number of components: 1 != 3
As for your current question, please provide a screenshot of the VOlumes module with the Volume Information tab expanded.
From your screenshot above the issue is the same, if you look at the NUmber of Scalars you see it is 3 (implying a RGB volume), not 1. I suspect the voxel spacing is incorrect. Again, you can take care all of those using ImageStacks module.