User Tools

Site Tools


convones

convones

Motivation

The main motivation to use convones is to have a faster routine for the special case where one of the arguments of a one-dimensional convolution is a series of all-1 values.

Reference

  convones  - convoles a function with a number of consecutive ones
 
  FORMAT:       cfunc = convones(f, cnum [, w])
 
  Input fields:
 
        f           function to convolve
        cnum        number of consecutive ones to use
        w           if 1x1 true, weight (divide by number of samples)
 
  Output fields:
 
        cfunc       ones-convolved function
 
  See also conv

Used by

The main internal use for this function is the creation of design matrices. Opposed to SPM (which typically uses a 16 timebin-per-TR resolution), the design matrix creation in NeuroElf uses a millisecond resolution. While differences between convolved time courses are small (the HRF does not have frequency components for which the maximally occurring shift would matter much w.r.t. their phase), I like the idea of being precise wherever possible. And since onset times are commonly given in milliseconds (and people seem to make a whole lot of fuss about stimulus timing these days), I figured it would be nice to have this implemented…

Exemplary use

conv_ones_rectwindow.m
% create a large gaussian kernel
k = smoothkern(2000);
 
% convolve with a all-ones vector of equal length
tic, ko = convones(k, numel(k)); toc
% reference: Elapsed time is 0.024565 seconds.
 
% and now the same with conv
tic, koc = conv(k, ones(numel(k), 1)); toc
% reference: Elapsed time is 0.240042 seconds.

Note: the difference gets larger the longer the vectors become!!

convones.txt · Last modified: 2010/06/22 05:10 by jochen