-
Notifications
You must be signed in to change notification settings - Fork 0
/
bvcTrDefineMainField.m
30 lines (27 loc) · 1.53 KB
/
bvcTrDefineMainField.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
function [out] = bvcTrDefineMainField( map, varargin )
% Define main field in pre-barrier trial: this is a couple of lines, but needs
% to be consistent across several different calling functions.
%
% [mask] = bvcTrDefineMainField( map, prms )
%
% map is the bsl trial rate map.
% mask is a logical mask for the main field.
prms.BslFieldThr = 0.5;
prms.mapNormMode = 'Z';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% - This is the template code for name-value list OR struct passing of parameters -- %
if ~isempty(varargin) %
if ischar(varargin{1}) %
for ii=1:2:length(varargin); prms.(varargin{ii}) = varargin{ii+1}; end %
elseif isstruct(varargin{1}) %
s = varargin{1}; f = fieldnames(s); %
for ii=1:length(f); prms.(f{ii}) = s.(f{ii}); end %
end %
end %
% ---------------------------------------------------------------------------------- %
if strcmp( prms.mapNormMode, 'Z' )
map = (map-nanmean(map(:))) ./ nanstd(map(:));
elseif strcmp( prms.mapNormMode, 'norm2Pk' )
map = map ./ nanmax(map(:));
end
out = map >= prms.BslFieldThr;