Back to the main page.

Bug 718 - ft_apply_montage of ft_megplanar causes ft_topoplotTFR problems after ft_rejectcomponent

Status CLOSED FIXED
Reported 2011-05-31 17:48:00 +0200
Modified 2011-07-13 14:22:22 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P1 normal
Assigned to: Jan-Mathijs Schoffelen
URL:
Tags:
Depends on:
Blocks:
See also:

Diego Lozano Soldevilla - 2011-05-31 17:48:00 +0200

After rejection of ICs by means of ft_rejectcomponent, I get topoplotTFR display problems (it appears the electrodes and the topo scalp but without frequency information). Importantly is that this problem doesn't appear with ft_multiplotTFR. Lines 112-121 of ft_apply_montage seems to cause the problem. Specifically, without rejecting ICs, the sens.label and montage.labelorg have different channels and this extra channels (28) seem to be important for topoploting. Rejecting ICs, this extra channels not appear in megplanar calculations and latter appear the topoplot problems.


Diego Lozano Soldevilla - 2011-05-31 17:48:35 +0200

Created attachment 60 data example


Jan-Mathijs Schoffelen - 2011-06-24 15:52:05 +0200

Created attachment 77 data causing problems in channelposition


Jan-Mathijs Schoffelen - 2011-06-24 15:59:56 +0200

Created attachment 78 yet other data causing problems in channelposition


Jan-Mathijs Schoffelen - 2011-07-07 11:01:50 +0200

Hi Diego, I think I solved it. I had to make a few changes to ft_componentanalysis and ft_rejectcomponent, among others. If I repeat the steps you take (i.e. ft_denoise_synthetic, ft_componentanalysis, ft_rejectcomponent, ft_megplanar, ft_combineplanar) all seems fine in terms of reconstructed sensor positions (which would mean no nans anymore). Unfortunately, you need to go back quite a few levels in your analysis pipeline to validate this. I would appreciate it if you coulr validate my changes with the 2 datasets which did not work for you. Could you let me know whether it works again? Thanks JM PS1: I am about to commit the changes, they will be available in about 20 minutes on /home/common/ PS2: You can always still work with the 'bad' data by replacing the data.grad with the original one, prior to calling ft_megplanar.


Jan-Mathijs Schoffelen - 2011-07-08 14:55:58 +0200

Created attachment 89 test data.grad


Jan-Mathijs Schoffelen - 2011-07-08 14:58:02 +0200

Created attachment 90 test data.grad


Jan-Mathijs Schoffelen - 2011-07-08 14:59:16 +0200

