<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Dear Mick,<br>
<br>
Indeed, ft_freqstatistics does not baseline for you, but the plotting functions do (although just for plotting, it does not change your data - I know you know that, just saying)<br>
<br>
So, yes, you have to baseline correct yourself. Which you did. Somehow it seems it didn't, at least not for freqstatistics. That's why I suggested to plot the data without the baseline correction option. Now, from what you report can we conclude that the data
 is baseline corrected or not?<br>
<br>
>From your code I see something else unexpected: your two data structures of the two conditions seem not be be indexed, your original code in your first mail has variables beginning with GA_, and you also say you make a grand average after baseline correction.
 I vaguely remember it is/was somehow possible to do statistics on grand averages (with keepindividual = 'yes'), but I would definitely advice using datastructures of your individual subjects/conditions - feeding those into freqstatistics, and not using grandaveraged
 data structures. Not sure if you do though. Are you?<br>
<br>
Cheers,<br>
Stephen<br>
<br>
<br>
<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF803844"><font face="Tahoma" color="#000000" size="2"><b>From:</b> fieldtrip-bounces@science.ru.nl [fieldtrip-bounces@science.ru.nl] on behalf of mick.lehmann@uzh.ch [mick.lehmann@uzh.ch]<br>
<b>Sent:</b> 30 July 2015 16:50<br>
<b>To:</b> fieldtrip@science.ru.nl<br>
<b>Subject:</b> Re: [FieldTrip] Baseline Correction using 'relchange' or 'db'<br>
</font><br>
</div>
<div></div>
<div><font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2"><font face="Verdana, Arial, Helvetica, sans-serif">Dear Stephen and Jim,</font>
<div style="font-family:Verdana,Arial,Helvetica,sans-serif"><br>
</div>
<div style="font-family:Verdana,Arial,Helvetica,sans-serif">sorry that I wasn't clear before: Before calculating the grand average, I applied the baseline correction in a separate script:</div>
<div style="font-family:Verdana,Arial,Helvetica,sans-serif"><br>
</div>
<div style="font-family:Verdana,Arial,Helvetica,sans-serif"><br>
</div>
<div style=""><font face="Verdana, Arial, Helvetica, sans-serif">TF_Remembered_db = ft_freqbaseline(cfg, TF_Remembered)</font></div>
<div style=""><font face="Verdana, Arial, Helvetica, sans-serif">    cfg.baseline     = [-1 -.1 ];</font></div>
<div style=""><font face="Verdana, Arial, Helvetica, sans-serif">    cfg.baselinetype = 'db'; </font></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">    cfg.parameter    = 'powspctrm'; </font></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif"><br>
</font></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">I repeated the same procedure for the second variable (TF_NotRemembered) and saved them as '</font><span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:12.8000001907349px">TF_Remembered_db'
 and 'TF_NotRemembered_db' respectively. From then on I used only the - as I thought - baseline corrected variables. However, calculating the statistics on the differences between the two variables was different from plotting the differences. As I figured out,
 the function for plotting (ft_multiplotTFR) includes the following step for baseline correction:</span></div>
<div><span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:12.8000001907349px"><br>
</span></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">% Apply baseline correction:</font></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">if ~strcmp(cfg.baseline, 'no')</font></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">  % keep mask-parameter if it is set</font></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">  if ~isempty(cfg.maskparameter)</font></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">    tempmask = data.(cfg.maskparameter);</font></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">  end</font></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">  data = ft_freqbaseline(cfg, data);</font></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">  % put mask-parameter back if it is set</font></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">  if ~isempty(cfg.maskparameter)</font></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">    data.(cfg.maskparameter) = tempmask;</font></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">  end</font></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">end</font><span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:12.8000001907349px"> </span></div>
<div><span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:12.8000001907349px"><br>
</span></div>
<div><span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:12.8000001907349px">The post stimulus data is either corrected again or for the first time for pre stimulus power. The latter would make sense, since I can't find a similar correction
 step for the statistics (e.g. ft_statistics_montecarlo or </span><font face="Verdana, Arial, Helvetica, sans-serif">ft_freqstatistics) </font><span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:12.8000001907349px">and therefore the have
 to assume that the data is not baseline corrected. This assumption is further supported by the fact that if I don't indicate the following in the plotting script </span><span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:12.8000001907349px">the
 plot is not baseline corrected as well:</span></div>
