Script for Surface Extraction: Missing Background Thresholding Option

Hi everyone,

I’m working on a script for my project where I need to extract several surfaces using different thresholds in Brainstorm. While I can successfully perform this task using the GUI, I encounter some issues when trying to implement it in a script.

To give some context, I’ve included images showing the steps I follow in the GUI (Untitled 1-5). The general process involves importing the MRI, normalizing it using SPM, and then extracting the head surface.

I used the pipeline code generator to create the script (attached as code.jpeg). However, I'm facing one key issue: when trying to generate the head surface through the script, there's no option for background thresholding like there is in the GUI (see Untitled 6 image).

I’d appreciate any advice on how to add the background thresholding to my script. Also, if you notice any other important steps I might have missed when translating the GUI process into the script, please let me know.

Thank you in advance!

Best,
Reza

Untitled1

Untitled2

Untitled3

Untitled4

Untitled5

Untitled6

From the interface, the background was set from the following function

HeadFile, iSurface] = tess_isohead(iSubject, nVertices, erodeFactor, fillFactor, Comment)

Hello Reza,

The process Generate head surface implements the simple approach of using background level which is estimated from the MRI.

To be able to use a custom background level please use the function tess_isosurface.
This function has been updated to accept as argument the background level (gbLevel). Commit: f41b679

You can use this code lines after computing the MNI normalization:

[~, iSubject] = bst_get('Subject', SubjectNames{1});
[HeadFile, iSurface] = tess_isohead(iSubject, nVertices, erodeFactor, fillFactor, bgLevel);