diff --git a/+CMBHOME/+Utils/AddChronuxPackage.m b/+CMBHOME/+Utils/AddChronuxPackage.m index f6f3145..ed8a070 100755 --- a/+CMBHOME/+Utils/AddChronuxPackage.m +++ b/+CMBHOME/+Utils/AddChronuxPackage.m @@ -1,5 +1,5 @@ function AddChronuxPackage - +% Add the chronux pacage if ~isempty(findstr('chronux', path)), return; end % check that it isnt already there a = what('CMBHOME'); diff --git a/+CMBHOME/+Utils/AutoCorrRotation.m b/+CMBHOME/+Utils/AutoCorrRotation.m index c0d6a1f..e18b4d7 100755 --- a/+CMBHOME/+Utils/AutoCorrRotation.m +++ b/+CMBHOME/+Utils/AutoCorrRotation.m @@ -1,7 +1,4 @@ function [phi, max_cor, phi_v_cor] = AutoCorrRotation(ac1, ac2, varargin) -% [phi] = AutoCorrRotation(ac1, ac2); -% [phi, max_cor, phi_v_cor] = AutoCorrRotation(ac1, ac2); -% % Calculates angle phi for which ac1 and ac2 are maximally correlated. % Useful for checking for rotation of grid field orientation between % conditions @@ -35,7 +32,8 @@ % 3. Finds max of the correlation score, and returns both vectors, as % well. % - +% [phi] = AutoCorrRotation(ac1, ac2); +% [phi, max_cor, phi_v_cor] = AutoCorrRotation(ac1, ac2); import CMBHOME.Utils.* p = inputParser; diff --git a/+CMBHOME/+Utils/CatCA.m b/+CMBHOME/+Utils/CatCA.m index 9a0061f..f672fb8 100755 --- a/+CMBHOME/+Utils/CatCA.m +++ b/+CMBHOME/+Utils/CatCA.m @@ -1,6 +1,4 @@ -function matout = CatCA(cellin) -% matout = CMBHOME.Utils.CatCA(cellin) -% +function matout = CatCA(cellin)% % Converts a cell array of vectors 'cellin' of size MxN to a matrix padded by NaNs of % size max_vector x N x M. This is useful for data structures in CMBHOME. % If cellin is a matrix, matout = cellin. The reason M (epochs) gets pushed diff --git a/+CMBHOME/+Utils/Cell2MatPlus.m b/+CMBHOME/+Utils/Cell2MatPlus.m index 2029f81..a9df78d 100755 --- a/+CMBHOME/+Utils/Cell2MatPlus.m +++ b/+CMBHOME/+Utils/Cell2MatPlus.m @@ -1,5 +1,4 @@ function matout = Cell2MatPlus(cellin) - % returns a matrix from cell cellin, where differently sized vectors are % padded with NaNs diff --git a/+CMBHOME/+Utils/CondorCheck.m b/+CMBHOME/+Utils/CondorCheck.m deleted file mode 100755 index 9552777..0000000 --- a/+CMBHOME/+Utils/CondorCheck.m +++ /dev/null @@ -1,45 +0,0 @@ -function CondorCheck(varargin) -% CMBHOME.Utils.CondorCheck() - -% Bill 2012.12.11 - -%% Parse Inputs -p = inputParser; - -p.addParamValue('user', 'lost', @(x) ischar(x)); -p.addParamValue('an', 'lost', @(x) ischar(x)); -p.addParamValue('endline', 'Done...', @(x) ischar(x)); - -origPath = pwd; % So that we can come back at the end of the function. - -cd([dropboxPath '/condor/' user '/' an]) - -%% find all relevant files -outFiles = dir('*.out'); -logFiles = dir('*.log'); -errFiles = dir('*.err'); - - -% parse files -for i = 1:length(outFiles) - - % look for finalOutStr in *.out file - fid = fopen(fullfile(condorPath,outFiles(i).name)); % out file - comparisons = false; - while 1 - tline = fgetl(fid); - if ~ischar(tline), break, end - comparisons = comparisons || strcmp(tline,finalOutStr); - end - fclose(fid); - - if comparisons ~=0 - delete(outFiles(i).name); - delete(logFiles(i).name); - delete(errFiles(i).name); - end - -end - -cd(origPath) -end diff --git a/+CMBHOME/+Utils/CondorSubmit.m b/+CMBHOME/+Utils/CondorSubmit.m deleted file mode 100755 index 1611926..0000000 --- a/+CMBHOME/+Utils/CondorSubmit.m +++ /dev/null @@ -1,138 +0,0 @@ -function CondorSubmit(varargin) -% CMBHOME.Utils.CondorSubmit('f2run','myFunction','logs',1,'RAMreq',1000,'jvm',0,'user','wchapman','an','myFunction_test') -% Creates & submits a condor job. See parser for input descriptions - -% Bill 2012.10.16 - -%% Parse Inputs -p = inputParser; - -p.addParamValue('f2run', 'none', @(x) ischar(x)); % The name of the function that you would like to run -p.addParamValue('logs', 1, @(x) isnumeric(x)); % Whether or not to keep log files -p.addParamValue('RAMreq', 1000, @(x) isnumeric(x)); % The amount of ram (MB) -p.addParamValue('holderVar', [], @(x) iscell(x)|isstruct(x)); % Variable array with input information for each iteration -p.addParamValue('jvm', 0, @(x) isnumeric(x)); % Whether or not to use the java machine -p.addParamValue('useWindows', 0, @(x) isnumeric(x)); % Whether of not to use Windows machines -p.addParamValue('user', 'lost', @(x) ischar(x)); % The user where to keep the output files (relative to dropboxPath/condor/ ) -p.addParamValue('an', 'lost', @(x) ischar(x)); % Subfolder to keep the log files and output files in. (Stands for "analysis name") -p.addParamValue('superNice', 1, @(x) isnumeric(x)); % By default, only submits to machines owner by you. Useful for prototyping. - -p.parse(varargin{:}); - -f2run = p.Results.f2run; -an = p.Results.an; -holder_var = p.Results.holderVar; -jvm = p.Results.jvm; -logs = p.Results.logs; -RAMreq = p.Results.RAMreq; -superNice = p.Results.superNice; -user = p.Results.user; -useWindows = p.Results.useWindows; - -nowStr = datestr(now,30); % Time stamp used to keep track of intermediate output files. - -%% double check script is prepared to exit after call -% If an error is thrown here, please add "exit" at the line before "end" - -fprintf('checking for exit command: '); -validScript = unix(['grep ''exit'' ' which(f2run)]); -if ~validScript - %error('f2run must call ''exit'' at the end to avoid hanging the job.') -end - - -%% Create EXE -% If user wants to use windows computers, then the first thing to do is -% compile the exe to use on those computers - -if useWindows == 1 - if ~ispc - error('Must submit from a windows machine to execute on windows nodes'); - else - addpath(pwd); - compileState = ['mcc -o ' f2run]; % mcc = "Compile" -o f2run defines which function we are compiling. - compileState = [compileState ' WinMain:end -T link:exe -d' pwd ]; %Make the exe with name f2run.exe in current directory. - compileState = [compileState ' -w enable:specified_file_mismatch -w enable:repeated_file -w enable:switch_ignored -w enable:missing_lib_sentinel -w enable:demo_license']; %Bunch of options to help compile smoothly - compileState = [compileState ' -v' pwd '\' f2run '.m']; % Point to the main file used - compileState = [compileState ' -a' dropboxPath '\Bill\CMBHOME_package']; %Add the minimized CMBHOME package to the EXE. - - eval(compileState); %run it - movefile([f2run '.exe'],[f2run '.WINDOWS']); % Final product: f2run.WINDOWS - end -end - -%% Create the shell for mac & linux machines -fid = fopen([f2run '.OSX'],'w'); -fprintf(fid,'#!/bin/bash \n # \n \n'); -fprintf(fid,'source /condor/pathv \n'); - -if jvm==0 - fprintf(fid,'exec matlab -nojvm -nodisplay -nosplash -r "$*" \n'); % requires that /Applications/MATLAB_VERSION/bin be in your path -else - fprintf(fid,'exec matlab -nodisplay -r "$*" \n'); -end -fclose(fid); - -%% create holder_var file -holder_var_name = [pwd '/' 'holder_var_',nowStr,'.mat']; -save(holder_var_name,'holder_var'); - -%% Create Submit file -fid = fopen([f2run,'.submit'],'w'); -fprintf(fid,'universe = vanilla \n'); -fprintf(fid,'executable = %s.$$(OpSys) \n',f2run); -argument = ['arguments = ' f2run '($(PROCESS),''' holder_var_name ''')']; -fprintf(fid,'%s \n',argument); -fprintf(fid,'transfer_input_files = %s \n',which(f2run)); - -req = 'requirements = ((OpSys == "OSX")'; % Allow macs -req = [req '|| (Target.OpSys == "LINUX")']; - -if useWindows ==1 - req = [req '||(OpSys == "WINDOWS"))']; -else - req = [req ')']; -end - -if superNice == 1 - %req = [req ')']; - req = [req '&& (TARGET.Memory >=' num2str(RAMreq) ,') ']; - req = [req '&& ((TARGET.OWNER == "' user '")) \n']; -else - req = [req ' \n']; -end - -fprintf(fid,req); - -if logs == 1 -% Sets the paths to keep the logs in, based on inputs - - mkdir([dropboxPath '/condor/' user '/' an]) - - sv = ['output = ' dropboxPath '/condor/' user '/' an '/$(CLUSTER).$(PROCESS).out \n']; - fprintf(fid,sv); - - sv = ['log = ' dropboxPath '/condor/' user '/' an '/$(CLUSTER).$(PROCESS).log \n']; - fprintf(fid,sv); - - sv = ['error = ' dropboxPath '/condor/' user '/' an '/$(CLUSTER).$(PROCESS).err \n']; - fprintf(fid,sv); -end - -lengthv = length(holder_var); -fprintf(fid,'queue %d',lengthv); - -fclose(fid); - -%% Submit to manager: -if ispc - dos(['condor_submit' f2run '.submit']); -else - if isempty(getenv('CONDOR_CONFIG')) - setenv('CONDOR_CONFIG','/condor/etc/condor_config'); - setenv('PATH',['/condor/bin:/condor/sbin:',getenv('PATH')]); - end - unix(['chmod 777 ' f2run '.OSX']); - unix(['cp ',f2run,'.OSX ',f2run,'.LINUX']); - unix(['condor_submit ' f2run '.submit']); -end diff --git a/+CMBHOME/+Utils/ContinuizeEpochs.m b/+CMBHOME/+Utils/ContinuizeEpochs.m index 5a81637..e6e0980 100755 --- a/+CMBHOME/+Utils/ContinuizeEpochs.m +++ b/+CMBHOME/+Utils/ContinuizeEpochs.m @@ -1,8 +1,7 @@ function varargout = ContinuizeEpochs(varargin) -% varargout = CMBHOME.Utils.ContinuizeEpochs(varargin); -% % Converts all cell arrays passed through varagin to arrays in varargout % +% % If the cell array is Mx1, then that vararg output is a column vector. If % the cell array is MxN, then the vararg output is a matrix max(cat(M) x N % padded by zeros. @@ -11,6 +10,7 @@ % takes all data from cell arrays in vargin, and continuizes them into % vectors in vargout +% varargout = CMBHOME.Utils.ContinuizeEpochs(varargin); varargout = cell(length(varargin),1); diff --git a/+CMBHOME/+Utils/EllipseDirectFit.m b/+CMBHOME/+Utils/EllipseDirectFit.m index 96b324e..8749410 100755 --- a/+CMBHOME/+Utils/EllipseDirectFit.m +++ b/+CMBHOME/+Utils/EllipseDirectFit.m @@ -1,6 +1,4 @@ function A = EllipseDirectFit(XY) -% coefficients = EllipseDirectFit(XY) -% % Direct ellipse fit, proposed in article % A. W. Fitzgibbon, M. Pilu, R. B. Fisher % "Direct Least Squares Fitting of Ellipses" @@ -22,6 +20,8 @@ % better approximated by a hyperbola. % It is somewhat biased toward smaller ellipses. % +% % coefficients = EllipseDirectFit(XY) + centroid = mean(XY); % the centroid of the data set diff --git a/+CMBHOME/+Utils/FilterEpochs.m b/+CMBHOME/+Utils/FilterEpochs.m index 66d0c75..f28853d 100755 --- a/+CMBHOME/+Utils/FilterEpochs.m +++ b/+CMBHOME/+Utils/FilterEpochs.m @@ -1,11 +1,10 @@ function epoch = FilterEpochs(epoch, mindur, minsep) -% -% epoch = CMBHOME.Utils.Filterepoch(epoch, mindur, minsep) -% -% For an Nx2 array of epoch values (time or otherwise), merges those closer +% For an Nx2 array of epoch values (time or otherwise), merges those closer % than 'minsep' and removes those less than 'mindur' % % andrew 6/29/2011 +% epoch = CMBHOME.Utils.Filterepoch(epoch, mindur, minsep) + [~, inds] = sort(epoch(:,1)); % sort ascending diff --git a/+CMBHOME/+Utils/IntersectEpochs.m b/+CMBHOME/+Utils/IntersectEpochs.m index 899db73..21a5db3 100755 --- a/+CMBHOME/+Utils/IntersectEpochs.m +++ b/+CMBHOME/+Utils/IntersectEpochs.m @@ -1,6 +1,4 @@ function epochs = IntersectEpochs(root, epochs) -% epochs = root.IntersectEpochs(epochs) -% % Returns list of epochs that are contained in both epochs lists { epochs1, epochs2 } % % INPUTS diff --git a/+CMBHOME/+Utils/IntersectEpochs2.m b/+CMBHOME/+Utils/IntersectEpochs2.m index ee87dbe..7173512 100755 --- a/+CMBHOME/+Utils/IntersectEpochs2.m +++ b/+CMBHOME/+Utils/IntersectEpochs2.m @@ -1,12 +1,9 @@ function epochs = IntersectEpochs2(varargin) +% Finds the intersection of all sets of epochs. % epochs = IntersectEpochs2(epochs1, epochs2, epochs3...) % % Must pass at least % -% Finds the intersection of all sets of epochs. -% -% andrew october 14 2011 - import CMBHOME.Utils.* if length(varargin)<2, error('you must pass at least 2 input arguments of type ''epoch'''); end diff --git a/+CMBHOME/+Utils/LinearRegression.m b/+CMBHOME/+Utils/LinearRegression.m index 9e49370..70dd3d7 100755 --- a/+CMBHOME/+Utils/LinearRegression.m +++ b/+CMBHOME/+Utils/LinearRegression.m @@ -1,9 +1,8 @@ function [y_m, R, P, b, y_int] = LinearRegression(x, y, ifPlot) -% [y_m, R, P, b, y_int] = LinearRegression(x, y) % fits x and y to a linear model, and returns the R and P values, along % with y_m, model y values - -% andrew 26 january 2010 +% +% [y_m, R, P, b, y_int] = LinearRegression(x, y) degree=2; % linear regression diff --git a/+CMBHOME/+Utils/MergeEpochs.m b/+CMBHOME/+Utils/MergeEpochs.m index b608365..83637b5 100755 --- a/+CMBHOME/+Utils/MergeEpochs.m +++ b/+CMBHOME/+Utils/MergeEpochs.m @@ -1,16 +1,12 @@ function root = MergeEpochs(root) -% -% root = CMBHOME.Utils.MergeEpochs(root); -% % Returns root with epochs that do not overlap. Touching epochs are merged. % +% % Assumes that all epochs are on the timescale of root.b_ts (all epochs % have samples within them. any epochs without samples within them are % deleted) -% -% v1. andrew -% v2. ehren - +% root = CMBHOME.Utils.MergeEpochs(root); + if ~strcmp(class(root), 'CMBHOME.Session'), error('MergeEpochs has been updated to require new syntax.'); end if size(root.epoch,1)<2, return; end diff --git a/+CMBHOME/+Utils/MergeEpochs2.m b/+CMBHOME/+Utils/MergeEpochs2.m index 775a2ec..3af3855 100755 --- a/+CMBHOME/+Utils/MergeEpochs2.m +++ b/+CMBHOME/+Utils/MergeEpochs2.m @@ -1,7 +1,8 @@ function epochs = MergeEpochs2(epochs, mergetouching) +% merge epochs of arbirary precision without creating binary vector +% % epochs = CMBHOME.Utils.MergeEpochs2(epochs, mergetouching) % -% merge epochs of arbirary precision without creating binary vector % % returned sorted % diff --git a/+CMBHOME/+Utils/MyvarHolder.m b/+CMBHOME/+Utils/MyvarHolder.m index 5b11b65..e50ac49 100755 --- a/+CMBHOME/+Utils/MyvarHolder.m +++ b/+CMBHOME/+Utils/MyvarHolder.m @@ -1,5 +1,6 @@ classdef MyvarHolder - + % Class for arbitrary time series variables. + properties (SetAccess=private, Hidden) p_var % Backup of the original variable, from the time of making the object p_ts % Backup of the original timestamps, from the time o fmaking the object diff --git a/+CMBHOME/+Utils/OverThresholdDetect.m b/+CMBHOME/+Utils/OverThresholdDetect.m index 984941a..ccf1ed8 100755 --- a/+CMBHOME/+Utils/OverThresholdDetect.m +++ b/+CMBHOME/+Utils/OverThresholdDetect.m @@ -1,10 +1,9 @@ function [ind,tf] = OverThresholdDetect(A, thresh, min_sep, min_length) -% ind = ThresholdDetect(A, thresh, min_sep, min_length); -% [ind, epochs] = ThresholdDetect(A, thresh, min_sep, min_length); -% % Searches for continuous epochs for which A is at least thresh, merges those % separated by less than min_sep indices, and returns ind, an Nx2 array of % indices for continuous epochs over thresh +% ind = ThresholdDetect(A, thresh, min_sep, min_length); +% [ind, epochs] = ThresholdDetect(A, thresh, min_sep, min_length); A = A(:); diff --git a/+CMBHOME/+Utils/PipeRaster.m b/+CMBHOME/+Utils/PipeRaster.m index da8d40a..759f550 100755 --- a/+CMBHOME/+Utils/PipeRaster.m +++ b/+CMBHOME/+Utils/PipeRaster.m @@ -1,5 +1,4 @@ function PipeRaster(cellin, varargin) - % Scatters the time course of a single element on ydim with the pipe '|' % character. Existing plot must be 'held' diff --git a/+CMBHOME/+Utils/RemoveJumpsAndSmooth.m b/+CMBHOME/+Utils/RemoveJumpsAndSmooth.m index 5f12a1c..e7496ca 100755 --- a/+CMBHOME/+Utils/RemoveJumpsAndSmooth.m +++ b/+CMBHOME/+Utils/RemoveJumpsAndSmooth.m @@ -1,6 +1,5 @@ function x = RemoveJumpsAndSmooth(x, max_allowed_flips, jitter_threshold, smooth_std,filter_def) -% x = RemoveJumpsAndSmooth(x, max_flip_length, jitter_threshold, smooth_std); -% +% Removes large jumps in data, smoothes the removed regions % ARGUMENTS % x a vector of something. NaNs may be used in place of % known bad samples @@ -17,7 +16,7 @@ % then linearly interpolate the missed samples and smooth by convolution % with a gaussion of standard deviation smooth_std bins. % -% andrew june 15 2011 +% x = RemoveJumpsAndSmooth(x, max_flip_length, jitter_threshold, smooth_std); import CMBHOME.Utils.* diff --git a/+CMBHOME/+Utils/LogRegression.m b/+CMBHOME/+Utils/SaturatingRegression.m old mode 100755 new mode 100644 similarity index 88% rename from +CMBHOME/+Utils/LogRegression.m rename to +CMBHOME/+Utils/SaturatingRegression.m index be52dd1..0fec502 --- a/+CMBHOME/+Utils/LogRegression.m +++ b/+CMBHOME/+Utils/SaturatingRegression.m @@ -1,10 +1,8 @@ -function [y_model,fit_params,rsquare,goodness] = LogRegression(x, y) -% [fit,params,rsquare,goodness] = CMBHOME.Utils.LogRegression(x,y) -% +function [y_model,fit_params,rsquare,goodness] = SaturatingRegression(x, y) % Does a natural growth fit and returns the model expected values, % parameters of best fit, rsquare value, and other goodness object. - -% Bill 23rd October 2012 +% +% [fit,params,rsquare,goodness] = CMBHOME.Utils.LogRegression(x,y) if length(x)~=length(y) error('LogRegression needs x and y with same lengths'); @@ -18,7 +16,7 @@ return; end -x = x(:); +x = x(:);1 y = y(:); tf = isnan(x) | isnan(y); % remove NaNs diff --git a/+CMBHOME/+Utils/SelectEpochs.m b/+CMBHOME/+Utils/SelectEpochs.m index 5dcf76f..bc80f26 100755 --- a/+CMBHOME/+Utils/SelectEpochs.m +++ b/+CMBHOME/+Utils/SelectEpochs.m @@ -1,8 +1,8 @@ function epochs = SelectEpochs(epochs, validepochs, partials) -% +% Takes epochs that exist within valid epochs, + % CMBHOME.Utils.SelectEpochs(epochs, validepochs) % -% Takes epochs that exist within valid epochs, % % INPUTS % epochs - Nx2 array, epochs (time1 time2;...) diff --git a/+CMBHOME/+Utils/SmartColorbar.m b/+CMBHOME/+Utils/SmartColorbar.m index c72a2c0..af0cd10 100755 --- a/+CMBHOME/+Utils/SmartColorbar.m +++ b/+CMBHOME/+Utils/SmartColorbar.m @@ -1,6 +1,4 @@ function [cbar, clims] = SmartColorbar(clims, cmap_style) -% CMBHOME.Utils.SmartColorbar(clims, cmap_style) -% % finds the proper value for null data points to be plotted as white in an % IMAGESC plot, or similar. % diff --git a/+CMBHOME/+Utils/SpkInds.m b/+CMBHOME/+Utils/SpkInds.m index cec2cab..ee3bcf5 100755 --- a/+CMBHOME/+Utils/SpkInds.m +++ b/+CMBHOME/+Utils/SpkInds.m @@ -1,8 +1,5 @@ function inds = SpkInds(t, spk) - -% this function replaces spike_location, which used to incorrectly align -% spike times with video stamps and spit out spk_x, spk_y and spk_t. Now, -% we just have spk_ind, which are indices in structin.x, etc +% Aligns two different timebases by using indices count = hist(spk, t); diff --git a/+CMBHOME/+Utils/SplitVec.m b/+CMBHOME/+Utils/SplitVec.m index a866bcf..c69dd64 100755 --- a/+CMBHOME/+Utils/SplitVec.m +++ b/+CMBHOME/+Utils/SplitVec.m @@ -1,7 +1,4 @@ function varargout = SplitVec(v, fun, varargin) -% [out1, out2, ...] = SplitVec(V, FUN, type1, type2, ...) -% [out1, out2, ...] = SplitVec(V, COL, type1, type2, ...) -% % Purpose: Partition an input vector V into smaller series of subvectors % of consecutive elements based on split points % @@ -77,7 +74,9 @@ % 02-Feb-2010: correct bug when 'loc' is required when working % down the columns of matrix (NUMEL(V) -> SIZE(V,1)) % 26-Aug-2011: New builtin outputs: blockID and subsetorder - +% +% [out1, out2, ...] = SplitVec(V, FUN, type1, type2, ...) +% [out1, out2, ...] = SplitVec(V, COL, type1, type2, ...) isrow = false; % Reshape a row vector in column vector if isvector(v) && size(v,1)==1 diff --git a/+CMBHOME/+Utils/SubplotSub2Ind.m b/+CMBHOME/+Utils/SubplotSub2Ind.m index 8c18a3e..b268b49 100755 --- a/+CMBHOME/+Utils/SubplotSub2Ind.m +++ b/+CMBHOME/+Utils/SubplotSub2Ind.m @@ -1,9 +1,9 @@ function ind = SubplotSub2Ind(size, pos) -% ind = CMBHOME.Utils.SubplotSub2Ind(size(mat),[row col]) +% 2D subplot position to 1d index (for subplot) % % pos is the row, col (top left corner is 1,1) % size is the [rows, cols] of subplot -% andrew oct 13 2010 +%ind = CMBHOME.Utils.SubplotSub2Ind(size(mat),[row col]) M = size(2); diff --git a/+CMBHOME/+Utils/anglecor2.m b/+CMBHOME/+Utils/anglecor2.m deleted file mode 100755 index b64cf19..0000000 --- a/+CMBHOME/+Utils/anglecor2.m +++ /dev/null @@ -1,45 +0,0 @@ -function [ rho,p,s,b ] = anglecor2( x,theta,varargin ) - -import CMBHOME.Utils.*; - -if nargin==1, s=varargin{1}; varargin = {}; end; - -if strcmp(class(x),'single') - x = double(x); -end - -goods = ~isnan(x)&~isnan(theta); -x = x(goods); -theta = theta(goods); - -if ~exist('s','var') - [s,b]=anglereg(x,theta,varargin{:}); -end - -n = length(x); - -phi = mod(s*x,2*pi); -theta = mod(theta,2*pi); - -phi_ = angle(sum(exp(1i*phi))/n); -theta_ = angle(sum(exp(1i*theta))/n); - -rho = abs(sum(sin(theta-theta_).*sin(phi-phi_))/... - sqrt(sum(sin(theta-theta_).^2)*sum(sin(phi-phi_).^2)))*sign(s); - -% if strcmp(class(rho),'single') -% keyboard -% end - -t = sign(rho) .* Inf; - -k = (abs(rho) < 1); -t(k) = rho(k).*sqrt((n-2)./(1-rho(k).^2)); - -p = 2*tcdf(-abs(t),n-2); - - -end - -%% - diff --git a/+CMBHOME/+Utils/anglediff.m b/+CMBHOME/+Utils/anglediff.m index 02aa9e1..4a7aed1 100755 --- a/+CMBHOME/+Utils/anglediff.m +++ b/+CMBHOME/+Utils/anglediff.m @@ -1,4 +1,5 @@ function k = anglediff(varargin) + % Finds angular difference between two vectors p = inputParser; p.addRequired('A',@isnumeric); p.addOptional('B',NaN,@isnumeric); diff --git a/+CMBHOME/+Utils/anglemean.m b/+CMBHOME/+Utils/anglemean.m deleted file mode 100755 index d15d539..0000000 --- a/+CMBHOME/+Utils/anglemean.m +++ /dev/null @@ -1,16 +0,0 @@ -function k = anglemean(theta,r,weight) - if exist('r','var') - if isscalar(r), r=[-r r]; end; - theta = 2*pi*(theta-r(1))/range(r)-pi; - end - - if ~exist('weight','var') - weight = ones(size(theta)); - end - - k = angle(sum(weight.*exp(1i*theta))/sum(weight)); - - if exist('r','var') - k = (k+pi)/(2*pi)*range(r)+r(1); - end -end \ No newline at end of file diff --git a/+CMBHOME/+Utils/anglereg.m b/+CMBHOME/+Utils/anglereg.m deleted file mode 100755 index 9531e42..0000000 --- a/+CMBHOME/+Utils/anglereg.m +++ /dev/null @@ -1,53 +0,0 @@ -function [ s,b ] = anglereg( x, theta, tolerance, maxiter ) - - -if ~exist('tolerance','var') - tolerance=0; -end - -if ~exist('maxiter','var'); - maxiter=inf; -end - -theta = mod(theta,2*pi); - -if size(x,1)>size(x,2) - x = x'; -end -if size(theta,1)>size(theta,2) - theta = theta'; -end - -step = 100; -rng = [-50*pi 50*pi]; -n = length(x); - -nn = 0; - -while nntolerance - - s = unique(linspace(rng(1),rng(2),step)'); - - % plot(s,sqrt((sum(cos(repmat(theta,[length(s) 1])-s*x),2)/n).^2+(sum(sin(repmat(theta,[length(s) 1])-s*x),2)/n).^2)); - % pause(0.5); - - [~,k]=max(sqrt((sum(cos(repmat(theta,[length(s) 1])-s*x),2)/n).^2+(sum(sin(repmat(theta,[length(s) 1])-s*x),2)/n).^2)); - rng = s(k)+[-2 2]*range(rng)/step; - - nn=nn+1; -end - -s = s(k); - -%% -rng = [0 2*pi]; - -nn=0; - -while nntolerance - b = unique(linspace(rng(1),rng(2),step)'); - [~,k] = min(sum((mod(repmat(s*x,[length(b) 1])+repmat(b,[1 n]),2*pi)-mod(repmat(theta,[length(b) 1]),2*pi)).^2,2)); - rng = b(k)+[-2 2]*range(rng)/step; -end - -b = b(k); \ No newline at end of file diff --git a/+CMBHOME/+Utils/anglewrap.m b/+CMBHOME/+Utils/anglewrap.m deleted file mode 100755 index e702627..0000000 --- a/+CMBHOME/+Utils/anglewrap.m +++ /dev/null @@ -1,17 +0,0 @@ -function [ X ] = anglewrap( X,r) - -if ~exist('r','var') - r = [-pi pi]; -end - -if isscalar(r) - r = [-r r]; -end - -X = (X-r(1))/range(r); -X(X<=0)=1+rem(X(X<0),1); -X(X>1)=mod(X(X>1),1); -X = X*range(r)+r(1); - -end - diff --git a/+CMBHOME/+Utils/array2path.m b/+CMBHOME/+Utils/array2path.m index 263faf0..a97d581 100755 --- a/+CMBHOME/+Utils/array2path.m +++ b/+CMBHOME/+Utils/array2path.m @@ -1,7 +1,6 @@ function [fname] = array2path(fnameArray,replaceString) -% [fname] = array2path(fnameArray) -% -% Recombines the strings stored in fnameArray with the system appropriate +% Recombines the strings stored in fnameArray +% with the system appropriate % filesep symbol to generate a valid path. % % INPUT ARGS: @@ -12,6 +11,7 @@ % fname - a string with the path using the system appropriate file % seperators (\ or /). The final character is never a file seperator. % +% [fname] = array2path(fnameArray) % eln 100519 cv=0; diff --git a/+CMBHOME/+Utils/cell2mat2.m b/+CMBHOME/+Utils/cell2mat2.m index 2b7fa30..2ac0241 100755 --- a/+CMBHOME/+Utils/cell2mat2.m +++ b/+CMBHOME/+Utils/cell2mat2.m @@ -1,5 +1,5 @@ function [ a ] = cell2mat2( b ) - + % cell2mat, but rotates vectors where 90* off if iscell(b) if ~(all(cellfun(@(x)size(x,1),b)==size(b,1))||all(cellfun(@(x)size(x,2),b)==size(b,2))) diff --git a/+CMBHOME/+Utils/circ_mean.m b/+CMBHOME/+Utils/circ_mean.m index d3f1fc8..506046f 100755 --- a/+CMBHOME/+Utils/circ_mean.m +++ b/+CMBHOME/+Utils/circ_mean.m @@ -1,7 +1,7 @@ function [mu ul ll] = circ_mean(alpha, w) +% Computes the mean direction for circular data. % % mu = circ_mean(alpha, w) -% Computes the mean direction for circular data. % % Input: % alpha sample of angles in radians diff --git a/+CMBHOME/+Utils/circ_r.m b/+CMBHOME/+Utils/circ_r.m index bf0caab..236054a 100755 --- a/+CMBHOME/+Utils/circ_r.m +++ b/+CMBHOME/+Utils/circ_r.m @@ -1,6 +1,5 @@ function r = circ_r(alpha, w, d) -% r = circ_r(alpha, w, d) -% Computes mean resultant vector length for circular data. +% Computes mean resultant vector length for circular data. % % Input: % alpha sample of angles in radians diff --git a/+CMBHOME/+Utils/circ_rtest.m b/+CMBHOME/+Utils/circ_rtest.m index 19d3558..57917ac 100755 --- a/+CMBHOME/+Utils/circ_rtest.m +++ b/+CMBHOME/+Utils/circ_rtest.m @@ -1,7 +1,7 @@ function [pval z] = circ_rtest(alpha, w, d) +% Computes Rayleigh test for non-uniformity of circular data. % % [pval, z] = circ_rtest(alpha,w) -% Computes Rayleigh test for non-uniformity of circular data. % H0: the population is uniformly distributed around the circle % HA: the populatoin is not distributed uniformly around the circle % Assumption: the distribution has maximally one mode and the data is diff --git a/+CMBHOME/+Utils/circcor.m b/+CMBHOME/+Utils/circcor.m index f080695..0bc9994 100755 --- a/+CMBHOME/+Utils/circcor.m +++ b/+CMBHOME/+Utils/circcor.m @@ -1,7 +1,8 @@ function [Un, Dn] = circcor( circvar, linearvar ) +% % CIRCCOR correlates a circular variable with a linear variable +% % [UN, DN] = circcor( circvar, linearvar ) % -% CIRCCOR correlates a circular variable with a linear variable % and returns a U-value, which should be compared to the lookup % table on pg. 231 of 'Statistical analysis of circular data.' % Fisher (1993). diff --git a/+CMBHOME/+Utils/corrC2L.m b/+CMBHOME/+Utils/corrC2L.m index c3377d9..df06a52 100755 --- a/+CMBHOME/+Utils/corrC2L.m +++ b/+CMBHOME/+Utils/corrC2L.m @@ -1,6 +1,4 @@ -function [x,phi,a,phi_knot,rho_c,p] = corrC2L(x,phi) -% [x,phi,slo,inter,rho,p] = utils.corrC2L(x,phi) -% +function [x,phi,a,phi_knot,rho_c,p] = corrC2L(x,phi) % Find the linear correlation between a linear and circular variable as in % R. Kempter 2012, Journal of Neuroscience Methods. % @@ -13,8 +11,8 @@ % phi_knot - Best-fit intercept (radians) % rho_c - correlation coefficient % p - Significance value (unreliable for small datasets) - -% wchapman 2012.12.05 +% +% [x,phi,slo,inter,rho,p] = utils.corrC2L(x,phi) bads = isnan(x) | isnan(phi); x(bads) = []; diff --git a/+CMBHOME/+Utils/findOnsetsAndOffsets.m b/+CMBHOME/+Utils/findOnsetsAndOffsets.m index 9461030..51122f6 100755 --- a/+CMBHOME/+Utils/findOnsetsAndOffsets.m +++ b/+CMBHOME/+Utils/findOnsetsAndOffsets.m @@ -1,6 +1,4 @@ function [OnOffs] = findOnsetsAndOffsets(boolVec) -% function [OnOffs] = findOnsetsAndOffsets(boolVec) -% % Returns list of aligned start and stops of chunks of 1's in a vector of % 1's and 0's. % @@ -11,10 +9,8 @@ % startEnds - Nx2 list of indices of the first and last 1's for the N % contiguous blocks of 1's. % +% % function [OnOffs] = findOnsetsAndOffsets(boolVec) -% created 6/16/11 eln -% update 7/5/11 arb line 1 -% update 7/6/11 eln line 26 boolVec = boolVec(:)'; diff --git a/+CMBHOME/+Utils/histcn.m b/+CMBHOME/+Utils/histcn.m index 33ad671..fe319c0 100755 --- a/+CMBHOME/+Utils/histcn.m +++ b/+CMBHOME/+Utils/histcn.m @@ -1,7 +1,7 @@ function [count, edges, mid, loc] = histcn(X, varargin) +% Purpose: compute n-dimensional histogram % function [count edges mid loc] = histcn(X, edge1, edge2, ..., edgeN) % -% Purpose: compute n-dimensional histogram % % INPUT % - X: is (M x N) array, represents M data points in R^N diff --git a/+CMBHOME/+Utils/moserac.m b/+CMBHOME/+Utils/moserac.m index 4c219c7..2167a5b 100755 --- a/+CMBHOME/+Utils/moserac.m +++ b/+CMBHOME/+Utils/moserac.m @@ -1,7 +1,8 @@ function CC = moserac(X, X2, threshold) +% Returns 2-d autocorrelation of matrix M with normalization standards as used by Mosers +% % AC = CMBHOME.Utils.moserac(M1, M2, thresh) % -% Returns 2-d autocorrelation of matrix M with normalization standards as used by Mosers % % ARGUMENTS % M1 N x M matrix, like a ratemap diff --git a/+CMBHOME/+Utils/myPolar.m b/+CMBHOME/+Utils/myPolar.m index 114cf58..7fdc3ec 100755 --- a/+CMBHOME/+Utils/myPolar.m +++ b/+CMBHOME/+Utils/myPolar.m @@ -1,5 +1,4 @@ function hpol = myPolar(theta,rho,maxrho,line_style) - % this is same as polar, but you can set the maximum rho value. if nargin < 1 diff --git a/+CMBHOME/+Utils/nanInterp.m b/+CMBHOME/+Utils/nanInterp.m index 0c731ef..32ec9f1 100755 --- a/+CMBHOME/+Utils/nanInterp.m +++ b/+CMBHOME/+Utils/nanInterp.m @@ -1,11 +1,7 @@ function [ X ] = nanInterp( X, method) -% x_interpolated = CMBHOME.Utils.nanInterp(x) -% % Interpolates all Nan's in the input vector, according to the second input % argument "method". Defaults to nearest neighbor interpolation. -% Bill 2013.01.08 - if ~exist('method','var'), method = 'nearest'; end; if all(isnan(X)) diff --git a/+CMBHOME/+Utils/path2array.m b/+CMBHOME/+Utils/path2array.m index 92f2308..d9768fc 100755 --- a/+CMBHOME/+Utils/path2array.m +++ b/+CMBHOME/+Utils/path2array.m @@ -1,5 +1,5 @@ function [fnameArray] = path2array(fname,refString) -% function [fnameArray] = path2array(fname) +% Splits a path in to cell aray, breaking upon filesep % % takes in a string representing the path to a file or folder and breaks it % into a cell array in which each cell holds the portions of the filename diff --git a/+CMBHOME/+Utils/RunningEpochs.m b/+CMBHOME/@Session/RunningEpochs.m old mode 100755 new mode 100644 similarity index 93% rename from +CMBHOME/+Utils/RunningEpochs.m rename to +CMBHOME/@Session/RunningEpochs.m index 7d9de27..c0acce0 --- a/+CMBHOME/+Utils/RunningEpochs.m +++ b/+CMBHOME/@Session/RunningEpochs.m @@ -1,5 +1,5 @@ function [self, success] = RunningEpochs(self, lower_threshold, upper_threshold, speed_dur) - + % Sets lower and upper thresholds for running speed & sets epochs accordingy import CMBHOME.Utils.* success = 0; diff --git a/+CMBHOME/@Session/Session.m~ b/+CMBHOME/@Session/Session.m~ deleted file mode 100644 index f06743c..0000000 --- a/+CMBHOME/@Session/Session.m~ +++ /dev/null @@ -1,2097 +0,0 @@ -% This is a standard data format class for in vivo spiking, video tracking, -% and lfp data at the CMB at Boston University. See -% http://conte.bu.edu/repos/abogaard/+CMBHOME/README_CMBHOME.pdf and -% TutorialData.zip for a tutorial. -% -% ACCESSING DOCUMENTATION -% -% >> doc CMBHOME.Session; % for documentation on root objects -% >> doc CMBHOME.LFP; % for documentation on LFP objects -% >> doc CMBHOME.Spike; % for documentation on Spike objects (units) -% -% By default epochs work like ts>=epoch(1) & ts<=epoch(2). The hidden field -% root.ops = {'ge', 'le'} may change this -% -% All vectors are Nx1 -% -% Version History -% -% v1 15 april 2010 presented and released -% v1.1 26 may 2010 changed root.spk_*(tetrode_i, cell_i) to -% root.spk_*(cel) to match convention -% v1.2 18 june 2010 added epoch_group to indicate epochs which indicate -% the same type of event -% v1.3 8 july 2010 added notes property -% v1.4 18 august 2010 added active LFP file property and how we handle -% LFP objects -% v1.5 11 jan 2011 added spk property, as well as user-defined "cel" -% property, updated behavior of root.vel. (if -% root.b_vel exists, it uses this. if not, simple -% derivative is used). also added the -% root.name_formatted field so that now the objects -% work in a relative naming convention if desired -% v2 14 oct 2011 greatly improved speed and inter-dependencies -% between properties -% 25 feb 2013 Added rotate and shift properties, as well as svel, sx, sy, and sheaddir dependent properties. -% andrew robert bogaard 2/10-9/11 - -classdef Session - - properties (Hidden) - - ops = {'ge', 'le'} % operators for epochs behavior - - end - - properties (Access=private) - - p_ind % same as root.ind, but set by set.epoch - p_lfp_ind - p_cel_ind % indices in root.b_ts and root.b_lfp(active_lfp).ts for each cell spike. set with set.cel - p_cel_spkind % indices in root.spike(cel(1), cel(2)).ts for each spike in the epoch. set with set.cel - p_cel_lfp_ind - - end - - properties - - date_created % date and time created as a serial date number (see 'doc now') - notes % cell array of notes and dates {datestamp, str_note} - spike % object array of class 'Spike', contains unit data - name % 1xM cellstr of directory and filename of current object. - cell_thresh = [0,0] % threshold of minimum spike rate [minimum spike frequency, check drift] - fs_video % sampling rate from video (samples/sec) - raw_pos=1 % boolean, is this uncorrected position? - raw_headdir=1 % boolean, is this uncorrected head direction? - event = cell(1, 2) % event flags, Nx2 cell array, {'label', time} - path_lfp % cell array of fnames to lfp recording data - path_raw_data % path to original recording data - spatial_scale=.5 % cm/pixel - - rotate=0 % deg rotation - shift=[0 0] % cm translation - - epoch_group % vector, Nx1, N is number of epochs with integer indicating like-epochs - user_def % property that may be whatever user defines, ex. struct of relevant - version = 1.5 % version control - b_lfp % object array of structs with fields ts, signal, path_lfp_index ex - myvar2 - end - - properties (Access=private, Hidden) - - p_epoch - p_cel - p_active_lfp - p_b_x - p_b_y - p_b_vel - p_b_headdir - p_b_ts - p_b_myvar - - end - - properties (Dependent) - - epoch % array, Nx2, start and stop times that exists (can be inf or -inf) - cel % Nx2 array of [tetrode, cell index] - active_lfp % index to root.path_lfp indicating which LFP is loaded (or to be loaded) - - end - - properties (Dependent, Hidden) - - b_x % x position - b_y % y position - b_vel % user defined velocity, if undefined, the derivative of b_x and b_y is used - b_headdir % head direction - b_ts % timestamps - b_myvar % other time varying variable - - end - - properties (Dependent=true, SetAccess=private) - - vel % velocity, within start and stop epoch (pixels/sec) - svel % velocity, (cm/sec) - x % x position (pixels) - y % y position (pixels) - sx % x position (cm) - sy % y position (cm) - sheaddir % headdir (degrees,-180:180) - ind % index in root.b_ts - ts % timestamps (seconds) - myvar % Arbitrary time varying variable - b_epoch_group % vector, Nx1, N is number of epochs with integer indicating like-epochs - headdir % head direction, (degrees, -180:180) - cells % Nx2 array of cells which meet specs_cell above, [tetrode, cell;...] - active_event % an Nx2 element cell array with event labels (if exist) that match current epoch times. - % N is the number of rows in root.epochs - lfp % object array of LFP objects of fields ts and signal - spk % struct with fields representing data at spike times of root.cel - name_formatted % this is the root.name field formatted for the current platform - cel_x % x position at spike times of root.cel - cel_sx % x position at spike times of root.cel - cel_y % x position at spike times of root.cel - cel_sy % x position at spike times of root.cel - cel_vel % x position at spike times of root.cel - cel_svel % x position at spike times of root.cel - cel_ts % x position at spike times of root.cel - cel_headdir % x position at spike times of root.cel - cel_sheaddir % x position at spike times of root.cel - cel_i % x position at spike times of root.cel - cel_theta % x position at spike times of root.cel - cel_thetaphase % x position at spike times of root.cel - cel_myvar % x position at spike times of root.cel - cel_myvar2 % x position at spike times of root.cel - - end - - methods (Static) - - [t,x,y,vx,vy,ax,ay] = KalmanVel(posx,posy,post,order,Q,R); - - function root = MergeSessions(cellarray_filename) %#ok - % (1) root = CMBHOME.Session.MergeSessions - % (2) root = CMBHOME.Session.MergeSessions(cellarray_filenames) - % - % Merges multiple Session objects by stitching together time - % indeces. Saves original Session times as events - % - % (1) Prompts user to select files to merge, stiches them together - % in the order selected - % (2) Accepts a cell array of file names to be merged. Stitches - % them together in the order of cellarray_filenames - % - % andrew 24 may 2010 - - warning('CMBH:notify', '%s', 'Warning: If you want to merge the LFP as well you must load it, resave the files, then run this function'); - - import CMBHOME.* - f_ind=1; - if ~exist('cellarray_filenames', 'var') - while 1 % loop until user cancels, and we get no files - - [load_files, base_path] = uigetfile('*.mat','Please select Session object mat files to merge. Exit to finish.',pwd, 'MultiSelect', 'on'); - - if iscell(load_files) - for i = 1:length(load_files) - fopen(f_ind) = {fullfile(base_path, load_files{i})}; %#ok - f_ind = f_ind+1; - end - elseif ischar(load_files) - fopen(f_ind) = {fullfile(base_path, load_files)}; %#ok - f_ind = f_ind+1; - else - break; % exit loop collecting files - end - - end - else - fopen = cellarray_filenames; - end - - clear x, clear y, clear ts, clear hd, clear vel - clear spike, clear even, clear event, clear lfp - for i = 1:length(fopen) - tmp = load(fopen{i}); - x{i}=tmp.root.b_x; - y{i}=tmp.root.b_y; - ts{i}=tmp.root.b_ts; - hd{i}=tmp.root.b_headdir; - vel{i}=tmp.root.vel; - spike{i}=tmp.root.spike; - event{i}=tmp.root.event; - lfp{i}=tmp.root.b_lfp; - fs = tmp.root.fs_video; - ss = tmp.root.spatial_scale; - end - - x=CMBHOME.Utils.ContinuizeEpochs(x(:)); y=CMBHOME.Utils.ContinuizeEpochs(y(:)); - hd=CMBHOME.Utils.ContinuizeEpochs(hd(:)); vel=CMBHOME.Utils.ContinuizeEpochs(vel(:)); - event=CMBHOME.Utils.ContinuizeEpochs(event(:)); - - %ts - firsts = cellfun(@(x) x(1), ts); - ts=cellfun(@(x) x-x(1), ts,'UniformOutput',0); - ends = cellfun(@(x) x(end), ts); - offset = [0 ends(1:end-1)+ts{1}(1)]; - offset = cumsum(offset); - ts=arrayfun(@(x,y) x{1}+y, ts,offset,'UniformOutput',0); - ts=CMBHOME.Utils.ContinuizeEpochs(ts(:)); - - %spike - spk_ts = cell(size(spike{1})); - for i = 1:numel(spike) - for k = 1:numel(spike{i}) - spk_ts{k} = [spk_ts{k}; spike{i}(k).ts + offset(i)-firsts(i)]; - end - end - - for i = 1:numel(spk_ts) - if ~isempty(spk_ts{i}) - spike2(i) = CMBHOME.Spike('ts',spk_ts{i},'vid_ts',ts); - else - spike2(i) = CMBHOME.Spike(); - end - end - sz=max(CMBHOME.Utils.ContinuizeEpochs(cellfun(@(x) size(x), spike(:),'UniformOutput',0))); - spike=reshape(spike2,sz); - - %LFP - lfp_fs=lfp{1}.fs; - lfp_sig=cell(size(lfp{1})); lfp_ts=cell(size(lfp{1})); - for i = 1:numel(lfp) - for k = 1:numel(lfp{i}) - lfp_ts{k} = [lfp_ts{k}; lfp{i}(k).ts+offset(i)-firsts(i)]; - lfp_sig{k} = [lfp_sig{k}; lfp{i}(k).signal]; - end - end - - for i = 1:numel(lfp_ts) - lfp2(i) = CMBHOME.LFP(lfp_sig{i}, lfp_ts{i},lfp_fs,'merged'); - end - - % Make it: - root = Session('b_x',x,'b_y',y,'b_headdir',hd,'b_ts',ts,... - 'fs_video',fs, 'spatial_scale',ss,... - 'b_lfp',lfp2, 'spike', spike); - - end - end - - methods - - function self = Session(varargin) - - import CMBHOME.Spike - - p = inputParser; - - p.addParamValue('name', 'default session name', @(x) ischar(x)||iscellstr(x)); - p.addParamValue('b_x', [], @(x) any(size( x)<=1)); - p.addParamValue('b_y', [], @(x) any(size(x)<=1)); - p.addParamValue('b_headdir', [], @(x) any(size(x)<=1)); - p.addParamValue('b_ts', [], @(x) any(size(x)<=1)); - p.addParamValue('b_lfp', CMBHOME.LFP, @(x) isstruct(x)||isa(x,'CMBHOME.LFP')); - p.addParamValue('fs_video', [], @(x) length(x)==1); - p.addParamValue('raw_pos', [], @(x) length(x)==1); - p.addParamValue('raw_headdir', [], @(x) length(x)==1); - p.addParamValue('event', cell(1,2), @(x) iscell(x)); - p.addParamValue('rem_ts', [], @(x) length(x)==1); - p.addParamValue('ripple_ts', [], @(x) length(x)==1); - p.addParamValue('path_lfp', []); - p.addParamValue('path_raw_data',[]); - p.addParamValue('date_created', now, @(x) isnumeric(x)); - p.addParamValue('spatial_scale',.5, @(x) length(x)==1); - p.addParamValue('epoch', [-inf inf], @(x) numel(x)==2); - p.addParamValue('spike', Spike, @(x) isa(x, 'CMBHOME.Spike')); - - p.parse(varargin{:}); - - self.name = p.Results.name; - self.notes = { date, ['Session object created, and saved to ', p.Results.name] }; - self.b_x = p.Results.b_x; - self.b_y = p.Results.b_y; - self.b_headdir = p.Results.b_headdir; - self.b_ts = p.Results.b_ts; - self.b_lfp = p.Results.b_lfp; - self.fs_video = p.Results.fs_video; - %self.fs = p.Results.fs; - self.raw_pos = p.Results.raw_pos; - self.raw_headdir = p.Results.raw_headdir; - self.event = p.Results.event; - self.path_lfp = p.Results.path_lfp; - self.path_raw_data = p.Results.path_raw_data; - self.date_created = p.Results.date_created; - self.spatial_scale = p.Results.spatial_scale; - - if ~isempty(self.b_ts) - self.epoch = p.Results.epoch; - end - - if isempty(self.fs_video)&&~isempty(self.b_ts) - self.fs_video = 1/mean(diff(self.b_ts)); - end - - if isempty(self.b_ts)&&~isempty(self.fs_video) - self.b_ts = (0:numel(self.b_x)-1)/self.fs_video; - end - - - self.spike = p.Results.spike; - end - - - %% DEPENDENT STATE VARIABLES - - function self = set.epoch(self, epoch) - % makes sure that all epochs are valid periods of time, and that - % the array is formatted correctly. - - if isempty(self.b_ts), error('root.b_ts must be set to use epochs'); end - - %tmin = self.b_ts(1); - %tmax = self.b_ts(end); - - if numel(epoch)==2, epoch = epoch(:)'; end - - if size(epoch,2)~=2 - error('Epoch must be a matrix with columns [start times, stop times]'); - end - - if any(epoch(:,2)-epoch(:,1)<=0) % check that all starts and stops are start0 && active_lfp<=length(self.b_lfp) - self.p_active_lfp = active_lfp; - elseif isempty(active_lfp) - self.p_active_lfp = []; - else - disp('root.active_lfp not set because it was not a valid index for root.b_lfp') - self.p_active_lfp = []; - end - - self = SetCelInds(self); - - end - - function active_lfp = get.active_lfp(self) - - active_lfp = self.p_active_lfp; - - end - - function self = set.cel(self, cel) - % sets the root.cel property (Nx2, [tetrode, cell_ind]) - - cells = ValidCells(self); - %cells = cel; - if isempty(cel), self.p_cel = []; self = SetCelInds(self); return, end - - if size(cel, 2)~=2, warning('CMBH:error', 'root.cel must be Nx2, [tetrode, cell_ind]'); return; end - - if ~isnumeric(cel), warning('CMBH:error', 'root.cel must be Nx2, [tetrode, cell_ind]'); return; end - - if any(~ismember(cel, cells, 'rows')) - warning('CMBH:error', 'error, some of root.cel are not cells, or do not pass root.cell_thresh. removed the following cells:'); - disp(num2str(cel(find(~ismember(cel, cells, 'rows')),:))); - cel(find(~ismember(cel, cells, 'rows')),:) = []; - end - - if all(size(cel)==size(self.p_cel)) - - if all(cel==self.p_cel) % you're trying to reset the same cells, so dont rerun the indexing - - return - - end - - end - - self.p_cel = cel; - - self = SetCelInds(self); % update the indices for the cells which are set - - end - - function cel = get.cel(self) - - cel = self.p_cel; - - end - - - %% DEPENDENT BASE VARIABLES - - function self = set.b_x(self, b_x) - % sets p_b_x. must be either empty or the same length as other base variables - - if (~isnumeric(b_x) && ~isvector(b_x)) && ~isempty(b_x) - error('X data must be numerical vector'); - end - - l = CheckBaseVarLength(self); - - if (l~=0 && length(b_x)~=l) && ~isempty(b_x) - - error('b_x must be the same length as all other base variables'); - - end - - self.p_b_x = b_x(:); - - end - - function self = set.b_y(self, b_y) - % sets p_b_y. must be either empty or the same length as other base variables - - if (~isnumeric(b_y) && ~isvector(b_y)) && ~isempty(b_y) - error('y data must be numerical vector'); - end - - l = CheckBaseVarLength(self); - - if (l~=0 && length(b_y)~=l) && ~isempty(b_y) - - error('b_y must be the same length as all other base variables'); - - end - - self.p_b_y = b_y(:); - - end - - function self = set.b_vel(self, b_vel) - % sets p_b_vel. must be either empty or the same length as other base variables - - if (~isnumeric(b_vel) && ~isvector(b_vel)) && ~isempty(b_vel) - error('vel data must be numerical vector'); - end - - l = CheckBaseVarLength(self); - - if (l~=0 && length(b_vel)~=l) && ~isempty(b_vel) - - error('b_vel must be the same length as all other base variables'); - - end - - self.p_b_vel = b_vel(:); - - end - - function self = set.b_headdir(self, b_headdir) - % sets p_b_headdir. must be either empty or the same length as other base variables - - if (~isnumeric(b_headdir) && ~isvector(b_headdir)) && ~isempty(b_headdir) - error('headdir data must be numerical vector'); - end - - l = CheckBaseVarLength(self); - - if (l~=0 && length(b_headdir)~=l) && ~isempty(b_headdir) - - error('b_headdir must be the same length as all other base variables'); - - end - - self.p_b_headdir = b_headdir(:); - - end - - function self = set.b_ts(self, b_ts) - % sets p_b_ts. must be either empty or the same length as other base variables - - if (~isnumeric(b_ts) && ~isvector(b_ts)) && ~isempty(b_ts) - error('ts data must be numerical vector'); - end - - l = CheckBaseVarLength(self); - - if (l~=0 && length(b_ts)~=l) && ~isempty(b_ts) - - error('b_ts must be the same length as all other base variables'); - - end - - self.p_b_ts = b_ts(:); - - end - - function self = set.b_myvar(self, b_myvar) - % sets p_b_myvar. must be either empty or the same length as other base variables - - if (~isnumeric(b_myvar) && ~isvector(b_myvar)) && ~isempty(b_myvar) - error('y data must be numerical vector'); - end - - l = CheckBaseVarLength(self); - - if (l~=0 && length(b_myvar)~=l) && ~isempty(b_myvar) - - error('b_myvar must be the same length as all other base variables'); - - end - - self.p_b_myvar = b_myvar(:); - - end - - - function self = set.myvar2(self,varargin2) - % Because we can't have multiple constructors in matlab use the - % varargin2 variable. Possible ways of setting root.myvar2 are: - % - % 1) root.myvar2 = []; clear root.myvar2 - % - % 2) temp = CMBHOME.Utils.MyvarHolder('x',x,t); - % root.myvar2 = temp; % Use a temporary variable - % - % 3) root.myvar2 = {'x',x,t}; % Uses a cell array to pass the necessary information - % - % Possibly rewrite in the future for clarity. - - if ~exist('varargin2','var'),varargin2 = [];end - - if iscell(varargin2) - name = varargin2{1}; %#ok - p_var = varargin2{2}; - p_ts = varargin2{3}; - tsVar = self.b_ts; %#ok - self.myvar2 = CMBHOME.Myvar(name,p_var,p_ts,tsVar); %#ok - - elseif (isa(varargin2,'CMBHOME.Myvar')) - self.myvar2 = varargin2; - - elseif (isa(varargin2,'CMBHOME.Utils.MyvarHolder')) - self.myvar2 = CMBHOME.Myvar(varargin2); - - elseif (isempty(varargin2)) - self.myvar2 = CMBHOME.Myvar(); %clear the root.myvar2 - else - error('mv2 must be a CMBHOME.myvar or the variables required to construct one') - end - end - - - function b_x = get.b_x(self) - - b_x = self.p_b_x; - - end - - function b_y = get.b_y(self) - - b_y = self.p_b_y; - - end - - function b_ts = get.b_ts(self) - - b_ts = self.p_b_ts; - - end - - function b_vel = get.b_vel(self) - - b_vel = self.p_b_vel; - - end - - function b_headdir = get.b_headdir(self) - - b_headdir = self.p_b_headdir; - - end - - function b_myvar = get.b_myvar(self) - - b_myvar = self.p_b_myvar; - - end - - - %% DEPENDENT NON-BASE VARIABLES - - function cells = get.cells(self) - cells = ValidCells(self); - end - - function name_formatted = get.name_formatted(self) - % returns the filename of the current object formatted for the current platform - - if isempty(self.name) - - name_formatted = 'CMBHno_name.mat'; - - elseif iscellstr(self.name) - - name_formatted = fullfile(self.name{:}); - - else - - name_formatted = self.name; - - end - - end - - function active_event = get.active_event(self) - % e = root.active_event; - % - % Returns strings which correspond to the start and stop labels for - % each epoch time. - % - % RETURNS - % - % e -> Nx2 cell array of strings (same size as root.epoch, or if - % root.epoch_group is set, N is the number of groups, and it - % defaults to the group's first label) - % - % andrew 18 june 2010 - - if size(self.event,2)<2 - - active_event = {'No Events', 'No Events'}; - - else - - active_event = cell(size(self.epoch,1), 2); - counter = 1; - for i = self.b_epoch_group' - - inds = find(self.b_epoch_group==i); - - if sum(vertcat(self.event{:,2})==self.epoch(inds(1), 1))==1 - str1 = self.event{vertcat(self.event{:,2})==self.epoch(inds(1), 1),1}; - else - str1 = ['Unknown t = ' num2str(self.epoch(inds(1), 1))]; - end - - if sum(vertcat(self.event{:,2})==self.epoch(inds(1), 2))==1 - str2 = self.event{vertcat(self.event{:,2})==self.epoch(inds(1), 2),1}; - else - str2 = ['Unknown t = ' num2str(self.epoch(inds(1), 2))]; - end - - active_event(counter, 1) = {str1}; - active_event(counter, 2) = {str2}; - - counter = counter+1; - end - - end - - end - - function vel = get.vel(self) - % returns pixels/sec - if isempty(self.b_vel) - %self = AppendKalmanVel(self); - self.b_vel = sqrt(([0;diff(self.b_x)]).^2+([0;diff(self.b_y)]).^2) * self.fs_video; - warning('No vel set, setting simple derivative. Recommended: root=root.AppendKalmanVel (slow)'); - end - - vel = []; - - if iscell(self.p_ind) - vel = cellfun(@(c) self.b_vel(c), self.p_ind, 'UniformOutput', false); - elseif ~isempty(self.b_vel) - vel=self.b_vel(self.p_ind); - end - end - - function ind = get.ind(self) - % These are indices in the base vectors (b_*) used to return data dynamic fields (ex. root.x = root.b_x(root.ind)) - % - % This is useful if you have a user defined vector that isnt - % included in the set of properties already defined. For example, a - % linearized position in the TMaze could be saved in - % root.user_def.linear_t. Then for any epoch the linear position on - % the track is root.user_def.linear_t(root.ind), so long as - % length(linear_t)==length(root.b_ts) - - ind = self.p_ind; - - end - - function x = get.x(self) - % x position in pixels - - x = []; - - if iscell(self.p_ind) - x = cellfun(@(c) self.b_x(c), self.p_ind, 'UniformOutput', false); - elseif ~isempty(self.b_x) - x=self.b_x(self.p_ind); - else - warning('CMBH:notify', '%s', 'No x data for this session.'); - end - - end - - function sx = get.sx(self) - pos = self.spos; - if iscell(pos) - sx = cellfun(@(x)x(:,1),pos,'UniformOutput',false); - sx = sx(:); - else - sx = pos(:,1); - end - end - - function svel = get.svel(self) - svel = self.vel; - if iscell(svel) - svel = cellfun(@(x)x*self.spatial_scale,svel,'UniformOutput',false); %eln 131002 - svel = svel(:); - else - svel = svel*self.spatial_scale; - end - end - - function sy = get.sy(self) - pos = self.spos; - if iscell(pos) - sy = cellfun(@(x)x(:,2),pos,'UniformOutput',false); - sy = sy(:); - else - sy = pos(:,2); - end - end - - function y = get.y(self) - % y position in pixels - - y = []; - - if iscell(self.p_ind) - y = cellfun(@(c) self.b_y(c), self.p_ind, 'UniformOutput', false); - elseif ~isempty(self.b_y) - y=self.b_y(self.p_ind); - else - warning('CMBH:notify', '%s', 'No y data for this session'); - end - - end - - function headdir = get.headdir(self) - % headdirection in degrees (although the user could input radians, - % all Toolbox functionality assumes degrees) - - headdir = []; - - if iscell(self.p_ind) - headdir = cellfun(@(c) self.b_headdir(c), self.p_ind, 'UniformOutput', false); - elseif ~isempty(self.b_headdir) - headdir=self.b_headdir(self.p_ind); - else - warning('CMBH:notify', '%s', 'Head Direction vector does not exist for this session'); - end - end - - function sheaddir = get.sheaddir(self) - sheaddir = self.headdir; - - if iscell(sheaddir) - sheaddir = cellfun(@(x)mod(x+self.rotate+180,360)-180,sheaddir,'UniformOutput',false); - else - sheaddir = mod(sheaddir+self.rotate+180,360)-180; - end - end - - function ts = get.ts(self) - % timestamps in seconds - - if iscell(self.p_ind) - ts = cellfun(@(c) self.b_ts(c), self.p_ind, 'UniformOutput', false); - else - ts=self.b_ts(self.p_ind); - end - - end - - function myvar = get.myvar(self) - % epoch data from b_myvar - - if isempty(self.b_myvar) - myvar = []; - return - elseif length(self.b_myvar)~=length(self.b_ts) && ~isempty(self.b_myvar) - disp('root.b_myvar must be the same length as root.b_ts'); - myvar = []; - return - - end - - myvar = []; - - if iscell(self.p_ind) - myvar = cellfun(@(c) self.b_myvar(c), self.p_ind, 'UniformOutput', false); - elseif ~isempty(self.b_myvar) - myvar=self.b_myvar(self.p_ind); - else - warning('CMBH:notify', '%s', 'No myvar data for this session'); - end - - end - - function lfp = get.lfp(self) - % check to see if b_lfp is populated. if not, check that there - % is a file by the index at root.active_lfp - - % if there is, load lfp it - - % then call self.lfp.signal and self.lfp.time and get chucks as - % per self.epoch - - if exist('self.b_lfp') % check if it's loaded yet - if length(self.b_lfp)1 - - tmp_signal = cell(size(self.epoch,1), 1); - tmp_ts = cell(size(self.epoch,1), 1); - tmp_b_theta = cell(size(self.epoch,1), 1); - tmp_b_theta_phase = cell(size(self.epoch,1), 1); - tmp_b_theta_amplitude = cell(size(self.epoch,1), 1); - - for i = 1:size(self.epoch,1) - - inds = ts>=self.epoch(i,1) & ts<=self.epoch(i,2); - - tmp_signal{i} = signal(inds); - tmp_ts{i} = ts(inds); - tmp_b_theta{i} = b_theta(inds); - tmp_b_theta_phase{i} = b_theta_phase(inds); - tmp_b_theta_amplitude{i} = b_theta_amplitude(inds); - - if ~isempty(b_myvar) - tmp_b_myvar{i} = b_myvar(inds,:); %#ok - end - - end - - signal = tmp_signal; - ts = tmp_ts; - b_theta = tmp_b_theta; - b_theta_phase = tmp_b_theta_phase; - b_theta_amplitude = tmp_b_theta_amplitude; - - if exist('tmp_b_myvar','var') - b_myvar = tmp_b_myvar(:); - end - else - - inds = ts>=self.epoch(1) & ts<=self.epoch(2); - - signal = signal(inds); - ts = ts(inds); - b_theta = b_theta(inds); - b_theta_phase = b_theta_phase(inds); - b_theta_amplitude = b_theta_amplitude(inds); - if ~isempty(b_myvar) - b_myvar = b_myvar(inds,:); - else - b_myvar = []; - end - - end - - user_def = self.b_lfp(self.active_lfp).user_def; %#ok - - fs = self.b_lfp(self.active_lfp).fs; - - channel_name = self.b_lfp(self.active_lfp).channel_name; - - lfp = CMBHOME.LFP(signal, ts, fs, channel_name, b_theta, b_theta_phase, b_theta_amplitude, user_def, b_myvar); %#ok - - end - - function b_epoch_group = get.b_epoch_group(self) - % Checks to see if root.epoch_group is set by user. If it is, and - % is valid (length=number of epochs), then root.b_epoch_groups == - % root.epoch_groups - - if length(self.epoch_group) == size(self.epoch,1) && all(self.epoch_group>0) - - b_epoch_group = self.epoch_group; - - else - - b_epoch_group = 1:size(self.epoch,1); - - b_epoch_group = b_epoch_group'; - - end - - end - - function cel_x = get.cel_x(self) - - if isempty(self.p_cel_ind) - - disp('Set root.cel.'); - - cel_x = cell(size(self.epoch,1), 1); - - return - - end - - cel_x = cellfun(@(c) self.b_x(c), self.p_cel_ind, 'unif', 0); - - end - - function cel_y = get.cel_y(self) - - if isempty(self.p_cel_ind) - - disp('Set root.cel.'); - - cel_y = cell(size(self.epoch,1), 1); - - return - - end - - cel_y = cellfun(@(c) self.b_y(c), self.p_cel_ind, 'unif', 0); - - end - - function cel_sx = get.cel_sx(self) - - if isempty(self.p_cel_ind) - disp('Set root.cel.'); - cel_sx = cell(size(self.epoch,1),1); - return - end - - cel_x = self.cel_x; - cel_y = self.cel_y; - cel_sx = self.spos(cel_x,cel_y); - - if ~isempty(self.cel) - cel_x = self.cel_x; - cel_y = self.cel_y; - - if iscell(cel_sx) - cel_sx = cellfun(@(x)x(:,1),cel_sx,'UniformOutput',false); - else - cel_sx = cel_sx(:,1); - end - end - end - - function cel_sy = get.cel_sy(self) - if isempty(self.p_cel_ind) - disp('Set root.cel.') - cel_sy = cell(size(self.epoch,1),1); - return - end - - cel_x = self.cel_x; - cel_y = self.cel_y; - - cel_sy = self.spos(cel_x,cel_y); - - if iscell(cel_sy) - cel_sy = cellfun(@(x)x(:,2),cel_sy,'UniformOutput',false); - else - cel_sy = cel_sy(:,2); - end - - end - - function cel_vel = get.cel_vel(self) - - if isempty(self.p_cel_ind) - disp('Set root.cel.'); - cel_vel = cell(size(self.epoch,1), 1); - return - end - - if ~isempty(self.b_vel), - cel_vel = cellfun(@(c) self.b_vel(c), self.p_cel_ind, 'unif', 0); - else - vel = cat(1, NaN, sqrt(diff(self.b_x).^2+diff(self.b_y).^2))*self.fs_video; - cel_vel = cellfun(@(c) vel(c), self.p_cel_ind, 'unif', 0); - end - - end - - function cel_svel = get.cel_svel(self) - if isempty(self.p_cel_ind) - disp('Set root.cel.'); - cel_svel = cell(size(self.epoch,1),1); - return - end - - cel_svel = self.cel_vel; - - if iscell(cel_svel) - cel_svel = cellfun(@(x) x*self.spatial_scale,cel_svel,'UniformOutput',false); - else - cel_svel = cel_svel*self.spatial_scale; - end - end - - function cel_ts = get.cel_ts(self) - %if isempty(self.p_cel_ind) - % disp('Set root.cel.'); - % cel_ts = cell(size(self.epoch,1), 1); - % return - %end - - if isempty(self.cel) - disp('set root.cel.') - cel_ts = cell(size(self.epoch,1),1); - return - end - - cel_ts = cell(size(self.epoch,1),size(self.cel,1)); - - for i = 1:size(self.cel,1) - cel = self.cel(i,:); - spks_ts = self.spike(cel(1), cel(2)).ts; - - for k = 1:size(self.epoch,1) - curInds = spks_ts >= self.epoch(k,1) & spks_ts <= self.epoch(k,2); - cel_ts{k,i} = spks_ts(curInds); - end - %cel = self.cel(i,:); - %cel_ts(:,i) = cellfun(@(c) self.spike(cel(1), cel(2)).ts(c), self.p_cel_spkind(:,i), 'unif', 0); %#ok - end - end - - function cel_headdir = get.cel_headdir(self) - - if isempty(self.p_cel_ind) - disp('Set root.cel.'); - cel_headdir = cell(size(self.epoch,1), 1); - return - end - cel_headdir = cellfun(@(c) self.b_headdir(c), self.p_cel_ind, 'unif', 0); - end - - function cel_sheaddir = get.cel_sheaddir(self) - - if isempty(self.p_cel_ind) - disp('Set root.cel.'); - cel_sheaddir = cell(size(self.epoch,1),1); - return - end - - cel_sheaddir=self.cel_headdir; - - if iscell(cel_sheaddir) - cel_sheaddir = cellfun(@(x)mod(x+self.rotate+180,360)-180,cel_sheaddir,'UniformOutput',false); - else - cel_sheaddir = mod(cel_sheaddir+self.rotate+180,360)-180; - end - - end - - function cel_i = get.cel_i(self) - if isempty(self.p_cel_ind) - disp('Set root.cel.'); - cel_i = self.p_cel_ind; - return - end - - cel_i = self.p_cel_ind; - end - - function cel_myvar = get.cel_myvar(self) - - if isempty(self.p_cel_ind) - disp('Set root.cel.'); - cel_myvar = cell(size(self.epoch,1), 1); - return - end - - % eln 131002 - if isempty(self.b_myvar) - cel_myvar = cell(size(self.epoch,1), 1); - return - end - - cel_myvar = cellfun(@(c) self.b_myvar(c), self.p_cel_ind, 'unif', 0); - end - - function cel_myvar2 = get.cel_myvar2(self) - % cel_myvar_xvar(:) = root.cel_myvar2.get('xvar'); - % - % Then cel_myvar_xvar will be cell array of "xvar" at spike - % times. - % - % root.cel_myvar2 takes the form of a Myvar, but only holds - % spike data. - - % wchapman 22/07/2013 - if isempty(self.myvar2) - cel_myvar2 = cell(size(self.epoch,1), 1); - return - end - - if isempty(self.p_cel_ind) - cel_myvar2 = cell(size(self.epoch,1), 1); - return - end - - cel_myvar2 = self.myvar2.setEpoch(self.p_cel_ind,self.b_ts); - - end - - - function cel_theta = get.cel_theta(self) - - if isempty(self.cel) % if no cel is set, return empty - disp('Set root.cel'); - cel_theta = cell(size(self.epoch,1), 1); - return - end - - if isempty(self.active_lfp) % if no active lfp set - disp('Set root.active_lfp'); - cel_theta = cell(size(self.epoch,1), size(self.cel, 1)); - return - end - - cel_theta = cellfun(@(c) self.b_lfp(self.active_lfp).theta(c), self.p_cel_lfp_ind, 'unif', 0); - - end - - function cel_thetaphase = get.cel_thetaphase(self) - - if isempty(self.cel) % if no cel is set, return empty - disp('Set root.cel'); - cel_thetaphase = cell(size(self.epoch,1), 1); - return - end - - if isempty(self.active_lfp) % if no active lfp set - disp('Set root.active_lfp'); - cel_thetaphase = cell(size(self.epoch,1), size(self.cel, 1)); - return - end - - cel_thetaphase = cellfun(@(c) self.b_lfp(self.active_lfp).theta_phase(c), self.p_cel_lfp_ind, 'unif', 0); - - end - - - %% INDEPENDENT PROPERTIES - - function self = set.cell_thresh(self, cell_thresh) - - if isnumeric(cell_thresh) - - if numel(cell_thresh)==1 - cell_thresh = [cell_thresh(1), 0]; - elseif numel(cell_thresh)==2 - if cell_thresh(2)~=1 && cell_thresh(2)~=0 - warning('CMBH:error', 'cell_thresh(2) must be boolean: average Fmin (0) or sustained Fmin (1)? Defaulting to 0.') - cell_thresh(2) = 0; - end - else - warning('CMBH:error', 'Improper number of elements on cell_thresh'); - end - - switch cell_thresh(2) - case 1 - str_cell = ' Hz continuously throughout the entire session'; - case 0 - str_cell = ' Hz on average during the session'; - end - - self.cell_thresh = cell_thresh; - - % warning('CMBH:notify', '%s', ['Cell Threshold: F_min is ' num2str(self.cell_thresh(1)) str_cell '.']); - - end - end - - function self = set.epoch_group(self, epoch_group) - - if all(epoch_group>0) && all(rem(epoch_group, 1)==0) && isvector(epoch_group) - - self.epoch_group = epoch_group(:); - - end - - end - - function self = set.event(self, event) - if ~iscell(event) - error('session.event must be cell array') - else - self.event=event; - end - - if size(event, 2)==2 && size(event,1)>1 % sort events if numeric - - isnumbers = cellfun(@isnumeric, event(:,2)); - isemptys = cellfun(@isempty, event(:,2)); - - if any(~isnumbers) || any(isemptys) - - warning('CMBH:notify', '%s', 'There are values in the timestamps column (2) that are not numbers. They will be deleted'); - - event(~isnumbers,:) = []; - event(isemptys,:) = []; - - end - - ts = [event{:,2}]; - - if isnumeric(ts) - - [~, ind] = sort(ts); - - self.event = event(ind,:); - - end - - elseif isempty(event) - - self.event = {'Session start', self.b_ts(1); 'Session stop', self.b_ts(end) }; %#ok - - end - - end - - function self = set.path_lfp(self, path_lfp) - - if isempty(path_lfp) - self.path_lfp = []; - return; - end - - if ~iscell(path_lfp), path_lfp = {path_lfp}; end - self.path_lfp = path_lfp; - end - - - function self = set.b_lfp(self, b_lfp) - - issue_warning = 0; - - if isa(b_lfp, 'CMBHOME.LFP') - - for i = 1:length(b_lfp) - - %if any(unique(diff(b_lfp(i).ts)).^-1 < .9*b_lfp(i).fs), issue_warning = 1; end - %!IMPLEMENTME: This line (1469) is broken in recent - %MATLAB upgrade. Need to fix definition of empty - - end - - end - - if issue_warning, warning('CMBH:notify', '%s', 'There are timestamps with uneven sampling intervals. Make sure this is expected for this session, and to use root.epoch properly.'); end - - self.b_lfp = b_lfp; - - end - - - %% METHODS - - function pos=spos(self,x,y) - if ~exist('x','var') - x = self.x; - y = self.y; - end - - if iscell(x) - % Switched from cellfun to self call for each cell wchapman 20131003 - pos = cell(size(x)); - for i = 1:numel(x) - pos{i} = self.spos(x{i},y{i}); - end - else - pos = self.spatial_scale*[x y]*[cosd(self.rotate) -sind(self.rotate);sind(self.rotate) cosd(self.rotate)]+repmat(self.shift,[numel(x) 1]); - tolerance = 0.01; - - if size(pos,2)>1 - count = 0; - while abs((sum(sqrt(sum(diff([x y]).^2,2)))*self.spatial_scale-sum(sqrt(sum(diff(pos).^2,2))))/(sum(sqrt(sum(diff([x y]).^2,2)))*self.spatial_scale))>tolerance - count = count+1; - pos = self.spatial_scale*[x-self.shift(1)/self.spatial_scale y-self.shift(2)/self.spatial_scale]*[cosd(self.rotate) -sind(self.rotate);sind(self.rotate) cosd(self.rotate)]; - if count > size(pos,2) - warning('Session:spos fail','Max iterations reached in spos') - break - end - end - end - end - end - - function self = AppendKalmanVel(self) - - if ~isempty(self.b_vel) - - warning('CMBH:error', 'User defined speed vector already created. Clear root.b_vel first.'); - - return - - else - - [t,~,~,vx,vy] = self.KalmanVel(self.b_x,self.b_y,self.b_ts, 2); % quadratic - - [~, inds] = ismember(t, self.b_ts); % all indices in self.b_ts for which we have a kalman estimate - - b_vel = zeros(size(self.b_ts)); - - b_vel(inds) = sqrt(vx.^2 + vy.^2); % pixels/sec - - self.b_vel = b_vel; - - %warning('CMBH:notify', '%s', 'Added Kalman Velocity to Session Object.'); - - end - end - - function ts = Label2Time(self, label) - % ts = root.Label2Time(str) - % - % Returns ts, a vector of timestamp(s) from root.event that line up - % with event label 'str' - - - if iscell(label) - - ts = zeros(size(label, 1), size(label,2)); - - for i = 1:size(label, 1) - for j = 1:size(label, 2) - tmp = cell2mat(self.event(ismember(self.event(:,1), label{i,j}),2)); - - if numel(tmp)==1, ts(i,j) = tmp; - elseif isempty(tmp), ts(i, j) = NaN; - else error('Multiple identical labels exist, cannot use cell array functionality'); - end - - end - end - else - - ts = cell2mat(self.event(ismember(self.event(:,1), label),2)); - - end - - end - - function self = AddLFP(self, fname) - % (1) root = root.AddLFP - % (2) root = root.AddLFP(fname) - % - % Appends root.path_lfp with valid LFP file name via user input - % prompts or filename, and adds it to root.path_lfp. - % - % (1) Prompts the user to select a file using the file browser - % (2) Checks if string 'fname' is a valid LFP file (.ncs, .mat, - % .plx files) and adds it to root.path_lfp. - % - % andrew 3 april 2010 - - if ~exist('fname', 'var') - if isempty(self.path_lfp) - i = 1; - else - i = length(self.path_lfp)+1; - end - - tmppath = self.name; - - tmppath = tmppath(1:find(tmppath==filesep, 1, 'last')-1); % directory of datafile - - [load_file,base_path] = uigetfile('*.eeg*;*.ncs;*.mat;*.plx','Select the LFP (EEG) file relevent to this project. Cancel to exit',tmppath, 'MultiSelect', 'on'); - - if iscellstr(load_file) - - for j = 1:length(load_file) - self.path_lfp{i} = fullfile(base_path, load_file{j}); - i = i+1; - end - - self = self.AddLFP; % recursively call this function to load files - - warning('CMBH:notify', '%s', 'Added'), warning('CMBH:notify', '%s', load_file(:)); - - elseif load_file - - self.path_lfp{i} = fullfile(base_path, load_file); - - self = self.AddLFP; % recursively call this function to load files - - warning('CMBH:notify', '%s', 'Added'), warning('CMBH:notify', '%s', load_file(:)); - - end - else - - if ~iscell(fname), fname = {fname}; end % convert to cell if char - - for i = 1:length(fname) - - if exist(fname{i}, 'file') - self.path_lfp{end+1} = fname{i}; - else - warning('CMBH:error', [fname{i} ' does not exist. Not added']); - fname{i} = ''; - end - - end - - warning('CMBH:notify', '%s', ['Added ' int2str(length(fname)) ' lfp filenames.']); - - end - - end - - function self = ClearLFP(self) - % root = root.ClearLFP; - % - % Clears the LFP signals from root.b_lfp. This may be useful if the - % LFP signals are very large, or highly sampled. - % - % andrew 3 april 2010 - - self.b_lfp = []; - - self.active_lfp = []; - - end - - function Status(self) - % root.Status - % prints to screen relevant information about this Session class - % object - % - % andrew 3 april 2010 - - switch self.cell_thresh(2) - case 1 - str_cell = ' Hz continuously throughout the entire session'; - case 0 - str_cell = ' Hz on average during the session'; - end - - disp(['This CMB Session is ' self.name '.' char(10) 'It has ' int2str(size(self.cells,1)) ... - ' cells which fire above ' num2str(self.cell_thresh(1)) ... - str_cell '.' char(10) char(10) 'There are ' int2str(size(self.event,1)) ' event flags' ... - '.' char(10) 'The recording duration is ' num2str(self.b_ts(end)-self.b_ts(1)) ' seconds.']); - - disp([char(10) 'It was created on ' datestr(self.date_created, 1)]); - - disp([char(10) 'The tracking sampling frequency is ' num2str(self.fs_video) ' Hz.']); - - if isempty(self.b_vel), disp('root.vel returns the simple derivative of position. Edit root.b_vel to specify a more accurate vector of running speed,'); - else disp('User defined speed vector'); end - - switch self.raw_headdir - case 1 - str_headdir = 'The head direction signal has not been corrected or smoothed'; - case 0 - str_headdir = 'The head direction signal has been corrected and smoothed'; - end - - switch self.raw_pos - case 1 - str_pos = 'The position data has not been corrected or smoothed.'; - case 0 - str_pos = 'The position data has been corrected and smoothed.'; - end - - switch isempty(self.spatial_scale) - case 1 - str_spat_scale = [char(10) 'You have not indicated resolution (cm/pixel). ' ... - 'Do so by assigning object.spatial_scale a value.']; - case 0 - str_spat_scale = [char(10) 'The resolution is set to ' num2str(self.spatial_scale) ... - ' cm/pixel.']; - end - - disp(str_spat_scale); - disp(str_headdir); - disp(str_pos); - - end - - function self = SetEpoch(self) - % root = root.SetEpoch; - % - % GUI for setting epoch start and stop times for plotting, etc - - width = 425; - height = 600; - - % Create and then hide the GUI as it is being constructed. - f = figure('Visible','off','Position', [50, -150, width, height],'Color', 'w'); - - sizes = [15, 180, 260]; - widths = [150, 75, 150]; - lineheight = 30; - - check_ind = 1; - - % Construct the components. - - %labels - hlabel1 = uicontrol('Style','text','String','Anchoring Event',... - 'Position',[sizes(1),height-50,widths(1),lineheight], 'BackgroundColor', 'w',... - 'FontSize', 8, 'HorizontalAlignment', 'left', 'HandleVisibility', 'off'); - hlabel2 = uicontrol('Style','text','String','Lag (+/- seconds)',... - 'Position',[sizes(2),height-50,widths(2),lineheight], 'BackgroundColor', 'w',... - 'FontSize', 8, 'HorizontalAlignment', 'left', 'HandleVisibility', 'off'); - hlabel3 = uicontrol('Style','text','String','Secondary Event',... - 'Position',[sizes(3),height-50,widths(3),lineheight], 'BackgroundColor', 'w',... - 'FontSize', 8, 'HorizontalAlignment', 'left', 'HandleVisibility', 'off'); - - str_help = ['If you specify start and stop above, we will ignore the selected labels.' ... - ' Start and stop must lie between 0 and 1, and indicate percent session time.']; - - helplabel = uicontrol('Style','text','String',str_help,... - 'Position',[5,65,width-10,60], 'BackgroundColor', 'w',... - 'FontSize', 10, 'HorizontalAlignment', 'left', 'HandleVisibility', 'off'); - - h_objarr(check_ind, 1) = uicontrol('Style','popupmenu',... % one popup - 'String',cellstr(char(cat(2, num2str(shiftdim(1:size(self.event,1),1)),char(self.event{:,1}), num2str(vertcat(self.event{:,2}))))),... - 'Position',[sizes(1),height-50-check_ind*lineheight,widths(1),lineheight],... - 'HandleVisibility', 'off'); - - h_objarr(check_ind, 2) = uicontrol('Style','edit',... % one textbox - 'String','',... - 'Position',[sizes(2),height-50-check_ind*lineheight+8,widths(2),22],... - 'HandleVisibility', 'off'); - - h_objarr(check_ind, 3) = uicontrol('Style','popupmenu',... % one popup - 'String',cellstr(char(cat(2, num2str(shiftdim(1:size(self.event,1),1)),char(self.event{:,1}), num2str(vertcat(self.event{:,2}))))),... - 'Position',[sizes(3)+15,height-50-check_ind*lineheight,widths(3), lineheight],... - 'HandleVisibility', 'off'); - - h_objarr(check_ind, 4) = uicontrol('Style','edit',... % one textbox - 'String','Start',... - 'Position',[sizes(1),height-50-check_ind*lineheight*1.5,widths(2),22],... - 'HandleVisibility', 'off'); - - h_objarr(check_ind, 5) = uicontrol('Style','edit',... % one textbox - 'String','Stop',... - 'Position',[sizes(2)-50,height-50-check_ind*lineheight*1.5,widths(2),22],... - 'HandleVisibility', 'off'); - - - % buttons for add epoch or finish - - h_add = uicontrol('Style','pushbutton','String','Add',... - 'Position',[width-100, height-50-(check_ind+1)*lineheight*1.5, 50, 25],... - 'Callback',{@add_Callback}, 'HandleVisibility', 'off'); - h_finish = uicontrol('Style','pushbutton','String','Done',... - 'Position',[width-50, height-50-(check_ind+1)*lineheight*1.5, 50, 25],... - 'Callback',{@finish_Callback}, 'HandleVisibility', 'off'); - - % Initialize the GUI. - % Change units to normalized so components resize - % automatically. - - % set([f; h_objarr; h_add; h_finish; hlabel1; hlabel2; hlabel3],'Units','Pixels'); - - %ha = axes('Position', [.1 .1 .6 .6]); - - % Assign the GUI a name to appear in the window title. - set(f,'Name','SetEpoch') - % Move the GUI to the center of the screen. - movegui(f,'center') - % Make the GUI visible. - set(f,'Visible','on'); - - uiwait(f); % wait to return until figure is closed - - function popup_lag_Callback(source, eventdata) - - % Determine the selected data set. - % clear old plots, and update header - - str = get(source, 'String'); - val = get(source,'Value'); - - end - - function add_Callback(source, eventdata) % add another line for epoch - - check_ind = check_ind+1; - - h_objarr(check_ind, 1) = uicontrol('Style','popupmenu',... % one popup - 'String',cellstr(char(cat(2, num2str(shiftdim(1:size(self.event,1),1)), char(self.event{:,1}), num2str(vertcat(self.event{:,2}))))),... - 'Position',[sizes(1),height-15-check_ind*lineheight*2,widths(1), lineheight],... - 'HandleVisibility', 'off'); - - h_objarr(check_ind, 2) = uicontrol('Style','edit',... % one textbox - 'String','',... - 'Position',[sizes(2),height-15-check_ind*lineheight*2+8,widths(2),22],... - 'HandleVisibility', 'off'); - - h_objarr(check_ind, 3) = uicontrol('Style','popupmenu',... % one popup - 'String',cellstr(char(cat(2, num2str(shiftdim(1:size(self.event,1),1)),char(self.event{:,1}), num2str(vertcat(self.event{:,2}))))),... - 'Position',[sizes(3),height-15-check_ind*lineheight*2,widths(3), lineheight],... - 'HandleVisibility', 'off'); - - h_objarr(check_ind, 4) = uicontrol('Style','edit',... % one textbox - 'String','Start',... - 'Position',[sizes(1),height-15-check_ind*lineheight*2-lineheight+8,widths(2),22],... - 'HandleVisibility', 'off'); - - h_objarr(check_ind, 5) = uicontrol('Style','edit',... % one textbox - 'String','Stop',... - 'Position',[sizes(2)-50,height-15-check_ind*lineheight*2-lineheight+8,widths(2),22],... - 'HandleVisibility', 'off'); - - set(h_add, 'Position', [width-100, height-15-(check_ind)*lineheight*2 - lineheight+8, 50, 25]); - set(h_finish, 'Position', [width-50, height-15-(check_ind)*lineheight*2 - lineheight+8, 50, 25]); - - end - - function finish_Callback(source, eventdata) % set self.epoch and close window - - epoch_ind = 1; - - dur = self.b_ts(end)-self.b_ts(1); % duration of recording - - for i = 1:size(h_objarr,1) - - user_start = get(h_objarr(i,4), 'String'); - user_stop = get(h_objarr(i,5), 'String'); - - if ~strcmp(user_start, 'Start') && ~strcmp(user_stop, 'Stop') %start and stop are declared and valid, - - user_start = str2num(user_start); - user_stop = str2num(user_stop); - - if user_start=0 && user_stop<=1 && user_stop>=0 - epoch(epoch_ind,:) = [dur*user_start+self.b_ts(1), dur*user_stop+self.b_ts(1)]; - - epoch_ind = epoch_ind+1; - else - disp('Start and Stop must lie between 0 and 1. Defaulting to 0 and 1 (start and end of session)'); - end - - else - - - t1ind = get(h_objarr(i,1), 'Value'); - t1 = self.event{t1ind,2}; - - if ~isempty(get(h_objarr(i,2), 'String')) - t2 = t1+str2num(get(h_objarr(i,2), 'String')); - if t2<0 - disp('One of the timestamps was less than zero. Setting to zero'); - t2=0; - end - end - - if ~exist('t2', 'var') - t2ind = get(h_objarr(i,3), 'Value'); - t2 = self.event{t2ind,2}; - clear t2ind - end - - if t1~=t2 - epoch(epoch_ind,1) = min([t1, t2]); - epoch(epoch_ind,2) = max([t1, t2]); - epoch_ind = epoch_ind+1; - end - clear t1 t2 ind - - end - end - - self.epoch = epoch; - - close(f) - - end - - end - - - function Save(root, params) - % (1) root.Save - % (2) root.Save(params) - % - % Saves Session class object to root.name_formatted - % - % (1) Saves root to root.name, asks if overwrite is necessary. If - % LFP exists, asks if it should be cleared. - % - % (2) Saves root to root.name, but will not prompt user as per - % params: - % - % params = [ , ] for batch processing ex. - % root.Save([1 0]) will clear the LFP, but not overwrite root.name, - % if it exists - % - % If noprompt == 1, then root.Save will attempt to save to - % root.name. If Directory does not exist, it will create it. If - % file exists, it will overwrite. - % - % If you want to save to a new filename, change root.name before - % calling root.save - - if ~exist('params', 'var') - params = [NaN NaN]; - elseif numel(params)==1 - params(2) = NaN; - end - - - if ~isempty(root.b_lfp) - - if params(1)==1 - root = root.ClearLFP; - warning('CMBH:notify', '%s', 'Cleared LFP from object. If you want to save it in the future, use root.Save(0)'); - elseif params(2)~=1 - user_entry = input('Would you like to save the LFP data with the object? This could make for a large filesize. [y/n]: ', 's'); - - while( ~strcmpi(user_entry, 'y') && ~strcmpi(user_entry, 'n') ) - user_entry = input('Would you like to save the LFP data with the object? This could make for a large filesize. [y/n]: ', 's'); - end - - if strcmpi(user_entry, 'n') - root = root.ClearLFP; - warning('CMBH:notify', '%s', 'Cleared LFP from object.'); - end - end - - end - - - if exist(root.name_formatted, 'file') && (isnan(params(2)) || params(2)==0) % if exists and user didnt specify what to do - reply = input(['You are about to overwrite ' root.name_formatted '. Are you sure? [y/n]: '], 's'); - if strcmpi(reply, 'y') - save(root.name_formatted, 'root', '-v7.3'); - warning('CMBH:notify', '%s', ['Saved ' root.name_formatted]); - else - warning('CMBH:notify', '%s', 'Save aborted.'); - end - elseif exist(root.name_formatted, 'file') && params(2)==1 % if exists and user specified overwrite - save(root.name_formatted, 'root', '-v7.3'); - warning('CMBH:notify', '%s', ['Saved ' root.name_formatted]); - elseif exist(root.name_formatted(1:find(root.name_formatted==filesep, 1, 'last')-1), 'dir') % if directory exists, but file doesnt, save it - save(root.name_formatted, 'root', '-v7.3'); - warning('CMBH:notify', '%s', ['Saved ' root.name_formatted]); - elseif params(2)~=1 % if directory doesnt exist and noprompt is false, ask user - disp('Folder in root.name not found. Please select where you would like to save the file.'); - [file, path] = uiputfile('*.mat', 'Save Object As', pwd); - root.name = fullfile(path, file); - - save(root.name_formatted, 'root','-v7.3'); - warning('CMBH:notify', '%s', ['Saved ' root.name_formatted]); - else % directory doesnt exist, but noprompt is true, so mkdir and save file - - mkdir(root.name_formatted(1:find(root.name_formatted==filesep, 1, 'last')-1)); - - save(root.name_formatted, 'root', '-v7.3'); - warning('CMBH:notify', '%s', ['Saved ' root.name_formatted]); - - end - - end - - function Session_array = SplitSession(self, varargin) - % (1) Session_array = root.SplitSession; - % (2) root.SplitSession(params); - % - % This method will split the present Session instance into more - % than one Session Objects. - % - % (1) Splits the session object as per root.epochs and optionally - % returns 'Session_array' of session objects of length(size(root.epoch,1)) - % - % (2) Takes optional parameters - % 'filenames' - cellarray of strings, filenames to make each root.name - % 'epoch' - Nx2 array of times to split. N = length off 'filenames' - % 'save' - 1 or 0 (default 0). Save each session object - % - % andrew 24 may 2010 - - import CMBHOME.* - - success = 0; %#ok % initialize variables - Session_array = Session; - - p = inputParser; - - p.addRequired('self'); - p.addParamValue('filenames', [], @(x) isccellstr(x)); - p.addParamValue('epoch', [], @(x) size(x,2)==2); - p.addParamValue('save', 0, @ischar); - - p.parse(self, varargin{:}); - - filenames = p.Results.filenames; - epoch = p.Results.epoch; - save = p.Results.save; - - if isempty(epoch) - epoch = self.epoch; - end - - if size(epoch,1)<2 % if there arent any epochs passed - help CMBHOME.Session.SplitSession - return; - end - - if isempty(filenames) - - append = 1:size(epoch,1); - - filenames = cat(2, repmat(strrep(self.name, '.mat', ''), size(epoch,1), 1), repmat('_Split', size(epoch,1), 1), int2str(append'), repmat('.mat', size(epoch,1), 1)); - - filenames = mat2cell(filenames, ones(size(filenames,1),1), size(filenames,2)); - - end - - if length(filenames)~=size(epoch,1) - help CMBHOME.Session.SplitSession - error('length of filenames does not match number of epochs'); - end - - for i = 1:length(filenames) % parse through all Session Objects - - self.epoch = epoch(i,:); - - self.cell_thresh = [ 0 0 ]; - - event = self.event( [self.event{:,2}]>= epoch(i,1) & [self.event{:,2}]<=epoch(i,2), : ); - - Session_array(i) = Session('name', filenames{i},... - 'b_ts', self.ts,'b_x',self.x, 'b_y', self.y, 'b_headdir',... - self.headdir, 'event', event, 'raw_pos', self.raw_pos, ... - 'raw_headdir', self.raw_headdir, 'date_created', now, ... - 'epoch', epoch(i,:), 'fs_video', self.fs_video,... - 'path_lfp', self.path_lfp, 'path_raw_data', self.path_raw_data); % put it all together - - Session_array(i).user_def = self.user_def; % copy over all user_def fields - - Session_array(i).user_def.SplitHistory = ['This Session object was split from ' self.name ' using SplitSession.']; - - for j = 1:size(self.cells,1) % import cells - - spike = self.spike(self.cells(j,1), self.cells(j,2)); - - spike.ts = spike.ts(spike.ts>=epoch(i,1) & spike.ts<=epoch(i,2)); - - spike.i = Utils.SpkInds(self.ts, spike.ts); - - Session_array(i).spike(self.cells(j,1), self.cells(j,2)) = spike; - - end - - if save, Session_array(i).Save; end % save, if specified - - end - - end - end - - properties (Hidden) % old or outdated properties, around for backwards compatibility - - b_kalmanvel - - end -end - -function [i_ts, i_i] = IsolateEpoch(ts, i, epoch) -% returns indeces from vector i which correspond to timestamps in ts within -% epoch start and stop times t_start and t_stop -% -% example: we have indeces i that refer to vector ts of timestamps, give me just the i which -% lie betweeh t_start and t_stop? -% -% also: i_i are indeces in i for which ts is good (used in theta vector - -% andrew 18 march 2010 - -if nargin<3 - error('IsolateEpoch: not enough input arguments'); -end - -if max(i)>length(ts) - - warning('CMBH:error', 'Your indeces do not align with the timestamp vector'); - return - -end - -t = ts(i); - -if numel(epoch)>2 && numel(t)>1 - epoch = mat2cell(epoch, ones(1, size(epoch,1)), 2); - - % if a stable sampling frequency can be identified, we can be way fast - dts = round((unique(diff(t)))*1000); % ms per sample - - if ~any(floor(abs(dts-median(dts)))) && length(dts)>3 % all dts are within 1 ms of the median - - fs = round(1000 / median(dts)); - endtime= cellfun(@(a) ceil(fs*a(2))>i(end),epoch); - sttime = cellfun(@(a) ceil(fs*a(1))=a(1) & t<=a(2)), epoch, 'Unif', 0); %otherwise do the brute force (100x slower) - end - - tmp_i_i = cell2mat(i_i); tmp_i_i(tmp_i_i==0) = []; - i_ts=i(tmp_i_i); %these steps avoid doing the really slow thing twice - i_ts= mat2cell(i_ts(:),cellfun(@length,i_i),1); - -else - t_start = epoch(1); - t_stop = epoch(2); - - i_ts = i(t>=t_start & t<=t_stop); - - i_i = find(t>=t_start & t<=t_stop); -end - -end -function self = SetLFPInds(self) - - if ~iscell(self.p_ind) - self.p_lfp_ind = cellfun(@(c) nan(size(c)), {self.p_ind}, 'unif', 0); % will eventually be the aligned indices in the LFP - else - self.p_lfp_ind = cellfun(@(c) nan(size(c)), self.p_ind, 'unif', 0); % will eventually be the aligned indices in the LFP - end - -end - -function self = SetCelInds(self) - - cel = self.cel; - - ind = cell(size(self.epoch,1), size(cel,1)); - - spkind = cell(size(self.epoch,1), size(cel,1)); - - ind_lfp = cell(size(self.epoch,1), size(cel,1)); - - for j = 1:size(cel,1) % now set root.p_cel_ind - - [i, i2] = IsolateEpoch(self.b_ts, self.spike(cel(j,1), cel(j,2)).i, self.epoch); - %[i, i2] = IsolateEpoch(self.spike(self.cel(1),self.cel(2)).ts, self.spike(cel(j,1), cel(j,2)).i, self.epoch); - - if iscell(i) - - if ~isempty(self.active_lfp) - if isempty(self.spike(cel(j,1), cel(j,2)).i_lfp) - self = self.AlignSpike2LFP; - end - ind_lfp(:, j) = cellfun(@(c) self.spike(cel(j,1), cel(j,2)).i_lfp{self.active_lfp}(c), i2, 'unif', 0); - else - ind_lfp(:, j) = cell(length(i),1); - end - - ind(:, j) = i; % video indices - - spkind(:,j) = i2; - - else - - if ~isempty(self.active_lfp) - if isempty(self.spike(cel(j,1), cel(j,2)).i_lfp) - self = self.AlignSpike2LFP; - end - ind_lfp{1, j} = self.spike(cel(j,1), cel(j,2)).i_lfp{self.active_lfp}(i2); - else - ind_lfp{1, j} = []; - end - - ind{1, j} = i; % video indices - - spkind{1,j} = i2; - - end - - end % now we have cell arrays like {epochs, cells} of indices in video tracking and lfp - - self.p_cel_ind = ind; % cell array like {epochs, cells} of tracking alignment - - self.p_cel_lfp_ind = ind_lfp; % cell array like {epochs, cells} of LFP alignment - - self.p_cel_spkind = spkind; - -end - -function l = CheckBaseVarLength(self) - - l(1) = length(self.p_b_x); - l(2) = length(self.p_b_y); - l(3) = length(self.p_b_ts); - l(4) = length(self.p_b_vel); - l(5) = length(self.p_b_headdir); - l(6) = length(self.p_b_myvar); - - l = max(l); - -end \ No newline at end of file diff --git a/Kwik2Mat.m b/Kwik2Mat.m deleted file mode 100644 index db7aa29..0000000 --- a/Kwik2Mat.m +++ /dev/null @@ -1,42 +0,0 @@ -function Kwik2Mat(fname, vid_ts) - - hinfo = hdf5info(fname); - for i = 1:length(hinfo.GroupHierarchy.Groups) - gn{i} = hinfo.GroupHierarchy.Groups(i).Name; - end - - ind = find(strcmp(gn,'/channel_groups')); - nGroups = length(hinfo.GroupHierarchy.Groups(ind).Groups); - - sr = h5readatt(fname, ['/recordings/0'], 'sample_rate'); - - for i = 1:nGroups - try - ts = (1/sr)*double(h5read(fname, ['/channel_groups/' num2str(i-1) '/spikes/time_samples'])) + ... - (1/sr)*double(h5read(fname, ['/channel_groups/' num2str(i-1) '/spikes/time_fractional']))/255; - - clust = double(h5read(fname, ['/channel_groups/' num2str(i-1) '/spikes/clusters/main'])); - clust_auto = double(h5read(fname, ['/channel_groups/' num2str(i-1) '/spikes/clusters/original'])); - - cels = unique(clust) +1; - for k = 1:length(cels) - inds = clust+1 == k ; - Spike(i,cels(k)) = CMBHOME.Spike('ts', ts(inds), 'vid_ts', vid_ts); - end - - cels = unique(clust_auto) + 1; - for k = 1:length(cels) - inds = clust_auto+1 == k; - Spike_Auto(i,cels(k)) = CMBHOME.Spike('ts', ts(inds), 'vid_ts', vid_ts); - end - - catch ME - if strcmp(ME.identifier, 'MATLAB:imagesci:h5read:libraryError') - warning(['Channel Group ' num2str(i-1) ' is not clustered']); - end - end - end - - keyboard - -end \ No newline at end of file diff --git a/support/queryTable_gui.fig b/support/queryTable_gui.fig deleted file mode 100755 index 0656a8c..0000000 Binary files a/support/queryTable_gui.fig and /dev/null differ diff --git a/support/queryTable_gui.m b/support/queryTable_gui.m deleted file mode 100755 index d8adab4..0000000 --- a/support/queryTable_gui.m +++ /dev/null @@ -1,799 +0,0 @@ -function varargout = queryTable_gui(varargin) -% QUERYTABLE_GUI MATLAB code for queryTable_gui.fig -% QUERYTABLE_GUI, by itself, creates a new QUERYTABLE_GUI or raises the existing -% singleton*. -% -% H = QUERYTABLE_GUI returns the handle to a new QUERYTABLE_GUI or the handle to -% the existing singleton*. -% -% QUERYTABLE_GUI('CALLBACK',hObject,eventData,handles,...) calls the local -% function named CALLBACK in QUERYTABLE_GUI.M with the given input arguments. -% -% QUERYTABLE_GUI('Property','Value',...) creates a new QUERYTABLE_GUI or raises the -% existing singleton*. Starting from the left, property value pairs are -% applied to the GUI before queryTable_gui_OpeningFcn gets called. An -% unrecognized property name or invalid value makes property application -% stop. All inputs are passed to queryTable_gui_OpeningFcn via varargin. -% -% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one -% instance to run (singleton)". -% -% See also: GUIDE, GUIDATA, GUIHANDLES - -% Edit the above text to modify the response to help queryTable_gui - -% Last Modified by GUIDE v2.5 19-Feb-2013 14:09:34 - -% Begin initialization code - DO NOT EDIT -gui_Singleton = 1; -gui_State = struct('gui_Name', mfilename, ... - 'gui_Singleton', gui_Singleton, ... - 'gui_OpeningFcn', @queryTable_gui_OpeningFcn, ... - 'gui_OutputFcn', @queryTable_gui_OutputFcn, ... - 'gui_LayoutFcn', [] , ... - 'gui_Callback', []); -if nargin && ischar(varargin{1}) - gui_State.gui_Callback = str2func(varargin{1}); -end - -if nargout - [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); -else - gui_mainfcn(gui_State, varargin{:}); -end -% End initialization code - DO NOT EDIT - - -% --- Executes just before queryTable_gui is made visible. -function queryTable_gui_OpeningFcn(hObject, eventdata, handles, varargin) -% This function has no output args, see OutputFcn. -% hObject handle to figure -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) -% varargin command line arguments to queryTable_gui (see VARARGIN) - -% Choose default command line output for queryTable_gui -handles.output = hObject; - -% Update handles structure -guidata(hObject, handles); - -% UIWAIT makes queryTable_gui wait for user response (see UIRESUME) -uiwait(handles.figure1); - - -% --- Outputs from this function are returned to the command line. -function varargout = queryTable_gui_OutputFcn(hObject, eventdata, handles) -% varargout cell array for returning output args (see VARARGOUT); -% hObject handle to figure -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Get default command line output from handles structure -varargout{1} = handles.output; - - -% --- Executes on button press in queryButton. -function queryButton_Callback(hObject, eventdata, handles) -% hObject handle to queryButton (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) -uiresume - - - - -function rat_name_Callback(hObject, eventdata, handles) -% hObject handle to rat_name (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of rat_name as text -% str2double(get(hObject,'String')) returns contents of rat_name as a double - - -% --- Executes during object creation, after setting all properties. -function rat_name_CreateFcn(hObject, eventdata, handles) -% hObject handle to rat_name (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function rat_notes_Callback(hObject, eventdata, handles) -% hObject handle to rat_notes (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of rat_notes as text -% str2double(get(hObject,'String')) returns contents of rat_notes as a double - - -% --- Executes during object creation, after setting all properties. -function rat_notes_CreateFcn(hObject, eventdata, handles) -% hObject handle to rat_notes (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function rat_implant1_Callback(hObject, eventdata, handles) -% hObject handle to rat_implant1 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of rat_implant1 as text -% str2double(get(hObject,'String')) returns contents of rat_implant1 as a double - - -% --- Executes during object creation, after setting all properties. -function rat_implant1_CreateFcn(hObject, eventdata, handles) -% hObject handle to rat_implant1 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function rat_implant2_Callback(hObject, eventdata, handles) -% hObject handle to rat_implant2 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of rat_implant2 as text -% str2double(get(hObject,'String')) returns contents of rat_implant2 as a double - - -% --- Executes during object creation, after setting all properties. -function rat_implant2_CreateFcn(hObject, eventdata, handles) -% hObject handle to rat_implant2 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function rat_depth1_Callback(hObject, eventdata, handles) -% hObject handle to rat_depth1 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of rat_depth1 as text -% str2double(get(hObject,'String')) returns contents of rat_depth1 as a double - - -% --- Executes during object creation, after setting all properties. -function rat_depth1_CreateFcn(hObject, eventdata, handles) -% hObject handle to rat_depth1 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function rat_depth2_Callback(hObject, eventdata, handles) -% hObject handle to rat_depth2 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of rat_depth2 as text -% str2double(get(hObject,'String')) returns contents of rat_depth2 as a double - - -% --- Executes during object creation, after setting all properties. -function rat_depth2_CreateFcn(hObject, eventdata, handles) -% hObject handle to rat_depth2 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - -% --- Executes on selection change in grp. -function grp_Callback(hObject, eventdata, handles) -% hObject handle to grp (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: contents = cellstr(get(hObject,'String')) returns grp contents as cell array -% contents{get(hObject,'Value')} returns selected item from grp - - -% --- Executes during object creation, after setting all properties. -function grp_CreateFcn(hObject, eventdata, handles) -% hObject handle to grp (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: listbox controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function tetrode_notes_Callback(hObject, eventdata, handles) -% hObject handle to tetrode_notes (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of tetrode_notes as text -% str2double(get(hObject,'String')) returns contents of tetrode_notes as a double - - -% --- Executes during object creation, after setting all properties. -function tetrode_notes_CreateFcn(hObject, eventdata, handles) -% hObject handle to tetrode_notes (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function tetrode_num2_Callback(hObject, eventdata, handles) -% hObject handle to tetrode_num2 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of tetrode_num2 as text -% str2double(get(hObject,'String')) returns contents of tetrode_num2 as a double - - -% --- Executes during object creation, after setting all properties. -function tetrode_num2_CreateFcn(hObject, eventdata, handles) -% hObject handle to tetrode_num2 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function tetrode_num1_Callback(hObject, eventdata, handles) -% hObject handle to tetrode_num1 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of tetrode_num1 as text -% str2double(get(hObject,'String')) returns contents of tetrode_num1 as a double - - -% --- Executes during object creation, after setting all properties. -function tetrode_num1_CreateFcn(hObject, eventdata, handles) -% hObject handle to tetrode_num1 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function session_filepath_Callback(hObject, eventdata, handles) -% hObject handle to session_filepath (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of session_filepath as text -% str2double(get(hObject,'String')) returns contents of session_filepath as a double - - -% --- Executes during object creation, after setting all properties. -function session_filepath_CreateFcn(hObject, eventdata, handles) -% hObject handle to session_filepath (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function session_notes_Callback(hObject, eventdata, handles) -% hObject handle to session_notes (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of session_notes as text -% str2double(get(hObject,'String')) returns contents of session_notes as a double - - -% --- Executes during object creation, after setting all properties. -function session_notes_CreateFcn(hObject, eventdata, handles) -% hObject handle to session_notes (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function session_date1_Callback(hObject, eventdata, handles) -% hObject handle to session_date1 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of session_date1 as text -% str2double(get(hObject,'String')) returns contents of session_date1 as a double - - -% --- Executes during object creation, after setting all properties. -function session_date1_CreateFcn(hObject, eventdata, handles) -% hObject handle to session_date1 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function session_date2_Callback(hObject, eventdata, handles) -% hObject handle to session_date2 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of session_date2 as text -% str2double(get(hObject,'String')) returns contents of session_date2 as a double - - -% --- Executes during object creation, after setting all properties. -function session_date2_CreateFcn(hObject, eventdata, handles) -% hObject handle to session_date2 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function session_experimenter_Callback(hObject, eventdata, handles) -% hObject handle to session_experimenter (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of session_experimenter as text -% str2double(get(hObject,'String')) returns contents of session_experimenter as a double - - -% --- Executes during object creation, after setting all properties. -function session_experimenter_CreateFcn(hObject, eventdata, handles) -% hObject handle to session_experimenter (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function session_manipulation_Callback(hObject, eventdata, handles) -% hObject handle to session_manipulation (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of session_manipulation as text -% str2double(get(hObject,'String')) returns contents of session_manipulation as a double - - -% --- Executes during object creation, after setting all properties. -function session_manipulation_CreateFcn(hObject, eventdata, handles) -% hObject handle to session_manipulation (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function session_task_Callback(hObject, eventdata, handles) -% hObject handle to session_task (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of session_task as text -% str2double(get(hObject,'String')) returns contents of session_task as a double - - -% --- Executes during object creation, after setting all properties. -function session_task_CreateFcn(hObject, eventdata, handles) -% hObject handle to session_task (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function ts_notes_Callback(hObject, eventdata, handles) -% hObject handle to ts_notes (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of ts_notes as text -% str2double(get(hObject,'String')) returns contents of ts_notes as a double - - -% --- Executes during object creation, after setting all properties. -function ts_notes_CreateFcn(hObject, eventdata, handles) -% hObject handle to ts_notes (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function ts_depth1_Callback(hObject, eventdata, handles) -% hObject handle to ts_depth1 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of ts_depth1 as text -% str2double(get(hObject,'String')) returns contents of ts_depth1 as a double - - -% --- Executes during object creation, after setting all properties. -function ts_depth1_CreateFcn(hObject, eventdata, handles) -% hObject handle to ts_depth1 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function ts_depth2_Callback(hObject, eventdata, handles) -% hObject handle to ts_depth2 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of ts_depth2 as text -% str2double(get(hObject,'String')) returns contents of ts_depth2 as a double - - -% --- Executes during object creation, after setting all properties. -function ts_depth2_CreateFcn(hObject, eventdata, handles) -% hObject handle to ts_depth2 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function ts_anatomy_Callback(hObject, eventdata, handles) -% hObject handle to ts_anatomy (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of ts_anatomy as text -% str2double(get(hObject,'String')) returns contents of ts_anatomy as a double - - -% --- Executes during object creation, after setting all properties. -function ts_anatomy_CreateFcn(hObject, eventdata, handles) -% hObject handle to ts_anatomy (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function cell_notes_Callback(hObject, eventdata, handles) -% hObject handle to cell_notes (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of cell_notes as text -% str2double(get(hObject,'String')) returns contents of cell_notes as a double - - -% --- Executes during object creation, after setting all properties. -function cell_notes_CreateFcn(hObject, eventdata, handles) -% hObject handle to cell_notes (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function cell_num2_Callback(hObject, eventdata, handles) -% hObject handle to cell_num2 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of cell_num2 as text -% str2double(get(hObject,'String')) returns contents of cell_num2 as a double - - -% --- Executes during object creation, after setting all properties. -function cell_num2_CreateFcn(hObject, eventdata, handles) -% hObject handle to cell_num2 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function cell_num1_Callback(hObject, eventdata, handles) -% hObject handle to cell_num1 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of cell_num1 as text -% str2double(get(hObject,'String')) returns contents of cell_num1 as a double - - -% --- Executes during object creation, after setting all properties. -function cell_num1_CreateFcn(hObject, eventdata, handles) -% hObject handle to cell_num1 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function cell_morphology_Callback(hObject, eventdata, handles) -% hObject handle to cell_morphology (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of cell_morphology as text -% str2double(get(hObject,'String')) returns contents of cell_morphology as a double - - -% --- Executes during object creation, after setting all properties. -function cell_morphology_CreateFcn(hObject, eventdata, handles) -% hObject handle to cell_morphology (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function cell_type_Callback(hObject, eventdata, handles) -% hObject handle to cell_type (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of cell_type as text -% str2double(get(hObject,'String')) returns contents of cell_type as a double - - -% --- Executes during object creation, after setting all properties. -function cell_type_CreateFcn(hObject, eventdata, handles) -% hObject handle to cell_type (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function session_taskNotes_Callback(hObject, eventdata, handles) -% hObject handle to session_taskNotes (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of session_taskNotes as text -% str2double(get(hObject,'String')) returns contents of session_taskNotes as a double - - -% --- Executes during object creation, after setting all properties. -function session_taskNotes_CreateFcn(hObject, eventdata, handles) -% hObject handle to session_taskNotes (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function session_enclosure_Callback(hObject, eventdata, handles) -% hObject handle to session_enclosure (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of session_enclosure as text -% str2double(get(hObject,'String')) returns contents of session_enclosure as a double - - -% --- Executes during object creation, after setting all properties. -function session_enclosure_CreateFcn(hObject, eventdata, handles) -% hObject handle to session_enclosure (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function epoch_label_Callback(hObject, eventdata, handles) -% hObject handle to epoch_label (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of epoch_label as text -% str2double(get(hObject,'String')) returns contents of epoch_label as a double - - -% --- Executes during object creation, after setting all properties. -function epoch_label_CreateFcn(hObject, eventdata, handles) -% hObject handle to epoch_label (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - - -function epoch_notes_Callback(hObject, eventdata, handles) -% hObject handle to epoch_notes (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of epoch_notes as text -% str2double(get(hObject,'String')) returns contents of epoch_notes as a double - - -% --- Executes during object creation, after setting all properties. -function epoch_notes_CreateFcn(hObject, eventdata, handles) -% hObject handle to epoch_notes (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - -% --- Executes on button press in ce_rm. -function ce_rm_Callback(hObject, eventdata, handles) -% hObject handle to ce_rm (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hint: get(hObject,'Value') returns toggle state of ce_rm - - -% --- Executes on button press in ce_acorr. -function ce_acorr_Callback(hObject, eventdata, handles) -% hObject handle to ce_acorr (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hint: get(hObject,'Value') returns toggle state of ce_acorr - - -% --- Executes on button press in includeIDs. -function includeIDs_Callback(hObject, eventdata, handles) -% hObject handle to includeIDs (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hint: get(hObject,'Value') returns toggle state of includeIDs diff --git a/untitled2.m b/untitled2.m deleted file mode 100644 index 57909ae..0000000 --- a/untitled2.m +++ /dev/null @@ -1,88 +0,0 @@ -%SEEscript Processes Tetrode Data and creates a CMBhome file. -% Detailed explanation goes here -% -%Import files from directory. -% -%NOTE: If a CMBobject already exists in the directory the original will be -%imported into the work space. The second CMBobject will be created in the -%directory, and can be loaded into the work space manually. -files = dir('TT*.txt'); -for i=1:length(files); -eval(['load ' files(i).name ' -ascii']); -end - - -%Create variables Sc* from TT* and saves created variables in the -%current directory. -if exist ('TT1'); -Sc1 = TT1; -save ('Sc1', 'Sc1'); -end -if exist ('TT2'); -Sc2 = TT2; -save ('Sc2', 'Sc2'); -end -if exist ('TT3'); -Sc3 = TT3; -save ('Sc3', 'Sc3'); -end -if exist ('TT4'); -Sc4 = TT4; -save ('Sc4', 'Sc4'); -end -if exist ('TT5'); -Sc5 = TT5; -save ('Sc5', 'Sc5'); -end -if exist ('TT6'); -Sc6 = TT6; -save ('Sc6', 'Sc6'); -end -if exist ('TT7'); -Sc7 = TT7; -save ('Sc7', 'Sc7'); -end -if exist ('TT8'); -Sc8 = TT8; -save ('Sc8', 'Sc8'); -end -if exist ('TT9'); -Sc9 = TT9; -save ('Sc9', 'Sc9'); -end -if exist ('TT10'); -Sc10 = TT10; -save ('Sc10', 'Sc10'); -end -if exist ('TT11'); -Sc11 = TT11; -save ('Sc11', 'Sc11'); -end -if exist ('TT12'); -Sc12 = TT12; -save ('Sc12', 'Sc12'); -end -if exist ('TT13'); -Sc13 = TT13; -save ('Sc13', 'Sc13'); -end -if exist ('TT14'); -Sc14 = TT14; -save ('Sc14', 'Sc14'); -end -if exist ('TT15'); -Sc15 = TT15; -save ('Sc15', 'Sc15'); -end -if exist ('TT16'); -Sc16 = TT16; -save ('Sc16', 'Sc16'); -end - - -%Create CMBobject in current directory -CMBHOME.Import.NL('n_tetrodes',16); - -%Import CMBobject from current directory -%files = dir('CMBobject*.mat'); -%root = load(files.name);