sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
6e342bf8d638638c00de5083c822ecd6451dad88e253f3c22a7783bc35363fe0
MATLAB
1,406
42
function [SNReff,bEff] = DWSSFP_SNREfficiencyOscillating(x,optSample,optScanner,bOsc,tau,~) %% % calculates DW-SSFP SNR Efficiency % % input: % x = array with difference between TR & gradient duration (incorporating deadtime) and the flip angle (ms) % optSample = T1 (ms), T2 (ms), T2* (ms) & D (um^2/ms) % optScan...
8175d1442f7afefa27c0fe33566c8866cf22ccf176b902dfe39e64dfe8600251
MATLAB
1,406
56
function chm = wmodacorr2(ch,targetAcorr,W,Wsqrt,epw,Niter,Na,Wind,Wsz,Wvec) % %----------------------------------------- % chm = wmodacorr2(ch,targetAcorr,W,Wsqrt,epw,Niter,Na,Wind,Wsz,Wvec) % % modify the weighted autocorrelation of an image matrix by taking % gradient steps (see wacorr2.m) % % ch: image % targetAco...
c54777002ecb24ddafced7e9ac824345e637dff96a15391fbcafdf42a1b06a8d
MATLAB
1,406
42
%%Plots binned data for each lap in grey and the mean data in black %Chad Heer; Sheffiel Lab function [] = plot_laps_axon(position, bin_mean_activity,tasks,ylims) %position = position for each bin %bin_mean_activity = {task} (lap x binned mean activity) %tasks = string array listing the order of the tasks %ylims = y l...
d880778e490c233be35f778d79c1ab053b85181289ff185e793de468e230f7cf
MATLAB
1,406
65
function plotRasterTraces (spikeRaster,traces,bin,norm); %% Downsample spike raster to match traces if nargin < 4 norm = 'no_norm'; end N_cells = size(traces,1); time = 1:size(traces,2); switch bin case 'bin' spikenums_mod = logical(sepblockfun(spikeRaster, [1,2], 'max')); case 'noBin' ...
de50c158830ba9d34a8a59f6f17bd21ed0ca497cb47e174ecb015b0818fbaa8a
MATLAB
1,406
45
function [channelsRanked, C] = meg_loadChannels(matDir, channelSelectionType) % function [channelsRanked, C] = meg_loadChannels(matDir, channelSelectionType) % % INPUTS % matDir % string, full path to mat directory % % channelSelectionType % method used to sort the channels, corresponds to an existing file name, ...
9e0de9408830c7e1b9cd5f2e78802da83a7687a7ffc51b699a158de843cbaa45
MATLAB
1,407
59
% Author: Milena Capiglioni, University of Bern % Contact: milena.capiglioni@extern.insel.ch % Last update: Nov.2023 function [min_s,max_s,aux_max,norm_min,norm_max] = im_overlay_RFR(Yoff,contrast,mask,min_s,max_s,aux_max,norm_min,norm_max,ax) gray_im = Yoff; over_im = contrast; alpha_mask = mask; n_colors = 256; %...
cd42d4a54c01f383b64bba8edd4b56b567ee6f44bcc93b1fae23aad16e805c7b
MATLAB
1,407
42
function Options=Config_text(varargin) [varargin,IncludeTouchSensor] = Utilities.ProcVarargin(varargin,'IncludeTouchSensor'); [varargin,TaskLabel] = Utilities.ProcVarargin(varargin,'TaskLabel',{}); % Config file that determines how to process the Symbolic Task Options.TaskType='experiment2'; Options.TaskVe...
e58bedba428164b72b3d8a90bfff4eb9021548b20c9c64d48dc1c8110ee29b7a
MATLAB
1,407
43
function d = bhattacharyyaDistance(x0,x1) %d = prtUtilBhattacharyyaDistance(X1,X2) %d = prtUtilBhattacharyyaDistance(DataSet1) %d = prtUtilBhattacharyyaDistance(DataSet1,DataSet2) % Copied and adapted by @dhasegan on 2021/12/16 from % https://www.mathworks.com/matlabcentral/fileexchange/46392-pattern-recognition-toolb...
0bed5ab643d6a8b23365d9b92156df4c6aee2dea4d673648b1faf4e3a9884e14
MATLAB
1,408
42
function [fx,J,dfdp] = f_embed(Xt,Theta,ut,in) % evolution function for dynamical system's delay embedding % function [fx,J,dfdp] = f_embed(Xt,Theta,ut,in) fxd = zeros(in.dim.n,1); Jd = zeros(in.dim.n_embed+in.dim.n,in.dim.n); dfdpd = zeros(size(Theta,1),in.dim.n); if sum(in.options.delays(:)) > 0 for i=1:in.dim.n...
608962ba4f09c9ac59704dca326eaa65260770d8915751c8d8b049ed25c6343e
MATLAB
1,409
29
function trial_summary = getTrialSummary(paths, num_markers, thresh) % initialize output file getTrialSummary_output.getTrialSummary = 'getTrialSummary.mat'; fcp1_output = loadjson([paths.anout_grp '/fcp1_output.json']); ppts = load_participants(paths, 'fcp1'); ppts = ppts.Var1; ppts = cellfun(@(x) x(1:4), ppts, 'Uni...
94e9e732f7a255944cd156b1c04e147b988f9b3d52ba37bde72e26380367e5f3
MATLAB
1,409
61
% This script loads model and NIfTI data when availble % It can be used as a starting point % % Copyright SNM 2017-2024 %% Load NIfTI data % This block is optional (only if NIfTI data are available) tic nifti_filepath = 'T1w.nii'; if exist(nifti_filepath, 'file') VT1 = niftiread(nifti_filepath); ...
0f2f191b3dc641156d4290bed614d2f4155d28e857ac8baf8b9d7f264112508a
MATLAB
1,410
47
function M = prepare_mesh_fittemplate(headshape,template) % PREPARE_MESH_FITTEMPLATE computes an affine transformation matrix between 2 point clouds % % This function relies on cpd toolbox from Myronenko, see https://sites.google.com/site/myronenko/research/cpd % % % See also FT_PREPARE_MESH % Copyright (C) 2019, S...
a937a127286f15441f501f577daf81d377ab8b5521d9b8c8e37db0e7b43a2e76
MATLAB
1,410
69
function Plot3AxisAtOrigin(x,y,z,s); % PLOT3AXISATORIGIN Plot lines and points in 3-D space with % axes through the origin % % Usage: % Plot3AxisAtOrigin(sin([-3:.3:6]),cos([-3:.3:6])-0.75,[-1:.1:2],'r') % title('Plot3 with Axis Through Origin'); % % It's not fancy, but it works % % 'just an example for CSSM % % s...
1318902af30cd150c5770e6b73e52b9ce37c1fecb4a4cc27fb36bdfae89a69bc
MATLAB
1,411
40
% $$C\frac{dV}{dt}=a(V-V_{rest})(V-V_c)+I$$ % Input defined at Line 29 clear; %clear all variables % close all; %close all open figures %DEFINE PARAMETERS dt = 1/1000; %time step [ms] t_end = 1200; %total time of run [ms] t_StimStart = 100; %time to start injecting current [ms] t_StimEnd = 1000; %time to end injecting...
87710343b71ca53f748abbee8c6f1cc3dfbdc1590d1955097397d1779bd9f96f
MATLAB
1,411
40
% SSEFunction.m % Sarah West % 6/30/22 % Function that calculates sum of squares on a PLSR model. Taken from % source code of Matlab built-in function plsregress. function sumsqerr = SSEFunction(Xtrain,Ytrain,Xtest,Ytest,ncomp) XmeanTrain = mean(Xtrain); YmeanTrain = mean(Ytrain); X0train = Xtrain - Xmea...
8d53b2b058374aa577c227c22ef360e0f0078fd1a21c06818d1501abd8eacb1e
MATLAB
1,412
40
function [F P]=y_ancova1(DependentVariable,GroupLabel,Covariates) % [F P]=y_ancova1(DependentVariable,GroupLabel,Covariates) % Perform one-way ANOVA or ANCOVA analysis % Input: % DependentVariable - the dependent variable. n by 1 vector % GroupLabel - the label indicate which group is. eg. [1 1 1 2 2 2 2 3 3 3...
9f48b6553bf1039484fc5266846d0d48acc1c13fe92aa98ee53887f0fc04b852
MATLAB
1,412
43
function [v] = v_discounting(x,P,u,in) % evaulates 2D utility function at u % function [v] = v_discounting(x,P,u,in) % This function computes 2D utility functions, as in, e.g., temporal % discounting models. Four different functional forms can be used: % hyperbolic, exponential, linear and basis functions sets. % IN: %...
2d59308c2040a9a054bf927439b06a0a712db26eebf9ecaca89ad024a100b666
MATLAB
1,413
20
function expInfo = expInfo_specifyKeys(expInfo) %% specify keys % Use OS X keyboard naming scheme across all plattforms % Otherwise LeftControl/RightControl are not recognized KbName('UnifyKeyNames'); expInfo.keyLeft = [KbName('LeftControl'), KbName('LeftAlt'), KbName('LeftArrow'), KbName...
6c983b507829b156f9afd19c96c15cf30a7da76fbf5816813691228a39dc83d6
MATLAB
1,413
59
function structexport(s,fname,varargin) % structexport(s,fname,varargin) % Optional PVs: % - format. One of {'csv' 'xls'}. Defaults to csv. format = myparse(varargin,'format','csv'); assert(ismember(format,{'csv' 'xls'}),'Invalid ''format''.'); pvargs = {}; if strcmp(format,'xls') pvargs = {'nansAsStrings' true};...
707338793f3f1e06ce54a85296b866aa75a751c1a7885c2e99014b48825c2a8f
MATLAB
1,413
93
% load camera results (for setting active images, n_ima,...) load camera_results; % Projection settings: wintx = 12; %8; winty = 12; %8; nx = 1024; ny = 768; dX = 32; dY = 32; dXoff=511.5; dYoff=383.5; proj_name = 'proj'; %input('Basename projector calibration images (without number nor suffix): ','s'); camera_na...
8a28f81e0cfce764f17a1257dfd3f7e0ab73660cb7a20b8c87951313d46f74dd
MATLAB
1,413
54
function tokens = tokenize(str, delimiter) % Tokenize a string % If delmiter is more than one character, it is assumed that you want % to tokenize based on multiple delimiters - if not use regexp instead. % % Empty cells are removed %% Example % str = 'a;man;a;,plan;a ,,,canal;panama! ' % delimiters = ';, '; % split at...
09e90b71ee1bfee7517b466ecba03db6ddce9c68cc9bc543c96987ade1a9a6a4
MATLAB
1,415
44
function V = mttkrp(X,U,n) %MTTKRP Matricized tensor times Khatri-Rao product for sparse tensor. % % V = MTTKRP(X,U,n) efficiently calculates the matrix product of the % n-mode matricization of X with the Khatri-Rao product of all % entries in U, a cell array of matrices, except the nth. How to % most efficien...
c192bbe78dd2998d3c3c5f17e47f74150459974e350cd7a6bc32694627e453c1
MATLAB
1,415
87
function loc_phys=mk_sensors_plane(sensors,pars); [ns_ori,ndim]=size(sensors); if nargin>1 if isfield(pars,'rot'); rot=pars.rot; else rot=0; end if isfield(pars,'nin'); nin=pars.nin; else nin=ns_ori; end if isfield(pars,'indices'); indices=pars.indices; else indice...
e0094534cb87e078768673588da18d11f110a75156a74c2ab0b8e5e0dc227cbd
MATLAB
1,415
35
function works=testNewFileCreationInJLabel() try jLabelFigure=JLabel(); pause(1); eventData=[]; JLabel('menu_file_new_Callback',jLabelFigure, eventData, guidata(jLabelFigure)); pause(1); projectSetupFigure=findall(0,'tag','figureProjectSetup'); behaviorNameEdit=findall(projectSetupFigure,'tag','editName'...
102bb59394de969b8de700e405007b3d90ab75cf1297e18ab12eca3519e7c561
MATLAB
1,416
93
classdef NNdata < VectorObject properties raw_data file_idx spiketimes label_idx categorical % timestamps to determine if more training is needed timestamp_last_modified char = datestr(now) timestamp_last_trained char = datestr(now) % neural network performance accuracy (1,1) double = 0 acceptable_...
aaa02f45bd3449921688df015cc7004fed7318786256d2c768722415c6608ffd
MATLAB
1,416
53
function [allVec_rest,allTs_rest] = Closed_Loop_Rest() % Record resting state EEG % allVec_rest: Resting EEG (channel*sample) % allTs_rest: Timestamp of each sample %% Parameters fnative = 10000; % Native sampling rate fs = 1000; % Processing sampling rate %% Initialization downsample = floor(fnative/fs); all...
05820470188e5c180b7c578b8521d7422f67223e89f161589277575af7e10ba6
MATLAB
1,417
51
addpath(genpath('external')) baseimg=zeros(91,109,91); cfg.type='MNI'; cfg.coordinates=[0 0 0]; cfg.imgsize=[91 109 91]; [xorig yorig zorig]=bramila_MNI(cfg); % sphere is x^2+y^2+z^2=r^2 r=10; for x=1:91 for y=1:109 for z=1:91 cfg.type='space'; cfg.coordinates=[x y z...
2bbf8f09bb315a93069d4673e059e0e9d0ded7411c493a9afe138bfe80c6208c
MATLAB
1,418
57
function tests = SWITCH_tile_processingTest tests = functiontests(localfunctions); end function setup(testCase) testCase.TestData.tempDir = '/mp/nas1/share/tmp/testworks'; if ~exist(testCase.TestData.tempDir) mkdir(testCase.TestData.tempDir) end img={}; chans = 1 for i = 1:chans ...
28469d4af71441140907380dea7dab6130d83456629223a7c2aab0222e953898
MATLAB
1,419
53
% RSKELF_SPDIAG_SV_N Dispatch for RSKELF_SPDIAG with DINV = 1 and F.SYMM = 'N'. function D = rskelf_spdiag_sv_n(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 ...
cd3e0418e6f8dc2d22327343dcba515cf09334b89af0ef03455a2999e3aab88c
MATLAB
1,419
60
%% Illustrate the robustness of the student and laplace distributions compared to the Gaussian. % %% % This file is from pmtk3.googlecode.com function robustDemo() 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); pr...
d9c44ea6d7583c71f6125f6ad4073d9a520a851cb6ab9e6080a976eb79a9f9ab
MATLAB
1,419
53
% RSKELF_SPDIAG_MV_N Dispatch for RSKELF_SPDIAG with DINV = 0 and F.SYMM = 'N'. function D = rskelf_spdiag_mv_n(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 ...
1c0f02f42001f4523d5263c40b99b2633ced2cefdd7c21f162e7c7fb75450d07
MATLAB
1,420
40
function st = inside_tetrahedron_vectorized(P,tets, nodes) % % st = inside_tetrahedron_vectorized(P,tets, nodes) % % This is vectorized vertion of 'inside_tetrahedron' % % Inputs: % P: Query point % tets: tetrahedron connectivity (n x 4) % nodes: coordinates of tets (m x 3) % st: % rows of 'st' are 1 (true) if...
4068308daa139c76003b255a93ee4c85a605ddb08ad175ccdc87ad6354206c1a
MATLAB
1,420
53
% RSKELF_SPDIAG_MV_S Dispatch for RSKELF_SPDIAG with DINV = 0 and F.SYMM = 'S'. function D = rskelf_spdiag_mv_s(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 ...
5aaca4e8c4a4c66e7b790de1c3ac13f9a3bd19287f43667c1c15601fbb2b7ec7
MATLAB
1,420
53
% RSKELF_SPDIAG_SV_S Dispatch for RSKELF_SPDIAG with DINV = 1 and F.SYMM = 'S'. function D = rskelf_spdiag_sv_s(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 ...
029ceaecf416e5be604fc8dbf3b7388c166f6b9abe215fccd9125ca5442ed529
MATLAB
1,421
52
function h_imstack3Loader(num, siz, overlapFlag) % this function load several h_imstack3 instances and spread them on screen % screenSiz = [1920 1080];% lab 27" monitor % screenSiz = [1440 900];%notebook screenSiz = get(0, 'screensize'); screenSiz = screenSiz(3:4); spacing = [20, 65]; %[x, y] if ~exist('si...
598b0175b2db6443665f03375c559bd7b4f57949c2f39e988932e6572df57095
MATLAB
1,421
74
% Mixtures of negative binomials % Demo for Sohrab function negBinomDemo() for trial=1:2 N = 100; theta = 0.5; xs = 1:N; probs = []; c = 1; if trial==1 for i=1:numel(xs) x = xs(i); probs(i,c) = binopdf(x,N,theta); end names{c} = sprintf('binom(%d, %3.1f)', N,theta); c = c+1; end mu = N*theta; if trial==1 thet...
12c61ae3ffeab242402de51ff6cd0e199f3cb9989ecfedcd57db63d18b7a777a
MATLAB
1,422
34
function [ fx ] = f_BSLinGame(x,theta,u,in) % evolution function for BSL learner engaging in dyadic games % [ fx ] = f_BSLinGame(x,theta,u,in) % BSL is simply tracking the log-odds of P(o_t=1|o_{t-1}), where o is the % opponent's binary action. This variable is updated according to a % Laplace-Kalman filter, yielding 2...
7630940a184e496d07320a76c766dc66dc9b50b7c879c7788bde1383515e72cb
MATLAB
1,422
56
function [yhat, py] = mlpPredict(model, X) % Multi-layer perceptron : prediction % % For classification: % [yhat, py] = mlpPredict(model, X) % yhat(i) is in same domain as ytrain, % py(i,k) = p(y=k|X(i,:)) % % For regression: % [mu, s2] = mlpPredict(model, X) % mu(i) = E[y|X(i,:)] % s2(i) = Var[y|X(i,:)] % This file i...
a55539a6f92d00f327816313de05f7813ac605d8cd757ff31cfddb8fde3d95b8
MATLAB
1,422
61
function A = lan_smooth_d1(A,n) if nargin==2 if n == 0 return end for x = 1:n A=lan_smooth(A); end else nn = isnan(A); A(nn) = 0; [d1 d2]= size(A); A = ( A + ... (cat(1,A(1,:),A(1:d1-1,:)))/2 .... + (cat(1,A(2:d1,:),A(d1,:)))/2 ... ...%+ (ca...
43e594a06723904756ac21718f6bc3c54ab01ca76fa68f5a5c65d10c49477760
MATLAB
1,423
67
% % _ _ % ___ _ __ __ _| |__ ___ ___ _ __| |_ % / __| '__/ _` | '_ \/ __|/ _ \| '__| __| % | (__| | | (_| | |_) \__ \ (_) | | | |_ % \___|_| \__,_|_.__/|___/\___/|_| \__| % % allows you to manually cluster a reduced-to-2D-dataset by % drawing lines around clusters. ...
7d672bf7a55c258f330651cba688392fe88d5e06866888b51fcfae30adca6be8
MATLAB
1,423
46
function [IDIF_corrected, rc, m_tb] = chen_correction(IDIF, IDIF_time, venous, venous_time, Ct, Ct_time) %It performs Chen correction to IDIF % % Chen et al., (1998). % Noninvasive quantification of the cerebral metabolic rate for glucose % using positron emission tomography, 18F-fluoro-2-deoxyglucose, the Patlak % ...
b237b31689601763e55ae188a9f42d7c1a3af0e43e538dfdfdd88d103620cdd3
MATLAB
1,423
1
% TSLOADRAW Load a MEDPC file onto the Experiment structure % TSLOADRAW(FILENAME) loads in the data from FILENAME into TSData. function [ SUCCESS , ExperimentID, SubjectID, Phase, Box, MatlabStartDate, Duration, tsdata, Notes, Weight, Program, FileReportedUnits ] = TSloadMEDPC(filename) SUCCESS = 0; %disp('Openi...
fac0e67a3b92e1166ebd5a507500a38abfafb9213a622166b983a44701e2426f
MATLAB
1,423
37
function [argout] = mxSerialize(argin) % MXSERIALIZE converts any MATLAB object into a uint8 array suitable % for passing down a comms channel to be reconstructed at the other end. % % See also MXDESERIALIZE % Copyright (C) 2005, Brad Phelan http://xtargets.com % Copyright (C) 2007, Robert Oostenveld http:/...
0750a3753cf7fcc63f5953f81d3f1e5d15b3b76f613e58720040b3d514893e88
MATLAB
1,424
52
function C = xor(A,B) %XOR Logical XOR 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 ...
084ef3cb1c1885dfcfd8f40d68c78032631bc3df8787a3f555bd6d16a7c2cdac
MATLAB
1,424
47
function S = splitString(varargin) % Split a string into multiple lines based on camel case % % Inputs % % '-S' the string to split % '-minSize' does not split at all if length(S) < minSize % '-maxSize' splits no matter what, (even if no camel case change) if length(S) > maxSize % '-center' if true, ...
93e23d0770c2a2afec601249ed7a82f303c563b2a44d575dc0a837db1442f565
MATLAB
1,424
51
function [impreds,sta] = predictSingleSubunitModel(mdlparams, imEnsemble, nrx, nry) %UNTITLED Summary of this function goes here % Detailed explanation goes here [ypix, xpix, Nims] = size(imEnsemble); imenuse = reshape(imEnsemble(nry, nrx, :), [numel(nry)*numel(nrx), Nims]); [xuse, yuse] = meshgrid(single(nrx)-0....
f2c92ae5fa267f8ec78d03b8c4ff013bdf8a43ca1db0e1c63f876eef3df06a13
MATLAB
1,424
54
function [ behavior,filename ] = bz_LoadBehavior( basePath,behaviorName ) %[ behavior,filename ] = bz_LoadBehavior( basePath,behaviorName ) function for %loading behavior.mat files. % % %DLevenstein 2017 %% if ~exist('basePath','var') basePath = pwd; end baseName = bz_BasenameFromBasepath(basePath); if ~exist('be...
42985f3330200f2c40a7660dedcbb0202fbe08cf2ff57c57dc691f10657afdc8
MATLAB
1,425
49
%% We compare the posterior on 2 graphs, X1-X2 and X1 indep of X2 % Here X1 and X2 are discrete % We use tabular CPDs with uniform priors % This file is from pmtk3.googlecode.com % simulate handedness data, X1=gender, X2=hand % suppose we have N1 males (1), N2 females (2) % of which y1 males are LH (1) and y2 female...
dfeb8822726758cdf5b1cb4f0f650a71ea541cae2871cef48f835fd67b179c1c
MATLAB
1,425
44
%% zscore_inv % Inverse a Z-score transformation to (projected) original values using % sample mean and standard deviation; % zVal = (xVal- xMean)/xStd ==> zVal*xStd+xMean = xVal; % % INPUT: % zscore = [N_samples x N_trials] data; %calcuated columnwise if N_trials % > 1 % % Copyright (C) 2023 Trevor ...
1e743dd00f0c865a578285f52435f2fd546d5c85078e0e172907ca77c1653e81
MATLAB
1,426
49
function outpoints = y_icbm_spm2tal(inpoints) % % This function converts coordinates from MNI space (normalized % using the SPM software package) to Talairach space using the % icbm2tal transform developed and validated by Jack Lancaster % at the Research Imaging Center in San Antonio, Texas. % % http://www3.intersc...
29dbde987fda0f5b0133257e22ed5131dcf19e471142a8c0d832fbe9ecaf7229
MATLAB
1,426
40
function e = hystThresh(e, g, thresh, conn) %HYSTTHRESH carries out hysteresis thresholding, as for Canny % E = HYSTTHRESH(E, G, THRESH) takes a raw edge map, a gradient magnitude % array and a threshold or pair of thresholds, and returns a new edge map % wherever the gradient magnitude exceeds or equals the ...
473d476e3d53c6e70748ebaca2c462b8a0b1e83d54dc315f177414522ffb896b
MATLAB
1,426
34
% SOFA API - demo script % load headphone IRs from a SOFA file from the ARI headphones database % Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences % Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (t...
51de834636f159d90b098c9ac0a4a9c3db44b40c4364de5260b909ada13e506b
MATLAB
1,426
53
function [Q Qds Qds_Li C] = calc_modularity_TL(Ci,B) % Calculate different quality metrics % This code was originally a part of MSCcodebase (Gordon et al. 2017 Neuron) K=sum(B); %degree N=length(B); %number of vertices m=sum(K); % B=B-(K.'*K)/m; % % s=Ci...
7280312f8fbea98ae4605ca334af7f74f1e397bc223111d74b817595c29d7f25
MATLAB
1,426
33
function [FileList]=CurrentVariableMemoryUsageTracker(Details,SizeRange) %use CurrentVariableMemoryUsage(whos,CutOff) in bytes warning on all warning off verbose warning off backtrace FileList=[]; FileCount=0; for i=1:length(Details) if Details(i).bytes>SizeRange(1)&&Details(...
cd94c0473cb1f1c8e11b949d161ef359633490c2255ed492c7f6d1f19ef36db1
MATLAB
1,426
15
%% 非线性特征 | nonlinear features %% 平均瞬时能量 Mean Energy % X: single channel EEG/imfx/hilbert(imfx) signal (either a row vector or a column vector) % 对于signal或者imf这样的时域信号,abs(signal).^2得到的是每个点处的瞬时能量(即瞬时振幅的平方,是一个长度为N的向量),再取mean后得到的是平均瞬时能量(是一个值) % 对于hilbert(imf1)这样得到的是imf的解析信号表示(是个复数),abs(hilbert(imf1)).^2得到的是每个点处的瞬时能量(同样是瞬时...
ee5386b5a936e9c7f67b457b29861bb5471c67f868e0b42a1bdf8d51feac9a5f
MATLAB
1,426
52
function [K] = VBA_spm_perm_mtx(n) % Returns a matrix of indices permuted over n % FORMAT [K] = spm_perm_mtx(n) % n - (scalar) number of indices % K - (2^n x n) permutation matrix % n - (vector) indices % K - (length(n)! x n) permutation matrix %______________________________________________________...
ff426e97cc87c2e064bc7e48dbb84d96ffc327886db18aa49999afbfc7bcd4e5
MATLAB
1,426
62
clear; clc; load data_for_figure8.mat srate = 500; %% param.plot = 1; param.minimum_cycles = 2; param.ovlp_threshold = 0.50; param.frequency_axis = 1:40; [cho_output] = CHO_v22(raw_data, srate, param); % [cho_output] = CHO_v25(raw_data, srate, param); % %% % target_freq = 50; % filtered_data1...
0ef82381432bf19ec32244f0acec6f625272ea79352a656d5fc3cd205e61b46e
MATLAB
1,427
36
function [rt] = isDatasource(src) % % % %<PRE> % This file is part of dspace-core. % % Copyright (C) 2020 University Zurich, Sepp Kollmorgen % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU Affero General Public License a...
5b797b70f996cfcce45e4f929f68af26d448495cc815c93d351715e8fdbbc904
MATLAB
1,427
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 = 70; OptimalityToler...
de670cd514a4c164a04e38abdfc37537579464145f76d0adabcdfbb8c5be96d6
MATLAB
1,427
58
function [fd_bin_v_sq,fd_bin_v_rct] = get_fixed_distances(v) fd_sq = zeros(5,2,v.env.Ny_sq, v.env.Nx_sq); fd_rct = zeros(5,2,v.env.Ny_rct,v.env.Nx_rct); for y = 1:v.env.Ny_sq for x = 1:v.env.Nx_sq fd_sq(1,:,y,x) = [x-0.5, v.env.Ny_sq-y+0.5]; end for x = 1:v.env.Nx_rct fd_rct(1,:,y,x) = [x-...
8ad63d4a911e095bfe3bb57d6bc91b6e6f0130150184444ac08ea665f05f0457
MATLAB
1,428
62
%% Detect small calcium transients Tr = traces; disp('Detecting transients...') [NCell,Nz] = size(Tr); % Savitzky-Golay filter Tr = sgolayfilt(Tr',3,5)'; % figure % for i = 1:NCell % plot(time,traces(i,:)+i-1) % hold on % end % Detect Calcium Transients using a sliding window TrRest = Tr(:,mvm.restEpochsI...
7f6cb8ca985a5b0e2891cf3d8b3ee5902de71821b8aea391d4a4317302a97e14
MATLAB
1,429
46
function h = mexhat(nu) ; %MEXHAT Mexican hat wavelet in time domain. % H=MEXHAT(NU) returns the mexican hat wavelet with central % frequency NU (NU is a normalized frequency in Hz). % % NU : any real between 0 and 0.5 (default : 0.05). % H : time vector containing the mexhat samples. % length(H)=2*ceil(1.5/NU)+...
46804887bdf7b3867979d21f3bb0e293441eb508b84012c35c763d84e780bd8c
MATLAB
1,430
54
function [V1,V2]=get_example_data % get_example_data is used to make some rigid and nonrigid transformed % 3D MRI example data for the registration examples. % % example, % [V1,V2]=get_example_data; % % Function is written by D.Kroon University of Twente (October 2008) addpaths; load mri; D=squeeze(D); V2=s...
4b7d08d161c5c9be01ac5d21cf4435762a5a0d83da04e529476c1fbddce64b46
MATLAB
1,431
42
clear clc %{ delete(gcp('nocreate')) myCluster.NumWorkers = 8; parpool('local',8) %} NineMuscleMorphParaInitial = load('NineMuscleMorphParaInitial.mat'); NineMuscleMorphParaInitial = NineMuscleMorphParaInitial.NineMuscleMorphParaInitial; MaxFunctionEvaluations_Data = 10^300; MaxIterations_Data = 70; OptimalityToler...
a3ac1e0fd4a23abe95adcdfc6897be92573d65bdbb9ec162d3f7c6dfdd199a5a
MATLAB
1,431
50
function [model, logev] = logregFitEbNetlab(X, y, pp) % Empirical Bayes logistic regression using Netlab's evidence procedure % X is n*d, y is d*1, can be binary or multiclass % Do not add a column of 1s % This file is from pmtk3.googlecode.com pp.addOnes = false; % netlab does this already [model.preproc, x] = prep...
dd1cf72827d6cf4fe6dfc14a434384d39bea250cb7962a0060afcd74206ce731
MATLAB
1,431
35
function check_position_scaling(basepath) % Checks SNLab behavior file position data to see if coordinates have been % scaled and translated to be centered at 0,0. If not, scales coordinates % realtive to maze center. basename = basenameFromBasepath(basepath); % load session and behavior file try load(fullfile(...
24215dadf3f6e159805516ce03718c8fc4387df4b12568624892948807d9041e
MATLAB
1,432
46
function savevar(filename, varname, value, hashfile) % SAVEVAR is a helper function for cfg.outputfile % % See also LOADVAR % Copyright (C) 2010, Robert Oostenveld % % $Id$ assert(ischar(filename), 'file name should be a string'); assert(ischar(varname), 'variable name should be a string'); ft_info('writing ''%s'' ...
5abb62743bac57c26087879cf26a5252b8115f384ea02c8069c43bcaca0379d7
MATLAB
1,432
36
function reactionTimesToExcel(reactionTimeSummary, outdir) %% Purpose: % This function saves the reaction time summary data (output of the % reactionTimes function) as an excel file for each participant. This % function is to be run only after the reactionTimes function has been run % and is only relevant if the user ...
5ee5bf41970a533a23ffa178396de05800c44338e3b0136b85c0dcad394fe5e4
MATLAB
1,432
46
function S = mdtvoting( E, s, sg, m, d, v ) % MDTVOTING Applies multiscale dense 2D tensor voting for ridge detection % in a range of input thickness (gaussian prefiltering) and % scale factor % INPUT: % E - Input tomogram (foreground dark) % s - Scale factor range [s_min s_max s...
6b6e8f0ad0e3a794f7cfce6e50260f045aa45d637664ffdcaec61cfdab260fea
MATLAB
1,432
51
function pw = lme_realizedPower(stats,C,alpha) % pw = lme_realizedPower(stats,C,alpha) % % Power associated with a contrast C for the actual realization of the % linear mixed-effects model (Depends on the Statistics toolbox). % % Input % stats: Struc...
9ebb457ad71113d7246f45c85eca1bc920970d6bf0e91e165db9b5b19244699b
MATLAB
1,433
61
f = @(x) tanh(2*x); %f = @(x) x.^2; sigma = 0.25; N=200; xs = linspace(-4,4,N); ys = linspace(-4,4,N); x=[]; y=[]; px=[]; pyx=[]; for i=1:N; for j=1:N; x(i,j) = xs(i); y(i,j) = ys(j); px(i,j) = normpdf(x(i,j),0,1); pyx(i,j) = normpdf(y(i,j),f(x(i,j)),sigma); end; end; p = px .* pyx; px = (sum(p,2) * ((xs(end)-xs...
dfd60623cd843a50810df1fbf26123c6bc61ea6e3d20234522859d4772307cea
MATLAB
1,433
44
function [fm,B]=locfreq(sig); %LOCFREQ Frequency localization caracteristics. % [FM,B]=LOCFREQ(SIG) computes the frequency localization % caracteristics of signal SIG. % % SIG is the signal. % FM is the averaged normalized frequency center. % B is the frequency spreading. % % Example : % z=amgauss(160,80,50...
5d0566bb88a4814aae0c0aebc6b71b30fa217c857ffd05d6b0246fe05f8b4e3b
MATLAB
1,434
65
% function dividir % EEG = datos en estructura eeglab (EEG.data) % pr = epocas de la primera divición % sg = epocas de la segunda divición % op == 1 separa la primera divición % == 2 separa la segunda divición % e.g.: EEG = dividir(EEG, 75, 7, 3, 'DC_controles_ica.set', 'DC_objetos_ica.set') function EEG = divi...
b23df46f076ae264b64c5f05505b439fc6c558070c046da04be3d3cd66473fbf
MATLAB
1,434
56
function P = fmorph( I, it, mode ) % FMORPH Dilation/Erotion over a forground % INPUT: % I - Input tomogram where 2 is foreground and 1 background surface % it: number iterations % I: if 1 erode, otherwise dilate % OUTPUT: % P: output foreground (2) and background (1) % % See also: membl...
b800da0b46e79b62df910f289810a91002c78beac75bf6cc43586252837392f1
MATLAB
1,434
38
function bemf2_graphics_vol_field_log(temp, th1, th2, levels, a, b) % Volume field graphics: plot a field quantity temp in the observation % plane using a planar contour plot. Revision 071318 % % temp - quantity to plot % th1, th2 - two threshold levels introduced manually % levels - number of levels in the ...
fe2dba3c08ef1a4620f89916161fe7b934b1a9f7e1d87c446d4f7cafb1bea2f4
MATLAB
1,434
33
function [W_thr, Wcv] = GLB_threshold_consistency(Ws, p) %THRESHOLD_CONSISTENCY Threshold edges ranked by consistency % % W_thr = threshold_consistency(Ws, p); % % This function "thresholds" the group mean connectivity matrix of a set % of connectivity matrices by preserving a proportion p (0<p<1) of the...
8019e8282cfeeef12a60b5f35bc431e84e189efbc8beb6e8e4af5c75668da81b
MATLAB
1,435
36
function [fx] = f_rwl2(x,P,u,in) % modified RW learning rule, with gains/losses asymmetry % function [fx] = f_rwl2(x,P,u,in) % This evolution function implements two different models (cf. in.model % switch). If in.model = 'utility', different weights are given to % negative, neutral and positive feedbacks. If in.model ...
df2c9e6c72855392536bfa9261d01a030b54edf7e5dbf47b4c30f36aaa7dbe52
MATLAB
1,435
54
function [model] = linregRobustStudentFitUnconstr(X, y, includeOffset) % Unconstrained optimization of linear regression with student noise model %PMTKauthor Yi Huang % This file is from pmtk3.googlecode.com if nargin < 4 includeOffset = 1; end [N, D] = size(X); if includeOffset X = [ones(N, 1), X]; D =...
e66b2e53717044275241d4166222877a0a5d016d99bdd25980d08ea3f43e4ffa
MATLAB
1,435
67
function error = wlProc_calcWaveErrorAbsolute( ... bigwave, bigstart, subwave, substart) % function error = wlProc_calcWaveErrorAbsolute( ... % bigwave, bigstart, subwave, substart) % % This function calculates the "error" between an event waveform and a % reference waveform. % The "Absolute" version computes this...
0ddb699dd7e105a6ab319f2cd4d99433d35604d20b9eadf3bf3e1c168674ffb3
MATLAB
1,436
57
function model = gaussFit(X, prior) % Fit a multivariate Gaussian via mle / map % % model = gaussFit(X) % MLE % model = gaussFit(X, 'map') % MAP with weak prior % model = gaussFit(X, prior) % MAP, where prior is a NIW model % with params mu, Sigma, dof, k % %% % This file is from pmtk3.googlecode.com [N, D] = s...
1cc186cc72ed48facdd25f272905e9f998c784d054cd858cb0f11677edf73ef6
MATLAB
1,436
60
% Checks the index of an image function [dattype,dat] = iimg_check_indx(dat,volInfo,varargin) % :Usage: % :: % % [dattype,dat] = iimg_check_indx(dat,volInfo,[outtype]) % % :Inputs: % % **dattype:** % is 'full' or 'masked' % % :Optional Input: % % **outtype:** % 'full' or 'masked' output % % .. % ...
868c1caa0e269351f25cf1269fc6eee957d5cf06f92029e788c023fe55c2cc07
MATLAB
1,436
52
function xticklabelRot(xTickLabels, angle, fontsize, ydelta) % function xticklabelRot(xTickLabels, angle, fontsize) % Angle defaults to 90 % fontsize defaults to current % % Example: % figure(1); clf; bar([1 2 3]); xticklabelRot({'foo','bar',22}, 90) % This file is from pmtk3.googlecode.com %PMTKauthor Denis Gilber...
ea8c76e5abcabc273274ba3e6299729cfe893ff634dd073afcc1937fad944532
MATLAB
1,436
74
function A=wnorm(L,grid,elecs,p,q); % calculates inverse operator according to weighted minimum norm % usage A=wnorm(L,grid,elecs); % Input: % L: nchan x nvoxel x 3 tensor of forward leadfield % grid: nvoxel x 3 matrix of voxel-locations % elecs: nchan x 3 matrix of electrode-locations % Output: % A (3*nvoxel) x ncha...
538d8a3ddcf2d2af2515c52295cb902fca18be286f125713664051b00a1a2a0c
MATLAB
1,437
42
function [Data, Header] = y_ReadMat(FileName,MatrixNames) %function [Data, Header] = y_ReadMat(FileName,MatrixNames) % Read Mat file into 1D Data and Header. For using DPABI functions % ------------------------------------------------------------------------ % Input: % FileName - the path and filename of the image file...
5ef50f0a8f7850aa25086cee3bf7d5597e3b146ca55546759df13d2faeb6f354
MATLAB
1,437
43
function [yhat, yprob] = knnPredict(model, Xtest) % K-nearest neighbors classifier % (ties broken by picking lowest class) % ypredProb(m, :) is the empirical distribution over classes % This file is from pmtk3.googlecode.com [yhat, yprob] = knnClassify(model.X, model.y, Xtest, model.K, model.C); end function [ypre...
ddfd6ff4c8e1ae46ac5cfcc41449697101a4ac873007018e9fcec40cae8a0685
MATLAB
1,437
48
function shape_classification_save_results_selected_clusters(data) classes = data.classes; for i = 1:size(classes,1) colors{i} = unique(cell2mat(classes{i,4})); end colors = unique(vertcat(colors{:})); c_map = colormap(jet); c_map = interp1(1:size(c_map,1),c_map,linspace(1,size(c_map,1),max(colors))); ...
2b47d433c666ee785a19bb395ee26a0ad6189db6cb96698391a761fa5b980c8d
MATLAB
1,438
45
function [tf,loc] = tblismember(tblA,tblB,flds) % Finds rows of tblA that match some row of tblB in all fields (aka columns) % named in flds. % % tf is a logical col vector with one element for each row of tblA, % which is true iff that row of tblA matches some row of tblB % loc is a numeric col vector with one ele...
4b5009a6284e9f26342c535ec6cdeba56ef340f806b213dc97f95ad911746c58
MATLAB
1,438
40
function pval = lme_mass_LR(statsfull,statsred,q) % pval = lme_mass_LR(statsfull,statsred,q) % % Likelihood ratio test for the random effects. It can be used to test if a % model with q+1 random effects is significantly better than a model with q % random effects. % % Input % statsfull: Structure array containing stat...
8756b20e002fcb3a6ed363cf6763c456bd9ab6021aa6a35b4db439233ca9d7f6
MATLAB
1,438
48
function h = hashmd5(inp) % Computes the MD5 hash of input data. % % function h = hashmd5(inp) % % Returns a string containing the MD5 hash of the input variable. The input % variable may be of any class that can be typecast to uint8 format, which % is fairly non-restrictive. % This file is part of Manopt: w...
df480d929989b8bc7a672a4dcb1db68e396edd58b689cfc0206e7ecfa57fe775
MATLAB
1,438
50
function [logZ] = mrf2Logprob(model, y) % logZ(i) = log p(y(i,:)) % We run inference with the y nodes clamped % This file is from pmtk3.googlecode.com edgeStruct = model.edgeStruct; [Ncases Nnodes] = size(y); nEdges = size(edgeStruct.edgeEnds,1); Nedges = nEdges; nInstances = Ncases; nNodes = Nnodes; Xnode = [ones...
e12097e48fa3117b1d2da910796e1b8fd49f13290f89daab872ad62d36a1a545
MATLAB
1,438
22
function addSurroundingCues(dotInfo, screenInfo, indRun, indBlock, indTrial) % adds the surrounding cues for the next flip for indAtt = 1:4 CueImg = ['img/', dotInfo.MAT.attNames{indAtt},'Q.png']; [cueLoad,~,~] = imread(CueImg); cue2Disp = Screen('MakeTexture',screenInfo.curWindow,cueLoad); ...
66cda84a9e717bac63b54e8cdb943d75e734681c55c7e903167bf78cab74b7f7
MATLAB
1,440
60
%% An illustration of Newton's method in 1D % %% % This file is from pmtk3.googlecode.com figure('Color',[1,1,1]); hold on; xmin = 7.5; xmax = 10; ymin = -1; ymax = 2.5e4; domain = xmin+0.2:0.001:xmax; e = exp(1); f = @(x) e.^(x); t = @(x) e^9*x-8*e^9; plot(domain,f(domain),'-b','LineWidth',3.5); plot(domain,t(do...
cbb97fd567d25da3b42fad0dcba56eee264510a2385b9601f8f23954d6d7a8f2
MATLAB
1,441
65
satis_distort = 0; while ~satis_distort, k_g_save = k_g; k_g = input(['Guess for distortion factor kc ([]=' num2str(k_g_save) '): ']); if isempty(k_g), k_g = k_g_save; end; x_n = (x - c_g(1))/f_g; y_n = (y - c_g(2))/f_g; [x_pn] = comp_fisheye_distortion([x_n' ; y_...
ccccfa82da4e9e9a001fb5951546bc18aad9e0b65eb3d554b329783097a37cfb
MATLAB
1,441
48
function y = ttsv(A,x,n) %TTSV Tensor times same vector in multiple modes. % % Y = TTSV(A,X) multiples the tensor A by the vector X in all modes. % % Y = TTSV(A,X,-1) multiplies the tensor A by the vector X in all modes % but the first. Returns the answer as a normal MATLAB array (not a % tensor). % % Y = TT...
d5accf2913d65328d942de2e52da642fc1253f6b6e0b126561f03b51d9ec7952
MATLAB
1,442
44
function [val, varargout] = VBA_maxMat (A) % // VBA toolbox ////////////////////////////////////////////////////////// % % [maxVal, idx1, idx2, ..., idxn] = VBA_maxMat (A) % Find maximal value and its position in the matrix A. % % IN: % - A: n-dimensional matrix % OUT: % - val: maximal value in A % - idx1, idx2...
3b1a4470baaa01d8567fc07fd3d47a1064e1d31a24d0b39fdf8c4897be6a5b23
MATLAB
1,443
45
function f = drawcircularblur(imagesize,amt,amtin) % function f = drawcircularblur(imagesize,amt,amtin) % % <imagesize> is number of pixels along one side % <amt> is fraction of radius for blurred border on the outer edge. % can also be [X Y] where X is the fraction of radius offset from % the outer edge at which ...
b599122106cf4c834a3baa30a2b0e627e121119754a2aa9299272ba58e7840b0
MATLAB
1,443
47
function [y, initSupport] = setSupport(labels, newSupport, initSupport) % Transform the support of the labels from one space to another % i.e. from say [0, 1] to [-1 1] or {'setosa', 'versicolor', virginica'} to % 1:3. % % This is a generalization of canonizeLabels to arbitary spaces. % % If the input labels do not ...
ba1a666d6a7ada6e77ffe47f30d367f28fed2997c3d1032a55af953dfcec45ac
MATLAB
1,443
49
function makeTestDemos() %% Make the testDemos script % This file is from pmtk3.googlecode.com error('deprecated') exclusions = {'PMTKbroken','PMTKinprogress', 'PMTKinteractive', 'PMTKreallySlow'}; % commented out in runDemos.m demos = filenames(processExamples({}, exclusions, 0, false)); text = {'function testDe...
bb4b96ae4e3b7c15b89da5aa3fb9979ae8cdb513badbc92b79db000b0f479f1b
MATLAB
1,443
54
function w = get_weights(x,y) % [const,w,allw,Imat] = get_weights(x,y) % % This function performs a regularized linear regression to retrieve the % kernels describing the selectivity of a single neuron % GLOBAL VARIABLES: this function assumes the definition of global % variable "glm" that defines a series of hyperp...
e54d53a9bb04afaef055e218fda07cf0e8db87d03da635a8551a3605868fde88
MATLAB
1,443
76
function [dips,c]=para2res(para,ndip,xtype); [n,m]=size(para); if m==1 m=n; end if nargin<3 xtype='imag'; end c=zeros(ndip,ndip); switch(xtype) case{'imag'} nc=ndip*(ndip-1)/2; count=1; for i=1:ndip for j=i+1:ndip c(i,...