[FieldTrip] Baseline Correction using 'relchange' or 'db'

Stephen Whitmarsh stephen.whitmarsh at ki.se
Thu Jul 30 20:44:40 CEST 2015


Dear Mick,

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)

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?

>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?

Cheers,
Stephen



________________________________
From: fieldtrip-bounces at science.ru.nl [fieldtrip-bounces at science.ru.nl] on behalf of mick.lehmann at uzh.ch [mick.lehmann at uzh.ch]
Sent: 30 July 2015 16:50
To: fieldtrip at science.ru.nl
Subject: Re: [FieldTrip] Baseline Correction using 'relchange' or 'db'

Dear Stephen and Jim,

sorry that I wasn't clear before: Before calculating the grand average, I applied the baseline correction in a separate script:


TF_Remembered_db = ft_freqbaseline(cfg, TF_Remembered)
    cfg.baseline     = [-1 -.1 ];
    cfg.baselinetype = 'db';
    cfg.parameter    = 'powspctrm';

I repeated the same procedure for the second variable (TF_NotRemembered) and saved them as '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:

% Apply baseline correction:
if ~strcmp(cfg.baseline, 'no')
  % keep mask-parameter if it is set
  if ~isempty(cfg.maskparameter)
    tempmask = data.(cfg.maskparameter);
  end
  data = ft_freqbaseline(cfg, data);
  % put mask-parameter back if it is set
  if ~isempty(cfg.maskparameter)
    data.(cfg.maskparameter) = tempmask;
  end
end

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 ft_freqstatistics) 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 the plot is not baseline corrected as well:

cfg.baseline = [-1 -.1];
cfg.baselinetype = 'db';



I hope very much that this information is sufficient for an external to understand the procedures and the resulting issue.

Best regards,
Mick

-----fieldtrip-bounces at science.ru.nl schrieb: -----
An: fieldtrip at science.ru.nl
Von: fieldtrip-request at science.ru.nl
Gesendet von: fieldtrip-bounces at science.ru.nl
Datum: 30.07.2015 12:16
Betreff: fieldtrip Digest, Vol 56, Issue 27

Send fieldtrip mailing list submissions to
fieldtrip at science.ru.nl

To subscribe or unsubscribe via the World Wide Web, visit
http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
or, via email, send a message with subject or body 'help' to
fieldtrip-request at science.ru.nl

You can reach the person managing the list at
fieldtrip-owner at science.ru.nl

When replying, please edit your Subject line so it is more specific
than "Re: Contents of fieldtrip digest..."


Today's Topics:

   1. Re: Baseline Correction using 'relchange' or 'db'
      (mick.lehmann at uzh.ch)
   2. Re: Baseline Correction using 'relchange' or 'db'
      (Stephen Whitmarsh)
   3. Re: FW:  align MRI- headmodel- EEG electrodes problem
      (Herring, J.D. (Jim))
   4. Re: Baseline Correction using 'relchange' or 'db'
      (mick.lehmann at uzh.ch)
   5. Re: Baseline Correction using 'relchange' or 'db'
      (Herring, J.D. (Jim))
   6. Re: Baseline Correction using 'relchange' or 'db' (Eelke Spaak)
   7. Re: Creating a New CTF Ds file (Luke Bloy)
   8. Re: Creating a New CTF Ds file (Tom Holroyd)
   9. Re: FW: align MRI- headmodel- EEG electrodes problem
      (Berdakh Abibullaev)


----------------------------------------------------------------------

Message: 1
Date: Wed, 29 Jul 2015 12:48:47 +0200
From: mick.lehmann at uzh.ch
To: fieldtrip at science.ru.nl
Subject: Re: [FieldTrip] Baseline Correction using 'relchange' or 'db'
Message-ID:
<OFB07CB436.0F6C069C-ONC1257E91.003B65E3-C1257E91.003B65E6 at lotus.uzh.ch>

Content-Type: text/plain; charset="utf-8"

Dear Stephan,

the whole script with the designmatrix looks as follows. It is a within-subject design with two conditions.?

load?ga_TFCond1
load?ga_TFCond2
load neighbours

