sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
015c69c1f4e3942c5231bf3e030147f445bd8212a683aba1a626cf05c58136a8
MATLAB
681
34
% D = dist2many2one( X , mu ) % % inputs: X is an n x d matrix % mu is a 1 x d vector % output: D is a n x 1 vector where D(i) is the squared Euclidean % distance between X(i,:) and mu. function D = dist2many2one(X,mu) % check input sizes if ndims(X) > 2 | ndims(mu) > 2, error('input X should be n x d, inp...
395654fbf81581de861282e16dfdb13cf562d38606a665f165015f3ff9548691
MATLAB
681
36
function varargout = scl_inter(varargin) % Format % For getting the value % dat = scl_inter(obj) % % For setting the value % obj = scl_inter(obj,dat) % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id$ if nargin==2, varar...
3d9bf4bc3666a712a503fb65c5b1e09f88db980062b0623cd62ca141074434ab
MATLAB
681
16
function plotRadialReflectanceTransmittance(model) [X,Y] = ndgrid(model.G.x,model.G.y); R = sqrt(X.^2 + Y.^2); Runq = unique(R(:)); Refl = NaN(size(Runq)); Tran = NaN(size(Runq)); for i = 1:numel(Runq) Refl(i) = mean(model.MC.NI_zneg(R == Runq(i))); Tran(i) = mean(model.MC.NI_zpos(R == Runq(i))); ...
43acd540a1433b051d7c8fd8440f72a89380b278ec278f70de1c575175b5c126
MATLAB
681
39
% Demo of ICA % This file is from pmtk3.googlecode.com [sigTrue,mixedsig]=demosig(); % create signal using fast ICA package [icasig, A, W] = fastica(mixedsig); X = mixedsig'; [B, Z, evals, Xrecon, mu] = pcaPmtk(X, 4); pcasig = Z'; figure; for i=1:4 subplot(4,1,i); plot(sigTrue(i,:)); end suptitle('truth') printPm...
44997b17c079f188efab098284488093572c0d9ce18348d41da68d1dbc02708c
MATLAB
681
33
%% Change of Variables Demo 1D % x ~ U(-1,1), y=x^2, plot pdf of y %% % This file is from pmtk3.googlecode.com xs = -1:0.1:1; a = -1; b = 1; %dist = UnifDist(a,b); %px = exp(logprob(dist, xs)); px = 1/(b-a) * ones(1,length(xs)); fn = @(x) x.^2; ys = fn(xs); % analtyic ppy = 1./(2*sqrt(ys)); % Monte Carlo n=1000; %s...
90f1323447140eb3a46252ee49c02f6b8ab559bc1b0426e5e9de5f83202acdfe
MATLAB
681
20
function display(t) %DISPLAY Command window display of a sptenmat. % % DISPLAY(T) displays the tensor with its name. % % See also SPTENMAT/DISP. % %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/Ten...
45de92b77af5e2abcf0333fe5a374e32b7635a4c8be7425a2014552bf80ca89f
MATLAB
682
27
% HIFDE_MV_SC Dispatch for HIFDE_MV with F.SYMM = 'S' and TRANS = 'C'. function X = hifde_mv_sc(F,X) % initialize n = F.lvp(end); % upward sweep for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; T = F.factors(i).T; if ~isempty(T), X(sk,:) = X(sk,:) + conj(T)*X(rd,:); end X(rd,:) = ...
4a4e90108263d51946308a8f4bce7a63616c21fe7f0460846773d3f12e647d41
MATLAB
682
23
% [path, fname, extension] = myfileparts(name) % [path, fname] = myfileparts(name) % Same as fileparts, except that: % if name ends with a filesep, the fname will be the last part of the path % and % if extension output is not specified, then extension will not be removed % from file name. function varargout = ...
6add0f0a59c7492f65dff259474c1a0dfffb9aba80c662a3d1a836bd4b102748
MATLAB
682
27
% HIFDE_SV_SC Dispatch for HIFDE_SV with F.SYMM = 'S' and TRANS = 'C'. function X = hifde_sv_sc(F,X) % initialize n = F.lvp(end); % upward sweep for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; T = F.factors(i).T; if ~isempty(T), X(rd,:) = X(rd,:) - T'*X(sk,:); end X(rd,:) = F.fac...
1185300ed9017d2f711a103553703eca27e9e7bd22f9ca9f5ad13126c00947b2
MATLAB
683
21
% Transform the json files obtained with OpenPose into a single MAT file. function openPoseJSon2Mat(jsonTargetDir,saveTargetName) fprintf('Transforming to mat file...\n') jsonFiles = dir(jsonTargetDir); jsonFiles([jsonFiles.isdir]==1) = []; openBodyData_all = struct; for iFrame=1:length(jsonFiles) bodyD...
778a0f509e67469fd43ae188a0b24cc330da055934f50845c922f48c5230d1d3
MATLAB
683
24
function labels=cookLabels(labelsRaw) % Make sure the labels only contains the fields we want from the raw labels. % ALTODO: remove me or put in Labels nLabels=length(labelsRaw); labels = ... struct('t0s',cell(1,nLabels), ... 't1s',cell(1,nLabels), ... 'names',cell(1,nLabels), ... 'flies'...
89dea057f7924389a6c6157b010a4990eae417cf42202a7d560470b13c927978
MATLAB
683
18
function [coherence, skew, roiSize] = evaluateROIs(A, C, patchSize) % [coherence, skew, roiSize] = evaluateROIs(A, C, patchSize) % Computes coherence, skew, and size of an ROI % Coherence is computed on all pixels in the FOV, so small ROIs will be % biased towards high values due to most pixels being 0 ...
acd29322686dc272913a52c6c4d25662f96c0b6b0dedc73a0d6fc3fd2b042e7e
MATLAB
683
23
seed = 0; rand('state', seed); randn('state', seed'); data = load('mpg.dat'); N = size(data,1); perm = randperm(N); %data = data(perm,:); % remove any possible ordering x = data(:, 1:7); y = data(:,8); [n,d] = size(x); Xtrain = x(1:300,:); ytrain = y(1:300); Xtest = x(301:end,:); ytest = y(301:end);...
d025c406e0fb13d6b96ff8cd2c28f247bab7e062d7620d59d8eeccdb40f6a3d9
MATLAB
683
29
function gg_out = getAxesChildren(h) % function gg = getAxesChildren(h) % gets all children of a function handle that are either axes, color bars % or other objects. Aims to ignore objects that aren't relevant for visible % formatting such as hidden items, context overlays etc. % Shaihan Malik Oct 2024 gg = get(h,'Chil...
d5c7f0b8f9220f27bf2fbcef3e71c0d92352966b541b1628b7527da712291e09
MATLAB
683
31
function v=simpvol(p,t) %SIMPVOL Simplex volume. % V=SIMPVOL(P,T) % Copyright (C) 2004-2006 Per-Olof Persson. See COPYRIGHT.TXT for details. switch size(p,2) case 1 d12=p(t(:,2),:)-p(t(:,1),:); v=d12; case 2 d12=p(t(:,2),:)-p(t(:,1),:); d13=p(t(:,3),:)-p(t(:,1),:); v=(d12(:,1).*d13(:,2)-d12(:,2).*d13(...
eb0cbc0fa6d30eaaba27750eb16f0fa7ae0bc6fab0974983ad3fc831ef824aa1
MATLAB
683
20
function display(t) %DISPLAY Command window display of a tensor. % % DISPLAY(X) displays a tensor with its name. % % See also TENSOR, TENSOR/DISP. % %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/T...
fcb27d07fb3ba177b017ec49e18d2c96ce62f7af61529f6e86acfdc8104bce9f
MATLAB
683
28
function str = printand(strs, quote) % PRINTAND prints a single or mutiple strings as "x1, x2, x3 and x4". If there is % only one string, that string is returned without additional formatting. % % See also PRINTOR if nargin<2 quote = false; end if quote if numel(strs)>2 str = sprintf('''%s'', ', strs{1:(end-...
4aa16407207ae64935b9bcbd1b892bdaf5532f9f2c1112660766d0f1c9337a45
MATLAB
684
33
clc clear close all rootdir = 'C:\Users\fmora103\iCloudDrive\Desktop\Mauricio\Trajectories-main\mouse_track\experiments\preliminary\mouse_6'; files = dir(fullfile(rootdir,['*.mat'])); for n=1:length(files) load([files(1).folder '\' files(n).name]) files(n).name clf plot(r_arena_holes(:,1),r_arena_ho...
699d00b2262e644a1ab1d28edce1d25c3e6133406d4d385355606bcb5be99576
MATLAB
684
25
function S = struct_mfile_reference(mfile,struct_name,strs) % S = struct_mfile_reference(mfile,struct_name,strs) % AF 11/1/01 pattern = [struct_name '.']; if (~isempty(mfile)) strs = grep(mfile,pattern); end S = []; for i = 1:length(strs) inds = strfind(strs{i},pattern); for j = inds(:)' start_field =...
86a2a818fbee9589ddab7fb58f32be30ac647bcd116f7e72882c45a85d0615a2
MATLAB
684
24
function V = value_determination(p, T, R, discount_factor) % VALUE_DETERMINATION Solve Bellman's equation for a fixed policy % V = value_determination(p, T, R, discount_factor) S = size(T,1); A = size(T,2); % Extract the part of T and R which is specific to this policy Tp = zeros(S,S); % Tp(s,s') = T(s, p(s), s') Rp...
d21ff182c21425d128dbcb4a6215ad322f0cd1a0f3480b01ba8323d882430edc
MATLAB
684
23
% checks if a given list % of files is consecutively numbered. % throws an error if not function checkConsecutive(allfiles) allfiles = {allfiles.name}; idx = all(~diff(char(allfiles(:)))); common_stub = allfiles{1}(1:find(~idx,1,'first')-1); seq_idx = NaN(length(allfiles),1); for i = 1:length(seq_idx) this_fil...
ec6ea4aeb9276e5501e994f775711bf4be1249a057d4759f46ac468357c9f656
MATLAB
684
29
function out = prepareArgs(args) % Convert a struct into a name/value cell array for use by process_options % % Prepare varargin args for process_options by converting a struct in args{1} % into a name/value pair cell array. If args{1} is not a struct, args % is left unchanged. % Example: % opts.maxIter = 100; % opts.v...
0b1158ea71fc3bb26c98f19a5dd26f80e9dfd87d3533a7b4eaf9c6950edafabf
MATLAB
685
29
function [X, y] = mixDiscreteSample(T, mixWeight, nsamples) % Sample nsamples from a mixture of discrete distributions. % X(i, :) is the ith sample generated from mixture y(i). % %% INPUTS: % % T is a matrix of size nmix-nObsStates-d % mixWeight is a stochastic vector of size 1-by-nmix %% OUTPUTS: % X is of size nsam...
4dae0d107eda4eed467540752aa33ab1ee97f7ea09f723c39c53f3798725abf6
MATLAB
685
28
function r = circ_dist(x,y) % % r = circ_dist(alpha, beta) % Pairwise difference x_i-y_i around the circle computed efficiently. % % Input: % alpha sample of linear random variable % beta sample of linear random variable or one single angle % % Output: % r matrix with differences % %...
6321614c33599dbd694c2a37fdcc58184ac235357755e6fd4078d70634910fcd
MATLAB
685
20
function A = double(X) %DOUBLE Convert tensor to double array. % % A = double(X) converts X to a standard multidimensional array. % % See also TENSOR. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www.sandia.gov/~tgkol...
7fffc0105a8e158e1c2a16952f953d43ad9819e4fb137c0a758566ab9265e252
MATLAB
685
20
function X = full(X) %FULL Convert to a (dense) tensor. % % FULL(X) returns X, i.e., does nothing. % % See also TENSOR, SPTENSOR/FULL, KTENSOR/FULL, TTENSOR/FULL. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www.sandi...
c29e2bd3edee58f75d006eedf865d4013509155fd77d4e8a8d83169fe010ea67
MATLAB
685
18
function [X, y] = createXORdata(doplot) %% Generate noisy XOR data % This file is from pmtk3.googlecode.com if nargin < 1, doplot = false; end setSeed(0); off1 = gaussSample(struct('mu', [1, 1], 'Sigma', 0.5*eye(2)), 20); off2 = gaussSample(struct('mu', [5, 5], 'Sigma', 0.5*eye(2)), 20); on1 = gaussSample(struct('m...
e63057d93c6c25fe410e05699684bc86f1e0deefda5d4fdd0d24d6bd29d44dc6
MATLAB
685
27
function [yes_or_no] = isBRODMANN(elec_number, elec_label_list, bnumber_list) %createColormapFromAnnotations - Creates a colormap for Annotation of the %Surface % surface - Surface Data object % returns: % annotation_remap - remapped annotations from 1 to max % cmap - colormap associated with annotations % See ...
f1a967565db18855597ff5468139239c3331aa188ebe8280f21a3c0d3f0cd4f8
MATLAB
685
29
function r = circ_dist(x,y) % % r = circ_dist(alpha, beta) % Pairwise difference x_i-y_i around the circle computed efficiently. % % Input: % alpha sample of linear random variable % beta sample of linear random variable or one single angle % % Output: % r matrix with differences % %...
020a5fe31c64a798c6f2479cca51fd149f3fa35c98f9759565633f2fca27bf55
MATLAB
686
19
function n = ndims(t) %NDIMS Return the number of dimensions for a ttensor. % % NDIMS(T) returns the number of dimensions of tensor T. % % See also TTENSOR. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www.sandia.gov/...
1675aaf4a265cf16deeb48b4e62efc03e63536a66106292e726b565dd11d31a7
MATLAB
686
28
function p = isprefix(short, long) % Return true iff the first input is a prefix of the second % The second arg may also be a cell array of strings, in which case, each % is tested. CASE SENSITIVE! % % If the second argument is not a string, p = false, it does not error. % % EXAMPLES: % % isprefix('foo','foobar') % a...
f93359b415dddb13b1933c8fb9532aa267a648760b583a683d29322e10de06ce
MATLAB
686
21
% ReplicateData.m % Sarah West % 4/13/22 % Replicates data for use with RunAnalysis.m. Uses a string cell array as % input for dimensions. function [parameters] = ReplicateData(parameters) % Display progress message to user. MessageToUser('Replicating ', parameters); toReplicate_string = CreateStrin...
1209a7d01b8413e1c0212be78e54cc10e5d01045597eda307b00ae3200cfce84
MATLAB
687
33
function X=ms_normalize_channels(X) %MS_NORMALIZE_CHANNELS - Normalize the data so each channel has unit variance % %Consider using ms_whiten or mscmd_whiten % % Syntax: [Y] = ms_normalize(X) % % Inputs: % X - MxN array of raw or pre-processed data % % Outputs: % Y - MxN array of normalized data % % Other m-file...
63c1bfc30fc6acdc04ef08fc44493aa42e6edb68403dc3b74c38b6b98d1adc3a
MATLAB
687
16
% HIFIE3X Hierarchical interpolative factorization for second-kind integral % equations in 3D. % % This is the essentially the same as HIFIE3 but with certain modifications % that make it more suitable for second-kind integral equations or matrices % that otherwise have high contrast between the diag...
7a06cedf7105dac9a1e5819aba8284e93eb877eedcc62ebfd3cc5940c6afd55e
MATLAB
687
26
function [vtxs,nvtxs] = fs_read_label(labelf) % [vtxs,nvtxs] = fs_read_label(labelf) % % Reads the indices of the vertices of a Freesurfer's label. % % Input % labelf: A Freesurfer's label file. % % Output % vtxs: Indices of the vertices (1-based). % nvtxs: The number of vertices in the label. % % $Revis...
be1965a1961f94e0cb58e89f708d7787ee04c0ddb6fa1472f6b514dfef05a1b1
MATLAB
687
38
% demo for log-normal priors clear all close all g_fname = @g_exp; % gx = phi(2)*exp(phi(1)*in.x)+phi(3); f_fname = []; priors.muPhi = [0;1;0]; priors.SigmaPhi = zeros(3,3); priors.SigmaPhi(1,1) = 0.1; priors.a_alpha = 0; priors.b_alpha = 0; priors.a_sigma = Inf; priors.b_sigma = 0; inG.x = 1; u = []; options.inG ...
d0cef91dec8c511014924267443fc9a8636d9d508845cf4f94fdb02cb65238ed
MATLAB
687
32
function wlAddPaths % function wlAddPaths % % This function detects its own path and adds appropriate child paths to % Matlab's search path. % % No arguments or return value. % Detect the current path. fullname = which('wlAddPaths'); [ thisdir fname fext ] = fileparts(fullname); % Add the new paths. % Don't worry...
dc9f43c9ab963edcd60725e49faeb321f89ad6b8b85ad988268fd3dff894a080
MATLAB
687
16
% HIFIE2X Hierarchical interpolative factorization for second-kind integral % equations in 2D. % % This is the essentially the same as HIFIE2 but with certain modifications % that make it more suitable for second-kind integral equations or matrices % that otherwise have high contrast between the diag...
f020ea944ebe45aa3deb4456f9962247e353b2bfdd84a6573ec71856f2b7fdba
MATLAB
687
19
function A = double(T) %DOUBLE Convert ttensor to double array. % % A = double(T) converts T to a standard multidimensional array. % % See also TTENSOR. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www.sandia.gov/~tgk...
50add9a51071f2aaa9bc528f1ed5bd8bde85a02969d68559ac53e8fcba3ed39a
MATLAB
688
23
% Modify a paths struct and re-save for moving to a different computer % assuming that you are starting from fcp_4_beamforming % need to transfer from other machine: % - analysis/PID/ft_meg_fullyProcessed.mat % - config/[all files] % change project path locations new_project_path = '/home/jtseng/katie'; paths_loc...
592bc95997a94bc27c750dd2decb248904d127c3cdcfbe3ffe9539db9ccacc82
MATLAB
688
43
function [LAN latency ]= search_lat(LAN) % 14.4.2009 prueba % % % if iscell(LAN) for lan = 1:length(LAN) [LAN{lan} latency{lan} ]= search_lat_st(LAN{lan}); end else [LAN latency ]= search_lat_st(LAN) end end function [LAN latency ]= search_lat_st(LAN) mn = 0 my = 0 minor = []; mayor = []; for i = 1:le...
8c6bf5fd561d2070aaa246d1e9047113f43846d1a8b12331f548370112d8ca45
MATLAB
688
25
function text = pmlExtraCodeLatex() % Generates the latex code for the extra demos % This file is from pmtk3.googlecode.com root = fullfile(pmtk3Root(), 'bookDemos'); cd(root); d = cellstr(ls()); d = filterCell(d, @(c)~startswith(c, '.')); text = cell(2, 1); for i=1:numel(d) cd(d{i}); if exist('.\extra', 'fi...
e7eb0c8e37997142cc1e765b7a416c8abb050d8773e5f70ff0c5119d70a1a918
MATLAB
688
25
function [Xu] = VBA_conv2glm(u,tau) % transforms input times series into a GLM matrix for convolution model % function [X] = VBA_conv2glm(u,tau) % Note that a constant term is added to the model, which means that the GLM % convolution model contains nu*tau+1 parameters. % IN: % - u: nuXnt input times series % - tau...
e8b2c3c9411f3d47fd248a09819e6803b414c724542fa9b7ba60454fcd73e9b7
MATLAB
688
20
function positions=extract_video(varargin) % If varargin = 'targets', run code to find all targets (all pixels rather % than just the position based on the largest region) [data,timestamps,~]=read_neuralynx_file('VT1.nvt'); timestamps=1e-6*timestamps; %convert to seconds if strcmp(varargin,'targets') disp('extract...
1de7f93f35424cb055ed7bfa0a7f6d4fa3edfb88a46006521f5bfe126e64dc2e
MATLAB
689
24
classdef ShapeAugOrientation enumeration RAW % Shapes are used as-is RANDOMIZED % Shapes are randomized to an arbitrary orientation SPECIFIED % Shapes are oriented to known orientations theta end methods (Static) % Factory utility, create SAO based on CPR params function obj = createPerPar...
433b6ee8b2e6b7a7ac216156c55b146e2f532de391271284678f63a58a767bc3
MATLAB
689
31
function h = height_triangle(a,b,c) % HEIGHT_TRIANGLE Calcultes triangles heights. % % SYNTAX: % [H] = HEIGHT_TRIANGLE(A,B,C) % HEIGHT_TRIANGLE(A,B,C) % % [H] = HEIGHT_TRIANGLE(A,B,C) % - A, B and C - are m by 2 matrices of (x,y) cartesian coordinates % of vertices of m tetrahedrons. % - H - i...
77b3f4b75edd9341baafac1575df2e72eb73b280a572c2b975fd09eddc29af94
MATLAB
689
27
% _ _ % ___ _ __ __ _| |__ ___ ___ _ __| |_ % / __| '__/ _` | '_ \/ __|/ _ \| '__| __| % | (__| | | (_| | |_) \__ \ (_) | | | |_ % \___|_| \__,_|_.__/|___/\___/|_| \__| % % this is a plugin for crabsort.m % computes the PCA on the spike shape, and peak amplitude % an...
b1abdaaf9e48a5418c1fe9cc6e1a13e349f4dac22276f7a73bfeda826970efdb
MATLAB
689
27
% HIFDE_SV_NC Dispatch for HIFDE_SV with F.SYMM = 'N' and TRANS = 'C'. function X = hifde_sv_nc(F,X) % initialize n = F.lvp(end); % upward sweep for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; T = F.factors(i).T; if ~isempty(T), X(rd,:) = X(rd,:) - T'*X(sk,:); end X(rd,:) = F.fac...
4de1cd0206d2d926589dccfb34378f7e2496956e57574fc696cba69f4a032033
MATLAB
690
24
function success_code = calculateDescriptorsInParallel() loadParameters; run_num_list = 1:params.NUM_ROUNDS; arg_list = {}; postfix_list = {}; for run_num = run_num_list arg_list{end+1} = {run_num}; postfix_list{end+1} = num2str(run_num); end conditions = conditions_for_c...
54f4ebe3c93c3fa22128000956401fe0dcbdacfeb3a81ed298db6351dcfc0d67
MATLAB
690
39
function [s, b] = getFileSize(f) % Return the size of a file as a formatted string % The size is in bytes if less than a KB, KB if less than a MB, MB if less % than a GB, otherwise GB. The string includes the units. If the file % cannot be found, an empty string is returned. % %% Example % % s = getFileSize('mnistAll....
623ae77cc50c13339daf9fb01c0919a2135d545414fe80925acdc03085b09efe
MATLAB
690
16
%% 统计特征 | statistical features %% Log Root Sum Of Sequential Variation % The log root sum of sequential variations (LRSSV) is proposed in this paper to measure the sequential variations between the samples of the signal. % X: single channel EEG signal (either a row vector or a column vector) %% Reference % [1] M...
8e81e79440a9554ea0d404b7aa701b091fab0f6a0c55ceb8177b6dda6053f603
MATLAB
690
23
function [z] = VBA_fisher (r, inverse) % // VBA toolbox ////////////////////////////////////////////////////////// % % [z] = VBA_fisher (r, inv) % apply Fisher transformation to Pearson correlation coefficient % % IN: % - r: correlation to transform % - inverse: flag to apply the reverse transformation (default = f...
adff17c727c1446413d95db2e3550eb9c6c8355a898c124cc23e6a6aab4b8df8
MATLAB
690
30
function pred = discretePredictMissing(model, data) % data(n,j) is value of node j, can be NaN if missing % pred(n,j,k) is predicted probability % pred(n,j,v) = 1 if data(n,j)=v % model.T(k,t) [N D] = size(data); %#ok nStates = model.K; if isscalar(nStates), nStates = model.K*ones(1, D); end % First make delta func...
c71a55fa35b9cab27fbb1dd16f6c9d810cb28b78454986badb10cafc1842d384
MATLAB
690
29
% saveSDPToNNdata % saves spike detection parameters from % crabsort into NNdata function saveSDPToNNdata(self) channel = self.channel_to_work_with; if isempty(channel) disp('No channel selected') return end if self.common.NNdata(channel).sdp.isdefault % we write to NNdata only if it has default values. thi...
e93a04eb4c2750b3a062152d15cc4ebc40089d796a21a7659d21eb0d4cc68e1e
MATLAB
690
24
function Tbig = bsxTable(fn, Tbig, Tsmall, bigdom, smalldom) %% Apply a binary function to two multidimensional vectors using bsxfun % reshaping and virtually expanding the smaller table as needed % % The tables are matched up according to smalldom and bigdom % smalldom must be a subset (but not necessarily a subsequen...
ee5f3acfcf9ff5f58b4d5755cc9ad1994f01a0fa49bb66ee6b5ec19f8ab65746
MATLAB
690
29
function [cc,nflies] = AssignPixels(isfore,diffim,trx,t) [y,x] = find(isfore); X = [x(:),y(:)]; w = diffim(isfore); mu = zeros(0,2); S = zeros(2,2,0); for fly = 1:numel(trx) if t > trx(fly).endframe || t < trx(fly).firstframe continue; end i = trx(fly).off + t; mu(end+1,:) = [trx(fly).x(i),trx(fly).y(i)]; ...
fcf8fab4ae6b7f9bccf27e10475dc16fdb284b9c00e89652f10af8f9a6a53c0b
MATLAB
690
36
function [anybad] = check_spm_matfiles(P) % Check a list of SPM-style images to see if they all have the same % space, dims. % % :Usage: % :: % % [anybad] = check_spm_matfiles(P) % V=spm_vol(P); for i=2:length(V), chk = V(1).mat - V(i).mat; chk = chk(:); chk = chk(1:end-1); % eliminate SPM scal...
1763130803d1dd70fafe45f2284aeaea2d90910eb96dcea25adebb9abc68788f
MATLAB
691
42
function updatefly(h,x,y,theta,maj,min) % draw an isosceles triangle with center (x,y) % with rotation theta % with height maj*4 % with base min*4 if isstruct(x), trx = x; t = y; x = trx.x(t); y = trx.y(t); theta = trx.theta(t); maj = trx.a(t); min = trx.b(t); end if 0, ellipseupdate(h,maj*2,min*2...
7395603335a23af1c80a1789126964ee3bdc5348a28331b19cbc91fbc485178d
MATLAB
691
26
% How the draw potentials on the head load clab_example; sa=prepare_sourceanalysis(clab_example); % sa.elec2head is a matrix which maps values % on electrodes to values on the head % it was calculated (in perpare_souceanalysis by % elec2head=prep_v2head(sa.locs_3D,sa.head.vc,.5)); y=sa.locs_3D(:,1:3);yn=y; yn(...
16df1a8dfbd63ccd66653020f108ca3380ae364fee743e84076d7c1ca61f5d17
MATLAB
692
25
% opens a figure and sets the defaults for position and size function [hFig] = SetupFigure_220724(FigSizeInch) FigSize = [3.5 5]; if nargin > 0 FigSize = FigSizeInch; end paperSize = FigSize+2;%[8.5 11]; paperPosition = [1 1 FigSize]; % hFig = figure; set(hFig,... 'Defau...
1a553331be40396287464e178848ae59d169f7d3b74d515c81829d82825bd14a
MATLAB
692
30
%% pro_AddInput: Add a model input to the project % % Usage: % pro = pro_AddInput(pro, inputpdf, name, analyse) % % Inputs: % pro project structure % inputpdf reference to a @(N)pdf(N,...) % name name of the input % % Output: % pro project structure...
2aa7c316cea1433dc31e353e779ba18689e0b270c96eeb587911716cf54950b7
MATLAB
692
45
function def = get_landef(r,newr) % % LAN def function % % v.0.1 % % Documentation in \tex\lan.pdf % only in spanish % % 14.03.2012 % Pablo Billeke %path path = mfilename('fullpath'); path((end-10):end) = []; % lan def try load landef def if nargin ==2 eval(['def.' r ' = newr;']) ...
955268b3f77208a498f284dcdb9220bc90cd93edb893a0a0487e21cb6e0fec05
MATLAB
692
29
function modelHgivenV = studentCondition(model, v, visValues) % p(xh|xv=visValues) % This file is from pmtk3.googlecode.com mu = model.mu(:); Sigma = model.Sigma; dof = model.dof; d = length(mu); b = visVars; a = setdiff(1:d, b); dA = length(a); dB = length(b); if isempty(a) muAgivenB = []; SigmaAgivenB = [...
0fb39ac9e00302c3e09837d8258cb36404b7f858e4a80c10bed84ff7a48b636d
MATLAB
693
26
function showImmediateToolboxDependencies(fname) %% Display the immediate toolbox dependencies of a function % This file is from pmtk3.googlecode.com if nargin == 0; fname = currentlyOpenFile(true); end D = depfun(fname, '-toponly', '-quiet'); [TB, NTB] = partitionCell(D, ... @(c)~startswith(c, fullfile(matl...
2d4f940be96d13f253d0ba6a13b4c4f502a1dc64708eacc000306037af613ed0
MATLAB
693
23
function exportname = qualitycheck_exportname(dataset) % QUALITYCHECK_EXPORTNAME is used in ft_qualitycheck and the associated cron job [p, f, x] = fileparts(dataset); if ft_filetype(dataset, 'ctf_ds') try info = read_ctf_hist(dataset); c = datevec(info.startdate); % construct something like 20070320_1...
5928eb6bfeaeca42b792bbe98d7dccad82b6ce39cf1f3948ce51fc0427c45255
MATLAB
693
16
function setup = StateSwitch_settingsTask_MR(setup) % settings for task eeg setup.DEBUG = 1; setup.opacity = .99; setup.keyB = 1; setup.ET.useET = 0; setup.EEG.useEEG = 0; setup.EEG.DIO.parallelTrigg...
82f8a491bb6a03dc644c06fad86b39734c4e5fafe5b039cdc16941689f2cebc6
MATLAB
693
39
function X = invGammaSample(arg1, arg2, arg3) % Sample from an inverse gamma distribution with parameters a, b % X = invGammaSample(model, n); or X = invGammaSample(a, b, n); % This file is from pmtk3.googlecode.com if isstruct(arg1) model = arg1; a = model.a; b = model.b; if nargin < 2 n = 1...
bb5bfb4c162b814641823170b7d8baf234295639603cfe9a938c780b0fb1a5d6
MATLAB
693
37
clear % close all Monkey = ['Monkey1']; % ['Monkey1' or 'Monkey1'] %--------------- AlignBase = [{'PER_ON'}]; %--------------- Align = [{'GO'} {'Touch'} ] ; %--------------- Signal = ['beta'] % ['beta' or 'gamma'] %--------------- for base = 1:length(AlignBase) for al = 1:length(Align) ...
7fe25730ad35f96845e0ef4e1e2917f2547742c3e94f7757b57b474cc426f73d
MATLAB
694
20
function display(t) %DISPLAY Command window display of a sparse tensor. % % DISPLAY(T) displays the tensor with its name. % % See also SPTENSOR, SPTENSOR/DISP. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www.sandia.gov...
8e208e4be506fad1f1842ac0ceb21596e5192ce95b768cea4850aca17e9400ac
MATLAB
694
21
function n = norm(T) %NORM Frobenius norm of a tenmat. % % NORM(X) returns the Frobenius norm of a tenmat. % % See also TENMAT. % %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. % Cop...
97e60731c3c4fcc9ad06c9c16be8bc0b8946729a5ca7006c804062b2a1d5a212
MATLAB
694
22
function [featureLexicon,animalType]= ... featureLexiconFromFeatureLexiconName(featureLexiconName) [featureLexiconNameList, ... featureLexiconFileNameList, ... featureLexiconAnimalTypeList] = ... getFeatureLexiconListsFromXML(); indexOfFeatureLexicon= ... find(strcmp(featureLexiconName,featureLexiconNameL...
bc0e3972982f1900a182d71dca7606642a4cac4aa3a17302b480e649cb3ebc92
MATLAB
694
21
function n = norm(T) %NORM Frobenius norm of a tensor. % % NORM(X) returns the Frobenius norm of a tensor. % % See also TENSOR. % %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. % Cop...
5c25309ab596ae94d5ef2271496511968a26cf42424d88360c5021664e99e2a5
MATLAB
695
22
function nrm = norm(T) %NORM Frobenius norm of a sparse tensor. % % NORM(T) returns the Frobenius norm of a sparse tensor. % % See also SPTENSOR, NORM. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. % http://www.sandia.gov/~tgko...
9ef3d96be965cb797b7cd2bfd0cf5004f7e3a0f4eeebc9d72bb3a1ba581a2446
MATLAB
695
25
function logp = markovLogprob(model, X) % logp(i) = log p(X(i, :) | model.pi, model.A) % model.pi(j) = p(S(1) = j) - dist over starting states - % model.A(j, k) = p(S(t) = k | S(t-1) = j) - state transition matrix - % % where S(t) denotes the state at time step t. % % X(m, n) is in 1:length(mode...
c2839693ec9029c7732dcd9bd5db3040d149e781a226194b26e22ba9df820650
MATLAB
695
36
function [gx,dgdx,dgdp] = g_softmax4decoding(Xt,P,ut,in) eta=P; Xt = Xt+eta; beta=100; sx = length(Xt); dgdx=zeros(sx,length(Xt)); dgdp=zeros(length(P),length(Xt)); % if size(Xt,1) >1 % % % choice % ex = exp(beta*Xt); % gx=ex/sum(ex); % % % derivative wrt state % dgdx(:,:)=diag(beta*gx...
c45ade27561333464bf3107e5582fd9a7b56dc9df4408d3835a1b26281c997b8
MATLAB
695
38
%% Conjugate Function % %% % This file is from pmtk3.googlecode.com function conjugateFnExp f = @(x)x-(x-x.*log(-x)); domain = -1:0.0005:0; figure; hold on; m = -1/exp(1); plot([m,m],[0,f(m)],'-k','LineWidth',4); plot(domain,f(domain),'-r','LineWidth',5); axis([-1 0 0 0.4]); set(gca,'XTick',[-1 -0.5 0],'YTick',[0 ...
cacff366c1233f70d7918095e2e6e0a84235970a13e0fd98baf0ae0ad561e2f8
MATLAB
695
17
function bf10 = binombf(k,n,p) % % bf10 = binombf(r,n,p) % % Calculates Bayes factor for binomial test with k successes, n trials and base probability p. % This is based on the Bayes Factor example on Wikipedia (http://en.wikipedia.org/wiki/Bayes_factor). % It is the same as the default prior assumed by Rouder's ...
d56b8ebc5df6294160f8b8f8f9f899383da016d8ab91801792659237a6439e76
MATLAB
695
15
function TSdeletesubject(SubId) % deletes a subject from the Experiment structure, eliminates its ID # from % the Experiment.Subject field and reduces the Experiment.NumSubjects by 1 % %Syntax: TSdeletesubject(SubId) % NB the input arguments is the subject's ID# --NOT its index # % Also IF THE STRUCTURE CONTAINS FIELD...
17be00c6fc0fae46f5b9ee424047e9f6371a3beee7589793dc29ad69cc7e6efb
MATLAB
696
27
function centerOnParentFigure(fig,parentFig,varargin) [setParentFigUnitsPx] = myparse(varargin,... 'setParentFixUnitsPx',false ... % for dealing with UIFigure/appdesigner ); if setParentFigUnitsPx parentUnitsOrig = get(parentFig,'Units'); set(parentFig,'Units','pixels'); end unitsOrig = get(fig,'Units'); set(...
980a3230068b1c336dfec6e350f6c4dcea2d06cd9d9e81fbfd32d6cd7565190f
MATLAB
696
33
function [tffound,f] = seekSmallLposThresh(lpos,f0,df,th,cmp) % lpos: [npts x nfrm] % f0: starting frame % df: frame increment % th: threshold % cmp: comparitor % % tffound: logical % f: first frame encountered with (non-nan) label that satisfies % comparison with threshold, applicable if tffound==t...
6675d41c17555cb0138b4b8851c84a247ab621e731e9cc13422f5d398e983d9c
MATLAB
697
21
function feat1= NNCAE(data) [N, n] = size(data); X = data; % Define the autoencoder architecture inputSize = size(data, 2); % Input size hiddenSize = 128; % Number of units in the hidden layer % Create and train the autoencoder autoencoder = feedforwardnet(hiddenSize); autoencoder.layers{1}.transferFcn = 'p...
c0d9d4dab9eb08dd8016b79a77055cbe13810a7bb56c686157764af1ea026b88
MATLAB
697
21
function s = tt_intvec2str(v) %TT_INTVEC2STR Print integer vector to a string with brackets. % %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...
cf1ed9e05d38639434c469c281bd7a703c14d7851c325181283259cc12208415
MATLAB
697
14
function mua = calc_mua(wavelength,S,B,W,F,M) persistent muadeoxy muafat muamel muaoxy muawater musp nmLIB if isempty(muadeoxy) load('spectralLIB.mat','muadeoxy','muafat','muamel','muaoxy','muawater','musp','nmLIB'); %#ok<NASGU> end mua_deoxy = interp1(nmLIB,muadeoxy,wavelength); mua_fat = interp1(nmLIB,m...
d8c3723cd245c6c530acf8003d505c95572fdba67b2344e9d8971f0fc528c95f
MATLAB
697
35
function varargout = offset(varargin) % Format % For getting the value % dat = offset(obj) % % For setting the value % obj = offset(obj,dat) % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id$ if nargin==2, varargout{1} =...
5102678261d4672188d9a3e77d831376c7feeb31ec0c1f7a6cdde1b9ff639be7
MATLAB
698
29
% RSKELF_MV_NN Dispatch for RSKELF_MV with F.SYMM = 'N' and TRANS = 'N'. function X = rskelf_mv_nn(F,X,mode) % initialize n = F.lvp(end); % upward sweep if bitget(mode,1) for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; X(sk,:) = X(sk,:) + F.factors(i).T*X(rd,:); X(rd,:) =...
753b822d1cc1e1fec8be8916ae5f4b1eca83901b23e8210fca4b56e7037f91d3
MATLAB
698
17
echo off % % The SUBPLEX method is a generalization of the Nelder-Mead Simplex (NMS) % method. It works by decomposing a high-dimensioned problems into % low-dimensioned sub-spaces which are easily handled by NMS. % Because of its relationship with NMS, SUBPLEX retains the advantages % of NMS on noisy functions. % ...
b2989a7c43c475adbb2cb4c52dc46eb10e4dca3880402bb53a914198820276a3
MATLAB
698
29
% RSKELF_SV_NN Dispatch for RSKELF_SV with F.SYMM = 'N' and TRANS = 'N'. function X = rskelf_sv_nn(F,X,mode) % initialize n = F.lvp(end); % upward sweep if bitget(mode,1) for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; X(rd,:) = X(rd,:) - F.factors(i).T'*X(sk,:); X(rd,:) ...
bae53d233c7a36203369216646a0bf6784fa0233787c207681184efa309c2528
MATLAB
698
29
function ell = getellipse(hfig,varargin) [color] = myparse(varargin,'color','r'); fprintf([' Use normal button clicks to add points. A shift-, right-, or\n',... ' double-click adds a final point and ends the selection.\n',... ' Pressing RETURN or ENTER ends the selection without adding\n',... ' a final poi...
ff80854e13997dbc134b170578b1e945140c651715c03456631a2c3aa4cdc772
MATLAB
698
25
ind = 1; data = dir('/DATAPOOL/ERRORMONITORING/SEM_mri_data/P*'); %% for i = 1:size(data,1) data_func = dir([data(i).folder, '/', data(i).name, '/mri/SEM_', data(i).name, '/nifti/func/run*']); for j = 1:size(data_func,1) spm_folder = [data_func(j).folder, '/', data_func(j).nam...
1e9819a96d072b734bfa933ea06a9dbb84dc16cca99bab378874d959c589b557
MATLAB
699
29
% RSKELF_MV_SN Dispatch for RSKELF_MV with F.SYMM = 'S' and TRANS = 'N'. function X = rskelf_mv_sn(F,X,mode) % initialize n = F.lvp(end); % upward sweep if bitget(mode,1) for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; X(sk,:) = X(sk,:) + F.factors(i).T*X(rd,:); X(rd,:) =...
7f89809b6a594049e131efa87379be0420bb2d465c167dbbeb911079cf413d25
MATLAB
699
24
% color correction function success_code = colorcorrection_3D_cuda() loadParameters; arg_list = {}; postfix_list = {}; run_num_list = 1:params.NUM_ROUNDS; for run_num = run_num_list arg_list{end+1} = {run_num}; postfix_list{end+1} = num2str(run_num); end conditions = cond...
8f9b5e862a3e607d8324f9d9eb453d6fd5e8b939cf1564d1cce0558cffb124da
MATLAB
699
29
% RSKELF_SV_SN Dispatch for RSKELF_SV with F.SYMM = 'S' and TRANS = 'N'. function X = rskelf_sv_sn(F,X,mode) % initialize n = F.lvp(end); % upward sweep if bitget(mode,1) for i = 1:n sk = F.factors(i).sk; rd = F.factors(i).rd; X(rd,:) = X(rd,:) - F.factors(i).T.'*X(sk,:); X(rd,:)...
1379b7780fa73f78369e2d9725b368aba044e75f6bfb9019002940095b45e00d
MATLAB
700
25
function [fn, extension] = remove_extension(fname) % REMOVE_EXTENSION Removes a file extension from the string/char array. % % [FN,EXTENSION] = REMOVE_EXTENSION(FNAME) Removes a file extension from % the filename FNAME. It returns the file root FN and the extension % itself. E.g. FNAME = '/dir1/dir2/file.xxx' give...
68020ccdc2e349107a2513fba1eb283f5014980e4767a910716ccd09373bfba2
MATLAB
700
20
% DETPERM Determinant of permutation vector. % % D = DETPERM(P) computes the determinant (i.e., sign) D of the permutation % P. % % In both MATLAB and Octave, this is done by calling DET on the associated % permutation matrix, which for efficiency should be represented explicitly % as sparse in the form...
72f40b52d311b140990bba8f65242f2432668bb15304520ec8379a2682d237d9
MATLAB
700
29
function LAN = lan_from_csv(Files, Path) LAN.data{1} = []; if nargin == 0 [Files, Path, ~] = uigetfile({'*.csv','CSV file';}, 'Open .csv EEG files',... '*.csv', 'MultiSelect', 'on'); elseif nargin == 1 Path = ''; end if iscell(Files) for c = Files LAN = importcsv(LAN, c{1}, Path); end ...
4ca281c373271b1e6e012d83b7b8930d218fa10b2288978fe82a04e7967fee1e
MATLAB
701
20
function anat_ns=no_skull(anat_file,mask,anat_nn) target_file{1,:}=[anat_file ',1']; target_file{2,:}=[mask, ',1']; out=fileparts(anat_file); matlabbatch=[]; matlabbatch{1}.spm.util.imcalc.input = target_file; matlabbatch{1}.spm.util.imcalc.output = anat_nn; matlabbatch{1}.spm.util.imcalc.outdir = {out}; matlabbatch...
a7a2a7be40581e8274feba1486389e1fb7d32151e544ca8bb65c38319043560d
MATLAB
701
25
function ndx = topAboveThresh(scores, N, thresh) % Return indices of top N items which are above threshold % scores(i): confidence % N - max number to return % thresh(i): threshold to use for scores(i); thresh can be a scalar % % Examples % topAboveThresh([1 2 3 4], 2, 1) % [4 3] % topAboveThresh([1 2 3 4], 4, 1) % [4...
ae2c07843848f55aad1f9bd9500b2f1282fd7b915e74281625e92efc936a754f
MATLAB
701
26
function new_filename = get_new_filename(filename, noSpaces) %GET_NEW_FILENAME Returns a new filename based on the one specified. % Usage: % new_filename = get_new_filename(filename) % new_filename = get_new_filename(filename, true) % no spaces if nargin < 2 || isempty(noSpaces); noSpaces = false; end % Break fil...
d45b15167740090ea10363d69baea7c54e5e63473fa029e138446e8974b28d90
MATLAB
701
25
% DFF.m % Sarah West % 12/2/22 % Function that finds the delta F/F, given a set of fluorescence values and % a mean. Is run by RunAnalysis % Inputs: % parameters.data -- the fluorescence values to convert into percents % parameters.fluorescence_mean -- the mean fluorescence, should work with % the dimensions of param...
d4e862045d48ffa472bc0c98df10267491f521496f15945dbfbfa26f53b855b2
MATLAB
701
25
function ROOTPATH = getRootDirPath(currentPath, N) % If N is set non-zero, return N-backward root path of current path. % NOTICE: DO NOT SET FieldTrip PATH to THE TOP % e.g. % currentPath = fileparts(mfilename("fullpath")) % >> currentPath = 'D:\Education\Lab\MATLAB Utils\file' % % N ...