Access a Surface from an Anatomy Node while on Functional Tab

I want to delete a surface in an Anatomy Node while performing functional tasks without having to switch back to the anatomy tab.

I am trying using GetNode() function in panel_protocols() to get the surface file node to be deleted. It works as expected when in anatomy tab but when I switch to functional I guess it loses track of the anatomy node. Any idea how to tackle this ?

Using GetNode() is not recommended in this case. It will not work in case Brainstorm is running headless (server option). A way to do it would be to delete the file, update database, and update node (this only happens if it is not server mode)

% Path to surface, either full or short
surfaceFileName = 'path/to/surface.mat'
% Get info for surface file
[sSubject, iSubject, iSurface] = bst_get('SurfaceFile', surfaceFileName);
% Delete surface
file_delete(file_fullpath(surfaceFileName), 1);
% Update database structure
sSubject.Surface(iSurface) = [];
bst_set('Subject', iSubject, sSubject);
% Update display
panel_protocols('UpdateNode', 'Subject', iSubject);

Awesome! works perfectly. Thanks @Raymundo.Cassani.