sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
71df2fd23109aca5128166dce1bd5d1d4dc3807b987acdae2cd6cd71d6321911
MATLAB
1,078
47
function [d dt pred] = bfs_in_mbgl(A,u) % BFS_IN_MBGL Reimplement the BFS function with MatlabBGL visitors. % % [d dt pred] = bfs_in_mbgl(A,u) % % See BFS % % Example: % load ../graphs/bfs_example.mat % d = bfs_in_mbgl(A,1) ip_d = ipdouble(-ones(num_vertices(A),1)); ip_dt = ipdouble(-ones(num_vert...
a284c2ad87ab9aa63c9d5bb1da5b1882f2c06dc5faefcf5508742c8d302feb18
MATLAB
1,078
28
function names = structunpack(s, force) %STRUCTUNPACK Copies the fields of a structure into the workspace. % STRUCTUNPACK(S) creates a variable in the workspace with name % 'fieldname' for each 'fieldname' that is a field of S, and copies the % value of S.('fieldname') into the variable 'fieldname'. % % ST...
578a4b296e4ad3c8418107e24cb5552bd063d9d703a0236f7679736b0029e272
MATLAB
1,079
30
ccc; %% Path % SINGLEPATHs = dir("..\MAT Data\granger result minus base\**\Prediction\**\average\**\*.mat"); % SINGLEPATHs = dir("..\MAT Data\granger result minus base\**\PE\**\average\**\*.mat"); % SINGLEPATHs = dir("..\MAT Data\granger result minus base\**\PE\**\average\**\*Passive\*.mat"); % SINGLEPATHs = dir("..\...
a9a658cc15a6fd1956f98c86737e6b622db728b9c598e38c423322b39bb83314
MATLAB
1,079
33
function ea_rBmap(varargin) % creates a correlation nifti file given a set of images and a % regressor ("R map" in Horn 2017 AoN) % ea_Rmap(fis,regressor,outputname,mask,sk) % sk can be 'k','s','sk' % for smoothing and normalization options. Mask only necessary if % choosing 'k' option. ...
f08164345d71dabc46a8ffeb199ea450baadc341d3b3b0daa3c6e8465fdad63c
MATLAB
1,079
41
% Exercise 5.33: Parametrized l1-norm approximation % Boyd & Vandenberghe "Convex Optimization" % Joëlle Skaf - 08/29/05 % (a figure is generated) % % Let p_star(epsilon) be the optimal value of the following problem: % minimize ||Ax + b + epsilon*d||_1 % Plots p_star(epsilon) versus epsilon and demons...
2463f33d5424617899dda7e52a0231f2801b941e7b753473e1a3f20dd54728bc
MATLAB
1,081
29
function M_recover = CBIG_MMLDA_matrix_completion_GLM(M, M_train) % M_recover = CBIG_MMLDA_matrix_completion_GLM(M, M_train) % % Use GLM to do matrix completion for missing entries by using training matrix. % % Input: % - M : N x B matrix with missing entries (NaN). N is the # of subjects. B is # of featur...
506b8ff848b35ffb4d847ca2ef3823babd9f87fd296aee34ee82785c21649a4c
MATLAB
1,081
48
function [d,dt]=formatts(d) % % Usage: [d,dt]=formatts(d) % % Helper function for CWT,XWT,WTC % % Brings a timeseries into a shape so that it has two columns: [time, value]. % % % (C) Aslak Grinsted 2002-2004 % % ------------------------------------------------------------------------- % Copyright (C)...
187c3b0b09790f8221b0bb0fca330113e89c5fe9ed166c1953149a367adc3dec
MATLAB
1,082
36
% Exercise 4.57: Capacity of a communication channel % Boyd & Vandenberghe "Convex Optimization" % Joëlle Skaf - 04/24/08 % % We consider a discrete memoryless communication channel, with input % X(t) \in {1,...,n}, and output Y(t) \in {1,...,m}, for t = 1,2,... % The relation between the input and output is give...
66833d115b520bcd4b79fb307268804e4631c5c0ab28b66d24b3a389b0da4c3f
MATLAB
1,082
40
%islscalar - Test if parameter is a (pseudo) logical scalar. % % USAGE % % test = islscalar(x) % % x parameter to test % % NOTE % % To be considered logical, the scalar should be equal to 0 or 1, but it does % not need to actually be of class 'logical' (class(x) could be e.g. 'double'). % % ...
ce0f1f17fa08cc5187da372da5d886f64203d120dd1539806123fd06143cf932
MATLAB
1,083
34
function out = freq2coord_1D(T, w, padN) %% freq2coord_1D.m % % Calculates the continuous 1D inverse Fourier transform of T. % % Inputs: T : array of 1D transfer function or signal in frequency space % size(T) = [1, length(w)] % w : vector of temporal frequencies % padN...
df148dbe4737e3757daf57516190be6b3df6962750bdf2e9e05587fc8ff3e44b
MATLAB
1,083
37
function l = length(tree,r) % XMLTREE/LENGTH Length Method % FORMAT l = length(tree,r) % % tree - XMLTree object % r - 'real' if present, returns the real number of nodes in the % tree (deleted nodes aren't populated) % l - length of the XML tree (number of nodes) %_______________________________...
fae30617bad948e9efe57688627f549062f5365d9e612ae39ce6e717d00706e2
MATLAB
1,083
36
function [connName, subset] = ea_connLabel2connName(connLabel) % Return connectome name [and subset] based on connLabel connName = []; subset = []; connBaseFolder = ea_getconnectomebase; datasetInfo = ea_regexpdir(connBaseFolder, '^dataset_info\.json$'); [~, connNames] = fileparts(fileparts(datasetInfo)); for c=1:le...
4e34be8ed51e9c6681f3b65df0eba62b442d41e05566471bc7b5cd46d59ef439
MATLAB
1,084
30
function k = xml_findstr(s,p,i,n) %XML_FINDSTR Find one string within another % K = XML_FINDSTR(TEXT,PATTERN) returns the starting indices of any % occurrences of the string PATTERN in the string TEXT. % % K = XML_FINDSTR(TEXT,PATTERN,INDICE) returns the starting indices % equal or greater than INDICE of occu...
776d20e787e4c9e894f063dbbd6f52fa6b5050aa9c3be50da374ccdd9473faaa
MATLAB
1,084
30
function z = lambda_sum_largest( Y, k ) % LAMBDA_SUM_LARGEST Sum of the k largest eigenvalues of a symmetric matrix. % % For square matrix X, LAMBDA_SUM_LARGEST(X,K) is SUM_LARGEST(EIG(X),k) % if X is Hermitian or symmetric and real; and +Inf otherwise. % % An error results if X is not a square matrix. %...
c5242f81cb241ea399dcd4cbcd17594b1f67a458c3fc6a3e8b03018367296ec5
MATLAB
1,085
33
function altered = ambiguate_dims(dims) %emulate matlab's singular-dimension-dropping behavior altered = dims; if length(dims) == 1 && dims(1) == 0 altered(2) = 0; %emulate [] behavior end lastnonsingular = find(dims ~= 1, 1, 'last'); %only applies to dimensions 3 and up if isempty(l...
764cbcfa31160d2bec657db4f416fedc5679e02bbfb01b713752c3dffe6c0034
MATLAB
1,086
38
function [] = LogScale_ss( whichaxis,logbase) %LogScale(whichaxis,logbase) renames the tick labels on your axes for a %logarithmically scaled variable. % %INPUT % whichaxis which axis did you log scale (can be 'x' 'y' or 'xy') % logbase base of the logarithm you used for your points (ex 10) % %EXAMPLE % plo...
312e7103112f0cc30f9e3328ee013459fd3ea882e4af6373afff806ab10386ea
MATLAB
1,087
39
function [n,names] = plx_event_names(filename) % plx_event_names(filename): gets the names of event channels in a .plx file % % [n, names] = plx_event_names(filename) % % INPUT: % filename - if empty string, will use File Open dialog % % OUTPUT: % names - array of event name strings % n - number of chan...
bf4cfd82b442340c765e063601598f98e21890d00baf7f4368324da335945e5a
MATLAB
1,087
42
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%% CPC METACOGNITION TUTORIAL 2019: CALCULATE TYPE2ROC %%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Function to calculate the area under the type2 ROC curve %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
c2ef77857b282984a3d690547b6078ff11cc72725f8f29d9abc595dae4e4299c
MATLAB
1,087
49
function [rho,pval] = circ_corrcl(alpha, x) % % [rho pval ts] = circ_corrcl(alpha, x) % Correlation coefficient between one circular and one linear random % variable. % % Input: % alpha sample of angles in radians % x sample of linear random variable % % Output: % rho correlation coeffic...
daac9c1da7c8c5a3275d231b8bafa26a490979e7314d5bbe684f6a3db9d58d1f
MATLAB
1,087
45
curr_path = pwd; addpath(pwd); if(exist('AnalysisTools', 'dir')) addpath(fullfile(curr_path, 'AnalysisTools')); end if(exist('AtlasSharpnessAndLabelMatch', 'dir')) addpath(fullfile(curr_path, 'AtlasSharpnessAndLabelMatch')); end if(exist('BasicTools', 'dir')) addpath(fullfile(curr_path, 'BasicTools')); end...
232786fd198375cb07790dd2415db4934c01a7d823eaa10be3a88b958a0eda59
MATLAB
1,088
41
%% Demo of the KDTREE and KDTREEIDX function. %% %% Guy Shechter %% guy at jhu dot edu %% June 2004 %% Generate a set of 10000 reference datapoints in R^3 ReferencePts = rand(100000,3); %%% Build the k-d Tree once from the reference datapoints. [tmp, tmp, TreeRoot] = kdtree( ReferencePts, []); for Iteration =...
6992f6d9bf493f210744fdcdb365d43fc8ae665332f8f432c21f9659cf68db77
MATLAB
1,088
54
getUtrackPackPaths smPropPerTimeInterval actinPropPerTimeInterval cleanActinPropPerTimeInt smactinPropPerTimeInt smactinMat smactinClean retainTassmInliers smactinAggMov runSmactinAggMovExplain multiCompareIndCellsMVRG scan4smSpeckleThreshold plotBiphasicLines getFsmTrackNum getUtrackNum collectSmPropByT...
f25d5b565136e05f7a9b87c347c3706fb53545a8aaf6f1f5428415e32c011d9c
MATLAB
1,088
31
function variables( varargin ) %VARIABLES Declares one or more CVX variables. % VARIABLES x1 x2 x3 ..., where x1, x2, x3, etc. are valid % variable names, declares multiple cvx variables. It is % exactly equivalent to issuing a separate VARIABLE command % for each x1, x2, x3, ... % % VARIABLES allows...
66ca6cd9957e3f145c9f1dd4e0b8ce343665134c34229acbd5cecfacb9de7997
MATLAB
1,089
49
function badout = ReadBadChannels_SleepScore(basepath) % Reads bad_channels.txt files in basepaths. Format must be a vertical set % of text lines, all numbers after the last blank line will be assumed to % be bad channels. Output is a vector of numbers of bad channels. % % Brendon Watson 2016 if ~exist('basepath','v...
8a1ae2fe8cb11340df710ee400176c1b61d363cbb12e4be365dfab03f1de68a6
MATLAB
1,089
43
function elist=surfpart(f,loopedge) % % elist=surfpart(f,loopedge) % % partition a triangular surface using a closed loop defined by existing edges % % author: Qianqian Fang, <q.fang at neu.edu> % date: 2012/02/09 % % input: % f: input, surface face element list, dimension (be,3) % loopedge: a 2-column array,...
c551aeecc54e0563e97d47e642a9fd9e704659deae342f8538df1df5e1d10f49
MATLAB
1,089
44
function b = getCubicBSplineBasis(x,nknots,isCirc) % Calculates set of splines with n evenly spaces knots to describe % fluctuations in x % Author: Abed Ghanbari % input % x = timestamps of neuron normalized by range % nknots = number of knots required to evens sample time range % isCirc = wrap time around ? %output...
2dede9c72dfebea32950010dad8476fd2f2978706d6a802f9fdefb91bb5f3ef7
MATLAB
1,091
22
function Energy = GCO_Expansion(Handle,MaxIter) % GCO_Expansion Run alpha-expansion algorithm. % GCO_Expansion(Handle) minimizes the current energy via % alpha-expansion until convergence. % GCO_Expansion(Handle,MaxIter) runs at most MaxIter expansion % Returns the energy of the computed labeling....
b84721050dedf93862373d9f1f04cc198548e4d8c64203c0980fc3f734fea059
MATLAB
1,091
38
function imat=ea_resample_planes(V,meanfitline,sample_width,doxx,resolution) % this function samples the 2D-planes orthogonally to the fitted trajectory % line. The code has gotten a bit cryptic for speed improvement % reasons. xxvec=-sample_width:resolution:sample_width; nn=length(meanfitline); xxlength=length(xxvec)...
4038293347c597f2424b7b547c96b7cc1bdadd6c63400ecac8c4227b8d128594
MATLAB
1,093
36
function ea_write_fiducials(coords_mm,path,options) % Small function to write fiducials (coordinates of electrode contacts) in % Slicer3 format. % __________________________________________________________________________________ % Copyright (C) 2014 Charite University Medicine Berlin, Movement Disorders Unit % % Andre...
57c8d7e708f8d2425fee5ed2a83833eeebc47b101e4b68366cf0425ab11cdec2
MATLAB
1,093
49
function [rho,pval,slope] = circ_corrcl(alpha, x) % % [rho pval ts] = circ_corrcl(alpha, x) % Correlation coefficient between one circular and one linear random % variable. % % Input: % alpha sample of angles in radians % x sample of linear random variable % % Output: % rho correlation c...
7ce646a4237a714a12007904fb6ebcaa1af50da3b364c627314efdc21d516490
MATLAB
1,094
43
function out = pairwiseArea2Dkstest(allROIs, areas, coordField, alpha) if nargin < 4 alpha = 0.05; end % Get data allCoords = cat(1,allROIs.(coordField)); % Allocate reject = zeros(length(areas), length(areas)); pvals = zeros(length(areas), length(areas)); ksstats = zeros(length(areas), length(areas)); % Plot po...
f44b1dde3d507ce51354eb8a57345a01d9037039036337c7c7cc558e98d13a53
MATLAB
1,094
51
function cvx_optval = sum_largest( x, k, dim ) %SUM_LARGEST Internal cvx version. narginchk(2,3); sx = size( x ); if nargin < 3 || isempty( dim ), dim = cvx_default_dimension( sx ); elseif ~cvx_check_dimension( dim ), error( 'Second argument must be a dimension.' ); elseif ~isnumeric( k ) || ~isreal( k ), ...
031bb9b9c2a3458e27ce5fe2fad78b74dd5c144566d7840a12519aa9d44fa947
MATLAB
1,095
47
function alldat=columnvangle(headpath) cd('extracted2'); filelist=dir; alldat={}; goodfilenum=1; for k=1:numel(filelist) dataname=filelist(k).name; cd(headpath); if contains(dataname,'_analysis2') fileexpnum=dataname(1:end-14);%remove _analysis.mat from it to feed into next code and get the two ...
107c23734dfdb84cda2bc3f8d59f36a1b32e73a77561c9a0d15fb83c10785048
MATLAB
1,095
29
function obj = set_point_options( obj , varargin ) % set_point_options Set point size and marker options % % 'name',value pairs: % 'base_size': Default/starting point size for geoms that take in account size % aesthetics. Default is 5 % 'step_size': Increment in point size for 'size' categories. Default is 2 % 'use_inp...
4fba1ed5b84a5c70283053f1cae5f4befdc4d954c70d00f71cdcbb74179e7c2d
MATLAB
1,095
40
function ea_rocrop(inputimage) % Reorient and crop nifti image % This is a workaround warpper to fix the 1KB output file issue of dcm2nii pth = fileparts(inputimage); if isempty(pth) pth = '.'; end disp(inputimage); ea_dcm2nii(inputimage, [pth, filesep, 'temp.nii']); tempf=dir([pth,filesep,'temp.nii']); tempfsi...
50d5f060ea0a297904a07aec2d09dfc9b8c15c1e0d3d7e80398990216bdf9afa
MATLAB
1,095
60
function icsi = calc_icsi(rgx,rgy) % icsi computes the common inter-spike interval (see Fee et al., J Neurosci. Meth., 1996) % Adrien Peyrache, 2012 % rewritten 1/4/2017 by David Tingley temp = [rgx;rgy]; icsi = diff(sort(temp)); % lx = length(rgx); % ly = length(rgy); % icsi = []; % % [dummy,ix] = min([lx,ly]); ...
99639de75c295410fe4728b1dff59393d1fd524371ba9637c75a30a20516d3dc
MATLAB
1,095
25
% ndims() - number of dimension 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 %...
cd3afafea690285d99d6f73d9d5311b484e082b3dd691b543d8be7a713b0099a
MATLAB
1,095
34
function M = getaffine(surface_name, hemisphere); % % Usage: % M = getaffine(surface_name, hemisphere); % % Description: % Returns vox2ras transform for a surface (author: @saratheriver) % % Inputs: % surface_name (string) - Name of surface {'fsa5', 'conte69'} % hemisphere (string) - Name of hemisphere {'lh', '...
20ec707249764a3fd281ebfe7043a73ef0efd4031f8a081d67078cd71fc48d3c
MATLAB
1,096
26
function cmap = tintmap(tint, M) %TINTMAP Tinted monochrome color map. % CMAP = TINTMAP(TINT, M), where TINT is a 1-by-3 RGB vector, returns an % M-by-3 matrix containing a monochromatic color map based on the color % TINT. % % CMAP = TINTMAP(TINT) uses the length of the colormap in the current % fi...
e41dfb0b0f10f27d8fd03cd7f61c45ae9055b6cfd1d6299b1ccdd03a2f480755
MATLAB
1,096
40
function y = blkdiag( varargin ) %Disciplined convex/geometric programming information for BLKDIAG: % BLKDIAG imposes no convexity restrictions on its arguments. nv = 0; nz = 0; sz = [ 0, 0 ]; for k = 1 : nargin, x = cvx( varargin{k} ); sx = x.size_; if length( sx ) > 2, error( 'N-D matrices no...
ea65fe60ba1ad4000f5494ce3e8fd940f26568b4ac0d596d21dd37ea0d8719dd
MATLAB
1,097
41
if any(~options_exist) a2_set_default_options; end printhdr('Options used in this analysis:'); for i = 1:length(options_needed) if ~exist(options_needed{i}, 'var') % If still can't find it % ...use the default value specified above. if ischar(option_default_values{i}) ...
42260ef2431dceb59b8199c4cfc3b56333e43fdc6d582a36412e063109055daa
MATLAB
1,098
44
%%********************************************************* %% lmifun: generate SDP data for the LMI constraint %% of the form: %% %% A*P*B' + B*P*A' + H*diag(d)*H' %% P and d are variables, P is symmetric. %% %% H is optional. %%********************************************************* function Avec...
a4bd66626a958dd372a9460d3d553423b700290ecb85eb4aa075712833454c7c
MATLAB
1,098
34
function order = CBIG_ASDf_hunMatch(K, Mean_ref, Mean) % order = CBIG_ASDf_hunMatch(K, Mean_ref, Mean) % % This function performs Hungarian matching between the factor-specific RSFC % patterns (i.e., E(RSFC patterns|Factor)) of two random initializations. % % Input: % - K: % An integer indicating the numb...
e3fbef9c28f0909b9da167bbf1e6921bad171559a14c7d745f6234c348009364
MATLAB
1,098
33
function [mesh_resources] = populate_mesh_resource_str(f, v, c) % % See also FACE_VERTEX_DATA_EQUALS_NPOINTS, MESH_NORMALS, VERBATIM. % % File: populate_mesh_resource_str.m % Author: Ioannis Filippidis, jfilippidis@gmail.com % Date: 2012.06.10 - % Language: MATLAB R2012a % Purpose: mesh resourc...
3dd23c56f115edf14529143d2d4a7865251142b7242506a48df86f72187a1ed2
MATLAB
1,099
41
function [allROIs, Y] = tSNEallROIs(allROIs, metricField, perplex) % Performs tSNE dimensionality reduction on the z-scored feature matrix, % then returns the original struct with tSNE space coordinates for each % cell included % Note: pass in only valid allROIs, perplexity depends on struct size if nargin < 2 met...
5e64f45e7f0bdaed362090a0037faa4c25cf02e5df10f619092c93ab4d7744eb
MATLAB
1,099
35
function plotGradientMapCCF(dorsalMaps, allROIs, metricField, smoothSDPts, smoothSDImg, cmapInfo) % Creates a binned and smooth map of cell metric values from the field % metricField, then compute the spatial gradient of this map and plots it % as an RGB image % Figure allenMapSMc(dorsalMaps, [-3.6, 0, -2, 3]) % Creat...
20b10a9ce4d3c39e67e95143d5830863dafc2571351e0aac9a5bdd8958e55491
MATLAB
1,100
22
function saveDregdata(dreg, indxr, RegPara, handles, imageinfo, fext, k, indxr_base) savename = RegPara.savenamebase; if handles.crossSessionReg == 0 for k1 = 1:size(dreg,3) nametmp = sprintf(['%0', num2str(floor(log10(RegPara.Imagelength))+1),'d.tif'], indxr(k1)); if ~isempty(fext) imw...
0d83c0e35e57fc861c95a53a40091c7f66f904c86d711e050859f4bfd727fb29
MATLAB
1,101
26
% Run this script once to prep data files, save them, calculate contrast % image objects, and get ready to run analyses. % % Before running, you need to customize two scripts for your analysis: % a_set_up_paths_always_run_first.m % prep_1_set_conditions_contrasts_colors.m % % If you have behavioral data and between-sub...
1082c6f7d5ccdfbfe693eb79c24578ea9f9b64119dab82a4be54b623b130c786
MATLAB
1,101
37
% ADJUST_KEY_STACK fix inconsistencies in a pointer into a struct % % ADJUST_KEY_STACK(obj, key_stack) follows the elements of `key_stack` % through the structure of `obj`. If an element is missing from the % pointer, it is inserted in the appropriate order. The (potentially) % corrected pointer is returned. f...
f7c67ff0079e6421b436efd8c4bd5c7f075b36e29d0329973db714872165491f
MATLAB
1,101
32
function plot_header(self, cel) % Used in Visualize2 primarily. % % root.plot_header(cel) % % prints the tetrode and cell number, current event labels, average firing % frequency for these epochs. % find event strings if all(arrayfun(@(a) any(a==self.event{:,2}), self.epoch)) % if both timestamps exist in str...
31d70b811095f9f0a35c0a24fdbbc335fb07888da8699d111d14241f9fbe32d6
MATLAB
1,102
38
function [channelNumber] = plx_resolve_channel(filename, channel) % plx_resolve_channel(filename, channel): returns .plx file spike channel number for the specified channel name % % [channelNumber] = plx_resolve_channel(filename, channel) % % INPUT: % filename - file name % channel - 1-based channel number o...
5159541494979b369c60fb0d07fd3fed2aeae2019fcce9dc7d0865513507860f
MATLAB
1,102
36
function sout = cvx_pause( flag ) %CVX_PAUSE Pauses the processing of CVX models. % CVX_PAUSE(TRUE) instructs CVX to pause and wait for user keypress before % and after proceeding with the numerical solution of a model. The pauses % occur within the CVX_END. This is useful for demo purposes. % % CVX_PAUSE(FA...
8720d79a59219873f93d6d9f2d2a7ff3d8f689d14d4a13ea9607df181276b614
MATLAB
1,102
26
function [f,findx]=getfgrid(Fs,nfft,fpass) % Helper function that gets the frequency grid associated with a given fft based computation % Called by spectral estimation routines to generate the frequency axes % Usage: [f,findx]=getfgrid(Fs,nfft,fpass) % Inputs: % Fs (sampling frequency associated with the data)-...
10a8b56df8c761accf49f9b7d900945e88a3998da3d529a041c3c96c66b5f455
MATLAB
1,103
36
function cvx_optpnt = nonnegative( sx ) %#ok %NONNEGATIVE The nonnegative orthant. % NONNEGATIVE(SX), where SX is a valid size vector, creates an array % of size SX and constrains each element to be nonnegative. Therefore, % given the declaration % variable x(sx) % the constraint % x == nonnegative...
6057bbc23ed0780e1f9c2d7fbd233b3a49245bb3ae7546d225261627cb9f3105
MATLAB
1,103
29
function [ D ] = isdiscrete(X) %%ISDISCRETE True for arrays of discrete variable-compatible types. % % ISDISCRETE(X) returns true if X is an array of a data type suitable to be % interpreted by ELPh as a discrete random variable. This is true for integer, % logical, and categorical types, as well as for float and...
cfff54c45d7aea558da7709383abc19d050b3a49346dbc9501b47b4fb55f535a
MATLAB
1,103
34
function [ts] = PL2TsBySource( filename, source, channelInSource, unit ) % PL2TsBySource( filename, source, channelInSource, unit ): read spike timestamps from a .pl2 file % % ts = PL2TsBySource( filename, source, channelInSource, unit ); % ts = PL2TsBySource( filename, 'SPK', 1, 2 ); % ts = PL2TsBySource( filenam...
86591f19ef564c04ebcee65fa5bc95470fb207d2f53269241dbcaaeeb1596a9a
MATLAB
1,104
31
iUnit = iUnit+1; %clf;%figure('Color', 'k'); subplot(1,5,[1:4]) hold on; scatter(ephysData.spike_times_timeline(ephysData.spike_templates==iUnit), ephysData.template_amplitudes(ephysData.spike_templates==iUnit),... [],prettify_rgb('Red'), 'filled') ylabel({'Spike-to-template'; 'scaling factor'},'Color','w', 'font...
c8c6bcc3164f93f1c08a90bd6c41822dde1032e5ca88aa6e693aec1c75fdce78
MATLAB
1,105
29
function I = mat2cell_ov(X,xx_s,xx_f,yy_s,yy_f,zz_s,zz_f,overlap,sz) % converts a matrix into a cell array with overlapping elements % INPUTS: % X: Input matrix % grid_size: size of each element without overlap % overlap: amount of overlap % sz: spatial size of X % OUTPUT: % I: ...
d6777911440d6fe648f3b79bb1225f7a24384039238c28ff5f3dc53d4eda753c
MATLAB
1,105
43
function mat=ea_antsmat2mat(afftransform,m_Center) % followed instructions from % https://www.neuro.polymtl.ca/tips_and_tricks/how_to_use_ants and ITK code % in ComputeOffset() itkMatrixOffsetTransformBase.hxx mat=[reshape(afftransform(1:9),[3,3])',afftransform(10:12)]; m_Translation=mat(:,4); mat=[mat;[0,0,0,1]]; f...
8c72d725ad763b8951b49af14392955fe65a73ed79c963e35f31c23e0174efbf
MATLAB
1,106
51
function [ x, sx, sy, zx, zy, nx, nv, perm ] = cvx_reduce_size( x, dim, do_reduce ) % % Reduction dimension % zx = size( x ); if isempty( dim ), dim = find( zx ~= 1, 1, 'first' ); if isempty( dim ), dim = 1; end elseif ~isnumeric( dim ) || numel( dim ) ~= 1 || ~isreal( dim ) || dim <= 0 || isinf(dim) || isnan...
cae03db38b7eb26ed2ae5436521c44b158eb763623e54cd1696b8ba59c727ccf
MATLAB
1,106
42
function ea_ttest(x,y,description,ylabel,groups,colors) % this simple function is a small wrapper for a t-test figure and has been % written to go in line with the ea_corrplot wrapper. if ~exist('groups', 'var') groups = {'0', '1'}; end if exist('colors', 'var') && ~isempty(colors) map = colors; if isnume...
418bb3c5b90baede6d0c5efc6cf935b65e3c2419446e794e155a463cb1aa2fea
MATLAB
1,107
33
function [data,sampling]=readdat % % function for reading *.mat, *.wav and *.au files % *.mat files have to contain variables data and sampling in order for the % returns to work properly % [fname,pname]=uigetfile('*.*'); strindex=findstr(fname,'.plx'); if ~isempty(strindex); error('This file format can be ...
8d4032d8139af31ffff383d974c00e0ab17bc0f81f0ee974121a7e883baa5f42
MATLAB
1,107
43
% % This function installs Blackrock Microsystems Neural Processing MATLAB % Kit in MATLAB. Run "help FUNCTIONAME" to get more information about each % function. % % Kian Torab % kian@blackrockmicro.com % Blackrock Microsystems % Version 1.0.0.0 % function installNPMK disp('Removing the previous version of Neural Pro...
55382da354d6f926d0691c9df36ca3b7f545269d3e649602c508ee16d4a26a13
MATLAB
1,108
45
function vol=elemvolume(node,elem,option) % % vol=elemvolume(node,elem,option) % % calculate the volume for a list of simplexes % % author: Qianqian Fang, <q.fang at neu.edu> % date: 2007/11/21 % % input: % node: node coordinates % elem: element table of a mesh % option: if option='signed', the volume is the...
8db805a937a9cb9a1555d424d7c96b77f300eed78d2d911846bc9ece9e64c4af
MATLAB
1,110
29
function P = palm_idx2perm(I) % Convert a set of indices into a % sparse permutation matrix. % _____________________________________ % Anderson Winkler % FMRIB / University of Oxford % Feb/2012 % http://brainder.org % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % PALM -- Permutation Analysi...
a39ae71102b780a29ffe818d66cdd0096e9ff608ca850d4f7db756104d4ea38e
MATLAB
1,110
48
function [t, f, S, clims] = plot_lfp_spectrogram(self, windowsize, windowinc, bandwidth, f_range, clims) % Plots a spectrogram in jet colormap for current LFP % % Uses the Chronux toolbox. % % root.plot_lfp_spectrogram(lfp_ind, windowsize, windowsin, bandwidth, % f_range); import CMBHOME.Utils.* AddChronu...
c152a517f81bf3167616badb65d54fc28e2905bb3871d73eca4dafb19eadef08
MATLAB
1,110
19
%extracts pulse parameters from pulse mat file associated w/ tifs %containing traces w/ multiple pulses function [PTfreq,PTdBampl,PTonsetInPulse,msPTpulseLen,msStimLen,msRamp,kHzSampleRate] = extractMapPulseParams(pulse) pulseCellStr = {pulse.pulsename}'; PTonsetInPulse = str2double(strrep(strrep(string(regexp(puls...
645048eb556f2b4f67142e3a443331173decfe5b376eb75ed1c35d016050a215
MATLAB
1,111
50
function [rho pval] = circ_corrcl(alpha, x) % % [rho pval ts] = circ_corrcc(alpha, x) % Correlation coefficient between one circular and one linear random % variable. % % Input: % alpha sample of angles in radians % x sample of linear random variable % % Output: % rho correlat...
ef50557d3ff544562f0111383ebe56e03975271b6a4fb5008050b2d613d80210
MATLAB
1,111
43
%wrap - Set radian angles in range [0,2pi] or [-pi,pi]. % % USAGE % % y = wrap(x,offset) % % x angles in radians % offset phase angle [0-2*pi] that circularly shifts output data % % % SEE ALSO % % See also isradians, clinspace. % % Copyright (C) 2010-2011 by Michaë...
b82c6f964d9669f5b6de4d75b35a49bbd7927365afdb06e950547d946cc4a413
MATLAB
1,112
46
function y = diag( v, k ) %Disciplined convex/geometric programming information for DIAG: % DIAG imposes no convexity restrictions on its arguments. switch nargin, case 0, error( 'Not enough arguments.' ); case 1, k = 0; case 2, if ~isnumeric( k ) || k ~= floor( k ), ...
c88f7c4de05a4a2eda597c4f008781376c035227bbb8380297deee21f17af2a5
MATLAB
1,112
27
function apref = ea_antspreset_ants_default_synquick(cmd) if ischar(cmd) % 'query' mode, return the name of the preset apref = 'ANTs Default: SyN Quick'; return end apref.rigid.gradientstep = '0.1'; apref.rigid.metric = 'MI'; apref.rigid.metricparams = '1,32,Regular,0.25'; apref.rigid.convergence='[1000x500x2...
1f6906cab94765a0bb905135024e755a9fad37ad8a84adb8d5ad1cc42450b522
MATLAB
1,114
34
function CancelBatch(batch) %CancelBatch - Cancel batch job. % % USAGE % % CancelBatch(batch) % % batch batch parameter returned by <a href="matlab:help StartBatch">StartBatch</a> % % SEE % % See also StartBatch, GetBatch, BatchInfo, CleanBatches, Store, Recall. % % Copyright (C) 2010-2011 by Mich...
3563c8ae49ec5b8b4852349f10653a9e92a817e175444823df2442c28015349f
MATLAB
1,114
39
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % demo script for using short-hand version of the meshing wrappers %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% preparation % user must add the path of iso2mesh to matlab path list % addpath('../'); % user ne...
508ccf1cefc7d09546c70388ffb2fda20943d57dd533b0c0f552c3432cc0315b
MATLAB
1,114
37
function varargout = ContinuizeEpochs(varargin) % Converts all cell arrays passed through varagin to arrays in varargout % % % If the cell array is Mx1, then that vararg output is a column vector. If % the cell array is MxN, then the vararg output is a matrix max(cat(M) x N % padded by zeros. % % This is useful in the ...
eaa8b49637ce2f1415362caf80e14bda4c1f1da44039fe42f632d5a9c315ca81
MATLAB
1,114
50
function [ind, min_val, max_val] = G_RangeLoc( vec, lim) % Returns a logical vector with the same length to input % % Input % vec, e.g. a time vector; vec = linspace( -0.5, 2, 1000); % rng, e.g. a time range; rng = [-0.25, 0]; % % Output % ind, a binarized vector indicating the location of the desinated range %...
8c540c7c978608cf55022fca239ede0433a81642ed6cbf5f196c320a5f4fc440
MATLAB
1,115
24
%% applyFSLTransformToPoints - transform points in world coordinats of sourceRefImage to % world coordinates in targetRefImage applying a FSL (FLIRT) transformation % matrix. world coordinates in PaCER style. (note L/R orientation in plots % i.e. axis ij vs axis xy!) % % Parameters: points - Nx3 matrix % fs...
96b019302f9c061f28dfbda06590a14d6e6dc95b61f1a8ca9e0c0e2f70f1ec2d
MATLAB
1,115
44
function [ ] = NiceSave(figname,figfolder,baseName,varargin) %NiceSave(figname,figfolder,baseName,<options>) formats the figure for best viewing %and saves it as a .pdf in figfolder with name recname_figname.pdf % %INPUTS % figname string with title of figure % figfolder folder to save figure to % baseName...
58fe075cc40ed4c6fae10633dd18a685df6713320d19f4a3e1072764df9ac183
MATLAB
1,116
32
function propLongISI = computePropLongISI(theseSpikes, longISI) spiking_stat_window = max(theseSpikes) - min(theseSpikes); spiking_stat_bins = [min(theseSpikes), max(theseSpikes)]; % Get firing rate across the session bin_spikes = ... histcounts(theseSpikes, ... spiking_stat_bins);...
720935d9cd68a2c09a9e40b649ed2b0760829706c462a74891e53228f8fb75a4
MATLAB
1,116
40
function opt=varargin2struct(varargin) % % opt=varargin2struct('param1',value1,'param2',value2,...) % or % opt=varargin2struct(...,optstruct,...) % % convert a series of input parameters into a structure % % authors:Qianqian Fang (q.fang <at> neu.edu) % date: 2012/12/22 % % input: % 'param', value: the input par...
0f7614aba6a6854ad8ad5defc8827bee72266dd4fcb268d3b80ae09b52b50579
MATLAB
1,117
28
function ea_run_Martinos_Launchpad_compile(options) % This is a function that runs code for each subject on a cluster. It needs % to be adapted to suit your needs. Then, you can "Export code" using % Lead-DBS and simply change the command ea_run to ea_run_cluster. jobFile = [options.root, options.patientname, filesep...
39ce6a9757c1c638e7be92b62405e75cfc5c0b95cb1d9a269b085d237636b168
MATLAB
1,117
53
function [out,cmap] = show(a,windfact,ncolors) % usage .. show(a,f); % displays matrix "a" as a greyscale image in the matlab window % and "f" is the optional window factors [min,max] verbose_flag=0; title_flag=1; if nargin<3, ncolors=128; end; if nargin<2, windfact=[]; end; if isempty(windfact), amin ...
d54e6ab96d6e5c8d8749bd044a17c1a0b2c611c87275f43f2dd267c605273fa4
MATLAB
1,117
37
function plotEventTimes(eventTimes, eventName, eventLabel, yLims, yTicks, yLabs) % Simple plot of boxplots depicting distributions of the % times of the chosen event for all animals fig; hold on; panelwidth = 2.5; panelheight = 1.5; leftoffset = 0.5; bottomoffset = 0.5; formatFigure(gcf, panelwidth, panelheight, lefto...
538c5b9cbfa3b97ad8cf4f3755a997f47df2b252d8e044bc8cdb7e1e97e4d7e3
MATLAB
1,118
27
function X = cell2mat_ov(I,xx_s,xx_f,yy_s,yy_f,zz_s,zz_f,overlap,sz) % converts a cell array to a matrix when the cell elements overlap % INPUTS: % I: cell array % grid_size: true size of each element % overlap: amount of overlap in each direction % d1: number of rows of matrix % d2: ...
9e05958b4c19fd8c707c3d503122263ccf1f7cf8c530137afd3b42fc878c1e89
MATLAB
1,118
34
function countSpots_old(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); tb...
171585e6b1b30b383aeff9ea45b2b11b8ec266da0c274934a00c0e0684d3d411
MATLAB
1,119
39
function fnew=removeisolatedsurf(v,f,maxdiameter) % % fnew=removeisolatedsurf(v,f,maxdiameter) % % remove disjointed surface fragment filtered by using mesh diameter % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % v: list of nodes of the input surface % f: list of triangles of the input surface % m...
e01cb257f4e87b9ac400c189e441e9101d8b27307744a70f0e03e21f27ca4669
MATLAB
1,119
30
fprintf(1,'Executing %s at %s:\n',mfilename(),datestr(now)); ver, try, if isempty(which('spm')), throw(MException('SPMCheck:NotFound', 'SPM not in matlab path')); end [name, version] = spm('ver'); fprintf('SPM version: %s Release: %s\n',name, version); fprintf('SPM p...
58c56f7d4da77d8348dde1783abfa65a3aa8810343448cd0c0f6716e7df72146
MATLAB
1,120
62
function xini = grid_search(y, f, x, lb, ub, NstepsGrid) tic disp(' - Performing Grid Search') Nparams = numel(lb); % Create the grid disp(' - Creating the Grid') for i=1:Nparams eval(['p' num2str(i) ' = linspace(' num2str(lb(i)) ',' num2str(ub(i)) ',' num2str(NstepsGrid) ');']); end command = '[p1'; for i=2...
899a730d6cdd306e9cce99e12d59a765e5d19a4fed45abd36c440b094a9164ee
MATLAB
1,120
39
function d2 = ea_tdhandles2options(tdhandles,fd2) % defaults: d2.col_overlay=1; d2.con_overlay=1; d2.con_color=[1,1,1]; d2.lab_overlay=1; d2.bbsize=50; d2.backdrop='ICBM 152 2009b NLIN Asym T2'; if isempty(tdhandles) % call from somewhere else, return defaults or loaded file try p = ea_prefs(''); ...
35fb2895e250bf6b200349c1d6f1dd3cb3fa1c1f41aac1fa5dfc21770703c88f
MATLAB
1,121
33
function [w,rho] = mh(A) % Computes the Metropolis-Hastings heuristic edge weights % % [W,RHO] = MH(A) gives a vector of the Metropolis-Hastings edge weights % for a graphb described by the incidence matrix A (NxM). N is the number % of nodes, and M is the number of edges. Each column of A has exactly one % +1 and one ...
e0873215665111a832442f0ab0f20cf5f965ec8ada04d14b6614faafaa883652
MATLAB
1,121
47
function ea_libs_helper(libpath, setpath) % add/remove shared libraries to search path % Use current folder as libpath by default if nargin < 1 || isempty(libpath) %load prefs for platform specific handling prefs = ea_prefs; % Check and load runtime libs when needed arch = ea_getarch; if eval(['p...
1cb4cfd7e01720fb6d48cbde112e107e31d641c48193c7c9daeb8b7ded769b61
MATLAB
1,122
25
function new_dist = pbc_dist(old_dist, box_size) % PBC_DIST Apply the minimum-image convention under periodic boundary % conditions (PBC) to a displacement (or array of displacements). % % new_dist = PBC_DIST(old_dist, box_size) wraps any displacement whose % magnitude exceeds half the box size back into the range...
90c32b758bb7c1d0074cd194f58f3471b0efb61f495031e4b893bdc4c097fda5
MATLAB
1,122
35
function data=createdatamatpt(data,E,win) % Helper function to create an event triggered matrix from a single % channel of spike times. % Usage: data=createdatamatpt(data,E,win) % Inputs: % data (input spike times as a structural array or as a column vector) - required % E (events to use as triggers) - require...
b4bab61dbe92367b1fca85f4032141b8014e2f6ea7b2c33aed32147537aea5cc
MATLAB
1,123
37
function imgdiff=imedge3d(binimg,isdiff) % % imgdiff=imedge3d(binimg,isdiff) % % Extract the boundary voxels from a binary image % % author: Aslak Grinsted <ag at glaciology.net> % modified by Qianqian Fang <fangq at nmr.mgh.harvard.edu> % % input: % binimg: a 3D binary image % isdiff: if isdiff=1, output will be...
e974aaec7c6a4f9b3ea25cb317d302e6177da5d8e62da89f7718e070bdb06c0f
MATLAB
1,123
46
function saveinr(vol,fname) % % saveinr(vol,fname) % % save a surface mesh to INR Format % % author: Qianqian Fang, <q.fang at neu.edu> % date: 2009/01/04 % % input: % vol: input, a binary volume % fname: output file name % % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) % fid=fopen(f...
1ff6d8bfabbd2785f0187436192f518fb5bdef64e80bea9691b64edd4ed22433
MATLAB
1,124
27
function edu = CBIG_MMLDA_get_edu(PTDEMOG_file, phase, rid, viscode) % edu = CBIG_MMLDA_get_edu(PTDEMOG_file, phase, rid, viscode) % % Get education year from PTDEMOG spreadsheet. % % Input: % - PTDEMOG_file : Demographic spreadsheet % - phase : cell array of phase for subjects. Each cell contains 'ADNI1'...
24289fa89a3e876e13c1cd0d15b6d43fd4f86e8aac80c674d43507e9f12f7f8d
MATLAB
1,124
34
% Computes clustering coefficient, based on triangle motifs count and local clustering % C1 = num triangle loops / num connected triples % C2 = the average local clustering, where Ci = (num triangles connected to i) / (num triples centered on i) % Ref: M. E. J. Newman, "The structure and function of complex networks" %...
0de061c4740aea9be7a8bd65b2e4617c3bf5df5b7cc2f78dd833a4ceeb5af64c
MATLAB
1,125
46
function out = filterAudio(trial,ord1,ord2) % load a trial of mic data % 1000 Hz sample rate assumed % load(trialname); for row = 1:size(trial,1) figure; set(gcf,'Position',[500 150 1000 700]); hold on; subplot(3,2,1); plot(trial(row,:)) subplot(3,2,2); spectrogram(trial(row,:),...
699d630dae0b948a02b50f0a7e7eb37988178d14b9057c1817aa0aa82a16e64e
MATLAB
1,125
48
function [U,labels,Z] = FRID(X,k,alpha,numanchor,ifnorm,nrepanch) % Input: % X: The neural activity, size of neuron number x time steps % k: number of clustering % alpha: sparisity penalty parameter % numanchor: anchor number % ifnorm: bool, if perform normalization % nrepanch: number of repetitions on finding anchor ...
6dcf6ed64ad448e9d7f6ece9ee5aa76823f87bfecb71dc23060a3aebb12ccebc
MATLAB
1,125
46
% Local Regression and Likelihood, Figure 4.3. % Author: Catherine Loader % % Residual plots for local likelihood. % Henderson-Shepherd Mortality Data. load morths; fit = locfit(age,deaths,'weights',n,'family','binomial','alpha',0.5); figure('Name','fig4_3a: Residual plots for local likelihood'); plot(age,residuals(f...
bc91adcdc316d90ae238943d3b5f1325f4807b5e543b2d68c6785eeedfe4d637
MATLAB
1,125
39
function [wavelet, t] = MorletWavelet( f, numcyc, si ) %MorletWavelet(f,numcyc,si) creates a Mortlet Wavelet of numcyc cycles with %frequency f (Hz). si: sampling interval % Adapted from Cohen Ch13 % %TO DO: % -Add ability to define width in bandwidth instead of cycles (varargin) % %Last Updated: 3/15/15 %DLevenst...