sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
c8aaa123911b459bb7b921ae86efd912f78a1a6521cd87794acf53285579c482
MATLAB
657
39
function displayimages(I,nr,nc,label) nI = numel(I); nperpage = nr*nc; npages = ceil(nI/nperpage); for page = 1:npages, clf; istart = (page-1)*nperpage; iend = min( page*nperpage, nI ); ni = iend - istart; for i = 1:ni, subplot(nr,nc,i); imshow(I{istart+i}); if exist('label') if isn...
0108319dcdd30e596b6bac3d9c7ffe543386bb1b5811746dd0bfc55f8a8fa823
MATLAB
658
40
function [err, inds]=decomp_error(v1,v2); [nchan, n1]=size(v1); [nchan, n2]=size(v2); errs=zeros(n2,n1); for i=1:n1 for j=1:n2 c=v1(:,i)'*v2(:,j)/norm(v1(:,i))/norm(v2(:,j)); %errs(j,i)=sqrt(1-c^2); errs(j,i)=1-abs(c); end end maxerrs=max(max(errs)); res=zeros(n1,3); if n1>...
9bb6f914fd8d1e48cdd30a4bec381a706c37dd0c02548c4b2ea03f38ce849b8f
MATLAB
658
26
function prob = gmmprob(mix, x) %GMMPROB Computes the data probability for a Gaussian mixture model. % % Description % This function computes the unconditional data density P(X) for a % Gaussian mixture model. The data structure MIX defines the mixture % model, while the matrix X contains the data vectors. Each row ...
fcb6c0c5c08dedf5e40c9cd80d33ace428b0d4fee3f574850f2a25e1e3049ca6
MATLAB
658
18
% Copyright Christopher Fricke, University Leipzig Medical Center, % Neurology 2024 srcf2 = 'data\prep\coreg_indiv\datscan_normalized'; refnii = single(niftiread(fullfile(srcf2,'Masken','ref2.nii'))); % okzipitale Referenz refnii(isnan(refnii)) = 0; refnii(refnii ~= 0) = 1; d = dir(fullfile(srcf2,'wc*.nii')...
086448aaf93f4cffb42672b9b5aac35eda1a75fc1ffe8ab9aa2f58c3c296772e
MATLAB
659
21
function lstnrObj = listenPropsPostSet(obj,props,cbk) % Listen to multiple properties with a single callback % % obj: scalar handle obj to be listened to % props: cellstr, properties to listen to % cbk: callback % % lstnrObj: scalar listener object, lifecycle not tied to obj assert(iscellstr(props) && isvector(props))...
167378b17b028f5bfbcb1e6ce615a9b65415265e7eccbb60b0de926e067c89c4
MATLAB
659
33
% Author: Birgit Nierula (Feb, 2020) % nierula@cbs.mpg.de function zim_writeLine(fid, headerLevel, mytext) %% input: % fid = file identifier % headerLevel: 1 = title1, 2 = title2, ..., 6 = title6, 0 = regular text % mytext = text you want to add if headerLevel > 6 headerLevel = 0; elseif headerLevel < 1 hea...
1c901126abb3eebc8f3d7fb6a9c437c6e22d75c29900cd6fe3eb6e5220a536d7
MATLAB
659
29
%% Simple test of hmmFitEm with Gaussian observations % %% % This file is from pmtk3.googlecode.com loadData('speechDataDigits4And5'); data = [train4'; train5']; d = 13; % test with a bogus prior if 1 prior.mu = ones(1, d); prior.Sigma = 0.1*eye(d); prior.k = d; prior.dof = prior.k + 1; else pri...
6fd9d58999799f2c03fb20920eb541c1c256a3843a67ef401144ddf811e85007
MATLAB
659
30
function [str, x_bytes, unit] = bytes2str(bytes, precision) %BYTES2STR Returns the number of bytes in a more readable format. % Usage: % bytes2str(bytes) % str = bytes2str(bytes) % str = bytes2str(filename) % str = bytes2str(_, precision) % [str, x_bytes, unit] = bytes2str(...) if ischar(bytes) bytes = g...
9b2eea4081ba546f7b77faba2d409575a609f942919ba0630e7430de3128c9f5
MATLAB
659
23
function fmf_write_frame( fp, data, stamp, data_format ) % fmf_write_frame( fp, data, stamp, data_format ) % % writes image data for the next frame in the file pointer FP % % FP is a file pointer to fmf file with header already written % DATA is specified by data_format, as below, F_HEIGHT x F_WIDTH % STAMP is the time...
8121eb7d620eeedadaa0d7f77a7baf9e54b7dd1180358e35421401240fbbc600
MATLAB
660
30
function coordsRot = rotateCoords(coords, rotation) % % function coordsRot = rotateCoords(coords, rotation) % % assumes the coords are centered around (0,0) % coords have 2 rows, x and y % rotation angle in degrees, positive is clockwise % % Rachel Denison % November 2014 rotation = rotation*pi/180; x = coords(1,:); ...
afaed30418252ef22fbb06d7c85a2ec6d28da5973c4be6f390691f16776f1271
MATLAB
660
28
function [ytest ypredt] = test_predict(xtest, ytest, modelfile) % --- Load test data [a, b, c] = size(xtest); % --- Load model file load(modelfile, 'Model', 'parm'); % % --- Estimate prediction error for test data % % Time alignment for prediction using embedding input [tx,ty] = pred_time_index(xtest,p...
fc056057aebb2cf3d956e78644cfa89b72025128ea71942ae7b250be6d0fb194
MATLAB
660
23
function v = repmatIfNec(v,n,name,varargin) % v = repmatIfNec(v,n,name,varargin) % % v: Some value that is either i) a scalar value or ii) a vector of length n % n: Number of repeats desired/expected % name: string used in warning % optional pvs: % - cell. If true, repmat into a cell vector % docell = myparse(vararg...
41616679919e6f003f3fb340a71e399a7b007f2c5ebd1d5f2b5a952e168aea91
MATLAB
661
29
function nboxes = ufmf_read_nboxes(header,frameis) FRAME_CHUNK = 1; fp = header.fid; nboxes = nan(size(frameis)); for i = 1:numel(frameis), framei = frameis(i); fseek(fp,header.frame2file(framei),'bof'); % read in the chunk type: 1 chunktype = fread(fp,1,'uchar'); if chunktype ~= FRAME_...
50261131df83a48a4e17c544b01005327aab642beece6ae0b7a968eb8bf6cbbe
MATLAB
661
22
function out = averagelocalstrain(X,epsilon) % averages the strain field epsilon by averaging the epsilon tensor % values over the nearest neighbours of the off particle NNacceptance = 2.2; % second minima of g(r) NNsq = NNacceptance* NNacceptance; N = size(X,1); averagestrain = zeros(N,10); for n0 = 1:N if epsi...
a0353d73da1a71ff301cd5ca48129b08b31923d50d0cbaa35787b7ba2473b881
MATLAB
661
20
function Params=BasicClassifier % Options For Collapsing Neural Data Through Time into a feature Params.TimeCollapseMethod='Null'; Params.NumBins=nan; % Number of TimeSamples to Average across % function to call to return Training Data Params.TrainingDataFcn=[]; % Feature Reduction Options % Params.FeatRed...
49e4b7daba63992936da889d418feaade92afa3398d215d8615020f7248d5f29
MATLAB
662
29
function deriv = dF(W) global XA XB bA sigma2 X1 = XA; X2 = XB-repmat(bA,size(XB,1),1); n1 = size(X1,1); n2 = size(X2,1); D12 = dist2(X1*W,X2); D1 = dist2(X1*W,X1*W); Matobj11=exp(-D1./(2*sigma2)); Matobj12=exp(-D12./(2*sigma2)); R1=repmat(X1',1,n1); J1tmp=repmat(X1',n1,1); J1=reshape(J1tmp,size(X1,2),[]); vecobj11...
82fcbfb5c9ad0d694e2387b5d7ef3b2eabadb2d7088674feacbf4942ff3a3788
MATLAB
662
18
function transpose(x) %TRANSPOSE is not defined on sparse tensors. % % See also SPTENSOR/PERMUTE. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www.sandia.gov/~tgkolda/TensorToolbox. % Copyright (2015) Sandia Corporation...
fc97049888d78af500788129b8235f816e42848880cafe98db96ca627ed0c7fb
MATLAB
662
22
% HIFIE_SV Solve using hierarchical interpolative factorization for integral % equations. % % Typical complexity: same as HIFIE_MV. % % Y = HIFIE_SV(F,X) produces the matrix Y by applying the inverse of the % factored matrix F to the matrix X. % % Y = HIFIE_SV(F,X,TRANS) computes Y = F\X if TRANS...
0044ce3dd5baae5c5ef5c7a3af3ebf02b4b89a32a548c87f882918bd6da4c8bb
MATLAB
663
28
% run.m % Run a simulation (simTauMap6) and save the results. % clear the workspace clear; % define save file name save_name = 'simulation3'; % initialize simulation parameters params = genParams(ttot=10, tau_gating=true); % set tau to a multiple of map6 ratio = 10; params.tau_on = params.map6_on * ratio; params.ta...
02da1dfc086fe2c95f2df972c92e4ddb7cd89b4330d82d142d68192d755f9a49
MATLAB
663
23
function [fx] = f_FitzHughNagumo(Xt,Theta,ut,inF) % FitzHugh-Nagumo membrane potential evolution function % function [fx] = FitzHughNagumo(Xt,Theta,ut,inF) % IN: % - Xt: system's states, ie: % Xt(1): membrane depolarization (mV) % Xt(2): proxy for ion channel opening probabilities % - Theta: evolution ...
28f33e7fca8207190edc949fc8d86763e4e0d72ab76f50e08da79abebc75191f
MATLAB
663
21
% This script is an adaptation of Dr. J. Fortin's original source code. % The original source code can be found at https://github.com/Jfortin1/ComBatHarmonization/tree/master/Matlab 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...
68878b2f17e5bab817905ccc4c5bc1b14209ec22725d13fbdbe5408f258bf474
MATLAB
663
21
%% Discriminant Analysis On the Fisher Iris Data % %% % This file is from pmtk3.googlecode.com loadData('fisherIrisData') X = meas(51:end, 1:2); % for illustrations use 2 species, 2 features labels = species(51:end); [y, support] = canonizeLabels(labels); types = {'quadratic', 'linear', 'diag'}; for tt=1:length(type...
97f82e639408020e9de11c367f759b5fe7975c3d5b772a928c04463a26b47850
MATLAB
663
23
%% Plot different smoothing kernels box = @(u) (1/2)*(abs(u) <= 1); epa = @(u) (3/4)*(1-u.^2).*(abs(u) <= 1); %tri = @(u) (35/23)*(1-u.^2).^3.*(abs(u) <= 1); tri = @(u) (70/81)*(1-abs(u).^3).^3.*(abs(u) <= 1); gauss = @(u) (1/sqrt(2*pi))*exp(-u.^2/2); fns = {box, epa, tri, gauss}; names = {'Boxcar', 'Epanechnikov', 'T...
d0bf7a00a64edb139a229d5a70e66df6a3a0685172998ba56546b6c7ad6b0e01
MATLAB
663
24
function [plotLabel] = cleanLabels(plotLabel) % remove the path from the labels, if present for barNum = 1:length(plotLabel) barLabel = char(plotLabel(barNum)); ind = strfind(barLabel, '/'); if isempty(ind) plotLabel(barNum) = {barLabel}; else plotLabel(barNum) = {barLabel(ind(length(in...
b67f36077092103e6f5dbdb022e16ef133a8426728f5d26d59610e03af884216
MATLAB
664
20
function txt = meg_annotateStats(x,y,stars) % Draws n.s. and significance stars % Inputs: % x: x position % y: y position, max(fh.YLim) for top of figure % stars: string, ns, *, **, *** % Ouputs: % txt: text handle if contains(stars,'*') txt = text(x,y,stars,'EdgeColor','none',... 'FontSize',18,'H...
82fb461c9d2afe237957e1decc3106a5d2a7b75dff3ebb2bca9a04844befdede
MATLAB
665
22
function candoit = canGetEuclideanGradient(problem) % Checks whether the Euclidean gradient can be computed for a problem. % % function candoit = canGetEuclideanGradient(problem) % % Returns true if the Euclidean gradient can be computed given the problem % description, false otherwise. % % See also: canGetGrad...
a27317aa48d9b10ea6adbcfa4f5604b93dd47b1ec020afe69f3538765699b87e
MATLAB
665
30
function S = surface_triangle(a,b,c) % SURFACE_TRIANGLE Calcultes riangles surface. % % SYNTAX: % [S] = SURFACE_TRIANGLE(A,B,C) % SURFACE_TRIANGLE(A,B,C) % % [S] = SURFACE_TRIANGLE(A,B,C) % - A, B and C - are m by 2 matrices of (x,y) cartesian coordinates % of vertices of m triangles. % - S - ...
e91d3bb2ffe2e97d4db0110f768310a80d4dfcb372bc57519ca8b862946370e5
MATLAB
665
23
function dgm = hmmToDgm(model, T, varargin) %% Convert an hmm model to a dgm of by unrolling the hmm for T time steps % All other args are passed directly to dgmCreate %% % This file is from pmtk3.googlecode.com G = mkChain(T); CPD1 = tabularCpdCreate(model.pi); CPD2 = tabularCpdCreate(model.A); localCPD = model...
f4e14604851072f32e06b14499dc848fa4c53e24a3fa64f9a1a278ed8100e8a7
MATLAB
665
18
function ctranspose(x) %CTRANSPOSE is not defined for sparse tensors. % % See also SPTENSOR/PERMUTE. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www.sandia.gov/~tgkolda/TensorToolbox. % Copyright (2015) Sandia Corporat...
16df52fb0fdf51960ebb0437a545b9636431586fbc1f4667212c70adb73ba913
MATLAB
666
37
function varargout = drawarena(varargin) if length(varargin) >= 1&& isstruct(varargin{1}), r = varargin{1}.r; x = varargin{1}.x; y = varargin{1}.y; varargin = varargin(2:end); else if length(varargin) >= 1 && ~isstr(varargin{1}), r = varargin{1}; varargin = varargin(2:end); else, r = 500; end; if lengt...
20d7e8412d338054422c94ef352d8e26577089fae58ebf4fd2aebdf7b43dfff9
MATLAB
666
34
function [tffound,f] = seekBigLpos(lpos,f0,df,iTgt) % lpos: [npts x d x nfrm x ntgt] % f0: starting frame % df: frame increment % iTgt: target of interest % % tffound: logical % f: first frame encountered with (non-nan) label, applicable if % tffound==true if isempty(lpos), tffound = false; ...
53c2ac53e74907470fcde9fdca9d8d1f8c2a7ba64a5500c4754e1a77e9161f9d
MATLAB
666
29
% RSKELF_MV_P Dispatch for RSKELF_MV with F.SYMM = 'P'. function X = rskelf_mv_p(F,X,mode) % initialize n = F.lvp(end); % upward sweep if bitget(mode,1) for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; X(sk,:) = X(sk,:) + F.factors(i).T*X(rd,:); X(rd,:) = F.factors(i).L'*X...
63c53af3ef7463857237ecaa5f2d76060018eb71f8f0b3bc5f515f07db1a76e3
MATLAB
666
28
%% Illustration of a piecewise linear surface % %% % This file is from pmtk3.googlecode.com setSeed(10); figure(); hold on; nsurfaces = 3; for i=1:nsurfaces x = randn(10, 1); y = randn(10, 1); z = randn(10, 1); P = [mean(x), mean(y), mean(z)]; [U, S, V] = svd([x-P(1), y-P(2), z-P(3)], 0); N =...
a755abb572e670b95778971706cc2d06cc065d8e458c514b1e414494c7a0cda4
MATLAB
666
31
disp('Pipeline_A_ImportData') Pipeline_A_ImportData % Insert ID of the procedure IdProcedure = 99 ; % Good Parameters for SOM Parametrization num_runs = 100 ; som_dims = [ 2 2 ]; epoch_values = 100 ; % % % % % USED FOR PRETRAINING (FINE TUNING) % % % % % som_dims = [2 2; 3 3; 4 4; 5 5; 6 6 ; 7 7; 8 8; 9...
c3c1560ad126c4a0f56134e740d96fb3d4f9737510425ae8280706187e50ec11
MATLAB
666
31
function update_showmri(hh,vals,col_limits,mythresh); colmin=col_limits(1); colmax=col_limits(2); np=length(hh); c=hot; nc=length(c); icol=ceil((vals-colmin)/(colmax-colmin)*(nc-1)+eps); icolb=min([icol';repmat(nc,1,np)]); icolc=max([icolb;repmat(1,1,np)])'; for i=1:np; %icol=ceil((vals(i,:)-colmin)/(colmax-c...
f0b3111608e76ad5d6f848e8f4ba9b0ace32626a6bc4db0ea399627322a47fe2
MATLAB
666
29
% RSKELF_SV_P Dispatch for RSKELF_SV with F.SYMM = 'P'. function X = rskelf_sv_p(F,X,mode) % initialize n = F.lvp(end); % upward sweep if bitget(mode,1) for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; X(rd,:) = X(rd,:) - F.factors(i).T'*X(sk,:); X(rd,:) = F.factors(i).L\X...
0d902385c0c6e2826561a1903a9697704058fed0ee1da4669e8500b644dc45e2
MATLAB
667
23
% QMAP_SQTRI2 Convert a quadrature on the unit square to one on a triangle in % reference configuration. % % [X,Y,W] = QMAP_SQTRI2(X0,Y0,W0,V2,V3) produces quadrature nodes and weights % [X,Y] and W, respectively, on the triangle with vertices [0; 0], [V2; 0], % and V3 by mapping from a quadratur...
c8785c36a3276fe3fe964a20af34831a7de693d181480bc57e7fb5e8bb28f6ee
MATLAB
667
18
% List of open inputs % CAT12: Segmentation: Volumes - cfg_files % Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md addpath(spm_dir) nrun = 1; % enter the number of runs here jobfile = {[script_dir '/CBIG_MMLDA_segment_job.m']}; jobs = repmat(jobfile, 1, nrun...
0bbb151fc14d2829bee6c065a221442e80c9df5f7c47aaeb26f63ddf7ddb1a1b
MATLAB
668
22
function [Mean_Out, STD_Out, SEM_Out, CV_Out, Num_Out]=Mean_STD_SEM_CV(InputData) InputData(InputData==Inf)=NaN; if any(isnan(InputData(:))) Mean_Out=nanmean(InputData); STD_Out=nanstd(InputData); Num_Out=sum(~isnan(InputData)); SEM_Out=STD_Out./sqrt(Num_Out); ...
7d09ab556d522dc39f65e03dd7715fbedd843c18695a3ebd89ae4699e1cd0621
MATLAB
668
24
function rms = movingrms(y, win, fs, varargin) % function to calculate a moving rms of signal y. % INPUT: - y: vector or matrix to rms % - win: window in seconds % - fs: the sampling frequency of signal % - dim (optional): dimension along which to calculate rms; default % is 1. % OUTPUT:...
9b8de71e99ace3d9e05aa7a490ac26c917438938f5002de8869dfa2d52566125
MATLAB
668
10
function nc_spm_deform_using_y_file(infile, y_file, voxsize, interpolation) SPMJOB.matlabbatch{1}.spm.spatial.normalise.write.subj.def = {y_file}; SPMJOB.matlabbatch{1}.spm.spatial.normalise.write.subj.resample = {[infile, ',1']}; SPMJOB.matlabbatch{1}.spm.spatial.normalise.write.woptions.bb = [-90 -126 -72 ...
631ebc2c479e3bd1840cfc6cc58f1521b6b16e909fa5894a9a1377c37f06b610
MATLAB
669
35
function [nll,g,H,T] = LogisticLoss(w,X,y) % w(feature,1) % X(instance,feature) % y(instance,1) [n,p] = size(X); Xw = X*w; yXw = y.*Xw; nll = sum(mylogsumexp([zeros(n,1) -yXw])); if nargout > 1 if nargout > 2 sig = 1./(1+exp(-yXw)); g = -X.'*(y.*(1-sig)); else g = -X...
7a91ea871f353575b38b45a1b680f7c70fa3ca9121cdaeb653d482eb8d00f9b0
MATLAB
669
32
function StatVal=w_PToStat(P, StatOpt) TestFlag=StatOpt.TestFlag; if isempty(TestFlag) StatVal=[]; end if isfield(StatOpt, 'Df') Df1=StatOpt.Df; end if isfield(StatOpt, 'Df2') Df2=StatOpt.Df2; end if StatOpt.TailedFlag==1 Scale=1; elseif StatOpt.TailedFlag==2 Scale=2; else error('Invalid Tailed...
8e72b7f19644985ea5ed88dc0cda3f54e54b8af3e71e07961f161372645a6362
MATLAB
669
27
function maskUnmask(self,src,~) if self.verbosity > 9 disp(mfilename) end if isempty(self.channel_to_work_with) return end if src == self.handles.mask_all_control self.mask(:,self.channel_to_work_with) = 0; elseif src == self.handles.unmask_all_control self.mask(:,self.channel_to_work_with) = 1; elseif src ==...
c56b8b5cd727eea95adb9556318a16e7b4dfe070e42a182b8d732a1d1db602b2
MATLAB
669
25
function pAdjusted = HolmBonferroni(p, alpha) if nargin < 2 alpha = 0.05; end % Sort and iterate p_vec = p(:); [p_sorted,sort_idx] = sort(p_vec); current_multiplier = sum(~isnan(p_vec)); pAdjusted = ones([length(p_vec), 1]); for i = 1:length(p_vec) pAdjusted(i) = p_s...
1b678b2a84e5412872f66dcbe411552241d3672369d099201424f912ddd76085
MATLAB
670
25
% _ _ % ___ _ __ __ _| |__ ___ ___ _ __| |_ % / __| '__/ _` | '_ \/ __|/ _ \| '__| __| % | (__| | | (_| | |_) \__ \ (_) | | | |_ % \___|_| \__,_|_.__/|___/\___/|_| \__| % % this is a plugin for crabsort.m % computes the PCA on the spike shape, and then uses the top 2 ...
21b5b0a58e1e89e2ae45812c04c739ace18794b94a868c5644a3a78691abbe69
MATLAB
670
25
function h1 = JoinUpErrorPoints(h, toJoin, plotargs) % function h = JoinUpErrorPoints(h, toJoin) % Join up pairs of errorbarplot points with lines % % Inputs: % h: errorBarPlot handles for lines % toJoin: matrix of pairs of points to join up [n x 2] % plotargs: cell array of name-value pairs to pass into plot() ...
8dd52ccaae9c2ee38dd5fc60ad6af71b932feaa2e4bf12f7fa282114d30d37ea
MATLAB
670
25
function saveTifSequence(imgvol, outputDirectory) %SAVE3DTif: Save a 3D volume into an image sequence. To be used in the %case of the vol being too big to be loaded as a single 3D tif %set the minimum to zero imgvol = imgvol - min(min(min(imgvol))); %set the max to max uint16 img...
c7a1968cdbd401dd44d91f8a13b15cc5ee636914d29f036c4c65ee888718acc5
MATLAB
670
28
% 2024-09-16: voxel-wise dictionary lookup function using dot product % matching % Inputs: x - signal vector over 3 echoes % b1 - relative B1 value of voxel % dict = struct containing dictionary, made by dict_create.m % Shaihan Malik, King's College London, 2024 function [t2,s0] = dict_match(x,b1...
d6da0d6778e3eb9d39df6ca87e196e6028683c71518e7184675562dc8892fcca
MATLAB
670
26
function options = TMapperOpts(k, resolution, gain, verbose) % Not implemented yet assert(false, "Not implemented yet") if nargin < 4 verbose = false; end options = struct; options.verbose=verbose; options.preprocess_type = 'none'; options.dist_type = 'euclidean'; options.prelens_type = 'wtd-pen'; options.prelens...
11d126d5f49fc70fc92a48aa93e2f5af9e94cf96aefe3e1fbd177cfc68dc0d80
MATLAB
671
26
function [p,pt] = permtest(x1,x2,n) if ((size(x1) ~= size(x2)) | (x1 == x2)) p = NaN; pt = NaN; return; end diffs = zeros(n,1); for i = 1:n x = [x1 x2]; sel = randi(2,length(x1),1); xt1 = zeros(length(x1),1); xt2 = zeros(length(x2),1); ...
2ec6ee90c21c26f8db49b31cf74367aaccfb8dd23d35064ffb6fbe996e934a81
MATLAB
671
20
function n = nnz(a) %NNZ Return number of nonzeros in a sptenmat. % % nnz(A) returns the number of nonzeros in A. % % See also SPTENMAT. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www.sandia.gov/~tgkolda/TensorToolb...
33795fb085bce0a0ee837d83bb6bc99e728b8544caf05800154810731b1d2f23
MATLAB
671
23
function maxLambda = groupLassoMaxLambda(groups, X, y) % Find the largest regularizer that drives all params to 0 % This is given by % max_groups sqrt( sum_{i in g} gradient(g,i)^2 ) % where the gradient is evaluated at the all 0s weight vector. % We exclude group 0 (representing the unregularized terms) % This file...
3fcee72ad562a6981b9e662a630346ed35fb131749bda8de7294c434380fd08b
MATLAB
671
27
function p = circ_iqr(alpha) % CIRC_IQR - estimates the interquartile range of circular data % % INPUT & OUTPUT % ------------- % alpha - input data (in radians, not binned) % p - estimated iqr % % METHOD % ------------- % For normal distributions IQR can be estimated from the % standard deviation of the sample, s...
7244544ca2a14aaa094810d40e55c7e701a1348ad346ee1f73e05179863e7593
MATLAB
671
32
function logp = gaussInvWishartLogprobBayes(arg1, arg2, arg3, arg4, arg5) % logp(i) = int_S log p(X(i, :) | model) % logp = gaussInvWishartLogprobBayes(model, X) OR % logp = gaussInvWishartLogprobBayes(mu, Sigma, dof, k, X) %% % This file is from pmtk3.googlecode.com if isstruct(arg1) model = arg1; X = arg2; ...
76eb4a945cb43d4860254e45e356c04f05f2f295283a5426654b286e0957e72a
MATLAB
671
27
function [B,src_indices,dest_indices]=noncircshift(A,offsets) %Like circshift, but shifts are not circulant. Missing data are filled with %zeros. % % [B,src_indices,dest_indices]=noncirchift(A,offsets) % %B is the resulting array and the other outputs are such that % % B(dest_indices{:})=A(src_indices{:}) siz=size(A)...
7ed4db9d89fb49c334b574f7345db6b8ea83328259faa94b18f423e485224192
MATLAB
671
16
function [p,Z]=HumanOdorRep_two_proportion_ztest(n1pos, n1, n2pos, n2) % function [p,Z]=HumanOdorRep_two_proportion_ztest(n1pos, n1, n2pos, n2) % calculate two-proportion z-test % %----------------------------------------------------------------------------------------- % Kehl et al. 2024 (DOI:XX) % Single-Neuron Repre...
2f2a1e889e99ed989459d34537d570e87927e1554086c8fa7773ae6b2bab2398
MATLAB
672
27
% HIFDE_MV_NN Dispatch for HIFDE_MV with F.SYMM = 'N' and TRANS = 'N'. function X = hifde_mv_nn(F,X) % initialize n = F.lvp(end); % upward sweep for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; T = F.factors(i).T; if ~isempty(T), X(sk,:) = X(sk,:) + T*X(rd,:); end X(rd,:) = F.fact...
57ef8d4fc79f437bb5f965f335d6fbb76dcb220f11f24837dd722a3a69570804
MATLAB
672
24
% INPUTS: % run_num_list is the index list of the experiment for the specified sample function success_code = batch_memory_errors() % get max_jobs loadParameters; run_num_list = [1] run_num_list_size = length(run_num_list); max_jobs = run_num_list_size; arg_list = {}; postfix_list = {}; ...
6c763f7a96f7c927f37d6a869a25158ca030cd69a22c26256e1b077bd3e2da05
MATLAB
672
18
function Dlocal=jacobiandet_transform_2d_double(Ox,Oy,Isize,dx,dy) % Determinant of the Jacobian of the transformation grid % % [Iout,Tx,Ty]=bspline_transform_2d_double(Ox,Oy,Isize,dx,dy) % % Inputs, % Ox, Oy : are the grid points coordinates % Isize : The size of the input image [m n] or in 3d [m n k] %...
7abfcc9e340653b683ba020c08bbafac8e0d597708bbf26e6fa00c0d88c88b7b
MATLAB
672
29
%% Simple test of hmmFit with tied mix Gauss observations % %% % This file is from pmtk3.googlecode.com loadData('speechDataDigits4And5'); data = [train4'; train5']; d = 13; nstates = 2; nmix = 3; % must specify nmix model = hmmFit(data, nstates, 'mixGaussTied', 'verbose', true, ... 'nRandomRestarts', 2, 'ma...
818eac42264b2eb83b4cc87561d42490eb3fa1992ea64768d82859a76b3bc776
MATLAB
672
31
function d = mahalsqrt(C,P) if ndims(C) == 3 n = size(C,2); d = zeros(1,n); for i = 1:n d(i) = mahal_internal(squeeze(C(:,i,:)),nanmean(squeeze(P(:,i,:)),1)); end else d = mahal_internal(C,P); end end function d = mahal_internal(C,P) [C,P] = eliminate...
8c40f458072857b0233e1a5e1e1fc9638ef9fbe446b3eed204e3b1e2ca9db6f7
MATLAB
672
27
% HIFDE_SV_NN Dispatch for HIFDE_SV with F.SYMM = 'N' and TRANS = 'N'. function X = hifde_sv_nn(F,X) % initialize n = F.lvp(end); % upward sweep for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; T = F.factors(i).T; if ~isempty(T), X(rd,:) = X(rd,:) - T'*X(sk,:); end X(rd,:) = F.fac...
acc8b26ab57053c7672d344de530584c4981756ad50807346b3a68d15a590bd2
MATLAB
672
29
%% Demonstrate perfect elimination ordering % Based on Lauritzen's Saint-Flour notes 2006 %% Non-chordal Example from Fig 3.6 % This file is from pmtk3.googlecode.com G = zeros(7,7); G(1,[2 3 4])=1; G(2,[1 3 6])=1; G(3,[1 2 4 5 7])=1; G(4,[1 3 5])=1; G(5,[3 4])=1; G(6,[2 7])=1; G(7,[6 3])=1; assert(isequal(G,G')); %...
eac9fe618894ab02553c63115d6a19ed9ed855f6187a1d8f7541a1728b3df555
MATLAB
672
29
% general_settings for LIP single trial paper xLimsSL = [0 0.6]; xLimsRL = [-0.3 0.1]; xLimsView = [0 0.4]; fontSize = 6; sFont=6; colorsYeBl = {{[102 51 0]/255, [204 102 0]/255, [255 128 0]/255,... [255 178 102]/255, [255 229 204]/255, 0.6118*[1 1 1]},... {[0 51 102]/255, [0 102 204]/255, [...
1291ac08af06239f40fd56640633f081d9b19326ec5fe4ce697fa9fc01d8fee0
MATLAB
673
1
function R=simple_egfit(data) % version 2.1 26/02/07 % (c) Yves Lacouture, Universite Laval tau=std(data).*0.8; % reasonable starting value for tau mu=mean(data)-tau; % reasonable starting value for mu sig=sqrt(var(data)-(tau^2)); % reasonable starting value for sig pinit = [mu sig tau]; ...
24af2d4739b8af1f488e0fe485126b44a40dd507fcc1946ab86692b741f2c30e
MATLAB
673
28
function [fx,dF_dX,dF_dTheta] = f_Lorenz(Xt,Theta,ut,inF) % Lorenz chaotic evolution function deltat = inF.deltat; x = Xt; rho = Theta(1); sigma = Theta(2); beta = Theta(3); fx = zeros(3,1); fx(1) = sigma.*(x(2)-x(1)); fx(2) = x(1).*(rho-x(3))-x(2); fx(3) = x(1).*x(2) - beta.*x(3); fx ...
2a3fbecae7c65a86b03723f09c1f4aba6271f66c04b3cffcf6c63a14cf72e789
MATLAB
673
27
% HIFDE_MV_SN Dispatch for HIFDE_MV with F.SYMM = 'S' and TRANS = 'N'. function X = hifde_mv_sn(F,X) % initialize n = F.lvp(end); % upward sweep for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; T = F.factors(i).T; if ~isempty(T), X(sk,:) = X(sk,:) + T*X(rd,:); end X(rd,:) = F.fact...
9070197a1b0d986003e45270f1bdc71e967538a342c290ca52d49376892b1073
MATLAB
673
24
function M = classConfMat(ytrue, yhat) % Make a class confusion matrix % M(truth, est) = num times truth gets labeled as est % result is an array with starting index of 1, so you have to figure out % labels separately. It will do all possible integer classes, i.e. if you % have two classes 1 and 1000 don't use this fun...
bb9a9a32d7fe8bfbbbc71d3b75978a2f24838e05b47c5d071aecf7d7286f5793
MATLAB
673
20
figure('color', [1, 1, 1], 'position', [360 50 600 400]); hold on; rgb = [112 112 112; 26 127 187]/255; nUnits = nan(2,2); for iArea = 1: 2 nUnits(iArea,1) = size(this_roc{iArea,1},1); mean_roc = mean(this_roc{iArea,1},1); h(iArea)=plot(rocaxis, mean_roc, 'Color',rgb(iArea,:),'LineWidth',10); ...
d94f3ed0e6db8042152b511203f33e06d4dfbe3c65acf13a95ad1f77f33b15c1
MATLAB
673
31
function SymbolicCopyStephenData(srcdir,destdir,varargin) [regexpexclude] = myparse(varargin,'regexpexclude',{}); [~,n] = myfileparts(srcdir); destdir1 = fullfile(destdir,n); if ~exist(destdir1,'dir'), mkdir(destdir1); end [fs,infos] = mydir(srcdir); for i = 1:numel(fs), if ~infos(i).isdir, [~,n] = myfilepa...
e787c34a0c2cf14376ff4d7f0385e0c6f8700780ac6ca780a7ba175fcfbfa914
MATLAB
673
27
% HIFDE_SV_SN Dispatch for HIFDE_SV with F.SYMM = 'S' and TRANS = 'N'. function X = hifde_sv_sn(F,X) % initialize n = F.lvp(end); % upward sweep for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; T = F.factors(i).T; if ~isempty(T), X(rd,:) = X(rd,:) - T.'*X(sk,:); end X(rd,:) = F.fa...
f5b98bd1405b5f63b7b680c88dbea8af0b0012603d962297b63d66fdd1f6fbb3
MATLAB
673
14
% Can we detect differential expression between genes? seed = 0; randn('state', seed); rand('state', seed); ngenes = 100; nsamples = 2; mu1 = 0; s1 = 1; mu2 = 5; s2 = 1; %ndx = 1:floor(ngenes/2); ndx = find(rand(1,ngenes) > 0.5); truth = zeros(1,ngenes); truth(ndx) = 1; % these entries are differentially expressed Xc...
f6e17ff04d35dddf0f12435c44f6e30e3cd3a9000e96d9f19a70b158d2e05c55
MATLAB
674
15
%both finds the keys and converts them within the bounds of the tile %by subtracting the y_min and x_min, which is necessary for transform calcs function relevant_keys = findRelevantKeys(keys, y_min, y_max,x_min,x_max) relevant_keys = {}; relevant_ctr = 1; for idx=1:length(keys) if keys{idx}.y>=y_min &&...
70d947d885548d8923d8789259484f516410544638a2253b9ca8374cd19b5e47
MATLAB
675
30
function s = structsetleaf(s,sset,varargin) % Set values for leaves of nested struct % % s: scalar struct (typically nested) % sset: scalar struct with fields/vals to replace % % structsetleaf recursively sets all leaf nodes matching fields of sset to % their corresponding new values. verbose = myparse(varargin,......
81b27da73ea3ada2b5c78912eccfa2b986086d71ba7c73397888d6ed07dfbaa1
MATLAB
675
12
J = load('~/bransonlab/PoseTF/headTracking/FlyHeadStephenCuratedData.mat'); for ndx = 1:numel(J.vid1files), J.vid1files{ndx} = ['/groups/branson/bransonlab/mayank/' J.vid1files{ndx}(19:end)]; J.expdirs{ndx} = ['/groups/branson/bransonlab/mayank/' J.expdirs{ndx}(19:end)]; J.vid2files{ndx} = ['/groups/branson/bransonlab/...
b11ff4de20903b00351f53e8c5ed78de5846f5dafe4f0c80af8e2ff8ffb4fa3a
MATLAB
675
20
function n = ndims(t) %NDIMS Number of dimensions for a ktensor. % % NDIMS(T) returns the number of dimensions of tensor T. % % See also KTENSOR % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www.sandia.gov/~tgkolda/Ten...
e8243353d6000eaeed9eb344c1fcca691098e4baa01bd3ebc3035f41ed7d8f9a
MATLAB
675
36
function LAN = mean_freq(LAN,dim) % v.1.0.1 24.11.2009 % % LAN = ; signal with fields 'freq' in cell {trail x elect} with matrix [freq x time] % dim = ; dimention of outcome % if dim = 3 ; matrix 3d [freq x time x elect] % if dim ~= 3 ; cell 1d {1, elect} with matrix 2d [freq x time] % % % P.Bill...
3b079c2bd2676a12ac053a885a855ba1487fd45d7715202a62d9eddb28365309
MATLAB
676
19
% Sequentially compute N best list for an HMM % See "Sequentially finding the N-Best List in Hidden Markov Models" % Nilsson and Goldberger, IJCAI 2001 % We do the example in sec 3.2 %PMTKinprogress initDist = [0.6; 0.4]; transmat = [0.6 0.4; 0.2 0.8]; obsmat = [0.9 0.1; 0.3 0.7]; y = [1 1 2 2 2 2 1 1 2 2]; % n=1, y=...
8c45947c301bbf5e6567f33de9430d08b506f7c9b91f2adecd22d559dd525613
MATLAB
676
21
function a = tt_subsubsref(obj,s) %TT_SUBSUBSREF Helper function for tensor toolbox subsref. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www.sandia.gov/~tgkolda/TensorToolbox. % Copyright (2015) Sandia Corporation. Under...
940deca26fea6548fa0d6ae087f270fc15b4f46a858395f304b98e1a00d125a7
MATLAB
676
25
function h_openGroup3(handles, filename) global h_img3; [currentInd, handles, currentStruct, currentStructName] = h_getCurrendInd3(handles); [pname, fname, fExt] = fileparts(filename); if isempty(pname) pname = pwd; end % try if exist(filename, 'file') load(filename,'-mat'); ...
9d7e41b4a4c996cf206b068c3926ce4e6a4dca8197927d749c4d8f6a4af4cf90
MATLAB
676
27
% HIFDE_MV_NC Dispatch for HIFDE_MV with F.SYMM = 'N' and TRANS = 'C'. function X = hifde_mv_nc(F,X) % initialize n = F.lvp(end); % upward sweep for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; T = F.factors(i).T; if ~isempty(T), X(sk,:) = X(sk,:) + T*X(rd,:); end X(rd,:) = F.fact...
140fb6e2544f4e2b4cd39e4c0c1c4cf69b6667853cd46aac80acd02c6dcdd7a7
MATLAB
677
26
function [ax, b, p] = plotExplainedVar(explained) %PLOTEXPLAINEDVAR Pretty plot PCA explained variance. % Usage: % plotExplainedVar(explained) % [ax, b, p] = plotExplainedVar(explained) % % See also: pareto2, plotyy if isstruct(explained) && isfield(explained,'explained'); explained = explained.explained; end [ax...
2a66c536fed181df41e6b560693fb4fc3bf71aa8e9c8045292f96d5305178c83
MATLAB
677
15
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% f4_load_forward_data.m %%% %%% Load the forward data associated to a dipole if it exists %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear Ptot; try...
340b3ce7ed90a71d42c0875a930a0217b30aaed66b68b6cadb9ef7dfe720f07e
MATLAB
677
35
function Name = TSeventname(EventNumber) % finds the name for an event, given its numerical code. In other words, % this function reads the event code dictionary backwards. This is useful % when troubleshooting % % syntax: Name = TSeventname(EventNumber) % or: TSeventname(EventNumber) global Experiment Name = 'not fo...
48edd98d497101f75d6ffb5159ec04657734ef028a59d02ffdce6351274f2b30
MATLAB
677
26
function padded = insertUnitBels(nodeBels, visVars, hidVars) % We insert unit factors for the clamped vars to maintain a one-to-one % corresponence between cell array position and domain, and to return % consistent results regardless of the inference method. % This file is from pmtk3.googlecode.com if isempty(visVars...
64abb72c7b26ee1516a1613dec2845f40f33b50b4739a5b6f3c58e96c930364b
MATLAB
677
36
function S = discreteSample(arg1, n) %% Sample from a discrete distribution % % S = discreteSample(model, n); OR % S = discreteSample(T, n); % % T is of size K-by-d where K is the number of states and d is the number % of distributions; n is the number of samples. Each *column* of T sums to % one. % % model, if spe...
722b0f7b7be0b0f0def57b7e5b1eae337ee3a0cbac38d519ddd356bb194e61db
MATLAB
677
25
function facs = addEvidenceToFactors(facs, evidence, doSlice) %% Slice (or clamp) multiple factors according to a sparse observation vector % % This file is from pmtk3.googlecode.com if nargin < 3, doSlice = true; end if doSlice fn = @tabularFactorSlice; else fn = @tabularFactorClamp; end if isempty(evidence...
53bc759cbb19d659169cb65c915efb4d9f537e7a735162a06f8a96ec4078fa8a
MATLAB
678
29
% succeeded = save_tracks(trx,matname,...) % optional arguments: % 'doappend' = false % 'varname' = trx function succeeded = save_tracks(trx,matname,varargin) [doappend,varname,timestamps] = myparse(varargin,'doappend',false,'varname','trx','timestamps',[]); succeeded = false; if isfield(trx,'f2i'), trx = rmfield(...
7e5c4f8c918f0c18f3fc9a784582c51a4ab66c938ccd2406ad779f396b146803
MATLAB
678
25
function lc = GetTDRcmap(settings,flp) if any(settings==[1 2 9:12 13:16]) lc = redblue(7); else lc = parula(8); lc(1,:) = []; for kk = 1:3 lc(kk,:) = GetShade(lc(kk,:),[1 1 1],kk,5); lc(7-kk,:) = GetShade(lc(7-kk,:),[1 1 1],kk,5); end end if flp==1;lc(1:4,:) = [];end % if any(s...
b65f69b9022a9fb7578c2f9a1ae4217b3dd444e67310d814e553d274b8330683
MATLAB
678
28
function str = printor(strs, quote) % PRINTOR prints a single or mutiple strings as "x1, x2, x3 or x4". If there is % only one string, that string is returned without additional formatting. % % See also PRINTAND if nargin<2 quote = false; end if quote if numel(strs)>2 str = sprintf('''%s'', ', strs{1:(end-2)...
be459362aa9912ad3146bf47ca3bcb062761b95c5a50a4b3b9e3c402e32d2995
MATLAB
678
28
function matches = dir_regex(path, expression, return_paths) %DIR_REGEX Returns contents in the path matching a regular expression. % Usage: % matches = dir_regex(path, expression) % matches = dir_regex(path, expression, true) % returns full paths % % See also: regexp, dir_ext, dir_paths % Default: returns just fi...
4ee8d1c6fe1246d9f42f9b915cae04314cfdbc624d8f9d866077acb18f268e6a
MATLAB
679
24
function Y = SimPopData(Xsamp,BB,d, n,T,N) % Function for generating observations from the BTDR model. % INPUTS: % Xsamp = [N x P] matrix of regressors on each trial % BB = [P x 1] cell array where each element is a n x T matrix of coefs % d = [n x 1] vector of noise variances for each neuron % n = number ...
592808daf653f047e2f0c9d9bae6352bf35e6b66621a0a7c698a6ccae94dbf14
MATLAB
679
28
% HIFDE_MV_H Dispatch for HIFDE_MV with F.SYMM = 'H'. function X = hifde_mv_h(F,X) % initialize n = F.lvp(end); % upward sweep for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; T = F.factors(i).T; if ~isempty(T), X(sk,:) = X(sk,:) + T*X(rd,:); end X(rd,:) = F.factors(i).L'*X(rd,:)...
a97e99cb9cf64a3290c0f9fbce830dc52afd8d9fb8255688fd778721a5529518
MATLAB
679
28
% HIFDE_SV_H Dispatch for HIFDE_SV with F.SYMM = 'H'. function X = hifde_sv_h(F,X) % initialize n = F.lvp(end); % upward sweep for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; T = F.factors(i).T; if ~isempty(T), X(rd,:) = X(rd,:) - T'*X(sk,:); end X(rd,:) = F.factors(i).L\X(rd,:)...
bab472cbcdf982d6ceaeaf302d7a071b54501b5e4fdd60736ee2b961e91f2b13
MATLAB
679
14
figure('color', [1 1 1]); % requires distributionPlot https://www.mathworks.com/matlabcentral/fileexchange/23661-violin-plots-for-plotting-multiple-distributions-distributionplot-m distributionPlot([fef_accuracies(:,1), lip_accuracies(:,1), fef_accuracies(:,2), lip_accuracies(:,2)],'color',[.6 .6 .6],'showMM', 2),hol...
d69207b56ebd9d37b7abe0763aef67b1dcf35124d4941d299770f6ba12689179
MATLAB
679
21
classdef FrameDecimationVariable < FrameDecimation properties getDecimationHookFcn % function with sig dec = getDecimationHookFcn(lObj) end methods function obj = FrameDecimationVariable(fcn) obj.getDecimationHookFcn = fcn; end function dec = getDecimation(obj,labelerObj) assert(isst...
2e2612186e00d676c8b53c505f27398deb64f22e3c26a33e153ecdbd3843bac0
MATLAB
680
35
function varargout = scl_slope(varargin) % Format % For getting the value % dat = scl_slope(obj) % % For setting the value % obj = scl_slope(obj,dat) % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id$ if nargin==2, varar...
84cdf35469f931cc53da7444124601f37a815428252fc017224263ace1ac986e
MATLAB
680
26
dataMatrix = synapseAnalysisData.dataMatrix; xCoordinates = synapseAnalysisData.xCoordinates; yCoordinates = synapseAnalysisData.yCoordinates; dataDim = size(dataMatrix); numSynapses = dataDim(1); numImagingDays = dataDim(2); global h_img3 for i = 1:numImagingDays iterInstance = ['I' num2str(i)]; caxes =...
9d4b99cf084e8f2ec8f722684b6e6044dd956cfab652430f6d8eac01d2acf1c8
MATLAB
680
22
function [bool_int, d, coords] = ut_RayIntersect(point, dir, P, t) % using metres does not seem to work, probably because of some % tolerance parameters in TriangleRayIntersection % We convert everything to mm, and then reconvert pp = repmat(1e3*point,size(t,1),1); dd = repmat(dir, size(t,1),1); ...