sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
7a57c375240c2118979b8192f109084102c96d257c82cbb5e9604ab21771b1ec
MATLAB
1,739
46
function [sig,iflaws]=griffitc(N,SNR); %GRIFFITC Test signal example C of Griffiths' paper. % [SIG,IFLAWS]=GRIFFITC(N,SNR) generates the test signal of % the example C of the paper of Griffiths. % % N : signal length (default: 200) % SNR : signal to noise ratio (default: 25 dB) % SIG : output sign...
f05e08bdf26e7ae315cf69caea3e59e45f37ab80c8348294ffebc9b80a9c78d8
MATLAB
1,739
1
function R=egfit(data, params, options) % version 2.2 27/02/07 % uses fminsearch instead of fmins % (c) Yves Lacouture, Universite Laval [n,m]=size(data); if min(n,m) > 1 error('First argument must be a vector'); end if n == 1 %case of a row vector of data data = data'; n = m; end if m...
26d0e2e3adb4dae1c9cd8f60805eabf0ae836ead76b04f741b2541ba7847be89
MATLAB
1,742
58
classdef VCodeImporter < FeaturesImporter properties end methods(Static) function n = typeName() n = 'VCode'; end function c = canImportFromPath(featuresFilePath) c = false; if exist(featuresFilePath, '...
f702f2490718f278c7b50a1874fee3c56a647dda56dd0d4436588e1e172538ff
MATLAB
1,742
31
function nc_spm_group_normalize_using_dartel(normalize_matfile, TemplateFile, FlowFieldFileList, ... gm_files, wm_files, csf_files, fdg_files) % normalize_matfile : spm job mat for normalization, usually refer to the % Dartel_NormaliseToMNI_ManySubjects.mat % template file : the dartel template file created us...
10f9a9901404a1faf83b31254f92b6937c4cabd7247411ae4c0d5ae34d38c74f
MATLAB
1,743
37
%% RELAX EEG CLEANING PIPELINE, Copyright (C) (2024) Aron Hill & Neil Bailey % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % any later...
205ebe80ee23675512f7973cf7a57aa8a7327fb95bd04f0cfe7a4d7d3e1b13b2
MATLAB
1,743
77
%% PCA Face Demo % Based on code by Mark Girolami %% % This file is from pmtk3.googlecode.com requireImageToolbox loadData('facesOlivetti'); h = 112; w = 92; % plot the first 25 faces as a single image figure; N = 25; XtrainImg = zeros(h,w,1,N); for i = 1:N XtrainImg(:,:,1,i) = reshape(Xtrain(i,:), [h w]); end mon...
38a519876dc53d1467c6e07ea8a562ab8aa533a7a3790ea53e5532bf5435280e
MATLAB
1,743
57
function [A,cost] = minSpanTreePrim(C1, C2) % % Find the minimum spanning tree using Prim's algorithm. % C1(i,j) is the primary cost of connecting i to j. % C2(i,j) is the (optional) secondary cost of connecting i to j, used to break ties. % We assume that absent edges have 0 cost. % To find the maximum spanning tree, ...
50bf7fb4d73d66c692bbd2087bc0b8650b670d37927166edf14adb6a500def8e
MATLAB
1,743
68
function f_pwr = check_forbbiden_fq(g_hz,scanner,plot_graph) % g_hz = spiral.grad_x.seg(1).shot(1).kslice(1).grad(1).waveform; % g_hz = gx(1).waveform; g = g_hz/42.58e3; if scanner == 7 f1 = 1100; bw1 = 300; f2 = 550; bw2 = 100; elseif scanner == 9 f1 = 3000; ...
adc304c922f0c35b794e0ec1ae65fda355589d6cd526a5df2694d8ee0a673255
MATLAB
1,743
81
function [t,TIN, TOUT,EC,EI,CHOICE,RT,COH,SESSION] = get_and_prep_data() % Adaptend from AZ 2022 TIN = []; TOUT = []; EC = []; EI = []; RT = []; COH = []; CHOICE = []; SESSION = []; % do_save_flag = 1; n_datasets = 8; global par_sess for idataset = 1 : n_datasets % dt_ms = 10; dt_ms = 25; par = par_ses...
fdb25b432996c6fb5135af895f986af7acef4602bcf9f9bc17cffa6380f492f7
MATLAB
1,743
48
classdef AbstractHeavyGraph < handle % HeavyLocalGroups are LGs that can contain data > 2GB. To store this % 'heavy-data' data fast, special arrangements are needed. Storing of % the data is done by the saveTableDataSource_v3 function. % % For convenience only: % Default methods work if a ...
0ca49dd4d9a5ae6bd7f55eeff20425013cf9f3bc9f673d7e7380726f8e75972a
MATLAB
1,744
44
function prf = wiCSpkProf(tsd,nses,SesStrt,CSon,CSoff,Pk) sesstrts = find(tsd(:,2)==SesStrt); tsd = tsd(sesstrts(end-nses):end,:); % only "terminal" sessions (2nd half?) LVpk = tsd(:,2) == Pk; LVon = tsd(:,2) == CSon; % flags tone onsets LVoff = tsd(:,2) == CSoff; % flags tone offsets CSdr = mean(tsd(LVoff,1)-tsd(LVon,...
26d3cbca6392298db650b16a84c9d656c74b0f3a5705d34d6a5eadc9113269ef
MATLAB
1,744
57
function compute_all_crop_locs() lbl_file = '/groups/huston/hustonlab/flp-chrimson_experiments/fly2BodyAxis_lookupTable_Ben.csv'; % lbl_file = '/groups/branson/bransonlab/mayank/stephen_copy/fly2BodyAxis_lookupTable_Ben.csv'; r_params = '/groups/branson/bransonlab/mayank/stephen_copy/crop_regression_params.mat'; cro...
a201d50686501f2fcd82342ed7108195b97c403963e33feab90090081240b822
MATLAB
1,744
40
projectFileName = ... '/groups/branson/bransonlab/apt/unittest/alice/multitarget_bubble_expandedbehavior_20180425_allGT_MK_MDN04182019.lbl' ; [labeler, controller] = StartAPT('projfile', projectFileName, 'isInDebugMode', true, 'isInAwsDebugMode', true, 'isInYodaMode', true) ; %% pathFromRegularMovieIndex = labeler...
02ed8bdaa997a4af3b7f908da3740305e25398e1abb26a2366ecd5fdf6caa43e
MATLAB
1,745
37
function [S] = SAttenuationHigherOrder(opt,PathwaySignalFirstOrder,PathwaySignalHigherOrder,GwaveFirstOrder,GwaveHigherOrder,TransFirstOrder,TransHigherOrder,dt,MSD,idxHigherOrder,GwaveBlock,E1,Sinit) %% %Initialise signal amplitude S=zeros([1,size(MSD,2)]); %% %Perform correction to only investigate pathways which co...
db0d70bd7d256b3075d2638652a082f0104ebb5bde5c15eba71c0573626bebf8
MATLAB
1,745
81
function [t p nnpe] = readVTK(fn) % This is a basic VTK reader that is intended to read meshes with uniform % number of nodes per elements (ex. triangular surface or tetrahedral % meshes) % Written by Hamid Ghadyani fn = add_extension(fn,'.vtk'); fid = OpenFile(fn,'rt'); s = fgetl(fid); if isempty(regexp(s,'Version ...
e92e41dcad96f4eb9f3a7caea16792dd6553b4ac86578de47d975adb58e5d08f
MATLAB
1,745
80
function [X, y, bs, perm] = logregGradeMH(); % Example from Johnson and Albert p87 %logregGradeData() % X,y,N stat = load('stat2.dat'); % Johnson and Albert p77 table 3.1 % stat=[pass(0/1), 1, 1, sat_score, grade in prereq] % where the grade in prereq is encoded as A=5,B=4,C=3,D=2,F=1 y = stat(:,1); N = length(y); X ...
fb15da9f21f68196509866be8bc3dbc83150ad77a94558eebe08ff481343963d
MATLAB
1,745
49
% HemoRegression.m % Sarah West % 9/12/21 % Runs hemodynamic correction on a 2-channel stack by regressing each blue % pixel against the corresponding violet pixel and keeping only the % residuals. function [residual_data, intercepts_data]=HemoRegression(bData, vData) % Inputs: % bData-- a 2D matrix of all th...
a103a32b7860717aa33e8d36a8d3257e4b6f9eba1c2af04d2972a5b5ea282524
MATLAB
1,746
69
function [ res ] = fiff_read_hpi_result(name) % % [ res ] = fiff_read_hpi_result(name) % % Read the HPI result block from a measurement file % global FIFF; if isempty(FIFF) FIFF = fiff_define_constants(); end me='MNE:fiff_read_hpi_result'; if nargin ~= 1 error(me,'Incorrect number of arguments'); end [ f...
b657dd007ea8ee0b9897b6accebb5913b9ccf17c8554f5e661a9e1adb8c6f382
MATLAB
1,746
67
function splitABFFile(varargin) options.abf_file_name = ''; options.max_file_length = 120; % seconds options.deltat = 1e-4; % s options = corelib.parseNameValueArguments(options,varargin{:}); [~,~,file_ext] = fileparts(options.abf_file_name); [raw_data,dt,metadata]=filelib.abfload(options.abf_file_name); dt = dt...
d21dcd447f813264c3ba39534b3b65bc8473916b50dd4d51df39536abc2b9182
MATLAB
1,746
31
% 171023 | located the word cues centrally function StateSwitch_addSurroundingCues_words_171023(expInfo, screenInfo, indRun, indBlock, indTrial) % adds the surrounding cues for the next flip % expInfo.Cues = {'Tier?'; 'einsilbig?'; 'gerade?'; 'H?'}; for indAtt = 1:4 posScale1 = 10; posScale...
e474363cf6e355dbe7d94c5efba8b3ecd8af06768bd51462dce5994d224b34f7
MATLAB
1,746
65
function [val, status] = ft_findcfg(cfg, var) % FT_FINDCFG searches for an element in the cfg structure % or in the nested previous cfgs % % Use as % val = ft_findcfg(cfg, var) % where the name of the variable should be specified as string. % % e.g. % trl = ft_findcfg(cfg, 'trl') % event = ft_findcfg(cfg, 'eve...
6348a79ea83fb6c0989e3e95ab8f409d92e2e569d9002b4f91d7a25aef3cc647
MATLAB
1,747
67
function [x,y,xhat,vx,yhat,vy] = VBA_comparePredictions(n_t,theta,phi,u,alpha,sigma,options,posterior,dim) % compares inferred predictive density and real samples if isempty(u) if options.microU u = zeros(1,n_t*options.decim); else u = zeros(1,n_t); end end % first get real system's sample...
9f4231a78a034041373b842932b443f27ca812af49e92a9910de8afb40711498
MATLAB
1,747
58
function [PsC_s,best_lag] = PsC(template,sig,lag) %% Psuedo_Correlation % Computes the Pseudo Correlation , a finer approach than normal % correlation for template matching. Please review the paper below in order % to see why it is much more accurate for the pattern recognition %% Input % template : template to be sear...
bd979b718eab80e03726247a779b2e29456c77d7703e69940c3a8ce992ae0082
MATLAB
1,747
56
% K-medoids algorithm % [idx,dpsim]=kmedoids(S,k,nruns,maxits) % % Input: % % S Similarity matrix (see above) % K Number of clusters to find, or a vector of indices % of the initial set of exemplars % nruns Number of runs to try, where each run is initialized % randomly...
134fa4673f2e31816155948282ee95b5455dfd9d6034b5494cca27213690769a
MATLAB
1,748
79
%% collapsed Gibbs sampler on DP mixture of 2d gaussians %PMTKauthor Yee Whye Teh %PMTKurl http://www.gatsby.ucl.ac.uk/~ywteh/teaching/npbayes/mlss2007.zip %PMTKmodified Kevin Murphy % Originally called dpm_demp2d dd = 2; KK = 1; trueK = 5; NN = 100; aa = 1; s0 = 3; ss = 1; numiter = 200; hh.dd = dd; hh.ss = s0^2/ss^...
6f9dd7c74bf07c88405d50874859b82ed498e748509e60b628e92e7698d6a39a
MATLAB
1,748
49
% Author: Birgit Nierula % nierula@cbs.mpg.de %% Remove double detections of R-peaks %% --> to use after manual detection steps srmr_nr = 2; ana_dir = '/data/pt_02151/'; sav_dir = '/data/p_02151/SRMR2_experiment/analyzed_data/Rpeak_detected/'; cfg_path = [ana_dir 'analysis/manuscript_sep/scripts/cfg_srmr2/']; % he...
fc9113d9e417a362adf2bf15c282e28f41651470eb7131e699f3539800106f2a
MATLAB
1,749
47
%% LOOK AT AMPLITUDE OF PEAKS, TOO- NOT JUST TEMPORAL LOCATION. % Looking at correlation of the amplitude of the peaks with the % number of peak in the significant portion of a trial mkdir([DIRresultsRipple, '/amplitude/']); for t=1:num_groups actual_index = (big_list_indexes{t}); if(length(the_indexes)>0...
1d4ca76959c29716cc9f7f2516a9d8fe96d05fdc0de375783a8a03a6c88342d5
MATLAB
1,751
68
function [FPrate, TPrate, AUC, thresholds] = computeROC(confidence, testClass) %% Compute ROC curve statistics % % Inputs: % confidence(i) is proportional to the probability that testClass(i) is positive % testClass(i) = 0 => target absent, testClass(i) = 1 => target present % % Outputs: % FPrate(i) = False positiv...
955dbfc674e9dc98e88cd2e852b75cf0b95de30ab781a2a030d8519756fa0406
MATLAB
1,751
50
%_______________________________________________________________________ % % showTargets(screenInfo, targets, targetIndex) %_______________________________________________________________________ % % Displays the targets identified by targetIndex in the structure targets %______________________________________________...
bcbdc934d7e8a0cb6ebc480468242d861d62964c51d935f66e7b567a4a61eb38
MATLAB
1,751
63
function [fr_position] = flyFinder(ROI_image, search_size, threshold, flip) %flyFinder % % Usage: % [fr_position] = flyFinder(ROI_image, search_size, threshold) % % This function finds a fly (region of darkness) in an image matrix (ROI_image). % Locates the darkest pixel in the image, retrieves a "search area" % (2...
129673ea125d7947c157ccafa41534285c0b3a1f4cbb824a8a5c50e3e97572e6
MATLAB
1,752
73
% Demo for partially observable oscillatory system. % This demo inverts a model of a linear oscillatory system, which is % observed through a nonlinear sigmoid function. clear variables close all % Choose basic settings for simulations n_t = 1e2; delta_t = 1e-1; f_fname = @f_lin2D; g_fname = @g_Id; u = zeros(1...
77c76449a9ed3a363377ebc5d4d7e5031e5e481adaa61cd81757f1cf0b932f06
MATLAB
1,752
59
%% Detect rois that have large shift in baseline using cusum % Chad Heer %INPUT %data = must be struct with field F data from axon analysis %OUTPUT %sig_events = events where baseline significantly shifts %tonic_activity_roi = ID of axon with tonic activity %tonic_start = frame where shift in baseline occurs functio...
1be7e1137a045fc72c065a1fd18ae0e5e8a844d14fb5adffd4a117b205f4c6e8
MATLAB
1,753
48
function PromptHandle=ZachPrompt(Message,MessageTitle,GoodIcon) if ~isempty(GoodIcon) if ispc userDir = winqueryreg('HKEY_CURRENT_USER',... ['Software\Microsoft\Windows\CurrentVersion\' ... 'Explorer\Shell Folders'],'Personal'); dc='\'; ...
64518a93beee398199f1ca6325dbd95e43ede2da743207deed760540365175e4
MATLAB
1,753
84
function bandevlist = wlAux_splitEventsByBand(oldlist, bandlist) % function bandevlist = wlAux_splitEventsByBand(oldlist, bandlist) % % This function splits an event list into smaller lists of events that match % the supplied frequency bands. % % "oldlist" is an array of event records per EVENTFORMAT.txt. % "bandlist"...
854353891c83742c0622f84c4175a2b0b48670d3f1388cfe11d95bae106d51cc
MATLAB
1,753
72
clear all; for s=1:180 load(sprintf('results_eff_hopf_fcrev_movie_MOVIE1sub_%03d.mat',s)); DataMOVIE1(s,:)=FCemp(:); end for s=1:177 load(sprintf('results_eff_hopf_fcrev_movie_MOVIE4sub_%03d.mat',s)); DataREST2(s,:)=FCemp(:); end task_nsubn={180,177}; trainno=167; valno=10; kfold=100; cl=1:2; pc=z...
93c3b46b84ba99e2471868bb4384eb443486cb395e3c4f0aea3110e47bd01813
MATLAB
1,754
56
function h = mysigstar(ax, xpos, ypos, pval, color, whichWay) % replaces sigstar, which doesnt work anymore in matlab 2014b if ~exist('ax', 'var'); ax = gca; end if ~exist('color', 'var'); color = 'k'; end if ~exist('whichWay', 'var'), whichWay = 'down'; end if numel(ypos) > 1, assert(ypos(1) == ypos(2), 'line wo...
0c700339aba7fe92c678b846bfc6b3217bfbd6a09bd821e4248b822d342071c0
MATLAB
1,755
40
function TSmakeemptyfield(L,F) % Makes and empty field at Session or Subject level, so that code that % assumes existence of a field for that session or subject will operate. % % Syntax: TSmakeemptyfield(L,F) % % The principal use of this function is for fields at the Session level % that are looked at by graphics func...
0f0887c90214edfda6bdd933b36f091c0c535f95e78def9a849365ba0819c5d5
MATLAB
1,755
46
function masks = txt2img( strings, h, txtPrp ) % Convert text string to a binary image. % % For each input string, creates a binary matrix of dimensions [hxw] that % when displayed as an image shows the string. See example for usage. % First, uses text() to display the text using Matlab's display % functionality. Next ...
83e42c5f4ce150af2f29b2f4bc8e4fcb318bb64d20c76a2fb1b74755ae2dd231
MATLAB
1,755
68
function [canonized, support] = canonizeLabels(labels,support) %% Transform labels to 1:K % The size of canonized is the same as labels but every % label is transformed to its corresponding entry in 1:K. If labels does not % span the support, specify the support explicitly as the 2nd argument. % % Examples: %% % str =...
062c7e857df0ce745633c70553daf6e8e5c62c27d878135bab1cbd9fa31f0a03
MATLAB
1,756
64
% Author: Birgit Nierula % nierula@cbs.mpg.de function bad_channels = prepro_esg_check4badChannels(epo, trigger_name, wait4input) %% check for bad channels % input: epoched data if ndims(epo.data) == 2 cnt = epo; clear epo load([getenv('CFGDIR') 'cfg.mat'], 'iv_epoch', 'iv_baseline') epoch_ival = iv_...
956f0e4f8ceddadc6186d4876c852c8aaccd5064459e242691685c0e834d51d7
MATLAB
1,756
70
%%%%%This package written by robert wilson, freely available at % https://github.com/d-r-b-o-b/UsefulMatlabFunctions%% function tb = addABCs(ax, offset, fontsize, abcString) % tb = addABCs(ax, offset, fontsize, abcString) % % Add letters to axes % Inputs: % ax - axes handles % offset - 2x1 vector o...
1c1aae8922adea6b4dc782d0943e18ab931b20e0173dc9de2bd711f18bd9dc72
MATLAB
1,757
52
function ep = VBA_ExceedanceProb(mu,Sigma,form,verbose,Nsamp) % calculates the exceedance probability for mutivariate Gaussian variables % function ep = VBA_ExceedanceProb(mu,Sigma) % IN: % - mu/Sigma: sufficient statistics of the pdf % -> if form='gaussian': mu=E[x] and Sigma=V[x] % -> if form='dirichlet...
817cf61ec52ead3bba95331faae85dd9e6b2eb3b65a8471847ce10b1c2ff0a8d
MATLAB
1,758
45
%% Note all the relevant filepaths %A few manual parameters to set upfront % There is a yaml file with all the major parameters of the experiment. We % will use the name of that yaml file as the experiment_name throughout % EXPERIMENT_NAME = 'cruk'; %Where do load/save the files for this experiment? ROOTDIR = '/User...
ef34c789311867c6b66efa8e618d466dd1be085d328b8cdb6349991c72465281
MATLAB
1,758
48
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% f13_create_plots -- Create the surface potential, and surface magne- %% %%% -tic field plots for the dipole source with no noise. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% eps0 = 8...
35923ded157ca89c164810e24afd4f5d618bcf80c8480e7a3a7c7ddb7380adfa
MATLAB
1,759
47
function [fi,ind] = interpF(F,n,s1,s2,s3,h) %% returns interpolated function value fi = F(s1,s2,s3) % where s1 = row index, s2 = col index, s3 = depth index %interpF(V,n,xi,xj,xk) == interp3(par.Yc,par.Xc,par.Zc,V,xj,xi,xk) if nargin < 6 h = [1,1,1]; end fi = zeros(length(s1),1); [n1,n2,n3]=deal(n(1),n(2),n(3...
3bedb5a587108523cbe4cd12b5f110b4492ce480dd0364a7c9260f807e12fa43
MATLAB
1,759
71
function applyCARtoDat(filename, nChansTotal) % Subtracts median of each channel, then subtracts median of each time % point. % % filename should include the extension % outputDir is optional, by default will write to the directory of the input file % % should make chunk size as big as possible so that the medians of ...
c30afda7547e6836bbdd95c8418c54ec10d4b0571fbcbe9ef136e73ab8eddce2
MATLAB
1,759
66
%% pxTools_getTransitionMatixFromDC % Utility to preview the transition matrices given a set of parameters. % Trevor S. Smith, 2022 % Drexel University College of Medicine function [mat] = getTransitionMatrixFromDC(xtData, XT_DC_CH_NO, varargin) p = inputParser; addParameter(p, 'N_BINS', 20); addParameter...
cfbe7308c87817eaf7a1a740c0a09fb9ad49a667b13909fe1825d3d9d1fe4c2f
MATLAB
1,759
55
function mapped = mapids(ids, obj) % mapids Map Imaris IDs to object types % % Syntax % ------ % mapped = mapids(ids, obj) % % Description % ----------- % mapped = groupids(ids, obj) creates a containers.Map object that % assigns object IDs to keys that co...
34a75456d93d63f875db9a350ea24c53635648d07df626c26308bbc665b64a65
MATLAB
1,760
70
%% Gauss Imputation Demo using ICM % %% % This file is from pmtk3.googlecode.com function gaussImputationICMDemo() setSeed(0); d = 10; mu = randn(d,1); Sigma = randpd(d); % Training data is larger than test data, and is missing data at random [XfullTrain, XmissTrain] = mkData(mu, Sigma, 100, true); % Test data omi...
df315320184243e14bca291a642aa02853a998959ff6a64911857045bb304e03
MATLAB
1,760
56
function h = mysigstar_glme(ax, xpos, ypos, pval, color, whichWay) % replaces sigstar, which doesnt work anymore in matlab 2014b if ~exist('ax', 'var'); ax = gca; end if ~exist('color', 'var'); color = 'k'; end if ~exist('whichWay', 'var'), whichWay = 'down'; end if numel(ypos) > 1, assert(ypos(1) == ypos(2), 'li...
4df1c5332ad9450d2e6da18f634a1cba6c58b145c49d923fb5e3afb27dd526fd
MATLAB
1,761
59
function [ network_lengths ] = skeleton_analysis( cell_mask, name ) % function: Short description % parameters; % load parameters % ---------------------------- Skeleton generation ----------------------------- disp('Skeleton generation:'); tic skeleton = Skeleton3D(logical(cell_mask)); toc % Save the skeleton as a ...
911f4d567335c31eeefce954a024e96626096f5bd688619156d6ab4fea316bc6
MATLAB
1,761
60
%% Visualization of error versus amount of regularization % %% Ficticious bias,variance,error functions % This file is from pmtk3.googlecode.com varFN = @(lambda) 0.012 -(0.025/4)*lambda; biasFN = @(lambda)((2.5.^(1.5*lambda-2.5))/20)+ 0.0012; biasvarFN = @(lambda) varFN(lambda) + biasFN(lambda); testerrorFN = @(lam...
c64708fb8f106c56171d3be080a6f0d057e3526e538640436ab8f464479280f7
MATLAB
1,761
50
%% Illustration of Newton's method for a non convex function. % %% % This file is from pmtk3.googlecode.com function newtonsMethodNonConvex figure(); hold on; xmin = -4; xmax = 13; ymin = -50; ymax = 600; domain = xmin:0.01:xmax; f = @(x)-x.^3 + 15*x.^2; Xk = 8; f1 = @(x) -3*x.^2 + 30*x; f2 = @(x) -...
4163307e8c3fc8d902ceee9926ea7ef9449d5fc49a71cc4f97915510e9bef894
MATLAB
1,762
84
function iimg_weighted_ttest(image_names,varargin) % fast weighted test % % :Examples: % :: % % iimg_weighted_ttest(image_names,'mask',maskname) % % .. % Tor Wager % .. % .. % Set up arguments % .. maskname = deblank(image_names(1,:)); % defaults w = []; varY = []; bcon = []; % inputs for i = 1:length(varar...
4888401ee5d1609b46f1b32924e645df14cbd3fae904a233c426a533c815ba68
MATLAB
1,762
58
function [lf] = inf_medium_leadfield(rd, pnt, cond) % INF_MEDIUM_LEADFIELD calculate the infinite medium leadfield % on positions pnt for dipole position R and conductivity cond % % [lf] = inf_medium_leadfield(R, pnt, cond) % Copyright (C) 1998, Robert Oostenveld % % This file is part of FieldTrip, see http://...
908b87712e46fdd2512bc38127eeb2b68090dd55a95381b05c6c6a9137facf2f
MATLAB
1,763
38
% Script for running a simple ex-Gaussian analysis % ========================================================================= % % Dependencies: % - MATLAB's Statistics and Optimization Toolboxes % - John D'Errico's fminsearchbnd file: http://bit.ly/Ky3xll % % Explanation of variables: % y - Nx1 vector of ...
f094415f431670a5b98d2c1f370c93216bcdaea291453b0a6b48f08af4555790
MATLAB
1,763
61
function data1 = setup_MISA_MMIVA1(M,X,W0,dist_type) nComp = size(W0{M(1)},1); S = cell(1,max(M)); % Cell array: each cell contains a matrix K x C(m). % Each k-th row has 0's and 1's to indicate what sources go within the k-th subspace in dataset m for mm=M S{mm} = sparse(1:nComp,1:nComp,1,nComp,nComp,nComp); ...
3f27fac803603a23b8f4f714530a07d714b213a2bd2393eede6251f1abdc1792
MATLAB
1,764
76
function dir_path = lastdir(new_path) %LASTDIR Remembers the last directory used for use in UI browsing dialogs. % Usage: % dir_path = lastdir % lastuidir(new_path) % % Args: % new_path: relative or absolute path to a folder or file. % Saves parent folder if path to a file is specified. % % Returns: % dir...
55e9ddf424de789b3631136b5a04cda91eb4d972ccb4002b1ea6768f1a94f43c
MATLAB
1,764
46
function otherFormat = convertTime(secondsOrString, minFields) % Convert between a number of seconds and the string representation. % TODO: unit tests if ischar(secondsOrString) % The string should be in the format xx:xx:xx.xx xx:xx.xx or xx.xx. pieces = regexp(secondsOrString, ':'...
69adaa7666700aad29bab3822958e737f101576901fae7a540b8d2ba26f56508
MATLAB
1,764
53
function [grid1,grid2] = generate_2d_grid(l1,l2,grid_image,plotflag,rotation) if(nargin<5) rotation = NaN; end if(nargin<4) plotflag = 1; end [grid1,grid2] = meshgrid(l1,l2); grid1 = grid1'; grid2 = grid2'; if(~isnan(rotation)) [grid1,grid2] = rotate_grid(grid1,grid2,rotation); end ...
a63fd7279461f925ab42595c8a40c9381c83d6a285b5a6853499a726b8c5964c
MATLAB
1,764
53
function peaks = FindPeaks(dat, s, varargin) % M. Farries 4/5/2017 % Simplified version of Murat Okatan's get_peaks % Finds peaks is dat at scale s, which should be an odd number. % dat is a matrix, nSamples X nChan. % Optional 3rd argument: "polarity" of the peaks being sought: +1 = positive peaks, -1 = negative ...
a9010169dcd149e5bc14a6ceeb9044840ca8ed3fafcb5d97b71ba551f279ac2c
MATLAB
1,764
34
function uc = GetUnicodeChar(character) % Get the unicode char value for a unicode character % gc = GetUnicodeChar('character' [string]) % gc = GetUnicodeChar('Mu') % The 'character' requested is case sensitive. 'Gamma' ~= 'gamma' % If 'all' is passed then a structure containing all character will b...
06588934d03cac4d439e6361ab1b9dc674f913c4dd255029635e09b4c92d1553
MATLAB
1,765
46
function [array] = distFilter(array, teleDistThreshold) numAvg = 5; % Teleport filter. Removes spurious points where fly position teleports all % over the vial due to a false track. teleFiltNum = 0; for dim = 2:2:size(array,2)-1 for numPoint = (numAvg+1):(size(array,1)-numAvg) point = array(numPoint, dim:...
689916999c45d33ae699b572c816daf0048c0584f20827598c3de2375bbd5c4f
MATLAB
1,765
62
function mesh = make_rectangle(sizevar) % mesh = make_rectangle(sizevar) % % Creates a 2D rectangular mesh % % sizevar.width - width % sizevar.height - height % sizevar.xc - x center % sizevar.yc - y center % sizevar.dist - distance between nodes % error checking if ~isfield(sizevar,'xc') || ~isfield(sizevar,'yc')...
8d8a394383839b58ffdbd3fbb1f0013432121eea00b7ec9d1b90cc6237ea29ce
MATLAB
1,765
40
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % The script prepares the design.mat and design.con files needed to run % % FSL randomise % % (1)https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/GLM#Single-Group_Average_with_Additional_Covariate % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
9093382a523628f549536b4262943db1bcb42003f43cec3aaf94f41f432f63f2
MATLAB
1,765
56
function C = plus(A,B) %PLUS Binary addition for sparse tensors. % % PLUS(A,B) is called for the syntax 'A + B' when A or B is a sparse % tensor. A and B must have the same size, unless one is a scalar. A % scalar can be added to a sparse tensor of any size. % % Examples % A = sptenrand([4 3 2],5); B = sp...
968c8e1fe6b8c5c89418a2c8c8c54e7fcff27e6112c40910b43b910f0878b5f6
MATLAB
1,765
61
fprintf(1,'Recomputation of the image corners using Lucchese''s saddle point detector\n'); q = input('This detector only works for X junctions (checker board corners). Is this the case here? ([]=yes, other=no)','s'); if isempty(q), ima_proc = 1:n_ima; fprintf(1,'Processing image '); for kk...
422ef54a02a206f725077b7b3c7e7157c3c1303ef94d4b75938244fa198726a8
MATLAB
1,766
53
function normalizeImage_cuda(src_folder_name,dst_folder_name,fileroot_name,channels,roundnum) loadParameters; %Check for any missing image file chan_filenames = {}; for c_idx = 1:length(channels) filename = fullfile(src_folder_name,sprintf('%s_round%.03i_%s.%s',... fileroot_name,ro...
a106738a71b1cd134a8c8d0b1467bf356294c71ab7fe229be78cae03328b0148
MATLAB
1,767
72
% addpath('../generic/'); % addpath('../analysis_reclassif/'); %% n_datasets = 8; fig_made = 0; for idataset = 1 : n_datasets % addpath('../analysis_explore/'); dt_ms = 25; par = par_sess{idataset}; D = get_data(dt_ms,[],idataset, par); % struct2vars(D); filt = ones(size(D.RT))==1; ...
bed285f3e3e5de9b32d9ca6ddb3427db9192523525674ece1b4a27f2882f642f
MATLAB
1,767
45
% Written by Einat Peled % einatspeled@gmail.com % % Get a vector of response amplitudes % ImageArray_CorrAmp_norm_InMax: contains images with highest-value pixels at all response locations function Vector_RF_CorrAmpNormValues_AllNMJ_Grouped = GetRFAmpValues_Array_Grouped(ImageArray_CorrAmp_norm_InMax, ImageAr...
d7408d429c43151b185b22c75190636ae91f97a1a891344dd6d9775e2b1fb473
MATLAB
1,767
46
function [Contour, GHeader] = y_Contour_Surf(LabelFile, SurfFile, AResultFilename) % Calculate Contour from the 2D surface brain % FORMAT [Contour, GHeader] = y_Contour_Surf(LabelFile, SurfFile, AResultFilename) % Input: % LabelFile The input Label file % SurfFile - The surface file % ARes...
cbf694492c48682e2bbe96e4853cbd011469f2c58e0f4d235c865cf367aa5cba
MATLAB
1,769
53
% Code taken from Paul Scovanner's homepage: % http://www.cs.ucf.edu/~pscovann/ % Calculate 3D Sift % img is the input in question. % keypts is an Nx3 matrix of keypoints % returns keypoints % struct % key.x, key.y, key.z voxel indices % key.xyScale and key.tScale - affects both the scale and the reso...
19cb102c7d1631a6074a98f6d35aae5033cf1ea71f8ca53340bb1011a2a3b93b
MATLAB
1,770
54
% WEIGHTED CORRELATION % Linear correlation between time and position weighted by the associated posterior probability % INPUTS: decoded_position (e.g. decoded replay event); T as vector of time bins; P as vector of position bins function output = weighted_correlation(decoded_event) pixel_size = size(decoded_event); ...
a47fd0146c6fa65d64352a20955113b35096dab56c6d79bcd4350bed4347ae1d
MATLAB
1,770
27
% This function bins the bump velocity residuals by the bump's position function [Binned] = Bin_Bump_Velocity_Residuals(AllFly, HD_Bin_Edges) % Loop over flies and do the binning Binned.Left_N=[]; Binned.Bump_HD_Good_Left=[]; Binned.Bump_AV_Good_Residual_Left=[]; Binned.Bump_AV_Good_Residual_Left_STD=[];...
bedcf2b4790b89108f1ca685ec3238219eb7e787cef656878391b533443fb62d
MATLAB
1,770
74
function [gx, dgdx, dgdp] = g_QLearning (x, P, u, in) % // VBA toolbox ////////////////////////////////////////////////////////// % % [gx, dgdx, dgdP] = g_QLearning (x, P, u, in) % softmax decision rule for Q-learning (N-armed bandit task) % % IN: % - x: Q-values % - P: (1) inverse (log-) temperature % (2)...
d1baeefc7a5d44aa9098e38f199009e53f81100b8047b3fc54a0ba34e5d359d5
MATLAB
1,770
53
%% getidealaxislength % Utility to find an ideal axis length, given a maximum/mininum observed value % Used to commonly set many subplots % Essentially finds the nearest whole number of the significant digit % % INPUT: % Y = A single number, representing the aggregate max or min of % values to plot % MODE: '...
d421cc9037c5533b25a38e78abec1b38b8445901fa618d68eb891b920669daa5
MATLAB
1,770
29
function [options] = defaultOptions_mcbDNMF() %[options] = defaultOptions_mcbDNMF() % Size of image patches options.patchSize = [64 64]; % Size of image patches options.stride = 56; % Offset of image patches % Initial ROI detection parameters options.DETREND_FRAMES = 45; ...
dd683e7fc1b3d2ac765a61f22a511ea79e630612f5af6263f73f09a1848e0506
MATLAB
1,770
49
function PlotFigure1(vars,varNames) % Plot Figure 1c-d % if no inputs, will load figure source data file if nargin==0 load('Figure 1 - Source Data 1.mat', 'vars', 'varNames') % vars is struct with fields of [nPP, nConds, nDrug] trial means end lineColours = get(gca,'ColorO...
ee63e57990e129fe2d9130d62394d243c62bf49cf247657283cf71129c2e3ef9
MATLAB
1,770
54
function mix = gmmunpak(mix, p) %GMMUNPAK Separates a vector of Gaussian mixture model parameters into its components. % % Description % MIX = GMMUNPAK(MIX, P) takes a GMM data structure MIX and a single % row vector of parameters P and returns a mixture data structure % identical to the input MIX, except that the mix...
1e49c6845b01cd2f216e5813bdd5df7bfbb78d56d21cbb4a2c447b0fb8e2d7cd
MATLAB
1,771
73
% 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,...
8b24f451271faa616a89f8c30835b7260ab21501120f0d92cf2c9d90025e9587
MATLAB
1,771
83
% [mu,S,priors] = mygmm(X,k,...) % Input: % X: N x D matrix of N D-dimensional data points % k: number of clusters % optional: % 'Replicates' = 1 % 'CovarType' = 'full' % 'display' = -1 % 'precision' = .0001 % 'ResetCovar' = 1 % 'MaxIters' = 100 % 'Start' = 'furthestfirst' % 'distance' = 'sqEuclidean' % 'weights' = [] ...
7c32723bce50adf2ffd9191bc24bcd43ee5a6ee6bbe4f3c389ea395b8c943113
MATLAB
1,772
43
function [parameters] = saveVelocities(parameters) % Give parameters their original names k = parameters.k; wheel_Hz = parameters.wheel_Hz; fps = parameters.fps; % sampling rate of encoder channelNumber = parameters.channelNumber; % skip = parameters.skip; frames = parameters.frames; ...
0223877905597c6181c59073467e5f87fcb5ccde982a32ba8873a4d8cc9c4641
MATLAB
1,773
73
%% Sequential Bayesian updating of (mu,sigma) for a 1D gaussian % % %% Uninformative prior % This file is from pmtk3.googlecode.com m0 = 0; k0 = 0; v0 = 0; % 0.01; S0 = 0; % 0.01; %% Sample data truth.mu = 5; truth.Sigma = 10; setSeed(1); X = colvec(gaussSample(truth, 100)); xyrange = [-5 15 eps 15]; figure; ho...
17b6efe3bd7ab19a0c940bd552ec24c43aa46a4594573fc4e649c83d0140b667
MATLAB
1,773
61
%% DownSampling Data_465=[input('465nm data name=','s'),'.csv']; Data_405=[input('405nm data name=','s'),'.csv']; Ds_Data_465=Downsampling(Data_465); Ds_Data_405=Downsampling(Data_405); %% Show figure plot(1:size(Ds_Data_465,1),Ds_Data_465(:,2)); xticks(0:100:size(Ds_Data_465,1)); %% Trimming Trim_time=200; T...
120c3dfacac1d97727ada40660387cd5dbc01c6e1d62a027fad39e39a8f71c81
MATLAB
1,774
51
function sites = sorw_GetSites(A,Nstep,x0,normalizeProb) % nodes of the arena in the self-organized random walk % A -> [N,N] adjacency matrix (either weighted or binary) % A(i,j) = p_ij (probability of stepping from j to i) % Nstep -> matrix containing the number of steps from nodes j to i % x0 -> value to...
3fa9602175b8a63a3505a883a30a168e85036b46a15afcb07337ef5bd0a89609
MATLAB
1,774
44
function [index_num, index_link,index_num_mask] = sources_active_index(mesh) % SOURCES_ACTIVE_INDEX Calculates permutation vectors for mesh sources. % % [INDEX_NUM, INDEX_LINK, INDEX_NUM_MASK] = SOURCES_ACTIVE_INDEX(MESH) MESH % is NIRFAST mesh structure. % INDEX_NUM - n by 1 vector where n is the number of acti...
5124d86221f61c13ffea4fe7be42632e4e77d2fe963e6c974568a7ec084db390
MATLAB
1,774
54
function [L,filters] = gaussSmooth( I, sigmas, shape, radius ) % Applies Gaussian smoothing to a (multidimensional) image. % % Smooths the n-dimensional array I with a n-dimensional gaussian with % standard deviations specified by sigmas. This operation in linearly % seperable and is implemented as such. % % USAGE % ...
47059ee6d5e406beb946ecc472ab16be14430bcf9b38ef63e76b9e44eeaec1f9
MATLAB
1,775
64
function [w, stderr, pval, R2, sigma2, confint, Zscore] = linregParamsFrequentist(y, XX, names, useLatex) % Frequentist inference for regression weights in a linear regression model. % This is similar to R's lm function or Matlab's regress function. % Each row ox X is a training case, excluding the first column of 1s ...
03488226c22a2e6726e4c274619faa89b883ee031d9bc45699836b4bfe96fe91
MATLAB
1,776
63
function savefaststruct(filename, savestruct) % savefaststruct: fast saves of large arrays to .mat files % % Matlab's 'save' command can be very slow when saving large arrays, % because by default Matlab attempts to use compression. This function % provides a much faster alternative, at the cost of larger files. % % 's...
2d201a471c08c76974fced0b65324f1ac555df29ed8ee62badb292168964abee
MATLAB
1,776
63
%% clear workspace close all; clear all; clc; %% globals beta_ranges = [[13 20];[20 30]]; %% load tf data addpath C:\code\spm12 spm('defaults','eeg') addpath('C:\Code\fieldtrip-20210302') addpath('C:\Code\wjn_toolbox') % Dt=spm_eeg_load('data/iEEG/tf_spm_ecog.mat'); % ft_defaults Dt=spm_eeg_load('D:\ECoG_Atlas\iEEG\i...
86899e0c35e9f4ad32120a31dc68ebf15fabc8b5e9979cddaec0bb68ce6e4de0
MATLAB
1,776
45
function [ events auxwaves auxdata ] = wlProc_doSegmentAndParamExtract_MT( ... wavedata, samprate, bpfband, segconfig, paramconfig) % function [ events auxwaves auxdata ] = ... % wlProc_doSegmentAndParamExtract_MT( ... % wavedata, samprate, bpfband, segconfig, paramconfig) % % This function performs event segm...
c51eafa5e07f686852428ed17d925d863fd001622bb34386e12e2fe68d038abf
MATLAB
1,776
48
%% SAT - app_input:: %% helper.checkColumns % Name: Phone Kyaw % Date: 09/19/2024 % Description: Check whether the old_column_cell and current_column_cell % has the same character data % Parameters: old_column_cell - 1xN cell containing char/str % new_column_cell - 1xN...
9eddf58202bdbe017cd7e458b6e9c69805352c55478fd1d44fdac721064950e7
MATLAB
1,777
63
function [D0,phisq0] = lme_fit_init(X,Zcols,y,ni) % [D0,phisq0] = lme_fit_init(X,Zcols,y,ni) % % Starting values for linear mixed-effects iterative estimation. % These starting values are based on the ordinary least squares estimators. % % Input % X: Ordered design Matrix (according to time for each subject). % Zcols...
aaecb677de133a71d9e2f7820187d479b8287656f4c91b66868905802351976d
MATLAB
1,777
54
% 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,...
961ea17bc240ff871488a2a2afd9e9a58a35b599f1f9e713f9d3a8af8a56b670
MATLAB
1,778
68
function [p, p1] = permtst2(x, y, Nit) %PERMTST2 Permutation test for means of non-paired data vectors % % [p, p1] = permtst2(x, y, Nit) % % Establishes whether two data sets have significantly different % means. It makes Nit Monte Carlo permutations of the full [x y] % data. Returns the probability p that differenc...
f8cdded9b011fee9bd9b3ce5f0c3c0a9702e07a85b6489fcfc49f76ed51227e9
MATLAB
1,778
95
function [fc,cc,kc,alpha_c,Rc,Tc,omc,nx,ny,x_dist,xd] = willson_convert(Ncx,Nfx,dx,dy,dpx,dpy,Cx,Cy,sx,f,kappa1,Tx,Ty,Tz,Rx,Ry,Rz,p1,p2); %Conversion from Reg Willson's calibration format to my format % Conversion: % Focal length: fc = [sx/dpx ; 1/dpy]*f; % Principal point; cc = [Cx;Cy]; % Skew: alpha_c = 0; % Ex...
2fe0a54866c7a64ab24b073695965178e03374467ed445e5aa7f671625d8ec77
MATLAB
1,779
37
function DataStructure=LinearFit_ZN(Xdata,Ydata) if size(Xdata,1)<=1&&size(Xdata,2)<=1&&size(Ydata,1)<=1&&size(Ydata,2)<=1 warning('Need to provide more than one data point to fit!') DataStructure=[]; elseif size(Xdata,1)~=size(Ydata,1)||size(Xdata,2)~=size(Ydata,2) warning('Need to pro...
fa6704eb8530c818883542d26eaa5d1d59d5703c8aa6b4b4e4c0ea4d6b010b37
MATLAB
1,779
48
function op = removeExtraDecodeStructFields(resultsStruct_variedDecode, varargin) % Remove un-necessesary fields from the decoding struct % % resultsStruct_variedDecode = utils.removeExtraDecodeStructFields(resultsStruct_variedDecode); %% Parse inputs inputObj = inputParser; addRequired(inputObj, 'resultsStruct_varie...
413db73a537813339b1b9acf4ad2a3ae199ab38974ba4a388b499318b69b0669
MATLAB
1,780
49
function orthobasis = tangentorthobasis(M, x, n) % Returns an orthonormal basis of tangent vectors in the Manopt framework. % % function orthobasis = tangentorthobasis(M, x) % function orthobasis = tangentorthobasis(M, x, n) % % M is a Manopt manifold structure obtained from a factory. % x is a point on the mani...
6624a67e4d20cf967857b3412da2682a917db4dabd0ba7b9ce3c1d08461b4ece
MATLAB
1,780
54
function noise=noisecu(N); %NOISECU Analytic complex uniform white noise. % NOISE=NOISECU(N) computes an analytic complex white uniform % noise of length N with mean 0.0 and variance 1.0. % % Examples : % N=512;noise=noisecu(N);mean(noise),std(noise).^2 % subplot(211); plot(real(noise)); axis([1 N -1.5 1.5]); % su...