<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle"></style><style></style><style></style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Helen,
<div>I ran your code and it seemed to work with the mri and headmodel I have. I looked back at the picture you sent originally. It looks like the electrodes were aligned (before alignment, the tip of the head is facing upwards, after alignment with the mri
 provided by the wiki it points to the right), but the headmodel is not plotted correctly. The headmodel needs to be driven from mri. You can double check the headmodel, which is <span style="font-family: 'Times New Roman'; font-size: 16px;">standard_bem in
 your code.</span></div>
<div><font face="Times New Roman" size="3">-jia<br>
</font>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div id="divRpF123106" style="direction: ltr;"><font face="Tahoma" size="2" color="#000000"><b>From:</b> fieldtrip-bounces@science.ru.nl [fieldtrip-bounces@science.ru.nl] on behalf of Helen Wieffering [helen.wieffering@gmail.com]<br>
<b>Sent:</b> Wednesday, September 16, 2015 10:00 AM<br>
<b>To:</b> FieldTrip discussion list<br>
<b>Subject:</b> Re: [FieldTrip] Aligning electrodes to template head model<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>Hi Jia,<br>
</div>
Thanks so much for getting back to me. If you have a free moment, would you mind looking over my code? I have tried the tutorial steps many times, even having changed the label of the GSN fiducials to 'Nz', 'LPA', 'RPA',  but seem to keep getting the same incorrect
 results.<br>
<br>
% ALIGN ELECTRODES TO STANDARD_BEM<br>
<br>
% read electrode coordinates<br>
elec = ft_read_sens('GSN-HydroCel-129.sfp');<br>
<br>
% convert units to mm to match units of headmodel<br>
elec = ft_convert_units(elec, 'mm');<br>
<br>
% change label of fiducials<br>
elec.label{1} = 'Nz';<br>
elec.label{2} = 'LPA'<br>
elec.label{3} = 'RPA';<br>
<br>
% create fiducial structure<br>
% draw fiducial coordinates from mri<br>
nas = standard_mri.hdr.fiducial.mri.nas;<br>
lpa = standard_mri.hdr.fiducial.mri.lpa;<br>
rpa = standard_mri.hdr.fiducial.mri.rpa;<br>
 <br>
transm = standard_mri.transform;<br>
 <br>
nas = ft_warp_apply(transm, nas, 'homogenous');<br>
lpa = ft_warp_apply(transm, lpa, 'homogenous');<br>
rpa = ft_warp_apply(transm, rpa, 'homogenous');<br>
<br>
% create a structure similar to a template set of electrodes<br>
fid.chanpos = [nas; lpa; rpa]; % mni-coordinates of fiducials<br>
fid.label = {'Nz','LPA','RPA'}; % same labels as in elec <br>
fid.unit = 'mm'; % same units as mri<br>
 <br>
% alignment<br>
cfg = [];<br>
cfg.method = 'fiducial';            <br>
cfg.template = fid; % see above<br>
cfg.elec = elec;<br>
cfg.fiducial = {'Nz', 'LPA', 'RPA'}; % labels of fiducials in fid and in elec<br>
elec_aligned = ft_electroderealign(cfg);<br>
<br>
% plot to check<br>
figure;<br>
ft_plot_mesh(standard_bem.bnd(1), 'edgecolor','none','facealpha',0.8,'facecolor',[0.6 0.6 0.8]);
<br>
hold on;<br>
ft_plot_sens(elec_aligned,'style', 'sk');<br>
<br>
</div>
For reference, the coordinates I get in the structure fid are the following:<br>
fid = <br>
<br>
    chanpos: [3x3 double]<br>
      label: {'Nz'  'LPA'  'RPA'}<br>
       unit: 'mm'<br>
<br>
fid.chanpos<br>
<br>
ans =<br>
<br>
    35   -36     0<br>
   118   -35     0<br>
   -82   -35     0<br>
