fieldtrip / website

This contains the content hosted on the FieldTrip website
http://www.fieldtriptoolbox.org
Other
39 stars 103 forks source link

Provide a direct link to actual data for Monkey ECoG Tutorial #164

Open iandol opened 5 years ago

iandol commented 5 years ago

It is not clear which dataset this tutorial is designed to work with:

https://github.com/fieldtrip/website/blob/master/tutorial/monkey_ecog.md

It gives a link to the general ECoG page with data sets from 2 monkeys, and I think the data should be from K2 if you look at the surface map picture name (tutorial/monkey_ecog/k2_1.png). When trying a couple of the K2 monkey datasets I get:

Error using ft_datatype_raw (line 84)
inconsistent number of channels in trial 1

Error in ft_checkdata (line 268)
  data = ft_datatype_raw(data, 'hassampleinfo', hassampleinfo);

Error in ft_redefinetrial (line 117)
data = ft_checkdata(data, 'datatype', {'raw+comp', 'raw'}, 'feedback', cfg.feedback);

Error in vdemo (line 57)
data_1 = ft_redefinetrial(cfg,data);

There is also a data set for this tutorial on the fieldtrip FTP, which does not work with the demo code either. Which data set should be used and I can then edit the link on the tutorial page...

schoffelen commented 5 years ago

Using the data from ftp I cannot reproduce your problem. Note, that the data.mat file already contains the data_1, data_2 etc., so the call to ft_redefinetrial is not necessary.

With respect to which of the datafiles to be used for download, I don't know which one to use. I tried to look into the saved variables data_1 (data_1.cfg.previous etc.) but this is a dead end street.

Sorry I cannot be of help, because I don't know who originally contributed this tutorial, so I don't know where to ask.

iandol commented 5 years ago

Hi Jan, thanks for the feedback. OK, lets ignore the raw data and ft_redefinetrial(cfg,data); We now just assume we will use data.mat — it is not clear to me how to use data_1 etc. found in data.mat.

The first place it is referenced is ft_databrowser(cfg, data_1); — but this gives an error Undefined operator '-' for input arguments of type 'cell'. — for some reason the trial / trl structure is wrapped in a cell array in the original code (ft_redefinetrial expects an Nx3 matrix).

Lets ignore the data browser, I comment out that line and try to replace data with data_1 on subsequent lines — ft_componentanalysis works, as does ft_multiplottrf, but subplot(2,2,1); ft_topoplotTFR(cfg,tfrhfbl); fails further down.

If I can get this all working I will rewrite the tutorial, and I'll work through the errors and update here. It has been quite a while since I last used FT and I apologise in advance for obvious error messages that I can't immediately grok...

robertoostenveld commented 4 years ago

This ain't good, the tutorial should just work (given the right data on the disk of the person running it).

I will add a test script for the tutorial to fieldtrip/test and give it a try...

iandol commented 4 years ago

The original data is this one (matching raw data length of 663270): 2010-07-23 | OLDS1 | Visual Grating | K2

To get the data to load I modified the first part of the tutorial code:

%% -- load events and layout
clear all
load Event.mat
load lay.mat

%% -- we first loop through and load raw data mat files from Neurotycho
vec=1:128;
data.time = {EventTime};
data.fsample = 1000;
for i=1:length(vec)
 filename=strcat('ECoG_ch', num2str(vec(i)));
 data.label{i} = num2str(vec(i));
 load(filename)
 filename2 = strcat('ECoGData_ch', num2str(vec(i)));
 data.trial(i,:) = eval(filename2);
end
data.trial(129,:) = EventData; %put event data into channel 129
data.trial = {double(data.trial)};
data.label = lay.label(1:128);
data.label{129} = 'event';
clear ECoG*

%% -- now we have to use the event triggers to redefine the data into a trial structure
trigger = EventData;
sample  = EventIndex;

% determine the number of samples before and after the trigger
pretrig  = -data.fsample*2;
posttrig =  data.fsample*2;
trls = [];
for i = 1:8
    trl = [];
    % ts is our trigger values taken from readme.txt
    % baseline values span from 300 400
    ts = [650 750;950 1050;1300 1400; ...
        1600 1700; 1950 2050; ...
        2250 2350; 2600 2700;
        2900 3000]; 
    for j = 2:(length(trigger)-2)
      trg1 = trigger(j);
      trg2 = trigger(j+1);
      trg3 = trigger(j+1);
      trg4 = trigger(j-1);
      if trg1 > 400 && trg2 < ts(i,2) && trg3 >= ts(i, 1) && trg4 <= 400
        trlbegin = sample(j) + pretrig;
        trlend   = sample(j) + posttrig;
        offset   = pretrig;
        newtrl   = [trlbegin trlend offset i];
        trl      = [trl; newtrl];
        trls     = [trls; newtrl];
      end
    end
    cfg     = [];
    cfg.trl = trl; fprintf('Loading Orientation Variable %i (%i - %i values)\n',i,ts(i,1),ts(i,2));
    try
        eval(['data_' num2str(i) ' = ft_redefinetrial(cfg,data);'])
    catch ME
        fprintf('Error using ft_redefinetrial: %s\n',ME.message);
        getReport(ME)
    end
end

This generates data_1-8 that can then be used in subsequent sections (i.e. no need for data.mat from the tutorial folder, the data is parsed directly from neurotycho.

If I get some time I'll try to work out what breaks from then on...