sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
45d2f9259d4fc48f0c452514a88f3a52e170950859f4b554de124089411d3c72
MATLAB
1,179
33
function worked = seek(vr,fnum) %WORKED=SEEK(VR,FNUM) % Attempts to go to frame number FNUM in video VR. Returns 0 if the user % attempts to seek past the end of the video. For most video plugins, the % first frame is 0 (not 1), thus in the following example, both IM1 and % IM2 should be the same for most pl...
b58b48a2972976111f6217720c5a1aec9adc8805657b1e7a8906209d980697e2
MATLAB
1,179
44
function [curv] = write_curv(fname, curv, fnum) % [curv] = write_curv(fname, curv, fnum) % % writes a curvature vector into a binary file % fname - name of file to write to % curv - vector of curvatures % fnum - # of faces in surface. % % % write_curv.m % % Original Author: Bruce Fischl % CVS Revision Info...
09a22097e4e884c33fbab04abda2241de6105207dda2f023e4b9d44a401bb2fc
MATLAB
1,180
36
% display() - display an EEG data class underlying structure % % Author: Arnaud Delorme, SCCN, INC, UCSD, Nov. 2008 % Copyright (C) 2008 Arnaud Delorme, SCCN, INC, UCSD % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the ...
300ef4ad1fc2110594cd266a028ceb39a2854bb5d61ec9bfee9add48462c28a1
MATLAB
1,180
29
function xmax=findpeaks(data,threshold) % Helper function to find peaks in a given continuous valued time series x % Usage: xmax=findpeaks(data,threshold) % Input: % data (data in time x channels/trials form or a single vector) % threshold (if specified returns locations of peaks at which data exceed...
a24d5543240db19456cb36a59d49e7692796d4263d45da3e80293dd7772fdc6d
MATLAB
1,180
41
function [mintime, maxtime]=minmaxsptimes(data) % Find the minimum and maximum of the spike times in each channel % Usage: [mintime, maxtime]=minmaxsptimes(data) % Input: % data (spike times as a structural array of multiple dimensions e.g. channels; channels x trials; % can also accept a 1d matrix of spi...
b7ed6fda588a1229d53813860b4aaffb2119ad4684e7bfb5763089f782c9c511
MATLAB
1,180
48
function handles = featuredetect_init(handles) %%%%%%%% initialize handles, set default value %%%%%%%%%%%%%%%%%%% close(figure(4)) % manual dendritic tracing close(figure(15)) % manual spine feature close(figure(7)) % cross-session registration % clc para_default = defaultparameter; handles.savingflag = 0; % handles...
f0f1bba739c65ab5df645634905a3860de7048b7fd0376cfe8cbb29b4573f1f5
MATLAB
1,180
39
% l1 trend filtering % Written for CVX by Kwangmoo Koh - 12/10/07 % % The problem of estimating underlying trends in time series data arises in % a variety of disciplines. The l1 trend filtering method produces trend % estimates x that are piecewise linear from the time series y. % % The l1 trend estimation problem ca...
f395064737d50f888c42d500d1a5a48468a58c188ef92ba7d7513384c6eff349
MATLAB
1,180
37
function max_card_match=test_matching(A,m,varargin) % TEST_MATCHING Tests if a matching is maximum cardinality % % max_card_match=test_matching(A,m) returns 1 if m is a maximum cardinality % matching on A. % % This method works on undirected graphs (symmetric matrices) and ignores % edge weights. % The runtime is O...
1cf51c376c69db7e15ba5123830a7bccd4fec09e41f493acbc543838b4bedf77
MATLAB
1,181
40
% Undo the flipping and rotations performed by xform_nii; spit back only % the raw img data block. Initial cut will only deal with 3D volumes % strongly assume we have called xform_nii to write down the steps used % in xform_nii. % % Usage: a = load_nii('original_name'); % manipulate a.img to make array...
8304ff4ecbc6fbddefada9fa33a7c98962c7077f222f22f3c3700cd921ae2eac
MATLAB
1,181
35
function y = log_sum_exp( x, dim ) %LOG_SUM_EXP log(sum(exp(x))). % LOG_SUM_EXP(X) = LOG(SUM(EXP(X)). % % When used in a CVX model, LOG_SUM_EXP(X) causes CVX's successive % approximation method to be invoked, producing results exact to within % the tolerance of the solver. This is in contrast to LOGSUMEXP_S...
aad10cd30dfcd0c6692a1f828ea3f3e03464f55bc0779f14140d9b90b59e78e7
MATLAB
1,181
58
function kappa = circ_kappa(alpha,w) % % kappa = circ_kappa(alpha,[w]) % Computes an approximation to the ML estimate of the concentration % parameter kappa of the von Mises distribution. % % Input: % alpha angles in radians OR alpha is length resultant % [w number of incidences in case of binned ...
1ff6fe4652895f6a4d1b6e87d5892d9d4cd69a34b948dbce5654c5833ed41d83
MATLAB
1,182
33
function fn = step(vr, delta) %WORKED=STEP(VR,DELTA) % Moves the frame counter by DELTA frames for video VR. This is a % generalization of NEXT. Returns 0 on an unsuccessful STEP. Note that % not all plugins support stepping, especially with negative numbers. In % the following example, both IM1 and IM2 shou...
313c7c9a8071db13c93361bdae4501ca40d7b97a7915b9d68cf31629eca97268
MATLAB
1,182
43
%%********************************************************* %% lmifun2: generate SDP data for the LMI constraint %% of the form: %% %% [A*P*B'+B*P*A' C*P*D'] %% [D*P*C' 0 ] %% %% P is the variable, P is symmetric. %% %%********************************************************* function Avec...
7f2b882e87e79e5bc8dfe76a000cd1b171f08d2247aef3777fcb6b7632359023
MATLAB
1,182
34
function CBIG_reorderNuisance(brainListFile, nuisanceVarsFile, concatOrderFile) % CBIG_reorderNuisance(brainListFile, nuisanceVarsFile, concatOrderFile) % % Helper function that reorders the lines in nuisanceVars so that now they % match the line order of concatOrder. Before this function, they match the % line order ...
90e78dbd453d66552c260293b548d07bf7001cc0cfccd70514bd6cee22d1c808
MATLAB
1,182
30
%% CANlab_help_examples second-level batch scripts example % % This code downloads sample data from figshare.com and contains basic % steps for running a standard batch set of analyses on 2nd-level fMRI data % (contrast images). % %% The dataset % The dataset contains fMRI contrast images from 59 participants, for bo...
c66704e8832bdf57b45eb34b93efcb52000c94d641bb7176dd04f5812618b034
MATLAB
1,182
27
function colPlot3D(lines,col,csc) N = 256; cmap = autumn(N); cmap = hot(N); lw = 1; delete(findobj(gca,'tag','fibplot3D_colplot3D')); for k = 1:length(lines), fib = lines{k}'; fib = fib'; if size(fib,1) > 1, sp = 1; if nargin == 1, dif = (fib(...
7ac9014fa60152c43151ec8a90e09dfb6d466cf59592a64b39ef4a3e86ccb420
MATLAB
1,183
30
function [ad] = PL2AdSpan(filename, channel, startCount, endCount) % PL2AdSpan(filename, channel, startCount, endCount): read a span of a/d data from a .pl2 file % returns a/d values in millivolts % % examples: % % ad = PL2AdSpan(filename, channel, startCount, endCount) % ad = PL2AdSpan(filename, ...
1218bc47323280e30aa8b369396edbab179c4a36423fdfa689d180bbec1c6815
MATLAB
1,184
57
function CBIG_fitGLM_hypoTest(rid_prob, rid_icv_vol, subCol, corCol) % CBIG_fitGLM_hypoTest(rid_prob, rid_icv_vol, subCol, corCol) %--------------------------------------------- Fit GLM % % Written by CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md % Construct X and y noSubs = siz...
673835d4c43065a19a06916f677dea282ecd943b37b48e788304db39d8f381e0
MATLAB
1,184
56
function imat=ea_gencontrastimage(imat,howto) switch howto case 2 %% use raw tra version imat=squeeze(imat(:,:,:,1)); case 3 %% use smoothed tra only imat=squeeze(imat(:,:,:,1)); imat = smooth3(imat,'gaussian',3); case 4 %% use smoothed mean of tra and c...
db8ecbd036abbc4f206d609546f00a767b44f789668e4554c6ea2db3850c62c4
MATLAB
1,184
26
function rval=rtest_7_karsi % Test the flow-graph that Karci identified as causing a problem with the % min-cut computation. The min-cut value should always be equal to the % max-flow value. G = [0 46 0 46 0 0 0 0 0 0 461; 0 0 46 0 46 0 0 0 0 ...
de816cee37dd8bec385b876423784d193a73aae8493154012fd968ad4c774e38
MATLAB
1,184
27
function scalingFactor = readOEMetaFile(metaFile) % JF % read open ephys meta file and extract scaling factor (bit_volts) value % ------ % Inputs % ------ % metaFile: string, full path to meta file (should be a structure.oebin file) % ------ % Outputs % ------ % scaling factor: double, scaling factor value to convert r...
f01ebf3ee08cc844290ffaab089c280d95759439fcfe26b2a4d9068ee0ac7425
MATLAB
1,184
55
function plotMetricPDFAreas(allROIs, metricField, areas, cmap, minmax, kdeBW) % Creates KDE plots for metric value distributions separated by area if nargin < 5 minmax = []; end if nargin < 6 kdeBW = []; end % Check size matches assert(length(areas) == size(cmap,1)) % Create figure fig; hA = gca; hold on; ...
a0f7010f0978717d29b2e003ab9da4c57e472b66695e6a916af0934db2e44c01
MATLAB
1,185
37
%% Calculate the arc length of an interval on a parameterized polynomial in R3 % Params: % polyCoeff - coefficient matrix % lowerLimit % upperLimit % % lowerLimit / upperLimit parameters can take scalar as well as vector inputs, % in the vector case arc lengths are returend for all pairs of intervals % betw...
524a3b6beed8a22869e4cbc8227e5689af3c591e749ddd84040cfd415ef8f4b1
MATLAB
1,186
28
function data_out = Trinh_makecontinData(data_in, conditions,refrainonsets,triallength,prestim) %% Function for segmenting the data and appending them into continous data stream % segments the condtitions and appends them to make continous data streams % insert the trial info for the needed conditions % Trinh nov22...
8d0ffc9887efb549ada921c4c4e17c3065ff7403e7413c585b947303f9208638
MATLAB
1,186
17
% Helper functions for FMAToolbox. % % Parameter testing. % % isstring_FMAT_FMAT - Test if parameter is an (admissible) character string. % isdscalar - Test if parameter is a scalar (double) satisfying an optional list of tests. % isdvector - Test if parameter is a vector of d...
fcab2e732a92dff2d565a7c6e5b90c5c9693e967fd0fcdb0cb12aa68a5b5aeb3
MATLAB
1,186
32
function y = sum_log( x, dim ) %SUM_LOG Sum of logarithms. % For vectors, SUM_LOG(X) is the sum of the logarithms of the elements of % the vector; i.e., SUM(LOG(X)). If any of the elements of the vector are % nonnegative, then the result is -Inf. % % For matrices, SUM_LOG(X) is a row vector containing the ap...
001994e4ea961d7590e995b19b81e133ff8587f18234465db26ce42e75ac5630
MATLAB
1,187
56
function mstruc = createCM_GT(ftr,ROI,Nsz,centroids) display('building connect mat'); lens = single(cellfun(@len,ftr.curveSegCell)); fibs = ftr.curveSegCell; rois = ROI.dataAy; T = inv(ROI.edges)*ftr.hMatrix; terms = cellfun(@(x) [x(1,:); x(end,:)],fibs,'UniformOutput',false); terms = cat(1,terms{:})'; terms = (T*...
9846596c705011ffd587230f8ccaab5644a6ada2a06ea4f027005e4e99dd804a
MATLAB
1,187
43
function coeffs = calc_eigendecomposition(data, eigenvectors, method) % calc_eigendecomposition.m % % Decompose data using eigenvectors and calculate the coefficient of % contribution of each vector % % Inputs: data : data [MxP] % M = number of points, P = number of independent data % ...
a3a13c696479b2f33f9afd2e885694125f9c1bac40855b89db439241feb646b5
MATLAB
1,187
36
function [IDout,group]=... inf_determineCVgroups(IDin,k) % This file is a part of the MDSINE program. % % MDSINE: Microbial Dynamical Systems INference Engine % Infers dynamical systems models from microbiome time-series datasets, and % predicts biologically relevant behaviors of the ecosystems. % Copyright (C) 201...
be79f8ebe096883909ce3ff4170db84aae1a24d6e11e8e804f131a7c05dd24e7
MATLAB
1,187
40
function plotPrevalenceMapCCF(dorsalMaps, allROIs, subpop, smoothSD, color) % Creates a binned and smooth map of subpop proportions based on the % field propField % Figure allenMapSMc(dorsalMaps, [-3.6, 0, -2, 3]) % Creates figure by itself % Plot params xLimits = [-4 0]; yLimits = [-2.35 3.3]; gridRes = 50; % Creat...
ea03ea23278757a73c359a67f7a762e5c4b0e348f969749b436aa19a673a4c7a
MATLAB
1,187
36
function uid = root(tree) % XMLTREE/ROOT Root Method % FORMAT uid = root(tree) % % tree - XMLTree object % uid - UID of the root element of tree %__________________________________________________________________________ % % Return the uid of the root element of the tree. %________________________________________...
0626e1c902e388a394f13ef47280dc9296e35f9896c9c30db463974489776a23
MATLAB
1,188
33
%% A Hierarchy of Layouts Example % This example shows how to use layouts within other layouts to achieve % more complex user interface designs with the right mix of variable and % fixed sized components. % % Copyright 2009-2014 The MathWorks Ltd. %% Open the window % Open a new figure window and remove the toolbar an...
1c46dfb4d19542c62927111fbd3a736770ddc430fc782a7a549598c772d5ac9f
MATLAB
1,188
36
function handles = selectsinglefiles(handles) if handles.datatype == 1 [filelist, filepath, cCheck] = uigetfile({'*.tif'; '*.tiff'}, 'Select Movies To Be Processed'); if (cCheck~=0) handles.filepath = filepath; if ~isempty(filelist) if ~isempty(filelist) handles.filen...
eb92ff290d124c60336aa80bf4c7cbbecc13b0d389bf5d116ff04cd166f7ac3b
MATLAB
1,188
28
function apref = ea_antspreset_ants_wiki(cmd) % from https://github.com/ANTsX/ANTs/wiki/Anatomy-of-an-antsRegistration-call if ischar(cmd) % 'query' mode, return the name of the preset apref = 'ANTs Anatomy of an antsRegistration call'; return end apref.rigid.gradientstep = '0.1'; apref.rigid.metric = 'MI'; a...
710190ad0672ff834475955c26383cdf19162acb1aea571c9985b20c437102e8
MATLAB
1,189
36
function tree = delete(tree,uid) % XMLTREE/DELETE Delete (delete a subtree given its UID) % % tree - XMLTree object % uid - array of UID's of subtrees to be deleted %__________________________________________________________________________ % % Delete a subtree given its UID % The tree parameter must be in ...
1b3c2df43b02b8702f90070b204f646ad2251f2b410b5bdcbf129bbf05b745bb
MATLAB
1,190
52
%isradians - Test if parameter is in range [0,2pi] or [-pi,pi]. % % USAGE % % test = isradians(x) % % x array to test (NaNs are ignored) % % OUTPUT % % range 0 if uncertain (issues a warning) % 1 for [-pi,pi] % 2 for [0,2pi] % SEE ALSO % % See als...
340a393295a70edceca72061c3817f8419dc4722bc8d047d607470eb2e3bbd78
MATLAB
1,190
36
function countSpots(imPath, wellPath, sgeID) d = dir(fullfile(imPath, '*.mat')); fname = d(sgeID).name; load(fullfile(imPath, fname)); x = strsplit(fname, '_'); jsonname = fullfile(wellPath, x{1}, 'scalefactors_json.json'); w = jsondecode(fileread(jsonname)); R = ceil(w.spot_diameter_fullres/2); tbl = ...
b5386446e861be507079719e71892700292267b5be0a15ee74e18a146966341c
MATLAB
1,190
30
addpath('.'); addpath('helperFunctions'); clear all; close all; clc; globalsMain; cd('../03_data/01_raw_data/'); for s=1:numel(subjects) cd(num2str(subjects(s))); for e=1:2 cd(exp{e}); % control folder = dir(sprintf('e*v%db*c1',subjects(s))); for f=1:numel(folder) ...
67a4d1a429a50ad77497b55393167ecb89cf2ea938a55ced35ceaa40ea7abf24
MATLAB
1,192
21
function outinfo = cifti_diminfo_dense_get_surface_info(diminfo, structure) %function outinfo = cifti_diminfo_dense_get_surface_info(diminfo, structure) % Get information on how to map cifti indices to gifti surface vertices. % % >> leftinfo = cifti_diminfo_dense_get_surface_info(cifti.diminfo{1}, '...
230325f58512bf5c9e2e492bf1425b2ace561d501fa51645fd23e25d9c819278
MATLAB
1,193
42
% Section 4.3.1: Compute and display the Chebyshev center of a 2D polyhedron % Boyd & Vandenberghe, "Convex Optimization" % Joëlle Skaf - 08/16/05 % (a figure is generated) % % The goal is to find the largest Euclidean ball (i.e. its center and % radius) that lies in a polyhedron described by linear inequalites in this...
9c36c6a37de2f61a3c62552a0472002392e1cc0849c0c60989fb322adb48cc3a
MATLAB
1,193
49
function yy=ring2(inmat,rrad,rwid,xy0,ang) % Usage ... y=ring2(inmat,rad,wid,xy0,ang) % % xy0=[0 0] will place ring in the center of the image floor(sz/2) if ~exist('ang','var'), ang=0; end; if ~exist('xy0','var'), xy0=[]; end; if isempty(xy0), xy0=[0 0]; end; if length(inmat)==2, yy=zeros(inmat); else, yy=...
8f7903bf59cd27270a4aded96fe47842a6ba079280cc3a821e38e837c96c9ca2
MATLAB
1,194
37
function handles = input_refresh(handles, dataID) f_wait = waitbar(0.5,'Data loading'); % load data handles = loadtrace(handles, dataID); if ~isempty(handles.im_norm) %%%% show spine rois handles = get_spineROImask(handles); roi_mask = handles.roi_mask; % roi_mask = zero...
9443e33049901138d62fef9d7ee3baff6eb824b2c4dcc00fe18701400138e226
MATLAB
1,194
44
function create(obj,wrt) % Create a NIFTI-1 file % FORMAT create(obj) % Write out the header information for the nifti object % % FORMAT create(obj,wrt) % Also write out an empty image volume if wrt==1 %__________________________________________________________________________ % Copyright (C) 2005-2013 Wellcome Trust C...
a2c1c2c78e4dd042c89c5163e6105c6174af9d96f0d36b87fe6634679691241b
MATLAB
1,194
26
function [n,dspchans] = plx_chanmap(filename) import CMBHOME.PLX2Mat.* % plx_chanmap(filename) -- return map of raw DSP channel numbers for each channel % % [n,dspchans] = plx_chanmap(filename) % % INPUT: % filename - if empty string, will use File Open dialog % OUTPUT: % n - number of spike channels % dspchans ...
ef118fcf3eedc5636155797a9c4106110bb09f1cdb1936ed7abd514927705568
MATLAB
1,194
32
function cvx_save_prefs( varargin ) %CVX_SAVE_PREFS Saves current CVX settings for future MATLAB sessions. % CVX_SAVE_PREFS saves the the current global CVX settings to a special % prefences file (stored in the "prefdir" directory). This enables CVX to % remember your preferred settings (solver, precision, etc...
8c4463904c9ca678734fb6da9877923eb674b749f1edc5017009416bae40c43c
MATLAB
1,195
36
function [interp_cmap]=interpolate_cbrewer(cbrew_init, interp_method, ncolors) % % INTERPOLATE_CBREWER - interpolate a colorbrewer map to ncolors levels % % INPUT: % - cbrew_init: the initial colormap with format N*3 % - interp_method: interpolation method, which can be the following: % 'nearest' - n...
fcd79ef9bf38d06e0fcb4b950d92edfacb016892f28def00b6304bb44ff71d0c
MATLAB
1,195
46
function kappa = Concentration(angles) %Concentration - Estimate the concentration parameter for circular data. % % Estimate the concentration parameter for circular data assuming a Von Mises distribution. % Uses the approximation described in "Statistical Analysis of Circular Data" (Fisher, p. 88). % % USAGE % % ...
a1e4f26238af0815a9525f82a5afe2554f86aed8b172ce58fb2d486ef63c5c35
MATLAB
1,196
34
figure; subplot(1,2,1) hold on; xvals= 0:.01:175; [yvals,pval] = linear_fit_eval(cday(1:16), mbeh(1:16,1),xvals); plot(xvals,yvals,'c-','linewidth',2) xvals= 200:.01:365; [yvals,pval] = linear_fit_eval(cday(21:28), mbeh(21:28,1),xvals); plot(xvals,yvals,'c--','linewidth',2) plot(cday([1:16 21:28])',mbeh([1:16 21:28],1)...
3f3e8dfcea01bb293c5cd620f3db2212a436210e3ee4ef6f0c7dd25a04267724
MATLAB
1,198
27
function [apoe2, apoe4] = CBIG_MMLDA_get_apoe(APOERES_file, rid) % [apoe2, apoe4] = CBIG_MMLDA_get_apoe(APOERES_file, rid) % % Get apoe2 and apoe4 gene number for each subject. % % Input: % - APOERES_file : path of APOERES.csv spreadsheet % - rid : cell array of rid for subjects % % Output: % - apoe2 ...
5b4d5302c47bd75c29308bea59ea150e291d1e82ae6b550fbb4e91fe2a315e5f
MATLAB
1,198
22
function output = SOFAappendText(Obj,attribute,new) %SOFAappendText % % output = SOFAappendText(input,new) appends the new text to the % attribute using the correct SOFA separators. If the attribute is empty % or non-existing, the output will be the new text only. % % SOFA API - function SOFAappendText ...
927d511ab0437ed4eacd4bcd384558346e89ff51ddb610c595fdf1de3519938b
MATLAB
1,198
28
function GCO_SetNeighbors(Handle,Weights) % GCO_SetNeighbors Set (weighted) pairwise connectivity of all sites. % GCO_SetNeighbors(Handle,Weights) determines which sites are neighbors % and thereby have a SmoothCost associated with them. Weights is a % sparse NumSites-by-NumSites matrix, where Weights...
d3113b3c8afa341d5aa72eec8e6decea847bb721ac8b2b34bf09f61b6834249b
MATLAB
1,198
45
function y = rms(x, dim) %RMS Root mean squared value. % For vectors, RMS(X) is the root mean squared value in X. For matrices, % RMS(X) is a row vector containing the RMS value from each column. For % N-D arrays, RMS(X) operates along the first non-singleton dimension. % % Y = RMS(X,DIM) operates along the ...
50c542965325f341149943bfea9421cf077ce3c0f62be64ef1c73062a6e1f218
MATLAB
1,199
37
function amyloid = CBIG_get_amyloid(rid_of_interest) % amyloid = CBIG_get_amyloid(rid_of_interest) % Fetch amyloid from .csv files % % Input: % - rid_of_interest: the RID's of subjects of interest % % Output: % - amyloid: 1st col is RID, 2nd col is (dummy) VISCODE, 3rd is (dummy) % EXAMDATE, 4th is value % %...
a3f885be1740d57a56c7cfdc6a052c3c7b137b928e748c51657f0dc8fff78264
MATLAB
1,199
45
function cvx_optval = norms_largest( x, k, dim ) %NORMS_LARGEST Computation of multiple norm_largest() norms. % NORMS_LARGEST( X, K, DIM ) provides a means to compute the largest-k % norms of multiple vectors packed into a matrix or N-D vector. This is % useful for performing max-of-norms or sum-of-norms calcula...
e7bff0843f2da3ca3b031446c7e233280feed5dc63b5d57c6e67bacf552913b0
MATLAB
1,199
36
function [xsmooth, Vsmooth, VVsmooth_future] = smooth_update(xsmooth_future, Vsmooth_future, ... xfilt, Vfilt, Vfilt_future, VVfilt_future, A, Q, B, u) % One step of the backwards RTS smoothing equations. % function [xsmooth, Vsmooth, VVsmooth_future] = smooth_update(xsmooth_future, Vsmooth_future, ... % xfilt,...
3b304e3431d291dabf42bc4d39713b165b30cca20c095044cd809d871d0397b6
MATLAB
1,200
35
function CBIG_MMLDA_matrix2doc(output_filename, input_mtx) % CBIG_MMLDA_matrix2doc(output_filename, input_mtx) % % This function convert input matrix to output document which is an input of % CBIG_MMLDA_est.sh or CBIG_MMLDA_inf.sh. For the docmument format, please refer to % $CBIG_CODE_DIR/external_packages/mmlda-c-di...
6a344681471164c2d68d2f358d92e851a8aab20f242a55796cd4fc72eec96bbe
MATLAB
1,200
49
function varargout= make_connected(A,varargin) % MAKE_CONNECTED Add edges to construct a connected graph % % C = make_connected(A) generates a new graph C with additional edges % to make C connected. % % [ei,ej] = make_connected(A) returns the additional edges instead. % % ... = make_connected(A) takes a set of % key...
863b5901155d41673616405724300ea87f52e842533ff94ae48b03161acdb996
MATLAB
1,200
26
function ea_add_sweetspot(~,~,leadgroup,resultfig) % small function to open ea_discfiberexplorer. lead group can be a path to % either lead group analysis file or saved fiber explorer. if ismember('M', who('-file',leadgroup)) % Add new discfiber analysis exp = ea_sweetspotexplorer(leadgroup,resultfig); sweetId...
32c8df1b7c2879515201e97d9122d2ac73b18a77d66dc3c7021b6811356d1c6f
MATLAB
1,201
18
% Chapter 6: Approximation and fitting % % deadzone.m - Section 6.1.2: Residual minimization with deadzone penalty % fig6_15.m - Figure 6.15: A comparison of stochastic and worst-case robust approximation % fig6_19.m - Figure 6.19: Polynomial fitting % convex_interpolation.m - ...
584cdc29d8824fd681a282c7cd2692aea87651369d692f6365975451d9847031
MATLAB
1,201
40
function [newnode,newelem]=mergesurf(node,elem,varargin) % % [newnode,newelem]=mergesurf(node1,elem1,node2,elem2,...) % % merge two or more triangular meshes and split intersecting elements % % author: Qianqian Fang <fangq at nmr.mgh.harvard.edu> % % input: % node: node coordinates, dimension (nn,3) % elem: ...
58b2be69cf23493a3a637754f3d6b86ff1b3ca21c07f72156880b742df1a4ad4
MATLAB
1,201
24
function cvx_expert_check( fname, varargin ) global cvx___ if cvx___.expert, return; end if ~isempty( varargin ) && ~any(cellfun('isclass',varargin,'cvx')), return; end url = [ 'file:///', cvx___.where, cvx___.fs, 'doc', cvx___.fs, 'advanced.html#the-successive-approximation-method' ]; fprintf( 1, [ 'CVX Warning:\n',...
6a1b7a7c5a7fff4b0e4763cc3f49db3b8bc35cfbab253ae984e3d2d106e83c1e
MATLAB
1,201
42
function dPrime = cellFRA2dPrime(FRA,varargin) p = inputParser; addRequired(p,'FRA',@ismatrix) addOptional(p,'nAmpl',3,@(x) isnumeric(x) && isscalar(x)); addOptional(p,'nFreq',28,@(x) isnumeric(x) && isscalar(x)); addOptional(p,'nBoots',1000,@isnumeric); parse(p,FRA,varargin{:}); FRA = p.Results.FRA; boots = ...
bb306c7fa8d696ed9d8733d8b5b5db713a10481f4dc572a61466dc7839935f7a
MATLAB
1,201
42
function [L, Lratio, df] = L_Ratio(Fet, ClusterSpikes, m) % [L, Lratio] = L_Ratio(Fet, ClusterSpikes) % % L-ratio % Measure of cluster quality % % Inputs: Fet: N by D array of feature vectors (N spikes, D dimensional feature space) % ClusterSpikes: Index into Fet which lists spikes from the cell ...
007ddbd6581dbc6600de9cce5a8672d6568b6d3125eb573f368ca6ddb9f4cf7e
MATLAB
1,202
42
function [trace_noBAP, coef] = BAPremove_auto(spinedff, dend_dff, inputcoef) x0 = dend_dff; y0 = spinedff; coef = []; Maxiter = 5; Maxtolt = 0.05; if nargin<3 inputcoef = []; end if isempty(inputcoef) f = fittype('a.*x', 'dependent',{'y'}, 'independent', {'x'}, 'coefficients',{'a'}); xx = linspace(min(min(...
979862c09e97f04b02e1592def502306b87dba8ec31cc4b2b2153aa6d540bc6a
MATLAB
1,202
39
function IMR = calcImr(m,im) %CALCIMR Calculates the Ideal Mask Ratio (IMR) % % IMR = IOSR.BSS.CALCIMR(M,IM) calculates the ideal mask ratio (IMR) from % the calculated mask M and ideal mask IM. Masks can be logical or % double, but must only contain values in the interval [0,1]. % Copyright 2016 University o...
2be3c92095c54fa4cae109cae04475b6aeecd9eef1d55ac2cc7159f6d8789f56
MATLAB
1,203
33
function figure_size = LeG_getnicedialoglocation(figure_size, figure_units) % adjust the specified figure position to fig nicely over GCBF % or into the upper 3rd of the screen % Copyright 1999-2010 The MathWorks, Inc. parentHandle = gcbf; convertData.destinationUnits = figure_units; if ~isempty(parentHandle) % ...
d3f4f40e67b30dba0cd5042defc0a3f91305c476c30b687140a2a592d12038a8
MATLAB
1,203
59
function [mu ul ll] = circ_mean(alpha, w) % Computes the mean direction for circular data. % % mu = circ_mean(alpha, w) % % Input: % alpha sample of angles in radians % [w weightings in case of binned angle data] % % Output: % mu mean direction % ul upper 95% confidence limit % ll lower...
fe7db8d08720dbaa20b49924ad100074a7c67279c476621ff99928c1f71ee26a
MATLAB
1,203
46
function models = fitAreaGMMs(allROIs, metricField, options, areas) % Fits Gaussian mixture model distributions to the feature vectors of % neurons specific to given anatomical area % Get metrics z-scored for all neurons switch metricField case 'PCs' metrics = cat(1, allROIs.PCs); metrics = metrics...
185a1a50f19cd621b531ab5e40f5f1cc26d0b6ff458e04da8537aaa2b2cd0c97
MATLAB
1,204
29
function [yinds,dists] = mindist(X,Y) %MINDIST Finds indices of closest vectors. % YINDS = MINDIST(XLIST,YLIST), where XLIST is an M x D matrix and Y is % N x D, returns an M x 1 vector YINDS such that YINDS(i) is the row % number in YLIST that has the minimum (Euclidean) distance to the i^th % row in...
61a9b6b41ed023fa3cb3945b6fc5db8a6936e54dedff417ea7673ef5f6f17292
MATLAB
1,204
39
function [tx_equil, ty_equil] = force_moment_equilibrium(tx,ty,r,theta) % % [tx_equil, ty_equil] = force_moment_equilibrium(tx,ty,r,theta) % % Adjust x and y tractions to approach force and moment equilibrium. % Run this function iteratively for best results. % % INPUTS % tx, ty: x and y components of tractions % ...
a4aad8c1e599dc6a055761612690a1df1b0d00b92a64c9a7cde3499ef5ab7b4d
MATLAB
1,204
40
function ea_run_cluster(~, ~, clusterfunctionname, handles, cmd) ea_busyaction('on', handles.leadfigure, 'lead'); options = ea_handles2options(handles); options.macaquemodus = getappdata(handles.leadfigure,'macaquemodus'); % handle 'prefs', 'lc' and 'd2' options options.prefs = ea_prefs(''); options = ea_amendtoolbo...
d8db3f783eb898a69eeba7bc65ebd85f5221ad58c849fbbd80f75cd311a0a572
MATLAB
1,204
37
function fibValThreshold = ea_explorer_applythresholding(threshstrategy, vals, threshold) switch threshstrategy case 'Percentage Relative to Peak' range = vals(1) - vals(end); fibValThreshold = vals(1) - threshold/100 * range; if range == 0 if vals(1) > 0 fibValTh...
99bfaf8d5a0e889228e4ecd2e4684455b916fa6264a2f522e58089a8cf5bcd15
MATLAB
1,205
26
function z = minus( x, y, cheat ) % Disciplined convex programming information for MINUS: % Terms in a difference must have opposite curvature. Real affine % expressions are both convex and concave, so they can be involved % in a difference with any nonlinear expression. Complex affine (or % cons...
ce0415d96a1c51f1eb15db8b0f004bfc762b2d8d4e1b03983bae736e5946018c
MATLAB
1,205
32
%% categorization % AC as source GC_tuning_AC2PFC_topoAC = zeros(nDay, nChAC, length(fIdx), length(tIdx)); for fIndex = 1:length(fIdx) for tIndex = 1:length(tIdx) GC_tuning_AC2PFC_topoAC(:, :, fIndex, tIndex) = mean(grangerspctrm_AC2PFC_topoAC(:, :, fIdx{fIndex}, tIdx{tIndex}), [3, 4]); end end % PFC a...
058cb712b02130f1cd2d3e501388bc147a03e25a9fa9ca282d91dfc2c5ef5173
MATLAB
1,206
31
% Input/output functions (including batch handling) for FMAToolbox. % % NOTE % % Although individual data files can be handled by these 'low-level' functions, % it is generally easier to use <a href="matlab:help SetCurrentSession">SetCurrentSession</a> and related <a href="matlab:help Data">Get...</a> functions % ...
4e5583e411f7a9611a60453ee180a1be5f0a250d33f051ff124e73d21e5cc31f
MATLAB
1,206
32
function ea_credits % The following code-snippets / software packages are being used and/or % have been incorporated by the LEAD-Toolbox: % SPM (http://www.fil.ion.ucl.ac.uk/spm/), mainly for normalization and % volume handling % Inhull.m - (c) John D'Errico % Tools for NIfTI and ANALYZE image - (c) Jimmy Shen % Dr...
8497c0f87791d05530b87e1bdb60545f4507a1a6c5140275d4c7fab374b377c8
MATLAB
1,207
34
%% Applying Tone Mapping to CT Data Enabling Simultaneus Display of Bony and Soft-Tissue Structures % % Andreas Husch % Centre Hospitalier de Luxembourg, Dep. of Neurosurgery / % University of Luxembourg - Luxembourg Centre for Systems Biomedicine % 2016 - 2017 % mail@andreashusch.de, husch.andreas@chl.lu function CTCo...
a190bbdd5bb654920f62fdea1d3519c62a333d00384148c193848cfb603df11e
MATLAB
1,209
34
function [data_var] = findHighVarianceOTUs(densities,experimentBlocks) % This file is a part of the MDSINE program. % % MDSINE: Microbial Dynamical Systems INference Engine % Infers dynamical systems models from microbiome time-series datasets, and % predicts biologically relevant behaviors of the ecosystems. % Cop...
e33cb93b22047a4d8602a4a5fd459073043aebe0346044a3c6d3af2e80800bcc
MATLAB
1,209
39
% eeglabciplot(lower,upper) % eeglabciplot(lower,upper,x) % eeglabciplot(lower,upper,x,colour) % % Plots a shaded region on a graph between specified lower and upper confidence intervals (L and U). % l and u must be vectors of the same length. % Uses the 'fill' function, not 'area'. Therefore multiple shad...
28e3f3c2bc7eec08d3ab75964f3564c87e2e3c3697c35dcb59b98cc1e720e98e
MATLAB
1,210
41
function propStackedBar(counts, groupLabels, cmapCategory) % propStackedBar Plot proportional stacked bar chart from counts. % % propStackedBar(counts, categoryLabels, groupLabels) % creates a stacked bar plot where each bar represents a group, % and the segments are proportional to the total counts. % % Input...
8ad8ba38e0925d4b183171e6c260b23a2d8b7ad071cb2b0d54efcfe6a825df45
MATLAB
1,210
46
function multiplot_segment(xx, yy, er, segX, seglist, ttlabel, figiniID) featureseg = unique(seglist); cc = colormap(hsv(length(featureseg))); N = size(yy,2); if N<=20 h1 = figure(figiniID+1); subc = round(sqrt(N)); subr = ceil(N/subc); for i = 1:N subplot(subr, subc, i), genera...
9ef0f39abafb5d272598ea5440053b245591ed2d5b0aa329cd7d4fd6a26611f0
MATLAB
1,210
57
function kappa = circ_kappa(alpha,w) % % kappa = circ_kappa(alpha,[w]) % Computes an approximation to the ML estimate of the concentration % parameter kappa of the von Mises distribution. % % Input: % alpha angles in radians OR alpha is length resultant % [w number of incidences in case of...
60f9ad5f7a64339f58843b7bf8588f0b05b1ad8c58f227e71ded6bd061e7eb02
MATLAB
1,211
48
% reads multi-channel recording file to a matrix % function .lfp] = function readmulti(fname,numchannel,chselect) % last argument is optional (if omitted, it will read all the % channels function .lfp] = readmulti_ss(fname,numchannel,chselect) if nargin == 2 datafile = fopen(fname,'r'); .lfp = fread(datafile,[num...
c845aed83bedd357c44430370130cce63c8aa2412519261e64e1db092500406f
MATLAB
1,211
67
function [x,y] = embed(z,v,w) % [x,y] or x= embed(z,lags) or embed(z,dim,lag) % embed z using given lags or dim and lag % embed(z,dim,lag) == embed(z,[0:lag:lag*(dim-1)]) % negative entries of lags are into future % % If return is [x,y], then x is the positive lags and y the negative lags % Order of rows in x and y th...
024f0c27560fe91cf12b83616cdd82863e413e1cbe3cac8de96dd7ccd4ab35b5
MATLAB
1,212
36
% sum() - sum of memory mapped underlying array % % Author: Arnaud Delorme, SCCN, INC, UCSD, Nov. 2008 % Copyright (C) 2008 Arnaud Delorme, SCCN, INC, UCSD % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software...
65564684a070536e5237143bb88f6b918c211c48a98d3a5b62814594d9413ccf
MATLAB
1,212
32
function CC = moserac(X, X2, threshold) % Returns 2-d autocorrelation of matrix M with normalization standards as used by Mosers % % AC = CMBHOME.Utils.moserac(M1, M2, thresh) % % % ARGUMENTS % M1 N x M matrix, like a ratemap % M2 (optional) O x P matrix, like a ratemap % threshold (optiona...
a3da765bc44cb199afebdf8643a26e08f579a895673083385f9b3b38b5cb1c6e
MATLAB
1,212
32
function [allflies,means,stds] = combineFlies(varargin) % Use this to combine outputs of calc_dFF() (which is for single flies), if % the flies are all part of the same experiment. % These should be saved to the 'extracted' folder, so navigate there before % you begin. allflies={}; one=dir([varargin{1} '.mat'...
cf07b1c781764c238cbef0caaa20df86dd015e72314fd25bd32753da452a613b
MATLAB
1,212
36
function [ w, cvx_optval ] = fdla( A ) % Computes the fastest distributed linear averaging (FDLA) edge weights % % [W,S] = FDLA(A) gives a vector of the fastest distributed linear averaging % edge weights for a graph described by the incidence matrix A (n x m). % Here n is the number of nodes and m is the number of ed...
6628bff75425e8858de8c72ca034e4de343ac9bcfb047c025edb5859c606f242
MATLAB
1,213
35
close all; [x y] = pol2cart(squeeze(shortData(:,:,:,:,1)).*pi./180,squeeze(shortData(:,:,:,:,2))); dist = []; for e=1:2 for t=1:2 for s=1:numel(subjects) for t1 = 1:size(x,4) for t2 = (t1+1):size(x,4) temp = hypot(x(e,s,t,t1)-x(e,s,t,t2),y(e,s,t,t1)-y(e,s,t,t2...
882750c96b1f7d5e027abc2fbf9ce0ea2f3639f668ad6464ea98c42c7d1b621d
MATLAB
1,214
41
function cmap = chMap(M) %CHMAP Create a monochrome-compatible colour map % % CMAP = IOSR.FIGURES.CHMAP returns a colour map CMAP (varying black - % blue - green - yellow - white) that is monochrome-compatible, i.e. it % produces a linear greyscale colour map. CMAP is size Mx3, where M is % the length of the c...
c59314d3b828008c9c329c46c5f67d11bd841ca4244a6dc198170c672a5d41b4
MATLAB
1,215
33
function fn = step(vr, delta) %WORKED=STEP(VR,DELTA) % Moves the frame counter by DELTA frames for video VR. This is a % generalization of NEXT. Returns 0 on an unsuccessful STEP. Note that % not all plugins support stepping, especially with negative numbers. In % the following example, both IM1 and IM2...
e1c56c0321147239d11008a8666f0e620bfe30fe21e12739f7629222c21320bb
MATLAB
1,215
35
function [green_dFF,red_dFF] = calc_dFF(fluorArray,redArray,diffArray,exptitle,triallength) % Make sure you're inside 'extracted' before running this function bc it % saves workspace variables. % This function calculates dF/F in each channel after you've done bg subtraction if % necessary. % triallength is in se...
85c8265224cefbad2a2eb757f65f3536027851fb8e92d449bf130d9638171181
MATLAB
1,216
44
function alldat=selectrespcolumns(headpath) %start by using a manual picker %eventually just change to something automatic cd('extracted2'); filelist=dir; alldat={}; for k=1:numel(filelist) dataname=filelist(k).name; %cd(headpath); if contains(dataname,'_analysis2') fileexpnum=dataname(1:end-14)...
cb803cd173981da6499f7252cb4bd0eedea97563533cbd3c5b44dda96ef22a94
MATLAB
1,217
36
function [f_cell, vel_dim] = VelocityRate(self, cel, vel_dim) % Calculates the rate of firing for cell cel, for bins of running speed. % % If vel_dim is specified, bin edges of running speed are vel_dim % If vel_dim is not specified, bin edges of running speed are [0 max_vel] % in increments of 1 cm sec^-1. % % Remembe...
9438b210c8cb8da052cc823e4c3811cb79dd9d0a4efeb7f02e3fdc1600260249
MATLAB
1,218
65
%% figure 4 load('figure4_data') %% Wave motif map for icomp = 1 : 7 f = vector_plot(squeeze(iTWC_motif_vector_maps(:,:,icomp)),ch_inx_map,ch_image,180,icomp); end % close all %% Time course an_col = [30 58 205]/255; aw_col = [229 32 21]/255; f = figure('Position', [100, 100, 10...
ae771ad63006d83db531bbcfabc34a82594f9ef1b635a0bfa7e4e5472a40ba04
MATLAB
1,218
37
function varargout=ea_corr(X,Y,corrtype) % wrapper for different correlation types if ~exist('corrtype','var') corrtype='pearson'; end % Set inf to nan X(isinf(X)) = nan; Y(isinf(Y)) = nan; switch lower(corrtype) case 'pearson' [varargout{1},varargout{2}]=corr(X,Y,'rows','pairwise','type','Pearson'); ...
d32eb35c33089dc48856cefae539f37cdafd3644aed299ba249431b6a230e2e5
MATLAB
1,218
41
parcellation_name = 'Shen'; %atlas_name = which('shen_2mm_268_parcellation.nii'); %% LOAD PARCELLATION FILE savefilenamedata = fullfile(resultsdir, ['Parcellation_data_' parcellation_name '.mat']); load(savefilenamedata, parcellation_name); printhdr(sprintf('Loaded parcels: %s', parcellation_name)); % Store in p...
ffcd0ffad7eaf22a6c4e2bc8ecf62f0f99a3efcc2b633a735c40f1e7d460384e
MATLAB
1,218
30
function reassignments = sortAssignments(assignments) % SORTASSIGNMENTS Renumbers assignments % reassignments = sortAssignments(assignments) % % Takes a list of assignment numbers and reassigns label numbers such % that the largest size group is assigned label '1', the next largest % is assigned label '2', and...
5b8f4863e15860526210df236f1a08ce066b86e2566579d08185147e176ff8bc
MATLAB
1,219
37
% find potential conflict between Matlab functions % % A. Delorme, May 25th, 2012 matlabRoot = fileparts(fileparts(fileparts(fileparts(which('ispc'))))); folders = path; delim = find(folders == ':'); delim = [ 0 delim length(folders)+1 ]; for iFolder = 1:length(delim)-1 currentFolder = folders(delim(iFolder)+1:de...
809592f59c09dbc1fdd82b8d88954a1f7d83bbb3596e3e25f4bdadea34263698
MATLAB
1,219
25
function dbURL=SOFAdbURL(dbURL) % dbURL=SOFAdbURL % % dbURL=SOFAdbURL returns the internet URL to the directory containing % HRTFs. The default URL is http://www.sofacoustics.org/data. % % dbURL=SOFAdbURL(newURL) sets the internet URL to the newURL for further calls % of SOFAdbURL. % SOFA API - func...