Not able to load Freesurfer Model (lh.pial) on Slicer 5.8.1

I’m trying to load a FreeSurfer model (lh.pial) programmatically through a scripted module but I’m not achieving it.

I’ve tried:

fsImporterLogic = slicer.util.getModuleLogic('FreeSurferImporter')
volumeNode = fsImporterLogic.LoadFreeSurferVolume(file_path)

where file_path is the path to one of the files I want to open, and got the following error:

vtkITKArchetypeImageSeriesReader::ExecuteInformation: Cannot open /Users/justo/Library/CloudStorage/GoogleDrive-justo.montoya@upf.edu/Mi unidad/SLICER/test_raw/fsfolder/surf/lh.pial. ITK exception info: error in unknown:  Could not create IO object for reading file /Users/justo/Library/CloudStorage/GoogleDrive-justo.montoya@upf.edu/Mi unidad/SLICER/test_raw/fsfolder/surf/lh.pial
[VTK]   Tried to create one of the following:
[VTK]     BMPImageIO
[VTK]     BioRadImageIO
[VTK]     DCMTKImageIO
[VTK]     GDCMImageIO
[VTK]     GiplImageIO
[VTK]     JPEGImageIO
[VTK]     LSMImageIO
[VTK]     MGHImageIO
[VTK]     MINCImageIO
[VTK]     MRCImageIO
[VTK]     MetaImageIO
[VTK]     NiftiImageIO
[VTK]     NrrdImageIO
[VTK]     PNGImageIO
[VTK]     ScancoImageIO
[VTK]     StimulateImageIO
[VTK]     TIFFImageIO
[VTK]     VTKImageIO
[VTK]     MRMLIDImageIO
[VTK]   You probably failed to set a file suffix, or
[VTK]     set the suffix to an unsupported type.
[VTK] Algorithm vtkITKArchetypeImageSeriesScalarReader (0x7f8fc479ae80) returned failure for request: vtkInformation (0x60001155aa00)
[VTK]   Debug: Off
[VTK]   Modified Time: 5320081
[VTK]   Reference Count: 1
[VTK]   Registered Events: (none)
[VTK]   Request: REQUEST_INFORMATION
[VTK]   ALGORITHM_AFTER_FORWARD: 1
[VTK]   FORWARD_DIRECTION: 0
[VTK] vtkMRMLVolumeArchetypeStorageNode::ReadDataInternal: Reading of file '/Users/justo/Library/CloudStorage/GoogleDrive-justo.montoya@upf.edu/Mi unidad/SLICER/test_raw/fsfolder/surf/lh.pial' failed: FileFormatError Number of files listed in the node is 0. File reader says it was able to read 0 files. File reader used the archetype file name of '/Users/justo/Library/CloudStorage/GoogleDrive-justo.montoya@upf.edu/Mi unidad/SLICER/test_raw/fsfolder/surf/lh.pial' (first filename: '')
[VTK] vtkMRMLVolumeArchetypeStorageNode::ReadDataInternal: Reading of file '/Users/justo/Library/CloudStorage/GoogleDrive-justo.montoya@upf.edu/Mi unidad/SLICER/test_raw/fsfolder/surf/lh.pial' failed: FileFormatError Number of files listed in the node is 0. File reader says it was able to read 0 files. File reader used the archetype file name of '/Users/justo/Library/CloudStorage/GoogleDrive-justo.montoya@upf.edu/Mi unidad/SLICER/test_raw/fsfolder/surf/lh.pial' (first filename: '')
[VTK] vtkMRMLVolumeArchetypeStorageNode::ReadDataInternal: Cannot read '/Users/justo/Library/CloudStorage/GoogleDrive-justo.montoya@upf.edu/Mi unidad/SLICER/test_raw/fsfolder/surf/lh.pial' file as a volume of type 'Volume'. Details: FileFormatError.
[VTK] vtkMRMLStorageNode::ReadData: Failed to read node lh (vtkMRMLScalarVolumeNode5) from filename='/Users/justo/Library/CloudStorage/GoogleDrive-justo.montoya@upf.edu/Mi unidad/SLICER/test_raw/fsfolder/surf/lh.pial'

I’ve also tried other options like:
modelNode = slicer.util.loadModel(file_path)

But it’s not working either. How can I open this FreeSurfer model programmatically?

Thanks in advance! :slight_smile:

The method you tried is for loading images. You can load models (in freesurfer terminology overlays) using LoadFreeSurferScalarOverlay.

Thanks.

What is an example usage of LoadFreeSurferScalarOverlay()?

I’ve seen that the logic is defined here SlicerFreeSurfer/FreeSurferImporter/Logic/vtkSlicerFreeSurferImporterLogic.h at master · PerkLab/SlicerFreeSurfer · GitHub but I can’t understand how to apply it to my situation.

I misspoke above, Slicer models correspond to freesurfer surfaces (*h.white, *h.pial, *h.inflated, *h.sphere, h.sphere.reg, h.orig files), and Slicer scalar arrays correspond to freesurfer overlays (.area, .curv, *.sulc, *.W files).

Surface reading was reworked about 1-2 years ago to use nibabel and is now implemented in a separate logic. You can use it as it is shown in this test:

slicer.util.loadNodeFromFile() would work if the NiBabelModelIO registered itself as a reader plugin. It would be nice if you could implement it (you would add a NiBabelModelIOFileReader class to the NiBabelModelIO.py and implement a few methods - similarly to this). But if you don’t have the time then you can simply use the NiBabelModelIO module logic directly.