[FieldTrip] Problems with ft_electroderealign

Amna Hyder hyder.amna at gmail.com
Fri Nov 29 07:55:36 CET 2019


Hi,
I am trying to get my electrodes to align to the headmodel I am using
(obtained from the sample data on the Fieldtrip website). However, I always
get errors in ft_electroderealign when I try to do this. I have tried this
in multiple different ways and although I think I am using all the
parameters right for ft_electroderealign, I get errors that dont make
sense. For example: Error in channelposition (line 348)
n = size(lab,2);

Any help would be appreciated!


% fit electrode coordinates to an individual MRI according to the same

% fiducials (nasion, left & right preauricular points) in both systems

load('/Users/amnahyder/Downloads/vol.mat')

mri = ft_read_mri('/Users/amnahyder/Research/MATLAB/Subject01.mri')

elec = ft_read_sens(
'/Users/amnahyder/Research/MATLAB/fieldtrip-20191028/template/electrode/GSN-HydroCel-256.sfp'
)

% ensure that the electrode coordinates are in mm

elec = ft_convert_units(elec,'mm'); % should be the same unit as MRI

elec.label{1,1}='nasion';

elec.label{2,1}='lpa';

elec.label{3,1}='rpa';

Nas = elec.chanpos(strcmp(elec.label, 'nasion'),:);

Lpa = elec.chanpos(strcmp(elec.label, 'lpa'),:);

Rpa = elec.chanpos(strcmp(elec.label, 'rpa'),:);



mri.nasion = [90 61 105]

mri.lpa = [30 148 151]

mri.rpa = [143 148 151]





vox_Nas = mri.nasion;  % fiducials saved in mri structure

vox_Lpa = mri.lpa;

vox_Rpa = mri.rpa;



vox2head = mri.transform; % transformation matrix of individual MRI



head_Nas          = ft_warp_apply(vox2head, vox_Nas, 'homogenous'); % nasion

head_Lpa          = ft_warp_apply(vox2head, vox_Lpa, 'homogenous'); % Left
preauricular

head_Rpa          = ft_warp_apply(vox2head, vox_Rpa, 'homogenous'); % Right
preauricular



cfg = [];

cfg.method   = 'fiducial';

cfg.elec     = elec;

cfg.warp = 'rigidbody';

cfg.target.pos(1,:) = head_Nas    % location of the nose

cfg.target.pos(2,:) = head_Lpa     % location of the left ear

cfg.target.pos(3,:) = head_Rpa     % location of the right ear

cfg.target.label    = {'nasion', 'lpa', 'rpa'}



cfg.fiducial = {'nasion', 'lpa', 'rpa'};

elec_new = ft_electroderealign(cfg);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20191128/fa2e661e/attachment.html>


More information about the fieldtrip mailing list