Operating system: Windows 10
Slicer version: 4.11.20210226
Expected behavior: Edit imported segmentation using segment-editor for the whole volume
Actual behavior: The editable area / segmentation dimension is smaller than the master volume dimension
I’m working on a lung detection project. I use ML models to identify the lung area and generate masks. To further adjust the masks, I want to load them into 3D slicer and use segment-editor. First, I imported the original CT images as master volume with dimensions 512*512. Then the masks of the same size were imported as segmentations. Both original CT images and masks are loaded as .nii files.
When I try to edit the segmentation with Paint tool, two problems show up.
For the layers with the highlighted regions, the editable area of the segmentation is smaller than the original size (or volume dimensions). The screenshot is attached.
For the layers with no highlighted regions, I can’t paint anything on the segmentation. It’s not editable.
If you meet the similar problem, please let me know how you fix it.
Check that the CT and the segmentation has the exact same geometry (origin, spacing, axis directions, and extents). This is hard to do for nifti files, as the header is not human-readable and axis directions are stored redundantly in two different fields and the behavior is practically undefined if both are set. To avoid this, save the images as nrrd files instead and have a look at the headers in a text file viewer. If they are the same then you will be able to load these nrrd files into Slicer correctly. If they are different then you need to fix the software that copies the origin, spacing, axis directions, and extents from the input CT to the segmentation.
Also, as always, if you find any unexpected behavior try if things are any different with the latest Slicer Preview Release.
Whatever code you used to process the CTs has led to a serious corruption, so you shouldn’t expect volumes to line up coorectly. You can see that that the axial view is upside down (the table is at the top of the image and the chest is pointing down, and that the strip at the top of the scan in sagittal/coronal views does not match the rest of the volume.
Thank you for your reply. First, I tried to save both CT and masks into nrrd files. But the problem is not solved. Then I tried to eliminate the data I generated. Here is what I did:
Load the original CT (Dicom file) into 3D slicer and add new segmentation in segment_editor. Save the segmentation into nrrd file. To avoid size change, in the export section, the reference volume is set as master volume.
Then I use python libraries (pydicom and pynrrd) to check the dimensions.
I load the segmentation file back to 3D slicer again. Then I use segment_editor to paint the mask. The editable area changes as well. Also, for the layer without painting, I still cannot paint anything on it.
Your CT looks better now. It’s not clear what you are doing in step 2. The dicom is a 2D slice but you are trying to work with a 3D volume. You should probably use the slicerio or pynrrd packages in python to operate on the 3D volumes and make sure the nrrd files you load back into slicer are consistent with what you exported.
Hello, I’m not working with 3D volume. The only thing I’m trying to do is to edit the masks. In the first post, it’s one batch of my ML model. I want to load the ct images into 3D slicer and edit the masks. But I don’t know why the masks couldn’t load properly. I guest that the software is trying to save the RAM and reduce the data size.
DICOM file format is very complex, so if you are not sure how to properly extract and modify slices while preserving their correct physical size, position, and orientation then I would recommend to only work with nrrd files. You can read and write the entire 3D volume as a numpy array and you can very easily access individual slices using numpy indexing.