<div><br style="font-family:'Courier New',Courier,monospace; font-size:medium">
<span style="font-family:'Courier New',Courier,monospace; font-size:medium">cfg.baseline = [-1 -.1];</span><br style="font-family:'Courier New',Courier,monospace; font-size:medium">
<span style="font-family:'Courier New',Courier,monospace; font-size:medium">cfg.baselinetype = 'db';</span><br style="font-family:'Courier New',Courier,monospace; font-size:medium">
<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:12.8000001907349px">I hope very much that this information is sufficient for an external to understand the procedures and the resulting issue.</span></div>
<div><span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:12.8000001907349px"><br>
</span></div>
<div><span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:12.8000001907349px">Best regards,</span></div>
<div><font face="Verdana, Arial, Helvetica, sans-serif">Mick</font></div>
<div><font style="font-family:Verdana,Arial,Helvetica,sans-serif" color="#990099"><br>
</font></div>
<div><font style="font-family:Verdana,Arial,Helvetica,sans-serif" color="#990099">-----fieldtrip-bounces@science.ru.nl schrieb: -----</font>
<div class="iNotesHistory" style="font-family:Verdana,Arial,Helvetica,sans-serif; padding-left:5px">
<div style="padding-right:0px; padding-left:5px; border-left:solid black 2px">An: fieldtrip@science.ru.nl<br>
Von: fieldtrip-request@science.ru.nl<br>
Gesendet von: fieldtrip-bounces@science.ru.nl<br>
Datum: 30.07.2015 12:16<br>
Betreff: fieldtrip Digest, Vol 56, Issue 27<br>
<br>
<div><font face="Courier New,Courier,monospace" size="3">Send fieldtrip mailing list submissions to<br>
fieldtrip@science.ru.nl<br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
or, via email, send a message with subject or body 'help' to<br>
fieldtrip-request@science.ru.nl<br>
<br>
You can reach the person managing the list at<br>
fieldtrip-owner@science.ru.nl<br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of fieldtrip digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. Re: Baseline Correction using 'relchange' or 'db'<br>
      (mick.lehmann@uzh.ch)<br>
   2. Re: Baseline Correction using 'relchange' or 'db'<br>
      (Stephen Whitmarsh)<br>
   3. Re: FW:  align MRI- headmodel- EEG electrodes problem<br>
      (Herring, J.D. (Jim))<br>
   4. Re: Baseline Correction using 'relchange' or 'db'<br>
      (mick.lehmann@uzh.ch)<br>
   5. Re: Baseline Correction using 'relchange' or 'db'<br>
      (Herring, J.D. (Jim))<br>
   6. Re: Baseline Correction using 'relchange' or 'db' (Eelke Spaak)<br>
   7. Re: Creating a New CTF Ds file (Luke Bloy)<br>
   8. Re: Creating a New CTF Ds file (Tom Holroyd)<br>
   9. Re: FW: align MRI- headmodel- EEG electrodes problem<br>
      (Berdakh Abibullaev)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Wed, 29 Jul 2015 12:48:47 +0200<br>
From: mick.lehmann@uzh.ch<br>
To: fieldtrip@science.ru.nl<br>
Subject: Re: [FieldTrip] Baseline Correction using 'relchange' or 'db'<br>
Message-ID:<br>
<OFB07CB436.0F6C069C-ONC1257E91.003B65E3-C1257E91.003B65E6@lotus.uzh.ch><br>
<br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Dear Stephan,<br>
<br>
the whole script with the designmatrix looks as follows. It is a within-subject design with two conditions.?<br>
<br>
load?ga_TFCond1<br>
load?ga_TFCond2<br>
load neighbours<br>
<br>
cfg = [];<br>
cfg.channel ? ? ? ? ?= 'all';<br>
cfg.latency ? ? ? ? ?= [0 2];<br>
cfg.avgovertime ? ? ?= 'yes';<br>
cfg.frequency ? ? ? ?= [5 7];<br>
cfg.avgoverfreq ? ? ?= 'yes';<br>
cfg.method ? ? ? ? ? = 'montecarlo';?<br>
cfg.statistic ? ? ? ?= 'ft_statfun_depsamplesT';<br>
cfg.correctm ? ? ? ? = 'cluster';<br>
cfg.clusteralpha ? ? = 0.05;<br>
cfg.clusterstatistic = 'maxsum';<br>
cfg.minnbchan ? ? ? ?= 2;<br>
cfg.tail ? ? ? ? ? ? = 0;<br>
cfg.clustertail ? ? ?= 0;<br>
cfg.alpha ? ? ? ? ? ?= 0.05;<br>
cfg.numrandomization = 500;<br>
cfg.neighbours ? ? ? = neighbours;<br>
<br>
<br>
subj = 20;<br>
design = zeros(2,2*subj);<br>
for i = 1:subj<br>
? design(1,i) = i;<br>
end<br>
for i = 1:subj<br>
? design(1,subj+i) = i;<br>
end<br>
design(2,1:subj) ? ? ? ?= 1;<br>
design(2,subj+1:2*subj) = 2;<br>
<br>
cfg.design ? = design;<br>
cfg.uvar ? ? = 1;<br>
cfg.ivar ? ? = 2;<br>
<br>
<br>
stat = ft_freqstatistics(cfg, ga_TFCond1, gaTF_Cond2);<br>
<br>
<br>
Thanks a lot for your efforts!<br>
<br>
Kind regards,<br>
Mick<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/6bb07361/attachment-0001.html" target="_blank">http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/6bb07361/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Wed, 29 Jul 2015 11:53:07 +0000<br>
From: Stephen Whitmarsh <stephen.whitmarsh@ki.se><br>
To: FieldTrip discussion list <fieldtrip@science.ru.nl><br>
Subject: Re: [FieldTrip] Baseline Correction using 'relchange' or 'db'<br>
Message-ID:<br>
<C2A579D858882B47926827674B07F5015844ED66@KIMSX02.user.ki.se><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Dear Mick,<br>
<br>
The designmatrix looks fine to me.<br>
I have not idea what might go wrong, but if I were you I would do the following checks:<br>
<br>
1) Calculate the difference of the TFRs by subtracting the two (manually or with ft_math) after you did the baselinecorrection for each - i.e. exactly what you were giving to freqanalysis. Then plot the results using topoplotTFR without any baseline in the
 configuration of topoplotTFR. This should tell you whether the right stuff is going into freqstatistics.<br>