<br>
<br>
</div>
If those are different from yours, would you let me know? I'm trying to find out at which step I went wrong.
<br>
</div>
Again, thank you very much!<br>
<br>
</div>
Best,<br>
</div>
Helen<br>
<div>
<div>
<div>
<div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Sep 14, 2015 at 11:00 PM, Wu, Jia <span dir="ltr">
<<a href="mailto:jia.wu@yale.edu" target="_blank">jia.wu@yale.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Helen,
<div><br>
<div>What a coincident. I'm also working on source analysis on EEG data using GSN HydroCel 128. I had a post a couple weeks ago about later steps. But I did get the alignment to work. The picture you posted looked like the status before the alignment. So i
 suspect that alignment did not happen. </div>
<div><br>
</div>
<div>I'm not sure whether you have noticed it, but the fiducial positions in elec location file were called '<font size="2">FidNz', 'FidT9', 'FidT10', instead of <span style="text-align:justify; white-space:pre-wrap; background-color:rgb(247,249,250)">'Nz','LPA','RPA'
 as in the tutorial. So they need to be changed. Then the alignment should work.</span></font></div>
<div><br>
</div>
<div style="text-align:justify"><font size="2"><span style="white-space:pre-wrap; background-color:rgb(247,249,250)">best,</span></font></div>
<div style="text-align:justify"><font size="2"><span style="white-space:pre-wrap; background-color:rgb(247,249,250)">-jia</span></font></div>
<div><br>
<div style="font-family:Times New Roman; color:#000000; font-size:16px">
<hr>
<div style="direction:ltr"><font face="Tahoma" color="#000000" size="2"><b>From:</b>
<a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">fieldtrip-bounces@science.ru.nl</a> [<a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">fieldtrip-bounces@science.ru.nl</a>] on behalf of Helen Wieffering [<a href="mailto:helen.wieffering@gmail.com" target="_blank">helen.wieffering@gmail.com</a>]<br>
<b>Sent:</b> Monday, September 14, 2015 4:46 PM<br>
<b>To:</b> FieldTrip discussion list<br>
<b>Subject:</b> [FieldTrip] Aligning electrodes to template head model<br>
</font><br>
</div>
<div>
<div class="h5">
<div></div>
<div>
<div dir="ltr">
<div>
<div>
<div>Hello all,<br>
<br>
</div>
I have a quick question on aligning electrodes to the standard_bem headmodel, which I downloaded from the FT server.
<br>
<br>
</div>
<div>Namely, are the standard_mri and the standard_bem in the same coordinate system? I assumed this would be so, since one was developed from the other. But when I try to align my electrodes to the standard_bem volume using fiducial positions from the standard_mri,
 I get very strange results: (image below and attached)<br>
<br>
<img alt="Inline image 1" src="cid:ii_14fcd98ad69b9786" style="margin-right:0px" height="251" width="334"> <br>
<br>
I'm using a GSN HydroCel 128 Cap, and my elec structure contains the fiducial positions relative to the electrodes.
<br>
I've been following the tutorial at <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.fieldtriptoolbox.org_tutorial_headmodel-5Feeg&d=AwMFaQ&c=-dg2m7zWuuDZ0MUcV7Sdqw&r=9ehCplyXHP0-m9ayYv1FOg&m=wNRiA8CLR4Y1ZrEaTkTaIoVaUczL5TYuWIx6FyQDphg&s=LjU77qpw8I7LnSHIEQrNIB0R0YLrutfAEtjjOMjBys0&e=" target="_blank">
http://www.fieldtriptoolbox.org/tutorial/headmodel_eeg</a> and would like to follow the steps under 'Automatic Alignment', but as I said: pulling the fiducial positions from the standard_mri seems to not work with the tutorial steps.<br>
</div>
<br>
</div>
Any help is appreciated - thanks in advance!<br>
<div>
<div><br>
</div>
<div>Helen Wieffering<br>
</div>
<div>Bowdoin College<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.science.ru.nl_mailman_listinfo_fieldtrip&d=AwMFaQ&c=-dg2m7zWuuDZ0MUcV7Sdqw&r=9ehCplyXHP0-m9ayYv1FOg&m=kW18ZarjEMl0kcSTFdA9daM4KYcFZdGymg7wgboAsmc&s=9wDX5VD5t6xGdP84l_wit7DYMhK57vFlE5v1OkxjFgA&e=" rel="noreferrer" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>