Error: failed to read input surface created by C++ CLI module

Hi,

I have compiled CLI module with slicer to use it within slicer.
The module input is vtk volume geometry (contains points, elements, stresses) then it calculates the average stresses on the surface to get a vtp surface geometry (output).
When I used the module in slicer I got this error that slicer failed to read input surface.
Kindly note the log file, Can someone help me solve this issue, please?

Many thanks,
Farah

[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Session start time .......: 2020-09-22 16:22:57
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Slicer version ...........: 4.11.0-0000-00-00 (revision 3037 / 0) win-amd64 - not installed release
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Operating system .........: Windows /  Personal / (Build 18362, Code Page 65001) - 64-bit
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Memory ...................: 8058 MB physical, 14584 MB virtual
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - CPU ......................: GenuineIntel , 8 cores, 8 logical processors
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - VTK configuration ........: OpenGL2 rendering, TBB threading
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Qt configuration .........: version 5.15.0, with SSL, requested OpenGL 3.2 (compatibility profile)
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Developer mode enabled ...: yes
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Prefer executable CLI ....: yes
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Application path .........: D:/S4R/Slicer-build/bin/Release
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Additional module paths ..: D:/AAA_build/lib/Slicer-4.11/qt-scripted-modules, D:/AAA_build/lib/Slicer-4.11/qt-loadable-modules/Debug, D:/AAA_build/lib/Slicer-4.11/cli-modules/Debug, D:/AAA_build/lib/Slicer-4.11/qt-loadable-modules/Release, D:/AAA_build/lib/Slicer-4.11/cli-modules/Release, D:/AAA_build/lib/Slicer-4.11/qt-loadable-modules/MinSizeRel, D:/AAA_build/lib/Slicer-4.11/cli-modules/MinSizeRel, D:/AAA_build/lib/Slicer-4.11/qt-loadable-modules/RelWithDebInfo, D:/AAA_build/lib/Slicer-4.11/cli-modules/RelWithDebInfo
[DEBUG][Python] 22.09.2020 16:22:58 [Python] (D:\S4R\python-install\Lib\site-packages\pydicom\datadict.py:432) - Reversing DICOM dictionary so can look up tag from a keyword...
[DEBUG][Python] 22.09.2020 16:22:59 [Python] (D:\S4R\Slicer-build\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: Annotations
[DEBUG][Python] 22.09.2020 16:23:00 [Python] (D:\S4R\Slicer-build\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: SegmentEditor
[DEBUG][Python] 22.09.2020 16:23:00 [Python] (D:\S4R\Slicer-build\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: SegmentStatistics
[DEBUG][Qt] 22.09.2020 16:23:00 [] (unknown:0) - Switch to module:  "Welcome"
[WARNING][Qt] 22.09.2020 16:23:13 [] (unknown:0) - Empty filename passed to function
[INFO][VTK] 22.09.2020 16:23:24 [vtkMRMLModelStorageNode (0000027E69D360D0)] (D:\S4\Libs\MRML\Core\vtkMRMLModelStorageNode.cxx:380) - ReadDataInternal (vtkMRMLModelStorageNode1): File C:/Users/farah/Desktop/stress.vtk does not contain coordinate system information. Assuming LPS.
[DEBUG][Qt] 22.09.2020 16:23:24 [] (unknown:0) - "Model" Reader has successfully read the file "C:/Users/farah/Desktop/stress.vtk" "[0.23s]"
[DEBUG][Qt] 22.09.2020 16:23:26 [] (unknown:0) - Switch to module:  "AAA_AverageStress"
[DEBUG][Qt] 22.09.2020 16:23:37 [] (unknown:0) - Found CommandLine Module, target is  D:/AAA_build/lib/Slicer-4.11/cli-modules/Release/AAA_AverageStress.exe
[DEBUG][Qt] 22.09.2020 16:23:37 [] (unknown:0) - ModuleType: CommandLineModule
[DEBUG][Qt] 22.09.2020 16:23:37 [] (unknown:0) - AAA_AverageStress command line: 

D:/AAA_build/lib/Slicer-4.11/cli-modules/Release/AAA_AverageStress.exe --numSegments 4 C:/Users/farah/AppData/Local/Temp/Slicer/JHBC_vtkMRMLModelNodeE.vtp C:/Users/farah/AppData/Local/Temp/Slicer/JHBC_vtkMRMLModelNodeF.vtp
[DEBUG][Qt] 22.09.2020 16:23:37 [] (unknown:0) - AAA_AverageStress standard output:

vtkDebugLeaks has found no leaks.
[ERROR][VTK] 22.09.2020 16:23:37 [vtkSlicerCLIModuleLogic (0000027E677C03B0)] (D:\S4\Base\QTCLI\vtkSlicerCLIModuleLogic.cxx:2017) - AAA_AverageStress standard error:

ERROR: Failed to read input surface from C:/Users/farah/AppData/Local/Temp/Slicer/JHBC_vtkMRMLModelNodeE.vtp
[ERROR][VTK] 22.09.2020 16:23:37 [vtkSlicerCLIModuleLogic (0000027E677C03B0)] (D:\S4\Base\QTCLI\vtkSlicerCLIModuleLogic.cxx:2048) - AAA_AverageStress completed with errors
[INFO][VTK] 22.09.2020 16:23:37 [vtkMRMLScene (0000027E6FDAFA40)] (D:\S4\Libs\MRML\Core\vtkMRMLScene.cxx:316) - vtkMRMLScene::Clear

Hi,

I have compiled CLI module with slicer to use it within slicer. (all succeeded no failure)
The module input is vtk volume geometry (contains points, elements, stresses) then it calculates the average stresses on the surface to get a vtp surface geometry (output).
When I used the module in slicer I got this error that slicer failed to read input surface. it seems the module couldn’t find vtk directory although it is included in cmake.txt.
Kindly note the log file, cmake module and cmake extension.
Can someone help me solve this issue, please?

Many thanks,
Farah

[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Session start time .......: 2020-09-22 16:22:57
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Slicer version ...........: 4.11.0-0000-00-00 (revision 3037 / 0) win-amd64 - not installed release
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Operating system .........: Windows /  Personal / (Build 18362, Code Page 65001) - 64-bit
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Memory ...................: 8058 MB physical, 14584 MB virtual
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - CPU ......................: GenuineIntel , 8 cores, 8 logical processors
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - VTK configuration ........: OpenGL2 rendering, TBB threading
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Qt configuration .........: version 5.15.0, with SSL, requested OpenGL 3.2 (compatibility profile)
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Developer mode enabled ...: yes
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Prefer executable CLI ....: yes
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Application path .........: D:/S4R/Slicer-build/bin/Release
[DEBUG][Qt] 22.09.2020 16:22:57 [] (unknown:0) - Additional module paths ..: D:/AAA_build/lib/Slicer-4.11/qt-scripted-modules, D:/AAA_build/lib/Slicer-4.11/qt-loadable-modules/Debug, D:/AAA_build/lib/Slicer-4.11/cli-modules/Debug, D:/AAA_build/lib/Slicer-4.11/qt-loadable-modules/Release, D:/AAA_build/lib/Slicer-4.11/cli-modules/Release, D:/AAA_build/lib/Slicer-4.11/qt-loadable-modules/MinSizeRel, D:/AAA_build/lib/Slicer-4.11/cli-modules/MinSizeRel, D:/AAA_build/lib/Slicer-4.11/qt-loadable-modules/RelWithDebInfo, D:/AAA_build/lib/Slicer-4.11/cli-modules/RelWithDebInfo
[DEBUG][Python] 22.09.2020 16:22:58 [Python] (D:\S4R\python-install\Lib\site-packages\pydicom\datadict.py:432) - Reversing DICOM dictionary so can look up tag from a keyword...
[DEBUG][Python] 22.09.2020 16:22:59 [Python] (D:\S4R\Slicer-build\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: Annotations
[DEBUG][Python] 22.09.2020 16:23:00 [Python] (D:\S4R\Slicer-build\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: SegmentEditor
[DEBUG][Python] 22.09.2020 16:23:00 [Python] (D:\S4R\Slicer-build\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: SegmentStatistics
[DEBUG][Qt] 22.09.2020 16:23:00 [] (unknown:0) - Switch to module:  "Welcome"
[WARNING][Qt] 22.09.2020 16:23:13 [] (unknown:0) - Empty filename passed to function
[INFO][VTK] 22.09.2020 16:23:24 [vtkMRMLModelStorageNode (0000027E69D360D0)] (D:\S4\Libs\MRML\Core\vtkMRMLModelStorageNode.cxx:380) - ReadDataInternal (vtkMRMLModelStorageNode1): File C:/Users/farah/Desktop/stress.vtk does not contain coordinate system information. Assuming LPS.
[DEBUG][Qt] 22.09.2020 16:23:24 [] (unknown:0) - "Model" Reader has successfully read the file "C:/Users/farah/Desktop/stress.vtk" "[0.23s]"
[DEBUG][Qt] 22.09.2020 16:23:26 [] (unknown:0) - Switch to module:  "AAA_AverageStress"
[DEBUG][Qt] 22.09.2020 16:23:37 [] (unknown:0) - Found CommandLine Module, target is  D:/AAA_build/lib/Slicer-4.11/cli-modules/Release/AAA_AverageStress.exe
[DEBUG][Qt] 22.09.2020 16:23:37 [] (unknown:0) - ModuleType: CommandLineModule
[DEBUG][Qt] 22.09.2020 16:23:37 [] (unknown:0) - AAA_AverageStress command line: 

D:/AAA_build/lib/Slicer-4.11/cli-modules/Release/AAA_AverageStress.exe --numSegments 4 C:/Users/farah/AppData/Local/Temp/Slicer/JHBC_vtkMRMLModelNodeE.vtp C:/Users/farah/AppData/Local/Temp/Slicer/JHBC_vtkMRMLModelNodeF.vtp
[DEBUG][Qt] 22.09.2020 16:23:37 [] (unknown:0) - AAA_AverageStress standard output:

vtkDebugLeaks has found no leaks.
[ERROR][VTK] 22.09.2020 16:23:37 [vtkSlicerCLIModuleLogic (0000027E677C03B0)] (D:\S4\Base\QTCLI\vtkSlicerCLIModuleLogic.cxx:2017) - AAA_AverageStress standard error:

ERROR: Failed to read input surface from C:/Users/farah/AppData/Local/Temp/Slicer/JHBC_vtkMRMLModelNodeE.vtp
[ERROR][VTK] 22.09.2020 16:23:37 [vtkSlicerCLIModuleLogic (0000027E677C03B0)] (D:\S4\Base\QTCLI\vtkSlicerCLIModuleLogic.cxx:2048) - AAA_AverageStress completed with errors
[INFO][VTK] 22.09.2020 16:23:37 [vtkMRMLScene (0000027E6FDAFA40)] (D:\S4\Libs\MRML\Core\vtkMRMLScene.cxx:316) - vtkMRMLScene::Clear
#-----------------------------------------------------------------------------
set(MODULE_NAME AAA_AverageStress)

#-----------------------------------------------------------------------------

#
# SlicerExecutionModel
#

#-----------------------------------------------------------------------------
set(MODULE_INCLUDE_DIRECTORIES
  ${vtkITK_INCLUDE_DIRS}
  )

set(MODULE_SRCS
  )

set(MODULE_TARGET_LIBRARIES
  ${VTK_LIBRARIES}
  )

#-----------------------------------------------------------------------------
SEMMacroBuildCLI(
  NAME ${MODULE_NAME}
  TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES}
  INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES}
  ADDITIONAL_SRCS ${MODULE_SRCS}
  )

#-----------------------------------------------------------------------------
if(BUILD_TESTING)
  add_subdirectory(Testing)
endif()
cmake_minimum_required(VERSION 2.8.9)

project(AAA_AverageStress)

#-----------------------------------------------------------------------------
# Extension meta-information
set(EXTENSION_HOMEPAGE "http://www.example.com/Slicer/Extensions/AAA_AverageStress")
set(EXTENSION_CATEGORY "AAA")
set(EXTENSION_CONTRIBUTORS "Grand Joldes (The University of Western Australia, ISML)")
set(EXTENSION_DESCRIPTION "This is an example of a simple extension")
set(EXTENSION_ICONURL "http://www.example.com/Slicer/Extensions/AAA_AverageStress.png")
set(EXTENSION_SCREENSHOTURLS "http://www.example.com/Slicer/Extensions/AAA_AverageStress/Screenshots/1.png")

#-----------------------------------------------------------------------------
# Extension dependencies
find_package(Slicer REQUIRED)
include(${Slicer_USE_FILE})

#-----------------------------------------------------------------------------
# Extension modules
add_subdirectory(AAA_AverageStress)
## NEXT_MODULE

#-----------------------------------------------------------------------------
include(${Slicer_EXTENSION_CPACK})

Is the following file the input vtp file that you specified in your module? Do you have this file in your system?

1 Like

If you use the latest master version then you need to enable “Preserve CLI module data files” option in developer section in application settings to keep the CLI input/output files after execution.

No, it is not my input file,
this folder is the slicer directory.

Thank you Andras for your reply,

Unfortunately, this didn’t solve the issue, the only thing that it saved this vtp file in the slicer directory “JHBC_vtkMRMLModelNodeE.vtp” but couldn’t read it,
Do you think older version of slicer would solve this issue (i.e. slicer 4.10.2) ?

Many thanks,
Farah

Could you please attach an example .vtp file that is created but could not be read? (upload somewhere and post the link here)

Kindly note the attached link:


stress.vtk is my input file, it has node coordinates, elements (cells), and stresses.
CCI_vtkMRMLModelNodeE.vtp is the created vtp file it contains only the node coordinates and stresses (of stress.vtk).

Thank you Andras,
Farah

The vtp file that the CLI module created is valid, but it is just a point cloud. You need to copy cells from the input data set (triangles, polygons, vertices, …). Alternatively, you can just leave it as a point cloud but then in Slicer you need to apply a glyph filter to create some displayable geometry, for example using a glyph filter:

inputPointCloud = getNode('CCI_vtkMRMLModelNodeE')
glypher=vtk.vtkGlyph3D()
glypher.SetInputConnection(inputPointCloud.GetPolyDataConnection())
model = slicer.modules.models.logic().AddModel(glypher.GetOutputPort())
model.GetDisplayNode().SetScalarVisibility(True)
model.GetDisplayNode().SetActiveScalarName("S:Mises")

1 Like

Thankyou very much Andreas for this solution and your valuable time,

but what I am interested in is that my extension should take the input file (stress.vtk) and calculate the average stresses through thickness and write the output file which is the outer surface of this geometry only (surface without thickness with the averaged stress values).

After trying a lot with slicer platform, I tried to run this extension using command line, it asks about the following files: (ITKFactoryRegistration.dll) (vtkIO-8.2.dll) (vtkFilters-8.2.dll) (vtkCommon-8.2.dll), I found the vtk.dll files and copied them from slicer built folder to my built extension folder but I couldn’t find ITKFactoryRegistration.dll anywhere.

I think the extension is not able to call some required files. Although it was compiled with old version of slicer (I think in 2014) and working perfectly.

Many thanks,
Farah

Hi Andreas,

I would like to thank you for your support.
I managed to solve the problem and the extension is working now using the command line.

Thanks again,
Farah

1 Like

Which extension and which module in it are you using?

Does it generate different VTP file than that you attached?

This extension is created by Prof. Grand Joldes and used within BioPARR software for aneurysm stress calculations, it is not available on github.

I just copied the required vtk.dll files (generated from slicer building) to the extension folder and run it through the command line not through slicer.

Many thanks,
Farah

In general, DLL files are not portable across different software versions. In some cases they might accidentally work, but in general, if there is a DLL version mismatch then the application is expected to crash.