cfg = [];
cfg.channel ? ? ? ? ?= 'all';
cfg.latency ? ? ? ? ?= [0 2];
cfg.avgovertime ? ? ?= 'yes';
cfg.frequency ? ? ? ?= [5 7];
cfg.avgoverfreq ? ? ?= 'yes';
cfg.method ? ? ? ? ? = 'montecarlo';?
cfg.statistic ? ? ? ?= 'ft_statfun_depsamplesT';
cfg.correctm ? ? ? ? = 'cluster';
cfg.clusteralpha ? ? = 0.05;
cfg.clusterstatistic = 'maxsum';
cfg.minnbchan ? ? ? ?= 2;
cfg.tail ? ? ? ? ? ? = 0;
cfg.clustertail ? ? ?= 0;
cfg.alpha ? ? ? ? ? ?= 0.05;
cfg.numrandomization = 500;
cfg.neighbours ? ? ? = neighbours;


subj = 20;
design = zeros(2,2*subj);
for i = 1:subj
? design(1,i) = i;
end
for i = 1:subj
? design(1,subj+i) = i;
end
design(2,1:subj) ? ? ? ?= 1;
design(2,subj+1:2*subj) = 2;

cfg.design ? = design;
cfg.uvar ? ? = 1;
cfg.ivar ? ? = 2;


stat = ft_freqstatistics(cfg, ga_TFCond1, gaTF_Cond2);


Thanks a lot for your efforts!

Kind regards,
Mick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/6bb07361/attachment-0001.html>

------------------------------

Message: 2
Date: Wed, 29 Jul 2015 11:53:07 +0000
From: Stephen Whitmarsh <stephen.whitmarsh at ki.se>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] Baseline Correction using 'relchange' or 'db'
Message-ID:
<C2A579D858882B47926827674B07F5015844ED66 at KIMSX02.user.ki.se>
Content-Type: text/plain; charset="iso-8859-1"

Dear Mick,

The designmatrix looks fine to me.
I have not idea what might go wrong, but if I were you I would do the following checks:

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.

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.

This should give you a good first idea whether the statistics are behaving as you would expect.

Hope this helps,
Stephen

________________________________
From: fieldtrip-bounces at science.ru.nl [fieldtrip-bounces at science.ru.nl] on behalf of mick.lehmann at uzh.ch [mick.lehmann at uzh.ch]
Sent: 29 July 2015 12:48
To: fieldtrip at science.ru.nl
Subject: Re: [FieldTrip] Baseline Correction using 'relchange' or 'db'

Dear Stephan,

the whole script with the designmatrix looks as follows. It is a within-subject design with two conditions.

load ga_TFCond1
load ga_TFCond2
load neighbours

cfg = [];
cfg.channel          = 'all';
cfg.latency          = [0 2];
cfg.avgovertime      = 'yes';
cfg.frequency        = [5 7];
cfg.avgoverfreq      = 'yes';
cfg.method           = 'montecarlo';
cfg.statistic        = 'ft_statfun_depsamplesT';
cfg.correctm         = 'cluster';
cfg.clusteralpha     = 0.05;
cfg.clusterstatistic = 'maxsum';
cfg.minnbchan        = 2;
cfg.tail             = 0;
cfg.clustertail      = 0;
cfg.alpha            = 0.05;
cfg.numrandomization = 500;
cfg.neighbours       = neighbours;


subj = 20;
design = zeros(2,2*subj);
for i = 1:subj
  design(1,i) = i;
end
for i = 1:subj
  design(1,subj+i) = i;
end
design(2,1:subj)        = 1;
design(2,subj+1:2*subj) = 2;

cfg.design   = design;
cfg.uvar     = 1;
cfg.ivar     = 2;


stat = ft_freqstatistics(cfg, ga_TFCond1, gaTF_Cond2);


Thanks a lot for your efforts!

Kind regards,
Mick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/31562bb2/attachment-0001.html>

------------------------------

Message: 3
Date: Wed, 29 Jul 2015 13:27:01 +0000
From: "Herring, J.D. (Jim)" <j.herring at donders.ru.nl>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] FW:  align MRI- headmodel- EEG electrodes
problem
Message-ID:
<3D00B7615FB58D46A0B49B9AD67A33EB51370F at exprd01.hosting.ru.nl>
Content-Type: text/plain; charset="us-ascii"

Dear Nadia,

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.

Best,

Jim

