sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
7c6aee43928ce12f9ffb0f6ec56bdb8c7dc9bdc498abe437c5234f6036f75b21
MATLAB
906
44
% this helper function checks every metadata % .txt file and makes sure that file % identifiers are monotonically increasing % non-monotonic fileids may suggest mistakes % in metadata function checkMetadata() spikesfolder = getpref('crabsort','store_spikes_here'); allexps = dir(spikesfolder); bad_exps = false(len...
7defb82959d93e986686e92b0142f2e5fe3196bbc5545fb9c3af8ce711b3bc0f
MATLAB
906
33
function [ data_shifted] = imtranslate3D(data,shifts ) %SHIFT3D Works like imtranslate but for 3 dimensions %Use the circular shift feature in matlab, which wraps elements around from %the end to positition 1, etc. Then we have to go back to zero out data_shifted = circshift(data,shifts); if shifts(1)<0 %note th...
865b2ecdd270948a8932a48b22c767df4b0ee64a1a1c8e74ba5f2acc1a8101e0
MATLAB
906
34
function sub = ind2subv(siz,index) % Return a subscript vector from a linear index % IND2SUBV(SIZ,IND) returns a vector of the equivalent subscript values % corresponding to a single index into an array of size SIZ. % If IND is a vector, then the result is a matrix, with subscript vectors % as rows. % % See ind2subvBs...
87de93bdd2a54cb04c279a775df842f5195fe06c5052c312a76362b87542f3c0
MATLAB
906
27
function [L, G] = fooof_curves(Dt) %% compute periodic and aperiodic part from fooof parameters L = zeros(Dt.nchannels,Dt.nfrequencies); G = zeros(Dt.nchannels,Dt.nfrequencies); for i=1:Dt.nchannels c = Dt.info.peaks.gaussian_params(Dt.info.peaks.ic==i,1); a = Dt.info.peaks.gaussian_pa...
ecbbe0251e4c27167fcdc7c72df36e260e93d78fccb2c3cdfd0d8a6e2556a033
MATLAB
906
53
% opens a dataset, and a text file for the metadata % usage % crabsort.open('exp_#') % function datafolder = open(exp_name, silent) if nargin == 1 silent = false; end try data_loc = getpref('crabsort','data_loc'); catch error('data_loc not set! ') end spikesfolder = getpref('crabsort','store_spikes_here'); ...
fa939e8c3bd2633d1548fd9aae3cb19018b5ba1436b24cce7080eee10de024ca
MATLAB
906
42
function S = read_smatrix(filename) fid = fopen(filename,'r'); h1 = waitbar(0,'loading sparse matrix...'); n = fread(fid,1,'int'); nnz = fread(fid,1,'int'); x = zeros(nnz,1); y = zeros(nnz,1); z = zeros(nnz,1); ct = 1; for i = 1:n waitbar(i/n,h1); nz(i) = fread(fid,1,'int'); vals = fread...
4e2c5e6f8c645190af690f334f4c84de41d1805fbc10ff20565e3f4f9e61fe60
MATLAB
907
29
function [fx,J,dfdp] = f_embed0(Xt,Theta,ut,in) % evolution function for dynamical system's delay embedding % function [fx,J,dfdp] = f_embed(Xt,Theta,ut,in) % First form delayed state vector and input iX = (1:in.dim.n) + (in.options.delays(:)'.*in.dim.n); dX = Xt(iX,:); % Evaluate evolution function at the delayed st...
5c331a59d04ee9f66c286a66a532f00cf7caeb226c4d6e9a983ca82f59e1fa91
MATLAB
907
29
function idx = tt_sub2ind(siz,subs) %TT_SUB2IND Converts multidimensional subscripts to linear indices. % % INDS = TT_SUB2IND(SIZ,SUBS) returns the linear indices % equivalent to the subscripts in the array SUBS for a tensor of % size SIZ. % % See also TT_IND2SUB, SUB2IND. % %MATLAB Tensor Toolbox. %Copyright...
64207534a7a55deac4cde2741b75c49374dbd43b0da6067937092533d2a447e1
MATLAB
907
29
function [pX] = mixDiscretePredictMissing(model, X) % Compute pX(i,j,v) = p(Xj=v|case i), where X(i,:) may be partially % observed (with NaNs) % This is like mixModelReconstruct expect we compute the posterior % predictive distribution, intsead of using MAP estimation % This file is from pmtk3.googlecode.com [pZ] = ...
7c232e696dd7bab0c79f93672bdb03406c367374f27387a3e91927e4ddb2e791
MATLAB
907
40
function [matlabclass,bytes_per_element] = dtypechar2matlabclass(dtypechar) switch dtypechar, case {'c','s','p'}, matlabclass = 'char'; bytes_per_element = 1; case 'b', matlabclass = 'int8'; bytes_per_element = 1; case 'B', matlabclass = 'uint8'; bytes_per_element = 1; case 'h', mat...
a274ffae627c35527715c9fec96527474fb1d3013d22f6279173e9e053795960
MATLAB
907
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 = CountResponses2(ImageArray_DeltaGFPnMax_Reg2, AllBoutonsRegion) LastImageNumber = size(ImageArray_DeltaGFPnMax_Reg2,3); ...
f4a6491588295dfdadf7fb9624e9eae7eeac1d00eda1c544cfba1189c5045386
MATLAB
907
30
function imMasked = maskWithAnnulus(im, outerCircleSize, innerCircleSize, blurRadius, bg) % imMasked = maskWithAnnulus(im, outerCircleSize, innerCircleSize, blurRadius, bg) % % Masks an image im with an annulus whose outer dimension is % outerCircleSize (in pixels) and inner dimension is innerCircleSize (in % pixels...
1caa2e67a6a2b1a87ef0495311fef9268ed2395201af069626fcbcf402b17f59
MATLAB
908
46
function S = multinomSample(arg1, arg2, arg3) %% S(1:nsamples, :) ~ Mu(N, p) % S = multinomSample(model, nSample); OR S = multinomSample(N, p, nSamples); % model.p must sum to one % sum(S(i, :)) = N for all i. % S is of size, nsamples-by-length(p), and S(i, j) is in {0, ... , N} %% Example % % setSeed(0); % model.N = 1...
6991fc99510526dbf3f260d6eddbabc9b625e62f41ec893b0062fad7c32abeef
MATLAB
908
19
function pp = HumanOdorRep_ranksum(resp_trials, bsl_trial, response_interval, bsl_interval) % simple ranksum test for responses %----------------------------------------------------------------------------------------- % Kehl et al. 2024 (DOI:XX) % Single-Neuron Representations of Odors in the Human Brain % Author: Ma...
6a5e174f5957949c22b8b3d6211c810a18c397b9c65b4f5baaddf549386955fd
MATLAB
908
34
function img_3d = volume_cleaning_plots(name, img_3d, z_proj_with_dust, take_maximal_volume) parameters; img_3d = volume_filtering( img_3d, take_maximal_volume); %---------------------- Cell colored z-projection ----------------------- z_proj = sum(img_3d, 3); z_proj = z_proj ./ max(max(z_p...
ac6bc70952f053f35e8bddda6d023d4c285a0b1e3c8afda8b4a4d06ce31e4237
MATLAB
908
37
function dgm = treeToDgm(tree) % Make a directed version of an undirected tree % so we can compute logprob efficiently % We assume all nodes have the same number of states fprintf('treeToDgm does not work\n'); % this is just because dgmCreate insists that nodes % be topologically ordered, which is not really necessar...
946ab61cfe5296eaa494adafc42581a3e426266fafca9ce04a4a7c3f5fe9dbba
MATLAB
909
24
function [P,w,idxfront,idxside] = Sample3DPoints(xfront,xside,Sfront,Sside,dlt_front,dlt_side,wfront,wside,K) nfront = size(xfront,2); nside = size(xside,2); w = nan(nfront,nside); pfront = nan(nfront,nside); pside = nan(nfront,nside); P = nan(3,nfront,nside); for ifront = 1:nfront, for iside = 1:nside, [P(:,ifr...
b35ab6697e30f7da0ace4a7a5bef0a61ebb075bb44fc5d674c3e6a3aeab56ed2
MATLAB
909
37
function fWriteQdec(fname,Qdec) % fWriteQdec(fname,Qdec) % % Writes cell string array Qdec to a Freesurfer's Qdec table data file. % % Input % fname: The name of a Qdec table data file. % Qdec: Two dimensional cell string array with the data. % % $Revision: 1.1.1.1 $ $Date: 2012/02/02 11:25:52 $ % Original Author: Jo...
e80678b1a1485bee54f1e512b011047f1e073a752bb56d43782e582dc320bb23
MATLAB
909
30
function yhat = svmlightPredict(model, Xtest) % PMTK interface to svmlight % which must be on the system path. % % model - a struct generated by svmlightFit() % yhat - output is in {-1, 1}, (unless regression) % This file is from pmtk3.googlecode.com % You can use the addtosystempath function to add the directory...
136387b3abaf371a56acc15eccf15005d422333eba2caa5d6684b6dad7e22630
MATLAB
910
43
%% Multiscale vesicles detector by template matching % Author: Antonio Martinez-Sanchez % I: input tomogram % r: radius range [min,max] % t: iteration step in r % s: membrane thickness % aw: wedge semiangle in degress % rw: angle rotation for the wedge % V: coeficients scale integration % R: estimated radii for the coe...
7219d3538f309453b27f2600478425b2f25b3abc25008169c5176865ec4c8b3b
MATLAB
910
28
function [ outputImage_interp ] = TPS3DApplyCUDA(in1D,out1D,imgToWarp,outdim,data_channel) %TPS3DAPPLY applies the warp to a vectorized version of the image data, %then returns an interpolated version of the data %now that we have the pixel->pixel mapping from the TPS, apply it to a %data c...
76f9053e427fb9212418bfaf4b447f0e6a157bd7add1b95d2d9b0120c40b0ca6
MATLAB
910
41
function res = bmmFit(con,lb,ub) rng default nIter = 5; %number of initial search conditions %param vector = [mu1 mu2 sd mix] if ~exist('lb','var') || isempty(lb) lb = [0 0 0 0]'; end if ~exist('ub','var') || isempty(ub) ub = [1 1 400 1]'; end ubSet = [1 1 100 1]'; maxfeval = 10000; options = optimset('T...
10965f8fc339e301e333dfe9d8c1863d389497ffce751880793d4af8103fbbae
MATLAB
911
33
%% Minfunc Logreg Demo %PMTKauthor Mark Schmidt %PMTKurl http://people.cs.ubc.ca/~schmidtm/Software/minFunc/minFunc.html %% % This file is from pmtk3.googlecode.com options.Display = 'none'; setSeed(1); nClasses = 5; nInstances = 1000; %nInstances = 100; nVars = 2; [X,y] = makeData('multinomial',nInstances,nVars,nC...
29fa20d4b769a2b641f3cacf86acdf1930012d43570118ad3922228968a423f8
MATLAB
911
33
%% Simple test of a discrete mixture model % This file is from pmtk3.googlecode.com setSeed(0); nmix = 6; truth.nmix = nmix; truth.d = 80; truth.nstates = 8; % number of observed states truth.mixweight = normalize(rand(1, truth.nmix)); truth.T = normalize(rand(truth.nmix, truth.nstates, truth.d), 2); nsamples = 100...
460b2944044b5a3197878a6e247b8fca10326fb53d5da42d62e6ad48bd193dd9
MATLAB
911
29
function [u,dudx,dudp] = u_Fourier(x,P,t,in) % input function for free-form (Fourier decomposition) deterministic DCM % function [u,dudx,dudp] = u_Fourier(x,P,t,in) % IN: % - x: [useless] % - P: nW*nuX1 vector of Fourier projection parameters, where nW is the % number of Fourier basis functions and nu is the dime...
65101a3702b758abd5a5349fed84e2b73a9683f40f3fae833041f40c5a6e2e63
MATLAB
911
34
function [ c ] = getEllipse( gauss, nsigma,detail) %GETELLIPSE Summary of this function goes here % Detailed explanation goes here if nargin<3; detail=5e1;end c = NaN(2,detail); if sum(isnan(gauss.sigma))>0; return; end; for j=1:size(c,2) alpha = 2*pi*(j-1)/(size(c,2)-1); c(:,j) = nsigma*sqrtm(gauss.sigma)*...
aca7264787b3631568945e35cc1e4a5600388ed9fdc70ecf8d726b7f0a9d180e
MATLAB
911
34
function [yhat, post] = generativeClassifierPredict(logprobFn, model, Xtest) % Return the predicted class labels %% Inputs % % logprobFn - a function handle: logp = logprobFn(classConditionals{c}, Xtest) % model - a struct returned by generativeClassifierFit() % Xtest - Xtest(i, :) is the ith case % %% Outp...
beca1ce3d0f6ffd97b99f813328c70830e3cfd76330a95db073edd8a29febdee
MATLAB
911
32
% http://en.wikipedia.org/wiki/Multivariate_adaptive_regression_splines figure; hold on; xs = 0:0.1:20; plot(xs, max(0,xs-5), '-', 'linewidth', 3); plot(xs, max(0,5-xs), 'r:', 'linewidth', 3); axis_pct set(gca, 'fontsize', 16) printPmtkFigure('marsHinge') figure; xs = 0:0.1:20; %f = @(x) 25+6.1*max(0,x-13) -3.1*max(0...
d67295b33ebfbafcf3841e141e768fb284f82575c6f81a3410cddedf4c9261cd
MATLAB
911
41
function [precMat, covMat] = ggmLassoR(C, rho, varargin) % Use R code to find L1-penalized precision matrix % This file is from pmtk3.googlecode.com %PMTKauthor Rob Tibshirani %PMTKurl http://www-stat.stanford.edu/~tibs/glasso/ %PMTKmodified Kevin Murphy useMBapprox = process_options(varargin, 'useMB', 0); %C ...
22e97dd4576799578a1782ebcf584bee57f01df28682976c3cbef2c89f7167ef
MATLAB
912
48
function [h] = first(fname, Nl) %FIRST Return the first Nl lines of text in file fname % % [h] = first(fname, [Nl]) % % If Nl is not given, or if it is empty, only the first 10 lines of % text are returned. If Nl is set to 'all', then all lines are % returned. % Emilio Salinas, May 1998, rev Septembery 2013 % how ...
ddd50e6b6b3125faaef43750c259fb45c1ea52209df30582ba52e2b68966f268
MATLAB
912
39
function tlt = save_tracklet(trx,matfile) % tlt = save_tracklet(trx,matfile) % matfile: pass [] to just return tracklet data without saving tfnosave = isequal(matfile,[]); tlt = struct; tlt.startframes = cat(1,trx.firstframe); tlt.endframes = cat(1,trx.endframe); ntargets = numel(trx); tlt.pTrk = cell(ntargets,1); if...
f0c02a77022ac93221a3f9b1b1a612625ea4ec15835e68233e0daacae392063b
MATLAB
912
37
function s = structrmfield(s,flds) % s = structrmfield(s,flds) % rmfield with removal of nested fields allowed % % Elements of flds which are not present in s are silently ignored. % % Example: % flds = {'fld1','fld2.subfld'}; % s = structrmfield(s,flds); assert(isstruct(s) && isscalar(s)); if ischar(flds) flds = ce...
48faa2f718d030519dd20fe78dc3b4d1800832658a79271381670645702c6fdb
MATLAB
913
58
%%normalized gaussian kernel %a=[.0003 .1065 .7866 .1065 .0003]; %n=length(a); %%make a 4D kernel %b=a; %for d=2:4 %b=kron(b,a'); %end %H=reshape(b,n*ones(1,4)); H = fspecial3('gaussian'); %H = [1 0 -1; 2 0 -2; 1 0 -1]; %a = H(1, :); n=length(a); %make a test matrix %A = randn(2048,2048,141); A = randn(10,10,...
94eed313bb74f9363238bdf8244dc5c09f846ad69639d9e3f5e9c81a2b63e6bd
MATLAB
913
28
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...
d753f442537db6308d159b03f84842fc2bed8d21afdc7f64590bc275362b89a4
MATLAB
913
23
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% step5_load_dipole_data.m %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if ~skip_user_prompts [dipole_name, dipole_path] = uigetfile(fullfile(patient_path,'dip...
ee9370f2d24e40b58340bfb58aef5873a1a3c3dd250c16cff4d22985b7844b8b
MATLAB
913
31
function plot_cor_xyz(vals,keys,ranges,coords) %% plot peak attribute distributions figure('units','normalized','outerposition',[0 0 1 1]); s=1; cnames = [string('x') string('y') string('z')]; for n=1:size(coords,2) for i=1:size(vals,3) subplot(size(coords,2),size(vals,3),s); ...
3a5a44b8b4e3c03714cbbeb28a18d4cddc4f7164354232b560a980a047ccfb35
MATLAB
914
34
% Not the latest version load(fullfile(saveLoc, 'sig_allSessions'), 'sigSL') ws{1} = sigSL.w.TinC; ws{2} = sigSL.w.TinI; ws{3} = sigSL.w.ramp; ws{4} = sigSL.w.PC1; ws{5} = sigSL.w.whatD; ws{6} = sigSL.w.whenC; allCs = nan(8,length(allW),length(allW)); for sess = 1 : 8 for w1 = 1 : length(dNames) ...
61099f57bbf736d7c75b04dda27c5b3f576c119409d6da3554b7662c5f480b52
MATLAB
914
40
function [X, y] = mixModelSample(model, nsamples) %% Sample from a mixture model % This file is from pmtk3.googlecode.com y = sampleDiscrete(model.mixWeight, nsamples, 1); switch lower(model.type) case 'gauss' mu = model.cpd.mu; Sigma = model.cpd.Sigma; d = size(Sig...
ad4cc0c4a415e5bfc3190d5f809685541d099208e5e90772b9439cbb1cff109a
MATLAB
914
48
% check if all files are sorted % % usage: % % crabsort.checkSorted('857_108',{'PD','LP'}) % function fatal = checkSorted(allfiles, neurons, early_exit) if nargin < 3 if length(allfiles) > 50 early_exit = false; else early_exit = true; end end fatal = false; if ischar(allfiles) allfiles = fullfile(getpref('...
e507dae3ee509e9d410c86a25df448775796e0e42538e721155355e6f8faa73b
MATLAB
914
18
function fileList = getAllFiles(dirName) dirData = dir(dirName); %# Get the data for the current directory dirIndex = [dirData.isdir]; %# Find the index for directories fileList = {dirData(~dirIndex).name}'; %'# Get a list of the files if ~isempty(fileList) fileList = cellfun(@(x) fullfile(dir...
29954f344f713092832dff972d39f34a8121d4126dfa5ee7c5fa10357196abba
MATLAB
915
20
clear;clc;close all ROOTPATH = strcat(NoveltySU.utils.getRootDirPath(mfilename("fullpath"), 4), "Data\Processed Data\"); cd(NoveltySU.utils.getRootDirPath(mfilename("fullpath"), 2)) protStr = "Active duration"; temp = NoveltySU.utils.dirItem(strcat(ROOTPATH, protStr), "spkData.mat"); popRes = cell2mat(cellfun(@(x)...
7ecc34de9707bfc0575d5af7182a3a7094ccd2413278108fb14ece33e137dd61
MATLAB
915
30
function X = VBA_spm_inv(A,TOL) % inverse for ill-conditioned matrices % FORMAT X = spm_inv(A,TOL) % % A - matrix % X - inverse % % TOL - tolerance: default = max(eps(norm(A,'inf'))*max(m,n),exp(-32)) % % This routine simply adds a small diagonal matrix to A and calls inv.m %________________________________________...
ecd08691fa245705bbed46bf393fde5dd039a085d009a953d20589e87492952d
MATLAB
915
23
function h = pbar(pVals, varargin) % h = pbar(pVals, varargin) % plot a bar where p values are less than alpha % Inputs: pVals is a vector of pvalues e.g. from tests at each time point % name-value pairs of optional inputs for graphical controls: % xVals = x-axis values to plot to (same size as pVals)...
11ef7c8d94946adfe8cb79acab6f3b49444d00e78ebc68da3eb5b08f061ed34a
MATLAB
916
38
%% Sensor Fusion Demo % %% % This file is from pmtk3.googlecode.com xs = [1.1 1.9]; nx = length(xs); ys = [2.9 4.1]; ny = length(ys); xbar = mean(xs); ybar = mean(ys); sx = sum((xs - xbar).^2)/nx; sy = sum((ys - ybar).^2)/ny; % MLE lamx = 1/sx; lamy = 1/sy; postPrec = (nx*lamx + ny*lamy); theta = (xbar*nx*lamx + yba...
a36698452c5526080ce2150727cc560b8ba3b64a4978086a132d29792e31d18d
MATLAB
916
36
function [drNduT] = get_drNduT(M,nt,dt,par,y) %% This function returns d(rho(:,end))/d(u) transpose times a vector y % % y... vector length(prod(n),1) % rho(:,0) -----------> rho(:,1) --------------> rho(:,2) % u(:,1) u(:,2) % R1, S1 R2, S2 %% n ...
fd4a82eef667f5b86071cbdfc1b0f5e324b87f494f1e7b5cf4cc61200e068cbe
MATLAB
916
35
function F = exgauss_cdf(y,X) % EXGAUSS_CDF computed cumlative distribution function % % DESCRIPTION % Computes cumulative distribution function for each of the data points in % y, given the vector of ex-Gaussian parameters X % % SYNTAX % F = EXGAUSS_CDF(y,X); % % EXAMPLES % Mu = 400; % Sigma = 50; % Tau =...
2465fa01abeee681f1bc951da8018480c1f18b2508e1b886fd2f163db4c38d62
MATLAB
917
47
function S = getcovariance(mix,inds,centers) if ~exist('inds','var'), inds = 1:mix.nin; end; if ~exist('centers','var'), centers = 1:mix.ncentres; end; inds = inds(:)'; ninds = length(inds); centers = centers(:)'; ncenters = length(centers); S = zeros(ninds,ninds,ncenters); switch mix.covar_type, case 'spheric...
4d06dea87f9ce33fd4e8a161ed2ee7cda9512e8c87574136ca966cde5c45b502
MATLAB
917
28
function y = not(x) %NOT Logical NOT (~) for sptensors. % % ~X performs a logical not on the input tensor X. The result always % returned as a sparse tensor. % % See also SPTENSOR. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others...
5f609c3b61950e117c1e1e5febca6bbfc35eb202ca877f6bc955205bcd0139f4
MATLAB
917
23
function y_CallSave(FileName,Data,Option) % function y_CallSave(FileName,Data,Option) % Call save for parfor usage. ('save' is not suitable for 'parfor') % Input: % FileName - The output File name. % Data - The data want to be saved. % Option - The option for calling save. Could be: % ...
784a2f77e82e0ef666f1aae0be9105ea05e8f3ceffe5f2db8c5475675d08725f
MATLAB
917
29
function find_and_move_videos(basepath,local_drive_path) % matlab wrapper for find_and_move_videos.py % % find_and_move_videos will copy videos to dlc video path and also copy % results back to original folder locations % % Input: % basepath: session or project path % local_drive_path: local path where you...
80ac73b2e5fbfaf978b9ea1cbb05c8d7933de9f00627682e5654bfc8bc05e394
MATLAB
917
15
function [] = NETCDFdisplay(filename) %NETCDFDISPLAY % [] = NETCDFdisplay(filename) displays information about specified SOFA file % SOFA API - function netcdf/NETCDFdisplay % Copyright (C) 2012 Acoustics Research Institute - Austrian Academy of Sciences % Licensed under the EUPL, Version 1.1 or – as soon they will...
960ce50a5e613526ae27492390c48bd6699d6ac7c637ba16079ff3a601919bad
MATLAB
917
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','...
0a118876b25ea6d9f75839316d4f841324a58b397a0db951107f55ca6f6a1d11
MATLAB
918
20
function sector_count_mask = generate_sector_count_mask(circle_centers, num_sectors_per_colony, outres, scaling_factor) sector_mask = zeros(outres,outres); num_circles = size(circle_centers, 1); for this_circle = 1:num_circles scaled_circle_center = scaling_factor*circle_centers(this_circle,:); translate...
8121e94e9d81485febf2c6710b93a02bbbaadb835326faac744f7b71c724fe0f
MATLAB
918
24
function [triplet] = makeTCATriplet( blue_dim, red_dim ) %UNTITLED2 Summary of this function goes here % Detailed explanation goes here triplet = figure('units','normalized', 'Position', [0.8, 0.7, 0.15, 0.22],... 'MenuBar', 'none', 'Color', [1, 1, 1]); set(triplet,'NumberTitle', 'off') hold on; plot([0,1,2], [0...
e2f7cae975fb9094abd26806b2923354f2dc44132fdd76101911d758fbb3aded
MATLAB
918
20
function subwts = getGaussianSubWeights(params) %UNTITLED2 Summary of this function goes here % Detailed explanation goes here %========================================================================== mx = params.gaussparams(1); my = params.gaussparams(2); sx = params.gaussparams(3); sy = params.gausspa...
0f5b4c40d0c96fdc597f53c4ea93266e8cda9b726ee6c5bee210bab69c8873a6
MATLAB
919
41
% Plot stimulus-locked mean traces for all coherences - considering nans in % each trial % meanTracesRL_bigSbigT conditions = rt_quant; colores = NS_colorsBY(length(nanunique(conditions))); dt = sigRL.t(2)-sigRL.t(1); min_num_bins = 50; % read from elsewhere... [Son,ti_on] = bigSbigT(rl,dt,dt,smooth_win_t,...
3a36e7b0563438e6773db7b9d71f7f3ad1f63782f2cb1a0d01eb091627aeb3dc
MATLAB
919
33
function [samples] = hmmSamplePost(model, X, nsamples, varargin) % Forwards filtering, backwards sampling for HMMs % % X must be a single sequence of size d-by-T % OUTPUT: % samples(t,s) = value of S(t) in sample s %% % This file is from pmtk3.googlecode.com softev = process_options(varargin, 'softev', []); initDist...
5a1c19f0151d622a1a68d86d4fa707ea7d44690b4d10a0a13fb697ebb6cc8330
MATLAB
919
42
%% MAIN clear all; clc; Screen('CloseAll'); % IOPort('CloseAll'); %% S= struct(); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% S.SUBJECT = 'P01'; S.RUN_ID = '_R1'; dir_path = 'F:\SEM_mri\MRI\SEM_mri_rawdata'; % Alterar! filename = [S.SUBJECT S.RUN_ID]; ...
b473cbd37a911ad85fad07ddda619513be1d912b543b655f48db0defaae3b85f
MATLAB
919
28
function SetDefaultValue(position, argName, defaultValue) % Initialize a missing or empty value in the caller function % % SETDEFAULTVALUE(POSITION, ARGNAME, DEFAULTVALUE) checks to see if the % argument named ARGNAME in position POSITION of the caller function is % missing or empty, and if so, assigns it the value DE...
d89909d3f9082a4669f2a6c8a35d2eef9589fa8ba69990044bfccc201774dfdc
MATLAB
919
36
spacing = 30; mytform = deformationField; sizeTform = size(mytform); %decimate deformation field Tformdec = zeros(sizeTform(1)/spacing,sizeTform(2)/spacing); for i = 1:sizeTform(1)/spacing for j = 1:sizeTform(2)/spacing Tformdec(i,j,1) = mytform(i*spacing,j*spacing,1); Tformdec(i,j,2) = mytform(i*...
3b5a4461b3b7cdedb0f6288db0ff40dfb32247f89241bdc49df66f6cca6b2c33
MATLAB
920
25
function A = VBA_spm_mesh_adjacency(F) % Compute the adjacency matrix of a triangle mesh % FORMAT A = spm_mesh_adjacency(F) % F - a [fx3] faces array or a patch structure % % A - adjacency matrix as a sparse [vxv] array %__________________________________________________________________________ % Copyrig...
3ca8b02b832cb288cc2fc17c113b151c493937f50f881d7ca59a9a104601ce04
MATLAB
920
47
function S = mixgetcovariance(mix,inds,centers) if ~exist('inds','var'), inds = 1:mix.nin; end; if ~exist('centers','var'), centers = 1:mix.ncentres; end; inds = inds(:)'; ninds = length(inds); centers = centers(:)'; ncenters = length(centers); S = zeros(ninds,ninds,ncenters); switch mix.covar_type, case 'sphe...
4a5e60a2bb1f612b21b1536144e38af6ca22a8df9bcfef5d5b7c25c221767235
MATLAB
920
31
function browse_topoplotVAR(cfg, data) % BROWSE_TOPOPLOTVAR is a simple helper function for FT_DATABROWSER that % computes the variance of band-pass filtered data and makes a topographic % plot. It serves to make a quick-and-dirty power topography. % % See also BROWSE_MOVIEPLOTER, BROWSE_TOPOPLOTER, BROWSE_MULTIPLOTER...
018f39a88bed03eab6023b4168240eb47995a2062bbaa9aa4e2d41c101378d7a
MATLAB
921
44
function [slope_results] = compute_slope(logreg_results) %%% weight of location evidence in the location context d(:,1)=logreg_results.thetadd; %%% weight of location evidence in the frequency context d(:,2)=logreg_results.thetadf; %%% weight of frequency evidence in the frequency context f(:,1)=logreg_results.theta...
0e230a346c03b82253266d1c3990b24cd72c6ce9270fb404a2ac14e75f7d3ec6
MATLAB
921
22
function [camPos camDir planeCoefs Z camUp camR] = DLTCameraGeometry(coefs) % function [camPos camDir planeCoefs Z] = DLTCameraGeometry(coefs) % Inputs: coefs - the 11 DLT coefficients for the camera in question % Outputs: % camPos - positions of the cameras (as computed by DLTcameraPosition) % camDir - look...
11910f1969c0c190398d09c8f3a18fe5810557b54769bcc157f12fac4d92649a
MATLAB
921
32
function r = matCell2Mat(A) if iscell(A) try n = numel(A); [mA,nA] = size(A{1}); r = zeros(n,mA*nA); for i = 1:n r(i,:) = reshape(A{i},1,mA*nA); end catch e if strcmpi(e.identifier,'MATLAB:getReshapeDims:notSameN...
54d03bb34f88572c018cbfaeb56470e6baf60ee86580ba811520b94f27a80a95
MATLAB
921
39
function res = parforOverVideo(readframe,frms,fun,varargin) [args,bufsize,verbose] = myparse(varargin,'args',{},... 'bufsize',128,'verbose',false); ncurrmov = numel(frms); useparfor = true; if useparfor, imbuf = cell(bufsize,1); niters = ceil(ncurrmov/bufsize); res = cell(1,ncurrmov); for iter = 1:niters...
de8d6cf13e82d51bf527cc5ee9dfe4f423260765e9a6eb1cdf1254574ed3754e
MATLAB
921
48
%% Demonstrate inference in pairwise mrf using 4 node network % Based on http://www.cs.ubc.ca/~schmidtm/Software/UGM/small.html % This file is from pmtk3.googlecode.com %% Setup model nNodes = 4; adj = zeros(nNodes); adj(1,2) = 1; adj(2,1) = 1; adj(2,3) = 1; adj(3,2) = 1; adj(3,4) = 1; adj(4,3) = 1; nStates = 2*one...
0f97dc95360c400e7167c22e214042dd67b21bf27f6ab7418bfbc5c9aed4b7cb
MATLAB
922
32
function outpoints = mni2tal(inpoints) % Converts coordinates from MNI brain to best guess % for equivalent Talairach coordinates % FORMAT outpoints = mni2tal(inpoints) % Where inpoints is N by 3 or 3 by N matrix of coordinates % (N being the number of points) % outpoints is the coordinate matrix with Talairach points...
33169758fc4d507e1d1aa176259efe16592cada1867d5d8c028d0240864ab3f8
MATLAB
922
33
function [pathname] = uigetdir2(start_path, dialog_title, name) % Pick a directory with the Java widgets instead of uigetdir import javax.swing.JFileChooser; import java.io.File; if nargin == 0 || isempty(start_path) || ~ischar(start_path), % Allow a null argument. start_path = pwd; end jchooser = java...
4948fb1a4de5ca3129aad5fb947edd0d309770ce222413e7f73b763ee76c88b4
MATLAB
922
46
function tracks = readmtrax(filename) load(filename); % because matlab is retarded load(filename,'angle'); D = 8; % total number of frames nframes = length(ntargets); % data. tracks{t} are the positions of the targets in frame t % tracks{t} is D x ntargets(t) tracks = cell(1,nframes); j0 = 1; for i = 1:nframes, ...
63a4596a29647af88140cbcfcfbc2db301e65b53aa61824847e0d30310e9a927
MATLAB
922
34
function MakeMATLABClusterScript(shfile,jobid,script,argstr,varargin) [MCR,TMP_ROOT_DIR] = myparse(varargin,'MCR','','TMP_ROOT_DIR',''); if isempty(TMP_ROOT_DIR), [~,me] = unix('whoami'); me = strtrim(me); TMP_ROOT_DIR = fullfile('/scratch',me); end MCR_CACHE_ROOT = fullfile(TMP_ROOT_DIR,'mcr_cache_root'); if...
87b5b3cc6f0ba738af41abf30ed7c4957c134c3a8243c8aa082e60b08060cbc8
MATLAB
922
23
function [parceldata parcelstd] = Bo_surfData2parcelData(surfdata, surfparcel) % function [parceldata parcelstd] = Bo_surfData2parcelData(surfdata, surfparcel) % computes means in each of the parcels and writes out a new matrix % % input: surfdata = k * v surface data (k subjects, v vertices) % surfpar...
a6d17a8ec6b5e4b23beac381bc14eb419eefac260f85fe0c9b9fda99248feeb8
MATLAB
922
41
function I = load_image(kk , calib_name , format_image , type_numbering , image_numbers , N_slots), if ~type_numbering, number_ext = num2str(image_numbers(kk)); else number_ext = sprintf(['%.' num2str(N_slots) 'd'],image_numbers(kk)); end; ima_name = [calib_name number_ext '.' format_image]; if ~exist...
c35e98ab1cfa113659614ba6e378e0ddbd0465f52099b6105f4cbd8fd7526057
MATLAB
922
28
function [V2,V3] = VFactor_Local(Data,Wnd,Overlap,position) if nargin==3 position = [1 length(Data)]; end if nargin==2 Overlap = round(numel(Data)./2); position = [1 length(Data)]; end if nargin==1 Overlap = round(numel(Data)./2); Wnd = numel(Data); ...
fd0f9fcd5d5be245f6acc422ccbac3a04be096ed815fabb5cb19cee0663afed4
MATLAB
922
38
function [Nburst,burstStart,period,burst] = calc_bursting_par(z) global trsh istart = 0; iend = 0; NZ = length(z); burstStart(1) = 0; burstEnd(1) = 0; for i = 1:NZ if i+1 <= NZ if z(i) < trsh && z(i+1) >= trsh istart = istart+1; burstStart(istart) = i; end en...
282c4e2276d8975f837d4bb9986c67018f45f35c6b008b4b1b49ba70aa68459e
MATLAB
923
13
function [P1,P2,P3,P4,T1]=PlotBox2(BoundingBox,LineStyle,LineColor,LineWidth,Text,TextFontSize,TextFontColor) P1=plot([BoundingBox(1),BoundingBox(1)+BoundingBox(3)],[BoundingBox(2),BoundingBox(2)],LineStyle,'color',LineColor,'LineWidth',LineWidth); P2=plot([BoundingBox(1),BoundingBox(1)+BoundingBox(3)],[BoundingBox(...
552f265e890d504290e96e022b0861fc1a7fd24bcb5b87c9d8a14a064b9bc243
MATLAB
923
32
%% Illustration of a GMM singularity % %% % This file is from pmtk3.googlecode.com f1 = @(x) gaussProb(x,0.5,0.12.^2); f2 = @(x) gaussProb(x,0.88,0.03.^2)/2; f3 = @(x) f1(x) + f2(x); domain = 0:0.001:1; dataPoints = [0.21 0.25 0.32 0.45 0.58 0.72 0.88]; figure; hold on; stem(dataPoints',f3(dataPoints)','Color','g','L...
5b8067f32e7d58d122a1048cf7e518ada96f63240c29361090f32b7b9f861908
MATLAB
923
37
function mutexlock(lockfile, timeout) % MUTEXLOCK creates a lockfile, or if it already exists, waits until % another process removes the lockfile and then creates it. This function % can be used for "mutual exclusion", i.e. executing multiple processes in % parallel where part of the processing is not allowed to run %...
69c8554d9ffd19568b294389faa87063162816d3ec0b9cb511c4f5d2b89a9f4b
MATLAB
923
26
function indlev = defIndlev(level,NtotPar) % indexing of k-ToM's hidden states % function findlev = defIndlev(level,NtotPar) % IN: % - level: k-ToM's sophistication level % - NtotPar: total nb of evol/obs params % OUT: % - indlev: structure of hidden-states indices if level==0 % 0-ToM indlev = []; else % k-T...
e27be969fd17371037e41a5d21f8203e2ea0d3c91176df2ce1d531c05ad64f32
MATLAB
923
27
% Filter object can be used for filtfilt % function Hd= get_filter_designfilt(filtType, freqWindow, fs, filtOrder, plotYes) function Hd= get_filter_designfilt(filtType, freqWindow, fs, filtOrder, plotYes) if ~exist('filtOrder', 'var') filtOrder= 2; end if ~exist('plotYes', 'var') plotYes =0; end switch lower(...
f9dd13ed1b4253511b45adc51e7f7daeacd54f0b15fa4d164b2b3665a84442bc
MATLAB
923
25
function Potential = bemf4_surface_field_potential_accurate(c, Center, Area, PC) % This function computes CONTINUOUS electric field and the full potential % on a surface facet due to charges on ALL OTHER facets including % accurate neighbor integrals. Self-terms causing discontinuity may not % be included for e...
9ad427cc672feefc0703e2c10ab160cf7a7b0e9070d68eae73dc1592e812f966
MATLAB
924
26
% MessageToUser.m % Sarah West % 4/26/22 % Is called within functions that are themselves called by RunAnalysis.m % Displays a message to user in the command window reporting the progress % of the function by saying what iterators it's on. % Inputs: % parameters.values -- created by RunAnalysis.m % message -- a stri...
409219d4f99df731c3655d1a1de32d56fd3e672b0b92013aecdc0b2da3e96b0c
MATLAB
925
38
%%%%%This package written by robert wilson, freely available at % https://github.com/d-r-b-o-b/UsefulMatlabFunctions%% fontname = 'Helvetica'; fontsize = 16; ABCfontsize = 24; fontweight = 'normal'; linewidth = 3; matlabGrey = [1 1 1]*215/255; global arminn arminn_pink arminn = [119, 171, 189]/256; arminn_pink =...
dbc378614d1bf53e397a1790719e7ae2c6dc7e77176640a39fb910dbc1dbcca4
MATLAB
925
17
function RotatedFullProfile=ImageRotationFullProfiles(TestImage,FullProfileAngles,RotateMethod,PixelLine_Full_XCoords,PixelLine_Full_YCoords) TestImage=single(TestImage); for angle=1:length(FullProfileAngles) TempAllProfiles(angle).TempProfile=zeros(size(PixelLine_Full_XCoords)); end parfor...
155dcba8211f96cc20ede8f7daca1bfde451f87e7ab9771bdf24c7d7b18fb558
MATLAB
926
27
function this_color = color_picker(object_type) % COLOR_PICKER assigns all colors to be plotted in a synthetic image. % Each object should have a representative color, a distribution, or % alternative data to support color selection. if strcmp(object_type, "table_background") this_color = [54 54 68]/255; els...
19c55c0a0f968ac84407d55ad57d0632d3e97b58d2f71c193131704b35c746da
MATLAB
926
44
% Author: Birgit Nierula (Feb, 2020) % nierula@cbs.mpg.de function zim_newpage(page_path, page_name, my_title) % make sure the path ends with / if ~strcmp(page_path(end), '/') page_path = [page_path '/']; end % create text file if ~exist([page_path page_name]) mkdir([page_path page_name]) end fid = fopen([p...
40df594b6e7d71ff442c55966be744c1d2d2283d7b5fc64adec7d90edc447769
MATLAB
926
38
function blocks = mrf2ImgMkTwoBlocks(nRows, nCols) %% Make Blocks - comb structure (2 interlocking trees) % This file is from pmtk3.googlecode.com nNodes = nRows*nCols; nodeNums = reshape(1:nNodes,nRows,nCols); blocks1 = zeros(nNodes/2,1); blocks2 = zeros(nNodes/2,1); b1Ind = 0; b2Ind = 0; for j = 1:nCols if mod(...
440e62acd511b2b00837942be75f2aad07e04d45cb4cd6702f3f9215f3638039
MATLAB
926
35
function ptrx = toPTrx(s) tgtsUn = unique(s.tgt); ntgts = numel(tgtsUn); ptrx = TrxUtil.newptrx(ntgts,s.npts); % default x/y fcns (centroid) xfcn = @(p)nanmean(p(1:s.npts,:),1); %#ok<NANMEAN> yfcn = @(p)nanmean(p(s.npts+1:2*s.npts,:),1); %#ok<NANMEAN> for jtgt=1:ntgts iTgt = tgtsUn(jtgt); ...
a20cf30212a6188e1efdaaca4bf7386190bc05c672ced572f5b3e13e4b9a335a
MATLAB
926
28
function Lengths = distBoundary (RatPosition, WallStart, WallVector) WallVectorX = repmat(WallVector(1,1),1,100); WallVectorY = repmat(WallVector(2,1),1,100); RatPositionX = RatPosition(1); RatPositionY = RatPosition(2); WallStartX = WallStart(1); WallStartY = WallStart(2); Bearings = 0 : 0.02*pi : 1.98*pi...
a5f56e4e332dc25929777d84139be603887e0a8cc8081ba01ce6e906eea3cdf6
MATLAB
926
30
%%This code is used to remove the bad anat_T1 that is not in the %%good_t1_list.txt data_info='/gpfs51/dors2/gpc/JamesBooth/JBooth-Lab/BDL/jinwang/PlausGram_9-10/scripts/better_t1.xlsx'; %This is your excel path. In this excel, it should have two columns, one is %subjects, the other is better_t1. data_path='/gpfs51/...
d33ae2a19ab9e2532c19acd6f3608c8ccd89b2670b080f62c4eb545906c5eb4e
MATLAB
926
20
% VIDEOS % See also % % Behavior annotation for seq files: % behaviorAnnotator - Caltech Behavior Annotator. % behaviorData - Retrieve and manipulate behavior annotation of a video. % % Seq files [custom codec free video format]: % seqIo - Utilities for reading and writing seq files. % seqReade...
364436a1394fc73b3140eb546931aa86e7d5e5fde8c79e8bd3d74f068fae36f4
MATLAB
927
34
function pthresh = lme_mass_FDR(p,fdr) % pthresh = lme_mass_FDR(p,fdr) % This function has slightly modified the freesurfer's fast_fdrthresh % function (jbernal modification 2010) % % p = list of p values between -1 and 1 % fdr = false discovery rate, between 0 and 1 % % Based on Tom's FDR.m from % http://www.sph.um...
531f9130cdd6df16b0e808a25f40237631edda259e34d202aa6a1a9ca54849e3
MATLAB
927
39
% rd_plotSeqAllTrials.m switch p.jitter case 'ITI' blockLengths = stimulus.itiSeq + p.blockDur; case 'blockPrecueInterval' blockLengths = stimulus.jitSeq + p.blockDur; end blockStarts = [0 cumsum(blockLengths(1:end-1))]; blockIdx = round(blockStarts*p.refrate + 1); nBlocks = numel(blockIdx); p...
53d539020eaac6c07a78456fafa4e53a859748e1ec483380861cf47e1d06e02b
MATLAB
927
31
function h_updateSpineAnalysisFileInfo3(handles) [currentInd, handles, currentStruct, currentStructName] = h_getCurrendInd3(handles); if ~isempty(h_img2) handles1 = h_img2.gh.currentHandles; currentFilename1 = get(handles1.currentFileName,'String'); [pname1, fname1, fExt1] = fileparts(currentFilena...
6d84b5864d5a4a5a95418300e21c8b24eeaab0dcceac763314560b604bfad8ee
MATLAB
927
30
function distances_X = compute_distance_matrix(X, dist_type) distances_X = sdist(X, dist_type); % Small cleanup for correlation del = 10*eps(class(distances_X)); if any(diag(distances_X) > del) % Sometimes the diagonal is not fully 0 because of rounding issues. % This makes sure it all...
7013f161ca6af15db52e2ffc365ab5dd5557c459d104eaffa557e0e3fe4cde67
MATLAB
927
34
load('linear-std-1-info', 'allinfo'); lin_info = allinfo; load('circ-std-1-info', 'allinfo'); circ_info = allinfo; load('DR-std-1-info', 'theinfo'); dr_info = theinfo; edges = 0:0.05:1.5; tick_length = 0.03; xc = edges(1:end-1) + 0.01; subplot(1, 3, 1); dry = histc(dr_info, edges); dry = dry(1:end-1); bar(xc, dry,...
7b855134e2a6dc569f39c755555a0e060094307addda9b96bd3989849a58b808
MATLAB
927
30
% readframe = mmf_get_readframe_fcn(header) % % Returns the handle to a function which inputs the frame number and % outputs the corresponding frame for a MMF file described by the input % 'header'. % % Note that this 'header' is modified by mmf_read_frame and that header % seems to be stored in the function ha...
b9d1eaa8dded18f102bba2fd7ea93ebafb7523704f23e019babdebf7659abb2a
MATLAB
927
39
function writeOFF(fn,t,p) % Writes surface mesh defined in 't' and 'p' to a filed called fn % Note: At the momemnt it assumes mesh is a triangulated surface mesh only % http://shape.cs.princeton.edu/benchmark/documentation/off_format.html % % Written by: % Hamid Ghadyani Oct 2010 fid = OpenFile(fn,'wt'); if ...
ffd85521e693bd46de6ccdc728112cfe09734b6b3f0c8096b18d17a65a43cbaa
MATLAB
927
23
function [pot] = lpcomp_helm_comb_dir(S,zpars,sigma,targs,eps) [ndtarg,ntarg] = size(targs); npts = S.npts; npatches = S.npatches; ipatch_id = zeros(ntarg,1); uvs_targ = zeros(2,ntarg); norders = S.norders; ixyzs = S.ixyzs; iptype = S.iptype; srcvals = S.srcvals; srccoefs = S.src...