sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
e029538a4122fcf2aae07ad981186a91f5446996e6906684a434ee231499d974
MATLAB
1,256
57
function [bMax splitVal splitDat] = MaxBimodal(waves, varargin) showPlot = false; datType = 'PCA'; for i = 1:2:length(varargin) switch lower(varargin{i}) case 'showplot' showPlot = varargin{i+1}; case 'type' datType = varargin{i+1}; end end [wL nChan nSpk] = size(waves)...
4e9020d490002f8a406bec5bb41f86c4f1b2f905e59fbb2fe3568b666cc8cd34
MATLAB
1,257
48
% _ _ % ___ _ __ __ _| |__ ___ ___ _ __| |_ % / __| '__/ _` | '_ \/ __|/ _ \| '__| __| % | (__| | | (_| | |_) \__ \ (_) | | | |_ % \___|_| \__,_|_.__/|___/\___/|_| \__| % % changes the ylims of a particular channel and fixes it there function resetYLims(self,src,~) i...
c2543beb72464e45823a9d800c0d84d81c7f1416db16b429e38f35e9033ab2d6
MATLAB
1,257
41
function V = hogDraw( H, w, fhog ) % Create visualization of hog descriptor. % % USAGE % V = hogDraw( H, [w], [fhog] ) % % INPUTS % H - [m n oBin*4] computed hog features % w - [15] width for each glyph % fhog - [0] if true draw features returned by fhog % % OUTPUTS % V - [m*w n*w]...
df45a4be7fab7d7b46705dc8351f4405f18c0cbde84c66c15bca8da14569cd17
MATLAB
1,257
44
function B = nonmaxsup( I, M, Vx, Vy, Vz ) % NONMAXSUP Ridge centreline detection by non-maximum suppresion criteria % INPUT: % I: Input tomogram, input data must be single or double % M: Binary (logical format) mask for improve the speed % Vi: The i coordinate of the major eigenvector % OUTP...
7c6a805632d5a34b611b3d19b0c2a8365c308eff7ec4cf16f1e4d121a98c3ea0
MATLAB
1,258
48
function LAN = lan_from_ncs(merge) % Currently assumes one channel and even sampling rate % It also assumes all Timestamps are sorted in ascending order % If merge = true, all it does is concatenating all "recording" [File, Path, iii] = uigetfile({'*.ncs','NCS file'}, 'Open .ncs EEG files','*.ncs', 'MultiSelect', 'off...
de56fd2f44f9746f04eae58047849d193e7eddec99fe237e4665567e09011773
MATLAB
1,258
74
clear;close all;clc;FS=22; %pkg load image % Co-ordinates and dispersions for the kernel y=-81:80; x=-86:85; [X,Y]=meshgrid(x,y); D=2; t=1:30; sigma2=4*D*t; for j=1:length(t); P0{j}=exp(-(X.^2+Y.^2)/(4*D*t(j)))/(pi*4*D*t(j)); P{j}=exp(-(X.^2+Y.^2)/(4*D*t(j)))/(pi*4*D*t(j))+exp(-((X-10).^2+(Y-10).^2)...
e785c22e051175d9c4f5dd138f8acaeda7eef179a65e90864babc9dc53e2a4c5
MATLAB
1,258
30
function domex_nirfast() % Routine to compile the NIRFAST CORE mex files in a batch. % Should only be run on a machine that has mex set up properly. % It should be called whenever NIRFAST CORE mex C/C++ files are updated. % A normal user is unlikely to run this script! % Written by Hamid Dehghani September, 2018 mypwd...
b710ca6d919b9a34376baf2a3d5911c0233633825cf36ac279348abadc30a871
MATLAB
1,259
40
function [Clean2,Clean3] = RemoveArtifacts(A2,A3,win,perMax) % cedric Wannaz remove artifacts solutions % A_temp2 = movmean(A2,win); d2 = [0; diff( A_temp2 )] ; Rderv=max(d2)-perMax*max( d2); isValid_2 = ~logical(cumsum( -sign( d2) .* (abs( d2 ) > Rderv) )); % ...
c33b2953a64fdd4f6b25cafe51dd92037f63d7753db603eb47204dfc784b175b
MATLAB
1,259
34
%{ Copyright (c) 2025 Axion BioSystems, Inc. Contact: support@axion-biosystems.com All Rights Reserved %} classdef VoltageWaveform < Waveform methods function this = VoltageWaveform(aChannel, aStart, aData, aSource, aSubsampleFactor) this@Waveform(aChannel, aStart, aData, aSource, a...
6738d87f89696390d0d566e09374aa36c9b878c5fb966aa92bf15224e0599bc3
MATLAB
1,260
33
function [ x_cm,y_cm] = transformCoordinates(behavior) %transformCoordinates converts xy coordinates using max and min input %values by translating and then scaling (by maze diameter). % input: % - dia: maze diameter (assumes symetric environment) in cm % - x_max: maze x_max in pixels % - x_min: ...
ef7b3020e954d815e952b6bda627aeb62c81ae044239a01c2d11b54a9365fed9
MATLAB
1,260
48
function [pathname] = uigetdir2(start_path, dialog_title, selections) % Pick multiple directories and/or files import javax.swing.JFileChooser; if nargin == 0 || isempty(start_path) || isnumeric(start_path) % Allow a null argument. start_path = pwd; end jchooser = javaObjectEDT('javax.swing.JFileChooser', start_...
fda7cab32822890c3f158e9bd69641daa136554193c91e2dd76bd132d20286bc
MATLAB
1,260
43
datRoot = '/Volumes/LaCie/Farries recordings/'; rat = 'IM1130'; sesList = dir([datRoot rat '/20*']); sesList = arrayfun(@(x) x.name, sesList, 'UniformOutput', false) taskList = {'RL', 'Pav'}; % tasks on which to perform burst analysis for iSes = 2:13 sesDir = [datRoot rat filesep sesList{iSes}] % create ...
0e88f3cafc36a2d61af840fe6272b6f2df632e45d065afd6a4723177d0130c89
MATLAB
1,261
52
function sagg = aggregateLabelsAddRoi(lObj,isObjDet,sPrmBBox,... sPrmLossMask,varargin) [incPartialRows,treatInfPosAsOcc] = myparse(varargin,... 'incPartialRows',true,... 'treatInfPosAsOcc',true ... ); isgt = lObj.gtIsGTMode; lbls = lObj.labelsGTaware; mfafs = lObj.movieFilesAllFullGTaware; ...
357d418a728a6d5d16f30d1a3d6debe43ad3eaf39601c6b052ee9a63c0f1c107
MATLAB
1,261
39
function data = read_data(path) %% Read data from path based on the extension % For CSV-like files, the lines of the files will become rows on the matrix. % Note: Mapper will reduce the matrix over rows, but you could also transpose % using preprocessing step % % **Supported formats:** ...
357db25ba778219ea86e8262d7cfbc41276fbde16779852e192140ffe64bf3ea
MATLAB
1,261
63
function c2 = makec2f % makecolormap.m % ----> c3(64,3) % red % yellow % black % cyan % blue c2 = zeros(64,3); % for ii=1:10 % black to grey % c2(ii,1) = 0.1 + 0.4*ii/10; % red % c2(ii,2) = 0.1 + 0.4*ii/10; % green % c2(ii,3) = 0.1 + 0.4*ii/10; % blue % end for ii=1:10 % black to grey c2(ii,1)...
41b27e4cf38e5bc87e10b4e40fed808a51be697c81bcb5b19b6162478067d531
MATLAB
1,261
31
areatxt{1} = 'lip'; areatxt{2} = 'fef'; timevector = -0.05:0.001:0.2; rgb = [0.1 0.4 0.5; 0.7, 0.4, 0.7]; labels = [{'Singleton distr in RF'}; {'Matched stimuli in RF'}]; for iArea = 1: 2 figtitle = upper(areatxt{iArea}); xlimToPlot = [-0.05 .2]; figure('Name', figtitle , 'NumberTitle', 'off', ...
98777ef8dcbd46799bfdc195b237fef073e21d10ed3ba1df9cc54d6fd3b33b8d
MATLAB
1,261
49
function [x,msg] = roundn(x,n) %ROUNDN Rounds input data at specified power of 10 % % y = ROUNDN(x) rounds the input data x to the nearest hundredth. % % y = ROUNDN(x,n) rounds the input data x at the specified power % of tens position. For example, n = -2 rounds the input data to % the 10E-2 (hundredths) positi...
00a9e22aa2a4eac06168effcef1136c3067e84ff246fe540330e7c3d8d0cf6a9
MATLAB
1,262
30
areatxt{1} = 'lip'; areatxt{2} = 'fef'; rgb = [0.1 0.4 0.5; 0.7, 0.4, 0.7]; timevector = -0.05:0.001:0.2; labels = [{'Singleton distr in RF'}; {'Non-singleton distr in RF'}]; for iArea =1:2 xlimToPlot = [-0.05 .2]; figtitle = upper(areatxt{iArea}); figure('Name', figtitle , 'NumberTitle', 'off',...
29f75dbdfb75823adb17182a9678992f469a9d58c4556f46c63da8380bc6d19c
MATLAB
1,262
51
function [logP,bestPhi] = gridL_binomial(y,u,f_fname,g_fname,dim,options) % nuemrically evaluates the posterior of (binomial) likelihood parameters [options,u,dim] = VBA_check(y,u,f_fname,g_fname,dim,options); iQ = VBA_inv(options.priors.SigmaPhi); gridPhi1 = -3:0.2e-1:3; gridPhi2 = -0.5:1e-2:0.5; n1 = length(gridPh...
eaa9cf8dca29a2400daec4877aae3cb92ecb94d964d071c55e0ae58f827222e0
MATLAB
1,262
63
function mergeAll() allfiles = dir([pwd filesep '*.crab']); assert(length(allfiles)>0,'No data found. Make sure you have .crab files in this folder') [~,thisdir]=fileparts(allfiles(1).folder); savename = [thisdir '_merged.crab']; if exist(savename) == 2 disp('Already merged, aborting...') return end % first es...
ee4eba96496636b9280f4446108cd346f8d047467fea12ba4173db29ff564cde
MATLAB
1,262
29
function bvc_pop = generate_bvc_firing(v) bvc_pop = cell(v.bvc.N, 1); FiringSquare = zeros(size(v.env.SquareSpaceY,1),size(v.env.SquareSpaceX,2)); FiringRect = zeros(size(v.env.RectSpaceY,1),size(v.env.RectSpaceX,2)); c = 1; for d = 1:length(v.bvc.dist_tunings) % for all preferred distances for a = 1:length(v.bvc...
fc32e2eb7338178d451be318ce0a04b09492136ed1374536de817b5bc571dd19
MATLAB
1,262
41
function [g,dgdx,dgdp] = g_conv0(x,P,u,in) % this function evaluates a linear convolution of the inputs % function [gx,dgdx,dgdp] = g_conv0(x,P,u,in) % This function evaluates the following multiple convolution model: % y(t) = cst + sum_k sum_tau w(k,tau)*u(k,t-tau) % where u can be of any dimension (k=1,...,K). % No...
1e64976c24a12fc1c51657a21987e456cde78901fd40a0cb5f859b5302500fc9
MATLAB
1,263
44
%% Test for CME data on run_main.m % Setup base path clear; basefolder = fileparts(fileparts(mfilename('fullpath'))); codefolder = [basefolder,'/code']; toolsfolder = [basefolder,'/tests/tools']; addpath(genpath(codefolder)); addpath(genpath(toolsfolder)); % Load Data data_root = [basefolder, '/tests/fixtures/cme']...
49b37e43535a351c725d67b097f5adfc9d8d23f37657f871c8342b89fa5c8e76
MATLAB
1,263
46
% Setup base path % clear; basefolder = fileparts(fileparts(mfilename('fullpath'))); codefolder = [basefolder,'/code']; toolsfolder = [basefolder,'/tests/tools']; addpath(genpath(codefolder)); addpath(genpath(toolsfolder)); % Load Data data_path = [basefolder, '/tests/fixtures/sub-1_rest1_schaefer400x7_ts.1D']; dat...
5d8a277dc14df1831e8faecfa831f6c20fc30504865b80c47caf3c94649b3ad7
MATLAB
1,263
46
function [model, loglikHist] = probitRegFit(X, y, varargin) %% Find MAP estimate (under L2 prior) for binary probit regression using EM % %% Inputs % X(i, :) is i'th case % y(i) is in {-1, +1} % %% Optional named inputs % % 'lambda' - value of the L2 regularizer % 'preproc' - a preprocessor struct % 'method' - one of...
793c242482f82a2a96179bf37017c0f144bc33696b9026cba6a7cadf814be7fd
MATLAB
1,263
44
%% From Schmee and Hahn, "A simple method for regression analysis % with censored data", technometrics 1979 table 1 % PMTKauthor Hannes Bretschneider %% Load % This file is from pmtk3.googlecode.com setSeed(0); loadData('schmeeHahn'); y = log10(time); x = 1000./(temp+273.2); n = length(y); uncensored = ~censored; %%...
ff6888139961fad61f2096568f9b93495c4e2ba6f2e3899b09154cb4c61a518b
MATLAB
1,263
46
function [parameters] = FindBetaChanges(parameters) MessageToUser('Beta change of ', parameters); % Inputs dataset = parameters.dataset; % Output from DatasetPrep if ~parameters.onPermutations if strcmp(parameters.comparison_type, 'categorical') betas = parameters.betas(2, :); %...
71c9e48c0c6b7e63f2700ff1e7fb2a8b8922a0072f0145cf45d82a5f7666dbcd
MATLAB
1,264
53
function f = displayTrigger(trigSeq, nBlocks) % % function displayTrigger(trigSeq, nBlocks) % % Given a trigger sequence, displays the triggers as they should appear in % the MEG channels % % trigSeq is the trigger sequence % nBlocks (optional) is the number of blocks for plotting = number of subplots % % Rachel Denis...
889aa7bf76c9288413dd6ff6731634bdf8c6754a08f619bf64a08a1bc900ebd5
MATLAB
1,264
38
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PCA before withening the EMG signal % Input: % signal: row-wise signal % Output: % E = full matrix E whose columns are the corresponding eigenvectors % D = diagonal matrix D of eigenvalues EIG(A) produces a diagonal matrix D of eigenva...
ba64c4d30ad53ca1f1497a004f157a965852e4fbc3f04ae3f071c84884dc7ad8
MATLAB
1,265
39
clear clc %{ delete(gcp('nocreate')) myCluster.NumWorkers = 8; parpool('local',8) %} NineMuscleMorphParaInitial = load('NineMuscleMorphParaInitial.mat'); NineMuscleMorphParaInitial = NineMuscleMorphParaInitial.NineMuscleMorphParaInitial; MaxFunctionEvaluations_Data = 10^300; MaxIterations_Data = 100; OptimalityTole...
c7c6434055ba60e7b75d25c81d0860804fbdae48801dc3009cff242ae18f1c2e
MATLAB
1,265
39
% Based on Tyson/MLfw/+tests/FindCenterOutFiles.m N1=hst.Subject('n1') today = datestr(now, 'yyyymmdd'); o=N1.getSessions('RANGE',{'20190401',today}); AllOpenLoop=table() for sesID=1:length(o) cSes=N1.getSessionObject(o{sesID}); cSes.TaskInfo=cSes.TaskInfo(cSes.TaskInfo.NumTrials>=48 & strcmp(cSes.TaskInf...
f49f4575eb97973c216a5521d05e4661744f624854617bbeada7dafaa8f679a6
MATLAB
1,265
42
% run_paper_tests % clear the workspace clear; % define save directory save_dir = fullfile('data', 'nov26_paper_test_run_true'); [~, ~, ~] = mkdir(save_dir); % calculate map6 values tau_map6_ratio = [10]; default_params = genParams(); map6_vals = default_params.tau_on .* (1./tau_map6_ratio); % iterate over values o...
5e8eaf9a03691155cd2e3c57dfbae84713115becf032633d63961d78e064b6b4
MATLAB
1,266
46
function [model, output] = mlpGenericFitNetlab(X, y, H, lambda, options, type) % Train a multi-layer perceptron; needs netlab and minFunc % X is an N*D matrix of inputs % y should be a N*K matrix contain reals or 0,1 % type is 'linear', 'logistic' or 'softmax' % H is the number of hidden nodes (single layer) % lambda i...
6e96efe4d8420ac9bf6423c96c79bbd503c4e0960b80e240ac418b25a162a697
MATLAB
1,266
45
function C = or(A,B) %OR Logical OR (|) for sptensors. % % See also SPTENSOR. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www.sandia.gov/~tgkolda/TensorToolbox. % Copyright (2015) Sandia Corporation. Under the terms of...
70db30ea120882673809918dc7ef95007b6f4a07ee1cf25f68bf7669ca036a92
MATLAB
1,266
29
function [Params, lh_labels, rh_labels] = CBIG_MSHBM_example_wrapper(out_dir) % [Params, lh_labels, rh_labels] = CBIG_MSHBM_example_wrapper(out_dir) % % This function will run examples sequentially % % Written by Ru(by) Kong and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md CBI...
99fba9e6c55180fde3b59982a61d717c7ca617638e38bd2bc2d2b08b69b9727b
MATLAB
1,266
40
%% addpath('../engines/bem_fmm_engine/'); [f1,f2] = uigetfile(fullfile(patient_path,"mesh_data","*.stl")); FileName = strcat(f2,f1) TR = stlread(FileName); P = TR.Points; t = TR.ConnectivityList; normals = meshnormals(P, t); % % If you also want to display normal vectors, uncomment...
a13fb542547278c4281d923da83c48b91a9508f33502bf7a2dcc5933e1b5644c
MATLAB
1,266
47
% [3D] Used to convert a stack of T images into a movie. % % To display same data statically use montage. % % USAGE % M = makemovies( IS ) % % INPUTS % IS - MxNxT or MxNx1xT or MxNx3xT array of movies. % % OUTPUTS % M - resulting movie % % EXAMPLE % load( 'images.mat' ); % M = makemovie(...
b63d32caa4838de8603926624550491b09c099cd4b7d0acd0832e33ccbe9466e
MATLAB
1,266
52
function unzipData(dataSource, dest, threshold) %% Unzip all of the data to another directory, without the zip or svn files % If threshold is specified, data is split into two by threshold size in % MB, creating "big" and "small" directories. % % dataSource is the location of the pmtkData local copy of the svn % repos...
dfac88de8afbe66dc839a39afe25b984230a1a1d26d880bf487d75441c34a88e
MATLAB
1,266
38
function [tf, tf_lambda, tf_U] = isequal(A,B) %ISEQUAL True if each datum of two ktensor's are numerically equal. % % TF = ISEQUAL(A,B) returns true if each factor matrix and the lambda % values are equal for A and B. Does not do any scaling or normalization % first. % % [TF, TF_LAMBDA, TF_FACTORS] = ISEQUAL(A,...
28365d188367e21f0d74e0dfe65768d66656e26cc2f46736d13bda5d95e40d18
MATLAB
1,267
52
function mask = voxel2mask(voxels,maskdims) % :Usage: % :: % % function mask = voxel2mask(voxels, x y z mask dimensions) % % :Voxels: % - 3 column vectors % - [i j k] = row, column, slice % - [x y z] in brain if brain is in analyze format % % (x is rows, y is columns, z is slices) % % .. % % Tor Wager,...
54d86e195c6e48acfb7740bfabc7d3ceeb760db1c02e12318098effe9b04335b
MATLAB
1,267
36
% Copyright Christopher Fricke, University Leipzig Medical Center, % Neurology 2024 close all; clear; datafolder = 'Resting State Connectivity Analysis\results\HCP\datscan_learning\firstlevel'; overwrite = 0; d1 = dir(fullfile(datafolder,'cond_Rest_RL')); for j = 3:length(d1) fprintf('%s',d1(j).name...
5e9b15c7d7eca5b3b0ab9f54fcbe499abe0980f06484a6b8aaaa77b87d663e80
MATLAB
1,267
75
function S = jpattern(Nplus) global N global NaP CaL M KCa kCain global mInst mpInst pInact qInst global N_mNaF N_hNaF N_mNaP N_hNaP N_Kdr N_M N_qCaL N_zCaL N_KCa N_Cain S = zeros(Nplus,Nplus); %% NaF if mInst == 0 S(N_mNaF,N_mNaF) = 1; S(1,N_mNaF) = 1; S(N_mNaF,1) = 1; end S(N_hNaF,N_hNaF) = 1; S(...
547cfc9b6098de29404c2021b164a772391f54f213f1c380d7c089a8b57deb09
MATLAB
1,268
51
%% Image denoising using an mrf and approximate inference % %% %PMTKneedsImageToolbox % This file is from pmtk3.googlecode.com if ~libdaiInstalled fprintf('cannot run %s without libdai; skipping\n', mfilename()); return; end requireImageToolbox setSeed(0); infEngine = 'libdaibp'; sz = 32; sigma = 1.5; data...
7a007bab26cbd8ce88c1798ec9a95248dae993c3ec028ad17328526a45a9cb0d
MATLAB
1,268
46
% this function opens the BG figures for a specific cell we are analysing and subtracts the smoothed BG from the %BG trace, and then takes the images we took the signal and baseline values %during for getdeltaF, and getsdeltaF for the BG too function [deltaF_BG, change] = get_deltaF_backgroundiv (path, rec_num, fn, i...
b2a74ec06f588c7f9010c9d824179fde5ff43c1ad91ff786cfa0030cc0503de0
MATLAB
1,268
44
% FixImageSize.m % Sarah West % 12/3/21 % Removes the extra pixel in each dimension sometimes captured in % microManager on 472 rig (no clue how that can happen). % Input: % data = the matrix of images you want to adjust. First 2 dimensions must % be pixels by pixels. % pixels = the y and x dimensions that you want...
450ef38597c3d9216d14c1ab95c696875ef306e0d89f77d699a6cda562cbb511
MATLAB
1,269
20
function test_AR_GRONe_SA_tracking() % Test training and tracking on a project using some of AR's flybubble videos. % That project is a multianimal project. linux_project_file_path = '/groups/branson/bransonlab/apt/unittest/multitarget_bubble_training_20210523_allGT_AR_MAAPT_grone2_UT_resaved_3_lightly_trained...
bbc88a9f55437b271722a494afa805ed3edc35f100f6d5c5c0c2484dc0bd3658
MATLAB
1,269
41
function [labeler, labelerController] = StartAPT(varargin) % Launch APT, the Advanced Part Tracker. % Note that varargin may be coming from the command line in a deployed % setting. % Set up the APT path APT.setpathsmart(); % If only one argument, assume it's a project file to be opened if isscalar(varargin) , ar...
dfaf2f3ecd98810594b00005c971e3b96c02f2635cf22c253b5c49a474be1ed5
MATLAB
1,269
35
function arsEnvelope x = randn([1,1000000]); [n, xout] = hist(x, -1.5:0.1:1.5); n(1) = []; xout(1) = []; n(end) = []; xout(end) = []; n = n / max(n); n = log(n); figure(1); clf; hold on; plot(xout, n, '-b', 'LineWidth', 3); x1 = -0.7; ind1 = find(xout == x1)...
146ef199230ef0be0e17f1ab706db1d23f2c4b8b5d2a353f7d86550ab9b5bc50
MATLAB
1,270
54
%% Illustrate the robustness of the t-distribution compared to the Gaussian % %% % This file is from pmtk3.googlecode.com function gaussVsStudentOutlierDemo() n = 30; setSeed(8); data = randn(n,1); outliers = [8 ; 8.75 ; 9.5]; nn = length(outliers); nbins = 7; %% figure; plotHist(data,nbins,n); plotPDFs(data); printP...
85b1828ba3af49b425b42c54ad54f52a6d6c9ad3917f6c762a4f5aa9404bf413
MATLAB
1,270
35
function cg = cliqueGraphCreate(Tfac, nstates, G) %% Construct a clique (a.k.a. cluster) graph % This is used as as the input to many inference algorithms such % as variable elimination, junction tree, and belief propagation. % % Here we assume one potential function per clique as opposed a factor % graph representat...
df21132e19f5ce9b8dcfbe0a6c879f7e2a2369cb4d326769d3805b36700d140e
MATLAB
1,270
35
function [dip] = ft_datatype_dip(dip, varargin) % FT_DATATYPE_DIP descripts the FieldTrip MATLAB structure for dip data % % The dip structure reprents a dipole model that has been fitted to % ERP or ERF data using a non-linear optimization approach. It is % usually generated by the FT_DIPOLEFITTING function. % % FIXME...
524ad095883878a348330ca9e2f7cba3eb498837c839e1d36d60b76721e2e5a3
MATLAB
1,271
45
function model= deepBelNetFit(X, numhid, y, opts) % Fit a deep belief network greedily, with no fine tuning % INPUTS % X ... X(n,d) is in [0,1] % numhid ... [h1 h2 .. hn] is num hidden units per layer for n layers % y ... y(i) in {1..C} for top level labels, or [] if none % opts ...
2f5c2a42689e39119320e0c9cc1ec3d442940975e7d2f9b5e3daa935090c2e65
MATLAB
1,272
41
function antsResample_series(file_string, fName_contains, new_size, smoothing_sigma, convert2u16, fName_doesnotcontain) %% User Input % subIDs = { % 'P14_JN0013'; % 'P14_JN0014'; % 'P14_JN0016'; % 'P14_JN0017'; % 'P14_JN0125'; % 'P14_XL1402'; % }; % file_string = '/hpc/home/cuk47...
47b1c2b6fb9df3446541e1cd1061b95a88f8b06c53fe2710232ec9102b1a7d74
MATLAB
1,272
39
function improfileOpts = h_getImprofileOpts(handles) [currentInd, handles, currentStruct, currentStructName] = h_getCurrendInd3(handles); if isfield(currentStruct.state, 'lineWidthOpt') switch currentStruct.state.lineWidthOpt.value case {1, 5} improfileOpts.lineWidth = 5; case ...
4bc23ee48a96cbfb820a3029144ecdb367ee3230cec7a75e20f608b4f350e585
MATLAB
1,272
31
areatxt{1} = 'lip'; areatxt{2} = 'fef'; timevector = -0.05:0.001:0.2; rgb = [0.1 0.4 0.5; 0.7, 0.4, 0.7]; labels = [{'Singleton distr in RF'}; {'Non-singleton distr in RF'}]; clear h for iArea = 1: 2 figtitle = upper(areatxt{iArea}); xlimToPlot = [-0.05 .2]; figure('Name', figtitle , 'NumberTitl...
2a38e805287e5ce31b8a7178e7cfa2987f259d178437f8a21da7e5313addc7af
MATLAB
1,273
40
clear clc %{ delete(gcp('nocreate')) myCluster.NumWorkers = 8; parpool('local',8) %} NineMuscleMorphParaInitial = load('NineMuscleMorphParaInitial.mat'); NineMuscleMorphParaInitial = NineMuscleMorphParaInitial.NineMuscleMorphParaInitial; MaxFunctionEvaluations_Data = 10^300; MaxIterations_Data = 100; OptimalityTole...
4decd608ef8b7eb6b610f6ec184055cbbb4ab0564e5567c0c10be823f89fb76f
MATLAB
1,273
37
function y = applyEnvelope(y, fs, rampDur_ms) % % function y = applyEnvelope(y, fs, [rampDur_ms]) % % ramps a vector y on and off % fs is the audio sampling frequency % rampDur_ms is the duration of each ramp in ms (optional: defaults to 10) % % Rachel Denison % March 2014 % % Cosine ramp section from Elise Piazza %% ...
64fd041704f473bcd09a65cc359939e82b6b9929fd417c8ec2e83661f4f079e7
MATLAB
1,273
26
% Count number of responses (individual spots) in input array % (ImageArray_DeltaGFPnMax_Reg2) % count only responses that are in the chosen region (AllBoutonsRegion) function [RFNum_AllNMJ, RF_CorrAmp_AllNMJ] = CountResponses2_withAmp(ImageArray_DeltaGFPnMax_Reg2, ImageArray_CorrAmp_norm, AllBoutonsRegion) Las...
cc3f758a52b31934c045710e41626fb7dd78556810ff15909cd19762bbc7b97a
MATLAB
1,273
57
function ignoreEntireFiles(self, src, ~) if self.verbosity > 9 disp(mfilename) end % get all files in this dataset thisfile = self.file_name; [~,~,ext]=fileparts(self.file_name); allfiles = dir([self.path_name filesep '*' ext]); if any(strfind(src.Text,'BEFORE')) for i = 1:length(allfiles) if strcmp(allfiles(...
eb19f44076583ae75a737d1f9f1333373591b449d9edf8f041a358a3250f29ed
MATLAB
1,273
42
function [A2, C2] = component_split(A, C, shape, minSize, maxSize) % [A2, C2] = component_split(A, C, shape, minSize, maxSize) % Splits ROIs into connected components if(nargin<5) maxSize = Inf; end if(nargin<4) minSize = 1; end nComponents = size(A,2);...
fd67d90bb2b6f609ba7217e51ddb621bd505b42e6de582f1b26d7cb1d4f35820
MATLAB
1,273
42
function [ f, J, H] = rlogistic4( params, x ) %LOGISTICFUN evaluates modified logistic with params at x % Detailed explanation goes here %========================================================================== %define inputs x = x(:); epsilon = params(1); gamma = params(2); beta = params(3); alpha ...
55275d3531caf09f35fac3d56a72e1aa5c4c70de8532ea04e16561e351abe17a
MATLAB
1,274
39
% data_verification_controlscript.m % Sarah West % 5/28/22 clear all; % Create the experiment name. This is used to name the output folder. parameters.experiment_name='Random Motorized Treadmill'; % Output directory name bases parameters.dir_base='Y:\Sarah\Data\'; parameters.dir_exper=[parameters.dir_base paramete...
68cb8eb429ff2ecd42312a9f9c6f4ab5cf585691eec0391da254572eff0f95d5
MATLAB
1,274
44
function rdelete(f,varargin) %RDELETE Delete a series of files. % RDELETE file_name deletes the named files. Wildcards may be used in % the filename, as with DELETE, but also in the pathnames, which allows % for deleting a series a files belonging to different directories. % Brackets ([]) may also be used (se...
7add91dce10f5ac1923498ae43ddd04a7fb28f8ec5af9b8d0ec308b4541ad10f
MATLAB
1,274
40
function f = whoDependsOnToolbox(TB, recache) % Return a list of all user files on the path that recursively depend on a toolbox %% Input % TB - the name of a toolbox, e.g. 'stats', 'images', 'optim' % % recache - [false] if true, the whoCallsMe cache is updated %% Output % f - a list of user mfiles that depe...
eed83f969a2a1caf5f3ee7745768e80d865779e24d4644e3e15321e4cb31d4f3
MATLAB
1,274
72
function [output,e] = VLALE_imp(imp,fs,delay,mu,niter,w) %%% Adaptive Variable Leaky ALE %% Inputs: % imp : ref sig % delay : delay in samples , also corresponds to the filter order % (default 4 sec) % mu : convergance factor, default 0.1 % niter : number of iteration, default 2 %% Outputs : % output : output signal %...
f3aa26892d4011687610611ac25c428c7ea01d9abf79f41cd7a9f91ab8c1650d
MATLAB
1,274
39
function restrict_and_transform(basepath,varargin) % restrict_and_transform takes xy coordinates from animal behavior file and % transforms them to cm. % % Assumes general behavior file and *maze_coords.csv is in basepath. p = inputParser; p.addParameter('overwrite',false,@islogical) p.parse(varargin{:}); overwrite ...
21ff6f1aeca85c71165733a48752b4b4cf5c3ba7d8acd24187f3907f3795c2ce
MATLAB
1,275
56
%% Settings resultsPath = 'D:\GAD67 results\Recordings\'; conditionType = 'belt'; conditionValue = 'uncued'; %% DF/F dff_uncued clearvars -except resultsPath conditionType conditionValue %% Corr corr_uncued clearvars -except resultsPath conditionType conditionValue %% Corr vs distance corrVsDistPooled_uncued clearv...
3fb1e3558d7c7de06b2b72b6cab168dd1c73699aa52483575c0a6b85d35851bc
MATLAB
1,275
47
%% Plot a Dirichlet distribution % Here we plot the dirichlet distribution as a function of a three % dimensional alpha vector, which we can do as the distribtion lives on a % lower dimensional simplex due to the sum to one constraint. % This file is from pmtk3.googlecode.com alphas = [10 0.1]; for alpha=alphas(:)...
8e4b7d8de93685330ab2316dda3ef374217fc33f71497f716bed6715537202ea
MATLAB
1,275
48
%% Kernel pca demo % Based on code by Laurens van der Maaten %{ setSeed(0); n = 1000; [X, labels, t] = generate_data('swiss', n, 1); figure; plot3(X(:,1), X(:,2), X(:,3), '.') grid on %} % Data from kpcaScholopf rbf_var = 0.1; xnum = 4; ynum = 2; max_ev = xnum*ynum; % (extract features from the first <max_ev> Eigenv...
b964d517686eab6211a7c28664ae940b23261c23a1b6b80e393079d9ac8d601c
MATLAB
1,275
40
function [saturatedChannelEpochs, saturatedChannels, saturatedTrials] = meg_findSaturatedChannelEpochs(trigData) cutoff = .10; nChannels = size(trigData,2); nTrials = size(trigData,3); for iTrial = 1:nTrials saturatedChannelEpochs(:,iTrial) = findClips(squeeze(trigData(:,:,iTrial))); end nSaturatedTrialsEachCha...
140173ca4f244666ef62f758fcf78162886e1b143e7e27bfee998ddd84671bcc
MATLAB
1,276
28
function y = nanstd(varargin) %NANSTD Standard deviation, ignoring NaNs. % Y = NANSTD(X) returns the sample standard deviation of the values in X, % treating NaNs as missing values. For a vector input, Y is the standard % deviation of the non-NaN elements of X. For a matrix input, Y is a row % vector containi...
ed3b05aad1d193bced38476674a5caa23db8dd6c79760260818970c2f0597db0
MATLAB
1,276
41
function S = randskew(n, N) % Generates random skew symmetric matrices with normal entries. % % function S = randskew(n, N) % % S is an n-by-n-by-N matrix where each slice S(:, :, i) for i = 1..N is a % random skew-symmetric matrix with upper triangular entries distributed % independently following a normal dis...
2f9d6872dad1eff55d45537388c535832582160486b3782483bf59f0e4dfb1f7
MATLAB
1,277
55
% h = PlotInterpColorLine(x,y,colors,alphas,...) function h = PlotInterpColorLine(x,y,colors,alphas,varargin) if nargin < 4, alphas = []; end if ischar(alphas), varargin = [alphas,varargin]; alphas = []; end [usepatch,parent,leftovers] = myparse_nocheck(varargin,'usepatch',true,'Parent',[]); x = x(:); y = y(:)...
85eeed4e68b3b1d01c4f4208bd25ca7a1a117961c99c63fa910fae1243fed762
MATLAB
1,277
51
%% Simulation example from "a tale of three cousins: lasso, l2boosting, and dantzig" % Meinshausen, Rocha and Yu % [y w s X]=three_cousin(options) creates measurements y with weights w and % selected variables s, and matrix X options has the following fields: n - % number of measurements d - number of variables rho - c...
59a7458666eb8d7e9f383df184da6b822100726c0f970692859a624c0d77072e
MATLAB
1,278
43
function H = calculateSecondPartials(rho,thc,psi, J0, J1, C0, th, N) [f,kact] = calculateFunctions0([psi thc], th,N); f0 = f(1); frho = f(2); fpsi = f(3); Nact = length(kact); W = 1/N*(J1*cos(th(kact) - th(kact)') + J0); s1 = sum((cos(th(kact) - psi) - cos(thc)).^2); s2 = (cos(th(kact) - psi) - cos(thc))'*W*(cos(th...
5c2286ace9c21ca2ef430c5370fbca7a2b79d60b4c8f9beaf1f0ab28f9582ac3
MATLAB
1,278
54
function shadowFunction(fname, output, quiet) % Shadow a function so that when it is called it silently does nothing % rather than its default behaviour. You can optionally specify a value % for the shadow to output. % % Also accepts a cell array of function names. % % **** Call removeShadows() when done **** % %% E...
935aacf32020f29d7830119627eb17eb54f69dd6b33b56b784dbe5a28be2eacf
MATLAB
1,278
30
% Please first add chronux to Matlab path. http://chronux.org/ datafieled = load('path to EEG mat file'); eeg = datafieled.values; movingwin=[5 5]; % set the moving window dimensions params.Fs=Fs; % sampling frequency params.fpass=[0 40]; % frequencies of interest params.tapers=[4 9];...
d477cf3acfcfa8fdcca23d56bf80af01d02709c473cc8363993a23f3e76e389a
MATLAB
1,278
45
% AUTHORSHIP % Primary Developer: Stephen Meehan <swmeehan@stanford.edu> % Math Lead & Secondary Developer: Connor Meehan <connor.gw.meehan@gmail.com> % Bioinformatics Lead: Wayne Moore <wmoore@stanford.edu> % Provided by the Herzenberg Lab at Stanford University % License: BSD 3 clause % function [a...
3ae21c03d026fc1030a29af321d9f20877ebf8349225206470fc595c1e058017
MATLAB
1,279
39
function X = sptendiag(v,sz) %SPTENDIAG Creates a sparse tensor with v on the diagonal. % % SPTENDIAG(V) creates a sparse tensor with N dimensions, each of % size N, where N is the number of elements of V. The elements of V % are placed on the superdiagonal. % % SPTENDIAG(V,SZ) is the same as above but creates ...
5cb156af6c1c346248f8383c167f50c96073dba4d1711967a12ddebde6fb4b09
MATLAB
1,279
48
function [yn,en] = RLS(ref,sig,M,lamda) %% ================== Recursive Least Squares Filter ================ %% %% === Inputs ===== %% % ref: Reference signal channel (vector) % sig: Input signal channel (vector) % M : Order of the filter % lambda : learning parameter %% ==== Outputs ====== %% % yn : output signal % ...
85e7dedb0e90052ca751da33268722d971796606409db067277b86baafe3513f
MATLAB
1,279
50
function LAN = lan_rt_segmentation(LAN, RT, chan, window) % Assumes unsegmented signal % % chan : for common events, use empty array : []; % window : window of interest in miliseconds % example: [-500 1000] (default). Our window of interest begins 500 ms % before the event and ends 1000 ms after the event. if LAN....
b3a1a80c70d93065b901ebbd7d412e87437f1e43226dbccbc07ef3a08b07529c
MATLAB
1,279
49
%% NVR Low-Pass filtering 45Hz % 2017 (edited 2018) by Felix Klotzsche % 2024 update by Antonin Fourcade function NVR_09_lpf(cropstyle, mov_cond, path_data, hicutoff) %% 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 '08_rejcom...
51a8db4dde6c8783eab1318a642fc354755e82df07cc7bf7c0345aca83f19968
MATLAB
1,280
44
function tests = test_VBA_r2 % Unit Tests for VBA_test_r2 tests = functiontests (localfunctions); % inputs function test_inputs (testCase) shouldFail = @() VBA_r2 (rand); testCase.verifyError(shouldFail, 'MATLAB:narginchk:notEnoughInputs'); shouldFail = @() VBA_r2 (rand, rand, rand, rand); testCase.ve...
66186a19db6131cdabc2049b49dca51d11fb8c43d05b3b490460150cf668d7ef
MATLAB
1,280
45
% calculate_ICs.m % Sarah West % 9/1/21 % Calculates ICs from SVD compressed data. Assumes one compressed dataset % per mouse. function []= calculate_ICs_forMSI(mouse_number) % Parameters. mouse = num2str(mouse_number); num_sources = 100; spatial_component = 'V'; folder=pwd; %addpa...
8f6e60fc148d6d97270ebe4036528ff400cc7edc24618ac4b0c09cdf59c80988
MATLAB
1,280
39
function fs_write_fstats(fstats,mri,fname,data_type) % fs_write_fstats(fstats,mri,fname,data_type) % % Writes F-statistic or p-value or Freesurfer significance maps to Freesurfer's % .mgh or .mgz data file. This can be useful for visualization and post-processing % in Freesurfer. % % Input % fstats: Structure obtai...
b907e74b07f573e38c5ab1355805a1d10479cd9385f08e2c6f9d5eda642ea934
MATLAB
1,280
42
function Y = squeeze(X) %SQUEEZE Remove singleton dimensions from a tensor. % % Y = SQUEEZE(X) returns a 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 is a scalar. %...
577a498023f01888359de50417d8a115882d0a73d3f2848f3d9b3f46e34efdab
MATLAB
1,281
51
function RecreateTspFile(fbasename) tspdata=load([fbasename '.tsp']); tspdata = tspdata(:,1); if size(tspdata,2)>1 warning('tsp has data in it! Are You sure you want to continue?') % keyboard end nFramesTsp = size(tspdata,1); tspnew = [tspdata -1*ones(size(tspdata,1),6)]; %readerobj = VideoReader([fbasename '...
846fdf2d590dc400573a3b6a49a10f71f63cb5d0f4fd55f6486f78dec260d201
MATLAB
1,281
41
% ApplyPawNormalization.m % Sarah West % 8/30/23 % A place to edit paw velocity normalizations with more control (was % previously doing everything with EvaluateOnData.m) function [parameters] =ApplyPawNormalization(parameters) MessageToUser('Applying normalization on ', parameters); % Inputs data = par...
0c12e12e97c7d08188814d64041ab908dc76f0f48a76f4e1321e91adc79b3bcb
MATLAB
1,282
38
function [WS, DS] = CBIG_AuthorTopicEM_ConvertActToGibbsFormat(act) % [WS, DS] = CBIG_AuthorTopicEM_ConvertActToGibbsFormat(act) % % Convert activation data to appropriate format for the Gibbs sampler % % Input: % - act = array containing activation data across all experiments % Output: % - WS and DS = arrays conta...
5e9f7e0b23f119a8160c95df8b1fe1a1d5a64dd2af9ca2c6ca1bffaa457de622
MATLAB
1,282
50
function E = energyLandscape(J1,J0,C0,N,psiSamples,thcSamples) %% PREFERRED FEATURE SPACE th = linspace(0,2*pi,N+1); th(end) = []; %% CONNECTIVITY W = 1/N*(J0 + J1*cos(th - th')); %% CALCULATE ENERGY Erec = NaN(length(thcSamples),length(psiSamples)); Eext = Erec; Eleak = Erec; frho = zeros(length(thcSamples), lengt...
7382c0daf7eb17090dd806591c8ae6ee6fbfe9bd2a3ae1985eb7498f8b97febd
MATLAB
1,282
40
clc clear all close all % alpha ratio code to produce the PSD figure in the alpha power ratio paper. % will also need the following: % raw data files % redbluegraphs function %% Figure (red blue graphs) % create a folder to store data in if ~isfolder(['alpha_ratio)']) mkdir(['alpha_ratio']); end % Results figur...
9410c390b5a85b6ee74fb0f09e4bcfe2021245d81b2d99845f1a03438f82671b
MATLAB
1,282
58
classdef String % String utils % comma-separated list of items methods (Static) function c = commaSepList2CellStr(s) c = regexp(s,',','split'); c = strtrim(c); end function s = cellstr2CommaSepList(c) if isempty(c) s = ''; else s = [sprintf('%s,',c{...
25906e6509d966a117598267f0f9f111e59397097b031e0e656108ee6b8a978c
MATLAB
1,283
67
% [success,errmsg] = csvwrite(filename,struct,[prefix]) % [success,errmsg] = csvwrite(fid,struct,[prefix]) function [success,errmsg] = csvwrite(f,s,prefix) errmsg = ''; success = false; isfilename = ischar(f); if nargin < 2, errmsg = 'Usage: csvwrite(filename,struct,[prefix]) or csvwrite(fid,struct,[prefix])'; re...
4033f41fe7107d0b08f1fff5df10a8026841f6531c05bfc9c5ca8b10c013e2b7
MATLAB
1,283
38
function [Zica, W, T, mu] = kICA(Z,r) % % Syntax: Zica = kICA(Z,r); % [Zica, W, T, mu] = kICA(Z,r); % % Inputs: Z is an d x n matrix containing n samples of d-dimensional % data % % r is the number of independent components to compute %...
4ddace4841fd43ca7eb52e3a7bb2bc372e0d7a326c03d584d97a6f8e8f485b3c
MATLAB
1,283
23
function [Epri, Ppri] = bemf3_inc_field_electric_plain(strdipolePplus, strdipolePminus, strdipolesig, strdipoleCurrent, Points) % Computes potential and electric field from the dipole distribution via the FMM % at observation points (Points) % % Copyright SNM 2018-2020 % Define source (pole) positions and ...
650e90010067e95f2dee2c8d80a46213b4a4ffa6fd40401287e4d9135b5a6843
MATLAB
1,283
39
%% Gaussian Kernel %// grab a generic gaussian kernel for 1D filtering of discrete-sampled % points % % INPUTS % WID (Integer) - Number of states/positions adjacent to mean to estimate % the kernel over % STD (Integer) - The standard deviation of the gaussian % OUTPUT % kn - Kernel for filtering, ...
8140d776c53f3098ce1083fc67e19ccf593b79b3aa59b755e8c78ef8a74acb9b
MATLAB
1,284
40
% Load data load(fullfile(saveLoc, 'cosine_sim'), 'cosine_sim') load(fullfile(saveLoc, 'resCorr_wiTrial'), 'filtW50b', 'resCorr', 'r_conv50b', 'rz_sess'); % load(fullfile(saveLoc, 'cosine_sim_randperm'), 'cosine_sim_randperm') % cosine_sim_randperm(sess, d1, d2, :) % Plot d load('E:\Matalb analyses\darkRed...
97981774c7229f9adc9c014130846b480318d0e17c1662e7dba88256205ba406
MATLAB
1,284
28
% Geometric Distortions Correction - Extract volumes to compute topup data = dir('/DATAPOOL/ERRORMONITORING/SEM_mri_data/P*'); %% for i = 1:size(data,1) data_func = dir([data(i).folder, '/', data(i).name, '/mri/SEM_', data(i).name, '/nifti/func/run*']); fprintf(data(i).name); ...
cc9bd966fe3ebc623a85b6cac822e5f1933f02ab5fc4be0fc9a6ff2206a87de5
MATLAB
1,284
42
function [True] = inside_triangle(P,P1,P2,P3) % INSIDE_TRIANGLE checks if a 2D point belongs to a 2D triangle usign the % 'area' criterion. % % TRUE = INSIDE_TRIANGLE(P,P1,P2,P3) Tests if point P belongs to the % triangle spanned on P1, P2 and P3. All points are cartesian % coordinates. % P - the point to tes...
0ead87899a47c0605087f9ae57a05b1ecc8da8cf05f53bedad6718f6d38df6f6
MATLAB
1,285
54
function mesh = read_obj_mod(filename) % read_obj - load a .obj file. % % mesh = read_obj(filename); % % mesh.v : vertices % mesh.f : faces % mesh.vn: vertex normals % % Copyright (c) 2008 Gabriel Peyre % % modified by Idse Heemskerk 2015, to accomodate obj format as output by % meshlab, return mesh ...