/
identify_eLFP_protocol.m
executable file
·116 lines (96 loc) · 3.9 KB
/
identify_eLFP_protocol.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
function isEvokedLfp = identify_eLFP_protocol (iVecsORfileName, varargin)
%% Identifies whether a .abf file or a set of current vectors follows an eLFP protocol
% Usage: isEvokedLfp = identify_eLFP_protocol (iVecsORfileName, varargin)
% Explanation:
% TODO
% Example(s):
% TODO
% Outputs:
% isEvokedLfp - whether the data corresponds to an evoked LFP protocol
% specified as a logical scalar
%
% Arguments:
% iVecsORfileName
% - current vector(s) OR
% .abf file name (could be either the full path or
% a relative path in current directory
% .abf is not needed (e.g. 'B20160908_0004'))
% must be a numeric array
% or a string scalar or a character vector
% varargin - 'ChannelTypes': type assigned to each channel, possibly:
% 'Voltage', 'Current', 'Conductance' or 'Other'
% must as a row cell array with the
% number of elements same as the length of the
% 2nd dimension of abfdata
% - 'MinSweeps': minimum number of sweeps
% must be a positive integer scalar
% default == 2
%
% Requires:
% cd/extract_channel.m
% cd/identify_repetitive_pulses.m
%
% Used by:
% cd/parse_abf.m
% File History:
% 2018-09-17 - Created by Adam Lu
% 2018-09-21 - Considered the case when iVecs is a cellarray
% 2018-09-21 - Considered the case when iVecs is 3-D
% 2018-10-03 - Updated usage of parse_abf.m
% 2018-12-15 - Made 'MinSweeps' an optional parameter with default 2
% 2018-12-15 - Moved code to identify_repetitive_pulses.m
% 2018-12-15 - Moved code to extract_channel.m
%
%% Hard-coded parameters
validChannelTypes = {'Voltage', 'Current', 'Conductance', 'Undefined'};
%% Default values for optional arguments
channelTypesDefault = {}; % set later
minSweepsDefault = 2; % must have at least 2 sweeps by default
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Deal with arguments
% Check number of required arguments
if nargin < 1
error(create_error_for_nargin(mfilename));
end
% Set up Input Parser Scheme
iP = inputParser;
iP.FunctionName = mfilename;
% Add required inputs to the Input Parser
addRequired(iP, 'iVecsORfileName');
% Add parameter-value pairs to the Input Parser
addParameter(iP, 'ChannelTypes', channelTypesDefault, ...
@(x) validateattributes(x, {'cell'}, {'nonempty'}));
addParameter(iP, 'MinSweeps', minSweepsDefault, ...
@(x) validateattributes(x, {'numeric'}, {'positive', 'integer', 'scalar'}));
% Read from the Input Parser
parse(iP, iVecsORfileName, varargin{:});
channelTypes = iP.Results.ChannelTypes;
minSweeps = iP.Results.MinSweeps;
% Validate channel types
if ~isempty(channelTypes)
channelTypes = cellfun(@(x) validatestring(x, validChannelTypes), ...
channelTypes, 'UniformOutput', false);
end
%% Preparation
% Parse the first argument and extract the current vectors if needed
if ischar(iVecsORfileName) || isstring(iVecsORfileName)
% The first argument is a file name
fileName = iVecsORfileName;
% Extract the current vectors
iVecs = extract_channel(fileName, 'current', 'MaxNChannels', 1, ...
'ChannelTypes', channelTypes);
else
% The first argument are the current vectors
iVecs = iVecsORfileName;
end
%% Do the job
% Identify whether the current vectors are repetitive pulses
isEvokedLfp = identify_repetitive_pulses(iVecs, 'MinSweeps', minSweeps);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%{
OLD CODE:
ampCp = iVecs(idxCpMid, iSwp);
disp('done');
iVecs = extract_channel(fileName, 'current', 'ChannelTypes', channelTypes);
%}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%