[FieldTrip] Problem with Geodesic 129 layout!!

Joseph Dien jdien07 at mac.com
Tue Sep 9 03:55:44 CEST 2014


yes, please do send me the data.

Thanks!

Joe

On Sep 8, 2014, at 3:38 PM, KatrinH Heimann <katrinheimann at gmail.com> wrote:

> Dear Joseph, thanks so much, I really appreciate your help. I was also wandering, if maybe there is another bug in my code.
> Our nets are 128 channels, Hydrocel, but as a colleague of me adviced me to do so, I also tried the 129 layout. 
> My code you find below (without selection of bad channels etc.) 
> If you need also the data of two subjects to have a look, let me know!!!
> Best and thanks really!
>  Katrin
> 
> 
> 
> subject=input('Which subject do you want to analyse?   ','s');
> 
> name = strcat(subject,'.raw');
> 
> subjectnumber=input('Which is the subjectnumber?', 's');
> 
> sb=subjectnumber
> 
> %subjectnumber = strcat(subjectnumber, '.txt')
> 
> %%
> 
> 
> 
> cfg                     = [];
> 
> cfg.dataset             = name;
> 
> cfg.trialfun            = 'ft_trialfun_general'; % this is the default
> 
> cfg.trialdef.eventtype  = 'trigger';
> 
> cfg.trialdef.eventvalue = 'stim'; % the value of the stimulus trigger 
> 
> cfg.trialdef.prestim    = 0.234; % in seconds
> 
> cfg.trialdef.poststim   = 7.266; % in seconds (whole time of video observation, but maybe we need less)
> 
> cfg                     = ft_definetrial(cfg);
> 
> 
> 
> cfg.trl([1:7],:) = []; 
> 
> 
> 
> %change timeline according to constant offset of 16 ms = 8 samples (because recorded with 500 hz)in
> 
> %structure trial
> 
> cfg.trl(:,3)=cfg.trl(:,3)-8
> 
> 
> 
> %change timeline to make the cut the zeropoint
> 
> 
> 
> cfg.trl(:,3)=cfg.trl(:,3)- 1000;
> 
> 
> 
> 
> 
> %% preprocess data
> 
> cfg.channel    = 'all';
> 
> cfg.preproc.detrend       = 'yes';
> 
> cfg.preproc.demean = 'yes';
> 
> cfg.preproc.baselinewindow = [-2.1 -2.0]
> 
> %cfg.preproc.bpfilter = 'yes';   - the data here has to be already filtered
> 
> %(0.1-45) and bad channels have to be replaced!!!!
> 
> %cfg.preproc.bpfreq = [6 32];
> 
> % 
> 
> % 
> 
> obs_data           = ft_preprocessing(cfg);
> 
> % 
> 
> save (strcat(sb,'obs_data') , 'obs_data')
> 
> 
> 
> %% determining channel neighbours (necessary for Artifact detection)
> 
> cfg = [];
> 
> cfg.channel  = obs_data.label;
> 
> cfg.layout   = 'GSN128.sfp';
> 
> cfg.feedback = 'yes';
> 
> lay          = ft_prepare_layout(cfg);
> 
>  
> cfg_neighb          = [];
> 
> cfg_neighb.feedback = 'yes';
> 
> 
> 
> cfg_neighb.method   = 'triangulation';
> 
> cfg_neighb.layout   = 'GSN128.sfp';
> 
> neighbours          = ft_prepare_neighbours(cfg_neighb, obs_data);
> 
> 
> 
> obs_data.elec = ft_read_sens('GSN128.sfp');
> 
> 
> 
> %% Artifacts - to detect bad channels - is not saved!!!
> 
> 
> 
> 
> 
> cfg.method = 'summary';
> 
> cfg.latency=[0 1];
> 
> cfg.layout = 'GSN128.sfp';       % this allows for plotting
> 
> obs_data_try = ft_rejectvisual(cfg, obs_data); 
> 
> 
> 
> cfg = [];
> 
> cfg.viewmode = 'vertical';
> 
> cfg.latency=[0 1];
> 
> cfg.continuous = 'no';
> 
> cfg.plotlabels='yes'
> 
> cfg = ft_databrowser(cfg,obs_data);
> 
> %cfg.artfctdef.reject = 'complete'; 
> 
> obs_data_try = ft_rejectartifact (cfg,obs_data);
> 
> 
> 
> 
> 
> %% Preparing neighbours for channel repair - but bad channel info in!!!
> 
> 
> 
> % cfg_neighb          = [];
> 
> % cfg_neighb.feedback = 'yes';
> 
> % cfg_neighb.method   = 'triangulation';
> 
> % cfg_neighb.layout   = 'GSN-HydroCel-128.sfp';
> 
> % neighbours          = ft_prepare_neighbours(cfg_neighb, obs_data);
> 
> 
> 
> % Interpolate and put into new data structure
> 
>  cfg                      = []; 
> 
>  cfg.badchannel           = {};
> 
>  cfg.layout               = 'GSN128.sfp';
> 
>  cfg.method               = 'nearest';
> 
>  cfg.neighbours           = neighbours;
> 
>  obs_data_channelrepaired       = ft_channelrepair(cfg,obs_data)
> 
> 
> 
>  % Check reconstruction
> 
> cfg = [];
> 
> cfg.viewmode = 'vertical';
> 
> cfg.continuous = 'no';
> 
> cfg.plotlabels='yes'
> 
> cfg = ft_databrowser(cfg,obs_data_channelrepaired);
> 
> %cfg.artfctdef.reject = 'complete'; 
> 
> obs_data_clean1 = ft_rejectartifact (cfg,obs_data_channelrepaired);
> 
> 
> 
> % dat1=obs_data;
> 
> % dat2=obs_data_channelrepaired;
> 
> % 
> 
> % x=dat1.trial{1}(62,:); % 68 is channel index of E68
> 
> % y=dat2.trial{1}(62,:);
> 
> % plot(x);hold on;plot(y,'r');
> 
> % 
> 
> % x=dat1.trial{1}(72,:);
> 
> % y=dat2.trial{1}(75,:);
> 
> % figure;
> 
> % plot(x);hold on;plot(y,'r')
> 
> % 
> 
> % x=dat1.trial{1}(75,:);
> 
> % y=dat2.trial{1}(75,:);
> 
> % figure;
> 
> % plot(x);hold on;plot(y,'r')
> 
> %% artifact rejection/trial inspection - throw out electrode jumps etc.
> 
> 
> 
> 
> 
> cfg = [];
> 
> cfg.viewmode = 'vertical';
> 
> cfg.continuous = 'no';
> 
> cfg.plotlabels='yes'
> 
> cfg = ft_databrowser(cfg,obs_data_channelrepaired);
> 
> %cfg.artfctdef.reject = 'complete'; 
> 
> obs_data_clean1 = ft_rejectartifact (cfg,obs_data_channelrepaired);
> 
> 
> 
> %% ICA - Anzahl der Komponenten anpassen!- adapt numcomponent according to channels interpolated %% 128-number of interp. channels)
> 
>   
> cfg = [];
> 
> cfg.channel = {'all'};
> 
> cfg.numcomponent = 128
> 
> comp = ft_componentanalysis(cfg,obs_data_clean1);
> 
> save (strcat(sb,'comp_all') , 'comp')
> 
> 
> 
> %%    
> 
> cfg = [];
> 
> cfg.viewmode = 'component'; 
> 
> cfg.continuous = 'no'; 
> 
> cfg.plotlabels='some';
> 
> cfg.layout = 'GSN128.sfp';
> 
> ft_databrowser(cfg,comp);
> 
> 
> 
> %% poweranalysis components
> 
> cfg              = [];
> 
> cfg.output       = 'pow';
> 
> cfg.channel      = 'all';%compute the power spectrum in all ICs
> 
> cfg.method       = 'mtmfft';
> 
> cfg.taper        = 'hanning';
> 
> cfg.foi          = 0:0.2:50;
> 
> obs_freq = ft_freqanalysis(cfg, comp);
> 
> 
> 
> %And you can plot the spectra:
> 
> 
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> 
> nsubplots = 16;
> 
> nbyn = sqrt(nsubplots);% sqrt(nsubplots) should not contain decimals, type doc subplot
> 
> 
> 
> Nfigs = ceil(size(comp.topo,1)/nsubplots);
> 
> tot = Nfigs*nsubplots;
> 
> 
> 
> rptvect = 1:size(comp.topo,1);
> 
> rptvect = padarray(rptvect, [0 tot-size(comp.topo,1)], 0,'post');
> 
> rptvect = reshape(rptvect,nsubplots,Nfigs)';
> 
> 
> 
> for r=1:size(rptvect,1);
> 
>   figure;set(gcf,'units','normalized','outerposition',[0 0 1 1]);%full screen
> 
>   k=0;
> 
>   for j=1:size(rptvect,2);
> 
>     if~(rptvect(r,j)==0);
> 
>       k=k+1;
> 
>       cfg=[];
> 
>       cfg.channel = rptvect(r,j);
> 
>       cfg.ylim =[0 500]
> 
>       cfg.xlim =[0 50]
> 
>       subplot(nbyn,nbyn,k);ft_singleplotER(cfg,obs_freq);
> 
>     end
> 
>   end
> 
> end
> 
> 
> 
> %For the IC topos you'll follow the same logic as above but with:
> 
> 
> 
> figure
> 
> cfg = [];
> 
> cfg.component = [1:20];       % specify the component(s) that should be plotted
> 
> cfg.layout    = 'GSN128.sfp'; 
> 
> cfg.comment   = 'no';
> 
> ft_topoplotIC(cfg, comp)
> 
> 
> 
> figure
> 
> cfg = [];
> 
> cfg.component = [21:40];       % specify the component(s) that should be plotted
> 
> cfg.layout    = 'GSN128.sfp'; 
> 
> cfg.comment   = 'no';
> 
> ft_topoplotIC(cfg, comp)
> 
> 
> 
> figure
> 
> cfg = [];
> 
> cfg.component = [41:60];       % specify the component(s) that should be plotted
> 
> cfg.layout    = 'GSN128.sfp'; 
> 
> cfg.comment   = 'no';
> 
> ft_topoplotIC(cfg, comp)
> 
> 
> 
> figure
> 
> cfg = [];
> 
> cfg.component = [61:80];       % specify the component(s) that should be plotted
> 
> cfg.layout    = 'GSN128.sfp'; 
> 
> cfg.comment   = 'no';
> 
> ft_topoplotIC(cfg, comp)
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> %% Seperate observation conditions
> 
> 
> 
> name1= strcat(num2str(sb),'_90.xls');
> 
>     list1=xlsread (name1)
> 
>     
>     
> name2= strcat(num2str(sb),'_180.xls');
> 
>     list2=xlsread (name2)
> 
>     
> %        
> 
> 
> 
> cfg = []
> 
> cfg.trials = [list1]
> 
> obs90_data = ft_redefinetrial(cfg,obs_data_channelrepaired)
> 
> 
> 
> cfg = []
> 
> cfg.trials = [list2]
> 
> obs180_data = ft_redefinetrial(cfg,obs_data_channelrepaired)
> 
> 
> 
> %%PIPELINE FOR obs90
> 
> 
> 
> %% Decompose original data according to the components found before
> 
> load (strcat(sb,'comp_all'))
> 
> 
> 
> cfg = [];
> 
> cfg.numcomponent = 128;
> 
> cfg.unmixing  = comp.unmixing;
> 
> cfg.topolabel = comp.topolabel;
> 
> 
> 
> comp_1     = ft_componentanalysis(cfg, obs90_data);
> 
> 
> 
> 
> 
> %% Reject component
> 
> cfg = [];
> 
>     cfg.component = [];
> 
>     obs90_data_ica_cleaned = ft_rejectcomponent(cfg, comp_1, obs90_data);
> 
>    
> 
> 
>  save (strcat(sb,'obs90_ica_cleaned') , 'obs90_data_ica_cleaned')
> 
> 
> 
> 
> 
> 
> 
> %% Artifacts - final detection
> 
> 
> 
> 
> 
> cfg.method = 'summary';
> 
> cfg.latency=[0 1];
> 
> cfg.layout = 'GSN128.sfp';       % this allows for plotting
> 
> obs90_data_clean3 = ft_rejectvisual(cfg, obs90_data_ica_cleaned); 
> 
> 
> 
> cfg = [];
> 
> cfg.viewmode = 'vertical';
> 
> cfg.latency=[0 1];
> 
> cfg.continuous = 'no';
> 
> cfg.plotlabels='yes'
> 
> cfg = ft_databrowser(cfg,obs90_data_clean3);
> 
> %cfg.artfctdef.reject = 'complete'; 
> 
> obs90_data_clean2 = ft_rejectartifact (cfg,obs90_data_clean3);
> 
> 
> 
> 
> 
> % Save clean data
> 
> 
> 
> save (strcat(subject,'obs90_clean') , 'obs90_data_clean2')
> 
> 
> 
> 
> 
> %% Rereferencing data
> 
> cfg = [];
> 
> 
> 
> cfg.channel    = 'all';
> 
> cfg.preproc.reref         = 'yes';
> 
> cfg.preproc.refchannel    = 'all'; 
> 
> obs90_data_ref= ft_preprocessing(cfg,obs90_data_clean2)
> 
> 
> 
> save (strcat(subject,'obs90_ref') , 'obs90_data_ref')
> 
> %% Snap out smaller pieces (the third second)
> 
> 
> 
> cfg = []
> 
> cfg.toilim    = [0 1]
> 
> 
> 
> obs90_data_small = ft_redefinetrial(cfg,obs90_data_ref)
> 
> 
> 
> %%  TIMELOCK ERP
> 
> obs90_data_ERP = ft_timelockanalysis(cfg, obs90_data_small);
> 
> 
> 
> save (strcat(subject,'obs90_ERP') , 'obs90_data_ERP')
> 
> 
> 
> %% plot it
> 
> cfg = [];
> 
> cfg.layout = lay ;
> 
> cfg.interactive = 'yes';
> 
> ft_multiplotER(cfg, obs90_data_ERP)
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> %% PIPELINE FOR obs180
> 
> 
> 
> 
> 
> %% Decompose original data according to the components found before
> 
> load (strcat(sb,'comp_all'))
> 
> 
> 
> cfg = [];
> 
> cfg.numcomponent = 128
> 
> cfg.unmixing  = comp.unmixing;
> 
> cfg.topolabel = comp.topolabel;
> 
> comp_2     = ft_componentanalysis(cfg, obs180_data);
> 
> 
> 
> 
> 
> %% Reject component
> 
> cfg = [];
> 
>     cfg.component = [];
> 
>     obs180_data_ica_cleaned = ft_rejectcomponent(cfg, comp_2, obs180_data);
> 
>    
> 
> 
>  save (strcat(sb,'obs180_ica_cleaned') , 'obs180_data_ica_cleaned')
> 
> 
> 
> 
> 
> 
> 
> %% Artifacts final 180
> 
> 
> 
> 
> 
> cfg.method = 'summary';
> 
> cfg.latency=[0 1];
> 
> cfg.layout = 'GSN128.sfp';       % this allows for plotting
> 
> obs180_data_clean3 = ft_rejectvisual(cfg, obs180_data_ica_cleaned); 
> 
> 
> 
> cfg = [];
> 
> cfg.viewmode = 'vertical';
> 
> cfg.latency=[0 1];
> 
> cfg.continuous = 'no';
> 
> cfg.plotlabels='yes'
> 
> cfg = ft_databrowser(cfg,obs180_data_clean3);
> 
> %cfg.artfctdef.reject = 'complete'; 
> 
> obs180_data_clean2 = ft_rejectartifact (cfg,obs180_data_clean3);
> 
> 
> 
> 
> 
> % Save clean data
> 
> 
> 
> save (strcat(subject,'obs180_clean') , 'obs180_data_clean2')
> 
> 
> 
> 
> 
> %% Rereferencing data
> 
> cfg = [];
> 
> cfg.channel    = 'all';
> 
> cfg.preproc.reref         = 'yes';
> 
> cfg.preproc.refchannel    = 'all'; 
> 
> obs180_data_ref= ft_preprocessing(cfg,obs180_data_clean2)
> 
> 
> 
> save (strcat(subject,'obs180_ref') , 'obs180_data_ref')
> 
> %% Snap out smaller pieces (the third second)
> 
> 
> 
> cfg = []
> 
> cfg.toilim    = [0 1]
> 
> 
> 
> obs180_data_small = ft_redefinetrial(cfg,obs180_data_ref)
> 
> 
> 
> %%  TIMELOCK ERP
> 
> obs180_data_ERP = ft_timelockanalysis(cfg, obs180_data_small);
> 
> 
> 
> save (strcat(subject,'obs180_ERP') , 'obs180_data_ERP')
> 
> 
> 
> %% plot 180 ERP
> 
> 
> 
> cfg = [];
> 
> cfg.layout = lay ;
> 
> cfg.interactive = 'yes';
> 
> ft_multiplotER(cfg, obs180_data_ERP)
> 
> 
> 
> %% plot both ERPs
> 
> 
> 
> cfg = [];
> 
> cfg.layout = lay ;
> 
> cfg.interactive = 'yes';
> 
> cfg.showlabels = 'yes';
> 
> ft_multiplotER(cfg, obs90_data_ERP, obs180_data_ERP)
> 
> 
> 
> %% plot difference wave
> 
> 
> 
> difference     = obs180_data_ERP;                   % copy one of the structures
> 
> difference.avg = obs180_data_ERP.avg - obs90_data_ERP.avg;   % compute the difference ERP
> 
>  
> cfg = [];
> 
> cfg.layout      = lay;
> 
> cfg.interactive = 'yes';
> 
> ft_multiplotER(cfg, difference)
> 
> 
> 2014-09-07 7:53 GMT+02:00 Joseph Dien <jdien07 at mac.com>:
> Hi,
>    I’m one of the main Fieldtrip contributors working on supporting EGI data.  A couple things.  First of all, exactly which net do you use?  If they are 129-channel, there is still the question of whether they are the Hydrocel or the older geodesic nets.  Regardless, that shouldn't cause an error like this.  Could you send me the file you are trying to process and the script you are using and I’ll try troubleshooting it.
> 
> Joe
> 
> 
> On Aug 26, 2014, at 12:53 AM, Ana Laura Diez Martini <diezmartini at gmail.com> wrote:
> 
>> Which nets do you use? I use EGI. I tried both the ones you mention and they didn't work. It was hard to find that exact one online but it was the only file that actually worked.
>> 
>> 
>> On Mon, Aug 25, 2014 at 7:52 AM, KatrinH Heimann <katrinheimann at gmail.com> wrote:
>> Dear Ana, dear all, 
>> the layout you used does not correspond to our nets. I tried the 
>>    GSN-HydroCel-128.sfp  and the GSN-HydroCel-129.sfp. Both don't work. Please can anybody help?
>> Cheers
>> Katrin
>> 
>> 
>> 2014-08-24 5:40 GMT+02:00 Ana Laura Diez Martini <diezmartini at gmail.com>:
>> 
>> Try this one I use
>> 
>> 
>> On Sun, Aug 24, 2014 at 4:08 AM, KatrinH Heimann <katrinheimann at gmail.com> wrote:
>> Dear all, my problems seem neverending. This time however i really need help. 
>> I implemented a pipeline for ERPs. All works now, trialdefinition, preprocessing, channelreplacement, ica, componentrejection, final artifactdetection, timelock of the single subject data. However, when I wanna compute the grandaverage of the single subjects I get the following error message:
>> 
>> computing average of avg over 19 subjects
>> Warning: discarding electrode information because it cannot be averaged 
>> > In ft_timelockgrandaverage at 249 
>> the call to "ft_timelockgrandaverage" took 0 seconds and required the additional allocation of an estimated 3 MB
>> computing average of avg over 2 subjects
>> Warning: discarding electrode information because it cannot be averaged 
>> > In ft_timelockgrandaverage at 249 
>> the call to "ft_timelockgrandaverage" took 0 seconds and required the additional allocation of an estimated 0 MB
>> the call to "ft_prepare_layout" took 0 seconds and required the additional allocation of an estimated 0 MB
>> the call to "ft_topoplotER" took 0 seconds and required the additional allocation of an estimated 0 MB
>> 
>> Furthermore in the plot of the significant clusters, the channelnames are mixed up (do not correspond to my net)
>> 
>> 
>> I guess that there is a problem with the layout I use. 
>> Here the code that I use 
>> 
>> %For generating the layout (also in the single subjects):
>> cfg = [];
>> 
>> cfg.channel  = obs_data.label;
>> 
>> cfg.layout   = 'GSN-HydroCel-129.sfp';
>> 
>> cfg.feedback = 'yes';
>> 
>> lay          = ft_prepare_layout(cfg);
>> 
>>  
>> cfg_neighb          = [];
>> 
>> cfg_neighb.feedback = 'yes';
>> 
>> cfg_neighb.method   = 'triangulation';
>> 
>> cfg_neighb.layout   = lay;
>> 
>> neighbours          = ft_prepare_neighbours(cfg_neighb, obs_data);
>> 
>>  
>> obs_data.elec = ft_read_sens('GSN-HydroCel-129.sfp');
>> 
>> 
>> 
>> %For computing the grand average
>> 
>> cfg = [];
>> 
>> cfg.channel   = 'all';
>> 
>> cfg.latency   = 'all';
>> 
>> cfg.parameter = 'avg';
>> 
>> cfg.keepindividual = 'no'
>> 
>> GA_90         = ft_timelockgrandaverage(cfg,all90{:});  
>> 
>> GA_180        = ft_timelockgrandaverage(cfg,all180{:});
>> 
>> % "{:}" means to use data from all elements of the variable
>> 
>>  
>> For plotting the significant clusters
>> 
>> cfg = [];
>> 
>> cfg.style     = 'blank';
>> 
>> cfg.layout    = lay;
>> 
>> cfg.channellabels = 'yes';
>> 
>> cfg.highlight = 'labels';
>> 
>> cfg.highlightchannel = find(stat.mask);
>> 
>> cfg.comment   = 'no';
>> 
>> figure; ft_topoplotER(cfg, GA_90)
>> 
>> title('Nonparametric: significant with cluster multiple comparison correction')
>> 
>> 
>> 
>> Do you have ANY idea to this? I am really completely helpless....
>> 
>> thanks and best
>> 
>> Katrin
>> 
>> 
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>> 
>> 
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>> 
>> 
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>> 
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> 
> --------------------------------------------------------------------------------
> 
> Joseph Dien, PhD
> Research Associate
> Cognitive Neurology
> The Johns Hopkins University School of Medicine
> 
> Lab E-mail: jdien1 at jhmi.edu
> Private E-mail: jdien07 at mac.com
> Office Phone: 410-614-3115
> Cell Phone: 202-297-8117
> Fax: 410-955-0188
> http://joedien.com
> 
> 
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> 
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

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

Joseph Dien, PhD
Research Associate
Cognitive Neurology
The Johns Hopkins University School of Medicine

Lab E-mail: jdien1 at jhmi.edu
Private E-mail: jdien07 at mac.com
Office Phone: 410-614-3115
Cell Phone: 202-297-8117
Fax: 410-955-0188
http://joedien.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20140908/81922ad2/attachment-0002.html>


More information about the fieldtrip mailing list