<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Dear Stephen,<br>
<br>
Thanks for the quick response! <br>
<br>
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.<br>
<br>
<br>
<p style="margin: 0px; font: 10px Courier; color: rgb(178, 69, 243); margin: 0px">
<span style="color: rgb(0, 0, 0); font-size: 11pt;">filename = </span><span style="font-size: 11pt;">'my_data.mat'</span><span style="color: rgb(0, 0, 0); font-size: 11pt;">;</span></p>
<p style="margin: 0px; font: 10px Courier; margin: 0px"><span style="font-size: 11pt;">dat = ft_read_data(filename);</span></p>
<p style="margin: 0px; font: 10px Courier; color: rgb(178, 69, 243); margin: 0px">
<span style="color: rgb(0, 0, 0); font-size: 11pt;">writematrix(dat, </span><span style="font-size: 11pt;">'my_data.csv'</span><span style="color: rgb(0, 0, 0); font-size: 11pt;">)</span></p>
<p style="margin: 0px; font: 10px Courier; color: rgb(178, 69, 243); margin: 0px">
<span style="color: rgb(0, 0, 0); font-size: 11pt;"><br>
</span></p>
<p style="margin: 0px; font: 10px Courier; color: rgb(178, 69, 243); margin: 0px">
<span style="color: rgb(0, 0, 0); font-size: 11pt;"><span style="color: rgb(200, 38, 19);">Error using feval</span><span><br>
</span></p>
<div><span style="color: rgb(200, 38, 19);">Attempt to execute SCRIPT matlab as a function:</span><br>
</div>
<div><span style="color: rgb(200, 38, 19);">/Applications/MATLAB_R2019b.app/toolbox/matlab/general/matlab.m</span><br>
</div>
<div><br>
</div>
<div><span style="color: rgb(200, 38, 19);">Error in ft_read_header (line 2594)</span><br>
</div>
<div><span style="color: rgb(200, 38, 19);">      hdr = feval(headerformat, filename);</span><br>
</div>
<div><br>
</div>
<div><span style="color: rgb(200, 38, 19);">Error in ft_read_data (line 214)</span><br>
</div>
<div><span style="color: rgb(200, 38, 19);">  hdr = ft_read_header(filename, 'headerformat', headerformat, 'chanindx',</span><br>
</div>
<span style="color: rgb(200, 38, 19);">  chanindx, 'checkmaxfilter', checkmaxfilter);</span><br>
</span>
<p></p>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<br>
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.<br>
<br>
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.<br>
<br>
Thank you in advance for your time!<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Best,<br>
Alina. </div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> fieldtrip <fieldtrip-bounces@science.ru.nl> on behalf of Stephen Whitmarsh <stephen.whitmarsh@gmail.com><br>
<b>Sent:</b> 23 June 2020 13:04<br>
<b>To:</b> FieldTrip discussion list <fieldtrip@science.ru.nl><br>
<b>Subject:</b> Re: [FieldTrip] Error using ft_read_header</font>
<div> </div>
</div>
<div>
<table class="x_MsoNormalTable" cellspacing="0" cellpadding="0" border="1" style="">
<tbody>
<tr style="">
<td style="border-top:#f0f0f0; border-right:#f0f0f0; background:#ffffcc; border-bottom:#f0f0f0; padding-bottom:0cm; padding-top:0cm; padding-left:0cm; border-left:#f0f0f0; padding-right:0cm">
<p class="x_MsoNormal" style="margin:0cm 0cm 0pt"><span style="font-size:12pt; font-family:"Arial",sans-serif"><font size="2">This email from stephen.whitmarsh@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 <a href="https://spam.ic.ac.uk/SpamConsole/Senders.aspx">
safe senders list</a> to disable email stamping for this address. </font></span></p>
</td>
</tr>
</tbody>
</table>
<p> </p>
<div dir="ltr">Dear Alina,
<div><br>
</div>
<div>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 
<i style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">
ft_read_header </i>to load a .mat file?</div>
<div><br>
</div>
<div>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)?</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>Stephen</div>
<div><br>
</div>
<div> </div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">Op di 23 jun. 2020 om 13:30 schreef Bondarenko, Alina I <<a href="mailto:alina.bondarenko19@imperial.ac.uk">alina.bondarenko19@imperial.ac.uk</a>>:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hello all,<br>
<br>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Arial,Helvetica,sans-serif">
<br>
I'll try to describe the problem I've been having as clearly as I can here:</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Arial,Helvetica,sans-serif">
<ul>
<li>I'm trying to use a Field Trip function<span> </span><i>ft_read_header<span> </span></i>to load some .mat files.<br>
<br>
</li><li>When I try to load up a file using<span> </span><i>ft_read_header,</i><span> </span>I get an error message saying that within the<span> </span><i>ft_read_header<span> </span></i>script, the function<span> </span><i>feval</i> is being used incorrectly. Namely,
 that<span> </span><i>feval</i> is trying to execute a script called<span> </span><i>matlab</i> as if it were a function. <br>
