sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
d86d62c089b649b7437da917a9525acbffb0cdfa6ae1985f5237ffc70f9eeda0
MATLAB
701
22
function nrm = norm(T) %NORM Frobenius norm of a sptenmat. % % NORM(T) returns the Frobenius norm of a matricized sparse tensor. % % See also SPTENMAT, NORM. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www.sandia.gov...
0954722e95206ea9dc1a6fcb6a34ca5876172fdddc311a562461ed4dbc245bc0
MATLAB
702
29
% RSKELF_MV_NC Dispatch for RSKELF_MV with F.SYMM = 'N' and TRANS = 'C'. function X = rskelf_mv_nc(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,:) =...
8f4687cb09b13a8ac177aff133a7cf99e4bdac6c4c8f0345345cb6b96a1f7cc4
MATLAB
702
31
%% Compare PMTK ridge with stats toolbox % PMTKneedsStatsToolbox ridge %% % This file is from pmtk3.googlecode.com requireStatsToolbox X = loadData('caterpillar'); % from http://www.ceremade.dauphine.fr/~xian/BCS/caterpillar y = log(X(:,11)); % log number of nests X = X(:,1:10); [n,d] = size(X); %% MLE [model] = li...
f702bafb44bc8b45d78acc3360cb17f8b6bbe7db6de68c7f5a9d3c775397704c
MATLAB
702
29
% RSKELF_SV_NC Dispatch for RSKELF_SV with F.SYMM = 'N' and TRANS = 'C'. function X = rskelf_sv_nc(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,:) ...
076b15cad3fd61a3d72831c7362e0c207628ae430b04cde0699b7449cc3feccc
MATLAB
703
28
function [resVal,idx, count] = findWithinInterval(value, range, col) narginchk(2,3); if nargin < 3 col = 1; end if size(range, 2) ~= 2 range = range'; end if size(range, 1) == 1 if ~isempty(value) idx = find(value(:, col)>=range(1) & value(:, col)<=range(2)); resVal = value(idx,...
28c1b7c05428bc124caf4198dc1cc84b58d13ae47ffc77ed03c78bc6dbfb81fb
MATLAB
703
34
function distance = emd(p, q) % distance = utils.emd(p, q) % % Earth mover's distance between probability distributions p and q % AKA Wasserstein distance % %% Checks % Check if the probability distributions have the same length if length(p) ~= length(q) error('Probability distributions must have the same length....
4344fe4e9d17633967f50630dadf5ef9469c0b3dcbda5565443311b66f4f7571
MATLAB
703
18
function [count,idx]=zerocross_count(data) %Computes the zero-crossing number %Written by Su Liu s = size(data); % size of matrix v l = s(1); % Number of row of matrix v for m=1:l x = data(m,:); % Method, eliminating the defects of precedent code x_sign= sign(x); ...
46e78d0abb97e4f09dad75d45c9473ed90aac080c34f95af331584ce10c813a3
MATLAB
703
36
function [ status ] = encodeH264( target, varargin ) %encodeH264 - Transcode the .avi video given in `target` into .mp4 % % Requires ffmpeg. % % Simeon Wong % 2014 June 18 %% Parse Parameters p = inputParser; addOptional(p, 'qp', 25); addOptional(p, 'savepath', []); parse(p, varargin{:}); if isempty(p...
4e8be72ad62d042526fec894137b14951b56011f25f76642b9c905b7e23c3e70
MATLAB
703
37
function [spacecorr,evsource,evcomp]=V2eigs(patt,V); [nchan,npat]=size(patt); [nchan,ng,ndum]=size(V); np=min([ndum npat]); [u_p,s_p,v_p]=svd(patt); o_patt=v_p*inv(s_p(1:npat,:)); spacecorr=zeros(ng,np); evsource=zeros(ng,ndum,np); evcomp=zeros(ng,npat,np); for i=1:ng; Vloc=squeeze(V(:,i,:)); [u_V,s_V,v_V]=sv...
3faa90540dc9e36fdb6684780e8b4a576e1c8c959f7603f10e3418058393b9ea
MATLAB
704
20
function display(t) %DISPLAY Command window display for a ktensor. % % DISPLAY(T) displays a Kruskal tensor with its name. % % See also DISPLAY, KTENSOR/DISP, KTENSOR. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www....
7149d7d0f8d15ba8f64b6de10370727264612ea80964be2e64aacb780ef38c68
MATLAB
704
26
function l = rotate_start_label(start_pos_label,angle) % CCW rotation -> angle > 0 % CW rotation -> angle < 0 R = func.rotation_mat(angle); if strcmpi(start_pos_label,'N') v = [0;1]; elseif strcmpi(start_pos_label,'S') v = [0;-1]; elseif strcmpi(start_pos_label,'W') v = [-1;0]; ...
bea7efcb5224a56f336c937e7dc013442664657e9c2bcc040c210d68f6bab8fb
MATLAB
704
41
function [Sx,dsdx,dsdp] = sigm(x,in,Phi) % legacy code s = warning ('on'); warning ('*** The function `sigm` is now deprecated. Please see `VBA_sigmoid` for an alternative.') warning (s); % fallback if nargin < 2 in = struct (); end if nargin < 3 Phi = []; end if isfield(in, 'G0') in.scale = in.G0; ...
c23327cb47ad1766e71e2a2d0060ea3f2e463c0eb52919d243e62b80b8c268d8
MATLAB
704
19
function mscmd_fit_stage(timeseries_in_path,firings_in_path,firings_out_path,opts) if (nargin<4) opts=struct; end; if (~isfield(opts,'clip_size')) opts.clip_size=100; end; if (~isfield(opts,'neglogprior')) opts.neglogprior=30; end; cmd=sprintf('%s fit_stage --timeseries=%s --firings=%s --firings_out=%s --use_old=0 -...
da112096378c436d706e6e7be7f81d38c22b0703dc32192e870f3ec819f386e3
MATLAB
704
11
% GEOMETRY % % Files % dmat_transpose_print - prints a double precision matrix, transposed. % dmat_transpose_print_some - prints some of a double precision matrix, transposed. % dvec_print - prints a real vector. % line_exp_is_degenerate_nd - finds if an e...
f0c77d4cfc265c27a3bbbd0e2deb237594e8dc8fe10b1b769ff0136bcf5d27d8
MATLAB
704
25
function refocusSplashScreen(hfigsplash, hmain) % Center the hfigsplash figure on the hmain figure, and make hfigsplash the % current figure, which brings it into the foreground and gives it focus. if ~isgraphics(hfigsplash), return end % Get the outer position of the main figure, in pixels oldunits = get(hmain,'Un...
fb42c5f741d29e56ba737d83380a7cc057cec35d9f209426c3002e0d34bf8626
MATLAB
704
26
function check = check_folders(basepath) % see if DLC files are present for each video % find all .avi videos and dlc files in basepath video_files = dir(fullfile(basepath,'*.avi')); video_files = video_files(~cellfun(@(x) ismember(x(1,2),'._'), {video_files.name})); video_files = extractBefore({video_...
0956133cafae444ecdd362723974b681b86ce9bab86d4b89c0926ba376fb0a40
MATLAB
705
36
function LAN = mat2cell_lan(LAN) % v.0.1 % % 27.07.2012 % 02.04.2012 % 14.4.2009 if iscell(LAN) for lan = 1:length(LAN) LAN{lan} = mat2cell_lan(LAN{lan}); end elseif isstruct(LAN) if ~iscell(LAN.data) paso = LAN.data; tr = size(paso,3); LAN = rmfield(LAN,'data'); if tr>1 % imp...
16efad6e68f6765e9503774174f24886004cf74bb5e1b7488803c0bf4c3f29ba
MATLAB
705
26
% PlotCleanICs.m % Sarah West % 3/21/22 function [parameters] = PlotCleanICs(parameters) % If the figure handle doesn't exist yet, create empty figure handle. if ~isfield(parameters.sources_artifacts_removed_figure) fig_overlay = figure; fig_colormasks = figure; else ...
2aeae18ad2d6b9e93053c5c6174ac9f9ce9cac47f4a2d418cb673f5985498c9d
MATLAB
705
20
function n = ncomponents(t) %NCOMPONENTS Number of components for a ktensor. % % NCOMPONENTS(T) returns the number of compontents in the ktensor 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...
554f6112a098f06a308f67e09997ea1f7d9731f0334f350b7e32671a4fe3407e
MATLAB
705
17
function k_spring = Convert_k(k,params) k_spring = k; if length(k) == length(params.LB) && length(k) == length(params.UB) for i = 1:length(k) if params.UB(i) == inf && params.LB(i) ~= inf k_spring(i) = log(1+exp(k(i))) + params.LB(i); elseif params.UB(i) ~= ...
5f4519d63ca28797e1c0cd347e145e3c703120cf7db0dc89f3f2f85c4e4ead3a
MATLAB
705
20
[numrow,numcols] = size(INSDataTable); binsize = 5; downtime = 4; %4 bins, 20ms for ck = 1:numrow curBars = BARSFits(ck,:); if sum(curBars)>0 INSDataTable{ck,26} = curBars; spontStartTime = 1; spontEndTime = 39; INSDataTable{ck,27} = getZScoreSingle(curBars,'spont',[spontStartTim...
a38fafd698406361937c725ebd46f3ce0f756aed59c367ec4ef941e6a680c9a4
MATLAB
705
18
function K = helm_dirichlet_kernel(x,y,zpuse,nuuse) % KFUN(X,Y,zpars,NU) computes the Helmholtz potential evaluated % pairwise between points in X and points in Y (does not handle the % singularity). zpars says which layer potential to use % using the surface normal vectors in NU. dx = bsxfun(@minus,x(1,:)',y(1,:)); ...
b38c10de75c5ee2cf1238113c87cc031acccc7f37fc8f2829489b6c070041ab9
MATLAB
705
47
function [accuracy, timestamp_last_trained] = NNgetCurrentAccuracy(self, worker) arguments self (1,1) crabsort worker (1,1) double end if self.verbosity > 9 disp(mfilename) end D = self.futures(worker).Diary; accuracy = 0; timestamp_last_trained = ''; if length(D) < 5 return end D = strsplit(D,'\n'); ac...
b8d119d97df623bea6216aaf7ea3692b8b1bdbb9e4b17e6ac6dff22419772c27
MATLAB
705
22
function [gparams,rftofit] = fitCenterGaussSurr(mdlparams) %UNTITLED3 Summary of this function goes here % Detailed explanation goes here pxranges = round(mdlparams.gridcent) + (-mdlparams.cwindow:mdlparams.cwindow)'; [xuse, yuse] = meshgrid(pxranges(:,1), pxranges(:,2)); subfilters = (xuse(:)-mdlparams.subcnts(:...
5b45a9569abe4883b4248fa8be7b0b73d50e7c04f4b086905672eb653a9a71f0
MATLAB
706
26
function h=gaussPlot2d(mu, Sigma, varargin) % Plot an ellipse representing the covariance matrix of a Gaussian % % This file is from pmtk3.googlecode.com if size(Sigma) ~= [2 2], error('Sigma must be a 2 by 2 matrix'); end [color, plotMarker] = process_options(varargin, 'color', 'b', 'plotMarker', true); mu = mu(:)...
6383e75afa63af2afa82771212e0ca63c78602a69ab638fa191f791e720de4c1
MATLAB
706
21
function r = get_start_position(p0,arenaShape,L) p0 = lower(p0); if strcmpi(arenaShape,'square') switch p0 case 'e' r = round((L(1)-1)*L(2) + L(2)/2); % south position case 's' r = round(ceil(L(1)/2)*L(2)); % east position case 'n' ...
825501da6b72389c25d6a23a894262ad1ca3c62c4391643d7bf3bed8b315e500
MATLAB
706
21
% M2HTML Toolbox - A Documentation Generator for Matlab in HTML % Version 1.4 16-Jun-2004 % % M2HTML main functions. % m2html - Documentation System for Matlab M-files in HTML. % mdot - Wrapper to GraphViz's <mdot> for dependency graphs. % mwizard - Graphical user interface for m2html. % private - Inte...
8f33f0169c56a66d676ce9ab7b6411096252006d2929b718b41d6291f83796b0
MATLAB
706
32
%% pro_SetModel: Set the model to the project % % Usage: % pro = pro_SetModel(pro, model, name) % % Inputs: % pro project structure % model handle to the @(x)model(x,...) where x is a vector % name optional, name of the model % % Output: % pro pro...
8f75b07e4e09a4b10fc1b5e84a351f8b2720151d6dfb0ae3b73cc1d9bd396885
MATLAB
706
31
function uv = transformPoints(uv0,xy0,th0,xy1,th1) % uv0: nptsx2 array of (x,y) coordinates % xy0: single (x0,y0) coordinate pair % th0: theta0, scalar angle % xy1: etc % th1: etc % % uv: npts2x array of transformed points % % Let F be the transformation (shift+rotatio) that maps (x0,y0,theta0) onto % (x1,y1,theta1). T...
9929e450c282ae732784ff3f2e3bb5524227d974348e591a670cb2891de2a83e
MATLAB
706
30
% RSKELF_MV_H Dispatch for RSKELF_MV with F.SYMM = 'H'. function X = rskelf_mv_h(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...
d1defbffb5a726c3cf02eb7294a1ffa3821202b774aead459d6e957cfb500c09
MATLAB
706
30
% RSKELF_SV_H Dispatch for RSKELF_SV with F.SYMM = 'H'. function X = rskelf_sv_h(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...
f21e353dbdb182f0b79d376a4a0f4a9831ca16fce6ff63fa9f4740d5c810e0dc
MATLAB
706
23
function bf10 = t1smpbf(t,n,r) % % bf10 = t1smpbf(t,n,[r=0.707]) % % Calculates JZS Bayes Factor for a one-sample t-test given t and sample size n. % The optional input r is the scale factor which defaults to 0.707. % This quantifies the evidence in favour of the alternative hypothesis. % See Rouder et al, 2009, Psych...
42237b42d6c06f9eea93a9358cc858c9a4108011835d9b80547f096e3cacc1f8
MATLAB
707
27
function rawLbl(lbl_file,out_file) tname = tempname; mkdir(tname); try fprintf('Untarring project %s into %s\n',lbl_file,tname); untar(lbl_file,tname); fprintf('... done with untar.\n'); rawLblFile = fullfile(tname,'label_file.lbl'); catch ME if strcmp(ME.identifier,'MATLAB:untar:invalidTarFile') warning...
6ced02a0ecbea3049776d29811a17450072b654e46b69e0c31dae1839b134c46
MATLAB
707
27
function LANs = only_interband(LAN) % aisla solo lo relebante del estudio interbanda % % if isstruct(LAN) LANs = only_interband_struct(LAN); elseif iscell(LAN) for lan = 1:length(LAN) LANs{lan} = only_interband_struct(LAN{lan}); end end end function LANs = only_interband_s...
96c6208e85a52c3059577a54b1f8c3a51dfbcb60757f6955620fb2b7093124e0
MATLAB
707
34
% % Copyright (c) 2015, Yarpiz (www.yarpiz.com) % All rights reserved. Please read the "license.txt" for license terms. % % Project Code: YPML110 % Project Title: Implementation of DBSCAN Clustering in MATLAB % Publisher: Yarpiz (www.yarpiz.com) % % Developer: S. Mostapha Kalami Heris (Member of Yarpiz Team) ...
abcfbca892252dfe3a62bba618d87e9902e9ae052a68a096b0f32e611645d5da
MATLAB
707
30
function scorefilenames = get_score_filenames(hmdir,fly,ptis,ns,varargin) [hmtype,firstframe] = myparse(varargin,'hmtype','jpg','firstframe',1); switch hmtype, case 'jpg', scorefilenames = cell([numel(ptis),numel(ns)]); for i = 1:numel(ptis), for j = 1:numel(ns), scorefilenames{i,j} =...
eca9b0165a952e34edc1f90bc9b70e52f849b3ca323a32486d3f2950cbf85df2
MATLAB
707
24
function [stat,msg] = myweb_nocheck(html_file) if ismac, [stat,msg] = unix(['open ' html_file]); elseif isunix, browsers = {'xdg-open','google-chrome','firefox','opera','konqueror','epiphany'}; browser = ''; for i = 1:numel(browsers), [a,b] = unix(sprintf('which %s',browsers{i})); b = strtrim(...
ff41b865ac469d10580719e8f63469dd2834a6a4bb13464f5e4f223f338b5578
MATLAB
707
24
function model = ppcaFit(X,K) % Probabilistic PCA - find MLEs % Each row of X contains a feature vector, so X is n*d % Each column of W is a pc basis, so W is d*k % We also return the evecs and evals of the covariance matrix % which are useful for efficient evaluation of ppcaLogprob % This file is from pmtk3.googlec...
0fdd60a259624960ef96178f6bc951918810302e14d5059d00e42afb038932fa
MATLAB
708
29
% RSKELF_SV_SC Dispatch for RSKELF_SV with F.SYMM = 'S' and TRANS = 'C'. function X = rskelf_sv_sc(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,:) ...
25a12aa4dfb25069195268b79624ea5906226a1816ee07a2cf746884fc52c8d4
MATLAB
708
32
function chm = wmodvar2(ch,v,W,Wsum,Niter,ep) %----------------------------------------- % chm = wmodvar2(ch,kt,W,Wsum,Niter,ep,nsc) % % modify the weighted variance of an image matrix by taking % gradient steps (see wvar2.m) % % ch: image % v: target variance % W: weighting functions % Wsum: sums of weighting functio...
2b0aaa31dcbbc7fd1e8176fbe92d1ee452068a68aac6f33786b6c1c3f176ddc7
MATLAB
708
24
function D = dexpm(X, H) % Fréchet derivative of the matrix exponential. % % function D = dexpm(X, H) % % Computes the directional derivative (the Fréchet derivative) of expm at X % along H (square matrices). % % Thus, D = lim_(t -> 0) (expm(X + tH) - expm(X)) / t. % % Note: the adjoint of dexpm(X, .) is dexp...
6b3ca5d0d284845da53539bd3619e638b32d941936bb9df090ddf2e1ea135b09
MATLAB
708
32
function [data,nTrialsRejected] = meg_rejectTrials(data, dataDir) % data = MEG_REJECTTRIALS(data) % % INPUT % data % data matrix, time x channels x trials % OUPUT % data % data matrix, time x channels x trials rejected NaN % nTrialsRejected % number of trials rejected % % Karen Tian % January 2020 %% check in...
b6e4d6e426694b57a1e294cef53fb8e3a23f941ad4aaa9ba726fde489a89c0c7
MATLAB
708
29
% RSKELF_MV_SC Dispatch for RSKELF_MV with F.SYMM = 'S' and TRANS = 'C'. function X = rskelf_mv_sc(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,:) + conj(F.factors(i).T)*X(rd,:); X(r...
e5b16ef1687d7b9ddce678191a54ec0b3e6d0b280b2256daf9981775660b1cea
MATLAB
708
29
function [yhat, sigma2Hat] = linregPredictBayes(model, X) % Posterior predictive for linear regression model % This file is from pmtk3.googlecode.com [X] = preprocessorApplyToTest(model.preproc, X); if isfield(model, 'netlab') [yhat, sigma2Hat] = linregPredictNetlab(model, X); return; end wN = model.wN; VN = mode...
fa208d62fade3b1ec618eec4c98f0799870589fdd3b0c0c47d2e1f42ae528e60
MATLAB
708
20
function [F] = calcSubunitActivationPhases(params, spforiphase) %The function can deal with mulitple subunits % Detailed explanation goes here %Returns derivatives for grid spacing, xshift and yshift %========================================================================== spf = spforiphase(:, 1); ori = spforiphas...
bd4129d9d2628322213a3de9222c5c35eb1ded29c9327b31cbd0ab30cb5d3f9f
MATLAB
709
24
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Band pass filter % Input: % signal: row-wise signal % fsamp: sampling frequency % emgtype: 1 = surface, 2 = intra % Output: % filteredsignal: row-wise filtered signal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
e22ae3823368a8f45f92bd96094bdbd998def5c7eb38574f52d32c4bc4f50387
MATLAB
709
36
function [dt, timer_id] = stoc(timer_id) %STIC TOC equivalent using precise system time. % Usage: % stoc % stoc(timer_id) % [dt, timer_id] = stoc % % See also: stic, systime global stic_timers; if nargin < 1 timer_id = numel(stic_timers); end if numel(stic_timers) == 0 error('You must call STIC before ...
f083254db45ab1f8bff6e2d2ed69ce8d45eb75b5d67dfa7332ba3d64395361a1
MATLAB
709
25
function [pZ, ll] = mixDiscreteInferLatent(model, X) % Infer latent mixture node from a set of data % pZ(i, k) = p( Z = k | X(i, :), model) % ll(i) = log p(X(i, :) | model) % X may contain NaN for missing values (in discrete case) %% % This file is from pmtk3.googlecode.com nmix = model.nmix; [n, d] = size(X); ...
f1b181fdd5df19beb391fd8d084b85554e3f69d1abfdeca00dfb9e56a4d5a0a3
MATLAB
709
17
function N = count_number_of_steps_in_lattice(r,L) % r -> linear lattice index position, i.e. r(i) = y(i) + x(i)*L, where (x,y) -> (1..L,1..L) are the lattice coords % this function should have the same functionality as the one with the same name in % D:\Dropbox\p\uottawa\data\animal_trajectories\mouse_track\process_mo...
fc7c9ab1e7fa2b3ea8809fd17528a374d826a866924280bf11e41591ca3152ab
MATLAB
709
28
function S = nameval2struct(C) %NAMEVAL2STRUCT Converts a cell array of name-value pairs to a struct. % Usage: % struct = nameval2struct(nameval_cell) % % See also: struct2nameval C = C(:); % Check input validateattributes(C, {'cell'}, {'vector', 'nonempty'}) assert(iseven(length(C)), ... 'Cell arrays of name-v...
445fd2960342a2d12aaf449390a19f11fa81ce11594376256a4f4eca9ec1c168
MATLAB
710
16
function [FWHM, pos] = h_findFWHM(ydata, thresh) if ~exist('thresh','var')||isempty(thresh) thresh = 0.5; end [maxY,I] = max(ydata); labelY = bwlabel(ydata>thresh*maxY); peak_ind = find(labelY==labelY(I)); % pos(1) = sum(ydata(peak_ind(1)-1:peak_ind(1)) .* [peak_ind(1)-1:peak_ind(1)]') / sum(ydata(peak_i...
889ff07e8c8f71dd380baebf6eef9c760b23323450bc59ea9ba7c44f78bc7f4e
MATLAB
710
22
function [fx] = f_wsls(x,P,u,in) % pseudo-evolution function for a "win/stay - lose/switch" strategy % function [fx,dfdx,dfdP] = f_wsls(x,P,u,in) % The "win/stay - lose/switch" strategy is encoded in terms of the % evolution of pseudo q-values, which swap sign depending upon the % feedback. Note: the feedback should ...
54adbb5511d0ad1dd7e2d03b26f8a495aa800cefe657f5c8ddd9c8f7f19c549e
MATLAB
711
32
function res = structapply(s,fcn,varargin) % Apply function to leaf notes of nested struct % % s: scalar struct (typically nested) % fcn: function handle with sig: res = fcn(fld,val) % % res: containers.map with keys as fully-quald paths and vals as res verbose = myparse(varargin,... 'verbose',false ... ); path ...
a1a4a5d168cea27e3fc3709ecb065573b50fcbd32f264dca3bef2c330e0ab787
MATLAB
711
20
function [] = utils_display_dipole(dip_plus,dip_minus, linecolor) %UTILS_DISPLAY_DIPOLE Summary of this function goes here % Detailed explanation goes here x0 = dip_minus(1); x1 = dip_plus(1); y0 = dip_minus(2); y1 = dip_plus(2); z0 = dip_minus(3); z1 = dip_plus(3); circle_size = 25; hold on scatter3(x0,y0,z0,circl...
dec69bcc84a6313fe98226d2120c63911de7944cbde244cfe13b92e7af653fa5
MATLAB
711
27
function writeCSVfromTranscriptObjects(transcript_objects,filename) %Write all the aligned transcripts to a csv DELIMITER = char(9); fileID = fopen(filename,'w'); for t_idx= 1:length(transcript_objects) transcript = transcript_objects{t_idx}; if isfield(transcript,'name') fprintf(fileID,'%i \t %s \t',t...
f5854a06e68824dd532b96b20e3a396f04a8f49cde6c2a277fcb63d938c4e970
MATLAB
711
14
function ph = plot_square_circular_hole(ax,r_center,R,square_offset,varargin) t = linspace(0,2.*pi,10000); t = t(1:(end-1)); x0 = r_center(1); y0 = r_center(2); x_circle = x0 + R.*cos(t); y_circle = y0 + R.*sin(t); x = [ max(x_circle)+square_offset, max(x_cir...
162e446d224a7994a36d066abfaf3aa0ddeee53d4c8aa595a1489667ca111ce9
MATLAB
712
26
function spkDat = MoveClusters(spkDat, clustList, varargin) % 11/21/2016 M. Farries destination = 'top'; oldLabels = setdiff(unique(spkDat.id), 0); nClust = length(oldLabels); [~, clustIdx] = ismember(clustList, oldLabels); otherClust = setdiff(oldLabels, clustList); [~, otherIdx] = ismember(otherClust, oldLabels...
3f970755c9a2682b74802a82001c0a9caabbe3bb072caa236e3e0bf3a4f10696
MATLAB
712
28
function conn_ele=get_conn_ele_2d(t) % returns a list of elements which share each node: % [e1 e4] % [e3 e5] % [e4 e5] ne=size(t,1); %assuming that 2d bdy is a closed one therefore number of points is the %same as number of elements conn_ele=zeros(ne,2); for i=1:ne n1=t(i,1); n2=t(i,2); if (conn_ele(n1,1)==0) ...
1d786685b421ba1b424eb51a57c0d587729a39c4909ef21f5afaefaf9397afec
MATLAB
713
29
function varargout=lsw(f) %LSW List directory with wildcards % LSW works as Matlab's built-in LS, but wildcards (*) are interpreted % differently: % LS mydir* lists the directory names matchning 'mydir*' % LSW mydir* lists the content of the first directory matching % 'mydir*...
6b2c4602ef75a81824747b95313b8604f54dafad93589127861db590c6b0b997
MATLAB
713
19
function result = charAdd(baseChar, num) % 将基础字符转换为数字('A' = 1, 'B' = 2, ..., 'Z' = 26) baseNum = double(baseChar) - 'A' + 1; % 计算总数,包括从基础字符开始的偏移量 totalNum = baseNum + num; % 初始化结果字符串 result = ''; % 当总数大于0时进行处理 while totalNum > 0 % 减1是为了使'A'成为循环的起点('A'到'Z',然后是'AA', 'AB', ...)...
8e43fe91257fc8d2b8f5c9f6fa7a945df8306f0730b36becc2da9636735bbf91
MATLAB
713
28
function V = volume_tetrahedron(a,b,c,d) % VOLUME_TETRAHEDRON Calcultes tetrahedron volume. % % SYNTAX: % [V] = VOLUME_TETRAHEDRON(A,B,C,D) % VOLUME_TETRAHEDRON(A,B,C,D) % % [V] = VOLUME_TETRAHEDRON(A,B,C,D) % - A, B, C and D - are m by 3 matrices of (x,y,z) cartesian coordinates % of vertice...
ac4ea72027ca5acdff25b484e150debe0ee54f4bf7a86ffe8609d99f421f5ee3
MATLAB
713
19
function ImageArray_Reg1 = TranslateArraySimple(ImageArray_Reg, DeltaX1, DeltaY1); LastImageNumber = size(ImageArray_Reg, 3); % this if is for when DeltaX, DeltaY are just one vector each (translate whole % array by these two vectors, instead of separate DeltaX, DeltaY for each % image) if (length(DeltaX1)==...
bff047a5bbe7645d4846f4d733c3ca68aee5289b3152d4914a8609f0634ce3ad
MATLAB
713
28
function plotSubunitGrid(subcents, subwts) %UNTITLED3 Summary of this function goes here % Detailed explanation goes here subcents = double(gather(subcents)); subwts = double(gather(subwts)); opts = {'QJ', 'Pp'}; [v,c] = voronoin(subcents, opts); gridXc = mean(subcents(:,1)); gridYc = mean(subcents(:,2)); % m...
ea1f205ec5b1ff69f6c610a15a3e92f261402eeea6c2e8355619e8d8fd81aebe
MATLAB
713
20
% plot_Fig6ab % Plot activity of Min neurons during motion viewing and motion % discrimination task if ~exist('sigSL'); load(fullfile(saveLoc, 'sig_allSessions')); end tmp = load(fullfile(saveLoc, 'sig_view_allSessions')); sigSLv = tmp.sigSL; clear tmp plotSig = {'MinC', 'MinI'}; sigName = {'S^{left}_{Min} [sp...
f67304c0b94f96e4e0280ca393338309d2b4228610ab0352cb7d082284e15204
MATLAB
714
27
%indices = batches{j}; %sdat = s_data(:,indices); %ghat = gamma_hat(j,:); %dhat = delta_hat(j,:); % g.star is first row % d.star is second row function adjust = inteprior(sdat, ghat, dhat) gstar = []; dstar = []; r = size(sdat,1); parfor i = 1:r g = ghat; d = dhat; g(i)=[]; ...
fc88486f9fb5b189268ee1a95c3dee341707ed48328ce1b5244c87d1fabeacbc
MATLAB
714
34
%% Optimization illustration % %% % This file is from pmtk3.googlecode.com function optMaxLambdaVal() f = @(x)x-(x-x.*log(-x)); domain = -1:0.0005:0; figure; hold on; m = -1/exp(1); plot([m,m],[0,f(m)],'-k','LineWidth',4); plot(domain,f(domain),'-r','LineWidth',5); axis([-1 0 0 0.4]); set(gca,'XTick',[-1 -0.5 0],'YTi...
1a9bc152e681a74378b03aa302532b067f2e8c8d09e112a9965cb2d7ee718401
MATLAB
715
29
% 2024-09-16: voxel-wise dictionary lookup function using dot product % matching % Inputs: x - signal vector over 3 echoes % dict = struct containing dictionary, made by dict_create.m % This version estimates t2 and b1, as in the original Ben Eliezer method % Shaihan Malik, King's College London, 2024 func...
1b6a592881bd752be9748971412b0e1728974466680483aba9483f714323e558
MATLAB
715
34
function P=w_StatToP(StatVal, StatOpt) TestFlag=StatOpt.TestFlag; if isempty(TestFlag) P=[]; return end Df1=StatOpt.Df; if isfield(StatOpt, 'Df2') Df2=StatOpt.Df2; end if StatOpt.TailedFlag==1 Scale=1; elseif StatOpt.TailedFlag==2 Scale=2; else error('Invalid Tailed Flag') end switch upper(T...
1cea83c3608e36c3e47107dbff49256383bb64d1ae72a3886a245f5bd2d672de
MATLAB
715
26
function path = meg_pathToTAMEG(exptName, user) % function path = meg_pathToTAMEG(exptName, user) if nargin < 1 error('Must provide experiment name [TANoise or TA2]') end if nargin < 2 || isempty(user) user = 'mcq'; end switch user case 'mcq' root = '/Volumes/purplab2/EXPERIMENTS/1_Current_Experim...
29ba0200d4a15215c98509ca9145b2ca86697c36d4aa519f4363e889e07d0c72
MATLAB
715
18
function plot_segmented_nuclei( nuclei_seg, name ) % ----- Plot nucleus label matrix --- label = bwlabeln(nuclei_seg); [nx, ny, nz] = size(nuclei_seg); rgb = zeros(nx, ny, nz, 3); for j = 1:nz rgb(:,:, j, :) = label2rgb(label(:,:, j)); end rgb_z...
4c3e1173c08d8367daf0bf7ce487d961939757ca2667328ca73f01dc33730467
MATLAB
715
23
function preds = fitAndPredictOutputNL(gensfit, genspred, spikesfit, funtype) %UNTITLED Summary of this function goes here % Detailed explanation goes here [svals, scents] = getNonlinearity(gensfit, spikesfit, 40, 1); switch funtype case 'logistic4' guess = fitRLogisticToSpikes(double(scents), do...
563cecc826b2aafd9b28fa5b023fdd22ea1324eb81857e23b4fe74667b683f8a
MATLAB
715
26
function [spikes, xax] = qrt_get_spikes(qRT, LAN, chan, w_pre, w_post) if nargin < 5; w_post=qRT.cfg.w_post; end if nargin < 4; w_pre = qRT.cfg.w_pre; end % if nargin < 3; chan = qRT.chan; end ind = find(qRT.chan == chan); TS = ceil(qRT.laten{ind} * LAN.srate / 1000); bounds = [w_pre+1 LAN.pnts-w_post]; useless = TS ...
6ab9344cab06e7ebdea32a0f6f823c45be177845c4f84e4918454b63d436e8a1
MATLAB
715
47
function ftrate = wlFT_getSamplingRate(trialdata) % function ftrate = wlFT_getSamplingRate(trialdata) % % This function returns the sampling rate used within a Field Trip trial data % structure. Priority is given to "rawsample", then to "hdr.Fs", and then to % "1.0 / (time{1}(2) - time{1}(1))". NaN is returned on erro...
3fffb28626140c7d65058dd371e2e544fa2e84850e38a8b6207365e54e9ee01f
MATLAB
716
15
function distance = calcTDTDist(electrode1,electrode2) electrodes = [1 3 5 7 2 4 6 8;10 12 14 16 9 11 13 15]'; elecdistx = [0 250 500 750 1000 1250 1500 1750;0 250 500 750 1000 1250 1500 1750]'; elecdisty = [0 0 0 0 0 0 0 0;375 375 375 375 375 375 375 375]'; [elec1WhereX,elec1WhereY] = find(electrodes==electrode1);...
6ddef8f4cb630b16b0b62cd546adc6648eca66142b5b2569bf79c87e0b24ab15
MATLAB
716
22
function generate_ROI_masks(stat_path,exp_folder,N_ROIs) % ======================================================================== % Ruslan Masharipov, October, 2023 % email: ruslan.s.masharipov@gmail.com % ======================================================================== tic mask = eye(N_ROIs); % Make folde...
b97c411d572ae96475775ba92efb97eb764d4322d236640939ec836c8d95c3af
MATLAB
716
25
function info = dirinfo(directory) % Collect information about the files in a directory structure %Recursively descend through the directory structure, starting at the %specified directory and collect information into a struct array with %fields, path, m, mat, mex, mdl, p, classes, packages. This is effectively %a rec...
c70632697d5a03c685354223b74a300a41255c8063376a0f660886b29397f088
MATLAB
716
29
function [rsq rsq2 y_fit_meanCorrected adjrsq] = calculateRSQ(y,y_fit,meanSub,d) % function rsq = calculateRSQ(y,y_fit,meanSub) % y: real data % y_fit: fitted data % d: number of parameters % n: number of samples (here, time points) % Calculate r-squared if meanSub % mean subtraction meanDiff = mean(y,'omitna...
cbba4a505f96cc2ba3ad89b11132500ca914130282e253bb31433faff9e2e763
MATLAB
716
21
function se = meshconnte(t, edges) % SYNTAX % se = meshconnte(t, edges) % DESCRIPTION % This function returns edges (indexes into array edges) for every % triangle - a Nx3 array. It is meaningful for manifold meshes only % Copyright SNM 2012-2018 % The Athinoula A. Martinos Center for Biomedical Imaging...
5846b53c8be50cd4f74ea67a26c4161000b9e82d9c75555a428f9614614ad84b
MATLAB
717
23
[corr_pyr,corr_int] = extract_variables ('pair_corr','tot',resultsPath, 'pyr','int',conditionType,conditionValue); [NRace] = extract_variables ('SCE',[],resultsPath, 'NRace',[],conditionType,conditionValue); [time] = extract_variables ('time',[],resultsPath,[],[], conditionType,conditionValue); maxTime = zeros(1,size...
c0639e1088e66b69bbcac97d52980c2cd942f4cae16f7e1db6bfc3bd1c2c4d43
MATLAB
717
39
%% Compare Gauss, and Laplacian distributions % %% % This file is from pmtk3.googlecode.com xs = -4:0.2:4; v = 1; mu = 0; pr{1} = gaussProb(xs, mu, sqrt(v)); % variance of laplace = 2b^2 b = sqrt(v/2); pr{2} = 1/(2*b)*exp(-abs(xs-mu)/b); legendStr = {'Gauss', 'Laplace'}; %[styles, colors, symbols] = plotColors;...
c1eac45c8effb8774421857b595a9e49e5c9dc53e318a61108e23155f3b7afe5
MATLAB
717
36
%%% Extraction of the final intrinsic and extrinsic paramaters: fc = solution(1:2); kc = solution(3:6); cc = solution(6*n_ima + 4 +3:6*n_ima + 5 +3); % Calibration matrix: KK = [fc(1) 0 cc(1);0 fc(2) cc(2); 0 0 1]; inv_KK = inv(KK); % Extract the extrinsic paramters, and recomputer the collineations for kk = 1...
c6382ab099c5d3d37c3ce2ea099c8a1452c9d08e375f98689e9d939227a41ae3
MATLAB
717
24
function [pth,nam,ext,num] = VBA_spm_fileparts(fname) % Like fileparts, but separates off a comma separated list at the end % FORMAT [pth,nam,ext,num] = spm_fileparts(fname) % fname - original filename % % pth - path % nam - filename % ext - extension % num - comma separated list of values %_______________...
56e8d4aa8ceb05df3f251b07bc8ea72579dae5d046fc50a25473911028d506b7
MATLAB
718
25
function labels=getLabelsFromExpDirs(expDirNames,labelFileNameRel) % ALTODO: guess this is deprecated nExps=length(expDirNames); labels = ... struct('t0s',cell(1,nExps), ... 't1s',cell(1,nExps), ... 'names',cell(1,nExps), ... 'flies',cell(1,nExps), ... 'off',cell(1,nExps), ... ...
811b1a99501548d5ddfb52ada3e16fe2eb5aa0704fa8bf60dc53f12b56f29027
MATLAB
718
30
classdef TestAllDemos < matlab.unittest.TestCase properties (TestParameter) demo = findDemos (); end methods (Test) function testDemo (testCase, demo) setup = 'pause off; warning off; ' ; try evalin ('base', [setup demo ' ; close all'])...
c68a2df7f75c011ba3968a20dd0a21f937e6411fae9183d6ff02dd256919fe1c
MATLAB
718
19
function ImageArray_Reg1 = TranslateArrayParallel(ImageArray_Reg, DeltaX1, DeltaY1); LastImageNumber = size(ImageArray_Reg, 3); % this if is for when DeltaX, DeltaY are just one vector each (translate whole % array by these two vectors, instead of separate DeltaX, DeltaY for each % image) if (length(DeltaX1)...
dc99cdd9c1ccd871eb0e5d58f2b14e27f4ba5524541fd02ab17052845436df37
MATLAB
718
27
function resDP = DPcal(data,iteration,varargin) for i = 1:2:length(varargin) eval([ varargin{i} '=varargin{i+1};']); end labels = data(:,2); scores = data(:,1); try [~, ~, ~, resDP.value] = perfcurve(labels, scores, 1); for i = 1:iteration [~, ~, ~, AUC, ~] = perfcurve(labels(randperm(numel(labels))), ...
f3d818a4a3a86ecb7f6347a5817267edae8ec30336a792ffe60fb9643c7de639
MATLAB
718
24
function mscmd_filter_events(firings_in_path,firings_out_path,opts) if (nargin<3) opts=struct; end; if (~isfield(opts,'detectability_threshold')) opts.detectablity_threshold=0; end; if (~isfield(opts,'outlier_threshold')) opts.outlier_threshold=inf; end; if (isinf(opts.outlier_threshold)) opts.outlier_threshold=...
1ce5ed30237d93af633daf11bc3ea4f0f02edd7c3542af15c8bc9bb0686e2ec1
MATLAB
719
19
% FillMasks.m % Sarah West % 9/1/21 % Takes a vector of mask indices and a matrix of data and fills in the mask % indices (with NaNs) that have been removed by masking.Returns the images % in the 2D format (because using it in 2D is the only time you'd want to % fill in the mask anyway). function [parameters]=FillMas...
3d96000af1c18a6a4196320998518026c1d070211c52e6d52aa6baf042ecbea0
MATLAB
719
27
function [X] = preprocessorApplyToTest(preproc, X) % Transform the test data in the same way as the training data % This file is from pmtk3.googlecode.com if isempty(preproc), return; end if isfield(preproc, 'Xmu') X = centerCols(X, preproc.Xmu); end if isfield(preproc, 'Xstnd') X = mkUnitVariance(X, prepro...
bcaad2527096ecdd17d553b5a7e62412bbb8d302f75aaf2b5bda08e05f051d08
MATLAB
719
23
%% Illustration that the epigraph of a convex function is a convex set. % %% % This file is from pmtk3.googlecode.com function epigraph f = @(x)(x-4).^2; domain = (0:0.01:8); subdomain = 0:0.1:8; xline = max([subdomain;subdomain+1]-1,min(domain)); yline = [f(max(domain))*ones(size(subdomain));f(subdomain)]; p1 = lin...
d7bb00460cd2d87915a959469536c4f72764ebeadb89b9bc8ea515dc6278ef8e
MATLAB
719
25
function jtree = updateJtreePots(jtree, factors) % Rebuild the precomputed jtree after model params have changed % The jtree structure does not change, just the clique potentials. % This file is from pmtk3.googlecode.com ncliques = numel(jtree.cliques); factorLookup = jtree.factorLookup; nstates = jtree.nstates; clqs...
e7d0d0808ad343bf33f3ad30b972b6d1beb7e8710c89e40fc37660cc2e2e57fc
MATLAB
719
27
function [y,bs] = buffered_stats(data,frame,overlap,type) % [y] = buffer_variance(data,frame,overlap,type) % input data: input vector of data % frame: frame size (scalar value) % overlap: overlap size between frames (scalar value) % type: i.e. std, mean, median, ... if nargin<4 ...
14b40b98010bbfae10c2af155f14dea313cfb98c462c11c7010441c13e167091
MATLAB
720
20
function [m c] = linmap( li, ui, lo, uo ) % LINMAP Calcultes the parameters for remaping data linearly % INPUT: % li - Lower bound input range for independent variable % ui - Upper bound input range for independent variable % lo - Lower bound input range for dependent variable % uo - Upper...
3d2d6d71b5b90671839bf20c1a0f5ac2be578864acb6e3495f4d987048ddd6bb
MATLAB
720
28
%% Make a 'relevance network' from the small 20-newsgroup data % (See also chowliuTreeDemo) % This file is from pmtk3.googlecode.com loadData('20news_w100'); % documents, wordlist, newsgroups %X is 16,642 documents by 100 words (sparse logical matrix) X = documents'; [mi, nmi] = mutualInfoAllPairsDiscrete(X); mi ...
c007f9b057443527352251d2e56180c261c3d516b25971fac776b3dec66af690
MATLAB
720
34
function tf = isabstract(className) % Return true iff the class is abstract % PMTKneedsMatlab 2008 % This file is from pmtk3.googlecode.com if hasTag(which(className),'%PMTKabstract') tf = true; return; end tf = false; metaInfo = meta.class.fromName(className); if(numel(me...
50a1885591a43e56d13499e5d425f52f7a93f14b53d52394236692b32de9adfc
MATLAB
721
28
function []=create_ft_model(pat_ix, model) pat_cell = {'110411','117122','120111','122317','122620','124422','128632','130013','131722','138534','149337','149539','151627','160123','198451'}; pat_cell fprintf("pat_ix=%s" ,pat_ix); pat_ix = str2num(pat_ix); patno = pat_cell{pat_ix}; % select patient cd ..; cd ....
60ca0ebbc977ce4214d6045d0953cdf506c1a0ba92312343c487455550710646
MATLAB
721
28
function Kc = kernelCentering(K, Ktest) % Center a kernel matrix % Kc = kernelCentering(K) returns size n*n % Kc = kernelCentering(Ktrain, Ktest) returns size ntest * ntrain % This file is from pmtk3.googlecode.com %PMTKurl http://www.kernel-methods.net/matlab/algorithms/centering.m %PMTKauthor John Shawe-Taylor %P...
b4633fc370be82d66f143ce8908425db11f774014f640ecacaf8decf9fc3f053
MATLAB
721
37
function templates=ms_templates(clips,labels) %MS_TEMPLATES - Compute templates (mean waveforms) corresponding to each %spike type. % %Consider using mscmd_templates % % Syntax: templates = ms_templates(clips,labels) % % Inputs: % clips - MxTxNC array of clips % labels - 1xNC array of integer labels % % Outputs:...
094867e077c86ffe4fa7b2330775491d54288fedaf281428398a32be035507f0
MATLAB
722
19
% make mid-gray surface % before we push volume onto surfaces, % we need to make mid-gray surfaces, % which is necessary in the next step. % cd('/home/stone-ext1/freesurfer/subjects/litong_dxh1/surf/'); %cd('/home/xianchige/YQZD/subject/sub17/surf/'); cd('/home/xianchige/DPHZD/subject/sub09/surf/'); unix('mris_expan...
0a6cc152723b3153ca88b1f5d315d022b27fe238dbb67125d43358a4eec5f648
MATLAB
722
24
function [corTrace] = corrTrace(Y, ROIs, padding) % [corTrace] = corrTrace(Y, ROIs, padding) if(nargin<3) padding = 3; end corTrace = NaN(size(ROIs,3),size(Y,3)); for i_roi = 1:size(ROIs,3) this = ROIs(:,:,i_roi); [b,a] = find(this>0); bb = [min(b) max(b)]+paddin...