sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
43560779866096bdb5da413aaa91f8edba65572a601fc0f2acee3e8245385ae6
MATLAB
1,820
73
function [OutputArray]=String2Array_Fixed(varargin) Delimiters=[]; StartCap=[]; EndCap=[]; switch nargin case 1 InputString=varargin{1}; case 2 InputString=varargin{1}; Delimiters=varargin{2}; case 3 InputString=varargin{1}; ...
652a269ec798f8275fa0839a9e5c5b95032b8429911a59564a70240e0322574b
MATLAB
1,820
46
function [msdx msdy stddev maddev ] = velthresh(vel) % VELTHRESH - compute median-based standard deviation (SD) estimators % of velocity time series % %------------------------------------------------------------------- % INPUT: % % vel: n-by-2 matrix with hor. [vel(:,1)] and vert. [vel(:,2)] eye velocity % % ...
c94376440b8f51d9d83f55f498e1939e550ef07538980ee248b6975165e675e5
MATLAB
1,820
40
function [s, cfg] = ft_statfun_mean(cfg, dat, design) % FT_STATFUN_MEAN computes the mean over all replications for each of the % observations (i.e. channel-time-frequency points or voxels). % % This function does not depend on the experimental design and cannot be used for any % statistical testing. However, it serve...
07ff870eaf2efb60e1f99212dde4f6d013ee6ac976270560292d1dfdb2569fe2
MATLAB
1,821
39
for q =1 [Z_score]=xlsread('Test',q,'U:U'); %start point of the particular behavioral state [time]=xlsread('Test',q,'T:T'); %end point of the behavioral state [Object_exploration_start]=xlsread('Test',q,'A:A'); %start time point of object or neutral zone exploration (list of object exploration start and end times...
2b8d4896ab0ed90b2d7f418938f609da794920cad4075b4e003a9955e92b4bd1
MATLAB
1,821
68
% Author: Birgit Nierula % nierula@cbs.mpg.de %% other preprocessing wrapper script % --> ENG preprocessing clear; clc delete(gcp('nocreate')) % clear parallel pool %% variables that need to be changed % loop loop_number = 1 % subject, condition, and block info subject_idx = []; condition_idx = []; %% define var...
80e41d036978480422c6ab5bfdcaa1d1e88d6e71aa0e64709afae111a354e362
MATLAB
1,822
66
function img = makeRadialCheckerboardGradient(pixelsPerDegree, sz, phase, contrast, thetaCycles, E, A, b, gradientAngle, bgContrast) % % img = makeRadialCheckerboard(pixelsPerDegree, sz, phase, contrast, thetaCycles, E, A, b, gradientAngle, bgContrast) % % Schira 2007 J Neurophys: % M = 19.2./(abs(grid) + .77); % plot(...
d789bce6a49463255176ccfd00d28c5b2b84e4bad4a9ebc370c66fee3bcea1aa
MATLAB
1,822
63
% clear all close all clear variables % class frequencies: nk = 3; % number of classes p = 2; % dimension of the feature space n = 4e2; % sample size K = 32;ceil(n/2); % max number of classes %-- Generate n samples from a mixture of p-dimensional gaussians (MoG) mu = 1e3+ 1e3*randn(p,nk); % class means gamma= 1e5*o...
3eeb17172e6d24c3d2bcd668be8275fc712532a123df2fc113296e9e5095ad11
MATLAB
1,823
57
function model = treegmCreate(G, nodePot, edgePot, nodePotNdx, edgePotNdx, ... localCPDs, localCPDpointers) % Create a tree-structured graphical model % We assume all nodes are discrete and have the same number of states. % G is sparse adjacency matrix % nodePot(:,n) is potential for node of type n % edgePot(:,:,e) i...
c70d05b45521eff618a525298e6e74ada2d24b637ee11fa288145a28749f4b27
MATLAB
1,823
61
clear % close all Monkey = ['Monkey1']; % ['Monkey1' or 'Monkey2'] Base = ['PER_ON']; Align = ['PER_ON_long'] ; switch Monkey case 'Monkey1' load(['TEST_SpettroXCHANNELS_SD_base_' Base '_' Align '_B2b.mat']) C_lim=[-.40 .02]; case 'Monkey2' load(['TEST_SpettroXCHANNELS_SD_base_' Ba...
cf2dcd5319d7ffc8e999f19eec643a478be54d7ea28ced18f1caaed897bbcebd
MATLAB
1,823
64
%% Demo of simulated annealing on a 2D function % The so-called "six-hump camelback" function has several local minima % in the range -3<=x<=3 and -2<=y<=2. It has two global minima, namely % f(-0.0898,0.7126) = f(0.0898,-0.7126) = -1.0316. % This file is from pmtk3.googlecode.com %PMTKauthor Joachim Va...
48a09748b289ec54b81433e61c68af04eff1ca1b609ebdb6b0cdb2a2998319d9
MATLAB
1,825
73
% Author: Birgit Nierula % nierula@cbs.mpg.de %% SRMR1: ESG preprocessing - wrapper script clear; clc %% variables that need to be changed % loop loop_number = 8 % subject index subject_idx = []; %% define variables and paths % experiment srmr_nr = 1; % conditions if loop_number < 3 conditions = 1:3; el...
4f6181f498165a2fa64d7d5b7e6ee9d845b2063d604f10b3350ab660fce0c81f
MATLAB
1,825
44
function [S] = SAttenuation(opt,MSD,PathwaySignalFirstOrder,PathwaySignalHigherOrder,GwaveFirstOrder,GwaveHigherOrder,TransFirstOrder,TransHigherOrder); %% %Calulate exponential decay term E1 E1=exp(-opt.TR/opt.T1); %% %Calculate temporal spacing dt=(opt.TR*10^-3/opt.SpectraResolution); %Convert G to G/cm opt.G=opt.G/1...
a606b843eee3e546a8c0d896cd6e79bd92f3406a2b0e5e6ea2c18504f439e035
MATLAB
1,826
25
function p = sorw_GetSimulationParam(start_pos,L,A,shape,w,alpha,xi,nu,food_site,stopAtFood,delta_model,pmin,can_go_back) % .start_pos: 'N', 'S','W','E' -- starting position of mouse % .L: [width,height] of the arena % .A: adjacency matrix where each entry A(i,j) is the step probability between sites j->i (this i...
be4ccd0c4dbab8ff7b45feeacde4c5610e450e07f3706ef89d2d8a06c51b024d
MATLAB
1,826
44
%Purpose: Implement Hungarian Matching Algorithm for MSHBM and k-means parcellations %parcellations. %Inputs: MSHBM and k-means parcellations (run directly following %parcellation BEFORE visualization) %Outputs: Individual parcellations with matched values (e.g., network 1 is the same across parcellation methods. % %...
d1bfc28843c74d6422f203939313555caee717b592dc04c557012e651a111793
MATLAB
1,826
56
function x=klauder(N,lambda,f0) %KLAUDER Klauder wavelet in time domain. % X=KLAUDER(N,LAMBDA,F0) generates the KLAUDER wavelet % in the time domain % K(f) = e^{-2.pi.LAMBA.f} f^{2.pi.LAMBDA.F0-1/2} % % N : number of points in time % LAMBDA : attenuation factor or the envelope (default : 10) % F0 : centra...
6e4314c822d34377f4c146b45f877591b7576ee1de29207907a36c1e085908cb
MATLAB
1,827
46
function [parameters] = saveVelocities(parameters) % Give parameters their original names k = parameters.k; wheel_Hz = parameters.wheel_Hz; fps = parameters.fps; channelNumber = parameters.channelNumber; skip = parameters.skip; frames = parameters.frames; trial = parameters.trial; ...
7cab39672cb9903ff75e20b767148ab85206977399db808f664e3eccae970bfb
MATLAB
1,827
50
load('INS_dataStore_MkX.mat') [animalnames,iA,iC] = unique(INSDataTable(:,1)); JPSTHCell = cell(1,length(animalnames)); for ii = 1:length(animalnames) JPSTHCell{ii} = animalnames(ii); end pointer = 1; % while pointer<length(iC) nameList = INSDataTable(:,1); for ck = 1:length(JPSTHCell) searchWin = JPSTHCell{ck}...
b102e896f253d9f8297450ab71ba17dd384585edfafc55b721a58207aa940f26
MATLAB
1,827
58
function dzt=zak(sig,N,M) %ZAK Zak transform. % DZT=ZAK(SIG,N,M) computes the Zak transform of signal SIG. % % SIG : Signal to be analysed (length(X)=N1). % N : number of Zak coefficients in time (N1 must be a multiple % of N) (default : closest integer towards sqrt(N1)). % M : number of Zak coeffi...
c30dff9d80a42222eb0272a3cb145e9dbc5add85f5eef63b7f0058687d86124c
MATLAB
1,827
76
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % analyze data from current file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% str = char(Out{1,1}(5)); Nstr = length(str); for i = 1:Nstr switch str(i) case '[' i0 = i; case ',' i1 ...
fe6eef6118b1413901c5bbce3f442a273b74041b46386a54d9009b48caed72a8
MATLAB
1,827
86
function nX=normal(X,direction,criterion) % normal - normalize the data % nx=normal(X,direction,criterion) % % [Input] % -X: data % -direction: normalized dimension (default=1) % -1:mean of each column become 0 % -2:mean of each row become 0 % -criterion: baseline (default='min') % set ... to 0 % ...
0fa245d518e8d3e875f23941537a55045d480ceac336178abf9f41c9b9a06b08
MATLAB
1,828
62
% 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,...
0ffcc9ba96a71fe1e53df3e2f38c445067d12f8c753cfef55205fb8e4f45c6eb
MATLAB
1,828
91
function [fx,dF_dX,dF_dTheta] = f_dcm4fmri(Xt,Theta,ut,inF) % nonlinear DCM evolution function % function [fx,dF_dX,dF_dTheta] = f_dcm4fmri(Xt,Theta,ut,inF) % This function evaluates the evolution function of the neuronal states of % a nonlinear DCM for fMRI model. deltat = inF.deltat; n = size(Xt,1); [dxdt,J,dfdp] =...
40b3728902ffd6d9cd1a2eafb6e0e49e47f9fd4e2b528113395e87d7bd059a15
MATLAB
1,828
51
function gmodel = initGaussModelFlicker(sta, cellspikes, stiminfo, orderfit, ... spx, spy, ktbas, stascale) %UNTITLED Summary of this function goes here % Detailed explanation goes here stixelsForFit = 10 * stascale; rfac = 10 * 1.4826; [ypix, xpix, Nt] = size(sta); [~, imax] = max(abs(sta(:))); [y0, x0, t0...
d887d7f7a268dc6e5f8925310e9c3cbe9312b34a042a8ae092233693d89116f8
MATLAB
1,828
65
function varargout = compileAndRun(fname,varargin) % Compile a Matlab function via emlmex and then run the compiled version. % The function must reside in its own file and be eml compliant. See the % help sections on emlmex for details. % % fname - the string name of the function % varargin - arguments to the com...
e7faf4ae6fe06db52d71da2af92716e16be4f1f576c7d01b2fcc20afa4342b9a
MATLAB
1,828
57
function [innermost, inside] = find_innermost_boundary(bnd) % FIND_INNERMOST_BOUNDARY locates innermost compartment of a BEM model % by looking at the containment of the triangular meshes describing % the surface boundaries % % [innermost] = find_innermost_boundary(bnd) % % with the boundaries described by a struct a...
505e76fcbaa11068d3412fcc953939e139ca0f6be6fd1bde6bcf66170f797785
MATLAB
1,829
61
function LAN = lan_load_ref(LAN,REF) if nargin ==1 [FileName,PathName,FilterIndex] = uigetfile({'*.lanref','lan ref-file'; '*.mat','MATLAB mat'},'open lan ref - file','LAN.lanref'); if isequal(FileName,0) || isequal(PathName,0) disp('User selected Cancel') ...
6b23436bf4797e35dfa6f76036e5b9c313ad9860494c1174d4885e1da43240eb
MATLAB
1,829
57
close all clear all clc % ****************check these parameters before running******************** fc = [300 5000]; % cutoff frequency for band-pass filter ampthresh = 1; % amplitude threshold for waveform after adaptive filter, % adjust this parameter based on figure...
79ad2257f385c0aa78df3b353b044365c0fb2f017b7ac1abbb8b35a5f08374ea
MATLAB
1,829
48
function mni_coords = CBIG_RF_fsaverageVertex2MNICoord(hemi, vertices) % mni_coords = CBIG_RF_fsaverageVertex2MNICoord(hemi, vertices) % % This function takes in a vertex number or a list of vertex numbers, to convert to the % corresponding RAS coordiantes in MNI152 space. % % Note that this conversion uses the MNI152...
afdb75aeeba9b324731f877db82b5d5eadd9441b0e6335fe8c30526e4f9960a6
MATLAB
1,829
44
function [pValue,df,tStat] = pairedTforMeansSEM(data1,data2,SE1,SE2) % perform paired t-test on pairs of \mu \pm s.e. % Example paired data and standard errors % % history. chatGPT3.5 provided this in response to Daniel Wolpert's % conversation: three promtpts % 1. is there a weighted t test % 2. how can i do it in ma...
baf96a8143acc47757f09092c80e4741862b01451f4548621e27b87de83f4ee9
MATLAB
1,829
46
function test_avi_reading() % Test that reading frames from a .avi movie is order-independent: a frame read % out of order must return the same pixels as the same frame read in order. % get_readframe_fcn reads .avi via VideoReader, which may preload or cache to % speed out-of-order reads, so a frame's content must not ...
ea8f70fda1509be92b5f1ec3025e686e88cc701f639201e539def7b1bf8b196e
MATLAB
1,829
66
function [psig, lb, ub] = p_bt_voxelwise(w_boot, CI, plot) % for each voxel: obtain confidence intervals for each voxel (separately) % based on sorting the bootstrapped coefficients %%% Input parameters % w_boot voxelwise coefficients from models with bootstrapped data % CI confidence intervals that should ...
f3bdae88da17fb31abeab7c4f806fd3b388be9972994ba47bb5d652a0eee9ad2
MATLAB
1,829
65
function surf_to_tetgen(filename, nodes, elements, element_types, attributes_nodes,attributes_elements) % This function converts a triangulated mesh in FieldTrip format into a % surface structure readable by Tetgen software % Copyright Arno Jannsen, 2011 %Write the node file node_filename = [filename '.node']; precis...
8f8788c1173176c23a3e3a5bab3ad55dfea510b95d0aea024c7bd4248dd1ab00
MATLAB
1,830
64
function [ newevent, error ] = wlProc_fitFreqPhase( ... hilfreq, hilphase, oldevent) % function [ newevent, error ] = wlProc_fitFreqPhase( ... % hilfreq, hilphase, oldevent) % % This function estimates oscillatory burst frequency and phase by curve % fitting. Linear and logarithmic fits are performed, and the vers...
fc874429922d8386d4ae8991825db786a031edc2d3e629a94c8791736f8890cf
MATLAB
1,830
51
%% quicksdo % % A function to quickly get the SDO matrix (and covariance matrix) from a % prespike and postspike distribution, without the full SDO script. This % provides one variant of a matrix which satisfies the least-squares fit % between prespike-->postspike, but often subpar. % % Uses the V3 algorithm. ...
80fa3d7b76a05ffa819857c379d77a3c266b109214a14328f26ddfb6dbd91ab5
MATLAB
1,831
59
function [h, he, vline, hline] = plotCVcurve(lambdas, cvMeanErrors, cvStdErrors, lambdaBest, useLogScale, hline) % Plot a cross validation curve with error bars. % This is just a pretty version of the built in errorbars function. % % lambdas - the parameter values, e.g. regularization coeffs. % cvMeanErrors - th...
94f86fa8f45b1d90f0f3e13beeeecccf4671cbb60c5c0481721297d2cc094ecc
MATLAB
1,831
53
%% % ================= PARTICIPANT MEAN REACTION TIME ================= %% clear all; close all; clc; %% mean_rt = {}; idx=1; for s = 1:21 if s < 10 sub = strcat('P0',num2str(s)); else sub = strcat('P',num2str(s)); end dir_files = strcat('F:\SEM_mri_rawdata...
95e46dff519ad548edc9d1a02d9a1f882578035a847f975f47b474229d8387bf
MATLAB
1,832
69
%% Test to see if Newcomb's speed of light data is Gaussian % Similar to Gelman04 p77, except we use a plug-in approximation % See newcomb.m for the Bayesian version %% % This file is from pmtk3.googlecode.com setSeed(0); % Data from http://www.stat.columbia.edu/~gelman/book/data/light.asc D = [28 26 33 24 34 -44 27...
1142f3938b3feaab0ffb219cd4f3af077665f9e27f8a57071a03729e5f441874
MATLAB
1,833
43
%% reproducability analyses using Randy's split_half_PLS_TestTrain.m filename_modifier = "age_plus_cattell"; file_prefixes = [ "SC_age_CattellTotal_1000_its_594_subs_0_to_150_age_range"; "SC_le_age_CattellTotal_1000_its_244_subs_0_to_50_age_range"; "SC_le_age_CattellTotal_100...
588f120d6d2b9104033fe1afa35675c5ff98e02742cf5991d4081dbcec41e848
MATLAB
1,833
48
function order = surface_nesting(bnd, desired) % SURFACE_NESTING determines what the order of multiple boundaries is to % get them sorted with the innermost or outermost surface first % % Note that it does not check for intersections and may fail for % intersecting surfaces. numboundaries = numel(bnd); % determine t...
d5060a821a7c85ede247007db7fd569d15131ba53f7b660f380e188cc3045386
MATLAB
1,833
62
function [varargout] = write_ctf_shm(varargin) % WRITE_CTF_SHM writes metainformation and data as a packet to shared memory. % This function can be used for real-time processing of data while it is % being acquired. % % Use as % write_ctf_shm(msgType, msgId, sampleNumber, numSamples, numChannels, data); % % See also...
767a1ed86ee24b8dfd57e1147a6761eb1b97a75caf9087b3593a5afb8484747e
MATLAB
1,834
54
function [A2, C2, A2_BG, C2_BG] = component_split_with_background(A, C, A_BG, C_BG, shape, minSize, maxSize) % [A2, C2, A2_BG, C2_BG] = component_split_with_background(A, C, A_BG, C_BG, shape, minSize, maxSize) % Splits ROIs into connected components if(nargin<7) maxSize = Inf; end if(n...
bbae001600352484fa27e4ee52edfaf226b2da5efb5822c687d4c041128c9d93
MATLAB
1,834
75
function m = mfiles(source, varargin) % List all mfiles in the specified directory structure % %% Optional Inputs % 'topOnly' - if true, (default = false), do not descend into % subdirectories % % 'removeExt' - if true, (default = false) remove the '.m' extensions % % 'useFullPath' - if true, (defaul...
f40b3bfe9c8f12efc1a803108a9a940ce087011d5a50023112d40a5f81614dd7
MATLAB
1,834
45
% SCEs [pyrInSCE,intInSCE] = extract_variables ('SCE','cellsInSCE',resultsPath, 'pyr', 'int',conditionType,conditionValue); [pyr_id,int_id] = extract_variables ('nCells',[],resultsPath, 'pyr', 'int',conditionType,conditionValue); for recCounter = 1:size(pyrInSCE,2) data1_mdn(recCounter) = length(pyrInSCE{recCounte...
2e49fe2bed769930805ff738743579388079fd7db2986eaec2c424e7c1f788dd
MATLAB
1,835
49
% FT_POSTAMBLE_TRACKCONFIG is a helper script that calls ft_checkconfig to switch the % optional configuration tracking off and to report on the used and unused options % and/or clean up the output cfg structure. This should be used together with % FT_PREAMBLE_TRACKCONFIG. % % Use as % ft_preamble trackconfig % ......
673dc63daccb2762b919a2eb9c09b65bebe55d8ff702db6fafc933a3bca3b5b4
MATLAB
1,835
36
function test_DeepTrackerTopDown_twining() linux_project_file_path = '/groups/branson/bransonlab/apt/unittest/four-points-testing-2025-04-11-with-rois-added-and-fewer-smaller-avi-movies-lightly-trained-2-stages.lbl' ; [project_file_path, replace_path] = localize_test_project_path(linux_project_file_path) ; [la...
41c7d81668385d50a7b707087017892c201b4db5f10b27f1886b85914da62552
MATLAB
1,836
39
function [good_color_samples, good_color_dists] = mahalanobis_color_sampler(object_type, color_data, num_samples, threshold) % This function generates randome samples from a multivaraite Gaussian % distribution of RGB values which satify a condition on the Mahalanobis % distance from the color distributions and are wi...
38df018cb7856a4b14e5e35f80a8805ac2739a671aee3016df9d0f2d58705621
MATLAB
1,837
73
classdef WaitBarWithCancelCmdline < handle % Dummy waitbar cmdline only properties isCancel = false; cancelData = []; % Stack of running contexts. contexts(end) is the top of the stack. contexts = WaitBarWithCancelContext.empty(0,1) end methods function obj = WaitBarWithCancelCmdlin...
4afecdafeb72f0ddc461650a0248b5f6c35dc3bf78f2be4b4fac9b1d836566c8
MATLAB
1,837
35
function [params, doc_log_likelihood, q] = CBIG_EM_doc_e_step(w, paradigm, params) % [params, doc_log_likelihood, q] = CBIG_EM_doc_e_step(w, paradigm, params) % % Perform E-step of the Author-Topic model on each experiment (document). Note that % compared to CBIG_EM_doc_e_step_wc.m, this function takes in an argument...
74257a7b38bef91f9f0a590bab5841de1261d39d5e4266e9fb1733921d191687
MATLAB
1,837
64
function [] = save_LPFFD_GEVDV(subjExtractedTimeSeries,framwiseMotionVectorOutputDir) numSubjects = length(subjExtractedTimeSeries); if ~exist(framwiseMotionVectorOutputDir, 'dir') mkdir(framwiseMotionVectorOutputDir); pause(eps); drawnow; end for i = 1:numSubjects thisSubj = s...
2149d5902b32c1db305a757f4a9d3b4655d7111e34901969014a49f738e99f89
MATLAB
1,838
36
% Geometric distortions correction - apply topup script % Participants data data = dir('/DATAPOOL/ERRORMONITORING/SEM_mri_data/P*'); directions = '/DATAPOOL/ERRORMONITORING/SEM_mri_data/datain.txt'; %% for i = 1:size(data,1) data_func = dir([data(i).folder, '/', data(i).name, '/mri/SEM_', data(i).name, '/ni...
903c078d0021d9584a771f5178402cb0a61522896ffd70d6929580ecfdbf51bf
MATLAB
1,838
59
% demo for RFT simulations clear all close all clc %--- RFT: specificity L = 2e3; % size of the 1D field %N = 1e3; % number of Monte-Carlo simulations N = 100; fprintf( 'WARNING: this is a demo! The number of Monte-Carlo simulation should largely be increased (N~1000) for real simulations\n') disp_and_verbose = 1; ...
a642c7519a383382761e69dcd26984bc0a31c9aa74f9664acd411150aec81188
MATLAB
1,838
89
%LOADPGM Load a PGM image % % I = loadpgm(filename) % % Returns a matrix containing the image loaded from the PGM format % file filename. Handles ASCII (P2) and binary (P5) PGM file formats. % % If the filename has no extension, and open fails, a '.pgm' will % be appended. % % % Copyright (c) Peter Corke, 1999 Machin...
beaa05f1efd496f1c9cc103b05b7543b96a78cdd675a7c0babfbc8019eb3a697
MATLAB
1,838
62
function dgm = dgmFit(X, varargin) %% Fit structure and parameters of a DGM % % X is an N*D matrix of binary (0/1) values % % We use the L1MB+local search algorithm to find the structure % This uses L1-penalized logistic regression to fit the model. % See http://www.cs.ubc.ca/~murphyk/Software/DAGlearn/index.html % % W...
d374bf41ecb3b5ef6f63b9b7887a691bcde63a3927f16db272c47305fe863aa0
MATLAB
1,838
68
function model = svmQPclassifFit(X, y, C, kernelParam, kernelFn) % Support vector machine binary classification % y will be converted to a column vector of -1,+1 % PMTKauthor Steve Gunn % PMTKurl http://www.isis.ecs.soton.ac.uk/resources/svminfo/ % PMTKmodified Kevin Murphy % PMTKneedsOptimToolbox %% % This file is fr...
3fe4185007c6716de5205d31f5bd6105bc5941f11da43bdeaa727b99a55f04aa
MATLAB
1,839
62
function [varargout] = write_ctf_shm(varargin) % WRITE_CTF_SHM writes metainformation and data as a packet to shared memory. % This function can be used for real-time processing of data while it is % being acquired. % % Use as % write_ctf_shm(msgType, msgId, sampleNumber, numSamples, numChannels, data); % % See also...
69ce963d3be28254bb7e32c5b04b0a2c1aa73501a9d378a01955a924bd86aef6
MATLAB
1,840
64
%% dlyap % % Solve discrete-time Lyapunov equation by Schur decomposition % % <matlab:open('dlyap.m') code> % %% Syntax % % X = dlyap(A,Q) % %% Arguments % % See also <mvgchelp.html#4 Common variable names and data structures>. % % _input_ % % A square matrix with spectral radius < 1 % Q s...
55a09ddec3d690c0ba7ff13700bfd9eeb8e91b6ec850913565bc7da7b907a7c8
MATLAB
1,841
60
function opt = ft_setopt(opt, key, val) % FT_SETOPT assigns a value to an configuration structure or to a cell-array % with key-value pairs. It will overwrite the option if already present, or % append the option if not present. % % Use as % s = ft_setopt(s, key, val) % where s is a structure or a cell-array. % % Se...
ea18340ba27c13f960f5006128f980e8588cb84e1c5dc83b3fa722e677bf7bb9
MATLAB
1,841
60
function opt = ft_setopt(opt, key, val) % FT_SETOPT assigns a value to an configuration structure or to a cell-array % with key-value pairs. It will overwrite the option if already present, or % append the option if not present. % % Use as % s = ft_setopt(s, key, val) % where s is a structure or a cell array. % % Se...
21da59570c16c8544af5c94336963449e710351159484bdf1bb75a8a6bc8f240
MATLAB
1,842
58
% Load the file created by completionReport and visualize the results function completionReport_visualize(yamlfile, compReport_file) %Load the expResults struct load(compReport_file); %Use a YAML file to load the parameters for a large experiment yamlspecs = ReadYaml(yamlfile); %The YAML files might have extra quotes...
45cff728e79b87bade7cf6588c26f5c6397934d5f17d41b9cdb89203b1264897
MATLAB
1,842
59
function W0 = init_W_noise(P,W0,Y,seed) M = 1:length(W0); comps = size(Y{1},1); rng(seed) figure('color',[1 1 1],'visible','off') for mm = M % if mod(mm-1,8) == 0 tt = eye(size(W0{mm},1)); W0{mm} = W0{mm}+((tt)*(P*1e-2)*(rand(size(W0{mm}))-.5)); % else % W0{mm} = W0{mm-1}; % end ...
d12c24263cacaa6b155bcc3d7692377951330413be4a822be52b60f048d07a30
MATLAB
1,842
56
function sig=sigmerge(x1,x2,ratio); %SIGMERGE Add two signals with given energy ratio in dB. % SIG=SIGMERGE(X1,X2,RATIO) adds two signals so that a given % energy ratio expressed in deciBels is satisfied. % % X1, X2 : input signals. % RATIO : Energy ratio in deciBels (default : 0 dB). % X : output signal. % X= X...
e2f20abc2eb618ee11ce740683275df48b5968fc3f7abd9720f9e9aa860d50a1
MATLAB
1,842
70
function saveinr(vol,fname,stackInfo,write_row_major) % saveinr(vol,fname) % % savesmf: save a surface mesh to INR Format % write_row_major: if true we'll write in row-major fashion otherwise in % default col-major % % author: fangq (fangq<at> nmr.mgh.harvard.edu) % date: 2009/01/04 % % modified: Hamid Ghadyani hameed...
e643683da068cb49d9117de51163337d71cf50adcf4d77a1c658c7c3c530a9c8
MATLAB
1,842
38
function q = CBIG_EM_doc_inference(w, paradigm, params) % q = CBIG_EM_doc_inference(w, paradigm, params) % % Update the auxillary parameter q in the E-step on each experiment (document). % Note that compared to CBIG_EM_doc_inference_wc.m, this function takes in an argument % w of a different structure % FORMAT q = C...
79401aa8979c26552e75948d56f5fcd58a06be7862ec8a54fe02b0a1b525cf59
MATLAB
1,843
60
%% Gaussian plot with shaded tails % Plot a standard normal distribution and shade in the left and right tails % together representing alpha % of the probability mass. %% % This file is from pmtk3.googlecode.com function quantileDemo %scrsz = get(0,'ScreenSize'); %width = 2*scrsz(3)/3;student %height = ...
86723ec64020dbe92511b2ffd78c5afc50f12520b6af96c4736c7e2dbd7da08d
MATLAB
1,844
72
% This function functions like the build in MATLAB function csvwrite but % allows a row of headers to be easily inserted % % known limitations % The same limitation that apply to the data structure that exist with % csvwrite apply in this function, notably: % m must not be a cell array % % Inputs % % fil...
43a16118406e667e06a5db0eaa512f256a9ad790da40ab67a21adbcc617369d6
MATLAB
1,845
82
function [x,k,res,negCurv] = cg(A,b,optTol,maxIter,verbose,precFunc,precArgs,matrixVectFunc,matrixVectArgs) % [x,k,res,negCurv] = % cg(A,b,optTol,maxIter,verbose,precFunc,precArgs,matrixVectFunc,matrixVect % Args) % Linear Conjugate Gradient, where optionally we use % - preconditioner on vector v with precFunc(v,p...
7ddd8e08c3206b030e0bbe93ba438d715e6ab3556153ddefce59750814260ce3
MATLAB
1,845
58
% SRMR1-script: % edit('/data/pt_02068/analysis/final/scripts/SRMR1_02_eeg_prepro_appendedBlocks.m') %% EEG preprocessing wrapper script clear; clc delete(gcp('nocreate')) % clear parallel pool %% variables that need to be changed % loop loop_number = 1; disp(['loop number = ' num2str(loop_number)]) % subject, condi...
7f3e2ef59250d717221767bf8c35ad8bce3517be24173f979c1fbe9a9f9e4bcd
MATLAB
1,845
73
%% Visualize fitting a mixture of Gaussians to the old faithful dataset % reproduce Bishop fig 9.8 %% % This file is from pmtk3.googlecode.com function mixGaussDemo2d setSeed(0); K = 2; dataset = 'heightWeight'; if strcmp(dataset, 'faithful') X = loadData('faithful'); X = standardizeCols(X); maxIter = ...
955ff3ccfe83927935b5d0459c15ac33e61cafe0d9989f9c0625cb541bba0b42
MATLAB
1,845
69
%% plot_tsdata % % Time series data plotting utility % % <matlab:open('plot_tsdata.m') code> % %% Syntax % % plot_tsdata(X,leg,dt,trange) % %% Arguments % % See also <mvgchelp.html#4 Common variable names and data structures>. % % _input_ % % X multi-trial time series data % leg cell vector ...
d3620ccf078c6ce387d90d4c65860b7ecf6c85b5e2a954b2ddfe1a7154f200cf
MATLAB
1,845
70
function [s1] = scatJit(vec, jitFactor, col, circleSize, color) % Takes a vector and plots it as a jittered scatter around value col % Adam Claridge-Chang 20120411. Improved to modify jitter based on the % histogram % Adam Claridge-Chang 20120413 Further edited to use the bin % information to spread out the data even...
32e1b8194069818c3079a69766cacc4cfe3dc7cacd42a97ea11869378dc43d94
MATLAB
1,846
81
function [hi,px,gx,x] = plotGraph3D(px,gx,x,ha,va,norm) % plot image as a map in 3D % function [hi] = plotGraph3D(px,gx,x,ha,va) % IN: % - px: the pxn image to plot % - gx: the nX1 grid on the first dimension of px % - x: a 1Xp trajectory to plot onto the 3D surface % - ha: the handle of the parent axes % - v...
3de376da0b82ed2faf231e48024f133ccd6cdbc94ad9282407547ed8b191ee89
MATLAB
1,846
55
%% NBS FOR LOOP run per frequency band and contrast for t-threshold values of 0.05 uptil 4.6 %STEP 1: Start NBS %STEP 2: Select design matrix, frequency band datamatrix and contrats of choice %STEP 3: Set the t-threshold to the lowest value of 0.05 %STEP 4: Run NBS %STEP 5: Save NBS result under any name using the...
90adb72432d0485e18c51cd81d44a1dc1cade645f94e9c55e88ad3daaa190d85
MATLAB
1,846
55
function Y = cell2array( X, padEl ) % Flattens a cell array of regular arrays into a regular array. % % Each element of X must be a regular array, and must have the same number % of dimensions k. Converts X to an array Y of dimension k+1 where % Y(:,:...,:,i) is X{i} padded to be as big as the biggest element in X % (...
a274562dcfe77379bdf09acc5db76045a5171cf456baa1bdbadffb69669ffaee
MATLAB
1,846
54
function h = errorBarERP(EEG, elecToPlot, varargin) % function h = errorBarERP(EEG, elecToPlot, varargin) % use errorBarPlot on a subset of electrodes from EEG data (after epoching) % Inputs: EEG = eeglab structure after epoching % elecToPlot = cell array of channel names to plot % varargin: 'NAME...
bbe4e908afaf492e4403fada0338faaa7cf31388af973f2eae9fbcab0e03e45e
MATLAB
1,846
56
classdef ToyTracker < handle methods function trx = track(obj,trx,lpos,iPt,frm0,frm1) %#ok<INUSD,INUSL> % trx (input): current/existing trx (ignored for this tracker) % lpos: current labels (labeledpos): npts x 2 x nFrm x nTgt (expect % labels only for first target) % iPt: desired pt(s)...
dc7cf0b6e26dbbe7ab2d59794d377d2389d8fadf003a3dbfd22f45fe7c554939
MATLAB
1,846
59
%% Logistic Regression with RBF Basis % based on Bishop fig 4.12 % %% Parameters % This file is from pmtk3.googlecode.com mus = [0 0; -1 -1; 1 1]; sigma = 0.05; N = 100; pi = normalize(ones(1, 3)); centres = [-1 -1; 0 0]; sigmaRbf = 1; lambda = 0; addOnes = true; %% Generate some data from ...
bb86de3bdf7c8ad4fb53e05a7404f37e4c54ad827c3f956035e397ef95f61e39
MATLAB
1,847
46
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 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 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
3dc294d1e11b5b5b0d57d7ce21d1b1690dc7b0c9cc72ab0034a71684c8cd3cd5
MATLAB
1,848
67
function I_s = create_synapse_seg_mask(CC_combo,buffer,upperlim,xystep,zstep,imsize) %Creates mask for segmenting synapses by adding bounding boxes around connected components. %Excludes objects over the size limit vol = regionprops3(CC_combo, 'Volume'); % sortedVol = sort([vol.Volume], 'descend'); % tokeep = sortedVo...
6f5ef2bbfa6921318932890b7f5a1f2571feb87cce2fa51808aa87bfd72a7cd1
MATLAB
1,850
65
function u = nvecs(X,n,r,opts) %NVECS Compute the leading mode-n vectors for a ktensor. % % U = NVECS(X,n,r) computes the r leading eigenvalues of Xn*Xn' % (where Xn is the mode-n matricization of X), which provides % information about the mode-n fibers. In two-dimensions, the r % leading mode-1 vectors are the...
7e40b40af6596d15593e6fc09a2ed79ec6673a979b56015449702060f33437b5
MATLAB
1,851
81
%% Learn a sparse dictionary from image patches %PMTKauthor Julien Mairal %PMTKmodified Kevin Murphy % Needs SPAMS, available from http://www.di.ens.fr/willow/SPAMS/ % This file is from pmtk3.googlecode.com %PMTKslow clear all; methods = {'SPCA1', 'SPCA2', 'SC', 'PCA', 'NMF'}; %methods = {'SC'}; p=64; % number of b...
b13c8e38273ad84dd69945b08996a3d4715b30d67e6afd5b2379b85ca65f9deb
MATLAB
1,851
68
%% Compare SVM and kernelized logreg on synthetic 2 class data in 2d % This file is from pmtk3.googlecode.com %PMTKbroken %% Load Data % Load synthetic data generated from a mixture of 2 Gaussians. Source: % http://research.microsoft.com/~cmbishop/PRML/webdatasets/datasets.htm % if ~svmInstalled fprintf('cann...
0e702f8e678e2416770413ce3d5e48a74888de2f30b4464bd249b47d00a22545
MATLAB
1,852
50
% Analyse acoustic stimuli: Temporal & Spectral Power spectra clear; clc addpath(genpath('/brainstorm3/')); addpath(genpath('/utils/')) origDir ='/stim/' brainstorm nogui % key parameters norm = 1; % normalize volume (1|0) fs = 44100; fq = .2:.2:50; % 32 cf cd([origDir]); stim = dir('*.wav');stim = dir('*...
21ee2a0c66488561ef73bbdb013d403d52e6e091ccb34d7235d0817215143ac3
MATLAB
1,854
30
function [optScanner,optSample,optSSFP,optSTE,optSE] = ParameterOptionsSNR() %% %Scanner properties optScanner.MaxReadout=inf; % Maximum Readout Duration (ms) optScanner.GMax=1000; % Maximum Gradient Stength (mT/m) optScanner.gamma=2*pi*42.58*10^6; % Gyromagn...
2d6ef6c25f75654f9fba443c7e6e18e55daef41a95ec71d3744b356edf196f50
MATLAB
1,854
60
% StrideSegmentationLooper.m % Sarah West % 7/19/23 function [parameters] = StrideSegmentationLooper(parameters) % Inputs % parameters.timeseries -- % parameters.time_ranges -- MessageToUser('Segmenting ', parameters); timeseries = parameters.timeseries; time_ranges = parameters.time_rang...
558562210e8b9d13a42f2a436ec815f9b0aacbf4458b4fea7c90c753b0f662ed
MATLAB
1,854
71
%% Illustration of decision regions for the 3 class case % %% % This file is from pmtk3.googlecode.com domain = -3:0.01:13; sigma = 1.5.^2; r1 = gaussProb(domain, 0, sigma); r2 = gaussProb(domain, 5, sigma); r3 = gaussProb(domain, 10, sigma); linesize = {'LineWidth',2.5}; plot(domain,r1,'-r',linesize{:}); hold on; p...
62be545fc4ad63e86156a49df51a12b0340a7936ef05a6ac25a27db3c10d9e59
MATLAB
1,854
44
function [OPTIONS] = solver_options % SOLVER_OPTIONS Defines BiCGStab solver options. % % [OPTIONS] = SOLVER_OPTIONS Always returns structure with default % values of BiCGStab solver options. The OPTIONS structure have following % entries: % - OPTIONS.no_of_iter (default 1000) % Maximum number of BiC...
9cfe4a34e019f2a3672e0554a8890e1ce3c09a7092785e392a7a07f6ca135979
MATLAB
1,854
50
function segmentation = convert_segmentationstyle(segmentation, fn, dim, style) % CONVERT_SEGMENTATIONSTYLE is a helper function for converting between probabilistic % and indexed representations. It is used by ft_datatype_segmentation and % ft_datatype_parcellation. % % See also FIXSEGMENTATION, DETERMINE_SEGMENTATIO...
0a1cc6216dffc0f2c60d8a3b9b860fae95fd1c5061fa4efe77742124751729e9
MATLAB
1,855
100
% Cartoon: Single trial power vs phase consistency %% figure set(gcf,'Position',[100 100 300 400]) grey = cmocean('-gray',14); lineWidth = 1.5; lineWidthAvg = 2; xli = [-3.5*pi 3.5*pi]; clear y subplot 211 figureStyle hold on ylabel('Power') xlabel('Time') yticks('') xticks('') xlim(xli) ylim([-1 1]) x = -8*p...
82118dfdb5b8ff8413e7015a969e23fe844f8087131bb255d7967c268e03b63f
MATLAB
1,856
81
function [T, A2] = mk_grid2(nrows, ncols, psucc_act, obstacle, terminal, absorb, wrap_around, noop) % This is a simplified (non-vectorised) version of mk_grid_world % obstacle(i,j) is assumed to be 0 or 1 N = 1; E = 2; S = 3; W = 4; nact = 4; nstates = nrows*ncols; if wrap_around rows{N} = [nrows 1:nrows-1]; cols{...
2154cd656292144ba45615e37a72f26e89ed37e47e6e6e04cebee8bd3d510600
MATLAB
1,857
51
function [wsvd, wt,wx] = SVDRegressB(xx,xy,wdims,ps,lambda,opts) if (nargin >= 5) && ~isempty(lambda) xx = xx + lambda*speye(size(xx)); % add ridge penalty to xx end if (nargin < 6) || isempty(opts) opts.default = true; end if ~isfield(opts, 'MaxIter'); opts.MaxIter = 25; end if ~isfield(opts, 'TolFun'); op...
46d3e9788170757e2f6a40d9296a7e5531e1b29decdbab75eaae49151cda3b27
MATLAB
1,857
82
% Demo for Rossler oscillator. % This demo inverts a model of chaotic Rossler system, which is % observed through a nonlinear sigmoid observation function. clear variables % close all % Choose basic settings for simulations f_fname = @f_Rossler; g_fname = @g_sigmoid; u = []; n_t = 500; deltat = 5e-2; alpha...
5c4a7499db448dd4ff070103239f2ff2057ef40c0f46cd64088f161279ada7bd
MATLAB
1,857
36
%% Compute the amplitude envelope correlation as defined in Hipp et al. 2012 Nature Neuroscience % % input: - virtChan_timeSeries: cell array of EEG time series, each cell % should represent a single epoch/trial % output: - connMatrix: s x s x e matrix, containing the connectivity % matrices f...
819749a378a689d475d8a109c5bcab9d3526c771213d393aeb8be7bc38df060c
MATLAB
1,857
46
%% Plot Decision boundaries induced by a mixture of two or three 2D Gaussians % Based on code by Tommi Jaakkola % This file is from pmtk3.googlecode.com %% Two class linear model(1).classPrior = [1 1]/2; model(1).mu = [1.5 1.5 ; -1.5 -1.5]'; model(1).Sigma = repmat(eye(2), [1 1 2]); model(1).SigmaPoo...
85f51cd35846601024b209eead033b1d6c09ade832117c5eca81283906ea123c
MATLAB
1,857
63
function [pairwise_corr_median,pairwise_corr_mat] = pairwise_corr (traces,source_cells,target_cells,plotting) if nargin < 4 plotting = false; end corr_matrix = corr(traces'); if find(size(source_cells)==1)~=find(size(target_cells)==1) % if source and target vectors don't have same orientation source_cells = ...
dc1bcb895780417295bbcf3758ec946ce6de8ef3fd08712c54907359e5fec8d5
MATLAB
1,857
78
function staircaseAdjustment(contrast, tilt, detect, discrim) % % function staircaseAdjustment(contrast, tilt, detect, discrim) %% report current values fprintf('original contrast: %.2f\n', contrast) fprintf('original tilt: %1.1f\n\n', tilt) fprintf('detection: %d%%\n', round(detect*100)) fprintf('discrimination: %d%...
d2783ad44a4838cfcb40431f75846439e496c14bd7efb152a63b70000ca822b4
MATLAB
1,859
53
%https://www.mathworks.com/matlabcentral/fileexchange/36141-laplacian-eigenmap-diffusion-map-manifold-learning % Author: Kye Taylor %% create swiss roll data N = 2^11; % number of points considered t = rand(1,N); t = sort(4*pi*sqrt(t))'; %t = sort(generateRVFromRand(2^11,@(x)1/32/pi^2*x,@(x)4*pi*sqrt(x)))'; z = 8*pi*...
dcf7b71234aaa4302898ec094a5b7d521e4662a68ec65fa4976395360d94b0b1
MATLAB
1,859
66
function avgX = gibbsIsingGrid(J, CPDs, logprobFn, visVals, varargin) %% Gibbs sampling in a 2d Ising grid % J = coupling (edge) strength % CPDs{1}=p(y|x=-1), CPDs{2}=p(y|x=+1) % logprobFn is a handle to a function that will be called with % logprobFn(CPDS{i}, visVals(:)) % visVals should be an m*n matrix % Returns p(X...
0bc538a2edbf9418bd64c5146c5bf4dc3b30b4395c056c7b0476352a10be4e37
MATLAB
1,860
59
function res = innerprod(X,Y) %INNERPROD Efficient inner product with a sparse tensor. % % R = INNERPROD(X,Y) efficiently computes the inner product between % two tensors X and Y. If Y is a tensor or sptensor, the inner % product is computed directly and the computational complexity is % O(min(nnz(X),nnz(Y)))....
1d7c3a0837fda0304df83648ab1ffa2d567d65fa7cdb16fcd63b858d1ce172e9
MATLAB
1,860
91
function dat=readinr(fname) % vol=readinr(fname) % % readinf: load a volume from an INR file % % author: fangq (fangq<at> nmr.mgh.harvard.edu) % date: 2009/05/03 % % parameters: % dat: output, data read from the inr file % fname: input file name % % -- this function is part of iso2mesh toolbox (http://iso2mes...
5274b045f6a8711611dadbe21030f72c3d1452c37072d83d9d9f354ecb9d6aac
MATLAB
1,860
63
function FilledImage=SmartImageFill(Image,XCoords,YCoords,FillImage) % % Image=STORM_Images{length(STORM_Images)}.STORM_Image; % XCoords=[1286 7536] % YCoords=[144 6939] % FillImage=ones(6250,6250); error('DOESNT WORK!') XCoords=round(XCoords); YCoords=round(YCoords); ImageHeight=s...