sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
47cc55b13d24f69766aa1ca0808cde0de75e14df6b3815e8f5904a2ee69b0f0c
MATLAB
974
30
% Function which computes Factor Analysis (FA) % INPUTS: % data : data on which to perform Factor Analysis, % size: (number of neurons)x(number of timepoints) % zDimList : list of dimensions to try out for FA % numFolds : number of cross-validation folds for FA % OUTPUTS: % dim : results for...
77629a918db3c99ada74a0f5fda4d522c46990dec1400526c41d00e0968dd87c
MATLAB
974
64
% make graph for figure 1 of IRM paper by Kemp et al %{ % from TR 2004 G = zeros(9,9); G(1,[3 5 7 8 9])=1; G(2, 9) = 1; G(3, [7 8 9])=1; G(4, [2 3 7 8 9])=1; G(5, [7 9])=1; G(6, [2 3 5 7 8 9])=1; G(7, 4)=1; G(8, [6 7 9])=1 %} % FROM AAAI'06 G = zeros(9,9); G(1, [3 5 8])=1; G(2, [7 9]) = 1; G(3, [3 7 9])=1; G(4, [2 3...
953e2177c164fb379f1d9431ca03ddd94c8d233a8d0b194803107dee300bf033
MATLAB
974
35
function [nodeBels, logZ, edgeBels] = mrfInferNodes(mrf, varargin) %% Return all node beliefs (single marginals) % % mrf is a struct as created by mrfCreate % % Optional named args are the same as for dgmInferNodes % %% % This file is from pmtk3.googlecode.com [clamped, doSlice, args] = process_options(varargin, '...
b83c3169fbad1feae60af61be1885ec077ed317225355137d60467f72310db42
MATLAB
974
28
function [th,ah] = plot_trajectory(ax,traj,simulation,plotArgs) if (nargin < 1) || isempty(ax) figure; ax = axes; end if (nargin < 4) || isempty(plotArgs) plotArgs = {'LineWidth',2}; end th = gobjects(size(traj)); ah = gobjects(size(traj)); cmap = [ linspace(1,0.5,num...
8d33731773f3cdcaecd50087573432e13c2b59271f926696b920bbda595d3e43
MATLAB
975
22
clear all %% %Define Parameters [opt] = ParameterOptions(); %% %Define Parameters for Oscillating gradients - Consistent with Aggarwal et al. opt.nOscillations=3; % Number of oscillations per TR opt.Waveform='Sine'; % Type of Oscillating Gradient. Choose from Rect (conventional rectangular gradient), Rect_Sym (sy...
04c760e5f1f12a47de5edcfb65a9aeb53f3eba59d62d55f0c0bdcc49fd28d84a
MATLAB
976
38
% plot_FigS4 of LIP single trial paper %% load signals for plotting single trials and trial averages load(fullfile(saveLoc, 'sig_allSessions')) plotSig = {'Ramp', 'PC1', 'TinC'}; sigName = {'S^{ramp} [a.u.]', 'S^{PC1} [a.u.]', 'S^{con}_{Tin} [sp/s]'}; sigCohs = nanunique(sigSL.sig_coh); fWin = 80; fW...
7dc0cf0d5b090befb24c40fb2c0da9a28368a08d28d173bd2862fe534aebc9fd
MATLAB
976
28
% Functon that puts a figure on second monitor, if available. % From https://www.mathworks.com/matlabcentral/answers/16663-is-it-possible-to-viewing-the-figure-window-on-second-display function FigHandle = figure2(varargin) MP = get(0, 'MonitorPositions'); if size(MP, 1) == 1 % Single monitor FigH = figure(varargin...
c86198f8d8104c9a1b516d51b1c6cabffcb65499ef4aea960c097a166c7fd503
MATLAB
976
11
function PlotBox3D(ZPosition,BoundingBox,LineStyle,LineColor,LineWidth,Text,TextFontSize,TextFontColor) plot3([BoundingBox(1),BoundingBox(1)+BoundingBox(3)],[BoundingBox(2),BoundingBox(2)],[ZPosition,ZPosition],LineStyle,'color',LineColor,'LineWidth',LineWidth); plot3([BoundingBox(1),BoundingBox(1)+BoundingBox(3)],[...
e191da3c99ddcac299d57142e1f54c3f85b21a52eb73590fa50409517a4db151
MATLAB
976
46
function [] = unpack_struct(ss, ws) %unpack_struct Creates and/or assigns variables in the base workspace % % [] = unpack_struct(ss, [ws]) % % This functions creates or assigns variables as specified by the % field names and values in structure ss. % % For example, if ss consists of % % crap1: 123 % ...
503d2af8721547c4918dd00d9d1ec07b798bda316dbaa43d350858708f8fcb14
MATLAB
977
38
function A = VBA_orth (A, norm) % // VBA toolbox ////////////////////////////////////////////////////////// % % A = VBA_orth (A, norm) % Iteratively orthogonalize the columns of A. In other words, this function % considers each column serially to project it in the null % space of the previous columns of A. % % IN: % ...
a9a14277c941d691ecaac9d4deb065c8eecb1554893c06d5bfd7a0329ba21d77
MATLAB
977
45
%% Bayesian Sequential Updating of a Gaussian % %% % This file is from pmtk3.googlecode.com setSeed(0); muTrue = [0.5 0.5]'; Ctrue = 0.1*[2 1; 1 1]; xrange = [-1 1 -1 1]; n = 50; model = struct('mu', muTrue, 'Sigma', Ctrue); X = gaussSample(model, n); ns = [1 5 10 50]; figure; nr = 2; nc = 3; subplot(nr, nc,1); plot(...
e58942e9123ecd2368024c43752d7d81d2ab51aa6e93632547a3dbbf11663ec0
MATLAB
977
44
function varargout = myparse(params,varargin) nin = length(varargin)/2; nout = nargout; if mod(2*nin,2)~=0 || mod(length(params),2)~=0, error('Odd number of parameters expected'); end % set defaults varargout = varargin(2:2:2*nout); % parameter names names = varargin(1:2:end); % go through parameters for i = 1:2:...
f52d0771812b29a9ff1fec53cf80ccd326b0d9a35f76b7178e9b68c6b0ac9902
MATLAB
977
27
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % To identify the discharge times of the motor unit % Input: % w = weigths % X = whitened signal % fsamp = sampling frequency % Output: % icasig = MU pulse train % spikes2 = discharge times of the motor unit %%%%%%%%%%%%%%%%%%%%%%...
51c72cd15acef9ce4725d20ac926b402f0bf3dacaaaa773682158aaea0196901
MATLAB
978
38
%% MLP Classification Demo % Based on Mark Schmidt's Demo from % http://people.cs.ubc.ca/~schmidtm/Software/minFunc/minFunc.html#9 %% % This file is from pmtk3.googlecode.com H = [3, 6, 9]; for hi=1:length(H) nhidden = H(hi); setSeed(0); nVars = 2; nInstances = 400; options.Display = 'none'; options.MaxIter = 100; ...
bc348dd193d27efa7a94c145e9bda4c467ee571711f215e563dec3aedb29bf66
MATLAB
978
29
function yhat = dtpredict(tree,Xtest) % Predict output using a decision tree trained via dtfit. i.e. % tree = dtfit(Xtrain,ytrain); % yhat = dtpredict(tree,Xtest); n = size(Xtest,1); paths = {'right','left'}; if(isnumeric(tree.yhat) || islogical(tree.yhat)) yhat = zeros(n,size(tree.yhat,2));...
cb7d1ca3aedce68ff69fac7c78f5b8a91475a5b086fc247bfcf5f3492eeba571
MATLAB
978
40
% MF_SPDIAG_SV_P Dispatch for MF_SPDIAG with DINV = 1 and F.SYMM = 'P'. function D = mf_spdiag_sv_p(F,spinfo) % initialize N = F.N; n = length(spinfo.i); P = zeros(N,1); % for indexing D = zeros(N,1); % for output % loop over all leaf blocks from top to bottom for i = n:-1:1 % find active indic...
52f851aeae755b8adbdac1b22cc24c46d1bb4abb396fe7df5ddefa83aa01c544
MATLAB
979
38
function [nchannel, idxgrid] = getgridconfigQuattro(ports, adapter) % find the ports from the Quattrocento with a grid idxports = find(ports == 1); if ~isempty(idxports == 2) || ~isempty(idxports == 6) nchannel = 408; elseif ~isempty(idxports == 5) nchannel = 312; elseif ~isempty(id...
a19951a8ff6a0e0d0f4d7c77a5188b5e5fc6af6ad3f05878b115978bae5d6d06
MATLAB
979
48
function synchrot = plot_syncro_g(LANs) LAN = LANs{1}; cond = length(LAN); chanlocs = LAN{1}.chanlocs; for l = 1:cond p_val{l} = LAN{l}.phase.alpha; end for lan = 2:length(LANs) LAN = LANs{lan} for l = 1:cond p_val{l} = cat(2,LAN{l}.phase.alpha) end end %%%%%%%%%%%%%%%% alpha =p_val{1} ; for i = ...
17b59c1665e0893d8e12ecabd2c748109e853fe2c92ba93e1b105bea8f6831cd
MATLAB
980
34
function [z, r, logSumRho, logr, Nk] = mixGaussBayesInfer(model, X) % z(i) = argmax_k p(z=k|X(i,:), model) hard clustering % pz(i,k) = p(z=k|X(i,:), model) soft responsibility % ll(i) = log p(X(i,:) | model) logprob of observed data % % Calculate responsibilities using Bishop eqn 10.67 % This file is from pmtk3.googl...
32aff882419cdd87911ce23dbbad8eb4fc5df387717db9801ace6376ddea6b86
MATLAB
980
39
%% Plot a Dirichlet distribution in 3d %PMTKauthor Peter Perkins %PMTKurl http://www.mofeel.net/582-comp-soft-sys-matlab/86896.aspx % This file is from pmtk3.googlecode.com alphaVals = [10]; for alpha=alphaVals(:)' alphas = alpha*ones(1,3); x1 = linspace(0,1,101); x2 = linspace(0,1,101); [X1,X2] = ndgrid(x1,x2); X3...
5f19606eeab360e7515fdf6e7208b38f39e4991f18d8f09c8cd39a1181c66f81
MATLAB
980
40
function im = plotWindows(m,opts,vals) % %----------------------------------------- % im = plotWindows(m,opts,vals) % % plots window functions as an image, % can scale grayscale values of each region % % m: structure contining window functions % opts: structure with options (see metamerOpts.m) % vals: vector of weigh...
629494e98bb2284341e264c80141007aef74a0287a494023dd5969df87f61361
MATLAB
980
30
function [fx,dfdx,dfdP] = f_Qlearn2(x,P,u,in) % evolution function of q-values of a RL agent (2-armed bandit problem) % [fx,dfdx,dfdP] = f_Qlearn2(x,P,u,in) % Here, there are only two q-values to evolve, i.e. there are only two % actions to reinforce (2-armed bandit problem). % IN: % - x_t : q-values (2x1) % - P :...
87fd1aca77376af019cadf506d7fa40e5d3ef44810c42047316aa5b08c40ef10
MATLAB
980
30
%% Convert a dgm to a pairwise mrf % %% % This file is from pmtk3.googlecode.com dgm = mkSprinklerDgm; %% first compute marginals using dgmInferNodes nodeBels = dgmInferNodes(dgm); %% compare these to beliefs from equivalent pairwise fg (low level) fg2 = factorGraphMakePairwise(dgmToFactorGraph(dgm)); cg2 = cliqueGr...
c05701834d0847348d8aa02142b63375bd4dee8c174250d73b5022103a65a4ef
MATLAB
980
40
% MF_SPDIAG_MV_P Dispatch for MF_SPDIAG with DINV = 0 and F.SYMM = 'P'. function D = mf_spdiag_mv_p(F,spinfo) % initialize N = F.N; n = length(spinfo.i); P = zeros(N,1); % for indexing D = zeros(N,1); % for output % loop over all leaf blocks from top to bottom for i = n:-1:1 % find active indic...
3882239dfa4b456c6d92431acfc0b44d46d2ed05a4bd0745d343cb1e0d633a79
MATLAB
981
33
% VesselRegression.m % Sarah West % 9/14/21 % Runs hemodynamic correction by regressing pixels against blood vessel % timeseries. % RIGHT NOW THE BLOOD VESSEL MASKS AND THE NOW-MASKED bDATA ARE DIFFERENT % SIZES function [corrected_data]= VesselRegression(bData, vessel_masks) % Inputs: % bData-- a 2D matrix of all th...
89b35b8ef004b6c4e86d2615b5cef3241081c8f8466ea488a8e4857c06fbe95a
MATLAB
981
34
function [fx,dF_dX,dF_dTheta] = f_vanDerPol(Xt,Theta,ut,inF) % evolution function for the Van Der Pol (limit cycle) oscillator. % function [fx,dF_dX,dF_dTheta,d2F_dXdTheta] = f_vanDerPol(Xt,Theta,ut,inF) % IN: % - Xt: current hidden state % - Theta: evolution parameter % - ut: current input to the system % - in...
f658a9717f2a1a6724cc23b9af404b316a397670927c5d4dcce4483cdc4a2a28
MATLAB
981
39
satis_distort = 0; disp(['Estimated focal: ' num2str(f_g) ' pixels']); while ~satis_distort, k_g = input('Guess for distortion factor kc ([]=0): '); if isempty(k_g), k_g = 0; end; xy_corners_undist = comp_distortion2([x' - c_g(1);y'-c_g(2)]/f_g,k_g); xu = xy_corner...
72200746c75a727d73b3d568a96ea853e51912021b7b20974fcb025195a72080
MATLAB
982
36
function missing_files = check_raw_data() config = utils.get_studydetails(); missing_files = {}; for subj = 1:19 subjname = sprintf( 'sub0%02d', subj ); subjpath = fullfile(config.datadir,'raw_data',subjname); % Check fif locations for run = 1:6 runpath = full...
8dd0fb7723536f0a26e36ace4fe3c2106fbb86ae1631f53e002bf49427cf78c4
MATLAB
982
30
function f = makeVideo(axh, vname, outFormat) f = repmat(struct('cdata',[],'colormap',[]),1,numel(axh)); for i = 1:numel(axh) f(i) = getframe(axh(i)); end if strcmpi(outFormat, 'mp4') vw = VideoWriter(vname, 'MPEG-4'); %vw = VideoWriter(vname, 'Motion JPEG 2000'); vw.Qual...
a582245433fbf7842d391dbf53a66aa48d96bf47ed07401864c7254b52e5c47d
MATLAB
982
24
rgb = [0.1 0.4 0.5; 0.7, 0.4, 0.7]; areatxt{1} = 'lip'; areatxt{2} = 'fef'; for iArea = 1: 2 figtitle = upper(areatxt{iArea}); figure('color',[1 1 1]) vx=-1:0.025:1; ax(1) = gca; signHistNeg = hist(index{iArea}(h{iArea}(:,1)==1 & index{iArea}<0,1), vx); signHistPos = hist(index{iArea...
aab4f138d9a26385d30846bf6ba4a5852a1c3f5e6b05240510e03cfeb53cb820
MATLAB
982
31
function ret = make_links_in_color_correction_dir() ret = true; loadParameters; src_dir = relpath(params.colorCorrectionImagesDir,params.deconvolutionImagesDir); old_dir = pwd; cd(params.colorCorrectionImagesDir); FILEROOT_NAME = sprintf('%s-downsample',params.FILE_BASENAME); for r_i = ...
5c9c607afa8d1dba1989ece28c183ce0a48de06535d4050491c42bbcba52e64e
MATLAB
983
30
function B = full(A) %FULL Convert a sptenmat to a (dense) tenmat. % % B = FULL(A) converts a sptenmat A to a (dense) tenmat B. % % See also SPTENMAT, TENMAT. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www.sandia.go...
c38af5830318cc0dfacaf2cb966ed4404a72c83b1da68d77a9d3381d2e44e8b6
MATLAB
983
26
function ph = circle_sector(ax,x0y0,R,theta,color,n_points,varargin) % plots a circular sector centered at x0y0 = [x0, y0], with radius R, between angles theta(1) and theta(2) % remaining args are forwarded to patch function via set(ph,varargin{:}) % % returns patch handler assert(isnumeric(x0y0) && (numel(x0y0) =...
e8b0499ef80ab054c544dc10076c7babda6d51ebf07f87fc26fe7f53952f5433
MATLAB
983
25
% Copyright (C) 2023 Trevor S. Smith % Drexel University College of Medicine % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any l...
698f794f4754af861181a6e98eb7d3a79d39b3bd24f1bbda5e101cca1198da67
MATLAB
984
31
data = readtable('PSTHdata.csv'); data = table2array(data); [coeff,score,latent,tsquared,explained,mu] = pca(data); %Plot the two top PCs dataRed = score(:,1:3); labels = readtable('ClassLabels.csv'); labels = table2cell(labels); labelsWords = cell(1); labelsWords{1} = 'Onset+Inhib'; labelsWords{2} = 'OnSus+In...
dbab103da2aac61c2a581105d649b2c085dc63c7dec21a15e8ba433e8cedb041
MATLAB
984
31
load clab_example;sc=prepare_sourcereconstruction_highlevel(clab_example); loc=sc.cortex.vc; tri=sc.cortex.tri; locm=mean(loc); [nloc,ndum]=size(loc); relloc=loc-repmat(locm,nloc,1); dis=(sqrt(sum((relloc.^2)')))';thresh=3;dis(dis<thresh)=thresh; %map=colormap('jet');newmap=colormap_interpol(map,3);size(newmap);col...
66efcd4c7df110811597ddc77793b19855ddc23485ccf680204ef3902c0d98f8
MATLAB
985
39
function inds = fernsInds( data, fids, thrs ) % Compute indices for each input by each fern. % % USAGE % inds = fernsInds( data, fids, thrs ) % % INPUTS % data - [NxF] N length F binary feature vectors % fids - [MxS] feature ids for each fern for each depth % thrs - [MxS] threshold corresponding to each...
73d9959b7845b5fb857d8d0ed97816906a2f617e6b13ce99c3e360bc645ce7c6
MATLAB
985
31
% specify the location of this download in the line below: % eg download_path = '/home/disk3/ajquinn/HMM_frontiers_download'; download_path = ''; % <- change this line if isempty(download_path) error('Please specify the location of the download path inside hmm_0_initialise.m'); end if exist( download_path, 'dir' ...
b9e50030139a7a6f445616436b8ad08d03969dc2f3684ad8038947dadc196887
MATLAB
985
39
%% Classify some MNIST digits using a binary RBM %PMTKauthor Andrej Karpathy %PMTKmodified Kevin Murphy % This file is from pmtk3.googlecode.com setSeed(0); Ntrain = 1000; Ntest = 100; keepSparse = false; binarize = false; [Xtrain, ytrain, Xtest, ytest] = setupMnist('binary', binarize, 'ntrain',... Ntrain,'ntest...
0473164e6f49955218bea8c85c9b086f94f4d07313d14a5afa701a8c9f5e3cb8
MATLAB
986
42
%% Multinomial Bayes Factor demo % %% % This file is from pmtk3.googlecode.com function multinomIndepLogBF() counts = [... 15 29 14; 46 83 56]; [logBF] = helper(counts) pIndepOverDep = exp(logBF) end function [logBF] = helper(counts) Njk = counts; Nj = sum(counts,2); Nk = sum(counts,1); N = sum(counts(...
17a6bde18ffbc7156836dec70fd563fe6a360fbd400cdcc530d9784ac5783b4a
MATLAB
986
39
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% mni2cor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function coordinate = mni2cor(mni, T) % function coordinate = mni2cor(mni, T) % convert mni coordinate to matrix coordinate % % mni:...
290d1b8d26866a326ce34b8587d939705e6960d9d2c6b290136c9a204c8786dd
MATLAB
986
30
function [binnedRaster] = binRaster(rasterToBin, binEdges); %%% >>> OPERATION >>> % Binning of spike raster (moving sum of n nearby points, where % n=binEdges). % Probably slower than using sepblockfun function, but works even when % binEdges is not multiple of the number of time points. % >>> INPUT VARIABLES >>> % N...
497a93d8997808b67c9b2a172905cafb6f8899ab3f367f1f850660a26ecb616a
MATLAB
986
45
function outpoints = mni2tal(inpoints) % Converts coordinates from MNI brain to best guess % for equivalent Talairach coordinates % % :Usage: % :: % % outpoints = mni2tal(inpoints) % % Where inpoints is N by 3 or 3 by N matrix of coordinates % (N being the number of points) % % :Output: % % **outpoints:** % ...
5749f60ac1cc0a3530fd34e2f97c09a3736c6b0d6159aff63a8e07e027702d2d
MATLAB
986
31
function sz = size(a,idx) %SIZE Size of tenmat. % % D = SIZE(X) returns the two-element row vector D = [M N] % containing the number of rows and columns in the matrix. % % M = SIZE(X,DIM) returns the length of the dimension specified by % the scalar DIM. For example, SIZE(X,1) returns the number of % rows. ...
5a1e22b8d7883ba4e395c6d13af36bb00fda6dfcc021ac29055a5cdc8a9bda73
MATLAB
986
32
function [S] = plane_a380(iref) npatches = double(7834*(4^iref)); norder = 3; npols = int32((norder+1)*(norder+2)/2); npts = double(npatches*npols); srcvals = zeros(12,npts); srccoefs = zeros(9,npts); wts = zeros(npts,1); iptype = zeros(npatches,1); ixyzs = zeros(npatches+1,1); n...
978db1caf9a7fcaea1c1af7d5b30b75e1982977befa2eb54ec8acb631a967a3a
MATLAB
986
40
L1_m=[]; MED=[]; bef=input('baseline (s)='); dur=input('duration (s)='); dur=dur+bef; lab={}; for n=-bef:5:dur-bef; lab=horzcat(lab,int2str(n)); end %% for n=1:1:size(onset,2); [~, tr1_st_unit(n)]= min(abs(TIME-(onset(n)-bef))); tr1_ed_unit(n)=tr1_st_unit(n)+120*dur; MED=median(Tr_Ds_...
a7a189e93d0280e37e3dc6915d0f245c3b467b6ebc1b7aa3a60b1cd7769da5b7
MATLAB
986
52
load for_plots_mediation_norm_to_se.mat %% J = ismember({leverage.signal},'MinC'); J = find(J,1); L1 = leverage(J).per_session.self_mediated; J = ismember({leverage.signal},'MinI'); J = find(J,1); L2 = leverage(J).per_session.self_mediated; p = publish_plot(2,1); set(gcf,'Position',[556 205 288 607]); V = {'rh...
1e67c39170aeb074e2c7f0e426f6a550b4f63e3cc24917948e8ec0c7b5e4e78d
MATLAB
987
33
function mask2mesh_2D(bmpfile,pixeldim,edgesize,triarea,saveloc,type,offset) % mask2mesh_2D(bmpfile,pixeldim,edgesize,triarea,saveloc,type) % % creates a nirfast mesh from a 2D mask (bmp) % % bmpfile is the location of the bmp mask % pixeldim is the pixel dimension of the mask, 2 values, x and y % triarea is the desir...
25dedbe383327c234720599b0948bcd472c4fe18793d73f0ca137dc1ee7231d1
MATLAB
987
37
function [tf] = lObjGetIsLabeled(lObj,labelsfld,tbl,gt,fullylabeled) if nargin < 5, fullylabeled = false; % KB: set default to be any kps labeled end tf = false(height(tbl),1); for i = 1:numel(lObj.(labelsfld)), if gt, movi = -i; else movi = i; end idx = tbl.mov == movi; ...
97c30752fa38885b56c073628ff82b68e772f9b208b201b674a05c308c24ca89
MATLAB
987
45
%% singular function for implementing predictions % in time. This uses the iterative update method. % % Note that each probability vector is handled independently; % % sdo = Singlular SDO matrix to apply to px0 % % px0 = NSTATES x nObs column-vector array of initial probability. % % N_STEPS = This is the relative n...
9f465c5ec0e7539e9012cce45933d990a7767282957ba9ffc973d28767fcdeb1
MATLAB
987
33
function [niix, mapping, dummy] = get_niix(filenames,Dt) for i = 1:size(filenames,1) try nii = ea_load_nii(filenames{i}); if i == 1 % allocate space to speed up the process niix = zeros(size(filenames,1),size(nii.img(:),1)); mapping =...
a81481ba313fe264afa9f7bca57b40744f53a62aa613d8df231b0cdeee54b968
MATLAB
987
45
function [type,center,theta,foci,ecc,normform] = conic_properties(A,B,C,D,E,F) [type,x0,y0,theta,A2,B2,C2,D2,E2,F2] = conic_standard_form(A,B,C,D,E,F); % change from translation followed by rotation to rotation followed by % translation % x <- (x + u)*R % = x*R + u*R R = [cos(theta),sin(theta);-sin(theta),cos(theta)]...
ae2b8f2b8044b9b1827bf5cb518fc3186daab69f4c7f605cd93ced0c1c9ba6e9
MATLAB
987
32
function I = subsToArray( subs, vals, siz, fillVal ) % Converts subs/vals image representation to array representation. % % Constructs array from subs/vals representation. Similar to Matlab's % sparse command, except doesn't actually produce a sparse matrix. Uses % different conventions as well. % % USAGE % I = subs...
7a75570b6004e942049a9d82a032cb17ebb459cab9b5fb9aed6b637cc9b918a2
MATLAB
988
22
function [ax,rh] = plot_arena_circle(ax,mouse_track,plotArgs) if (nargin < 1) || isempty(ax) figure; ax = axes; end if (nargin < 3) || isempty(plotArgs) plotArgs = func.get_cell_set_default(plotArgs,'LineWidth',2,'EdgeColor','k','FaceColor',0.9.*ones(1,3)); end %if (nargin < ...
9ac2a38ea062d7c8d8ca3e2aae615e7ad31b2417e586e2d4ef14d0e1c71fbd54
MATLAB
988
44
function [y,labels] = generateGMM(n,lambda,mu,gamma,verbose) % % function y = generateGMM(n,lambda,mu) % This function generates n observations following a MoG distribution % given by the class frequencies lambda, their mean mu and their variance gamma. try, verbose = ~~verbose; catch, verbose = 1; end p = size(mu,1...
dd1e87bfb06ab763c1de69c6aee8ab19e46acb917cea0709a14b8d79a2c21c46
MATLAB
988
46
function [options] = VBA_check4DCM(options) A = options.inF.A; B = options.inF.B; C = options.inF.C; D = options.inF.D; TR = options.inF.deltat.*options.decim; microDT = TR./options.decim; if isfield(options.inG,'homogeneous') homogeneous = options.inG.homogeneous; else homogeneous = 0; end [odcm] = prepare_fu...
5b6d2e250cc0bc96efd429cca9966e4e185b43bf202155e6bcc40014616339f9
MATLAB
989
48
function plotPatches( A, cols) % display receptive field(s) or basis vector(s) for image patches % % A(:,i) is i'th patch, assumed to be square % cols number of columns (x-dimension of grid) % This file is from pmtk3.googlecode.com if nargin < 2 [nr nc] = nsubplots(size(A,2)); cols = nc; end %PMTKauthor Aa...
a88f304ee1598c866ad05240d02cb1efed6064c00d8e0c02c0cc856641ada945
MATLAB
989
30
function A = multiscale(scale, A) % Multiplies the 2D slices in a 3D matrix by individual scalars. % % function A = multiscale(scale, A) % % Given a vector scale of length N and a 3-dimensional matrix A of size % n-by-m-by-N, returns a matrix A of same size such that % A(:, :, k) := scale(k) * A(:, :, k); % % ...
e804790ff7187979f3528eb1c098fecbe12315380605034caa7e799b4668f283
MATLAB
990
40
function [lab, pos] = read_besa_sfp(filename, uniqueonly) % READ_BESA_SFP reads a besa style electrode location file. % % Use as: % [lab, pos] = read_besa_sfp(filename, uniqueonly) % % Input arguments: % filename = the file name % uniqueonly = flag to determine behaviour, to return the positions of the % ...
f750b4c79e757036097b69ef60fb3a4b4d14eaa2254e90137b2576ea8d269a08
MATLAB
990
36
function sz = tsize(a,idx) %TSIZE Tensor size of sptenmat. % % D = TSIZE(X) returns the size of the tensor being stored as a % matrix. % % M = TSIZE(X,DIM) returns the length of the dimension(s) specified % by DIM. For example, SIZE(X,1) returns the size of the first % dimension of the tensor. % % See al...
6453fafe452b51f907af017461ef07a3d7c86a6eb2ceabde29fa2eca968f427e
MATLAB
991
30
function inputfile = make_or_fetch_inputfile(reproducescript_dir, filename, varname, value) % MAKE_OR_FETCH_INPUTFILE is a helper function for ft_preamble_loadvar and ft_postamble_savevar, and % is used for the cfg.reproducescript functionality. % where to look for the hashes hashfile = fullfile(reproducescript_dir, ...
0ba0bc66696ff6b827622634fbd04215db058ecf5a708761733c038e81755e78
MATLAB
992
33
% extractEncoderData.m % Sarah West % 10/11/21 % Extracts rotary encoder data from .txt or PUTTY .log files and saves them % as .mat files. function [parameters] = extractEncoderData(parameters) % Announce what stack you're on. message = ['Extracting ']; for dispi = 1:numel(parameters.values)/2 ...
1f947545615d9ee1b7e9012d660a68c4ece36f82d92fc449eef46a56715b3039
MATLAB
992
13
function prec_shoot(fn_rp1,fn_rp2,fn_rm) matlabbatch = {}; matlabbatch{1}.spm.tools.shoot.warp.images = {fn_rp1;fn_rp2}'; matlabbatch{2}.spm.tools.shoot.norm.template(1) = cfg_dep('Run Shooting (create Templates): Template (4)', substruct('.','val', '{}',{1}, '.','val', '{}',{1}, '.','val', '{}',{1}, '.','val', '{...
70536e1cbb54215689970680169338909cc8437fc3b137540dffa2a3ae0b5527
MATLAB
992
25
areatxt{1} = 'lip'; areatxt{2} = 'fef'; rgb = [133 200 226;246 173 205;0 139 0;0 100 0; 255 165 0; 255 165 165]./255; for iArea =1:2 figure('NumberTitle','off','color',[1 1 1]) xaxis = timevector(rangetoAnalyze); imagesc(xaxis, 1: size(clustToPlot{iArea},1), -clustToPlot{iArea}) height = 0.5;...
8f84486c2b5fd4ce2745378df24f3949a23ff5177629cd8504b7c07ef4519f23
MATLAB
992
19
function fileList = getAllIntanFiles(dirName) dirData = dir(dirName); %# Get the data for the current directory dirIndex = [dirData.isdir]; %# Find the index for directories fileList = {dirData(~dirIndex).name}'; %'# Get a list of the files fileList=fileList(cellfun(@any,strfind(fileList,'.int'))); %onl...
ca4b09a5567f4d3a5d82fa9c268c84b19ce234013f59ca9d5ea97dda7187ad29
MATLAB
992
21
function fileList = getAllXFiles(dirName,ext) dirData = dir(dirName); %# Get the data for the current directory dirIndex = [dirData.isdir]; %# Find the index for directories content = {dirData(~dirIndex).name}'; if isempty(content) fileList = {}; else fileList = {ls([dirName '\*' ext]...
df4325036828f16f8a98f2db41383ccf48276ace4f53d56784d003b4808b32a9
MATLAB
992
44
function cl = iimg_princomp_display(volInfo,k,overlay,dofigs) % :Usage: % :: % % cl = iimg_princomp_display(volInfo,k,overlay,dofigs) % % Show output from iimg_princomp % % :Example: % :: % % cl2 = iimg_princomp_display(volInfo2,1,EXPT.overlay); tor_fig; plot(volInfo.eigval(:,k),'ko-','LineWidth',2); %overla...
62127aee8a8775da5f750656ff6d0891d95e412c41e469ee7c021608a4a1e9f6
MATLAB
993
40
function dtdisplay(tree) %A very simple visualizatiion of the tree, which shows the feature that was %used to split each node. figure('color',[1,1,1]); axis off; hold on; width = 10; height = 10; markerSize = 10; markerType = 's'; plot(0,0,markerType,'MarkerSize',m...
8b6439536b2e255e8bc2895512792148351ae6ce72a4741ecc70eabfee8bebb8
MATLAB
993
32
function [totvol tet_vol]=shell_volume(t,p,p0) % calculates the volume of 3D shell defined in t and p. % if p0 is provided then it will use it as its fixed point. % it will return the volume of the shell in totvol and individual vol of % each tetrahedron formed by p0 and triangular patches of the shell in % tet_vol % N...
a44e61487bd0a343ebc9cb0031a89af9b6d52c48b9c934b217dba4e068a426fa
MATLAB
993
46
function BaslerTrackPerFrame(movname) % % tspdata=load([fbasename '.tsp']); % tspdata = tspdata(:,1); % % if size(tspdata,2)>1 % warning('tsp has data in it! Are You sure you want to continue?') % % keyboard % end % % nFramesTsp = size(tspdata,1); % tspnew = [tspdata -1*ones(size(tspdata,1),6)]; readerobj = V...
a5ea9abd0626ee71c7ba7078e613c8c42b2e616e9c4751b8610a093d52b8cc20
MATLAB
993
40
%%% Script that combines two calibration sets together. dir; name1 = input('Calibration file name #1: ','s'); name2 = input('Calibration file name #2: ','s'); load(name1); n_ima_1 = n_ima; load(name2); n_ima_2= n_ima; active_images_2 = active_images; for kk=n_ima:-1:1, eval(['X_' num2str(kk+n_ima_1) ...
d906de95f3b089b6de28ba979a6681e7a9f6d6322ac89a79d620a147b6bd666d
MATLAB
993
35
function f = exgauss_pdf(y,X) % EXGAUSS_PDF computes probability density % % DESCRIPTION % Computes probability density for each of the data points in y, given the % the vector of ex-Gaussian parameters X % % SYNTAX % f = EXGAUSS_PDF(y,X); % % EXAMPLES % Mu = 400; % Sigma = 50; % Tau = 100; % X = [Mu, S...
f374d81d5b99ecf43fb60631d92c3cf6492c37a3318cd5c0c98e4877fdcda7d9
MATLAB
993
36
function [flag] = VBA_isWeird (X) % // VBA toolbox ////////////////////////////////////////////////////////// % % [flag] = VBA_isWeird (X) % check if X contains any Infs, NaNs or non real entries % % IN: % - X: matrix, cell array of matrices, or structure to be checked % OUT: % - flag: - true if any element or fiel...
215adde479bec34d3febabe65f96216ce0d8c8f0034755514fd850ad251b975e
MATLAB
994
24
%% created by Antoine Wystrach function [W_KC_MBON] = learn_MB (PN_input_learn, synaptic_plasticity, MB, nb_KC_firing) % Will create a Matrice for KC output synaptic weight to MBON. % Simplest learning rules: % At the begining, all KC_MBON weight = 1 (naive stage); % During learning, all active KCs switch thei...
3d5555b0e69b736fe8b235163f48f04f04cd8de4b31e91add6b42f1f17f9a2ea
MATLAB
994
36
function clf = clfDecTreeTrain( clf, X, Y ) % Train a decision tree classifier. % % USAGE % clf = clfDecTreeTrain( clf, X, Y ) % % INPUTS % clf - model to be trained % X - nxp data array % Y - nx1 array of labels % % OUTPUTS % clf - a trained binary decision tree clf % % EXAMPLE % % See also CL...
4b20abcea8cd097e93a00662ea70811deb18225693929c2585ba681867aedc5f
MATLAB
994
54
function [A,f,tt] = func_hhspectrum(imf,t,l,aff) % [A,f,tt] = HHSPECTRUM(imf,t,l,aff) computes the Hilbert-Huang spectrum % % inputs: % - imf : matrix with one IMF per row % - t : time instants % - l : estimation parameter for instfreq % - aff : if 1, displays the computation evolution % % outputs: % - A ...
ace192bc66439236041b9cf0a9dbb75dc59635450dfd310476bd1b520e9cc330
MATLAB
994
43
% AUTHORSHIP % Primary Developer: Stephen Meehan <swmeehan@stanford.edu> % Math Lead & Secondary Developer: Connor Meehan <connor.gw.meehan@gmail.com> % Bioinformatics Lead: Wayne Moore <wmoore@stanford.edu> % Provided by the Herzenberg Lab at Stanford University % License: BSD 3 clause % function setA...
e171bde72b5430d61d493c77257f501cd2640b1dfc5fe818d45798920720cd80
MATLAB
994
35
function [START_STOP, PEAK] = fitness_detect(traces_C, rois_A, video_Y) % [START_STOP, PEAK] = fitness_detect(traces_C, rois_A, video_Y) THR_DF = 1.95; THR_FIT = 0.28; DETREND_FRAMES = 45; DT = 20/30; video_Y = j_detrend2b(video_Y,DETREND_FRAMES,3); video_Y(isnan(video_Y) | isinf(video...
1d1e4a73990a74f9a29c84aac3d3589ea0751a65801577ffbb0410559858e685
MATLAB
995
48
%% Run PCA on the height weight data % %% % This file is from pmtk3.googlecode.com data = loadData('heightWeight'); % data(:,1) = class, 2 = height, 3 = weight for doStnd = 0:1 X = data(:,2:3); if doStnd X = standardize(X); end Y = data(:,1); [n d] = size(X); [W, Z, evals, Xrecon, mu] = pcaPmtk(X, 1); maleNdx...
4df3db4f3aa7de3ef83d0de284477086ca9b8c16f317a3f96c8b405507441740
MATLAB
995
26
%----------------------------------------------------------------------------------------- % Cross-modal decoding of stimulus identity, trained on images and tested on odors % % Kehl et al. 2024 (DOI:XX) % Single-Neuron Representations of Odors in the Human Brain % Figure 5e % Author: Marcel Kehl % License: MIT Lice...
5be972496f5765f2b65b64b786e4082f9ae3c3bb065721121b09ebf9f8c030f8
MATLAB
995
39
%- ------------------- Histogram of volumes at radius ------------------- y = []; x = []; n_slices = max(size(volumes)); for ii = 1:n_slices y = [y, (volumes{ii})]; % increase instances of x corresponding to same y x = [x, rr(ii).*ones(size(volumes{ii}))]; end % normalize volumes y = y .* (dx*dy*dz); %% f...
71488ebba575d7806fd1e7b035b568b8b959da86cf6b9054ea4ec6ba56871297
MATLAB
995
34
% run_dt_invariance.m % Run a simulation (simTauMap6) at varying values of dt. % clear the workspace clear; % define the save directory save_dir = fullfile('data', 'tm_sweep_true'); [~, ~, ~] = mkdir(save_dir); % iterate over four ratios for ratio_val = [1, 5, 10, 50] for i = 1:5 % load parameters ...
7839e7cd2f9e663e24e12f0ae6b22092c6cae729f4a906d9bc5f3b628cdf0862
MATLAB
995
25
function [pX,gX,pY,gY,X,Y,U] = get_MCMC_predictiveDensity_fb(f_fname,g_fname,u,n_t,options,dim,fb,N,np,lx,ly) % legacy code s = warning ('on'); warning ('*** The function `get_MCMC_predictiveDensity_fb` is now deprecated. Please use `VBA_MCMC_predictiveDensity_fb` instead (same syntax).') warning (s); % fallback swi...
969870af80feae6059a6bcdd1139990aa0f791bf9d56aabad2fe7115439365ef
MATLAB
995
43
function writenodelm_abaqus_inp(fn,e,p) % Writes list of nodes 'p' and elements 'e' into Abaqus .inp file format. % Written By: Hamid Ghadyani fprintf('Writing data to file... ') fn = add_extension(fn,'.inp'); [fid,st]=OpenFile(fn,'wt'); if st~=0 error('I/O Error.'); end fprintf(fid,'*HEADING\n'); fprintf(fid,'...
9f9ec47ce035a9d3728d6145f6b78739a0d8151f000d1e197579ceafbb37a105
MATLAB
995
34
function outpoints = tal2mni(inpoints) % Converts coordinates to MNI brain best guess % from Talairach coordinates % FORMAT outpoints = tal2mni(inpoints) % Where inpoints is N by 3 or 3 by N matrix of coordinates % (N being the number of points) % outpoints is the coordinate matrix with MNI points % Matthew Brett 2/2/...
c56c5fa555cc5e01c53ae4cb72c837763dffbb2dd6d27d11f6372aa06f194cc8
MATLAB
995
38
function Z = plus(X,Y) %PLUS Binary addition (+) for tenmat. % % See also TENMAT, TENMAT/TENMATFUN. % %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...
7293c322553f34dc23531a73827963792c31be46d188f26f37df1063e16e9716
MATLAB
996
44
function [D,num] = h_dir(directory_name,opt) if ~exist('directory_name')|isempty(directory_name) directory_name = pwd; end currentpath = pwd; if ~isdir(directory_name) [pname, fname] = h_analyzeFilename(directory_name); else pname = directory_name; fname = ''; end if ~isempty(pname) ...
f711add90732b78bd136e2c1ff6e328e67cdb058081eb20fa8718d784a6e84d6
MATLAB
996
26
%----------------------------------------------------------------------------------------- % Cross-modal decoding of stimulus identity, trained on odors and tested on images % % Kehl et al. 2024 (DOI:XX) % Single-Neuron Representations of Odors in the Human Brain % Figure 5f % Author: Marcel Kehl % License: MIT Lice...
1ad9156c51d81ac232a17bd56de90ce02aea3cecbaac1cf359e28b8555300ac6
MATLAB
997
29
function skip_number = CBIG_ABCD_proc_get_skip_frame(manufacturer) % % skip_number = CBIG_ABCD_proc_get_skip_frame(manufacturer) % % This function returns the number of frames to discard given the scanner manufacturer % The number of frames to discard follows the suggestion on ABCD release notes % % Inputs: % - manu...
14fb8a30b1ff356132186c6b3fc2bbac69f8c3df40664d9a6be2d4bfd9e7e63f
MATLAB
998
34
function diskFill( tDir, nGig ) % Fill a harddisk with garbage files (useful before discarding disk). % % USAGE % diskFill( tDir, nGig ) % % INPUTS % tDir - target directory to fill with garbage % nGig - maximum number of gigabytes to write to disk % % OUTPUTS % % EXAMPLE % diskFill( 'k:', 500 ) % % See also ...
92f890600bf9b9277617388a1bddd1e91f54bd203ffda433da62f43adbbdc40f
MATLAB
998
41
function X = tenzeros(varargin) %TENZEROS Create zeros tensor. % % X = TENZEROS(SZ) forms a tensor of size SZ with all zeros. % % TENZEROS(SZ) is equivalent to TENSOR(ZEROS(SZ(1),SZ(2),...),SZ). % % See also TENSOR, ZEROS. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor...
617387cf96348e15bbb5e86fc73cef72be0bcac9cfc38dbe44ffee4db1da05b9
MATLAB
999
40
function [path, j1, j2] = hmmViterbiC(logpi, logA, logB) % Find the most-probable (Viterbi) path through the HMM state trellis. % logpi(j) = log of initial state distribution % logA(i,j) = log of transition matrix % logB(k,t) = log of soft evidence % * we use log of inputs for compatability with .mex version * % * cal...
6cf8095ccf91f6ef5508f3324e476534239408b16ba5d680e6fa47221e88f450
MATLAB
999
30
% GQGW Gaussian quadratures using the Golub-Welsch algorithm. % % [X,W] = GQGW(ALPHA,BETA,MU) produces the nodes and weights X and W, % respectively, of the Gaussian quadrature rule corresponding to the % orthogonal polynomials P with ALPHA(I) = -B(I)/A(I) and % BETA(I) = SQRT(C(I+1)/(A(I)*A(I+1))), where ...
872c07fdd9b4d7e43b7c38f5d9172aacca359b7eff13a947efb48effdd8cc03d
MATLAB
999
52
%% Hinge Loss Plot % %% % This file is from pmtk3.googlecode.com z = -2:0.01:2; % margin y*f L01 = double(sign(z)<0); Lhinge = max(0,1-z); %Lnll = log(1+exp(-z))/log(2); Lnll = log2(1+exp(-z)); Lbinom = log2(1+exp(-2*z)); Lexp = exp(-z); figure; hold on plot(z, L01, 'k-', 'linewidth', 3); plot(z, Lnll, 'r--', 'lin...
3bd8774d509cb22a4bbe6fc607b4e35b80058c1e1bd8c91e88830c5cda87982a
MATLAB
1,000
18
% [AxesObj, Fcn]=w_RenderSurf('/Users/ycg/Dropbox/ITraAllOnline/ITraAll/ITraDropBox/GoogleDrive/ITraActive/Programs/DPABI/Github/DPABI/DPABISurf/SurfTemplates/fsaverage5_lh_inflated.surf.gii'); % Fcn.AddOverlay('T2.gii'); % Your Overlay Gifti; % Fcn.SetOverlayThres(1, -3, -1, 1, 3); % Fcn.SetOverlayColorMap(1, colormap...
ad2e962204e0030394052afafa7b570f2cddf0fee2413617721e94369e4482fb
MATLAB
1,000
27
% List of open inputs % 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_deformation_job.m']}; jobs = repmat(jobfile, 1, nrun); inputs = cell(4, nrun); for crun = 1...
b4e447c740598d31b32651e79dd818d70df63869eca0897b71310011a004f2b5
MATLAB
1,000
42
%% Bayesian T test demo % %% Paired test % Data from http://en.wikipedia.org/wiki/Student's_t-test % This file is from pmtk3.googlecode.com %PMTKneedsStatsToolbox tcdf, ttest z = [ 30.02, 29.99, 30.11, 29.97, 30.01, 29.99]; y = [ 29.89, 29.93, 29.72, 29.98, 30.02, 29.98]; % Method based on posterior distribution x ...
f38ab89d2dfbd3d5f7c7dd83ebabb501f0a2d4fa90f0ab35268d280fd2d83511
MATLAB
1,000
38
function Z = minus(X,Y) %MINUS Binary subtraction (-) for tenmat. % % See also TENMAT, TENMAT/TENMATFUN. % %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 Corp...
1620d0f5d4e7e1a26d1bc551366a160643e51b89d86dac9fa6d0768f16703c07
MATLAB
1,001
41
function ffine(h) % ffine -- set paramerters of figure % % [Inputs] % -h:handle % % % % % [Ex.] % close all % h=figure; % n=10; % x=1:n; % y1=randn(n,1); % y2=randn(n,1); % plot( x, y1 ); % hold on; % plot( x, y2 ); % ffine(h) % % % % Written By Tomoyasu Horikawa horikawa-t@atr.j...
2043f118746b3af28a18c091afc6d109120d71f7000c9e9f7a6a97edf6aafd87
MATLAB
1,002
33
function [fcr, Bxr] = partialvariance(fc,Bx,covariates) %% Control for Covariates %% % covariates are cov1, cov2... covN assumed to be column vectors %MW 1-3-2020 %% Nroi=size(fc,1); Nsubs = size(fc,3); sizecov = size(covariates,2); meancovariates = zeros(Nsubs,sizecov); % mean center covariates for i=1:sizecov cov = ...