(In reply to comment #4) > Hi Diego, > > I think I solved it. I had to make a few changes to ft_componentanalysis and > ft_rejectcomponent, among others. If I repeat the steps you take (i.e. > ft_denoise_synthetic, ft_componentanalysis, ft_rejectcomponent, ft_megplanar, > ft_combineplanar) all seems fine in terms of reconstructed sensor positions > (which would mean no nans anymore). > Unfortunately, you need to go back quite a few levels in your analysis pipeline > to validate this. I would appreciate it if you coulr validate my changes with > the 2 datasets which did not work for you. Could you let me know whether it > works again? Thanks > > JM > > PS1: I am about to commit the changes, they will be available in about 20 > minutes on /home/common/ > PS2: You can always still work with the 'bad' data by replacing the data.grad > with the original one, prior to calling ft_megplanar. Hi Jan-Mathijs, I re-did my analysis from the very begining (ft_preprocessing-> ft_componentanalysis -> ft_rejectcomponent -> ft_rejectartifact -> ft_megplanar) and when the planar calculation I get this error: %planar calculation cfg = []; cfg.planarmethod = 'sincos'; cfg.channel = {'MEG'}; cfg.trials = 'all'; meg = ft_megplanar(cfg, meg); the input is raw data with 274 channels and 370 trials undoing the invcomp balancing Warning: the linear projection for the montage is not full-rank, the resulting data will have reduced dimensionality > In ft_apply_montage at 76 In fieldtrip/private/undobalancing at 29 In fieldtrip/private/channelposition at 31 In fieldtrip/private/megplanar_sincos at 26 In ft_megplanar at 171 undoing the comp balancing Warning: the linear projection for the montage is not full-rank, the resulting data will have reduced dimensionality > In ft_apply_montage at 76 In fieldtrip/private/undobalancing at 29 In fieldtrip/private/channelposition at 31 In fieldtrip/private/megplanar_sincos at 26 In ft_megplanar at 171 ??? Error using ==> ft_apply_montage at 133 not all output channels of the montage are unique Error in ==> undobalancing at 29 sens = ft_apply_montage(sens, sens.balance.(sens.balance.current), 'inverse', 'yes', 'keepunused', 'yes'); Error in ==> channelposition at 31 sens = undobalancing(sens); Error in ==> megplanar_sincos at 26 [pnt, ori, lab] = channelposition(grad); Error in ==> ft_megplanar at 171 montage = megplanar_sincos(cfg, data.grad); In ft_apply_montage at 133 seems to be a matrix dimension problem in the grad.tra structure but I can't figure out why. I attach you my grad matrix.


Jan-Mathijs Schoffelen - 2011-07-12 14:41:06 +0200

Hi Jan-Mathijs, Last week Stephen told me that both you solve similar sensor problem. I re-do again the whole analysis for one of my problematic subjects and I get this error: meg = ft_megplanar(cfg, meg); the input is raw data with 274 channels and 388 trials undoing the invcomp balancing Warning: the linear projection for the montage is not full-rank, the resulting data will have reduced dimensionality > In ft_apply_montage at 76 In fieldtrip/private/undobalancing at 29 In fieldtrip/private/channelposition at 31 In ft_megplanar at 243 undoing the comp balancing Warning: the linear projection for the montage is not full-rank, the resulting data will have reduced dimensionality > In ft_apply_montage at 76 In fieldtrip/private/undobalancing at 29 In fieldtrip/private/channelposition at 31 In ft_megplanar at 243 ??? Error using ==> ft_apply_montage at 133 not all output channels of the montage are unique Error in ==> undobalancing at 29 sens = ft_apply_montage(sens, sens.balance.(sens.balance.current), 'inverse', 'yes', 'keepunused', 'yes'); Error in ==> channelposition at 31 sens = undobalancing(sens); Error in ==> ft_megplanar at 243 [sens.pnt, sens.ori, sens.label] = channelposition(data.grad); I saw your changes in the ft_megplanar code but the error that I get is because the same reason than in my previous reply: seems to be a matrix dimension problem in the grad.tra structure but I don't know what is the size that this matrix has to have because I get the same error running my code in the unique participant who I never had any problem until now! Importantly, on grad.tra I'm not getting NaNs anymore. You can find the data on one of my problematic subjects in the temporary folder with my pipeline (/home/common/temporary/4Jan-Mathijs). I save the data after epoching (megdata_epochs.mat), after ica rejection (megdata_icrejected.mat) and before planar transformation bug (megdata_planar_bug.mat). I hope this will be informative for you. Diego (In reply to comment #7) > (In reply to comment #4) > > Hi Diego, > > > > I think I solved it. I had to make a few changes to ft_componentanalysis and > > ft_rejectcomponent, among others. If I repeat the steps you take (i.e. > > ft_denoise_synthetic, ft_componentanalysis, ft_rejectcomponent, ft_megplanar, > > ft_combineplanar) all seems fine in terms of reconstructed sensor positions > > (which would mean no nans anymore). > > Unfortunately, you need to go back quite a few levels in your analysis pipeline > > to validate this. I would appreciate it if you coulr validate my changes with > > the 2 datasets which did not work for you. Could you let me know whether it > > works again? Thanks > > > > JM > > > > PS1: I am about to commit the changes, they will be available in about 20 > > minutes on /home/common/ > > PS2: You can always still work with the 'bad' data by replacing the data.grad > > with the original one, prior to calling ft_megplanar. > > Hi Jan-Mathijs, > > I re-did my analysis from the very begining (ft_preprocessing-> > ft_componentanalysis -> ft_rejectcomponent -> ft_rejectartifact -> > ft_megplanar) and when the planar calculation I get this error: > > > %planar calculation > cfg = []; > cfg.planarmethod = 'sincos'; > cfg.channel = {'MEG'}; > cfg.trials = 'all'; > meg = ft_megplanar(cfg, meg); > the input is raw data with 274 channels and 370 trials > undoing the invcomp balancing > Warning: the linear projection for the montage is not full-rank, the resulting > data will have reduced dimensionality > > In ft_apply_montage at 76 > In fieldtrip/private/undobalancing at 29 > In fieldtrip/private/channelposition at 31 > In fieldtrip/private/megplanar_sincos at 26 > In ft_megplanar at 171 > undoing the comp balancing > Warning: the linear projection for the montage is not full-rank, the resulting > data will have reduced dimensionality > > In ft_apply_montage at 76 > In fieldtrip/private/undobalancing at 29 > In fieldtrip/private/channelposition at 31 > In fieldtrip/private/megplanar_sincos at 26 > In ft_megplanar at 171 > ??? Error using ==> ft_apply_montage at 133 > not all output channels of the montage are unique > > Error in ==> undobalancing at 29 > sens = ft_apply_montage(sens, sens.balance.(sens.balance.current), > 'inverse', 'yes', 'keepunused', 'yes'); > > Error in ==> channelposition at 31 > sens = undobalancing(sens); > > Error in ==> megplanar_sincos at 26 > [pnt, ori, lab] = channelposition(grad); > > Error in ==> ft_megplanar at 171 > montage = megplanar_sincos(cfg, data.grad); > > > > In ft_apply_montage at 133 seems to be a matrix dimension problem in the > grad.tra structure but I can't figure out why. > > I attach you my grad matrix.