Back to the main page.

Bug 1341 - trialfun_general an be made more robust

Status CLOSED DUPLICATE
Reported 2012-02-23 09:32:00 +0100
Modified 2019-08-10 11:55:56 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P3 normal
Assigned to:
URL:
Tags:
Depends on:
Blocks:
See also:

Jan-Mathijs Schoffelen - 2012-02-23 09:32:44 +0100

Repeatedly, people report problems when running the tutorials. They specify cfg.dataset = 'Subject01.ds', then enter the Subject01.ds directory, and get an error in trialfun_general (which is not immediately leading to the cause of the problem (see below)). The obvious reason is that they are in the wrong directory (-> should we consider making this more robust????), but the direct cause is a crash in trialfun_general, that assumes at some point the event-structure being a proper structure, rather than being empty (when a reading failure such as above occurs). I see a few solutions (possibly not mutually exclusive): 1 make the path issue for .ds datasets more robust (other parts of the code may also benefit) 2 throw an error in trialfun_general when event-reading fails (and when it is needed according to the cfg) 3 check for isempty(event) in trialfun_general before treating it as a structure cfg = []; % empty configuration cfg.dataset = 'Subject01.ds'; % name of CTF dataset cfg.trialdef.eventtype = 'backpanel trigger'; cfg.trialdef.prestim = 1; cfg.trialdef.poststim = 2; cfg.trialdef.eventvalue = 3; % event value of FIC cfg = ft_definetrial(cfg); Warning: no trialfun was specified, using trialfun_general > In ft_definetrial at 123 evaluating trialfunction 'trialfun_general' Warning: adding /Users/jessamynorton-ford/Documents/MATLAB/fieldtrip-20120222/external/ctf toolbox to your Matlab path readCTFds: Data set error : size of meg4 file(s) 0 bytes (from dir command) 179071200 bytes (from res4 file) reading the events from 'Subject01.ds/Subject01.res4' readCTFds: Data set error : size of meg4 file(s) 0 bytes (from dir command) 179071200 bytes (from res4 file) ??? Attempt to reference field of non-structure array. Error in ==> trialfun_general at 118 sel = ismember({event.type}, cfg.trialdef.eventtype); Error in ==> ft_definetrial at 166 [trl, event] = feval(cfg.trialfun, cfg);


Jan-Mathijs Schoffelen - 2012-02-24 09:07:33 +0100

To make it more robust, one could probably do something like this: % check whether the dataset is somewhere on the path x = which(cfg.dataset); cfg.dataset = x; (I just type this without having actually tried it).


Roemer van der Meij - 2012-05-16 13:47:52 +0200

duplicate of ... *** This bug has been marked as a duplicate of bug 1471 ***


Robert Oostenveld - 2019-08-10 11:52:00 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue describing the issue on https://github.com/fieldtrip/fieldtrip/issues.


Robert Oostenveld - 2019-08-10 11:55:56 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue describing the issue on https://github.com/fieldtrip/fieldtrip/issues.