Back to the main page.

Bug 3259 - ft_headmovement passes empty array to kmeans and crashes

Status NEW
Reported 2017-02-27 17:34:00 +0100
Modified 2017-03-06 13:16:07 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to: Sebastian
URL:
Tags:
Depends on:
Blocks:
See also:

Sebastian - 2017-02-27 17:34:28 +0100

Calling ft_headmovement crashes. % code cfg = []; cfg.dataset = filenames{1}; cfg.trl = trl_used; [grad_adj] = ft_headmovement(cfg); >> output processing channel { 'HLC0011' 'HLC0012' 'HLC0013' 'HLC0021' 'HLC0022' 'HLC0023' 'HLC0031' 'HLC0032' 'HLC0033' } reading and preprocessing reading and preprocessing trial 687 from 687 the call to "ft_preprocessing" took 58 seconds and required the additional allocation of an estimated 14 MB >> error Error using kmeans (line 262) X must have more rows than the number of clusters. Error in ft_headmovement (line 125) [bin, cluster] = kmeans(dat', cfg.numclusters); -------------------------------------------------------------------------- Probably caused by the check for number of unique positions in line 101: wtmpdat(1,m) = sum(sum(tmpdat-utmpdat(:,m)*ones(1,size(tmpdat,2))==0,1)==9); together with discarding all positions that are not present at least 100 times in the data line 108: dat(:, wdat<100) = []; leading to an empty dat passed to kmeans in line 125 [bin, cluster] = kmeans(dat', cfg.numclusters);


Jan-Mathijs Schoffelen - 2017-03-01 09:47:38 +0100

what's your suggested fix to address this?


Sebastian - 2017-03-01 17:42:18 +0100

a simple fix would be to replace line 95-109 with: dat = []; for k = 1:length(data.trial) dat = [dat data.trial{k}]; end


Jan-Mathijs Schoffelen - 2017-03-02 09:39:50 +0100

Feel free to contribute this fix in a pull request, as instructed in: http://www.fieldtriptoolbox.org/development/git Once this is in place, we will review it and if appropriate merge the fix into the main branch of the code. Thanks.


Sebastian - 2017-03-06 13:16:07 +0100

ok this should work now. best, Sebastian