From: fieldtrip-bounces at science.ru.nl [mailto:fieldtrip-bounces at science.ru.nl] On Behalf Of Konstantina Kalogianni
Sent: woensdag 22 juli 2015 15:53
To: FieldTrip discussion list
Subject: [FieldTrip] FW: align MRI- headmodel- EEG electrodes problem

Hi Jan-Mathijs,

You can download my best result from this link: https://surfdrive.surf.nl/files/public.php?service=files&t=6d591406015bcb7715ffaebd18fd7d03
I don't think is optimal.
Some of the frontal electrodes are placed inside the head and some of the back ones are floating.

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?

After reading posts on the discussion list, I  defined left ear as what seems the right ear.
But are there some other tricks that I should apply on the fiducials identification  or at the ft_warp_apply?

I agree that it will never be optimal because of the issues you described.
But I was wondering when is it satisfying in order not to influence my inverse solution.

One more question,  is there a function that I should I use that will optimize my electrodes locations after doing the alignment?

Thank you for your help.

Best,
Nadia



From: fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl> [mailto:fieldtrip-bounces at science.ru.nl] On Behalf Of Schoffelen, J.M. (Jan Mathijs)
Sent: dinsdag 21 juli 2015 20:55
To: FieldTrip discussion list
Subject: Re: [FieldTrip] align MRI- headmodel- EEG electrodes problem

Hi Nadia,

>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'?

Best,
Jan-Mathijs


Jan-Mathijs Schoffelen, MD PhD, Senior researcher

Max Planck Institute for Psycholinguistics
Donders Centre for Cognitive Neuroimaging

E-mail: j.schoffelen at donders.ru.nl<mailto:j.schoffelen at donders.ru.nl>
Telephone: +31-24-3614793

http://www.hettaligebrein.nl
http://www.fieldtriptoolbox.org





On Jul 21, 2015, at 4:56 PM, Konstantina Kalogianni <K.Kalogianni at tudelft.nl<mailto:K.Kalogianni at tudelft.nl>> wrote:

Dear fieldtrippers,

I am struggling with aligning the individual MRI, the headmodel and electrode positions(EEG) for some days now, without any success.
I would appreciate some help.

To begin with,  as an input I have the subject specific MRI which was segmented with the use of freesurfer and MNE software.
I load first the MRI ,the triangulated meshes for brain skull and skin, and the electrodes positions of 65-channel EEG.
I am then computing the bem headmodel from the brain skull skin (computed with the use of MNE software)
Afterwards I am aligning the MRI to my headmodel (ft_volumerealign) and then I identify the fiducials with the interactive mode (ft_volumerealign).
I do the transformation of the fiducial points  with ft_warp_apply to the coordinates specified at the alignment.
Then I call the  ft_electroderealign to align my electrodes to the mri's fiducial points.
And then I realign  my electrodes manually.

The problem is that no matter how much rotation translation scaling I do, it's IMPOSSIBLE TO FIT THE ELECTRODES TO THE HEADMODEL!
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.

Below you can find the code that I used.
Any ideas on this issue would be of great help!


%% READ
% read mri
mri=ft_read_mri([freesurferDir 'mri\orig.mgz']);
mri.coordsys='neuromag';

% read surfaces

brain=ft_read_headshape([freesurferDir 'bem\brain.surf\Pilot08_brain_surface']);

skull=ft_read_headshape([freesurferDir 'bem\brain.surf\Pilot08_inner_skull_surface' ]);
skin=ft_read_headshape([freesurferDir 'bem\brain.surfilot08_outer_skin_surface' ]);

% read electrodes positions
elec_file=[datadir '\raw\M10.elc'];
elec=ft_read_sens(elec_file );
elec.coordsys='neuromag';
elec.label=upper(elec.label);

%% HEADMODEL
%assign values of segmented surfaces
geom(1).tri=brain.tri;
geom(2).tri=skull.tri;
geom(3).tri=skin.tri;

geom(1).pnt=brain.pnt;
geom(2).pnt=skull.pnt;
geom(3).pnt=skin.pnt;
% compute headmodel
vol=ft_headmodel_bemcp(geom);
vol=ft_convert_units(vol, 'mm');
vol.coordsys='neuromag';

