Back to the main page.

Bug 3019 - error using fieldtrip functions in a gui.

Reported 2015-11-30 15:48:00 +0100
Modified 2019-08-10 12:41:37 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 enhancement
Assigned to:
Depends on:
See also:

medina - 2015-11-30 15:48:50 +0100

Hi, I'm an engineer and i'm working at the MEG center in Marseille. I'm trying to call fieltrip functions in a matlab gui. I have the following error while calling any functions of fieldtrip (ft_preprossing, ft_volumereslice, ft_sourceplot, etc...), only using a gui : Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer. If it could be useful, the problem is partially solved when i comment "ft_postamble hisory ..." in ft_preprocesing for example. Thanks a lot for your help, Sincerely, Samuel Medina

Robert Oostenveld - 2015-11-30 16:27:27 +0100

Hi Samuel, I don't think the GUI has anything to do with it. Are you using the latest version of FieldTrip? What matlab version are you using on what kind of computer? Using the smallest examples I can think of data = ft_freqsimulation([]) data2 = ft_preprocessing([], data) or cfg = [] cfg.dataset = 'eog_ecg_test.fif' data3 = ft_preprocessing(cfg) I cannot reproduce any errors. So there is something specific to the way you are calling the function. Could you - just prior to calling ft_preprocessing in your wrapper code - save the input arguments to the ft_preprocessing function to a mat file and send that to us (using something like or Robert PS if the data is not anonymised and cannot be shared with everyone, please don't paste the download link in this bug report, but send it to me on my regular email address.

medina - 2015-12-01 14:17:14 +0100

Created attachment 758 Script example

medina - 2015-12-01 14:17:31 +0100

Hi, Thanks for your quick answer. You will find below the answer of a person who was confronted to the same problem. I'm using guide in matlab2015 with the version 20151129 of fieltrip. The problem seems to be due to the fact that some functions of fieldtrip works with the callback function name ( @(hObject,eventdata)A('B_Callback',hObject,eventdata,guidata(hObject)) ), that is too long and not supported. Over 63 characters the problem happens if i'm not wrong. Please find attached an example of my script. Is it possible to adapt the fieldtrip script to make it works? Thanks a lot, Samuel %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Hi Samuel. It has been a while since I have used Matlab or fieldtrip. If I remember correctly the error you mention has to do with fieldtrip generating names for some cell arrays that are based on the name of the functions calling ft functions. Ni matlab if you make a GUI using the gui creator then the callback functions generated for the different gui elements will have these huge names (you can check them out in the properties of the elements). These names are too long to then be used for names of cell arrays but this is what ft tries to do and you get this error. The solution is to use smaller names for the callback functions. I am not sure if the automatic gui making thing allows to do this (I do not remember), but if it does you will be able to change the names in the properties of the element (e.g. the button or whatever it is you are calling ft with). In the properties list you can see the different callback functions allowed by the element and you can (maybe) rename them. If this is not possible then you have to make guis yourself (not using the gui maker in matlab) by writing scripts that fully define the gui you want. I have found for a lot of other reasons this is much better. I hope this helps George ________________________________________ From: MEDINA VILLALON Samuel <> Sent: Monday, November 30, 2015 2:19 PM To: Dimitriadis, G. (George) Subject: error using fieldtrip functions in a gui. Hi, I saw you've reported an error while calling fieltrip functions in a gui. I have the same problem with several versions of fieldtrip and Matlab 2015. Please can you tell me if you have you solved your problem? Thanks. Sincerely,

Jan-Mathijs Schoffelen - 2016-05-05 09:55:27 +0200

It looks as if this either has been resolved, there is no interest in pursuing this further, or it's not a problem that is strictly related to Fieldtrip. Either way, Samuel, I'd like to remove clutter from the open bugs list. Can we close this one?

medina - 2016-05-23 16:15:32 +0200

Hi, To summarize, it seems that when I want to create a GUI using GUIDE to call FT functions, the function "ft_postamble" (I couldn't figure out properly what that function does...) uses at some point the callback functions name. But this latter one is too long which leads to the error mentioned in previous comment. This problem doesn't occur when I am not using fieldtrip functions. Currently, I have found a trick to avoid it. In the guide, for the callback of my button, I manually modify the length of the string callback functions name and delete " hObject,eventdata,... " : For instance @(hObject,eventdata)example_fieltripGUI_pb('B_Callback') instead of : @(hObject,eventdata)example_fieltripGUI_pb('Push_Button_original_Callback',hObject,eventdata,guidata(hObject)) I illustrate the error with the attached example. Is there a way to modify the ft_postamble function (or another function) to avoid the manual modification? Thanks for your help, Samuel Medina

medina - 2016-05-23 16:16:40 +0200

Created attachment 792 example illustrating the problem

Jan-Mathijs Schoffelen - 2017-01-17 15:27:35 +0100

It's unclear what the status of this one is, but given the fact that we're severely underpowered in terms of people contributing to fixing issues on bugzilla, Robert and JM have decided to close the low-priority bugs for now. This in order to keep the number of open bugs manageable. Feel free to reopen it, if you are willing to move this one forward towards a more proper resolution.

Robert Oostenveld - 2019-08-10 12:35:25 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue on

Robert Oostenveld - 2019-08-10 12:41:37 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue on