I tried to share a .fig file with a colleague who did not have Brainstorm. Because the image-file has callback functions that are specific for BST, it caused errors on a BST-free computer (requiring a matlab restart).
I wasn’t sure if there was a tool to remove the BST-dependent information out of a figure.
I wrote a small script that worked for me:
hFig = gcf;
% Check if right type of file
if ~strcmp( get(hFig,‘Tag’), ‘3DViz’ )
error(‘Selected figure is NOT appropriate’)
else
set(hFig,‘Visible’,‘off’); % Must be invisible to change button functions
set(hFig, …
‘CloseRequestFcn’, ‘closereq’, … % needs to be something
’KeyPressFcn’, [], …
‘KeyReleaseFcn’, [], …
‘WindowButtonDownFcn’, [], …
‘WindowButtonMotionFcn’, [], …
‘WindowButtonUpFcn’, [], …
‘WindowKeyPressFcn’, [], …
‘WindowKeyReleaseFcn’, [], …
‘WindowScrollWheelFcn’, [], …
‘ResizeFcn’, [], …
‘MenuBar’, ‘figure’); % Add in the figure bar; you’ll need it
set(hFig,‘Visible’,‘on’)
end
Yes, this is indeed the way to proceed. Removing all the callbacks is the only way to make the figure independent from Brainstorm.
There was an export menu like that a while ago, but I removed it because saving figures causes all sorts of other compatibility issues…
Have you seen that there are menus to export the figures as images or movies? (right-click on the figure > Snapshots > …)
What is for you the major advantage to save a figure instead of an image?
Do you think it would be worth it to add again a menu “Save as figure” in the snapshot menu?
I think my situation is unique. I have colleagues who want the freedom to manipulate a 3D image and they don’t have Brainstorm. It will likely happen only once or twice for me. I was mostly wondering if there were functions that already exist. I do not think this functionality is needed.
I appreciate the 3D manipulation in BST esp. given matlab’s camera controls are impossible to use. The BST saving functions are more than adequate for me.
I realized that this could be useful for various purposes so I added a more formal support for the export of callback-free figures.
I modified the function out_figure_image.m to support two things:
In the popup menu Snapshots > Save as image, there is now an option “Matlab figure (*.fig)” in the file formats list
The popup menu Snapshots > Open as figure allows to make a “brainstorm-free” copy of a specific figure (you can close Brainstorm, this one would stay open).
Please let me know if you have any comments about the way it is coded now of if you find any bugs in those new features.
But no find happens...
My aim is to modify the figure (the colorbar (size, limits, font...), in particulary) . I tried to use the bst functions for colorbar etc without success...
I don't get the resize of colobar when I change the fontsize...
I'm not sure why you'd expect that changing the text size would resize the objects.
You need to resize yourself the axes object that contains the colorbar surface (change the Position property of the colorbar), and NOT call the ResizeFunction after (which would reset the axes to their initial position).
in the out_figure_image, FileFormat='ARRAY ' and output is a 987x1680x3 uint8 matrix.
The function out_figure_image(hFig, 'Figure') creates a new figure without Brainstorm callbacks only if it has no output variable. If you want to get the figure handles after calling it, use the "gcf".