sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
bb215a896fda4f04ae702eb68c65329b1cacef54544965d4dbdddf3bdfb57ffd
MATLAB
786
33
% % Create autocorrelation plot % addpath /comp_neuro/Software/Github/CMBHOME_github/ use_carlsim = 1; load filenames; % small: %191108_S1_lightVSdarkness_cells11and12.mat %file_number=15; % medium %merged_sessions_ArchTChAT#22_cell1.mat file_number=23; % large %GCaMP6fChAT10_gridCell_mergedSessions.mat %file_number=1...
bd15c0229cb83588d2be7d06adfba9e403fcbdf7661bdb27708e8416f3ad6bdf
MATLAB
786
30
% Cost function (using gpu) % % Cost function present in the Matlab Help for fminunc function function [f,g] = costfunction_gpu(x) % BROWNFG Nonlinear minimization test problem % % Evaluate the function n = length(x); y = parallel.gpu.GPUArray.zeros(n,1); i = 1:(n-1); y(i)=(x(i).^2).^(x(i+1).^2+1) + (x(i+1).^2).^(x...
bb8146dcb051676b69cae4a874de24ab61e8cf1192819c8725bf9a034d62cf65
MATLAB
787
32
function x = gsamp(mu, covar, nsamp) %GSAMP Sample from a Gaussian distribution. % % Description % % X = GSAMP(MU, COVAR, NSAMP) generates a sample of size NSAMP from a % D-dimensional Gaussian distribution. The Gaussian density has mean % vector MU and covariance matrix COVAR, and the matrix X has NSAMP % rows in whic...
eed142a550c8ba150631b0fac2e4e7b88449b6c66dcd48daf1fbc83f9734b819
MATLAB
787
38
function resultFlag = IsLinux(is64) % resultFlag = IsLinux([is64=0]) % % Returns true if the operating system is Linux. % If optional 'is64' flag is set to one, returns % true if the runtime is 64 bit and on Linux. % % See also: IsOSX, IsWin, OSName, computer % HISTORY % ??/??/?? ??? Wrote it. % 6/30/06 awi Fixed h...
50ca94469ea9d9c8a46465325fae650ecb51af9bfe9f04fc18e99096c4c1ea9d
MATLAB
790
42
function R = SelectAlongFirstDimension(IN, f) % R = SelectAlongFirstDimension(IN,f) % % equivalent of IN(f) for 1D, IN(f,:) for 2D, IN(f,:,:) for 3D, etc... % % INPUTS: % IN = any matrix input % f = selection indices (such as returned by find) % % OUTPUTS: % R = same type matrix as IN % % ADR 1998 % version...
ca89cc3902eb3a94f45c2b32ee4c391fb50da76074dbd628498849849a75c45f
MATLAB
790
20
function [coeffs] = CalculateT2Map(T2raw_reordered_reshaped,tvalues) %UNTITLED2 Summary of this function goes here % Detailed explanation goes here opts = optimoptions(@lsqcurvefit,'Algorithm','levenberg-marquardt'); tmax = max(tvalues); fun = @(coeffs,tvalues)coeffs(1)*exp(-tvalues...
4855b3d3a23552cda2152ec67edf265a90f331e4b2e4145ba2a133f5c7805dbe
MATLAB
791
35
% Compute the minimum description length % In fNIRS case, we use symmetric extension. % Signal content at border are unimportant, fortunately. % X is design matrix. % Y is fNIRS signal function mdlScore = calcMDL4DWT(Y,X) % other choice is 'per' dwtmode('sym'); mdlScore = 1; function ...
9a6d57cb280d274f8e9f6b6fca148451a7201cde49b54a36185a56b2df19800d
MATLAB
791
25
function [isthere] = exist_group(subj,objtype,objname) % Checks whether a group of that type and name exist % % [ISTHERE] = EXIST_GROUP(SUBJ,OBJTYPE,OBJNAME) % % Just calls find_group and checks whether it's empty % License: %===================================================================== % % This is part of th...
e7fa350c7ae299e9e6a8e3341bc58304bb6b076239d1147b43cd304d55cb046b
MATLAB
791
24
function msBatchSelectROIs( dirName ) %MSBATCHSELECTROIS Summary of this function goes here dataFolders = msBatchFindDataFolders(dirName,[]); for folderNum = 1:length(dataFolders) currentFolder = dataFolders{folderNum}; dirData = dir(currentFolder); dirIndex = [dirData.isdir]; fil...
5a086593769a2c6b8df0b91ac3e9d7a0ace578ec8c9189673d18d25a2fc157f5
MATLAB
793
20
function A_out = applyCellfunskipEmpty(x_struct, var_field_name, sub_field_name, fn_x, ii_inds, jj_inds) % Applies the function fn_x to contents of x_struct.(var_field_name).(sub_field_name) % when x_struct.(var_field_name) is non-empty. fn_x must return a scalar % value. % ii_inds and jj_inds allows selecting certain...
b4a99c7e55d3d388ce4d8355dab71eb4fd310406bfe73d654c6bec191d2b41c1
MATLAB
793
39
n = size(Y,2); p = size(Y,1); s = size(Lm,2); psi2 = zeros(p); zeta = 0; for tt = 1:s kt = size(Lm{tt},2); temp_alt = Xm{tt}.*repmat(Qns(:,tt)',kt,1); temp = Xcov{tt}*sum(Qns(:,tt),1) + Xm{tt}*temp_alt'; if pcaflag == 0 psi2 = psi2 + (repmat(Qns(:,tt)',p,1).*Y) * (Y-2*Lm{tt}*Xm{tt})' ... + Lm{tt}*tem...
1f5115ed106ac7747d2c129dc9ff41ea484f1f17876819161e5b7320cbfa6c66
MATLAB
794
35
%% Plot V4 MI firing rates cued vs cue-opp (moving window plots locked to cue onset/offset) %% Code load('V4_FR.mat') monkey = ["G","B","Combined"]; metric = "MI_FR"; trial_type = "all"; yl = [-0.02,0.06]; close all cueMI = eval(sprintf("cue%s",metric)); oppMI = eval(sprintf("opp%s",metric)); sum_metric = "mean"; ...
6bdcdc4dc1cc3afa9c4db91fbe9ff00de4f47a218ea06245f6487e3b397a5a14
MATLAB
794
39
function A = subsasgn(A, S, B) % overload of operator {} for element. % if subscripts are numieric, the correspondign elements of the array are returned, if % subscript is a string, all the tsd's are returned that contain that % string in their name % copyright (c) 2004 Francesco P. Battaglia % This software is r...
2afc9ee13b9923c52d963c21b246ab57e3c389f4573ec3c780180030a2f47cec
MATLAB
795
34
function d = simulateDataError(d) global ERROR_ODDS_CONST global logger logger = InitLogger(logger); if nargin == 0 d = []; return end if isempty(d) return end if isempty(ERROR_ODDS_CONST) return end if ERROR_ODDS_CONST == 0 return end % Set error odds in percent units r = round(ERROR_ODDS_CONST*...
c44f40d5a680c27f9063e14a0a89c020023e794a0305242c129c9a8430339699
MATLAB
795
25
function [status, txt] = awsEC2RunCommandOnInstance (ec2Instance,cmd) %This function runs a command on the instance defined by DNS. Make sure to supply the PEM file path %Both command and PEM file path are procided by awsEC2StartInstance %INPUTS: % ec2Instance - instance created by awsEC2StartInstance % cmd - ...
d3680f89bab7a36494ad38a7a861e2be29ef60136fb14a58882886bfb6fd6d12
MATLAB
795
32
function UpdateCondPopupmenu(handles) global maingui if isempty(handles) return; end if isempty(maingui) return; end if maingui.dataTree.IsEmpty() return; end iG = maingui.dataTree.GetCurrElemIndexID(); CondNames = maingui.dataTree.groups(iG).GetConditions(); CondNamesCurrElem = maingui.dataTree.currElem....
ef1f8b7c9559d2b234103025de922d3e3591610c8d4a28a3d1d6fa3a5cab0865
MATLAB
795
30
dt = 2^-5; Vmem = -90:dt:60; l_V = length(Vmem); Vt = -55; % minf1 = @(v) ((-4.626e-06)*v^2 + 0.00013 * v + 0.5224) * tanh(-1.615 + 0.064*(v-Vt)) + 0.4803; minf1 = @(v) (0.0001005 * v + 0.5052)*tanh(1.961+0.06681*v)+0.4921; minf2 = @(v) am(v, Vt)/(am(v, Vt)+betam(v, Vt)); minf1tab =...
ecac03d6409226c87fc6f63ec28ff978cc611640c5e98d349d7fcdc26373453c
MATLAB
796
18
function s= table_transient(files) for k = 1 : length(files) fName = files(k).name; fFolder = files(k).folder; fullname = fullfile(fFolder,fName); load(fullname) file_name = fullname ; info_file_name = split(file_name,'.'); info_file_name = info_file_name{1}; % Group transient variables...
1ac65efb4c2e75090692ae9d17a4ecfbc32e9e6a6db11bdf6c261bdd9ded6a8e
MATLAB
797
28
function CueRotPaper_GetCueEpochs clear all %% Load data led1 = load(fullfile('Data','LED1_TS.csv')); led2 = load(fullfile('Data','LED2_TS.csv')); %% Get cue change times % get timestamps of cue change led1 = led1(:,1); led2 = led2(:,1); ix = find(diff(led1) > 150 & diff(led1) < 250); ...
bf17d18fd3ef0f001b47981ff768179158f2dbf93b052f76ad1a3dc31ba95663
MATLAB
797
22
% reference: https://www.mathworks.com/matlabcentral/answers/47065-matrix-resize-rows-and-cols % instructions: supply matrix as ext_dir_init data. set new_size. use % ext_dir_init2 as new data. % set params new_size=40; orig_size=sqrt(size(ext_dir_init,2)); matrix_orig=reshape(ext_dir_init,orig_size,orig_size); matrix...
23fcdc494d882cc056ae23dfe4055ae7834c3027eebb4bea0a3a0cd0543b59df
MATLAB
799
31
%IsPositiveInteger - Test if array contains only positive integers. % % USAGE % % test = IsPositiveInteger(x,strict) % % x array to test % strict optionally, test for strictly positive integers % (default = 'off') % Copyright (C) 2004-2006 by Michael Zugaro % % This pr...
7f777cbed93512ddcf51e4f8e5cffd6570e8d03cbfc9948b0bd7cc0304b0b4c4
MATLAB
799
20
function [wl initialweight] = weaklearnerinitialize_template(trainpats,traintargs,epsilonconstant,seed); % Template for defining weak learner initialization functions for AdaBoost. See % decisionStumpInitialize.m for an example. % % License: %=====================================================================...
bc13b2e0c35d5c7c1f8ef719961a2b4028850f1a07ef437aa0c8b710fd7980f0
MATLAB
799
38
function [subj results] = load_subj(fn) % Loads in a SUBJ structure % % [SUBJ] = LOAD_SUBJ([FN]) % % This is the complement to SAVE_SUBJ.M. It's very simple indeed % % FN (optional, default = 'subj') % License: %===================================================================== % % This is part of the Princeton MV...
99be7fe8413b9ae83fd46fd1ead41091fb4465a9807930ab878ab36a0f0b8a07
MATLAB
800
22
clc; clear all; close all; n_bio=1.37; n_PLGA=1.46; n_BG=1.51; n=n_bio/n_PLGA; theta_c=asind(n_bio/n_PLGA); phi=0:0.2:90; phi_c=asind(n_PLGA/n_BG*cosd(theta_c)); theta=acosd(sind(phi).*n_BG/n_PLGA); r_perpendicular=(n_PLGA.*cosd(theta)-n_bio.*(1-(n_PLGA/n_bio)^2.*sind(theta).^2).^(1/2))./(n_PLGA.*cosd(...
5547aafae6fd4069c6dd0dd976432b45e470627f2ddd4cbb8715d1f8fde9e95c
MATLAB
801
39
function [y, mu1, mu2, denom] = yuent_dep(x1, x2, percent, dim, flag) if nargin<5 flag = 1; end if nargin<4 dim = find(size(x1)>1, 1, 'first'); end if nargin<3 percent = 0.2; end n1 = size(x1, dim); n2 = size(x2, dim); g1 = floor(percent*n1); g2 = floor(percent*n2); [mu1, thrlo1, thrhi1] =...
15b3025bf05dbc3a657c154779fd6bdd6918c91d3fcb2e2c625091d19014fa38
MATLAB
803
20
function [output] = randtn(mu,sigma,bounds,n) %RANDTN mu, sigma, bounds, n % Returns an array of pseudorandom numbers from trancated normal distribution. % mu mean before truncation % sigma standard deviation before truncation % bounds interval bounds or the the one half of the inteval [mu-bounds, mu...
afe2ab98c4bc31c7f81bfd277c9c6bd779916eafa1f809deca5d742db735ecf1
MATLAB
803
24
function CalculateOpticalFlow(exportFolder, optFlowParams, image) % Params wSig = optFlowParams.WindowSigma; relThresh = optFlowParams.ReliabilityThreshold; % Calculate Optical Flow vxMat = zeros(size(image, 1), size(image, 2), size(image, 3) - 1); vyMat = zeros(size(image, 1), size(image, 2), size(image, 3) - 1); rel...
eda040428c2b761412b45f3580fbed548fd1a530a9a00e2e65fbc6ee0e9f420c
MATLAB
803
25
function [isthere] = exist_object(subj,objtype,objname) % Checks whether an object of that type + name exists % % [ISTHERE] = EXIST_OBJECT(SUBJ,OBJTYPE,OBJNAME) % % Just calls get_number with IGNORE_ABSENCE = true % License: %===================================================================== % % This is part of th...
9ae6689fe859cbb98825774a9bd6e3fcd9def114961842c9f4d30f809b99e46c
MATLAB
805
36
function mTSD = Mask(tsd, varargin) % % mTSD = tsd/Mask(tsd, TrialPairs....) % % INPUTS: % tsd = tsd object % TrialPairs = pairs of start/end times (can be matrices of n x 2) % % OUTPUTS: % mtsd = tsd object with times *not* in TrialPairs set to NaN % ADR 1998 % version L4.0 % status PROMOTED % Unwrap trial ...
a721f92a777a638f270315c379ae305e4ef966f32fa06f6d54f0750f82ee4dc6
MATLAB
805
27
function [c,ceq] = t1obs_constraint(x,T1obs,eps) % Function to enforce inequality constraint during model fitting. % x is parameter vector [k*1000 f T1a T1b Gsf] Gsf is scaling factor applied to G0, % T1a,b in seconds % % T1obs is the observed T1 that the fit parameters must be consistent with % eps is the allowed dev...
bb3d4f0c64733ae8277d5d4ba01600afb2ecbf2a28bdf8dc4a336b12c2fb5876
MATLAB
805
29
function [m] = cellssq(x, dim) % [S] = CELLSSQ(X, DIM) computes the sum of squares, across all cells in x along % the dimension dim. % % X should be an linear cell-array of matrices for which the size in at % least one of the dimensions should be the same for all cells nx = size(x); if ~iscell(x) || length(nx)>2 ...
0479de7cc30e3e1219e63f5900e69b256512f9f05f772ff87cbc08a58b5532d4
MATLAB
806
43
function A = array(O, TimeUnits) % No comprendo % % USAGE: % S = array(O, TimeUnits)% % % INPUTS: % O - an intervalSet object % TimeUnits - a units object or the abbreviation string % % OUTPUT: % S - a N x 2 array of starting and end points for each interval in the set % copyright (c) 2004 Fra...
1085bd60cd97cbffc56caec39e1c0da9aa86339db09bec23dffcbd025c00e30f
MATLAB
807
22
% script to run all. Can take up to 1 full day. Parallel computing version is % available at ... % Preprocess nirs data for 3-class results for Figure 5 and 6. prompt = 'Warning. It'' take up to 1 day to run the whole thing. Are you sure? (Y/N)'; x = input(prompt); if strcmp(x,'Y') sbjList = {'12','13','14','15'...
40eed37039f4b0733b12acfa1d277cf45c343b95fd25c9d9d49ca18499c87c1b
MATLAB
807
29
function [cv timeBound] = CV(rg,varargin); % [cv timeBound] = CV(rg) computes the coefficient of variation of a spike % train rg given in second. It computes std and mean of the difference between spike timing % up to the 99% percentile of the cumulative histogram (given by % timeBound) to prevent any divergence of th...
5b82099759a49277054545346b781187ee67e14dd0f5137e6befcd4d1ca57abf
MATLAB
807
22
% script to run all. Can take up to 1 full day. Parallel computing version is % available at ... % Preprocess nirs data for 2-class results for Figure 5 and 6. prompt = 'Warning. It'' take up to 1 day to run the whole thing. Are you sure? (Y/N)'; x = input(prompt); if strcmp(x,'Y') sbjList = {'12','13','14','15'...
77e9bc586e64d79552add8f80926c8b8e94499b3688c30e9d0d853a687b7e9cb
MATLAB
807
26
function [post, a] = mdnpost(mixparams, t) %MDNPOST Computes the posterior probability for each MDN mixture component. % % Description % POST = MDNPOST(MIXPARAMS, T) computes the posterior probability % P(J|T) of each data vector in T under the Gaussian mixture model % represented by the corresponding entries in MIXPAR...
a4aef48f442f33c533b1b44fb1ddd702865737048e86efe78d99e4dae903227a
MATLAB
807
29
function resultFlag = IsOctave % resultFlag = IsOctave % % Returns true if the script is running under GNU/Octave. % % Some scripts need to behave differently when running under % GNU/Octave instead of running under Mathworks Matlab. % History: % 05/10/06 Written (MK). % 03/08/06 Added the 'var' parameter to the exist...
25344e6b6b415b9122e4eddb892c9b2ce92a17ee89a9b5d846b9ef4be573db5a
MATLAB
811
26
function [f, df, ddf] = rosenbrock(x); % rosenbrock.m This function returns the function value, partial derivatives % and Hessian of the (general dimension) rosenbrock function, given by: % % f(x) = sum_{i=1:D-1} 100*(x(i+1) - x(i)^2)^2 + (1-x(i))^2 % % where D is the dimension of x. The true minimum is 0 at x ...
4f09a7a4de1e8ca248e44035e142cc2905700d465af8b2156a7b27efbfd4de5c
MATLAB
811
29
function str = camel_case(str) % % Removes non alphanumeric characters and uppercase first letter of all % words but the first % % USAGE:: % % str = camel_case(str) % % :param str: % :type str: char % % :returns: % :str: (char) returns the input with an upper case for first letter ...
0869610c2c6065453411cf4b9aab81fc61a8e9ac5456061a0dd78bdbfc6e7129
MATLAB
812
24
function [t,x] = ml_EM(K,g_Ca,g_K,g_L,C,E_Ca,E_K,E_L,phi,V1,V2,V3,V4,I0,sigma_noise,x0,T,dt) % SOURCE: https://doi.org/10.1007/978-3-662-61184-5 N = length(K); t = 0:dt:T; V = x0(1:N); W = x0(N+1:end); x = nan(2*N,length(t)); x(:,1) = x0; for ii=2:length(t) if (t(ii)>716 && t...
980749af4d6cdb275bfce7314c24c769f9e1dec290cd956e126d33fd11b66c6f
MATLAB
812
33
% *WAVE* % % PHASE GRADIENT TEST SCRIPT takes the phase gradient of a test % test signal (here, a 2d target wave) % clear all; clc %#ok<CLSCR> % parameters T = 1; %s Fs = 1000; freq = 13.5; %Hz image_size = 8; decay_sigma = 5; %px wavelength = 20; %px/cyc pixel_spacing = 1; %a.u....
303650635c9db4a10bccfc6d26a12f319e9386358ad0a4e739580f93aa131312
MATLAB
813
27
function mri_level1(p) % Run a first-level GLM on the fMRI data, to model brain activation in % response to the target and other trial events (distractor, cue, delay % onset, probe onset, report). The aim is to calculate a % target-vs.-baseline contrast, which is then used to select voxels for the % reconstruction ana...
60182d80d4452bf409c1b9a6905ec487fa2657d153f3e44fbaf1d55a559c035c
MATLAB
813
25
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function simplified_uV2= simplified_uV2(v, rpre, dt) % inf = (2^-1)*tanh(-(2^-6 + 2^-7)*v-1.404)+0.5193; % tau = ((...
7eaca374e587d23e70846ce0b17853e6ac7eaa818e51d690c2e4dcd62dafb984
MATLAB
813
35
%% Wave Clus Output Plotting % load both the raw data and times files manually %this is for wells %clc %close all format long figure('units','normalized','OuterPosition',[0 0 1 1]) hold on data=highpass(data,300,25000); x=[1:length(data)]; x=x./25000; plot(x,data,'Color','k') %cluster range inputted by user to for si...
c424807433f7f99c40b9472c592af6b7f9529df549377138ec81f5d881fe14b3
MATLAB
813
30
function [angVel,epClock,epAnti] = HeadVelocity(ang) % Loads and computes angular head velocity. % % USAGE % [angVel,epClock,epAnti] = HeadDirectionWhl(fbasename) % % INPUT: % fbasename: session file basename % % OUTPUT % angVel: a tsd object of angular values % epClock: intervalSet object of clo...
04693095eb00793fb963c4fc87970e5b707806511899e54628049b8681560abc
MATLAB
814
23
function awsEC2UploadDataToInstance (ec2Instance,source,destination) %This function moves data / files to and from the instance %INPUTS: % - ec2Instance - instance created by awsEC2StartInstance % TempPEMFilePath - PEM file path % source - file path of files / directory at source. local! % destination - f...
9f14425801c45089539d46e5c10dd518b4d783458b71a9f2acb560140e0d5af4
MATLAB
814
27
function updateWasAlignmentSuccessful(slidePath) % This function adds wasAlignmentSuccessful to slides that where aligned % manually (for LC & LD) % Written at Jan 25, 2020. %% Load Data if ~exist('slidePath','var') slidePath = [s3SubjectPath('03','LD') 'Slides/Slide01_Section01/']; end slideConfigPath = ...
d418dfc95c9044e8545f84198b9360ab7a8ddf914933cb367684c0ab07b15e23
MATLAB
814
30
% SCRIPT % % If you don't like the way that the ARGS structure created % by PROPVAL stores your arguments as fields in a % structure, this script will blurt them out into your % workspace as full-fledged variables. % % e.g. % % defaults.blah = 42; % args = propval(varargin,defaults); % args_into_workspace % dis...
68b6d85394d4a53df9766ccb31988046e84d957528e5507dd9038d4cc04ff937
MATLAB
815
30
function [angVel,epClock,epAnti] = HeadVelocity(ang) % Loads and computes angular head velocity. % % USAGE % [angVel,epClock,epAnti] = HeadDirectionWhl(fbasename) % % INPUT: % fbasename: session file basename % % OUTPUT % angVel: a tsd object of angular values % epClock: intervalSet object of clo...
4d0a903af052e36848e5b35b4b3f5c5a3164ca4d981e1160aa067352020bafa2
MATLAB
817
31
function [Y,ppp] = preprocess(Y,ppp,shrinkQ); %[Yout,ppp] = preprocess(Yraw); OR % Yraw = preprocess(Yout,ppp,shrinkQ); % % Yraw - p x N matrix of raw observations % Yout - p x N matrix of processed observations % ppp - p x 2 matrix, the columns being the sample mean and % sample standard deviation of e...
b4b6c11d19ecf12a135169860bc5140e0f43836422a2d8daf0e0e6fc81a72cad
MATLAB
817
31
function mlAct = mlAct_Initialize(mlAct0, ml) % if size(ml,2) > 2 % k = find(ml(:,4)==1); % else % k = 1:size(ml,1); % end k = 1:size(ml,1); if isvector(mlAct0) && (length(mlAct0) == length(k)) mlAct = [ ml(:,1:2), mlAct0, ml(:,4) ]; elseif isvector(mlAct0) && (length(mlAct0) > length(k)) if size(ml,2) ...
c2bff106abada17f249cec013312a70dc209fa7d3a9dcf9c0fd15999343e9d83
MATLAB
817
29
function [s,m] = unixf(varargin) % A shortcut to unix(sprintf(...)) if islogical(varargin{1}) & varargin{1} varargin = varargin(2:end); cmd = sprintf(varargin{:}); dispf('unixf: %s', cmd); end if nargout == 0 unix(sprintf(varargin{:})); else [s,m] = unix(sprintf(varargin{:})); end % License: %=========...
cbd81b82c93b6af6d0d6199d52c66e8ea8117143594afcd153fa53040244c5aa
MATLAB
817
20
% This file is part of the Matlab Toolbox for Dimensionality Reduction v0.7.2b. % The toolbox can be obtained from http://homepage.tudelft.nl/19j49 % You are free to use, change, or redistribute this code in any way you % want for non-commercial purposes. However, it is appreciated if you % maintain the name of th...
690cf50df952c34197aa36c083762139e05dc2556744cabe604b8d2440002872
MATLAB
819
30
function net = glmunpak(net, w) %GLMUNPAK Separates weights vector into weight and bias matrices. % % Description % NET = GLMUNPAK(NET, W) takes a glm network data structure NET and a % weight vector W, and returns a network data structure identical to % the input network, except that the first-layer weight matrix W1...
c257bd029357406928ef5d81e0e1cba6f40077a10c09303df3c346905e23a7af
MATLAB
819
34
function [returnVar,msg] = RemoveDCfromDat_AllDat(fbasename) % USAGE: % RemoveDCfromDat_AllDat(fbasename) % % removes DC offset in all channels from all dat files starting with % 'fbasename'. Assumes that there is at least one xml file associated to % one the dat file (must be created before with Neuroscope and/o...
6177e37cb0263795d7ad7ade672696aecb46fdfe78fd523e2e31e78fda17aa6e
MATLAB
820
33
function isIt = fdlnIsLineIdentified (fdln) %Are lines in fdln structure identified? meaning are they of type %'v','h','t', or '-' and at least one 'h' and one 'v' %INPUT: % fdln - a single Fiducial Line structure or an array of a few % structures %OUPTUT: % isIt - 0 if non of fdln are identified, 1 - ...
9f097f097632b4e3ffb0ecbfe5a88d59e32225de208300f7f1d0beb50122ce9e
MATLAB
821
27
function netwtonsY = solveWithNewton(A, b, newtonsIter, rowI, rowII, colII, v, Ival, breakOnConverge, x0) tresh = 1e-6; N = size(A, 1); netwtonsY = zeros(N, newtonsIter); netwtonsY(:, 1) = x0; for i = 2:newtonsIter x = netwtonsY(:, i-1); xRaw = A*x + b; g = activation(xR...
0a626649361d6b22ffc8cdae440c76513025213a5d914c887f0d00275113cf29
MATLAB
822
21
function ms = msSelectAlignment(ms) %MSSELECTALIGNMENT Summary of this function goes here % Detailed explanation goes here bins = -20:20; for ROINum=1:size(ms.alignmentROI,2) subplot(2,size(ms.alignmentROI,2),ROINum) alignH2 = hist2(ms.hShift(:,ROINum) ,ms.wShift(:,ROINum),bins,...
c68aee0698d8278d5e6d7c6414d0bb289581dd5a83dd488d95aa9a0e065e24d1
MATLAB
822
25
function [m, ssmp] = cellmean(x, dim) % [M] = CELLMEAN(X, DIM) computes the mean, across all cells in x along % the dimension dim. % % X should be an linear cell-array of matrices for which the size in at % least one of the dimensions should be the same for all cells nx = size(x); if ~iscell(x) || length(nx)>2 ||...
61a374037f08ed93e9865a2fe36b205c723d1beaacb93c4860633b77df505a70
MATLAB
823
35
function net = knn(nin, nout, k, tr_in, tr_targets) %KNN Creates a K-nearest-neighbour classifier. % % Description % NET = KNN(NIN, NOUT, K, TR_IN, TR_TARGETS) creates a KNN model NET % with input dimension NIN, output dimension NOUT and K neighbours. % The training data is also stored in the data structure and the % t...
214c52689e3a12e73f458d7ced08dac21e6e42f8150a685426d897e291510576
MATLAB
824
28
function [flm,indices] = flm_dipole(r,rq,q,Lin) % r - r distance % rq - position of dipole % q - current rqn = norm(rq); theta = acos(rq(3)/rqn); phi = atan2(rq(2),rq(1)); % qs(1) - unit vector e(theta)/ qs(2) - unit vector e(phi) qs(1) = q(1)*cos(theta)*cos(phi) + q(2)*cos(theta)*sin(phi) - q(3)*sin(theta); qs(2) ...
28cf42058a0f313486d7bfbb8bfa7bf780244b015dff51ddf320ff6f3dbe9411
MATLAB
824
20
function ss_str = switchSimulationSet(ss_str, field_name) % sets the specified field to true, all others to false. % for selecting which of the simulation sets to load % options may include: % run_f20_e3010_timesweep = false; % pull data from 20-field, time sweep % run_f5_e1204_timesweep = false; % pull d...
ba0221214d234588981a76c245dc6f75d0af23ae3afb40b48ada9377229e54c9
MATLAB
824
35
function [k, nErrs] = generateErrorOddsConstant(oddsDesired, nTrials) if nargin == 0 oddsDesired = 10; nTrials = 1000; end if nargin == 1 nTrials = 1000; end % We want to calculate k that is the number to multiply rand() by to % achieve desired odds. This seems to be a good fomula for % approximating the ...
c2669b52ec8ddac0f216348a2bbb5cf949910c51959c2083cce61f8dfff28c93
MATLAB
824
39
clear all; S.ROI = 'sphere'; Flmr_sum = flm_dipole_script(S); Lin = 11; % % Reconstruct Fig. 1 of the 2005 JAP paper % for j = 1:size(Flmr_sum{1},1) ff = squeeze(abs(Flmr_sum{1}(j,:,:))); for k = 1:size(ff,1) for l = 1:Lin indices = (l^2):((l+1)^2-1); ffl(k,l) = sqrt(sum(ff(k,i...
e429708fd39ebb723dcdfe2ac2bf4ba06a0c3a17af2b71ba84d6057a7837cfcf
MATLAB
825
40
function [hf, hp] = plotFiltersLearn(K1, K2, color1, color2) % Only plots the vestibular weights and their changes % Plot resulting filter hf = gcf; dt = K1.dt; ntf = length(K1.PH); tf = (0:ntf-1)*dt; % k_PH hs = subplot(2, 2, 1); hp = plot(tf, K1.PH,'Color',color1); hold on hp(2) = plot(tf, K2.PH,'Color',col...
1780f9032a73ea37dea6dc3385461b1ed33daac168fad88e9f5b90178f5e4355
MATLAB
826
32
function weights = ComputeXCPrediction(q,Q,ep,varargin) % weights = ComputePeerPrediction(S,Q,ep) % S: ts of the cell % Q: binned spike train matrix (tsd object) of all other cells q = full(Data(Restrict(q,ep))); Q = Restrict(Q,ep); rg = Range(Q); dt = median(diff(rg)); pop = full(Data(Q)); %In Hz if ~isempty(...
09fc0b8e73b8ba07250ae939d403143df31e71ecc447010ad3eb872ee7ee690d
MATLAB
827
21
function [dmat3d_cropped_label1] = Individual_ROI_mask(dmat3d_cropped_label, dcount) %For method 2 %This function sets the values for a particular ROI to 1 and the rest of it to 0 %Thereby creating a ROI specific binary mask %Input: dmat3d_cropped_label (cropped labels with all ROIs), dcount(desired ROI to be se...
feeb7d5eab8fe890b1a49da0c3d7eb0b60dcc64a160cbbe53c6b890819e2ff01
MATLAB
827
20
function ms = msAlignmentFFT(ms,plotting) %MSALIGNMENTFFT Summary of this function goes here % Detailed explanation goes here for ROINum = 1:size(ms.alignmentROI,2) display(['Alignment ' num2str(ROINum) '/' num2str(size(ms.alignmentROI,2))]); rect = ms.alignmentROI(:,ROINum); if(mod(r...
925c44af6c63d62d9c10acd3fff176be60e88eb9f8ffbde572351ca07c2a2776
MATLAB
832
22
function [d] = inv2x2(x) %computes inverse of matrix x, using explicit analytic definition if %size(x,1) < 4, otherwise use matlab inv-function siz = size(x); if all(siz(1:2)==2), adjx = [x(2,2,:,:) -x(1,2,:,:); -x(2,1,:,:) x(1,1,:,:)]; denom = det2x2(x); d = adjx./denom([1 1],[1 1],:,:); elseif all(siz(1:...
04085574a77899caa221f7376e20a9e427ecc714df904e4eb09f8868e85ff503
MATLAB
833
33
function groupFolders = FindUnitTestsFolders() global logger global SCRAMBLE logger = InitLogger(logger); % Find all the group data folders with processOpt_default_homer2.cfg % Those are the folders that can be unit tested rootpath = filesepStandard(fileparts(which('Homer3.m'))); dirs = mydir([rootpath, 'UnitTests/'...
105a8fe3c13a8355d5b82bf25dc7c60d650c59172650be4905e2abe92c6fa746
MATLAB
833
30
function yOCT2Mat(data,filepath,dim) %This function saves data to mat file (local or in cloud) %INPUTS % filepath - filepath of output mat file % data - OCT Volume or B scan % dim - dimention structure, to be saved along, if needed %% Do we need AWS? if (awsIsAWSPath(filepath)) %Load Data from AWS ...
4af9723cd2d60123b420b58ea256206f91df7f314c5424b44a0ecbe51577d272
MATLAB
833
24
function [xn] = complex_exponential_reconstruction( amplitude, phase ) % *WAVE* % % COMPLEX EXPONENTIAL RECONSTRUCTION reconstructs a real-valued datacube % from its instantaneous amplitudes % and phases % % ...
0a217bc0009041d5d5dbe07a96f0584bb26777473450ea94cfb74c31941c0f1f
MATLAB
834
39
function [tso, ix] = RestrictThreshold(tsa, thr, varargin) % Restricts TSD to values above (below) threshold % % USAGE: % [tso, ix] = Restrict_threshold(tsa, thr, varargin) % % INPUTS: % tsa - a tsd object % thr - a threshold value % % OUTPUTS: % tso - the restricted tsd % ix (optional) - t...
b7ef7afe39d77fbaa304f92809d5070079a436083bcbd1010fc0d6b3528f878d
MATLAB
834
23
%% Create timeseries for turbulence clear all addpath('/Volumes/LASA/TBI_OpenNeuro/Shared_code/Turbulence/TBI_turbulence_current_code') %code path data_path='/Volumes/LASA/TBI_OpenNeuro/TBI_openneuro/timeseries/preprocessing/controls_tp2'; input_path='/Volumes/LASA/TBI_OpenNeuro/TBI_openneuro/timeseries/inputs_sch1000...
060d1501854210fac7f9777d52fcf6b54e8fad7f1895c407f17f2c12c9d1835e
MATLAB
835
24
%% Create timeseries for turbulence clear all addpath('/Volumes/LASA/TBI_OpenNeuro/Shared_code/Turbulence/TBI_turbulence_current_code') %code path data_path='/Volumes/LASA/TBI_OpenNeuro/TBI_openneuro/timeseries/preprocessing/controls_sch1000/'; input_path='/Volumes/LASA/TBI_OpenNeuro/TBI_openneuro/timeseries/inputs_sc...
92ac54f20534d2e7c0ebfc0a0a6bbd67e80eadc77bbb76154d68f1d6977a251b
MATLAB
835
30
function [res, fmt] = detNonparametric(actigraphy, epoch, varargin) %DETNONPARAMETRIC do nonparametric analysis (ISIV and M10L5) % % [RES, FMT] = DETNONPARAMETRIC(ACTIGRAPHY, EPOCH, STARTTIME, QUALITY, ISIVINFO) % performs sleep detection on ACTIGRAPHY of epoch length EPOCH and % return results t...
d383f08446a37e8b9b86d449484e3259a5cdfd7384f4b9357ff116c05d4d340e
MATLAB
835
41
function RMSE=fitparchoice(InpMats) switch length(InpMats) case 2 Pmat=InpMats{1}; Cmat=InpMats{2}; DF=Cmat-Pmat; DF=DF.^2; N=length(DF); RMSE=sqrt(sum(DF)./N); case 4 Pmat1=InpMats{1}; Cmat1=InpMats{2}; Pmat2=InpMats{3}; ...
5ed5dea3c01275545ecf240665a2ad2f67361b032a4f472fd7bbfe34de69735a
MATLAB
836
47
function d = mvnCrutchfield(Data1,Data2,varargin) % multivariate crutchfield distance computation % Adrien Peyrache 2007 N = size(Data1,2); if size(Data2,2) ~= N error('Data dimensions don''t fit') end if nargin ==1 mask = varargin{1}; if (size(mask,1)~=N) && (size(mask,2) ~=N) error('mask dimensions don''t ...
1b2195fe72e2c0fa727ce66e79de60dd3389f7ff8d4802f2aae91efe2558720b
MATLAB
838
33
% script to run all. Fast. % Generate figures for the manuscript. % Final figures require photo editing. % Figure number refers to preprint version at % https://www.biorxiv.org/content/10.1101/2022.09.06.506821v2.full.pdf % Figure 3 % Requires some photo editing plotAllHRF_Grp_ChnCriteria_Fig3_TTest(1,0) % Figure 4 ...
32a67a9f2e556371c249806509a72dc192489d50c763874151e81f33a90bf034
MATLAB
838
34
function R = Restrict(tsa, t0, t1) % tsd/Restrict % R = Restrict(tsa, t0, t1) % Returns a new tsa R so that tsa.data is between timestamps t0 and t1 % % ADR % version L4.1 % status: PROMOTED % v4.1 29 oct 1998 now can handle nargin=2 % v4.2 23 jan 1999 now can handle t0 and t1 as arrays switch nargin case 2 ...
499352ec847c527f9b4c4b8033d6c178103af9b691af6484e285527989143f92
MATLAB
839
35
%% Waveclus Cluster rejection based on ISI fast_thresh=0.1; times_files=dir; times_files=times_files(contains(string({times_files.name}),'times')); times_files=string({times_files.name}); %compute ISI num_clus=length(unique(cluster_class(:,1))); %calculate ISI for i=1:num_clus pts=cluster_class(cluster_class(:,...
069a3ef79673ca8ec076a9fd10a68e1e08346c338f52dd90c2c34b11ab402a05
MATLAB
840
35
function S = EPG_shift_matrices(Nmax) % Generates shift matrices up to order Nmax for 3 standard EPG % Layout of state vector is [F0 F0* Z0 F1 F-1 Z1 F2 F-2 Z2 ... etc] % i.e. 3 states per n-value % % Shaihan Malik 2017-07-20 N = (Nmax+1) * 3; S = zeros([N N]); %%% F(k>=1) kidx = 4:3:N; sidx = kidx-3;...
c04df93d7fcd1f35515179f81e65fb7e1ac7bc397084647d80a2215264814c36
MATLAB
840
18
function vidObj = msColumnCorrection(vidObj,downSamp) %MSREMOVECOLUMNVARIATION Generates the vector used to correct for ADC noise % downSamp will cut down on the number of frames used in the calculation meanFrame = zeros(vidObj.height,vidObj.width); %allocate memory count = 0; for frameNum=1:downSamp:vid...
c47db45974ba8ec22ae70e9c21a5d1bf02b8b983068098de80ea34bd0c213893
MATLAB
840
30
function [covp, covf] = gpcovarp(net, x1, x2) %GPCOVARP Calculate the prior covariance for a Gaussian Process. % % Description % % COVP = GPCOVARP(NET, X1, X2) takes a Gaussian Process data structure % NET together with two matrices X1 and X2 of input vectors, and % computes the matrix of the prior covariance. This ...
9a9e37bfffe27d1a013414f86cb93656406c97e173dd58cde0d406c1d763afc2
MATLAB
841
32
function v = getVernum(appname, appdir) v = ''; if ~exist('appname','var') || isempty(appname) [~,f,e] = fileparts(pwd); appname = [f,e]; end if ~exist('appdir','var') || isempty(appdir) appdir = getAppDir(); end libdir = '/Shared'; if isdeployed() p = appdir; elseif length(appdir) > length(libdir) ...
e128b6035394293e89637b7c378f420c2447b469d0ec8be25e59d0dd750c5dfe
MATLAB
841
30
function vbl = draw_fixcross(Experiment, color, flip, flipTime) % takes color as additional argument to allow feedback, default color is % white % takes flipTime as additional argument to specify exact time of flip % (script waits until time is reached) Stimulus = Experiment.Stimulus; Display = Experiment.Display; i...
60a0ac3aa3c3301acb9f40528f96146ae4826befef5079dbf339631ddf75bc2f
MATLAB
842
52
function [C,B] = CrossCorr(t1,t2,binsize,nbins) nt1 = length(t1); nt2 = length(t2); % we want nbins to be odd */ if floor(nbins / 2)*2 == nbins nbins = nbins+1; end m = - binsize * ((nbins+1) / 2); B = zeros(nbins,1); for j = 1:nbins B(j) = m + j * binsize; end % cross correlations */ w = ((nbins) / ...
d7a07c8442978c80887eb6dfcbd647082424915b46b95635369da1757777f353
MATLAB
842
35
%% Peak distribution to help find largest peaks for break off %manually load data and spikes files min_peak_distance=1.5; %in ms min_sd=11; data=highpass(data,300,25000); x=[1:length(data)]; x=x./25000; plot(x,data,'Color','k') [pospeaks,poslocs]=findpeaks(data,x,'MinPeakDistance',1.5/1000); [negpeaks,neglocs]=findp...
f73c622bab5905f13b0a5d6d3bc449ff74bd0c3cfa6fb7fc5d1824b1a1b74b5f
MATLAB
843
23
function fdln = fdlnCreate (u,v,group,linePosition) %Creates a Fiducial Line structure %INPUTS: % u,v - points in the picture (x,y) that are on the fiducial line. % u,v are arrays n by 1, u,v for each point [pix] % group - what is the group that this line is associated with, can be: % '1','2',... ...
c35f0dc324781c19635e32559fab300edd31a1f726ae4feb272f52e1306c4edd
MATLAB
844
28
function varb1=pca_reconstruction(varb,rank) if nargin<2 rank=4; end time1=max(varb(1).coords(:,4)); for i=2:numel(varb) time1=min([time1 max(varb(i).coords(:,4))]); end raster=zeros(numel(varb),time1,3); reraster=zeros(numel(varb),time1,3); for i=1:numel(varb) raster(i,:,1)=varb(i).coords(1:time...
e037609aeda02e9d2c592538da10977bd850b4adb91ff25326d5cf7136bb53ed
MATLAB
844
24
function msBatchGenerateBehav(dirName) %MSBATCHGENERATEBEHAV Summary of this function goes here % Detailed explanation goes here dataFolders = msBatchFindBehavFolders(dirName,[]); figureNum = 0; for folderNum = 1:length(dataFolders) currentFolder = dataFolders{folderNum}; dirData = dir(cur...
603186dc602dae3a93ee2d9479bb81cc61a503af71dd9c4b93205e25556cdb54
MATLAB
845
35
function [traj2,NeuronSL2,Lap2] = speed_filter(traj1,NeuronSL,Lap,spdthr) %SPEED_FILTER ´Ë´¦ÏÔʾÓйش˺¯ÊýµÄÕªÒª % ´Ë´¦ÏÔʾÏêϸ˵Ã÷ if nargin < 4 spdthr = 10; end speed1 = traj1.speed; fms = (speed1 >= spdthr); x1 = traj1.x1; y1 = traj1.y1; thetaPosition = traj1.thetaPosition; rhoPosition = traj1.rhoPo...
2b00b61ffadd335c5ff67b134c0d720d53230258f11e47ae503c90e931962947
MATLAB
846
29
function varb1=pca_reconstruction(varb,rank) if nargin<2 rank=4; end time1=max(varb(1).coords(:,4)); for i=2:numel(varb) time1=min([time1 max(varb(i).coords(:,4))]); end raster=zeros(numel(varb),time1,3); reraster=zeros(numel(varb),time1,3); for i=1:numel(varb) raster(i,:,1)=varb(i).coords(1:ti...
50da80fb500791c68a4544ce97b0364f337168da4a048cc0c8d099af4ce641e4
MATLAB
846
29
function [Traj_trunc] = TruncateAtRadius(Traj, radius) % Truncates any trajectory at a given radius from start point (first cross). % use interpolated (1ms or 5ms) trajectories to increase spatial resolution numTraj = size(Traj,1); Traj_trunc = Traj; for i = 1:numTraj x1 = Traj{i,...
558b8c0db79390723a9eaa93dce68e6626c9756a7e185fc8bcdf3f8caecd2f10
MATLAB
848
27
% function dist = euclidean(X) % % A function to calculate the Euclidean distance between multiple vectors. % Usually faster than squareform(pdist(X,'euclidean')), unless we are % dealing with lots of patterns and very little data. Takes the input like % pdist, i.e. columns and rows are flipped w.r.t. correlation...
caa5997ab8ef11ab9796a92c7c0375b5da9c9b1d9689b15560c100dd261cba55
MATLAB
848
39
%% test script close all, clear all %% load bb load('C:\Users\DBHeyer\Documents\PhD\Human Database\bbtest.mat') %% get tables abfs = bb.abftable ; channels = bb.channeltable ; ins = bb.analogintable ; sweeps = bb.sweeptable ; epochs = bb.epochtable ; aps = bb.aptable ; %% get new batch cc = Abfbatc...
c91a5dff5ff34589552007178b546181c942a266aca3e95b7aee7bfd145900f2
MATLAB
850
14
% Basic functions for the analysis of kinematic data % Joern Diedrichsen % V.1.0 09/13/05 (jdiedric@jhu.edu) % ----------------------------------------------------------------- % 1. Calculating numerical derivatives and smoothing % velocity_discr - Numerical first derivative (with filter option) % accelerat...
e582a99fb81ff12d40c02a48230e6bf5f98ebee10dfe2e55a1b6bb7166ec9156
MATLAB
850
32
function wm=winmean(x,percent) % function wm=winmean(x,percent) % returns the winsorized mean of x % x must be a vector % percent must be between 0 and 100; the function winsorizes the lower and % upper extreme g values of x, where g=floor((percent/100)*length(x)). If x is empty, then NaN is % returned. % percent=20 ...
5bc423ff7a4f2141c2921e5f54e0a8d86bc09bc149219bed603bb793c72a2e31
MATLAB
851
39
close all clear all clc %% Insert filepath and parameters % File location FileLocation = %Insert path % input parameters channel = [1 2]; ns=[1 2]; sz=[11 5]; pkh=[12 10]; channel_track = [1 2]; param.mem=1; param.good=10; param.dim=2; param.quiet=1; oldFolder = cd(FileLocation); listing = di...
1ca5aef2d159d5729e977b52d5e883190a7f6a6891f7294a697e1a134565b61c
MATLAB
852
38
function [dateNum, dateStr] = gitLastRevDate(repo, file) dateNum = 0; dateStr = ''; if ~exist('repo','var') || isempty(repo) repo = pwd; end if ~exist('file','var') || isempty(file) file = ''; end repoFull = filesepStandard_startup(repo, 'full'); currdir = pwd; if ismac() cmdprefix = 'TERM=ansi; '; e ...