sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
b3bbbc08f7f76c47a2f9b3accf0228b571bd757248c95e23f115d9a5add10d3b
MATLAB
1,137
26
function phi = rad2deg(phi) %RAD2DEG returns the given angle in degree % phi = rad2deg(phi) converts the angle phi given in radians to degree % % Input options: % phi - angle, can be a scalar or matrix (rad) % % Output options: % phi - angle (degree) % % See also: deg2rad % SOFA API - funct...
c7c8edcf12e364ef4a2665e0b42b493ee7e9d21026572c3be85770890cd9d73e
MATLAB
1,137
41
% 1D Gaussian filter. % % Equivalent to (but faster then): % f = fspecial('Gaussian',[2*r+1,1],sigma); % f = filter_gauss_nD( 2*r+1, r+1, sigma^2 ); % % USAGE % f = filter_gauss_1D( r, sigma, [show] ) % % INPUTS % r - filter size=2r+1, if r=[] -> r=ceil(2.25*sigma) % sigma - standard deviation of filter % ...
e8b74ea40b6ba7af2abd47edb572fa89abc17f9edd72366feb1c1b61f87f6d64
MATLAB
1,137
39
function sub = ind2sub2( siz, ind ) % Improved version of ind2sub. % % Almost the same as ind2sub, except always returns only a single output % that contains all the index locations. Also handles multiple linear % indicies at the same time. See help for ind2sub for more info. % % USAGE % sub = ind2sub2( siz, ind ) % ...
fbf73f5b2d6a3ba73d1acec8b90235c8a703844b7d95a5cf2ec294ed0515cd5a
MATLAB
1,138
26
function phi = deg2rad(phi) %DEG2RAD returns the given angle in radians % phi = deg2rad(phi) converts the angle phi given in degree to radians % % Input options: % phi - angle, can be a scalar or matrix (degree) % % Output options: % phi - angle (rad) % % See also: RAD2DEG % SOFA API - func...
039d1bf8d22981e3a9b460b2354f6896028ef1b724ee5f94d3f7cbb4111ce2a8
MATLAB
1,139
42
function result = GuessImageMaxValue(im) % Guess a good maximum value for the display of image im, which is typically % the first frame of a movie. % This version improves on the old version by first branching on the class of im. % In particular GuessImageMaxValue(uint8(0)) => uint(255), not uint8(0). if isa(im, 'uint...
05273f420a564425ef3598a64c6ee6007d4558a4c01d223527e6602d34fb328d
MATLAB
1,139
57
function p=hfo_amp_detector(x,sD,th,fs,fc,Nc) % function p=hfo_amp_detector(x,sD,th,fs) % x is the filtered signal in HFO range % sD is the standard deviation threshold % th is the amplitude threshold. 4uV default % fs s the sampling rate % Fc minimum HFO frequency % Nc is the min number of threshold crossings. ...
adc52f30633416f362b7fa9f06b47569ad8ca5665fff114dbdc605c9136296a1
MATLAB
1,139
39
function [chk, clusters] = check_spm_mat(mat1,mat2,clusters) % mat1 is from clusters, mat2 is functional (imgs to extract) % % :Usage: % :: % % check_spm_mat(mat1,mat2,clusters) chk = mat1 - mat2; chk = chk(:); chk = chk(1:end-1); % eliminate SPM scale factor chk = any(chk); if chk % we need...
d7ef3bb283cc53735f7b51d7e456fdbd4dfdf014ec3a545830d9dbbbd8879dfe
MATLAB
1,139
40
function [flag] = VBA_isInRange (X, bounds) % // VBA toolbox ////////////////////////////////////////////////////////// % % [flag] = VBA_isInRange (X, bounds) % check if all elements of X are within bounds % % IN: % - X: matrix, cell array of matrices, or structure to be checked % - bounds: a 2x1 vector that define...
c08458ecc2ea16621e1dd03eed0e5e19d82b7387c87d4d82694ab982113a01fd
MATLAB
1,140
29
function [AllProfiles,AllProfiles_Mean,AllProfiles_STD,AllProfiles_SEM]=... ImageRotationProfiles(TempImage,CenterCoord,ProfileCoords,DegreeInterval,DegreeRange,RotationMethod) AllProfiles=[]; for theta=1:length(DegreeRange) TempAllProfiles(theta).Profile=[]; end % p = gcp('noc...
267df4c9ce155f90abf3a768012d16e920ac3490d4fe7efd066a9087e3f9f290
MATLAB
1,141
26
function results = SOFAgetVersion(flag) %SOFAGETVERSION % version = SOFAgetVersion() returns the version of the SOFA API % version = SOFAgetVersion('API') does the same. % % version = SOFAgetVersion('SOFA') returns the version of the SOFA % supported by this API. % SOFA API - function SOFAgetVersion % Copyright...
c4b0938402eb0a573b7823d39a5c82d1553bbf51629ae7a61cf3cf3a74c44ee0
MATLAB
1,142
49
%% Compare Monte-Carlo and Numerical Integration % Gelman p95 exercise 3.10.2 %% % This file is from pmtk3.googlecode.com function betaMCdemo() data = [6 4 5 5; 60 40 52 48]; S = 10000; setSeed(0); for i=1:size(data, 1) H1 = data(i, 1); T1 = data(i, 2); H2 = data(i, 3); T2 = data(i, 4); m1.a = H1+...
31c4cfd4296b298d83c9411c920d9dfe5dc6b0e955612de48cf0fc14eba5cabd
MATLAB
1,144
64
%% Minfunc Rosen Demo % %% % This file is from pmtk3.googlecode.com function demoMinfunc() figure; %methods = {'sd', 'csd', 'cg', 'bfgs', 'newton', 'bb'}; methods = {'sd', 'cg', 'newton', 'bfgs'}; [nr nc] = nsubplots(length(methods)); for i=1:length(methods) subplot(nr,nc,i); helper(methods{i}); end printPmtkF...
8f9220569795481289e03bdc4e589f30686a46ec8294103bed433598c1a78e4e
MATLAB
1,144
38
%Support function for essential_distMinAnglePair implementing Newton's search function [tMin,fMin]=essential_distMinAnglePair_dfNewton(m1,p1,c1,m2,p2,c2,tMin,tLow,tHigh) tolDist=1e-8; for i=1:100 % d=dfi(m1,p1,c1,tMin)+dfi(m2,p2,c2,tMin); % dd=ddfi(m1,p1,c1,tMin)+ddfi(m2,p2,c2,tMin); %The code below u...
c039b9b757563a0bf068f964c4498ab47508be7f1d7fa668ba9c1aa134088f19
MATLAB
1,144
36
%-------------------------------------------------------------------- function y_filt = Zach_MovingAvgFilter_Exclusions(y,span,exclude) % moving average of the data. span_halfish=floor(span/2); exclude=logical(exclude); y_nan=y; %set all exclusions as nan as well as a ~half span +/- for i=1:l...
ddc9e6b8f9b6d41a1448e9720781e004833e9ff9c4ff00764cf081408b5c58ea
MATLAB
1,144
52
%% PCA Scree Plot % %% % This file is from pmtk3.googlecode.com seed = 0; randn('state', seed); %X=[randn(100,2)+2.*ones(100,2);2.*randn(100,2)-2.*ones(100,2)]; data = loadData('heightWeight'); % data(:,1) = class, 2 = height, 3 = weight X = data(:,2:3); X = standardize(X); figure; plot(X(:,1), X(:,2), '.'); xlabel...
e5659971a5ca2f2768e2dd29490a0edb3d7db9d79b195a80d1595ff893f3438e
MATLAB
1,144
48
function [events] = lan_spkfieldcoh(data, ts, freq, srate, std_thr) %------- DEPENDENCIES % - filter_hilbert.m % - filtfilt.m % - hilbert.m % % IMPORTANT: this function doesn't admit simultaneous continuous data. % No results are provided if these are found. % %------- UNITS % ts: seconds % freq: 1/seconds % srate: 1/s...
9b60f5eb26d56f06b1156bd4d8c2c28cd5c38ea56a9125cdc9f7de1031ff2aae
MATLAB
1,145
43
function [S,bEff,Delta] = DWSE(G,tau,b,TR,D,T1,T2) % % calculates DW-SE Signal % % input: % G = strength of diffusion gradient (mT/m) % tau = duration of diffusion gradient (ms) % b = b-value (ms/um2) % TR = repetition time (ms) % D = diffusion coefficient (um2/ms) % T1 = longitudinal relaxation time (ms) % T2 ...
e9962411b18fc0b75a3671c60f696fe3ab2e9b5c0b9cf1136477c91d2f91a586
MATLAB
1,145
42
Q = load('/groups/branson/bransonlab/roian/apt_testing/head_tail.lbl','-mat'); %% nmov = numel(Q.labeledpos); newnames = cell(nmov,1); nlabels = zeros(nmov,1); ddir = '/groups/branson/bransonlab/roian'; expnum = nan(nmov,1); mousenum = nan(nmov,1); sz = {}; for ndx = 1:nmov curmov = Q.movieFilesAll{ndx,1}; curmov...
45fb019dd94f90f7cbae157521a979b9e684d8e3391a6ee4554e7bc277676c6f
MATLAB
1,146
40
function vers = eegplugin_PAA(fig, trystrs, catchstrs) % eegplugin_PAA() - EEGLAB plugin for period amplitude analysis % % Usage: % >> eegplugin_PAA(fig, trystrs, catchstrs) % % Inputs: % fig - [integer] EEGLAB figure. % trystrs - [struct] "try" strings for menu callbacks. % catchstrs - [struct] "ca...
8ee127ad5f8a2ce106634c003b9c7770f917910c07eea9f62f6784da24ea0ce1
MATLAB
1,146
56
function paracylTest() %% Compare the speed of different implementations of the paracyl function % This file is from pmtk3.googlecode.com z=-10:0.5:10; x=-10.5:.5:10; as = [0.01 0.75 1]; bs = ones(1,4); compare = true; if true tic outNEG = zeros(numel(as), numel(z)); for k=1:length(z) for i=1:len...
9fb6199701aae3f96a24fe3a5540cdedf0bbc3ceb9589175025cb7a50e9e5a12
MATLAB
1,146
25
function dataType = convertDataType(charOrClass) % Convert between a data type character and a MATLAB class name. % Data types from <http://docs.python.org/2/library/struct.html#format-characters> persistent dataTypes; if isempty(dataTypes) dataTypes = struct('typeChar', {'c', 's',...
cee3178becd9ea4d31248a15fe71adcb219a8c9c0e7cddd7722c902854afe9e6
MATLAB
1,146
38
function h_newGroup3(handles) global h_img3; [currentInd, handles, currentStruct, currentStructName] = h_getCurrendInd3(handles); [fname,fpath] = uiputfile('*.grp','Please specify a group name.'); if fname == 0 return; else [pname, fname2, fExt] = fileparts(fname); if isempty(fExt)||strcmp(fEx...
cc55a4d5be1164be503ab38c254e5de4451781fa07ebdf0dc12eb94997529c61
MATLAB
1,147
29
clearvars close all %load('self_intersection_fixtgt_reltgt.mat'); %load('self_intersection_fixtgt_reltgt_vth0.2.mat'); %load('self_intersection_fixtgt_reltgt_vth0.2_1st_half.mat'); load('self_intersection_fixtgt_reltgt_vth0.2_2nd_half.mat'); n_trials = numel(trial_labels_rt); % making observation matrices % rows -> ...
d931bbd9129264dcfb037ab4198a9892ae43fa59a388b4c97526fef180db0987
MATLAB
1,147
27
function [XCF,XCF_bounds]=crosscorr_curv_r(curv,r,range_of_Lags) % range_of_Lags: 'default' or 'full range' % default use the default range of function crosscorr % full range use the full range of curve or r. for w=1:length(r) % num of worms for n=1:height(r{w}) % num of neurons for i=1:width(r{w}) % num of...
a942dd1281ab53c7de6d6c7843b78544655b29d07cb740fc68c72bd78906b5b1
MATLAB
1,148
54
function TF = tabularFactorMultiply(varargin) % Multiply tabular factors % T = tabularFactorMultiply(fac1, fac2, fac3, ...) % Each factor is a struct as returned by tabularFactorCreate and has % fields T, domain, sizes. %% % This file is from pmtk3.googlecode.com if nargin == 1 facs = varargin{1}; else facs =...
7abda504145a0494d475d78dde1bd20babf8d6295bfd6476e78d01158f3ceff4
MATLAB
1,149
47
% % Copyright (c) 2015, Yarpiz (www.yarpiz.com) % All rights reserved. Please read the "license.txt" for license terms. % % Project Code: YPML110 % Project Title: Implementation of DBSCAN Clustering in MATLAB % Publisher: Yarpiz (www.yarpiz.com) % % Developer: S. Mostapha Kalami Heris (Member of Yarpiz Team) ...
0af6dcae85f96d5923da3c52c365520737a14a537d06104ce7882ee09101807e
MATLAB
1,150
43
classdef TrxVisualizerMAModel < TrackingVisualizerModel % Model layer for TrxVisualizerMA. % % Holds non-gobject properties extracted from TrxVisualizerMA: % trajectory parameters, color state, and show/hide flags. properties lObj % Labeler reference showTrxPreNFrm = 15 % number of preceding frames to show ...
5cc6fd29bda5b3dc92243f4f9583b46532a70a1c666e922d7ad136c5ce42d3cd
MATLAB
1,150
45
%% Plot CI and HPD for beta posterior % %% % This file is from pmtk3.googlecode.com model.a = 3; model.b = 9; alpha = 0.05; %% l = betainvPMTK(alpha/2, model.a, model.b); u = betainvPMTK(1-alpha/2, model.a, model.b); CI = [l,u] %% [styles, colors, symbols] = plotColors; xs = linspace(0.001, 0.999, 40); ps = exp(bet...
d89ee98d0d29c5e26cdd88e5e6a1b3a2b2c1f35ae71168282f57e78d49019310
MATLAB
1,150
40
function output = zlibdecode(input) %ZLIBDECODE Decompress input bytes using ZLIB. % % output = zlibdecode(input) % % The function takes a compressed byte array INPUT and returns inflated % bytes OUTPUT. The INPUT is a result of GZIPENCODE function. The OUTPUT % is always an 1-by-N uint8 array. JAVA must be enabled ...
fe333e32b8e44fbe31db5486475d35ce5e091be83db09292a014a87530668dd0
MATLAB
1,150
41
function val = numericalIntegral(f, range, tol) % Evalaute an integral using quad, dblquad or triple quad % f must be a function that takes an n*1, n*2 or n*3 matrix % and returns the function value at the specified points. % range is [x1min x1max x2min x2max x3min x3max] % This file is from pmtk3.googlecode.com if ...
0392e34a401521e0c514c147dc8486a96463a71e50e9fe2d4bc750be00c596bd
MATLAB
1,151
34
function zScores = getZScores(PSTH,binSize,condition,spontTimes,fs) if strcmp('full',condition) == 1 %Use the full data to calculate zscore. More conservative estimate [psthRow,psthCol] = size(PSTH); zScores = zeros(psthRow,psthCol); for ck = 1:psthRow curVal = PSTH(ck,:); curZ = zscore(...
34dbacc5cc51e254dce1969566afd2bef982e8c968c673e592c34744f6225177
MATLAB
1,151
46
%%%%%%%%%%%%%%%%%%%% RECOMPUTES THE REPROJECTION ERROR %%%%%%%%%%%%%%%%%%%%%%%% check_active_images; % Reproject the patterns on the images, and compute the pixel errors: ex = []; % Global error vector x = []; % Detected corners on the image plane y = []; % Reprojected points if ~exist('alpha_c'), alpha_c = 0; e...
717c8155bcdb7f3439d3ae8b8e070717fefff655ea0f994541ae811dcb5e139d
MATLAB
1,151
40
function [cl1,cl2,dat1,dat2] = iimg_cluster_intersect(dat1,dat2,volInfo) % Prunes two image data vectors (dat1 and dat2) assumed to contain suprathreshold % contiguous clusters ("blobs") by saving only those blobs that have one or % more significant (nonzero) elements in both images % % :Usage: % :: % % [cl1,cl2,da...
27087006f8f36bb7621db0e679344e3428475d109bd3e903fa241a1791d8b726
MATLAB
1,152
20
function test_roian_aws_tracking() linux_project_file_path = '/groups/branson/bransonlab/apt/unittest/four-points-testing-2025-04-12-with-rois-added-and-fewer-smaller-avi-movies-lightly-trained.lbl' ; [project_file_path, replace_path] = localize_test_project_path(linux_project_file_path) ; tester = LabelerProj...
7d109b6e0c6fe110b413934fab4fb7b3f95b11c068ee3d13be2df1339894356d
MATLAB
1,152
35
function bels = jtreeQuery(jtree, queries) %% Query a calibrated jtree for marginals % Multiple queries can be requested in a cell array % This file is from pmtk3.googlecode.com queries = cellwrap(queries); cliques = jtree.cliques; cliqueLookup = jtree.cliqueLookup; nqueries = numel(queries); bels = ...
cfbe4549b6f3b7fe340bea61a505134be5952f59e691b2c685ecc8b1409b61c2
MATLAB
1,152
51
function h = about(labelerController) %% PURPLE = [0.147058823529412 0.033333333333333 0.245098039215686]; WDTH = 900; HGHT = 420; h = uifigure(... 'Position',[1000 1078 WDTH HGHT],... 'Name','About APT' ... ); if ~isempty(labelerController) mainFigurePosition = labelerController.mainFigurePixelPosition() ; ...
d4d8634c0a6f67c52a036694bb0c12829a82e2db02d3c1ececd1d0f0b2b0cc52
MATLAB
1,153
40
% Hypothesis 2: Gaussian Blurring %_______________________________________ % Copyright (C) 2024 Trevor S. Smith % Drexel University College of Medicine % % 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 F...
78316f0fd9680f1c2131bb87e294947eb32ec91c14e284d4ef44d6f12841a2bb
MATLAB
1,154
39
function Y = divide(X,K,epsilon) %DIVIDE Divide an SPTENSOR by a nonnegative KTENSOR. % % Y = DIVIDE(X,K,EPSILON) divides the sparse tensor X by the % nonnegative ktensor K. Avoids divide-by-zero errors by dividing % by MIN(EPSILON,K-VALUE) at each nonzero of X. % % See also SPTENSOR, KTENSOR. % %MATLAB Tensor T...
b20168bbf325f9538e1a455245b3b713b41f7c7d84b2eda1b9047585f4f80d85
MATLAB
1,154
42
function AmplPlot(spkDat, plotClust) convertToVolt = true; clustList = setdiff(unique(spkDat.id), 0); clust = plotClust(ismember(plotClust, clustList)); nClust = length(clust); nonClust = setdiff(plotClust, clustList); if length(nonClust) ~= 0 disp([num2str(length(nonClust)) ' clusters not found in spkDat: ' num2...
d44e4127548480848b7a4039a7a00c56e8e7a2cba080e58f55c0e7b5d3312326
MATLAB
1,154
39
function [tf, tf_core, tf_U] = isequal(A,B) %ISEQUAL True if the part of two ttensor's are numerically equal. % % TF = ISEQUAL(A,B) returns true if each factor matrix and the core % are equal for A and B. % % [TF, TF_CORE, TF_FACTORS] = ISEQUAL(A,B) returns also the result of % comparing the core (TF_CORE) an...
14a00991879ef3d2055d5a69cae10a85fa9fe2ab16b046b9eec58f6917b57a58
MATLAB
1,155
35
temp_string = readmatrix(meta_data_file_name,'OutputType','string'); temp_number = readmatrix(meta_data_file_name,'OutputType','double'); iamge_set_folder_detail = temp_number(8:end,:); x_pix = 2000; y_pix = temp_number(1,2); x_res = temp_number(1,3); z_res = temp_number(1,4); %clear temp_string temp_n...
87654ef484f475efe01978b4fbdc487e7614acb19f4c6e35bcb45192254547d9
MATLAB
1,155
49
% MF_SPDIAG_SV_H Dispatch for MF_SPDIAG with DINV = 1 and F.SYMM = 'H'. function D = mf_spdiag_sv_h(F,spinfo) % initialize N = F.N; n = length(spinfo.i); P = zeros(N,1); % for indexing D = zeros(N,1); % for output % loop over all leaf blocks from top to bottom for i = n:-1:1 % find active indic...
d59132c56b10d51249a866e5002f3eb23625ee20611284a68f06c532896513e0
MATLAB
1,155
45
function f = subscript(m,range) % function f = subscript(m,range) % % <m> is a matrix or a string referring to a matrix % variable in the base workspace. % <range> is: % (1) vector index range that does not use % the 'end' keyword, e.g., 4, [5 6] % (2) the string ':' % (3) a cell vector, where elements c...
d98de1b779df8be203123d4656801867eff9fbabada415aa980f0f404e63bd13
MATLAB
1,155
47
function [xn] = normalize(x_kk,fc,cc,kc,alpha_c) %normalize % %[xn] = normalize(x_kk,fc,cc,kc,alpha_c) % %Computes the normalized coordinates xn given the pixel coordinates x_kk %and the intrinsic camera parameters fc, cc and kc. % %INPUT: x_kk: Feature locations on the images % fc: Camera focal length % c...
578e9d74008a21e40b8e4807064a2655dd674c04ad831d0cdc642719b1f9ec98
MATLAB
1,156
43
function newdata = wlProc_calcPaddedLowpass(olddata, fcorner, samprate) % function newdata = wlProc_calcPaddedLowpass(olddata, fcorner, samprate) % % This function wraps Matlab's "lowpass" function. % Zero-padding is added on both sides of the data to give Matlab's filters % time to stabilize. This is removed when the...
b1ebe44d67fd5a04d0ce2b200230471608a83b38b096b2a909bdd3859f8672a6
MATLAB
1,156
32
clear all %% %Define Parameters [opt] = ParameterOptions(); %% %Generate Pathway Amplitude & Gradient Waveform basis set %First Dictionary [PathwaySignalFirstOrder,GwaveFirstOrder,TransFirstOrder] = PathwayOperatorOrder(opt,'First'); %Second Dictionary [PathwaySignalHigherOrder,GwaveHigherOrder,TransHigherOrder] = Path...
496a260d71d5a9cb766f1538a0bd7cf019060ec65ac94c108fb0ab226fd953f7
MATLAB
1,157
47
function Params=MinimalReduction Params.Tests.usePCA=0; Params.nPrinComp=20; Params.plotPCA=0; Params.robustPCA=0; % Per feature stat test. Params.Tests.anovaTest=0; Params.anovaThresh=.05; % Data Normalization Params.Tests.zscore=0; % Rate Restrictions Params.Tests.DeflectionCoeffTest=0; % Params...
d0d2c78cf173a01239267598947c6c53ba863a4c1c55c1cfb9e88d3dd56243ae
MATLAB
1,157
49
% MF_SPDIAG_MV_H Dispatch for MF_SPDIAG with DINV = 0 and F.SYMM = 'H'. function D = mf_spdiag_mv_h(F,spinfo) % initialize N = F.N; n = length(spinfo.i); P = zeros(N,1); % for indexing D = zeros(N,1); % for output % loop over all leaf blocks from top to bottom for i = n:-1:1 % find active indic...
48138ce33031b843f4551332542f93bfbaff9d08067f4981bd4f338faea2ac1c
MATLAB
1,158
22
%----------------------------------------------------------------------- % Job saved on 28-Sep-2021 12:25:37 by cfg_util (rev $Rev: 7345 $) % spm SPM - SPM12 (7771) % cfg_basicio BasicIO - Unknown % dtijobs DTI tools - Unknown % impexp_NiftiMrStruct NiftiMrStruct - Unknown %---------------------------------------------...
515fc0eb16763abc48c938c8eb13816e83f8d1526240ae5faefbb288d778fcb4
MATLAB
1,158
46
%%%%%%%%%%%%%%%%%%%% RECOMPUTES THE REPROJECTION ERROR %%%%%%%%%%%%%%%%%%%%%%%% check_active_images; % Reproject the patterns on the images, and compute the pixel errors: ex = []; % Global error vector x = []; % Detected corners on the image plane y = []; % Reprojected points if ~exist('alpha_c'), alpha_c = 0; e...
7845f71cfca1ad9249d3393b2a1e023580881c3e51113ffa9d7969e2306c6e54
MATLAB
1,158
34
function OTF = read_otf2d(otfPath, nx, ny, dkx, dky) % ------------------------------------------------------------------------ % read_otf2d: generated 2D OTF image from OTF mrc files % % usage: OTF = read_otf2d(otfPath, nx, ny, dkx, dky) % where, % otfPath -- path of OTF mrc files % nx, ny -- image size...
832427015f4906eafbd7ec21c9b5d2f6f97d9f8d9cd7a1e7e32e91f45644c2fc
MATLAB
1,158
38
function Z = waveletTransformFourier(f1,f2,pas,X) % wavelet transform (Morlet complex wavelet) of signal X % % Z = waveletTransformFourier(f1,f2,pas,k,x) % INPUTS: % X is a column vector % f1 is the lower frequency in the decomposition (in normalized units, ie the highest frequency is 0.5) ...
0def145d42be1d5025eaaea34ad3827a3f4ff72f1fbd33a041a87d54948594d0
MATLAB
1,159
55
function R= rotationmat3D(r,Axis) %function R= rotationmat3D(radians,Axis) % % creates a rotation matrix such that R * x % operates on x by rotating x around the origin r radians around line % connecting the origin to the point "Axis" % % example: % rotate around a random direction a random amount and then back % the ...
1bebf155de238da2362c4d1ffc3c0b6e7950954906731beb6b7096e721a9333d
MATLAB
1,159
34
function [x, y, z] = h_calculateCenterOfMass(matrix) % note: x is the second dimension, y is the first. % the way below make the computer crash. (matrix too big) % matrix = double(matrix); % siz = size(matrix); % if length(siz)<3 % siz(3) = size(matrix,3); % end % [X, Y, Z] = meshgrid(1:siz(2), 1:siz(...
72726f45ce9bdba1e853c8b4a741b255c4da95be719629c918b204d6c13fb3f7
MATLAB
1,159
36
function [parameters] = MouseNotToUseVariability(parameters) MessageToUser('Checking mouse for ', parameters) % Get current mice not to use dir_stem_iterator = parameters.values{strcmp(parameters.keywords, 'dir_stem_iterator')}; comparison_iterator = parameters.values{strcmp(parameters.keywords,...
9e41a0aad39a6b6a872ea572ef2b5c88a374e5e535cfaec9b81c61b76d7617aa
MATLAB
1,159
31
function plot_atlasregions(params) % Source model: centroid positons from Schaefer atlas atlas = readtable(params.AtlasPath); cfg = []; cfg.method = 'basedonpos'; cfg.sourcemodel.pos = [atlas.R, atlas.A, atlas.S]; cfg.unit = 'mm'; cfg.headmodel = params.HeadModelPath; sourcemodel_atlas = ft_prepare_sourcemodel(cfg); so...
ba4145e698815323e3c6e9b81762d99ce23e4894e497153adfaa39ebd56b2848
MATLAB
1,159
30
function A = read_raw_file(filename,framenum,window,FOV,bitsize) %Taken from epnev's NoRMCorre repository for use in the ExSeq Processing % on 09/2017. All credit and appreciation to the original authors %% Starting from frame number: 'framenum', read 'window' fid = fopen(filename); imsize = FOV(1)*FOV(2)*bitsize; ...
0af84f54087d573b21fe60b8fd79e71259fb4eab01f36eaff48ddea2faa09ac8
MATLAB
1,160
29
function X = matrandcong(m,n,gamma) %MATRANDCONG Create a random matrix with a fixed congruence. % % X = MATRANDCONG(M,N,GAMMA) creates a matrix X of size M x N such % that each column of X has norm 1 and any two columns of X have an inner % product equal to GAMMA. % % Based on code from Evrim Acar and the pape...
123b82a037f7191dd9cc788b7a1f4d49f457b54f9dde2ed1ed1c9c83324d23cb
MATLAB
1,160
36
function [F, J] = calcGaussianActivationPhase(gparams, spforiphase) %The function can deal with mulitple subunits % Detailed explanation goes here %Returns derivatives for grid spacing, xshift and yshift %========================================================================== spf = spforiphase(:, 1); ori = spfor...
3cf59b9a07936b363c564580f333a26c01de35d5f52ddefa4d5f9089776bac14
MATLAB
1,160
43
function [faRate, hitRate, AUC] = ROCcurve(score, trueLabel, doPlot) % Plot a receiver operating curve % function [faRate, hitRate, AUC] = plotROCcurve(score, trueLabel, doPlot) % % score(i) = confidence in i'th detection (bigger means more confident) % trueLabel(i) = 0 if background or 1 if target % doPlot - optional ...
db904f383057dda2b5eaece76b50d0d16d4b8b8edfa7e5aae198805697d6b96d
MATLAB
1,161
52
% Illustration of gibbs sampling for 2-dim Gaussian Mu = zeros(1,2); Sigma = [1,0.99;0.99,1]; hold on; axis([-3 3 -3 3])%'nolabel'); gaussPlot2d(Mu,Sigma,'-plotMarker','false'); x1 = [-2:0.01:2]; x2obs = 0.7; mux1Cond = Mu(1) + Sigma(1,2)/Sigma(2,2) * (x2obs - Mu(2)); varx1Cond = Sigma(1,1) - Sigma(1,2)^2 / Sigma(2...
03e83944d55cc105a5821f00b96a8f9306807546ff72adc7d73aeebe5329ab6f
MATLAB
1,162
40
function stage_puncta_extraction() loadParameters; %Save the loadParameters into the output director in case we need to do %later debugging copyfile('loadParameters.m',fullfile(params.punctaSubvolumeDir,... sprintf('loadParameters.m.log-%s',date))) [ret,messages] = check_files_in_punct...
5748416ace0c26e5207ae6eea0d89f29f4b65c27e4416aa96e86aada456cbd90
MATLAB
1,162
33
function xiSummed = hmmComputeTwoSliceSum(alpha, beta, A, B) %% Compute the sum of the two-slice distributions over hidden states % % Let K be the number of hidden states, and T be the number of time steps. % Let S(t) denote the hidden state at time t, and y(t) be the (not % necessarily scalar) observation at time t. ...
63997531892ef199b91d975fd2c4eb962007b90be025ad3b1983e6360e9ee43e
MATLAB
1,162
53
% current directory: /m2_aae/utils/ %% read tf and gene association x=textread('../data/raw/colon/human_PPI.txt','%s'); tt=length(x)/2; binr = reshape(x,2,tt)'; %% doing ANOVA bioMarker = 'PROM1'; name_pool_dir = strcat('../data/colon/resplit/ANOVA/os/',bioMarker,'_name_pool.mat'); load(name_pool_dir) name_pool = na...
a2c6886dcdccc7ac6f40fa8757a742c3d2c3e3af557e895f9c35cdea8dcf6b98
MATLAB
1,162
40
function sp = polyn2sympoly(polyn) % polyn2sympoly: convert a regression polynomial from polyfitn into a sympoly % usage: sp = polyn2sympoly(polyn) % % arguments: (input) % polyn - a structure as returned from polyfitn % % arguments: (output) % sp - A sympoly object % % After conversion into a sympoly, any symbolic o...
ad06e7aa4864bc9973ae7073c048b7ac01b0752d6fd3664e5c7454a32c2f63a8
MATLAB
1,162
35
function C = mtimes(A,B) %MTIMES sptensor-scalar multiplication. % % C = MTIMES(A,B) is called for the syntax 'A * B' when A or B is a % sparse tensor and the other argument is a scalar. % % For tensor-matrix multiplication, use TTM. % For tensor-tensor multiplication, use TTT. % For tensor-tensor array mul...
fa4df0942044cc913af8651e2bbdb48b829421aab006db3c4e4f5b1b4d7da22d
MATLAB
1,162
53
classdef FeaturesImporter < FeaturesReporter properties featuresFilePath end methods(Static) function n = typeName() % Return a name for this type of importer. n = 'Feature'; end function initialize ...
fb2f482dfe563931746ccdcfbc9b05aa056288f79babc0e46904e6f26cb87fe8
MATLAB
1,162
44
%% Plot monte carlo approximation to a distribution % Based on Peter Hoff's book, fig 4.1, p55 % He uses Gamma(68, 45) % This file is from pmtk3.googlecode.com useGam = false; setSeed(0); xs = 0.5:0.01:2.5; S = 1000; if useGam a = 68; b = 45; % shape (matlab uses scale) p = gampdf(xs, a, 1/b); samples = gamrnd...
5b3a5fe849433acc201cae26caa173e23fb0d16536164288134b1f695c4d66fc
MATLAB
1,163
40
function [ f, J, H] = rlogistic3( params, x ) %LOGISTICFUN evaluates modified logistic with params at x % Detailed explanation goes here %========================================================================== %define inputs x = x(:); gamma = params(1); beta = params(2); alpha = params(3); %========...
aa56092dce38533e0de348377c35fbad86e74f84e25558c7015d1b2d7d652639
MATLAB
1,163
23
function [palmar_mask, palmar_template, dorsum_mask, dorsal_template] = GetHandMasks() % Palm mask palmar_template = imread(".\ReferenceImages\palm_right.png"); orig_size = size(palmar_template); bw_image = imbinarize(palmar_template); bw_image = bw_image(:,:,1); [B, ~, ~] = bwboundaries(bw_ima...
c1b02d870f6b4c77c87d70dff8cd4e8a00ac02b21aba54e99cf7c0dcd9794eb1
MATLAB
1,163
53
%% Likelihood surface of mixture of 2 Gaussians in 1d % Based on code by Mike Li %% % Generate data % This file is from pmtk3.googlecode.com fs = 12; setSeed(0); true_mu1 = -10; true_mu2 = 10; true_pi = 0.5; sigmas = [5]; for sigmai=1:length(sigmas) true_sigma = sigmas(sigmai); n_obs = 100; obs = [true_mu1 + true_...
333ef7f4de46d0785c68d7ba643777b6d05361ba6d54ffaa708da71ccd911fe0
MATLAB
1,164
36
function yhat = predictForest(forest,Xtest) %Predict the output of a random forest generated via dtfit. If forest is a %forest of regression trees, the mean of the output of the trees is taken, %otherwise the mode. nexamples = size(Xtest,1); ntrees = size(forest,2); if(isnumeric(for...
39db239ae7ba893b451d2d2b58961a39d60c7d080dead671be3155730caeba5a
MATLAB
1,164
36
function mscmd_extract_raw(input_path,output_path,opts) %MSCMD_EXTACT_RAW - extract a time chunk and/or channel subset of a timeseries % % This is a wrapper to the command-line mountainsort procedure. % % Syntax: mscmd_extract_raw(input_path,output_path,opts) % % Inputs: % input_path - path to MxN timeseries array ...
3a415a1f64e4dc73d6691a39790d2cc2b9b17e65be9140d1ae6e4c9466a00e2b
MATLAB
1,164
41
function data = spm2fieldtrip(D) % SPM2FIELDTRIP converts an SPM8 meeg object into a FieldTrip raw data structure % % Use as % data = spm2fieldtrip(D) % where D is the SPM meeg object which you can load in with SPM_EEG_LOAD % and where data is a FieldTrip raw data structure as if it were returned % by FT_PREPROCESSI...
d05e41bc024b2eee9caeb53b183c4e71aab72174a5359082cfcea8d915f70dc3
MATLAB
1,164
39
function Tbig = bsxTable(fn, Tbig, Tsmall, bigdom, smalldom) %% Apply a binary function to two multidimensional vectors using bsxfun % reshaping and virtually expanding the smaller table as needed % % The tables are matched up according to smalldom and bigdom % smalldom must be a subset (but not necessarily a subsequen...
f62019c3e54399be21ac7bdda23393773b5e16f7312681ca04e0576d61ba9441
MATLAB
1,164
32
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % To calculate the silouhette value to estimate the quality of the Motor % Unit (the distance between the peaks and the noise) % Input: % w = weigths % X = whitened signal % fsamp = sampling frequency % Output: % icasig = Normalized...
1e24792573f152eed0b4c306cf332a8a78df1b655b0785f2e7b446b1f57c7d29
MATLAB
1,165
30
df = compile_sessions('Y:\laura_berkowitz\behavior_validation\appps1_cheeseboard\completed_sessions_10072025.csv'); for i = 1:length(df.basepath) basepath = df.basepath{i}; basename = basenameFromBasepath(basepath); session = loadSession(basepath,basename); for ii = 1:length(session.epochs) ...
e9be9bb45414fa39ef7dc5edad8667408d3df00d0881d24ed624a62ae95a1f28
MATLAB
1,165
28
function candoit = canGetSqrtPrecon(problem) % Checks whether a square root of preconditioner was specified in problem. % % function candoit = canGetSqrtPrecon(problem) % % Returns true if the problem structure allows for applying the square root % of a preconditioner to tangent vectors at a given point. The squa...
943f013c4666553d4b1da268da90126b96806c706eec2a2ec3901825eaae41d9
MATLAB
1,166
41
function [data] = spm2fieldtrip(D) % SPM2FIELDTRIP converts an SPM8 meeg object into a FieldTrip raw data structure % % Use as % data = spm2fieldtrip(D) % where D is the SPM meeg object which you can load in with SPM_EEG_LOAD % and where data is a FieldTrip raw data structure as if it were returned % by FT_PREPROCES...
b3b09846299227de2666e71e6a3724644d0634c884e321a62945c46b572de2e0
MATLAB
1,166
33
function plot_ratio_only(deltaR_R0, varargin) figure % various arguments in oder: curvature of head, fwd, bkw, turn N = size(deltaR_R0, 1); for i=1:N subplot(N,1,i); plot(deltaR_R0(i,:),'b','LineWidth',1.5);hold on; plot(zeros(length(deltaR_R0(i,:)),1),'b:','LineWidth',1.5); % de...
d46fdee0b7afe5b431e2019e39e2d150c5004a1ce5ef1017f4ff798842d23fd8
MATLAB
1,166
37
function [fx,dfdx,dfdP] = f_Qlearn(x,P,u,in) % Reinforcement-learning model for a 2-armed bandit task % function [fx,dfdx,dfdP] = f_Qlearn(x,P,u,in) % An RL agent learns by trial and error. A bandit task is such that, after % each action, the agent receives a feedback (reward if positive, % punishment if negative). T...
265f71745b9af2b8d6d877e5cabeb59980589cfa674d604b6fecb13dc6e4af92
MATLAB
1,167
33
% 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,...
6c72fd490e33e47cb2aa2559e1f3b3efafc836b10d1eb301cedf6be15cf6fa5a
MATLAB
1,167
47
function [xn] = normalize_pixel(x_kk,fc,cc,kc,alpha_c) %normalize % %[xn] = normalize_pixel(x_kk,fc,cc,kc,alpha_c) % %Computes the normalized coordinates xn given the pixel coordinates x_kk %and the intrinsic camera parameters fc, cc and kc. % %INPUT: x_kk: Feature locations on the images % fc: Camera focal leng...
971a4edbbaf6df9fd7a120218b61d0d7d04b0f87024cedbe5a54ddd203c2c200
MATLAB
1,167
33
function Safe_imwrite(Image,FileNameDir,FileType) ReSizeMethod='bicubic'; ReduceRatio=0.95; if ~strcmp(class(Image),'double') warning on warning('Must convert image to double first!') Image=double(Image); end ImageInfo=whos('Image'); if ImageInfo.bytes>(2^32-1) ...
b31dc2ff96d7f2b8aa5920a2707f844ce14b83600d157df4f018c2bef122ae83
MATLAB
1,167
42
function handles = prettyColorbar(titleStr, thinning) if ~exist('thinning', 'var'), thinning = 0.5; end % ================================================================== % make colorbar look pretty % ================================================================== drawnow; handles = findall(gcf,'Type','colorbar'...
536f9f1535a2e2ae8beebb6e73692543e5262a98280cc6e90f4ed657d3f84a7e
MATLAB
1,168
36
function h_loadMEIAnalysis3(handles) global h_img3; [currentInd, handles, currentStruct, currentStructName] = h_getCurrendInd3(handles); currentFilename = get(handles.currentFileName,'String'); [pname, fname, fExt] = fileparts(currentFilename); analysisNumber = h_img3.(currentStructName).state.analysisNumb...
532b1b0cb7d4ba77d51e05f4f6e4fa587cb901161792ca0ce0ac7f992ac820f1
MATLAB
1,169
33
function varargout = extractArgs(indices,args) % Extract specified arguments / values from the output of processArgs % also returning the unused name/value pairs in a cell array. % % When processArgs is called with exactly one output, the output contains % all of the name value pairs in a single cell array. The values...
bfecab554320f23287ccd0df7dd3e185df28111e012b296ae8c4d421bdb3b990
MATLAB
1,169
25
function [PulseT, Distime, exFactor] = getPulseT(EMG, EMGmask, MUFilters, fsamp) EMG(EMGmask > 0,:) = []; nbextchan = 1000; exFactor = round(nbextchan/size(EMG,1)); eSIG = demean(extend(EMG,exFactor)); ReSIG = eSIG*eSIG'/length(eSIG); iReSIGt = pinv(ReSIG); nMU=1; for i = 1:size(MUFilters,2) PulseTtmp = (MUFilter...
f96854818f21d3321f0fa952d237171ac049a6eb32f0a06800fe913e4e6f3e03
MATLAB
1,169
45
%% Online Bayesian linear regression using Kalman filter % %% % This file is from pmtk3.googlecode.com standardize = false; %true; [xtrain, ytrain] = polyDataMake('sampling','thibaux'); if standardize [xtrain] = standardizeCols(xtrain); end N = length(xtrain); wBatch = [ones(N,1) xtrain] \ ytrain; w = zeros(2,...
053275b69ba4b78b09123bf506bdc23c9d469245f5a233d41736af7a9fb27d2b
MATLAB
1,170
36
%% Generate the pxtDataCell from sdoMat/sdoMultiMat with appropriate parameters; function pxtdc = getConformedPxtDataCell(obj, type) arguments obj type {mustBeMember(type, {'px0', 'px1'})} = 'px0'; end pxtdc = pxtDataCell; if ~isempty(obj.pxProperties) pxtdc.zDelay = obj.pxProperties....
f8b7e5403ef19c4aa6dfb97cec66a9a113d6bd3c1c147e6673f730cbcb96aa3f
MATLAB
1,170
49
function [counts1, counts2] = getCounts() % counts1(i,l) = num times word i occurs in language l % counts2(i,j,l) = num times word i followed by j occurs in language l % l=1 = english, l=2 = german, l=3 = spanish, l=4 = italian linesEng = readlines('cnn.eng'); linesGer = readlines('cnn.ger'); linesSpa = readlines('cn...
1ff4ee19af9cf0b98d4f8e0b15f170f9923d1ce870a0788729c8f58a0da3f7ca
MATLAB
1,171
42
function v = getOr(s, field, default, emptyOpt) % getOr Returns the structure field or a default if either don't exist % v = getOr(s, field, [default]) returns the 'field' of the structure 's' % or 'default' if the structure is empty of the field does not exist. If % default is not specified it defa...
3671ec8ac57f084d7946f8af1b498a774d0c332057608003e34a2d70d734ac88
MATLAB
1,171
57
function Z = concMovies(sizeThresh); %% % >>> OPERATION >>> % Concatenation of short TIFF calcium movies into a long one %% % >>> USE >>> %Select first TIFF file in the folder. The remaining files will be %automatically found and concatenated % Typical size threshold (sizeThresh) used for calcium movies: 20 MB % For ...
7613b99c577e59f75a1a00d0fc40a35192245a7c2df0819d4c52be17c1f6288d
MATLAB
1,171
37
function FormattedText = ColorText(input_text, colors) % FormattedText = ColorText(input_text, colors) % input text = cell(n,1) with chars in each cell % colors = double(n,3) in RGB format with range 0-1 % Output: cell array with formatted text. Can then use text(x,y,FormattedText) if size(...
b97f900892a5e6285c0d5fbabd02b5cc0f525638876e4c8ce4d31c7723eb2ac4
MATLAB
1,171
47
function C = mtimes(A,B) %MTIMES tensor-scalar multiplication. % % C = MTIMES(A,B) is called for the syntax 'A * B' when A or B is a % tensor and the other argument is a scalar. % % For tensor-matrix multiplication, use TTM. % For tensor-tensor multiplication, use TTT. % For tensor-tensor array multiplicati...
d48662277559f21cf7c3c76c0ec23cb9381daf994a15872d77a0b797d4656995
MATLAB
1,171
69
function plotTraces (traces,time,norm,color) % if isempty(color) % color = 'b'; % end if nargin < 4 color = 'b'; end if isempty(norm) norm = 'no_norm'; end N_cells = size(traces,1); snr = mean(max(traces,[],2)./min(traces,[],2)); if snr < 0 snr = -snr; end if snr < 1.8 norm_fact = 10/snr; e...
826d8829c8b8392edbc15c7d7294694660291aea83cfec90dd17e8da7f1c83b6
MATLAB
1,172
39
function [posR, triR, keeppos] = remove_double_vertices(pos, tri) % REMOVE_DOUBLE_VERTICES removes double vertices from a triangular mesh % renumbering the vertex-indices for the triangles and removing all % triangles with one of the specified vertices. % % Use as % [pos, tri] = remove_double_vertices(pos, tri) [po...
95aecf493275bd035732be5c145ee3a44e353d8f18293b9281c923f0571ac269
MATLAB
1,172
37
function [ template_seg ] = fcp_generatetemplatesegment( ) % FCP_GENERATETEMPLATESEGMENT check if already-segmented template exists. if so, use it. otherwise, generate! % determine path to template MRI fullPath = which('ft_preprocessing.m'); if ~isempty(fullPath) [pathstr,~,~] = fileparts(fullPath); info.templ...
ccaa55626efe4cdbf218a7bdcb56f7992cc9caaab20a0d4fadd4eb6dbaf64ef2
MATLAB
1,172
41
function p = MultiTestCorrection(p, nTests, Method, Inverse) % Correct p-values for multiple testing, by Bonferroni or Sidak method. % % p = MultiTestCorrection(p, nTests, Method, Inverse) % % Given a certain number of tests or comparisons (nTests), correct % p-values (p) to obtain the family-wise error ra...
79c0eaf240b8d7b7b65da4b37cf4bea015ea98049381a63164c641bd6b2368be
MATLAB
1,173
53
function LAN = arreglaeventos(LAN,inicio,final) currcode = cell2mat({LAN.event.type}); if isfield(LAN.event,'latency_aux') currlate = cell2mat({LAN.event.latency_aux}) else currlate = cell2mat({LAN.event.latency}) end if isfield(LAN.event, 'duration' ) currdura = cell2mat({LAN.event.duration}); else cur...