<div dir="ltr"><div><div>Dear Eelke,<br><br>Thanks for your comment--a relevant suggestion. However, the fieldnames() command is present in my version of MATLAB when I type "help fieldnames". Therefore, I suspect my problem arises not because the function is unavailable, but because the input to the function is incorrect.<br><br>The documentation states that the input to fieldnames() should be a structure.<br>However, if data.avg should be a structure, this seems to conflict with other fieldtrip data types involving data.avg. <br><br>I suspect that I should not input the source matrix to the data.avg field. However, I am unsure into which field it should go... Is there anyone who could help me?<br><br>Best,<br>Emma<br><br><br><div><div><pre>On 31 October 2014 13:29, Eelke Spaak <eelke.spaak at <a href="http://donders.ru.nl">donders.ru.nl</a>> wrote:<br>> Dear Emma,

> I've not read your full post, but can say this about the latter part:
> fieldnames() should be a builtin MATLAB command. Most likely your
> version of MATLAB is too old; could you try using a more recent
> version? Typically we try to support versions up to 5 years old for
> use with FieldTrip.

> Hope that helps,
> Best,
> Eelke

On 31 October 2014 13:19, Emma Holmes <<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip">eh776 at york.ac.uk</a>> wrote:
><i> Dear all,
</i>><i>
</i>><i> I am trying to perform spatio-temporal cluster statistics to the sources of
</i>><i> an EEG dataset, which I localised using the SPM8 toolbox.
</i>><i> For each participant (averaged across trials), I have a .nii image
</i>><i> containing the source reconstruction for each of two conditions at multiple
</i>><i> different time points. Each nifti file contains a matrix of 91 x 109 x 91,
</i>><i> which corresponds to the source estimates at each voxel.
</i>><i> My aim is to identify sources of activity that span large clusters of voxels
</i>><i> and/or time points, similar to what I have done previously with the scalp
</i>><i> data.
</i>><i>
</i>><i> I understand that the function 'ft_sourcestatistics' should be able to
</i>><i> achieve this with the data output from the function 'ft_sourcegrandaverage'.
</i>><i> However, I am having difficulty structuring the data from the nifti files in
</i>><i> a format that can be successfully input to 'ft_sourcegrandaverage'.
</i>><i>
</i>><i> The data that I am trying to input to 'ft_sourcegrandaverage' contains a
</i>><i> cell array of structures--one for each participant.
</i>><i> As far as I understand from the documentation, each structure should contain
</i>><i> a 'pos' field, which specifies the [x y z] co-ordinates for each position in
</i>><i> the matrix (in my case, a matrix of size 91*109*91 x 3).
</i>><i> I have also included a 'time' field, containing a vector of the time points
</i>><i> to which each .nii image corresponds and a 'dim' field containing the vector
</i>><i> [91 109 91].
</i>><i>
</i>><i> Could you please let me know whether or not this is correct and in which
</i>><i> field(s) I should subsequently add the source reconstruction estimates at
</i>><i> each time point.
</i>><i> So far, I have tried including an 'avg' field with the data at each time
</i>><i> point (91 x 109 x 91 x ntps).
</i>><i> However, when I do so, I get the following error:
</i>><i>
</i>><i> ??? Undefined function or method 'fieldnames' for input arguments of type
</i>><i> 'double'.
</i>><i>
</i>><i> Error in ==> parameterselection at 47
</i>><i>     tmp = fieldnames(data.avg);
</i>><i>
</i>><i> Error in ==> ft_checkdata at 578
</i>><i>   param = setdiff(parameterselection('all', data), exclude);
</i>><i>
</i>><i> Error in ==> ft_sourcegrandaverage at 81
</i>><i>   varargin{i} = ft_checkdata(varargin{i}, 'datatype', {'source'},
</i>><i> 'feedback', 'no',
</i>><i>   'inside', 'logical', 'sourcerepresentation', 'new');
</i>><i>
</i>><i> I am using matlab version 7.7.0.471 (R2008b) and fieldtrip-20140415
</i>><i> (although I have also tried other fieldtrip versions).
</i>><i>
</i>><i> Any help would be greatly appreciated.
</i>><i>
</i>><i> Best wishes,
</i>><i> Emma</i></pre></div></div></div></div></div>