Back to the main page.

Bug 2470 - Allow freq statistics over custom fields

Status CLOSED FIXED
Reported 2014-02-10 21:46:00 +0100
Modified 2014-06-18 12:32:39 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: All
Operating System: All
Importance: P5 enhancement
Assigned to: Jan-Mathijs Schoffelen
URL:
Tags:
Depends on:
Blocks: 2502
See also:

- 2014-02-10 21:46:53 +0100

Currently, freq statistics can only be performed on fields that FieldTrip knows about e.g., powspctrm. It would be nice to leverage FieldTrip's extensive statistics framework to perform tests on arbitrary fields. For example, I am returning Fourier coefficients from my analysis and computing various values from them such as power, phase, intertrial coherence, phase-locking value, etc. I would like to be able to specify these in the same manner as powspctrm using ft_freqstatistics cfg.parameter. This is almost supported, but is not currently possible due to the way that variables are set in dimlength.m, see below: elseif strcmp(data.(fld)(1:4), 'rpt_') n = []; % generic solution for XXXspctrm fnames = fieldnames(data); tmp = find(~cellfun('isempty', strfind(fnames, 'spctrm'))); for k = 1:numel(tmp) n = [n size(data.(fnames{tmp(k)}), 1)]; end % some other possibilities if isfield(data, 'cov'), n = [n size(data.cov, 1)]; end %if isfield(data, 'crsspctrm'), n = [n size(data.crsspctrm, 1)]; end %if isfield(data, 'powcovspctrm'), n = [n size(data.powcovspctrm, 1)]; end %if isfield(data, 'powspctrm'), n = [n size(data.powspctrm, 1)]; end if isfield(data, 'trial'), n = [n size(data.trial, 1)]; end %if isfield(data, 'fourierspctrm'), n = [n size(data.fourierspctrm, 1)]; end if isfield(data, 'individual'), n = [n size(data.individual, 1)]; end if isfield(data, 'stat'), n = [n size(data.stat, 1)]; end if ~all(n==n(1)) error('inconsistent number of repetitions for dim "%s"', seldim); end n = n(1); I can add the following lines to get it to work for my data if isfield(data, 'ITC'), n = [n size(data.ITC, 1)]; end if isfield(data, 'PLV'), n = [n size(data.PLV, 1)]; end This could be done programatically if the field name was passed to dimlength, but I'm not sure if that's the correct design. Can we rewrite this function (or the calling function) to me more general and operate on arbitrary fields?


Jan-Mathijs Schoffelen - 2014-02-12 14:26:02 +0100

Hi Dean, You're absolutely right. We'll look into it. For now, can you work around the issue with your proposed fix? Best wishes, Jan-Mathijs


- 2014-02-12 16:43:47 +0100

Yes, I am currently using the workaround. Thanks for looking into it.


Jan-Mathijs Schoffelen - 2014-03-17 21:27:31 +0100

*** Bug 2502 has been marked as a duplicate of this bug. ***


Jan-Mathijs Schoffelen - 2014-03-18 20:52:14 +0100

On second thought, bug 2502 was a duplicate... I fixed it, so that the code doesn't use ft_selectdata_old (and seloverdim/dimlength) anymore, but uses ft_selectdata_new instead. Should work now without workaround. Could you verify this with the latest version and confirm?


- 2014-03-20 15:47:31 +0100

Working great for me now with fieldtrip-20140319. Thanks for the fix!