<br>
2) First do the freqanalysis without averaging over frequencies or using any clustering. Then plot the t-values (of every time-frequency point) using ft_topoplotTFR.<br>
<br>
This should give you a good first idea whether the statistics are behaving as you would expect.<br>
<br>
Hope this helps,<br>
Stephen<br>
<br>
________________________________<br>
From: fieldtrip-bounces@science.ru.nl [fieldtrip-bounces@science.ru.nl] on behalf of mick.lehmann@uzh.ch [mick.lehmann@uzh.ch]<br>
Sent: 29 July 2015 12:48<br>
To: fieldtrip@science.ru.nl<br>
Subject: Re: [FieldTrip] Baseline Correction using 'relchange' or 'db'<br>
<br>
Dear Stephan,<br>
<br>
the whole script with the designmatrix looks as follows. It is a within-subject design with two conditions.<br>
<br>
load ga_TFCond1<br>
load ga_TFCond2<br>
load neighbours<br>
<br>
cfg = [];<br>
cfg.channel          = 'all';<br>
cfg.latency          = [0 2];<br>
cfg.avgovertime      = 'yes';<br>
cfg.frequency        = [5 7];<br>
cfg.avgoverfreq      = 'yes';<br>
cfg.method           = 'montecarlo';<br>
cfg.statistic        = 'ft_statfun_depsamplesT';<br>
cfg.correctm         = 'cluster';<br>
cfg.clusteralpha     = 0.05;<br>
cfg.clusterstatistic = 'maxsum';<br>
cfg.minnbchan        = 2;<br>
cfg.tail             = 0;<br>
cfg.clustertail      = 0;<br>
cfg.alpha            = 0.05;<br>
cfg.numrandomization = 500;<br>
cfg.neighbours       = neighbours;<br>
<br>
<br>
subj = 20;<br>
design = zeros(2,2*subj);<br>
for i = 1:subj<br>
  design(1,i) = i;<br>
end<br>
for i = 1:subj<br>
  design(1,subj+i) = i;<br>
end<br>
design(2,1:subj)        = 1;<br>
design(2,subj+1:2*subj) = 2;<br>
<br>
cfg.design   = design;<br>
cfg.uvar     = 1;<br>
cfg.ivar     = 2;<br>
<br>
<br>
stat = ft_freqstatistics(cfg, ga_TFCond1, gaTF_Cond2);<br>
<br>
<br>
Thanks a lot for your efforts!<br>
<br>
Kind regards,<br>
Mick<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/31562bb2/attachment-0001.html" target="_blank">http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/31562bb2/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Wed, 29 Jul 2015 13:27:01 +0000<br>
From: "Herring, J.D. (Jim)" <j.herring@donders.ru.nl><br>
To: FieldTrip discussion list <fieldtrip@science.ru.nl><br>
Subject: Re: [FieldTrip] FW:  align MRI- headmodel- EEG electrodes<br>
problem<br>
Message-ID:<br>
<3D00B7615FB58D46A0B49B9AD67A33EB51370F@exprd01.hosting.ru.nl><br>
Content-Type: text/plain; charset="us-ascii"<br>
<br>
Dear Nadia,<br>
<br>
Looking at your images the registration seems to be quite fine. Having some electrodes in/outside of the head due to the issues JM addressed is not a  problem as electrode positions are projected onto the scalp surface anyway when creating the leadfield.<br>
<br>
Best,<br>
<br>
Jim<br>
<br>
From: fieldtrip-bounces@science.ru.nl [<a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">mailto:fieldtrip-bounces@science.ru.nl</a>] On Behalf Of Konstantina Kalogianni<br>
Sent: woensdag 22 juli 2015 15:53<br>
To: FieldTrip discussion list<br>
Subject: [FieldTrip] FW: align MRI- headmodel- EEG electrodes problem<br>
<br>
Hi Jan-Mathijs,<br>
<br>
You can download my best result from this link: <a href="https://surfdrive.surf.nl/files/public.php?service=files&t=6d591406015bcb7715ffaebd18fd7d03" target="_blank">
https://surfdrive.surf.nl/files/public.php?service=files&t=6d591406015bcb7715ffaebd18fd7d03</a><br>
I don't think is optimal.<br>
Some of the frontal electrodes are placed inside the head and some of the back ones are floating.<br>
<br>
In my case the automatic alignment with the fiducials didn't work well, do you have any suggestions on how to make this in a better way?<br>
<br>
After reading posts on the discussion list, I  defined left ear as what seems the right ear.<br>
But are there some other tricks that I should apply on the fiducials identification  or at the ft_warp_apply?<br>
<br>
I agree that it will never be optimal because of the issues you described.<br>
But I was wondering when is it satisfying in order not to influence my inverse solution.<br>
<br>
One more question,  is there a function that I should I use that will optimize my electrodes locations after doing the alignment?<br>
<br>
Thank you for your help.<br>
<br>
Best,<br>
Nadia<br>
<br>
<br>
<br>
From: fieldtrip-bounces@science.ru.nl<<a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">mailto:fieldtrip-bounces@science.ru.nl</a>> [<a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">mailto:fieldtrip-bounces@science.ru.nl</a>]
 On Behalf Of Schoffelen, J.M. (Jan Mathijs)<br>
