Back to the main page.

Bug 2033 - implement replacement for signal processing toolbox

Status CLOSED FIXED
Reported 2013-03-07 16:34:00 +0100
Modified 2013-08-21 14:41:34 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P3 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks: 1981
See also: http://bugzilla.fcdonders.nl/show_bug.cgi?id=2208

Robert Oostenveld - 2013-03-07 16:34:04 +0100

Preparing for the Toronto workshop, we found out that the computer lab here does not have the signal processing toolbox. It is needed for some of the tutorials, so I have to implement a workaround. The octave signal package provides a good start: http://octave.sourceforge.net/signal/index.html


Robert Oostenveld - 2013-03-07 16:35:56 +0100

I am aware of porblems due to hanning, window and dpss. We have a drop in replacement for hanning (in specest/private) but not for the others. The octave signal package contains among others: window.m and barthannwin.m blackmanharris.m bohmanwin.m chebwin.m flattopwin.m gausswin.m hann.m kaiser.m nuttallwin.m parzenwin.m rectwin.m triang.m tukeywin.m


Robert Oostenveld - 2013-03-07 16:51:02 +0100

the octave version is not drop-in compatible with matlab. list of required changes ## -> % endfunction -> end endswitch -> end endif -> end " -> ' ! -> ~


Robert Oostenveld - 2013-03-07 16:59:29 +0100

