sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
41dd5dccaeb446b2198f8a24fd313a14de47dbf1b48d9f4dbf4deab9b060f634
MATLAB
881
32
%% Test that factorGraphMakePairwise creates an equivalent model % by comparing the results of inference %% % This file is from pmtk3.googlecode.com setSeed(0); nnodes = 10; maxFanIn = 2; maxFanOut = 3; maxNstates = 3; ntrials = 10; for i=1:ntrials dgm = mkRndDgm(nnodes, maxFanIn, maxFanOut, ...
9ac22531135aab0069bca26ffc40a1dd500f1b6958bed3b1f896252202f51fd8
MATLAB
881
32
function val=jsonopt(key,default,varargin) % % val=jsonopt(key,default,optstruct) % % setting options based on a struct. The struct can be produced % by varargin2struct from a list of 'param','value' pairs % % authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu) % % $Id: loadjson.m 371 2012-06-20 12:43:06Z fangq $ % %...
eec9e9ea633486de87172fe334d3ae193679a50e83edf2c3c8f2b13e6d5651a6
MATLAB
881
32
function EMP_Transform_Curvelet(num_) X1 = readtable(strcat('../../Data/VCF/output_0.csv')); X1(:,1) = []; X1(1,:) = []; X = table2array(X1); C = fdct_wrapping(X,1); A = []; for i = 1:length(C) for j = 1:length(C{i}) D = reshape(C{i}{j}, 1, []); A = [A D]; ...
138d13bc6356c2328fa8a88a6c76e5963ac0ae9a4f4b560b54643247f7450ec0
MATLAB
882
31
function nrm = norm(A) %NORM Frobenius norm of a ktensor. % % NORM(T) returns the Frobenius norm of a ktensor. % % See also KTENSOR. % %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. ...
353baccea893a1e8c86fb310ad90d12dcf5bd5650959a55987ccedb8ef7d7195
MATLAB
882
11
function res = calDP(spkDev, cIndx, wins, iteration) for wIndex = 1 : size(wins, 1) [~, ~, count_Correct] = cellfun(@(x, y) NoveltySU.utils.calFR(x, wins(wIndex, :), y), {spkDev.correct(cIndx).spikePlot_on}', {spkDev.correct(cIndx).trials}', "UniformOutput", false); [~, ~, count_Wrong] = cellfun(...
71c6e38d0a1681e84aaaa0e933ee5a7b2173c13ecb9b99725f33b9735c36a011
MATLAB
882
26
function Simul(file,vid) start = AS_Init(strcat(file,'.csv')); out = AS_Run(start,vid); if vid gifmaker(file,out); out = rmfield(out,'MOV'); end save(strcat(file,'.mat'),'out','-v7.3'); %% Figures s = out.s; t_lim = out.t_lim; T = out.RES.T; P = out.RES.P; U = out.RES.U; N1 = sum(out.NEUR(:,2)==1); N2 = su...
831b54b07c1868e55d33bcbd6f24f97431c7eb3f6940291298e873aebf156e5f
MATLAB
882
37
function e = check_element_orientation_3d(e,p) % Checks if the 3D tetrahedral elements are oriented in a positive way. % If not, it re-orients them. % Tetrahedron (pa, pb, pc, pd) is % positive if the point pd lies below the % plane passing through pa, pb, and pc; "below" is defined so % that pa, pb, and pc a...
a4315e73d9cc3eb3e254cff4724e73a0742da2a3d9fb7d73f023915d96f0891f
MATLAB
882
36
function new = ensureAllStructsAssignable(old, DEBUG) % checks each structure in an array to ensure they all have the same % fields, will also reorder all the fields into the same order % new = ensureAllStructsAssignable(old, DEBUG) % old is a structure array, DEBUG is [0 1] on whether to print messages % when mismatch...
bd81a2952338a9d216fc741c1dfcc006af7d388037ecdc347c73409483ccc3b3
MATLAB
882
27
% crop_fmf(infmf,outfmf,startframe,endframe) function crop_fmf(infmf,outfmf,startframe,endframe) [header_size,version,nr,nc,bytes_per_chunk,nframes,data_format] = fmf_read_header(infmf); if startframe < 1 || startframe > nframes || endframe < 0 || endframe > nframes || startframe > endframe, error('startframe or ...
bf7bb8ff7978426fa129b8e3658a153b642d4bfb9e1b9244ab2bc3975a51a0db
MATLAB
882
34
function lbl = loadLbl(lbl_file,varargin) % Load a .lbl file. Returns a *struct* with fields similar to those you might % find in a Labeler object. keeptempdir = myparse(varargin,... 'keeptempdir',false ... ); tname = tempname() ; mkdir(tname); try fprintf('Untarring project %s into %s\n',lbl_file,tname); un...
581dc3d84894bdaf9a7e418dca84b6cea07c7af1c558272444c937e23ecd8b87
MATLAB
883
39
function [TestImage_Round]=ImageRoundnessTest(TestImage,Round_Threshold) TestImage_BW=logical(TestImage); se = strel('disk',5); TestImage_BW = imclose(TestImage_BW,se); [B,L] = bwboundaries(TestImage_BW,'noholes'); stats = regionprops(L,'Area','Centroid','PixelList'); % loop over the boundaries for k = 1:length(B)...
b187cc6dc758fd35197d66bff18edf4ed0dec90ed96b7fed19e00220efe64188
MATLAB
883
20
function [m,c] = linmap( li, ui, lo, uo ) % DIFF2D Differentiation in 2D images % INPUT: % li,ui - minimum and maximum input variable values (X) % lo,uo - minimum and maximum output variable values (Y) % OUTPUT: Linear conversion can be done with Y = X*m + c; % m - linear slope parameter % c -...
22d2af43d5346257810bc84123b61cfd15f61c5de3930c8eb9cab71670567127
MATLAB
884
37
function [gamma, alpha, beta, loglik] = hmmFwdBack(initDist, transmat, softev) % Calculate p(S(t)=i | y(1:T)) % INPUT: % initDist(i) = p(S(1) = i) % transmat(i,j) = p(S(t) = j | S(t-1)=i) % softev(i,t) = p(y(t)| S(t)=i) % % OUTPUT % gamma(i,t) = p(S(t)=i | y(1:T)) % alpha(i,t) = p(S(t)=i| y(1:t)) % beta(i,t) propto p(...
97576546ad2705d67fb7a98d5040fbfbbb1feb2ac943d4909726cfe6ae3a978b
MATLAB
884
31
function [S] = facets_area_tetrahedron(a,b,c,d) % FACETS_AREA_TETRAHEDRON Calcultes tetrahedron facets area. % % SYNTAX: % [S] = FACETS_AREA_TETRAHEDRON(A,B,C,D) % FACETS_AREA_TETRAHEDRON(A,B,C,D) % % [S] = FACETS_AREA_TETRAHEDRON(A,B,C,D) % - A, B, C and D - are m by 3 matrices of (x,y,z) cartesian coordinates ...
ab5746ec80ab8f71cfae47076252189cae99476cf1474212fdbd92cdce946101
MATLAB
884
26
function [index, logicArray] = consecAboveThresh (inputVector, amplThreshold, spanThreshold) %% >>> OPERATION >>> % Finds n consecutive values above a certain threshold % Marco Bocchio, 4/7/19 if size(inputVector,2) == 1; inputVector = inputVector'; end aboveThreshold = (inputVector > amplThreshold); %whe...
bc1833718477d06ebda8898734536fa32ae248f7b8ef0b98d5bf2023db30d119
MATLAB
884
28
%% Posterior predictive density for Bayesian linear Regression in 1d % %% % This file is from pmtk3.googlecode.com setSeed(1); [xtrain, ytrain, xtest] = polyDataMake('sampling', 'sparse', 'deg', 2); fitMethods = {@(x,y) linregFit(x,y), @(x,y) linregFitBayes(x,y)}; predictMethods = {@(x,y) linregPredict(x,y), @(x,y...
d7dafd413c60b1372a71bde327f29306b76aa254cdfe44bd07540e0d791366f1
MATLAB
884
48
function [pnt, tri] = read_vtk(fn) % READ_VTK reads a triangulation from a VTK (Visualisation ToolKit) format file % Supported are triangles. % % Use as % [pnt, tri] = read_vtk(filename) % % See also WRITE_VTK % Copyright (C) 2002, Robert Oostenveld % % $Id$ fid = fopen(fn, 'rt'); if fid~=-1 npnt = 0; while...
6407668dc9653d25ea4af0faed3b89929b7565636c3119f68b386687ec76ed82
MATLAB
885
40
function [dtypechar,bytes_per_element] = matlabclass2dtypechar(matlabclass) switch matlabclass, case 'char', dtypechar = 'c'; bytes_per_element = 1; case 'int8', dtypechar = 'b'; bytes_per_element = 1; case 'uint8', dtypechar = 'B'; bytes_per_element = 1; case 'int16', dtypechar = '...
e98d2445d4142c47c93d3f74cae3c51f6afc8b47484f317d39ad297a01a1744a
MATLAB
885
53
function X = lyapslv(~,A,~,Q) % called from 'dlyap' as: X = lyapslv('D',A,[],Q); n = size(A,1); assert(size(A,2) == n,'matrix A not square'); assert(isequal(size(Q),size(A)),'matrix Q does not match matrix A'); % Schur factorisation [U,T] = schur(A); Q = -U'*Q*U; % solve the equation column ~by column X = zeros(n...
f2a7a9e43d64478f01f4322d4661ccb434cc783a77c4d63eabdfe14d8f0b9835
MATLAB
885
22
% from http://www-stat.stanford.edu/~tibs/ElemStatLearn/ % See their book p47 fid = fopen('prostate.txt'); C = textscan(fid,'%f%f%f%f%f%f%f%f%f%f%s'); fclose(fid); % rownum lcavol lweight age lbph svi lcp gleason pgg45 lpsa names = {'lcavol', 'lweight', 'age', 'lbph', 'svi', 'lcp', 'gleason', 'pgg45', 'lpsa'}; istrai...
6f1ff8c62b8ce807b95798309875738af3984ce03d86e3543aebed6f20e10053
MATLAB
886
25
function kout = merge_seg(seg,kval) % merge small voxels to neighboring clusters % % Alexandru V. Avram, % NIH 2022 % if nargin<2 kval = 1e4; % dummy value end % assign labels to spurious voxels denoted with 1e4 kout = seg; disp(['Total of ',num2str(length(unique(seg(seg>0)))),' clusters found. As...
a6c4bcc229db6de3c1cd59a71c84dd42cea3f51d42028c2d8581f0a129234b77
MATLAB
886
32
function lf = leadfield_interpolate(pos, vol) % LEADFIELD_INTERPOLATE interpolates the leadfield for a source at % an arbitrary location given the pre-computed leadfields on a regular % grid. % % Use as % lf = leadfield_interpolate(pos, vol) % Copyright (C) 2013, Vladimir Litvak % % $Id$ % express the position in ...
d769ca8530df7cff3afcf7dbd51f51770c69457607fd0aaf573b64ae5dcdf5fb
MATLAB
886
41
% this demo replicates the exemple in the 'dynamical system theory' part % of the 'principles of DCM' talk (SPM course, may 2013). clear all close all nt = 3e2; f_fname = @f_2d; g_fname = @g_Id; in.A = [-2 -16 4 -2]; in.dt = 1e-2; x0 = [1;1]; theta = []; phi = []; alpha = 1; sigma = Inf; u =zeros(1,nt); %...
ee31d581e965704711124db4bd59e78569df03c38e0088eb4af71b9c5e631ffc
MATLAB
886
31
% Author: Birgit Nierula % nierula@cbs.mpg.de function [norm_matrix] = normalize_2zscore(data_matrix) % concutenate trials to continuous signal tmp = NaN(1, size(data_matrix,1) * size(data_matrix, 2)); size_counter = 0; for itrial = 1:size(data_matrix, 1) tmp(1, size_counter+1 : size_counter+size(data_matrix, 2))...
704da6f5f5de1e6d2a8532e90ed50ecb4a10fefe4ce4b3580e49652b5d6a31b2
MATLAB
887
32
% Parse the file 04cars.dat from % http://www.amstat.org/publications/jse/datasets/04cars.txt if 0 fid = fopen('04cars.dat'); %dat = textscan(fid, '%45c%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d'); while 1 tline = fgetl(fid); if ~ischar(tline), break, end disp(tline) end fclose(fid); end %Cosma Shalizi has already pa...
b3808ad51225c9c4c04c6f9dee7673f3b84687da9b194e9dce9f9abc64b38042
MATLAB
887
33
function clf = clfKnnTrain( clf, X, Y ) % Train a k nearest neighbor classifier (memorization). % % USAGE % clf = clfKnnTrain( clf, X, Y ) % % INPUTS % clf - model to be trained % X - nxp data array % Y - nx1 array of labels % % OUTPUTS % clf - a trained k-nearest neighbor classifier. % % EXAMP...
b85cfb7985988d77fb232f75e7c240049fa2c9489c160d56f4556eff434c945c
MATLAB
887
34
function otherForm = onOff(originalForm) % Convert 'on' and 'off' to true and false and vice-versa. % TODO: support arrays/cell arrays of values. otherForm = []; % Special case 1 and 0 to be the same as true and false. if isnumeric(originalForm) if originalForm == 1 ...
c24b452fedcf6b9f163596f7664391c798a771d1de549a6a7c110322dd78ff9e
MATLAB
887
54
function [u_hori,u_vert] = UnWarpPlane(x1,x2,x3,x4); % Recovers the two 3D directions of the rectangular patch x1x2x3x4 % x1 is the origin point, ie any point of planar coordinate (x,y) on the % rectangular patch will be projected on the image plane at: % x1 + x * u_hori + y * u_vert % % Note: u_hori and u_vert are a...
db7186ba4202b73905f6602a8cd49bd1890c2c13a1c6554613b83bcfc2770aae
MATLAB
887
30
function HumanOdorRep_plot_sig_stars(pair, p, yheight, deltay) % function to add sig stars to a barplot %----------------------------------------------------------------------------------------- % Kehl et al. 2024 (DOI:XX) % Single-Neuron Representations of Odors in the Human Brain % Author: Marcel Kehl % License: MIT...
98886e97569bcc96b8f14c184a579ecde02cc20239e2bf9a6788f9ab1f9a0f41
MATLAB
888
25
function [dlc_files, pickle_files] = get_dlc_files_in_basepath(basepath) % use dir to find all files in basepath files = dir(basepath); files = files(~ismember({files.name},{'.','..'})); % remove non-files % get csv files csv_files = files(contains({files.name},'.csv')); pickle_files = files(contains({files.name},'.p...
ba52dbb0093d37bf9855b59621b434f71f0b16faa8d355f6c7e869329d70bb97
MATLAB
888
31
function offsetAxes(ax,varargin) % thanks to Pierre Morel, undocumented Matlab % and https://stackoverflow.com/questions/38255048/separating-axes-from-plot-area-in-matlab % % by Anne Urai, 2016 if ~exist('ax', 'var'), ax = gca; end if isempty(varargin) offset= 4; else offset= varargin{1}; end % modify the x a...
da06f39fdc1ffe10b5eba2967e9c4d4b30bec454d9f8d11d95c2e261620b2075
MATLAB
888
45
function Cfg = DPABISurf_MultiEcho(Cfg) % DPABISurf_MultiEcho % Select multi-echo data analysis method. % % Usage: % Cfg = DPABISurf_MultiEcho(Cfg); if nargin < 1 || isempty(Cfg) Cfg = struct; end CfgOriginal = Cfg; figWidth = 320; figHeight = 240; fig = uifigure( ... 'Nam...
4ded85a323b6fd2200db361ea16a7381a57805dd0e9877598bdc50b2b536c174
MATLAB
889
24
%{ Copyright (c) 2025 Axion BioSystems, Inc. Contact: support@axion-biosystems.com All Rights Reserved %} classdef BlockVectorData < Entry %BlockVectorData contains instructions for loading the Data types % (See BlockVectorDataType.m) from the data portions of the file % listed in the header...
5217676f2278152c453399d2b6d679b8b13ab822ce1e82bfccb096827cce67cf
MATLAB
889
28
function Draw_ROIs_Through_Cortex_3_Views(Anat,roi,Conn,params) % This function displays hemispheres with ROI spheres and sticks connecting % them in 3 views. Px=0; Py=-110; Pz=-125; Txt='+'; Ctxt=[1,0,0]; disp('<<< Drawing ROIs and sticks on transparent brains, please be patient') figure('Color','w','Position',[50...
52fd6935d6e66327cbbfe014adee9f50087d047ca92f83f206daaef494a6e95d
MATLAB
889
32
% MF_SV Solve using multifrontal factorization. % % Typical complexity: same as MF_MV. % % Y = MF_SV(F,X) produces the matrix Y by applying the inverse of the % factored matrix F to the matrix X. % % Y = MF_SV(F,X,TRANS) computes Y = F\X if TRANS = 'N' (default), Y = F.'\X % if TRANS = 'T', and Y = F'\X...
7265a1234995cdf6915f83155a35259f0f4b429a37dc8a49689578f8299411ab
MATLAB
889
39
function I = movieToImages( M ) % Creates a stack of images from a matlab movie M. % % Repeatedly calls frame2im. Useful for playback with playMovie. % % USAGE % I = movieToImages( M ) % % INPUTS % M - a matlab movie % % OUTPUTS % I - MxNxT array (of images) % % EXAMPLE % load( 'images.mat' ); [X,map]=gray2ind...
ba4040ff1b62e6a840e54ad2a9e41b9b13ceda96358e5e3ef55f1c5e970217a4
MATLAB
889
44
%% cov2corr % % Convert (auto)covariance to (auto)correlation % % <matlab:open('cov2corr.m') code> % %% Syntax % % R = cov2corr(G) % %% Arguments % % See also <mvgchelp.html#4 Common variable names and data structures>. % % _input_ % % G a covariance matrix or autocovariance sequence % % _output_ % % ...
e4a8e2cfa4bd09dbf627988968d9ab8150071da3bdefac5df75229916ba48c57
MATLAB
889
34
% %forked from +util/read_indexed_column.m % %urut/jan'19 function data = nwb_read_unit(vector_index, vector_data, row) %READ_INDEXED_COLUMN returns the data for a specific row of an indexed vector % % DATA = READ_INDEXED_COLUMN(VECTOR_INDEX, ROW) takes a VectorIndex from a % DynamicTable and a ROW number and outpu...
44a18d3d7c2746bc7af20e114133168e6ffa1b2544eec305d650e4448f59b891
MATLAB
890
29
function X = full(T) %FULL Convert a ttensor to a (dense) tensor. % % X = FULL(T) converts ttensor T to (dense) tensor X. % % See also TTENSOR, 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/~tgko...
4f1f0c7be1c90bee61ca06d28fb5d0cb83f9c3795092729d42475c5221356f90
MATLAB
890
34
function c = cond_2x2(A) %COND Condition number with respect to inversion. % COND2d(X) returns the 2-norm condition number (the ratio of the % largest singular value of X to the smallest). Large condition % numbers indicate a nearly singular matrix. % % COND(X,P) returns the condition number of X in 2-norm: ...
57d91ed07bbe8c4c196419c0b1820bcca4bf4db3012c77a4fad20b536613b1ab
MATLAB
890
32
function m = size(t,idx) %SIZE Size of a ttensor. % % D = SIZE(T) returns the size of the tensor. % % I = size(T,DIM) returns the size of the dimension specified by % the scalar DIM. % % See also TTENSOR, TTENSOR/NDIMS. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tens...
b04df09e8cc5b9e3eed06ab8b7cde69dbf66cd0fbc6a5b92f513434931371735
MATLAB
890
26
clear all; close all; clc; % import table T=readtable('PatientData.csv'); % Memory recall DV=T.PSD; % compare values between groups [p h stats]=ranksum(DV(T.RandomisationOrder==1), DV(T.RandomisationOrder==2),'method','approximate','tail','right') % correlation in LF and HF group DVB=T.MemoryTask2-T.MemoryTask1; [r...
c4b86fd3e9d15994fb4ae7dbfffffd509216962cf2ebcc166e8d4e8725ef3629
MATLAB
890
23
function [nchannel, idxgrid] = getgridconfigOEphys(ports, adapter) % find the ports from the Quattrocento with a grid idxports = find(ports == 1); % get the indexes of the grid nchannel = 0; ch = 1; for i = 1:sum(idxports) if contains(adapter{i}, 'GR04MM1305') || contains(gridname{i}, ...
3bed0265a30cf04fa106f63fe8c71ea452c73b51097e3e6d10cda95b122fb49d
MATLAB
891
32
function model = linregRobustLaplaceFitLinprog(X, y) % Minimize the L1 norm of the residuals using linear programming % We assume X is an N*D matrix, with no column of 1s % model.w = [w0 w1 ... wD], where w0 is the bias % PMTKneedsOptimToolbox % PMTKauthor John D'Errico % PMTKmodified Kevin Murphy % PMTKurl http://ww...
54ae4227c1ca7ff59c28ab575fabc19398689934528d78e9aa3f083959bc8442
MATLAB
891
33
function siz = size(a,idx) %SIZE Return size of sptenmat. % % D = SIZE(T) returns the size of the tensor. % % I = size(T,DIM) returns the sizes of the dimensions specified by DIM. % % See also SPTENMAT. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. K...
73e05ac01ad333812640dffc71f7beb849c39dd639064b0fe838107c489ce749
MATLAB
891
31
function n2 = dist2(x, c) %DIST2 Calculates squared distance between two sets of points. % % Description % D = DIST2(X, C) takes two matrices of vectors and calculates the % squared Euclidean distance between them. Both matrices must be of % the same column dimension. If X has M rows and N columns, and C has % L rows...
eb0c2f9c4b88228d3ee1c7f3cf117e937fd66bc798d60c593635a0ef4dd4fa1f
MATLAB
891
39
%% Bayes factor for handedness/ gender data % This file is from pmtk3.googlecode.com clear all sfs = [1 2 3 4 5]; Nsf = length(sfs); BF10vsN = zeros(1,Nsf); for i=1:Nsf sf = sfs(i); y1 = 9*sf; n1 = 52*sf; y2 = 4*sf; n2 = 48*sf; N(i) = n1+n2; alphas = [1 1]; logZ = betaln(alphas(1), alphas(2)); logmarglik0 = ... bet...
6473048878053247d10e900b139d88a4412e3b12e34714298bde3b47cebb55e7
MATLAB
892
30
function w = linregFitGroupLassoProj(X, y, groups, lambda, winit) %% Fits the group lasso model % This file is from pmtk3.googlecode.com nVars = size(X,2); if nargin < 5, winit = zeros(nVars,1); end nGroups = max(groups); lambdaVect = lambda*ones(nGroups,1); funObj1 = @(w)SquaredError(w,X,y); funObj2 = @(w)groupL1re...
6db6c86fe4143c615e41772e45655af9417df2f34934bf131fb7daccb212fd44
MATLAB
892
34
% key = waitforkeypress(keys) function key = waitforkeypress(keys) keynums = zeros(size(keys)); for i = 1:length(keys), if length(keys{i}) == 1, keynums(i) = double(keys{i}); elseif strcmpi(keys{i},'enter') || strcmpi(keys{i},'return'), keynums(i) = 13; elseif strcmpi(keys{i},'backspace'), keynums(i)...
93f7c17bca6e81d34bf2bdb7fcbdbf78aee8a055677a97ecbb2ae8b5e532411a
MATLAB
892
31
function Z = mrdivide(X,Y) %MRDIVIDE Slash right division for tensors. % % MRDIVIDE(A,B) is called for the syntax 'A / B' when A is a tensor and B % is a scalar. % % Example % X = tenrand([4 3 2],5); % X / 3 % % See also TENSOR, TENSOR/RDIVIDE. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation....
a39d8fef676d0cb4dad0aa973dde8e66b28f49303913c6517be48d6e22f6fc3c
MATLAB
892
31
function Z = mldivide(X,Y) %MLDIVIDE Slash left division for tensors. % % MLDIVIDE(A,B) is called for the syntax 'A \ B' when A is a scalar and B % is a tensor. % % Example % X = tenrand([4 3 2],5); % 3 \ X % % See also TENSOR, TENSOR/LDIVIDE. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation....
d0128d6cb5e0566e945c35ec1a6e7d539c7e51aa3892785294cc9b42c840a95c
MATLAB
892
20
for total_wab_queue = 1:(shifting_key_n.*length(stitching_queue)) [kk, mm] = ind2sub([length(stitching_queue), shifting_key_n], total_wab_queue); asdasdasd = trform_2_pfor{total_wab_queue}; asdasdasd = flip(asdasdasd); if rssq(asdasdasd)>5 img_temp_1_max = image_observatory{total_wab_q...
9314700dcb9e06453930be58bc4ebdb0aa563db2994d39954efc3d34493ccf8a
MATLAB
893
40
function [ns, STEP, DELAY] = conveRT (s, g, typestat) %Function converts statistics concerning reaction time from model units to milliseconds. TALL = find (typestat == 2); DALL = find (typestat == 3); ns = s; sumsT = sum (s (TALL)); sumsD2 = sum (s (DALL) .^ 2); if sumsT == 0 & sumsD2 == 0 STEP = 0; DELAY = 0; els...
9cfc6d9b5c2a5876fa9c80342a97b0e9c53d09a8ad8016cd264e41630e844ae2
MATLAB
893
37
function [tf,f0,p0] = findLabelNear(s,frm,itgt,fdir) % find labeled frame for itgt 'near' frm % % fdir: optional. one of +/-1, +/-2, [] (default) to search above, % below, or in either direction relative to frm if nargin<4 fdir = []; end if isempty(itgt), istgtmatch = true(size(s.frm)); else...
9fb9e28c828b4d161f18c51e885ba999d17e0c2806c446f6649640ac1393afe7
MATLAB
893
33
function m = size(t,idx) %SIZE Size of ktensor. % % D = SIZE(T) returns the size of the tensor. % % I = SIZE(T,DIM) returns the size of the dimension specified by % the scalar DIM. % % See also KTENSOR, KTENSOR/NDIMS. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor...
b3a0b59e12148ba612d47c4336b1c77fb04ec5ebe5d0e3977ad32c3e1e5c89bc
MATLAB
893
27
function filelist=nc_generate_file_list(fromdir, folder_prefix, file_prefix, file_suffix, second_folder) filelist={}; folders=dir(fullfile(fromdir, [folder_prefix, '*'])); if isempty(folder_prefix) == 1 folders(1:2)=[]; end for i=1:numel(folders) one_dir=fullfile(fromdir, folders(i).name, second_fold...
c001c306e033b95cc62b85d095abcc13e792b4de8bb92fc8a3707467dfc8ae5b
MATLAB
893
21
function max_run_jobs = concurrency_size_in_calculateDescriptorsInParallel(cond) loadParameters; if ~isfield(params,'CALC_DESC_MAX_RUN_JOBS') if params.USE_GPU_CUDA job_worker_mem_usage = 10 * cond.downsample_imgsize_dbl + params.MATLAB_PROC_CONTEXT; else job_worker_mem...
4037aa75d788e6a0eecccddc8a8b26cb7b9eb4b1fddf2531972ce17a7568666b
MATLAB
894
34
function X = tenones(varargin) %TENONES Ones tensor. % % X = TENONES(SZ) forms a tensor of size SZ with all ones. % % TENONES(SZ) is equivalent to TENSOR(ONES(SZ(1),SZ(2),...),SZ). % % See also TENSOR, ONES. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. ...
40ce62506b2c6c5de408c17a107dde084d68b07776eeade0ace29ff5dd462957
MATLAB
894
34
function [file_list_to_load, file_size, flcount] = import_tif_v4 (dataset_name, file_path, pixel, sliceNum, flyback) import ScanImageTiffReader.ScanImageTiffReader file_size = []; flcount = 0; for i = 1:31 file_name = [dataset_name '_' num2str(i,'%05d') '.tif']; fn = fullfile(file_path, file_name); if e...
6906ba6aa8bb151982c238b5a609e121907f2dc6d3acad3132c60e44c8a56901
MATLAB
894
36
% _ _ % ___ _ __ __ _| |__ ___ ___ _ __| |_ % / __| '__/ _` | '_ \/ __|/ _ \| '__| __| % | (__| | | (_| | |_) \__ \ (_) | | | |_ % \___|_| \__,_|_.__/|___/\___/|_| \__| % % gets spiketimes of already sorted spikes % from current channel's nerve function [spiketimes,...
5ca1c490e79f476df8126e50986ea91118edd99976c52ff1736b58becb232a56
MATLAB
895
22
function P2 = readpdf(P0,xg0,yg0,xg1,yg1,x0,y0,th0) % Translate/rotate an existing PDF to a new location/orientation and return % the resulting PDF. % % THE RESULT IS NOT (RE)NORMALIZED AND MAY NOT SUM TO 1 OR TO THE ORIGINAL % NORMALIZATION WHATEVER THAT MAY BE. % % P0: [ny x nx] array % xg0: [ny x nx] xgrid (origin...
61aa6f22a71c6b8c209a5ba2b7726a4c9ed1d50f2c7ab9f907481e4ff40df26e
MATLAB
895
28
% SPPUSH2 Append to 2-array sparse matrix representation. % % [I,J,NZ] = SPPUSH2(I,J,NZ,IA,JA) overwrites I(NZ+(1:N)) = IA and % J(NZ+(1:N)) = JA, where N = LENGTH(IA) = LENGTH(JA), and replaces % NZ := NZ + N, appropriately reallocating and expanding the capacities of I % and J as needed. % % Note: This fun...
c9602ae51815d9b815dab7211195c24b2e80859546ec342ab42a16df67902424
MATLAB
895
24
% finish spectrogram,psd,and bandpower calcalation % Edited by Jerry. 10/11/2022 function [Clkfy,Clktx,Clk_SPGM,Clkfw,Clk_PSD,Clk_deltaBP,Clk_betaBP]=... GetFrequencyAnalysis_221011(params,ClkLFP) % get parameters % spectrogram and fft parameters sps = params.SampleRate; % sample rate specNfft = pa...
01de9d04e56a18802af84c3864e66ff209ee5d93b881eb4a206b91aeb5e306d8
MATLAB
896
28
function [frMean, frSE, countRaw, frSD, trials] = calFR(spikes, window, trials) if ~iscolumn(trials) trials = trials'; end trialN = length(trials); spikes(~(spikes(:,1) >= window(1) & spikes(:,1) <= window(2)),:) = []; if size(spikes, 2) == 1 temp = tabulate(spikes(:, 1)); elseif size(spikes, 2) == 2 ...
15bdf78668838bc19338a572ff94e6859d44e827af93b15757600a6830b3a767
MATLAB
896
46
function [G, names] = parseAlarmData() % data from http://www.cs.huji.ac.il/site/labs/compbio/Repository/Datasets/alarm/alarm.net T = removeEmpty(getText('alarm.net')); names = {}; for i=1:numel(T) line = T{i}; if startswith(line, '(var') toks = tokenize(line); V = toks{2}; names = i...
8ce7b1a7b4f3b4b973ffeb7c4b6422261efc5a75dbe6583d499a338bbed27a02
MATLAB
896
41
%% Fit linear and quadratic surfaces to data % Based on code by Romain Thibaux <thibaux@eecs.berkeley.edu> %% % This file is from pmtk3.googlecode.com loadData('moteData'); % X,y N = size(X,1); for useQuad = 0:1 if ~useQuad Phi = [ones(N,1), X]; else Phi = [ones(N,1), X, X.^2]; end w ...
50e29346434affd3bb587b3aaf5a88f5b56db1b806c1813bdaa2ac987679f95e
MATLAB
897
30
% changeaxisunits(factorx,factory) % changeaxisunits(factorx,factory,hax) % Changes the units of the x and y axes. % Suppose the original units of the x axis is frames and the original unit % of the y-axis is pixels, and we want to change to seconds and % centimeters, respectively. If a frame is .05 seconds and a pixe...
e4f93ecd3213325da475a2e324b960e7f3aa97907059add2967e5269a9a902f9
MATLAB
897
36
function y = VBA_sample(form,suffStat,N) % legacy code s = warning ('on'); warning ('*** The function `VBA_sample` is now deprecated. Please see `VBA_random` for an alternative.') warning (s); if nargin < 3 N = 1; end switch form case 'gaussian' if isscalar(suffstat.mu) N = {1, N}; ...
f06cb985ecfc5526b2a4876dd20c61f18359fcd63ed5951b42cc83267bf919e9
MATLAB
897
70
% _ _ % ___ _ __ __ _| |__ ___ ___ _ __| |_ % / __| '__/ _` | '_ \/ __|/ _ \| '__| __| % | (__| | | (_| | |_) \__ \ (_) | | | |_ % \___|_| \__,_|_.__/|___/\___/|_| \__| % % callback when main window is closed function close(self,~,~) path_name = self.path_name; pref...
cda9d099c878e7010517186a432d7861c68b23757b747153c24f670c7ad35b4c
MATLAB
898
30
% This script is an adaptation of Dr. J. Fortin's original source code. % The original source code can be found at https://github.com/Jfortin1/ComBatHarmonization/tree/master/Matlab % indices = batches{j}; % sdat = s_data(:,indices); % ghat = gamma_hat(j,:); % dhat = delta_hat(j,:); % g.star is first row % d.star is s...
f157c002cc32c6b98bf3e10876e6d5561dd680698eca247564346324593387f9
MATLAB
898
51
function sub_s=subsets1(s, k) % Creates sub-sets of a specific size from a given set % SS = subsets1(S, k) % % S is the given set % k is the required sub-sets size % % Example: % % >> ss=subsets1([1:4],3); % >> ss{:} % ans = % 1 2 3 % ans = % 1 2 4 % ans = % 1 3 4 % ans = % 2...
00b790c4939d88cca04972e506c2a5f686fc62dbf3353a7ddb7ec2e116a7e2f1
MATLAB
899
34
function [gx,dgdx,dgdp] = g_HRF_distributed(Xt,P,ut,in) % observation function for distributed HRF Balloon model (DCM for fMRI) % function [gx,dgdx,dgdp] = g_HRF(Xt,P,ut,in) % This function evaluates the hemodynamic static observation equation % function. if isfield(in,'fullDCM') && in.fullDCM ind_profile = in.ind...
b70f5d9815692e856cc6d2c344c6b86af0bc1291999e4d93a8578b5d6d31ec63
MATLAB
899
37
function logp = dirichletLogprob(arg1, X) % logp(i) = log p(X(i, :) | alpha) % logp = dirichletLogprob(alpha, X) OR logp = dirichletLogprob(model, X); % *** X is automatically appended with [X, 1-sum(X, 2)] *** % % If model.alpha is a scalar, it is automatically replicated to the right % size. % %*** Note, values outsi...
fd5e74ea9614a3405b75af1ad58ba85402431dbd3defc179eb77d0521b1c5a3f
MATLAB
899
43
%% Create a 3D vesicle template % Author: Antonio Martinez-Sanchez % r: radius % t: thickness % s: size of the template (should be odd) % w: wedge semiangle in degress % rw: angle rotation for the wedge % mode: 1-> hard in range [-1,1], 2-> hard in range [0,1], otherwise -> soft % T: output 3D template function [T] = ...
477b020ba25a6fd1a437a509fa755fda364c66ae3a7361e3bdf49b428cd507a3
MATLAB
900
32
function [Results] = normality(x, alpha) % alpha=0.05; n=length(x); y=sort(x); % D'AGOSTINO - PEARSON TEST beta2=(3*(n^2+27*n-70)*(n+1)*(n+3))/((n-2)*(n+5)*(n+7)*(n+9)); wsquare=-1+sqrt(2*(beta2-1)); delta=1/sqrt(log(sqrt(wsquare))); alfa=sqrt(2/(wsquare-1)); expectedb2=(3*(n-1))/(n+1); varb2=(24*n*(n-2)*(...
48c006c6957af310cee3d887c2f2628c2d7cd9196515e6078f337e6b5c77dc06
MATLAB
900
30
function [model, bestParams, CVmu, CVse] = svmlightFitCV(X, y, varargin) % Fit an svm using svmlight setting C and/or the kernelParam via cv. % This file is from pmtk3.googlecode.com [C, kernelParam, kernelType, saveAlphas, cvopts, svmopts] = ... process_options(varargin,... 'C' , [] ,... ...
aef87ab0f897cfd34e29f9c783fd5cf15e30bb62e16a207d01bc348b1e021376
MATLAB
900
26
function Z = times(X,Y) %TIMES Array multiplication for tensors. % % TIMES(A,B) is called for the syntax 'A .* B' when A or B is a % tensor. A and B must have the same size, unless one is a scalar. A % scalar can be multiplied by a tensor of any size. % % See also TENSOR. % %MATLAB Tensor Toolbox. %Copyright ...
bbe98a9b5b2a8927200174b8cf5b7e3cac29fefce9c7e5797fea128dc18d5574
MATLAB
900
37
%% K-means clustering for Height Weight data % %% % This file is from pmtk3.googlecode.com rawdata = loadData('heightWeight'); X = [rawdata(:,2) rawdata(:,3)]; % height, weight [styles, colors, symbols] = plotColors(); plotArgs = {'linewidth', 1.5, 'markersize', 10}; figure(); plot(X(:, 1), X(:, 2), [symbols(1), co...
220b751a31dac54f1ec7b47da99095e38e7e98ee4ae9b37d2670ca0c09b8e5da
MATLAB
901
27
function imroi = montageImPadGrab(im,xc,yc,rad,th,tfAlign,padval) % grab a patch form an image centered around a certain point % im: image % xy/yc: center of patch % rad: radius % th: (optional) angle. only used if tfAlign % tfAlign: logical. if true, grab patch with rot as given by th % padval: backgroun...
d3300bbd09565e5699c065794b3632980c4267c6e878af7ef79eb920558d740e
MATLAB
901
45
function [header] = jbm_parseHeader(fn) imginfo = imfinfo(fn); imginfo = imginfo.ImageDescription; input = imginfo; tempstring = {}; index = 0; tempcell = strread(input, '%q'); for lineCounter = 1 : length(tempcell) data = tempcell{lineCounter}; if strncmp(data, 'state.', 6) index = in...
01dc23d787499f4a59a2c86fe7872936aeaf4e2315205d937c35f7d03210195f
MATLAB
902
24
%% 统计特征 | statistical features %% 过零率 | Zero-crossing rate % X: single channel EEG signal (either a row vector or a column vector) %% Reference % [1] Şen, B., Peker, M., Çavuşoğlu, A., and Çelebi, F. V. (2014). A Comparative Study on Classification of Sleep Stage Based on EEG Signals Using Feature Selection and ...
05d40968d4a6939191a73f8cf07197416122b936b5a68cf61cf4bbf5b370b25d
MATLAB
902
53
function [C,lambda,S] = shrinkcov(X) % Ledoit-Wolf optimal shrinkage estimator for cov(X) % % % % C = lambda*T + (1-lambda)*S % % using the diagonal variance "target" T=diag(S) with the % unbiased sample cov S as the unconstrained estimate % This file is from pmtk3.googlecode.com %PMTKauthor Baback Moghaddam ...
26d7d49172ee2c926dd6cfe131bd395fb65640d55b12a9d8e3787d629e2ed3fb
MATLAB
902
37
function texto = plus_text(texto1, agre) % v.0.3 % % % if nargin == 0 texto{1,1} = [' _ ']; texto{2,1} = [' TOOLBOX: ' lanversion('l') ' ']; texto{3,1} = [' ']; texto{4,1} = [' laboratorio de analisis...
4d7cc50059daf6e96f1981500bc83bdcc5e2ac6ff1721bd67e91d66a29d81a73
MATLAB
902
24
% This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful,...
6b1caa6a56eaab8cbd49d4d6e71afdd15acde8ed824dcbf408d11e487d2a3c08
MATLAB
902
33
function gridDispProgress(~, totalCount) % gridDispProgress.m % % Prints the progress and estimated remaining time, even in a parfor loop % % Example Usage: % % D = parallel.pool.DataQueue; % num_files = 10; % gridDispProgress(1, num_files); % afterEach(D, @gridDispProgress); % tic % parfor ithParamSet = 1:num_files % ...
bc608f2564d5c2db51dc0ec3c3da5d0c3b99b6be876ecb6a33b25467afbc2e66
MATLAB
902
37
function D = diff2d( I, k, h ) % DIFF2D Differentiation in 2D images % INPUT: % Is - Input image % k - Dimension 1: x-dimension, otherwise: y-dimension % h - Step size % OUTPUT: % D - Output tomogram % % See also: diff3d, dtvoting, dtvotinge % % AUTHOR: Antonio Martinez-Sanchez (an...
0a5373851c34bf022609f037047201a21d5167e155635fdfb73260fdb4466d14
MATLAB
903
34
function [post, a] = gmmpost(mix, x) %GMMPOST Computes the class posterior probabilities of a Gaussian mixture model. % % Description % This function computes the posteriors POST (i.e. the probability of % each component conditioned on the data P(J|X)) for a Gaussian mixture % model. The data structure MIX defines th...
25bfea20f6c1f173c5ab551c68a88eeadf7df289f23ed34a20ad597f68977308
MATLAB
903
21
% This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful,...
376af4fd116090b7ba41167b761a9af4d2f24d8787e9c2b24751768fe57f74fc
MATLAB
903
45
function back = textWaitbar(back,percent) % %----------------------------------------- % back = textWaitbar(varagin) % % init: T=text_waitbar('Text'); % % use: T=text_waitbar(T,percent); % % example: % T=text_waitbar('Text'); % for i=1:200 % T=text_waitbar(T,i/200); % pause(.03) % ...
46fad7773dd7f3cc44e938aa99567916df7afe544a71363f2a44d76b661eb0f7
MATLAB
903
29
%% OLS on the prostate data set % Should match table 3.3 on p63 of "Elements of statistical % learning" 2nd edn % (The OLS results should be identical - the fact that they are not % suggests something strange is going on - most likely to do with % the offset term, which should be unregularized.) % Used to debug pros...
19d976b5c3413120f82172ba944fd01c127f0b3703b369faa1728d68e7dfd058
MATLAB
904
37
function img = makeRadialCheckerboard(pixelsPerDegree, sz, phase, contrast, thetaCycles, E, A, b) % % img = makeRadialCheckerboard(pixelsPerDegree, sz, phase, contrast, thetaCycles, E, A, b) if nargin==0 pixelsPerDegree = 100; sz = 5; thetaCycles = 8; E = 0.05; A = 1; % 0.8; b = 0.2; %.04; ...
2b34800bb6743353cbd12310b348a19cce03de575d6934423e02243bad7f7197
MATLAB
904
35
function [ filtered_data ] = fft_bandpass_filtering(data, srate, fband ) %FFT_BANDPASS_FILTERING ÀÌ ÇÔ¼öÀÇ ¿ä¾à ¼³¸í À§Ä¡ % ÀÚ¼¼ÇÑ ¼³¸í À§Ä¡ % data : time by channel or trials matrix % srate : sampling rate % fband : [low_bound high_bound] n_tp = size(data,1); n_ch = size(data,2); Fs = srate; %...
3fb72d889599610ac166868e178e86d841bdecb0cda65e787a6847e986911472
MATLAB
904
51
function out = zipvects(in1, in2) % 'zips' two vectors % put in the same shape in1 = in1(:); in2 = in2(:); n1 = length(in1); n2 = length(in2); % these have to be the same size assert(isequal(n1, n2), 'inputs are not the same length'); % turn everything into cells if iscell(in1) || iscell(in2), if ~iscell(i...
a383d2cc1080ff1fa82017be31bc80936d4d312f7b55f4d5ec2ddeda8906f7d7
MATLAB
904
17
% Count number of responses (individual spots) in input array % (ImageArray_DeltaGFPnMax_Reg2) % count only responses that are in the chosen region (AllBoutonsRegion) function RFNum_AllNMJ = CountResponses(ImageArray_DeltaGFPnMax_Reg2, AllBoutonsRegion) LastImageNumber = size(ImageArray_DeltaGFPnMax_Reg2,3); p...
c0989e943fc657752231075e612424bb1bb73e38c3f6d9a401a208c1734544b7
MATLAB
904
40
%===============================Preprocessing_Pipeline for MRI data=============================== % Geometric Distortions Correction - Compute topup run('extract_vols.m'); run('merge_vols.m'); run('compute_topup.m'); % Slice Timing Correction run('slice_timing.m'); %Motion Correction run('motion_correction_unwar...
65dc6f4a06990b5e7fdb72b4a90cac557d78d6da92ef26ad501cbc65ab8d9e47
MATLAB
905
22
% This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful,...
b543b72ea605a39ca53e2751b0d248f7b802fc9c856e100872d18afabeff6b22
MATLAB
905
34
function printPmtkFigure(filename, format, printFolder) %#ok % print current figure to specified file in .pdf (or other) format % This file is from pmtk3.googlecode.com %return; % uncomment this to enable printing if nargin <2, format = 'pdf'; end if nargin < 3, printFolder = []; end if isempty(printFolder) printF...
d9e823863b5b07a82d3c997220ba7a7c3404ec4690be7c5017f78b10751b77b5
MATLAB
905
37
function D = diff2d( I, k, h ) % DIFF2D Differentiation in 2D images % INPUT: % Is - Input image % k - Dimension 1: x-dimension, otherwise: y-dimension % h - Step size % OUTPUT: % D - Output tomogram % % See also: diff3d, dtvoting, dtvotinge % % AUTHOR: Antonio Martinez-Sanchez (an...
5a880da6198d6cb1f9028f6a26101854dd6b734bd0e28a67d0c3b11c1508f093
MATLAB
906
31
% CountRolls.m % Sarah West % 5/28/22 % Returns the number of data "rolls" (sliding/rolling window windows) that % can come out of a data period, based on "duration." % Inputs: % duration -- the number of time points in a time period. % windowSize -- the number of time points the window is across. % stepSize -- the n...
5fd1072d1bdf5bc10bce94dec31a0603c01619df3646b13671047d8ddee701f3
MATLAB
906
33
function model = crf2Create(adj, nStates, varargin) % Make a Conditional random field with pairwise potentials % This is identical to mrf2Create % except that we cannot create node and edge potentials % until we have seen some data % However, we let the user manually specify % the edge weights w and the node weights v,...