sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
75751f76363ab915de3844862fe04d03af67a58836af8e54f0c051d18d7d9cc6
MATLAB
385
18
% function checking if a specific file is a script% function bool = isscript(fileName); fid = fopen(fileName, 'r'); cont = true; while cont && ~feof(fid) l = strtok(fgetl(fid)); if ~isempty(l) && l(1) ~= '%' if strcmpi(l, 'function') bool = false; return; else bool...
5df604ad3de0a2824014843935a6091ab7d8edbbf0f48531f387e07717245d5e
MATLAB
386
20
function hdi = calc_CI(samples, q) % function hdi = calc_CI(samples, q) % % Calculates symmetric 95% confidence interval for MCMC samples % % INPUTS % % samples - vector of MCMC samples % q - bounds on symmetric CI, default [0.025 0.975] % % Steve Fleming 2015 stephen.fleming@ucl.ac.uk if ~exist('q','var') || isempty(...
3dbd8071ffe15e6d960a634b04b007a93e9fdf6ef9ed512b9d0a6b360cf0a6d7
MATLAB
387
18
function psgOut = eeglab2danalyzer(psgIn) % Converts an EEGLAB struct to danalyzer format. %% % Authors: Dan Denis % Date: 2021-07-14 %% psgOut.data = psgIn.data; psgOut.hdr.srate = psgIn.srate; psgOut.hdr.samples = psgIn.pnts; if isfield(psgIn.etc, 'T0') psgOut.hdr.recStart = psgIn.etc.T0; else ...
86ffac85aa1ea7dd641aebf17183e7f2c2dfebc2076467a543aeb333a2588194
MATLAB
387
8
function idx = findROI(allROIs, mouse, session, idxFOV) % findROI - Find row index matching mouse, session, and idxFOV. % idx = findROI(allROIs, mouse, session, idxFOV) idx = find(strcmp({allROIs.mouse}, mouse) & strcmp({allROIs.session}, session) & [allROIs.idxFOV] == idxFOV, 1); if isempty(idx) erro...
8df8fa1c75dbe59ef8aec0682da1c7e924583b8fbaf77fa4895bc20327acfb9f
MATLAB
387
15
function unset( ~, ~, ~ ) %uiextras.unset Clear a default property value from a parent object % % This functionality has been removed. % Copyright 2009-2014 The MathWorks, Inc. % $Revision: 979 $ $Date: 2014-09-28 14:26:12 -0400 (Sun, 28 Sep 2014) $ % Check inputs narginchk( 2, 2 ) % Warn warning( 'uiextras:Depr...
9075b2b9d83b664cca5946126b7280259a4feddaa9b0556347c3e529c3640779
MATLAB
387
21
function LaBGAScore_move_repos_matlabpath(repoA, repoB) % moves repoA below repoB in matlab path and saves new path - saves you % tons of clicking in pathtool ;) p = strsplit(path, pathsep); idxA = find(contains(p, repoA)); block = p(idxA); p(idxA) = []; idxB = find(contains(p, repoB), 1, 'last'); p = [p(1:idxB) ...
c9dea89ce435ffbb1321bc4193b3daac2c9c80dc67f8ebe42f1dd2349bd0829d
MATLAB
387
14
function string = mygettext(tree, varargin) uid = root(tree); if ~isempty(varargin) uid = varargin{1}; end string = ''; mychildren = children(tree, uid); for ch_uid = mychildren switch get(tree, ch_uid, 'type') case {'chardata', 'cdata'} string = [stri...
e2738a2bf13916d3f777be9c1aa7ed245414fc1b94c0763b4663f41013662330
MATLAB
387
9
function [Energy D S L] = GCO_ComputeEnergy(Handle) % GCO_ComputeEnergy Run alpha-expansion algorithm. % E = GCO_ComputeEnergy(Handle) returns energy of current labeling. % [E D S L] = GCO_ComputeEnergy(Handle) also provides a breakdown of % the energy into Data, Smooth, and Label costs. GCO_LoadLib(...
254ffadafdd8de95297b38c7c4622d58a71d008b4455cf574d2cf7d59f1d7b8e
MATLAB
388
20
function z=smooth_lf(x,y,varargin) % must (unlike R smooth.lf() function) give x and y. % also R's direct=T is automatic. % xev = x; if (k>1) if (strcmp(varargin{1},'xev')) xev = varargin{2}; varargin(1:2) = []; end; end; fit = locfit(x,y,varargin{:},'ev',xev,'module','simple'); z = lfknots(fit); fv = inv...
8d6d349af954f262b42d9b18be89f7a91d8dca276e8addb632f7aafcc5edcb08
MATLAB
388
20
function y=mysmooth(x,p1,p2,p3) % Usage ... y=mysmooth(x,p1,p2,p3) % % Wrapper for Matlab's smooth function if prod(size(x))==length(x), x=x(:); end; y=x; for mm=1:size(x,2); if nargin==2, y(:,mm)=smooth(x(:,mm),p1); elseif nargin==3, y(:,mm)=smooth(x(:,mm),p1,p2); elseif nargin==4, y(:,mm)=smooth(x...
9fad9771187167b3a5e13a5a615318759fd77027c4e737b0cb3d875ba37a1fdd
MATLAB
388
14
% is_sccn() - returns 1 if computer is located at SCCN (Swartz Center % for computational Neuroscience) and 0 otherwise function bool = is_sccn; bool = 0; domnane = ' '; try eval([ 'if isunix, [tmp domname] = unix(''hostname -d'');' ... 'end;' ... 'bool = strcmpi...
c1ea375f8d7e5292fb1af07cc06ebd8ae39b16f934049ad9f2f5866b7d730090
MATLAB
388
14
function [n,freqs] = plx_adchan_freqs(filename) import CMBHOME.PLX2Mat.* % plx_adchan_freq(filename): Read the per-channel frequencies for analog channels from a .plx file % % [n,freqs] = plx_adchan_freq(filename) % % INPUT: % filename - if empty string, will use File Open dialog % OUTPUT: % freqs - array of frequ...
578dfffea10cc636b9f436f5680b2e71d8c256bafa5928ebe8b0b365af99ed6b
MATLAB
389
10
function Q = makeQForWeightedCorr(UniqueNumBins, numPlaces) %function Q = makeQForWeightedCorr(UniqueNumBins, numPlaces) a1 = repmat((1:max(UniqueNumBins))', [1, numPlaces]); b1 = repmat(1:numPlaces, [max(UniqueNumBins), 1]); Q = {}; for i = 1:length(UniqueNumBins) Q{UniqueNumBins(i)} = [reshape(a1(1:UniqueNu...
d8dc66b1e232f40c367e9291008dbccbb2f4899709298787f4873cbf992991e0
MATLAB
389
14
function s = char(tree) % XMLTREE/CHAR Converter function from XMLTree to a description string % FORMAT s = char(tree) % % tree - XMLTree object % s - a description string of an XMLTree % % Return a string describing the XMLTree: % 'XMLTree object (x nodes) [filename]' % % See also XMLTREE s = sprin...
20b99c82aac28cb6d7f2dfaca9de2b4a578b78b497e7d615fe9884bb8b8790d5
MATLAB
391
13
function actual = calculate_CL_turn(turns) % get turns; turns are recorded without gain but with zero thresholding % get camera direction % camera direction at start = 0 % actual cam dir = cam dir previous - turn value for the previous step gain = 40; a = [0]; for i = 1:length(turns...
26850ffb5ec81a2d20903ce388149e454516ba1c905ca84a5315da64da054d8c
MATLAB
391
10
% get turns; turns are recorded without gain but with zero thresholding % get camera direction % camera direction at start = 0 % actual cam dir = cam dir previous - turn value for the previous step gain = 40; actualcamdir = [0]; for i = 1:length(turns) actualcamdir = [actualcamdir,actualcamdir(i)-(turns(i)*g...
707581482ebf5efe5da504a35710ecf87bd1358a08fa9536d487775810250b50
MATLAB
392
11
function TimeTest = getBinaryClassifiersTestTime(blockTagsAC,features,folderpath,nameTag) classes = ['OC';'OH';'OW';'CH';'CW';'HW']; TimeTest = zeros(size(features,3),1); for cla = 1:6 class1 = classes(cla,1); class2 = classes(cla,2); [perfMat,TimeTest0] = binaryClassTestTime(class1,class2,blockTagsAC,...
934bd0ace8857266cdcfe32998013de0173a80da70da72451377cb7ec0716256
MATLAB
392
8
function [va vm] = sumPFNvecs(PFN_bumps,PFN_amps) % assumes PFN_bumps is already 45-deg shifted. because that's what i've % done in FBmodel7.m. adj = PFN_amps(:,1).*cos(PFN_bumps(:,1)) + PFN_amps(:,2).*cos(PFN_bumps(:,2)); opp = PFN_amps(:,1).*sin(PFN_bumps(:,1)) + PFN_amps(:,2).*sin(PFN_bumps(:,2))...
bb126808265c86ecc88f74cd633d5cf44b14e5cfcd07ea0db0f243452c28bf40
MATLAB
392
21
clear; clc; close all; addpath(genpath('../functions/')); CBIG_plotSetup; K_0 = 2; K = 10; k_bestRun = cell(K-K_0+1, 2); idx = 1; for k = K_0:K r = CBIG_find_maxLikeRun(['../../lda/outputs/188blAD' sprintf('/k%i/', k)]); k_bestRun{idx, 1} = k; k_bestRun{idx, 2} = ['../../lda/outputs/188blAD/' sprintf('k...
d9609780ec6c3643f942ce35843edc6092221fe93bbdc09106039ef8bda96efe
MATLAB
392
15
function displayProgress(msg,iter,total) % display message for updating progress % setup for first iteration if(iter == 1) fprintf(1,[msg ' ']); % an extra space takes care of the first backspace end % update through the iterations fprintf(1,[repmat('\b',1,numel(num2str(iter-1))) '%d'],iter); % a new ...
26199e137a04729243d1df31940d31880f4a0adaeb82866f96813feca841d1f9
MATLAB
393
12
% Local Regression and Likelihood, Figure 5.2. % Author: Catherine Loader % % Density Estimation, for the Old Faithful Geyser Data. % identity link. load geyser; fit = locfit(geyser,'alpha',[0.1 0.8],'link','ident','ll',1,'ur',6); figure('Name','fig5_2: Density estimation for Old Faithful geyser data' ); lfpl...
5c01d40d63fc17dce3ef0887d511180506f4a633df3c240e2b5714da060afcf7
MATLAB
393
18
function volume=CheckVolumeFaceMesh(V,F) volume=0; for i=1:size(F,1) a=V(F(i,1),:); b=V(F(i,2),:); c=V(F(i,3),:); k=cross(b,c); v = (a(1)*k(1)+a(2)*k(2)+a(3)*k(3))/6; volume=volume+v; end volume=-(volume); function c=cross(a,b) a=a(:); b=b(:); c = [a(2,:).*b(3,:)-a(3,:).*b(2,:) ...
ce369039e386110abda4279f8d85419a8122af8f17b2145bcf1c54aa1d23699f
MATLAB
393
25
function idx = matIndex(sz, dir) idx = false(sz); if strcmpi(dir, 'right') for i = 1:sz idx(i, i + 1:end) = true; end elseif strcmpi(dir, 'left') for i = 1:sz idx(i, 1:i - 1) = true; end elseif strcmpi(dir, 'diagonal') for i = 1:sz ...
525c85391f82e94bcadb1010eec108d4b71f8db739f95cf09bfc5ff926501427
MATLAB
394
12
% Local Regression and Likelihood, Figure 1.1. % % A linear regression and plot for Spencer's mortality % data. Unlike the book, I use locfit for this! % % Setting 'ev','none' means that locfit computes only % the parametric fit. In this case, 'deg',1; i.e. linear. load spencer; fit = locfit(age,mortality,'deg',1,'ev'...
4e7aa7d76e668bea5db277091dca3fce0f3f29932ae615543295ee9b0cbf7e72
MATLAB
395
13
clear all; close all;clc;dbstop if error; CMBHPATH = 'D:\Dropbox\scripts\packages\CMBHOME_stable\'; PIPATH = 'D:\Dropbox\scripts\general_scripts\pass_index'; load('D:\Dropbox\scripts\jrc_scripts\Projects\CaitlinData\CMBobject_clamps-69 (1).mat') % root = root.FixPos; % root.spatial_scale=1; % root.spatial_scale = 150...
3d7b8648011ba88edc2e7ba1b36e0f36eef5983253903784b645eb6dba248982
MATLAB
396
14
function res = length(this); tmp = struct(this); %if any(cellfun(@length, { tmp.EEG }) > 1) % error('EEG structure in object with more than 1 element') %end; try res = length(tmp.EEG); catch res = length(tmp); return; end; if res > 1, error('EEG st...
c540857cfb3bd0e6c454a358d96c6ccc7d63b3881b1abda877dda1899d2e2ec9
MATLAB
396
9
function [Unique_basis_cell] = extract_unique_bases_multiple_k(X, cluster_num_list, labels_cell, rank) Unique_basis_cell = {length(cluster_num_list)}; for idx = 1: length(cluster_num_list) labels = labels_cell{idx}; [uniqueBases, sharedBasis,clusterBases,ev_cumsum] = extractUniqueBases(X, label...
90f645fbb06594ec15189edc38820248a237ee92c2549efe57b88707ce1ba8f0
MATLAB
397
15
function ea_elvis_surfice(~,~,handles,native) uipatdir=getappdata(handles.leadfigure,'uipatdir'); ea_exportpat([],[],'PLY',handles) for pt=1:length(uipatdir) thispt=uipatdir{pt}; script=['BEGIN;',... ' RESETDEFAULTS;',... ' MESHLOAD(''',[thispt,filesep,'export',filesep,'ply',filesep,'combined_sce...
a01d1368c1c70b7821694ef2f539e5df1f3894da1b81a69cf426ad29cc62d3d6
MATLAB
397
14
function Yf = split_frame(Y,patches) df = diff(patches(1,:)); ndim = size(patches,2)/2; Yf = zeros([df(1:2:end)+1,size(patches,1)],'like',Y); otherdims = repmat({':'},1,ndims(Yf)-1+(size(patches,1)==1)); for i = 1:size(patches,1) indeces = cell(1,ndim); for j = 1:ndim indeces{j} = patches(i,...
e1c855fe5523233348788dd45cc547c11d6ac9ad5829b1accd944034d765a271
MATLAB
398
16
function t = mystruct(obj) % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: mystruct.m 1143 2008-02-07 19:33:33Z spm $ if numel(obj)~=1, error('Too many elements to convert'); end; fn = fieldnames(obj); for i=1:length(f...
ee1aaf5eb5ab97244d06099723dfa1ba78ff20c08eb83615dfe856f00e3b6e15
MATLAB
398
15
function v = value( x ) global cvx___ v = cvxaff( x ); switch class( v ), case 'cvx', v = value( v, cvx___.y ); case 'cell', for k = 1 : numel( v ), v{k} = value( v{k}, cvx___.y ); end end % Copyright 2005-2016 CVX Research, Inc. % See the file LICENSE.txt for full copyright...
472a476bf9a0f150ada018d5295828db30e29b66795a4f2df7abc1fafa465cc7
MATLAB
399
16
function prob = cher( A, b, Sigma ); % Computes Chernoff upper bounds on probability % % Computes a bound on the probability that a Gaussian random vector % N(0,Sigma) satisfies A x <= b, by solving a QP % [ m, n ] = size( A ); cvx_begin quiet variable u( m ) minimize( b' * u + 0.5 * sum_square( chol( Sigma )...
7c345f5db7dc6f854b045cadbc4f58390e5f479d4cea5fb9eb5deb39bb92e6e9
MATLAB
399
17
function [results] = VerifyError(expr, results) wasError = 0; try eval(expr); catch ex wasError=1; end if wasError == 0 disp ([expr ' <-- expected error, but was no error']) count = 0; if(isfield(results, 'failedTests')) count = size(results.failedTests, 1); end resul...
a80ed8bb7a2ce90c200c1cd08666b1c03d6e53719da831bfaf9c5956aba1d44a
MATLAB
399
15
% Local Regression and Likelihood, Figure 2.4. % % Bivariate Local Regression. load ethanol; alp = [0.25 0.3 0.49 0.59]; lab = {'Local Constant' 'Local Linear' 'Local Quadratic' 'Local Cubic'}; f=['a','b','c','d']; for (i=1:4) figure('Name', sprintf( 'figure2_4%c: Bivariate local regression', f(i) ) ); fit = lo...
993fc5a5deac82c5939ae21bade41c18443aa9792233386db41219adc5115a35
MATLAB
400
15
function vidstack = makeCatStack(files) vidstack = []; for file = 1:length(files) vidpath = [files(file).folder '\' files(file).name]; vreader = VideoReader(vidpath); disp(vreader.NumFrames) vreader.CurrentTime=0; while hasFrame(vreader) % j = imbinarize(readFrame(vreader),'adapt...
cb5bba793b98032eff4be2db0162a694b0ebd1c0b4ab3563e771af640fb7afc9
MATLAB
400
15
function y = sum_log( x, dim ) %SUM_LOG Internal CVX version. cvx_expert_check( 'sum_log', x ); narginchk(1,2); if nargin == 2, y = size( x, dim ) * log( geo_mean( x, dim ) ); else y = length( x ) * log( geo_mean( x ) ); end % Copyright 2005-2016 CVX Research, Inc. % See the file LICENSE.txt for full copyrig...
d1f67635e016b923298149ee8eec7234f1f92bfa35d5b03596f05d96551fe53c
MATLAB
400
16
%% Converts offline sorter variables into a structure for easy MATLAB manipulation % % Kian Torab % ktorab@blackrockmicro.com % Blackrock Microsystems for i = 1:96 ChannelName = ['Chan', num2str(i, '%03.0f')]; if exist(ChannelName, 'var') VariableName = eval(ChannelName); Channel...
03b8e97cb9363e5406bd8d648183d0257c591de632bd098945a82455a465abbe
MATLAB
401
18
function [ MPC ] = subfun_computeMPC( inputData1 ) % inputData1 should be ROIxlayer cvm = corr(inputData1', 'Type', 'Pearson'); pcm = corr(inputData1',mean(inputData1,1)','Type', 'Pearson'); MPC = zeros(size(cvm)); for i = 1:size(MPC,1) for j = 1:size(MPC,2) MPC(i,j) = (cvm(i,j) - pcm(i)*pcm(j)) / sqrt((1...
219eb6d27b31d91c078ebcc2edb92d4be8b2097814e846021da1046e67743629
MATLAB
401
8
function v = cvx_value( x ) warning( 'CVX:IllegalUse', ... 'CVX error: illegal use of a cvx problem object has been detected.\n Please do not copy or manipulate the value of ''cvx_problem'' in any way.', 1 ); %#ok v = []; % Copyright 2005-2016 CVX Research, Inc. % See the file LICENSE.txt for full copyrigh...
7f724afe54230869d389c76da21c9cbcdde03a9d9bf2bfa70deb9f966efff112
MATLAB
401
14
% Local Regression and Likelihood, Figure 5.3. % Author: Catherine Loader % % Density Estimation using poisson regression. % Stamp thickness data. load stamp; n = sum(count); w = 0.001*n*ones(76,1); fit = locfit(thick,count,'weights',w,'family','poisson','alpha',[0 0.004]); figure('Name','fig5_3: Poisson regression de...
ed07669df2716ff6aff9ef44de8059572a57f32920c14d6834ae4298572d81fc
MATLAB
401
24
function formatCCFMap(metricField, ARfactor, fontSize, leftOffset, bottomOffset) % Formatting for maps plotted over Allen CCF if nargin < 2 ARfactor = 1; end if nargin < 3 fontSize = 6; end if nargin < 4 leftOffset = 0.5; end if nargin < 5 bottomOffset = 0.5; end % Set sizes formatCCF(ARfactor, font...
094e3d1e843c2a026fb42185ee0e4fa2de7e46dffa12d02cba0569d8d849af39
MATLAB
402
15
function varargout = get( ~, ~ ) %#ok<STOUT> %uiextras.get Retrieve a default property value from a parent object % % This functionality has been removed. % Copyright 2009-2014 The MathWorks, Inc. % $Revision: 979 $ $Date: 2014-09-28 14:26:12 -0400 (Sun, 28 Sep 2014) $ % Check inputs narginchk( 2, 2 ) % Error er...
1a292efa21e7c93ea236f29ff5b2c1366184fbf669f581ffbb532e041d2ac0a6
MATLAB
402
16
function [ rsq ] = goodnessFit( pts, mdl ) %UNTITLED Summary of this function goes here % Detailed explanation goes here % Observed points y = pts(:,2); x = pts(:,1); % Estimated linear model Yhat = x*mdl(1) + mdl(2); ss = sumsqr(y - nanmean(y)); % Sum of squares w.r.t. the original mean ssr = sumsqr(Yhat - y); ...
cf605bd054a170f6a3a2feadc158f82854706ead5d98107fab3e44c144e4834d
MATLAB
402
8
% CVX: Internal functions and scripts. % This directory contains code that is meant for internal use by % the CVX system itself. Documentation of the functions in this % directory is more sparse and not intended for end users. % Copyright 2005-2016 CVX Research, Inc. % See the file LICENSE.txt for full copyr...
d02abf6d9c3149b5fad0824df46b9e31808bd17af6b588fade7f4a58e5ba84be
MATLAB
402
14
function convLike = CBIG_compute_convLike(b, subtype_compo, gender, avg_stats) % convLike = CBIG_compute_convLike(b, subtype_compo, gender, avg_stats) % 1 for male, 2 for female % % Written by CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md avg_stats(2) = gender; X = [1 subtype_c...
0d3f7145d78ab96b0b275d3a797da55890e4558f51c30cc5897a23becfaf76c4
MATLAB
403
13
% Local Regression and Likelihood, Figure 11.4. % Author: Catherine Loader % % Local Adaptive Smooth - Dopler example. % % NEED: Improve plot - curve is hard to see. x = (0:2047)'/2047; m = 20*sqrt(x.*(1-x)) .* sin(2*pi*1.05 ./ (x+0.05)); y = m + normrnd(0,1,2048,1); fit = locfit(x,y,'pen',4,'acri','cp','maxk',500); f...
a6f9fbc7a49ad033dcdd70125e7b69ee9e69236f4b4e23c5728f039e2faff8b7
MATLAB
403
15
function cvx_optval = sum_square_pos( x, varargin ) %#ok %SUM_SQUARE_POS Internal cvx version. narginchk(1,2); x2 = []; cvx_begin variable x2( size( x ) ); minimize( sum_square( x2, varargin{:} ) ); x2 >= x; %#ok cvx_end % Copyright 2005-2016 CVX Research, Inc. % See the file LICENSE.txt for full copy...
ee73c8aa3f52d103c45546424b0722413797ae94841d47a4ca58d070bb9df3b8
MATLAB
403
17
function en = end(a,k,n) % Overloaded end function for file_array objects. % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: end.m 1143 2008-02-07 19:33:33Z spm $ dim = size(a); if k>length(dim) en = 1; else if n<leng...
8e47eba79c8b23d205692f846f82714118f14f42502929e028d4764ce9d3c6bb
MATLAB
404
7
function inter=CheckInsideTetrahedron(p1,p2,p3,p4,rx,ry,rz,mi,ma) if((rx<mi(1))||(rx>ma(1))||(ry<mi(2))||(ry>ma(2))||(rz<mi(3))||(rz>ma(3))), inter=false; return, end Lambda=BarycentricCoordinatesTetrahedron(p1,p2,p3,p4,rx,ry,rz); % Check if inside tetrahedron inter=(Lambda(1)>=0)&&(Lambda(1)<=1)&&(Lambda(2)>=0...
f7c8d5d52b8948d4a67f54ff9841ff3c6987a480d8fce5889c9fa560997d1e26
MATLAB
404
24
%% Plot close all; sourceArea = 'AC'; targetArea = 'PFC'; topoArea = 'AC'; section_granger_subplotImpl; close all; sourceArea = 'AC'; targetArea = 'PFC'; topoArea = 'PFC'; section_granger_subplotImpl; close all; sourceArea = 'PFC'; targetArea = 'AC'; topoArea = 'AC'; section_granger_subplotImpl; close all; sou...
48d9c1cdbdf6a2bbe7a32e856ba32c4205964c5d2ea4431f136197d6f4fcc82a
MATLAB
405
15
% Local Regression and Likelihood, Figure 7.5. % % Author: Catherine Loader load border; fit0 = locfit(day,runs,'cens',no,'family','geom','nn',0.7); fit1 = locfit(day,runs,'weights',ones(265,1)*0.8,'cens',no,'family','geom','nn',0.7); xev = lfmarg(fit); xev = xev{1}; y0 = predict(fit0,xev); y1 = predict(fit1,xev); fig...
637392e47ce6d0ed5cd52dedb0d075405770fe0848a77df09fb46e219ec3c1ac
MATLAB
405
19
function display(tree) % XMLTREE/DISPLAY Command window display of an XMLTree % FORMAT display(tree) % % tree - XMLTree object % % This method is called when the semicolon is not used to terminate a % statement which returns an XMLTree. % % See also XMLTREE disp(' '); disp([inputname(1),' = ']); disp(' '); for i=1:...
dae7a0e4b4f44a11769e6be1e2cf57e9b17eaebe88f81f6855766746febbdbe4
MATLAB
405
15
clear; clc; close all; addpath(genpath('../functions/')); SUBINFO_FILE = '../../subInfo/rid_sex_mDoB_yDoB_mExam_yExam_ageExam_dx_icv_bl.csv'; GMICV_FILE = '../../vbm_810bl/gmVolAndICV/rid_gmVol_icv_bl.csv'; %------- Which quantity? - Q % 1 for MMSE, 2 for MEM, 3 for EF Q = 3; [betas, stats] = CBIG_fitGLM(SUBINFO_FI...
28241b2645fab9a3b313f906d8697e46a0779ab607ea1f597efcf91cf9cdbac9
MATLAB
406
5
function hdtrajectory=ea_genhdtrajectory(trajectory,options) hdtrajectory(:,1)=interp1q([1:length(trajectory)]',trajectory(:,1),[1:1/options.zresolution:length(trajectory)]'); hdtrajectory(:,2)=interp1q([1:length(trajectory)]',trajectory(:,2),[1:1/options.zresolution:length(trajectory)]'); hdtrajectory(:,3)=interp1q([...
9d9e368460dee7d51b47f8ad1948d5ea661659e51db376b42eabd4c81e493cc4
MATLAB
406
9
function r = pearson(a, b) %PEARSON Pearson correlation, base MATLAB only. % corr() lives in the Statistics and Machine Learning Toolbox. The harness % must not depend on a toolbox to check a base-MATLAB library, so this % two-line replacement is used throughout the suite instead. a = double(a(:)) - mean(double(a...
75ee0844f1107dc22fb42dd5069b05096515caf39e4215cd818614895ecc721f
MATLAB
407
14
function [n,filters] = plx_chan_filters(filename) import CMBHOME.PLX2Mat.* % plx_chan_filters(filename): Read channel filter settings for each spike channel from a .plx file % % [n,filters] = plx_chan_filters(filename) % % INPUT: % filename - if empty string, will use File Open dialog % OUTPUT: % filter - array of...
1f10eb3c294a33d3ae3e9bb0aacefaf31f7feee0c9f6ac2061cd4b05f64a3ea5
MATLAB
408
20
function [g,a]=ar1nv(x) % AR1NV - Estimate the parameters for an AR(1) model % Syntax: [g,a]=ar1nv(x); % % Input: x - a time series. % % Output: g - estimate of the lag-one autocorrelation. % a - estimate of the noise variance. x=x(:); N=length(x); m=mean(x); x=x-m; % Lag zero and one covarian...
2654b6eac92580d4dd8b276853f32107045b77c0bfdf09a0e49de0c3735f48bc
MATLAB
408
11
function a = gt( x, y ) if isa(y,'cvxin')||~isa(x,'cvxin')||~x.active, error( 'CVX error: improper use of the <in> pseudo-operator.' ); end b = newcnstr( evalin( 'caller', 'cvx_problem', '[]' ), x.value, y, '==' ); if nargout, a = b; end % Copyright 2005-2016 CVX Research, Inc. % See the file LICENSE.txt for full...
52846c96f0d682fb62379a3729e17d9cdf2221acf1e509c75b58f8405d393956
MATLAB
408
15
function [ se m ] = se_mean( raw ) %SE_MEAN Summary of this function goes here % Detailed explanation goes here m = nanmean(raw); sd = nanstd(raw); %n = length(find(isnan(raw)==0)); if size(raw,1)==1 n = length(find(isnan(raw)==0)); else n = sum(~isnan(raw)); % changed 16.12.14 %n = length(find(isnan(raw...
c7b17860a0c6744268157c66a27d167be61068634325dd479d2ab547df10c4e9
MATLAB
408
5
signatures_to_plot = {'Content' 'Amused' 'Surprised' 'Fearful' 'Angry' 'Sad' 'Neutral'}; % NPS, VPS, SIIPS, etc., etc. myscaling = 'raw'; % 'raw' or 'scaled' mymetric = 'dotproduct'; ...
8e7aa175b8d86ac711f55f9ecd9697d40377ac467606f0698e12aa162008a3f8
MATLAB
409
17
%constants for sorting. see spikesortingParameters.txt for explanations. CLUSTERID_NOISE_CLUSTER=99999999; %extraction method METHOD_EXTRACTION_POWER=1; METHOD_EXTRACTION_AMPP=2; METHOD_EXTRACTION_AMPN=3; METHOD_EXTRACTION_AMPA=4; METHOD_EXTRACTION_WDM=5; %alignment/peak finding method METHOD_PEAKFIND_...
aa7ab04ed7c3af2c2b4d25277a935378a459c9d046d4d074f9c71a4eb50d16a9
MATLAB
409
13
function val = try_load_relative_snr(glmdir) val = NaN; try sfile = dir(fullfile(glmdir,'*_Visual_Checkerboard_GLM_Relative_Beta_SNR.mat')); if ~isempty(sfile) [~,ix] = sort([sfile.datenum],'descend'); S = load(fullfile(sfile(ix(1)).folder, sfile(ix(1)).name), 'relative_beta_SNR'); if isfield(S,'...
cadb5949d232593716d459022526546091b018de7055b8c6f33b9f70f67bf96d
MATLAB
409
8
function inter=CheckInsideFace(VN0,VN1,VN2,rx,ry,mi,ma,ignore_corners) if((rx<mi(1))||(rx>ma(1))||(ry<mi(2))||(ry>ma(2))), inter=false; return, end Lambda=BarycentricCoordinatesTriangle(VN0,VN1,VN2,rx,ry); % Check if inside face if(ignore_corners), mv=1e-8; vv=1-1e-8; else mv=0; vv=1; end inter=(Lambda(1)>=mv)...
14ce2e58dd01059a14a29353763fc31510aad9fe609bfa0582c3e47a6fc85cbc
MATLAB
410
16
function subList = generatesublist(folderLocation) % Generate a list of subjects to run through as a batch. Only use when data % is stored in a way that each subject's data is stored in their own % folder. %% % Authors: Dan Denis % Date: 2021-07-14 %% subList = dir(folderLocation); isItAFolder = [subList(:).isdir...
e9d6166e7bc0b03701204134465a07828191f983a45a66b5e4a41960db68d6fb
MATLAB
410
20
function root = alpha2counting(root) %Takes in an CMBHOME object and reorders the root.pathlfp to be in counting %order (eg: 'DATE_BASE.EEG1', 'DATE_BASE.EEG2') %Bill 2012.05.23 for i = 1:length(root.path_lfp) eegs.names(i) = root.path_lfp{i}(3); eegs.lengths(i)= length(eegs.names{i}); end [trash ind] =sort...
fa4db14a4717405f26ec952cc0d072392ef4d005f25050be8915e6d625aee303
MATLAB
410
16
% Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md % reorient all images in the raw folder spm_tool_dir = [spm_dir '/toolbox/OldNorm/'] addpath(spm_dir) addpath(spm_tool_dir) % apply reorient matrix to T1 images x = load(reorient_matrix); f = strtrim(image_pa...
bd6a37e4bf4dc60a8aa7a9577f6212f6bd754d8a835f941926df2f50859ab317
MATLAB
411
13
function areaMods = getAreaModulation(allROIs, areas, modField) % Gets the binary vector of modulated or not for each desired area % Allocate and loop over areas areaMods = cell(length(areas),1); for i = 1:length(areas) area = areas{i}; % Get cells in this area thisArea = arrayfun(@(x) strcmp(x.area, area)...
e0ff8e66d9bf38ab6be88545dc3bfd7a9c5e87b9df3670576552499373b063c7
MATLAB
411
15
function signal_filtered = ThetaFilter(signal, Fs) % Takes 'signal' and bandpasses it to theta frequencies (6 to 10 Hz) % % Arguments % % signal - arbitrary signal to be filtered % Fs - sample frequency % % signal_filtered = ThetaFilter(signal, Fs) Wn_theta = [6/(Fs/2) 10/(Fs/2)]; % normalized by the nyquist frequency...
988f8119bb864d61c4bb15d10ea25d8e4e3e562a102938737f3f1520ed6c6608
MATLAB
412
12
function ea_menu_addtransfer(handles,prefs) [leadsuiteapps,leadsuiteids,accs]=ea_getsuiteapps(prefs); [~,todel]=ismember(handles.callingfunction,leadsuiteids); leadsuiteids(todel)=[]; leadsuiteapps(todel)=[]; accs(todel)=[]; f = uimenu('Label','Open in...'); for app=1:length(leadsuiteids) uimenu(f,'Label',leadsui...
bd057f06bf976df18710de8d290934f7b95381366ef546559074784b0a475ef5
MATLAB
412
12
function ea_updatemodpopups(mdl,sf,handles) set(handles.fiberspopup,'String',mdl(sf==1)); set(handles.fmripopup,'String',mdl(sf==2)); if isempty(get(handles.fiberspopup,'String')) set(handles.fiberspopup,'String','No structural connectome found.'); end if isempty(get(handles.fmripopup,'String')) set(handles.fm...
ec8a4f8168e236f3e3e917909a1ca4dc9d07996ff29df83150ea92426f4f9685
MATLAB
412
25
function S = merge_structs(A, B) % MERGE_STRUCTS Merge two structures. % % S = merge_structs(A, B) makes the structure S have all the fields from A % and B. Conflicts are resolved by using the value in A. % % % merge_structs.m % David Gleich % % Revision 1.00 % 19 Octoboer 2005 % S = A; fn = fieldnames(B); for ii ...
a790aebd46de1bb51bafe865fbcfe0467c25cb6a21e5681bbdf92a8c1caf10f1
MATLAB
414
13
function [C,u]=PointToClosestPointOnLine(L1,L2,P) % C,u = PointToClosestPointOnLine(L1,L2,P) % % inputs, % L1,L2 : Points (x,y) describing a line % P : A certain (x,y) point % % outputs, % C : Point on the line which is closest to point P % u : Percentage [0..1] of position on line from L1 to L2 % ...
e645cc33cfa99fc73eeca1831f7217973b989c1c851c96016c8e2d0e19cad509
MATLAB
414
5
canlab_help_set_up_pain_prediction_walkthrough; [mask_obj, networknames, imagenames] = load_image_set('bucknerlab'); mycolors={[120 18 134]/255 [70 130 180]/255 [0 118 14]/255 [196 58 250]/255 [220 248 164]/255 [230 148 34]/255 [205 62 78]/255 }; [fitresult, gof] = evaluate_spatial_scale(image_obj,mask_obj,'cv_la...
214febf0edfe491cc08d7082cf0f09ff73c1d72b5313a3db4b5faf87c4caaea8
MATLAB
415
14
% Local Regression and Likelihood, Figure 5.3. % Author: Catherine Loader % % Density Estimation using poisson regression. % Stamp thickness data. load stamp; n = sum(count); w = 0.001*n*ones(76,1); fit = locfit(thick,count,'weights',w,'family','poisson','alpha',[0 0.004]); figure('Name','fig5_3: Poisson reg...
636d7547742ed577047e1eb5ec5d633dbfeddcfa1191cbf1ad3f5f6208e263b6
MATLAB
415
6
%----------------------------------------------------------------------- % Job saved on 11-Apr-2016 11:09:29 by cfg_util (rev $Rev: 6460 $) % spm SPM - SPM12 (6470) % Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md %-------------------------------------------...
83805f9742bd3f99a2f6d08fe764264394b8f4ee30fb8c0c6b86e43f25623aa1
MATLAB
415
14
function [n,thresholds] = plx_chan_thresholds(filename) import CMBHOME.PLX2Mat.* % plx_chan_thresholds(filename): Read channel thresholds from a .plx file % % [n,thresholds] = plx_chan_thresholds(filename) % % INPUT: % filename - if empty string, will use File Open dialog % OUTPUT: % thresholds - array of treshold...
9da5c6e4ed2f3161ffaabf42af9893bdc1f1a6d4a4cb2a8f13ef41e96fe6c7b6
MATLAB
416
25
function timestamp ( ) %*****************************************************************************80 % %% TIMESTAMP prints the current YMDHMS date as a timestamp. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 14 February 2003 % % Author: % % John Burkardt % ...
a52afae5896840f9c9cbb7ac9efabed2d4a62f3e21d0aca16400bb32f2a1f63d
MATLAB
416
13
% Local Regression and Likelihood, Figure 11.4. % Author: Catherine Loader % % Local Adaptive Smooth - Dopler example. % % NEED: Improve plot - curve is hard to see. x = (0:2047)'/2047; m = 20*sqrt(x.*(1-x)) .* sin(2*pi*1.05 ./ (x+0.05)); y = m + normrnd(0,1,2048,1); fit = locfit(x,y,'pen',4,'acri','cp','max...
47e872d5112bad16c48e78ceb6b19982bce585207e672982d07bb40d9376be9d
MATLAB
418
10
function ea_cvshowvatresults(resultfig,pX,directory,filesare,handles,pV,selectedparc,options) % determine if fMRI or dMRI mods=get(handles.vatmodality,'String'); mod=mods{get(handles.vatmodality,'Value')}; if regexp(mod, '^Patient''s fMRI - ', 'once') ea_cvshowvatfmri(resultfig,pX,directory,filesare,handles,pV,select...
2a55992aadef2af3988ec13652bd8d4b1cfd39ff18e896863301f9ae5d4817ef
MATLAB
419
7
% Examples employing logarithms, exponentials, and entropy functions % % max_entropy.m - Entropy maximization % sparse_covariance_est.m - Sparse covariance estimation for Gaussian variables % sparse_covariance_est_tradeoff.m - Sparse covariance estimation for Gaussian variables % weighte...
2de0187c773bd471b23674cf3b61f7a6e2aa1dd91bb74f0b3d23c2f841eb39dc
MATLAB
419
13
function p = CBIG_lr_test(X_r, y, n, ll_u, dof) if isempty(X_r) % only constant term mu = sum(y==1)/numel(y); % ML estimate ll_r = sum(y==1)*log(mu)+sum(y==0)*log(1-mu); else [b_r, ~, ~] = glmfit(X_r, [y n], 'binomial', 'link', 'logit'); % log(µ/(1-µ)) = Xb yFit = glmval(b_r, X_r, 'logit', 'size', n); ...
2577307de3e8edf0129e8f32bf1b115b5f768273ba2817989999fd05bd9686f0
MATLAB
420
13
function [M,Mz,My,Mx] = ea_diode_rollpitchyaw(roll,pitch,yaw) %% returns a 3x3 rotation matrix for roll->pitch->yaw rotation in that order %% all in radians a = pitch; %around x axis b = yaw; %around y axis c = roll; %around z axis Mx = [1, 0, 0; 0, cos(a), sin(a); 0, -sin(a), cos(a)]; My = [cos(b), 0, sin(b); 0, 1, 0...
75a3c1f59d0ad04564d83d4b387ca140d2d329f64266851a3874b30e1d8df566
MATLAB
421
13
function [paramEP, ephysProperties, acg] = loadSavedProperties(savePath) % JF, Load saved ephys properties % ------ % Inputs % ------ % % ------ % Outputs % ------ ephysProperties = parquetread(fullfile(savePath, 'templates._bc_ephysProperties.parquet')); acg = parquetread([fullfile(savePath, 'templates._bc_acg.parque...
8fd71c710dafd55f94eafdea4331186f0232d4709825fcad4897c54f1b6f7aac
MATLAB
421
13
function y = wrapped_2gaussian(x, a1, a2, mu, sigma1, sigma2) if nargin==2 coef = a1; a1 = coef(1); a2 = coef(2); mu = coef(3); sigma1 = coef(4); sigma2 = coef(5); end % 'f(x) = a1*exp(-((x-b1)/c1)^2) + a2*exp(-((x-(b1+pi))/c2)^2)'; y = a1 * exp(-min(abs(x - mu), mu+2*rad2deg(pi)-x).^2 ./ (2 *...
663c59a29a7257b3b690f416a9b36efde39f52ba1eeed11c9973d89763faa091
MATLAB
422
17
function xfit = lfmarg(fit) % computes grid margins from a locfit object, used for plotting. % this function is called from lfplot and lfband, will not normally % be called directly by users. box = fit.fit_points.fit_limits; d = size(box,1); xfit = cell(1,d); mg = 10*ones(1,d); if (d==1) mg = 200; end; if (d==2) mg =...
37893a6229ed836698ac5775b8280994cb6c208d7655255bec9f558ddc374272
MATLAB
423
13
function obj = fig(obj,fig) % fig Create separate figures according to one factor % % Example syntax : gramm_object.fig(variable) % For each unique value of variable, a new gramm figure will be created, % containing only the corresponding data. Useful when facet_ generates too % crowded figures. Warning: the generated ...
dd7fdfbbd468e24b47d476897732dbccf7876cfb69a3f617cd57bcf85ca0a170
MATLAB
423
13
function [p_ANOVA,Q_ANOVA,p_two,q_two,or_two,or_twolow,or_twohigh] = ClincFreq_Chi2test(x,C) [p_ANOVA,Q_ANOVA] = chi2test(x); for i = 1:size(C,1) X = [x(C(i,1),:);x(C(i,2),:)]; [p_two(i,1),q_two(i,1)] = chi2test(X); freqv = x(C(i,1),:)./x(C(i,2),:); if freqv(1)<freqv(2) q_two(i,1) = q_two(i,1)*-...
02373d13f2699e428c21f5794bac1fa2f2256d761de5004f87a2216879c4238b
MATLAB
424
10
function [dfG,dfR]=takeDelta(CinGreen,CinRed,FrameRate) %normally start at 2 but try moving to 10 because sometimes it messes up %the normalization I think? baseG=mean(CinGreen(:,2:round(5*FrameRate)),2);%skip the first frame since it's sometimes messed up dfG=CinGreen./baseG; baseR=mean(CinRed(:,2:round(5*FrameRate))...
8a582a9c2e5224a44aff26d2bff9d48356acc619d6c35956ebc4f16097b88926
MATLAB
425
18
function [interped] = makelength(varargin) % figure it out. signal = varargin{1}; len = varargin{2}; if nargin > 2 method = varargin{3}; else method = 'linear'; end interped = interp1(1:length(signal),signal,1:length(signal)/len:length(signal),method); c=1; while length(interped) < len interped = i...
a44da256e25d2c4a46907cd1d43a399a7aefe53c68de33036c5130f9ba27364d
MATLAB
426
18
function n=num_edges(A) % NUM_EDGES The number of edges in a graph. % % n = num_edges(A) returns the number of edges in graph A. % % For symmetric/undirected graphs, the number of edges returned is twice % the number of undirected edges. % % Example: % load graphs/dfs_example.mat % n = num_edges(A) ...
c181ab37a3a73281187231a7c9a220f116fa3aeb96ba3ce4aec2cec9ddbe8b0b
MATLAB
426
15
function [fnamesSorted,inds] = alphabetizeEEGfnames(fnames) if ~iscell(fnames) fnameLengths = arrayfun(@(x) length(x.name), fnames, 'unif', 1); else fnameLengths = cellfun(@(x) length(x), fnames, 'unif', 1); end lengths = unique(fnameLengths); fnamesSorted = []; inds = []; for i = 1:length(lengths) fnamesSorte...
ee7542c233864762e84c7e73b97a0127ef0c45c1d93b13b4361dd6656b7fe850
MATLAB
426
16
function [visang_deg] = Visual_Angle (screenwidth, totdist) % % [visang_deg] = Visual_Angle (screenwidth, totdist) % % visang_deg = visual angle in deg % Screenwidth = width of screen in % totdist = is viewing distance to screen (take care to use same unit as width) % % written by: Tessa Dekker 16-3-2015 t....
7b7dd607a562ad47f02e63198d5586ee7fd126dc56382831f1ee00d16c149f03
MATLAB
427
16
function varargout=m2v(varargin) % % vol=m2v(node,face,Nxyz) % or % vol=m2v(node,face,xi,yi,zi) % % shortcut for mesh2vol, rasterizing a teterahedral mesh to a volume using graphics % % author: Qianqian Fang (fangq <at> nmr.mgh.harvard.edu) % % input/output: please see details in the help for mesh2vol % % -- this func...
cecd2274dcad8bd3963c202a8d5ff2856b2f1db2f9134fa7e7e67d268f422836
MATLAB
427
24
function mu = RiceMean(nu, sig) % This code is from Jelle Veraart - NYU if sig>0 x = - nu.^2 ./ (2*sig.^2); I0 = besseli(0, x/2, 1).*exp(abs(real(x/2))); I1 = besseli(1, x/2, 1).*exp(abs(real(x/2))); K = exp(x/2).*(x.*I1 + (1-x).*I0); mu = 1.2533 .* sig .* K; nanlocs = find(isnan(mu) | ~isfinite(mu)); mu(nanlocs...
cdbb41e0a2912d7767ff662877c8fec805189d440b65678ec9be81fa9d2a5be7
MATLAB
428
15
function drawploy_custom(shapeoutline, shapecolor, Mver) if str2double(Mver(end-4:end))<2019 h1 = impoly(gca, shapeoutline); h1.Deletable = false; setColor(h1, shapecolor) setVerticesDraggable(h1, false) else drawpolygon(gca,'Position', shapeoutline, ... 'Color', shapecolor,... ...
b67cd1e19fcd54c3139df87f04a30a8ca6e8effe3c2b6368f06e496dbc340094
MATLAB
429
21
function [times groups spikesmat] = spikes2sorted(spikes) times=[]; groups = []; for i=1:length(spikes) % if ~isempty(spikes{i}) times = [times;spikes{i}]; groups = [groups;ones(length(spikes{i}),1)*i]; % else % times = [times; nan]; % groups = [groups; i]; % end ...
fef2ae65cd8fe759a3fcc1591cabe48fa10f72fce4c64c894ac3ded3c2a7bf2a
MATLAB
429
15
function [nch, npoints, freq, d] = ddt(filename) import CMBHOME.PLX2Mat.* % ddt(filename) Read data from a .ddt file % % [nch, npoints, freq, d] = ddt(filename) % % INPUT: % filename - if empty string, will use File Open dialog % % OUTPUT: % nch - number of channels % npoints - number of data points for each chan...
09168078b62c59b59737eb5eba3be9048038707e4bdfeb8902eff62a33e5f0ff
MATLAB
430
15
function [ y, symm ] = cvx_s_hankel( m, n, symm ) %CVX_S_HANKEL Hankel matrices. c = 0 : n - 1; c = c( ones( 1, m ), : ); r = ( 0 : m - 1 )'; r = r( :, ones( 1, n ) ); v = abs( r + c ) + 1; y = sparse( v, r + m * c + 1, 1, m + n + 1, m * n ); symm = false; % Copyright 2005-2016 CVX Research, Inc. % See the fil...
5d6083a352cebfe3cb15b1fffeb80c6aac799919a32724a2638836ff91e96b3f
MATLAB
430
15
function hdr = empty_hdr(fmt) % Create an empty NIFTI header % FORMAT hdr = empty_hdr %__________________________________________________________________________ % Copyright (C) 2005-2013 Wellcome Trust Centre for Neuroimaging % % $Id: empty_hdr.m 5451 2013-04-26 14:03:05Z guillaume $ if ~nargin, fmt = 'nifti1'; end...
46dc8fbe75a15f3ed2fe5aeaf558293f4ab0a285b6326f4275b15de4749c317b
MATLAB
431
19
function [isbinary,minmax]=ea_discfibers_checkcustomNii(vatlist) % small function to check whether input custom ROI (pseudoM case) are % binary and/or return their min/max values for v=1:length(vatlist) nii=ea_load_nii(vatlist{v}); isbinary(v)=ea_isbinary(nii.img); minmax(v,:)=[ea_nanmin(nii.img(:)), ea_...