Back to the main page.

Bug 1730 - consider making a function private to the preproc module that implements various ways of padding

Status CLOSED FIXED
Reported 2012-09-20 20:33:00 +0200
Modified 2014-03-12 12:21:41 +0100
Product: FieldTrip
Component: preproc
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P3 normal
Assigned to: Jörn M. Horschig
URL:
Tags:
Depends on:
Blocks: 1318
See also:

Jan-Mathijs Schoffelen - 2012-09-20 20:33:28 +0200

We now have the following possibilities here and there: - implicit zero - padding - implicit zero - padding after mean subtraction (in several filter functions) - mirror - padding - local mean - padding (ft_preproc_smooth


Jan-Mathijs Schoffelen - 2012-11-07 13:57:07 +0100

Jorn is working on this and is almost done. Arjen will provide the necessary documentation on the wiki


Jörn M. Horschig - 2012-11-16 14:15:47 +0100

Hey JM, I see you are padding with a local mean, not with the global mean. The ft_preproc_padding function currently has only these options: % padtype 'zero', 'mean', 'edge', 'mirror' or 'remove' Does it make sense to include a 'localmean' option? In case padding would be more than N/2, should the local mean then be computed until N/2? So, something like: case 'edge' dat = [dat(:,1)*ones(1,padlength) dat dat(:,end)*ones(1,padlength)]; return; case 'mean' mu = mean(dat, 2); dat = [mu*ones(1,padlength) dat mu*ones(1,padlength)]; case 'localmean' pad = min(padlength, floor(size(dat, 1)/2)); edgeleft = mean(dat(:, 1:pad), 2); edgeright = mean(dat(:, 1+end-pad:end), 2); dat = [edgeleft*ones(1,padlength) dat edgeright*ones(1,padlength)]; return; case 'zero' dat = [zeros(nchans,padlength) dat zeros(nchans,padlength)]; return; btw, working from home today, so in case you want to hop over, we can discuss it on Wednesday (Mo&Tu: Heidag).


Jörn M. Horschig - 2012-11-21 16:54:51 +0100

In my working copy, I replaced all padding operations by instead calling ft_preproc_padding, apart from datapadding of course. However, the only functions I could find that use padding were ft_preprocessing and ft_specest_* functions. If I missed anything, just let me know, Since I won't have time tomorrow to fix any bugs I might introduce, I will commit those changed functions on Friday (this also allows for more testing on my side). Anyways, this is the function: % FT_PREPROC_PADDING performs padding on the data, i.e. adds or removes % samples to/from the data matrix. % % Use as % [dat] = ft_preproc_padding(dat, padtype, padlength) % or as % [dat] = ft_preproc_padding(dat, padtype, prepadlength, postpadlength) % where % dat data matrix (Nchan x Ntime) % padtype 'zero', 'mean', 'localmean', 'edge', 'mirror' or 'remove' % padlength scalar, number of samples that will be padded % prepadlength scalar, number of samples that will be padded before the data % postpadlength scalar, number of samples that will be padded after the data % % If padlength is used instead of prepadlength and postpadlength, padding % will be symmetrical (i.e. padlength = prepadlength = postpadlength) % svn ci ft_preproc_padding.m -m "enhancement-#1730-padding can be asymmetrical now&added localmean padding" Sending ft_preproc_padding.m Transmitting file data . Committed revision 6969.


Jörn M. Horschig - 2012-11-23 10:36:53 +0100

CC Vladimir so that he's up to date new option cfg.padtype added/key-value pair 'padtype' http://code.google.com/p/fieldtrip/source/detail?r=6977 and the many commits after that to fix some smaller issues, like typos