Back to the main page.

Bug 1210 - inconsistent number of grad.pnt and grad.labels

Status CLOSED INVALID
Reported 2011-12-01 19:43:00 +0100
Modified 2011-12-06 09:59:40 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P3 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

May - 2011-12-01 19:43:08 +0100

D is a small mat data file with 9 trials derived from 4D data % D = % % hdr: [1x1 struct] % label: {248x1 cell} % time: {1x9 cell} % trial: {1x9 cell} % fsample: 1.0172e+003 % sampleinfo: [9x2 double] % trialinfo: [9x5 double] % grad: [1x1 struct] % cfg: [1x1 struct] % I would like to get D.grad.pnt for say sensor 'A1' BUT there are more D.grad.pnt (N==276) than there are lables (N==271) for them. How should I go about doing this? LabelIdx=find(strcmp(D.grad.label,'A1')) LabelIdx = 186 --> presumably isn't straightforwardly corresponding to D.grad.pnt(186,:) is it? Could someone kindly help? Thank you, may % D.hdr.grad % % ans = % % pnt: [276x3 double] % ori: [276x3 double] % tra: [271x276 double] % label: {271x1 cell} % unit: 'm' % balance: [1x1 struct] % % D.grad % % ans = % % pnt: [276x3 double] % ori: [276x3 double] % tra: [271x276 double] % label: {271x1 cell} % unit: 'm' % balance: [1x1 struct] %% How D was created. % subjNUM=1 % iset=2 % irun=1 % % cd([subj{subjNUM}.runpath{irun}]) % % %% load raw data % cfg = []; % % cfg.subjNUM = subjNUM; % cfg.irun=irun; % % cfg.headerfile = 'c,rfDC'; % cfg.datafile = cfg.headerfile; % cfg.trialfun ='trialfun_general'; % % cfg.channel={'all'}; % need all for denoise_pca later!!! % cfg.channel={'MEG'}; % cfg.continuous='yes'; % cfg.trialdef.eventtype = '?'; % % cfg.trialdef.eventtype = 'RESPONSE'; %'TRIGGER'; % cfg=ft_definetrial(cfg); %--->cfg.events % % cfg.header = ft_read_header(cfg.headerfile) % % cfg2=ft_definetrial(cfg); % % % cfg.continuous='yes'; % cfg.trialdef.eventtype = '?'; % % cfg=ft_definetrial(cfg); %--->cfg.events % % cfg.header = ft_read_header(cfg.headerfile); % % just to be sure % cfg = rmfield(cfg,'trl'); % % % %% specify 'trial' information for 'epoching' % cfg.detrend='yes'; %no other filtering at the moment. % % cfg.trialdef.stimulusSETnum = [iset]; % cfg.trialdef.eventtype = 'PostStimTriggerIdx'; %% % cfg.trialdef.eventinfo = 'PostStimSampleTime'; % cfg.trialdef.eventvalue = [iset].*2 + 128; % % cfg.trialdef.response_time=[1]; % to include RXNtime in the definetrial procedure... % cfg.trialdef.CorrectWrong = [1]; %only correct ones % % cfg.trialdef.prestim = 2; % duration in secs before '0' % cfg.trialdef.poststim = 2; % duration in secs after '0' % % cfg.trialfun ='trialfun_readEventgetRespInfo'; %%CHANGE 3rd Column!!! % % cfg=ft_definetrial(cfg); % % cfg.trl ==//// [begsam endsam off runN stimN ] % % D=ft_preprocessing(cfg);


May - 2011-12-01 19:54:11 +0100