Sent: dinsdag 21 juli 2015 20:55<br>
To: FieldTrip discussion list<br>
Subject: Re: [FieldTrip] align MRI- headmodel- EEG electrodes problem<br>
<br>
Hi Nadia,<br>
<br>
>From the code I cannot see any obvious flaws, but it's hard to tell, without some pictorial feedback. It could be that all went well, but that the end result is just the best that can be achieved. Note that there will always be some discrepancy between the
 head surface reconstructed from the anatomical image (image distortion, thresholding issues etc), and the electrode positions (having the cap in between, some slight inacurracy between the recorded fiducial positions, and the positions obtained by clicking
 in the MR-image). Do you have an image of your 'best result'?<br>
<br>
Best,<br>
Jan-Mathijs<br>
<br>
<br>
Jan-Mathijs Schoffelen, MD PhD, Senior researcher<br>
<br>
Max Planck Institute for Psycholinguistics<br>
Donders Centre for Cognitive Neuroimaging<br>
<br>
E-mail: j.schoffelen@donders.ru.nl<<a href="mailto:j.schoffelen@donders.ru.nl" target="_blank">mailto:j.schoffelen@donders.ru.nl</a>><br>
Telephone: +31-24-3614793<br>
<br>
<a href="http://www.hettaligebrein.nl" target="_blank">http://www.hettaligebrein.nl</a><br>
<a href="http://www.fieldtriptoolbox.org" target="_blank">http://www.fieldtriptoolbox.org</a><br>
<br>
<br>
<br>
<br>
<br>
On Jul 21, 2015, at 4:56 PM, Konstantina Kalogianni <K.Kalogianni@tudelft.nl<<a href="mailto:K.Kalogianni@tudelft.nl" target="_blank">mailto:K.Kalogianni@tudelft.nl</a>>> wrote:<br>
<br>
Dear fieldtrippers,<br>
<br>
I am struggling with aligning the individual MRI, the headmodel and electrode positions(EEG) for some days now, without any success.<br>
I would appreciate some help.<br>
<br>
To begin with,  as an input I have the subject specific MRI which was segmented with the use of freesurfer and MNE software.<br>
I load first the MRI ,the triangulated meshes for brain skull and skin, and the electrodes positions of 65-channel EEG.<br>
I am then computing the bem headmodel from the brain skull skin (computed with the use of MNE software)<br>
Afterwards I am aligning the MRI to my headmodel (ft_volumerealign) and then I identify the fiducials with the interactive mode (ft_volumerealign).<br>
I do the transformation of the fiducial points  with ft_warp_apply to the coordinates specified at the alignment.<br>
Then I call the  ft_electroderealign to align my electrodes to the mri's fiducial points.<br>
And then I realign  my electrodes manually.<br>
<br>
The problem is that no matter how much rotation translation scaling I do, it's IMPOSSIBLE TO FIT THE ELECTRODES TO THE HEADMODEL!<br>
I tried the volume_realign with ctf coordinates as well and I tried the ft_electroderalign with the interactive mode only(without matching the fiducials), it doesn't work.<br>
<br>
Below you can find the code that I used.<br>
Any ideas on this issue would be of great help!<br>
<br>
<br>
%% READ<br>
% read mri<br>
mri=ft_read_mri([freesurferDir 'mri\orig.mgz']);<br>
mri.coordsys='neuromag';<br>
<br>
% read surfaces<br>
<br>
brain=ft_read_headshape([freesurferDir 'bem\brain.surf\Pilot08_brain_surface']);<br>
<br>
skull=ft_read_headshape([freesurferDir 'bem\brain.surf\Pilot08_inner_skull_surface' ]);<br>
skin=ft_read_headshape([freesurferDir 'bem\brain.surfilot08_outer_skin_surface' ]);<br>
<br>
% read electrodes positions<br>
elec_file=[datadir '\raw\M10.elc'];<br>
elec=ft_read_sens(elec_file );<br>
elec.coordsys='neuromag';<br>
elec.label=upper(elec.label);<br>
<br>
%% HEADMODEL<br>
%assign values of segmented surfaces<br>
geom(1).tri=brain.tri;<br>
geom(2).tri=skull.tri;<br>
geom(3).tri=skin.tri;<br>
<br>
geom(1).pnt=brain.pnt;<br>
geom(2).pnt=skull.pnt;<br>
geom(3).pnt=skin.pnt;<br>
% compute headmodel<br>
vol=ft_headmodel_bemcp(geom);<br>
vol=ft_convert_units(vol, 'mm');<br>
vol.coordsys='neuromag';<br>
<br>
%% ALIGNMENTS<br>
%align mri and headshape<br>
mri_coord=ft_determine_coordsys(mri, 'interactive', 'yes');<br>
vol_coord=ft_determine_coordsys(vol, 'interactive', 'yes');<br>
<br>
cfg=[];<br>
cfg.method = 'headshape';<br>
cfg.headshape=vol_coord.bnd(3);<br>
mri_headshape=ft_volumerealign(cfg,mri_coord);<br>
<br>
%find fiducials<br>
cfg=[];<br>
cfg.method='interactive';<br>
cfg.coordsys='neuromag';<br>
mri_fid=ft_volumerealign(cfg,mri_headshape);<br>
<br>
<br>
%% APPLY TRANSFORMATIONS ON FIDUCIALS<br>
<br>
transm=mri_fid.transform;<br>
nas=ft_warp_apply(transm,mri_fid.cfg.fiducial.nas, 'homogenous');<br>
lpa=ft_warp_apply(transm,mri_fid.cfg.fiducial.rpa, 'homogenous');<br>
rpa=ft_warp_apply(transm,mri_fid.cfg.fiducial.lpa, 'homogenous');<br>
<br>
<br>
<br>
fid.chanpos       = [nas;  rpa; lpa];<br>
fid.elecpos       =fid.chanpos;<br>
fid.label         = {'NASION',  'RIGHTEAR','LEFTEAR'}; % same labels as in elec<br>
fid.unit          = 'mm';            % same units as mri<br>
% Automatic electrode alignment using the fiducials<br>
cfg               = [];<br>
cfg.method        = 'fiducial';<br>
cfg.template      = fid;<br>
cfg.elec          = elec;<br>
cfg.fiducial      = {'NASION',  'RIGHTEAR','LEFTEAR'};  % labels of fiducials in fid and in sens<br>
cfg.headshape=vol_coord.bnd(3); % use the scalp as headshape<br>
elec_aligned_fid      = ft_electroderealign(cfg);<br>
<br>
<br>
%% Interactive alignment of electrodes to fix some misalignment<br>
<br>
cfg=[];<br>
cfg.method='interactive';<br>
cfg.elec=elec_aligned_fid;<br>
cfg.headshape=vol_coord.bnd(3); % use the scalp as headshape<br>
elec_aligned=ft_electroderealign(cfg);<br>
<br>
<br>
<br>
Best Regards,<br>
<br>
K. (Nadia) Kalogianni<br>
PhD candidate<br>
<br>
TU Delft /Department of Biomechanical Engneering<br>
Neuromuscular Control Laboratory<br>
<br>
Mekelweg 2<br>
2628 CD Delft<br>
Room: F-1-320<br>
T +31 15-27 84230<br>
E  k.kalogianni@tudelft.nl<<a href="mailto:k.kalogianni@tudelft.nl" target="_blank">mailto:k.kalogianni@tudelft.nl</a>><br>
<br>
_______________________________________________<br>
fieldtrip mailing list<br>
fieldtrip@donders.ru.nl<<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">mailto:fieldtrip@donders.ru.nl</a>><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/2b714e30/attachment-0001.html" target="_blank">http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/2b714e30/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 4<br>
Date: Wed, 29 Jul 2015 15:55:38 +0200<br>
From: mick.lehmann@uzh.ch<br>
To: fieldtrip@science.ru.nl<br>
Subject: Re: [FieldTrip] Baseline Correction using 'relchange' or 'db'<br>
Message-ID:<br>
<OF712C6BF3.82EA65A9-ONC1257E91.004C2CEF-C1257E91.004C8128@lotus.uzh.ch><br>
<br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Dear Fieltrippers,<br>
<br>
yesterday I addressed this mailing list with an issue regarding the baseline correction for time frequency analysis. While plotting a comparison of two conditions revealed exactly the results I've expected, the statistic didn't at all. Regardless of electrode,
 time window and freq range, the comparison of the two conditions was significantly different (with t-values between 8 and 10 and p < 0.001). Digging a little deeper, the main difference between the script for plotting and the one for stat analysis is that
 in for the figure, I've to indicate again the baselinewindow and the baselinetype:<br>
