Home > FMAToolbox > IO > SaveRippleEvents.m

SaveRippleEvents

PURPOSE ^

SaveRippleEvents - Save hippocampal ripple (~200Hz oscillations) events.

SYNOPSIS ^

function SaveRippleEvents(filename,ripples,channelID,varargin)

DESCRIPTION ^

SaveRippleEvents - Save hippocampal ripple (~200Hz oscillations) events.

  USAGE

    SaveRippleEvents(filename,ripples,channelID,options)

    filename       file to save to
    ripples        ripple info as provided by <a href="matlab:help FindRipples">FindRipples</a>
    channelID      channel ID (appended to the event description)
    <options>      optional list of property-value pairs (see table below)

    =========================================================================
     Properties    Values
    -------------------------------------------------------------------------
     'overwrite'   overwrite file if it exists (default = 'off')
    =========================================================================

  SEE

    See also FindRipples, RippleStats, PlotRippleStats, SaveEvents.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function SaveRippleEvents(filename,ripples,channelID,varargin)
0002 
0003 %SaveRippleEvents - Save hippocampal ripple (~200Hz oscillations) events.
0004 %
0005 %  USAGE
0006 %
0007 %    SaveRippleEvents(filename,ripples,channelID,options)
0008 %
0009 %    filename       file to save to
0010 %    ripples        ripple info as provided by <a href="matlab:help FindRipples">FindRipples</a>
0011 %    channelID      channel ID (appended to the event description)
0012 %    <options>      optional list of property-value pairs (see table below)
0013 %
0014 %    =========================================================================
0015 %     Properties    Values
0016 %    -------------------------------------------------------------------------
0017 %     'overwrite'   overwrite file if it exists (default = 'off')
0018 %    =========================================================================
0019 %
0020 %  SEE
0021 %
0022 %    See also FindRipples, RippleStats, PlotRippleStats, SaveEvents.
0023 
0024 % Copyright (C) 2004-2015 by Michaƫl Zugaro
0025 %
0026 % This program is free software; you can redistribute it and/or modify
0027 % it under the terms of the GNU General Public License as published by
0028 % the Free Software Foundation; either version 3 of the License, or
0029 % (at your option) any later version.
0030 
0031 % Default values
0032 overwrite = 'off';
0033 
0034 if nargin < 3,
0035   error('Incorrect number of parameters (type ''help <a href="matlab:help SaveRippleEvents">SaveRippleEvents</a>'' for details).');
0036 end
0037 
0038 for i = 1:2:length(varargin),
0039     if ~ischar(varargin{i}),
0040         error(['Parameter ' num2str(i+2) ' is not a property (type ''help <a href="matlab:help SaveRippleEvents">SaveRippleEvents</a>'' for details).']);
0041     end
0042     switch(lower(varargin{i})),
0043         case 'overwrite',
0044             overwrite = varargin{i+1};
0045             if ~isastring(overwrite,'on','off'),
0046                 error('Incorrect value for property ''overwrite'' (type ''help <a href="matlab:help SaveRippleEvents">SaveRippleEvents</a>'' for details).');
0047             end
0048         otherwise,
0049             error(['Unknown property ''' num2str(varargin{i}) ''' (type ''help <a href="matlab:help SaveRippleEvents">SaveRippleEvents</a>'' for details).']);
0050     end
0051 end
0052 
0053 n = size(ripples,1);
0054 r = ripples(:,1:3)';
0055 events.time = r(:);
0056 for i = 1:3:3*n,
0057     events.description{i,1} = ['Ripple start ' int2str(channelID)];
0058     events.description{i+1,1} = ['Ripple peak ' int2str(channelID)];
0059     events.description{i+2,1} = ['Ripple stop ' int2str(channelID)];
0060 end
0061 
0062 if strcmp('overwrite','on'),
0063     SaveEvents(filename,events,'overwrite','on');
0064 else
0065     SaveEvents(filename,events);
0066 end

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