<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Thanks both,<br>
    <br>
    I do agree it's a bug then, because the units are known to the
    functions and they should not behave like this. The units should be
    converted automatically, or an error should appear telling the user
    to convert units to match. Anyway, a bugs already filed and a work
    around is possible, so all good. By the way, I also found a way
    around my self that might be useful for others to know. There are
    templates in FieldTrip now (great all this pre-made stuff). So I
    just did below, and voila :)<br>
    <br>
    Thanks, <br>
    Ingrid<br>
    <br>
    %%% my work around %%%<br>
    load('standard_sourcemodel3d7point5mm')<br>
    <br>
    % read the single subject anatomical MRI<br>
    mri = ft_read_mri(['D:\FT_DATA\Subject01', filesep,
    'Subject01.mri']);<br>
     <br>
    % create the subject specific grid, using the template grid that has
    just been loaded<br>
    cfg = [];<br>
    cfg.grid.warpmni   = 'yes';<br>
    cfg.grid.template  = sourcemodel;<br>
    cfg.grid.nonlinear = 'yes'; % use non-linear normalization<br>
    cfg.mri            = mri;<br>
    cfg.sourceunits    = 'mm';<br>
    grid               = ft_prepare_sourcemodel(cfg);<br>
     <br>
    <br>
    <br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 4/12/2013 1:14 AM, Erik te Woerd
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAEGmzkiSJnKXVOvaHg7CzWGjMZoCv2Cu+DvBG+Exyx+=F4aPzg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div>Hi Ingrid,<br>
                <br>
              </div>
              I also encountered this problem when following the
              tutorial, but was able to solve it in the way Diego
              suggests it below. While following the tutorial, all
              variables should be returned with corresponding units, but
              in ft_prepare_headmodel this doesn't work.<br>
            </div>
            I reported it already to bugzilla and it's being looked
            after...<br>
            <br>
          </div>
          Best,<br>
          <br>
        </div>
        Erik<br>
        <div>
          <div>
            <div>
              <div>
                <div>
                  <div class="gmail_extra"><br>
                    <br>
                    <div class="gmail_quote">2013/4/12 Diego Lozano
                      Soldevilla <span dir="ltr"><<a
                          moz-do-not-send="true"
                          href="mailto:d.lozanosoldevilla@fcdonders.ru.nl"
                          target="_blank">d.lozanosoldevilla@fcdonders.ru.nl</a>></span><br>
                      <blockquote class="gmail_quote" style="margin:0 0
                        0 .8ex;border-left:1px #ccc
                        solid;padding-left:1ex">
                        <div dir="ltr">Hi Ingrid,
                          <div><br>
                          </div>
                          <div>I had similar problem with MEG and
                             changing the units with ft_convert_units
                            solved the issue:</div>
                          <div><br>
                          </div>
                          <div>vol = ft_convert_units(vol,'cm')<br>
                          </div>
                          <div><br>
                          </div>
                          <div>If not, please file a bug with a piece of
                            data and I'll have a look,</div>
                          <div><br>
                          </div>
                          <div>best,</div>
                          <div><br>
                          </div>
                          <div>Diego</div>
                          <div><br>
                          </div>
                          <div><br>
                          </div>
                        </div>
                        <div class="gmail_extra"><br>
                          <br>
                          <div class="gmail_quote">On 11 April 2013
                            20:30, Ingrid Nieuwenhuis <span dir="ltr"><<a
                                moz-do-not-send="true"
                                href="mailto:inieuwenhuis@berkeley.edu"
                                target="_blank">inieuwenhuis@berkeley.edu</a>></span>
                            wrote:<br>
                            <blockquote class="gmail_quote"
                              style="margin:0 0 0 .8ex;border-left:1px
                              #ccc solid;padding-left:1ex">Hi all,<br>
                              <br>
                              When I follow the code according to the
                              example matlab script "Create MNI-aligned
                              grids in individual head-space" something
                              goes all wrong with the units.<br>
                              <br>
                              I've followed the code (pasted below, from
                              the wiki), but when I make the figure with
                              the template head model and dipole grid,
                              it's wrong (see attached ..._problem.png).
                              The dipole grid is tiny in the bottom of
                              the head model. The black area is the
                              dipole grid, not good.<br>
                              template_grid =<br>
                                    xgrid: [1x41 double]<br>
                                    ygrid: [1x41 double]<br>
                                    zgrid: [1x41 double]<br>
                                      dim: [41 41 41]<br>
                                      pos: [68921x3 double]<br>
                                     unit: 'mm'<br>
                                   inside: [1x68910 double]<br>
                                  outside: [758 759 760 761 799 800 801
                              802 843 884 925]<br>
                                      cfg: [1x1 struct]<br>
                              <br>
                              It's a problem with the units, because the
                              template grid has 'mm' in the unit field,
                              but when I look in the xgrid, ygrid, zgrid
                              and pos fields the numbers are clearly cm
                              not mm. However, when I multiply my
                              xyzgrid and pos field by 10, the grid is
                              not tight (see attached
                              ..._multiplied10.png). It looks like the
                              unit problem messed up the determination
                              of what's inside and outside. As you can
                              see in the template_grid, there are only a
                              few grid point outside, which is clearly
                              not correct (maybe inside/outside was
                              determined on wrong units?).<br>
                              <br>
                              So, it looks like a bug to me, or am I
                              doing something wrong? I'm using the
                              newest FT version.<br>
                              <br>
                              Thanks,<br>
                              Ingrid<br>
                              <br>
                              %%% CODE FROM WIKI %%%<br>
                              template          =
                              ft_read_mri([cur_path_FT 'external',
                              filesep, 'spm8', filesep,'templates',
                              filesep,'T1.nii']);<br>
                              template.coordsys = 'spm'; % so that
                              FieldTrip knows how to interpret the
                              coordinate system<br>
                              <br>
                              % segment the template brain and construct
                              a volume conduction model (i.e. head
                              model): this is needed<br>
                              % for the inside/outside detection of
                              voxels.<br>
                              cfg          = [];<br>
                              template_seg = ft_volumesegment(cfg,
                              template);<br>
                              <br>
                              cfg          = [];<br>
                              cfg.method   = 'singleshell';<br>
                              template_vol = ft_prepare_headmodel(cfg,
                              template_seg);<br>
                              <br>
                              % construct the dipole grid in the
                              template brain coordinates<br>
                              % the source units are in cm<br>
                              % the negative inwardshift means an
                              outward shift of the brain surface for
                              inside/outside detection<br>
                              cfg = [];<br>
                              cfg.grid.xgrid  = -20:1:20;<br>
                              cfg.grid.ygrid  = -20:1:20;<br>
                              cfg.grid.zgrid  = -20:1:20;<br>
                              cfg.grid.unit   = 'cm';<br>
                              cfg.grid.tight  = 'yes';<br>
                              cfg.inwardshift = -1.5;<br>
                              cfg.vol        = template_vol;<br>
                              template_grid  =
                              ft_prepare_sourcemodel(cfg);<br>
                              <br>
                              % make a figure with the template head
                              model and dipole grid<br>
                              figure<br>
                              hold on<br>
                              ft_plot_vol(template_vol);<br>
                              ft_plot_mesh(template_grid);<span><font
                                  color="#888888"><br>
                                  <br>
                                  -- <br>
                                  Ingrid Nieuwenhuis PhD<br>
                                  Postdoctoral Fellow<br>
                                  Sleep and Neuroimaging Laboratory<br>
                                  Department of Psychology<br>
                                  University of California, Berkeley<br>
                                  California 94720-1650<br>
                                  Tolman Hall, room 5305<br>
                                  <br>
                                </font></span><br>
_______________________________________________<br>
                              fieldtrip mailing list<br>
                              <a moz-do-not-send="true"
                                href="mailto:fieldtrip@donders.ru.nl"
                                target="_blank">fieldtrip@donders.ru.nl</a><br>
                              <a moz-do-not-send="true"
                                href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip"
                                target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
                            </blockquote>
                          </div>
                          <br>
                        </div>
                        <br>
                        _______________________________________________<br>
                        fieldtrip mailing list<br>
                        <a moz-do-not-send="true"
                          href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
                        <a moz-do-not-send="true"
                          href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip"
                          target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
                      </blockquote>
                    </div>
                    <br>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
fieldtrip mailing list
<a class="moz-txt-link-abbreviated" href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a>
<a class="moz-txt-link-freetext" href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Ingrid Nieuwenhuis PhD
Postdoctoral Fellow
Sleep and Neuroimaging Laboratory
Department of Psychology
University of California, Berkeley
California 94720-1650
Tolman Hall, room 5305 </pre>
  </body>
</html>