<br>
<br>
diff = gaTF_Cond1;<br>
diff.powspctrm = (gaTF_Cond1.powspctrm -?gaTF_Cond2.powspctrm);<br>
<br>
<br>
cfg = [];<br>
cfg.baseline ? ? = [-1 -.1];<br>
cfg.baselinetype = 'db'; ?<br>
cfg.maskstyle ? ?= 'saturation';<br>
<br>
cfg.zlim ? ? ? ? = [-3 3]; <br>
cfg.ylim ? ? ? ? = [2 25]; ??<br>
cfg.xlim ? ? ? ? = [-1 2];?<br>
cfg.channel ? ? ? = {'all'};<br>
cfg.layout = 'C:\Users\MickLehmann\Documents\Emo_React_EEG\FieldTrip\Scripts\egi128_GSN_HydroCel3.sfp';<br>
cfg.interactive = 'yes'<br>
ft_multiplotTFR(cfg,diff);?<br>
<br>
Runningit like this, the figure looks fine. However, if I switch off the bold part, the figure is dark red (as the stat analysis would suggest).?<br>
<br>
In the statistic script, I don't indicate the baseline again and I've no clue how to implement it. Do you think that could be the problem and has anybody a suggestion how to address the problem??<br>
<br>
If that is actually the main issue then I'm hardly the first encountering this problem.<br>
<br>
Kind regards,<br>
Mick<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/72542427/attachment-0001.html" target="_blank">http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/72542427/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 5<br>
Date: Wed, 29 Jul 2015 14:10:02 +0000<br>
From: "Herring, J.D. (Jim)" <j.herring@donders.ru.nl><br>
To: FieldTrip discussion list <fieldtrip@science.ru.nl><br>
Subject: Re: [FieldTrip] Baseline Correction using 'relchange' or 'db'<br>
Message-ID: <873A3AC5-23E9-4764-8760-095324D27832@donders.ru.nl><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Dear Mick,<br>
<br>
Indeed, if you apply a baseline correction only while plotting the the TFR it could be that you get different results when running statistics on the non-baseline corrected data.<br>
<br>
You can apply a baseline correction on your data prior to running the statistical analysis by using ft_freqbaseline to your ?diff? structure with cfg.baseline and cfg.baselinetype having the same values as you used while plotting.<br>
<br>
Best,<br>
<br>
Jim<br>
<br>
<br>
<br>
On 29 Jul 2015, at 15:55, mick.lehmann@uzh.ch<<a href="mailto:mick.lehmann@uzh.ch" target="_blank">mailto:mick.lehmann@uzh.ch</a>> wrote:<br>
<br>
Dear Fieltrippers,<br>
<br>
yesterday I addressed this mailing list with an issue regarding the baseline correction for time frequency analysis. While plotting a comparison of two conditions revealed exactly the results I've expected, the statistic didn't at all. Regardless of electrode,
 time window and freq range, the comparison of the two conditions was significantly different (with t-values between 8 and 10 and p < 0.001). Digging a little deeper, the main difference between the script for plotting and the one for stat analysis is that
 in for the figure, I've to indicate again the baselinewindow and the baselinetype:<br>
