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