Home > FMAToolbox > IO > ResampleBinary.m

ResampleBinary

PURPOSE ^

ResampleBinary - Resample binary data file.

SYNOPSIS ^

function ResampleBinary(inputName,outputName,nChannels,up,down)

DESCRIPTION ^

ResampleBinary - Resample binary data file.

 Resample binary data file, e.g. create LFP file from raw data file.

  USAGE

    ResampleBinary(inputName,outputName,nChannels,up,down)

    inputName      binary input file
    outputName     binary output file
    nChannels      number of channels in the file
    up             upsampling integer factor
    down           downsampling integer factor

  NOTE 1

    This function is provided for convenience. It simply calls <a href="matlab:help ProcessBinary">ProcessBinary</a>
    using the same parameters. See this function for details.

  NOTE 2

    The actual resampling ratio is up/down.

    Here is a list of typical values for Spike2 recording systems:

    FROM           TO       UP     DOWN
    =====================================
    20000          1025     1      16
    19531.25       20000    128    125
    19531.25       1025     128    125*16
    19841.29...    20000    126    125
    19841.29...    1025     126    125*16
    20284          20000    5000   5071
    20284          1025     5000   5071*16

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function ResampleBinary(inputName,outputName,nChannels,up,down)
0002 
0003 %ResampleBinary - Resample binary data file.
0004 %
0005 % Resample binary data file, e.g. create LFP file from raw data file.
0006 %
0007 %  USAGE
0008 %
0009 %    ResampleBinary(inputName,outputName,nChannels,up,down)
0010 %
0011 %    inputName      binary input file
0012 %    outputName     binary output file
0013 %    nChannels      number of channels in the file
0014 %    up             upsampling integer factor
0015 %    down           downsampling integer factor
0016 %
0017 %  NOTE 1
0018 %
0019 %    This function is provided for convenience. It simply calls <a href="matlab:help ProcessBinary">ProcessBinary</a>
0020 %    using the same parameters. See this function for details.
0021 %
0022 %  NOTE 2
0023 %
0024 %    The actual resampling ratio is up/down.
0025 %
0026 %    Here is a list of typical values for Spike2 recording systems:
0027 %
0028 %    FROM           TO       UP     DOWN
0029 %    =====================================
0030 %    20000          1025     1      16
0031 %    19531.25       20000    128    125
0032 %    19531.25       1025     128    125*16
0033 %    19841.29...    20000    126    125
0034 %    19841.29...    1025     126    125*16
0035 %    20284          20000    5000   5071
0036 %    20284          1025     5000   5071*16
0037 
0038 % Copyright (C) 2004-2014 by Michaƫl Zugaro
0039 %
0040 % This program is free software; you can redistribute it and/or modify
0041 % it under the terms of the GNU General Public License as published by
0042 % the Free Software Foundation; either version 3 of the License, or
0043 % (at your option) any later version.
0044 
0045 if nargin ~= 5,
0046   error('Incorrect number of parameters (type ''help <a href="matlab:help ResampleBinary">ResampleBinary</a>'' for details).');
0047 end
0048 
0049 segmentLength = 2^16  - mod(2^16,down);
0050 % Number of overlapping points per channel, chosen so that both resampled and original overlaps are integers
0051 resampledOverlap = 8*up;
0052 originalOverlap = resampledOverlap * down/up;
0053 
0054 ProcessBinary(inputName,outputName,nChannels,@ResampleSegment,'parameters',{up,down},'overlap',originalOverlap,'segment',segmentLength);
0055 
0056 function y = ResampleSegment(x,up,down)
0057 
0058 resampledOverlap = 8*up;
0059 y = resample(x,up,down);
0060 y = y(resampledOverlap/2+1:end-resampledOverlap/2,:)';

Generated on Fri 16-Mar-2018 13:00:20 by m2html © 2005