sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
0bfc6586ada00846eb26ac1fc49eb717303739c9442a086533854d1cfd006a36
MATLAB
928
31
%Demo of the dtfit and dtpredict functions. Creates a regression tree for %the prostate data and sets the depth of the tree via cross validation. load prostate; [n,d] = size(Xtrain); nfolds = 5; [trainfolds, testfolds] = Kfold(n, nfolds,1); depth = 0:8; errors = zeros(numel(depth),n); for f=1:nfolds ...
3ac9de1a23ccb41d294f09251906d9efcef25b82b0b7a129845fd7f8c28cfaf6
MATLAB
928
41
function [gx,dgdx,dgdp] = g_demo_extended(Xt,P,ut,in) % canonical observation function for extended DCM. % The output is the concatenation of: % - classical HRF applied on neural states % - multinomial prediction from hidden extended states %- initializations idX1 = 1:in.n5(end); nreg=length(in.n5); nresp=length(in.r...
69541f9a9369b6341c5efda0328a9f03427eabfd7e45c6283a76a2343e78e522
MATLAB
928
35
% %assembly1on = SCE.TRace(find(assemblies.PCl(1,:))); % %raster(assembly1on) = 1; % raster(find(SCE.RasterRace(8,:))) = 1; event = zeros(1,length(traces.all)); %event(find(SCE.RasterRace(8,:))) = 1; assembly_active = SCE.TRace(find(assemblies.PCl(1,:))); int_active = find(SCE.RasterRace(8,:)); assembly_and_int = int...
6fce15d699869aa453aa5d82881170014e597292e543ee5b71421b18408c2ef2
MATLAB
928
29
function [u,dudx,dudp] = u_RBF(x,P,t,in) % input function for free-form (RBF) deterministic DCM % function [u,dudx,dudp] = u_RBF(x,P,t,in) % IN: % - x: [useless] % - P: nW*nuX1 vector of RBF projection parameters, where nW is the % number of RBFs and nu is the dimensionality of the output % - t: time at which t...
ca680c4fbc32bf36b9d6bda7d0e91af9dd1beda61f7a0315666bd60f9deae262
MATLAB
928
26
function [contours] = getContoursLarvaeLouis(coeffs,nPoints) % calculate contours using fourier coefficients % author: marvin albert % inputs: % kinData.fourier contains coeffs over time (time,ncoeffs) % nPoints: contour resolution % output: % contours over time (time,nPoints) %coeffs = kinData.fo...
e38eba6df0ec3c9354e5fc88c9fa3d3df6ee135360ab61db6b820067a42dd653
MATLAB
928
32
function essential_distMinAnglePair_test resetRands(3) flagDegenerateCase=true; k=2; e3=[0;0;1]; Q1=rot_randn([],[],2); if flagDegenerateCase Q1b=[Q1(:,:,1);Q1(:,:,2)]; Q2b=essential_randomVerticalMotion(Q1b); Q2=cat(3,Q2b(1:3,:),Q2b(4:6,:)); else Q2=rot_randn([],[],2); end Rzt=@(t) rot(t...
5467f99635eb7ee0abd7054a6bff3a3fa09f38780dd980d5de0e3e87873327e1
MATLAB
929
37
%% Simple test of mixGaussMissingFitEM % This file is from pmtk3.googlecode.com setSeed(1); nmix = 5; d = 2; model.mu = 10*randn(d, nmix); Sigma = zeros(d, d, nmix); for c=1:nmix Sigma(:,:,c) = randpd(d) + 0.1*eye(d); end model.Sigma = Sigma; model.mixweight = normalize(rand(1, nmix) + ones(1, nmix)); nsamples =...
af319699f1403370d48768911c15c4c152d7092c056da49f6a0b81b87eb772f7
MATLAB
929
34
% Setup base path clear; basefolder = fileparts(fileparts(mfilename('fullpath'))); codefolder = [basefolder,'/code']; toolsfolder = [basefolder,'/tests/tools']; addpath(genpath(codefolder)); addpath(genpath(toolsfolder)); % Load Data data_path = [basefolder, '/tests/fixtures/chan-60_-1000to1499ms.txt']; data = read...
c3a1d1d889a1470e7c73c9b482f71499b03499aaf139bb2e41c5311cdcac2a7b
MATLAB
929
44
function [f, activeInd] = calculateFunctions(x,N) % x(:,1) = psi values % x(:,2) = thc values % N = number of computational units th = linspace(0,2*pi,N+1); th(end) = []; th = th'; f = zeros(size(x,1),3); activeInd = zeros(size(x,1),N); for i = 1:size(x,1) p = mod(x(i,1),2*pi); thc = x(i,2); actInd...
9b5bc01067bba6b752e7f14d6789e9ba01f0ffe30d1877a23345b7c06e8db50c
MATLAB
930
27
function [c_jk_norm, c_jk_unnorm, gm_FR] = xcorr_gm(pre, post, maxlag, minlag) % input % pre: num_trials x num_timepts logical array of presyn neuron spikes % post: num_trials x num_timepts logical array of postsyn neuron spikes % maxlag: number of trials in past to compute ccg, e.g. 25 % minlag: number of tria...
b5041171e044752082f37367fb9c511a8145cf3744aeae3432122d2f1f5acbe2
MATLAB
930
22
function h = polarimagesc(edges_r,edges_theta,center,v,varargin) ninterptheta = 5; nbinsr = length(edges_r)-1; nbinstheta = length(edges_theta)-1; xplot = nan(2*ninterptheta,nbinsr,nbinstheta); yplot = nan(2*ninterptheta,nbinsr,nbinstheta); for binr = 1:nbinsr, for bintheta = 1:nbinstheta, rplot = [repmat(edges...
c5ce40df544427102b11351c8fa4934a7c7af0c0ec78f072e895b23e30d5d21b
MATLAB
930
38
%http://graphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/convolution.pdf foo=load('clown'); clown = foo.X; g = fspecial('gaussian',15,2); %figure;imagesc(g) figure; surfl(g); title('kernel'); gclown = conv2(clown,g,'same'); figure; imagesc(clown); axis off; title('clown'); printPmtkFigure('clown') figure;...
e4785600486170374d1094364f97b2f7a4a88059c48a1230a37cf4dd1fe768c8
MATLAB
930
25
% 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 [data_matrix_filled]...
3de6e5a0f8fae101f70bcd4ceaf4624df5776fd27d564473bcb4e1fb80cba9f1
MATLAB
931
35
%% Reproduce fig 3.5 on p56 of "Elements of statistical learning" % %% % This file is from pmtk3.googlecode.com loadData('prostate'); [n, d] = size(X); X = standardizeCols(X); y = centerCols(y); mse = zeros(2^8-1, 1); ss = powerset(1:d); ss(1) = []; for i=1:numel(ss); ndx = ss{i}; model = linregFit(X(:, n...
7ad5248950bce9f27b06c7b5d689e57accd8857054542b6060a957d33f6aa645
MATLAB
931
40
function S = multiLineString(varargin) %% Parses the multiline comment just below where it is called % % % %% Example % % % function foo % % S = multiLineString('test', 3); % %{ % The text here will be converted to a string using sprintf like syntax % so that this %s is converted to 'test' and this %d is converte...
f1ce27a8b5d680084f1a2c6eab7a729c6bbf33229a3ce046f7c21551ddba8b63
MATLAB
931
16
function [states,state_name]=get_awake_and_sleep_times load('extracted_position.mat'); load('extracted_sleep_state.mat'); if sleep_state.sleep_indices.start(1) ~= 1 %if the first index is not 1, it means that session starts with rat awake awake_indices= [1, sleep_state.sleep_indices.start(1)-1]; awake_indices= ...
fd5a542072acd52af6ef1f7936ebb4b75a9c3ff9ae4ea5ea6e1359718a30e343
MATLAB
931
28
function n2 = dist2_metropolis(x, c) %DIST2 Calculates squared distance between two sets of points. % % Description % D = DIST2(X, C) takes two matrices of vectors and calculates the % squared Euclidean distance between them. Both matrices must be of % the same column dimension. If X has M rows and N columns, and C h...
0e258a717e36dce3929aa53019d4b34b8b918e68f257eb6c20b078cb6a69ceaa
MATLAB
932
23
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Extracts cosecutive MUAPs out of signal Y % INPUTS: % MUPulses = triggering positions (in samples) for rectangular window used in extraction of MUAPs (MU firring patterns); % len = radius of rectangular window (window length = 2*le...
2a7d9044e51805afc1b4936c2f8d96c6e289ac9e7b93830f5df955c67500b430
MATLAB
932
34
% test function CircosDataOrganize.m clc;clear; workingDir = pwd; load('CircosStruct.mat'); % load('RawDataCircos.mat'); % CircosStruct = RawDataCircos; RawDataCircos = CircosStruct; % LINK_MODE = 4; WorkDir = pwd; %% [CircosNetworkPath, CircosRegionPath, CircosLabelPath, CircosLinkPath]=CircosDataOrganize(WorkDir,...
39844b2bd8fe0a8f964d6362cc20c2b291b04902bb352c0dda13faacdc41be6d
MATLAB
932
32
function z = isequal(x,y) %ISEQUAL for sptensors. % % ISEQUAL(A,B) compares the sparse tensors A and B for equality. % % See also SPTENSOR. % %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/TensorTo...
a42e7093ba57ea529cebcb1600697ad4a9264f5d238ebec55739796230b3edcc
MATLAB
932
23
% Edited by Jerry. 08/02/2022 function processedData = RemoveArtifacts_220802(rawData,polyOrder) % ********************************************************************* % this function process a signal to remove polynomial artifacts. % Inputs: % (1) rawData: raw data with artifact % (2) polyOrder...
d8821274e3485bb52b2bee93c2dedb17b97612bb306913009f8bc69e0989cc0a
MATLAB
932
27
function ax1 = axisOverlay(ax0,ax1) if exist('ax1','var')==0 ax1 = axes('Parent',ax0.Parent,'Visible','off','PickableParts','none','Color','none'); end PROPS = {'XLim' 'YLim' 'YDir' 'Position' 'PlotBoxAspectRatio'}; for p = PROPS,p=p{1}; %#ok<FXSET> if ~isequal(ax1.(p),ax0.(p)) % AL20160928. Protect against se...
33bc4c898d897ad5061f3c8a397de51537c402100c4a41af624273e44ddba71a
MATLAB
933
23
function im_vals = grab_output_vals(stim_images,grid1,grid2,spot_rad) if(isvector(grid1)) [grid1,grid2] = meshgrid(grid1,grid2); grid1 = grid1'; grid2 = grid2'; end im_vals = zeros(size(grid1,1),size(grid1,2),size(stim_images,3)); for i = 1:size(grid1,1) for j = 1:size(grid1,2) if...
42276e8727878ff2d0a8525b38bfb53dfbf0cfb052a2c8fbdf0dea14da8684c4
MATLAB
933
27
function h_resetAnalysisNumber3(handles, syncFlag, currentValue) global h_img3; if ~exist('syncFlag','var')||isempty(syncFlag) syncFlag = 1; end [currentInd, handles, currentStruct, currentStructName] = h_getCurrendInd3(handles); h_img3.(currentStructName).state.analysisNumber.value = currentValue; h...
43556d565a6dfc6c75c2bcf572af7d524877343dc9ae912f87b67c77ddee3322
MATLAB
933
28
% 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 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful,...
45b59ac7cad22eb00ff0ddc9787434510db580dc338c8d8c050f93e8bb8712f4
MATLAB
933
45
function [om2,T2,dom2dom,dom2dT,dT2dom,dT2dT] = inverse_motion(om,T); % This function computes the inverse motion corresponding to (om,T) om2 = -om; dom2dom = -eye(3); dom2dT = zeros(3,3); [R,dRdom] = rodrigues(om); Rinv = R'; dRinvdR = zeros(9,9); dRinvdR([1 4 7],[1 2 3]) = eye(3); dRinvdR([2 5 8],[4 5 6]) = eye(...
4c7687520a7e7db2c9e246d880ad143869016a8ef3c13f0e542dc8a984f2f1fc
MATLAB
933
29
function [model, loglikHist] = ldsFit(data, nlatent, varargin) %% Fit a linear dynamical system model via EM % We do not estimate parameters associated with an input/ control sequence. % We fix Q=I and R=diagonal. % See ldsFit.pdf for details of the algorithm. % %% Inputs % data - a cell array of observation se...
ad88a03644fe1854a7804fdc2311a22897c6f260f9906504c622c1958db953ec
MATLAB
933
42
function padded = insertClampedBels(nodeBels, visVars, hidVars, nstates, clamped) %% Insert clamped belief nodes. % Similar to insertUnitBels, but we do not slice the observed node down to % a unit factor, we just clamp it to its observed value. % This file is from pmtk3.googlecode.com if isempty(visVars) pad...
f77037f5689581c00d8762b2825251ed4c83d7f85a3468103064b73a6008907e
MATLAB
933
21
% Geometric Distortions Correction - compute topup data = dir('/DATAPOOL/ERRORMONITORING/SEM_mri_data/P*'); datain='/DATAPOOL/ERRORMONITORING/SEM_mri_data/datain.txt'; %% for i = 1:size(data,1) data_func = dir([data(i).folder, '/', data(i).name, '/mri/SEM_', data(i).name, '/nifti/func/run*']); fpr...
26d094ae41f74ae30903d45d51e22c74d157197e38f7aae92a01c62c0dc3f1ae
MATLAB
934
36
% Copyright Christopher Fricke, University Leipzig Medical Center, % Neurology 2024 srcf = 'data\prep\coreg_indiv\ct'; srcf2 = 'data\prep\coreg_indiv\datscan_normalized'; d = dir(fullfile(srcf,'w*.nii')); data = []; info = niftiinfo(fullfile(srcf,d(1).name)); for i = 1:length(d) disp(d(i).name); dn...
90d9c191a2ea4ad8693ab1decb74d7228c7c11a9441fee713d87bc7b898aa11e
MATLAB
934
41
function imax = RFT_localmax(X) % find local maxima on the field % function imax = RFT_localmax(X) % This function searches for local maxima on the field, whose values X are % assumed to be sampled on a regular lattice. % IN: % - X: the Lx1 sampled RF % OUT: % - imax: set of locam maxima indices L = length(X); % ...
2cded994f8bbab8c8c203166cb3865aaa31075b3452b42c57e3730b8314f98f3
MATLAB
935
24
function [fcost,u_error,u_sol,e_sol,F_err] = Spring2D_MSE(k0,F,params,optims,condition) if isequal(condition,'1') k = Convert_k(k0,params); elseif isequal(condition,'0') k = k0; end D = params.C.'*diag(k)*params.C; F([2*params.ind_fix-1,2*params.ind_fix]) = []; D(:,...
36d7e5b4ebfcf4c53a36bed461101d68df537fbe727fc51efdc8601f79ee3331
MATLAB
935
38
if n_ima ~= 0, if ~exist('active_images'), active_images = ones(1,n_ima); end; n_act = length(active_images); if n_act < n_ima, active_images = [active_images ones(1,n_ima-n_act)]; else if n_act > n_ima, active_images = active_images(1:n_ima); end; ...
47c6864a162e33fa8170b0fbc50efa2ad8b7a9b3a03256ddcb302a1bc78bd3c8
MATLAB
935
44
function WriteSPRHeaderInfo(fn,props) % props is a structure: % .dim : number of dimensions % .mysize : array with information about the size of each dim % .fov : field of view % .interval : spacing between pixels and slices % .orient : 'axis' ,... % .datatype : 'WORD' , ... % .endian : 'ieee-le' , ... fn = remove_ext...
6affb14aa5d7f62b85bd4dd278bc1b3a1ccab1fef30737dfdad15976a5968a97
MATLAB
935
32
function [model, output] = mlpRegressFitSchmidt(X, y, nHidden, lambda, options) % Multi-layer perceptron for regression; fit using minFunc % nHidden can be a vector of integers if there are multiple laters % We currenly assume the same L2 regularizer on all the parameters % output is the return value from minFunc % Th...
07b0f2a7ceaf19dbcae05b56a1458a8f244ce5d8fb33735f18ee701df79a7e4f
MATLAB
936
28
function [hs,probs] = fernsClfApply( data, ferns, inds ) % Apply learned fern classifier. % % USAGE % [hs,probs] = fernsClfApply( data, ferns, [inds] ) % % INPUTS % data - [NxF] N length F binary feature vectors % ferns - learned fern classification model % inds - [NxM] cached inds (from previous call to...
1d7a05e9e6c93c3b936655ed7238caa8c226a84de1ceb97e882754c1ad2c8000
MATLAB
936
31
function [edge_avg edgesizes] = GetEdgeSize(e, p, nnpe, average_only) % Assuming e and p define a 3D shell surface, or tetrahedral mesh, % this function returns the list of all edge lengths or their average % By default this routine returns the average of edges only edgesizes = []; if nargin < 4 || isempty(average_only...
3c24e3016a3db43845482ac7038584e7cd5cd420a66500351aa14d33de3c690d
MATLAB
936
54
function T = imtile(I, varargin) %IMTILE Tiles a stack or set of images. % Usage: % T = imtile(stack) % T = imtile(I1, I2, ...) % T = imtile(stack, cols) % % Args: % stack: 3-d, 4-d or cell array of images % I1, I2, ...: 2-d images % cols: number of columns to use % % Returns: % T: single tiled image % %...
9f33c4901e3735a0bdfe2ae7def9a42dae93fd9089671d6971c584375dac98f7
MATLAB
936
39
function [ROI] = findCores(V, thr, filtMask, minSz) % [ROI] = findCores(V, thr, filtMask, minSz) if(nargin<4) minSz = 15; end if(nargin<3) filtMask = [3 3 3]; end if(nargin<2) thr = 2; end height = size(V,1); width = size(V,2); ...
d1486ba724e79106325e1d835718a50311df87a6c3eda4e7570d6b221561d334
MATLAB
936
34
% Setup base path clear; basefolder = fileparts(fileparts(mfilename('fullpath'))); codefolder = [basefolder,'/code']; toolsfolder = [basefolder,'/tests/tools']; addpath(genpath(codefolder)); addpath(genpath(toolsfolder)); % Load Data data_path = [basefolder, '/tests/fixtures/sub-1_rest1_schaefer400x7_ts.1D']; data ...
d18dfd1e70c6ee8ff2b8e6d0dd931ce2640c21470b8c8d6674421b965623f187
MATLAB
936
49
function [output,e] = ALE_imp(imp,fs,delay,mu,niter) %%% Adaptive Noise Canceler with NLMS algorithm %% Inputs: % imp : impedance sig % delay : delay in samples , also corresponds to the filter order % (default 4 sec) % mu : convergance factor, default 0.01 % niter : number of iteration, default 2 %% Outputs : % outpu...
1eddad41ada59688c233a39c39f38b7de945e1bc254887df93d6384e19f04db1
MATLAB
937
20
rgb = [179 102 179; 26 112 128]/255; figure('color',[1 1 1]) h(1)=plot(timetoPlot,mean(trgt.accuraciesBase,1),'color',rgb(1,:),'Linewidth',4); hold on, h(2)=plot(timetoPlot,mean(distr.accuraciesBase,1),'color',rgb(2,:),'Linewidth',4); hold on, h(3)=plot(timetoPlot,mean(trgt.accuracies,1),'color',rgb(1,:),'Linewid...
2ede2a41d6f8820b3c26bcf6b85bd7a35f00f93063a9532b6a8a96a0ecae8d6f
MATLAB
937
55
%% LMS Demo % %% % This file is from pmtk3.googlecode.com [X,y]=contoursSSEdemo(true); % X, y d = 2; w = [-0.5;2]; % randn(d,1); i = 1; eta = 0.1; sf = 0.999; %for i=1:20 % eta = eta * sf %end done = false; maxIter = 25; iter = 1; n = size(X,1); whist = []; while ~done xi = X(i,:)'; yhat(i) = w' * xi; wold ...
4aa81ad500a924afec3a533a8f8431d54c0aa6909efcbb71d8e3409f38fa5fd0
MATLAB
937
22
timevector = -0.05:0.001:0.2; rgb = [0.1 0.4 0.5; 0.7, 0.4, 0.7]; labels = [{'Singleton distr in RF'}; {'Non-singleton distr in RF'}]; clear h f = figure('NumberTitle', 'off', 'color', [1, 1, 1], 'position', [360 50 600 400]); hold on; h(1)=shadedErrorBar(timevector, mean(fr1), std(fr1)/sqrt(size(fr1,1)), {'C...
52133376377f88109576742e6299b4c267cf77ecb0d0c2bf407d78b4888b16c7
MATLAB
937
20
rgb = [179 102 179; 26 112 128]/255; figure('color',[1 1 1]) h(1)=plot(timetoPlot,mean(trgt.accuraciesBase,1),'color',rgb(1,:),'Linewidth',4); hold on, h(2)=plot(timetoPlot,mean(distr.accuraciesBase,1),'color',rgb(2,:),'Linewidth',4); hold on, h(3)=plot(timetoPlot,mean(trgt.accuracies,1),'color',rgb(1,:),'Linewid...
bc845888ff63318d11ef17052d3321b3c2bb55177204173c3308f9f82b3a6597
MATLAB
937
35
function [text, ismodified] = convertLinksToHtml(text, name) %% Convert any web links in the text to html by adding <a href> tags % If any <a href ... tags already exist, nothing is done % This file is from pmtk3.googlecode.com if iscell(text) [text, ismodified] = cellfunc(@(text)convertLinksToHtml(text, name), ...
f6185165ab30676dee14274045b7ab7c0b63fbbf6c5cb42fc02a644e2ff51836
MATLAB
937
32
%% Ridge regression for splines %PMTKauthor John D'Erico %PMTKurl http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8553&objectType=fileY % This file is from pmtk3.googlecode.com setSeed(0); n = 50; x = sort(rand(n,1)); y = sin(pi*x) + 0.2*randn(size(x)); xtest = linspace(min(x), max(x), 100);...
f9c9e0451fe2b241d902e8bc4bcbd99572f394d335374a4582dcefe72b2b6dc0
MATLAB
937
41
%% pdf_Uniform: Uniform Probability Density Function % % Usage: % x = pdf_Uniform(N, range, seed) % % Inputs: % N scalar, number of samples % range vector [min max] range of the random variable % seed optional, seed for the random number generator % % Output: % x ...
3359e64dde28d4145ef79b98b187e2f3bb64f93b485e86f6431403554a2a14c6
MATLAB
938
40
function A = convnfft_light(A,B) % light version of % http://nl.mathworks.com/matlabcentral/fileexchange/24504-fft-based-convolution % behaviour: size 'same' % save memory A = single(A); B = single(B); % eliminate loop m = size(A); n = size(B); % IFUN function will be used later to truncate the result % M and N are ...
3644c398cb2139aaf62ba57b8ae2747caef13bc5d5a2cc6b4bdb7fdb4e7111ae
MATLAB
938
22
classdef (Sealed) AdjMatrixComplGraph < adjmatrix.AdjMatrixFromNetX methods function this = AdjMatrixComplGraph(params, loadOnInit, delAfterLoad) % creates a complete graph (mean-field network) % % params {AdjMatrixParams}: params of the adjacency matrix % loa...
9a1dfd981d7426b6821773188924148d135ea61a74810bf92eb73c83131d1501
MATLAB
938
31
function mscmd_geom2adj(infile,outfile,opts) % mscmd_geom2adj call mountainsort to convert geom CSV to adjacency matrix % % mscmd_geom2adj(infile,outfile,opts) % Inputs: % infile - filename of input geometry x,y for electrodes in CSV % outfile - filename for output adjacency matrix in MDA % opts - struct containing...
c96771d41c7d71cae708a0ea561b6efa9f5fb306667b1d8407257dc9854a8c80
MATLAB
938
40
function [t p edges] = readGTS(fn) % Reads a surface mesh from a file formatted in GNU Triangulated Surface mesh fid = OpenFile(fn,'rt'); junk = fgetl(fid); blah = sscanf(junk,'%d %d %d'); nnodes = blah(1); nedges = blah(2); nfaces = blah(3); data = textscan(fid,'%f %f %f%*[^\n]',nnodes); if length(data{1}) ~= nnode...
e4282f43cd12876ace1728ea8df801c64f3042f8c31008ac67f6c9ce99cb9669
MATLAB
938
34
function result = dosubstitution(r, dictionary) import yaml.*; if ~exist('dictionary','var') dictionary = {}; end; result = recurse(r, 0, dictionary); end function result = recurse(data, level, dictionary) import yaml.*; if iscell(data) && ~ismymatrix(data) result = iter_cell(data, level, dictio...
2d8023e020b0799a11334934ba2e91d5e728563926435dd7614fbeab1781fea4
MATLAB
939
53
function [xL,xR] = click_stereo(NUMBER_OF_POINTS,IL,IR,R,T,fc_right,cc_right,kc_right,alpha_c_right,fc_left,cc_left,kc_left,alpha_c_left); figure(1); image(IL); figure(2); image(IR); [ny,nx] = size(IL); xL = []; xR = []; for kk = 1:NUMBER_OF_POINTS, figure(1); hold on; x = ginput(1); plot(x(1...
45a8e5757b6e12eca578ac7eeb2649228db7368908d92bf95d5d390b351c68f6
MATLAB
939
42
function newcombPostPred() setSeed(1); % Data from http://www.stat.columbia.edu/~gelman/book/data/light.asc % This file is from pmtk3.googlecode.com D = [28 26 33 24 34 -44 27 16 40 -2 29 22 24 21 25 30 23 29 31 19 ... 24 20 36 32 36 28 25 21 28 29 37 25 28 26 30 32 36 26 30 22 ... 36 23 27 27 28 27 31 27 ...
496b748fc0847054132b32cd0bcdcd09c477ff0683f18d63d2968afd3f02b7ad
MATLAB
939
27
load('IM_13nets_246_newcolor_MNI.mat'); % load parcellation based on Seitzman 2020 300 ROI load('MNI_coord_meshes_32k.mat'); Anat.CtxL=MNIl;Anat.CtxR=MNIr; clear MNIl MNIr Anat.alpha = 0.8; IM.name = ''; Params.radius = 4; figure('Position',[100,100,500,300]); View_ROI_Modules(IM,Anat,IM.ROIxyz,Params); % set(g...
5be6b6c07f96237577131b6242cefa39128db375a4a1854b74aaeeb02519b68e
MATLAB
939
20
function afxLnmSum(input,output,thresh) % if exist(output,'file') % fprintf('afxLnmSum: %s already exists.\n', output) % else [pth,name,ext] = fileparts(output); if ~exist(pth,'dir'), mkdir(pth); end matlabbatch{1}.spm.util.imcalc.input = input; matlabbatch{1...
d3556d36c0d45987e1d7da302b9ba7e5e27d85fbfe0f12fb1f51a0016f752682
MATLAB
939
31
function [probOn, postPred] = binaryFApredictMissing(model, y) % Compute probOn(n,t) = p(yt=1|y(n,:)), % where y(n,t) in {0,1,NaN} where NaN represents missing data % We also comptue postPred(n,t,:) = [p(0) p(1)] % to be compatible with other multiclass code % This file is from pmtk3.googlecode.com y = canonizeLabel...
d9ce02388c3b73ec7397835b14bdff87cb3a38cbfc74f38214536e3b92527d89
MATLAB
939
31
function H = CBIG_MFMem_rfMRI_Num2Color(Wvector,colormap_name) %------------------------------------------------------------------------- % H = CBIG_MFMem_rfMRI_Num2Color(Wvector,colormap_name) % % This function transfers vector value into a color map % % Input: % - Wvector: parameter value vector {Parame...
179f47e70405f75c1854f15feccb8c4f6814f79443cc10d3a52c48b7ee63fcdd
MATLAB
940
37
function data = afxCsvWrite(fname,data) % Export Data to CSV-Files % mycsvread(filename,raw) % % max.wawrzyniak@medizin.uniklinikum-leipzig.de delimiter = char(9); % Tab nl = '\r\n'; % newline % open csv-file fid = fopen(fname,'w'); % write line by line...
4e1c26a89045bb8d41926af472a20ed03f3ba25a54e47652a94c4a5de43cbb93
MATLAB
940
41
function [cData,cLabel,LabelList]=list2cell(Data,Label) % Turn a list with labels into a cell array, grouped by label % Note : cell2list does the reverse. % Handle case of numerical list % if ~iscell(Data) if ndims(Data)==2 [Labels,ia,ib]=unique(Label); for i=1:length(Labels) cData{i...
4e54b9c0476397853b24b9c35839abdcc653201368d188f5e29e617207500318
MATLAB
940
29
% proxy function function [Kpxy,nbr] = pxyfun_lap_neumann(x,slf,nbr,proxy,l,ctr,area) % PXYFUN(X,SLF,NBR,L,CTR) computes interactions between the points % X(:,SLF) and the set of proxy points by scaling the proxy sphere to % appropriately contain a box at level L centered at CTR and then pxy = bsxfun(@plus,proxy*l,c...
532f74a63e1cce44578c01b52e16058e2251a93e95e20694d947d7f72a328060
MATLAB
940
32
function e = end(X,k,n) %END Last index of indexing expression for ktensor. % % The expression X(end,:,:) will call END(X,1,3) to determine % the value of the first index. % % See also KTENSOR, KTENSOR/SUBSREF, END. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbo...
6c0ebe14879812fe0d5d8f017d1cf5c6d8c26aba5db4dc9db42b919151dfe52c
MATLAB
940
38
function [X, mu, mode] = meanValueImputation(Xmiss, type) % Compute mean (or mode for discrete) of each column % and use it to fill in NaN entries in Xmiss (size N*D) % type(j) = 'c' for continuous or 'd' for discrete % % Example % Xmiss = [1 2 3 1 NaN 4 NaN]' % meanValueImputation(Xmiss, 'd') % [1 2 3 1 1 4 1] % meanV...
6fd8991b8233dfe94ade1bfccaed2d2a39a258454895a0672d341800dc293e03
MATLAB
940
46
%% sfreqs % % Return vector of frequencies % % <matlab:open('sfreqs.m') code> % %% Syntax % % freqs = sfreqs(fres,fs) % %% Arguments % % See also <mvgchelp.html#4 Common variable names and data structures>. % % _input_ % % fres frequency resolution % fs sample rate (default: 2*pi) % % _output_...
753559f7b5b7038b27260e3fdfa410984ae76f8a3408b46f604b71beaaf58863
MATLAB
940
35
function aps=findaps(data,thresh) % function aps=findaps2(data,varargin); % %finds action potentials in a current clamp (Vm) trace % if nargin==2 % mode=varargin{1}; % else % mode='points'; % end % thresh = -.035; %in mV aps=[]; data=reshape(data,[1 numel(data)]); % if mean(data)>-50 | mean(data)<-85; % ...
b54df889c5f29204f722d86533a7cbb297e92357fe5443e117984212e7fd887e
MATLAB
940
34
function [dx,flag] = VBA_checkGN(S,dx0) % Levenberg-Marquardt regularization on Gauss-Newton update step % [dx] = VBA_checkGN(S,dx0) % This function checks the Gauss-Newton update required for the % optimization of the variational energies of parameters. This % regularization should not happen in normal cases (nonlinea...
b79c41e20dac4e3d4c6f8db19a6aa15b39b9c41eac1e80f82d819c07240e9381
MATLAB
940
59
function jumpToNextUncertainSpike(self) if self.verbosity > 9 disp(mfilename) end if isempty(self.channel_to_work_with) self.say('No channel chosen'); beep return else channel = self.channel_to_work_with; end uncertain_spikes = self.handles.ax.uncertain_spikes(channel).XData; if isempty(uncertain_spikes) se...
c8209f43b1ae725e60b488838c1d81ae771291bbc9f179e7cb676bfe3de5ca0c
MATLAB
940
56
function cls = correction(carta) % busca cluster en cartas de valor p 0 y 1 % 9.Agosto.2009 % P.Billeke % if size(carta,3)==1 cls = bwlabel(carta,4) return end disp(['making clusters ...']) yc = size(carta,1); cn = 0; for y = 1:yc if ~any(carta(y,:)),continue,end for x = find(carta(y,:)) if carta(y,x) ...
ff9005bd981ac9d5f2a2f2ce744d7c3a576dfd3930f877ce91ceab96a16b165e
MATLAB
940
45
%% Demo of an RBF gram matrix % %% % This file is from pmtk3.googlecode.com setSeed(2); mu = [0 0; 0 1; 1 1; 1 0]; sigma = 0.05; N = 9; K = 4; pi = normalize(ones(1,3)); X = zeros(N,2); %z = sampleDiscrete(pi,1,N); z = [1 1 1 2 2 2 3 3 3]; for c=1:3 ndx = find(z==c); Nc = length(ndx); X(ndx,:) = gaussSampl...
6a210357ae840aee3aed0d8142a23c17a69a2e9876d4e3107944f4d77a3ebef4
MATLAB
941
36
%% Vesicles predetection filter based on template matching for GUI vesseg % Author: Antonio Martinez-Sanchez % I: input tomogram % M: input membrane mask tomogram % C: input citosol mask tomogram % rm: minimum radius % rM: maximum radius % s: membrane thickness % wa: angle for missing wedge % wr: rotational angle for m...
b049b08432b9e952045e6fd47fc2e76630e19d6f675f677652cab7086f06df55
MATLAB
941
43
function Z = loadAudio(paths) % Syntax: Z = loadAudio(paths); % Parse inputs p = numel(paths); % Load audio audio = cell(1,p); for i = 1:p path = paths{i}; [~, ~, ext] = fileparts(path); if strcmpi(ext,'.mat') % Load from .mat file data = load(path); fields = fieldnames(data); ...
b907b2a3a25f3169f8ca517c9773b06522c6e4cace65df501cce0db88bbeaf42
MATLAB
941
37
function Tsmall = tabularFactorSlice(Tbig, visVars, visValues) % Slice a tabular factor % Return Tsmall(hnodes) = Tbig(visNodes=visValues, hnodes=:) % visVars are global names, which are looked up in the domain % This file is from pmtk3.googlecode.com %% if isempty(visVars), Tsmall = Tbig; return; end domain...
063be1c02ce8dd80a3fa1359c67c6db1c92b0aeb7a96947a94133ec122208eb2
MATLAB
942
38
%% Classify some MNIST digits using a binary RBM %PMTKauthor Andrej Karpathy %PMTKmodified Kevin Murphy %PMTKreallySlow % This file is from pmtk3.googlecode.com setSeed(0); Ntrain = 1000; Ntest = 100; keepSparse = false; [Xtrain, ytrain, Xtest, ytest] = setupMnist('binary', true, 'ntrain',... Ntrain,'ntest', Nte...
577279eb96dbf03573d394a64cdc463a8fc92116e3a0a7432db3a09d0a4442de
MATLAB
942
28
function [w]=linregFitGroupLasso(X, y, groups, lambda, method) % Fits the grouped lasso model % This file is from pmtk3.googlecode.com if nargin < 5, method = 'SPG'; end [N,D] = size(X); %#ok winit = zeros(D,1); if isscalar(lambda), lambda=lambda*ones(nunique(groups),1); end lambda = colvec(lambda); % required by L...
c746f0e425d8425611f9347aadf9ce6a8a4217a85caa1c3cab82edea8b141783
MATLAB
942
35
%% Set directories basedir = '/path/to/directory/interpret_ml_neuroimaging/data'; savedir = '/path/to/directory/interpret_ml_neuroimaging/data'; gray_matter_mask = which('gray_matter_mask.img'); %% Load data heat_imgs = filenames(fullfile(basedir, 'data', 'derivatives', 'trial_images', 'sub*', 'heat_*.nii')); reje...
1a725888b07070fe6a3a1212e8781cf2aef4138f9bc25a9c9a5376d4d5a4de93
MATLAB
943
12
function PlotBox(BoundingBox,LineStyle,LineColor,LineWidth,Text,TextFontSize,TextFontColor) plot([BoundingBox(1),BoundingBox(1)+BoundingBox(3)],[BoundingBox(2),BoundingBox(2)],LineStyle,'color',LineColor,'LineWidth',LineWidth); plot([BoundingBox(1),BoundingBox(1)+BoundingBox(3)],[BoundingBox(2)+BoundingBox(4),Bound...
4341006f30672eaea0293182d39e801dcec6dba625fab31842d19f3a3157c589
MATLAB
943
37
function [img,nz,QC] = read_image(path,chind,nchannels,filt) info = imfinfo(path); try C = strsplit(info(1).ImageDescription,char(10)); ch_str = strsplit(C{3},"="); z_str = strsplit(C{4},"="); nc = str2double(ch_str{2}); nz = str2double(z_str{2}); catch nc = ...
569ebc7986c65fbcbf351e9013a2f46c929a9d57c0bafb42525b981648f6bab8
MATLAB
943
34
% Author: Birgit Nierula % nierula@cbs.mpg.de function [cnt, QRSevents, fwts, ecg_idx] = prepro_prepare4ecgCleaning(cnt_qrs, esg_chans) % esg_chans have to include ECG channel! %% select only ESG channels and ECG channel [~, idx] = ismember({cnt_qrs.chanlocs.labels}, esg_chans); channels = find(idx); cnt = pop_sel...
7760614da6906740d23d3173c1febe62bdaf6d1e6f6ae909e7cf5c01c8847d0b
MATLAB
943
34
function [alignedSpikeCount] = sortByTrial (spikeCount,eventTimes,PSTHwindow,offset) %% >>> OPERATION >>> % Sort 2D spike matrix into 3D spike matrix based on event index (e.g. % locomotion onset). Trials are arranged in 3rd dimension. % Marco Bocchio, 22/11/19 %% % number of trials (i.e. events or stimulations) t...
90a578a426d195739c6ffbc561799adfcb15a3e37fc1530ceedecb3b0001fe65
MATLAB
943
1
% TSSETTRIAL Set the currently active trial % TSSETTRIAL(TRIALNAME) sets TRIALNAME as the active trial that will be % used for computing statistics. If you want no active trial (so that, % for example, TSapplystat does not search for fields at the Trial level, % then TSsettrial('none'). This command has been r...
224761071bba12acceae542ef660bfdb00f2f80f57ce3e1875bfd57a35b5d936
MATLAB
944
29
function pauseTight(delayInterval) %PAUSETIGHT A command that completely blocks Matlab execution access for specified delay. Unlike the built-in pause() command, callbacks are also prevented from firing. % %% NOTES % The pauseTight() function is primarily intended as a fully blocking delay, in contrast to the bui...
64f0a9d934f1fd9b992cd4771f70920a132447fb3bdd87f68b5ab9e961db25b7
MATLAB
945
39
%% pdf_LogNormal: LogNormal Probability Density Function % % Usage: % x = pdf_LogNormal(N, m, s) % % Inputs: % N scalar, number of samples % m mean of the lognormal distribution % s standard deviation of the lognormal distribution % % Output: % x ...
728ddf0269064cdd7443875edb12a1371a241a723b2666447352a9b321b31e63
MATLAB
945
34
function model = markovFit(X, nstates, pseudoCountsPi, pseudoCountsA) % Fit a markov model via MLE/MAP. % X(i, :) is the ith case and X(i, j) is in 1:nstates. % % Returns a struct with fields pi, A. % % pi(j) = p(S(1) = j) % A(i, j) = p(S(t) = j | S(t-1) = i) % % where S(t) denotes the state at time step t. % % This f...
620377c185bf1c85d734512ffc75388f5e51e07621e31a5a11f1b03a9ac58276
MATLAB
946
46
%% Kpca demo setSeed(0); %{ % Make data on a 2d circle (from stprtool/data/gencircledata.m) num_data = 500; Center = [0;0]; R = 10; phi = 2*pi*rand(1,num_data); gnd_X = repmat(Center,1,num_data)+R*[cos(phi);sin(phi)]; gnd_y = ones(1,num_data); % add noise dev = 1; X = gnd_X + randn(2,num_data)*dev; X = X'; % rows are...
98226bcb2838a0640d6d716bf24ef322eaaeb22ee56e80e4cba7453553f5c34f
MATLAB
946
24
function [pX,gX,pY,gY,X,Y] = get_MCMC_predictiveDensity(f_fname,g_fname,u,n_t,options,dim,N,np,lx,ly) % legacy code s = warning ('on'); warning ('*** The function `get_MCMC_predictiveDensity` is now deprecated. Please use `VBA_MCMC_predictiveDensity` instead (same syntax).') warning (s); % fallback switch nargin ...
f50e4c5f3e4699b2c142dd64676c31a831d9a2efef655b7b089e340d192f2f77
MATLAB
946
25
function [adja_pruned, prunedMat, prunedBins] = prune_graph_neighbored( ... memberMat, binNeighbors) % Input: % - memberMat: matrix of nr bins by nr datapoints. value is 1 if datapoint % in bin % - binNeighbors: matrix of nr bins by nr bins. value is 1 if bin i % is within neighborhood of bin j %% Find bins that ...
07e4c8c10a79a6d09d169d1ef98f6bd194f82463b84c295db6c012ba42bb2989
MATLAB
947
24
function candoit = canGetPartialEuclideanGradient(problem) % Checks whether the partial Euclidean gradient can be computed for a problem. % % function candoit = canGetPartialEuclideanGradient(problem) % % Returns true if the partial Euclidean gradient of the cost function can % be computed given the problem desc...
164be58291977939e9b55026c9191c451699c996491ce8cd4e19ef419966312a
MATLAB
948
33
% MF_MV Multiply using multifrontal factorization. % % Typical complexity for N = SIZE(A,1) = SIZE(A,2): O(N) in 1D and % O(N^(2*(1 - 1/D))) in D dimensions. % % Y = MF_MV(F,X) produces the matrix Y by applying the factored matrix F to % the matrix X. % % Y = MF_MV(F,X,TRANS) computes Y = F*X if TRANS =...
2bc23715cf4c4a0040dd774a89d6f15fb011ba717a682668c4c588280c01f1aa
MATLAB
948
31
function show_maps(D,cc) % SHOW_MAPS(D,CC) % Show cross-sectional views around maximum-valued voxel for given CC-th % volume in D. switch length(size(D)) case 4 % Permute 1st and 2nd dimensions D = permute(D,[2 1 3 4]); % Pick only selected component t = squeeze(D(:,:,:,cc)); ...
62472eec529bd8f370e44d4298684a5689f4125d09dae6b2f63962d574d55c2e
MATLAB
948
44
function g = gsmooth(y, sig) % gsmooth - smooth vector or matrix by filtering with a Gaussian % % g = gsmooth(x, sig); % % Inputs: % y [MxN] - matrix or vector (if matrix, operates along columns only) % sig [1x1] - stdev of smoothing Gaussian % % Output: % g [MxN] - smoothed signal % % Note: normalizes fi...
7adc5e65c1d4e3e41235529eb23b0666a5f4a88eced0be6f35e2fe92af062ac6
MATLAB
948
24
function trigInds = FindTriggers(channelData, threshold) % trigInds = FindTriggers(channelData, threshold) % finds indices of where the channelData changes by more than threshold % (positive and negative change) % and returns those indices % Inputs: channelData is a vector of the voltages from the EEG channel % ...
d0d6c239ead1047b77b19fdc41efe71dc34f2788e25412391b794bcdd5a6fb5d
MATLAB
948
32
function gaussian = make2DGaussianCentered(w, h, x0, y0, sigma, gaussAmp) % % function gaussian = make2DGaussian(w, h, x0, y0, sigma, gaussAmp) % make sure width and height are even if mod(w, 2) w = w - 1 ; fprintf('make2DGaussianCentered: adjusting width, w, to be even ...\n') widthAdjusted = 1; else ...
1d5af2990d8fd00b670232fbacbd3599d4bf300aa5e5520b0a5766506313081e
MATLAB
949
27
function theta = packRNN(net, n_Wru_v, n_Wrr_n, m_Wzr_n, n_x0_c, n_bx_1, m_bz_1) % This function is appropriate for an FFN with a single hidden layer. The % variable names are w.r.t. to the actual weights, but any derivative % products during learning can be packed / unpacked in this way. Note that % net isn't modified...
203b07cd3cba65dcae59e54893a01e89dec1e320adc72f86f99f4ae770f9f8f2
MATLAB
949
34
function h = height_tetrahedron(a,b,c,d) % HEIGHT_TETRAHEDRON Calcultes tetrahedron heights. % % SYNTAX: % [H] = HEIGHT_TETRAHEDRON(A,B,C,D) % HEIGHT_TETRAHEDRON(A,B,C,D) % % [H] = HEIGHT_TETRAHEDRON(A,B,C,D) % - A, B, C and D - are m by 3 matrices of (x,y,z) cartesian coordinates % of vertic...
5dea95766407009f9c83071b1729253447699fd017f45c9e578c22406099c0e1
MATLAB
949
54
function PlotAxisAtOrigin(x,y); %PlotAxisAtOrigin Plot 2D axes through the origin % This is a 2D version of Plot3AxisAtOrigin written by Michael Robbins % File exchange ID: 3245. % % Have hun! % % Example: % x = -2*pi:pi/10:2*pi; % y = sin(x); % PlotAxisAtOrigin(x,y) % % PLOT if nargin == 2 plot(x...
803c38c0b7c58eae36932b96a1b783fb27ce0002ddc316c79c8abac31e755fa4
MATLAB
949
30
function [Xsamp, Xcond]= SimConditions(var_uniq,N) % Create array of all possible conditions P = length(var_uniq); levP = zeros(P,1); for p = 1:P levP(p) = numel(var_uniq{p}); %number of levels per covariate end switch P case 1 Xcond = ndgrid(var_uniq{:}); case 2 [x1, x2] = ndgrid(var_uniq...
a0ecb26642e5f9dd47f862973168b97e62c5a9b1909cbfa3607d64a61fe7da85
MATLAB
949
46
%SAVEINR Write an INRIMAGE format file % % SAVEINR(filename, im) % % Saves the specified image array in a INRIA image format file. % % SEE ALSO: loadinr % % Copyright (c) Peter Corke, 1999 Machine Vision Toolbox for Matlab % Peter Corke 1996 function saveinr(fname, im) fid = fopen(fname, 'w'); [r,c] = size(im'); ...
77bb1b124e2c1c6ab99cdd81a02580bf2eef74ca2d52283c87f315bd598d79b4
MATLAB
950
40
function is_same = compare_tif_with_hdf5_files(tifDir, hdf5Dir) tifFiles = dir(fullfile(tifDir,'*.tif')); hdf5Files = dir(fullfile(hdf5Dir,'*.h5')); if length(tifFiles) == 0 disp('no tif file.'); is_same = false; return; end if length(tifFiles) ~= length(hdf5Files) ...
9095d406ab2d53aa4de4a18cb9d0deea36a4b0a4cf47983783f41989f0612a77
MATLAB
950
56
function LAN = eeg2lan(cfg) % <*LAN)<] % v.0.0.2 % % cfg.filename % cfg.where % cfg.delbad if nargin == 0 [file, path] = uigetfile('*.EEG;*.eeg', 'Choose a EEG Neuroscan file -- cnt2lan()'); delbad = 0; elseif ischar(cfg) %%$ compatibility with old versions file = cfg; path = ''; del...