sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
eb7fc1e2f2e765aa2b19a420b01d4c4efdd65ef814508c637bfc2488eff8646a | MATLAB | 458 | 13 | % @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_r= simplified_r(v, rpre, dt)
inf = ((-0.000396*v - 0.5129)*tanh(1.583 + 0.02531*v)) + 0.5503;
tau ... |
46f3e369e2f220e0f054a97a56a91758ff8b61e24eeccabd2ae47065c7685394 | MATLAB | 459 | 16 |
n = size(Y,2);
p = size(Y,1);
for tt = 1:s
kt = size(Lm{tt},2);
T1 = reshape(reshape(Lcov{tt}(2:end,2:end,:),(kt-1)*(kt-1),p)*psii,kt-1,kt-1) ...
+ Lm{tt}(:,2:end)'*diag(psii+eps)*Lm{tt}(:,2:end);
Xcov{tt} = zeros(kt,kt);
Xcov{tt}(2:end,2:end) = inv( eye(kt-1)+T1 );
trXm{tt} ... |
90f7b82ba35dbd11f9f9fea7d1a7818cb2013d31976741be96966f3ad2686798 | MATLAB | 462 | 15 | function um = magnificationToPixelSizeMicrons (magnification)
% This function converts from magnification to pixel size
% magnification can be '10x','4x','2x' etc
% See https://www.microscopyu.com/tutorials/matching-camera-to-microscope-resolution
switch(lower(magnification))
case '10x'
um = 1;
... |
001042423a1c36b37abe1eee3ae2e4d6ad0fd2780e2bf8de8365ced727947f6e | MATLAB | 463 | 23 | %% 22-7-17: steady state SPGR with BM equations
function [Mss] = ssSPGR_BM(alpha, TR, T1x, f,ka)
M0a = (1-f);
M0b = f;
kb = ka * M0a/M0b;
R1a = 1/T1x(1);
R1b = 1/T1x(2);
%%% Relaxation-exchange matrix for Longitudinal components
Lambda_L = [[-R1a-ka kb];[ka -R1b-kb]];
Xi_L = expm(TR*Lambda_L);
% Use same notation a... |
c851e0353715522c043f8d76fd51e7d6465f3ed95e03e644e6e805c6c3d05c86 | MATLAB | 464 | 13 | % @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 [IsynG, Aval, Pval] = IsynG(Vpresyn, Esyn, GsynG, ICa, Ppre, Apre, Dt)
C = 10^(-29); % Coulombs
Aval ... |
835701e9f0615511c788665f40ef8151a454aa2e6ff84e986b586425b9eccef4 | MATLAB | 466 | 19 |
n = size(Y,2);
p = size(Y,1);
s = size(Lm,2);
for tt = 1:s
kt = size(Lm{tt},2);
mean_Lambda = [mean_mcl zeros(p,kt-1)];
num{tt} = [nu_mcl repmat(a./b{tt},[p 1]) ];
temp = Xm{tt}.*repmat(Qns(:,tt)',kt,1);
T2 = Xcov{tt}*sum(Qns(:,tt),1) + Xm{tt}*temp';
T3 = diag(psii)* Y *temp';
for q = 1:p
Lcov{tt}(:... |
8bed7b84ba0ba84511f9f402942a98e16120a9953d2fcfbcc9674bdf1042a349 | MATLAB | 466 | 19 | function y = gaussianFilter(x,fs,fc)
% y = gaussianFilter(x,fs,fc)
% INPUTS:
% x: vector (or column matrix) of data
% fs: sampling fq
% fc: high pass cut off frequency or a 2 value vector of [lowpass
% highpass] frequencies of the passband filter.
% Adrien Peyrache
sigma = fs./(2*pi*fc);
y = gaussFilt(x,sigm... |
b14a974d91c6cfc6bac20bd1dd8e6f14a11d5ab34006fee952e40c1c83316cad | MATLAB | 466 | 17 | function output = ReadShiftsAndCorrFile(varargin)
% varargin: filepath or empty
% output is Xshift, Yshift, CorrValue
if nargin == 0
[filename, folderpath] = uigetfile('.bin', 'Select the shifts and correlation value file');
filePath = [folderpath filename];
end
fileID = fopen(filePath);
data = frea... |
a75d5961db4182ff226a85860f7337e25723799474d1041f83f829cfa424772b | MATLAB | 467 | 28 | function p = bootstraspWelchANOVA(y, g)
REPEATS = 10000;
if iscell(g)
g = g_cell2vec(g);
end
[~,F_true,] = wanova(y, g);
F_dist = nan(1,REPEATS);
for j=1:REPEATS
prm = permVec(g);
[~,F_dist(j)] = wanova(y,prm);
end
p = mean(F_dist>F_true);
end
function g = g_cell2vec(g)
g_cell=g;
unique_g ... |
ac0ef42f3f933731fcdf05d14c0fc6c6a76d9571a5d1faf12859a743257c7817 | MATLAB | 467 | 11 | function cmap = RedBlueVaryingScale(numColors, minVal, maxVal)
ss = (maxVal - minVal)/numColors;
numR = ceil(abs(minVal)/ss) - 1;
numB = ceil(abs(maxVal)/ss) - 1;
bluSeg = 1 - linspace(numB/max(numB, numR), 0, numB);
redSeg = 1 - linspace(numR/max(numB, numR), 0, numR);
redLine = [ones(length(redSeg), 1); 1; flipud(b... |
dda986afaedeaba49844565649a860bbea7b5daac78e73d5efc7513a475a1cb9 | MATLAB | 467 | 12 | function awsEC2TemporarilyDisconnectFromInstance(ec2Instance)
% This function temporarily disconnect from instance, clears pem file. to
% reconnect use awsEC2RunstructureToInstance. You will need to save
% instance id and dns from ec2Instance to reconnect.
%
% INPUTS:
% ec2Instance - see awsEC2RunstructureToIn... |
25488ec8b10cb81ace20a852fe5b510d793dc275f1afbd0ac69fa65efd3246eb | MATLAB | 468 | 17 | function seg = detConstantOne(Signal)
%DETCONSTANTONE Detect constant number 1 from 0-1 series.
% For isolated 1, the start and end indices are the same (the location of
% 1)
%
% $Author: Peng Li, Ph.D.
% MBP, Div Sleep Med, BWH &HMS
% $Date: Nov 14, 2016
% $Modif.: Dec 02, 2020
% ... |
30b8e7736dee25923c09fabf0d04c4f5a84e829cc41851283b3d6ee2bf8f0166 | MATLAB | 468 | 13 | function varargout = get_filenames_spm8b(varargin)
% get_filenames:
% inputs: file path (1 x n string), possible filenames with wildcards (e.g. *.img or rf*.img)
% output: filenames as n x m char array (n = number of files)
if nargin >= 2 && strncmp(varargin{2},'REGEXP:',7)
fname_regexp = var... |
93e1f0c7c3e7a8a09955c048001927c43357158ddd311bfdb0e8d463b35c1758 | MATLAB | 468 | 13 | function [pre_stim_vals,post_stim_vals]=pre_post_time_comp_210511(table1,table2)
% Tables 1 and 2 should be pre stim and post stim in that order
% Assumes the tables are already zero padded
pre_stim_vals=[];
post_stim_vals=[];
for i=1:length(table1)
pre_stim_vals=[pre_stim_vals,[table1{i}.("Spike Area"){1:end}]];
... |
254c298dc171990524a672695e35d1a5021b2de85a17da63561112befc1e9e9b | MATLAB | 469 | 11 | function A_out = pullFieldskipEmpty(x_struct, var_field_name, sub_field_name, ii_inds, jj_inds)
% Pulls the scalar value out of x_struct.(var_field_name).(sub_field_name)
% when x_struct.(var_field_name) is non-empty.
use_cell_arr = x_struct.(var_field_name)(ii_inds, jj_inds);
has_entry = cellfun(@(x) ~isempty... |
327270b6b0338468ef7cdff8cf9e78671681df049b3c4b17525c4173dd674c73 | MATLAB | 469 | 20 | function [optimalLocalDim, localDimSubj] = decideOnLocalComplexityBasedOnEnergy(data,energy)
if nargin<2
energy = 0.9;
end
if energy>1
error('energy is defined as: (0,1]')
end
for subj=1:length(data)
[~,~,latent] = princomp(data{subj}');
ix= find((cumsum(latent)/sum(latent)<energy));
if isempty(i... |
565a0fe6434d558e8de7d4f34317369a889d8742eec4a025d103dba54437b674 | MATLAB | 470 | 14 | function [isPathToDataset, origDatasetName] = analyze_origPath (origPath)
% This is an auxilary script to get if the origPath is originated in a
% dataset or a snapshot, and get the name
origPath = awsModifyPathForCompetability([origPath '/'],true);
if (contains(origPath,'_Datasets/'))
isPathToDataset = tr... |
d58231449a2ef651e0426b48350c80f24492fd2df2a6ae2e9875f9ee0526da12 | MATLAB | 471 | 16 | function s = maxitmess()
%MAXITMESS Create a standard error message when training reaches max. iterations.
%
% Description
% S = MAXITMESS returns a standard string that it used by training
% algorithms when the maximum number of iterations (as specified in
% OPTIONS(14) is reached.
%
% See also
% CONJGRAD, GLMTRAIN, G... |
c5184f4491b744993cf0130aca994d2ade09966ff732c4ae343cbf4072bd4033 | MATLAB | 473 | 15 | function [ii,s] = findSectionInStatusReport(s,subjectName,sectionName)
% Returns section's index in the status report s.
% If s is a cell or a string, will first load status report than search for
% the secitoin in it
%% Input checks
if iscell(s) || ischar(s)
s = loadStatusReportByLibrary(s);
end
%% Fin... |
979b48614e39e858c08020941fc53fd583c11726480d7987405be1de3913eb52 | MATLAB | 474 | 19 | function P = CorrelationCompare(r1,r2,N1,N2)
% P = CorrelationCompare(r1,r2,N1,N2)
% Statistical comparison of two correlations coefficients.
% INPUT:
% r1,2: correlation coefficients to compare
% N1,2: number of samples in population 1,2
% OUTPUT:
% P, the p-vlue that r1 is different from r2;
%
% Adrien ... |
d6598389a50f7ca1720d4b2fbce6d126c540efc39580b39420f096d8d6e3bf19 | MATLAB | 474 | 29 |
%% Parameters
binsize = 1;
nbins = 100;
%% Load data
load(fullfile('Data','SpikeData'));
%% Compute AutoCorrs
totC = length(S);
allAC = nan(nbins+1,totC);
for n = 1:totC
[ac, bins] = CrossCorr(Range(S{n},'ms'),Range(S{n},'ms'),binsize,nbins);
ac(bins == 0) = 0;
rx = length(R... |
5ad2ad18216f18e1808a885c6ec198206372a46853504570819bfadebf2e1bf2 | MATLAB | 475 | 32 | function [C,B] = SpectCrossCorr(S,t,nbBins)
if round(nbBins/2) == nbBins/2
nbBins = nbBins+1;
end
dS = Data(S)';
tS = Range(S);
totBin = size(dS,2);
C = zeros(size(dS,1),nbBins);
dt = median(diff(Range(S)));
l = (nbBins-1)/2;
% try
for i=1:length(t)
trigT = binsearch_floor(tS,t(i));
if trigT>l & trigT<totBin-... |
f0b8c415f892ed4dff25b7af30319e922e2f9b0ed967fdd5c68e93e2c12c1690 | MATLAB | 475 | 17 | function data = extract_events_from_file(filepath, data, rc)
[path_,name,ext] = fileparts(filepath);
n = size(rc,2);
for i=1:n
tmp = rc{i};
if strcmp(tmp{1},'EventFile')
e = readtable([path_ filesep name tmp{3}]);
event_times_msec = e.Time_msec(find(strcm... |
290adb8e8060ff0f4835bcd999d966afa47dfa2f9ab474b197b1617ae93f147d | MATLAB | 476 | 27 | function dt = DT(tsa)
%
% dt = tsd/DT(tsd, tsflag)
% returns DT from tsa
% INPUTS
% tsd
% tsflag: if 'ts' returns time in timestamps (default),
% if 'sec' returns time in sec
% if 'ms' returns time in ms
% ADR
% version L1.0
% status: promoted
dt = mean(diff(tsa.t));
if nargin =... |
4322dc8425195604e9ee31b9fdb8d8c2779d19a8001119ab20a8d284b5f7bc43 | MATLAB | 477 | 18 | function c = convert(A, B)
% c = convert(A, B) returns multiplicative factor to convert unit A into unit B
%
% the conversion is such that if a is data expressed in unit A
% b = c * a is the same data expressed in unit B
% copyright (c) 2004 Francesco P. Battaglia
% This software is released under the GNU GPL
% www.... |
6f53a628bfe05595c0154351e166e5c392f7bfb494822c8d4801728e22dba6b7 | MATLAB | 477 | 23 | function tss = subset(tsa, ix);
% Returns tsd of a subset of input
%
% USAGE:
% tss = subset(tsa, ix);
%
% INPUTS:
% ts - an input object
% ix - an array of indices
%
% OUTPUTS:
% tss - a tsd containing the point in tsa indicated by ix
% copyright (c) 2004 Francesco P. Battaglia
% This softw... |
6f80e316d11bceaca0cd55eddf596df8d1534f83b94772127f7a7e71fda2d613 | MATLAB | 477 | 23 | function rois = getROIcell
rois = cell(0);
n = 1;
while(1)
[x,y] = ginputwhite;
if(length(x) == 0)
break;
end
patch(x,y,'r','FaceAlpha',0.49);
text(x(1),y(1),num2str(n),'Color','g');
rois = [rois [ x y ] ];
n = n+1;
end
% sa... |
b8b4572074b7f91cc3201aecb70e751f1b0c3cfab20e5e8b45b01d791d2147ff | MATLAB | 477 | 13 | % @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_qV2= simplified_qV2(v, qpre, dt)
inf = 0.5*tanh((2^-4 + 2^-5 + 2^-6)*v+3.628)+0.4952;
tau = ((2... |
213634ff16e603c4a3147b5eeea57bad1e520a56a41b2d7780d8ae6f51652dbb | MATLAB | 478 | 24 | function SpatBits=SpatialInfo(pf,occ)
% USAGE
% SpatBits=SpatialInfo(pf,occ)
%
% compute for each cells the number of spatial bits per spikes
%
% INPUT:
% pf: placeField (In Hz per pixel)
% occ: Occupancy probability
% OUTPUT:
% SpatBits: the spatial information (in bits/spikes)
%
% Adrien Peyrache... |
c6b1a4e1e1e2c2b32fdd42042a2cc6e785253da52775f54aa75fcf8a26aa7bba | MATLAB | 478 | 12 |
% Detect foreground.
mask = obj.detector.step(frame);
% Apply morphological operations to remove noise and fill in holes.
%mask = imopen(mask, strel('rectangle', [3,3]));
%mask = imclose(mask, strel('rectangle', [15, 15]));
mask = imfill(mask, 'holes');
... |
7a1f9bd5b77c2eace7d96c9b0ac84caf75f29d88124929636a939486e95de750 | MATLAB | 479 | 15 | function [SpeedMax, MaxSpeedPoint] = MaxSpeed_AllTraj(Traj,smf)
% Gives for each trajectory the x/y coordinates of the max speed (1,2)
% And the Value of the Max speed
% smf = smoothing factor
numTraj = size(Traj,1);
for i = 1:numTraj
[SpeedMax(i,1), indx_MaxSpeed] = max(smooth(Traj{i,1}(1:end-1,8)... |
4aa4cd976a60a95ddb93bd0ab7fe3670cbfe04da6aa2012dd6b662c126ea8c3e | MATLAB | 480 | 13 | function [r, cout] = polyexp_solve_system(basis, convres_f, convres_c, ...
isreal, cout_func, cout_data)
% POLYEXP_SOLVE_SYSTEM
%
% Helper function for polyexp.m, implemented as a mex file. This function is
% of no independent interest.
%
% Author: Gunnar Farnebäck
% Computer Vision Laboratory
% ... |
57912f62add8a3374166e1444d3b2d0c9ff2f484a04091694e632cf58a9725f9 | MATLAB | 480 | 17 | % output = transres_model_parameters(decoding_out, varargin)
%
% This function returns the raw model parameters for the last decodings
%
% To use it, use
%
% cfg.results.output = {'model_parameters'}
%
% Kai, 2012-03-12
function output = transres_model_parameters(decoding_out, chancelevel, cfg, varargin)
% check t... |
b12ca4fee4df3e1956f8a30671b07d4af0bb9211e16f7e5413e5822ec2a49b15 | MATLAB | 480 | 19 | function hp = gppak(net)
%GPPAK Combines GP hyperparameters into one vector.
%
% Description
% HP = GPPAK(NET) takes a Gaussian Process data structure NET and
% combines the hyperparameters into a single row vector HP.
%
% See also
% GP, GPUNPAK, GPFWD, GPERR, GPGRAD
%
% Copyright (c) Ian T Nabney (1996-2001)
% Check... |
b7a2dd48ed5eae288d51cecfb3de39ff3dd25774c04ee316c64ef4577d67e351 | MATLAB | 480 | 20 | function g = rosegrad(x)
%ROSEGRAD Calculate gradient of Rosenbrock's function.
%
% Description
% G = ROSEGRAD(X) computes the gradient of Rosenbrock's function at
% each row of X, which should have two columns.
%
% See also
% DEMOPT1, ROSEN
%
% Copyright (c) Ian T Nabney (1996-2001)
% Return gradient of Rosenbrock's... |
802c976cc38cf4e6f766be50834e40e6c89fac19eb28928cfc34a8b801c92939 | MATLAB | 481 | 11 | function varargout = get_filenames_spm2(varargin)
% get_filenames:
% inputs: file path (1 x n string), possible filenames with wildcards (e.g. *.img or rf*.img)
% output: filenames as n x m char array (n = number of files)
if nargin >= 2 && strfind(varargin{2},'REGEXP:') == 1
error('Input to ... |
d40c139df6302f04736da672cdafbf7dcc29b8cf40dff3ecf0abb1eb7bc5ee6a | MATLAB | 481 | 33 | function L = SpkTrainHDValuation(pf,S,x1,ang,testEp,trainingEp)
dAng= Data(Restrict(ang,testEp));
t = Range(Restrict(ang,testEp));
f = zeros(length(t),1);
r = rate(S,trainingEp);
S = Restrict(S,testEp);
xx = floor((length(x1)-1)*contrast(dAng))+1;
pf = pf(:);
try
f = pf(xx);
catch
keyboard
end
dt = median(... |
1ce994e8bac7574ae799eb92d3e77c119874b31d6fe1f4870a85776411d4b2b3 | MATLAB | 482 | 20 | function logbeta1 = VBHMMbackward(v,phghm,logOutput)
T = size(v,2);
H = size(logOutput,1);
logbeta1 = zeros(H,T);
logbeta1(:,T) = zeros(H,1);
for t=T:-1:2
phatvgh1 = zeros(H,1);
for h = 1:H
phatvgh1(h) = exp(logOutput(h,t))+1e-100; % eps
end
logbeta1(:,t-1)=logsumexp(repmat(logbeta1(:,t),1,H),r... |
468325b28c380f465ce9d11adc8e71e7c05625d7fc52dcb1da6708301da6870e | MATLAB | 482 | 13 | % @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_hV2= simplified_hV2(v, hpre, dt, Vt)
hinf = (2^-1)*tanh(2.705-(2^-3)*(v-Vt))+ 0.5018;
tauh = 2^... |
92d5fbef3f1df78d08dbe58c25b427ff34df7d21dec0487b222cc992217a5883 | MATLAB | 482 | 16 | function y_pred = test_ridge(model, X)
% Applies an ridge regression model to test data and outputs predicted
% responses.
%
% Usage:
% y_hat = test_ridge(model, X)
%
%Parameters:
% model - struct describing the regression model obtained from training
% data. Must contain the fields w and b... |
a924cc3700f7586252a4d172c07cc741996031391ce2cb33f38f227a3a3f1316 | MATLAB | 482 | 16 |
nTracks = length(tracks);
nDetections = size(centroids, 1);
% Compute the cost of assigning each detection to each track.
cost = zeros(nTracks, nDetections);
for i = 1:nTracks
cost(i, :) = distance(tracks(i).kalmanFilter, centroids);
end
% Solve th... |
5e6cbd652904adbd0d670ce0cfe954f28c1b6e112ab8f5b8eeb60a94f8835c6c | MATLAB | 484 | 22 | function A = truc(A)
% Find Upstate
% Adapted from Muckovski, Cerebral Cortex, 2007
% Adrien Peyrache 2007
A = getResource(A,'PfcTrace');
A = getResource(A,'Sleep1DeltaEpoch');
A = getResource(A,'Sleep1SpindleEpoch');
A = getResource(A,'Sleep2DeltaEpoch');
A = getResource(A,'Sleep2SpindleEpoch');
load([current_dir... |
210ebcbe8c5d4b4dc90afbaf52f870b422bc15abf9d4edbaaca0ab1270456913 | MATLAB | 485 | 19 | function lvl2_save(p, model)
data_dir = p.dirs.data;
title = p.lvl1.title;
out_file = fullfile(data_dir, 'Nifti', 'all', 'lvl2', title, ['lvl2_log_' datestr(now,'yymmddHHMM') '.mat']);
% only save if there are non-empty cells
if ~all(cellfun(@isempty, model))
% detect empty... |
807569c1589f42ee07740d043dde91e78ad8814092ae7b50994f77a702f6eb7e | MATLAB | 485 | 15 | % @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_pV2= simplified_pV2(v, ppre, dt)
pinf = 0.5*tanh((2^-5 + 2^-6 + 2^-8)*v+1.778)+0.4998;
taup = 1... |
92c507131e18b96ae1542358f3e2ae1885f225098aef3097b6351c3c0276ba10 | MATLAB | 485 | 24 | function SpatBits=SpatialInfo(pf,occ)
% USAGE
% SpatBits=CellsSpatialInfo(S,XS,YS,epoch)
%
% compute for each cells the number of spatial bits per spikes
%
% INPUT:
% pf: placeField (In Hz per pixel)
% occ: Occupancy probability
% OUTPUT:
% SpatBits: the spatial information (in bits/spikes)
%
% Adr... |
01cd4fb6f132baea41a3c48dd354df50c578ce17b25c7a4fbfdffc2db40fd6fa | MATLAB | 486 | 17 | % NANZSCORE - Calculate the z-score per dimension, omitting NaN values.
%
% Authors: Rafael Naime Ruggiero, 2021
function [zscored] = nanzscore(x,dim)
zscored=zeros(size(x));
if dim == 1
for irow = 1:size(x,1)
zscored(irow,:) = (x(irow,:) - mean(x(irow,:),'omitnan'))./std(x(irow,:),'omitnan');
... |
c0f43adc43c46aec257fd2d4fe9599f3df671fb797324643f4310e488d8941b7 | MATLAB | 486 | 21 | function [beh_dat,angles] = get_beh_dat(behavData,session_list)
%% Extract behavioral data from behavData to beh_dat
beh_dat = cell(1,length(session_list));
angles = cell(1,length(session_list));
for iSess = session_list
temp = behavData{iSess};
temp.empSacc(temp.empSacc==0) = temp.nosaccValid(temp.em... |
f3a0c2db3aa105daeb50f5f88bf0bd900492a0907d795f3c091c79ec59b4f7d6 | MATLAB | 487 | 17 | function e = dempot(x, mix)
%DEMPOT Computes the negative log likelihood for a mixture model.
%
% Description
% This function computes the negative log of the unconditional data
% density P(X) for a Gaussian mixture model. The data structure MIX
% defines the mixture model, while the matrix X contains the data
% vecto... |
5f77aa32827acf8b7e86943a97049f362e8a4e1a77adfe70aed1187a5b8b7deb | MATLAB | 488 | 22 | function means = gtmlmean(net, data)
%GTMLMEAN Mean responsibility for data in a GTM.
%
% Description
% MEANS = GTMLMEAN(NET, DATA) takes a GTM structure NET, and computes
% the means of the responsibility distributions for each data point in
% DATA.
%
% See also
% GTM, GTMPOST, GTMLMODE
%
% Copyright (c) Ian T Nabn... |
6bd7fe9f3ba215cb03a3c2ddbaa94a6618006781184d029d9183585e89c63aa7 | MATLAB | 489 | 25 | function pos = waveForm2ProbePos(meanWaveF)
% z points downward // x leftward
x = [17 -17 15 -15 13 -13 5 -5]';
z = [-70 -50 -30 -10 10 20 40 60]';
pos = zeros(length(meanWaveF),2);
for c=1:length(meanWaveF)
w = meanWaveF{c};
w = sum(w'.^2);
w = w./sum(w);
if length(w)<8
w = [zeros(1,8-length... |
1d6da4eecdff04cdcab09d6759183793404c7b0332c0b3d390a893d2e9371f5d | MATLAB | 493 | 13 | function [ax1,ax2,sc] = plotScatterChange(x,y,logscale)
% fig = figure;
minAll = min([x(:);y(:)]);
maxAll = max([x(:);y(:)]);
ax1 = subplot(1,3,[1,2]);
sc = scatter(x,y,'MarkerEdgeColor',[.5,.5,.5]);hold on;
plot([minAll,maxAll],[minAll,maxAll],'--k');
if (logscale); set(ax1, 'YScale','log',... |
7cb04582dd1040ab02287ea2a69c92d50e856e7db0aea5630496104ee5e03de9 | MATLAB | 493 | 24 | function inputOutputfig(effect, cellType)
figure;
REPEATS = 10000;
pops = {'SNR','BG msn','PC ss','CRB'};
cols = {'r','y','b','g'};
x1 = subplot(2,1,1); hold on
x2 = subplot(2,1,2); hold on
for i = 1:length(pops)
indType = find(strcmp(pops{i}, cellType));
plot(x1,i,effect(indType),['o' cols{i}])
error... |
30f2cb1b5577f10069217a30947dd8c2523aa5844c07d8c605ff75e905a6410d | MATLAB | 494 | 28 | function [StO,ix] = Start(S0)
% Returns a vector containing the time of the first event of each tsd
%
% USAGE:
% sto = Start(tsa,is)
%
% INPUTS:
% tsa - a tsdArray
% is - an intervalSet
%
% OUTPUT:
% sto - an vector of time
% ix - index of tsds with at least one event
% copyright (c) 2009 Adr... |
61960ceae42d10428a817b4768f7d63e4943869897fefd3b3cc627a7023d30a9 | MATLAB | 494 | 19 | function C=correlation_matrix_gf(n,final_time)
nen=numel(n);
signals{nen,nen}=0;
for i=1:nen
signal = n(i).coords(100:final_time,5);
signal = signal - imgaussfilt(signal,80);
signals{i} = signal;
end
for i=1:nen
for j=i+1:nen
signal1 = signals{i};
signal2 = signals{j};
... |
62131d17e9e71dd67f3287adae29d2b51c3da2fa036245df0bfc79b87c99a7f6 | MATLAB | 494 | 19 | function [EV, EVr] = ReactEV(x_s1, x_s2, x_m)
% [EV EVr] = ReactEV(x_s1, x_s2, x_m)
%
% computes reactivation EV and reverse EV for matching columns in the
% three inputs
r_m_s1 = ReactCC(x_m, x_s1);
r_m_s2 = ReactCC(x_m, x_s2);
r_s1_s2 = ReactCC(x_s1, x_s2);
EV = ( (r_m_s2 - r_m_s1 .* r_s1_s2) ./ ...
... |
6514832d33649d4f56cab5efa23586c1512ebd63fd0c10f0b8553b0b96f45faa | MATLAB | 494 | 15 | function V=velocity_discr(A,sigma)
% VELOCITY: calculates the velocity for one axis, without time-shift
% Synopsis
% v=velocity_discr(A,sigma)
% Description
% A is a vector of position data (one dimensional)
% if sigma is given, the data will be smoothed with
% a gaussian kernel (SD=sigma)
% v is a Vector... |
96b4d505c97667e705c31db534d1fc93b60d08c4eb242330887b3fb587bb96e2 | MATLAB | 494 | 17 | function cout = polyexp_cout_helper(r, G, options)
% Helper function for polyexp.m.
% This would have been a local function in polyexp.m if that had worked
% in Matlab (tested with 5.3 and 6.5).
%
% Author: Gunnar Farnebäck
% Computer Vision Laboratory
% Linköping University, Sweden
% gf@isy.liu... |
4fa5602dc0746f2e282b4813c0639241a7eb148afbf19614c5601d05929580ee | MATLAB | 495 | 24 | function setup_analysis(p)
% TO DO
% Script to copy all relevant files into the folder structure
% - Dicoms
% - Logfiles
% - Eye tracking data
% - ProbAtlas
% - VVIQ data
% Set up main directory structure
setup_directories(p);
% Set up the BIDS file structure for each subject
bids_setup(p);
% Transfer data from a s... |
b3ec7cd29398f6b5c532c59f4e1e8287880c65f7863a71088889eb2475f4763d | MATLAB | 495 | 25 | function shiftVec = randshift(origVec)
% Randomly permute the n*m vector along the row.
% Keeping the mean of each row unchanged
%
[n,m] = size(origVec);
newVec = zeros(n,m);
cellindx = (1:m);
for i=1:n
temp = origVec(i,:);
sf = randi([1,m],1);
cellindx = cellindx + sf;
for j=1:m
if cellindx(j) > ... |
e8228ce3da0f3ffad80798d324725e3b400510ea0978f8228b5332e25577c312 | MATLAB | 495 | 12 | function x_dot = ml(x,K,g_Ca,g_K,g_L,C,E_Ca,E_K,E_L,phi,V1,V2,V3,V4,I)
% SOURCE: https://doi.org/10.1007/978-3-662-61184-5
N = length(x)/2;
V = x(1:N);
w = x(N+1:end);
x_dot = [(-g_Ca * 1/2 .* (1 + tanh((V - V1) ./ V2)) .* (V - E_Ca) - ...
g_K .* w .* (V - E_K) ... |
c2a65a4aeec45be61adc985a4a15016278100c616c217980b019bd5fdc127ea9 | MATLAB | 496 | 18 | % @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 cai = caiFunc(IPre, caiPre, dt, Sm)
dcai = drive_channel(IPre/(Sm*(10^9))) + ((2e-4)-caiPre)/5;
cai = Eul... |
6673ed750d311152581334d323e0fc38af958d11341b3de863c45580a359b7bf | MATLAB | 497 | 25 | function i = dyad(j)
% dyad -- Index entire j-th dyad of 1-d wavelet xform
% Usage
% ix = dyad(j);
% Inputs
% j integer
% Outputs
% ix list of all indices of wavelet coeffts at j-th level
%
i = (2^(j)+1):(2^(j+1)) ;
%
% Copyright (c) 1993. David L. Donoho
%
%
% Part of W... |
9098b75ba78a527d645def9c89ed6763393735e529d19babf6191a24cfd2568a | MATLAB | 497 | 29 | %% PyBehaviour: Compiler (MATLAB)
% Lloyd Russell
%%
subjects = {''};
%%
current_mfile_path = mfilename('fullpath');
[current_mfile_dirname, current_mfile_filename] = fileparts(current_mfile_path);
cd(current_mfile_dirname)
cd('../../')
try
cd('Results')
catch
warning('Results directory does not exist')
end
... |
513b0c5bead225f484166b9abd9e0a32eeaa10704763766a7f6538d406855de3 | MATLAB | 498 | 26 | %% Run PLS analysis %%
%% Read in data and functions
workdir='';
addpath(genpath('/dagher/dagher11/filip/Obesity_maps/scripts/'));
addpath(genpath('/dagher/dagher11/filip/Obesity_maps/data/'));
BMI='HCPA_CT_DKT_LH';
expr='DKT_aba_LH';
%% Read coord_data
load('DKT_coords_LH.mat');
coords=DKT_coords_LH(:,5:7);
%% Ru... |
81bdc45bf304248d1fc5296f108c195199ac48b7e263842219061fb61cbb5efe | MATLAB | 498 | 27 | function [Xout,Yout]=gplot3(A,xy,lc)
[i,j] = find(A);
[ignore, p] = sort(max(i,j));
i = i(p);
j = j(p);
% Create a long, NaN-separated list of line segments,
% rather than individual segments.
X = [ xy(i,1) xy(j,1) repmat(NaN,size(i))]';
Y = [ xy(i,2) xy(j,2) repmat(NaN,size(i))]';
Z = [ xy(i,3) xy(j,3) repmat(NaN,s... |
dc52eacb0d22ae772ed63a9e42b48079927c81ed36dac0416488c31136c4823a | MATLAB | 498 | 19 | function g = netderiv(w, net, x)
%NETDERIV Evaluate derivatives of network outputs by weights generically.
%
% Description
%
% G = NETDERIV(W, NET, X) takes a weight vector W and a network data
% structure NET, together with the matrix X of input vectors, and
% returns the gradient of the outputs with respect to the we... |
63e37a897935b391d431c389d794a718e59341e2791db3caa218b364cdae22ac | MATLAB | 499 | 24 | function [xf] = generate_sin( dt, T, frequency, phase_angle )
% *WAVE*
%
% GENERATE SINE WAVE TEST DATA generates a simple test sine wave for
% use with the functions in WAVE
%
%
% INPUT
% dt - timestep
% T - epoch length (s)
% frequency - frequency
% (optional) phase_angle - ... |
3c423111492f86d565452ed6662c6bf2b7fbf472a59d48847bcfabbf29e0aa8b | MATLAB | 500 | 26 | function s = vertcat(varargin)
% Vertical concatenation (overload of the [a; b] operator)
%
% USAGE:
% s = vertcat(tsa, tsb,..)
%
% arguments must be all tsdArray.
%
% copyright (c) 2004 Francesco P. Battaglia
% This software is released under the GNU GPL
% www.gnu.org/copyleft/gpl.html
C = {};
for... |
9fee6552912f65931c5465ddc2ee43c89e7bda4f9f6e73e32665fb6cb7244a02 | MATLAB | 500 | 18 | function NameStruc = ParseName(NameString, varargin)
%PARSENAME Parsing recording names
%
% This is a general function and only one field in output (filename)
%
% $Author: Peng Li
% Medical Biodynamical Program
% Brigham and Women's Hospital and Harvard Medical School
% $Date: Mar 28, 2016
% $... |
c358d336dcfc8a1168c047c5c5796c491465fbfd12175d7865f9b136f827b89f | MATLAB | 500 | 19 | function t = Data(tsa, tsb)
% Returns the timestamps of TS object
%
% t = Data(tsa) returns the timestamps of the TS object tsa
%
% t = Data(tsa,tsb) returns the timestamps of the TS object tsa restricted on the timestamps of tsb (and aligned 'prev')
%
% copyright (c) 2004 Francesco P. Battaglia
% This software... |
ed7e6827df8aec47aaa0ec16f4fdca10dcb3b9e075968266866a98acd6d413f1 | MATLAB | 500 | 36 | function C = List2Cell(filename)
% C = List2Cell(filename)
% INPUTS
% filename: a file containing a list of strings (one per line)
%
% OUTPUTS
% C: a cell array containing the strings
fid = fopen(filename, 'r');
if(fid == -1)
v error('Could not open file');
end
S = fscanf(fid, '%c');
fclose(fid);
C = cell(0,1);
... |
3b619e2d2535bf41b6b0ee4714a1ba86c0ac39080e897425af714eda168c221f | MATLAB | 501 | 26 | function s = horzcat(varargin)
% Horizontal concatenation (overload of the [a, b] operator)
%
% USAGE:
% s = horzcat(tsa, tsb,..)
%
% arguments must be all tsdArray.
%
% copyright (c) 2004 Francesco P. Battaglia
% This software is released under the GNU GPL
% www.gnu.org/copyleft/gpl.html
C = {};
f... |
f32651ad71a9880295a9a932aacef67039bcf700c3a933c663dcd48a73bd9c89 | MATLAB | 502 | 19 | function tiffWrite(imData,PSFname)
[nx, ny, nz]= size(imData);
imgType= class(imData);
tagstruct.Photometric= Tiff.Photometric.MinIsBlack;
tagstruct.ImageLength = nx;
tagstruct.ImageWidth = ny;
tagstruct.PlanarConfiguration= Tiff.PlanarConfiguration.Chunky;
tagstruct.Compression = Tiff.Compression.None;
tagstruct.Bits... |
99b128eddf74f199fc0ac3d58b20d8f138843a631fa8ac334d159cc54221cce4 | MATLAB | 503 | 24 | function [xf] = generate_cos( dt, T, frequency, phase_angle )
% *WAVE*
%
% GENERATE COSINE WAVE TEST DATA generates a simple test cosine wave for
% use with the functions in WAVE
%
%
% INPUT
% dt - timestep
% T - epoch length (s)
% frequency - frequency
% (optional) phase_angl... |
7c1611b74799ea5ff2d715c58fa0883461fff9e70530bb72822d534378407ea2 | MATLAB | 505 | 20 | function integerTicks(ax, directions)
% set x/yticks to integer values only
%
% INPUTS
% ax: an axis handle
% directions: a string containing 'x' and 'y' indicating which directions
% to act on
if ismember('x', directions)
set(ax, 'XTickMode', 'auto');
yl = get(ax, 'XTick');
yl = yl(find(yl==floor(yl)));
... |
81049fb4f880260757279bd330fbd24bb856f72ea8ff6d167c1b702ef4f9b960 | MATLAB | 506 | 20 | function j = awsReadJSON(fp)
%This function reads a JSON file from AWS or locally
if (awsIsAWSPath(fp))
%Load Data from AWS
isAWS = true;
awsSetCredentials;
fp = awsModifyPathForCompetability(fp,false);
else
fp = awsModifyPathForCompetability(fp);
isAWS = false;
end
%Load JSON to ... |
95fe1c6382bf953bdacae22d9158b64a904ccc2396589db0a15a8ff3a00fbde2 | MATLAB | 506 | 20 | function PrairieLink_WriteRawFile(data, filePath)
% Write binary file to match that made by PrairieLink_RawDataStream
% Lloyd Russell 2017
% Open the file
fileID = fopen(filePath, 'wb');
% write file header
pixelsPerLine = size(data,1);
linesPerFrame = size(data,2);
fwrite(fileID, pixelsPerLine, 'uint16')... |
a11c8ebfc5d9d569a2ed9c720fc2b765496c3d08112bbac8123406b00b0a33fb | MATLAB | 506 | 18 | %res = kldirichlet(vecP,vecQ)
%
%Calculates KL(P||Q) where P and Q are Dirichlet distributions with
%parameters 'vecP' and 'vecQ', which are row vectors, not
%necessarily normalised.
%
% KL(P||Q) = \int d\pi P(\pi) ln { P(\pi) / Q(\pi) }.
%
%Matthew J. Beal GCNU 06/02/01
function [res] = kldirichlet(vecP,vecQ)
alphaP... |
f2fd413c439ec3509e2faade2742bc8bd52f3d8f9ada9e0662e7fdeae69dd468 | MATLAB | 506 | 25 | function L = CrossValidationHDCheck(S,ang,ep)
nbEp = 10;
epV = regIntervals(ep,nbEp);
L = zeros(nbEp,1);
for ii=1:nbEp
ix = (1:nbEp);
ix(ii)=[];
testEp = epV{ii};
trainingEp = epV{ix(1)};
for jj=1:nbEp-2
trainingEp = union(trainingEp,epV{ix(jj)});
trainingEp = mergeCloseInter... |
f02b254d43d487c7e14decd05e1a0fad0e2ecbbdc1c3298d1ed30fb22867b653 | MATLAB | 507 | 18 | function [idx_vec] = find_in_channel_list_210725(channel_list,chan_name_vec)
%Returns the index of chan_name in channel_list
channel_list = replace(channel_list, ' ','');
if class(chan_name_vec) == "char"
chan_name_vec = {char(chan_name_vec)};
end
for chani = 1:length(chan_name_vec)
chan_name = replace(chan_na... |
53f28e2f554afc07805ff6edd2d9723bbf8e20e9811ffef8ebb6346db76eea8f | MATLAB | 508 | 21 | % compute squared Euclidean distance
% ||A-B||^2 = ||A||^2 + ||B||^2 - 2*A'*B
function d = L2_distance_1(a,b)
% a,b: two matrices. each column is a data
% d: distance matrix of a and b
if (size(a,1) == 1)
a = [a; zeros(1,size(a,2))];
b = [b; zeros(1,size(b,2))];
end
aa=sum(a.*a); bb=sum(b.*b); ... |
332f5be2eb454698a11f6ecc777bb3e2b27b5ed0843d1a1dfef97345c1231ab5 | MATLAB | 510 | 20 | % function out = covq(x)
%
% Slightly faster, but less general version of cov(x). When passing a row
% vector to covq, it will return a matrix of NaNs. We always calculate the
% sample covariance.
%
% 2015/04/21 Martin Hebart
function out = covq(x)
n = size(x,1);
try % if exist('bsxfun','builtin')
... |
9eba5b0b1c1406bde1063230339668af00dbef5e80c95882589718e64f02f48a | MATLAB | 510 | 22 | function prob = gtmprob(net, data)
%GTMPROB Probability for data under a GTM.
%
% Description
% PROB = GTMPROB(NET, DATA) takes a GTM structure NET, and computes
% the probability of each point in the dataset DATA.
%
% See also
% GTM, GTMEM, GTMLMEAN, GTMLMODE, GTMPOST
%
% Copyright (c) Ian T Nabney (1996-2001)
% Ch... |
aeda4e5a6755dbce8e36c4e85845f20079497bd6f116ce708f2a7fdbec66b822 | MATLAB | 510 | 19 | function [a, r, sel] = fit2lines(x, y)
% temporarily rotate the data, to create a 'cross'
[u, s, v] = svd([x y], 'econ');
x_ = [x y]*v(:,1);
y_ = [x y]*v(:,2);
% first guess is fit a line to the points in the left-lower/right-upper
% quadrant, and the left-upper/right-lower quadrant
sel = (x_<0 & y_<0) | (x_>0 & y_... |
2fe3aeeb74e1b86f3f53f3d8d92acf610d90eac2f6d776a928f35ac56aba46cd | MATLAB | 511 | 25 | function O = add_items(O, k, v)
% add_item(D, k, v) add items with keys k and values v to dictArray D
%
% k and v are
% if key k is already present the corresponding value is replaced
% copyright (c) 2004 Francesco P. Battaglia
% This software is released under the GNU GPL
% www.gnu.org/copyleft/gpl.html
ix = ... |
2f3d8be8b1e62679bd9573b081094fc79912b17918d6d2ac2583a41c2817972d | MATLAB | 512 | 24 | function goto(dir_shortcut)
code_path = 'C:\Users\apetitbon\Documents\MATLAB\20230628';
try, params = evalin('base','params');end
if exist('params')
data_path = params.data_folder;
analysis_path = params.analysis_folder;
else
data_path = 'E:\NAS_SD\SuiviClient\Triffilieff\2023';
analysis_path = 'E:\N... |
7ce0ee04e1a8521c7a9c400927ad4ee0fd4b268248f838fb2df5055bea400f70 | MATLAB | 512 | 25 | function v = Data(tsa, ix)
% Returns Data of a TSD object
%
% USAGE
% d = Data(tsa)
% d = Data(tsa, alignments)
%
% Retrieves data from ctsd
% if called with alignment list (timestamps), returns those tsa.Data(ix)
% if called without, returns complete tsa.Data
% ADR 1998
% version L4.1
% status: PROMOT... |
21ee6786c964ef05b67e9133a2dded796c6f4376e4f41f51fbbcc47c20537695 | MATLAB | 513 | 25 | function L = tot_length(O, TimeUnits);
% Returns total length of intervalSet
%
% USAGE:
% L = tot_length(O, TimeUnits),
%
% Returns the total length in the units specified by TimeUnits
% (defaults to ts)
% copyright (c) 2004 Francesco P. Battaglia
% This software is released under the GNU GPL
% www.gnu... |
6bf4dc70495fe19dbaf15b128a679c3aa897cd028262c232e7a88edb035771fb | MATLAB | 513 | 15 | function x = standardizeSR(x, oldSR, newSR)
% standardizeSR Take a signal and change its sampling rate w/o warnings
% Zeke Barger 100119
%
% Arguments: (note that these are data, not paths to files)
% x - a 1-D matrix of data
% oldSR - the original sampling rate of x
% newSR - the desired sampling rate ... |
1f7792b79f7d98cfdf4d6ee302dbf1204cd202f3184d15f6fca985d2722d6f6e | MATLAB | 514 | 18 | % output = transres_other_average(decoding_out, varargin)
%
% This function averages other output that was generated across decoding
% steps (in the field decoding_out.opt), but works only if this other
% output is numerical
%
% To use it, use
%
% cfg.results.output = {'other_average'}
%
% Martin, 2017-06-30
functi... |
8f276ac5b24eaac41bc753e47c42dbfa9cf5e2f5ff6b90824d3fd3ffdedba482 | MATLAB | 514 | 20 | %
% For a set of axis (subplots), determine and set common axis range
%
% axList: list of axis, i.e. [ax1 ax2 ax3] with ax1=subplot(...)
% axisToSet: 1 X, 2 Y
%
% Implemented following https://www.mathworks.com/matlabcentral/answers/164039-readjusting-y-limits-on-subplots
%
%urut/Oct22
function setCommonAxisRange( ax... |
fb66c3942a78884ed3291ca800e98abd2394fd2022c986ebc65ae46e37c20f41 | MATLAB | 514 | 18 | function R2 = estimateRepeatReliability(Sigs)
% Sigs = [Repeats, Time]
if size(Sigs, 1) > size(Sigs, 2)
Sigs = Sigs';
end
Sigs(isnan(Sigs(:, 1)), :) = [];
nRepeat = size(Sigs, 1);
comb = nchoosek(1:nRepeat, round(nRepeat/2));
ncomb = size(comb, 1);
rperm = nan(ncomb, 1);
reps = 1:nRepeat;
for i = 1:ncomb... |
ea790ad9569d509b252a29b8ff51124327277303982cfe3649d2a167c9c7edd4 | MATLAB | 515 | 27 | function tss = subset(tsa, ix);
% Returns tsd of a subset of input
%
% USAGE:
% tss = subset(tsa, ix);
%
% INPUTS:
% ts - an input object
% ix - an array of data indices
%
% OUTPUTS:
% tss - a tsd containing the columns indicated by ix
% copyright (c) 2004 Francesco P. Battaglia
% This softw... |
81eaf8d6a9c30a93daf4b51f227a7dacc0bdf2e60e2cd475fbb2d74a60efac42 | MATLAB | 516 | 24 | % Kbeta
%
% Computes weighted sum of kernel matrices
%
% Usage:
% K = Kbeta(Ks,w);
% K = Kbeta(Ks,w,symmetric);
%
% Input:
% Ks - Gram matrices [n x n x M]
% w - weights [M x 1]
% symmetric (=false) - optional argument. If 1 the Ks
% matrices are assumed to be symmetric which results in a
% small speedup.
%
% Outpu... |
e67312c26f58e3eaa422147d02157bf7d393712e42c53b3a843953c16a9c92d0 | MATLAB | 516 | 19 | % mirror-symmetric viewpoint tuning index function
% October 24 2022
% Amirhossein Farzmahdi
function [output] = msvt_index(input)
% input: RDM, views x views
% ouput: mirror-symmetric viewpoint tuning index
input_hflipped = fliplr(input);
% index of central column
indx = ceil(length(input)/2);
... |
fd70cb0b01192e250c96fc05242245fdfc7057a05ee0bb38c1cf9c0ee94f6c52 | MATLAB | 516 | 19 | function [sigma] = winvar(x, percent, dim)
% Compute the %percent Winsorized variance across dimension dim.
% Implementation according to Wilcox; Robust Estimation
% and Hypothesis Testing. As opposed to matlab's implementation
% the percent is taken on both sides, rather than taking percent/2
if nargin<3
dim = fin... |
1ba550f21a1dd23ae7d0586a23bccdc54bc77455724b17898f76349b6d0d68b1 | MATLAB | 517 | 21 | function [whl,t,GoodRanges] = LoadPosition_Pos(fbasename)
% Intermediate wrapper, should not be used directly
%
% USAGE
% [whl,t,GoodRanges,ep] = LoadPosition(fbasename)
%
% OUTPUT:
% whl: the position matrix
% t: time vector
% Good Ranges:
fid = fopen([fbasename '.pos']);
whlt = fscanf(fid,'%f\t%f\t%f... |
91a7aa18557d0d6a43bcf3ae3f92fe9797e198b04de3697056659efb26c0a95c | MATLAB | 518 | 21 | X_vals = [260.5188];
Y_vals = [98.4048];
Xc = 180; % center of x vals
Yc = 180; % center of y vals
% rotate 90 degrees clockwise
Xs = X_vals - Xc; % shift data
Ys = Y_vals - Yc;
Xsr = Ys; % rotate data 90 degrees clockwise
Ysr = -Xs;
Xr = Xsr + Xc; % unshift rotated data
Yr = Ysr + Yc;
% flip horizonally
Xcd ... |
3150d140c29303d38861074d4a144702ce5764a86cebc8ba624d1ed80904a706 | MATLAB | 519 | 12 | function p_opt = fitBinomial(data)
% Define the negative log-likelihood function for binomial distribution
negLogLikelihood = @(p) -sum(log(binopdf(round(data), 1, p)));
% Optimization settings
options = optimset('fmincon');
options.Display = 'off';
% Use fmincon to find the p that... |
50f744a2a9c81107a200f6b8cbc632f0f0925082a20ce2bc5d140e7f7d22ec50 | MATLAB | 519 | 15 | function smoothDist = TimeAverageDistSmoothing(dist, numSmoothedFrames)
%% Check numSmoothedFrames to be odd
if mod(numSmoothedFrames, 2) == 0
error('numFrames needs to be odd');
end
%% Time Average Smooth
smoothDist = zeros(size(dist));
numFrames = size(dist, 1);
badIdx = (numSmoothedFrames - 1)/2;
for frameNum = ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.