<br>
<br>
diff = gaTF_Cond1;<br>
diff.powspctrm = (gaTF_Cond1.powspctrm - gaTF_Cond2.powspctrm);<br>
<br>
<br>
cfg = [];<br>
cfg.baseline     = [-1 -.1];<br>
cfg.baselinetype = 'db';<br>
cfg.maskstyle    = 'saturation';<br>
cfg.zlim         = [-3 3];<br>
cfg.ylim         = [2 25];<br>
cfg.xlim         = [-1 2];<br>
cfg.channel       = {'all'};<br>
cfg.layout = 'C:\Users\MickLehmann\Documents\Emo_React_EEG\FieldTrip\Scripts\egi128_GSN_HydroCel3.sfp';<br>
cfg.interactive = 'yes'<br>
ft_multiplotTFR(cfg,diff);<br>
<br>
Runningit like this, the figure looks fine. However, if I switch off the bold part, the figure is dark red (as the stat analysis would suggest).<br>
<br>
In the statistic script, I don't indicate the baseline again and I've no clue how to implement it. Do you think that could be the problem and has anybody a suggestion how to address the problem?<br>
<br>
If that is actually the main issue then I'm hardly the first encountering this problem.<br>
<br>
Kind regards,<br>
Mick<br>
_______________________________________________<br>
fieldtrip mailing list<br>
fieldtrip@donders.ru.nl<<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">mailto:fieldtrip@donders.ru.nl</a>><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/586f46eb/attachment-0001.html" target="_blank">http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/586f46eb/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 6<br>
Date: Wed, 29 Jul 2015 15:11:52 +0100<br>
From: Eelke Spaak <eelke.spaak@donders.ru.nl><br>
To: FieldTrip discussion list <fieldtrip@science.ru.nl><br>
Subject: Re: [FieldTrip] Baseline Correction using 'relchange' or 'db'<br>
Message-ID:<br>
<CABPNLUoxbiy5Rx=HiUkN29ovG12nnGcEoLZszafQh7chf2OyYA@mail.gmail.com><br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
Dear Mick,<br>
<br>
If you want to run statistics on baseline-corrected time-frequency<br>
data, you should apply ft_freqbaseline on your data before entering it<br>
into ft_freqstatistics. Let us know if that solves the problem.<br>
<br>
Best,<br>
Eelke<br>
<br>
On 29 July 2015 at 14:55, mick.lehmann@uzh.ch <mick.lehmann@uzh.ch> wrote:<br>
> Dear Fieltrippers,<br>
><br>
> yesterday I addressed this mailing list with an issue regarding the baseline<br>
> correction for time frequency analysis. While plotting a comparison of two<br>
> conditions revealed exactly the results I've expected, the statistic didn't<br>
> at all. Regardless of electrode, time window and freq range, the comparison<br>
> of the two conditions was significantly different (with t-values between 8<br>
> and 10 and p < 0.001). Digging a little deeper, the main difference between<br>
> the script for plotting and the one for stat analysis is that in for the<br>
> figure, I've to indicate again the baselinewindow and the baselinetype:<br>
><br>
><br>
> diff = gaTF_Cond1;<br>
> diff.powspctrm = (gaTF_Cond1.powspctrm - gaTF_Cond2.powspctrm);<br>
><br>
><br>
> cfg = [];<br>
> cfg.baseline     = [-1 -.1];<br>
> cfg.baselinetype = 'db';<br>
> cfg.maskstyle    = 'saturation';<br>
> cfg.zlim         = [-3 3];<br>
> cfg.ylim         = [2 25];<br>
> cfg.xlim         = [-1 2];<br>
> cfg.channel       = {'all'};<br>
> cfg.layout =<br>
> 'C:\Users\MickLehmann\Documents\Emo_React_EEG\FieldTrip\Scripts\egi128_GSN_HydroCel3.sfp';<br>
> cfg.interactive = 'yes'<br>
> ft_multiplotTFR(cfg,diff);<br>
><br>
> Runningit like this, the figure looks fine. However, if I switch off the<br>
> bold part, the figure is dark red (as the stat analysis would suggest).<br>
><br>
> In the statistic script, I don't indicate the baseline again and I've no<br>
> clue how to implement it. Do you think that could be the problem and has<br>
> anybody a suggestion how to address the problem?<br>
><br>
> If that is actually the main issue then I'm hardly the first encountering<br>
> this problem.<br>
><br>
> Kind regards,<br>
> Mick<br>
<br>
<br>
------------------------------<br>
<br>
Message: 7<br>
Date: Wed, 29 Jul 2015 15:12:59 +0000<br>
From: Luke Bloy <luke.bloy@gmail.com><br>
To: Tom Holroyd <tomh@kurage.nimh.nih.gov><br>
Cc: FieldTrip list serve <fieldtrip@science.ru.nl><br>
Subject: Re: [FieldTrip] Creating a New CTF Ds file<br>
Message-ID:<br>
<CAG5Ru-rsmdr3okSjnAxqwp8RO_XXSTi8pa_1iVJCXtS=6=PpVA@mail.gmail.com><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Thanks for the replies.<br>
<br>
Jan-Mathijs, I am working on some  preprocessing/artifact correction<br>
projects and would like the option to write back to the DS format so that<br>
others in my lab, using native ctf tools or besa, can easily incorporate<br>
what I am doing into their pipelines. Starting with readCTFds.m and the<br>
files in external/ctf is probbaly a good idea. Thanks.<br>
<br>
Tom, rewriting the meg4 file would certainly work for what I need to do.<br>
Would you be willing to share an example (Python would be fine) of writing<br>
out to the meg4 file.<br>
<br>
Best,<br>
Luke<br>
<br>
On Tue, 28 Jul 2015 at 16:12 Tom Holroyd <tomh@kurage.nimh.nih.gov> wrote:<br>
<br>
> On Tue, 28 Jul 2015 17:03:41 +0000<br>
> Luke Bloy <luke.bloy@gmail.com> wrote:<br>
><br>
> > Is anyone aware of any tools for writing CTF DS files out from<br>
> > fieldtrip data structures?<br>
><br>
> Well, I have Python code. But the usual way to go here is to use an<br>
> existing dataset. The CTF .meg4 file is a "flat" file*, so you can read<br>
> in a CTF dataset, modify the data, and then easily re-write only<br>
> the .meg4 file without changing any of the other files, assuming the<br>
> modification doesn't change the trial structure or length of data.<br>
><br>
> The only thing you need to do is convert the internal floating point<br>
> representation (units of Tesla) back into the .meg4 file representation<br>
> (32-bit integers) by inverting the gain calculation, using the same<br>
> gains stored in the header.<br>
><br>
> With some trickery, you can even make shorter datasets from existing<br>
> ones using the usual newDs tool, and then rewrite the short .meg4 file<br>
> with whatever data. Writing CTF datasets from scratch is certainly<br>
> possible, but you're still going to be copying things from existing<br>
> datasets (such as sensor geometry and gain factors).<br>
><br>
> * with an 8 byte (constant) header<br>
><br>
> --<br>
> Dr. Tom<br>
> --<br>
> "There are not more than five musical notes,<br>
> yet the combinations of these five give rise to<br>
> more melodies than can ever be heard." -- Sun Tzu<br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/8d3ea717/attachment-0001.html" target="_blank">http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/8d3ea717/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 8<br>
Date: Wed, 29 Jul 2015 12:12:05 -0400<br>
From: Tom Holroyd <tomh@kurage.nimh.nih.gov><br>
To: Luke Bloy <luke.bloy@gmail.com><br>
Cc: FieldTrip list serve <fieldtrip@science.ru.nl><br>
Subject: Re: [FieldTrip] Creating a New CTF Ds file<br>
Message-ID: <20150729121205.7ec413af@kurage.nimh.nih.gov><br>
Content-Type: text/plain; charset=US-ASCII<br>
<br>
On Wed, 29 Jul 2015 15:12:59 +0000<br>
Luke Bloy <luke.bloy@gmail.com> wrote:<br>
<br>
> Tom, rewriting the meg4 file would certainly work for what I need to<br>
> do. Would you be willing to share an example (Python would be fine)<br>
> of writing out to the meg4 file.<br>
<br>
Here's a snippet. If you are reading it with Matlab, the important<br>
thing you'll need is the array of channel gains. I don't know where<br>
Fieldtrip stashes those, but they are there somewhere.<br>
<br>
# Get the channel gains. There are three sets of gains in the<br>
# res4 file, and they are just multiplied together to get one<br>
# gain for each of the M channels.<br>
<br>
gain = zeros(M)<br>
for m in range(M):<br>
    sr = res4.sensRes[m][0]<br>
    gain[m] = sr[sr_properGain] * sr[sr_qGain] * sr[sr_ioGain]<br>
