Skip to content

Commit dd6cd2d

Browse files
author
ian
committed
some refactoring
1 parent 770fa5f commit dd6cd2d

4 files changed

Lines changed: 176 additions & 195 deletions

File tree

omniplex/LFPAnalysis.m

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ function getFiles(ego, force)
122122
return
123123
end
124124
end
125+
checkPaths(ego);
125126
end
126127

127128
% ===================================================================
@@ -151,6 +152,26 @@ function parse(ego)
151152
plot(ego,'normal');
152153
end
153154

155+
% ===================================================================
156+
%> @brief reparse data after an initial parse
157+
%>
158+
%> @param
159+
%> @return
160+
% ===================================================================
161+
function reparse(ego)
162+
if isempty(ego.lfpfile) %we obviously haven't done an initial parse
163+
parse(ego);
164+
return
165+
end
166+
ego.ft = struct();
167+
ego.results = struct();
168+
parseEvents(ego.p);
169+
parseLFPs(ego);
170+
select(ego);
171+
selectTrials(ego);
172+
getFieldTripLFPs(ego);
173+
end
174+
154175
% ===================================================================
155176
%> @brief reparse data after an initial parse
156177
%>
@@ -172,26 +193,6 @@ function toggleSaccadeRealign(ego)
172193
disp('Saccade Realign is now DISABLED...')
173194
end
174195
end
175-
% ===================================================================
176-
%> @brief reparse data after an initial parse
177-
%>
178-
%> @param
179-
%> @return
180-
% ===================================================================
181-
function reparse(ego)
182-
if isempty(ego.lfpfile) %we obviously haven't done an initial parse
183-
parse(ego);
184-
return
185-
end
186-
ego.ft = struct();
187-
ego.results = struct();
188-
parseEvents(ego.p);
189-
parseLFPs(ego);
190-
select(ego);
191-
selectTrials(ego);
192-
getFieldTripLFPs(ego);
193-
plot(ego,'normal');
194-
end
195196

196197
% ===================================================================
197198
%> @brief

omniplex/analysisCore.m

Lines changed: 19 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
measureRange@double = [0.1 0.2]
1717
%> default range to plot
1818
plotRange@double = [-0.2 0.4]
19+
%> root directory to check for data if files can't be found
20+
rootDirectory@char = ''
1921
end
2022

2123
%--------------------ABSTRACT PROPERTIES----------%
@@ -101,6 +103,12 @@ function checkPaths(ego)
101103
warning('Can''t find valid source directory')
102104
end
103105
end
106+
if ~isempty(regexpi(ego.dir,'^/Users/'))
107+
re = regexpi(ego.dir,'^(?<us>/Users/[^/]+)(?<rd>.+)','names');
108+
if ~isempty(re.rd)
109+
ego.dir = ['~' re.rd];
110+
end
111+
end
104112
end
105113
if isprop(ego,'p') && isa(ego.p,'plxReader')
106114
ego.p.dir = ego.dir;
@@ -605,7 +613,7 @@ function initialiseStats(ego)
605613
end
606614

607615
% ===================================================================
608-
%> @brief format for ROC
616+
%> @brief format data for ROC
609617
%>
610618
%> @param dp scores for "signal" distribution
611619
%> @param dn scores for "noise" distribution
@@ -622,7 +630,7 @@ function initialiseStats(ego)
622630
end
623631

624632
% ===================================================================
625-
%> @brief ROC
633+
%> @brief ROC see http://www.subcortex.net/research/code/area_under_roc_curve
626634
%>
627635
%> @param data - [class , score] matrix
628636
%> @return tp - true positive rate
@@ -660,60 +668,16 @@ function initialiseStats(ego)
660668
% ===================================================================
661669
%> @brief Area under ROC
662670
%>
663-
% ===================================================================
664-
function [A,Aci] = auc(ego,data,alpha,flag,nboot,varargin);
665-
% [A,Aci] = auc(data,alpha,flag,nboot,varargin);
666-
%
667-
% INPUTS
668-
% data - Nx2 matrix [t , y], where
669-
% t - a vector indicating class value (>0 positive class, <=0 negative)
670-
% y - score value for each instance
671-
%
672-
% OPTIONAL
673-
% alpha - level for confidence intervals (eg., enter 0.05 if you want 95% CIs)
674-
% flag - 'hanley' yields Hanley-McNeil (1982) asymptotic CI
675-
% 'maxvar' yields maximum variance CI
676-
% 'mann-whitney'
677-
% 'logit'
678-
% 'boot' yields bootstrapped CI (DEFAULT)
679-
% nboot - if 'boot' is set, specifies # of resamples, default=1000
680-
% varargin - additional arguments to pass to BOOTCI, only valid for 'boot'
681-
% this assumes you have the STATs toolbox, otherwise it's
682-
% ignored and a crude percentile bootstrap is estimated.
683-
%
684-
% OUTPUTS
685-
% A - area under ROC
686-
% Aci - confidence intervals
687-
%
688-
% EXAMPLES
689-
% % Classic binormal ROC. 100 samples from each class, with a unit mean separation
690-
% % between the classes.
691-
% >> mu = 1;
692-
% >> y = [randn(100,1)+mu ; randn(100,1)];
693-
% >> t = [ones(100,1) ; zeros(100,1)];
694-
% >> [A,Aci] = auc([t,y])
695-
% >> trueA = normcdf(mu/sqrt(1+1^2))
696-
%
697-
% REFERENCE
698-
% Gengsheng Qin & Lejla Hotilovac. Comparison of non-parametric
699-
% confidence intervals for the area under the ROC curve of a continuous
700-
% scale diagnostic test.
701-
% Stat Methods Med Res 17:207, 2008
702-
671+
%> @param data - [class , score] matrix
672+
%> @param alpha - level for confidence intervals (eg., enter 0.05 if you want 95% CIs)
673+
%> @param flag - 'hanley' yields Hanley-McNeil (1982) asymptotic CI; 'maxvar' yields maximum variance CI;'mann-whitney';'logit';'boot' yields bootstrapped CI (DEFAULT)
674+
%> @param nboot - if 'boot' is set, specifies # of resamples, default=1000
675+
%> @param varargin - additional arguments to pass to BOOTCI, only valid for 'boot' this assumes you have the STATs toolbox, otherwise it's ignored and a crude percentile bootstrap is estimated.
676+
%> @return A - area under ROC
677+
%> @return Aci - confidence intervals
678+
% ===================================================================
679+
function [A,Aci] = auc(ego,data,alpha,flag,nboot,varargin)
703680
% $ Copyright (C) 2011 Brian Lau http://www.subcortex.net/ $
704-
%
705-
% This program is free software: you can redistribute it and/or modify
706-
% it under the terms of the GNU General Public License as published by
707-
% the Free Software Foundation, either version 3 of the License, or
708-
% (at your option) any later version.
709-
%
710-
% This program is distributed in the hope that it will be useful,
711-
% but WITHOUT ANY WARRANTY; without even the implied warranty of
712-
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
713-
% GNU General Public License for more details.
714-
%
715-
% You should have received a copy of the GNU General Public License
716-
% along with this program. If not, see <http://www.gnu.org/licenses/>.
717681
if size(data,2) ~= 2
718682
error('Incorrect input size in AUC!');
719683
end

0 commit comments

Comments
 (0)