multiplotER and Neuromag data

Stephan Moratti moratti at MED.UCM.ES
Wed Feb 24 11:23:29 CET 2010


Hola Gianpaolo,

I had the same problem as you. The probel lies in the ft_prepare_layout.m 
function. It calculates the minimum distance between sensors. As the 
neuromag sensor has different types of sensors, the layout puts the 3 
different sensors at the same place. So calculating the min(d(:)) results in 0 
values. Please find below the modified subfunction sens2lay that is located in 
ft_prepare_layout.m that prevents this error. With that, the topoplots (and 
multiplots) should work out. Maybe this error can be prevented in a more 
elegant way that I did.

Best,

Stephan



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SUBFUNCTION
% convert 3D electrode positions into 2D layout
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function lay = sens2lay(sens, rz, method, style)

fprintf('creating layout for %s system\n', senstype(sens));
% apply rotation
if isempty(rz)
  switch senstype(sens)
    case 
{'ctf151', 'ctf275', 'bti148', 'bti248', 'ctf151_planar', 'ctf275_planar', 'bti148_pla
nar', 'bti248_planar'}
      rz = 90;
    case {'neuromag122', 'neuromag306'}
      rz = 0;
    case 'electrode'
      rz = 90;
    otherwise
      rz = 0;
  end
end
sens.pnt = warp_apply(rotate([0 0 rz]), sens.pnt, 'homogenous');

% use helper function for 3D layout
[pnt, label] = channelposition(sens);

if strcmpi(style, '3d')
  lay.pos   = pnt;
  lay.label = label;
else
  if strcmp(senstype(sens),'neuromag306') %this is to prevent distance of 0
      prj = elproj(pnt(1:102,:), method);
      n=3;
  else
    prj = elproj(pnt, method);
    n=0;
  end
  d = dist(prj');
  d(find(eye(size(d)))) = inf;
  mindist = min(d(:));
  
  
  % this is to fix the planar layouts, which cannot be plotted anyway
  if n>1  %this is to prevent confusion when lab happens to be a row array
    prj = repmat(prj, n, 1);
  end
  
  X = prj(:,1);
  Y = prj(:,2);
  Width  = ones(size(X)) * mindist * 0.8;
  Height = ones(size(X)) * mindist * 0.6;
  lay.pos    = [X Y];
  lay.width  = Width;
  lay.height = Height;
  lay.label  = label;
end

----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/neuroimaging/fieldtrip.



More information about the fieldtrip mailing list