Back to the main page.

Bug 3120 - ft_apply_montage breaks on different trial-lengths

Status CLOSED FIXED
Reported 2016-05-04 13:17:00 +0200
Modified 2016-06-14 16:14:53 +0200
Product: FieldTrip
Component: forward
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Stephen Whitmarsh - 2016-05-04 13:17:29 +0200

Hi there, The last commit (https://github.com/fieldtrip/fieldtrip/commit/20e645fb7068b429a2c2f001a4787e3ac7c02016) added a check for NaNs. However, the use of a 'cat' supposes similar trial lengths, therefor breaking when this is not the case: ****************** Error using cat Dimensions of matrices being concatenated are not consistent. Error in ft_apply_montage (line 245) tmp = cat(1, data_unused.trial{:}); Error in ft_rejectcomponent (line 185) data = ft_apply_montage(data, montage, 'keepunused', keepunused, 'feedback', cfg.feedback); ****************** I think a solution could be to replace line 245&246: tmp = cat(1, data_unused.trial{:}); if any(isnan(tmp(:))) simply with: any(isnan([data_unused.trial{:}])); This works for me. Cheers, Stephen


Robert Oostenveld - 2016-05-04 13:46:31 +0200

The "cat" by eelke is along the wrong direction, it should be along dimension 2. That is also what you are doing it with the []. I am worried about the memory impact of either solution. A copy of the data is made and for large data that is inefficient. I have changed it into % use an anonymous function to test for the presence of NaNs in the input data hasnan = @(x) any(isnan(x(:))); if any(cellfun(hasnan, data_unused.trial)) ... end mac011> git commit fileio/private/ft_apply_montage.m [master b1d9fbc] FIX - see http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3120 1 file changed, 3 insertions(+), 2 deletions(-)


Robert Oostenveld - 2016-06-14 16:14:53 +0200

Hereby I am closing multiple bugs that have been resolved for some time now. If you don't agree to the resolution, please reopen.