Back to the main page.

Bug 2789 - ft_checkdata fails in ft_sourceanalysis for TFR with nfreq=1 and ntime=2

Reported 2014-12-19 17:21:00 +0100
Modified 2018-11-12 10:55:31 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P5 normal
Assigned to: Jan-Mathijs Schoffelen
Depends on:
See also:

Robert Oostenveld - 2014-12-19 17:21:09 +0100

on line 1249 it fails, because fn{ii} = 'chancmb', so it tries to convert chancmb as if it were data. I have stored the data and will upload it later to reproduce and fix. ----------------------------------------------------------------------- An error was detected while executing ft_sourceanalysis Saving debug information to /private/tmp/ft_sourceanalysis_20141219T171926.mat ----------------------------------------------------------------------- PS did you know that storing the data+cfg that causes an error is as easy as specifying cfg.debug='saveonerror'?

Robert Oostenveld - 2014-12-22 10:39:53 +0100

I copied the test data to /home/common/matlab/fieldtrip/data/test/bug2789.mat

Robert Oostenveld - 2014-12-22 10:48:00 +0100

>> data data = label: {102x1 cell} dimord: 'chan_freq_time' freq: 32.2896 time: [-0.1000 0.1600] powspctrm: [102x1x2 double] labelcmb: {5151x2 cell} crsspctrm: [5151x1x2 double] elec: [1x1 struct] grad: [1x1 struct] cfg: [1x1 struct] >> ft_sourceanalysis(cfg, data); the input is freq data with 102 channels, 1 frequencybins and 2 timebins The following error occurred converting from cell to double: Error using double Conversion to double from cell is not possible. Error in ft_checkdata>fixcsd (line 1249) tmpdat(indx) = reshape(data.(fn{ii})(j,cmbindx(indx),m,k),[numel(indx) 1]); Error in ft_checkdata (line 791) data = fixcsd(data, cmbrepresentation, channelcmb); Error in ft_checkdata>fixcsd (line 1353) data = ft_checkdata(data, 'cmbrepresentation', 'full'); Error in ft_checkdata (line 791) data = fixcsd(data, cmbrepresentation, channelcmb); Error in ft_sourceanalysis (line 249) data = ft_checkdata(data, 'cmbrepresentation', 'full');

Robert Oostenveld - 2014-12-22 12:47:49 +0100

(In reply to Robert Oostenveld from comment #1) mac011> svn commit test/test_bug2789.m Adding test/test_bug2789.m Transmitting file data . Committed revision 10061.

Jim Herring - 2015-06-30 17:45:44 +0200

I've just noticed the same error for nfreq == 2, and ntime == 1. It seems that 'labelcmb' is deleted after these lines of code anyway so I moved the lines that delete this field a bit forward to prevent this error from happening. Let's see if the testscript starts working now.

Jim Herring - 2015-06-30 17:54:06 +0200

Sending utilities/ft_checkdata.m Transmitting file data . Committed revision 10496. This seems to fix the bug of ft_checkdata seeing labelcmb as a data field but now another bug pops up for this test script. For some reason if there is only one frequency, data.freq = NaN. This also seems to be an issue with ft_checkdata

Jim Herring - 2015-06-30 20:44:22 +0200

I found the culprit: ft_selectdata uses nans to indicate no sub-selection needs to be made (i.e. output=input). However, one line of code which is intended to update the freq field after a selection replaces data.freq with the selected frequency (nan in case of no sub-selection). This happens when you specify the exact frequencies you wish to select, which automatically happens when you only have one frequency: lines 1048-1053: for k = 1:ndata if isequal(freqindx{k}, 1:length(varargin{k}.freq)) % the cfg was updated, but no selection is needed for the data freqindx{k} = nan; end end I changed the following line to check for nans. This should fix the problem if fieldhasfreq && ~isnan(selfreq{i}), varargin{i}.freq = selfreq{i}; end;'s password: Sending utilities/ft_selectdata.m Transmitting file data . Committed revision 10498.

Jim Herring - 2015-06-30 21:17:05 +0200

Disregard the last comment. I added the buggy lines causing the last problem as an ad-hoc fix to the first problem (in my personal copy). I then forgot I added those lines. I've removed them and ft_selectdata works fine after only solving the first issue ;)

Jan-Mathijs Schoffelen - 2016-02-19 11:55:04 +0100

is this still an issue?

Jan-Mathijs Schoffelen - 2018-03-10 21:52:21 +0100

Due to lack of activity from the assignee, taking over and closing, assuming fixed

Jan-Mathijs Schoffelen - 2018-11-12 10:55:31 +0100

closing time.