Back to the main page.

Bug 1262 - Problem reading fcdc_buffer_offline filetypes (version 20111231)

Status CLOSED FIXED
Reported 2012-01-16 17:20:00 +0100
Modified 2015-05-04 13:42:31 +0200
Product: FieldTrip
Component: fileio
Version: unspecified
Hardware: Macintosh
Operating System: Mac OS
Importance: P2 major
Assigned to: Boris Reuderink
URL:
Tags:
Depends on:
Blocks: 2888
See also:

Rutger Vlek - 2012-01-16 17:20:41 +0100

The following problem occurred while attempting to slice data from a dataset in fcdc_buffer_offline format (in FieldTrip version 20111231): -------------------------------------- Error in ==> utilities/private/dataset2files at 13 if isempty(format) ??? Output argument "datafile" (and maybe others) not assigned during call to "/Users/rutger/source/fieldtrip-20111231/utilities/private/dataset2files.m>dataset2files". Error in ==> ft_checkconfig at 466 [cfg.dataset, cfg.headerfile, cfg.datafile] = dataset2files(cfg.dataset, []); Error in ==> ft_definetrial at 116 cfg = ft_checkconfig(cfg, 'dataset2files', {'yes'}); -------------------------------------- This seems related to the fact that the fcdc_buffer_offline format uses a directory rather than a file to indicate location of the dataset, and the problem is complicated even more by using files without extension for header, samples and events. The representation of this slightly complicated data format appeared inconsistent over various functions related to file reading (ft_read_event.m, dataset2files.m, ft_filetype.m). I managed to solve the problem with the following changes (all fixes replace previous code): ------------------ft_read_event.m --- lines.849 to 856---------- case 'fcdc_buffer_offline' [path, file, ext] = fileparts(filename); if isempty(hdr) headerfile = fullfile(path, 'header'); % Rutger's fix hdr = read_buffer_offline_header(headerfile); end eventfile = fullfile(path, 'events'); % Rutger's fix event = read_buffer_offline_events(eventfile, hdr); ----dataset2files.m (both in fileio and utilities) --- lines.106 to 109-------- case 'fcdc_buffer_offline' [path, file, ext] = fileparts(filename); headerfile = fullfile(path, 'header'); %Rutger's fix datafile = fullfile(path, 'samples'); %Rutger's fix ------------------ft_filetype --- lines.576 to 579---------- elseif isdir(p) && exist(fullfile(p, 'header'), 'file') && exist(fullfile(p, 'events'), 'file') %Rutger's fix type = 'fcdc_buffer_offline'; manufacturer = 'Donders Centre for Cognitive Neuroimaging'; content = 'FieldTrip buffer offline dataset';


Rutger Vlek - 2012-01-16 17:21:50 +0100

Can someone from the FieldTrip development team check and incorporate these fixes in a fature release?


Rutger Vlek - 2012-01-16 17:22:15 +0100

(In reply to comment #1) future I mean :)


Rutger Vlek - 2012-01-16 18:29:41 +0100

(In reply to comment #2) Additionally, I discovered a bug in read_buffer_offline_header.m, resulting in the following error: -------------------------------------- ??? Error using ==> read_buffer_offline_header at 96 Invalid channel name definition - broken header file? Error in ==> ft_read_header at 925 [hdr, nameFlag] = read_buffer_offline_header(headerfile); Error in ==> trialfun_rtpp at 10 hdr = ft_read_header(cfg.headerfile); Error in ==> ft_definetrial at 166 [trl, event] = feval(cfg.trialfun, cfg); -------------------------------------- It can be fixed this way: ------------------ft_read_event.m --- lines.89 to 98---------- if numel(indCol)>=1 ind = str2num(s(1:(indCol-1))); %Rutger's fix name = s((indCol+1):end); %Rutger's fix if ~isempty(ind) && ind>=1 && ind<=hdr.nChans hdr.label{ind} = name; nameFlag = 2; else error('Invalid channel name definition - broken header file?'); end end


Boris Reuderink - 2012-03-28 10:27:09 +0200

Hi Rutger, this seems like a useful patch. I tried to copy your changes, but I got a bit confused during the patching of ft_filetype.m, since it appears to have been changed in the meanwhile. Would it be possible for you to use the latest SVN version, and 1) modify the files to implement this fix, and 2) send me the version you used, and the output of "svn diff"? That would enable me to quickly integrate your changes.


Boris Reuderink - 2012-04-11 15:21:44 +0200

Got the changed code by email. Patch is below, waiting for test data to create script. -- --- a/fileio/ft_filetype.m +++ b/fileio/ft_filetype.m @@ -580,7 +580,7 @@ elseif isdir(filename) && most(filetype_check_extension({ls.name}, '.nte')) manufacturer = 'Neuralynx'; content = 'spike timestamps'; -elseif isdir(filename) && exist(fullfile(filename, 'header'), 'file') && exist(fullfile(filename, 'events'), 'file') +elseif isdir(p) && exist(fullfile(p, 'header'), 'file') && exist(fullfile(p, 'events'), 'file') type = 'fcdc_buffer_offline'; manufacturer = 'Donders Centre for Cognitive Neuroimaging'; content = 'FieldTrip buffer offline dataset'; --


Boris Reuderink - 2012-05-07 12:50:26 +0200

Created attachment 263 Generated (noisy) sines and saved with record.exe.


Boris Reuderink - 2012-05-23 12:59:48 +0200

Fixed in SVN revision 5750. Test was added in SVN rev. 5749. Closed.


Boris Reuderink - 2012-06-20 15:03:23 +0200

Changed my resolved bugs to closed.