sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
4c44609aaca2a4f14e591ab50a5e7e95e7c75acdf78b79a88180a5d423ea3fdd
MATLAB
606
18
function [ql,qu]=idealf(x) % Compute the ideal fourths for data in x % The estimate of the interquartile range is: % IQR=qu-ql; % Adapted from Rand Wilcox's idealf R function, described in % Rand Wilcox, Introduction to Robust Estimation & Hypothesis Testing, 3rd % edition, Academic Press, Elsevier, 2012 % Cyr...
a549b519c2d32c052263d22ffafdf78fb09746a56a60c6463bfeba30ed5a6f2f
MATLAB
606
14
%% calling wrapper for numerical integration (C. diff simulations) pathogen_ID = 2; %C. diff currently hardcoded elsewhere as OTU #2 pathogen_t0 = 1; %pathogen introduction time numSubjects = length(T_sample); experimentBlocks = ones(numSubjects,1); med_biomass = 22.3358; %these values obtained from a run (with fewer...
e98ed100a49315ef6625e80bfba0dd325a86e6a54b4c27cb029c42e769e73a0e
MATLAB
606
17
function result = safeDivideGBVS(arg1,arg2) % safeDivide - divides two arrays, checking for 0/0. % % result = safeDivide(arg1,arg2) % returns arg1./arg2, where 0/0 is assumed to be 0 instead of NaN. % This file is part of the SaliencyToolbox - Copyright (C) 2006 % by Dirk Walther and the California Institute of Tec...
156c2d75b54d25e98ef465a1e732b16f8ccdeed0c134e80113fa63870334c996
MATLAB
607
36
function y=normch(x,xmin,xmax) % Usage ... y=normch(x,min,max) % % Takes x and returns it with range from 0 to 1 or from min to max if (prod(size(x))==length(x)), x=x(:); end; ncol=size(x,2); if (~exist('xmin')), xmin=[]; end; if (~exist('xmax')), xmax=[]; end; if (isempty(xmin)), xmin=min(...
369ac16b0ea2fd7a038821bc514da23c299c98a662c232f9a3137d2a9555d127
MATLAB
607
14
function GCO_SetLabelOrder(Handle,Order) % GCO_SetLabelOrder Set label order for Expansion/Swap moves. % GCO_SetLabelOrder(Handle,Order) tells Expansion/Swap to select labels % in a specific order when Order contains integers from 1..NumLabels. % By default, Expansion/Swap use a consistent, prescribed order...
617d08500c19c9e52ae3128fcb0514e6d73c6dced1fddf3be4c8ea049acec871
MATLAB
607
18
function y = isreal( x, full ) %Disciplined convex/geometric programming information for ISREAL: % ISREAL(X) may be freely applied to any CVX expression. It will % return TRUE for all real affine, convex, concave, log-convex, % and log-concave expressions, and FALSE for complex affine % expressions. y = x.ba...
7bf7986e9f5caaf61d619d4f7c8cb5395e94a7b4f5ea99d7c9fe952de62531ee
MATLAB
608
19
function [ea_stats,thisstim]=ea_assignstimcnt(ea_stats,S) thisstim=1; if isfield(ea_stats,'stimulation') if ~isfield(ea_stats.stimulation,'label') % legacy, delete older stimulations ea_stats=rmfield(ea_stats,'stimulation'); else for stimfield=1:length(ea_stats.stimulation) if strcmp...
badd94e8350bd491225ccafbe70e52c0d358370e20fdb413cced54a29b591d88
MATLAB
608
26
function child = children(tree,uid) % XMLTREE/CHILDREN Return children's UIDs of node uid % FORMAT child = children(tree,uid) % % tree - a tree % uid - uid of the element % child - array of the UIDs of children of node uid % % Return UID's of children of node uid % % See also XMLTREE child = []; uid = uid(:); ...
27fc0722e836c6c71284635f94b16136a13c8fa467e3860cb369b3953cc9da6b
MATLAB
609
20
function r = CBIG_MMLDA_get_run_num(in_dir, k) % r = CBIG_MMLDA_get_run_num(in_dir, k) % % Get best run number based on visualization folder name. % % Input: % - in_dir: input directory which is the parent direcotry of "k*" % - k : number of fators, e.g. 2, 3, 4 % % Output: % - r : number of run. e.g. 11,...
90bb6c1cead81f0eb331beb48d9f196d431f733863567614fd4ff0159156ac8e
MATLAB
609
27
r = linspace(0,0.9,51); g = linspace(0,0.9,51); b = linspace(0,0.9,51); x = [-pi:0.1:pi]; %% s = [1:50:2001]; for s = [1:100:4001] for i = 1:51 AF(i,:) = cos(x-stims(s).Atheta(i)); OF(i,:) = cos(x-stims(s).Otheta(i)); end for i = 1:51 thing(i,:) = (stims(s).Am...
c165ca4c57308e27825586ecc40336a398d4cdec10e648e91f32f5904f25d86d
MATLAB
609
23
function v = cvxtuple( varargin ) if nargin == 1, v = varargin{1}; switch class( v ), case 'struct', if numel( v ) ~= 1, error( 'struct arrays not permitted in cvx tuple objects.' ); end case 'cell', v = reshape( v, 1, numel( v ) ); ot...
d115d320662689d963b95c18d84bb11fce35898c9c57905cddecf73fbc157901
MATLAB
609
38
function rval = rtest_6() rval = 0; try % create a line graph n = 10; A = sparse(1:n-1,2:n,1,n,n); A = A+A'; u = 1; v = 5; d = dist_uv(A,u,v); if any(d(v+1:end) > 0) error('breadth_first_search did not stop correctly'); end rval = 1; catch lasterr end end...
eb297969dfb13c9de71508958960605a41c987e80fa9f9b81a7e3c72e7b430c8
MATLAB
609
24
%%****************************************************** %% graph: generate random adjacency matrix. %% %% B = graph(n,prob); %% %% see maxcut.m %% %% SDPT3: version 3.0 %% Copyright (c) 1997 by %% K.C. Toh, M.J. Todd, R.H. Tutuncu %% Last modified: 2 Feb 01 %%*************************************************...
ec9e169c13296e4872b4d4d8f5b60297d5e354a5fff53d4670d7a09c8459b650
MATLAB
609
23
function s1 = resize_scales(s0,dim,args) % Resize scalefactors %__________________________________________________________________________ % Copyright (C) 2005-2013 Wellcome Trust Centre for Neuroimaging % % $Id: resize_scales.m 5456 2013-04-29 15:49:22Z guillaume $ dim = [dim ones(1,max(numel(args)-numel(dim),0))];...
423b209c35563a0c19aa7a2d6ee7da2eb45359db823c5257fb034020dc4537e8
MATLAB
610
27
function [isBuzcode, path] = bz_isBuzcode(basePath) % USAGE % [isBuzcode] = bz_isBuzcode(basePath) % % INPUT % basePath the basePath to check (default: current directory) % % OUTPUT % % % written by david tingley, 2017 if ~exist('basePath','var') basePath = pwd; end if bz_isSession(basePath) % onl...
ce702501d2ea8fed00dc3e388da740ccf1bf0b9a38c2cb9644881d9ecd6679aa
MATLAB
610
29
function fit = lf_censor(x,y,cens,varargin) % % Censored local regression using normal assumption. % Must provide x, y and cens. % All other arguments to locfit() can be provided, with the % exception of weights. % % NEED: Kaplan Meier Estimate. Iterations are fixed. % lfc_y = y; unc = find(~cens); for i = 0:3 fit ...
31c2ac2e916fb741a51d7c6b5030e65cdff270fc2d2b6b2c5917f176bcddbbbb
MATLAB
611
17
function obj=axe_property(obj,varargin) % axe_property Add a matlab axes property to apply to all subplots % % Example syntax: gramm_object.axe_property('ylim',[0 1]) % Arguments are given as a name,value pairs. The accepted % arguments are the same as in matlab's own set(gca,'propertyname',propertyvalue) if mod(nargi...
71eaa757ee564a64e305eaaf65d5d3317112ca59045f477bada6df710749a34a
MATLAB
611
24
function A=erdos_reyni(n,p) % ERDOS_REYNI Generates a random Erdos-Reyni (Gnp) graph % % A=erdos_reyni(n,p) generates a random Gnp graph with n vertices and where % the probability of each edge is p. The resulting graph is symmetric. % % This function is different from the Boost Graph library version, it was % reimple...
f8b0ef2c9a54445c720ed518ddae80817de445c7eda052bdc81a0dc7528bdcc6
MATLAB
611
17
function y = square( x ) %SQUARE Square. % SQUARE(X) is an array of the same size as X, whose elements are the % squares of the elements of X. % % Disciplined convex programming information: % If X is real, then SQUARE(X) is convex and nonmonotonic in X. If X % is complex, then SQUARE(X) is neithe...
f1a446f86705a5f0b8cf156f3bf0ee080e521fc471838248e023dc5d3f2fd1ba
MATLAB
612
17
function [n, npw, ts, wave] = plx_waves_v(filename, ch, u) import CMBHOME.PLX2Mat.* % plx_waves_v(filename, channel, unit): Read waveform data from a .plx file % % [n, npw, ts, wave] = plx_waves_v(filename, channel, unit) % % INPUT: % filename - if empty string, will use File Open dialog % channel - 1-based channel...
d18b76df96445ceb5c5cbb28fe7823b908cf6d8b57676dfe12f46b1e1feec5c2
MATLAB
614
18
function spikes = GetSpikes(units,varargin) %GetSpikes - Get spike timestamps. % % NOTE % % This function is provided for convenience. It simply calls <a href="matlab:help GetSpikeTimes">GetSpikeTimes</a> % using the same parameters. See this function for details. % Copyright (C) 2004-2011 by Michaël Zugaro %...
f643acd56b83404a6700de167607cfbf1122e168c4f5b80e764d6b70b7b25214
MATLAB
614
35
function len = s_len_trim ( s ) %*****************************************************************************80 % %% S_LEN_TRIM returns the length of a character string to the last nonblank. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 14 June 2003 % % Author: % %...
173ca5fd9e849f168c7cfc85081ae3cde8ae97efaded20f0e85276c3fbbc7b35
MATLAB
616
28
function em = errormatrix(fet,clu) cluIx = unique(clu); nClu = length(cluIx); nDim = size(fet,2); mu = zeros(nClu,nDim); sigma = zeros(nDim,nDim,nClu); p = zeros(1,nClu); for ii=1:nClu f = fet(clu==cluIx(ii),:); % Mean fet vector mu(ii,:) = mean(f); % Covariance. We add 1e-5 to the diagonal to ensure ...
9144f2c863cab66f346c7d2fdaaed2e1cacfd5cc7c611a093b5cc3b2ccc291da
MATLAB
616
26
function seeds=surfseeds(node,face) % % seeds=surfseeds(node,face) % % calculate a set of interior points with each enclosed by a closed % component of a surface % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % node: a list of node coordinates (nn x 3) % face: a surface mesh triangle list (ne x 3) % % ou...
faad785fc4e8b8be997f6993e3b7944e4ffe5645b6420463193f07ac9600b827
MATLAB
617
25
function ea_addrecent(handles, uidir, type) % Add new item to recent patients/group analyses try load([ea_prefsdir, filesep, 'ea_recent',type,'.mat'], 'recentfolders'); catch recentfolders = {}; end if ismember(['No recent ', type, ' found'], recentfolders) recentfolders = {}; end if isrow(uidir) uid...
297844afd32beed3a790597e3b71ea75b3c8d9607db78f12c35021f3a488d705
MATLAB
618
23
% Local Regression and Likelihood, Figure 7.6. % % Estimating the mean survival time using a local weibull % (transformed Gamma) model. load heart; z = 0.625; ts = (surv+0.5).^z; fit = locfit(age,ts,'cens',cens,'family','gamma','nn',0.8); i = find(cens==0); figure('Name','fig7_6: mean survival time local wei...
432e1f0114fc886f39d46c276b98c87f94aea9393f0c5e5424bc41285265cf98
MATLAB
618
14
function control_max_eig = circular_shift(SpikeCount,number_of_surrogates) control_max_eig=zeros(1,number_of_surrogates); for surr_idx = 1:number_of_surrogates ControlSpikeCount=zeros(size(SpikeCount)); for neuron_idx = 1:size(SpikeCount,1) drawnbin = randi(length(SpikeCount),1); auxbin ...
d232fba11b43cbefa789371644629d0e63202995ab98513836eee8f551fee741
MATLAB
618
22
function status = ea_checkJavaClassPath % Check if static Java class path has been set for LeadDBS classpath = {fullfile(ea_getearoot, 'ext_libs', 'dragndrop') fullfile(ea_getearoot, 'helpers', 'gui', 'ListBoxRenderer')}; spath = javaclasspath('-static'); if all(ismember(classpath, spath)) status = 1; else ...
26a84c9a75efc7a4b7c2cc4aa5d91a01c2e03e78593d62b55cf451a29f0ed9d9
MATLAB
619
22
%% Figure 9 supp 4 % RUN fig9_analysis, then return here fig9_analysis % Load map load('allenDorsalMap.mat'); % Params cmap = 'L20'; smoothSD = 0.15; %% Panel A: % CCF with log probabilities for the area-agnostic GMM component 1 plotMetricMapCCF(dorsalMaps, allROIs, 'lpAllComp1_metrics', smoothSD, cmap) %% Panel B:...
6913569e8c5be0971ab4b9dc55cd168d451bb9ba3f26e4e519751ac7b92bae26
MATLAB
619
24
function [out filenames] = rotoball_importer(varargin) n = 1; for i = 2:2:length(varargin) refs(n).date = varargin{i-1}; refs(n).expnumber = varargin{i}; n = n+1; end all_dir = dir; for e = 1:length(refs) ii = 1; for i = 1:length(all_dir) if strfind(all_dir(i).name, ['E' num2str(refs(e).e...
b4dea1a5b61cb5f962143a1e6ebc175d03e6d42d1cdc948a38ec6821227a71bc
MATLAB
619
19
for i=1:length(files_on_disk) study_string=strfind(files_on_disk{i},'Study'); subject_string=strfind(files_on_disk{i},'Subject'); nii_string=strfind(files_on_disk{i},'.nii'); Study(i)=str2double(files_on_disk{i}(study_string+5:subject_string-1)); Subject(i)=str2double(files_on_disk{i}(su...
fd20b0bddd3f6be5b75c95005d06eb5d36cca3fb0a35973dc2b0964dd89ee5f4
MATLAB
619
25
function [n,ind]=my_histcounts(X,edges,normalization) persistent old_matlab if isempty(old_matlab) old_matlab=verLessThan('matlab','8.4'); end if old_matlab %We make histc behave like histcounts [n,ind]=histc(X,edges); ind(ind==length(n))=length(n)-1; n(end-1)=n(end-1)+n(end); n(end)=[]; ...
36733a3cc7c3db6aee907e43f9e161af0920c1443f0fcbedcc99d49f21622bdc
MATLAB
620
20
function worked = next(vr) %WORKED=NEXT(VR) % Advances to the next frame in the video. Returns 0 if the next frame is % not available. % % After the videoReader constructor is called, NEXT, SEEK, or STEP should % be called at least once before GETFRAME is called. % % See videoReader/getinfo for more de...
e71944ec402abdc78c3f81ddf292273df14394d8564ccb8a08f2d96d389a24e2
MATLAB
620
34
function [x,yp_out]=calcRadius3(proj,mii) % Usage ... x=calcRadius3(proj,mii) if (nargin<2), mii=[]; end; if (isempty(mii)), mii=[1:length(proj)]; end; xp=[1:length(proj)]; mp=polyfit(xp(mii),proj(mii),1); yp=polyval(mp,xp); yp_out=proj./yp; ypm=mean(yp); yp=proj-yp+ypm; xi=[1:0.01:length(proj)]; ypi=interp1(xp,...
5108b35426e988b9d5b9c8e7798b83fbe7e263acb95f8754c676505519a719af
MATLAB
621
18
function s = struct(this) % Struct method for GIfTI objects % FORMAT s = struct(this) % this - GIfTI object % s - a structure containing public fields of the object %__________________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging %...
9de81e2d0a531e6bb7ec4dad63263d8c711fd7d7acc078f071500f9d3d63f5aa
MATLAB
621
16
function scalingFactors = getAnalogToVoltageScaling(param) % get scaling factor if strcmp(param.ephysMetaFile, 'NaN') == 0 if contains(param.ephysMetaFile, 'oebin') % open ephys format scalingFactor = bc.load.readOEMetaFile(param.ephysMetaFile); % single sclaing factor per channel for now ...
e18db57a64e6ed8b91307e34b0bf0d06ba3c123b033549dafc070f580818ffd5
MATLAB
622
27
% Local Regression and Likelihood, Figure 13.1 % % Author: Catherine Loader load mmsamp; figure('Name','fig13_1a'); plot(x,y,'o'); hold on; fit = locfit(x,y,'deg',1,'kern','minmax','alpha',4000,'ev','grid','mg',200,'ll',0,'ur',1); xev = fit.fit_points.evaluation_points'; yev = predict(fit,'fitp'); plot(xev,yev); fi...
54a515b936d4a460e6815d59d6db01ecc2551901b893c12eace0aa1399eee268
MATLAB
623
29
function SH = cpmSH(dirin,L) if size(dirin,3) > 1, for k = 1:size(dirin,3), [V D] = eigs(dirin(:,:,k)); [~,ix]=sort(D(logical(eye(length(D))))); dir(:,k) = V(:,ix(3)); end; else dir = dirin; end; N = size(dir,2); costheta = (dir(3,:)); xiy = dir(1,:) + i*dir(2,:); xiy = xiy ....
988056e49b775b85e6b17442aa9a6b1d1af0b0f2387b482e18f09d84a5bb130b
MATLAB
623
23
function [q, q_str] = CBIG_get_quantityOfInterest(rid, Q, predementedOnly) % [q, q_str] = CBIG_get_quantityOfInterest(rid, Q, predementedOnly) % Quantity of interest % % Written by CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md if Q == 1 % MMSE q = CBIG_get_mmse(rid, predement...
f51e4ff3f044e70f6bc9be9606e2ec94c0a3f15e70d21aebe1d4db18eb5b8b8a
MATLAB
623
20
% eeg_ms2f() - convert epoch latency in ms to nearest epoch frame number % % Usage: % >> outf = eeg_ms2f(EEG,ms); % Inputs: % EEG - EEGLAB data set structure % ms - epoch latency in milliseconds % Output: % outf - nearest epoch frame to the specified epoch latency % % Author: Scott Make...
76625b8329c0fd630e45538510a1cafbaf2601a5ac12eb2e9a6257cdf5392da1
MATLAB
624
18
function Jspec = computeSpectralJacobian(Jcell, epsilon) %COMPUTESPECTRALJACOBIAN Convert dOD/dmua to dOD/d[HbO,HbR]. % Jcell : cell array of Jacobian structs per wavelength with field .complete % epsilon : [L x 2] extinction coefficients matching Jcell order % Returns : [ (#meas*L) x 2N ] stacked spectral Jacobian...
ae1d1dfb474b431585afb3ec5bad29b10bb7b9d2b43d9f54663eb12b921e5855
MATLAB
624
24
function [fname] = clear_file_extension(fname, unwanted_ext) % See also CHECK_FILE_EXTENSION, ISFILEXTENSION. % % File: clear_file_extension.m % Author: Ioannis Filippidis, jfilippidis@gmail.com % Date: 2012.06.22 % Language: MATLAB R2012a % Purpose: remove the unwanted file name extension, if pr...
1bbb7ea54ec261c9d5494cd942a108b9d635f5a6914c4acb6891ad8a384fbd96
MATLAB
626
26
function mrs = ea_DPS_nifti_to_mrs(nii) if ischar(nii) nii = ea_load_untouch_nii(nii); end if ndims(nii.img) > 3 mrs = mrstruct_init( 'series3D', double(nii.img) ); else mrs = mrstruct_init( 'volume', double(nii.img) ); end mrs.vox = sqrt( sum((nii.mat*diag([1 1 1 0])).^2) ); mrs.edges = nii.mat; mrs.edg...
2bd7b3597280fc8f4b0f0f6419c7c67660b4ced16636fa6de28a367a1e621233
MATLAB
626
18
% List of open inputs % CAT12: Segmentation: Volumes - cfg_files % Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md addpath(spm_dir) nrun = 1; % enter the number of runs here jobfile = {[script_dir '/CBIG_MMLDA_segment_new_template_job.m']}; jobs = repmat(job...
6cf85da306325e48c03aa3fed45be20ea0fa5735f1408f1a4eb188fcd8d8b7c4
MATLAB
626
16
function[a,ROIs]=fixROIs(a,ROIs) [x1,y1,n1]=size(ROIs); %get the size of the ROIs X*Y*number of ROIs for k=1:n1 test=a{k};%get each individual structure try newROI=poly2mask(test.mnCoordinates(:,1),test.mnCoordinates(:,2),x1,y1);%use the real coordinates saved in 'a' to draw the ROI properly using it ...
74d1f8c8a2cd3bbf426c151edc09c52b59e327913238d5879c052d1d3abf9c16
MATLAB
626
23
function v = cvxtuple( varargin ) if nargin == 1, v = varargin{1}; switch class( v ), case 'struct', if numel( v ) ~= 1, error( 'struct arrays not permitted in cvx tuple objects.' ); end case 'cell', v = reshape( v, 1, numel( v ) ); ot...
e884f6ad22457d764d0048f905ea4195a4f15a3935d1e6906ce52222e5eeb6f6
MATLAB
626
16
function onoff = bool2onoff(bool) %BOOL2ONOFF Substitutes 'on' for non-zero and 'off' for zero input. % ONOFF = BOOL2ONOFF(BOOL) returns the string 'on' if BOOL evaluates as % logically true or the string 'off' otherwise. % % BOOL2ONOFF and ONOFF2BOOL improve readability for Matlab settings % (e.g., Han...
862e9d9b583aaeabb0234fc7d64ea167180d93c5e17a59484544620c606a50f5
MATLAB
628
11
%----------------------------------------------------------------------- % Job saved on 16-Feb-2016 13:52:08 by cfg_util (rev $Rev: 6460 $) % spm SPM - SPM12 (6470) % cfg_basicio BasicIO - Unknown % Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md %-----------...
7fed733e5deb6499e1bb05bfef31c9bed74c6daa9a9e75b414735a3bdc8daf9f
MATLAB
629
22
function kbd = KullbackLeiblerDivergence(P1,P2) % KULLBACKLEIBLERDIVERGENCE returns the similarity measure between two % probability distributions if abs(sum(P1) - 1.0) > 1e-5 || sum(~P1) P1(P1 == 0) = range(P1)*1e-6; P1 = P1/sum(P1); end if length(P1) == length(P2) N = length(P1); if abs(sum(P2) - 1) >...
60aa20468d08f28eda51d9bdfcfa82a3372631a5596ba84cbb04f6b454f86961
MATLAB
630
17
% Local Regression and Likelihood, Figure 6.3. % Author: Catherine Loader % % Local smooth of CO2 dataset. Estimate the main trend, % then use periodic smoothing of the residuals to estimate % the annual effect. % % A periodic smooth is specified by 'style','a'. % Note that year+month/12 scales the predictor to have a ...
f63e1240ed00bc6503c2c9ecf7bc8c0742cdc2c6d10cd5a70d0461bf640b7aaa
MATLAB
630
30
% so that stats toolbox is not used function cmbs = mycombnk( nums , k ) N = length(nums); T = N^k; cmbs = zeros( T , k ); for j=T:-1:1 n = j; for jj=1:k b = mod(n,N); n = n - b; n = n / N; cmbs( j , k-jj+1 ) = nums(b+1); cmbs( j , : ) = sort( cmb...
2748c9d66f68ab0838042cea62f89474e8a72c07f289f151115796742ca397e4
MATLAB
631
23
function y = residuals(fit,type) % Residuals (or a few other things) from a locfit() fit. % % Input arguments: % fit - the locfit() fit. % type (optional) type of residuals. Valid types are % 'dev' (deviance, the default) % 'd2' (deviance squared) % 'pearson'(Pearson) % 'raw' (observed - ...
5e766e672e6747268a25cd96a40d5bb2c4778786c58510188e42f8ac248a80e7
MATLAB
632
26
function tf = subStrCmp(C,S) % function tf = subStrCmp(C,S) % % Test if string S (S can be a cell array of strings) exists in C (C can be % cell array of strings). If both are cell arrays, results will have size % N x M where N is the length of cell array C and M is the length of cell % array S. if ~iscell(C), C = {C...
80d3e45e2febd3532450730afb0ea5854cd48d3d69a50a5ce690bc880c6ab0ff
MATLAB
632
33
% Entropy maximization % Joëlle Skaf - 04/24/08 % % Consider the linear inequality constrained entroy maximization problem % maximize -sum_{i=1}^n x_i*log(x_i) % subject to sum(x) = 1 % Fx <= g % where the variable is x \in \reals^{n} % Input data randn('state', 0); ...
91521e34be428af3839ecff7e66fed926e27484cf00b27e7f74314bdd47985a4
MATLAB
632
29
function vol=surfvolume(node,face,option) % % vol=surfvolume(node,face,option) % % calculate the enclosed volume for a closed surface % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % node: node coordinates % face: surface triangle list % % output: % vol: total volume of the enclosed space % % --...
bbf7ff1167ad7cedb9094fbae6b155e916768562cdd7523bfa2a7b72f15500f4
MATLAB
632
25
function obj=set_polar(obj,varargin) % set_polar Activate polar axes % % This command changes axes to polar form. 'x' then corresponds % to theta % Additional parameters: % 'closed': When plotting lines, connect the first % and last points when set to true % 'maxy': set the maximum y value (automatic scaling can't work...
8b86754c5091d4a9b8dde52726da4cdd82a79694a85c5128b48be17ebbd523ac
MATLAB
633
27
function lutEntry = createInteractionLUTs(ten,sinterp,Pstruc,fixedtissuemodel,thedir) verbose = false; % model model correlations fid = fopen(fullfile(thedir,'interactionLUTs.h'),'w'); fprintf(fid,'/********* DWscheme dependent model-model interaction ***********/\n\n'); bestpp = createModelModelLUT(ten,Pstruc,fixe...
13c7d01fc32e20e1218b3e4bc3f77cc48c27256ffe90e755c3160adffd9d4061
MATLAB
634
19
function [Xpix,Ypix,FrameRate]=findkeyparams() %use this function to get the FOV and the framerate of aquisition %you have to parse the XML file from thor. %this sucks and is definitely not elegent disp('Show me where the XML file is for any experiment from this set'); [matexpfile,matexppath]=uigetfile('*.*'); cd(...
854204b2b637d53bc783afdaa8cab1031c3d9f0e08b0afe39e7cf83dcdaf59ff
MATLAB
634
15
function [fdArray] = makeArray(fluordata,startIdx) % This function takes a struct of single vector multitrial data (such as % output from combineFluordata() or backgroundSubtract() with one ROI) % and combines trials into a single array. dirn = fieldnames(fluordata); for d=1:numel(dirn) % for every trial type ...
c7774f9cb98a171e269cadbd0e05105c5c08acd526daa825b7750594a0afb052
MATLAB
634
21
% subfunction checking the number of local copies % ----------------------------------------------- function ncopies = checkcopies_local(obj, arg); ncopies = 0; if isstruct(arg) for ilen = 1:length(arg) for index = fieldnames(arg)' ncopies = ncopies + checkcopies_local(obj, arg(ilen).(index{1}))...
f9056dc54c682859ff97c39e5db925d7def86245080c102d86b3a0caf993d828
MATLAB
634
15
function y = polyenv( varargin ) %POLYENV Evaluate the convex or concave envelope of a polynomial. % We have replaced this function with POLY_ENV to better match our % function naming conventions. Please start using it instead. warning( 'CVX:Renamed', [ ... 'The function "polyenv" has been renamed "poly_env"....
6d279581352208a48513b88bb476cbeb2ebc2d89a5b27deea5cdcbfabadb6c43
MATLAB
635
23
function uipatdir = ea_getpatients(options,handles) uipatdir = ea_uigetdir(ea_startpath, 'Please choose patient folder(s)...'); if isempty(uipatdir) return end if exist('handles','var') ea_load_pts(handles,uipatdir); if isfield(handles,'atlassetpopup') % not present in connectome mapper atlasset...
70acadc2ace9dd3b2c8b198c33eea74bb4f8337870258d4554893d09cf36318f
MATLAB
635
15
%.^ Array power. % Z = X.^Y denotes element-by-element powers. X and Y must have % compatible sizes. In the simplest cases, they can be the same size or % one can be a scalar. Two inputs have compatible sizes if, for every % dimension, the dimension sizes of the inputs are either the same or one % of them is...
71c9bcbc7e4e9cd042c907f10b73e6531cb6f0aaaeeb006d5f4b9ebd90cf25bc
MATLAB
635
25
function root = AddLFPTheta(root) % Adds filtered LFP signal (and phase, amplitude) to root.b_lfp % % For all root.b_lfp, adds theta filtered signal and theta phase vectors to % speed up further analysis if isempty(root.b_lfp) disp('No LFP data was loaded, adding all root.path_lfp'); root = root.Load...
760357a5666b640cd284516bb582cc1c7222eb7f6d1610536ebe5b6231f8222b
MATLAB
635
30
function slice=ea_contrast(slice,contrast,offset) % Enhance slice contrast if ~exist('contrast','var') contrast=1; end if ~exist('offset','var') offset=0; end if ~isa(slice,'double') slice=double(slice); end ispositive=ea_nanmin(slice(:))>=0; if sum(slice(:)~=0) slice(slice(:)~=0)=contrast*ea_nanzsc...
ce7e232246fdcd3bf021489073ee3cf5f2d577f77cb283abc79a5ed137b78d2e
MATLAB
636
28
function compilefma % compilefma - Compile C/C++ functions in FMAToolbox % Move to the 'FMAToolbox' directory, compile, and move back path = fileparts(which('FMAToolbox')); currentDir = pwd; cd(path); processDir; cd(currentDir); function processDir files = dir; for i = 1:length(files), if strcmp(files(i).name,'.')...
8926e68a1eb87edf55cf1c91fd9d922be8772069acb942c83286eaa321c6aeca
MATLAB
637
28
function uniqueStrings = uniqe_cell_string(c) % uniqe string from a cell-array containing only strings, ignores all % non-strings. nonStringCells = []; for i=1:length(c) % remove non-string cells if ~strcmp(class(c{i}),'char') nonStringCells = [nonStringCells i]; end; end; c(nonStringCells) = []; uniq...
58fa147650444b290188bceb8b6aa38fe45f7e9821850c7561bfb73405fb963b
MATLAB
638
23
% Normalize PET with respect to cerebellum grey matter. % Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md mri = MRIread(Mask_file); vol = mri.vol; mri_size = size(vol); mask_vol1d = reshape(vol, [mri_size(1)*mri_size(2)*mri_size(3) 1]); mri = MRIread(MRI_fi...
754ad2f08a50d98c9c4cae1fc9398f56d6d2cd44b619323ba0651ebe691173ae
MATLAB
638
16
function y = geomean( varargin ) %GEOMEAN Geometric mean. % GEOMEAN(X) = GEO_MEAN(X) = PROD(X).^(1/LENGTH(X)). We have replaced this % function with GEO_MEAN to better match our function naming conventions. % Please start using it instead. warning( 'CVX:Renamed', [ ... 'The function "geomean" has been ren...
964e3903cd8d17f0add780658edc67b7e5d4cf0762eb341f754b51b3323b0e6a
MATLAB
639
28
% Local Regression and Likelihood, Figure 8.1. % % Discrimination/Classification, simple example using % logistic regression. % % Author: Catherine Loader % % NEED: level=0.5 for contour plot. load cltrain; fit = locfit([x1 x2],y,'family','binomial','scale',0); figure('Name','fig8_1: logistic regression'); lfplot(fit,...
ab2454f1eaef9fb6d060a860775b0dffd06826ac5e938fadb6c42b1a519ed10b
MATLAB
639
23
function delF = dFcalc(rawF,baseIDX,varargin) if ~isempty(varargin) traceDim=varargin{1}; else traceDim=1; end if traceDim==1 if ~iscell(rawF) delF = rawF(:,baseIDX(1):end)-nanmean(rawF(:,baseIDX(1):baseIDX(2)),2); else delF = cellfun(@(c) c(:,baseIDX(1):end)-nanmean(c(:,base...
0f0f802fab552b81bb52087bb1c07bb6a2cc0729a7470dbb87e43d0f96e1b126
MATLAB
640
24
function dag = test_dag(A,varargin) % TEST_DAG Tests if a graph is directed and acyclic % % dag = test_dag(A) returns 1 if A is the adjacency matrix for a dag and % returns 0 otherwise. This function just calls topological order and % checks the output to determine if the graph is a dag. It is provided % merely for e...
34a48d7ce84bcf03c1aae4e086df5fdbdae154b412f9d1b1de48f49c6f13ef82
MATLAB
640
25
function plane=surfplane(node,face) % % plane=surfplane(node,face) % % plane equation coefficients for each face in a surface % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % node: a list of node coordinates (nn x 3) % face: a surface mesh triangle list (ne x 3) % % output: % plane: a (ne x 4) array, i...
7c6c991fcf7b9049182791525c37c7b8eb962cb258766d1b6430de30bae19959
MATLAB
641
28
% datlim() - return min and max of a matrix % % Usage: % >> limits_vector = datlim(data); % % Input: % data - numeric array % Outputs: % limits_vector = [minval maxval] % % Author: Scott Makeig, SCCN/INC/UCSD, May 28, 2005 function [limits_vector] = datlim(data) if ~isnumeric(data) erro...
91d490d79468ffdb44ca24c33fa8afdf254a313dd954451a1d335355a82748ad
MATLAB
641
19
% % Calculate protected exceedance probabilities using VBA toolbox % % pmp: shape (nModels x nSubjects) z counts or point posterior estimate % pep: shape (nModels) % %% Sequential HLM path_root = getenv('DECIDENET_PATH'); path_vba = fullfile(path_root, 'data/main_fmri_study/derivatives/jags/vba'); load(fullfile(path_vb...
efd89461afca3c7190aa8af4d204632398602b0e29a7c6daf17dbd14ff95dff3
MATLAB
641
21
function events = NewEvents(times,description) %NewEvents - Create events structure. % % USAGE % % events = NewEvents(times,description) % % times event timestamps % description (common) event description % Copyright (C) 2008-2011 by Michaël Zugaro % % This program is free software; yo...
38dc22789897c3d89975dcccbeb968869351e4f584466fde50c3eddbdc7ca8ee
MATLAB
642
35
function [X,V,E,F]=mesheuler(face) % % [X,V,E,F]=mesheuler(face) % % Euler's charastistics of a mesh % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % face: a closed surface mesh % % output: % X: Euler's charastistics % V: number of vertices % E: number of edges % F: number of faces % % -- this fu...
6d233ac56cc5e9921459134f4aba12db281bbe5fb766d235a523de2636740e49
MATLAB
642
19
function [Xpix,Ypix,FrameRate]=findkeyparams_newThor() %use this function to get the FOV and the framerate of aquisition %you have to parse the XML file from thor. %this sucks and is definitely not elegent disp('Show me where the XML file is for any experiment from this set'); [matexpfile,matexppath]=uigetfile('*....
b5d7507467d32ed4c07a9e7a472fe0e4602e916e2d5405b5a3fa9335ba76e804
MATLAB
642
14
function varargout = Surr_PseudoPeriodic(varargin) %SURR_PSEUDOPERIODIC (deprecated) Use surr_pseudo_periodic instead. % Surr_PseudoPeriodic has been renamed to surr_pseudo_periodic. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Sil...
c41c0f5892a129fd17b2bcf11e61db2443f1e5ada185ec7c14bfbf689ea6fd56
MATLAB
642
28
function Lambda=BarycentricCoordinatesTetrahedron(p1,p2,p3,p4,rx,ry,rz) % Edge Vectors r1 = (p2-p1); r2 = (p3-p1); r3 = (p4-p1); r4 = (p3-p2); r5 = (p2-p4); r6 = (p4-p3); % Jacobian determinant J = dot(cross(r1,r2),r3); % Lambda Gradient g1 = cross(r4,r5)/J; g2 = cross(r2,r3)/J; g3 = cross(r3,r1)/J; ...
fa83dd79643ea4d610a2dee091c59322e1bb247d28bf8c7a6cb79e53818f5c80
MATLAB
642
18
% [data, units, names] = ABF.load(filename) % Load abf files from Axon. % % This is currently a function draft and may only work for special cases % (e.g. one channel and gap-free mode). % 2020-03-02. Leonardo Molina. % 2023-11-09. Last modified. function [data, units, names, header] = load(filename) [da...
447ea42944bc9a184bf35f5b6af8bf569da76401722949a26ab4c6a0aa5b7773
MATLAB
643
25
function X = myPLS_norm(X,num_groups,subj_grouping,mode) % Normalization switch mode case 1 X = zscore(X); case 2 for iter_group = 1:num_groups idx = find(subj_grouping == iter_group); X(idx,:) = zscore(X(idx,:)); end case 3 ...
c33f64bc7398ab2ba00fd85dab71794ebc48694e85fa97158440c8f265f1cd9e
MATLAB
643
22
function epsilon = readExtinctionCoeffs(excoefTxtPath, lambdas) %READEXTINCTIONCOEFFS Read 2-column HbO/HbR extinction coefficients. % excoefTxtPath: text file with columns [lambda nm, eps_HbO, eps_HbR] % lambdas : vector of wavelengths to extract (e.g., [760 850]) % Returns epsilon as size numel(lambdas) x 2 T ...
12de57b0b75cbe8b2f2da8d1b176f984df0977684e13f75a9ed3c809d6fa317b
MATLAB
644
31
function [normX,Bx,By]=normalizepdf(X) % Forces the pdf of data to have a normal distribution using a data adaptive lookup table. % % [normX,Bx,By]=normalizepdf(X) % % normX=N(X) where N is an data adaptive monotonically increasing function. % normX will have zero mean and unit variance. % % Bx,By describes...
46bee3c975c4af7385aa73ad5d5fe4380a9109bd082b13c6a606bb510a1ebfc0
MATLAB
644
24
function h = createStopButton hmain = gcf; pos = get(hmain,'Position'); h = figure(539375677); %set(h,'WindowStyle','modal'); %set(handle,'title','FiberGT Progress Control'); set(h,'NumberTitle','off'); set(h,'resize','off'); set(h,'MenuBar','none') set(h,'ToolBar','none') set(h,'Visible','off') set(h,'Tag','stopbutt...
7b8cddcde84c815c3b12bfc58357b3eace9e2f692b560d6166f48314b4ecb243
MATLAB
644
18
function [adfreq, n, ad] = plx_ad_span(filename, ch, startCount,endCount) import CMBHOME.PLX2Mat.* % plx_ad_span(filename, channel): Read a span of a/d data from a .plx file % % [adfreq, n, ad] = plx_ad_span(filename, ch,startCount,endCount) % % INPUT: % filename - if empty string, will use File Open dialog % start...
d185733f02c9f0919fe110ff4c7f75c87c8ae49eec09d12c6da0ad4468dea026
MATLAB
644
21
function sedumi_binary_error() %Throw an error indicating the sedumi binaries are not available if exist('OCTAVE_VERSION','builtin'), software = 'Octave'; else software = 'Matlab'; end fs = filesep; mpath = mfilename('fullpath'); temp = strfind( mpath, fs ); mpath = mpath( 1 : temp(end) - 1 ); error( 'SeDuMi...
d3bdec94a5c511b6e317b20852d413c6f8ee0eae64951503a886fedefd6bedf3
MATLAB
644
21
function ea_reconstruction2acpc(options) load(options.subj.recon.recon, 'reco'); for iside=1:length(options.sides) side=options.sides(iside); for c=1:size(reco.native.coords_mm{side}(:,1),1) cfg.xmm=reco.native.coords_mm{side}(c,1); cfg.ymm=reco.native.coords_mm{side}(c,2); cfg.zmm=rec...
c1a34481ae6c9292540400912a7ca865897fc5000530ce59327bc6cd525fae14
MATLAB
645
19
function [ pc ] = control_analyze( e,s,b,TYPE ) globalsConditions; close all; data = dlmread(sprintf('e%dv%db%dc1/e%dv%db%dc1.log',e,s,b,e,s,b)); pc = length(find(data(:,COL_RESPONSE)==1))./size(data,1); directions = unique(data(:,COL_DIR)); % define directions for d=1:length(directions) sel = find(data(:,C...
580047dcb988f9467f5801cc5277d8fe8134d414d40558435b2f6e7d65bdbada
MATLAB
646
32
function f=rect(t,w,lag) % Function f=rect(t,w,lag) = Rect(t-lag/w) % % w is the rectangle function width in time % lag is the location of the center of the rectangle % if lag is a vector, multiple rectangles with lags will be generated ff=zeros([length(lag) length(t)]); fe=1e2; %if (t(1)-lag>=0), % for ...
9330f004d4ac0306e5209d4caa46290ccbdbcb34f230c75b31fd387f67490f50
MATLAB
646
25
function plotAreaROIsCCF(dorsalMaps, allROIs, areas) % Plots the ROI centroids colored by areas % Figure allenMapSMc(dorsalMaps) % Creates figure by itself % Paper ready figure/axis formatting panelwidth = 2.25; panelheight = 3; leftoffset = 0.5; bottomoffset = 0.5; formatFigure(gcf, panelwidth, panelheight, leftoffs...
95e3d44f14e110457c9fb38d7afd7761d0079031344887e3d94f4e5c0979cbb2
MATLAB
646
22
function x = cvx_accept_convex( x ) global cvx___ if isa( x, 'cvx' ), t = cvx_vexity( x ) > 0; if any( t( : ) ), prob = cvx___.problems(end).self; if all( t ), src = x; dst = newtemp( prob, size( src ) ); x = dst; else src = x( t...
552194c025d80f5d9545f85ecd846d86766e0f9b926cd53f30757f971c34ec8f
MATLAB
647
22
function x = cvx_accept_concave( x ) global cvx___ if isa( x, 'cvx' ), t = cvx_vexity( x ) < 0; if any( t( : ) ), prob = cvx___.problems(end).self; if all( t ), src = x; dst = newtemp( prob, size( src ) ); x = dst; else src = x( ...
5f9131627ed85e5436cb591e6cf35d97e3e170d862e0a4123ee24956cf3e2886
MATLAB
647
17
% Local Regression and Likelihood, Figure 6.3. % Author: Catherine Loader % % Local smooth of CO2 dataset. Estimate the main trend, % then use periodic smoothing of the residuals to estimate % the annual effect. % % A periodic smooth is specified by 'style','a'. % Note that year+month/12 scales the predictor to...
9e711a779185c0236129b689c10e688b121a4c59f0b7d6c3a66ad5600bb2e5cd
MATLAB
647
25
function x = touch( p, x, iseq ) global cvx___ if nargin < 3, iseq = false; end if isa( x, 'cvx' ), p = p.index_; b = cvx_basis( x ); y = any( b, 2 ); if iseq, cvx___.canslack( y ) = false; end v = cvx___.problems( p ).t_variable; nv = size( v, 1 ); ny = length( y ...
d35ca25d82e27b683cd9d9d579ef7a76a9647cbffe76461ec30b444aebcefeb2
MATLAB
647
27
% Weighted analytic center of a set of linear inequalities % Joëlle Skaf - 04/29/08 % % The weighted analytic center of a set of linear inequalities: % a_i^Tx <= b_i i=1,...,m, % is the solution of the unconstrained minimization problem % minimize -sum_{i=1}^m w_i*log(b_i-a_i^Tx), % where w_i...
234175603b91a02feeada582a715bbcb2f425574f9168730fc099ff4f82e8d9b
MATLAB
648
16
function z = mpower( x, y ) % Disciplined convex/geometric programming information for MPOWER (^): % The CVX version of the matrix power function Z=X.^Y supports only % the case where X and Y are scalars. In such instances, the rules % are identical to those outlined in the help for CVX/POWER. if len...
8ae866b4be2cf25f329159bfc4f93e7dba4d0df0bbda91cc9ff14af1cc786088
MATLAB
649
31
function r = CBIG_find_maxLikeRun(kDir) dirList = dir([kDir 'r*']); maxLogLike = -inf; figure; hold on; for idx = 1:numel(dirList) runName = dirList(idx).name; try logLikes = load([kDir runName '/likelihood.dat']); logLike = logLikes(end, 1); runID = str2num(runName(2:end)); ...
c4fa8caab3cb10a5d7347d27ab1b9bcdb3f7a068ccaa91de168f1b6f81b9f713
MATLAB
649
29
function [ X ] = nanInterp( X, method) % Interpolates all Nan's in the input vector, according to the second input % argument "method". Defaults to nearest neighbor interpolation. if ~exist('method','var'), method = 'nearest'; end; if all(isnan(X)) X=zeros(size(X)); return elseif isscalar(X)||isempty(X) ...
d3f38258dcdc2bf57d39ace6b8b46b7473999e231738ae564a63ff0e4221faf6
MATLAB
649
27
function v = cvx_classify( x ) % Classifications: % 1 - negative constant % 2 - zero % 3 - positive constant % 4 - complex constant % 5 - concave % 6 - real affine % 7 - convex % 8 - complex affine % 9 - log concave % 10 - log affine % 11 - log convex monomial % 12 - log convex posynomial % 13 ...