<br>
# Format to write big endian 32-bit integers. CTF .meg4 files<br>
# are big endian 32-bit ints. Here, newlen is the length of<br>
# a trial in samples.<br>
<br>
be_int = Struct(">%di" % newlen)<br>
<br>
# Open the file and write the header.<br>
<br>
meg4name = os.path.join(newdsname, newset + ".meg4")<br>
f = open(meg4name, "w")<br>
f.write("MEG41CP\x00")<br>
<br>
# This loop only writes one trial. If there's more than<br>
# one, the next trial just goes right after the first one.<br>
# Within a trial it's channels by samples.<br>
<br>
for m in range(M):<br>
    #print "channel", res4.chanName[m]<br>
<br>
    # Get the data to write into trialbuf, in Tesla.<br>
    trialbuf[] = ...<br>
<br>
    # convert to int and write<br>
    trialbuf *= gain[m]<br>
    l = map(int, trialbuf + .5) # round to nearest int<br>
    f.write(be_int.pack(*l))    # writes newlen ints<br>
<br>
f.close()<br>
<br>
If the mailer screws up the formatting, just let me know<br>
and I can send you this whole app, which is dsimDs, which<br>
creates simulated MEG data from dipoles and noise. This is<br>
easy enough to convert to Matlab, anyway, once you know<br>
where the gains are (I'm not an expert in Matlab so I don't<br>
know how to write files ...)<br>
<br>
-- <br>
Dr. Tom<br>
--<br>
"There are not more than five musical notes,<br>
yet the combinations of these five give rise to<br>
more melodies than can ever be heard." -- Sun Tzu<br>
<br>
<br>
------------------------------<br>
<br>
Message: 9<br>
Date: Wed, 29 Jul 2015 11:50:14 -0500<br>
From: Berdakh Abibullaev <berdakho@gmail.com><br>
To: FieldTrip discussion list <fieldtrip@science.ru.nl><br>
Subject: Re: [FieldTrip] FW: align MRI- headmodel- EEG electrodes<br>
problem<br>
Message-ID:<br>
<CAOjxBaqkG=oah_yVQjQyFrvhabAU6+18Cb6FUjPM5X7UkKLS+Q@mail.gmail.com><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hi,<br>
<br>
?You could use the following function to project the electrodes onto the<br>
head surface, right after calling ft_electroderealign.<br>
<br>
[vol, elec] = ft_prepare_vol_sens(volume, electrode_aligned)?<br>
<br>
As Jim mentioned this function seems to be called internally while<br>
computing the leadfield.<br>
<br>
Best,<br>
Berdakh.<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/0409ac5a/attachment-0001.html" target="_blank">http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/0409ac5a/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
fieldtrip mailing list<br>
fieldtrip@donders.ru.nl<br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<br>
End of fieldtrip Digest, Vol 56, Issue 27<br>
*****************************************<br>
</font></div>
</div>
</div>
</div>
<div></div>
</font></div>
</div>
</div>
</body>
</html>