sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
462a2c2c69de344d1dd658079c18cfad778015fcb44b0f271da00725891e0fe2
MATLAB
460
16
function [LIBSVMTRAIN, LIBSVMPREDICT] = nk_DefineLIBSVMfun(SVM) switch SVM.LIBSVM.LIBSVMver case 2 LIBSVMTRAIN = 'svmtrain289'; LIBSVMPREDICT = 'svmpredict289'; case 0 LIBSVMTRAIN = 'svmtrain312'; LIBSVMPREDICT = 'svmpredict312'; case 1 LIBSVMTRAIN = 'svmtrain291'; ...
ae1994f168eb40c88b197737f0159296a55de75f864d7af11abef799c8cbfe6c
MATLAB
461
16
function acc = eval_MTL_accuracy (Y, X, W, C) %calculate accuracy for classification task_num = length(X); total_sample = 0; acc_list = zeros(task_num, 1); %calculate corrested classified numbers for every dataset for t = 1: task_num acc_list(t) = nnz(sign(X{t} * W(:, t) + C(t)) =...
f5b8ae3f59c0ee2e5c0cefa655ca1deef374fba410f72bf054cc3b7cd59cb85b
MATLAB
461
19
function P = nk_ConvProbabilities(C, ngroups) m = size(C,1); P = nan(m,ngroups); if iscell(C) for i=1:m if isempty(C{i}) || sum(isnan(C{i}))==size(C{i},2), continue, end for j=1:ngroups P(i,j) = sum(C{i}==j)/numel(C{i}); end end else indn = ~(sum(isnan(C),2)==size(C,2));...
0448303f2f621684563c412ac67cb8e64e7f9dcaeb1068e338d91133381e1440
MATLAB
463
11
function x_new = NextSolution1(x_curr, itt, n, featureID_order) % The new voxel is introduced to the solution in the order determined by % futureID_order. moduloItt = mod(itt,n); if moduloItt == 0, moduloItt = n; end x_new = x_curr; % @#$% user-defined % ==================================================== % Appproach ...
386d88c66df435fc05c7a1ddcbb5564b9eef9cf8f3c2f22711332c44df1d082f
MATLAB
463
14
function [ nexFile ] = nexCreateFileData( timestampFrequency ) % [nexFile] = nexCreateFileData(timestampFrequency) -- creates empty nex file data structure % % INPUT: % timestampFrequency - timestamp frequency in Hertz % nexFile.version = 100; nexFile.comment = ''; nexFile.freq = timestampFrequency; n...
d1299de0870253f4d2f2e597f51f4094251660de52d66f26766ba019518f70d8
MATLAB
463
17
function [ sY, IN ] = nk_PerfZeroOut(sY, IN) % Zeros out completely non-finite features global VERBOSE mY = size(sY,1); % Zero-out non-finite data if IN.zerooutflag == 1 if ~isfield(IN,'indnonfin') IN.indnonfin = sum(~isfinite(sY)) == mY; end if sum(IN.indnonfin)>0 if VERBOSE, fprintf(' zero-...
5138d70073bac9cafbed0fd1e1d46d6706139d53a9fb99c8688aeddd04ba2475
MATLAB
466
23
function [vec,I]=greatsort(x); %GREATSORT sorts the vector x in descending order. % % Required input arguments: % x : vector to be sorted % % Output arguments: % vec : sorted vector % I : index => x(I)=vec. % % I/O: [vec,I]=greatsort(x); % % This function is part of LIBRA: the Matlab Library for Robust Ana...
821760d68cf032131168fd901ff05f05839e18f274caf79ed326aa21616fc468
MATLAB
466
25
function Xts = nk_PLSpredict(brainlv_tr,Ytr,Xtr,Yts) mx = max(Xtr); Xd = single(zeros(size(Xtr,1),mx)); dx = Xtr(1); cnt=1;Xd(1)=dx; for i=2:length(Xtr) if Xtr(i) > dx, dx=Xtr(i); cnt=cnt+1; end Xd(i,cnt)=1; end %[mtr,ntr]=size(Ytr); mts=size(Yts,1); % Mean centering mYtr = mean(Ytr); mXtr ...
e99eaa1af66e88cf026790d989df49adff6d3d1967792efcd1108c04d8bcacce
MATLAB
468
5
% Compiles the MIToolbox functions mex -I../include MIToolboxMex.c ../src/MutualInformation.c ../src/Entropy.c ../src/CalculateProbability.c ../src/ArrayOperations.c mex -I../include RenyiMIToolboxMex.c ../src/RenyiMutualInformation.c ../src/RenyiEntropy.c ../src/CalculateProbability.c ../src/ArrayOperations.c mex -I....
af2fbed1c4e0d98124547cf52fa689e5b867f1e9c34b6902d23ec9a3b421a22a
MATLAB
470
20
function CutterOption_EvalOverlap(self) nC = length(self.Clusters); Overlap = zeros(nC,nC); Overlap(2:end,1) = 2:nC; Overlap(1,2:end) = 2:nC; for iC = 2:nC Ci = self.Clusters{iC}; Overlap(iC,iC) = length(Ci.GetSpikes); for jC = (iC+1:nC) Cj = self.Clusters{jC}; Overlap(iC,jC) = length(int...
9ad420022c0af571e550307e591b9a4ff8aa07d3b7db83f7529bf7c20f698597
MATLAB
472
24
function codes=genCode(W) % generate codes for columns of logical matrix W % W: logical, matrix of m x n % code: column vector of n x 1 % Yifeng Li % Mar. 18, 2013 % example: % W=[true,false,false,true,true,true,; % false,false,true,false,true,true]; % codes=genCode(W) [m,n]=size(W); codes=zeros(n,1); for i=1:n ...
3c237d8e94d990f39eb9ed8f261e25aa69a6acd7546e46e836551a97afba7cc5
MATLAB
473
22
function txt = lfpCursor(empt, event_obj) % Customizes text of data tips persistent toggle if isempty(toggle) toggle = cputime; end pos = get(event_obj,'Position'); tag = get(event_obj.Target,'Tag'); txt = {['X: ',num2str(pos(1))],... ['Y: ',num2str(pos(2))],... ['TAG: ' tag]}; if cputime > toggle+0.5 lw = g...
b09f294f323402762f1f52c4698e2f408633eb72981dab4b25d28ac211a3a44c
MATLAB
473
24
function IsoD = CalculateIsolationDistance( self ) % Calculate Isolation Distance % 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...
8fe5a477d3e3a047618acb7db4ad5ad0c3a0b687b26606b53241bebf0df812b5
MATLAB
474
23
function [PREPROC, cmdseqold, cmdseqnew] = nk_NumberCmdStr(PREPROC) nA = numel(PREPROC.ACTPARAM); cmdseqold = cell(nA,1); cmdseqnew = cell(nA,1); for i=1:nA cmdseqold{i} = PREPROC.ACTPARAM{i}.cmd; end uCmd = unique(cmdseqold); nuCmd = numel(uCmd); for i=1:nuCmd idx = find(strcmp(cmdseqold,uCmd{i})); for...
be2703317e5c5e45bb89b9dffbf663231cfd8443c6ffaac9107fe57362efe5da
MATLAB
474
20
function [Params, Desc] = nk_ReturnParam(Desc, Params_desc, opt) Params = []; if iscell(Params_desc) for p=1:numel(Params_desc) switch Params_desc{p} case Desc if iscell(opt(p)) Params = opt{p}; else Params = opt(p); ...
3f67b55e7cce1cb8acf2ee705a66d5fb265bf656be0d50123be6d7f026a64287
MATLAB
476
22
function disp(obj) % Disp a NIFTI-1 object %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: disp.m 7147 2017-08-03 14:07:01Z spm $ sz = size(obj); fprintf('NIFTI object: '); if length(sz)>4 fprintf('%d-D\n',lengt...
7c45784e35bdf39b53f95e95f700a7e3ea474eb9f9e69d2dcb163ace05ce71e0
MATLAB
476
20
function C = AUtoPhysicalUnits(X,B) % INPUT % X: data matrix (DxN; D: dimensionality of input data, N: number of samples) % B: estimated components (DxK; K: number of components) % % Note that this function can also be used to calculate coefficients for out of sample subjects % % OUTPUT % C: new matrix (KxN) - values...
c153c1f4ff5bcad3761dd1139c39e087d044bf0552476c5f1b589942b5b542a0
MATLAB
477
25
function clouds(f) figure xyz = f.xyz; state_color = f.state_colors; cdata = bt_utils.state_cdata; xyzlim = [0 -1 0 ;... 1 1 1.3]; gridres = 0.025; for j = 1:size(cdata,1) pts = state_color == j; if any(pts) [Vcount] = utils.simple_bin3d(xyz(pts,:),xyzlim,gridres); v...
33f9c94e6d788c6c553b60dfe5ff1ac3cca2797a3e94417a6d33cf2fdda62b2b
MATLAB
478
20
function [scaled] = Scale(Data, Lower, Upper) % [scaled] = Scale(Data); % [scaled] = Scale(Data, Lower, Upper); % % scale the elements of all the column vectors in % the range of [Lower Upper]. (default [-1 1]) if (nargin<3) Lower = -1; Upper = 1; elseif (Lower > Upper) disp (['Wrong Lower or Upper values!'])...
e5358af043f6be325d3784fff8755868fdb99ddeb60cd99e17fb05601ddba26c
MATLAB
479
23
function [ V, Ro ] = add_outlier(rho, F, N, Vo) dense = rho * F; Ro = zeros(F,N); for i = 1 : N n_before = 0; for f = 1 : dense c = randi(F); Ro(c,i) = randi([30,50]); n = nnz(Ro(:,i)); if n_before == n ...
951fe2af12311cf3e0abc8a1af6f36a270e0dc93c48430c8dd4fe77fbcd6f33c
MATLAB
480
18
function adjust = itSol(sdat,g_hat,d_hat,g_bar,t2,a,b, conv) g_old = g_hat; d_old = d_hat; change = 1; count = 0; n = size(sdat,2); while change>conv g_new = postmean(g_hat,g_bar,n,d_old,t2); sum2 = sum(((sdat-g_new'*repmat(1,1,size(sdat,2))).^2)'); d_new = postvar(sum2,n,a,b); change = m...
24a46873f89cf1611fb30389df910ee750ade28277060bbdeb4160849ec8b832
MATLAB
482
15
function loaded = loadobj(loaded) % This function is designed to convert older instances % into newer instances return % Error is: "You cannot set the read-only property 'param_symbols' of full." if isempty(loaded.model.param_symbols) disp('Upgrading model parameter symbols and units using sam...
e6a7fed43083ddd933863be0bbe4fc7541df56be04b431d20ddc793bab950934
MATLAB
482
21
function [newL, newR] = rowsum_R_one(L, R, varargin) % normalizes rows in R so that the product LR stays the same % handle_zeros option: leaves rows that sum up to 0 as they were coeffL = sum(R,2); % added by HK coeffL = max(coeffL, 1e-16); if not(isempty(varargin)) && varargin{1}==1 ...
1df39d2214edffab559a5258da64f0459f6240b96ba995c3a238dbee83110693
MATLAB
483
18
function MutualInformation = nk_MutualInfo(Y, labels) % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ % function MutualInformation = nk_MutualInfo(symY, labels) % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ix = size(Y,2); MutualInformation = zeros(ix,1); try parfor i=1:ix sY = Y(:,...
b387a33eda0c7f2be4faa1a7704a541dda025ae07033555b4dc9a71e8c2b25ea
MATLAB
483
11
function x_new = NextSolution3(x_curr, itt, n, featureID_order) % The new voxel is introduced to the solution in the order determined by % futureID_order. moduloItt = mod(itt,n); if moduloItt == 0, moduloItt = n; end x_new = x_curr; % @#$% user-defined % ==================================================== % Toggle the...
f7b41a9c763bcf84b8ba14dbd05ff64961e46f71057fbf35dc4061629d59e405
MATLAB
483
22
function [vscaled,minv,maxv]= scale_matrix(v,minv,maxv) % scale_matrix scales a matrix into [0 1] along the vertical direction, % this is a simplified version % % SYNTAX % % Inputs: v: m*n matrix; % Outputs: % Wenbin, 08-Mar-2007 vr =size(v,1); if vr <2 error('The rows of input matrix must be greater than 1'); end if ...
d707047d8a56c71269219f7e8b44a79b579450904ce40ed6f275295e4e9a422e
MATLAB
484
14
function [blocks,block_color,state_numbers] = state_blocks(self) % For a given state_str % return a matrix of the states and their corresponding colours % which can be used as indexes for plotting state_number = self.state_colors; trans = find(diff(state_number))+1; trans = [1; trans(:); self.latest]; blocks =...
c76a93d77ff23ca5e1b97b8a1a01dab82898e9d4f09fa6a90dc7d931515937a0
MATLAB
485
13
function [expectedC,expectedL] = ER_Expected_L_C(k,n) % ER_EXPECTED_L_C the expected path-length and clustering of an ER random graph % [C,L] = ER_EXPECTED_L_C(K,N) for a network of N nodes and mena degree K, % computes the expected shortest path-length L and expected clustering % coefficient C if that network w...
464a0123e3af181409532d806940d77224719e07a350034a6120b3caf82f5645
MATLAB
488
16
function [ts] = PL2StartStopTs(filename, startOrStop) % PL2StartStopTs(filename, startOrStop): read recording start or recording stop event timestamps from a .pl2 file % % [ts] = PL2StartStopTs(filename, 'start') % [ts] = PL2StartStopTs(filename, 'stop') % % INPUT: % filename - if empty string, will use File Open dia...
0c4d8b75e8a7f40aee90cd4432282de45c01a8bd697da4d18d6da1257f759ac1
MATLAB
490
17
function modeflag = nk_DefineModeflag(modeflag) defmode = 1; if exist('modeflag','var') && ~isempty(modeflag) modes = {'classification','regression'}; defmode = find(strcmp(modes,modeflag)); if isempty(defmode),defmode = 1; end end modeflag = nk_input('Would you like to perform ...',0,'m', ... ...
e8944c7b28c027f4dcf6a0fd887d666300ccfbf85cfcd7120d0e335ccf7e2959
MATLAB
490
19
function t = structn(obj) % Convert a NIFTI-1 object into a form of struct %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: structn.m 7147 2017-08-03 14:07:01Z spm $ if numel(obj)~=1 error('Too many elements to c...
11b0f0897d70a065326897b48af955ac0cdde4ecc38a63e8f0f37eb741829752
MATLAB
491
18
function Q = mripy_normalize_weight(Q, exclude_diag) %MRIPY_NORMALIZE_WEIGHT Normalize positive and negative weights to sum up to ±1 % 2017-08-06: Created by qcc if nargin < 2 exclude_diag = false; end if exclude_diag Q(eye(length(Q))>0.5) = 0; end P = (Q > 0); N = (Q < 0); ...
20188e7f58859cc3f614cc5d32aea43cd008edda0b64773a5b09585b7c0d1ef9
MATLAB
494
18
function o = niftistruc(fmt) % Create a data structure describing NIFTI headers %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: niftistruc.m 7147 2017-08-03 14:07:01Z spm $ if ~nargin, fmt = 'nifti1'; end switch low...
a10a6daf0062b68984790878e273b6614499e429d2a345fdd2d0c27bfa87c24e
MATLAB
494
14
function handles = binarize_regr(handles) m = str2double(get(handles.txtBinarize,'String')); if isempty(m) errordlg('Enter numeric threshold') elseif m < min(handles.labels) || m > max(handles.labels) errordlg(sprintf('Threshold out of target range [%g %g]',min(handles.curRegr.labels),max(handles.curRegr....
3d64ce993929c7d7ca6fb72c171e21f917a3f5e42cfa24bce65b108e6150b467
MATLAB
497
24
nvids = numel(proc.npix); t0 = 20000; clf; np = [0 proc.npix]; np = cumsum(np); mall=[]; nc = 10; for ic = 1:nc for k = 1:nvids i1 = proc.uMotMask{1}(np(k)+[1:proc.npix(k)], ic); ib = NaN*zeros(floor(proc.nY{k}/proc.sc), floor(proc.nX{k}/proc.sc)); ib(proc.wpix{k}) = i1; my_subplo...
5a3ef9eba2d3976a8202f30e43c45a1d3107c45791ac0102ae5cf5f1f6a9c65e
MATLAB
497
19
function gCell = sparseCellArray(Y1, Y2, sp) % in case of test kernel, Y1 should be Ytest if ~isequal(Y1,Y2) test = 1; Y = vertcat(Y1,Y2); else test = 0; Y = Y1; end gCell= {}; for i = 1:size(Y,1) % apply sparsity threshold spArray = apply_sparsity_th...
e2334e628c1eb306d9770ccd53d1be945ee396f80f62ec4bc504970ab5aa6c01
MATLAB
497
14
function DScore = simbamain(Y, labels, cpus, SortInd) global FEATSEL gpu = FEATSEL.simba.gpu; extra_param = FEATSEL.simba.extra_param; if nargin < 5, if ~isempty(SortInd), Y = resamp(Y, SortInd, cpus); end; end if FEATSEL.salthreshmode == 1, extra_param.salCI = FEATSEL.salCI; end if isfield(extra_param,'beta') && st...
6ae7bb30c4418945d414d048c9f22e8069db2ee21ccd2105c30948ce97e43d4c
MATLAB
498
24
function OK = WriteWVfiles(self) % OK = WriteWVfiles(MCD) MCD = self; nClust = length(MCD.Clusters); WV = MCD.LoadNeuralWaveforms(); WVT = WV.range(); WVD = WV.data(); for iC = 1:nClust tSpikes = MCD.Clusters{iC}.GetSpikes; if ~isempty(tSpikes) fnWV = [MCD.TfileBaseName(iC) '-wv.mat']; [mW...
8d31634b38c22fe6e10ac2b693d99697902b6330802f28bdf58166574ed1799d
MATLAB
498
22
function map = coolhot1(siz) % Create a colormap that is a combination of % 'cool' and 'hot'. % % Usage: % coolhot(SIZ) % % - SIZ = Size of the colorbar. To ensure symmetry, % an even number is recommended. % % _____________________________________ % Anderson M. Winkler % Yale University / Institute of Living ...
8e2413fc146b836751d062e255c89e6bb6337e4d1623044435f87400c1d713f4
MATLAB
501
19
function nk_ThreshImages P = spm_select(Inf,'image','Select images'); V = spm_vol(P); threshval = spm_input('Specify percentile threshold for images ',0,'e'); for i=1:numel(V) [p,n,e] = fileparts(V(i).fname); Vx = spm_read_vols(V(i)); ind = Vx(:) > 0; Thresh = prctile(Vx(ind), threshval); VxP = ...
defadcdface416c0cb90ee2758daaa163b6d5848275eff4b2bfb9a42aec0d7e3
MATLAB
502
16
function output = joint(X,arities) %function output = joint(X,arities) %returns the joint random variable of the matrix X %assuming the variables are in columns % %if passed a vector of the arities then it produces a correct %joint variable, otherwise it may not include all states % %if the joint variable is only compa...
ed75a65a1eb8f560b246edde3e5533165ed29d1d3a8b5816909408af80f4a150
MATLAB
504
25
function tsout = merge(varargin) % tsout = merge(tsA, tsB, ...) % % merges the sequences of tsds % checks to make sure sizes match nTSD = length(varargin); assert(nTSD>=2, 'Cannot concatenate < 2 tsds.'); assert(isa(varargin{1},'tsd'), 'Initial tsd not a tsd.'); T = varargin{1}.range; D = varargin{1}.data; for iTS...
e59115a783d77983078ee61b9769e88d15d2e35854ef41a3ef0cbba493866f7b
MATLAB
507
1
function CutterOption_00_CheckAllClusters(self) % CheckClusters(self) % % % INPUTS % % OUTPUTS % % NONE % NCST 2002 % % Status: PROMOTED (Release version) % See documentation for copyright (owned by original authors) and warranties (none!). % This code released as part of MClust 3.0. % Version control M3.0. % Extensi...
4d601b00b0a037e78133cfccf63d8548e4d9c8493d27de02b24710b49b0b153a
MATLAB
509
23
function out = unmask(mask, data, fillVal) %% UNMASK Adds empty rows to data (which may have been removed previously) %% Examples % unmask([1 0 1 0 1 0], (1:3)') % unmask([1 0 1 0 1 0 1 0]', magic(4), 0) % % %% TODO % * docs % % %% Authors % Mehul Gajwani, Monash University, 2024 % % assert((numel(mask)==len...
c36bfbcd91329ed0ccfb17a8ca4f7847ed6faf57a8a5fb50fceaf77d204f9a50
MATLAB
509
21
function A = nk_Ambiguity(P,~) % % Compute the entropy-based ambiguity according to the formula given in % Padraig Cunningham TCD-CS-2000-07 m = size(P,1); Mx = 0; for i=1:m % Loop through samples x_i Kx = 0; pos = P(i,:)~=0; minx = min(P(i,pos)); maxx = max(P(i,pos)); for j=minx:maxx ...
afb98024b23e344eb3fe13f11d1848ff2e2c388d70dabac4c9931dbe11051d65
MATLAB
510
17
function [verts, faces] = mripy_average_asc(fnames, output) %MRIPY_AVERAGE_ASC Average the volumetric geometry of surface meshes. % 2017-08-17: Created by qcc N = length(fnames); [verts, faces] = mripy_read_asc(fnames{1}); for k = 2:N [v, f] = mripy_read_asc(fnames{k}); assert(all(size(v)=...
ab3650c7d33679ff817319d2256d3d2bd25862b55690dbb2bc83dba71fed9020
MATLAB
513
24
function ClusterFunc_AddSpikesByPolygon(self) % PreCut Clusters - ClusterFunction_AddSpikesByPolygon % % Adds ability to add individual spikes MCC = self.getAssociatedCutter(); MCC.StoreUndo('Add Spikes by Polygon'); [xg,yg] = DrawPolygonOnAxes(MCC, false); plot(xg,yg,'-', 'color', self.color); drawnow; % get axes...
37eb95786a71ae73aa9e281e28e8212b7c6b4e2e87a2a751376993948f7035ba
MATLAB
514
15
classdef reduced_alpha_emphasized < bt.model.reduced % This model is the same as reduced, but with increased alpha weighting methods function self = reduced_alpha_emphasized() % Constructor self = self@bt.model.reduced self.name = 'reduced_alpha_emphasized'; end function w = get_weights(self,target_f) %...
cc5e4911c4710fbe7ab694dfcc8522654877f44de29010eae2b5e23892de1657
MATLAB
514
28
function [w, b] = nk_GetPrimalW(model) global SVM MODEFL switch SVM.prog case 'LIBSVM' w = model.SVs' * model.sv_coef; b = -model.rho; if strcmp(MODEFL,'classification') if model.Label(1) == -1 w = -w; b = -b; end en...
0f941179abe873c42686be25af1b3c7ddb9b06c91c91ddcd3d15d3efa8dfeffe
MATLAB
516
21
function A = nk_Diversity(E, L, m, n) % function A = nk_Diversity(P, vec, m, n) % Compute entropy-based measure of ensemble diversity ind0 = L ~= 0; E = E(ind0,:); L = L(ind0); if ~exist('m','var'), m = size(E,1); end if ~exist('n','var'), n = size(E,2); end E = sign(E); rL = repmat (L, m, n); cE = E == rL; ...
ee57bb02c8ee46161ad5798920914c90e6f2f72201f8dd3f1018d59f239c4d3c
MATLAB
516
19
% SB1_DIAGNOSTIC Output neat diagnostic info with verbosity control % % % 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 SB1_Diagnostic(level, message_, varargin) Diagnostic = ge...
6e39d79cdf32a4e6b8a25615fd374758219df29cf30f29f3722a5cfebea700c3
MATLAB
518
18
function [out,f] = Mysvmdecision(Xnew,svm_struct) %SVMDECISION evaluates the SVM decision function % Copyright 2004-2006 The MathWorks, Inc. % $Revision: 1.1.12.4 $ $Date: 2006/06/16 20:07:18 $ sv = svm_struct.SupportVectors; alphaHat = svm_struct.Alpha; bias = svm_struct.Bias; kfun = svm_struct.KernelFunction; ...
d55fae66eff2d6f25f7fe9355e1f5a6f6d541b08789e600ab25c77c116a9c129
MATLAB
519
26
function ClusterFunc_AddSpikesByCvxHull(self) % PreCut Clusters - ClusterFunction_AddSpikesByConvexHull % % Adds ability to add individual spikes MCC = self.getAssociatedCutter(); MCC.StoreUndo('Add Spikes by Cvx Hull'); [xg,yg] = DrawPolygonOnAxes(MCC, true); plot(xg,yg,'-', 'color', self.color); drawnow; % ge...
4264782b0c4ae551303f34c8151bccaaaffe69af7d425eb2729bf0574b01e4d9
MATLAB
521
29
function rr = smoothPupil(parea) win = 30; rr = parea(:); RR = zeros(win, numel(rr)); for k =-win/2:win/2 if k<0 RR(k+win/2+1, 1:end+k) = rr(-k+1:end); else RR(k+win/2+1, k+1:end) = rr(1:end-k); end end mrr = nanmedian(RR,1)'; ix = find(isnan(mrr) | isnan(rr)); ix2 = find(~(isnan(mrr) | ...
c553ff49e1e34ef33a59e5d23bc6b3270b57b38e4d673c4761465c1ece86e26e
MATLAB
522
16
clear load('ProcessedData\tables_compiled_bestD1.mat'); %% generate heatmaps for trials by D1 responsive order % for now, i'm editing colormaps in the GUI as I haven't figured out % how to to do that right in code as of yet figure, tiledlayout(1,5) for i = 1:length(tables_compiled) D_now = tables_compiled{...
70bec558fba0d175227dac840bb833567fc167e17e6256486689d85712c6d536
MATLAB
525
20
function [C_tri]=transitivity_bu(A) %TRANSITIVITY_BU Transitivity % % T = transitivity_bu(A); % % Transitivity is the ratio of 'triangles to triplets' in the network. % (A classical version of the clustering coefficient). % % Input: A binary undirected connection matrix % % Output: T t...
5d245cbb21e1dd2011b5eaf3ed3f0da3c30429650d750fb5fc07d1a56f197424
MATLAB
526
20
function cost=IMRelief_cost(alpha, Z, Weight, descent, Targets, lambda) %Function ComputeAlpha: compute alpha using linear search Weight = Weight-alpha*descent; a = ((Weight(:).^2)')*Z; %margin Result = 1./(1+exp(-a)); %probability of being class 1 index = Result==1; Result(index) = 1-10^(-10); index = Result==0; Re...
d0df914bab608584ea88d0e1892bc3025a41a975c4b1a118af8ef08639aefc8c
MATLAB
527
22
%% Master_script_AST clearvars; close all;clc; %% load data load('dn.mat') % calcium signal load('behEvtTbls.mat') %% extract peri-event signal array sigArray = periEventSigArray(dn,behEvtTbls); %% calculate convergence and visualization sessionName = {'Rev','EDS'}; distMethod = 'correlation'; %distM...
e07c25cd9ed211b7e47f55f56b1d98423700bc5e0c1d90c7b165f43d8a26fe1a
MATLAB
527
10
function I = nk_SignBasedConsistency(E) % Compute modified version of sign-based consistency criterion using a binary % classifier ensemble. See paper by Vanessa Gomez-Verdejo et al., % Neuroinformatics, 2019, 17:593-609. We additionally downweight the % consistency vector I by the number of nonfinite values in the ens...
6a051ac08362e94cf41063d1b6d2b356f19c19951eaa36c6c541a2fcc320e900
MATLAB
528
25
function N = nk_FormatNicely(S) [m,n] = size(S); I = strfind(cellstr(S),'['); ind0 = ~cellfun(@isempty,I); if ~isempty(I) try maxI = max(cell2mat(I(ind0))); catch maxI = max(cellfun(@(v) v(1), I(ind0))); end else maxI=[]; end if isempty(maxI), N = S; return; end N = cell(m,1); for i=...
cbd0283d35d742dd60fca2c73b142558c6d096ccf985e5129c2489f604c9dc5b
MATLAB
528
13
function altlabels = nk_DataLabel_config(n_subjects_all, altlabelnames) % this function asks the user to define alternative labels for the % validation data as used in the locked analyses unique_altlabels = unique(altlabelnames); c = cell(length(unique_altlabels),1); altlabels = cell2struct(c, unique_altlabels); for...
fbf58fa928a61c03bfcad33e7a73249a564fe14558664d766d5cb5606f9305d9
MATLAB
530
14
% ========================================================================= % FORMAT param = MAERR(expected, predicted) % ========================================================================= % Compute Mean Absolute Error of regression % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (c...
2898024ea1ae87abdae39e3fcd906d8a4cb6417730438d043244338ae2d423a7
MATLAB
532
25
function ClusterFunc_RemoveSpikesByCvxHull(self) % PreCut Clusters - ClusterFunc_RemoveSpikesByCvxHull % % Adds ability to add individual spikes MCC = self.getAssociatedCutter(); [xg,yg] = DrawPolygonOnAxes(MCC, true); plot(xg,yg,'-', 'color', self.color); drawnow; MCC.StoreUndo('Add Spikes'); % get axes xFeat = ...
4182ae69e231e70e08dff63adb4fdd50733130d5b42fca89b04cddd6d3bc696a
MATLAB
532
25
function ClusterFunc_RemoveSpikesByPolygon(self) % PreCut Clusters - ClusterFunc_RemoveSpikesByPolygon % % Adds ability to add individual spikes MCC = self.getAssociatedCutter(); [xg,yg] = DrawPolygonOnAxes(MCC, false); plot(xg,yg,'-', 'color', self.color); drawnow; MCC.StoreUndo('Add Spikes'); % get axes xFeat = ...
5f740550ca028cee44b8105c65672339283bdddbd879376c379cbd7385f6a526
MATLAB
532
14
% ========================================================================= % FORMAT param = NMRSD(expected, predicted) % ========================================================================= % Compute Normalized Root of Mean Squared Deviation (NRMSD) of regression % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
addd5750becb9700556e155adc271d17cc6b9effae9504149f6d10b2fca40d01
MATLAB
532
25
function Vm = nk_Write2Atlas(Y, fname, Vm) if ~exist('Vm','var') || ~exist(Vm, 'file') Vm = spm_select(1,'image','Select atlas image'); end Vmvol = spm_vol(Vm); A = spm_read_vols(Vmvol); Al = unique(A(:)); if Al(1) == 0, Al(1)=[]; end if numel(Al) ~= numel(Y) error('Vector Y does not have the same dimensional...
7c37c754a93aeddd459879ca87966fac216c418d2ec6cc4a63df618a4b19241c
MATLAB
534
20
function view(tree) % XMLTREE/VIEW View Method (deprecated) % FORMAT view(tree) % % tree - XMLTree object %__________________________________________________________________________ % % Display an XML tree in a graphical interface. % % This function is DEPRECATED: use EDITOR instead. %_______________________________...
6d429bcc433d5ab2f541547b21828246a8789539ffd108a5df215971f6731183
MATLAB
537
28
function ClusterFunc_AddLimit(self) % Convex Hull clsuter add limit MCC = self.getAssociatedCutter(); [xg,yg] = DrawPolygonOnAxes(MCC, true); plot(xg,yg,'-', 'color', self.color); drawnow; MCC.StoreUndo('Add Limit'); % get axes xFeat = MCC.get_xFeature(); yFeat = MCC.get_yFeature(); iL = self.findLimit(xFeat, yF...
a240fd24fdcecd6f7705da4c38cb94344d26360458785eb228317c42bfb85354
MATLAB
537
1
function CutterOption_CloseAllNonEssentialFigs(self) % CloseAllNonEssentialFigs(self) % % % INPUTS % % OUTPUTS % % NONE % NCST 2002 % % Status: PROMOTED (Release version) % See documentation for copyright (owned by original authors) and warranties (none!). % This code released as part of MClust 3.0. % Version control...
0e00324d972fbe400ae7db6bac76689fdea371ca8de0e4721d66efb41db2c194
MATLAB
538
25
function P=innerProduct(A,B,option) % compute the inner product of two matrices which containing missing values % A: matrix % B: matrix % P, matrix, the inner product of A and B. That is A'*B; % Yifeng Li [ra,ca]=size(A); [rb,cb]=size(B); if ra~=rb P=[]; error('A and B should have the same number of rows'); e...
3e89a6d4b2773a23277a06b3d1a8bb8a4d6f9029a8c4753e0f08e0da57b5d435
MATLAB
538
30
function n = normc(m) %NORMC Normalize columns of a matrix. % % Syntax % % normc(M) % % Description % % NORMC(M) normalizes the columns of M to a length of 1. % % Examples % % m = [1 2; 3 4] % n = normc(m) % % See also NORMR % Mark Beale, 1-31-92 % Copyright 1992-2007 The MathWorks, Inc. % $Revisio...
6509837b7269f5b53ebc14f90f89f5a264b45d2de6e48a8e6f1130f0765bd533
MATLAB
538
23
function G = generateDAG(T) [mT,nT]=size(T); G = zeros(mT,mT-1); G(1,1)=1; i=2; oT=T; while i<mT cnt = 1; d = G(:,i-1); dvec = find(d); for j=1:numel(dvec) jT = oT(:,d(dvec(j))); tT = oT(:,d(dvec(j))+1:nT); Ip = find( tT( jT == 1, :) == 1 ); In = find( tT (jT == -1, ...
0c56cbc1f5c5b5867e4b13b160504c47d1ade0a8df8b2ce79fc4fff8a77d0408
MATLAB
539
25
function ClusterFunc_LimitSpikesByPolygon(self) % PreCut Clusters - ClusterFunction_LimitSpikesByConvexHull % % Adds ability to limit spikes MCC = self.getAssociatedCutter(); MCC.StoreUndo('Limit Spikes by Polygon'); [xg,yg] = DrawPolygonOnAxes(MCC, false); plot(xg,yg,'-', 'color', self.color); drawnow; % get axe...
64fe5a0f709a3891b54556bddcbf1857b81f3ec00f5d9a4773228a846f4e19c0
MATLAB
539
15
% UIWAIT makes nk_PrintResults2 wait for user response (see UIRESUME) % uiwait(handles.figure1); function load_popupmenu1(handles) switch handles.modeflag case 'classification' for i = 1:handles.nclass popuplist{i} = sprintf('Classifier %g: %s', i, handles.BinClass{i}.description); end ...
bf128a1ff81f2832fa3402caec6e631f0fa9b94f5a7da2367a89ad3190676552
MATLAB
539
31
function mED = nk_LobagMulti(E, T, L, C, uC, luC, G) [dum, hE] = nk_MultiEnsPerf(E, T, L, C, G); if nargin < 6 uC = unique(C); luC = length(uC); end % Biased results bias = hE ~= L; % Biased variance vb = 0; % Unbiased variance vu = 0; for i=1:luC vu = vu + var(E(~bias,C==uC(i)),1,2); vb = vb + v...
37418e5e430724452886d5616cb38312b0004a35a9dea51f784bd129a7ca404d
MATLAB
540
22
% Extract_varargin % % NOT A FUNCTION -- this allows it to access the current workspace % % expects varargin to consist of sequences of 'variable', value % sets variable to value for each pair. % changes the current workspace! % % ADR 1998 % version L4.0 % status: PROMOTED % % warning('MATLAB:depreciated', 'e...
47288a9a14bef0193682ca2a92445544d77b6c990e1e65d2b77e8732cb9cbd85
MATLAB
541
13
% ========================================================================= % FORMAT param = RMSD(expected, predicted) % ========================================================================= % Compute Root of Mean Squared Deviation (RMSD) of regression % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
24d4faeffdce154d8b7073f232bbc9ac1fd6d6a6b9bc3de02b872304efb47d28
MATLAB
542
25
function ClusterFunc_LimitSpikesByCvxHull(self) % PreCut Clusters - ClusterFunction_LimitSpikesByConvexHull % % Adds ability to limit spikes MCC = self.getAssociatedCutter(); MCC.StoreUndo('Limit Spikes by Convex hull'); [xg,yg] = DrawPolygonOnAxes(MCC, true); plot(xg,yg,'-', 'color', self.color); drawnow; % get ...
a2bb35adc5ae37b023a50b2d7a98387bd8fe48dc05b551aaadcae5519766c306
MATLAB
542
17
function num_closed_loops = count_closed_loops(A) % Get the size of the adjacency matrix (number of nodes) [n, m] = size(A); % Initialize the closed loop counter num_closed_loops = 0; % Loop through the upper triangular part of the matrix to avoid double counting for i = 1:n fo...
fdb016e6925e89f5504cd0bae6ff085b5a1d8ac5595a02fe1d54ff012e68471f
MATLAB
543
22
function hX = h(rX, epsilon) lenVec=size(rX,1); numVec=size(rX,2); % Compute the conjunction of all binary % rank distance matrices. Cx=0; for n=1:lenVec xBinVec = abs(rX(1:lenVec-n,1)-rX(1+n:lenVec,1))<epsilon; for i = 2:numVec xBinVec = xBinVec & (abs(rX(1:lenVec-n,i)-rX(1+n:lenVec,i))<epsilon); ...
039ec422dc96cc8220691f76950017cde170d345ab165cb3db3c4753b10cc8c6
MATLAB
544
26
function t = fieldnames(obj) % Fieldnames of a NIFTI-1 object %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: fieldnames.m 7147 2017-08-03 14:07:01Z spm $ if isfield(obj.hdr,'magic') t = {... 'dat' ...
fb7c00d467181bf889e633458854fdd7626cbb4ffe44cc1da96ad44cbe409a18
MATLAB
544
18
function [ res ] = MCE( labels, predictions ) ordered = sortrows([predictions,labels]); N = size(ordered,1); rest = mod(N,10); for i = 1 : 10 if (i <= rest) group = ordered((i-1) * ceil(N / 10) + 1 : i * ceil(N / 10),:); else group = ordered(rest + (i-1) * fix(...
156bc48a99fbcd6b2062ed70c4a30a25e503bf0e41b29b215c8af6daeb774db5
MATLAB
545
24
function D = nk_AUCFeatRank(Y,L, AUCparam) global VERBOSE [~,nY] = size(Y); D = zeros(nY,1); if length(unique(L))==2 uL = unique(L); Ltemp = L; Ltemp(L == min(uL)) = -1; Ltemp(L ~= min(uL)) = 1; else Ltemp = L; end for i=1:nY D(i) = AUC(Ltemp,Y(:,i)); end if exist('AUCparam','var') in...
a94e3faec324d80fee6e37a3302a726768d2f94f6dd3b049cc77e97ac0720f35
MATLAB
547
26
function output = condh(X,Y) %function output = condh(X,Y) %X & Y can be matrices which are converted into a joint variable %before computation % %expects variables to be column-wise % %returns the conditional entropy of X given Y, H(X|Y) if nargin == 2 if (size(X,2)>1) mergedFirst = MIToolboxMex(3,X); else ...
d1c517e1c7ba11bac489c3c0142328e6d62ff7fa1b46fe3cba4812f93d1e12e4
MATLAB
550
19
function data = mripy_write_geometry(fname, verts, faces) %MRIPY_WRITE_GEOMETRY Write FS/SUMA surface (vertices and faces) as % three.js BufferGeometry. % % References % ---------- % https://threejs.org/docs/#api/core/BufferGeometry % % 2017-08-17: Created by qcc data.position = reshape(verts(:,1:3)', []...
d6987bfc4b871ba461df14abed6d3228b445ce7a20c8d9f0c886616c9209b5ec
MATLAB
550
14
% ========================================================================= % FORMAT param = MSE(expected, predicted) % ========================================================================= % Compute Mean Standand Error of regression % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (c) ...
2c5094d685844c0a237d987b8316b3d07a4e39dcfb1cf49bb0b802d1c83a68f9
MATLAB
551
22
function indperm = nk_VisXPermHelper(act, N, nperms, L) s = RandStream.create('mt19937ar','seed',sum(100*clock)); RandStream.setGlobalStream(s); switch act case 'genpermlabel' indperm = zeros(N, nperms); for perms = 1:nperms indperm(:,perms) = randperm(N); end case 'genper...
cd50b67357284b2abb2ee41f279d6b058b9e55166cde9b8a5396c30ac05eee84
MATLAB
551
22
function spectrum(self) % Plot the spectrum if self.latest == 0 return elseif self.latest > 1 fit = self.subrange(self.latest); fprintf(2,'Multiple fits provided - displaying the last one\n') else fit = self; end figure set(gca,'XScale','log','YScale','log') hold(gca,'on'); box(gca,'on'); set(gca,'X...
e88de83940292ecbaee4d4e2f435ba9e8bda8696bbdf9d096fe3d394ef83fc02
MATLAB
552
23
function NeuroMinerMCCMain(action, paramfile) nm_pth = which('nm'); pth = fileparts(nm_pth); hpc_pth = [pth filesep 'hpc']; addpath(hpc_pth); switch action case 'preproc' nk_Preprocess_batch(paramfile) case 'train' nk_MLOptimizer_batch(paramfile) case 'visualize' nk_VisModels_batch...
35935780bb6b651c693ec213b996b123825ae44140fcfc920314429d94737eb6
MATLAB
554
21
function resample_image(V, voxsiz) if ~exist('V','var') || isempty(V) V = spm_select([1 Inf],'image'); end if ~exist('voxsiz','var') || isempty(voxsiz) voxsiz = [3 3 3]; % new voxel size {mm} end V = spm_vol(V); VV = [V(1) V(1)]; for i=1:numel(V) bb = spm_get_bbox(V(i)); VV(1:2) = V(i); VV...
ac3b617c412eda3ce7ca0c3418503d82721f98cdf9babecdb5bdb8d9cb925fa3
MATLAB
555
17
clear load('ProcessedData\tables_compiled_bestD1.mat'); %% generate heatmaps for trials by D1 responsive order % for now, i'm editing colormaps in GUI as I haven't figured out % how to to do that right in code as of yet figure, tiledlayout(1,5) D1 = tables_compiled{1,1}.Deltas(1:8,:).'; [~,idx] = sort(mean(D1,...
a6a930840f4db47a5e785f867ed627804720cd232ef872eb0ca303668ef1bbb1
MATLAB
556
21
% Objective function for NDM % % param(1) = beta % param(2) = x0_value function [f] = objfun_NDM(param,seed_location,pathology,time_stamps,C) %y = param(1)*param(2) - pathology(2,1) + C(1,1) + seed_location(1); % Define Laplacian matrix L rowdegree = (sum(C, 2)).'; L = diag(rowdegree) - C; % Calculate pred...
647ffeb6c61727633e9cc2d16fe1d232a7a63b714934f0596510303c432d574c
MATLAB
557
31
function chain_diagnostics_parallel(model,out,chisq_out,accept) keyboard n = size(out{1},1); m = length(out); for k = 1:size(out{j},2) % For each variable for j = 1:m subplot(size(out{1},2),1,k); h = autocorr(out{j}(:,k),1000); plot(h) hold all end end theta = NaN; for k = 1:size(out{j},2) ...
793d7cadb5a43287c3b905e6fcb68d100ee51c259c194f256f7b926c8add388e
MATLAB
557
23
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 (~isa(X,'double') || ~isa(Y,'double')) error('Error, inputs must be double vect...
a8a2bec1b966d8cfb00b5d27e662632950ca397f9ce9095f31fa6b84606ca4b6
MATLAB
557
20
function a = reshape(b,varargin) % Overloaded reshape function for file_array objects %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: reshape.m 7147 2017-08-03 14:07:01Z spm $ if length(struct(b))~=1, error('Can onl...
ba45644763d595438e8d03556770b9f87f2e5dae43e6cc8a5085e4509afc52d7
MATLAB
557
21
function [DScore, idxF] = gflipmain(Y, labels, cpus, FeatInd, SortInd) global FEATSEL ix = size(Y,2); if nargin < 6, if ~isempty(SortInd), Y = resamp(Y, SortInd, cpus); end; end if nargin < 4 || isempty(FeatInd), FeatInd = true(ix,1); end gpu = FEATSEL.gflip.gpu; extra_param = FEATSEL.gflip.extra_param; idxF = f...
8d61481d965eb7c0312e2c357d7a76c0e26607cd122c7f8d10268be707da818a
MATLAB
558
23
function graph = array_to_graph2(a) % binarize adjacency matrix a(a>0) = 1; am = reshape(a,[sqrt(length(a)),sqrt(length(a))]); graph.edges = adj2edge(am); %graph.edges = cellfun(@(x) find(x),num2cell(am,2),'un',0); nodes = 1:sqrt(length(a)); graph.nodelabels = nodes'; end function el=adj2edge(adj) n=length(adj)...
09d0958ae3b7479b4525c556bb0be45fae69ebc8e48c8e4bca88b9f64e044287
MATLAB
560
11
function [pth, fil] = nk_GenerateNMFilePath(RootDir, AnalDesc, DatType, OptDesc, StrOut, DatID, CV2Perm , CV2Fold, CV1Perm, CV1Fold, ext) if ~exist('ext','var') || isempty(ext) ext = '.mat'; end CV2Desc = sprintf('_oCV%g.%g', CV2Perm, CV2Fold); if exist('CV1Perm','var') && exist('CV1Fold','var') && ~isempty(CV1Perm...
82b6134bfffe7b9beb9eb82ec31da7cf8fe4f256a2d6480b23f6b7aa9038825c
MATLAB
560
23
function [V, Ro] = add_outlier_new(rho, F, N, Vo, outlier_min, outlier_max, val_min, val_max) dense = rho * F; Ro = zeros(F, N); for i = 1 : N n_before = 0; for f = 1 : dense c = randi(F); Ro(c,i) = randi([outlier_min, outlier_max])/10; ...
ffaf1622d01c3f57ba51aa69cc8320f020ba74f752129845620d83c1437018f6
MATLAB
564
18
function S = cv_apply_sparsity_thres(A, thres) % if mod(sqrt(size(A,2),1)) == 0 % the full connectivity matrix is entered % nEdges = (size(A,2)*thres)-size(A,2); % number of edges minus diagonal % else % only upper triangle (without diagonal was entered) nEdges = size(A,2)*thres; % number of edges % end nEdges = ce...