Memory issue (3d Slicer crashes when writing STL file)

Hi

This is my first post; be gentle with me. I have been using Slicer for a few years to segment CT or MRI scans and extract STL files for use with other CAE tools. I don’t use it extensively, but I have used the process that is currently giving me issues many times.

A client has provided a CT scan to me which reads in without problems, segments fine, but Slicer crashes when I try to write a STL file of the segment.

The scan is 2081 x 2081 x 1995 . The volumes output is attached.

Note the Image spacing is not correct, in x and y the spacing is 600nm and in z it is 600 um.

I segment between 12 and 254 and then try to write that to a STL file, which is when Slicer crashes. Attached is an image of memory usage at the point Slicer crashes.

Below is the output from Help>Report a bug

I presume this is a memory error, but I have more RAM that the 10X scan resolution. However, I have taken just the first 500 layers of the scan, and Slicer does not crash in this case.

I have tried the same process on the nightly build - 4.13.0-2021-05-19 - which tells me to increase the virtual memory, but then tells me there are memory leaks (I can provide this output if required).

Thanks for any help in advance.

Regards,

Mike

[DEBUG][Qt] 22.05.2021 11:19:30 [] (unknown:0) - Session start time …: 2021-05-22 11:19:30
[DEBUG][Qt] 22.05.2021 11:19:30 [] (unknown:0) - Slicer version …: 4.11.20210226 (revision 29738 / 7a593c8) win-amd64 - installed release
[DEBUG][Qt] 22.05.2021 11:19:30 [] (unknown:0) - Operating system …: Windows / Professional / (Build 19041, Code Page 65001) - 64-bit
[DEBUG][Qt] 22.05.2021 11:19:30 [] (unknown:0) - Memory …: 262065 MB physical, 366513 MB virtual
[DEBUG][Qt] 22.05.2021 11:19:30 [] (unknown:0) - CPU …: GenuineIntel , 56 cores, 56 logical processors
[DEBUG][Qt] 22.05.2021 11:19:30 [] (unknown:0) - VTK configuration …: OpenGL2 rendering, TBB threading
[DEBUG][Qt] 22.05.2021 11:19:30 [] (unknown:0) - Qt configuration …: version 5.15.1, with SSL, requested OpenGL 3.2 (compatibility profile)
[DEBUG][Qt] 22.05.2021 11:19:30 [] (unknown:0) - Developer mode enabled …: no
[DEBUG][Qt] 22.05.2021 11:19:30 [] (unknown:0) - Prefer executable CLI …: yes
[DEBUG][Qt] 22.05.2021 11:19:30 [] (unknown:0) - Application path …: C:/Users/mike.lewis/AppData/Local/NA-MIC/Slicer 4.11.20210226/bin
[DEBUG][Qt] 22.05.2021 11:19:30 [] (unknown:0) - Additional module paths …: (none)
[DEBUG][Python] 22.05.2021 11:19:35 [Python] (C:\Users\mike.lewis\AppData\Local\NA-MIC\Slicer 4.11.20210226\lib\Python\Lib\site-packages\pydicom\datadict.py:432) - Reversing DICOM dictionary so can look up tag from a keyword…
[DEBUG][Python] 22.05.2021 11:19:40 [Python] (C:\Users\mike.lewis\AppData\Local\NA-MIC\Slicer 4.11.20210226\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: Annotations
[DEBUG][Python] 22.05.2021 11:19:41 [Python] (C:\Users\mike.lewis\AppData\Local\NA-MIC\Slicer 4.11.20210226\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: SegmentEditor
[DEBUG][Python] 22.05.2021 11:19:41 [Python] (C:\Users\mike.lewis\AppData\Local\NA-MIC\Slicer 4.11.20210226\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: SegmentStatistics
[DEBUG][Qt] 22.05.2021 11:19:41 [] (unknown:0) - Switch to module: “Welcome”
[ERROR][VTK] 22.05.2021 11:23:45 [vtkITKArchetypeDiffusionTensorImageReaderFile (0000025137F1B380)] (D:\D\S\Slicer-1\Libs\vtkITK\vtkITKArchetypeDiffusionTensorImageReaderFile.cxx:166) - There is more than one file, use the vtkITKArchetypeImageSeriesReader instead
[INFO][VTK] 22.05.2021 11:25:12 [vtkMRMLVolumeArchetypeStorageNode (000002514BD122C0)] (D:\D\S\Slicer-1\Libs\MRML\Core\vtkMRMLVolumeArchetypeStorageNode.cxx:509) - Loaded volume from file: D:/Dropbox/Exchange/BioMedical/OxfordBioMedical/VOI_diameter_1,3mm/meniscotot_ir_rec_voi__cor_voi_00001032.bmp. Dimensions: 2081x2081x1995. Number of components: 3. Pixel type: unsigned char.
[DEBUG][Qt] 22.05.2021 11:25:12 [] (unknown:0) - “Volume” Reader has successfully read the file “D:/Dropbox/Exchange/BioMedical/OxfordBioMedical/VOI_diameter_1,3mm/meniscotot_ir_rec_voi__cor_voi_00001032.bmp” “[95.82s]”
[DEBUG][Qt] 22.05.2021 11:25:51 [] (unknown:0) - Switch to module: “Volumes”
[WARNING][Qt] 22.05.2021 11:25:51 [] (unknown:0) - Assertion this->Table->rowHeight(i) == newHeight failed in D:\D\S\Slicer-1-build\CTK\Libs\Widgets\ctkMatrixWidget.cpp line 253
[WARNING][Qt] 22.05.2021 11:25:51 [] (unknown:0) - Assertion this->Table->rowHeight(i) == newHeight failed in D:\D\S\Slicer-1-build\CTK\Libs\Widgets\ctkMatrixWidget.cpp line 253
[WARNING][Qt] 22.05.2021 11:25:51 [] (unknown:0) - Assertion this->Table->rowHeight(i) == newHeight failed in D:\D\S\Slicer-1-build\CTK\Libs\Widgets\ctkMatrixWidget.cpp line 253
[WARNING][Qt] 22.05.2021 11:25:51 [] (unknown:0) - Assertion this->Table->rowHeight(i) == newHeight failed in D:\D\S\Slicer-1-build\CTK\Libs\Widgets\ctkMatrixWidget.cpp line 253
[WARNING][Qt] 22.05.2021 11:25:51 [] (unknown:0) - Assertion this->Table->rowHeight(i) == newHeight failed in D:\D\S\Slicer-1-build\CTK\Libs\Widgets\ctkMatrixWidget.cpp line 253
[WARNING][Qt] 22.05.2021 11:25:51 [] (unknown:0) - Assertion this->Table->rowHeight(i) == newHeight failed in D:\D\S\Slicer-1-build\CTK\Libs\Widgets\ctkMatrixWidget.cpp line 253
[WARNING][Qt] 22.05.2021 11:25:51 [] (unknown:0) - Assertion this->Table->rowHeight(i) == newHeight failed in D:\D\S\Slicer-1-build\CTK\Libs\Widgets\ctkMatrixWidget.cpp line 253
[WARNING][Qt] 22.05.2021 11:25:51 [] (unknown:0) - Assertion this->Table->rowHeight(i) == newHeight failed in D:\D\S\Slicer-1-build\CTK\Libs\Widgets\ctkMatrixWidget.cpp line 253
[WARNING][Qt] 22.05.2021 11:25:51 [] (unknown:0) - Assertion this->Table->rowHeight(i) == newHeight failed in D:\D\S\Slicer-1-build\CTK\Libs\Widgets\ctkMatrixWidget.cpp line 253
[WARNING][Qt] 22.05.2021 11:25:51 [] (unknown:0) - Assertion this->Table->rowHeight(i) == newHeight failed in D:\D\S\Slicer-1-build\CTK\Libs\Widgets\ctkMatrixWidget.cpp line 253
[WARNING][Qt] 22.05.2021 11:25:51 [] (unknown:0) - Assertion this->Table->rowHeight(i) == newHeight failed in D:\D\S\Slicer-1-build\CTK\Libs\Widgets\ctkMatrixWidget.cpp line 253
[DEBUG][Qt] 22.05.2021 11:31:14 [] (unknown:0) - Switch to module: “SegmentEditor”
[DEBUG][Qt] 22.05.2021 11:32:54 [] (unknown:0) - Switch to module: “Segmentations”

Couple quick comments:

  1. Log doesn’t indicate the crash, are you sure this is from the session that crashed? When you go to file a bug, you want to choose the one down in the droplist (as the top is the active slicer session).
  2. You seem to load data from a cloud syncing drive. It is a small chance, but strange things happens when you try to read/write to these folder, I would suggest testing from a non-synced folder.
  3. You have an enormously anisotropic data, because you said the correct spacing is 600nm in XY and 600um in Z (a 1000 folds difference, is that really true?). If maintaining correct proportions in slicer you need to change your spacing to 1x1x1000. But such highly anisotropic data would create all sorts of issues in segmentation. So I would suggest first checking whether that’s indeed correct spacing and then decide how to proceed.
  4. In your screenshot above, your volume data type is a vector (as oppose to scalar). CT volumes are typically not vector. That might be the culprit with your crash. If it is not vector (multichannel image), you can try to use the VectorToScalar module to create a new volume of correct data type, segment and try to save it and see if it works.

Hi - thanks for the response.

1&2 This is the response from the log file, and I tried writing the stl file to a non cloud syncing drive, where I get a different error message.

image

a memory diagnostics test shows no errors. So it’s not clear to me what this memory error is.

3 This is a mistype/misread from me - Z is 600 nm as well.

4 I have tried this and doesn’t seem to make a difference. However, Resource Monitor says there are up to 4 Hard Faults/sec just before Slicer crashes.

Regards,

Mike

That’s a pretty large volume, and depending on the structure it could lead to an extremely large stl file that may push some limits.

If you can come up with a way to replicate this issue using public data others could investigate.

That was what I was thinking too.
@mikelewis does the error continue to persist if you try to write other model format (PLY, OBJ, VTK)? Can you tell us what the model size is (use Models module and expand the information tab).

Also, can you try to downsample the volume before segmentation (use crop volume by a factor of 2 or more) and repeat the segmentation and see if error goes away? If it does, it might have something to do with how large the model is.