Fieldtrip: ft_timelockstatistics error

Hello everyone,

I am trying to use ft_timelockstatistics to compare the ERP data of two different conditions and this error message appears:

Any solution? Thanks!

Hi Gubei,

It seems like it cannot find a full version of fieldtrip to work with, that is what is checked on that line, did you do the following steps: https://neuroimage.usc.edu/brainstorm/Tutorials/Statistics#FieldTrip_implementation ?

Kind regards,
Steven

You may have a problem in your Matlab path, FieldTrip is not using the correct isfolder function.

What is your version of Matlab?
What is the output when you type which isfolder in the Matlab command window?

Try the following: edit your Matlab path, remove all the folders that are not related with the MATLAB installation, including the Brainstorm and Fieldtrip folders and subfolders (they are not supposed to be added permanently in your path).
Restart Matlab, start brainstorm.m, try again.

Hello Francois,

Thank you for your reply.

I am using Matlab R2016a.
When I type which isfolder in the Matlab command window it says 'isfolder' not found.

I have already deleted all new folders other than the default ones in Matlab but the same error appears again.

Hi Gubei,

The isfolder is introduced in Matlab 2017b, that is why it errors for the 2016 version.
Upgrading your matlab or using the compiled version of brainstorm would help.

Kind regards,
Steven

Hello SBeumer,

Thank you for the suggestion. Could you please tell me what is the compiled version of branstorm?

Hello Gubei,

I will wait for Francois to answer that, maybe he has a better option.

Kind regards,
Steven

There is something wrong in the way you set up FieldTrip.

  • Make sure you are using a recent version of FieldTrip (not older than 2 months)
  • Make sure Brainstorm is up-to-date (not older than one month)
  • Close Matlab, restart it
  • Check the Matlab path: remove everything that is not strictly related to the Matlab installation path. Save the path, restart Matlab. Never add again permanently any toolbox subfolder to your Matlab path.
  • Go to the brainstorm3 folder
  • In your Matlab command window type:
    brainstorm
    
  • In Brainstom, menu File > Edit preferences > Set the FieldTrip path to the most recent version of FieldTrip you have on your computer.
  • In your Matlab command window type:
    bst_ft_init
    [ft_ver, ft_path] = ft_version
    
  • Copy-paste here the full text output you got.

bst_ft_init
[ft_ver, ft_path] = ft_version
BST> FieldTrip install: C:\Program Files\MATLAB\R2016a\toolbox\fieldtrip-20200423\fieldtrip-20200423
Warning: removing "C:\Program
Files\MATLAB\R2016a\toolbox\fieldtrip-20200423\fieldtrip-20200423\compat\matlablt2016b" from your path,
see Redirecting…
In contains (line 29)
In ft_hastoolbox>is_subdir_in_fieldtrip_path (line 634)
In ft_hastoolbox (line 437)
In ft_defaults (line 249)
In bst_ft_init (line 93)

ans =

 1

Warning: removing "C:\Program
Files\MATLAB\R2016a\toolbox\fieldtrip-20200423\fieldtrip-20200423\compat\matlablt2017b" from your path,
see Redirecting…

In isfolder (line 28)
In ft_version (line 64)
Error using feval
Undefined function 'isfolder' for input arguments of type 'char'.

Error in isfolder (line 34)
[varargout{1:nargout}] = feval(mfilename, varargin{:});

Error in ft_version (line 64)
issvn = isfolder(fullfile(ftpath, '.svn'));

Here are what I've got. I guess I should follow the instruction to remove the corresponding folder from the path?

There is something wrong with FieldTrip or with your Matlab path: you may have another "isfolder" function somewhere.
Have you cleaned your Matlab path?
Do you have multiple versions of FieldTrip in the path?

In fieldtrip-20200423/compat/matlablt2017b/isfolder.m, at line 25, it removes the folder fieldtrip-20200423/compat/matlablt2017b from the path. While with Matlab 2016a, this folder should actually remain in the path...
Put a breakpoint at line 25, and see why: try to understand what part of this test is not doing what you need.

Follow the instructions on this page:
http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path/

If you have issues you don't know how to debug, you should reach out the FieldTrip team:
http://www.fieldtriptoolbox.org/development/issues/

Atlernative: Use the compiled version of Brainstorm:
https://neuroimage.usc.edu/brainstorm/Installation
Follow the sections "without Matlab"

Thank you very much for your help! Now it works!

Thank u soooo much!!!!