Created attachment 195 inconsistent number of grad_labels for grad_pnt % Not sure if you need the orignal raw data -- it is huge! D is a small mat data file with 9 trials derived from 4D data % D = % % hdr: [1x1 struct] % label: {248x1 cell} % time: {1x9 cell} % trial: {1x9 cell} ----> only 1 trial kept to keep file size small % fsample: 1.0172e+003 % sampleinfo: [9x2 double] % trialinfo: [9x5 double] % grad: [1x1 struct] % cfg: [1x1 struct] ---> REMOVED to keep file size small % I would like to get D.grad.pnt for say sensor 'A1' BUT there are more D.grad.pnt (N==276) than there are lables (N==271) for them. How should I go about doing this? LabelIdx=find(strcmp(D.grad.label,'A1')) LabelIdx = 186 --> presumably isn't straightforwardly corresponding to D.grad.pnt(186,:) is it? Could someone kindly help? Thank you, may % D.hdr.grad % % ans = % % pnt: [276x3 double] % ori: [276x3 double] % tra: [271x276 double] % label: {271x1 cell} % unit: 'm' % balance: [1x1 struct] % % D.grad % % ans = % % pnt: [276x3 double] % ori: [276x3 double] % tra: [271x276 double] % label: {271x1 cell} % unit: 'm' % balance: [1x1 struct] %% How D was created. % subjNUM=1 % iset=2 % irun=1 % % cd([subj{subjNUM}.runpath{irun}]) % % %% load raw data % cfg = []; % % cfg.subjNUM = subjNUM; % cfg.irun=irun; % % cfg.headerfile = 'c,rfDC'; % cfg.datafile = cfg.headerfile; % cfg.trialfun ='trialfun_general'; % % cfg.channel={'all'}; % need all for denoise_pca later!!! % cfg.channel={'MEG'}; % cfg.continuous='yes'; % cfg.trialdef.eventtype = '?'; % % cfg.trialdef.eventtype = 'RESPONSE'; %'TRIGGER'; % cfg=ft_definetrial(cfg); %--->cfg.events % % cfg.header = ft_read_header(cfg.headerfile) % % % just to be sure % cfg = rmfield(cfg,'trl'); % % % %% specify 'trial' information for 'epoching' % cfg.detrend='yes'; %no other filtering at the moment. % % cfg.trialdef.stimulusSETnum = [iset]; % cfg.trialdef.eventtype = 'PostStimTriggerIdx'; %% % cfg.trialdef.eventinfo = 'PostStimSampleTime'; % cfg.trialdef.eventvalue = [iset].*2 + 128; % % cfg.trialdef.response_time=[1]; % to include RXNtime in the definetrial procedure... % cfg.trialdef.CorrectWrong = [1]; %only correct ones % % cfg.trialdef.prestim = 2; % duration in secs before '0' % cfg.trialdef.poststim = 2; % duration in secs after '0' % % cfg.trialfun ='trialfun_readEventgetRespInfo'; %%CHANGE 3rd Column!!! % % cfg=ft_definetrial(cfg); % % cfg.trl ==//// [begsam endsam off runN stimN ] % % D=ft_preprocessing(cfg); % % D = rmfield(D,'cfg') % D.trial = D.trial{1} % whos D % save D.mat D


Robert Oostenveld - 2011-12-02 09:50:29 +0100

Hi May, Since you are referring to grad.pnt, it is clear that you are using an old fieldtrip version. In the recent fieldtrip versions that field is called grad.coilpos. There is also a field grad.chanpos, which is the one you want to have. grad.pnt is the position of each coil. The Glasgow MEG system has magnetometers, but also a small number of gradiometers which consist of two coils. The field grad.tra tells how the coils are combined in channels, have a look at imagesc(grad.tra). See the help of FT_DATATYPE_SENS With a recent fieldtrip version, you can do gradnew = ft_datatype_sens(gradold) to update the gradiometer structure. The new gradiometer structure represents both the channel and the coil positions. best Robert


Robert Oostenveld - 2011-12-02 09:58:45 +0100

I added a test script to our development version to ensure that it works as advertised --------------------------------------------------------------- manzana> svn commit test_bug1210.m* Adding test_bug1210.m Adding (bin) test_bug1210.mat Transmitting file data .. Committed revision 4926. --------------------------------------------------------------- load test_1210.mat % the input is old-style assert(isfield(D.grad, 'pnt')); assert(isfield(D.grad, 'ori')); gradnew = ft_datatype_sens(D.grad); % the output should be new-style assert(isfield(gradnew, 'chanpos')); assert(isfield(gradnew, 'chanori')); assert(isfield(gradnew, 'coilpos')); assert(isfield(gradnew, 'coilori'));


May - 2011-12-03 00:25:18 +0100

(In reply to comment #2 &#3) Hi Robert Thanks for taking a look! I shall try your suggestions. And also those of comment3. Much appreciated! Best, May


May - 2011-12-03 00:26:20 +0100

And thanks to JM too! May (In reply to comment #4)


May - 2011-12-05 12:27:50 +0100

(In reply to comment #3) Hi Robert Sorry it's me again. I get an error with this: >> gradnew = ft_datatype_sens(D.grad) ??? Undefined function or method 'channelposition' for input arguments of type 'struct'. Error in ==> ft_datatype_sens at 95 [chanpos, chanori, chanlab] = channelposition(sens, 'channel', 'all'); Do I have to specify a field D.channel='MEG'or something else? There seems to be some missing information (channelposition) it needs. Hope to hear back from you. Thanks again, May


May - 2011-12-05 13:41:38 +0100

(In reply to comment #6) Hi again, I wonder if the problem might not rather be that FT doesn't really prune out the unselected channels from the hdr.grad related fields when cfg.channel={'MEG'}; is specified for ft_definetrial or ft_preprocessing etc. may


Robert Oostenveld - 2011-12-06 09:55:32 +0100

(In reply to comment #6) please upgrade your fieldtrip version, because the file utilities/private/channelposition.m (which should be called) does exist in later version.


Robert Oostenveld - 2011-12-06 09:59:40 +0100

(In reply to comment #7) selecting channels from the data should not change the gradiometer structure. ------ It is not clear what the problem or bug is. Please download the latest version of fieldtrip and rerun your analysis using cfg settings that are consistent with the current documentation. If you then still find any behavior that you believe to be an error and due to the implementation of the code, please report it as a new bug. I will close this bug.