%% ALIGNMENTS
%align mri and headshape
mri_coord=ft_determine_coordsys(mri, 'interactive', 'yes');
vol_coord=ft_determine_coordsys(vol, 'interactive', 'yes');

cfg=[];
cfg.method = 'headshape';
cfg.headshape=vol_coord.bnd(3);
mri_headshape=ft_volumerealign(cfg,mri_coord);

%find fiducials
cfg=[];
cfg.method='interactive';
cfg.coordsys='neuromag';
mri_fid=ft_volumerealign(cfg,mri_headshape);


%% APPLY TRANSFORMATIONS ON FIDUCIALS

transm=mri_fid.transform;
nas=ft_warp_apply(transm,mri_fid.cfg.fiducial.nas, 'homogenous');
lpa=ft_warp_apply(transm,mri_fid.cfg.fiducial.rpa, 'homogenous');
rpa=ft_warp_apply(transm,mri_fid.cfg.fiducial.lpa, 'homogenous');



fid.chanpos       = [nas;  rpa; lpa];
fid.elecpos       =fid.chanpos;
fid.label         = {'NASION',  'RIGHTEAR','LEFTEAR'}; % same labels as in elec
fid.unit          = 'mm';            % same units as mri
% Automatic electrode alignment using the fiducials
cfg               = [];
cfg.method        = 'fiducial';
cfg.template      = fid;
cfg.elec          = elec;
cfg.fiducial      = {'NASION',  'RIGHTEAR','LEFTEAR'};  % labels of fiducials in fid and in sens
cfg.headshape=vol_coord.bnd(3); % use the scalp as headshape
elec_aligned_fid      = ft_electroderealign(cfg);


%% Interactive alignment of electrodes to fix some misalignment

cfg=[];
cfg.method='interactive';
cfg.elec=elec_aligned_fid;
cfg.headshape=vol_coord.bnd(3); % use the scalp as headshape
elec_aligned=ft_electroderealign(cfg);



Best Regards,

K. (Nadia) Kalogianni
PhD candidate

TU Delft /Department of Biomechanical Engneering
Neuromuscular Control Laboratory

Mekelweg 2
2628 CD Delft
Room: F-1-320
T +31 15-27 84230
E  k.kalogianni at tudelft.nl<mailto:k.kalogianni at tudelft.nl>

_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>
http://mailman.science.ru.nl/mailman/listinfo/fieldtrip


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/2b714e30/attachment-0001.html>

------------------------------

Message: 4
Date: Wed, 29 Jul 2015 15:55:38 +0200
From: mick.lehmann at uzh.ch
To: fieldtrip at science.ru.nl
Subject: Re: [FieldTrip] Baseline Correction using 'relchange' or 'db'
Message-ID:
<OF712C6BF3.82EA65A9-ONC1257E91.004C2CEF-C1257E91.004C8128 at lotus.uzh.ch>

Content-Type: text/plain; charset="utf-8"

Dear Fieltrippers,

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:


diff = gaTF_Cond1;
diff.powspctrm = (gaTF_Cond1.powspctrm -?gaTF_Cond2.powspctrm);


cfg = [];
cfg.baseline ? ? = [-1 -.1];
cfg.baselinetype = 'db'; ?
cfg.maskstyle ? ?= 'saturation';

cfg.zlim ? ? ? ? = [-3 3];
cfg.ylim ? ? ? ? = [2 25]; ??
cfg.xlim ? ? ? ? = [-1 2];?
cfg.channel ? ? ? = {'all'};
cfg.layout = 'C:\Users\MickLehmann\Documents\Emo_React_EEG\FieldTrip\Scripts\egi128_GSN_HydroCel3.sfp';
cfg.interactive = 'yes'
ft_multiplotTFR(cfg,diff);?

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).?

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??

If that is actually the main issue then I'm hardly the first encountering this problem.

Kind regards,
Mick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/72542427/attachment-0001.html>

------------------------------

Message: 5
Date: Wed, 29 Jul 2015 14:10:02 +0000
From: "Herring, J.D. (Jim)" <j.herring at donders.ru.nl>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] Baseline Correction using 'relchange' or 'db'
Message-ID: <873A3AC5-23E9-4764-8760-095324D27832 at donders.ru.nl>
Content-Type: text/plain; charset="utf-8"

