sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
5e08c8b552f5014e2f357cfb17a4dfd4d6161fe928886f4f28dc27b5f9452232
MATLAB
343
13
function [p, t] = nk_PTfromR(r, v, fl) r(isnan(r))=0; t = r .* sqrt((v-2) ./ (1 - r.^2)); if ~exist('v','var') || isempty(v) error('Degrees of freedom missing!') end if ~exist('v','var') || isempty(v) error('One or two-sided p values have to be specified!') end x=1-r.^2; p=betainc(x,0.5*(v-2),0.5); if fl==1, ...
0644f02ab1d7ed810822fce0c90b3d980b7b38be39c87c4f0e0a70f05b0d61b7
MATLAB
345
15
function b = loadobj(a) % loadobj for file_array class %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: loadobj.m 7147 2017-08-03 14:07:01Z spm $ if isa(a,'file_array') b = a; else a = permission(a, 'rw'); ...
b76661c84e5f93bfa5880f769e81274655a5fdf53f0e534379d4dd0c9295ed5a
MATLAB
345
5
% Compiles the MIToolbox functions mex MIToolboxMex.c MutualInformation.c Entropy.c CalculateProbability.c ArrayOperations.c mex RenyiMIToolboxMex.c RenyiMutualInformation.c RenyiEntropy.c CalculateProbability.c ArrayOperations.c mex WeightedMIToolboxMex.c WeightedMutualInformation.c WeightedEntropy.c CalculateProbabi...
c7fc9e55566e5b00480210a9302151c60e77ae9b82992527c1ef5a6c484918e8
MATLAB
345
13
function [RotMat, rotatemat] = nk_Procrustes(TempMat,SourceMat) % Define coordinate space between orignal and rotated components temp=TempMat'*SourceMat; % Orthogonalize space [V,~,U]=svd(temp); % Determine procrustean transform rotatemat=U*V'; % Finally transform SourceMat to minimize difference to TempMat RotMat ...
ff99e8d0718d5d6643acb6c8e8f2e63cfd83a61e95ae465d5ecae3883d3a0603
MATLAB
348
28
function c = myCallerName() % c = myCallerName() % % OUTPUTS % c = name of function that called function that called "myCallerName" % % % i.e. % function foo() % bar(); % end % % function bar() % c = myCaller(); % % c will be "foo" % end % % % uses dbstack ST = dbstack(); if length(ST)<3 c = 'base'; e...
0462e9aa363589bb7acfd71b5d4084fd86792ae67d6a906ea688401ad129da1b
MATLAB
349
13
function [X] = proximalL1infnorm(D, tau) % min_X 0.5*||X - D||_F^2 + tau*||X||_{1,inf} % where ||X||_{1,inf} = sum_i||X^i||_inf, where X^i denotes the i-th row of X % X = D; n = size(D,2); % for ii = 1:size(D,1) % [mu,~,~] = prf_lb(D(ii,:)', n, tau); % X(ii,:) = D(ii,:) - mu'; % end [m,n]=size(D); [mu,~,~]=pr...
82a4a3a460fc179609c09475ef42d66744915fba17b96cee077ca0a7addee6ca
MATLAB
349
19
function blobs(f) figure xyz = f.xyz; state_color = f.state_colors; cdata = bt_utils.state_cdata; for j = 1:size(cdata,1) pts = state_color == j; if any(pts) h = bt_utils.alphavol_wrapper(xyz(pts,:),Inf); hold on set(h,'FaceColor',cdata(j,:),'EdgeColor','none','FaceAlpha',0.9,'UserData','blob'); ...
a43269ea135d84d03e0ebbffda501688decf26f65e44fcd254ddd8a6304813ae
MATLAB
350
10
% Inner-product and apply sparse selection % This function performs the following: % UV = U * V, out(ii) = UV(iR(ii), iC(ii)); % To use this function % out = sparse_inp_native (U', V, iR, iC, length(iR)) % U: m x r (for C simplicity, we follow LMaFit to use U') % V: r x n % iR: len x 1 ...
6ee71c3def9fd256719e8cdc0c860a7746a9bc1bbfcc7652e1ce37ee5180b0c5
MATLAB
354
17
function t = fieldnames(obj) % Fieldnames of a file-array object %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: fieldnames.m 7147 2017-08-03 14:07:01Z spm $ t = {... 'fname' 'dim' 'dtype' 'offset' ...
9321210021d365d2c3188d4907e61791668fa4a47e57989749c77ed537e9cbff
MATLAB
355
12
function [ Y, integerformat ] = mp2rage_scale_UNI( Y ) %MP2RAGE_SCALE_UNI converts MP2RAGE to -0.5 to 0.5 scale, if necessary if min(Y(:))>=0 && max(Y(:))>=0.51 % converts MP2RAGE to -0.5 to 0.5 scale - assumes that it is getting only positive values Y = (Y- max(Y(:))/2)./max(Y(:)); integerformat=1; else ...
78339fb47adf6f85211e6364318383f116199ef4715048ba12b1e3199b62fed0
MATLAB
359
15
function graph = array_to_graph(a) NODES = (1+sqrt(1+(8*length(a))))/2; adj_m = zeros(NODES); %a(a>0) = 1; adj_m(triu(true(NODES),1)) = a; adj_m = adj_m + transpose(adj_m); graph.am = adj_m; %reshape(a,[sqrt(length(a)),sqrt(length(a))]); graph.al = cellfun(@(x) find(x),num2cell(graph.am,2),'un',0); nodes = 1:size(adj...
2b97fada9a58ba67eaf9e5a56e7afc5e2c8025116b044aba075fda9f73fabb7e
MATLAB
361
10
% This make.m is used under Windows % add -largeArrayDims on 64-bit machines mex -largeArrayDims -O -c svm.cpp mex -largeArrayDims -O -c svm_model_matlab.c mex -largeArrayDims -O svmtrain.c %svm.obj svm_model_matlab.obj mex -largeArrayDims -O svmpredict.c %svm.obj svm_model_matlab.obj mex -largeArrayDims -O libsvmrea...
d855e3488f02297c52191d91a0de7fcd142557b8f149a3d98e84fc249aa75f27
MATLAB
361
19
function [res] = elbow(scores, alpha) b = length(scores); sigma2 = var(scores,1); [R, idxs ] = sort(scores,'descend'); k = 1; while (R(k)==R(k+1)) k = k + 1; end while (k<b)&&((R(k)-R(k+1))/sigma2 > alpha) k = k+1; end if k > 1 res = idxs(1:k-1); els...
bcda029fe34e65693b9dba9bb167eb1376b68d8f0d079752ed54d4ccd6b966ad
MATLAB
363
13
function out = full(fa) % Convert to numeric form % FORMAT full(fa) % fa - a file_array %__________________________________________________________________________ % Copyright (C) 2018 Wellcome Trust Centre for Neuroimaging % % $Id: full.m 7501 2018-11-30 12:16:58Z guillaume $ [vo{1:ndims(fa)}] = deal(':'); out = su...
c2f789b3580d71ad35caa5c998989584e649bfe636e81806ae8fa52fe2ca7734
MATLAB
363
22
function [fea] = mrmr_mibase_d(d, f, K) % function [fea] = mrmr_mibase_d(d, f, K) % % Baseline for comparing MRMR % % By Hanchuan Peng % April 16, 2003 % nd = size(d,2); nc = size(d,1); t1=cputime; for i=1:nd, t(i) = mutualinfo(d(:,i), f); end; fprintf('calculate the marginal dmi costs %5.1fs.\n', cputime-t1); ...
e87bef8234a72a973f9e60130c9742cbf58fdd58fbe750e81ed83d0b1b432012
MATLAB
363
8
% Note, this is used only for App deployment disp('===>>> Running Opticka via App Deployment…'); disp(['===>>> $HOME is: ' getenv('HOME')]); disp(['===>>> App root is: ' ctfroot]); disp(['===>>> PTB root is: ' PsychtoolboxRoot]); disp(['===>>> PTB config is: ' PsychtoolboxConfigDir]); o=opticka; disp(['===>>> Opticka V...
fc6fb489220fa3d6b731a43722bc27850a1ba56d0a556495c34ed948fa188eee
MATLAB
363
16
%[2018]-"A Novel Multi-Class EEG-Based Sleep Stage Classification System" %(5) function HC = jHjorthComplexity(X,~) % First & second derivative x0 = X(:); x1 = diff([0; x0]); x2 = diff([0; x1]); % Standard deviation of first & second derivative sd0 = std(x0); sd1 = std(x1); sd2 = std(x2); % Complexity...
a1825b53b159a498be1fbed158b6440f46fa1dcedc19f020a62942e09a56b73c
MATLAB
364
8
function outputMatrix = assessCounterbalancing(conditionOrder) %> @fn assessCounterbalancing %> @brief Compatibility wrapper for taskSequence.assessCounterbalancing. %> %> @param conditionOrder ordered integer condition sequence. %> @return square matrix where A(i,j) is count of i preceding j. outputMatrix = taskSeque...
fd842d1fee94a222fce607e648622504cfa55fdee5e41c7fee57d101aa6be5ec
MATLAB
366
27
function [nAtA,normA,nBtB,normB,nAtB]=normalizeKernelMatrix(AtA,BtB,AtB) % normalize random kernel % Yifeng Li % Feb. 08, 2012 nAtA=[]; normA=[]; nBtB=[]; normB=[]; nAtB=[]; normA=sqrt(diag(AtA)); nAtA=AtA./(normA*normA'); if nargin==1 return; end normB=sqrt(diag(BtB)); nBtB=BtB./(normB*normB'); if nargin==2 ...
298c1d496ff2642282a1246b1de1d527a10ff513a156de9ae9591eaef3012a12
MATLAB
367
13
function trimmed = mripy_trim_init_resp(x, trim, run_len) % Trim the initial TRs of each run. % 2021-03-05: Created by qcc assert(mod(length(x), run_len)==0); n_runs = length(x) / run_len; trimmed = reshape(x, run_len, n_runs); trimmed = trimmed(1+trim:end,:); trimmed = trimmed(:); if size(x, 1)...
882d14fe8767a551af9ef9afc4f0ca78ce67aad3a847f3af3cc0308c0fd3dc02
MATLAB
368
12
function [random,seed]=uniran(seed) %UNIRAN is the uniform random generator used in mcdcov.m and ltsregres.m % % This function is part of LIBRA: the Matlab Library for Robust Analysis, % available at: % http://wis.kuleuven.be/stat/robust.html seed=floor(seed*5761)+999; quot=floor(seed/65536); seed=floor...
b3f3b5c03990df1795602fb6305b141a2ecef0e28357b7a0bca7bbc751383648
MATLAB
369
13
function kappa = nk_DiversityKappa(E, L, m, n) % function A = nk_DiversityKappa(P, vec, m, n) % Compute entropy-based measure of ensemble diversity if ~exist('m','var'), m = size(E,1); end if ~exist('n','var'), n = size(E,2); end rL = repmat ( L, 1, n); cE = bsxfun(@eq, E , rL); sCE = sum(cE,2); p = mean(sCE./m); kap...
e88c7fbd5e1743b27119c0d484054fd8aa19911e3733f055bd851adddcc3294e
MATLAB
369
19
function [hEPerf, hE] = nk_EnsPerf(E, L) global MODEFL EVALFUNC % Compute ensemble performance switch MODEFL case 'classification' hE = sign(mean(E,2)); % throw a coin on the zeros hE = nk_ThrowCoin(hE); case 'regression' hE = mean(E,2); end % Measure accuracy or some ...
ec3f71c8792f84c617e93179a4d4d68be11ce5a0e7e956bbd609f11411ab6ab5
MATLAB
371
18
function [ f_y, Df_y ] = pnopt_quad( P, q, r, x ) % pnopt_quad : PNOPT local quadratic approximation % % $Revision: 0.8.0 $ $Date: 2012/12/01 $ % global subprob_Dg_y if isa( P, 'function_handle' ) H_x = P( x ); else H_x = P * x; end f_y = 0.5 * x' * H_x + q' * x + r; if nargout > 1 sub...
82e69bc581b05b3d03493d8c8f19834ebf1ee8efdf6726e1917fc493dc584dbc
MATLAB
373
12
%% run_all_core_oracle.m % Convenience script for the core oracle benchmark pipeline. % % Assumes the workspace already contains: % EEG_all_epochs, EOG_all_epochs, EMG_all_epochs, and optionally fs. % % Steps: % 1) build benchmark dataset % 2) run validation-set oracle sweeps run('scripts/build_decomp_benchmark_...
c48502cb8031831c2d8cfca860837b1f213905da30c56852be6c0a47a6ee1816
MATLAB
373
17
% GETENVIRONMENT Read value of "global" variable % % % Copyright 2009 :: Michael E. Tipping % % This file is part of the SPARSEBAYES baseline implementation (V1.10) % % Contact the author: m a i l [at] m i k e t i p p i n g . c o m % function value = getEnvironment(variable) VA = get(0,'UserData'); if isfield(VA,varia...
daec576cd9c92e4c9619fd72536653f32f60ebf4a3520811dbae6e166c0e6eec
MATLAB
374
20
clear; %clc; U = rand(500, 3); V = rand(3, 10000); iR = [1, 3, 3]; iC = [2, 4, 6]; len = length(iR); out_us_mex = sparse_inp(U', V, iR, iC)'; out_us_net = sparse_inp_native(U, V, iR, iC); % call native if nnz(out_us_mex ~= out_us_net)>0 warning('inconsistent results found in sparse_inp_native') else dis...
20ca9580c4f994ac827fa35dfd55efb36e346555461e1c10ec809817d80c09ad
MATLAB
375
13
function res = im2row(im, winSize) %res = im2row(im, winSize) [sx,sy,sz] = size(im); res = zeros((sx-winSize(1)+1)*(sy-winSize(2)+1),prod(winSize),sz); count=0; for y=1:winSize(2) for x=1:winSize(1) count = count+1; res(:,count,:) = reshape(im(x:sx-winSize(1)+x,y:sy-winSize(2)+y,:),... ...
8cf39399d044886204b7053960e5bfa19c4df9a5138ca731ca175420a3429a94
MATLAB
375
32
function y = rescale(x,a,b) % rescale - rescale data in [a,b] % % y = rescale(x,a,b); % % Copyright (c) 2004 Gabriel Peyr? if nargin<2 a = 0; end if nargin<3 b = 1; end if iscell(x) for i=1:length(x) y{i} = rescale(x{i},a,b); end return; end m = min(x(:)); M = max(x(:)); if M-m<eps ...
ebc7c2140c7c63270fa7c0400c3d125c8343f39776426a1fc1b220f88535f54a
MATLAB
375
14
function [trainExtr, testExtr, outTrain, outTest] = nk_NNMFFeatRank(Y, label, Ynew) feMethod='nmf'; optionFE.facts=15; Y=Y'; [trainExtr,outTrain]=featureExtractionTrain(Y,[],label,feMethod,optionFE); if exist('Ynew','var') && ~isempty(Ynew) && nargout==4 Ynew = Ynew'; [testExtr,outTest]=featureExtrationTest(...
ab31e55f236cd4a77c523e1033a43e72a5e7a2ff1fb19292b14408964e6ed396
MATLAB
376
17
% ======================================================================== %> @brief %> %> Copyright ©2014-2022 Ian Max Andolina — released: LGPL3, see LICENCE.md % ======================================================================== classdef rewardManager < handle properties end methods fu...
5d62c3acb09a1ca305e4281249c2c86605194f34814b702c1510f25b03bd066a
MATLAB
377
16
% Function to start parallel pool with number of workers as currently % accessible CPUs % % Jeff Eilbott, 2016, jeilbott@surveybott.com function pool = start_parpool() numCores = feature('numCores'); pool = gcp('nocreate'); if ~isempty(pool) && pool.NumWorkers < numCores delete(pool); pool = gcp('nocreate'); e...
36411872afaace73a73a633d5f5a9556dc7ad2dd386e680912d024368ffb15bb
MATLAB
381
15
function tso = restrict(tsin, t0 ,t1) % R = Restrict(tsa, t0, t1) % Returns a new tsa (ts) R so that only D.Data is between % timestamps t0 and t1, where t0 and t1 are in units % % If units are not specified, assumes t has same units as D % t0 and t1 can be arrays % % ADR 2011 % version L6.0 % converts to tsd ...
6e9599a6cf23c90211de9a22a8163bcb8e7eb25b158b2e5d7502d5744341b77b
MATLAB
382
16
function [menustr, menuact] = nk_CheckCalibAvailMenu_config(menustr, menuact, calibuse) global CALIBAVAIL if CALIBAVAIL if exist('calibuse','var') && ~isempty(calibuse) && calibuse calibstr = 'yes'; else calibstr = 'no'; end menustr = [sprintf('Use calibration data [ %s ]|',c...
c18644cddbf6befb9eafb8444c53b0052f3eadb04dab634c30226ec8973e1e74
MATLAB
382
20
function D = nk_BhattacharyaFeatRank(Y, L) % Y : Data % L : Target Labels [~,n] = size(Y); ix = unique(L(~isnan(L))); indP = L==ix(1); indM = L==ix(2); YP = Y(indP,:); YM = Y(indM,:); D = zeros(1,n); warning off try for i=1:size(Y,2) ind = true(1,n); ind(i)=false; D(i) = bhattacharyya(YP(:,i...
fa5508f204b16b9a5761aeb442edaf7226e3919cf2725e2e284bd54a0f79cb54
MATLAB
384
14
function t = numel(obj) % Number of simple file arrays involved. %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: numel.m 7147 2017-08-03 14:07:01Z spm $ % Should be this, but it causes problems when accessing % obj ...
b9d3c3ce636d37e5fb0bf791a5695daaad721d169fdf3536daed90d04f592715
MATLAB
385
17
function OK = FillFeatures(self) % CalculateFeatures and save them MCS = MClust.GetSettings(); % Which features need to be calculated featuresToCalc = MCS.FeaturesToUse; try [self.FeatureTimestamps, self.Features] = MClust.CalculateFeatures(featuresToCalc); OK = true; catch ME disp('Failed to fill (calculate) feat...
79c54d43e5a3ca2def4a16272fb2f6574c3412d691d3e5c42c3ee7e1b38049fa
MATLAB
386
23
function [PP, fPP] = nk_CheckFileExist(P) PP=[]; fPP=[]; if iscell(P), P = char(P);end for i=1:size(P,1) iP = deblank(P(i,:)); if ~exist(iP,'file') if isempty(PP) PP = iP; else PP = char(PP,iP); end else if isempty(fPP) fPP = iP; ...
0f9767460e102cc97b7d592e715abd780d89fad4b310ef00cd09cb107ca754f1
MATLAB
387
16
function [ecovs, eind] = nk_ExtractCovs(covs, ACTPARAM) lact = numel(ACTPARAM); ecovs=[];eind=[]; for i=1:lact if ~isempty(ACTPARAM{i}) && strcmp(ACTPARAM{i}.cmd,'correctnuis') ecovs = covs(:,ACTPARAM{i}.COVAR); break end end for i=1:lact if ~isempty(ACTPARAM{i}) && strcmp(ACTPARAM{i}.cmd,'no...
15db0d4badf6f331be825bd967ff108ba0b9d348624c4dffcb32cbc59abdc7ab
MATLAB
391
23
function DIRSTACK = pushdir(newdir); % dirstack = pushdir(newdir) % % Pushes the current dir onto the directory stack. % Then cd's to the newdir if given. % Maintains the directory stack in a global variable. % ADR 1998 % version L4.1 % status PROMOTED global DIRSTACK if isempty(DIRSTACK) DIRSTACK = {pwd}; else ...
153597c08d97192a1e62ccb218a07a520f10ebde099816f20516e334c8d0f0e9
MATLAB
392
12
function ClusterFunc__ToggleUnaccountedForSpikesOnly( self ) % ShowUnaccountedForSpikesOnly % remove all points from the cluster %================================================ % PARAMETERS %================================================ %================================================ % MAIN CODE %==============...
a573e0fed59428db0254114ffd5a999ef1c8e60ba44e8c1d8635fe016f57725f
MATLAB
392
22
function ClusterFunc_DeleteLimit(self) % Convex Hull clsuter add limit MCC = self.getAssociatedCutter(); MCC.StoreUndo('Delete Limit'); % get axes xFeat = MCC.get_xFeature(); yFeat = MCC.get_yFeature(); iL = self.findLimit(xFeat, yFeat); if ~isempty(iL) self.featuresX(iL) = []; self.featuresY(iL) = []; ...
1ff8ea94458eb69a9450663fa70903a1d15a27914471680305a79873775646e9
MATLAB
393
20
function results = run_tests() % results = run_tests() % run all tests in this caffe matlab wrapper package % use CPU for testing caffe.set_mode_cpu(); % reset caffe before testing caffe.reset_all(); % put all test cases here results = [... run(caffe.test.test_net) ... run(caffe.test.test_solver) ... run(caf...
73d4b9f66d0bab178eda562ce97da9b0038e9bb72d197100d9acc72262c05419
MATLAB
393
18
function rX = ranking(X) % Transform an arbitrarily distributed signal to a uniformly distributed % one. nX = size(X,2); sortX = zeros(size(X)); sI = sortX; rX = sortX; for n=1:nX % Determine sort index [sortX(:,n),sI(:,n)]=sort(X(:,n)); % Resort ascending sequence according to % the corresponding sort ...
26a6d0a73377d41e835865986521e87e30385f119cc50cf88d2cc7e7c44777c4
MATLAB
394
16
function print_figure(handles, objnames, savename) tmpfig = figure; %tmpfig = figure('visible','off'); n_obj = numel(objnames); h = []; for i= 1:n_obj hi = handles.(objnames{i}); h =[hi h]; end newax = copyobj(h,tmpfig); set(newax, 'units', 'normalized', 'position', [0.13 0.11 0.775 0.815]); %I = getframe(t...
372b94e400b2e7a6538e1ebed96c1e88df4699d851d1a028a041bb19bc24a6c7
MATLAB
395
17
function [selectedFeatures scoreVector] = MIM(k, data, labels) %function [selectedFeatures scoreVector] = MIM(k, data, labels) % %Mutual information Maximisation % % The license is in the license.txt provided. numf = size(data,2); classMI = zeros(numf,1); for n = 1 : numf classMI(n) = mi(data(:,n),labels); end [sco...
83dfc4cbb1210f77d526d70d218aaa5b12b002e43b08b7af5d20eb2071bf7766
MATLAB
395
15
function t = mystruct(obj) %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: mystruct.m 7147 2017-08-03 14:07:01Z spm $ if numel(obj)~=1 error('Too many elements to convert.'); end fn = fieldnames(obj); for i=1:le...
72f129f3b0f182e0ab59be294caf0bfea8f7436f153c7a3775f7eac4eb9f9d88
MATLAB
398
13
% Predicts class scores using a trained ELM model. % % scores = mexElmPredict( inW, bias, outW, X ); % % INPUT : % inW - input weights matrix (trained model) % bias - bias vector (trained model) % outW - output weights matrix (trained model) % X - samples matrix (vectors in colu...
d41d67be388e1b4578bb7e43aec8d4539fd8321a67b128e0541b0cec8b148161
MATLAB
399
16
% Notation: This fitness function is for demonstration function cost = jFitnessFunction1(r , X, Ps) if sum(X == 1) == 0 cost = 1; else cost = jwrapper(r.Y(:, X), r.YL, r.T(:, X), r.L, Ps ); end function cost = jwrapper(xtrain, ytrain, xvalid, yvalid, Ps) global TRAINFUNC [~, FullModel] = TRAINFUNC(xtrain, ytrai...
f9e1301f7c8beeacfd0917dc03e7cb04d16d3cd2c8f12733316f460f3620a13f
MATLAB
399
12
function h = alphavol_wrapper(a,r) if nargin < 2 || isempty(r) r = Inf; end [V,S] = utils.alphavol(a,r); k = S.bnd; map = unique(k(:)); map(:,2) = 1:length(map); % First col is the index in k, second row is the new index vertices = a(map(:,1),:); % A final list of vertices faces = arrayfun(@(b) map(find(map(...
2f1836a8db3d73b914927ca7440d19ae6efe1b788a5af470bd842b760b1f3010
MATLAB
400
16
function R = restrict(tsa, t0, t1) % R = Restrict(tsa, t0, t1) % Returns a new tsa (ts) R so that only D.Data is between % timestamps t0 and t1, where t0 and t1 are in units % % If units are not specified, assumes t has same units as D % t0 and t1 can be arrays % % ADR 2011 % version L6.0 timerestricted = tsa...
ea996437be24c9fdaeed67a362ac114486adad711a4f2b41426cf07782feec1c
MATLAB
400
19
function set_SubInd(handles, act) SubInd = true(size(handles.label)); switch act case 'set' SubInd = get(handles.txtSubgroupSet,'Value'); if ~isempty(SubInd) && ~strcmp(SubInd,'') try SubInd = evalin('base',SubInd); catch en...
9d81bbc9dacfc0d74acf6a3ef1130b00a4689a61f4ba877c49543de9224fdcb9
MATLAB
402
15
function dispsig(signalMatrix, range, titlestr); %DISPSIG - deprecated! % % Please use icaplot instead. % % See also ICAPLOT % @(#)$Id: dispsig.m,v 1.2 2003/04/05 14:23:57 jarmo Exp $ fprintf('\nNote: DISPSIG is now deprecated! Please use ICAPLOT.\n'); if nargin < 3, titlestr = ''; end if nargin < 2, range = 1:siz...
3df2d189f33ff8dad1d4267002e453d6b8078398ea7982cb20423d5b12afc859
MATLAB
403
16
clear, clf, clc data = readmatrix('../../experiment/field_intensity.dat'); field = data(:,1) % ==== Experiment Exp.mwFreq = 179.818; Exp.Range = [min(field) max(field)]; Exp.nPoints = 401; Exp.Harmonic = 0; % ==== Theory Sys = orca2easyspin('./PYD_epr.out'); Sys.lwpp = 0.5 ; [ field, spec ] = pepper(Sys, Exp); data =...
a0a30c37a5ea3efd6450c95bf9f689c7a258a30754288c069260f83b734b8f0b
MATLAB
403
26
function r=getRank(v) % rank the values in column vector v % Yifeng Li % October 24, 2012 % example: % v=[ 0.5;0.2;0.4;0.6;0.2;0.1;0.9;0.5;0.5] % r=getRank(v) n=numel(v); r=zeros(n,1); [vS,ind]=sort(v); i=1; while i<=n c=1; su=i; % sum while i<n && vS(i)== vS(i+c) su=su + i+c; c=c+1; end ...
80c0a6469f9063a75e69ef94f47b79509888f6a665f42faab2727f23eb3820b1
MATLAB
404
13
clf tm = 1.84e4; plot([1:tm]/(60*30),proc.pupil(1).area_raw(1:tm),'color',[0 .6 0],... 'linewidth',1.5) hold all; plot([1:tm]/(60*30),proc.pupil(1).area(1:tm),'k','linewidth',.5) axis tight; box off; ylim([0 400]) xlabel('time (minutes)') ylabel('area (pixels^2)'); text(.78,.65,'raw trace','color',[0 .6 0],'units',...
9be756ee47a9e59eabafb68ead941e25be26419e5e53cface194e54cefe5ee44
MATLAB
404
14
function y = ObjectiveFunction1(n, c, L, T, tL, tY, Ps) global TRAINFUNC RFE [~, model] = feval(TRAINFUNC, tY, tL, 1, Ps); switch RFE.Wrapper.datamode case 1 param = nk_GetTestPerf(tY, tL, [], model, tY); case 2 param = nk_GetTestPerf(T, L, [], model, tY); case 3 param = nk_GetTe...
835687467fc8d426bfe9bbd5e3ef2e1697cc475d3c6e7e4f7c8c15c23fce98c1
MATLAB
405
10
function [verts, faces] = mripy_read_asc(fname) %MRIPY_READ_ASC Read FS/SUMA surface (vertices and faces) in *.asc format. % 2017-08-12: Created by qcc n = dlmread(fname, '', [1, 0, 1, 1]); % Undocumented feature: \s as delimiter n_verts = n(1); n_faces = n(2); verts = dlmread(fname, '', [2, 0, 1+n_ve...
93d078804fe8c0b6051ac3505781be1c747e8abb81b802265e6fdef4f1e638b2
MATLAB
405
17
function w = TGL_projection_rowise(v, lambda_3) %% FUNCTION TGL_projection_rowise % projection of temporal group Lasso (l21 projection). % %% OBJECTIVE: % argmin_w { 0.5 \|w - v\|_2^2 % + lambda_3 * \|v\|_2 } % This is a simple thresholding: % w = max(\|v\|_2 - \lambda_3, 0)/\|v\|_2 * v nm = norm(v, 2); i...
9b80f55cc447b35bb53eadafde5d53afa3eb0ea42ed952328dac971141cbf1a8
MATLAB
407
16
function output = h(X) %function output = h(X) %X can be a matrix which is converted into a joint variable before calculation %expects variables to be column-wise % %returns the entropy of X, H(X) if (~isa(X,'double')) error('Error, inputs must be double vectors or matrices') end if (size(X,2)>1) mergedVector = MI...
9fd8cbbdcf5f5ded1427527cd34b8870e7f2f7bf0df3bb5c1215e2abb7d99f35
MATLAB
408
18
function en = end(a,k,n) % Overloaded end function for file_array objects. %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: end.m 7147 2017-08-03 14:07:01Z spm $ dim = size(a); if k>length(dim) en = 1; else i...
d1b5c037fbe14d2e34a7ab3d18b43feb0eed95b73cc5991356f948e7194bc049
MATLAB
410
3
mex -I../../ mRMR_D_Mex.c ../../src/MutualInformation.c ../../src/ArrayOperations.c ../../src/CalculateProbability.c ../../src/Entropy.c mex -I../../ DISR_Mex.c ../../src/MutualInformation.c ../../src/ArrayOperations.c ../../src/CalculateProbability.c ../../src/Entropy.c mex -I../../ CMIM_Mex.c ../../src/MutualInfor...
fdacbb92bc6c3cd04c64156fb7fa345f45a26978aa504f374bbe2dc5129bc4a1
MATLAB
411
18
function oECOC = nk_OneVsAll(Classes, number_classes) nc = size(Classes,2); oECOC=zeros([number_classes nc]); tECOC=-1*ones([number_classes number_classes]); % Create multi-group coding matrix for one-vs-one for i=1:number_classes tECOC(i,i)=1; end % Assign dichotomizers to class vector for i=1:number_classes ...
3892cbaae03dc328faf682afa3d86dc9f524d536495140db8013323dc34d8aac
MATLAB
414
16
function [mcX,mX]=mcenter(x) %MCENTER mean-centers the data matrix x columnwise % % Required input arguments: % x : Data matrix (n observations in rows, p variables in columns) % % This function is part of LIBRA: the Matlab Library for Robust Analysis, % available at: % http://wis.kuleuven.be/stat...
b0a8d76139f9e2ee01a02f03d52632475f33ebf2df6714f24a3eed7f01d02795
MATLAB
415
13
function s = perlin (m) %m is the size of the patch, will always return a square s = zeros(m); % output image w = m; % width of current layer i = 0; % iterations while w > 3 i = i + 1; d = int...
6b682fcf35ec2b307671182674b1a96a0786c2aa6636fe24a02eea9bf8bde22c
MATLAB
418
14
function [ fvP ] = primalObj( X, y, W, lambda1, lambda2) %PRIMALOBJ Summary of this function goes here % Detailed explanation goes here % primal objective (without augmented terms) % P(W) sum_i^m ||Xi wi - yi|| + lambda1 ||W||_{1,2} + lambda2/2 ||W||_F^2 fvP = lambda1 * sum(sqrt(sum(W.^2, 2))) + lambda2 /2 * sum(...
fbf9597c39fb63018ef50f44f0e1b8b20e6cc3f7f130b5df327d31788d0fbe92
MATLAB
419
16
function E = isemptycell(C) % ISEMPTYCELL Apply the isempty function to each element of a cell array % E = isemptycell(C) % % This is equivalent to E = cellfun('isempty', C), % where cellfun is a function built-in to matlab version 5.3 or newer. if 0 % all(version('-release') >= 12) E = cellfun('isempty', C); else ...
11144b339516fdb2d302f4338d0a48e7010f4b6a304cd7733f8bfd07aa73f9b7
MATLAB
420
19
function D = nk_DirSelector(titlestr, D) global SPMAVAIL if isempty(SPMAVAIL), SPMAVAIL = logical(exist('spm_select','file')); end if ~exist('D','var') || ~exist(D,'dir'), D = {pwd}; elseif ischar(D) D = {D}; end if ~exist('titlestr','var') || isempty(titlestr) titlestr = 'Select Directory'; end if SP...
15f5ec1641b0f9376744d702c2461005a6dce6db08d4f9d5aa6e1e518bf8ced4
MATLAB
420
14
function set_panel_visibility(handles,flag) % Visualization panel set(handles.pnVisual,'Visible',flag); set(handles.pn3DView,'Visible',flag); % Classification / Regression plot set(handles.pnBinary,'Visible',flag); % Model performance set(handles.pnModelPerf,'Visible',flag); % Binary classifier selector set(handles.po...
a2999123b9ce0d872853f1158ec2ea8a798ee69e9b002230058a29aa96c0a98e
MATLAB
421
15
function ClusterFunc_DeleteAllSpikes( self ) % DeleteAllSpikes % remove all points from the cluster %================================================ % PARAMETERS %================================================ %================================================ % MAIN CODE %===========================================...
89281451787a954bf0f1ba8e7dbd27ecd7866e5831545a015c448831c01a48cb
MATLAB
422
14
function [AUC] = getAUC (Actual,Predicted) if length(unique(Actual))~=2 ||max(unique(Actual))~=1 error('Strange input for AUC analysis'); end nTarget = sum(double(Actual == 1)); nBackground = sum(double(Actual ~= 1)); % Rank data R = tiedrank(Predicted); % 'tiedrank' from Statistics Toolbox % Calculate AUC A...
e3b4f1bc7f5b7fc89a143689806becf4777a69f31d9d5396053924826938827c
MATLAB
423
17
function PlotSelf(self, xFD, yFD, ax ,xFeat, yFeat) % Redraw cluster using xFD and yFD on a given axes S = self.GetSpikes(); h = plot(ax, xFD(S), yFD(S), '.', ... 'marker', self.marker, ... 'markerSize', self.markerSize, ... 'color', self.color); % is x,y one of the limits iL = self.findLimit(xFeat, yFeat...
fc836f35636f8a7679e982331b72306c0f21ca32dd1dae0d9e8b141db57affce
MATLAB
423
18
function K = WLKernel_rowsInput(Y, height) %K = zeros(size(Y,1)); %size(K) gList = [] for i = 1:size(Y,1) i %for j = 1:size(Y,1) graph = array_to_graph(Y(i,:)); %gB = array_to_graph(Y(j,:)); gList = [gList, graph]; end %height = 3; ...
0a2cbab92c5a4e2738cdd1feaf2591a359c594c9a400ec939590c24ae6452e08
MATLAB
424
19
function result = normalizekm(km) % Copyright 2012 Nino Shervashidze, Karsten Borgwardt % normalizes kernelmatrix km % such that diag(result) = 1, i.e. K(x,y) / sqrt(K(x,x) * K(y,y)) % @author Karsten Borgwardt % @date June 3rd 2005 % all rights reserved nv = sqrt(diag(km)); nm = nv * nv'; knm = nm .^ -1; for i = 1...
1522133940f55eac55c1a78d5a23161c7d67a24cbfa4e74e737cf7b8acfdff25
MATLAB
424
15
function hdr = empty_hdr(fmt) % Create an empty NIFTI header % FORMAT hdr = empty_hdr %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: empty_hdr.m 7147 2017-08-03 14:07:01Z spm $ if ~nargin, fmt = 'nifti1'; end org =...
2a5ac0d28f167d0526b7a761c9373d1c247f2876df5e4a5119c2150980ed702a
MATLAB
425
21
function RecalculateProjection(self) % Recalculate Projection (self) % % Modified from Jadin Jackson's original code. iPath = self.projectionPath.GetI(); %fprintf('Recalculating using projection path %d\n', iPath); switch (iPath) case 1 self.Projection1(); case 2 self.Projection2(); case 3 self.Projection3(...
ede5ea5f133df93e76f1e7e15a365bd53954fee57fb1e53a518fccf2fef020c0
MATLAB
426
20
function RBA = jRatioBandPowerAlphaBeta(X,opts) % Parameters f_low1 = 8; % 8 Hz f_high1 = 12; % 12 Hz f_low2 = 12; % 12 Hz f_high2 = 30; % 30 Hz % sampling frequency if isfield(opts,'fs'), fs = opts.fs; end % Band power alpha BPA = bandpower(X, fs, [f_low1 f_high1]); %...
f9e57b939025a9c114dd581b2384ffd2fde04facd5969dfcfc7d17d9aead616a
MATLAB
428
16
%[2018]-"Improved binary dragonfly optimization algorithm and wavelet %packet based non-linear features for infant cry classification" (4) function ReEn = jRenyiEntropy(X,opts) % Parameter alpha = 2; % alpha if isfield(opts,'alpha'), alpha = opts.alpha; end % Convert probability using energy P = (X...
24e4335c0bfa324c4965c0e97518e73d46618e852cf92bf7af8a5222611b0034
MATLAB
432
16
%[2018]-"Improved binary dragonfly optimization algorithm and wavelet %packet based non-linear features for infant cry classification" (5) function TsEn = jTsallisEntropy(X,opts) % Parameter alpha = 2; % alpha if isfield(opts,'alpha'), alpha = opts.alpha; end % Convert probability using energy C = ...
d2fc330c4d1d1cadde262bfee1f5cdeb9167722b702d681a76647e50c3f1171b
MATLAB
435
33
function P = Permutationmatrix3 P = zeros(8,8); for a = 0:1 for b = 0:1 for c = 0:1 am = [0, a, b; a, 0, c; b, c, 0;]; perm=perms([1 2 3]); for k=1:6 P(graphlettype(am), graphlettype(am(perm(k,:),perm(k,:)) )) = 1; end end end end end function result = graphlettype(am) % determine grap...
f6b7c6d98c60c3d5898eeb6aca9d31ec5254699fa1402557a4fe6172b5efe245
MATLAB
435
15
function CutterOption_SelectAndDelete(self) self.StoreUndo('Select and Delete'); names = self.getClusterNames; clustersToDelete = listdlg(... 'ListString', names, ... 'Name', 'Delete clusters', ... 'PromptString', 'Select clusters to delete...', ... 'OKString', 'DONE', 'CancelString', 'Cancel', ... ...
3cbbece6a69776ca1540d40dc47a950cb9e38891ed56d50a0e341428a5ec5852
MATLAB
437
24
function G = nk_CompGridFreq(V1, V1ind, V2, V2ind) vl1 = length(V1ind); vl2 = length(V2ind); G = zeros(vl1,vl2); G1 = zeros(length(V1),1); G2 = zeros(length(V2),1); for z=1:length(V1ind) ind = V1 == V1ind(z); G1(ind) = z; end for z=1:length(V2ind) ind = V2 == V2ind(z); G2(ind) = z; end for z=1:length...
0ce3b58091da87796103b3c5d434fd59ba13945b432fd72966cfc3100e217942
MATLAB
438
15
function sVimg = nk_SmoothImage(Vdat, Vm, indvol, SmoothKern) % if exist('badcoords','var') && ~isempty(badcoords), % indvol = indvol(~badcoords); % end Vol = Vm; Vol.dim = [Vm.dim(1:3)]; Vol.dt = [64,0]; Vimg = zeros(Vm.dim(1:3)); sVimg = Vimg; Vimg(indvol) ...
3f782a17f05418401fd77f2df253204e8756d07541e73a0c732920f48ebddd3b
MATLAB
440
13
function runConcatStep8(path) %% Pipeline for the proper concatenation of miniscope data across sessions % Developed by Daniel Almeida Filho July/2020 (SilvaLab - UCLA) % If you have any questions, please send an email to % almeidafilhodg@ucla.edu %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
4b3ba106c3ed32b8919fb3fca704d7898c42102ef1377e428ab99ad407e34abf
MATLAB
440
26
function H = nk_FeatGenEntropy(X, dim, skipzeros) if dim==2; X=X'; end [Cl, kFea] = size(X); % # features , # observations H = zeros(kFea,1); for q=1:kFea if skipzeros Xx = X(X(:,q)~=0,q); Cl = length(Xx); else Xx = X(:,q); end Cu = unique(Xx); Cux = length(Cu); ...
133ebcceb3b4fb9c821ebc2c1e6e2e5013b99a052ce520f77b296ae2fd0f334f
MATLAB
441
15
% Trains an ELM model on the provided dataset. % % [inW bias outW] = mexElmTrain( X, Y [, nhn, C ] ); % % INPUT : % X - samples matrix (samples in columns) % Y - labels vector % nhn - number of hidden neurons (default: dims / 2) % C - regularization parameter (default: 1) ...
d0da39ab9bdf5c32edd8546f92aed26c1c055424761b2a031610c4017b3e1415
MATLAB
441
12
function data = mripy_dataset2json(asc, anat, func) %MRIPY_DATASET2JSON Save surface dataset as three.js data in *.json. % 2017-08-18: Created by qcc [verts, faces] = mripy_read_asc(asc); data = mripy_write_geometry([], verts, faces); ds = cosmo_surface_dataset(anat); data.underlay = ds.samples'; ...
e7481545223ed66ccb8f5b4c9e0a05b660fef188ae5695aaf26bcd39f40dd591
MATLAB
441
19
function s = merge_struct( s1 ,s2 ) % merge_struct : Merge two structures % % $Revision: 0.1.0 $ $Date: 2012/6/15 $ % s = s1; names = fieldnames( s2 ); for k = 1:length( names ) if isfield( s, names{k} ) if isstruct( s.(names{k}) ) s.(names{k}) = merge_struct( s.(names{k}), s2.(names{k})...
87768f1c36ece4d9f266f096b883e9de16f6e6435b4531d0dce122503401d90b
MATLAB
442
24
function LabelMatrix = nk_MakeRVMTargetMatrix(LabelVector) uL = unique(LabelVector); if numel(uL) > 1 if min(LabelVector) == -1 LabelVector(LabelVector == -1) = 2; LabelVector(LabelVector == 1) = 1; end uL(~uL) = []; nclass = numel(uL); else nclass = 2; end lx = size(LabelVector,1)...
4bb14fb999761631228a852673d43867962cd051aa995074b9f691bb95135384
MATLAB
446
13
function [P, Pfdr, Z, I] = nk_SignBasedConsistencySignificance(E) % Computed sign-based consistency [0= no consistency, 1=absolute % consistency] I = nk_SignBasedConsistency(E); % Compute Z score Z = I ./ std(I); % Compute P value of Z score (right-tailed one-sided test of Z) P = nm_normcdf(-Z,0,1); % Correct for mult...
958b36b97f8738f086d4118432d46cacaa9eec596d3e90306ada39838cb21eed
MATLAB
447
24
function [L, F, m] = CalculateLRatio( self ) % Calculate LRatio % ADR 2012/12 % construct components % 1. FD for each element of ClusterSeparationFeatures MCS = MClust.GetSettings(); [T, F] = MClust.CalculateFeatures(MCS.ClusterSeparationFeatures); nSpikes = length(T); nFeat = length(F); FD = nan(nSpikes, nFeat); ...
11ce5b78885d5f269ae8050b63640de823ae2ed2c9a98f0cdc404b06e2e87286
MATLAB
448
16
%% Execute this script with fastAUC.cpp in the current directory %Compile mex fastAUC.cpp %Test - needs the statistics toolbox labels = [1,1,1,1,1,-1,1,1,1,-1,1,1,-1,-1,1,1,1,1,1,1]; scores = rand(1,numel(labels)); posclass = 1; AUC = fastAUC(labels,scores,posclass); [~,~,~,AUC2] = perfcurve(labels,scores,posclass...
7fe3fa9453e08c2c11bfdcf6e0c1a8a2829acabe213c2d1e63f695b2c9e3c871
MATLAB
449
15
function [ThreshPerc, ThreshProb, Time] = EvalCoxPH(Models) [ix, jx, nclass] = size(Models); Time = cell(ix,jx,nclass); ThreshPerc = zeros(ix,jx,nclass); ThreshProb = zeros(ix,jx,nclass); for h=1:nclass for k = 1:ix for l= 1:jx ThreshPerc(k,l,h) = Models{k,l,h}{1}.cutoff.val; Thres...
751c1e033b76e7d03e34a3131177b7e74e733341257329d02e57fc246dbd5cb5
MATLAB
451
20
function output = mi(X,Y) %function output = mi(X,Y) %X & Y can be matrices which are converted into a joint variable %before computation % %expects variables to be column-wise % %returns the mutual information between X and Y, I(X;Y) if (size(X,2)>1) mergedFirst = MIToolboxMex(3,X); else mergedFirst = X; end if (...
b997eb297cd9abfed6c46c44d6c4a3321c572850286118186b41db4cb604bbeb
MATLAB
451
21
% % RT (295) % % EEG.icaact = [30x2000x295 single] % ic=7; [Y,I]=sort(RT); baseline=reshape(EEG.icaact(ic,1:500,I),500,224); [PB, freqs, times]=timefreq(baseline, 250, 'wavelet', 0, 'freqs', [3 45], 'winsize', 128, 'padratio',2); PB=10*log10(PB.*conj(PB)); PB=mean(PB,2); PB=reshape(PB, 44, 224); % 44 x 295 PB_aler...
24af29df21906a123296b20f5cf879c8d4daf34d80b1523e5e6683b9b2dbd2b4
MATLAB
453
22
function [TimeData, TimeNames,TimePars] = feature_Time(V, ~, ~) % MClust % [TimeData, TimeNames] = feature_Peak(V, ttChannelValidity) % Calculate time feature % % INPUTS % V = TT tsd % ttChannelValidity = nCh x 1 of booleans % % OUTPUTS % Data - nSpikes % Names - "Time" % % ADR April 2008 % version M1.0 ...
73967378eed98b2bd1cbcf2529542ec0aa022e3226bb0804799f7d6a8a79c788
MATLAB
459
19
function p_map = nk_ComputeSVMPmap( Y, labels, model) p = sum(labels==1)/max(size(labels)); if ~isfield(model,'w') w = model.SVs' * model.sv_coef; else w = model.w'; end X = Y; [r,c] = size(Y); J = ones(r,1); K = X*X'; Z = inv(K)+(inv(K)*J*inv(-J'*inv(K)*J)*J'*inv(K)); C ...
89006a9f60ee8dd565ca7d6060d4b8411c0d3e9e3f58420f2f98df1ef05fa4c6
MATLAB
459
15
function param = NNP(expected, predicted) if isempty(expected), param = []; return; end ind0 = expected ~=0; expected = expected(ind0); predicted = predicted(ind0); TP = sum( predicted > 0 & expected > 0 ); FP = sum( predicted > 0 & expected < 0 ); TN = sum( predicted < 0 & expected < 0 ); FN = sum( predicted < 0 & e...
d8fe01b316744fc303c26c5aa13ee21a007ee98c44d8ae5ec1aa86310acd4ff0
MATLAB
459
15
function [newVectors, meanValue] = remmean(vectors); %REMMEAN - remove the mean from vectors % % [newVectors, meanValue] = remmean(vectors); % % Removes the mean of row vectors. % Returns the new vectors and the mean. % % This function is needed by FASTICA and FASTICAG % @(#)$Id: remmean.m,v 1.2 2003/04/05 14:23:58 ja...
45f4dbd92eb651659199c1a466342610f221161220898f7277381377575dd9be
MATLAB
460
15
function param = PSI(expected, predicted) if isempty(expected), param = []; return; end ind0 = expected ~=0; expected = expected(ind0); predicted = predicted(ind0); TP = sum( predicted > 0 & expected > 0 ); FP = sum( predicted > 0 & expected < 0 ); TN = sum( predicted < 0 & expected < 0 ); FN = sum( predicted < 0 & e...