View Issue Details

IDProjectCategoryView StatusLast Update
0004392Slicer4Core: Segmentationpublic2017-07-27 08:02
Reporterfepegar Assigned Topinter  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product VersionSlicer 4.6.2 
Target VersionSlicer 4.7.0Fixed in VersionSlicer 4.7.0 
Summary0004392: Exported segmentation is empty
Description

When trying to export a segmentation to a label map, the result is empty.

Additional Information

The colors of the segments come from a custom terminology file. This seems to be the source of the problem (see attached log). If I load the terminology before exporting, I still get the same.

TagsNo tags attached.

Activities

fepegar

fepegar

2017-07-05 18:14

reporter  

HumanBrainstemTerminology.json (78,804 bytes)
TC4_903_rgb_small.nii.gz (1,554,748 bytes)
TC4_903_segmentation.seg.nrrd (494,671 bytes)
log.txt (16,826 bytes)
log.txt (16,826 bytes)
pinter

pinter

2017-07-07 18:06

developer   ~0014916

Thanks for the detailed report! Your assessment makes sense. I'll fix it shortly.

fepegar

fepegar

2017-07-10 04:21

reporter   ~0014918

Apparently I can't paste the whole thing in a note. Here's a link: https://www.dropbox.com/s/vb4nu4yswpsz3xz/HumanBrainstemTerminology.json?dl=0

pinter

pinter

2017-07-14 21:00

developer   ~0014919

Hi Fernando,
I tried to export the the attached segmentation with the terminology you last linked to, and it was successful. Is there anything to do?
(I deleted your many page comment to keep the page manageable, but your comment went along with it, sorry!)

fepegar

fepegar

2017-07-16 08:41

reporter   ~0014920

I would like to be able to do the conversion even when the Terminology file is not the same that was used to create the segmentation / when the Terminology file is not in the scene. Would that be possible?

pinter

pinter

2017-07-16 18:01

developer   ~0014921

Terminology codes should uniquely identify a terminology entry, so a different code will mean a different entry. So if your codes change, and the segmentation contains terminology information using the old codes, the link is "broken". If you want this question to be discussed in more detail, please open a discourse topic, or an issue here https://github.com/QIICR/QuantitativeReporting