Dear Mick,

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.

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.

Best,

Jim



On 29 Jul 2015, at 15:55, mick.lehmann at uzh.ch<mailto:mick.lehmann at uzh.ch> wrote:

Dear Fieltrippers,

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:


diff = gaTF_Cond1;
diff.powspctrm = (gaTF_Cond1.powspctrm - gaTF_Cond2.powspctrm);


cfg = [];
cfg.baseline     = [-1 -.1];
cfg.baselinetype = 'db';
cfg.maskstyle    = 'saturation';
cfg.zlim         = [-3 3];
cfg.ylim         = [2 25];
cfg.xlim         = [-1 2];
cfg.channel       = {'all'};
cfg.layout = 'C:\Users\MickLehmann\Documents\Emo_React_EEG\FieldTrip\Scripts\egi128_GSN_HydroCel3.sfp';
cfg.interactive = 'yes'
ft_multiplotTFR(cfg,diff);

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).

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?

If that is actually the main issue then I'm hardly the first encountering this problem.

Kind regards,
Mick
_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>
http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/586f46eb/attachment-0001.html>

------------------------------

Message: 6
Date: Wed, 29 Jul 2015 15:11:52 +0100
From: Eelke Spaak <eelke.spaak at donders.ru.nl>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] Baseline Correction using 'relchange' or 'db'
Message-ID:
<CABPNLUoxbiy5Rx=HiUkN29ovG12nnGcEoLZszafQh7chf2OyYA at mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

Dear Mick,

If you want to run statistics on baseline-corrected time-frequency
data, you should apply ft_freqbaseline on your data before entering it
into ft_freqstatistics. Let us know if that solves the problem.

Best,
Eelke

On 29 July 2015 at 14:55, mick.lehmann at uzh.ch <mick.lehmann at uzh.ch> wrote:
> Dear Fieltrippers,
>
> 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:
>
>
> diff = gaTF_Cond1;
> diff.powspctrm = (gaTF_Cond1.powspctrm - gaTF_Cond2.powspctrm);
>
>
> cfg = [];
> cfg.baseline     = [-1 -.1];
> cfg.baselinetype = 'db';
> cfg.maskstyle    = 'saturation';
> cfg.zlim         = [-3 3];
> cfg.ylim         = [2 25];
> cfg.xlim         = [-1 2];
> cfg.channel       = {'all'};
> cfg.layout =
> 'C:\Users\MickLehmann\Documents\Emo_React_EEG\FieldTrip\Scripts\egi128_GSN_HydroCel3.sfp';
> cfg.interactive = 'yes'
> ft_multiplotTFR(cfg,diff);
>
> 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).
>
> 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?
>
> If that is actually the main issue then I'm hardly the first encountering
> this problem.
>
> Kind regards,
> Mick


------------------------------

Message: 7
Date: Wed, 29 Jul 2015 15:12:59 +0000
From: Luke Bloy <luke.bloy at gmail.com>
To: Tom Holroyd <tomh at kurage.nimh.nih.gov>
Cc: FieldTrip list serve <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] Creating a New CTF Ds file
Message-ID:
<CAG5Ru-rsmdr3okSjnAxqwp8RO_XXSTi8pa_1iVJCXtS=6=PpVA at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Thanks for the replies.

Jan-Mathijs, I am working on some  preprocessing/artifact correction
projects and would like the option to write back to the DS format so that
others in my lab, using native ctf tools or besa, can easily incorporate
what I am doing into their pipelines. Starting with readCTFds.m and the
files in external/ctf is probbaly a good idea. Thanks.

Tom, rewriting the meg4 file would certainly work for what I need to do.
Would you be willing to share an example (Python would be fine) of writing
out to the meg4 file.

Best,
Luke

On Tue, 28 Jul 2015 at 16:12 Tom Holroyd <tomh at kurage.nimh.nih.gov> wrote:

