sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
18a81777f16930f357c363bede12df8f0b25aa65cb5754a3fb932d90329226bb
MATLAB
1,024
35
function [pval, RealCorrDiff] = permtest_correlation(x, y1, y2, tail, nrand) % test if two correlations are different if ~exist('nrand', 'var'), nrand = 10000; end if ~exist('tail', 'var'), tail = 0; end % the real correlations of both y1 and y2 RealCorrDiff = corr(x, y1, 'type', 'Pearson', 'rows', 'pairwise') ... ...
44d5859ef17587bb7ccdd4088dde9f8e17bfeb4f0f4a987ea893eccc06cf17f0
MATLAB
1,024
37
% affirms a spike to be something % and adds it to NNdata function affirmSpike(self, channel, spike_position, spike_name) arguments self (1,1) crabsort channel (1,1) double spike_position (1,1) double spike_name char end if self.verbosity > 9 disp(mfilename) end if isempty(self.common.NNdata(channel).spiket...
5c1b7692a13e2feea7639844cc584fe2b81424bf69871bc285cd6ea3316e2e8d
MATLAB
1,024
44
function M = sampleDiscrete(prob, r, c) % Like the built in 'rand', except we draw from a non-uniform discrete distrib % M = sample_discrete(prob, r, c) % % Example: sample_discrete([0.8 0.2], 1, 10) generates a row vector of 10 random integers from {1,2}, % where the prob. of being 1 is 0.8 and the prob of being 2 is ...
994c0cc06db48a8a6bf5e89f9a0a96cfbb60ae47fc48f4f91eff56e98413a3bb
MATLAB
1,024
37
function varargout = structvals(S, varargin) % Extract the values of a structure into an output argument list % specify a cell array listing the fieldnames in the order you want them % returned. The number of output arguments must equal the number of names % in order. % % Example % % model.mu = zeros(1, 5) % model.Sig...
2a342dfda8b7bc1f57b4ee6101a249d84546e9e7659e2390771a7284f050ddd0
MATLAB
1,025
29
function s = accumulate_prob(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'); ...
707ae23801d19de65e9096d685694c27ea680afd0d13fff76473f4adfc44da54
MATLAB
1,025
36
function result = tidy_struct_from_yaml(x) % Recurses through a scalar struct that came of yaml, and tries to make it % nicer. Currently, replaces cell arrays that cleanly convert to numeric % arrays with cell2mat() with the cell2mat() output. if isstruct(x) if ~isscalar(x) , error('All struct elemen...
c7fa4381da9551cb7aaefe6ba92e85166e9580d7cbc5d43b91f7051ad59479d2
MATLAB
1,025
64
function wave = wlProc_calcCosineWindow(s2, s3, s4) % function wave = wlProc_calcCosineWindow(s2, s3, s4) % % This function generates a cosine roll-off window with the two roll-off % lengths independent of each other. % % This returns a [1xN] array of samples in the range 0..1. % % wave(1) is 0. % wave(s2) is the firs...
42f03a4a934a0170eddb9c3d393202595b73dab925660038103c7108ea9c71f0
MATLAB
1,026
65
%%% Program that launchs the complete for N_ima_active = 1:30, error_analysis; end; return; f = []; f_std = []; c = []; c_std = []; k = []; k_std = []; NN = 30; for rr = 1:NN, load(['Calib_Accuracies_' num2str(rr)]); [m1,s1] = mean_std_robust(fc_list(1,:)); [m2,s2] = mean_std_robu...
e8e60bd0878bf1c30efcb744fc881efd576cf61d0ef96a30f75f466dc176e7cc
MATLAB
1,026
32
function [P,Uinit] = parafac_als(X,R,opts) %PARAFAC_ALS Deprecated. Use CP_ALS instead. % % See also CP_ALS. % %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) Sand...
593d4bc3a97a2caa234ea8c15b09945171fb9d1e4527262e26ca656700507a25
MATLAB
1,027
52
addpath c:\nolte\matlab\toolbox addpath c:\nolte\matlab\toolbox_stefan clab=importdata('names.txt'); clab=clab'; pat1=importdata('pat1.txt'); pat2=importdata('pat2.txt'); sa=prepare_sourceanalysis(clab,'montreal'); V=reshape(detrend(reshape(sa.V_fine,19,[]),'constant'),19,17177,3); %figure; pat=pat1; [nchan npat]=siz...
42767408858d76f25069a81ed2e9a7d84a1d1977b2dd1cfba7652c6b43620030
MATLAB
1,028
27
% alignLandmarks(pts,mux,muy,theta) % pts is 2 x n x T, where n is the number of landmarks % mux is 1 x T, x-coord of centroid of the fly from Ctrax % muy is 1 x T, x-coord of centroid of the fly from Ctrax % theta is 1 x T, orientation of the fly from Ctrax function pts = alignLandmarks(pts,mux,muy,theta) % pts [2,n,...
afa939d97d7d46645d5b7a526b2cea994bfd2922c203fdae7b2f66f4eda805bd
MATLAB
1,028
35
%% Compare kernalized L1 logistic regession to an svm. % %% % This file is from pmtk3.googlecode.com if ~svmInstalled fprintf('cannot run %s without svmFit; skipping\n', mfilename()); return; end loadData('crabs'); %% SVM gammas = logspace(-2, 2, 30); Cvals = logspace(-1, 3.5, 30); SVMmodel = svmFit(Xtrain,...
cb1b40888193dc395805a816ddea0660d66f67b2fd18f5d2eeb3ec01ce92567c
MATLAB
1,028
33
function y = afxFilter(rt,filter,x) % y = afxFilter(rt,filter,x) % 4th order butterworth bandpass filter if ~isempty(filter) f = 1/rt; [b,a] = butter(2,2*filter/f); y = filtfilt(b, a, x); else disp('Note: Time series filtering has been skipped ...'); y = ...
0b5db3fa626736712d938386030172acf5724fae221ff2bd78479670faa974b6
MATLAB
1,029
39
function verb=savprint(handle,savName,verbose) % function savprint(handle,savName,verbose) % % % Tomoyasu Horikawa horikawa-t@atr.jp 2010/10/26 % setdir(fileparts(savName)); set(handle, 'PaperType', 'A4'); set(handle,'PaperOrientation','landscape'); set(handle,'PaperUnits','normalized'); set(handle,'PaperPosition'...
4e01014bee0e6e267c20ec0c146bb76383373687e2d78b6d8f05b8e63f6ffdc2
MATLAB
1,029
35
function data = leaveoneout(data) dimtok = tokenize(data.dimord, '_'); rptdim = find(strcmp('rpt', dimtok)); % the selected dimension as number if length(rptdim)<1 ft_error('the ''rpt'' dimension is not present in the data'); elseif length(rptdim)>1 ft_error('cannot jackknife over multiple dimensions at the same ...
67a6dfed70b6b8f69ce7f22320ce01a6137f2c54bc16a129addec2c464d3d958
MATLAB
1,029
52
%LOADINR Load an INRIMAGE format file % % LOADINR(filename, im) % % Load an INRIA image format file and return it as a matrix % % SEE ALSO: saveinr % % Copyright (c) Peter Corke, 1999 Machine Vision Toolbox for Matlab % Peter Corke 1996 function im = loadinr(fname, im) fid = fopen(fname, 'r'); s = fgets(fid); ...
ce0acae8e98d41df4c644b3ec767e749cccdbffc2c8eff0c7decf36926186052
MATLAB
1,029
37
function smallT = margTable(bigT, bigdom, bigsz, onto, maximize) % Marginalize a table % This file is from pmtk3.googlecode.com if nargin < 5, maximize = 0; end smallT = reshapePMTK(bigT, bigsz); % make sure it is a multi-dim array sum_over = setdiffPMTK(bigdom, onto); ndx = lookupIndices(sum_over, bigdom); ...
d4bc9e8373fda22c42451efe4b5c9f2106fb562bf847cfebf1676eab2ab4b096
MATLAB
1,029
32
function [M] = hullModel(M) %HULLMODEL Smooth a brain model by computing its convex hull. % % The convex hull of a data set in n-dimensional space is defined as the % smallest convex region that contains the data set. For example, the convex % hull of a brain model results in a hull containing the whole bra...
1a03a620613f6e401e51cc07cde250a4417b4bcc5e60ad58511e79096e1ecba6
MATLAB
1,030
32
tic; clear all; param_currents; param_neuron; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % INITIALIZATION FOR VOLTAGE CLAMP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% nfV = 100; t_array = [1000; 3500; 6000; 7000]; Nta = length(t_array); time_maxV = ...
321c3ff41ba39f5335a8cfa8c8218f93941fe238503676734e4372c12c9cb917
MATLAB
1,030
37
function [data, XYZvoxSphere, XYZmmSphere] = iimg_sphere_timeseries(images, XYZmmCenter, radius) % :Usage: % :: % % function [data, XYZvoxSphere, XYZmmSphere] = iimg_sphere_timeseries(images, XYZmm, radius) % % :Inputs: % % **images:** % list of image files % % **XYZmm:** % [3 x n] array of mm coo...
269ee5f64bce677597992187009bce7a00c35ac8593d6b09f6f84274c8b7b872
MATLAB
1,031
27
function [F, J] = calcGaussianActivationAmplitude(gparams, spftheta) %UNTITLED6 Summary of this function goes here % Detailed explanation goes here %========================================================================== spff = spftheta(:, 1); %standardize input thori = spftheta(:, 2); %standardize input sigm...
c35c1bfc00e0daf18c99ef2520bb37289c032a87662854ce9d80ae0e579c0ecb
MATLAB
1,031
30
function out=is_octave () %% Determine if we are currently using GNU Octave %% E. Chassande-Mottin %% Copyright (c) 2007 %% %% 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 Softwar...
99e1241beb653e7648acd4c90d03302353fd9b02ff7c5e3b8f7851fb910522fa
MATLAB
1,032
46
% assignSignal % Assign signal from sigSL and sigRL clear sl rl ylims switch dim case 'TinC' sl = sigSLv.TinC*1000; ylims = [0 30]; if sub0 == 1 ylims = [0 20]; end case 'TinI' sl = sigSLv.TinI*1000; ylims = [0 20]; case 'WhenD' ...
388a6235b5b68ca80263277ccf8b46abf08e13ba4bb5859b99d6b7e3bc3d395f
MATLAB
1,033
30
function [Y, XYZ] = iimg_read_vols(V, mask) % Drop-in replacement for spm_read_vols % Primary difference is that if the images have the same voxel size but are NOT resliced % (e.g., have differing affine matrices), this will handle reading each individually and % putting them together. if nargin<2, mask = 0; end ...
39940602ec6ea77885ae410e2393d98eb887f0200542bd849264831d0fb71f17
MATLAB
1,033
41
function plotConvDiagnostics(X, ttl, filename, maxAcf) % Plot trace plot, smoothed trace plot, and ACF of 1d quantity % X(samples, chain/seed) if nargin < 3, filename = []; end if nargin < 4, maxAcf = 20; end % This file is from pmtk3.googlecode.com if nargin < 2, ttl = ''; end nseeds = size(X,2); colors = {'r', 'g...
5830cca6c5ed034dfc81340dcca592220f0c6b478ef4d81fef23c32f5ec48143
MATLAB
1,033
48
function [d,dt]=formatts(d) % % Usage: [d,dt]=formatts(d) % % Helper function for CWT,XWT,WTC % % Brings a timeseries into a shape so that it has two columns: [time, value]. % % % (C) Aslak Grinsted 2002-2004 % % ------------------------------------------------------------------------- % Copyright (C) 2002-2004, A...
61c88715ba9f531ea58544eacb53a5e78cf66a8896504c15fbd2efe3fbaee6f7
MATLAB
1,033
40
function [xn] = normalize_pixel_fisheye(x_kk,fc,cc,kc,alpha_c) %normalize % %[xn] = normalize_pixel(x_kk,fc,cc,kc,alpha_c) % %Computes the normalized coordinates xn given the pixel coordinates x_kk %and the intrinsic camera parameters fc, cc and kc. % %INPUT: x_kk: Feature locations on the images % fc: Camera fo...
7dba117f5e2fe9335ac274bf0ffe6bc466a9b6dffd74380db2b1d3f9c7328989
MATLAB
1,033
16
% Utilities for coloring with MATLAB by Carlos Vargas. % % COLORMAP utilites: % cmapping - Colormap linear mapping/interpolation. v1.1 (Sep 02, 2009) % cmfit - Sets the COLORMAP and CAXIS to specific color bands. v1.0 (Jun 08, 2009) % cmjoin - Joins colormaps at cer...
d29e7d12436975e37f1cb5d1d785a4671c9d2e78fff346f95fa1caa3f7d8adb5
MATLAB
1,033
46
% Plot stimulus-locked mean traces for all coherences - considering nans in % each trial % meanTracesSL_bigSbigT filter = ones(size(sigSL.sig_coh))==1; % filter = sigSL.sig_coh == 0; conditions = rt_quant; colores = NS_colorsBY(length(nanunique(conditions))); clear Son dt = sigSL.t(2)-sigSL.t(1); min_num...
d85daa50ccdd61ae84cdf9a386fb82b0cff1bd3d77a00bffa36ab67bedccc3f4
MATLAB
1,033
45
%% Compare Student and Gaussian pdfs % %% % This file is from pmtk3.googlecode.com for useLog = [false true] dofs = [0.1 1 5]; xs = linspace(-4, 4, 40); figure; [styles, colors, symbols, styleStr] = plotColors; N = length(dofs); for i=1:N dof = dofs(i); %ps = tpdf(xs, dof); model.mu = 0; model.Sigma ...
13f02aa81bc628aefa43b04806159af9a39961778518533c7520a89da42db57d
MATLAB
1,034
32
% readframe = ufmf_get_readframe_fcn(header) % % Returns the handle to a function which inputs the frame number and % outputs the corresponding frame for a UFMF file described by the input % 'header'. % % Note that this 'header' is modified by ufmf_read_frame and that header % seems to be stored in the function...
1c3c3aeb6524d661d2c70bf47121276e6eee0cc4754043518ca09490d7fe73ff
MATLAB
1,034
1
% TSSETTRIALTYPE Set the currently active trial type % TSSETTRIALTYPE(TRIALNAME) sets TRIALNAME as the active trial type, the % trial type used for computing statistics. Not to be confused with % TSlimit('Trials'), which limits which trials within a trial type are % subject to analysis. If you want no active t...
871c52ec7e90893a6f8fc05eec2209e745ec69da6e3f9c2c98c841a95a858228
MATLAB
1,035
71
function [basic, supervised, latent, graphical] = classNameMappings() %% This file stores the mapping from classname to group name. % It needs to be manually updated when new models are created. % This file is from pmtk3.googlecode.com basic = { 'beta' 'betaBinom' 'binomial' 'chi2' 'diric...
87a07d511d7930348200930d619b4054340bac7037a3537dd3f88009e639f8f2
MATLAB
1,035
40
% meg_runAlpha %% input expt = 'TA2'; % 'TANoise' 'TA2' sessionNames = meg_sessions(expt); user = 'karen'; saveFigs = 1; saveAnalysis = 1; %% for i = 1:numel(sessionNames) sessionDir = sessionNames{i}; % 'R0817_20181120'; %% setup % directories exptDir = meg_pathToTAMEG(expt, user); dataDir = s...
99527c0f830aa6efd7db0c5e132c3b2bc81205439490b16a60ba1595218bf412
MATLAB
1,035
30
function [yhat, p] = logregPredict(model, X) % Predict response for logistic regression % p(i, c) = p(y=c | X(i,:), model) % yhat(i) = max_c p(i, c) % For binary, this is {0,1} or {-1,1} or {1,2}, same as training % For multiclass, this is {1,..,C}, or same as training % % Any preprocessing done at training time ...
b080996234e01e7e40476bcfa14348252f7b73543201837e6c823d7ccca587a5
MATLAB
1,035
27
function generate_funct_images_FIR(stat_path,sim_path,exp_folder,SF,SNR,N,N_ROIs,dummy) % ======================================================================== % Ruslan Masharipov, October, 2023 % email: ruslan.s.masharipov@gmail.com % ======================================================================== tic fo...
b35c14eb5d4960e2d1af760459f666f935a35eb2bfeb74310b36b68fdb63175b
MATLAB
1,035
40
function dat = LoadSingleChannel(trodeFile, chan, varargin) timeRange = [0 Inf]; for i = 1 : 2 : length(varargin) switch lower(varargin{i}) case 'timerange' timeRange = varargin{i+1}; otherwise 'Invalid optional argument passed to LoadSingleChannel' end end hsdHeader = g...
dad5426115ed611852e901872a7d2071fb92bdfa37d7050b748137328ffe0b6c
MATLAB
1,035
33
function display_feature_TvsT_mean(var1,newfig,rev_color) color_test1 = cbrewer('seq','YlGnBu',100); % colormap for corr color_test2 = color_test1(end:-1:1,:); for mouse = 1:size(var1,2) if newfig figure; end h = imagesc(var1{mouse}); if newfig title(['Mouse ' num2str(mo...
fe438c855a9ea960ece3bcdc73ff12238ea52d5e7213e4ff18403e39e6deb20d
MATLAB
1,035
39
function [path fnprefix num_flag ext startn endn] = GetFilenameNumbering(filename) % Return the file path, its name without ending numberings and its % extension: % [path fn num_flag ext] % num_flag is the smallest number that the fnprefix is prefixed to. [path fname ext]=fileparts(filename); idx = regexpi([fname ext]...
19100745b5e5921c2f3af56d3cfbaca3f151c2be31e2ea1d2363398aa01b05f2
MATLAB
1,036
38
% - figure dth = 0; % Extract response data for excitatory (z1) and inhibitory (z2) neurons z1 = dr_all(1:NE, :); z1 = reshape(z1, 1, []); z2 = dr_all(1+NE:end, :); z2 = reshape(z2, 1, []); figure('Position',[100,100,250,450]) subplot(211); title('exc'); hold on % Plot the histogram bars for positive and negative...
25a4e10546927ffec60eeefa6486b354cedc7afedec0197fc51abd42232f0fa4
MATLAB
1,036
38
function [ f, J, H] = rlogistic2gpu( params, x ) %LOGISTICFUN evaluates modified logistic with params at x % Detailed explanation goes here %========================================================================== %define inputs x = x(:); gamma = params(1); beta = params(2); %=================================...
39ec8b63f19bd3c03b396aa193f2022b61052adba2fcc852864a4a6a5d4ab643
MATLAB
1,036
37
function C = plus(A,B) %PLUS Binary addition for ktensor. % % C = PLUS(A,B) adds two ktensors of the same size, and the % result is a ktensor of the same size. % % See also KTENSOR. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and other...
64e6445edc0ce652c76aef839c51efe05411b700552532d2e5922949417a6bea
MATLAB
1,036
33
%https://github.com/QuantEcon/QuantEcon.jl/blob/master/test/test_kalman.jl A = [.5 .4; .3 .2]; Q = [.34 .17; .17 .17]; G = [.5 .4]; R = [.05^2]; y = [1. 2. 3. 4.]; cov_init = [0.722222222222222 0.386904761904762; 0.386904761904762 0.293154761904762]; %{ %k = Kalman(A, G, Q, R); set_s...
75cda8ae90cf7f3d4b3a39d23c1a66b75b781da0ea965062dcc437fedea48187
MATLAB
1,036
29
function H=kaytth(length); %KAYTTH Kay-Tretter filter computation. % H=KAYTTH(length); Kay-Tretter filter computation. % % See also INSTFREQ % F. Auger, March 1994. % Copyright (c) 1996 by CNRS (France). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU Gener...
d13338d653d737b86234e402c7eb490af5576ef91a7080686c99a4092fb866eb
MATLAB
1,036
32
% SPPUSH3 Append to 3-array sparse matrix representation. % % [I,J,V,NZ] = SPPUSH3(I,J,V,NZ,IA,JA,VA) overwrites I(NZ+(1:N)) = IA, % J(NZ+(1:N)) = JA, and V(NZ+(1:N)) = VA, where % N = LENGTH(IA) = LENGTH(JA) = LENGTH(VA), and replaces NZ := NZ + N, % appropriately reallocating and expanding the capacities of ...
fa1014b44450a5c27b2b13d0d519e2cce1dec588a3361739c1b5fac22b060246
MATLAB
1,036
46
function spirallin_data_generate(nc,sampnum) ns = sampnum/nc; X = []; y = []; for i = 1:nc %ic: class index r = linspace(0.02,1,ns); t = linspace(i*2*pi/(nc), (i+nc-1)*2*pi/nc, ns) + 0.1*randn(1,ns); X = [X ; [(r.*sin(t))' (r.*cos(t))']]; y = [y;(i)*ones(ns,1)]; end X = 255*(X+1)/2; y...
9bf4ec872787309dc8c28c5b6c7bad5e6a1e8c26ed7278e42dee7746099222a2
MATLAB
1,037
36
function [fx,dF_dX,dF_dTheta] = f_doubleWell(Xt,Theta,ut,inF) % damped double Well Lyapunov evolution function % function [f,J] = f_doubleWell(t,x,theta) % % This function computes the evolution function that comes from a . % IN: % - t: time index (not used here) % - x: the current state of the system % - theta: ...
b12b3b4e3afc8e15d800352389970d1a6945a2a9f4618bda1ffbe24100406f55
MATLAB
1,037
30
data_folder = 'Y:\laura_berkowitz\alz_stim\data\crimp'; folders = dir(data_folder); folders = folders(~ismember({folders.name},{'.','..'}),:); folders = folders(~ismember({folders.name},{'session_check.csv','._session_check.csv'}),:); % loop through folders and process those that don't have evidence of % processing (...
27351aec4bd71bb71ed914c615ac60ded9adeb08df068db99fcc1982d9551910
MATLAB
1,038
35
function A = tt_cp_vec_to_fac(x,Z) %TT_CP_VEC_TO_FAC Converts a vector to a cell array of factor matrices. % % A = TT_CP_VEC_TO_FAC(X,Z) converts the vector X into a cell array % of factor matrices consistent with the size of the tensor Z. % % See also TT_FAC_TO_VEC, TT_CP_FUN, TT_CP_OPT. % %MATLAB Tensor Toolbox...
a1b557e9c2f6dacf21059ad46c472eb677ff88ceb0a5b682537e577cb4df4aea
MATLAB
1,038
38
% Vie the Action-Selector you can search available module functions in Dataspace. % % DSPACE-HELP-IMAGE<ActionSelector_img1_v2.png> % % Enter a string in the search fields and all actions whose name contains % the string are provided as options. Click on an option to select it. % ...
ad228fe39a35c3d999c4bbb8a0a6eb7c5769bda7d8b200ffeb36658923438a0d
MATLAB
1,038
34
function order = IDX2order( IDX ) % Converts class labels into an ordering. % % Creates an ordering order such that IDX(order)=[1 1...1 2...2 ... k...k]. % All points within a class retain the ordering in which they originally % appeared. Also, Xb = X(order,:) has cluster labels IDX(order), ie % adjacent elements in X...
5d3b6bfb8b66e436d53cba7fa6b8812bb0c1a3d6cfc04233b4050dc5705cdab9
MATLAB
1,039
38
function mnistSplit() %Put each digit into its own file % train_images: [28x28x60000 uint8] % test_images: [28x28x10000 uint8] % train_labels: [60000x1 uint8] % test_labels: [10000x1 uint8] load('mnistALL.mat'); for c=1:10 y = c; if y==10, y=0; end ndx = find(mnist.train_labels==y); Ntrain(c) = length(ndx) ...
af3d2d103aa9284b979d2bced54bd709f0dd8544f42fc684fa0d702192d9476b
MATLAB
1,039
47
% this script demonstrates how to derive and display Monte-Carlo esimates % of the (prior) predictive density over hidden states of dynamical % systems. clear variables close all % Choose basic settings for simulations n_t = 5e2; deltat = 2e-2; alpha = 1e0/deltat; sigma = 1e-1; theta = [28;10;8/3]; f_fname = @f...
bcd40843dd7c4be11a4cd8fd7654866b88a06757639eabc181e35288ace66244
MATLAB
1,039
40
%% Tikhonov regularization for a piecewise smooth function % Based on code by Uri Ascher %% % This file is from pmtk3.googlecode.com function tikhonovDemo() setSeed(0); lambdas = [0.1 2 10]; for j = 1:numel(lambdas); lambda = lambdas(j); %% Generate data N = 50; noise = 0.5; x = ((1:N)-0.5)./N; ...
c2bbabb3941cbded1730308e65d2a1400f3386d03f5d3d04f1fb9478423b6a69
MATLAB
1,039
37
function [X, y] = processColonData() %% Parse I2000.html, and tissues.html for X and y % See http://genomics-pubs.princeton.edu/oncology/affydata/index.html % for a description of the data. % % There are 62 x 2000-dimensional examples % y = -1 indicates malignant tissue % y = +1 indicates normal tissue % D = ...
89f463644704ad78d4a5f8285b0a08609a8250c62d81259f95b422d759a9d562
MATLAB
1,040
24
function varargout = maxprojmask(a, b, c, d) % returns masks for a, b, c, d (or however many inputs u give) % where mask(a) = 1 where a > b,c,d; 0 else % usage: [am, bm, cm] = maxprojmask(a, b, c) varargout = cell(1,nargin); if nargin ==2 max_ = max(a, b); % Q: threshold needed?!?! % level = m...
92db2f23d4eb1f9e84548dd9dfb240b7780d32d77110a4c727c9a168688b6c72
MATLAB
1,040
27
function [subs,vals] = find(t) %FIND Find subscripts of nonzero elements in a sparse tensor. % % [SUBS,VALS] = FIND(T) returns the subscripts and corresponding % values of the nonzero elements of T. % % Note that unlike the standard MATLAB find function for an array, % find does not return linear indices. Inste...
9bf4ce269bfd8789e2cf9c0b962dea9826d7a2e60a7937547aa0f69fd712048a
MATLAB
1,040
28
%% created by Antoine Wystrach function [KC_AP, KC_EPSP] = use_MB (PN_input, MB, nb_KC_firing) %in PN_input, glomerulus is vertical, time is horizontal %work with a single input too (vertical PN vector) if size(PN_input,1) == size(MB,1) %necessary requirement, nb of PNs input must match nb of PNs in MB KC_A...
d72c3cfd000bbc2e9abebe619b712bc431c8245de70678c38713cdc65d1c75ad
MATLAB
1,040
26
function [Fout, J] = calcDoGActivationsGrating(params, xvals) %UNTITLED Summary of this function goes here % Detailed explanation goes here %========================================================================== spfreq = xvals(:, 1); ori = xvals(:, 2); surrwt = params.surrwt; %============================...
edf9035e2629601feec9f0ced3a631ca31bf2545edfa7283000546743410eb02
MATLAB
1,040
50
function clip=w_ClipLevel(varargin) %varargin{1}=mfac; %varargin{2}=dataset; %Acquire 4D Matrix mfrac=varargin{1}; if ischar(varargin{2}) [Volume4D, VoxelSize, Header]=y_ReadRPI(varargin{2}); MeanAbsVolume=mean(abs(Volume4D) , 4); else MeanAbsVolume=varargin{2}; end MeanAbsVolume=reshape(MeanAbsV...
25478321df70a31086832c2d928d55a4b49aeeaef46b2ea54c68054515c84f7c
MATLAB
1,041
29
function q = dblquadvec(f, varargin) % Calls dblquadvec but assumes you can't vectorize your input function % DBLQUADVEC has the same calling syntax as DBLQUAD but doesn't require that % the integrand be vectorized. % % Q = DBLQUADVEC(FUN,A,B) tries to approximate the integral of scalar-valued % function FUN fr...
3eb06a742f4a784cbe9ad0e9700729d4d7724f2d740383dab3517f2d00877faa
MATLAB
1,041
38
function output = base64decode(input) %BASE64DECODE Decode Base64 string to a byte array. % % output = base64decode(input) % % The function takes a Base64 string INPUT and returns a uint8 array % OUTPUT. JAVA must be running to use this function. The result is always % given as a 1-by-N array, and doesn't retrieve t...
59dbe99160941707295812e112da45839f64e94b1c0f2de4198db1c04b37eaa7
MATLAB
1,041
44
% Author: Birgit Nierula (Feb, 2020) % nierula@cbs.mpg.de %% cfg definition % this file defines important analysis parameters. % sampling rate srate_ica = 250; srate_rpeak = 5000; % interpolation window - just for R-peak detection!! interpol_window_rpeak = [-1.5 1.5]; % eeg interpolation window interpol_window = [-...
654be92c8b881d78a32ef458d9a2036483ededc7d2e05cc8f8aaccf06f9af0e1
MATLAB
1,041
35
%_______________________________________________________________________ % % targets = setNumTargets(numTargets) %_______________________________________________________________________ % % creates the targets structure %_______________________________________________________________________ % % By default, the number ...
6b953299579d27dff4c17ee89b627401186792457237c2cf9b3e80fdf3db18b7
MATLAB
1,041
32
function samples = crf2Sample(model, Xnode, Xedge, Nsamples) % Sample from a CRF % samples = crf2Samples(model, Xn, Xe, Nsamples) % Input should be a single datacase: % Xn is NnodeFeatures*Nnodes % Xe is NedgeFeatures*Nedges % samples is Nsamples*Nnodes % % This file is from pmtk3.googlecode.com if isempty(model.samp...
7bd532b6bc109851ee2fe70b0f95974b7dbd9090ffa8e67bf0fa90d8c1511b6c
MATLAB
1,041
41
%% Simple inference test in the alarm network % This file is from pmtk3.googlecode.com nnodes = 37; dgmJ = mkAlarmDgm('jtree'); dgmV = mkAlarmDgm('varelim'); J = dgmInferNodes(dgmJ); V = dgmInferNodes(dgmV); if libdaiInstalled dgmL = mkAlarmDgm('libdaiJtree'); L = dgmInferNodes(dgmL); assert(tfequal(J, ...
f6184472cdcceb1f4a7670cc04aedc329a6369396d5f7819f3304876e01e02a2
MATLAB
1,041
30
% Matlab version of the CTF command line program changeHeadPos. Changes % the dataset .hc and .res4 files such that the initial head coil positions % is the one provided. This does not change the data, only the sensor % coordinates and orientations and the coil coordinates. Backups of the % modified files are create...
5076f64485f291cc800d5cc866806e31265f998a3b01c39d73325a748140fa20
MATLAB
1,042
30
function [data_crop,data_outofcrop] = loc_list_roi(data) try coordinates = getline(); data_crop = cell(1,length(data)); data_outofcrop = cell(1,length(data)); for i = 1:length(data) [data_crop{i},data_outofcrop{i}] = loc_list_crop_inside(data{i},coordinates); end data_crop = data...
85951cab596f7b5b67ea02fb4b61432088de26be26427613d84739938fe259e5
MATLAB
1,042
31
function [pos, tri] = icosahedron42() % ICOSAHEDRON42 creates a 1-fold refined icosahedron with the vertices on a unit % sphere % % Use as % [pos, tri] = icosahedron42; % % See also ICOSAHEDRON % Copyright (C) 2003, Robert Oostenveld % % This file is part of FieldTrip, see http://www.fieldtriptoolbox.org % for the ...
8ccbfe931c5f997643c2f826b15544e1b7f487c4e206364d1d6ca98f90bceef9
MATLAB
1,042
40
%% Find the MLE tree from a word-document binary matrix % This file is from pmtk3.googlecode.com loadData('20news_w100'); % documents, wordlist, newsgroups %X is 16,642 documents by 100 words (sparse logical matrix) X = documents'; disp('mlapa chowliu demo') %setSeed(0); %X = randn(100,5)>0; model = treegmFit(X);...
af1db7a816cbce987d5c6d66f806456767be9706fba4691426037627de335c23
MATLAB
1,042
32
function q = CBIG_MFMem_rfMRI_matrixQ(i,n,T) %------------------------------------------------------------------------ % q = CBIG_MFMem_rfMRI_matrixQ(i,n,T) % % function for generation specitial diagnal matrix used in estimation % % Input: % - i is the index to selected i-th trail % - n is total availble ...
c62a33e3cd2553497ef6be6ac4f53c2c0745cc38a8350e3de8fd6007830a78c9
MATLAB
1,042
23
function [fr, sd, count]= HumanOdorRep_firing_rate(trial, from, to) %% function [fr sd count] = HumanOdorRep_firing_rate(trial, from, to) % compute the mean (sd: standard deviation) firing rate (fr) in Hz for a cell array with spike-times % trial{1} = [-241 -290 390 ...], trial{2} = [-241 111 129...] % from and to are...
590b6f41a89279ed778fc7743b94ad6c907071c56e9d5df0de673083cc7c20fb
MATLAB
1,043
53
function [x] = project2_oulu(X,R,T,f,t,k) %PROJECT Subsidiary to calib % (c) Pietro Perona -- March 24, 1994 % California Institute of Technology % Pasadena, CA % % Renamed because project exists in matlab 5.2!!! % Now uses the more elaborate intrinsic model from Ou...
a6ba8c1e582787d8dc0b1115c65af3d700114fb5e05cde067bbea52060412c50
MATLAB
1,043
37
function [vec, precomp_grads] = KeySampleVec(key, pix, sift_params, precomp_grads) % DG's Addition: Method 1 with rotational invariance added in: [index precomp_grads] = KeySample(key, pix, sift_params, precomp_grads); %Add up each of the IndexSize x IndexSize x IndexSize bins into the %corresponding tesselatio...
df552bfcb5474893130607764471c771811ac0d419b6d3d7f1105b3c3bb445dc
MATLAB
1,043
29
function [b, se, t_stat, p_val] = lm_lean(X,Y) %%% Fit a linear model and calculate standard error, t statistic as %%% well as p values; faster than fitlm %%% intercept has to be manually included in X %%% formula assembled from Learning Statistics with R, page 468 %%% Inputs % X: de...
2336f2b372c7ddc068e6b0641fba7bc3b3dd04f325fa8bade30014d8852a2fb4
MATLAB
1,044
48
function map = redblue(N, dark) %REDBLUE Red and blue colormap going from blue to white to red. % Usage: % map = redblue(N) % % Args: % N: number of samples in the colormap (default: 64) % % Returns: % map: N x 3 matrix of RGB colors % % Example: % imagesc(repmat(linspace(-1,1,200),100,1)),colorbar,colormap re...
78e4af1b7f19c80f93c577eb45eb80faf112871a417b25e2263b94b075632a4c
MATLAB
1,044
44
function [dt, timer_id] = stocf(timer_id, str, varargin) %STOCF Report elapsed time with print formatting. % Usage: % stocf(str, ...) % stocf(timer_id, str, ...) % [dt, timer_id] = stocf(_) % % See also: stic, stoc % Get elapsed time if ischar(timer_id) if nargin > 1; varargin = [{str} varargin]; end % N...
a60ce6dfdc77c810d2e68b128f298f1c425122929bdc9a24269d75622f4871ba
MATLAB
1,044
28
function h_loadSelectedROISettings3(handles) % load the selected annotation ROI color and z settings when it was % created. selectedROIObj = findobj(handles.imageAxes, 'tag', 'annotationROI3', 'Selected', 'on'); if length(selectedROIObj) == 1 UData = get(selectedROIObj,'UserData'); settings = UData....
a669c320ca29dac3c201ef5ff60755f4824c7be703308b0f64f11875bd84d406
MATLAB
1,045
47
function caller = get_caller_name(varargin) %GET_CALLER_NAME Returns the name of the caller function. % Usage: % caller = get_caller_name() % caller = get_caller_name('Path', true) % caller = get_caller_name(..., 'Warn', true) % warning if called from workspace % % See also: mfilename, funpath, dbstack % Parse i...
a94ea18234416fec6c7738cdb8cd03a95b9428cc063cd5ac6077c78dcea04726
MATLAB
1,045
35
%% Compare EM to matlab stats toolbox % PMTKneedsStatsToolbox mle %% % This file is from pmtk3.googlecode.com requireStatsToolbox %% same data as gaussVsStudentOutlierDemo n = 30; setSeed(8); data = randn(n,1); outliers = [8 ; 8.75 ; 9.5]; X = [data; outliers]; MLEs = mle(X,'distribution','tlocationscale'); mu1d = ML...
aff02cdd9b547fe884eba1c6b668930e22914e697f0dd74e3d7625dd269c1e9a
MATLAB
1,045
35
% demo: VBA inversion of generative models with unnormalized likelihoods. % This demo considers a dummy scenario, whereby a Gaussian log-likelihood % is specified as if it was arbitrary, i.e. in terms of a quadratic error % function. We can then compare the VBA_UNL inversion of this model and its % normalized variant, ...
b03a70ac6b727f21781f01eae0e14da830d3ee8564440c0a7cd3381032e6f101
MATLAB
1,045
31
function [pos, tri] = icosahedron162() % ICOSAHEDRON162 creates a 2-fold refined icosahedron with the vertices on a unit % sphere % % Use as % [pos, tri] = icosahedron162; % % See also ICOSAHEDRON % Copyright (C) 2003, Robert Oostenveld % % This file is part of FieldTrip, see http://www.fieldtriptoolbox.org % for t...
b76927d3066c8d6d19b9f0d568c5ff1ad03347e0d29e7217cb2485ca63c3a0df
MATLAB
1,045
47
%% quads % % Trapezoidal rule quadrature (numerical integration) % % <matlab:open('quads.m') code> % %% Syntax % % q = quads(x,Y) % %% Arguments % % _input_ % % x vector of evaluation points % Y matrix of values corresponding to x % % _output_ % % q vector of quadratures % %% ...
02fb370f8c8a16a94d55233337be4516c30ad41f5c50a6b549a772923d743026
MATLAB
1,046
28
function registerModularToolWithManager(modular_tool,target_images) %registerModularToolWithManager registers a modular tool with the modular tool manager of a target image. % registerModularToolWithManager(MODULAR_TOOL,TARGET_IMAGES) registers % MODULAR_TOOL with the modular tool manager of each of the % TARGET_...
143298446911696e58fde4a328ac058ba60ab07cfdb2a4fbd1a2ae693d772379
MATLAB
1,046
32
function [pos, tri] = icosahedron642() % ICOSAHEDRON642 creates a 3-fold refined icosahedron with the vertices on a unit % sphere % % Use as % [pos, tri] = icosahedron642; % % See also ICOSAHEDRON % Copyright (C) 2003, Robert Oostenveld % % This file is part of FieldTrip, see http://www.fieldtriptoolbox.org % for t...
7f2f6b6c53cba221e775145a0277f425cb03a939c0d379deca7d035f167d78d4
MATLAB
1,046
28
function mappedX = mds(X, no_dims) %MDS Run MDS on the data to get a low-dimensional visualization % % mappedX = mds(X, no_dims) % % Run multidimensional scaling on the dataset X to get a two-dimensional % visualization. The low-dimensional representation is returned in mappedX. % It has dimensionality no_di...
ba3806484f2bdefd916557a40acce3bdadef26e5798329b336857265a8c86b02
MATLAB
1,046
46
function LAN = lan_cat(LAN) % % function in developing, usefull to merge resting state period, % or opauses recording % if LAN.trials == 1 warning('LAN data seen as a continuous recording, nothing to do') return end % "selected" field newselected{1} = LAN.selected{1}; newselected{1}(end)=0; % deja el u...
cfdf22440cd1e691e728b0826643516ca4eaa34e3495b85d6a98935943b44962
MATLAB
1,046
64
function visualizeAlarmNetwork() %% Uses drawNetwork to display the alarm network DGM % This file is from pmtk3.googlecode.com [G, names] = parseAlarmData(); N = camelCaseNames(); g = drawNetwork('-adjMat', G, '-nodeLabels', N, '-splitLabels', 1, '-layout', Treelayout); maximizeFigure; g.tightenAxes; g.growNodes; g.g...
4cd293733bd9e48ba2875b678d2b1558d078e3e40315d74fc3a21f5f8564abbc
MATLAB
1,047
28
function normalized_psd = calculate_normalized_power(psd_matrix) % calculate_normalized_power - Calculates the normalized power of multiple PSD curves % psd_matrix - A 2D matrix where each row represents a PSD curve of a signal % Initialize the output matrix normalized_psd = zeros(size(psd_matrix))...
4ec934c9cd4ccd1afd0551cb550aed49aedee7cbda42c58ffbe0f15b43f0743b
MATLAB
1,047
42
function wlPlot_plotWaveAndSpec(cfg, times, wave, figtitle, filelabel) % function wlPlot_plotWaveAndSpec(cfg, times, wave, figtitle, filelabel) % % This function plots a time-series waveform and a corresponding spectrogram. % % "cfg" contains figure configuration information (see "FIGCONFIG.txt"). % "times" is a [1xN]...
53d625052bcc3325dd73a8d8089cd8f4c885403f113356c034b542a94e311e89
MATLAB
1,047
38
function [fractal,original] = ft_fooof_matlab_v1(signal_data,param) %FT_FOOOF_MATLAB_V1 Summary of this function goes here % Detailed explanation goes here % signal_data should be 1 by time matrix srate = param.srate; slide_window_length_sec = param.slide_window_length_sec; window_overlap = param.window_overlap; freq...
a78d55dcc5499e25f95d81525283f44f7765b2538bdd167fc6d28d3d68ccb5cb
MATLAB
1,047
40
function LAN = mix_trials(LANa, LANb) if nargin == 1 if iscell(LANa) LAN = LANa{1}; for c = 2:length(LANa) LAN = mix_trials(LAN, LANa{c}); end end else if LANa.nbchan ~= LANb.nbchan disp('error: All trials should have the same number of channels') LAN = [...
aa2254a764973159169eac3e3f0ead730a62e1523172cec492ac0ad871c7357d
MATLAB
1,047
35
function s = ismatch(x, y) % ISMATCH returns true if x is a member of array y, regardless of the class % of x and y, if y is a string, or a cell-array of strings, it can contain % the wildcard '*' if isempty(x) || isempty(y) s = false; elseif ischar(x) && ischar(y) y = sprintf('%s%s%s', '^', regexptranslate('wild...
e2165437e5ff168e5929b4d517bf88c9a623ea5ad3d7305bc195e8d6233f8a3a
MATLAB
1,047
39
function output = zlibencode(input) %ZLIBENCODE Compress input bytes with ZLIB. % % output = zlibencode(input) % % The function takes a char, int8, or uint8 array INPUT and returns % compressed bytes OUTPUT as a uint8 array. Note that the compression % doesn't preserve input dimensions. JAVA must be enabled to use t...
4b55fadc00466c07df75f45651e83dbb2fbba3bd7075f95728e77f24bc6642c5
MATLAB
1,048
43
function U = tocell(X,N) %TOCELL Convert X to a cell array. % % TOCELL(X) converts X to a cell array, evenly distributing the % weight in lambda. % % TOCELL(X,N) absorbs the weights into the Nth factor matrix. % % See also KTENSOR, NORMALIZE. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % Thi...
580b7a17b3a6387dae4c0cef5a8aa07791bb426a671db6f28f8e81c6f93978b8
MATLAB
1,048
36
function outpoints = mni2tal(inpoints) % Converts coordinates from MNI brain to best guess % for equivalent Talairach coordinates % FORMAT outpoints = mni2tal(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 Talairach points...
6b00f00733238389aeafc312d4eeffe080d97d569830f5facd187f0f5c80dde5
MATLAB
1,048
29
function packages = scrapePmtkSupport(folder, exclude) %% Scrape pmtkSupport.googleCode.com to get the names of all the support packages there % This file is from pmtk3.googlecode.com if nargin < 1, folder= []; end if nargin < 2, exclude = strtrim(tokenize(getConfigValue('PMTKmetaDirs'), ',')'); end url = 'http://...
76e8babbf7be0f5750f3ffb19efe7229fb848a185031d65f9b0aca6833b28bf0
MATLAB
1,048
24
function [index precomp_grads] = AddSample(index, pix, distsq, r, c, s, i_indx, j_indx, s_indx, fv, sift_params, precomp_grads) % r, c, s is the pixel index (x, y, z dimensions respect.) in the image within the radius of the % keypoint before clamped % For each pixel, take a neighborhhod of xyradius and tiradius, ...
c3b87221a71c010825b971ded5088c61a6962b070e7ac447e8dce7737f05856a
MATLAB
1,048
45
function cl = iimg_indx2contiguousxyz(dat,volInfo,remove_mean_flag) % Take in index image data vector (in-mask values only) and a volume info structure with xyzlist % and return a cl structure whose XYZ values list contiguous sets of voxels % ("blobs") % % :Usage: % :: % % cl = iimg_indx2contiguousxyz(dat,volInfo,[...
d2d8b44ec3b2fc2f0cdcf491ff37bfd13e651e28c17883995b285dabf308db5a
MATLAB
1,048
50
rawdata = dlmread('heightWeightData.txt'); % comma delimited file data.Y = rawdata(:,1); % 1=male, 2=female data.X = [rawdata(:,2) rawdata(:,3)]; % height, weight maleNdx = find(data.Y == 1); X = data.X(maleNdx,:); XS = standardize(X); % Whiten Sigma = cov(X); mu = mean(X); n = size(X,1); [E,D] = eig(Sigma); Wpca...