Back to the main page.

Bug 1800 - ft_topoplotER does not map correctly channels in data to channels in topoplot

Status CLOSED INVALID
Reported 2012-10-30 14:42:00 +0100
Modified 2014-03-12 12:21:35 +0100
Product: FieldTrip
Component: plotting
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P3 normal
Assigned to: Jörn M. Horschig
URL:
Tags:
Depends on:
Blocks:
See also:

Giorgos Michalareas - 2012-10-30 14:42:12 +0100

Created attachment 358 mat file containing variable 'tmpavg1' which is the timelocked data. I have tried to plot the topology of erf data, resulted from ft_timelockanalysis, with ft_topoplotER of the latest FT(fieldtrip-20121029.zip). The data spans from roughly -4 to 4 sec. When the entire time of the data is used for the plot then the ft_topoplotER does not seem to perform any matching between the data channels and the layout channels and it seems to assume that the are already matched. This results in a wrong topology plot. If a subset of the time is selected thorough cfg.xlim then the plot seems ok. However if cfg.xlim is equal or higher than the time interval in the data then the same probem occures. Please find attached a mat file 'bugtopoavg.mat' containing variable 'tmpavg1' which is the timelocked data. Below I have put some code to reproduce the problem in different scenarios: %================================================================== % Add fieltrip-20121029 to the path ft_defaults; load bugtopoavg tmpavg1; % Load the timelocked data tmpavg2=ft_selectdata(tmpavg1,'avgovertime','yes'); % average timelocked data across all time points % Error case - Plot the topoplot for timelocked data cfg=[]; ft_topoplotER(cfg,tmpavg1); % Error case - Plot the topoplot for timelocked data averaged all time points cfg=[]; ft_topoplotER(cfg,tmpavg2); % Error case - Plot the topoplot for timelocked data by setting xlim equal to the time range of the data; cfg=[]; cfg.xlim=[tmpavg1.time(1) tmpavg1.time(end)]; ft_topoplotER(cfg,tmpavg1); % Correct case - Plot the topoplot for timelocked data by setting xlim to a SUBINTERVAL of the time range of the data; cfg=[]; cfg.xlim=[tmpavg1.time(2) tmpavg1.time(end-1)]; ft_topoplotER(cfg,tmpavg1); %==================================================================


Jan-Mathijs Schoffelen - 2012-10-31 13:49:47 +0100

marked as duplicate *** This bug has been marked as a duplicate of bug 1607 ***


Jan-Mathijs Schoffelen - 2012-10-31 13:52:10 +0100

It's not a duplicate. Jorn is going to look at it.


Jörn M. Horschig - 2012-10-31 16:22:44 +0100

hey dude... ehm, strange bug. I checked the layout and channelposition, but that's alright, I checked channelselection, that's alright either. then as a sanity check I also checked whether just one of your samples is crazy and blowing things up, but that's not it also. Plotting from 2:end is fine and plotting from 1:end-1 is also fine. Gonna think about what might be going wrong, atm I'm pretty much stepping in the dark here svn ci test_bug1800* -m "added testscript and data" Adding test_bug1800.m Adding (bin) test_bug1800.mat Transmitting file data .. Committed revision 6841.


Jörn M. Horschig - 2012-11-05 14:49:47 +0100

Created attachment 359 first and second half of giorgos data - they cancel out Hey Giorgos, I present: "demystifying your data" Let me start off with my guess: Nothing is wrong with FieldTrip. Your data is just noise ;) Let me explain: I attached a figure in which I use a low-level matlab function that is indeed used by FieldTrip to plot your data. I essence it's a topographic map of your data, just without the fancy head shape, nose and ears. I plotted the first half of your datasamples and the last half of your data. It's pretty easy to spot that they are the more-or-less exact reverse from one another. Thus, if leaving out only one sample from either half, you end up with basically plotting the inverse of this one sample. If you plot all your data, all your samples exactly cancel out and you are left with some measurement noise. Here's the steps I did to get there: 1) put a break point in ft_topoplotTFR at line 694. 2) Define the first and second half of your experiment: dat = data.(cfg.parameter); dat_half_1 = nanmean(dat(:, 1:993), 2); % you got 1987 samples dat_half_2 = nanmean(dat(:, 994:1987), 2); 3) plot contours: hlim = [min(chanX) max(chanX)]; vlim = [min(chanY) max(chanY)]; xi = linspace(hlim(1), hlim(2), 67); yi = linspace(vlim(1), vlim(2), 67); figure; subplot(211) [Xi,Yi,Zi] = griddata(chanX', chanY, dat_half_1, xi', yi, 'nearest'); contourf(Xi,Yi,Zi); subplot(212) [Xi,Yi,Zi] = griddata(chanX', chanY, dat_half_2, xi', yi, 'nearest'); contourf(Xi,Yi,Zi); So, after analyzing your data for you, co-author on paper? :P tbh: pretty unlikely that data cancels out exactly, so I guess you are doing some crazy step in your analysis pipeline? The funny thing is, it does not matter at all *where* I split the data into two parts. Even if I do: dat_half_1 = nanmean(dat(:, 1), 2); dat_half_2 = nanmean(dat(:, 2:1987), 2); they are the reverse of each other. Since I did not use any FieldTrip here in this code (apart from determining the layout, but that's fine), it cannot be a FieldTrip error.


Jörn M. Horschig - 2012-11-05 14:50:36 +0100

if you think I'm wrong, let me know! but thanks for the riddle, was much fun