[FieldTrip] ft_preprocessing error

Ty McKinney ty.mckinney.412 at gmail.com
Fri May 19 18:16:15 CEST 2017


Hi, I am having some trouble getting the ft_preprocessing function to work.

The ft_definetrial function works and gives the trl matrix in the cfg
output.

As best as I can tell the read data function is returning a matrix that is
smaller than the dimensions of the event sample indexes (by several orders
of magnitude) from the read event function. I confirmed with EEG lab's
loading function that the data matrix is thee same size.

What is odd is that this script was working several weeks ago...

I get this error:
Error using ft_read_data (line 221)
cannot read data after the end of the file

Error in ft_preprocessing (line 576)
      dat = ft_read_data(cfg.datafile, 'header', hdr, 'begsample',
begsample, 'endsample', endsample, 'chanindx', rawindx,
      'checkboundary', strcmp(cfg.continuous, 'no'), 'dataformat',
cfg.dataformat)

Posted below is my code leading up to the execution of the function. Any
and all helps you can give me would be greatly appreciated

%% Set up fieldtrip path
ft_dir = 'C:\Users\Public\Documents\Euler_electrophys (Not backed
up)\EEG_scripts\fieldtrip-master';
addpath(ft_dir);
ft_defaults; % run this line ft needs it
clc

%% Load data

datainfo.origdir = input('Please copy and paste the filepath for the .CNT
file ', 's');
%datainfo.savdir = input('Please copy and paste the filepath for save
directory ', 's');
datainfo.SID = input('Enter the Subject Name, e.g., Hick99 use
lowercase!!', 's');
datainfo.hp = input('Was the data highpass filtered at 0.1Hz? (y/n)', 's');
cd(datainfo.origdir); % cd into the S's directory
wrkdir = pwd;
%go get the scalp maps
% use the line below on MJE's computer upstairs
%chanlocdir = 'C:\Users\u0850304.ADCSBS\Documents\MATLAB\euler_
electrophys\All_purpose_fxs';
% use the line below on the downstairs lab computer
 chanlocdir = 'C:\Users\Public\Documents\Euler_electrophys (Not backed
up)\EEG_scripts\All_purpose_fxs\Waveguard_scalp_coordinates';
cd(chanlocdir);
load WG64_4topoplot.mat
cd(wrkdir);

%find the exact file we need
myfname = dir(strcat(datainfo.SID, '*', 'hick', '*','.cnt')); %Note that
the file needs to end in ft.cnt/ft.trg
exactname = myfname.name;
datainfo.sourcepth = strcat(datainfo.origdir, '\',  exactname); %set file
path for the data

cfg.trialfun='trialfun_Hick_tm2';
cfg.datainfo=datainfo;
cfg.padding=0;
cfg.padtype='data';
cfg.continuous='yes';
cfg.datafile=datainfo.sourcepth;
cfg.headerfile=datainfo.sourcepth;
cfg.dataset=datainfo.sourcepth;
cfg.fsample=512;

cd(cfg.datainfo.origdir);
fileattrib;
savep=ans.Name;
newfolder = strcat(datainfo.SID, '_FT');
mkdir(newfolder); % Create new folder in Current Subject folder for FT
output
cfg.datainfo.savepath = strcat(savep,'\', newfolder); %create save path to
new folder

cfg.hdr   = ft_read_header(cfg.datafile); %things I think fieldtrip needs
according to site
cfg.event = ft_read_event(cfg.datafile);
cfg.data = ft_read_data(cfg.datafile);
%% Define Trial Stuff
% How much time, in seconds, is retained on either side of trigger codes

%cfg.trialdef.eventtype= 'backpanel trigger';
%cfg.trialdef.eventvalue= '55 ';
cfg.trialdef.pre= 1; % in seconds
cfg.trialdef.post= 1; % in seconds

%% read the header (needed for the samping rate) and the events
evtsamps   = [cfg.event.sample]';% for the events of interest, find the
sample numbers (these are integers)
Evtypes    = {cfg.event.value}';% for the events of interest, find the
trigger values (these are strings in the case of BrainVision)

evtsamps=evtsamps(2:end); %Trim off first event that crashes script
Evtypes =Evtypes (2:end);

evtypes=zeros(length(Evtypes),1);
for kk=1:length(evtsamps); %Convert string to numbers
evtypes(kk) = str2double(Evtypes{kk}); %
end

pretrig  = -round(cfg.trialdef.pre  * cfg.hdr.Fs); % pre-stimulus boundary
in samples
posttrig =  round(cfg.trialdef.post * cfg.hdr.Fs); % post-STIMULUS boundary
in samples

%% Trial definition
[cfg]=ft_definetrial(cfg);
data=ft_preprocessing(cfg);




Ty McKinney
Graduate Student-University of Utah
ty.mckinney.412 at gmail.com
385.321.4061
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20170519/7775ecc2/attachment-0001.html>


More information about the fieldtrip mailing list