View Issue Details

IDProjectCategoryView StatusLast Update
0004391Slicer4Core: Segmentationpublic2017-10-06 15:13
ReporterfepegarAssigned Topinter 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionSlicer 4.6.2 
Target VersionSlicer 4.7.0Fixed in VersionSlicer 4.8.0 
Summary0004391: Problems loading and rendering segmentations
Description

When a segmentation is loaded, some segments have apparently random opacities and also they're not rendered correctly.

Steps To Reproduce

Load the attached file as a Labelmap with Freesurfer labels, export to segmentation, save it, close scene and load the segmentation. Some segments don't have opacity 1 anymore, and they have rendering artifacts.

Or load the file into Slicer and paste this code:

import os
import vtkSegmentationCorePython

labelmapVolumeNode = getNode('freesurfer-label')
segmentationNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLSegmentationNode')
segmentationNode.CreateDefaultDisplayNodes()
segmentation = segmentationNode.GetSegmentation()
segmentation.SetMasterRepresentationName(vtkSegmentationCorePython.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())
slicer.modules.segmentations.logic().ImportLabelmapToSegmentationNode(labelmapVolumeNode, segmentationNode)
path = os.path.join(tempDirectory(), 'segmentation.seg.vtm')
saveNode(segmentationNode, path)
displayNode = segmentationNode.GetDisplayNode()
# print displayNode

slicer.mrmlScene.Clear(0)
segmentationNode = loadSegmentation(path, returnNode=True)[1]
displayNode = segmentationNode.GetDisplayNode()
# print displayNode
Additional Information

The attached snapshots are:
before.png: labelmap is exported to segmentation. Meshes look fine.
after.png: labelmap is loaded. Opacities are messed up and meshes look bad.

Comparison of the prints' outputs in the code: https://www.diffnow.com/?report=2nkqh

TagsNo tags attached.

Activities

fepegar

fepegar

2017-07-03 03:43

reporter  

freesurfer-label.nii.gz (600,652 bytes)
before.png (249,902 bytes)
before.png (249,902 bytes)
after.png (273,187 bytes)
after.png (273,187 bytes)
pinter

pinter

2017-07-17 10:03

developer   ~0014922

Based on the prints you referred to, it's indeed the opacities that cause the different visualization. Unfortunately the current VTK rendering doesn't do a very good job when showing models with various opacities. The change of opacities most probably happens due to automatically calculating them based on containment. This is a feature that allows the user to see all the loaded segments, because in many cases there is a "body" segment that is outside everything else, and if it's opaque, then no other segment is visible unless manually tweaking the opacities (frequently this is even more complex, as there could be a brain segment, inside that a planning target volume, and inside that the tumor).
This is where this happens: https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Segmentations/Logic/vtkSlicerSegmentationsModuleLogic.cxx#L290

What could solve your problem:

  1. Waiting for OpenGL 2.0. Several people are working on that, and should be coming soon
  2. Adding an option to Application Settings to disable this feature
  3. Writing a python script that sets all opacities to 1
fepegar

fepegar

2017-07-17 10:31

reporter   ~0014923

Thanks for looking into this.

Can't the opacity be saved in the nrrd, like the color? Otherwise, I think it would be useful to have this in the settings.

pinter

pinter

2017-07-17 11:07

developer   ~0014924

We used to, however display settings are generally not saved with the data, so we removed that. Display settings are stored in the mrml scene.
If you want to pursue discussion about this, please start a discourse topic. Otherwise I can implement solution 1 for example.

fepegar

fepegar

2017-07-17 11:11

reporter   ~0014925

Do you mean solution 2?

Anyway don't worry, we can manage using Python while we wait for the new OpenGL.

pinter

pinter

2017-07-17 11:13

developer   ~0014926

Yes, sorry :)
OK, if you'd like me to do that, please ask. If it's not critical, then I agree that we can wait for OpenGL 2.

lassoan

lassoan

2017-07-24 20:38

developer   ~0014929

Should we only apply the opacity heuristics when importing from DICOM?
Or should we at least make it optional (add a checkbox in the Add data dialog)?

pinter

pinter

2017-07-25 09:11

developer   ~0014963

I like the IO plugin option idea, but I'm not sure it's better than adding it to application settings. I think if you have to uncheck it every time you load a segmentation it becomes annoying, in which case app settings would work better.

lassoan

lassoan

2017-07-25 13:54

developer   ~0014981

We could implement both. Configuring through IO plugin properties would be mandatory (so that programmatically you could select the behavior without altering application settings) but default behavior could be stored in application settings.

lassoan

lassoan

2017-09-27 10:58

developer   ~0015163

@pinter Is there a chance it could be fixed in a few weeks (to be included in the upcoming stable release)?

pinter

pinter

2017-09-27 11:01

developer   ~0015165

Yes, I'll address this.

pinter

pinter

2017-10-06 15:13

developer   ~0015274

Fixed in https://github.com/Slicer/Slicer/commit/82bf550405a5b0dd7f914697c5ce967c6deac8f6

Issue History

Date Modified Username Field Change
2017-07-03 03:43 fepegar New Issue
2017-07-03 03:43 fepegar Status new => assigned
2017-07-03 03:43 fepegar Assigned To => pinter
2017-07-03 03:43 fepegar File Added: freesurfer-label.nii.gz
2017-07-03 03:43 fepegar File Added: after.png
2017-07-03 03:43 fepegar File Added: before.png
2017-07-03 17:57 fepegar Summary Segments visualization => Problems loading and rendering segmentations
2017-07-03 17:59 fepegar Steps to Reproduce Updated View Revisions
2017-07-17 10:03 pinter Note Added: 0014922
2017-07-17 10:31 fepegar Note Added: 0014923
2017-07-17 11:07 pinter Note Added: 0014924
2017-07-17 11:11 fepegar Note Added: 0014925
2017-07-17 11:13 pinter Note Added: 0014926
2017-07-24 20:38 lassoan Note Added: 0014929
2017-07-24 20:55 lassoan Target Version => Slicer 4.7.0
2017-07-25 09:11 pinter Note Added: 0014963
2017-07-25 13:54 lassoan Note Added: 0014981
2017-09-27 10:58 lassoan Note Added: 0015163
2017-09-27 11:01 pinter Note Added: 0015165
2017-10-06 15:13 pinter Status assigned => resolved
2017-10-06 15:13 pinter Resolution open => fixed
2017-10-06 15:13 pinter Fixed in Version => Slicer 4.8.0
2017-10-06 15:13 pinter Note Added: 0015274