Tess_cortex_white_low file name not saved in brainstormsubject.mat

In your script, sFiles should be a cell-array of strings rather than a string. Just enclose its definition within {}.

Other than this minor detail, I don't think there is any problem with your script.
The code executed from the GUI or the pipeline editor is the same.

I also noticed that from time to time, it was not the correct cortex surface that was selected at the end of the process, but I could never find a way to reproduce it.
Please let me know if you find a procedure to reproduce this incorrect selection (white surface instead of central).