Back to the main page.

Bug 3118 - ft_artifact_zvalue give an error with button press using mouse but keyboard works fine

Status CLOSED FIXED
Reported 2016-04-28 15:11:00 +0200
Modified 2016-06-17 15:56:33 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to: Jan-Mathijs Schoffelen
URL:
Tags:
Depends on: 285628572936
Blocks:
See also:

Weiyong Xu - 2016-04-28 15:11:07 +0200

Hi, The ft_artifact_zvalue function gives an error whenever button press using mouse. I am using matlab2014a in windows7. the error looks like: Attempt to reference field of non-structure array. Error in ft_artifact_zvalue>keyboard_cb (line 710) curKey=eventdata.Key; Error using waitfor Error while evaluating uicontrol Callback Attempt to reference field of non-structure array. Error in ft_artifact_zvalue>keyboard_cb (line 710) curKey=eventdata.Key; Error using waitfor Error while evaluating uicontrol Callback


Robert Oostenveld - 2016-04-28 16:17:26 +0200

what is the cfg structure that you are giving as input to the function?


Weiyong Xu - 2016-04-28 20:13:50 +0200

The cfg structure is copied from tutorial: % jump cfg = []; cfg.trl = trl; cfg.datafile = my_file; cfg.headerfile = my_file; cfg.continuous = 'yes'; % channel selection, cutoff and padding cfg.artfctdef.zvalue.channel = my_channel; cfg.artfctdef.zvalue.cutoff = 20; cfg.artfctdef.zvalue.trlpadding = -0.2; cfg.artfctdef.zvalue.fltpadding = 0.2; cfg.artfctdef.zvalue.artpadding = 0; % algorithmic parameters cfg.artfctdef.zvalue.cumulative = 'yes'; cfg.artfctdef.zvalue.medianfilter = 'yes'; cfg.artfctdef.zvalue.medianfiltord = 9; cfg.artfctdef.zvalue.absdiff = 'yes'; % make the process interactive cfg.artfctdef.zvalue.interactive = 'yes'; [cfg, artifact_jump] = ft_artifact_zvalue(cfg);


Jan-Mathijs Schoffelen - 2016-05-11 10:42:41 +0200

I ran into this as well. ANNOYING!!!! It seems the problem is the following lines in ft_artifact_zvalue if isa(eventdata,'matlab.ui.eventdata.ActionData') % only the case when clicked with mouse % determine the key that corresponds to the uicontrol element that was activated tmpKey = get(h, 'userdata'); h = getparent(h); % otherwise h is empty if isa [...].ActionData end In particular, the if statement does not return 'true' when expected to do so (i.e. on a mouse click). Commenting out the if-end fixes it for the mouse clicks. I checked on matlab2013b and matlab2012b, so it's not tied to a specific matlab version


Jan-Mathijs Schoffelen - 2016-05-11 10:53:28 +0200

I found this in change in the history, which clearly doesn't work for me. I don't understand why nobody has complained, because this seems to have been introduced one year ago. https://github.com/fieldtrip/fieldtrip/commit/9016bd7405e72f403d81ac0c992d7b3f3b2df35e


Jan-Mathijs Schoffelen - 2016-05-11 11:51:32 +0200

I have implemented a fix and 'pull requested' it. Pending Robert's approval... :o)


Robert Oostenveld - 2016-05-11 13:20:29 +0200

(In reply to Jan-Mathijs Schoffelen from comment #5) I tried this in 2015b and 2012b and it worked fine. I also reviewed the code, looks good to me. I will merge. ---- % jump cfg = []; cfg.dataset = 'Subject01.ds'; cfg = ft_definetrial(cfg); %% cfg.continuous = 'yes'; % channel selection, cutoff and padding cfg.artfctdef.zvalue.channel = 'MEG'; cfg.artfctdef.zvalue.cutoff = 20; cfg.artfctdef.zvalue.trlpadding = -0.2; cfg.artfctdef.zvalue.fltpadding = 0.2; cfg.artfctdef.zvalue.artpadding = 0; % algorithmic parameters cfg.artfctdef.zvalue.cumulative = 'yes'; cfg.artfctdef.zvalue.medianfilter = 'yes'; cfg.artfctdef.zvalue.medianfiltord = 9; cfg.artfctdef.zvalue.absdiff = 'yes'; % make the process interactive cfg.artfctdef.zvalue.interactive = 'yes'; [cfg, artifact_jump] = ft_artifact_zvalue(cfg);


Robert Oostenveld - 2016-05-11 13:21:05 +0200

(In reply to Robert Oostenveld from comment #6) I have merged https://github.com/fieldtrip/fieldtrip/pull/152 into the master thanks Robert