sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
40bbbeb5d48305eb57dcc0fece991ce075bd46df6c22423b576c17291b806ec0
MATLAB
800
25
function [converged] = convergenceTest(fval, previous_fval, threshold, warn) % Check if an objective function has converged % % We have converged if the slope of the function falls below 'threshold', % i.e., |f(t) - f(t-1)| / avg < threshold, % where avg = (|f(t)| + |f(t-1)|)/2 % 'threshold' defaults to 1e-4. % This ...
d63a96ce531b910567d92660aec8a83768adb0d0f6746e8fd75b792adffed834
MATLAB
800
24
function e = end(X,k,n) %END Last index of indexing expression for tensor. % % The expression X(end,:,:) will call END(X,1,3) to determine % the value of the first index. % % See also TENSOR, TENSOR/SUBSREF, END. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox b...
0a9dcc6078e126207d5ba738e912d4c8c76ff2cc0aea0491e70c390ff7996aa9
MATLAB
801
34
function smat = sprintfmat(s,varargin) % check argument sizes if nargin == 1, smat = s; return; end; if size(varargin{1},1) == 1 & size(varargin{1},2) > 1, varargin{1} = varargin{1}'; end; n = size(varargin{1},1); for i = 2:nargin-1, if size(varargin{i},1) ~= n & size(varargin{i},2) == n, varargin{i} = var...
1486afc11a51d9299ed2eb6fc1bda617fc2506b473006607bf0b32fd0bb62261
MATLAB
801
27
function [ max_overlap ] = get_cell_nucleus( cell, nucleus, name ) % Input: cell channel, nuclei channel take_maximal_volume = 1; max_overlap = volume_filtering( cell.*nucleus, take_maximal_volume); % % ----------------- Watershed segmentation % [ nuclei_seg ] = segment_nuclei( nucleus ); % % ...
6b6c221df5b8bb89036119095d271689d9ad380fb6e912efb0c98686ca3949c7
MATLAB
801
28
function Y = linearTransform(X,X_range,Y_range) if (nargin < 2) || isempty(X_range) X_range = minmax(X(:)'); end if isempty(Y_range) error('linearTransform:Y_range','Y_range cannot be emtpy'); end if isempty(X) error('linearTransform:X','X cannot be emtpy'); end if nu...
538b7642a78df6a94ad51ed00b38ee6df7169e404ff0b00ff9ad752263f46eea
MATLAB
802
31
function sNew = structSelect(s, fieldSel) fieldSel = string(fieldSel); if length(s) > 1 sField = fields(s); wrongIdx = find(~ismember(fieldSel, sField)); if ~isempty(wrongIdx) error(strcat(strjoin(fieldSel(wrongIdx), ","), " is not a field in the old structure!")); end [~, selectId...
f9092983e3113b940c0d9298cc2d22f8c51f92c98ddb8f04a094be2b52d4984b
MATLAB
802
34
function [transform] = pos2transform(pos, dim) % POS2TRANSFORM reconstructs a transformation matrix from an ordered list % of positions. % % Use as % [transform] = pos2transform(pos, dim) % where pos is an ordered list of positions that should specify a full 3D volume. % % The output transform is a 4x4 homogenous t...
24a2ad54b44256c8e1f75fb77a391ed204c8d6b5f8e4164385a70aa3e9f0bc42
MATLAB
803
24
function e = end(X,k,n) %END Last index of indexing expression for tenmat. % % The expression X(end,:) will call END(X,1,2) to determine % the value of the first index. % % See also TENMAT, TENMAT/SUBSREF, END. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by ...
ab22e16875d2338fbd9ffb019831ddc2e5f8131b92e0feb272346f6b584153c5
MATLAB
803
23
function [ f, J] = nakarushton( params, x ) %LOGISTICFUN evaluates modified logistic with params at x % Detailed explanation goes here %========================================================================== %define inputs x = x(:); Rmax = params(1); n = params(2); kappa = params(3); %===========...
d9bdb419e502d01fc5af4d66927d3f561bc8ec1c79efcfdca3aa187625a70e4d
MATLAB
803
21
function [time_matrix] = Xtime_traintest(trainA,trainB,testA,testB,timewindow,labels_train,labels_test) % cross decode between condtions train on 4 test on 1 bin. And across time. % train on timepoint t and test on all other timepoints % checked with simulation % train time_matrix = nan(1,length(timewindow)); %vecto...
359d168c6326b3449f5dc223b84253f201c76fe8a420d06bb74abe8ad093b320
MATLAB
804
30
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Peel off of the Motor unit spike train % Input: % X = whitened signal % spikes = discharge times of the motor unit % fsamp = sampling frequency % win = window to identify the motor unit action potential with spike trigger averaging ...
911dd57a6be243dc39f73e1aaa0e3e45963ea99fca02c9ddc6b6dd38b2216339
MATLAB
804
25
function [h, p, c] = plotContour(fn, xyRange, varargin) % Plot contours of the function % evalatuated at xyRange = [xmin xmax ymin ymax]. % % All other args (varargin) are passed directly to the contour function, % except for 'npoints', which is by default 100 and 'ncontours'. %% % This file is from pmtk3.googlecode.c...
bc3da89e01652dfbb5ff1f1662db0f92cb3bf4b09802c4c07268f9d6f826bc1e
MATLAB
804
30
function h_resetXYLimit3(handles) [currentInd, handles, currentStruct, currentStructName] = h_getCurrendInd3(handles); fig = findobj('Tag','h_imstack3Plot','Selected','on'); axesobj = findobj(fig,'type','Axes'); xlimStr = get(handles.xLimSetting,'String'); if strcmpi(xlimStr,'auto') set(axesobj,'XLimMod...
7762c7a142a68541c233240e7111237b316a1a99421ce771cd9fe9097af28caa
MATLAB
805
33
% % _ _ % ___ _ __ __ _| |__ ___ ___ _ __| |_ % / __| '__/ _` | '_ \/ __|/ _ \| '__| __| % | (__| | | (_| | |_) \__ \ (_) | | | |_ % \___|_| \__,_|_.__/|___/\___/|_| \__| % % plugin to load .SMR files into crabsort. % uses the smrlib toolbox % that can be found here: ...
e727d1bffdb50a824132194c56fd9e57f2a20a52bd570230c212992c720ea53c
MATLAB
805
34
function save3DImage_uint16(vol,path) if max(vol(:))>intmax('uint16') fprintf('Warning: some values to be saved at %s are over uint16 maxval\n',path) end if min(vol(:))<0 fprintf('Warning: some values to be saved at %s less than 0\n',path) end if endsWith(path,'.tif') %This is a wrapper function around...
fb941d5263a5f0e12a20d20e9bd4d3cdecce8ea24cbfdf1f7616e8df81521ecc
MATLAB
805
25
%% Run t-test Enrichment TCfc= fc(:,:,(group==1)); VPTfc = fc(:,:,(group==2)); fccombined={ TCfc VPTfc}; Bxname='group1 vs group2'; group1 = 'group1'; group2 = 'group2'; % Set parameters params.np=1e4; % Number of permutations: set to 1 to get simple stats %params.type='Pearson'; % flavor of correla...
ff65c853e6f42f6568235b428fac7d093c8e2a8d08988a88e25617b50d1a8a47
MATLAB
805
40
function [coeffs,err]=harmfit(vc,center,order); % fits spherical harmonics to a set % of surface points vc=vc(:,1:3); [nsurf,ndum]=size(vc); vc=vc-repmat(center,nsurf,1); rad=sqrt(vc(:,1).^2+vc(:,2).^2+vc(:,3).^2); nblock=ceil(nsurf/100); for i=1:nblock; disp(i); if i<nblock vcloc=vc((i-1)*100+1:i*1...
28518a1f4b92c0066e23677fc24701ef0d616cf76df896bddb8deee5a6eef3f9
MATLAB
806
25
%% Linreg frequentist caterpillar demo %PMTKneedsStatsToolbox regress %% % This file is from pmtk3.googlecode.com requireStatsToolbox X = loadData('caterpillar'); % from http://www.ceremade.dauphine.fr/~xian/BCS/caterpillar y = log(X(:,11)); % log numner of nests X = X(:,1:10); [w, stderr, pval, R2, sigma2, confint,...
3cd77f9e475efb242dccc6c50da4cb4ddcee58e2063a03e58d241aee2c5a5260
MATLAB
806
22
function Z = plus(X,Y) %PLUS Binary addition (+) for tensors. % % PLUS(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 % added to a tensor of any size. % % See also TENSOR. % %MATLAB Tensor Toolbox. %Copyright 2015, Sand...
3f1b269f511fb89f02c22a7399f266216b92aa0ab7b97da10d2de8dd234e54d6
MATLAB
806
33
function S = h5att2struct(filename, location) %H5ATT2STRUCT Reads a set of HDF5 attributes into a named structure. % Usage: % S = h5att2struct(filename, location) % % Returns: % S: structure with fields corresponding to the attribute names, or empty % if no attributes are found if nargin < 2; location = '/'; ...
b3977072e5edae03e8e6f18e85242afb5b1fd5a8d2b68c21a6178404ac41626c
MATLAB
806
26
function m = size(t,idx) %SIZE Sparse tensor dimensions. % % D = SIZE(T) returns the size of the tensor. % % I = size(T,DIM) returns the sizes of the dimensions specified by DIM. % % See also SPTENSOR, SPTENSOR/NDIMS. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor ...
38ce38758676acb433ac36dd1593918b67124b2967ba96d31490c2db503756b2
MATLAB
807
53
function h = hline(y, varargin) %HLINE Easy plotting of a horizonal line. % Usage: % hline % hline(y) % hline(ax, _) % hline(_, ...) % plot args (e.g., linespec) % h = hline(_) % % Args: % y: y-value % % See also: vline if nargin < 1; y = []; end ax = []; if isax(y) ax = y; y = []; if nargin ...
4bf47cc879ae79223a3257bda4c15d28534e923efdce42949085c873320822b0
MATLAB
807
44
%% Agglomerative Clustering Demo %PMTKneedsStatsToolbox dendrogram, cophenet, linkage % Based on http://www.mathworks.com/access/helpdesk/help/toolbox/stats/index.html %% % This file is from pmtk3.googlecode.com requireStatsToolbox clear all if 0 % Alpaydin data X = [1 3; 1 4; 5 2; 5 1; ...
571b1c0db69e853855093f5437c7ad9e7f2a375ea1b1c4d464313f6bc91cc15f
MATLAB
807
27
function [arena_center_x,arena_center_y,arena_radius] = arena_params(annname,moviename) if exist(annname,'file'), [arena_center_x,arena_center_y,arena_radius] = ... read_ann(annname,'arena_center_x','arena_center_y','arena_radius'); else arena_center_x = []; end; if isempty(arena_center_x) if exist(annname,'...
5f52d3bcb8082e4491e18124a5483774a14d5b6c721683c231b8354a0b11fe16
MATLAB
807
20
function [ax,sh,fh,cmap] = plot_rfields(ax,space,rfield,simulation,spaceArgs,rfieldArgs) if (nargin < 5) || isempty(spaceArgs) spaceArgs = {}; end if (nargin < 6) || isempty(rfieldArgs) rfieldArgs = {'LineWidth',1,'HandleVisibility','off'}; end [ax,sh] = func.plot_space(ax,space,spac...
b3f4644c46d906789ee717457276829c1e6a2be99f122ce440c48b4b0493d750
MATLAB
807
41
function [imgvec,maskvec] = iimg_clusters2indx(cl,volInfo) % Take a clusters structure and turn it into an indexed image of dims % volInfo.dim % % :Usage: % :: % % [imgvec,maskvec] = iimg_clusters2indx(cl,volInfo) % [imgvec,maskvec] = iimg_clusters2indx(cl,my_image_name) % % :Outputs: % % **imgvec:** % ...
cea9783574200ce53bd78aebc42734e3c562f852c0eae4a069939666d7751ae5
MATLAB
807
28
function [startStopIndices] = j_event_detect(Y, onThr, offThr) % [startStopIndices] = j_event_detect(Y, onThr, offThr) Y = zscore(Y); startIndices = jzeroCrossing(Y-onThr,1); if(isempty(startIndices)) startStopIndices = NaN(0,2); return; end stopIndices = jzeroCrossing(Y-offThr,...
85a0e8b1ead080d1dd592ed6056736190948dac28af4680e43651941d0479327
MATLAB
808
17
function currentSettings = h_getCurrentSettings3(handles) % this function gets the red, green and blue limits and z limits from h_imstack2/2a % as specified in handles. currentSettings.zLim(1) = str2num(get(handles.zStackStrLow, 'string')); currentSettings.zLim(2) = str2num(get(handles.zStackStrHigh, 'string'))...
d382f9cb047b080d1268628d325fc103da5d312e53b0805d56b4b164dd0f877c
MATLAB
808
34
function [loglik, alpha] = hmmFilter(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 % loglik = log p(y(1:T)) % alpha(i,t) = p(S(t)=i| y(1:t)) % This file is from pmtk3.googlecode.com ...
d8e73d31e80af7cb6265da34c239bbd644500e9ea51d6ba58b4ba4bd3a7014f5
MATLAB
808
46
% Important: all relevant parameters must be defined here. % voxel size [microns] dx_0 = 0.048100; % um dy_0 = 0.048100; % um dz = 0.125885; % um % downsampling the images scale = 0.5; dx = dx_0 / scale; dy = dy_0 / scale; % slices = 81 % channels = 3 ? % what is in third channel ? % more volume has cell image, le...
23e99e7c35e99048d2a22f4d83ef5f1b7a2133322eea72ecaab72319dbccee1a
MATLAB
809
36
function [gx] = g_Gaussian(Xt,P,ut,in) % Gaussian convolution observation function % function [gx] = g_Gaussian(Xt,P,ut,in) % This function evaluates a gaussian-like observation function. % IN: % - Xt: [useless] % - P: a 4X1 parameter vector % - ut: [useless] % - in: input structure. Contains the grid at which ...
48e73b292ba928fe78e9d55fced5a7bbbeb41f886d3831f62c2bcc85f5ad0660
MATLAB
810
28
function [lf] = leadfield_simbio(pos, vol) % leadfield_simbio leadfields for a set of dipoles % % [lf] = leadfield_simbio(pos, vol); % % with input arguments % pos a matrix of dipole positions % there can be 'deep electrodes' too! % vol contains a FE volume conductor (output of ft_prepare_vol_sen...
8d3e7f6aeb8c5ba4cddff0a5f64ec053237ec137679d21be24989052182910a7
MATLAB
811
24
function e = end(X,k,n) %END Last index of indexing expression for sparse tensor. % % The expression X(end,:,:) will call END(X,1,3) to determine % the value of the first index. % % See also SPTENSOR, SPTENSOR/SUBSREF, END. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tenso...
5105b034efd7684bc29e53807c200e167245b6f19b3b467e34db59eaf42726bd
MATLAB
812
25
function conv = Check_conv(fcost,k_error,u_error,iter,optims) % Check convergence conv = 0; formatSpec = 'Iteration:%d Cost:%e Error(u):%e Error(k):%e\n'; fprintf(formatSpec,iter,fcost(end),u_error(end),k_error(end)); if iter > 1 if k_error(iter) <= optims.k_conv conv =...
635fff413d1d3bace3e71902f80c143a902709a409ba5ea8e64ba771f9f01de1
MATLAB
812
28
function c = getEllipseFromNewParams(gparams, nsigma, varargin) %UNTITLED3 Summary of this function goes here % Detailed explanation goes here if nargin<3; detail=5e1; else, detail = varargin{1}; end mx = gparams(1); my = gparams(2); sx = gparams(3); sy = gparams(4); theta = gparams(5); aa = (cos(theta)...
75d859907e9a997c6ff111b25ee3ae00864e487a561c55726d119d08b37907d3
MATLAB
812
28
function [dprime, crit] = dprime(stim, resp) % if there was only one stimulus class shown, this whole thing doesn't make % sense if length(unique(stim(~isnan(stim)))) == 1, dprime = NaN; crit = NaN; return; end % use only 2 identities, however this is coded stim(stim~=1) = -1; resp(resp~=1) = -1; % compu...
8148095bbf18c37c6976d0eefbc01a8ef01da85f7093d2e976600f46b77d84d7
MATLAB
812
24
% Copyright Christopher Fricke, University Leipzig Medical Center, % Neurology 2024 srcf = 'data\prep\coreg_indiv\ct'; matlabbatch = {}; matlabbatch{1} = []; matlabbatch{1}.spm.tools.MRI.CTnorm.images = {}; d = dir(fullfile(srcf,'P*.nii')); for i = 1:length(d) matlabbatch{1}.spm.tools.MRI.CTnorm.image...
c05696949978d6b432fb267fe4a345422518f1397e0f7f4eaa93eaf080146239
MATLAB
812
37
% _ _ % ___ _ __ __ _| |__ ___ ___ _ __| |_ % / __| '__/ _` | '_ \/ __|/ _ \| '__| __| % | (__| | | (_| | |_) \__ \ (_) | | | |_ % \___|_| \__,_|_.__/|___/\___/|_| \__| % % % updates the upper bound of the spike detector slider function updateSpikePromSlider(self,src...
f456c9f905283ec17e87889d63d75ed6a67c3c3915c2adbf66732979e2de67bf
MATLAB
812
31
% Calculates partial derivate along k dimension of tomogram T % Author: Antonio Martínez Sánchez % T -> tomogram (3D image) % k -> 1: x-dimension, 2: y-dimension and otherwise: z-dimension function [D] = diff3d( T, k ) [Nx Ny Nz] = size( T ); Idp = zeros( Nx, Ny, Nz ); Idn = zeros( Nx, Ny, Nz ); if k == 1 Idp(1:N...
3bf267cfd03bfddadc269333f6dedc760df83594075c5118a12bee83942e8b19
MATLAB
813
39
%% Peaks Demo %PMTKneedsOptimToolbox fminunc %% %[X,Y,Z] = peaks; % 49x49 surface surface % This file is from pmtk3.googlecode.com requireOptimToolbox; [X,Y] = meshgrid(linspace(-2.5,2.5,40),linspace(-3,3,50)); Z = peaks(X,Y); figure; %surf(X,Y,Z); contour(X,Y,Z); colorbar xlabel('x'); ylabel('y'); %view(-19,48) ho...
4d91a223b88c264aafc3ad12f8658a62182ef450d858fddcbc1afe0c2982f026
MATLAB
813
31
function EWsig=Enrichment_Figs2(dataOut,IM,B) % Plot network pairs meeting significance if ~exist('B','var'),B=1;end Pth=0.05./B; PthMcN=0.05; [NNidx,Tidx,TNidx]=IM2idx(IM); Npairs=length(TNidx); Nnets=max(IM.key(:,2)); NetKey=[[1:Nnets]',[1:Nnets]']; cMap=[1,1,1;0,0,0]; %% Significant stats by network ...
5424661ba65b6858bd4c43446c0e2dc7625cefa40fbdeda2150122dc1aa6e193
MATLAB
813
32
function new_stack = stack_contrast_enhance(stack) max3 = @(x) max(max(max(x))); % Allocate new stack new_stack = stack.*0; high = []; % intensity increase low = []; % number of z-slices Nz = length(stack(1,1,:)); % Computing the optimal contrast enhancement for all slices for ...
7ba4c5e55c36c501fe95fbc7fd22735c00f79040188cb79237449f4bbc11d4d8
MATLAB
813
23
function C = mtimes(A,B) %MTIMES Implement scalar multiplication for a ttensor. % % 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/~tgkolda/TensorToolbox. % Copyright (2015) Sandia Corpora...
d61537fab4c4c8bae1711d7843f4a600d61b88d6ea8d2585aadbff6f64b05af5
MATLAB
813
27
%http://www.mathworks.com/access/helpdesk/help/toolbox/bioinfo/index.html?/access/helpdesk/help/toolbox/bioinfo/ug/a1060813239b1.html load yeastdata.mat %%%%%%%%%%%%% filtering emptySpots = strcmp('EMPTY',genes); yeastvalues(emptySpots,:) = []; genes(emptySpots) = []; nanIndices = any(isnan(yeastvalues),2); yeastval...
0266c61d5ace325ea97b50e63ba3e1de042afc2c1c76308b62e8b5fb07054b07
MATLAB
814
31
function Els = VBA_Elogsig (m, V) % // VBA toolbox ////////////////////////////////////////////////////////// % % Els = VBA_Elogsig (m, V) % semi-analytical approx to E[log(sig(x))] when x~N(m,V) % This function computes a semi-analytical approximation to the expected % log-sigmoid mapping of x, when x is a gaussian v...
1b5b4312006133a2be3785024877152464a53d824caa7ada334da90b4fa3c4aa
MATLAB
814
33
%COPYFIG Create a copy of a figure, without changing the figure % % Examples: % fh_new = copyfig(fh_old) % % This function will create a copy of a figure, but not change the figure, % as copyobj sometimes does, e.g. by changing legends. % % IN: % fh_old - The handle of the figure to be copied. Default: gcf. % % OU...
848a7ee1df5d3a6578e568361ec8714f5c7806b8075228d387ce5936fc65ad34
MATLAB
814
25
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','...
e164598ab26031c1d42e1d337af96f3888f2622d0e119497c6534d957f6dca60
MATLAB
814
33
%%bin novel aligned activity %Chad Heer %INPUTS %novel_activity = novel aligned activity %bin_size - size of each bin %ids = id of each roi %OUTPUTS %out = if each roi is above baseline or not function [out] = bin_novel_activity(novel_activity, bin_size, ids) %generate bins number_bins = length(novel_activity)/bin...
19166ecb608a6badd07058cccb13446761d5944b4c847b1eaaf075c583d35106
MATLAB
815
30
% Calculates the sum in non-overlapping blocks of I of size dims. % % Similar to localsum except gets sum in non-overlapping windows. % Equivalent to doing localsum, and then subsampling (except more % efficient). % % USAGE % I = localsum_block( I, dims ) % % INPUTS % I - matrix to compute sum over % dims -...
30cf6309009e307e0caf51f0ebcc493b98e7e60be8a899c806a6564114076e88
MATLAB
815
19
% 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,...
6cfe1c0c0f2978130505325f39c86895e19279b37a114a6e575c1df9e829d832
MATLAB
815
51
%% var5_test % % Create VAR coefficients for 5-node test network % % <matlab:open('var5_test.m') code> % %% Syntax % % A = var5_test % %% Arguments % % See also <mvgchelp.html#4 Common variable names and data structures>. % % _output_ % % A VAR coefficients matrix for 5-node test network % %% Descript...
709249f07eafaccf744201e890b62d99e07491c33a90bbee7b0715f5ba69cf0f
MATLAB
815
31
function [model] = mlpClassifFitSchmidt(X, y, nHidden, lambda, options) % Multi-layer perceptron for BINARY regression; fit using minFunc % nHidden can be a vector of integers if there are multiple laters % We currenly assume the same L2 regularizer on all the parameters % This file is from pmtk3.googlecode.com if n...
793823baca6468bb5285167e6a598c2a0b242e1534dbdcb623199b8438d28bf1
MATLAB
815
28
function [intersect_bool, d, intersection,t,u,v] = ut_MTRayIntersect(point, dir, P, t) vert1 = P(t(:, 1),:); vert2 = P(t(:, 2),:); vert3 = P(t(:, 3),:); pp = repmat(point,size(vert1,1),1); dd = repmat(dir, size(vert1,1),1); e1 = vert2-vert1; e2 = vert3-vert1; e3 = pp-vert1; P = cros...
8107673a3e67fa86d884e9be7022da5f506a3d58f52da26afb8211e217c2b304
MATLAB
815
19
% 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,...
989f5b877d0ba3ff4ebf1f79bef19726c77b5e33c00ee45b322510991690d474
MATLAB
815
26
function S = tt_matrix2cellstr(M) %TT_MATRIX2CELLSTR Convert a matrix to a cell array of strings. % %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. ...
eb05b7aebe2e31b3ccafd47232a49490be318609284c82f2d7327e6da3e250a7
MATLAB
815
26
function [reads1_common,reads2_common,strings_common] = calcCorrelationOfReads(reads1,strings1,reads2,strings2) %calcCorrelationOfReads Calculate the correlation between two vectors of %genes %Get the list of all genes present strings_common = union(strings1,strings2); %Map reads1 into the common list of genes now r...
eb9c2dc15ff3220174434fee316eb66f9a655cc786641de867d0fe4695d644e4
MATLAB
815
25
function this = save(this) % Save an meeg object into a file % FORMAT this = save(this) % % Converts an meeg object to struct and saves it. %__________________________________________________________________________ % Copyright (C) 2008-2019 Wellcome Trust Centre for Neuroimaging % Vladimir Litvak % $Id: save.m 7619 2...
7d4ec6b64dad172a78b74bb86d7957546286284d5db6df741ff9ba3fe671a682
MATLAB
816
26
function T = calc_ttest_all_pairs(data_cell,varargin) % performs T-test between all pairs of cells in data_cell N = numel(data_cell); T = repmat(ttest.ttest2Struct(),N,N); for i = 1:N for j = (i+1):N T(i,j) = ttest.ttest2Struct(data_cell{i},data_cell{j},varargin{:}); end end ...
b4e6fe63d970b036a77e99c124eccb09f22fb0965b8e56da848a98e79fba3467
MATLAB
816
19
function TSremovetrials(S,s,TT,trls,sup) % removes trials from the specified trials from the specified trial type % for the specified session of the specified subject. % % Syntax: TSremovetrials(Subject idx #,Session idx #,Trial type,trial #s,sup) % sup is optional; if true, it suppresses the query if nargin==4 su...
d6345dfbf11ebff13b614702f33f532140c3cd63086929b460c949bb5e32c41a
MATLAB
816
31
function leadall=calc_leadcorr_major(x,ori,para_sensors,shell); % calculates the corrections to the lead field coming from % a set of centers, for given type (type=1: singular at infinity, % type=3: singular at origin, type=2; both [ndum,nsens]=size(para_sensors); leadall=[]; for k=1:nsens para_exp=para_sensors{...
de7799a428f6d486725b2e2a4b11a1f62ffe61e08c40c1d4f688a911e282b298
MATLAB
816
15
function result = summarizePerViewFiles(fileNameFromViewIndex, fileContentsFromViewIndex) % Put all the per-view files (typically logs or error files) together into a % single cellstring of lines. (With no trailing newlines.) Both % fileNameFromViewIndex and fileContentsFromViewIndex should be a cell array % of strin...
e4575450247db34f332a3ec6e22b8901974fbd17e2de629a8969da34d3b3ee67
MATLAB
816
26
function ufmf_write_struct(fid, s) if ~(isstruct(s) && isscalar(s)) , error('Can''t write a non-scalar struct') ; end fwrite(fid, 'd', 'char') ; field_names = fieldnames(s) ; field_count = length(field_names) ; fwrite(fid, uint16(field_count), 'uint8') ; % seems small, but this is what ufmf_read_head...
fbfadfbae2538dec102f1b7798d036f3c00c951469af98e0b85eea8ac92d113b
MATLAB
816
34
% _ _ % ___ _ __ __ _| |__ ___ ___ _ __| |_ % / __| '__/ _` | '_ \/ __|/ _ \| '__| __| % | (__| | | (_| | |_) \__ \ (_) | | | |_ % \___|_| \__,_|_.__/|___/\___/|_| \__| % % small helper method to fix some YTicks function updateYTicks(self,channel) d = dbstack; if se...
3dcaacba2bb8d312e3db142bbf82c1c331ba12dda8a4b1b88d017c8a5abbcf71
MATLAB
817
33
function varargout = deconstruct(S) % Deconstruct a structure from the output arguments only % See also, structure(). %% Example % mu = zeros(1, 10); % Sigma = randpd(10); % pi = normalize(ones(1, 10)); % model = structure(mu, Sigma, pi); % % [mu, Sigma, pi] = deconstruct(model); % cannot be called from the command lin...
82ccc3dcc144fe7f14cc405817d08b72010752b0f0c1f1dd6e0a4760c5199927
MATLAB
817
33
function A = affine(X,n,om,T,fc,cc,alpha_c) if nargin < 7, alpha_c = 0; if nargin < 6, cc = [0;0]; if nargin < 5, fc = [1;1]; if nargin < 4, T = zeros(3,1); if nargin < 3, om = zeros(3,1); if nargin < 2, n = [0;...
90be6e27e94c660deac09eba4565cebac0ceb2ad7b77e0ea1235681a021b607f
MATLAB
817
30
function h = plotROC(falseAlarmRate, detectionRate, col, EER, tprAtThresh, fprAtThresh) % Plot (convex hull of a) receiver operating curve % This file is from pmtk3.googlecode.com if nargin < 3, col = 'k'; end k = convhull([colvec(falseAlarmRate); 1], [colvec(detectionRate); 0]); %k = 1:numel(falseAlarmRate); k = so...
f57abbbba762d504462b4d564d730eda5bcd13a5bcc2e48f49fcb2ee9be01160
MATLAB
817
14
function dxtick = heuristic_dxtick_from_xspan(raw_xspan) % Want dxtick to be close to xspan/10 and to be a positive real, and to be a % power of ten, or be two times a power of ten, or be five times a power of ten. % This guarantees the number of ticks per span will in the interval (6,18). assert(isnumeric(raw_...
07338a23ee26bce1a21714c7809d103deaeb4b7652bf8c759d65652c7fe179a4
MATLAB
818
28
function nrm = norm(X) %NORM Norm of a ttensor. % % 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/~tgkolda/TensorToolbox. % Copyright (2015) Sandia Corporation. Under the terms of Contrac...
10feef6286d15ad365e362a59ddda451c7c754fe2179b8854c155d73f590afbf
MATLAB
818
26
function [] = make_sift_binaries(img, map, image_size, sift_params, N) assert(all(size(map) == size(img))); f = fopen('test_map.bin', 'w'); fwrite(f, image_size(1), 'uint32'); fwrite(f, image_size(2), 'uint32'); fwrite(f, image_size(3), 'uint32'); fwrite(f, int8(map), 'int8'); fclose(f); ...
88006a4bc7c3a263a1ff00643908a27de16a88aa96ff9bcaa0be6f8e940a5845
MATLAB
818
28
function statsToolboxDependencies(rootDir) % Generate an html table showing all of the stats toolbox functions used % by files in rootDir, (and subdirectories), along with the files that use % them. % This file is from pmtk3.googlecode.com cd(rootDir); R = deptoolbox('stats'); S = unique(vertcat(R.dependsOn{:})); F ...
ec728cd0d0bb92ea3c104c3fb69e9ec56b41a005417e02f03bf83fc8495235a6
MATLAB
818
38
function writeText(text, fname, append) % Write text to a file. % % WARNING: Any existing text inside fname will be lost unless in append % mode. % % INPUTS: % % text - an N-by-1 cell array of strings written out as N separate lines. % fname - the name of the output file. % append - (default=false) if true, the text i...
b5e54f528dcaa242e405107b37a51bfca3c09ceba07397a64112abcbe5c444b3
MATLAB
819
32
classdef TrainingOverlayReceiver < handle properties axs tstrBases tblMFT end methods function obj = TrainingOverlayReceiver(hAx,tbases,tMFT) assert(numel(hAx)==numel(tbases)); obj.axs = hAx; % can be nonscalar obj.tstrBases = tbases; obj.tblMFT = tMFT; end ...
ccdcab1706c22eafe6a0315a62c2a10eba2f7fd9db55ce3062b3c44d4ceb1f83
MATLAB
819
37
%% MLP Regression Demo % Based on Mark Schmidt's Demo from % http://people.cs.ubc.ca/~schmidtm/Software/minFunc/minFunc.html#8 %% % This file is from pmtk3.googlecode.com setSeed(0); nVars = 1; nInstances = 400; options.Display = 'iter'; options.MaxIter = 50; [X,y] = makeData('regressionNonlinear',nInstances,nVars); ...
f507108a82c2157986cf37ea973855517840297af73ab430cdc1ad41c03cedb6
MATLAB
819
22
function Z = minus(X,Y) %MINUS Binary subtraction (-) for tensors. % % MINUS(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 % subtracted from a tensor of any size. % % See also TENSOR. % %MATLAB Tensor Toolbox. %Copyrigh...
0fbb619e8c900db1274905b1f78fd58c49916055a3b3c5bda475f9824e8c9ba8
MATLAB
820
37
function [xi_summed, xi] = hmmComputeTwoSlice(alpha, beta, transmat, softev) % Calculate p(Q(t)=i, Q(t+1)=j | y(1:T)) , t=2:T % INPUT: % alpha(i,t) computed using forwards % beta(i,t) computed using backwards % transmat(i,j) = Pr(Q(t) = j | Q(t-1)=i) % softev(i,t) = Pr(Y(t)| Q(t)=i) % % OUTPUT: % xi(i,j,t) = p(Q(t)=i,...
10ff7f0454e1dfbe6f33490c58e88df768a608da410660c52f0a13532d2559a4
MATLAB
820
51
% % filtro segun script EEGLAB % % function LAN = filt_eeglab(LAN,low,hi) if isstruct(LAN) LAN = filt_eeglab_struct(LAN,low,hi); elseif iscell(LAN) for lan = 1:length(LAN) LAN{lan} =filt_eeglab_struct(LAN{lan},low,hi); end end end function LAN = filt_eeglab_struct(LAN,low,hi) if iscell(LAN.da...
e0b772ee93cc7cd912ba1d9f6b92c208c95aeb14fa6ff767bb9fc358da240d6b
MATLAB
821
33
function [flag] = VBA_isBinary (X) % // VBA toolbox ////////////////////////////////////////////////////////// % % [flag] = VBA_isBinary (X) % check if X only contains 0 or 1 values % % IN: % - X: matrix, cell array of matrices, or structure to be checked % OUT: % - flag: - true if all elements of X are binary (0 o...
f0f67ab4d7b5f6d3b3841c1256016bf72eb988ef3e77b07a2b1d2af7ee29d706
MATLAB
821
24
function [Sig,Lam] = covcond(c,a) % Generate a covariance matrix and its inverse with a given cond number % C and first direction A. %COVCOND covariance matrix with given condition number % [Sig,Lam] = covcond(C,A) generates covariance matrix and its % inverse with given cond number C and first direction A. % This fil...
76da00f17132b16edc3014e56e5ef04ec18696d004a214cb16c36bfa15f73d4d
MATLAB
822
32
function [R,M,k] = circumcenter(A,B,C) % Center and radius of the circumscribed circle for the triangle ABC % A,B,C 3D coordinate vectors for the triangle corners % R Radius % M 3D coordinate vector for the center % k Vector of length 1/R in the direction from A towards M % (Curvature ...
9581b28df831831e96b1544088259ee5b1a44ae7a6b0df92176537afb70125e8
MATLAB
822
46
%normalized gaussian kernel a=single([.0003 .1065 .7866 .1065 .0003]); n=length(a); %make a 3D kernel H3 = fspecial3('gaussian'); a2 = H3(3, :, 3); H4 = fspecial('gaussian',5); [s,v,d] = svd(H4); a3 = abs(s(:,1)); b=a; b2 = a2; b3 = a3; for d=2:3 b=kron(b,a'); b2=kron(b2,a2'); b3=kron(b3,a3'); end H=sin...
a002bbbb98a4cea487a7dbb96ae6d186d1fc4e1768cd1249ce858f866cea2d38
MATLAB
822
36
function [Rhat, m, s] = epsr(samples) % EPSR "estimated potential scale reduction" statistic due to Gelman and Rubin. % % Inputs % samples(i,j) for sample i, chain j % % Outputs % Rhat = measure of scale reduction - value below 1.1 means converged: % m = mean(samples) % s = std(samples) % This file is from pmtk3.googl...
acf3c88392354c76e422b7829a7a245401fc7683a6e272b68a3dcc8dba65fd9a
MATLAB
822
39
function logp = invWishartLogprob(arg1, arg2, arg3) % logp(i) = log p(S(:, :, i) | model) % If model.Sigma is scalar, than logp(i) = log p(S(i) | model) % % model has fields Sigma and dof % model.dof must be > d-1 % % logp = invWishartLogprob(model, S); OR % logp = invWishartLogprob(Sigma, dof, S); %% % This file is f...
8526e3c5550190af1794472b2bf772c7889f0eb5a75a7ff28440eb574bb1410b
MATLAB
823
30
function X = gibbsSample(fullCondSampler, xinit, Nsamples, Nburnin, thin) %% Generic gibbs sampler % fullCondSampler{i}(xh) returns a single sample for ith hidden variable, % from the full conditional, (i.e. the distribution conditioned on all % variables except the ith hidden), and with xh used as the values for the %...
d657b54fc47e097d5a9a7ca6c8bab3191eb87e88696e7c31739735158c2ff0dd
MATLAB
823
22
function e = end(X,k,n) %END Last index of indexing expression for ttensor. % % The expression X(end,:,:) will call END(X,1,3) to determine % the value of the first index. % % See also TTENSOR, TTENSOR/SUBSREF, END. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbo...
41403da411bcd614d100c088ef09f9200915fcc65d46a62b59e0dc7413c8dbb0
MATLAB
824
21
function args = set_arg_in_cellarray(cell_with_args,varargin) n = numel(varargin); assert(mod(n,2)==0 ,'set_arg_in_cellarray :: varargin must have pairs of arguments and values'); assert(iscell(cell_with_args),'set_arg_in_cellarray :: cell_with_args must be a cell with pairs of arguments and value...
9405bf0401b3bce5a469bd9cb2f97cbe72dd04d81695a6e7fc3af5168ddf62aa
MATLAB
824
27
function normals = compute_normals( mesh ) % Modified by William Warriner 22 Aug 2019 % from COMPUTE_mesh_normals by Adam H. Aitkenhead % Inputs: % - @mesh is either an FV-struct, or a real, finite, 3D double array with % dimensions (:,3,3) representing face-vertex data with only triangular % faces. The first dimens...
c1428339858fb14d6ff2c09bfa56e39ed6936f9e514c2845d884fed82412bf06
MATLAB
824
36
function df = numericalGradient(f, x, args) % We assume f is a function of the form v=f(X,args) % where v(i)=f(X(:,i), args) computed in parallel % args is a cell array; use {} if no args required % This file is from pmtk3.googlecode.com n = length(x); df = zeros(n,1); method = 'complex'; %method = 'centralDiffere...
0d50ad9b7ad43aaad133a5da801d3792ddcda91fcc80edb6ea386a4ace2bbb02
MATLAB
827
43
function [gx,dgdx,dgdp] = g_demo_susceptibility(Xt,P,ut,in) %- initializations idX1 = 1:in.n5(end); nreg=length(in.n5); nresp=length(in.r); gxr=zeros(nresp,1); dgdxr=zeros(length(Xt),nresp); dgdpr=zeros(length(P),nresp); %== compute gradients [gxn,dgdxn,dgdpn] = g_HRF3(Xt(idX1),P,ut,in) ; if nresp>0 [gxr,dgdxr(in....
42e0523208017eb019177c06c65d3831fd080f8887c6ffed46c53f8b3b96588d
MATLAB
827
19
function max_pool_size = concurrency_size_in_downsample_all(cond) loadParameters; if ~isfield(params,'DOWN_SAMPLING_MAX_POOL_SIZE') main_mem_usage = params.MATLAB_PROC_CONTEXT; par_worker_mem_usage = 2 * cond.imgsize_dbl + cond.downsample_imgsize_dbl + params.MATLAB_PROC_CONTEXT; max_p...
54bea7b17473a0a0c719c788fe80556e9f524ed042038a50c704959bec1a3094
MATLAB
827
22
function [Fc, Fs, Jc, Js] = calcSubunitSurrActivationAmplitude(params, spf) %UNTITLED6 Summary of this function goes here % Detailed explanation goes here %========================================================================== spff = spf(:); %standardize input sigma = params.subsigma; kscale = params.subsurrsc; ...
55b011e47086698ed9258447d65657fa5bdf7e652ada14b0d1808a110ac39861
MATLAB
827
51
% dprime_test.m nsignaltrials = 18; nnoisetrials = 12; faweight = .3; h = 0:nsignaltrials; fa = 0:nnoisetrials; hh = repmat(h',1,length(fa)); ff = repmat(fa,length(h),1); ns = ones(length(h),1)*nsignaltrials; nn = ones(length(h),1)*nnoisetrials; for i = 1:length(fa) [dd(:,i), cc(:,i)] = rd_dprimeWeighted(hh(:,...
a99eed80db801ab3296716f78c99e8a7065f46dab64983a653114a6c2772a8b6
MATLAB
827
43
function varargout = permission(varargin) % Format % For getting the value % dat = permission(obj) % % For setting the value % obj = permission(obj,dat) % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id$ if nargin==2, va...
b17258249b75654d6db8791389b9b0245d2deb862df5b50be8aceb5f766b205b
MATLAB
827
50
function s2d=sensor3d2sensor2d(sensors,lr,ud); [ns,ndum]=size(sensors); [center,radius]=sphfit(sensors); s=sensors-repmat(center,ns,1); cms=mean(sensors); zz=cms-center; zz=zz/norm(zz); snorms=sqrt(sum((s').^2)'); s=s./repmat(snorms,1,3); thetas=acos( s*zz'); ex=[1;0;0];ey=[0;1;...
0365770646054b6f72240b66a11fa01461c7382db988e806fcc5684a9120afca
MATLAB
828
35
function [X, mu, sigma2] = polyBasis(x, d, mu, sigma2) %% Polynomial basis expansion of degree d % function [X] = polyBasis(x, d) % x(i) -> [1 x(i) x(i)^2 ... x(i)^d] stored in rows of X % We put highest powers first, to be consistent with Matlab's convention (see polyfit) % % function [X, mu, sigma2] = polyBasis(x, d)...
079feb6ae61ea01ee65b16a283e435977f3152b3cf37e3555f3bc17c8bef660c
MATLAB
828
38
function [C,nbits] = clfEcocCode( k ) % Generates optimal ECOC codes when 3<=nclasses<=7. % % USAGE % [C,nbits] = clfEcocCode( k ) % % INPUTS % k - number of classes % % OUTPUTS % C - code % nbits - number of bits % % EXAMPLE % % See also CLFECOC % % Piotr's Image&Video Toolbox Version 2.0 % Copyrig...
64917088249468c6d755df77ec02e2772fe72709ed37c7bf1b0ed626d3a497cd
MATLAB
828
33
% Continuous movement correction based on cross-correlation barycenter % in a selected window function ImgCor=CorMovWin2(Img,Win) %Display mean image h=figure; imagesc(mean(Img(:,:,Win),3)) %Coming soon: automatic box Box=ginput(2); close(h) %Define data in box WinX=floor(min(Box(:,2))):floor(max(Box(:,2))); WinY=flo...
b98b8d7ff2889a0684a40c80fcb4e520fe10556814f4897c07b81bdb5bc56a89
MATLAB
828
31
dataPath = getenv('GADIR'); matName = 'robustness_amplitude_singleTrial.mat'; stimType1 = {'median', 'tibial'}; srmr_nr = str2num(dataPath(19)); if srmr_nr == 1 stimType2 = {'mixed'}; elseif srmr_nr == 2 stimType2 = {'d1', 'd2', 'd12'}; end aType = {'CCA', 'target'}; removeNaNs = ...
c0ab5ec26ab44a8156fd18d115dd1970ce43fd07c409439d65d4d2dcf91e0b60
MATLAB
828
39
function [wn, Sn] = normalEqnsBayes(X, y, Lam0, w0, sigma) % Numerically stable solution to posterior mean and covariance % under Gaussian prior N(w | w0, Lam0^{-1}), where sigma is noise std % wn is the ridge (MAP) estimate, Sn is its covariance % This file is from pmtk3.googlecode.com if all(Lam0==0) [Q,R] = q...
f8413881da7734c3c614e9d72df697d07f72cf37648f325d270cf9a2194a755d
MATLAB
828
14
function test_roian_aws_training() linux_project_file_path = '/groups/branson/bransonlab/apt/unittest/four-points-testing-2025-04-11-with-rois-added-and-fewer-smaller-avi-movies.lbl' ; [project_file_path, replace_path] = localize_test_project_path(linux_project_file_path) ; tester = LabelerProjectTester(projec...
083609b776a6cd4386044a9642940cc92e93d1db44700f8244ac5fe623bc1f7b
MATLAB
829
24
function [mri] = align_fsaverage2mni(mri) % ALIGN_FSAVERAGE2MNI performs an affine alignment of the anatomical volume from % FSAVERAGE towards MNI coordinates. Only the homogeneous transformation matrix is % modified and the coordsys-field is updated. % % Use as % mri = align_fsaverage2mni(mri) % where the first inp...