sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
60dd19dde40e9d1fd131c6cc1d1cb46f3bc4c3ea034b798b17afc06ef3b3d450
MATLAB
1,285
62
%{ Example: Graph is this: 1 / \ 2 3 | 4 Let us tie the 1-2 and 1-3 edges. %} G = zeros(4,4); G(1,[2 3]) = 1; G(2,4) = 1; G = mkSymmetric(G); Nnodes = size(G,1); edgePot12 = [1 2; 3 4]; edgePot24 = [5 6; 7 8]; edgePots = zeros(2,2,2); edgePots(:,:,1) = edgePot12; edgePots(:,:,2)...
3cd5e28b52eaa89b219cf5a8697794626dfb215ee5486dfe0b18db2ca27b7db1
MATLAB
1,286
35
function Data = yw_ReadOrganizedData(InputName) % deal with the InputName if iscell(InputName) FileList = reshape(InputName, [], 1); elseif ischar(InputName) || isstring(InputName) if ~exist(InputName, 'file') error('yw_ReadOrganizedData:InvalidInput', 'File not found: %s', Inp...
b0d0641ca44305f73e84ad18bfcb0d83d8277c97590e03d4337d3a858c875c7e
MATLAB
1,286
61
function lead0=getleadfield_sphero(x1,n1,para); if isfield(para,'senslocs') senslocs=para.senslocs; sensus=para.uall; sensds=para.dall; [nsurf,ndum]=size(x1); [nsens,ndum]=size(senslocs); lead0=getlead(sensus,sensds,senslocs,x1,n1); else lead0=0; nsens=1; end if isfield(para,'refloc') re...
f2e58aa79d1c1e60d6bcf3c9c36f1c9d9a525f7ff59347013b8469d6aa7249fc
MATLAB
1,286
38
function tol = GLM_tolerance(X0) % computes regression tolerance of a given design matrix % function tol = GLM_tolerance(X) % In the context of multiple regression, tolerance measures how well each % regression weight can be estimated, given that the design matrix may % suffer from multicollinearity. Note: multicolline...
08b60f1b0464c31093b4eeda55f13b288ffc01e7383cf50e821a334421631ad9
MATLAB
1,287
50
function colorim = h_createGOMImage(red,green,blue,climitr,climitg,climitb) warning off MATLAB:divideByZero; green = double(green); red = double(red); blue = double(blue); if ~(exist('climitg')==1)|isempty(climitg) temp2 = sort(green(:)); climitg = [temp2(round(0.05*length(temp2))),temp2(round(0.99*l...
3ba214ea466cf0f49b2fd86ad18faca38e6b5b4e75510b24bd4735e559e676bc
MATLAB
1,287
35
% At startup, matlab will find a file startup.m assumed to be located in directory specified by % the environmental variable MATLABPATH (see http://www.mathworks.com/help/matlab/ref/startup.html). # Written by Csaba Orban and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md if (~isd...
cd93d2f826f43c28138c75022741da6feb5df1668166264ecd9c78ee7da9ed68
MATLAB
1,287
62
M = M4_cropped; T = size(Tracecellsdf,2); %ContoursAll=ContoursAll'; for i = 1:length(ContoursAll) Contour = ContoursAll{1,i}; Contour = Contour'; ContoursAll{1,i}=Contour; end raw_traces= zeros(length(ContoursAll),T); for i = 1:length(ContoursAll) BW1=zeros(size(M,1),size(M,2)); cont=cell2mat...
fc13600f0873abac15d7239ff0a67f8e360fded7b6a5c71b13a9e9a33d6478ed
MATLAB
1,287
51
%% Fit an HMM and an equivalent DGM and make sure the results agree % %% % This file is from pmtk3.googlecode.com setSeed(2); %% sample data nstates = 10; d = 13; T = 11; nsamples = 15; hmmSource = mkRndGaussHmm(nstates, d); [Y, Z] = hmmSample(hmmSource, T, nsamples); Y = cellwrap(...
313a30bdc9b5b25597c1f1dc41b28af6d8f1a2ddac7b222319194db27ac40f5d
MATLAB
1,288
24
function [Epri, Ppri] = bemf3_inc_field_electric_plain(strdipolePplus, strdipolePminus, strdipolesig, strdipoleCurrent, Points) % Computes potential and electric field from the dipole distribution via the FMM % at observation points (Points) % % Copyright SNM 2018-2020 % Define source (pole) positions and ...
58b52c243a4e68067b83a91137bda4da41e7eedb892fdf5da52dfa1efc307fb7
MATLAB
1,288
25
function [normalized_weigthing] = region_source_weighting(centroid,aal_node,sourcemodel) % aal_node: array comprised of indices of sources in region % example: aal_node=find(source_aal.tissue==1); % sourcemodel: is the source model structure % centroid: source index that represents the centre source centroid_dis...
be9e3a416092100ee46298c3a8e844ab27aab7d7a4baa91e1f30ec46ba0ae0fe
MATLAB
1,288
57
%XMLDEMO3 Demonstrate how to convert an XMLtree in a simple structure % % Description % This script demonstrates the use of the xmltree class to % convert an XMLtree (when possible) in a simple structure. % This can only be performed when the XML file is simple enough % (one element cannot have more than one ...
08e74887e3f66737a431e8c626c82f1e04a2ddd156546b053b4c5fad09f8a65f
MATLAB
1,289
37
function [alligned,allignedIndex,K] = getaligneddata(data,index,range,artifact) % [alligned] = getaligneddata(data,index,range) % index Tx1 = The sample index of the trigger % range 1x2 = range(1) samples before and range(2) samples after the % trigger index % data : Multichannel data first dimension is the sample...
b05a78ad16e29e852790a9023d0ccc8ad4d342da357c3010d79e487fb093d480
MATLAB
1,289
63
function RT = rt_del(RT,ind,inv) % v.0.0.4 % <*LAN)<] % % 31.03.2014 PB: (Descomete lan_check, puse opsion para no ordenar, REVISAR!!) % 26.04.2013 (agregue condiciones para que no se caiga) % 07.01.2013 % 08.08.2012 % 03.04.2012 if numel(ind)==1 && ind==0 return end if islogical(ind) ind=find(ind==1); end ...
e6c69a2137018313a9c63c49dca5aed5fee4304ab109d34d02b22fc770cdce90
MATLAB
1,289
53
function A=mkfilt_eloreta(L, gamma); % Code by Guido Nolte with minor modifications by Stefan Haufe [nchan ng ndum]=size(L); LL=zeros(nchan,ndum,ng); for i=1:ndum; LL(:,i,:)=L(:,:,i); end LL=reshape(LL,nchan,ndum*ng); u0=eye(nchan); W=reshape(repmat(eye(ndum),1,ng),ndum,ndum,ng); Winv=zeros(ndum,ndum,ng); winvkt...
f035e71f36ccb54ce44b82daa507f2d38b2ae226098424cde36d439ae97a3c0a
MATLAB
1,289
40
function [subs,vals] = find(t) %FIND Find subscripts of nonzero elements in a tensor. % % S = FIND(X) returns the subscripts of the nonzero values in X. % % [S,V] = FIND(X) also returns a column vector of the values. % % Examples: % X = tensor(rand(3,4,2)); % subs = find(X > 0.5) %<-- find subscripts of valu...
2761d93442dd15b78267cad1b6158ad95f45108bc990ed45cc8bb5d7108011d8
MATLAB
1,290
38
%{ Copyright (c) 2025 Axion BioSystems, Inc. Contact: support@axion-biosystems.com All Rights Reserved %} classdef StimulationEventData %STIMULATIONTAGBLOCK Structure that contains the data describing a %marked, stimulation portion of a file properties(SetAccess = private) %ID: Number t...
45d188ca89136907f953ba0dded77210953504f5809426a953967ac4de4bccbf
MATLAB
1,290
30
function y=umaxbert(u); %UMAXBERT Determination of the maximum value of u for Bertrand distribution. % Y=UMAXBERT(u) is the function Y(u)=(H(u)+u/2)/(H(u)-u/2)-fmax/fmin. % Doing UMAX = fzero('umaxbert',0); gives the maximum value for U in the % computation of the Bertrand distribution. For this distribution, % H(...
870ad7d0e78edf61ba91b91b436751fc4d7b747d10e7e6a81612cc2e3d7e8965
MATLAB
1,290
40
%% Sequential Bayesian Updating of a Beta-Bernoulli model. % In this example we draw samples from a Bernoulli distribution and then % sequentially fit a Beta-Bernoulli model, plotting the posterior of the % parameters at each iteration. %% Sample % This file is from pmtk3.googlecode.com setSeed(0); mu = 0.7; % 70%...
8cadf120427871d50553a985ae7714a1ce4f4825af4dc74a04ac88e4415696ba
MATLAB
1,290
48
function [model] = noisyMixModelFit(X, Y, K, obstype) % Mix model of form Q -> Xj -> Yj % similar to a tied mixture (semi-continuous) HMM % p(X,Y|Q=k) = prod_j p(Xj|Q=k) p(Yj|Xj) % p(Xj|Q=k) Ber(xj|theta(j,k)) % p(Yj|X=c) = Gauss(y(:,j) | mu(j,c), Sigma(j,c)) % % The idea is that Xj is the j'th binary tag % Yj is the...
a635800394cee922a5628dbbc14f5032b899cc755dc2f04f47d8f3318b2f57de
MATLAB
1,290
37
function varEMbound x = 0:0.1:4; figure(1); clf; hold on; y1 = logistFn(x, 2); plot(x, y1, '-b', 'LineWidth', 3); text(2.3,1.03, 'true log-likelihood', 'FontSize', 16, 'FontWeight', 'bold'); y2 = logistFn(x, 1); plot(x, y2, ':r', 'LineWidth', 3); text(2.8,0.92, 'lower bound'...
bd8cc7060b78e352f36abf94c8559dbd24286dfd64e2b10042f726b0cb56c0ab
MATLAB
1,290
33
function forest = fitForest(X,y,varargin) %Fit a random forest. Rows of X are examples, columns are features. See %dtfit for tree specific documentation. Fits 'ntrees' on randomly selected %subsets of the training examples in X, (with replacement). At each node in %each tree, the best of a random selection of candi...
0e7ed18980924959b59a6e8b27eb87eac486cf03af531c77fed93c456b0f9592
MATLAB
1,291
36
% At startup, matlab will find a file startup.m assumed to be located in directory specified by % the environmental variable MATLABPATH (see http://www.mathworks.com/help/matlab/ref/startup.html). % Written by Valeria Kebets and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md if (~...
272e2f0811511014a2e1ef06847e55d2296f9c509a73d553764c6e15c0555fe9
MATLAB
1,291
34
function stack = GaussSmooth(stack, sigma) % Gaussian smoothing with periodic BCs % % GaussSmooth(stack,sigma) % %--------------------------------------------------------------------- % license %--------------------------------------------------------------------- % Copyright 2015...
32128ffcef96999ccd91d1cc474897b4ba0b0d7502035c5569d6ad305a3dfbd5
MATLAB
1,291
31
psthPara.binsize = 10; psthPara.binstep = 10; % ms cwStr = ["push", "nopush"]; for cwIdx = 1 : length(cwStr) switch cwStr(cwIdx) case "push" %% (cwStr(cwIdx)) tIndex = ([trialAll.stdNum] >= sIndex & [trialAll.correct] & [trialAll.oddballType] == "DEV")|([trialAll.stdNum] >= ...
47de1a782b920c7eb17c8da5d88049177843ff3217bf0802f65ccd6a3a2a33f2
MATLAB
1,291
43
function D = build_KLdivta(datadir, kerneldir, only_1st) % D = build_KLdivta(datadir, kerneldir, only_1st) % % build symmetrised KL divergence matrix based on time-averaged model (single-state HMM) % The divergence matrix will be used in Gaussian kernel for KRR in main % prediction function % % Dependencies: % HMM-MAR...
8e87834da33918bfba9ec6d71374a9b9c89ffd3ef3f3adcfbae1f67ce7fe4ee5
MATLAB
1,291
37
% At startup, matlab will find a file startup.m assumed to be located in directory specified by % the environmental variable MATLABPATH (see http://www.mathworks.com/help/matlab/ref/startup.html). % % Written by Wu Jianxiao and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md if (~...
ab8039ba6ac73c15494c358fc9593a8412448624450ee14503472484bf60ccf1
MATLAB
1,291
33
function [tau] = fit_fd_tau_to_data(euclidean_distances,similarity_distribution,df,v) fun = @(x) tau_fit(df, v, similarity_distribution, euclidean_distances, x(1)); tau = ... fmincon(fun, ... v.fit.tau_init, [],[],[],[], v.fit.tau_lb, v.fit.tau_ub, [], ... optimset('TolX', 0.0001, 'TolFun', 0.0001, 'MaxFun...
f37260302898cdff7b7a1397ee3486a8b792b8feb00549a836416ec7dc07f08a
MATLAB
1,291
56
function [timePlot, freqPlot, dB_powPlot]= plot_spectrogram(sig, fs, tWindow, fracOVlap, nfft, cbar_range, useDefaultPlot, tStart) if ~exist('tStart', 'var') tStart= 0; end if ~exist('useDefaultPlot', 'var') useDefaultPlot= 1; end if ~exist('cbar_range', 'var') cbar_range= 60; end if ~exist('tWindow', 'v...
84381de876dabeb5e4869711cd5b9d27d15d735684b86c90b76f280242ba66e4
MATLAB
1,292
64
% 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,...
d291c79e4e05c66c7b6b7cd610739e11f1c615e7ba408f66846777004f67fede
MATLAB
1,292
50
function [MuscleLength, MuscleVelocity, MuscleMomentArm] = MuscleOneJoint_JointAngles(a1,a2,phi1,phi2,R1,f1,n1,alpha1,alpha1_dot,handrule) % MATLAB code provided by Seyed Mohammad Ali Rahmati % Affiliation: Biomechanics and Motor Control Lab, Department of Biological Sciences, Georgia Institute of Technology, Atlanta,...
dba934341b7fc7bc7d852425b062e8c8045993bc9b877cf9795de7c76c9f0038
MATLAB
1,292
24
function test_roian_bsub_tracking() if ispc() warning('bsub backend is not supported on Windows, so %s always passes on Windows', mfilename()); return end linux_project_file_path = '/groups/branson/bransonlab/apt/unittest/four-points-testing-2025-04-12-with-rois-added-and-fewer-smaller-avi-movies-...
ff5c7b628ad83561e184a783241c9ed473a1f8ad7de736f89b85e93f12885e47
MATLAB
1,292
41
function ind = sub2ind2( siz, sub ) % Improved version of sub2ind. % % Almost the same as sub2ind, except always returns only a single output % that contains all the subscript locations. Also handles multiple linear % subscripts at the same time more conveniently then matlab's version. See % help for sub2ind for more ...
0ba428e58ecb8555b0437ace6b0e52947e6e4e03a2964912fabdd5d5661cf721
MATLAB
1,293
54
function [source,source_mag]=min_norm(patt,V,para); % makes a minimum norm estimate of a potential patt; % % input: patt nx1 vector where n is the number of channels; % V nxmx3 tensor where m is the number of gridpoints; % V(:,i,j) is the potential of unit dipole at the i.th % point i...
e9749fa7e981aeb683b6c26a8e56b7a2b19bc66d7e4fc261e62442acf935ce2b
MATLAB
1,293
40
function [inh] = spm_deconv(out,u,SNR) % basic Wiener deconvolution % function [inh] = spm_deconv(out,u,SNR) % Let us define the above LTI convolution model: % out = conv(in,u) + e % where e is a white noise process. % This function inverts this model using Wiener deconvolution, i.e. % estimates the input in, given ...
72fd6c96de54d9898803f998d0f95a8e86ded2e1959acb04af8c03fc3a24b4d7
MATLAB
1,294
44
function [samples, naccept] = metropolisHastings(target, proposal, xinit, Nsamples, proposalProb) % Metropolis-Hastings algorithm % % Inputs % target returns the unnormalized log posterior, called as 'p = exp(target(x))' % proposal is a fn, called as 'xprime = proposal(x)' where x is a 1xd vector % xinit is a 1xd vect...
7b9d7e7e18f3863bdcb92c27a702d28e9d5617fbcbe614c76a8241c4e04035a5
MATLAB
1,294
40
% example of 2D affine registration using the lsqnonlin optimizer. % clean clear all; close all; clc; % Add all function paths addpaths % Read two greyscale images of Lena I1=im2double(imread('lenag3.png')); I2=im2double(imread('lenag2.png')); % Type of registration error used see registration_error.m ...
e0fb5288d62dcb81929eec3da8bfdc44bf7df0f5f4ec6de8bda38b33614b75a4
MATLAB
1,294
43
function spkDat = MergeClusters(spkDat, mergeDat) % 11/21/2016 M. Farries relabelClusters = true; [wL, nChan, ~] = size(spkDat.waves); if isstruct(mergeDat) mergeClust = arrayfun(@(x) x.clust, mergeDat); dt = arrayfun(@(x) x.dt, mergeDat); destClust = mergeDat(1).refClust; else destClust = mergeDa...
6d5968229ad9571ddb965869ffebfd8dc175ccaaab9fd526765ff42ba2e47453
MATLAB
1,295
56
function [] = plot_model_psychometrics(performance_matrix) hold on %average over location strengths y3=mean(performance_matrix,1); vec=[-4 -2.5 -1 1 2.5 4]; %%% compute logistic fit ft = fittype( 'bao+t./(1+exp(-(x-alpha)/beta))', 'independent', 'x', 'dependent', 'y' ); opts = fitoptions( ft ); opts.Display = 'Off';...
a81ab7a3cc1da14c3d90501cd3a2ddb9a5b5201081dc231d40d657c96c820f3b
MATLAB
1,295
51
% SecLevel clear all; close all; clc; Datapath='/home/Damian/PD_sleep_memory/EEG/Scripts/data/'; nSubj=18; roiChannel=3; %Fz: 3 for s=1:nSubj clear EEGPSD % load events load([Datapath,'EEG_S',num2str(s),'.mat']);%eventfile showing offset of stimulation in SR (512) % remove: s11k4, s10k3k4, s9k1k3k4...
bec2b9cc35c8688d9a3a75f7953bb72662bab60a22e0c0afa7e982881f7d46ed
MATLAB
1,295
33
function [SNReff,bEff,Tmix] = DWSTE_SNREfficiency(x,optSample,optScanner,b,~) %% % calculates DW-STE SNR Efficiency % % input: % x = array with diffusion gradient (mT/m), duration of diffusion gradient (ms), echo time (ms) and repetition time (ms) % optSample = T1 (ms), T2 (ms) & D (um^2/ms) % optScanner = Maximu...
fc961e9049db97ab5fe4b2fabce64956003c7a68b455331ebd9e05185b24438e
MATLAB
1,295
23
%% Spiral disp('######################################'); disp('#### Design a dual density spiral ####'); disp('#### ####'); disp('######################################'); disp(' '); [k_rv,g_rv,s_rv,time_rv,Ck_rv] = vdSpiralDesign(1, 16, 0.83,[55,55,10,10],[0,0.2,0.3,1],4,15,4e-3,'cubic'...
9a33525fca55f664334aa2b9ab0652cff8752ee5b3226ce2bc99c82b52b5be7f
MATLAB
1,296
44
function [BF01, probH0] = bayesTtestTwoSample(x,y,xbar,ybar,Nx,Ny,sx,sy) % BF01 = p(data|H0)/p(data|H1), where H0 says delta=0, H1 says delta is unconstrained % probH0 = p(model=H0|data) % % Usage: % [BF01, probH0] = bayesTtestTwoSample(x,y) % or % [BF01, probH0] = bayesTtestTwoSample([],[],xbar,ybar,Nx,Ny,sx,sy) % % R...
6528d1ea71aeb76ba7ea160e7dfd054d62923627177ce4d5c16f6b17b68489a0
MATLAB
1,297
47
function lme_timePlot(time,y,ni,subjs) % lme_timePlot(time,y,ni,subjs) % % Spaghetti time plot of longitudinal data. % % Input % time: Time covariate. % y: Ordered data vector (according to time for each subject). % ni: Vector whose entries are the number of repeated measures for each % subject in the study (ordered ac...
935bf29f18dc2740078bab3eb78ef78c6ca89cca1ca58a3fc16bad7884ac717d
MATLAB
1,297
53
% Test depth first search % This file is from pmtk3.googlecode.com %% A DAG % Do the example in fig 23.4 p479 of Cormen, Leiserson and Rivest (1994) u = 1; v = 2; w = 3; x = 4; y = 5; z = 6; n = 6; dag=zeros(n,n); dag(u,[v x])=1; dag(v,y)=1; dag(w,[y z])=1; dag(x,v)=1; dag(y,x)=1; dag(z,z)=1; directed = 1; root = 1;...
a67cb0bbfdf482007d7efa30070d88d19e836d68a7cd46ffa7acd0c5bfb15090
MATLAB
1,297
59
function [PLV,meanphi] = pair_wise_PLV_wavelet(data) %function PLV = pairwisePLV(data) % Compute Phase Locking Value (PLV) for all pairs of channels % Data: timepoints x channels % % % Example: % x = sin(2*10*pi*t); % y = sin(2*10*pi*t); % x = x + randn(size(x))*0.1; % y = y + randn(size(y))*0.1; % [PLV,meanphi] = pair...
9447c3b8de70c5d6d30f73a2bfa4fc7d09262d79fdcf1773d66087336f1520cd
MATLAB
1,298
55
function model = logregBinaryFitL2IRLS(X, y, lambda, includeOffset) % Iteratively reweighted least squares for logistic regression % % Rows of X contain data. Do not add a column of 1s. % y must be binary and will be transformed into [-1 1] % lambda is optional strength of L2 regularizer % % model.C is the asymptotic c...
2f6f2c5eb807770083cccd73ab49cc69f8e9d0c9829e5658dd68c15a8fe26f9b
MATLAB
1,299
19
function [x,fval,exitflag,output,lambda,grad,hessian] = SQPGenerateCode(x0,lb,ub,MaxFunctionEvaluations_Data,MaxIterations_Data,OptimalityTolerance_Data,StepTolerance_Data,ObjectiveLimit_Data,ConstraintTolerance_Data) %% This is an auto generated MATLAB file from Optimization Tool. %% Start with the default options op...
6fb27f9245d7a79751c64abbd48d75af1ac94435a12d5af79b71391157aa5005
MATLAB
1,299
31
function Path = dirItem(rootPath, keyword, varargin) % Description: find file or folder name in rootpath % Input: % rootpath: ROOTPATH % keyword: the raw file or folder name used to find % newName: the string to replace the raw name % folderOrFile: decide rename file or folder mIp = in...
f3b5b4a0abd9ce854ee4027a876e6175e77ea28cd86800a283c251774cf2032a
MATLAB
1,299
58
% h = drawellipse(trk,varargin) % h = drawellipse(x,y,theta,semimaj,semimin,varargin) % extra arguments will be fed to plot function varargout = updateellipse(h,x,varargin) % draw an isosceles triangle with center (x,y) % with rotation theta % with height maj*4 % with base min*4 if isstruct(x), fly = x; if nargin...
100ac779bc364ed9973586c46f2a076d5f6d9388595181c23aacb063faec4bf4
MATLAB
1,300
66
% _ _ % ___ _ __ __ _| |__ ___ ___ _ __| |_ % / __| '__/ _` | '_ \/ __|/ _ \| '__| __| % | (__| | | (_| | |_) \__ \ (_) | | | |_ % \___|_| \__,_|_.__/|___/\___/|_| \__| % % makes a raster using all sorted spikes function makeRaster(self,~,~) if self.verbosity > 9 d...
89133d451839e6c1cbbbebd98ffd6d20cdb2c5343138522564416b99dfc6b442
MATLAB
1,300
39
function s = accumulate_steps(sites_per_run,return_as_matrix,return_total) if (nargin < 2) || isempty(return_as_matrix) return_as_matrix = false; end if (nargin < 3) || isempty(return_total) return_total = false; end assert(iscell(sites_per_run),'sites_per_run must be a cell array');...
a318189b948abd65a7a3e3075c689acb88e398faa8383840afeefc6c2c28e37b
MATLAB
1,300
51
function ev_trig_stagger(event, signal, windowSize, plot_type) if nargin < 4 plot_type = 'cell' end event(1:windowSize/2)=0; nEvs = sum(event); evIdx = find(event); avg = zeros(1,windowSize+1); x = -windowSize/2:1:windowSize/2; figure hold on switch plot_type % Staggered plot by cell case 'cell' ...
aa5a51ecd5b9693cdbcc13ac69ea76c43521809b66a12987cf403fecf74c1d88
MATLAB
1,300
27
function y = var_proj(Q,C,eigsum) % function for finding variance explained in a certain projection % Q: A matrix with orthogonal columns that define the subspace % C: Covariance matrix of the data with the same row dimension as Q % eigsum: sum of the largest k eigenvalues of C where k = size(Q,2) % authors: Xiyua...
79d6e631513325d4c33c211bee9d1218bb42b685fe9af7387e102d28a5f60108
MATLAB
1,301
58
%% fnc_FAST_getInputs: transform the normed input in the real range inputs % % Usage: % X = fnc_FAST_getInputs(pro, NormedX) % % Inputs: % pro project structure % NormedX normed inputs % % Output: % X inputs in the correct ranges % % ----------------------------------...
8a6cd4da7132bf44f8617ab2ac4a10fe4361aa4ad1cd933793cc1b219a50f98a
MATLAB
1,301
30
function y=umaxdfla(u); %UMAXDFLA Determination of the maximum value of u for D-Flandrin distribution. % Y=UMAXDFLA(u) is the function Y(u)=(H(u)+u/2)/(H(u)-u/2)-fmax/fmin. % Doing UMAX = fzero('umaxdfla',0); gives the maximum value for U in the % computation of the D-Flandrin distribution. For this distribution, % ...
b0c27525bf328b623071af6fedd4c2a1db15dbbdcbb3bb974fd28cfb9b6aec21
MATLAB
1,301
32
function AttachedTriangles = meshconnet(t, edges, flag) % This function finds triangles attached to every edge of a triangular mesh % Inputs: array of nodes P, triangulation t, flag % Output: cell (for presumably non-manifold meshes) array of triangles % attached to each edge. % % Copyright SNM 2017-2018 % ...
bd293c0108f0e0de41a5c2b6f400f84ef44503073bae2a7c1b27e3b390e2ea4c
MATLAB
1,301
48
function [gx, dgdx, d2gdx2] = VBA_prodX (X1, X2) % // VBA toolbox ////////////////////////////////////////////////////////// % % [gx, dgdx, d2gdx2] = VBA_prodX (X1, X2) % calculates the 1st and 2nd order derivatives of the dot product X1' * X2 % of two vectors X1 and X2 % % IN: % - X1,X2: two vectors of same size (on...
3c8c61de6a31710b5317aafafdccc37d7057e4f3cf39f9eca6afc57ee626771c
MATLAB
1,302
47
function histMontage( HS, mm, nn ) % Used to display multiple 1D histograms. % % USAGE % histMontage( HS, mm, nn ) % % INPUTS % HS - HS(i,j) is the jth bin in the ith histogram % mm - [] #images/row (if [] then calculated based on nn) % nn - [] #images/col (if [] then calculated based on mm) % % OUTPUTS % % EXAM...
af8f4340966a2360344a00db47a0c3417095300bad679341f507b3312728cd8b
MATLAB
1,302
43
function [mu, se] = cvEstimate(fitFn, predictFn, lossFn, X, y, Nfolds, varargin) % Cross validation estimate of expected loss % model = fitFn(Xtrain, ytrain) % yhat = predictFn(model, Xtest) % L = lossFn(yhat, ytest), should return a vector of errors % X is N*D design matrix % y is N*1 % Nfolds is number of CV folds %...
3780cc7dae7ef7fbcca7308b9abe14aed75aab7ea690a7f8834240e4b14b2f5e
MATLAB
1,303
50
% HIFIE_SPDIAG_MV_N Dispatch for HIFIE_SPDIAG with DINV = 0 and F.SYMM = 'N'. function D = hifie_spdiag_mv_n(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 act...
eb04c178b9872dc9ec0bac9e3d4eff1d9a4fff3c71508cadbcf99ca50c278ff9
MATLAB
1,303
50
% HIFIE_SPDIAG_SV_N Dispatch for HIFIE_SPDIAG with DINV = 1 and F.SYMM = 'N'. function D = hifie_spdiag_sv_n(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 act...
015d3d77a6d8e0675c3b514a3ab9d1abb1551a5a07f62a8f7831d9c18806b511
MATLAB
1,304
50
function disp(X,name) %DISP Command window display of a tensor. % % DISP(X) displays a tensor with no name. % % DISP(X,NAME) displays a tensor with the given name. % % See also TENSOR, TENSOR/DISPLAY. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, ...
1a2f50a85c9ec60006b7533107c828319247bb146e67f93b6a645b99b6444c3e
MATLAB
1,304
45
% Setup base path clear; basefolder = fileparts(fileparts(fileparts(mfilename('fullpath')))); codefolder = [basefolder,'/code']; toolsfolder = [basefolder,'/tests/tools']; addpath(genpath(codefolder)); addpath(genpath(toolsfolder)); % Load Data data_path = [basefolder, '/tests/fixtures/w3c/SBJ99_bold.npy']; data = r...
585b91c025f719d1cfd599a3b76e09fb05df3b8cbcc6c19ab4973b6555a58049
MATLAB
1,304
50
function gifmaker(filename,out) filename = append(filename,'.gif'); PART = out.MOV.P; NEUR = out.MOV.N; div = out.div; [X,Y] = meshgrid(1:div); s = out.s; f = out.f; mapcol = [ autumn(s) ; 0 .9 0 ]; % A green, B red/yellow based on size % Setup figure figure('units','normalized','outerposition',[0 0 1 1]); ho...
6284446e06aa577a95a22378426fa7b7fd308eaefdbd12043fe326a9ac5f7bf5
MATLAB
1,304
50
% HIFIE_SPDIAG_MV_S Dispatch for HIFIE_SPDIAG with DINV = 0 and F.SYMM = 'S'. function D = hifie_spdiag_mv_s(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 act...
94e6d99d5b0374bb4d2e8c23bb0508b5578bcdf615d0bfaea4c72c6646f25901
MATLAB
1,304
50
% HIFIE_SPDIAG_SV_S Dispatch for HIFIE_SPDIAG with DINV = 1 and F.SYMM = 'S'. function D = hifie_spdiag_sv_s(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 act...
ad5aa1eba4d74cd46c727026e4531afcd4efcfb120268ab60994450deab35fde
MATLAB
1,304
28
% GUI Layout Toolbox % Version 2.3.3 (R2018b) 25-October-2018 % % Panels % uix.Panel - arrange a single element inside a standard panel % uix.CardPanel - show one element from a list % uix.BoxPanel - arrange a single element inside a panel with a boxed title % uix.TabPanel - arrange el...
b4e47004f1d01cb7aeb562b182ce2b9c090dcd97fd94825a84e649b1cdeccc49
MATLAB
1,304
38
function varargout = im( I, range, extraInf ) % Function for displaying grayscale images. % % Handy function for showing a grayscale or color image with a colorbar. % % USAGE % h = im( I, [range], [extraInf] ) % % INPUTS % I - image in a valid format for imagesc % range - [] minval/maxval for imagesc % ex...
c0c8f8b4f9b66009434a9b9541fde7721d9396c6703db2650a2119963f3d09c5
MATLAB
1,304
44
disp(' '); disp('fdct_wrapping_demo_basic.m -- Displays a curvelet') disp ('both in the spatial and frequency domains.'); disp(' '); disp(['This is achieved by setting all the coefficients in the curvelet']) disp(['domain to zero except that at the required location (which']) disp(['is set to one). The curvelet is obta...
4d63b7ad1102a2a73d4671231a3751a5ab48971c184297ef873980e47ecd44a9
MATLAB
1,305
37
% $$C\frac{dV}{dt}=-g_L(V-V_L)+I$$ % Input defined at Line 26 clear; %clear all variables % close all; %close all open figures %DEFINE PARAMETERS dt = 1/1000; %time step [ms] t_end = 1200; %total time of run [ms] t_StimStart = 100; %time to start injecting current [ms] t_StimEnd = 1000; %time to end injecting current ...
786533322d515b0f3fd16424e16f32ed4b8e1723c259afa7bd4e727c4784643a
MATLAB
1,305
75
function T=prep_v2head(elecs,head,zmin); % creates a matrix to make a linear interpolatation % from potentials in electrodes to potentials % on head surface % % usage T=prep_v2head(elecs,head); % % input: % elecs Nx3 matrix (3D coordinates of electrodes) % head Mx3 matrix (3D coordinates of head surfac...
8bf9181b7d94d06c0dbbcafc24cb6fa06c3ccefb7c72a11b51f5fc84bda1a838
MATLAB
1,306
61
gKdr = 4; hptau_nb = 3100; hptau_adult = 22000; switch igr case 1 % group I pos1 = 1; gM = 0.801; gNaP = 0.595; gCaL = 0.4; gKCa = 0; hptau = hptau_nb; IM_exp = 56.08; PICa_exp = 39.52; PICd_exp = 1.04; case 2 % group...
df738d1e7a388a1debde309d0d31a921de19f48cb01bf3e17417a5074ef8ed58
MATLAB
1,306
25
% demo_SOFAplotHRTF - script demonstrating the usage of SOFAplotHRTF % Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences % Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License") % You may not ...
f0910033c8b4256503dfd60c34a94a928e4c02e64c1c4c87c8603aa5dad79105
MATLAB
1,306
40
function [tm,T]=loctime(sig); %LOCTIME Time localization caracteristics. % [TM,T]=LOCTIME(SIG) computes the time localization % caracteristics of signal SIG. % % SIG is the signal. % TM is the averaged time center. % T is the time spreading. % % Example : % z=amgauss(160,80,50); [tm,T]=loctime(z) % % See also LOC...
f82b406426dae47e893e796bef5534992c3511b58a4e0a21e1ce35f101f99e6e
MATLAB
1,306
53
%% Illustration of a linear vs 'wiggly' decision boundary. % We make four misclassifications using the linear boundary and none using % the 'wiggly' boundary; however, in the latter case, we may have overfit. %% % This file is from pmtk3.googlecode.com function decisionBoundaryLinearVSwiggly domain = 0:0.01:1; f = @...
0d748c315af92394e721e51dda2aaa494bca3a98751076fa0fac62edc47e40bc
MATLAB
1,307
47
function I = ind2im(ind, sz, vals, fillval) %IND2IM Create image from a set of linear indices. % Usage: % I = ind2im(ind, sz) % I = ind2im(ind, sz, vals) % I = ind2im(ind, sz, vals, fillval) % I = ind2im(BW, vals) % I = ind2im(BW, vals, fillval) % I = ind2im(S) % % Args: % ind: linear indices of the imag...
5e5a55c1c699ed13becbcb2c775524bd500d5203a31976f30a736523f200b148
MATLAB
1,307
75
function T=prep_v2head(elecs,head,zmin); % creates a matrix to make a linear interpolatation % from potentials in electrodes to potentials % on head surface % % usage T=prep_v2head(elecs,head); % % input: % elecs Nx3 matrix (3D coordinates of electrodes) % head Mx3 matrix (3D coordinates of head surfac...
eb629e0462041d256c8dfc1c472a1533a806ef0eb5c7254c6b331b018caccd2a
MATLAB
1,307
26
function compile_compute3Dfrom2D() % get the directory where this file lives % figure out where the root of the Ohayon code is thisScriptFileName=mfilename('fullpath'); thisScriptDirName=fileparts(thisScriptFileName); % just put the executable in the did with the build script % exeDirName=thisScriptDirName; exeDirNam...
423fb9c874bb1ee45dd481c41b62ba46593ec5e9835b54514cb040398c210a2c
MATLAB
1,308
35
%% load adaptative solution load(fullfile(patient_path,'dipoles',dipole_name, ... strcat(patno,'_',model_name,'_',dipole_name,'_charge_solution_adapt'))); %% create figures figure; semilogy(100*Conv.ErrorC, '-o'); grid on; title('Error percentage - global C'); xlabel('Adaptive pass number'); ylabel('% change') sa...
5966ea432acc29f0a86d24b5241cb4367a191ea5ec8cddf6b59870d5ca4ccc52
MATLAB
1,308
28
function dbPath=SOFAdbPath(newPath) % dbPath=SOFAdbPath % % dbPath=SOFAdbPath returns the path to the directory containing % HRTFs for demos and applications. The default path is: this_directory/../HRTFs/SOFA % % [...]=SOFAdbPath(Path) sets the path to the directory for further calls % of SOFAdbPath. % SOFA ...
6b2c17085cae9605d9e89f6b19c07a5b5ffc9dea938d34617c1d8f28b847de41
MATLAB
1,308
47
function colorim = h_createGOMImage(red,green,blue,climitr,climitg,climitb) warning off MATLAB:divideByZero; green = double(green); red = double(red); blue = double(blue); if ~(exist('climitg')==1)|isempty(climitg) temp2 = sort(green(:)); climitg = [temp2(round(0.05*length(temp2))),temp2(round(0.99*l...
708f1beced2c2ed0244f85e5bf52b9a608cef39f027989e1430bb9a1dbd09389
MATLAB
1,308
32
function [ gx ] = g_BSLinGame(x,P,u,in) % observation function for BSL learner engaging in dyadic games % [ gx ] = g_BSLinGame(x,P,u,in) % In a game, a BSL learner bases her decision (a=1 or a=0) upon her % prediction of her opponent's next move, given the game payoff table. NB: % BSL tracks the probability that her op...
8c7c3a404b5215399893ac9bb5b5b2f0963ec4543cafaf90e0d30d0de2c581a6
MATLAB
1,308
46
function score=fast_pacman(decoded_event) %https://blog.usejournal.com/dynamic-programming-finding-optimal-paths-2cf89f3d1437 [score1,maxsum1]=maxsum_algorithm(decoded_event); %start from top and go to bottom right [score2,maxsum2]=maxsum_algorithm(flipud(decoded_event)); %start from bottom and go to top right if s...
25aac941bb3a8c066e3df2a6f53c273637b67250e35b0ae9321577a940fd725f
MATLAB
1,310
53
function softev = localEvToSoftEvBatch(model, localev) % Convert local evidence to soft evidence % localev(n,t,d) is obs for node t, case n, component d % softev(k,t,n) is p(node(t)=k | case n) % % This is a batch version of localEvToSoftEv % that is much faster % This file is from pmtk3.googlecode.com [Ncases, Nno...
7d5f3129b50b28c70a38087f37231cd515b64305dbe75d4b655847dfdab931c0
MATLAB
1,310
53
% RSKELF_SPDIAG_SV_H Dispatch for RSKELF_SPDIAG with DINV = 1 and F.SYMM = 'H'. function D = rskelf_spdiag_sv_h(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 ...
a75a5c9cf9d24850fb4ccc3c9a64d5a03b01d02d175c735798c92d637d783ed8
MATLAB
1,310
40
%% Example script to extract responses of several models to an AP pair % % m-file Requirements: % run_simulation.m % simulate_vesicle.m % % See also: run_simulation, simulate_vesicle % % Author: Chris Norman, University of Warwick % Source: https://github.com/ChrisAlexNorman/SytSim % Directory and file prefix to save ...
b04b7ba3b478e7fb643c16a0500b0b8a24909dbc4966f6e9c74a3987a0ee18b1
MATLAB
1,310
43
%% capCaseLine % utility macro from % string/char switch macro for capitalizing the first term % 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 publi...
bf598ae11ebba7598c1d11d239b05a3d146d32f0a66b1529ed116b37e0237bae
MATLAB
1,310
59
% h = drawellipse(trk,varargin) % h = drawellipse(x,y,theta,semimaj,semimin,varargin) % extra arguments will be fed to plot function varargout = drawellipse(x,varargin) % draw an isosceles triangle with center (x,y) % with rotation theta % with height maj*4 % with base min*4 if isstruct(x), fly = x; if nargin == ...
c7d530852d0c8b668eeab25990abab9cf7fa92d111d4010d0483065809277261
MATLAB
1,310
36
%% conformMarkov % Small utility to take a 2D array, assumed to be a (left) Markov % Stochastic Matrix, and conform it. Assume all elements >=0 % 1) Rescale columns to sum to 1. % 2) Ensure non-populated columns have a 1 on diagonal to preserve % probability. % Copyright (C) 2023 Trevor S. Smith % Drexel U...
fa381426130da1c5c5e89b0bb98edbab3e79070bf505824552899bb689ee26f9
MATLAB
1,310
64
function fmf_copy_some(infilename,outfilename,nframes,startframe,nskip) if nargin < 4, startframe = 1; end; if nargin < 5, nskip = 1; end; % read in the header [header_size, version, f_height, f_width, bytes_per_chunk, ... max_n_frames, data_format] = fmf_read_header( infilename ); datatype = fmf_get_da...
afd172b8b3d073609a11b888297f99e4bbe3924a64b21d120a86299af2300e97
MATLAB
1,311
53
% RSKELF_SPDIAG_MV_H Dispatch for RSKELF_SPDIAG with DINV = 0 and F.SYMM = 'H'. function D = rskelf_spdiag_mv_h(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 ...
56e7af57cc56cffb5318b730b0509bd355c4868876119a9c342a8855db4928d2
MATLAB
1,312
44
%% Conditioning a 2D Gaussian % % Take a horizontal slice thru a 2d Gaussian and plot the resulting % conditional %% % This file is from pmtk3.googlecode.com mu = [0 0]'; rho = 0.5; S = [1 rho; rho 1]; figure; gaussPlot2d(mu, S); hold on; [U,D] = eig(S); sf= -2.5; line([mu(1) mu(1)+sf*sqrt(D(1,1))*U(1,1)],[mu(2) mu...
02ecc82e9e7c5e80d84cc37ad6bba49338c9ab1887d2ad77a071565ac9cd4245
MATLAB
1,313
39
function H = graystep(B, d) %% Cycle a logical vector d steps through the Gray cyclic binary codes % H = graystep(B, d) takes row B of logical values (0 or 1) % through one step forward, if d ~= 0 , or otherwise backward, % through the Gray Cyclic Binary Codes. Only one element of H % differs from the ...
44a65f06a0bc20579a06cb42725b4e2199192bd839460380b4cefff91791e7f6
MATLAB
1,313
45
function y = VBA_nanmean(x, dim) % // VBA toolbox ////////////////////////////////////////////////////////// % % y = VBA_nanmean(varargin) % mean ignoring NaNs % % This function enhances the functionality of NANMEAN as distributed in % the MATLAB Statistics Toolbox and is meant as a replacement (hence the % identical n...
58cec7a793a50054147a5cb1a7f7c5e0040795005772c19a5b6090ede76be67d
MATLAB
1,313
43
function [dat, lab] = read_bham(filename) % READ_BHAM reads the EEG data files as recorded by Praamstra in Birmingham % the datafiles are in a particular ascii format % % [dat, lab] = read_bham(filename) % Copyright (C) 2000, Robert Oostenveld % % This file is part of FieldTrip, see http://www.fieldtriptoolbox.org %...
730dc1cbc3964ed374b7e8babc6952b4ab778b915d8136ad56a437c6a9c613ff
MATLAB
1,313
53
%% Project 3D data onto a 2D basis using PCA % Based on an example by Hamid Bolouri %% % This file is from pmtk3.googlecode.com setSeed(0) n = 100; d = 3; Sigma = diag(sqrt([10,2,0.5])); %Sigma = diag([10,2,0.1]); model = struct('mu', zeros(1, d), 'Sigma', Sigma); X = gaussSample(model, n); % rotate the data alpha...
1c273f704ff6aa69213714f7d5fb94412f478262f2d6fcec674af3627c839243
MATLAB
1,314
56
function [precMat, iter] = ggmFitHtf(S, G, maxIter) % MLE for a precision matrix given known zeros in the graph % S is d*d sample covariance matrix % G is d*d adjacency matrix % We use the algorithm due to % Hastie, Tibshirani & Friedman ("Elements" book, 2nd Ed, 2008, p633) % This file is from pmtk3.googlecode.com ...
7b44960f3b430ad4f45e53e5cba536458d054ded92f4c0777518916da6f4401c
MATLAB
1,314
42
function sig=izak(dzt) %IZAK Inverse Zak transform. % SIG=IZAK(DZT) computes the inverse Zak transform of matrix DZT. % % DZT : (N,M) matrix of Zak samples. % SIG : Output signal (M*N,1) containing the inverse Zak transform. % % Example : % sig=fmlin(256); DZT=zak(sig); sigr=izak(DZT); % plot(real(sigr)); hold; plot...
aa04ceef4b2c7afeffaa0cd57809ce34a69cb3473a01bb6908a83d5be0141daa
MATLAB
1,314
36
function J = genstickgflt( ro, s ) % GENSTICKGFLT Generates (unrotated) stickness kernel with gaussian profile % INPUT: % ro: Radius % s - Scale % OUTPUT: % J - Output kernel (unrotated) with size s+ceil(s/2) % % See also: dirfiltersparse % % AUTHOR: Antonio Martinez-Sanchez (an.martinez....
ed59dde4d63401590d221bbd252e9d6c559962d2757929570f649f40c13f1a11
MATLAB
1,314
69
function fiff_write_int_matrix(fid,kind,mat) % % fiff_write_int_matrix(fid,kind,mat) % % Writes a integer matrix tag % % fid An open fif file descriptor % kind The tag kind % mat The data matrix % % % % Author : Matti Hamalainen, MGH Martinos Center % License : BSD 3-claus...