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ā€™)
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);

Thank you for your kind support!

1 Like