sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
1dd358abd9cb27e48a5c0ef4b3df4263db725dd7bf7c125b782600abb93094d5
MATLAB
235
14
function SVM = GetSVMStruct(FEATSEL, nclass, curclass) if iscell(FEATSEL.SVM) if numel(FEATSEL.SVM)<nclass SVM = FEATSEL.SVM{end}; else SVM = FEATSEL.SVM{curclass}; end else SVM = FEATSEL.SVM; end end
b7cc611799e8d2f8ad1e6802276439af695b7428da9f7ad010a0d7795d07e771
MATLAB
235
14
function rACTPARAM = nk_ReturnActionParam(ACTPARAM, actstr) lact = numel(ACTPARAM); rACTPARAM = []; for ac=1:lact act = ACTPARAM{ac}.cmd; if strcmp(act,actstr) rACTPARAM = ACTPARAM{ac}; break end end end
d80f007b01affe9e1105bf84bb0d17a850587debc8de319c687d986240590e8e
MATLAB
236
12
function [n] = plx_close(filename) % plx_close(filename): close the .plx file % % [n] = plx_close(filename) % % INPUT: % filename - if empty string, will close any open files % % OUTPUT: % n - always 0 [n] = mexPlex(22, filename);
adf0ed8d24274a97dae525ef22945b53659b60809e30404db73219e2606b4874
MATLAB
238
11
function psnr = calc_psnr(Vo, W, H) % PSNR = 10 log10 (MAX^2/MSE) % % MAX_VAL: Maximum value of pixels max_val = max(max(Vo)); mse = calc_mse(Vo, W, H); psnr = 10 * log10 (max_val.^2/mse); end
81083d6bd5528cd5ad0cce79a1bdbf825a533ffc131360ab51d5caa5e89b1b58
MATLAB
239
6
% language_imana('BIDS:move_unzip_raw_func') % language_imana('BIDS:move_unzip_sbref') % language_imana('FUNC:align_avrg_sbref') % language_imana('FUNC:make_fmap') language_imana('FUNC:realign_unwarp') language_imana('FUNC:make_samealign')
728da2a954a8e9efd099d7f3836f38257e3edc59f7687457b7b721840d51a11e
MATLAB
241
6
function [rs, ds] = nk_GetTestPerfSVM(tXtest, Ytest, md, SVM, LIBSVMPREDICT) [err_test, dum, predict_test] = feval( LIBSVMPREDICT, Ytest, tXtest, md, sprintf(' -b %g',SVM.LIBSVM.Optimization.b)); rs = err_test; ds = predict_test(:,1); end
6b72ea57bdf65766c1426c74b122bb981e5bc3b8ce30705a050667b880232eaf
MATLAB
243
15
function ClusterFunc_DeleteAllLimits(self) % Convex Hull clsuter add limit MCC = self.getAssociatedCutter(); MCC.StoreUndo('Delete all limits'); self.featuresX = {}; self.featuresY = {}; self.xg = {}; self.yg = {}; MCC.RedrawAxes(); end
b15aca55893fcd0d4e1d9e6752febe96601e25402eedecaa67cc118758cff765
MATLAB
243
10
function disallow = CheckReadyStatus(mess) disallow = false; if isempty(mess) || ~isstruct(mess), return; end nM = numel(mess); for i=1:nM if isempty(mess(i).flag), continue; end if mess(i).flag == 1; disallow = true; break; end end
bd8485c4d8f0da038ef61b0b3c559c1a7065def92bb8ca24d37efbd254528d19
MATLAB
243
10
function [confmatrix, err] = nk_GenConfMatrix(labels, pred) ml = max(labels); lx = length(labels); confmatrix = zeros(ml,ml); err = labels ~= pred; for i=1:lx confmatrix(labels(i),pred(i)) = confmatrix(labels(i),pred(i)) + 1; end return
832a38d72804f78f27d4464df280057b36aa7d907a63f43b73904405036b0ed4
MATLAB
245
12
% performing paired t-test for load 'N250_left.mat' %column numbers of t-test comparison y = erpval(:,[1 2]); X1 = y(:,1); X2 = y(:,2); [h,p,ci,stats] = ttest(X1,X2,'Tail', 'right'); pval = p d = computeCohen_d(X1,X2,'paired')
8c09db97639526dca176874c405aa1c79b32b3c2f3ed35de6ffe549c622789b0
MATLAB
246
9
% y = MAT2VEC(X) Given an m x n matrix X, this produces the vector y of length % m*n that contains the columns of the matrix X, stacked below each other. % % See also vec2mat. function y = mat2vec(X) [m n] = size(X); y = reshape(X,m*n,1); end
beb8b57ff2e9b5899180158f3b6dc5b1e479d4471ebf7f5b3669d7d84d3796ed
MATLAB
246
8
function cmap = twocolor(startcolor,endcolor,nbins) rvals = linspace(startcolor(1),endcolor(1),nbins).'; gvals = linspace(startcolor(2),endcolor(2),nbins).'; bvals = linspace(startcolor(3),endcolor(3),nbins).'; cmap = [rvals, gvals, bvals]; end
f2be6f1c9800c1992f2375d385ae6ac943171592cab91a8ca81a4a49f97196f5
MATLAB
246
10
function StoreWindowPlace(self, W) % If the name of window W is in the windows map container, then read the % location and place it there. If it is not, then don't. name = get(W, 'name'); self.windowLocations(name) = get(W, 'position'); end
25cd73c3bb4c55ad9fd82756e68d7ea53bedb0d4cb6e7f5a839480b6f95306db
MATLAB
247
10
function D = getModelNumDim(h, iy, jy, nP, Pspos, GDFEAT) D=0; for m = 1 : nP % Parameter combinations for k=1:iy % permutations for l=1:jy % folds D = D + size(GDFEAT{Pspos(m)}{k,l,h},2); end end end
8b155a56fa57511331abd3f6179e2bda670ba81a6c21462ad09af0ca38ae48e0
MATLAB
247
11
function diffNm = maxNorm_ind(V, V0, U, U0) n = length(V0); diffV = zeros(n, 1); diffU = zeros(n, 1); for i = 1: n diffV(i) = norm(V{i} - V0{i}, 'fro'); diffU(i) = norm(U{i} - U0{i}, 'fro'); end diffNm = max(mean(diffV), mean(diffU)); end
b024431d0b93674e0ca63dbcebfb179d9e64cdefba8a1989d79a0e70716daee2
MATLAB
247
13
function BPD = jBandPowerDelta(X,opts) % Parameters f_low = 1; % 1 Hz f_high = 4; % 4 Hz % sampling frequency if isfield(opts,'fs'), fs = opts.fs; end % Band power BPD = bandpower(X, fs, [f_low f_high]); end
ee201deed0b68953e39ad16ac70f0c660cded8664ac7e64d73b730326bd8cdf0
MATLAB
247
13
function BPT = jBandPowerTheta(X,opts) % Parameters f_low = 4; % 4 Hz f_high = 8; % 8 Hz % sampling frequency if isfield(opts,'fs'), fs = opts.fs; end % Band power BPT = bandpower(X, fs, [f_low f_high]); end
1a5f764d6a194ab4ee57aba11116052fe87c006c9c517cef094fe9e18246f269
MATLAB
248
6
function param = nk_PolyKernel_config(param) switch param.kernel.kernstr case {' -t 1', 'poly', 'polynomial', 'Polynomial', 'hpolyN', 'polyN'} param.kernel.poly_coef = nk_input('Define coefficient for polynomial kernel',0,'e',0); end
d115f2e08ca0b51621b8cbf329b59c8eb728c13480fa1e0f52ccae46256a0ded
MATLAB
248
13
function BPA = jBandPowerAlpha(X,opts) % Parameters f_low = 8; % 8 Hz f_high = 12; % 12 Hz % sampling frequency if isfield(opts,'fs'), fs = opts.fs; end % Band power BPA = bandpower(X, fs, [f_low f_high]); end
108c090ef42920f0e54de378e5f162e042211576bd860ee389e7c69c4e5c7f74
MATLAB
250
8
function NM = DeleteModalityInNM(NM, varind) NM.datadescriptor(varind) = []; NM.Y(varind) = []; NM.files(varind) = []; NM.brainmask(varind) = []; NM.badcoords(varind) = []; NM.featnames(varind) = [];
86f546cc09784c58c97a0c4fd39e9b72d253674c9a77d1a6e4cc187b1ee4e49d
MATLAB
250
11
function set_device(device_id) % set_device(device_id) % set Caffe's GPU device ID CHECK(isscalar(device_id) && device_id >= 0, ... 'device_id must be non-negative integer'); device_id = double(device_id); caffe_('set_device', device_id); end
e6899dcf8cedf12dabf9d3f32393f54fb38d0c76c6c3b36b558a94a8bcc96e35
MATLAB
250
13
function BPB = jBandPowerBeta(X,opts) % Parameters f_low = 12; % 12 Hz f_high = 30; % 30 Hz % sampling frequency if isfield(opts,'fs'), fs = opts.fs; end % Band power BPB = bandpower(X, fs, [f_low f_high]); end
91be61b4ee40030d04eeefd362860e16136e051dca0d8cb020bcd3006e9db301
MATLAB
251
13
function BPG = jBandPowerGamma(X,opts) % Parameters f_low = 30; % 30 Hz f_high = 64; % 64 Hz % sampling frequency if isfield(opts,'fs'), fs = opts.fs; end % Band power BPG = bandpower(X, fs, [f_low f_high]); end
cab2bd34c067450f0d3b11302f1dc0b909abca8d2097382409c3f3270453f86d
MATLAB
251
9
function [ Vo ] = normalization( Vo_org, max_gray_level ) %NOMALIZATION ‚±‚̊֐”‚ÌŠT—v‚ð‚±‚±‚É‹Lq % Ú×à–¾‚ð‚±‚±‚É‹Lq Vo_max = max(max(Vo_org)); Vo = Vo_org * (max_gray_level / Vo_max); end
48a2daf9a4cba952a6f589af82b3276287b4a1adc9fa5e7eb8e1048ddcbd897f
MATLAB
253
10
% compute pupil area from set of frames function [pup] = processPupil(frames,sats,thres) sats = min(254,max(1, sats*255)); r.fr = frames; r.sats = sats; r.thres = thres; params = findGaussianContour(r); pup.com = params.mu; pup.area = params.area;
0dc421200af07ae6626682906cceb079d5ca578dc144aec7d8dc9b9e9cde11f4
MATLAB
255
7
function load_selOneVsAll_Info(handles) popuplist{1} = sprintf('Multi-group display'); for i = 1:numel(handles.NM.groupnames) popuplist{end+1} = sprintf('%s vs. REST', handles.NM.groupnames{i}); end set(handles.selOneVsAll_Info, 'String', popuplist);
99f45fe88b2f0a036454877a0a947eff1850427420e3b8ffd6b99ecc59ce1792
MATLAB
256
13
%[2018]-"A Novel Multi-Class EEG-Based Sleep Stage Classification System" %(4) function HM = jHjorthMobility(X,~) % First derivative x0 = X(:); x1 = diff([0; x0]); % Standard deviation sd0 = std(x0); sd1 = std(x1); HM = sd1 / sd0; end
a7463d4f354bf43ffb43f62071b20881b357b5a607b73f7435cc7e3970c88253
MATLAB
257
10
function PlotSelf(self, xFD, yFD, ax, ~, ~) % 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); end
6f7e16d4352815eba775c9b0ef0bdb8f14276a7ddb2e6203d7e7c9bfdfa97f64
MATLAB
259
12
%[2014]-"Feature Extraction and Selection for Emotion Recognition from %EEG" function NFD=jNormalizedFirstDifference(X,~) T = length(X); Y = 0; for t = 1 : T - 1 Y = Y + abs(X(t+1) - X(t)); end FD = (1 / (T - 1)) * Y; NFD = FD / std(X); end
4c601de2c2eadb94a7e3f5121839b9646906792e59b3ec4ba907f6c8ac960690
MATLAB
260
12
disp('Test: Mutual information between two images') load mri A=D(:,:,8); B=D(:,:,9); mi(A,A),mi(A,B) disp('Test: Mutual information between two signals') load garchdata nasdaq = price2ret(NASDAQ); nyse = price2ret(NYSE); mi(nasdaq,nasdaq), mi(nasdaq,nyse)
3bea437fc3a6b3e3bd96a3e2fc1545353d7c606271dcadb42fb3943a7c346d88
MATLAB
261
12
function tso = keep(tsin, keep) % tso = keep(tsin, OK) % returns a new tsd with only the elements in OK % % ADR v6.0 2011/12 T = tsin.range(); D = tsin.data(); dim = size(D); D = reshape(D, length(T), prod(dim(2:end))); tso = tsd(T(keep), tsin.data(T(keep)));
f7ece6aeddc0048c41ae5cf09ad7bdb922689c00612263e6fbbd01e1cba78c62
MATLAB
261
12
%[2014]-"Feature Extraction and Selection for Emotion Recognition from %EEG" function NSD = jNormalizedSecondDifference(X,~) T = length(X); Y = 0; for t = 1 : T - 2 Y = Y + abs(X(t+2) - X(t)); end SD = (1 / (T - 2)) * Y; NSD = SD / std(X); end
067f7584911696f1701ec3000495349700e0dd2b106acf01e8c388fc9aabd819
MATLAB
264
11
%[2018]-"A Novel Multi-Class EEG-Based Sleep Stage Classification %System" (11) function LRSSV = jLogRootSumOfSequentialVariation(X,~) N = length(X); Y = zeros(1, N-1); for i = 2:N Y(i-1) = (X(i) - X(i-1)) ^ 2; end LRSSV = log10(sqrt(sum(Y))); end
2026b74a98ccbaeafb7ccda8b59f8872cba3026b81b8ec4080d4751d9983b91b
MATLAB
264
12
function S = nk_DefineMLParamStr(P, Pdesc, curclass) S = []; if ~isempty(Pdesc{curclass}) for n = 1:numel(P) if iscell(P), Pn = P{n}; else, Pn=P(n); end S = sprintf('%s, %s: %1.6f',S, Pdesc{curclass}{n}, Pn); end S = S(3:end); end end
e1b51402b2e0aace1e130b2fe3bb57dc353eb1f1924064ac67077ba6454c0ebf
MATLAB
264
13
function h = my_subplot(ny, nx, i, varargin) dx = .7; dy = .7; if numel(varargin)>0 dx = varargin{1}(1); dy = varargin{1}(2); end ix = rem(i-1, nx)/nx + (1-dx)/nx * 2/3; iy = 1 - ceil(i/nx)/ny + (1-dy)/ny *2/3; h = axes('Position', [ix iy dx/nx dy/ny]);
18519500e9e0bcd0076afee7ea951176d2ae92b225efbe30efe920772829704a
MATLAB
268
12
function [CVR, SE] = nk_ComputeCVR(I, SEL) SUM2 = nm_nansum(I.^2,2); SUM = nm_nansum(I,2); SQ = sqrt(SUM2 ./ SEL - (SUM ./ SEL).^2); SE = SQ./sqrt(SEL)*1.96; % Mean relevance/weight vector across partitions MN = nm_nansum(SUM, 2) ./ SEL; % Compute CVR CVR = MN./SE;
0e4b79321a7ce8390698046c7a6cada3382a4a5d39e736f8883a3a5fa1088a48
MATLAB
270
12
function [v] = plx_mexplex_version() % plx_mexplex_version(): returns mexPlex DLL version % % [v] = plx_mexplex_version() % % INPUT: % None % % OUTPUT: % v - mexPlex DLL version as a number. For example, version 180 corresponds to version 1.8.0. [v] = mexPlex(29);
ebdf70812e0220ce522da7a24f685cd25613c774b54e55fc16c2fd31665926e1
MATLAB
270
11
function rotatemat = bootprocrust(origlv,bootlv) %syntax rotatemat=rri_bootprocrust(origlv,bootlv) %define coordinate space between orignal and bootstrap LVs temp=origlv'*bootlv; %orthogonalze space [V,W,U]=svd(temp); %determine procrustean transform rotatemat=U*V';
04bb232995a9256f2858f2dbac8500f5771b43bce4da984c48d0e5a585932c7d
MATLAB
272
21
clear;clc; rng('default'); rng(100); X = rand(300, 500); omega = X<0.05; %nnz(omega) S = rand(500, 100); XS1 = X* S; Xom = X; Xom(~omega) = 0; Xoc = X; Xoc( omega) = 0; XS2 = Xom * S + Xoc * S; if nnz(XS1 ~= XS2) disp('identical'); else disp('different'); end
18aad3110591e40f6d82e6aec30e8f0eb03b4db5a7ba4b3d3351784391331443
MATLAB
272
11
function fixedOrder = nk_CheckFixedFeatOrderStackInput(stacking, analyses) fixedOrder = true; if stacking == 1 for a = 1:numel(analyses) if analyses{a}.params.TrainParam.GRD.NodeSelect.mode >1, fixedOrder = false; break end end end
1f74f77b532cf056a832731553798a5721e658d55062e13d2329d3b811d0c530
MATLAB
275
10
function [Fmask, opt_heD, opt_heT, opt_D, opt_T] = nk_FilterCVMax(D, T, L, F, kSub, kSp, kInd, MinNum) % Select classifiers acording to their decision values / target predictions % using the margin-based g-flip algorithm % First, [heD, heT] = nk_EnsPerf(D, T, L); return
1b7f42dbbe8bca0298dcb47ad8bd471a9f9fd252b5626fee46a07246aa28b0ce
MATLAB
276
16
function xDs = nk_RenormalizeScores(Dr,Ds) nR = size(Dr,1); nS = size(Ds,1); X = floor(nR/nS); [sDr, indR] = sort(Dr,'descend'); [~, indS] = sort(Ds,'descend'); xDs = zeros(nS,1); vec = 1: X : nR; for i = 1:numel(vec) xDs(i) = mean(sDr(vec(i):vec(i+1))); end
f5c184e29119965c76b465450052efe3a31b114b797c8fcdb7a65570c1333f83
MATLAB
276
11
function out = ndims(fa) % Number of dimensions %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: ndims.m 7147 2017-08-03 14:07:01Z spm $ out = size(fa); out = length(out);
3fb92b0c16d064d6d8035bf47b65034e0bbe0804e9d1e3b3e22958cf050401d9
MATLAB
278
12
function w2flag = nk_CheckW2Avail(SVM, MODEFL) w2flag = false; switch SVM.prog case 'LIBSVM' if SVM.LIBSVM.LIBSVMver == 3 && strcmp(SVM.kernel.kernstr, ' -t 0') && ~strcmp(MODEFL,'regression'), w2flag = true; end case 'LIBLIN' %w2flag = true; end end
4fdf44b37b85926e4d928b54f462890c8edde378fb8245050c7746c88628db04
MATLAB
278
17
function Y = nk_Vol2Vec(P) if ~exist('P','var') || ~exist(P,'file') P = spm_select(Inf, 'image', 'Select images'); end V = spm_vol(P); Y = zeros(numel(V),prod(V(1).dim)); for i = numel(V); y = spm_read_vols(V(i)); Y(i,:) = reshape(y,1,numel(y)); end end
1cbc36f482c71c49df2134e10e7409684f65de99371d2fb2a391fd1a6a52b904
MATLAB
279
15
function sY = nk_Normalize2Mean(Y) [n, m] = size(Y); sY = zeros(n,m); for i=1:n fprintf('\nNormalizing subject %g',i) Yi = Y(i,:); indNonZero = ~(Yi == 0); meani = median(Yi(indNonZero)); sY(i,indNonZero) = Yi(indNonZero) * 100 / meani; end
d61d2cb925c3d0fde88ef217e2d06c32def8b2af94868736412e1f3045ced1db
MATLAB
279
10
function load_selLabel(handles) labelstr=''; for i=1:size(handles.NM.label,2) if isfield(handles.NM,'labelnames') labelstr = handles.NM.labelnames{i}; end popuplist{i} = sprintf('Label #%g%s',i,labelstr); end set(handles.selLabel, 'String', popuplist);
5a2f1cae5ea88ffd01a76fa9f3fea3ae9b346f63c0bba4d4362685e93f575038
MATLAB
280
13
function N = elmScale( A ) % FUNCTION scales data to -1;+1 range. % % get column max and min maxA = max( A, [], 2 ); minA = min( A, [], 2 ); maxA = repmat( maxA, 1, size(A,2) ); minA = repmat( minA, 1, size(A,2) ); % normalize to -1...1 N = ( (A-minA)./(maxA-minA) - 0.5 ) *2;
911601b3b25b1c7eeb5199bc794649a6ed0a7d175524b700db88f427cbd824b7
MATLAB
280
10
function PlaceWindow(self, W) % If the name of window W is in the windows map container, then read the % location and place it there. If it is not, then don't. name = get(W, 'name'); if isKey(self.windowLocations, name) set(W, 'position', self.windowLocations(name)); end
9f893134df0dd9f93653597574155fd6c14e38e18e10b775c304a873a003b645
MATLAB
280
16
function [nR, nC] = BestSubplots(nP) % [nR, nC] = BestSubplots(N) % % Calculates the best distribution of subplots for N plots % % INPUTS % nP = number of subplots to place % % OUTPUTS % nR, nC = number of rows and columns % % ADR 2013 nR = ceil(sqrt(nP)); nC = ceil(nP/nR);
0ec814b67db43a7e43f0b18adee4284e3462b7fe94b2edf160ac8f1da5ac228e
MATLAB
281
10
% Y = VEC2MAT(x,m,n) % Given a vector of length m*n, this produces the m x n matrix % Y such that x = mat2vec(Y). In other words, x contains the columns of the % matrix Y, stacked below each other. % % See also mat2vec. function X = vec2mat(y,m,n) X = reshape(y,m,n); end
e44b25b6be2813acf8220d2c7b045e642550e8d7e91b88eca574c67d765d8b9a
MATLAB
284
12
function [P, I] = nk_ComputeEnsembleCasePropagationProbability(C, nNodes) nCases = size(C,1); P = zeros(nCases,nNodes); I = zeros(nCases,1); for i=1:nCases ni = numel(C{i}); for j=1:nNodes P(i,j) = sum(C{i}==j) * 100 / ni; end [~,I(i)] = max(P(i,:),[],2); end
eb0d6257928ab709177cdfc5294181b4e66e35681cf51a70b38f31ccb37bcf1d
MATLAB
284
13
function R = nk_FScore(Y, L) indP = L == 1; indM = L == -1; nYp = sum(indP); nYm = sum(indM); mY = mean(Y); mYp = mean(Y(indP,:)); mYm = mean(Y(indM,:)); R = ((mYp - mY).^2 + (mYm - mY).^2) / ( sum((Y(indP,:)-mYp) ^ 2) / (nYp - 1) + sum((Y(indM,:)-mYm) ^ 2) / (nYm - 1) ); end
7c8a4b96ac290b6bd99a52706ae5a2db0a3a57caf5d3fa46ab848fca4c09e692
MATLAB
286
4
%Compiles the FEAST Toolbox into a mex executable for use with MATLAB mex -I../MIToolbox FSToolboxMex.c BetaGamma.c CMIM.c CondMI.c DISR.c ICAP.c JMI.c mRMR_D.c ../MIToolbox/MutualInformation.c ../MIToolbox/Entropy.c ../MIToolbox/CalculateProbability.c ../MIToolbox/ArrayOperations.c
25cdd377080341cc07036bb9013145cf907bb47c592efa75e7020072fa961f31
MATLAB
287
10
function l = length(x) % Overloaded length function for file_array objects %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: length.m 7147 2017-08-03 14:07:01Z spm $ l = max(size(x));
5f07d130b9ec656743f789fc6fd500faea73dba0fed144cd57ce0ec9f9d568b0
MATLAB
287
12
%[2014]-"A Comparative Study on Classification of Sleep Stage Based on %EEG Signals Using Feature Selection and Classification Algorithms" (13) function MCL = jMeanCurveLength(X,~) N = length(X); Y = 0; for m = 2:N Y = Y + abs(X(m) - X(m-1)); end MCL = (1 / N) * Y; end
4b9ff8e09580ce8574172521d581ce89e458acdf52de52f8178d74312dc1e322
MATLAB
290
10
function result = samplesize(delta, epsilon, a) % delta = confidence level (typically 0.05 or 0.1) % epsilon = precision level (typically 0.05 or 1) % a = number of isomorphism classes of graphlets % % Karsten Borgwardt % 4/11/2008 result = 2 * ( a* log(2) + log(1/delta) ) / (epsilon^2)
6190cf811b5c9b7b26a67c9920ebe8d6b3fac638bee26f4bf7135de71439f664
MATLAB
295
14
function disp_freq = set_disp_frequency(options) % select disp_freq if options.verbose > 0 disp_freq = floor(options.max_epoch/100); if disp_freq < 1 || options.max_epoch < 200 disp_freq = 1; end else disp_freq = 100000; end end
4ab410b22c5d8c2f8bb3a268d3d24628e3fc35f6b700ddd48fae45ed21664740
MATLAB
297
7
function out = getEigengroupIdx(groupNumber, nMax) %% GETEIDENGROUPIDX Gets position IDs for the eigengroup number specified % first constant mode is group 1, next three modes are group 2 (1-indexed) out = (1:(2*groupNumber-1)) + (groupNumber-1)^2; if nargin > 1; out = out(out <= nMax); end end
539783a299322ca3d53e340ca8e16254fadc9c2b1829cca6a04060688a0b199b
MATLAB
298
10
function o = vertcat(varargin) % Vertical concatenation of file_array objects. %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: vertcat.m 7147 2017-08-03 14:07:01Z spm $ o = cat(1,varargin{:});
9b2fb668c1f56089e303b389ca57bc8dd7c356362d5401d72eaba2203b07a114
MATLAB
298
10
function indvol = nk_ExtrIndVol(Vm, thr, throp) indvol=[]; for sl=1:Vm.dim(3) M = spm_matrix([0 0 sl 0 0 0 1 1 1]); mask_slice = spm_slice_vol(Vm,M,Vm.dim(1:2),1); ind0 = find(feval(throp, mask_slice, thr)); ind = ind0 + (sl - 1)*prod(Vm.dim(1:2)); indvol = [indvol; ind]; end
f4f2d8d9a19f978c64e4eb07172b36427110f5058e923d4eeff7c33a6409848e
MATLAB
298
10
function solver = get_solver(solver_file) % solver = get_solver(solver_file) % Construct a Solver object from solver_file CHECK(ischar(solver_file), 'solver_file must be a string'); CHECK_FILE_EXIST(solver_file); pSolver = caffe_('get_solver', solver_file); solver = caffe.Solver(pSolver); end
20a7fbc45b6220dd286c576683fcbf3e04ff5b98a4eae14c16fba19fd051575b
MATLAB
299
10
function o = horzcat(varargin) % Horizontal concatenation of file_array objects %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: horzcat.m 7147 2017-08-03 14:07:01Z spm $ o = cat(2,varargin{:});
509bfa4390a62a0d81ef3c7d52733d734625e623f58ada3e773cfedb013fdf18
MATLAB
300
12
%[2014]-"A Comparative Study on Classification of Sleep Stage Based on %EEG Signals Using Feature Selection and Classification Algorithms" (11) function MTE = jMeanTeagerEnergy(X,~) N = length(X); Y = 0; for m = 3:N Y = Y + ((X(m-1) ^ 2) - X(m) * X(m-2)); end MTE = (1 / N) * Y; end
fcb20726a2b097fdf24290dffd0f7ab1737a55f3931a45ccf73eb3ee105ad9b0
MATLAB
303
6
% Save cognitive model parameters in a normal .mat file that can be read using % scipy. clear; data = load('/oak/stanford/groups/menon/projects/percym/2020_ABCD_SST/results/dynamic2023z9413.mat'); save('/oak/stanford/groups/menon/projects/branigan/2022_abcd_glm/data/behavior/SST_pm_cog.mat', 'data');
aae781f7f34a59f7f1aa8fd44adba2390120fe74bfc3396b0fc30cf3a509bd26
MATLAB
304
7
function IO = CalcGlobals(IO) %-Compute as mean voxel value (within per image fullmean/8 mask) fprintf('Calculating globals\n') IO.g = zeros(numel(IO.VV),1); for i=1:numel(IO.VV), IO.g(i) = spm_global(IO.VV(i)); fprintf('.'); end if ~isfield(IO,'globnorm') || isempty(IO.globnorm), IO.globnorm = 1; end
65bbd19de7ac6d4bf2b91dcd33d660cf6621780bf77d0c76f995a84ca819aee7
MATLAB
305
15
function catarray = cellcat(arr, dim) [ix,jx] = size(arr); if nargin < 2, dim = 1; end catarray = []; for i=1:ix for j=1:jx switch dim case 1 catarray =[catarray; arr{i,j}]; case 2 catarray =[catarray arr{i,j}]; end end end
ed7042633be2a4430b3fbb80379c6b9bcc6d611c51e6a0482e6e0f197e4c4122
MATLAB
305
12
% List of open inputs spm_path = [getenv('KUL_apps_DIR') filesep 'spm12']; addpath(spm_path) nrun = 1; % enter the number of runs here jobfile = {'###JOBFILE###'}; jobs = repmat(jobfile, 1, nrun); inputs = cell(0, nrun); for crun = 1:nrun end spm('defaults', 'FMRI'); spm_jobman('run', jobs, inputs{:});
3a58f80b24a28576531baff0256997e6b1398648bc44f7eba7a3c905dd7250bf
MATLAB
306
13
function tso = removeNaNs(tsin) % tso = removeNaNs(tsa) % removes all times where all components of the data of tsin is nan % % ADR v6.0 2011/12 T = tsin.range(); D = tsin.data(); dim = size(D); D = reshape(D, length(T), prod(dim(2:end))); keep = ~all(isnan(D),2); tso = tsd(T(keep), tsin.data(T(keep)));
b2f8f5d37235d808b42bd26b37e0c955352f6051f23f702c0652a3aa2afbcea9
MATLAB
308
10
function [contains_img, where_img] = nk_CheckContainsImagingData (NM, analind) F = NM.analysis{analind}.params.TrainParam.FUSION.M; nF = numel(F); where_img = false(1,nF); for i=1:nF if strcmp(NM.datadescriptor{F(i)}.source, 'image') where_img(i) = true; end end contains_img=any(where_img);
d4161a5b47f2efd02f46e6645bb777f6b375f6c9ce2a7e152231128c0f6b8922
MATLAB
310
3
mex -I.. CMIM_Mex.c ../MutualInformation.c ../Entropy.c ../CalculateProbability.c ../ArrayOperations.c mex -I.. DISR_Mex.c ../MutualInformation.c ../Entropy.c ../CalculateProbability.c ../ArrayOperations.c mex -I.. mRMR_D_Mex.c ../MutualInformation.c ../Entropy.c ../CalculateProbability.c ../ArrayOperations.c
32a94921c4500d275d3c197ca5b34599f3bb2e51cd70c2da08146978ea90034b
MATLAB
311
11
%[2018]-"Improved binary dragonfly optimization algorithm and wavelet %packet based non-linear features for infant cry classification" (3) function ShEn = jShannonEntropy(X,~) % Convert probability using energy P = (X .^ 2) ./ sum(X .^ 2); % Entropy En = P .* log2(P); ShEn = -sum(En); end
f5cd915b1b65df67f6d3cccabe35d1eaf49d3f73f4cb429e01df80d44ac7583d
MATLAB
311
12
function out = numeric(fa) % Convert to numeric form % FORMAT numeric(fa) % fa - a file_array %__________________________________________________________________________ % Copyright (C) 2005-2018 Wellcome Trust Centre for Neuroimaging % % $Id: numeric.m 7501 2018-11-30 12:16:58Z guillaume $ out = full(fa);
8363840afe5064cbacf1fcb71591300e7f018c86f52304e2da84231dc7b889a5
MATLAB
313
14
function [newL, newR] = colsum_L_one(L, R, varargin) % normalizes columns in L so that the product LR stays the same if isempty(varargin) [helpR, helpL] = rowsum_R_one(R',L'); else [helpR, helpL] = rowsum_R_one(R',L',varargin{1}); end newR = helpR'; newL = helpL'; end
fd671eef214bd3f7bd2ad8799c8f7ac4aa99f1a6f02306d18b246eae6079a649
MATLAB
313
15
function Ydims = nk_GetCV2EnsembleDims(D) [nperms, nfolds, nclass] = size(D); Ydims = zeros(nclass,1); %Xdims = ones(nclass,1); for i=1:nperms for j=1:nfolds for curclass=1:nclass DY = size(D{i,j,curclass},2); Ydims(curclass) = Ydims(curclass) + DY; end end end
ff8d3a526075bd8699e21fabed1d7bacc3b0c5e9bcc2b27ef6787b8de98ace38
MATLAB
313
14
function display(obj) % Display a NIFTI-1 object %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: display.m 7147 2017-08-03 14:07:01Z spm $ disp(' '); disp([inputname(1),' = ']) disp(' '); disp(obj) disp(' ')
16eee50e826fd55387d1c85db8546fd471cf3c7dc54de1af514c35fece05382f
MATLAB
314
8
function [ fvP ] = primalObjD( Xdiag, yvect, Th_vecIdx, lambda1, lambda2, W ) % primal objective (diagonalized) % 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(sum(W.^2))... + segL2 (Xdiag * W(:) - yvect, Th_vecIdx); end
3533bfb988e82430f0736920c067554a7930f2631da9ca51b3f76d2431b35d8f
MATLAB
314
12
function [entrop, perf,D, T, L] = nk_ComputeEntropy(decs, targs, TsInd, TsIdx, TsLabels) global EVALFUNC [D, T, L] = nk_Vals2Ind(decs, targs, TsInd, TsIdx, TsLabels); lbind = any(T,2); hx = sign(sum(T(lbind,:),2)); lb = sign(sum(L(lbind,:),2)); perf = EVALFUNC(hx,lb); entrop = nk_Ambiguity(T(lbind,:)); return
eee9c542e4f97a3fff212b008463adbe5120ad3aa3f9a60c235237ac6f497587
MATLAB
315
10
function mess = GenerateMessageEntry(mess, text, flag, format) if ~exist('format','var') || isempty(format), format = 'red*'; end if ~exist('flag','var') || isempty(flag), flag = 1 ; end e = numel(mess); if e==1 && isempty(mess), e=0; end mess(e+1).format = format; mess(e+1).flag = flag; mess(e+1).text = text;
907267537ca15b96d7e503b211f4bbd8e8321f27181ba903ee1bd16e5ef0b829
MATLAB
316
9
function [tbl,chi2stat,pval] = mychisquare(new_contbl) n1 = new_contbl(1,1); N1 = new_contbl(2,1); n2 = new_contbl(1,2);; N2 = new_contbl(2,2); x1 = [repmat('a',N1,1); repmat('b',N2,1)]; x2 = [repmat(1,n1,1); repmat(2,N1-n1,1); repmat(1,n2,1); repmat(2,N2-n2,1)]; [tbl,chi2stat,pval] = crosstab(x1,x2); end
d280865c3437199d51972b2e24d5fa1ddb60c0dd022fa66d9bd134d89782b9bf
MATLAB
316
14
function display(obj) % Display a file_array object %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: display.m 7147 2017-08-03 14:07:01Z spm $ disp(' '); disp([inputname(1),' = ']) disp(' '); disp(obj) disp(' ')
1ec13a0407cf241a0590083cdc239b94fd0e294ddf7d1d3758b93b37025b5793
MATLAB
317
9
function varargout = ctranspose(varargin) % Transposing not allowed %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: ctranspose.m 7147 2017-08-03 14:07:01Z spm $ error('file_array objects can not be transposed.');
4979e386c355dc45d6088fac8328d48e3e7239e6e00f60403fe9f51542f9deba
MATLAB
319
11
function newPos = drawROI(handles,ROI) h = imrect(handles.axes1, ROI); title(handles.axes1, 'Update the ROI and double-click') %addNewPositionCallback(h,@(p) title(mat2str(p,3))); %fcn = makeConstrainToRectFcn('imrect',get(gca,'XLim'),get(gca,'YLim')); %setPositionConstraintFcn(h,fcn); newPos = wait(h); delete(h);
c89a3a18eb6718fabe08da80d19b29e73ad62cdfe78ac072d446c27e89c69142
MATLAB
319
13
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 (size(X,2)>1) mergedVector = MIToolboxMex(3,X); else mergedVector = X; end [output] = MIToolboxMex(4,mergedVector);
037107e642a6a50e300514a5526ec3d235eb885a79c41ad9c3445f68637f4c87
MATLAB
320
12
function out = double(fa) % Convert to double precision % FORMAT double(fa) % fa - a file_array %__________________________________________________________________________ % Copyright (C) 2005-2018 Wellcome Trust Centre for Neuroimaging % % $Id: double.m 7501 2018-11-30 12:16:58Z guillaume $ out = double(full(fa));
c2f5d1baf28348c89e8df25819cba638d4971b424e960af09c1d13764a8c1702
MATLAB
320
13
function IO = ReadSurf(IO) cnt = 1; IO.Y=[]; for j=1:numel(IO.V) for i=1:IO.n_subjects(j) filename = deblank(IO.PP(cnt,:)); [~,y] = SurfaceReader(filename); fprintf('\nsample %g, file: %s',j, filename) if size(y,1)>1, y=y';end IO.Y = [IO.Y; y]; cnt=cnt+1; end end
f2af68ad7317b20814e77c93d3390a9e76dd2b5f8a9066e2165b180aec5a6c85
MATLAB
320
14
function [ out ] = sparse_inp_native( U, V, iR, iC ) %SPARSE_INP inner-product and apply sparse selection. % Perform the following: % UV = U * V, out(ii) = UV(iR(ii), iC(ii)); len = length(iC); out = zeros(len, 1); for ii = 1: len out(ii) = U(iR(ii), :) * V(:,iC(ii)); end end
d1188101b3113b7e923f4a271efaf49eb3071047791ae5e14b995ebae698f1b8
MATLAB
323
12
function ClusterFunc_00_ShowInfo(self) S = {self.name, ... sprintf('@%s', class(self)), ... sprintf('%d spikes', self.nSpikes()), '', ... }; for iL = 1:self.nLimits S = cat(2, S, ... sprintf('Limited on < %s X %s >', self.featuresX{iL}.name, self.featuresY{iL}.name)); end msgbox(S, self.name); ...
b2aa7128ead264fa8d49f20ddd72f4f386fc09f50ac6aa07311d067753474ad5
MATLAB
324
18
clear; S = sparse(diag(eye(5))); idx = find(S~=0); v = rand(5, 1); out_us_nat = sparse_update_native(S, v); out_us_mex = S; sparse_update(out_us_mex, v); if nnz(out_us_mex ~= out_us_nat)>0 warning('inconsistent results found in sparse_update') else disp('[MEX: sparse_update] consistency check passed.'); ...
0b184ba5a57c2b6309d7ea64cefab274ba2a85d6ab770ab45857d6811997ae5f
MATLAB
325
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 D -O svmtrain289PLUS.c svm.obj svm_model_matlab.obj mex -largeArrayDims -O svmpredict289PLUS.c svm.obj svm_model_matlab.obj %mex -O libsvmread.c %mex -O libsvmwri...
fb2acd4e7f7126fe3e0df72dadc808aeacfedcc3cfd216d7b058c359d0580f99
MATLAB
325
10
function varargout = permute(varargin) % file_array objects can not be permuted %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: permute.m 7147 2017-08-03 14:07:01Z spm $ error('file_array objects can not be permuted...
9d7b9b749f1e482858e1cb1228abbbcda60c727fe4e5b27c21bb0ce81595cf5d
MATLAB
326
12
function bool = streq(S1, S2) % bool = streq(S1, S2) % % returns true if S1 == S2 and false otherwise % % 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. bool = strcmp(S1, S2) ...
0ef821688b5f5a6dd1402fa1fc5f7ad2906c06be203a79e08bf4071b63471869
MATLAB
327
14
%[2012]-"Classification of EMG signals using combined features and %soft computing techniques" (1-2) function AR = jAutoRegressiveModel(X,opts) % Parameter order = 4; % order if isfield(opts,'order'), order = opts.order; end Y = arburg(X,order); % First index is meaningless AR = Y(2 : order + 1); ...
d239372985056df4a31a55be811e00e160a3aae289f87e735de3123573b7ce08
MATLAB
332
9
function xform = mripy_read_transform(fname) %MRIPY_READ_TRANSFORM Read AFNI coordinates transform matrix in *.1D format. % 2017-08-14: Created by qcc fid = fopen(fname); c = textscan(fid, '%f', 'Delimiter', ' ', 'MultipleDelimsAsOne', true, 'CommentStyle', '#'); fclose(fid); xform = reshape([c{1}], 4...
32c90da7200841d63fefa816caade984191b4aa4886ddb82b9f339320a0421eb
MATLAB
333
10
function varargout = transpose(varargin) % file_array objects can not be transposed %__________________________________________________________________________ % Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging % % $Id: transpose.m 7147 2017-08-03 14:07:01Z spm $ error('file_array objects can not be tr...
35d98d4a9ca0446979c259eb72ca9115fbe6a52fa19974240a1ba707dc9d47f7
MATLAB
333
12
function stop = tfocs_stop( x, nonsmoothF, optTol ) % tfocs_stop : TFOCS stopping condition % % $Revision: 0.1.2 $ $Date: 2012/09/15 $ % global subprob_Dg_y subprob_optim [ ~, x_prox ] = nonsmoothF( x - subprob_Dg_y ,1); subprob_optim = norm( x_prox - x ,'inf'); stop = subprob_optim <= op...
2b17a136b52bd9d243b5f25365ea8d7960bd851431b8a0a691ade8546fd05621
MATLAB
334
14
function [SIG, ind] = nk_CheckMatrixEmptyNonVarNonFinite(Y) indany = any(Y); indvar = std(Y) > 0; indfinite = any(isfinite(Y)); ind = ~indany & ~indvar & ~indfinite; if any(ind) , warning('No-variance / empty / non-finite features in matrix'); SIG = 1; else SIG...
5397530addf88b507f8c8d86ab3c48538ad108deaf7d0666df246868531dbdf0
MATLAB
336
10
function [B] = standardize(A) % normalize A such that sum_i A_ij = 0, sum_i A_ij^2 = 1 (mean 0 and variance 1) % each row of A is a sample m = size(A,1); % B = A - repmat(mean(A),m,1); % sum_i A_ij = 0 B = A; ind = (sum(B==0) == m); B(:,ind) = 1/(sqrt(m)); B(:,~ind) = B(:,~ind)./repmat(sqrt(sum(B(:,~ind).^2)),m,1); % ...
a1d098d57fb7cd5409e8fc33c50a0f894cfcc6df6979bbf97015deff8cf23632
MATLAB
338
11
function f = fit_br_spatial(model,subject_id,npts) fdata = load_br_data(subject_id,'all'); [init_default,prior_pp] = model.initialize_fit(fdata.f,fdata.P); model.set_electrodes(fdata.electrodes); f = bt.core.fit_spectrum(model,fdata.f,fdata.P,prior_pp,init_default,npts,[],[]); fprintf('Fit took %.2f seconds\n'...
ef4c2fec5e63771af6ce635a21b25d96732085a976ce03a9ea908fb52ed19598
MATLAB
339
14
function C = AddCluster(self, ClusterType) % MClustData % % Add cluster if room if length(self.Clusters) < self.maxClusters C = feval(ClusterType); self.Clusters{end+1} = C; else C = []; warning('MClust:TooManyClusters', ... 'Tried to add clusters beyond maximum.\n Current maximum is %d.', sel...