Error using ==> nargout

Robert Oostenveld r.oostenveld at FCDONDERS.RU.NL
Tue Oct 11 22:18:04 CEST 2005

Hi Kambiz,

The subfunction "trialfun_ctf_epoched" is automatically selected if
you specify a particular dataformat (CTF) in combination with
particular cfg settings in preprocessing. The "trialfun_ctf_epoched"
function is included in recent fieldtrip versions, and can be found
in the private subdirectory. [Gijs, please update to a recent
version]. Since it is not a functino that you should call directly,
it is not included in the fieldtrip main directory.

In general, user defined trialfunctions should return a "trl" matrix,
but also can return a second structure with additional information.
That second return argument is the "event" structure (see
read_fcdc_event for more information). Fieldtrip is using the
standard "nargout" function of Matlab to determine whether the
trialfunction returns one or two output arguments. It seems that
there is an incompatibility with the nargout function on specific
combinations of Matlab with MS Windows. I have heard the problem from
others as well, but have not been able to reproduce the problem
myself since I do not have a Windows computer. Since 4 October I
changed the nargout behaviour, and hope that that fixes the problem
on Windows.

Please download the latest version of fieldtrip from ftp://, that should fix the problem.

best regards,

On 11-okt-2005, at 21:56, Gijs van Elswijk wrote:

> Hi,
> You have defined a trial function with the name
> "trialfun_ctf_epoched" in the cfg structure. Supposedly, this
> function (.m file) does not exist (or is not found somewhere in the
> matlab path). Therefore, during preprocessing "nargout" is called
> with an non-existing .m file as parameter and returns with an error.
> I've had the same problem recently. The solution would normally be
> to set cfg.trialfun to an existing trial function or to create a
> trial function with name "trialfun_ctf_epoched". However, in the
> sample dataset of the tutorial no trial function was (is?)
> included, and I think it is a bit hard to make one if you don't
> know how trials are marked in the raw data.
> Jan-Mathijs has sent me an .m file with a trialfunction that worked
> for this tutorial. Jan-Mathijs, is it allright if I forward that
> file to Kambiz?
> Gijs
>     -----Original Message-----
>     From: FieldTrip discussion list on behalf of Kambiz Tavabi
>     Sent: Tue 10/11/2005 4:26 PM
>     Cc:
>     Subject: [FIELDTRIP] Error using ==> nargout
>     The errors below result from running the excerpt code provided
> in the
>     FIELDTRIP tutorial/example MATLAB script for Time Frequency
> analysis.  My
>     MATLAB work directory is set to $:\Matlab\work\FIELDTRIP which
> contains the
>     folder 'Subject01.ds' and associated head shape/MRI files.
>     Any suggestions on what I am doing wrong?
>     >> cfg = [];
>     cfg.dataset = 'Subject01.ds';
> = {'MEG' 'STIM'};
>     cfg.trialdef.excludeConditions = {'BAD'};
>     cfg.trialdef.includeTrigger = 3;
>     cfg.detrend = 'yes';
>     dataFIC = preprocessing(cfg);
>     evaluating trialfunction 'trialfun_ctf_epoched'
>     ??? Error using ==> nargout
>     Not a valid M-file.
>     Error in ==> definetrial at 141
>         num = nargout(cfg.trialfun);
>     Error in ==> preprocessing at 263
>     [cfg] = definetrial(cfg);
>     ============================================
>     Kambiz Tavabi, Dipl. Psych., MS.
>     Institute for Biomagnetism and Biosignalanalysis
>     Muenster University Hospital
>     Malmedyweg 15
>     D-48149 Muenster
>     Germany
>     phone:   +49-(0)251-83-56884
>     fax:     +49-(0)251-83-56874
>     e-Mail: Kambiz.Tavabi at
>     ============================================

Robert Oostenveld, PhD
F.C. Donders Centre for Cognitive Neuroimaging
Radboud University Nijmegen
phone: +31-24-3619695

More information about the fieldtrip mailing list