I see one way out of this, however, which is similar to the way we handle the non-standard DICOM files (this is the same issue practically, as your segmentation's terminology information becomes invalid), namely that we write a simple script that matches the Category and CodeMeaning entries in the segmentation and the terminology, and overwrites the CodeValue entries based on the matches.

By the way I just imported the original json file and exported the segmentation, and although I got a lot of warning messages, the resulting labelmap seems OK!

lassoan

lassoan

2017-07-24 20:32

developer   ~0014928

Is there any code change needed and/or just a note in the module documentation?

fepegar

fepegar

2017-07-25 09:49

reporter   ~0014965

The problem happened when I tried to export the segmentation using the modified JSON. I still think that should work, even if the codes are different.

pinter

pinter

2017-07-25 10:04

developer   ~0014966

From my last comment:
"By the way I just imported the original json file and exported the segmentation, and although I got a lot of warning messages, the resulting labelmap seems OK!"
Can you please try again?

fepegar

fepegar

2017-07-25 10:16

reporter   ~0014967

Sorry, I thought you meant that you used the original terminology that was used to create the segmentation.

l = slicer.modules.terminologies.logic()
l.LoadTerminologyFromFile('/Users/fernando/Downloads/HumanBrainstemTerminology.json')
[Load volume & segmentation]
Go to Segmentations and export using the volume as reference

I get the warnings and my label map is filled with zeros. I've used the three files I originally uploaded in this issue.

I'm using today's nightly.

pinter

pinter

2017-07-25 10:42

developer   ~0014970

I used the open button in Terminologies. I just did it again, and it works. Without having your terminology loaded, and with it as well:
https://www.screencast.com/t/D5mzMZzi6D
I'll check with the python calls now.

pinter

pinter

2017-07-25 10:49

developer   ~0014971

Still worked with the terminology.

Then it struck me that you mentioned using the volume as reference. I opened Advanced, set the volume as reference, and that is when the volume became empty!
Can you please confirm that it's not the terminology that causes the issue on your computer? Use the original terminology, but don't set the reference.
Thanks!

pinter

pinter

2017-07-25 10:50

developer   ~0014972

FYI if you load the terminology from python like that it will not be cached, so you have to do that every time. But if you use the load button, then it will be cached, and loaded automatically on every startup afterwards.

fepegar

fepegar

2017-07-25 10:51

reporter   ~0014973

I watched your video and the difference is that you don't set the volume node as reference. If a reference is given, the label map is empty. If the reference is None, the labels are ok but not the geometry.

fepegar

fepegar

2017-07-25 10:53

reporter   ~0014974

I hadn't read your last two comments. So yes, the reference node seems to be what's causing trouble and not the JSON.

Thanks for the info about the button.

pinter

pinter

2017-07-25 10:59

developer   ~0014976

Well if we knew that it's not the terminology but the referece, we could have saved a lot of time. Please be very specific about the steps next time. I'll look into this issue now that I can reproduce it.

fepegar

fepegar

2017-07-25 11:04

reporter   ~0014977

Ok, next time I'll make sure to include the exact steps. I'm sorry for the trouble.

pinter

pinter

2017-07-26 14:25

developer   ~0014990

It seems that the exported labelmap is empty because the reference image is only one slice, and the oriented image data becomes empty when resampling to that reference.

When I used a transformed MRHead as reference, then the labelmap was not empty and the segments were in the right place, but stripes appeared in it, probably because as the axes were not aligned, only the voxels were filled where the voxel center of the reference volume was inside the segmentation. This may have to do something with the thin slice reference as well. I'll keep digging.

pinter

pinter

2017-07-26 14:55

developer   ~0014992

This is definitely one of the reasons the exported labelmap is empty with a single-slice volume as reference
https://github.com/Slicer/Slicer/blob/master/Libs/vtkSegmentationCore/vtkOrientedImageDataResample.cxx#L476

pinter

pinter

2017-07-26 15:02

developer   ~0014993

Last edited: 2017-07-26 15:03

View 2 revisions

I did a commit to fix this issue.
https://github.com/Slicer/Slicer/commit/195961a3ccec1b336b4ed8dda585d56704e38b1d
Can you try tomorrow's nightly? Thanks!

fepegar

fepegar

2017-07-26 15:24

reporter   ~0014994

Ok, thanks Csaba. I'll let you know what happens tomorrow.

fepegar

fepegar

2017-07-27 05:33

reporter   ~0014999

It works fine now, thank you!

pinter

pinter

2017-07-27 08:02

developer   ~0015000

Excellent, thanks! I'm closing the issue.

Issue History

Date Modified Username Field Change
2017-07-05 18:14 fepegar New Issue
2017-07-05 18:14 fepegar Status new => assigned
2017-07-05 18:14 fepegar Assigned To => pinter
2017-07-05 18:14 fepegar File Added: HumanBrainstemTerminology.json
2017-07-05 18:14 fepegar File Added: TC4_903_rgb_small.nii.gz
2017-07-05 18:14 fepegar File Added: TC4_903_segmentation.seg.nrrd
2017-07-05 18:14 fepegar File Added: log.txt
2017-07-07 18:06 pinter Note Added: 0014916
2017-07-10 04:19 fepegar OS Sierra =>
2017-07-10 04:19 fepegar OS Version 10.12.5 =>
2017-07-10 04:19 fepegar Platform Mac =>
2017-07-10 04:21 fepegar Note Added: 0014918
2017-07-14 21:00 pinter Note Added: 0014919
2017-07-16 08:41 fepegar Note Added: 0014920
2017-07-16 18:01 pinter Note Added: 0014921
2017-07-24 20:32 lassoan Note Added: 0014928
2017-07-24 20:58 lassoan Target Version => Slicer 4.7.0
2017-07-25 09:49 fepegar Note Added: 0014965
2017-07-25 10:04 pinter Note Added: 0014966
2017-07-25 10:16 fepegar Note Added: 0014967
2017-07-25 10:42 pinter Note Added: 0014970
2017-07-25 10:49 pinter Note Added: 0014971
2017-07-25 10:50 pinter Note Added: 0014972
2017-07-25 10:51 fepegar Note Added: 0014973
2017-07-25 10:53 fepegar Note Added: 0014974
2017-07-25 10:59 pinter Note Added: 0014976
2017-07-25 11:04 fepegar Note Added: 0014977
2017-07-26 14:25 pinter Note Added: 0014990
2017-07-26 14:55 pinter Note Added: 0014992
2017-07-26 15:02 pinter Note Added: 0014993
2017-07-26 15:03 pinter Note Edited: 0014993 View Revisions
2017-07-26 15:08 pinter Status assigned => resolved
2017-07-26 15:08 pinter Resolution open => fixed
2017-07-26 15:08 pinter Fixed in Version => Slicer 4.7.0
2017-07-26 15:24 fepegar Note Added: 0014994
2017-07-27 05:33 fepegar Note Added: 0014999
2017-07-27 08:02 pinter Status resolved => closed
2017-07-27 08:02 pinter Note Added: 0015000