sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
4614184872f11fb6636af448976e90f6f9453403c60818062653521ae277b912
MATLAB
1,345
51
%% NVR rejection of ICA artifacts components % 2017 (edited 2018) by Felix Klotzsche % 2024 update by Antonin Fourcade function NVR_08_rejcomp(cropstyle, mov_cond, path_data) %% 1.Set Variables %clc %clear all %1.1 Set different paths: % input paths: path_data_eeg = [path_data 'EEG/']; path_in_eeg = [path_data_eeg '0...
5a1ed2b39c153b148d56eabf5e4898d0231ef32770f82574cf3e05b0eabb1cdd
MATLAB
1,345
45
% demo for image registration close all clear variables % 1: create original 2D image [X,Y] = meshgrid(-2:.2:2, -2:.2:2); Z = X .* exp(-X.^2 - Y.^2); inG.Y = Z; [nx,ny] = size(inG.Y); % 2: dis-align original image with rotation & translation phi = [2;-2;-1]; sigma = 1e6; [gx] = g_ri...
b2c0664bb3b21e47057b54c17bb0233fb62c2a6eab1caafd6bd99e4b18d5345a
MATLAB
1,345
67
function trialstarts = wlFT_getTrialStartSamples( ftdata ) % function trialstarts = wlFT_getTrialStartSamples( ftdata ) % % This extracts the continuous-data sample indices of the first samples of % each trial in a Field Trip dataset. % % This is the first column in ftdata.sampleinfo or ftdata.trialdef or % cfg.trl. %...
c535e852b88066216b1ac0a22daf76ce8279b37f3650bda832367a0ee7146ebf
MATLAB
1,345
45
function params = genParams(varargin) %GENPARAMS Summary of this function goes here % Detailed explanation goes here % initialize the input parser input = inputParser; % define input validation functions validScalar = @(x) isscalar(x) && (x >= 0); validInt = @(x) validScalar(x) && (mod(x, 1) == 0); % simulation in...
d9dff01e1629a55d9b235d2b291ee3408078c8b771d368a055f3f4f87967cd3b
MATLAB
1,345
55
function Ximpute = imputeKnn( X, K, distMeasure ) % imputeKnn: Impute missing values using mean of k nearest fully observed neighbors % We only compute distance based on the features that are observed in current row % This file is from pmtk3.googlecode.com %PMTKauthor Hannes Bretschneider if nargin < 3 distMeas...
d646729eb84ab0d15df397d64ce441e8828157d637011971b585e1a4634616f8
MATLAB
1,346
44
% Load data load(fullfile(saveLoc, 'cosine_sim'), 'cosine_sim') % load(fullfile(saveLoc, 'resCorr_wiTrial'), 'rz_sess'); load(fullfile(saveLoc, 'single_trial_corr')) rho = cat(3,C.rho); rz_sess = nanmean(rho,3); % load(fullfile(saveLoc, 'cosine_sim_randperm'), 'cosine_sim_randperm') % cosine_sim_randperm(...
e42fbc8ca878f88e4b89df504c5b64d2ab12edf02b759f4304869be7e6e672fe
MATLAB
1,346
36
classdef TestArgs <handle methods(Static) function argsObj=Umap argsObj=UmapUtil.GetArgsWithMetaInfo('eliverLabeled.csv', ... 'label_column', 'end', 'n_neighbors', 17, ... 'match_scenarios', [1 2 4]); msg(argsObj.getArgumentClinicPanel); he...
509dfef50dc8e3112932e5c4c4228450c409e843d7721e9afa6a14cf0c6fabd8
MATLAB
1,347
42
Tassembly_logic = zeros(size(CellCl,1),size(Tracecellsdf,2)); for assemblyCounter = 1:size(CellCl,1) assemblyActiv{1,assemblyCounter} = TRace(find(PCl(assemblyCounter,:))); Tassembly_logic(assemblyActiv{1,assemblyCounter}) = 1; end r_class2 = zeros(size(TraceClass2df,1),41); r_class1 = zeros(size(TraceClass1d...
6e35f84fe3bcfb69e8c35670d498b2654a4bb204aaf98d74b5c4cd762ea82709
MATLAB
1,347
50
%% Prepare continuous EEG data for export to MNE % Rejection of ICA artifacts components % % 2024 by Antonin Fourcade function NVR_13_eeglab2mne(cropstyle, mov_cond, path_data) %% 1.Set Variables %clc %clear all %1.1 Set different paths: % input paths: path_data_eeg = [path_data 'EEG/']; path_in_eeg = [path_data_eeg ...
860f5e9cacb49ef06ac23220b6f04deaebe617586f6c50dbf3ffe599d5d4dfb3
MATLAB
1,347
72
function med = circ_median(alpha,dim) % % med = circ_median(alpha) % Computes the median direction for circular data. % % Input: % alpha sample of angles in radians % [dim compute along this dimension, default is 1, must % be either 1 or 2 for circ_median] % % Output: % mu mean dire...
fc01378789b816c3a717d34a6088eaa187cb965c3fa61143ad8075fb60c5d6c8
MATLAB
1,347
47
function cm = set_redblue_colourmap( ax, clmin, clmax, N ) %%function cm = set_redblue_colourmap( ax, clmin, clmax, N ) % % if nargin < 4 || isempty(N) N = 64; end % scale to sensible order of magnitude min_scale = floor(log10(abs(clmin))); clmin = clmin*10.^-min_scale; max_scale = floor(log10(abs(clmax))); clma...
d81e51a08974cac4799d9fa6ca905df2a83fd73440dfb77c95426dae8d0b4850
MATLAB
1,348
55
%% Least means squares (Widrow-Hoff) Demo % %% % This file is from pmtk3.googlecode.com [X,y]=contoursSSEdemo; % makes data X, y and plots surface d = 2; w0 = [-0.5;2]; % randn(d,1); options.batchsize = 1; options.verbose = true; options.storeParamTrace = true; options.storeFvalTrace = true; options.maxUpdates = 20...
d4d7b41135740c405bc5789510dfe362f006f9e8c3f000a9282d0b7c99f1ddf4
MATLAB
1,349
36
% PSTH computes the PSTH of a single spike train % Equations from Aertsen et al. 1989 % psthMean: Equation 1 % psthStdDev: for Equation 7a % psthVariance: for Brody Covariogram % psth.m % % Copyright 2008 Vanderbilt University. All rights reserved. % John Haitas, Jeremiah Cohen, and Jeff Schall % % This file is ...
19dafc20345105307a44f100a198db227efe58358dd55386ae3ad910ec3b6a14
MATLAB
1,350
39
clear all; close all; clc; % import table T=readtable('PatientData.csv'); % Memory recall DV=T.MemoryTask2-T.MemoryTask1; % compare values between groups [p h stats]=ranksum(DV(T.RandomisationOrder==1), DV(T.RandomisationOrder==2),'method','approximate') % baseline difference [p h stats]=ranksum(T.MemoryTask1(T.Ran...
3a8bb6fae66cec098c3a9241869006d8efa145f50c4517a0ac568a0af1e40167
MATLAB
1,350
49
% Get subpopulation rate (spikes/s) as a function of time % Run this script on the HPC cluster. Specify the data path accrodingly and % load the file of interest. Then copy the saved file on local machine % before running 'plot_subpopulationRateDifference_perDisc.m' clear all close all clc % Data path on the HPC c...
de7d9617869c80c6009c15b9b8dfaaaff0ef8f0fbd5d3fa359c8deec005af45c
MATLAB
1,350
44
function a = reshape(a,new_size,old_modes) %RESHAPE Reshape sparse tensor. % % RESHAPE(X,SIZ) reshapes the sparse tensor to the given size. PROD(SIZ) % must be the same as PROD(SIZE(X)). % % RESHAPE(X,SIZ,MODES) reshapes only the specifies modes and appends the % new reshaped modes to the end of the indices. % %...
e8123ce8bdd16e0a2f371492f06da03161342086454cb0c84f4b6aef1c83868c
MATLAB
1,350
79
%% bigdom = [1 2]; Tbig = reshape([1 2 3 4], [2 2]); %smalldom = [1 2]; %Tsmall = reshape([5 6 7 8], [2 2]); smalldom = [2 1]; Tsmall = reshape([5 6 7 8], [2 2]); %smalldom = [1]; %Tsmall = reshape([5 6], [2 1]); T = bsxTable(@times, Tbig, Tsmall, bigdom, smalldom); TT = zeros(2,2); for i=1:2 for j=1:2 %TT(...
09b44bc909b1a04b79534151e979f059319aae00a349d4565a6bd86a33cb1d3b
MATLAB
1,351
49
function wlPlot_plotPowerAndPersist(cfg, wave, fmin, fmax, ... figtitle, filelabel) % function wlPlot_plotPowerAndPersist(cfg, wave, fmin, fmax, ... % figtitle, filelabel) % % This function plots power spectral density and a persistence spectrum % for the specified waveform. % % "cfg" contains figure configuration...
72c958b03ac951ede7c4b4925810f27aef9307e3a76e3d230b75932af1ecf055
MATLAB
1,351
47
% MF_CHOLMV Multiply using Cholesky factor from multifrontal factorization. % % Typical complexity: about half that of MF_MV. % % Y = MF_CHOLMV(F,X) produces the matrix Y by applying the Cholesky factor C % of the factored matrix F = C*C' to the matrix X. Requires that F be % computed with the Hermitian po...
b0f43cd97ebe75d8f8a76117d45a21d160e9dd7d6c80049f975a97a57da5ab71
MATLAB
1,351
34
function h_makeZoomInBox3(handles, factor) [currentInd, handles, currentStruct, currentStructName] = h_getCurrendInd3(handles); h = currentStruct.gh.currentHandles.imageAxes; delete(findobj(h, 'Tag', 'zoomInBox3')); xlim = get(h,'xlim'); ylim = get(h,'ylim'); offset(1) = diff(xlim)/factor; offset(2) = di...
d9b2d7a125785cbbe76277194f27667e48dd8d3cdcbe257d6525038b4b893cb0
MATLAB
1,351
39
function ehess = essential_ehessE2ehess(X, egradE, ehessE, S) % Converts the Hessian in essential matrix E to the Hessian in X. % % function ehess = essential_ehessE2ehess(X, egradE, ehessE, S) % % egradE is the function handle for the gradient in E. % ehessE is the function handle for the Hessian in E. % S is t...
7c0415c09dcfd4f2e59f866ac116e482c4af74027c404df9cd8fb531c933333b
MATLAB
1,352
38
function [ gx ] = g_HGFinGame(x,P,u,in) % observation function for HGF learner engaging in dyadic games % [ gx ] = g_HGFinGame(x,P,u,in) % In a game, a HGF learner bases her decision (a=1 or a=0) upon her % prediction of her opponent's next move, given the game payoff table. NB: % HGF tracks the probability that her op...
443c2a127c3383e09fa6a024df763ad3860f491563d49a98505149eef8b02e0c
MATLAB
1,353
42
%% Plot mean Fc figure('units','inches','position',[10 10 6 4]); count = 0; for i = 1:length(unique(bins)) count = count+1; subplot(2,3,count); rmat = mean(rmatGroupMean(IM.order,IM.order,bins==i),3); Matrix_Org3(rmat,... IM.key,10,[-0.3,0.3],IM.cMap,0); title(grouplabel{i}); set(gca,'FontSi...
5529db69ed22cbcbd5afac503f529a04c8b0b225f894719630f6133f654fede2
MATLAB
1,353
59
function mesh = make_circle(sizevar) % mesh = make_circle(sizevar) % % Creates a 2D circular mesh % % sizevar.xc - x coordinate of the center % sizevar.yc - y coordinate of the center % sizevar.r - radius % sizevar.dist - distance between nodes % error checking if ~isfield(sizevar,'xc') || ~isfield(sizevar,'yc') ......
826f5d10f110bafb14301450e4f73bbfd7b44e0d4d862bee862021f84bcc8ae5
MATLAB
1,353
58
% Usage: % h = createsubplots(nrows,ncols,border) % h = createsubplots(nrows,ncols,[borderx,bordery]) % h = createsubplots(nrows,ncols,[[sideborderx, middleborderx];[sidebordery, middlebordery]]) % h = createsubplots(...,[hfig]); function h = createsubplots(n1,n2,border,hfig) if nargin == 0, error('usage: createsubp...
9f67030f1b7c9d15ba6675d6077ca64dacd1899673a3e4e7dcd247308a7dcabd
MATLAB
1,353
41
function [ImageArray,MetaData]=CZI_Importer(FileName) TempMeta=czifinfo(FileName); MetaData = GetOMEData(FileName); if any(strfind(TempMeta.genInfo.pixelType,'16')) MetaData.BitDepth=16; elseif any(strfind(TempMeta.genInfo.pixelType,'8')) MetaData.BitDepth=8; end if M...
a6397cc45f47f51085c0fee0fc4ca81fbe9455521362ab14d00b1cd1a916a119
MATLAB
1,353
38
function b = multihconj(a, dim) %MULTIHCONJ Hermitian conjugating arrays of matrices. % B = MULTIHCONJ(A) is equivalent to B = MULTIHCONJ(A, DIM), where % DIM = 1. % % B = MULTIHCONJ(A, DIM) is equivalent to % B = PERMUTE(A, [1:DIM-1, DIM+1, DIM, DIM+2:NDIMS(A)]), where A is an % array containing...
d4e811996e891163ab986c22b0dc0885940c09c306887bff5ea61ca7cdc80b52
MATLAB
1,353
38
%% Fit a mixture of Gaussians comparing mixModelFit and dgmTrain % %% % This file is from pmtk3.googlecode.com setSeed(0); nstates = 3; d = 10; nobs = 100; %% initialize both models the same mu0 = randn(d, nstates); Sigma0 = zeros(d, d, nstates); for i=1:nstates Sigma0(:, :, i) = randpd(d) + 2*ey...
dc3ac8b39d1de120ed5523c813387cca250b6535057961c6768be5ed9592e44c
MATLAB
1,353
73
function TF = shouldAutomateStop(self, channel) arguments self (1,1) crabsort channel (1,1) double end TF = false; if self.automate_action == crabsort.automateAction.none TF = true; return end M = self.handles.menu_name(4).Children; Checked = {M.Checked}; % should stop if artifacts are marked if strcmp(Checked...
1bf1f809aa192ff78cccf5926c78a3d487c3250397a69cdc327600629c8e78e0
MATLAB
1,354
35
function [inside, outside] = find_inside_vol(pos, vol) % FIND_INSIDE_VOL locates dipole locations inside/outside the source % compartment of a volume conductor model. % % [inside, outside] = find_inside_vol(pos, vol) % % This function is obsolete and its use in other functions should be replaced % by inside_vol % C...
1d029c8cbc5ebc60999b846ea998c63ae24e73a83dcf3cce430c350ea7715767
MATLAB
1,354
33
% Wrapper script to turn parcellation files into FreeSurfer annotation % files. Then you can calculate surface area of parcellations! % % Assumes ind_parcellation output from Kong2019 CBIG pipeline. % Written by M. Peterson, Nielsen Brain and Behavior Lab %To run: % 1. Claim computing resources using salloc (ex: `sa...
5f6d241e2367d2b37dc99e2b75841c29a05713798ac406871a138e32f4a69ec7
MATLAB
1,354
46
%% Test calcium sensitivity on calcium transient and active tension %% Setting parameters clear clc close all param.bcl = 800; % basic cycle length in ms param.model = @model_ToRORd_Land; % which model is to be used param.verbose = true; % printing numbers of beats simulated param.cellType = 1; % 0 endo, 1, epi, 2, mi...
f149a99d6a91e4136c7f355e26c50e27a1fb33ab564247b1d6b3158fe0e2f842
MATLAB
1,354
48
function [logZ, nodeBel, edgeBel] = bruteForceInferNodes(factors, edges) % Compute all node marginals given a set of factors using enuemration % We assume all nodes are discrete and have the same num states % factors{f} is a tabular factor % % logZ is log normalization constant % nodeBel(:,t) % % Optional: if you pass...
136aaa4880b90e4f7508897dd7f31788c1c99b97ca3edc7b8628a7c484527242
MATLAB
1,355
46
function afxLnmTTest(images,fnameOut,nCond) if exist(fnameOut,'file') fprintf('afxLnmTTest: %s already exists.\n', fnameOut); return; end Vi = spm_vol(char(images)); Vo = struct(... 'fname', [],... 'dim', Vi(1).dim(1:3),... 'dt', [spm_type('i...
83397337dff101d8795375f2a92f12c4b2a5618f440e3982be045a146b055a7f
MATLAB
1,355
43
function value = loadvar(filename, varname) % LOADVAR is a helper function for cfg.inputfile % Copyright (C) 2010, Robert Oostenveld % % $Id$ assert(ischar(filename), 'file name should be a string'); if nargin<2 fprintf('reading variable from file ''%s''\n', filename); else assert(ischar(varname), 'variable nam...
e01f3efaac7aaad54af59880f6461d9dcf02af7355cf5ebb11b9776d85d456a8
MATLAB
1,356
48
% this function recompiles all .c scripts to create the apropriate .mex* files on your local machine %NOTE: current directory must be the buzcode base directory buzpath = pwd; addpath(genpath('externalPackages')) compilefma % compiles FMAToolbox try cd(['externalPackages' filesep 'FilterM' filesep '']) catch di...
e0367659b06a405bf1f02ee6078ad995fab69ecb048f88eb8992b423c4e9f279
MATLAB
1,356
69
function flag = AnnotateSig(fig, xVal, pVal, pCriterion, contCriterion, barColor, varargin) barDrop = 0.05; barWidth = 8; returnPts = false; flag = false; annotate = true; for i = 1:2:length(varargin) switch lower(varargin{i}) case 'bardrop' barDrop = varargin{i+1}; case 'barwidth' ...
ec822051f0f4fad0d3c0314c758b387441c272751c28263baf91248e006ac316
MATLAB
1,356
52
%% Grid world MDP % Based on Russell and Norvig 1995 ch 17 (p501) % 2010 version p648 % (1,1) is top left corner. % actions: 1 up, 2 ->, 3 down, 4 <- r = 3; c = 4; p = 0.8; action_cost = -1/25; % get to +1 %action_cost = -1.65; % get out quickly obstacle = zeros(r,c); obstacle(2,2)=1; terminal = zeros(r,c); terminal...
2c3fcdf641c6db6180dfe9f7aa03130163e2de9bdaa1597308ab5c8ab5be397d
MATLAB
1,357
35
%% memory color decoding and truefalse color decoding for color patches clear clc load(['data.mat'],'all_monkey_single_mean','all_monkey_single_sd','all_monkey_accuracy_perrun','each_monkey_single_mean','chance_level','nROI'); face_color = [200/255,36/255,35/255]; face_alpha = 0.75; name = 'memory_color_decoding...
46a97ec2e1bdddbecef4e25f21a59a1c5b4e14733a5c63f669e535e919c6f42e
MATLAB
1,357
52
function [style, colors] = meg_manuscriptStyle % parameters for reproducing manuscript figures style.widthTS = 470; style.widthScatter = 300; style.height = 300; style.ebLineWidth = 0.2; % line width of shaded error bar edges % scatterplots style.xBuffer = 1; style.xBufferSml = 0.2; style.scatter.MarkerSize...
49ea3b5fd568e3de5c0e853694e71a8af76b4e833768be8cb9ee6ebc68bc022c
MATLAB
1,357
43
clear close all clc %% Load atlas % path to MRI template - must include hdr and img files atlas = niftiread('/Users/jstrohl/Documents/20230908 Pipelines for neural data analysis/Dependencies/ATLAS-MICE 2/2011-10-30_MRI-template3.hdr', ... '/Users/jstrohl/Documents/20230908 Pipelines for neural data analysis/D...
836861a0796bdfcf055bbee8194b904643dbe5c61cc989d900ffd96031c2d3fb
MATLAB
1,357
43
clear close all clc %% Load atlas % path to MRI template - must include hdr and img files atlas = niftiread('/Users/jstrohl/Documents/20230908 Pipelines for neural data analysis/Dependencies/ATLAS-MICE 2/2011-10-30_MRI-template3.hdr', ... '/Users/jstrohl/Documents/20230908 Pipelines for neural data analysis/D...
90885da5f32017d2f48d4a6285ca0a5613f85a6ac623e0a95a8a3aa6c12c9b86
MATLAB
1,357
43
function out = h_autoGetPAROI3(header) pos = eval([header.init.eom.powerBoxNormCoords]); if ~isempty(pos) if size(pos,1) == 2 beam = 2; else beam = 1; end pos = pos(beam,:); pos([1,3]) = pos([1,3]) * header.acq.pixelsPerLine; pos([2,4]) = pos([2,4]) * header.acq.lines...
c94161ff368ccd739c1c38ac767af0d1ee6724aca494b691e47a6fd30b613287
MATLAB
1,357
44
%% local renormalization approach (no mask) %blur out all features, leaving just a local scaling factor sd = 200; gFilter = fspecial('gaussian', 4*sd, sd); blurred = imfilter(imgToFilter,gFilter,'replicate'); imgRenormed = imgToFilter*max(blurred(:))./blurred; figure;subplot(1,3,1);imagesc(imgToFilter);subplot(1,3,2);...
eac174193c7512203005f8100ea25754d6429836d0f651609cf2d551abc27b03
MATLAB
1,357
47
function ps = normpdf2( xs, m, C ) % Normal prob. density function (pdf) with arbitrary covariance matrix. % % Evaluate the multi-variate density with mean vector m and covariance % matrix C for the input vector xs. Assumes that the N datapoints are d % dimensional. Then m is dx1 or 1xd, C is dxd, and xs is dxN or Nx...
f01cccbd6ce1b16deeb69bad0d8645907469b099fe17660c2d6c71d75a02625a
MATLAB
1,357
55
% bw = ellipsepixels(params,bb) % params: vector of length 5 describing the ellipse, where % params(1) is the x coordinate of the center % params(2) is the y coordinate of the center % params(3) is the major axis length % params(4) is the minor axis length % params(5) is the orientation % bb is a vector of length 4 des...
6eab1047351fad2a9c7bc97bcba8625b096f2d9519dce6c0657a807b6b97bf51
MATLAB
1,358
54
function dat = read_spike6mat_data(filename, varargin) % read_spike6mat_data() - read Matlab files exported from Spike 6 % % Usage: % >> header = read_spike6mat_data(filename, varargin); % % Inputs: % filename - [string] file name % % Optional inputs: % 'begsample' first sample to read % 'endsample' ...
25afed6bf7acfc8a4d767b6e148611e47021037d0d4f3ba02933e4691b2d3127
MATLAB
1,359
72
%% Error surface for linear regression model % Based on code by John D'errico %https://www.mathworks.com/matlabcentral/fileexchange/8553-optimization-tips-and-tricks?s_tid=prof_contriblnk % This file is from pmtk3.googlecode.com function [X,y] = contoursSSEdemo(varargin) if nargin == 0 doPlot = true; else ...
487c109d35abf3fbd28a08cd828e76722988e4946f6bf713e1c40e8fba3c9c9e
MATLAB
1,359
57
function varargout = eval_network(net, init_condition, v_u_t, m_target_t) %% Setup. % Network structure. [n_Wru_v, n_Wrr_n, m_Wzr_n, n_x0_c, n_bx_1, m_bz_1] = unpackRNN(net, net.theta); [V,T] = size(v_u_t); [M,N] = size(m_Wzr_n); % Transfer functions. rec_transfun = net.layers(2).transfun; out_transfun = net.layers(3)...
b3684861eab60a7ed2c01b61a51f79554d34b55564a73d988db2107728ef0332
MATLAB
1,359
48
%% Visualize the MNIST digits and a version where we permute the pixels % %% % This file is from pmtk3.googlecode.com loadData('mnistAll') % already randomly shuffled across classes % train_images: [28x28x60000 uint8] % test_images: [28x28x10000 uint8] % train_labels: [60000x1 uint8] % test_labels: [10000x1 uint8] se...
d41f6171bee14c96ad6fdde18302423e159c6c2edb99af4fad7fdf137d70c6a5
MATLAB
1,359
50
function [z, mu, sigma] = VBA_zscore (x, flag, dim, omitnan) % // VBA toolbox ////////////////////////////////////////////////////////// % % [z, mu, sigma] = VBA_zscore (x, flag, dim, ignore_nans) % standard score, aka z-score % % Compute the stardardized zscore of x, ie z = (x - mean(x)) / std(x) % % IN: % x: vector...
1ebfb464c1ec15a828d933d695003986f477a6d242a9cdeb46ac0e6533bba2c5
MATLAB
1,360
47
% fastif() - fast if function. % % Usage: % >> res = fastif(test, s1, s2); % % Input: % test - logical test with result 0 or 1 % s1 - result if 1 % s2 - result if 0 % % Output: % res - s1 or s2 depending on the value of the test % % Author: Arnaud Delorme, CNL / Salk Institute, 2001 %123456789012...
30d10d96ee48dab97316b31939348501b69d43ff51cc3bbf42c3e974d842bf72
MATLAB
1,360
40
function varargout = ft_error(varargin) % FT_ERROR prints an error message on screen, just like the standard ERROR function. % % Use as % ft_error(...) % with arguments similar to fprintf, or % ft_error(msgId, ...) % with arguments similar to error. % % See also FT_ERROR, FT_WARNING, FT_NOTICE, FT_INFO, FT_DEBUG, ...
6aa36dd0daa0dfd449b8ac24d64efac50cf8403fd0e6a2ae910099576c459ca0
MATLAB
1,360
29
%function calib_gui(mode) % calib_gui(mode) % % Runs the Camera Calibration Toolbox. % Set mode to 1 to run the memory efficient version. % Any other value for mode will run the normal version (see documentation) % % INFORMATION ABOUT THE MEMORY EFFICIENT MODE FOR THE CAMERA CALIBRATION TOOLBOX: % % If your calibratio...
8158ceb398ae58a36760c3e1a7d298d609d703a954fc4b3c45c0cfc90bc72d9e
MATLAB
1,360
25
%% Circle disp('######################################'); disp('#### Design a circular trajectory ####'); disp('#### ####'); disp('######################################'); disp(' '); C = exp(i*2*pi*linspace(0,1,512)')*10; C = [real(C) imag(C) 0*C]; [C_riv, time_riv, g_riv, s_riv, k_riv] ...
9a7eaaa4328bac086ebce07b8ad3974a8bc504acaa8deedc328881dee30c3b9c
MATLAB
1,360
42
function Iout=movepixels_2d_double(Iin,Tx,Ty,mode) % This function movepixels, will translate the pixels of an image % according to x and y translation images (bilinear interpolated). % % Iout = movepixels_2d_double(I,Tx,Ty,mode); % % Inputs; % Tx, Ty: The transformation images, describing the % ...
b9131f6596b9179264921ffd0484252cafbdf2a38c310b6ebb769b538262c80d
MATLAB
1,360
47
function [xd, dxd_dx] = apply_fisheye_distortion(x,k) %apply_fisheye_distortion.m % %[x] = apply_fisheye_distortion(xd,k) % %Apply the fisheye distortions % %INPUT: x: undistorted (normalized) point coordinates in the image plane (2xN matrix) % k: Fisheye distortion coefficients (5x1 vector) % %OUTPUT: xd: dist...
2a90bb31d3b3e682e9bff81499732abd9ee57dcbb69e8aede0da0d5fe74d081f
MATLAB
1,361
42
function [myPool]=ParPoolManager(StartPool,myPool) warning on all warning off backtrace warning off verbose if isempty(StartPool) PoolChoice = questdlg('Start Parallel Pool?','Start Parallel Pool?','Start','Skip','Start'); if strcmp(PoolChoice,'Start') StartPool=1; ...
a29e7c17e7862e7760f2b14c51b183e7e8c6de6f516c4c657803366764f69bbf
MATLAB
1,361
48
%% Analysis of binomial differences % PMTKneedsStatsToolbox ksdensity % Based on http://www.johndcook.com/blog/2011/09/27/bayesian-amazon/ % See also unpairedTestHandednessDemo % This file is from pmtk3.googlecode.com clear all requireStatsToolbox setSeed(0); y1 = 90; n1 = 100; y2 = 2; n2 = 2; [deltas, post, thetas...
0ce2f9ba9ce2f0ccea490879b044833fc67d01ede6431f18ab9465cbde370ff2
MATLAB
1,362
64
disp("This is an example matlab driver for the stokes fmm"); disp("On output the code prints the pot+pre+grad in example1 and, pot+pottarg+pre+pretarg in example2"); disp(" "); disp(" "); %% source to source, stokeslet only, pot+pre+grad example % clear srcinfo ns U eps pg; disp("Example 1: source to source, stokesl...
1a46db0bdfa356e9ce3f2896d6350d8e264df1be3f8016143ebbaa23c1305c30
MATLAB
1,362
50
function varargout = get(tpl,action,varargin) %TEMPLATE/GET Access data stored in a Template object % TPL = GET(TPL,ACTION,VARARGIN) % ACTION 'var' % ACTION 'undefined' % Copyright (C) 2003 Guillaume Flandin <Guillaume@artefact.tk> % $Revision: 1.0 $Date: 2003/05/05 22:19:51 $ narginchk(2,3); switch lower...
2bf2ceb48074af1863bf4c9571e4111b85f65e893a488be0820a5b4b865f0728
MATLAB
1,362
62
function [edgesUp, edgesDown] = treeMsgOrderPmtk(adj, root) %treeMsgOrder Find message scheduling for inference on a tree. % % edgesUp(e,:) = [c p] where edge is oriented p->c en route to root % edgesDown(e,:) = [p c] % % This is similar to treeMsgOrder by Erik Sudderth, % except it works on disconnected trees (fo...
ec4d4da171523fc80e2d9eb885ddb0cfe56283ae7c104c8678e922cc43a71686
MATLAB
1,362
40
% PickReferenceDay.m % Sarah West % 8/23/21 % Loads the "bRep.mat" file for each day of each mouse (which is the % reference image for the within- and across-stack registrations) and plots them % so you can pick what day to use. Called by "registration_pick_reference_day_permouse.m" function [dayi_output]=PickReferen...
952c1c4534e0ef7b8dfe6f1bd6a2a60e8894429c1830a48dffcf3c3e9e46d2bc
MATLAB
1,363
71
function lan2mat(cfg) % v.0.0.1 % % breve funcion que exporta trials de cada condicion por sujeto. % Tambien elimina electrodos % % cfg.subject % Deben por empezar con letras y no numeros % cfg.cond % Deben por empezar con letras y no numeros % cfg.indx % cfg.delelectrode % % Francisco Zamorano % % 01.02...
9fc181d2bdd950953d34a8a308054b89b860af128ad6ba4f41feed3c2da25928
MATLAB
1,363
57
function [trainfolds, testfolds] = Kfold(N, K, randomize) % Compute indices for K-fold cross validaiton % N = num data % K = num folds, if K=N, use leave-one-out CV % [trainfolds{i}, testfolds{i}] = indices of i'th fold % If randomize = 1, we shuffle the indices first % This is useful in case the data has some speci...
e5c2d51efdc489fe833407a907072eca35f88fb3655b70b4add4d357985e5d93
MATLAB
1,363
47
% MF_CHOLSV Solve using Cholesky factor from multifrontal factorization. % % Typical complexity: about half that of MF_SV. % % Y = MF_CHOLSV(F,X) produces the matrix Y by applying the inverse of the % Cholesky factor C of the factored matrix F = C*C' to the matrix X. Requires % that F be computed with the ...
7fd9ed5577eb250417f210bc3011dfa9ba725f490c68bde4ffef90bd568d33e6
MATLAB
1,364
35
%% ALS optimization for CP and Tucker tensor decompositions %% Alternating least squares for PARAFAC/CANDECOMP % The function |parafac_als| computes an estimate of the best rank-R % PARAFAC model of a tensor X using an alternating least-squares % algorithm. The input X can be a tensor, sptensor, ktensor, or % ttensor...
e00bea58ae8f2bb2b75a2f6cdae78b1623d539502e46a4f39f12f2de89d130ea
MATLAB
1,364
71
function EEG = eraseventcodes(EEG, expression) % Deletes all event codes that match with expression % (to deal with biosemi when your using 8 bits trigger... % and some weird codes appear...or whatever else) % % expresion has to be someting like this: % '==1' or '>255' or '~41' % Example: % EEG = eraseventcodes(EEG, '...
109d18a56aa6a2193ed746208e2259129f43a3dbd7cadad42a717783bf224c58
MATLAB
1,365
46
function varargout=rrmdir(varargin) %RRMDIR Delete a series of directories. % RRMDIR dir_name deletes the named directories. Wildcards may be used % in the directory name and in the intermediate pathnames, contrarily % to RMDIR. Brackets ([]) may also be used (see RDIR). % % Use the functional form of RRMDIR,...
5d5439c04314328e8090b58d7b2615cb6579b98932a1d535fdcf7cfb6e80fb0b
MATLAB
1,365
42
function res = innerprod(X,Y) %INNERPROD Efficient inner product with a tensor. % % R = INNERPROD(X,Y) efficiently computes the inner product between % two tensors X and Y. If Y is a tensor, then inner product is % computed directly. Otherwise, the inner product method for % that type of tensor is called. % %...
87e6c493410bce8a29f5135c2e75d4927f75c494faf6ec291c36602f2a5e8ac7
MATLAB
1,365
60
% TrihexyQuestionnaireAnalysis % Analyse demographics + questionnaires clc; clear all; close all; % file name qFile = 'C:\Users\groganj\OneDrive - Nexus365\Comp_Neurology_Lab\Data\Trihexy\Questionnaires\TrihexyQuestionnaires.xlsx'; [num,txt,raw] = xlsread(qFile,'Sheet1','A1:BW26'); %% get into a table colNames = ra...
a6473f7b9560fd8449db2256343af253530a2427838233d3ee77b5c6c2bac090
MATLAB
1,365
54
%% Illustration of the Neyman-Pearson testing paradigm % %% % This file is from pmtk3.googlecode.com xmin = -4;xmax = 8; ymin = 0;ymax = 0.3; res = 0.01; domain = xmin:res:xmax; sigma = 1.5; f1 = @(x)gaussProb(x,0,sigma); f2 = @(x)gaussProb(x,4,sigma); linesize = {'LineWidth',2.5}; plot(domain,f1(domain),'-b',lines...
0f0d1da720d59e9f8a2f179c01701518309f5bccfc9b7c68ed1fea73800bd589
MATLAB
1,366
51
% this small class will count the number of images in a camera ttl trace % it will also get the image on which a puff starts and ends % input a camera trace cut off just after the last image for max efficiency function [num_images, imgs, imge] = count_images (camera, puffs, puffe) dps = size (camera, 1); %check if ...
63f6ab8e105bcf9577f1cc3fac98d1d6d961331a81fe13ad49b02ed70555f9ba
MATLAB
1,366
43
function effects = mystat (info) % function effects = mystat (info) % % calculate the following descriptive statistics: % effects(1) = error rate compatibile % effects(2) = error rate incompatible % effects(3) = RT compatible % effects(4) = RT incompatible % effects(5) = RT correct - RT incorrect % effects(...
65fef3317b2c32488bef59785a0ea650991549af1f6469d88c3e12586e4aea55
MATLAB
1,366
63
% [newX, snr1, M] = adjustCorr1s(X, Cx, MODE, p) % % Linearly adjust variables in X to have correlation Cx. % Rows of X and newX are samples of a (random) row-vector, such that: % 1: newX = X * M % 2: newX' * newX = Cx % % MODE is optional: % 0 => choose randomly from the space of linear solutions % 1...
61ecb670a3b6a3722c83c11a9833b6421c904b08198fc9ff54d039d378d2d6a6
MATLAB
1,367
83
function RT = rt_merge_block(RT1,RT2) % v.0.0.0 % <*LAN)<| % % % % if iscell(RT1.rt) l1 = size(RT1.rt); end if iscell(RT2.rt) l2 = size(RT2.rt,1); end if iscell(RT1.rt) RT.rt(1:l1) = RT1.rt; RT.laten(1:l1) = RT1.laten; try RT.misslaten(1:l1) = RT1.misslaten; catch RT...
79ff567a6be07eaa247e35b5b037428b6677756be255ee9ae125874011ca2658
MATLAB
1,367
51
function st = IsInsideMatRegion(inode,regionID,inele,node) % Checks if points in 'inode' are inside sub-surfaces that are tagged as % 'regionID' % Inputs: % ele : ns x 5 matrix, list of triangles along with two region id's that are % being separated by the surface: % n1 n2 n3 m1 m2 % node : np x 3, coordinats of ...
7a478960ab752170f24e0f443ba2a7ca93babef961c5e1a5ab29a0126775fc67
MATLAB
1,367
39
function lse = VBA_logSumExp (z, dim) % // VBA toolbox ////////////////////////////////////////////////////////// % % lse = VBA_logSumExp (z) % log of a sum of exponential, ie. log (sum (exp (z)) % % IN: % - z: values to aggregate % - dim: if x is multidimensional, dimension along which the LSE is % applied ...
dc126a5ffc7e74721fb78ac7c3805b2564efec180d381d0c1f5823f833614202
MATLAB
1,367
63
% % disp("This is an example matlab driver for the maxwell fmm"); disp("On output the code prints the field in example1 and, field+curl in example2"); disp(" "); disp(" "); %% source to target, magnetic current only, field example % clear srcinfo targ ns U eps ifE ifcurlE ifdivE zk; disp("Example 1: source to sourc...
88d5484956f4587ed99f2371a23ec2e99a99e546b55af8b664818c8b0a9ec66d
MATLAB
1,368
49
function [im,header] = mmf_read_mean(header,varargin) [meani,framei] = myparse(varargin,'meani',[],'framei',[]); fp = header.fid; meani = [meani,header.frame2mean(framei)]; if isempty(meani), [im,header] = mmf_read_mean_helper(fp,header); else if length(meani) > 1, im = zeros([header.nr,header.nc,length(mean...
ba7f2616ba1cfb1e69fc3a98c74ce970fbfebe393183ae49d93594e294bd8389
MATLAB
1,368
49
% 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,...
6d4901d8142ca6baf4a03ec83065735239cd81221ff8923aa0fa5ac154dd8835
MATLAB
1,369
37
function [BoundingBoxNeg, BoundingBoxPos, VoxSize]= y_GetBoundingBox(InputFile) % FORMAT [BoundingBoxNeg, BoundingBoxPos, VoxSize]= y_GetBoundingBox(InputFile) % Input: % InputFile - input filename % Output: % BoundingBoxNeg,BoundingBoxPos - image dimention % VoxSize - vox size. %________________________________...
9ac751df4f8c1b673402a3424a092774c276dc38c47d8384a22f52ada96e109c
MATLAB
1,369
45
function Y = squeeze(X) %SQUEEZE Remove singleton dimensions from a sparse tensor. % % Y = SQUEEZE(X) returns a sparse tensor Y with the same elements as % X but with all the singleton dimensions removed. A singleton % is a dimension such that size(X,dim)==1. % % If X has *only* singleton dimensions, then Y ...
13a2b1f01ab42fd258e68257654c76bb6893d6d3e37c201d0abbffaf24cd76d4
MATLAB
1,370
52
function varargout = ginput_ax(ha,n) if nargin<2 n=1; end k = 0; xy = zeros(n,2); hf = get(ha,'parent'); figure(hf); set(hf,'WindowButtonMotionFcn',@changepointer) set(ha,'ButtonDownFcn',@getpoints) hp = get(ha,'children'); ht = get(hp,'hittest'); set(hp,'hittest','off') axlim = get(ha,'Position'); fg...
7fa5a3bb7cdc2357491dd972a7c0b7efcd807d0581a2f3731ccfe00acda7584a
MATLAB
1,370
60
function RT = event2RT(event,srate,time,other) % <*LAN)<] toolbox % v.0.1 % % convert event structure (EEGLAB) to RT structure (LAN) % % Pablo Billeke % 17.10.2012 RT.latency = cell2mat({event(:).latency} )*(1000/srate); RT.OTHER.names = ({event(:).type}); n=1; est = zeros(size(RT.OTHER.names)); mequedan = RT.OT...
98c8aaf663dcc13a055c2d74288e818244489f9174a52686d7112427463b3f2d
MATLAB
1,370
56
%% Illustration of an arbitrary PDF and its corresponding CDF % Reproduces Bishop Figure 1.12 %% % This file is from pmtk3.googlecode.com function plotPdfCdfDemo() pdf = @(x) (gaussProb(x,1,2.^2)+gaussProb(x,6,1))/2; fplot(pdf,[-10,10],'r'); cdf = @(x) quad(pdf,-3.99,x)/5 + 0.01; % /5 + 0.01 is a hack to super...
9eeec2bb0243e133b1499cc978fa341ebe1c1a13183888b656fa02098994e66d
MATLAB
1,370
59
function [volInfo,clusters] = iimg_princomp(maskname,image_names) % :Usage: % :: % % [volInfo,clusters] = iimg_princomp(maskname,image_names) [dat,volInfo] = iimg_get_data(maskname,image_names); % Get data and principal components [eigvec, compscore, eigval] = princomp(dat,'econ'); figure;plot(eigval,'ko-'); ...
ae4357392055e41831ca7985062f2f86da027f75e135042bef920eaca79828f5
MATLAB
1,370
39
function remove_IEDs_from_ripples(basepath) % Load ripples, if ripple event overlaps with IED then define as % IED ( Gelinas et al 2016) % LB 2023 basename = basenameFromBasepath(basepath); rip_file = fullfile(basepath,[basename,'.ripples.events.mat']); ied_file = fullfile(basepath,[basename,'.interictal_spikes_offli...
2e01d691a83f2162abe10a494eeea4c1e60e7b94305a614efa036ee8719dd10b
MATLAB
1,371
71
%% Google's PageRank % pagerank(U,G,p) uses the URLs and adjacency matrix produced by SURFER, % together with a damping factory p, (default is .85), to compute and plot % a bar graph of page rank, and print the dominant URLs in page rank order. % x = pagerank(U,G,p) returns the page ranks instead of printing. % See als...
68ac06ac4c793e96e4d0e6da6c24219c5da6786d22a8b3c03654596f29f2e90d
MATLAB
1,371
45
function [V,Y,XYZ] = tippVol(fname) % [V,Y] = tippVol(fname) % % This is a wrapper function for spm_vol and spm_read_vols. If only one % output is requested, only the vol structure is loaded and returned. V = spm_vol(fname); visstruct = false; if nargout > 1 if isstruct(V) ...
7c119f3a60940e842b562591125b62fcf9ece592124968fc1ed501228f52ad49
MATLAB
1,371
50
function mesh = create_mesh(outputfn,shape,sizevar,type) % create_mesh(outputfn,shape,sizevar,type,link,source,meas) % % Creates a mesh with the desired properties % % outputfn is the filename to save the mesh to % shape is the shape of the mesh % sizevar is a structured variable containing the shape sizes % type is t...
7e8c09e57dc3a9ca5957fd9066bef738c400678df7ec033ce2d7688b78d36af0
MATLAB
1,371
46
%% Test calcium sensitivity on calcium transient and active tension %% Setting parameters clear clc close all param.bcl = 800; % basic cycle length in ms param.model = @model_ToRORd_Land; % which model is to be used param.verbose = true; % printing numbers of beats simulated param.cellType = 0; % 0 endo, 1, epi, 2, mi...
fee543cda96794659d87fcfd18e719aeb4ef33b325a3b3095cad59f6489f8873
MATLAB
1,371
52
%% Hierarchical Clustering Demo %PMTKneedsStatsToobox cluster, pdist, linkage %% % This file is from pmtk3.googlecode.com requireStatsToolbox %requireBioinfoToolbox loadData('yeastData310') % 'X', 'genes', 'times'); corrDist = pdist(X, 'corr'); clusterTree = linkage(corrDist, 'average'); clusters = cluster(clusterTr...
0b9fe1cde5ad34020bfacaf113102705681aa7979a8aeec14541dd11efb7fc81
MATLAB
1,372
44
%% Illustration of Newton's method for minimizing a 1d function % %% % This file is from pmtk3.googlecode.com function newtonsMethodMin1d figure(); hold on; xmin = 0.1; xmax = 12; ymin = -5; ymax = 4; domain = xmin:0.01:xmax; f = @(x) log(x) - 2; Xk = 2; m = 1/Xk; b = f(Xk) - m*Xk; tl = @(x) m*x+b; plot([xmin, xma...
0f2ef3f20e0f324fdeda40e8ec8cc0b81658f5af209e7c292236579168ab27f9
MATLAB
1,372
42
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % To remove high values of DR that we consider as outliers until we reach a % low coefficient of variation of the discharge rates % Input: % PulseTold = previous pulse trains of the motor units % Distimeold = previous discharge times of t...
8df568b34d900e0b4fcaae8019d4a39a77a97db9fd1a769e42a372553a74f54a
MATLAB
1,373
34
function [range, poly] = identify_linear_piece(x, y, window_length) % Identify a segment of the curve (x, y) that appears to be linear. % % function [range poly] = identify_linear_piece(x, y, window_length) % % This function attempts to identify a contiguous segment of the curve % defined by the vectors x and y t...
e1d907956117b410a0f638113084d66f9d44001f93f04b7bfe4fc9cf57a937d8
MATLAB
1,373
48
% meg_moveFiles.m %% move files sourceDir = '/e/1.3/p1/denison/Downloads/MEG'; exptDir = meg_pathToTAMEG(expt, user); success = zeros(1,numel(sessionNames)); for i=1:numel(sessionNames) if success(i)==0 sessionDir = sessionNames{i}; disp(sessionDir) dataDir = sprintf('%s/%s', expt...
f0b19cbe8ec1327ea0bddb908ce437c70cd0ecd5ffd00f2e77b3b5b38fdef7c3
MATLAB
1,373
48
function [idx_keep, idx_reject] = commonDistributions(binstep, inps) % take a binstep and a set of distributions (in a cell array) as input % returns for each distribution the indices of the values that are common % in all of them % Anne Urai, 2015 if ~exist('binsize', 'var'), binstep = 0.020; end % make behaviour of...
0772cb7a068074d24135a3c78424452929d8c97f9e1a58c07ae4ef5278a10440
MATLAB
1,374
49
function [output] = volumefillholes(input, along) % VOLUMEFILLHOLES is a helper function for segmentations % % See also VOLUMETHRESHOLD, VOLUMESMOOTH % ensure that SPM is available, needed for spm_bwlabel hasspm = ft_hastoolbox('spm8up', 3) || ft_hastoolbox('spm2', 1); if nargin<2 inflate = false(size(input)+2); ...
756f39382ff8987882b5f3d49de87433c8d5f02d47e85c9b5f762ee7957ca90c
MATLAB
1,374
61
function EEG = InsertMatFileIntoEEG(EEG, behDataFolder, mFileName) % insert mat file name into EEG % and the matfile % Inputs: % EEG = eeglab structure % behDataFolder = path where mFile is % mFileName [optional] = name of mat file to load, will be taken from EEG % name info if not given %% inputs if ~exist(...