> On Tue, 28 Jul 2015 17:03:41 +0000
> Luke Bloy <luke.bloy at gmail.com> wrote:
>
> > Is anyone aware of any tools for writing CTF DS files out from
> > fieldtrip data structures?
>
> Well, I have Python code. But the usual way to go here is to use an
> existing dataset. The CTF .meg4 file is a "flat" file*, so you can read
> in a CTF dataset, modify the data, and then easily re-write only
> the .meg4 file without changing any of the other files, assuming the
> modification doesn't change the trial structure or length of data.
>
> The only thing you need to do is convert the internal floating point
> representation (units of Tesla) back into the .meg4 file representation
> (32-bit integers) by inverting the gain calculation, using the same
> gains stored in the header.
>
> With some trickery, you can even make shorter datasets from existing
> ones using the usual newDs tool, and then rewrite the short .meg4 file
> with whatever data. Writing CTF datasets from scratch is certainly
> possible, but you're still going to be copying things from existing
> datasets (such as sensor geometry and gain factors).
>
> * with an 8 byte (constant) header
>
> --
> Dr. Tom
> --
> "There are not more than five musical notes,
> yet the combinations of these five give rise to
> more melodies than can ever be heard." -- Sun Tzu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/8d3ea717/attachment-0001.html>

------------------------------

Message: 8
Date: Wed, 29 Jul 2015 12:12:05 -0400
From: Tom Holroyd <tomh at kurage.nimh.nih.gov>
To: Luke Bloy <luke.bloy at gmail.com>
Cc: FieldTrip list serve <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] Creating a New CTF Ds file
Message-ID: <20150729121205.7ec413af at kurage.nimh.nih.gov>
Content-Type: text/plain; charset=US-ASCII

On Wed, 29 Jul 2015 15:12:59 +0000
Luke Bloy <luke.bloy at gmail.com> wrote:

> Tom, rewriting the meg4 file would certainly work for what I need to
> do. Would you be willing to share an example (Python would be fine)
> of writing out to the meg4 file.

Here's a snippet. If you are reading it with Matlab, the important
thing you'll need is the array of channel gains. I don't know where
Fieldtrip stashes those, but they are there somewhere.

# Get the channel gains. There are three sets of gains in the
# res4 file, and they are just multiplied together to get one
# gain for each of the M channels.

gain = zeros(M)
for m in range(M):
    sr = res4.sensRes[m][0]
    gain[m] = sr[sr_properGain] * sr[sr_qGain] * sr[sr_ioGain]

# Format to write big endian 32-bit integers. CTF .meg4 files
# are big endian 32-bit ints. Here, newlen is the length of
# a trial in samples.

be_int = Struct(">%di" % newlen)

# Open the file and write the header.

meg4name = os.path.join(newdsname, newset + ".meg4")
f = open(meg4name, "w")
f.write("MEG41CP\x00")

# This loop only writes one trial. If there's more than
# one, the next trial just goes right after the first one.
# Within a trial it's channels by samples.

for m in range(M):
    #print "channel", res4.chanName[m]

    # Get the data to write into trialbuf, in Tesla.
    trialbuf[] = ...

    # convert to int and write
    trialbuf *= gain[m]
    l = map(int, trialbuf + .5) # round to nearest int
    f.write(be_int.pack(*l))    # writes newlen ints

f.close()

If the mailer screws up the formatting, just let me know
and I can send you this whole app, which is dsimDs, which
creates simulated MEG data from dipoles and noise. This is
easy enough to convert to Matlab, anyway, once you know
where the gains are (I'm not an expert in Matlab so I don't
know how to write files ...)

--
Dr. Tom
--
"There are not more than five musical notes,
yet the combinations of these five give rise to
more melodies than can ever be heard." -- Sun Tzu


------------------------------

Message: 9
Date: Wed, 29 Jul 2015 11:50:14 -0500
From: Berdakh Abibullaev <berdakho at gmail.com>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] FW: align MRI- headmodel- EEG electrodes
problem
Message-ID:
<CAOjxBaqkG=oah_yVQjQyFrvhabAU6+18Cb6FUjPM5X7UkKLS+Q at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi,

?You could use the following function to project the electrodes onto the
head surface, right after calling ft_electroderealign.

[vol, elec] = ft_prepare_vol_sens(volume, electrode_aligned)?

As Jim mentioned this function seems to be called internally while
computing the leadfield.

Best,
Berdakh.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150729/0409ac5a/attachment-0001.html>

------------------------------

_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl
http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

End of fieldtrip Digest, Vol 56, Issue 27
*****************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150730/0dd2eb75/attachment-0002.html>


More information about the fieldtrip mailing list