<br>
<span style="margin:0px; color:rgb(134,17,6)">Error using feval</span><span style="margin:0px"><br>
</span>
<div style="margin:0px"><span style="margin:0px; color:rgb(134,17,6)">Attempt to execute SCRIPT matlab as a function:</span><br>
</div>
<span style="margin:0px; color:rgb(134,17,6)">/Applications/MATLAB_R2019b.app/toolbox/matlab/general/matlab.m</span><br>
<br>
</li><li>When I look inside the<span> </span><i>ft_read_header</i><span> </span>script, the line (2594) that gives the error looks like this:<br>
<br>
<span style="margin:0px; color:rgb(23,78,134)">feval(headerformat, filename)</span><br>
<br>
Where<span> </span><i>headerformat</i><span> </span>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'. <br>
<br>
Headerformat is assigned the string 'matlab' in line 203 of<span> </span><i>ft_read_header </i>(found in debugging mode):<br>
<br>
<span style="margin:0px; color:rgb(23,78,134)">headerformat = ft_filetype(filename);</span><br>
<br>
 </li><li>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. <br>
<br>
</li></ul>
</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Arial,Helvetica,sans-serif">
<b><br>
</b></div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Arial,Helvetica,sans-serif">
Here are some things I've tried to fix the problem:</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Arial,Helvetica,sans-serif">
<br>
</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Arial,Helvetica,sans-serif">
<ul style="font-size:16px; background-color:rgb(255,255,255)">
<li><span style="margin:0px">
<div style="margin:0px; font-size:12pt">
<div style="margin:0px"><span style="margin:0px">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.<br>
<br>
However, when I change the name of the matlab.m script (e.g. to matlab_change.m) I get this error message instead:<br>
<br>
</span><span style="margin:0px; color:rgb(134,17,6)">Error using feval</span><span style="margin:0px"><br>
</span><span style="margin:0px; color:rgb(134,17,6)">Previously accessible file</span><br>
<span style="margin:0px; color:rgb(134,17,6)">"/Applications/MATLAB_R2019b.app/toolbox/matlab/general/matlab.m" is now inaccessible.</span><br>
</div>
</div>
<div style="margin:0px; font-size:12pt"><span style="margin:0px"><br>
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 "</span><i>which matlab -all"</i><span style="margin:0px"> to check this). There are no functions called matlab. <br>
<br>
</span></div>
</span></li><li><span style="margin:0px">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.</span></li><li><span style="margin:0px">Uninstalled and reinstalled Field Trip</span></li><li><span style="margin:0px">Uninstalled and reinstalled Matlab</span></li><li><span style="margin:0px">Copy pasted all the functions involved and saved these under different names in different folders. Tried running them - got the same error. <br>
</span></li></ul>
<div><span style="margin:0px"><br>
</span></div>
<div><span style="margin:0px">I would greatly appreciate anyone's help on this! This error has been driving me crazy.<br>
<br>
All the best,<br>
Alina. </span></div>
<br>
</div>
<br>
</div>
</div>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<a href="https://doi.org/10.1371/journal.pcbi.1002202" rel="noreferrer" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
</blockquote>
</div>
</div>
</body>
</html>