# FreeSurfer output loading on slicer via command line

**URL:** <https://discourse.slicer.org/t/freesurfer-output-loading-on-slicer-via-command-line/22055>\
**Category:** Support\
**Created:** [February 18, 2022, 5:47pm UTC](https://discourse.slicer.org/t/freesurfer-output-loading-on-slicer-via-command-line/22055 "2022-02-18T17:47:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tejasvi0409](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tejasvi0409/32/13763_2.png) [@Tejasvi0409](https://discourse.slicer.org/u/Tejasvi0409)\
**Post date:** [February 18, 2022, 5:47pm UTC](https://discourse.slicer.org/t/freesurfer-output-loading-on-slicer-via-command-line/22055/1 "2022-02-18T17:47:36Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 18, 2022, 6:43pm UTC](https://discourse.slicer.org/t/freesurfer-output-loading-on-slicer-via-command-line/22055/2 "2022-02-18T18:43:09Z")

</div>

You can use the [FreeSurferImporterLogic module’s logic](https://github.com/PerkLab/SlicerFreeSurfer/blob/ecdc500aa8a53f2733c4cb4d5340331286422fc7/FreeSurferImporter/Logic/vtkSlicerFreeSurferImporterLogic.h#L58-L63) in Python scripts to load freesurfer data then process, quantify, export, etc. Something like this can work for data loading:

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

```

---

<div class="post-metadata">

**Author:** ![ysakato](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ysakato/32/14607_2.png) [@ysakato](https://discourse.slicer.org/u/ysakato)\
**Post date:** [March 9, 2022, 6:35am UTC](https://discourse.slicer.org/t/freesurfer-output-loading-on-slicer-via-command-line/22055/3 "2022-03-09T06:35:01Z")

</div>

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’

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 9, 2022, 6:47am UTC](https://discourse.slicer.org/t/freesurfer-output-loading-on-slicer-via-command-line/22055/4 "2022-03-09T06:47:30Z")

</div>

`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?

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [March 9, 2022, 3:43pm UTC](https://discourse.slicer.org/t/freesurfer-output-loading-on-slicer-via-command-line/22055/5 "2022-03-09T15:43:27Z")

</div>

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:

```auto
bool LoadFreeSurferScalarOverlay(std::string filePath, vtkCollection* modelNodes);
bool LoadFreeSurferScalarOverlay(std::string filePath, vtkMRMLModelNode* modelNode);

```

---

<div class="post-metadata">

**Author:** ![ysakato](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ysakato/32/14607_2.png) [@ysakato](https://discourse.slicer.org/u/ysakato)\
**Post date:** [March 11, 2022, 4:36am UTC](https://discourse.slicer.org/t/freesurfer-output-loading-on-slicer-via-command-line/22055/6 "2022-03-11T04:36:51Z")

</div>

Thank you for your kind support!
