[FieldTrip] ft_prepare_layout rotate axis does not work in the new Fieldtrip release

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Wed Mar 29 18:11:04 CEST 2023


Hi Elisa,

Can you point us to the ‘rotation problem’ in the figure you attached? I don’t see it. Both figures have the electrodes placed in the same orientation (in the figure), relative to the ‘head’. Given that the distribution left/right is more or less symmetric, it seems to me that everything went according to plan. The onlly difference I see is how the positions are scaled with respect to the size of the circle. So, I don’t understand what you think is wrong. Also, you did not provide us with any additional details with respect to the cfg used to call ft_prepare_layout, nor what type of data you are using etc.

Best wishes,
Jan-Mathijs




On 29 Mar 2023, at 17:10, Elisa Tatti <elisatatti at msn.com<mailto:elisatatti at msn.com>> wrote:



Dear Fieldtrip community,
I am writing to ask for help with creating the channel layout using the function ft_prepare_layout. I have two questions:


  1.  In the past, I successfully used the option cfg.rotate to rotate the axis of 90 degrees due to the differences in orientation between eeglab and fieldtrip. In the latest Fieldtrip (20230118) version, the option cfg.rotate does not work anymore. It does not give any error and it creates the layout but it does not rotate the axis. I ran the function with cfg.rotate both as default [] (which should automatically rotate the axis) and with different rotations (90,180). I checked the output and it seems it is not rotating the axis at all.
I compared it with a previous version (20200607) (where it works perfectly) and noticed that parts of the code have been changed. Specifically, in ft_prepare_layout in Fieldtrip 20200607 the section that rotates the axis using ft_warp_apply (lines 1291-1307, see below) in the subfunction sens2lay has been changed in Fieldtrip 20230118. I can see the function ft_warp_apply for the subfunction opto2lay but it is not there for sens2lay anymore. I am unsure if that is actually what it was meant to be done and it is okay like this but may this be the reason why it does not rotate anymore?

Old Fieldtrip function:

% apply rotation, but only if viewpoint is not used specifically
if isempty(viewpoint)
  if isempty(rotatez)
    switch ft_senstype(sens)
      case {'ctf151', 'ctf275', 'bti148', 'bti248', 'ctf151_planar', 'ctf275_planar', 'bti148_planar', 'bti248_planar', 'yokogawa160', 'yokogawa160_planar', 'yokogawa64', 'yokogawa64_planar', 'yokogawa440', 'yokogawa440_planar', 'magnetometer', 'meg'}
        rotatez = 90;
      case {'neuromag122', 'neuromag306'}
        rotatez = 0;
      case 'electrode'
        rotatez = 90;
      otherwise
        rotatez = 0;
    end
  end
  sens.chanpos = ft_warp_apply(rotate([0 0 rotatez]), sens.chanpos, 'homogenous');
end

Fieldtrip 20230118

% apply rotation, but only if viewpoint is not used specifically
if isempty(viewpoint) && isempty(rotatez)
  if isfield(sens, 'coordsys')
    % the x-axis to the right of the screen and the y-axis is to the top of the screen
    % the nose is usually plotted toward the top of the screen
    sens = ft_convert_coordsys(sens, 'ras', 0);
  elseif isfield(sens, 'type') && startsWith(sens.type, 'ctf')
    sens.coordsys = 'ctf';
    sens = ft_convert_coordsys(sens, 'ras', 0);
  elseif isfield(sens, 'type') && startsWith(sens.type, 'bti')
    sens.coordsys = 'bti';
    sens = ft_convert_coordsys(sens, 'ras', 0);
  elseif isfield(sens, 'type') && startsWith(sens.type, '4d')
    sens.coordsys = '4d';
    sens = ft_convert_coordsys(sens, 'ras', 0);
  elseif isfield(sens, 'type') && startsWith(sens.type, 'yokogawa')
    sens.coordsys = 'yokogawa';
    sens = ft_convert_coordsys(sens, 'ras', 0);
  elseif isfield(sens, 'type') && startsWith(sens.type, 'neuromag')
    sens.coordsys = 'neuromag';
    sens = ft_convert_coordsys(sens, 'ras', 0);
  elseif isfield(sens, 'type') && startsWith(sens.type, 'itab')
    sens.coordsys = 'itab';
    sens = ft_convert_coordsys(sens, 'ras', 0);
  else
    ft_warning('use cfg.rotate to specify the correct rotation of the sensors');
  end
end

If anyone has information about it, please share it with the community. Thank you!

  1.  Using the old Fieldtrip version, I created the layout using ft_prepare_layout and 90 degrees rotation to have the frontal channels oriented toward the nose. However, when I plot the channels with the function ft_plot_layout, they look too centered in the middle (see the attached image with a comparison between the EEGLAB channel layout and the output of ft_prepare_layout. What can I do to fix them?

Thank you in advance for your help!

Best.

Elisa




Elisa Tatti, Ph.D.

Research Associate
Research Foundation of the City University of New York
CUNY, School of Medicine
160 Convent ave
New York City, NY, 10031

Adjunct Assistant Professor
College of Staten Island,
2800 Victory Blvd, Staten Island, NY 10314

Tel. +1 3472043952

<Screen Shot 2023-03-28 at 3.27.08 PM.png>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230329/9c130757/attachment.htm>


More information about the fieldtrip mailing list