(In reply to comment #2) # -> % print_usage -> help(mfilename) default input handling is different indexing cannot be done directly on function output


Robert Oostenveld - 2013-03-07 17:00:40 +0100

I'll make a test script like this type = { 'barthannwin' 'blackmanharris' 'bohmanwin' % 'chebwin' % removed, as it required another function (cheb). 'flattopwin' 'gausswin' 'hann' 'kaiser' 'nuttallwin' 'parzenwin' 'rectwin' 'triang' 'tukeywin' }; for i=1:length(type) w = window(type{i}, 1000); end at this moment (with all modifications) it works.


Robert Oostenveld - 2013-03-07 17:05:22 +0100

ok, now onto the timefrequency tutorial. As expected it fails on Undefined function 'dpss' for input arguments of type 'double'. Error in ft_specest_mtmconvol>double_dpss (line 392) tap = dpss(double(a), double(b), varargin{:}); Error in ft_specest_mtmconvol (line 146) tap = double_dpss(timwinsample(ifreqoi), timwinsample(ifreqoi) .* (tapsmofrq(ifreqoi) ./ fsample))'; Error in ft_freqanalysis (line 505) [spectrum_mtmconvol,ntaper,foi,toi] = ft_specest_mtmconvol(dat, time, 'timeoi', cfg.toi, 'timwin', cfg.t_ftimwin, 'taper', ... Error in test_tutorial_timefrequencyanalysis (line 284) TFRmult = ft_freqanalysis(cfg, dataFIC);


Robert Oostenveld - 2013-03-07 17:34:40 +0100

there is http://sourceforge.net/projects/dpsseq but that is cpp code, without MATLAB wrapper. It also requires some LAPACK fortran functions. Not something I cat get to work in one hour. I'll proceed with a precomputed set of dpss tapers and interpolate based on them.


Robert Oostenveld - 2013-03-08 03:44:43 +0100

laptop> git commit [bug2033 a179de9] enhancement - added alternative windowing functions for signal processing toolbox, including test script. See http://bugzilla.fcdonders.nl/show_bug.cgi?id=2033 19 files changed, 665 insertions(+), 0 deletions(-) create mode 100644 external/signal/README create mode 100644 external/signal/barthannwin.m create mode 100644 external/signal/blackmanharris.m create mode 100644 external/signal/bohmanwin.m create mode 100644 external/signal/dpss.m create mode 100644 external/signal/flattopwin.m create mode 100644 external/signal/gausswin.m create mode 100644 external/signal/hann.m create mode 100644 external/signal/hanning.m create mode 100644 external/signal/kaiser.m create mode 100644 external/signal/nuttallwin.m create mode 100644 external/signal/parzenwin.m create mode 100644 external/signal/precompute_dpss.m create mode 100644 external/signal/precompute_dpss.mat create mode 100644 external/signal/rectwin.m create mode 100644 external/signal/triang.m create mode 100644 external/signal/tukeywin.m create mode 100644 external/signal/window.m create mode 100644 test/test_bug2033.m


Robert Oostenveld - 2013-03-08 03:58:08 +0100

laptop> git commit . [bug2033 3224e02] enhancement - check signal processing toolbox, add the one from external/signal if needed 2 files changed, 40 insertions(+), 34 deletions(-)


Robert Oostenveld - 2013-03-10 11:56:39 +0100

during the workshop I found out that boxcar is used in ft_databrowser for some fast fft computation. TODO: add boxcar replacement


Robert Oostenveld - 2013-03-16 10:01:54 +0100

I made a boxcar implementation. Furthermore, I have tried collecting all private functions that are replacements for signal toolbox functions in the external/signal directory. mbp> mv specest/private/hilbert.m external/signal/ mbp> mv specest/private/hanning.m external/signal/ mbp> mv specest/private/filtfilt.m external/signal/ mbp> mv specest/private/bilinear.m external/signal/ mbp> mv specest/private/butter.m external/signal/


Robert Oostenveld - 2013-03-16 10:07:05 +0100

also needs this one mbp> mv specest/private/sftrans.m external/signal/private/ mbp> mv specest/private/postpad.m external/signal/private/ removed them here mbp> rm preproc/private/butter.m mbp> rm preproc/private/bilinear.m mbp> rm preproc/private/filtfilt.m mbp> rm preproc/private/sftrans.m mbp> rm preproc/private/postpad.m


Robert Oostenveld - 2013-03-16 10:12:31 +0100

mbp> rm private/butter.m mbp> rm private/postpad.m mbp> rm private/bilinear.m mbp> rm private/sftrans.m mbp> rm private/filtfilt.m I committed it to git, see oostenveld/fieldtrip/branch2033 [bug2033 b6cb21d] restructuring - moved all signal processing replacement functions to external/signal, see http://bugzilla.fcdonders.nl/show_bug.cgi?id=2033 18 files changed, 1 insertions(+), 1257 deletions(-) rename {preproc/private => external/signal}/bilinear.m (100%) rename {preproc/private => external/signal}/butter.m (100%) rename {preproc/private => external/signal}/filtfilt.m (100%) rename {specest/private => external/signal}/hilbert.m (100%) rename {preproc => external/signal}/private/postpad.m (100%) rename {preproc => external/signal}/private/sftrans.m (100%) delete mode 100644 private/bilinear.m delete mode 100644 private/butter.m delete mode 100644 private/filtfilt.m delete mode 100644 private/postpad.m delete mode 100644 private/sftrans.m delete mode 100644 specest/private/bilinear.m delete mode 100644 specest/private/butter.m delete mode 100644 specest/private/filtfilt.m delete mode 100644 specest/private/hanning.m delete mode 100644 specest/private/postpad.m delete mode 100644 specest/private/sftrans.m


Robert Oostenveld - 2013-03-16 10:52:09 +0100

Hmm, the merge with git did not exactly result in the detailed comments that I had hoped. But the code is correctly merged. See http://code.google.com/p/fieldtrip/source/detail?r=7674 @Vladimir & Guillaume: this means that fieldtrip/preproc and fieldtrip/specest by themselves are not independent of the signal toolbox any more as they do not have the private drop-in replacement functions. Rather external/signal contains all of them. I believe this makes it easier to manage. If you disagree, please let me know.


Robert Oostenveld - 2013-04-23 12:05:55 +0200

closed various bugs


Robert Oostenveld - 2013-04-23 12:06:30 +0200

closed various bugs