[FieldTrip] Error using ft_read_header

Bondarenko, Alina I alina.bondarenko19 at imperial.ac.uk
Tue Jun 23 15:18:28 CEST 2020


Dear Stephen,

Thanks for the quick response!

I have been initially using another function, ft_read_data (which calls on ft_read_header) as part of some code to load and convert .mat files to .csv files - and it was in this code that the bug/error first showed up.



filename = 'my_data.mat';

dat = ft_read_data(filename);

writematrix(dat, 'my_data.csv')


Error using feval

Attempt to execute SCRIPT matlab as a function:
/Applications/MATLAB_R2019b.app/toolbox/matlab/general/matlab.m

Error in ft_read_header (line 2594)
      hdr = feval(headerformat, filename);

Error in ft_read_data (line 214)
  hdr = ft_read_header(filename, 'headerformat', headerformat, 'chanindx',
  chanindx, 'checkmaxfilter', checkmaxfilter);


There are other ways of converting .mat to .csv files, so that's not a huge problem, however, it seems that whenever I use any function that requires/calls on  ft_read_header the same error comes up.  So, I haven't been able to use quite a few Field Trip functions as a result.

I am working with data that has been preprocessed by another lab, so unfortunately I don't have more code than this to show you. However, I get the same error with a different dataset, which I was also previously able to run through these functions without a problem.

Thank you in advance for your time!

Best,
Alina.
________________________________
From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of Stephen Whitmarsh <stephen.whitmarsh at gmail.com>
Sent: 23 June 2020 13:04
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] Error using ft_read_header


This email from stephen.whitmarsh at gmail.com originates from outside Imperial. Do not click on links and attachments unless you recognise the sender. If you trust the sender, add them to your safe senders list<https://spam.ic.ac.uk/SpamConsole/Senders.aspx> to disable email stamping for this address.



Dear Alina,

Not sure there is not something more sinister at play in the code somewhere (I mean a bug or installation error), but I would start by asking why you are using  ft_read_header to load a .mat file?

Are you sure you don't just want to load the matfile with MATLAB's load functions? I.e. header = load('myfilename.mat')? Or, otherwise, read the header of an original EEG/MEG datafile (some EEG/MEG dataformat)?

If not, and for a more informed response, please specify a bit more of the code you use to process/write and then (try to) load the header.

Cheers,
Stephen



Op di 23 jun. 2020 om 13:30 schreef Bondarenko, Alina I <alina.bondarenko19 at imperial.ac.uk<mailto:alina.bondarenko19 at imperial.ac.uk>>:
Hello all,


I'll try to describe the problem I've been having as clearly as I can here:

  *   I'm trying to use a Field Trip function ft_read_header to load some .mat files.

  *   When I try to load up a file using ft_read_header, I get an error message saying that within the ft_read_header script, the function feval is being used incorrectly. Namely, that feval is trying to execute a script called matlab as if it were a function.

Error using feval
Attempt to execute SCRIPT matlab as a function:
/Applications/MATLAB_R2019b.app/toolbox/matlab/general/matlab.m

  *   When I look inside the ft_read_header script, the line (2594) that gives the error looks like this:

feval(headerformat, filename)

Where headerformat is assigned a string 'matlab', which is supposed to represent the file type of the file I'm trying to load. Filename is a string variable I assign, e.g. filename = 'session1.mat'.

Headerformat is assigned the string 'matlab' in line 203 of ft_read_header (found in debugging mode):

headerformat = ft_filetype(filename);


  *   Feval is supposed to "evaluate a function" (I'm not quite sure exactly what this means based on the documentation), but it's first argument is supposed to be a function name, so I guess that a string saying 'matlab' should have always thrown an error, but the thing is that this function used to work just fine for me before. I also haven't edited any of the built in Field Trip scripts, so I'm not sure why this has stopped working.


Here are some things I've tried to fix the problem:


  *
I looked up the 'executing script as function error' and thought that since Matlab would like to execute a function, but is instead executing a script of the same name, then changing the name of the script could stop the problem.

However, when I change the name of the matlab.m script (e.g. to matlab_change.m) I get this error message instead:

Error using feval
Previously accessible file
"/Applications/MATLAB_R2019b.app/toolbox/matlab/general/matlab.m" is now inaccessible.

The only file called matlab.m is a short text file containing some info about what Matlab is and what it can be used for (I used "which matlab -all" to check this). There are no functions called matlab.

  *   In between the time when this function was working fine for me, and when it started showing me this error, I installed several versions of OSL and SPM on my computer. So, I uninstalled all these things.
  *   Uninstalled and reinstalled Field Trip
  *   Uninstalled and reinstalled Matlab
  *   Copy pasted all the functions involved and saved these under different names in different folders. Tried running them - got the same error.

I would greatly appreciate anyone's help on this! This error has been driving me crazy.

All the best,
Alina.


_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200623/7dca17e8/attachment.htm>


More information about the fieldtrip mailing list