FreeSurfer output loading on slicer via command line

I have been able to load freesurfer volume outputs on the slicer, import segmentations, and perform radiomic feature extraction using the slicer application. However, I would like to do the same using the command line in MacBook Air in batch mode for multiple subjects. Could someone please direct me in the right direction?

You can use the FreeSurferImporterLogic module’s logic in Python scripts to load freesurfer data then process, quantify, export, etc. Something like this can work for data loading:

fsImporterLogic = slicer.util.getModuleLogic('FreeSurferImporter')
volume = fsImporterLogic.LoadFreeSurferVolume('path/to/myfile')

I’m also trying to load FreeSurfer data with Python command line.
I succeeded to load volume, segmentation and model(pial) with this approach.
However, I cannot load annotation file by LoadFreeSurferScalarOverlay with error below. (This process can work with GUI.)
Would you suggest some solution for this problem?

fsImporterLogic = slicer.util.getModuleLogic(‘FreeSurferImporter’)
pial = fsImporterLogic.LoadFreeSurferModel(‘fsaverage/surf/lh.pial’)
modelNode=slicer.util.getNode(“lh_pial”)
fsImporterLogic.LoadFreeSurferScalarOverlay(‘fsaverage/label/lh.aparc.annot’, modelNode.GetID())
Traceback (most recent call last):
File “”, line 1, in
AttributeError: ‘vtkSlicerFreeSurferImporterModuleLogicPython.vtkSl’ object has no attribute ‘LoadFreeSurferScalarOverlay’

LoadFreeSurferScalarOverlay method is not Python-wrapped (VTK’s Python wrapper does not support vector of VTK objects).

@Sunderlandkyl could you add a Python-wrappable variant of this method?

New python wrapped methods should be available tomorrow in the nightly.

There are two function signatures, one that can load the overlay on many model nodes, and one that loads the overlay on a single model node:

bool LoadFreeSurferScalarOverlay(std::string filePath, vtkCollection* modelNodes);
bool LoadFreeSurferScalarOverlay(std::string filePath, vtkMRMLModelNode* modelNode);
2 Likes

Thank you for your kind support!

1 Like