sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
2d3f7965f48e4511722383f9c18e3dac1376e37dfe3c031076cf6f5074549bb2
MATLAB
636
23
function err = can_hrf_fit(vP,y,st) % fits SPM's canonical HRF based on two gamma functions % vP = parameters: 1-6 are those in spm_hrf; 7 is amplitude scaling % y = FIR data % st = FIR pst % usage: % [p, err, flag] = fminsearch(@(vP) can_hrf_fit(vP,y,st)) dt = 0.1; % resolution of 0.1s t ...
3d93012beabcb6251de358bbb3bd7784f1f5ba10e22f805567b0b71b9ea8fc55
MATLAB
636
27
function data_expre_c=splineformissing(data_expre,time) nan=isnan(data_expre); nansum=sum(nan,2); for a=1:size(data_expre,1) z=1; if nansum(a)>0 tt=zeros(1,(size(data_expre,2)-nansum(a))); gene0=zeros(1,(size(data_expre,2)-nansum(a))); for b=1:size(data_expre,2) ...
4546a0ca6ea70df247884b2c91e61cb8d5cd210f693a1e416e280e5c779e484a
MATLAB
636
23
function sigma_R = metastability_calculation(BOLD_data,window_size) % Preallocate the phase and order parameter matrix phases = nan(height(BOLD_data),450); order_param = nan(height(BOLD_data),1); % Loop over each ROI for roi = 1:width(BOLD_data) time_series = BOLD_data(:,roi); analytic_signal = hilbe...
7357c14cc3613a4d63ff0cd72c0389ed52ea4b8778e1c38ef5a6258bdde68efa
MATLAB
636
18
function [Mean_Out, STD_Out, SEM_Out, CV_Out, Num_Out]=Mean_STD_SEM_CV2(MeanDimension,InputData) InputData(InputData==Inf)=NaN; if any(isnan(InputData(:))) Mean_Out=nanmean(InputData,MeanDimension); STD_Out=nanstd(InputData,0,MeanDimension); Num_Out=sum(~isnan(InputData)); ...
a25159fbbe8465cd2b525f4fd908c3e35a3b50d854d38b8658cb81b1de299ab6
MATLAB
636
27
%% 3D Monge-Ampere operator for blob detection % Author: Antonio Martinez-Sanchez % T: intput tomogram % s: scale for anistropic filtering % r: aspect ratio for anistropic filtering % B: blob detection function B = blobdetec( T, s, r ) %% Anistropic filtering I = angauss( T, s, r ); %% Directional derivatives Ix = di...
78beca0f47f65c8345f836060bf250f1b3bfb845e29338b67d64761ab7ab24c1
MATLAB
637
29
function ext = get_ext(path, no_dot) %GET_EXT Returns the extension in a path. The path need not exist. % Usage: % ext = get_ext(path) % ext = get_ext(paths) % cell array of paths % ext = get_ext(_, no_dot) % if true, returns ext without dot (default: false) % % Notes: % - Extension returned will be the charact...
b2b820da35d36d916a9eecb88411aa8cf3d5cb0b83d8833dd27997142e88f428
MATLAB
637
19
rgb = [112 112 112; 26 127 187]/255; figure('color', [1 1 1]); h(1) = plot(time,mean(lip_accuracies{2},1),'color',rgb(1,:),'Linewidth',8);hold on h(2) = plot(time,mean(fef_accuracies{2},1),'color',rgb(2,:),'Linewidth',8);hold on ylim([40 100]); xlim([-0.05 0.2]); array_pres = 0; chance = 50; plot([arr...
f6ee5f2d4bd10c8c77587ea475f98cec89b6cd070bb435bd063f65d4552de86f
MATLAB
637
16
%Evaluate cost function for closest representative search given coefficients %function ft=essential_distMinAnglePair_ft(t,m1,p1,c1,m2,p2,c2) %Evaluates the cost function used by essential_distMinAnglePair to find the %closest representative in the equivalence class of a QREM %If m2,p2,c2 are omitted or empty, get v...
34c281085105eecd6d786614e427083513ba5cf6cd5862336aee516c792c728f
MATLAB
638
19
%% %load a token image so we get the size img = load3DTif('/Users/Goody/Neuro/ExSeq/registration_analysis/20170813regtest/exseqautoframe7_round004_summedNorm_registered.tif'); load('/Users/Goody/Neuro/ExSeq/exseq20170524/exseqautoframe7_puncta_filtered.mat'); %load the puncta_allexp.mat file %% %Make a 3D image of t...
79f2fe796edc96ee4a4dbeea6b50985b6224d3cba9d880bf6e235938bfef80ed
MATLAB
638
15
function setup = StateSwitch_settingsResting_MR(setup) % settings for resting state eeg setup.DEBUG = 0; setup.opacity = .4; setup.keyB = 1; setup.ET.useET = 0; setup.EEG.useEEG = 0; setup.EEG.DIO.pa...
7b3876ecc6e9b610c21d4433956fb6f4e260c82ab4dfff3dbfad182999453f37
MATLAB
638
24
function [pZ, pX] = noisyMixModelInfer(model, Y) % Y is Ncases * Nnodes * Ndims % so Y(i,j,:) are the observations for node j in case i % % Z -> Xj -> Yj % % pZ(i, k) responsibility of cluster k for case i % pX(i, c, j) = p(Xj = c | case i) % % This interface is similar to mixInfer, and is batch-oriented. % Use noisy...
afd8a21bea5a9cb64d292a6ddd5f55151fa4b00bfbb90739f8eb7315445cf9f8
MATLAB
638
30
% Tomogram (3D) equalization for blob detection % Author: Antonio Martinez-Sanchez % T: input tomogram % M: binary mask for input data % n: number of bins for the histogram % mode: 1-> vesicles center enhancement, otherwise-> usual % E: output histogram (with constrast enhanced) with range [0,n]; function E = histeq3db...
de1f7c10dbef78b3af13f2dc5a18b87cbc82c7a10521caebe1811c1f42a00909
MATLAB
638
24
function [E, V] = VBA_dirichlet_moments (a) % // VBA toolbox ////////////////////////////////////////////////////////// % % [E, V] = VBA_dirichlet_moments (a) % Derives the first- and second-order moments of a Dirichlet density % % IN: % - a: parameters of the Dirichlet distribution (pseudo-counts) % OUT: % - E: fi...
8e57f1cc5ee4eaee52af9773c1704dff78a2738b4f45b1b848bc60291527f2f3
MATLAB
639
29
function V=grid2V(grid,fp); % makes forward calculation for a grid for unit % dipoles in all 3 directions % usage V=grid2V(grid,fp); % % input: % grid nx3 matrix, each row is a the location % fp structure to make forward calculation % output: % V nxmx3 matrix, for m gridpoints % V(i,j,k) is the poten...
9d4d1cfc6f332cef8192e23a7a01efb53246e964777c1c001845b005070fbf1a
MATLAB
639
25
function S = gaussSample(arg1, arg2, arg3) % Returns n samples (in the rows) from a multivariate Gaussian distribution % % Examples: % S = gaussSample(mu, Sigma, 10) % S = gaussSample(model, 100) % S = gaussSample(struct('mu',[0], 'Sigma', eye(1)), 3) % This file is from pmtk3.googlecode.com switch nargin case 3...
a0dfbeb9bb367790fc5db99bd1dd8993fdc0107d0b1309427ab01de6890ac465
MATLAB
639
26
function [V, Q, iter] = value_iteration(T, R, discount_factor, oldV) % Solve Bellman's equation iteratively. % [V, Q, niter] = value_iteration(T, R, discount_factor, oldV) % oldV is an optional staring point. S = size(T,1); if nargin<4 % set initial value to R oldV = max(R,[],2); end done = 0; % We stop iterati...
223eeccba526e23976c19a0b6f95556181c8640a85046f492f7d54d5e3a63edc
MATLAB
640
20
load clab_example; %sa=prepare_sourceanalysis(clab_example); dips=[[3 0 8 0 0 1];[-3 0 8 0 0 1]]; %define two dipoles v=forward_general(dips,sa.fp); % calculate the fields; vv=v*[[1 1 ];[1 -1]]; %mix the the fields [s,vmax,imax,dip_mom,dip_loc]=SMusic_v1(vv(:,2),sa.V_fine,sa.grid_fine); grid_fine_val=[sa.grid_fi...
626da35510e29750acd6b295bbee70e007f647ade367f5631f7b4717e04c5c01
MATLAB
640
37
function coh=dicscoh(L,C,refind,alpha); if nargin<4 alpha=0; end [nchan nchan]=size(C); [nchan ns ndum]=size(L); Cr=C+alpha*eye(nchan); Crinv=inv(Cr); A=zeros(nchan,ns,3); for i=1:ns Lloc=squeeze(L(:,i,:)); A(:,i,:)=reshape((inv((Lloc'*Crinv*Lloc))*Lloc'*Crinv)',nchan,3); end Aref=transpose(squeeze(A(:,...
211fe95113d43e0706b26e30ef07f17ae3f19852bd20bfdcb61e288ec775a981
MATLAB
641
27
% HIFDE_MV_P Dispatch for HIFDE_MV with F.SYMM = 'P'. function X = hifde_mv_p(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,:)...
6a75808f11dca424e8847ccfe694dd1330f384a85d8897efdf68508338ab70d4
MATLAB
641
27
% HIFDE_SV_P Dispatch for HIFDE_SV with F.SYMM = 'P'. function X = hifde_sv_p(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,:)...
a4a9e0fd58521ff75c4a9a4ef81ebd0c2c4d3d07fe526583307d397ca8e04131
MATLAB
641
19
function userDir = getuserdir %GETUSERDIR return the user home directory. % USERDIR = GETUSERDIR returns the user home directory using the registry % on windows systems and using Java on non windows systems as a string % % Example: % getuserdir() returns on windows % C:\Documents and Settings\MyN...
b9079b535e4a2f7afa37b74daa7d20eadf8588cca18f1aced84c8323d687c816
MATLAB
641
23
function V = VBA_getVar(Sigma,T) % gets the time-dependent variances % function V = VBA_getVar(Sigma,T) % This function gets the (possibly time-dependent) variance stored in a % cell array of covariance matrices. % IN: % - Sigma: the cell array of covariance matrices % - T: the index of the end of the time series %...
eed76cb05a430f1ade3b0d21a2b022da2be3ee5ee3118802f0d13399f15c841d
MATLAB
641
31
function [ accept data ] = get_accept(data,accept) % <*LAN)<] % v.0.0.1 % % 22.06.2012 % Pablo Billeke if nargin==1 % get_accept(LAN) accept = data.accept; data = data.data; end % fix accept vector if any(accept>1) paso = false(1,length(data)); paso(accept); ...
60d67d6218ed1d1bcf0370f5651a99ca5a6e662298d368afac9f105e44dba001
MATLAB
642
23
function [pID,pN] = FDR(p,q) % FORMAT [pID,pN] = FDR(p,q) % % p - vector of p-values % q - False Discovery Rate level % % pID - p-value threshold based on independence or positive dependence % pN - Nonparametric p-value threshold %______________________________________________________________________________ % $I...
a05c5c9efc7511689ac966195aa77b726638d5cd0380fd18e791850a7e65d375
MATLAB
642
48
%%% Replay the set of solution vectors: if ~exist('param_list'), if ~exist('solution'); fprintf(1,'Error: Need to calibrate first\n'); return; else param_list = solution; end; end; N_iter = size(param_list,2); if N_iter == 1, fprintf(1,'Warning: There is a unique state in the list of ...
edb58d2bf32fb4ccb7afef88e1ae0f9baaa2d4a9bc6048c48b057bef6ef832b0
MATLAB
642
29
function [dprime, criterion] = rd_dprimeWeighted(nh,nfa,nsignal,nnoise,faWeight) % [dprime, criterion] = rd_dprimeWeighted(nh,nfa,nsignal,nnoise) % % nh = number of hit trials % nfa = number of false alarm trials % nsignal = number of signal trials % nnoise = number of noise trials % inputs if nargin<5 faWeight =...
2305e3cf17452d9648c7ae3bbcb34913eb1b15688d5b7d66925716d41a3a3de7
MATLAB
643
26
function [gx] = g_discounting(x,P,u,in) % delay discounting 2AFC observation function t = u(in.ind.t); R = u(in.ind.R); switch in.model case 'hyperbolic' k = exp(P(in.ind.logk)); v = R./(1+k.*t); case 'exponential' k = exp(P(in.ind.logk)); v = R.*exp(-k.*t); case 'linear' ...
bc5a1145dca0a7d0703beec84b61b28f859e97895574bebc11978787115830b6
MATLAB
643
21
function [ clean_brain ] = cleanSmallClusters( brain, minimal_cluster_size, cluster_numbers ) %the function receives a binary brain and removes too little clusters. use %cluster_numbers to mark each cluster with an integer (instead of a binary %mask if nargin<3 cluster_numbers = 0; end CC = bwconncomp(brain,18); ...
dffdfa442702ec47cd97634676020c7edd292a0045fb445415d8630d851f0ea1
MATLAB
643
27
function [postMean, postCov] = ppcaInfer(X, W, mu, sigma2, evals, evecs) % Probabilistic PCA - compute posterior on Z % postMean(i,:) = E[Z|X(i,:)] % postCov(:,:) is the same for all i % This file is from pmtk3.googlecode.com warning('ppcaInfer is deprecated; use ppcaInferLatent') [d K] = size(W); [N d] = size(X); L...
04a7b3b60695aefebea3b68c023c561e02e32d73db5e1c3c3a75a147f675e20a
MATLAB
644
34
function S = uniformSample(arg1, arg2, arg3) % Sample n uniformly distributed random numbers in the range [a, b]. % (Note, n can also be a size vector as in sampleUniform(model, [3,2]), % yielding a 3x2 matrix of numbers. % S = sampleUniform(model, n); OR S = sampleUniform(a, b, n); % This file is from pmtk3.googleco...
1c73c10d0e4f67b557bfad523c9c23eaa73f4e985567d1f83fc0aff1bfb996ff
MATLAB
644
19
function [ISD,integration,segregation,ML_efficiency,ML_clustering] = ISD_calculation(FC_noGSR, FC_GSR) % calculate multilevel efficiency and clustering at different thresholds ML_efficiency = nan(1,100); ML_clustering = nan(1,100); for threshold = 1:100 [~,ML_efficiency(threshold)] = charpath(distance_bin(FC...
3d95e661c2c1d142b8ae6188d688e7f33dc57e4641f4c2411eaa570a6f7a99e1
MATLAB
644
31
function convertResultsToTrx(infile,frontout,sideout) %% Q = load(infile); %% ts = now; Jf = struct; nd = size(Q.pfrontbest,1); npts = size(Q.pfrontbest,2); nfrms = size(Q.pfrontbest,3); Jf.pTrk = permute(Q.pfrontbest_re,[2 1 3 4]); Jf.pTrkTS = repmat(ts,[npts,nfrms,1]); Jf.pTrkTag = cell([npts,nfrms,1]); Jf.pSampl...
a0c1c1eefee438fdddb094103397c1d6fdac5f9bc66d6cbf6aedebdef3c7c46f
MATLAB
644
31
%% boxplot of the Michelson-Morley data % Based on http://en.wikipedia.org/wiki/File:Michelsonmorley-boxplot.svg % PMTKneedsStatsToolbox boxplot %% % This file is from pmtk3.googlecode.com requireStatsToolbox loadData('morley'); for notched = [false true] %notched = true; figure; if(notched) boxplot(Speed, Expt, '...
abca520e91f9266da0f74bb15dcb047f14f8170d9d91e7350e0c85c82a56f3c4
MATLAB
644
27
function [lblDate,lblCat,frms,fly] = findMovDateCat(movID,lblDate,lblCat,frms,fly) movID = unique(movID); assert(isscalar(movID)); movID = movID{1}; fly = unique(fly); assert(isscalar(fly)); lblDate = cellstr(lblDate); lblDate = unique(lblDate); ndate = numel(lblDate); if ndate>1 fprintf('movID %s, %d dates: %s. c...
d27c71bd2ed36de37710727b077e046520a96e350fdd7ba69d295937e4b63c6f
MATLAB
644
23
function H = hdiFromSamples(samples, mass) % Compute 1 highest density interval from bag of samples % Based on p628 "Doing Bayesian Data Analysis" Kruschke 2010 % Example: 95% HDI for beta(3,9) is [0.045, 0.49] % setSeed(0); a= 3; b = 9; hdiFromSamples(betarnd(a,b,1,10000)); % See also hdiFromIcdf if nargin < 2, mass ...
888518fb68cbaf417c9a3c0011396bff9b92ba161be4bc3acad4b349880ebee5
MATLAB
645
30
function m = getenvall() % Return a containers.Map of all environment variables and their values. % % Based on % https://stackoverflow.com/questions/20004955/list-all-environment-variables-in-matlab if ispc() cmd = 'set'; else cmd = 'env'; end [~,out] = system(cmd); vars = regexp(strtrim(out), '^(.*)=(.*)$', ... ...
aa429f706aee50e538262ca01f3b51d995de08f5de8136ec1930f107e1039758
MATLAB
645
28
function cols = getcols(labs) % _ % Get DELCODE plotting colors % get number of labels num_labs = numel(labs); cols = zeros(num_labs,3); % determine RGB triplets for i = 1:num_labs switch labs{i} case 'young' cols(i,:) = [ 0, 176, 80]; case 'older' cols(i,:) = [ 0, ...
c627e5ccfa9c283b0afbdd396cccec14223cd601ac7f11b7f5102bb2c3dd4099
MATLAB
645
22
% TRI3GEOM Centroid, unit normal, and area of a triangle in 3D. % % [C,N,A] = TRI3GEOM(V) produces the centroid C, unit normal N, and area A % of the triangle with vertices V. % % [C,N,A] = TRI3GEOM(V,F) computes the centroid, normal, and area of each % triangle I with vertices V(:,F(:,I)). function [C,N,...
c8fe71861b96ce9b8ac61546fcaa7224ccfad11d7b9b0551b9ea7cd3c8667737
MATLAB
645
12
function nc_spm_coreg_subject(coreg_matfile, t1_file, other_files, interp, prefix) % interp: 0 for nearest neighbor; 4 for 4-order B-spline SPMJOB = load(coreg_matfile); SPMJOB.matlabbatch{1, 1}.spm.spatial.coreg.estwrite.ref={t1_file}; SPMJOB.matlabbatch{1, 1}.spm.spatial.coreg.estwrite.source=other_files(1,:); i...
f5abad186efe82af03fb121b72a7e34762c1f62cd91e643daf86c14381d49ce0
MATLAB
645
31
function [lo,hi]= findcontiguous(x, order) %function [lo,hi]= findcontiguous(x, order) % % Find the beginnings (lo) and ends (hi) of contiguous values in x. % E.g. x= [1 2 5 6 7 8 10] results in % lo= [1 5 10] % hi= [2 8 10] lo= []; hi=[]; if ~isempty(x); if nargin<2; order= 1; end if ~any(siz...
faa242418fffd83cd1043a53efa75713216800f0ba2c940a870a31d9e42e82aa
MATLAB
645
18
function R = gui_q(text,del) if nargin==1; del = {''};end; R = {}; % text = 'prueba'; del='' if ischar(text); text = {text}; del={del};end; %global H H = figure('Position',[300,300,300,100],'Menu','none'); for e = 1:length(text) uicontrol(H,'Style','Text','String',text{e},'Position',[10...
2cc894d91284a311e8829d1fa8c84e5f712c7d99cfdca78e516e1597eea75235
MATLAB
646
22
function [fx,dfdx,dfdP] = logExp(x,P) % approximates the mappings y=a at x=-Inf and y=b(x-c) at x=Inf % [fx,dfdx,dfdP] = logExp(x,P) % IN: % - x: the variable to be passed through the logExp mapping % - P: parameters of the logExp mapping (P = [a b c]) % OUT: % - fx: the logExp mapping % - dfdx: the gradient w...
473e074a09ab134945cb6dec4ba4ed6e211d6ef9d2f7cc73a6d6672f15a5a7b8
MATLAB
646
22
function [rotMat] = EPG_Operator(alpha,phi,E1,E2,LongitudinalState) %% %Define components TtoT=E2.*(cosd(alpha/2)^2); T180toT180=E2.*(cosd(alpha/2)^2); LtoL=E1.*cosd(alpha); T180toT=exp(1i*2*phi)*E2.*(sind(alpha/2)^2); LtoT=-1i*exp(1i*phi).*E2.*sind(alpha); TtoT180=exp(-1i*2*phi)*E2.*(sind(alpha/2)^2); LtoT180=1i*exp(-...
ac084b14bea5772f3f0e5ad006edcf8e21eb0a39273e6c222a30e03d66a3b792
MATLAB
646
28
%% HMM Self Loop % %% % This file is from pmtk3.googlecode.com Ls = 1:10:600;%1:10:1000; ns = [1, 2, 5]; %1:5; p = 0.99; figure; hold on; [styles, colors, symbols] = plotColors; logp = log(p); logq = log(1-p); legendstr = cell(length(ns), 1); h = zeros(length(ns), 1); for i=1:length(ns) n = ns(i); ps = zeros...
0a8db5abd70f2cd8502ab491f5f11bc908a554ed437ea0f3447c91e69af5498d
MATLAB
647
29
% measures SNR in all folders in the current directory % function data = measure(look_here, UseCache) if nargin == 0 look_here = pwd; UseCache = true; elseif nargin == 1 UseCache = true; end all_folders = filelib.getAllFolders(look_here); for i = length(all_folders):-1:1 data(i).file_name = categorical(NaN(10...
3230d17409296306b88b1816d6b05f3bf7f88c25504f55e5bd4a16201ea0b4b0
MATLAB
647
25
function [pX] = treegmPredictMissing(model, X) % X(n,d) may be Nan % pX(n,d,v) is predictive distribution for node d in case n [N,D] = size(X); [~, X3d] = dummyEncoding(X, model.Nstates*ones(1,model.Nnodes)); % X3d(n,d,v) for n=1:N softev = squeeze(X3d(n,:,:))'; % softev(v,d) miss = isnan(X(n,:)); % replace h...
3f96d35d4a4897d47d8f7ee4d1a17702f41be9f8af830f17ea4100c45cefb318
MATLAB
647
46
function mychmod(varargin) if nargin < 1, d = '.'; else d = varargin{1}; end if nargin < 2, args = {'g+rw'}; else args = varargin(2:end); end if ~exist(d,'file'), error('File/directory %s does not exist',d); end mychmod1(d,args); function mychmod1(d,args) try cmd = ['chmod ',sprintf('%s ',args{:}),'...
4d40365fa198a22d4556c85af579d66fe5cbc5cb28db26d4b1b56f42201aa441
MATLAB
647
26
function y=temp_variance(data,frame,overlap,type) %Computes the temporal variance of signal using moving window. %Written by Su Liu if nargin<4 type=1; end if isscalar(frame) winlength = frame; window = ones(winlength,1); elseif isvector(frame) window = frame; winlength = length(frame); end lx=len...
5815a2319254552474f3f0c8d10259e21e013ab8393a0172db167fafd6c45fee
MATLAB
647
27
function fprintf_cell(fid, cell,format ) % Easy loop for write a file % % % %---% parameter if nargin < 3 % for dfault each cell is a line format = ' %s \n '; end %---% loop for i = 1:length(cell) fprintf(fid,format, cell{i} ); end %fprintf(fid,' %s \n ',['ccc = 0'] ); %fprintf(fid,' %s \n ',[...
06df49f65176fa5e49e90f4863fd237ae36cb37ff5b134f57fe6e88b3eebb038
MATLAB
648
26
function net = clfSvm(varargin) % Wrapper for svm that makes svm compatible with nfoldxval. % % Requires the SVM toolbox by Anton Schwaighofer. % % USAGE % net = clfSvm(varargin) % % INPUTS % see svm in SVM toolbox by Anton Schwaighofer. % % OUTPUTS % see svm in SVM toolbox by Anton Schwaighofer. % % EXAMPLE % % See...
2804fde8b2f57c53f74c73d98c770ec756ac32b565bc271d99416bfcca2229ce
MATLAB
648
29
function [Sx,dsdx,dsdp] = g_sigm_binomial(x,Phi,u,in) % evaluates the sigmoid function for binomial data analysis try in.x; catch in.x = 0; end if in.x % for learning effects (sigmoid parameters evolve over time) [Sx, ~, dsdx] = VBA_sigmoid(u, ... 'slope', exp(x(1)), ... 'center', x(2), .....
3e9c6f5696e5c18f8e5f5744b3af42c02ced06cbcc53accbdd356373b6d196e8
MATLAB
648
39
function [dABdA,dABdB] = dAB(A,B); % [dABdA,dABdB] = dAB(A,B); % % returns : dABdA and dABdB [p,n] = size(A); [n2,q] = size(B); if n2 ~= n, error(' A and B must have equal inner dimensions'); end; if issparse(A) | issparse(B) | p*q*p*n>625 , dABdA=spalloc(p*q,p*n,p*q*n); else dABdA=zeros(p*q,p*n);...
413ec40e89eb1d4c295abfb300626305bf08aa77dcea0c969c0e1d707b5679ce
MATLAB
648
18
function dataSets = scrapePmtkData() %% Scrape pmtkData.googleCode.com to get the names of all the data sets there % This file is from pmtk3.googlecode.com excludedDirs = tokenize(getConfigValue('PMTKmetaDirs'), ',')'; url = 'http://pmtkdata.googlecode.com/svn/trunk/'; raw = tokenize(urlread(url), '\n'); dataSets =...
53a60a01ee95f8544f8ee2565b5aeb0f4fae37c118b2763b8f7d9e97ff69348c
MATLAB
648
35
function varargout = fname(varargin) % Format % For getting the value % dat = fname(obj) % % For setting the value % obj = fname(obj,dat) % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id$ if nargin==2, varargout{1} = as...
7e059dfd97c17492ecf5c6531f648c2d0c934cf3d64ee99ea369767b62de4b80
MATLAB
648
23
function beta = elasticNet(X, y, lambda1, lambda2, lassoSolver, varargin) % elastic net is L1 + L2 regularized least squares regression % We assume X is standardized and y is centered % lassoSolver must have this interface: % w = lassoSolver(X, y, lambda1, varargin{:}) % See also elasticNetPath % This file is from ...
db96df93c667dfbf6b6ee4e249cd1b852c03a4754930420d8d37c1125af6ee43
MATLAB
648
28
function [c1, c2, c3, n_channels] = load_detect_chanells(tif_name) % 1. Detect a number of channels % 2. TODO: Detect the cell and nucleus channels c3 = 0; % ------------------------------- Read from tif ------------------------------- n_channels = detect_number_of_channels(tif_name); tif_matrix = loadtiff(['...
e1c48abdd01c531bee431c9676ea4d9f4481958456319091f08d3f69fb665261
MATLAB
648
31
% [x1,x2,y1,y2] = ellipse_to_bounding_box(x,y,a,b,theta) function [x1,x2,y1,y2] = ellipse_to_bounding_box(x,y,a,b,theta) if abs(cos(theta)) < eps, x1 = x-b; x2 = x+b; y1 = y-a; y2 = y+a; elseif abs(cos(theta)) > 1 - eps, x1 = x-a; x2 = x+a; y1 = y-b; y2 = y+b; else phix = ...
fb7c4c877c1afa43c1a908055902220dfeb13d907b520aff6503293cd4b0cd3b
MATLAB
648
30
function [matrix_final_0,p]=delete_matrix(matrix) % transform a(i,j)=a(j,i) matrix=matrix-diag(diag(matrix)); matrix=trans(matrix); matrix=triu(matrix); p=[]; for i=1:size(matrix,2) if sum(matrix(i,:))~=0 || sum(matrix(:,i))~=0 p=[p;i]; end end matrix_...
0080031f5bfe770ae288dcd89d53144b420f8067f441fd952f020c8d2329df3b
MATLAB
649
15
function populate_callbacks_bang(control, controller) % Populate the Callback property for a single control, setting it to call the % generic controlActuated(tag, source, event) method on the supplied % % controller. But only do this if the Callback property is empty---don't % overwrite existing callbacks. Do the sam...
1f636384ee2eb05d3e598f752d57e9664ed5b62ce4b6d325192b5405d8bbea23
MATLAB
649
18
function C = VBA_spm_mesh_curvature(M) % Compute a crude approximation of the curvature of a surface mesh % FORMAT C = spm_mesh_curvature(M) % M - a patch structure % % C - curvature vector %__________________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Cent...
24c7da5633fa8a22a893ebf8c8ebe03ebacd871bcc79c82a51c21b0ea8f7642c
MATLAB
649
25
function previewPublished(fname, evalCode, outputDir) %% Preview what the published result of the demo will look like % % If evalCode is set to false, (default true), the demo is not run and only % text is published. %% Example % publishPreview mixGaussVbDemoFaithful % PMTKneedsMatlab % This file is from pmtk3.googl...
9718148cc38e34bd9b8605f88f41abe526bbef31c89a42dae0608b4556c135fa
MATLAB
649
18
function ctranspose(x) %CTRANSPOSE is not defined for tensors. % % See also TENSOR/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. Unde...
da3ce7e5485cbc5e81dce75273fa00ad6eea7042c84fb1b1bf7650e49075c1a1
MATLAB
649
31
function [theta] = get2VecAngle(v,u,n,plotFig) % get2VecAngle Find the angle between 2 vectors % % Inputs: % v: vector 1 % u: vector 2 % n: vector normal to plane that vector 1 and 2 resides in % Outputs: % theta: angle in degrees between bectors 1 and 2 if isempty(n) theta = acosd(dot(v,u)./(norm(v...
e2c57628a1443acfc6f9d77566c46c13ae9676689cf21651c5d074aff79e06c5
MATLAB
649
24
function [Max_Out, Min_Out, Median_Out]=Max_Min_Median(InputData) InputData(InputData==Inf)=NaN; InputData_Clean=[]; if size(InputData,1)>size(InputData,2) for i=1:size(InputData,1) if ~isnan(InputData(i,1)) InputData_Clean=[InputData_Clean,InputDa...
ed4433686045837c43594f7ff2dacb7dc4b9ff73777c29eef7a0990b6cca2317
MATLAB
649
20
function stderror = HumanOdorRep_std_error(X) % function stderror = HumanOdorRep_std_error(X) % calcualte standard error for given data %----------------------------------------------------------------------------------------- % Kehl et al. 2024 (DOI:XX) % Single-Neuron Representations of Odors in the Human Brain % Aut...
7932d8d1761106f0da381e85aa4fa54ba2d5e156aa571178fa9235fc971909e7
MATLAB
650
22
% _ _ % ___ _ __ __ _| |__ ___ ___ _ __| |_ % / __| '__/ _` | '_ \/ __|/ _ \| '__| __| % | (__| | | (_| | |_) \__ \ (_) | | | |_ % \___|_| \__,_|_.__/|___/\___/|_| \__| % % this is a plugin for crabsort.m % reduces spikes to a amplitude, measured from the minimum to p...
fff78247f57b21387976749e98afda679aa7baf9ca6e1ea45a74aadb68c9612d
MATLAB
650
34
function X = laplaceSample(arg1, arg2, arg3) % X(1:n, j) ~ laplace(mu(j), b(j)) % X = laplaceSample(model, n); OR X = laplaceSample(mu, b, n); % See http://en.wikipedia.org/wiki/Laplace_distribution % This file is from pmtk3.googlecode.com if isstruct(arg1) model = arg1; mu = model.mu; b = model.b...
31fac3491aab1dfa6cb19ed4219eb0eaea7a13292a06be16a52f24046102c808
MATLAB
651
27
%{ Copyright (c) 2025 Axion BioSystems, Inc. Contact: support@axion-biosystems.com All Rights Reserved %} classdef ChannelID < handle %ChannelID Representation of ChannelID class in AxIS % % Artichoke: Numerical amplifier number (e.g., 0-11) % % Channel: Numerical channel number (e.g...
4b739d58fc995258afd690ca0d986affdf10e9a0c4877ea04c2747cf40949501
MATLAB
651
25
function [A, z] = normalize(A, dim) % Make the entries of a (multidimensional) array sum to 1 % [A, z] = normalize(A) normalize the whole array, where z is the normalizing constant % [A, z] = normalize(A, dim) % If dim is specified, we normalize the specified dimension only. % dim=1 means each column sums to one % dim=...
cd1d0a04adace93fe59a00a1e75a99a34dcbbf8d9d610d1f742e08ba549d06db
MATLAB
651
25
function [p,t,pix]=fixmesh(p,t,ptol) %FIXMESH Remove duplicated/unused nodes and fix element orientation. % [P,T]=FIXMESH(P,T) % Copyright (C) 2004-2012 Per-Olof Persson. (See DISTMESH) if nargin<3, ptol=1024*eps; end if nargin>=2 & (isempty(p) | isempty(t)), pix=1:size(p,1); return; end snap=max(max(p,[],1)-min...
0cececcbf628c5d5334addfb62f978c81d03b772da0de1229e87c9211d41f091
MATLAB
652
28
function out = slices2mosaic(mat,fillValue) if nargin < 2 fillValue = 0; % Default to filling with zeros end x=size(mat,1); y=size(mat,2); z=size(mat,3); %t = size(mat,4); % find the side length of the mosaic image (number of images) m_side = ceil(sqrt(z)); % create...
29b39204b421396d93bc8fa1d992038f9a7027f25d5adb76f59f7448ebb2ee58
MATLAB
652
22
function out = averageLocalStrain_2D_qst(X,epsilon) % averages the strain field epsilon by averaging the epsilon tensor % values over the nearest neighbours of the off particle NNacceptance = 2; %8 2.3 second minima of g(r) NNsq = NNacceptance * NNacceptance; N = size(X,1); averagestrain = zeros(N,1); for n0 = 1:N ...
3dc1547a2712ec73106ef3c2a40e3869fc9f54a4b8759140494750a2a27f641a
MATLAB
652
30
function yred=rednoise(N,g,a); % REDNOISE: A fast rednoise generator using filter. % % example: rednoise(N,g); % % Description: generates a rednoise series % with zero process mean. % note: statistical mean&variance will be different. % % Inputs: n - desired length of time series % g - lag-1 autocorrelation % ...
c783a2ee2e66182007b26a13774fb17b7800be754380c8a1ab6c615b12e2dfcb
MATLAB
652
9
function [t_food_mat,t_food_err_mat,L_mat,trials_mat] = get_tfood_plot_matrices(si_exp,L_values,trial_values) get_t_food = @(si) reshape(arrayfun(@(a)mean([a.trial(:).t_food]),si.learning_stage),[],1); get_t_food_err = @(si) reshape(arrayfun(@(a)func.stderr(double([a.trial(:).t_food])),si.learning_stage),[]...
2da8f6bcef96750a6e1b7500c720ded631d9484f9f4f23cc187f7ace4711e967
MATLAB
653
17
% SPGET Sparse matrix access. % % S = SPGET(A,I,J) returns S = FULL(A(I,J)). % % This function exists because computing A(I,J) appears to be quite slow in % some versions of MATLAB, requiring O(N) time, where N = SIZE(A,2), say (we % have only tested square matrices), even when A has only a constant number...
77dd65bf34a6d7530847983aeba7063ece9f5181fc5c3c71bd336b03a81d79cf
MATLAB
653
20
function [Gamma,Gamma1,Gamma2,Gamma3,rho] = get_Gamma(rho0,u,r,nt,dt,par) % Created by Xinan Chen % This function is to calculate the cost functional Gamma under given velocity % field u, relative source function r and its indicator function K if K is used. % Gamma(u,r) = Gamma1 + alpha*Gamma2 + beta*Gamma3 % Ga...
7a2a7b60eb6a43b041999fd6ec502023442c36ff9b7c8bbe9e59a9629faa833f
MATLAB
653
29
function value = line_exp_is_degenerate_nd ( ndim, p1, p2 ) %% LINE_EXP_IS_DEGENERATE_ND finds if an explicit line is degenerate in ND. % % Discussion: % % The explicit form of a line in ND is: % % the line through the points P1, P2. % % An explicit line is degenerate if the two defining points a...
a35a0803a74ea69d515d856036b8a2fd40ca50c5a842cef71b26676afb601656
MATLAB
653
24
function [NNidx,Tidx,TNidx]=IM2idx(IM) % % This function provides indexing into module pairs for fast reference based % on the IM structure of a grouped network. Nroi=length(IM.key); Nnets=max(IM.key(:,2)); Tidx=find(tril(ones(Nroi),-1)==1); TNidx=find(tril(ones(Nnets),0)==1);% Lower triangle w main diag for...
ac766239a278266c4ab467f66df3b5cc8b86821e6e0a00bd4877dbc7fe53f689
MATLAB
653
28
function [model, logev] = linregFitBayesJeffreysPrior(X, y, pp) % Bayesian inference for a linear regression model with uninformative prior % This file is from pmtk3.googlecode.com [model.preproc, X] = preprocessorApplyToTrain(pp, X); [N,D] = size(X); % Posterior on w %[model.wN, model.VN] = normalEqnsBayes(X, y,...
df289e7afe9a82eda5f5bf6f376717b9904e2ec448c731af18f290d61fb12e2e
MATLAB
653
34
%{ _ _ ___ _ __ __ _| |__ ___ ___ _ __| |_ / __| '__/ _` | '_ \/ __|/ _ \| '__| __| | (__| | | (_| | |_) \__ \ (_) | | | |_ \___|_| \__,_|_.__/|___/\___/|_| \__| # getFileSequence **Syntax** ``` C.getFileSequence() ``` **...
1e9b1f15f51c503b63a2a11115076e62045dc54c806128ecc328ba93aa3c568f
MATLAB
654
17
function [icat,cats] = shmovieCat(m) tf = [... ~isempty(regexp(m,'pre2016_trainingData_kineFormat_blindToErrors','once')) ... ~isempty(regexp(m,'2016_trainingData_blindToErrors','once')) ... ~isempty(regexp(m,'18012017_trainingData_errorTargetted','once')) ... ~isempty(regexp(m,'Nov201...
22127d71c3e63c5d20f4029d4fa5f5f1a7506d31493af3cb626d2e2139b4c346
MATLAB
654
32
function [ npoints ] = chosePointsForPatlak( tissue,Cp,Cpint ) if ~any(tissue) npoints=8; disp(' !!! WRN: NO TACs found in IDWC FILE!!!') disp(' !!! WRN: PATLAK SETS as DEFAULT [8 samples]'); else X=Cpint./Cp; Y=tissue./Cp; [m,i]=max(Cp); figure plot(X(end-10:end),Y(end-10:end),'*'); hold o...
295cdf6a74eeca38c974026b4db947108ed3e9c7124826d18fd32de3463b7c6e
MATLAB
654
32
function S = poissonSample(arg1, arg2) %% Sample n integers from a poisson distribution with parameter lambda %S = poissonSample(model, n); OR S = poissonSample(lambda, n); % This file is from pmtk3.googlecode.com if isstruct(arg1) model = arg1; lambda = model.lambda; else lambda = arg1; end if nargin <...
42e189081f4c310c206c0d922139eb341ed03d7017d33129aaf25dab26f7b9e3
MATLAB
654
18
function transpose(x) %TRANSPOSE is not defined on tensors. % % See also TENSOR, TENSOR/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....
893f4b7db887c737af6d47e3d36b4e65e02a413183fca5c361b27108500bbc60
MATLAB
654
36
function XYZmm = voxel2mm(XYZ,m) % :Usage: % :: % % function XYZmm = voxel2mm(XYZ,m) % % :Inputs: % % **XYZ:** % is 3 vector point list (3 rows, n columns) % % **m:** % is SPM mat - 4 x 4 affine transform % (what's stored in the .mat file) % % :Example: % :: % % XYZmm = voxel2mm([x y z]'...
bed03e9fc6bb7d5dbff74ca7b1bf9f197d578652f9908f5db65bafc1c763e03a
MATLAB
654
27
function [HC,EHC,gridx] = RFT_Euler(X,verbose) % derive induced Euler-characteristic mi = min(X); ma = max(X); dm = (ma-mi).*1e-2; gridx = mi:dm:ma; [out0] = RFT_expectedTopo(gridx,L,fwhm,1); EHC = out0.HC; HC = NaN(length(gridx),1); if verbose fprintf(1,'RFT: deriving Euler-Hadwiger characteristic ...') fprint...
eb8c741a0c7c1104c97aea026f1d307e3a12e9eb580c184dd59b067de835c4c7
MATLAB
654
28
%% Illustration of the concavity of the log function % %% % This file is from pmtk3.googlecode.com figure('Color',[1,1,1]); xmin = -1;xmax = 7; ymin = -2;ymax = 3; %axes axesLineSpec = {'-k','LineWidth',3}; plot([xmin,xmax],[0,0],axesLineSpec{:});hold on; plot([0,0],[ymin,ymax],axesLineSpec{:}); domain = 0.01:0.00...
f431135b55281f3642b0fb1354058249d1930f8f827776fb16e87d6a753a3e7f
MATLAB
654
25
function y = meanfilter(x,r,dir) if ~exist('dir','var'), if size(x,1) == 1 && size(x,2) > size(x,1), dir = 2; else dir = 1; end end sz = size(x); notdir = true(1,length(sz)); notdir(dir) = false; notdiridx = find(notdir); x = permute(x,[dir,notdiridx]); m = prod(sz(notdir)); x = reshape(x,[sz(dir),m]...
f588f4c681b858f083c3db2f3d1e9a79b901d4ff67586555e1ca6145e2483f60
MATLAB
654
16
function ep = find_evaluation_points( r, evaluation_angle, tol ) % *SPONTANEOUS WAVE DEMO* % % FIND EVALUATION POINTS find points at which the phase distribution % over channels passes a specified angle % (within numerical tolerance "tol") % % INPUT % r - ph...
32b1fa4cc49a97c51aa5535c8b9bf2f1f0afc2289184a8492d2ff35d5caf2974
MATLAB
655
27
function models = makeModelSpace(varargin) % Return a cell array of every combination of the inputs % Pass in one argument per dimension. Returns a cell array of every % combination of values. % % Example: % % lambdaRange = logspace(0, 100, 10); % sigmaRange = linspace(0, 10, 10); % % allCombinations = makeModelSpace(...
5418fb3113010527e1c03e2893ef4000400e1679684bafc9a37082e03b11731f
MATLAB
655
15
function setup = StateSwitch_settingsStroop(setup) % settings for Stroop setup.DEBUG = 0; setup.opacity = .4; setup.keyB = 1; % number of available keyboards setup.ET.useET = 0; setup.EEG.useEEG = 1; ...
70cec55b748864ae8266826c6faeefecaf90b39e503b6bf2f8bfb7ed0846073c
MATLAB
655
22
% HIFIE_MV Multiply using hierarchical interpolative factorization for integral % equations. % % Typical complexity: quasilinear in all dimensions. % % Y = HIFIE_MV(F,X) produces the matrix Y by applying the factored matrix F % to the matrix X. % % Y = HIFIE_MV(F,X,TRANS) computes Y = F*X if TRAN...
e6e45e28306ef0eb889c692eafe4e04c765ceda2b4d04e815559db8b14ab0b1f
MATLAB
655
31
function UpdateInterpColorLine(h,varargin) [x,y,z,colors,alphas] = myparse(varargin,'x','','y','','z','','colors','','alphas',''); args = {}; if ~ischar(x), x = x(:); x = [x;flipud(x)]; args(end+1:end+2) = {'XData',x}; end if ~ischar(y), y = y(:); y = [y;flipud(y)]; args(end+1:end+2) = {'YData',y}; end if...
0ffc6a764e2366571cd91ad270468a6421e8521f85c429bfcf0371201b1bc199
MATLAB
656
23
function [corr_value, p_value]=spearman_median(spike_id, spike_times, sorted_place_fields) c = 1; cell_IDs = []; median_spikeTime = []; for cell = 1 : length(sorted_place_fields) index = find(spike_id == sorted_place_fields(cell)); if ~isempty(index) cell_IDs(c) = cell; median_spikeTime...
40476c93c0ce344f8e19d31c8a7a0a65b3d4c1da839f4402f72a69f4f5236a94
MATLAB
656
27
function lead=calc_leadcorr_major_global(x,ori,para_global,shell); % calculates the corrections to the lead field coming from % a set of centers, for given type (type=1: singular at infinity, % type=3: singular at origin, type=2; both leadall=[]; para_exp=para_global{shell}.para; [ndum,ncenter]=size(para_exp); fo...
91d465d7ae3d9e81bc134b9a3caab10776b899377b1e22fded9238391d88cffc
MATLAB
656
35
%% Make the sprinkler dgm % Nodes are not ordered topogically! %% % This file is from pmtk3.googlecode.com function [dgm, C, S, R, W] = mkSprinklerDgmOutOfOrder(varargin) % C % / \ % v v % S R % \/ % v % W %% %C = 1; S = 2; R = 3; W = 4; % topological ordering %C = 2; S = 1; R = 3; W = 4; % rnd order...
99402568bd70ab43acbb92e0f645a9f6b73c0b9979fa8f1c69070b8e822fbafc
MATLAB
656
21
function P=ar1spectrum(ar1,period) % AR1 power spectrum... % % power=ar1spectrum(ar1,period) % % % (c) Aslak Grinsted 2002-2004 % % ------------------------------------------------------------------------- % Copyright (C) 2002-2004, Aslak Grinsted % This software may be used, copied, or redistributed as long as ...
ab9853075ada9147cd28727b6166a98c4819874a16dfab7c53223298d9e6e22f
MATLAB
656
21
%% Look at individual tasks for the clusters mkdir([DIRresultsRipple, '/tasks/']); the_min = min(trials_aligned_avg_all,[],'all'); the_max = max(trials_aligned_avg_all,[],'all'); for i=1:num_groups for q=1:length(task_data) q if(rand < 0.1) figure('visible','off','position', [200, 200,...
750bbc74c99df0d8f57f16a2419fa2da1f74a20f163d60b308ebac8785b06d99
MATLAB
657
25
function model = linregRobustStudentFit(X, y, dof, sigma2) %% Fit linear regression with Student noise model % This file is from pmtk3.googlecode.com if nargin < 3, dof = []; end if nargin < 4, sigma2 = []; end if dof==0, dof = []; end if isempty(sigma2) && isempty(dof) % estimate everything model = linregRobu...
868f4fbaa00e6b684024237b8af36ddf30b0e3379c374ed2c6ea948563b9e741
MATLAB
657
17
function [frame,timestamp]=read_seq_frame(seqinfo,frame_num) % read_seq_frame: function to read in a single frame from a seq file % % form: frame=read_seq_frame(fname_prefix,frame_num) % % fname is a string, the filename of the seq file to read a frame from % e.g. b6_popcage_16_110405_09.58.30.268.seq. % % fra...