sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
3c23f806373c31d25f3364f572214f8febe98b46fa35028153630442a3cbef1e
MATLAB
1,312
59
function [pval, f] = circ_ktest(alpha1, alpha2) % [pval, f] = circ_ktest(alpha1, alpha2) % % A parametric two-sample test to determine whether two concentration % parameters are different. % % H0: The two concentration parameters are equal. % HA: The two concentration parameters are different. % % Inpu...
c3d1fd8ba94f4d5c209d26f17b15ef2f05d1a4f09f73517164c69662fad81a82
MATLAB
1,312
42
% Section 5.2.4: Solves a simple QCQP % Boyd & Vandenberghe, "Convex Optimization" % Joëlle Skaf - 08/23/05 % % Solved a QCQP with 3 inequalities: % minimize 1/2 x'*P0*x + q0'*r + r0 % s.t. 1/2 x'*Pi*x + qi'*r + ri <= 0 for i=1,2,3 % and verifies that strong duality holds. % Input data ...
b3b0731fc97e54bf361e696510471c80403da6c3f299fd14c2df8eaec0b921c2
MATLAB
1,313
59
function [pval, f] = circ_ktest(alpha1, alpha2) % [pval, f] = circ_ktest(alpha1, alpha2) % % A parametric two-sample test to determine whether two concentration % parameters are different. % % H0: The two concentration parameters are equal. % HA: The two concentration parameters are different. % % Inpu...
eb64462b948f0b181a7388518de7f1be75a0a55d2aae4c38c0da342c7a9891be
MATLAB
1,313
36
%%***************************************************************** %% HKMcorr: corrector step for the HKM direction. %% %% SDPT3: version 3.1 %% Copyright (c) 1997 by %% K.C. Toh, M.J. Todd, R.H. Tutuncu %% Last Modified: 16 Sep 2004 %%***************************************************************** function [dX,dy,...
96419a3e499aa17d399a588446fc6ef7f4b92613dd7cc21570175b3559c03bcb
MATLAB
1,314
44
function [tmp] = ea_diode_respecifyslices(tmp,ct,cscale,electrode,activecontact) if ct.mat(1,1) < 0 for k = 1:length(tmp) tmp{k} = flip(tmp{k},1); end end if ct.mat(2,2) < 0 for k = 1:length(tmp) tmp{k} = flip(tmp{k},2); end end for k = 1:length(tmp) sp(k) = subplot(numel(tmp),1...
004116c9aef32ec9f9a720b626f013fc4f75feb5c0a777e5fdae8abc4d129ae5
MATLAB
1,315
39
function [ft_struct,ft_todss] = Robs_automaticICA(data,eye_channels_idx, NREMOVE) %addpath([U '\NoiseTools\']); % http://audition.ens.fr/adc/NoiseTools/ ft_struct = data ; [B,A]=butter(2,1/(data.fsample/2), 'high'); x = cat(2,ft_struct.trial{:})'; %x = nt_trial2mat(eeg_asr.trial); x(isnan(x)) = 0; xori...
5215b49006b489b2d69ddc87e4ea8d18a969a5ad92fe5adf34e110984b6f418c
MATLAB
1,315
38
%%************************************************************************ %% NTcorr: corrector step for the NT direction. %% %% SDPT3: version 3.1 %% Copyright (c) 1997 by %% K.C. Toh, M.J. Todd, R.H. Tutuncu %% Last Modified: 16 Sep 2004 %%************************************************************************ func...
3209f6a6dac038ee106446681d3af770f2140078bc3c1dc584869f1bf427aa13
MATLAB
1,316
34
% Local Regression and Likelihood, Figure 6.1. % % Derivative (local slope) estimation, for the Old Faithful Geyser Data. % The 'deriv' argument specifies derivative estimation, % 'deriv',1 First-order derivative. % 'deriv',[1 1] Second-order derivative. % 'deriv',2 For bivariate fits, partial de...
7b4e50fa3ffbf10ec1b33af625cd8f61e0034657d79d923c145997a66c441328
MATLAB
1,316
49
function cvx_optval = berhu( x, M, t ) %#ok %BERHU Internal cvx version. % % Check arguments % narginchk(1,3); if ~cvx_isaffine( x ), error( 'Disciplined convex programming error:\n HUBER is nonmonotonic in X, so X must be affine.', 1 ); %#ok end if nargin < 2, M = 1; elseif isa( M, 'cvx' ), error( ...
a3cd23db9d45036b522a0ec0ba33ce76270128b9d31958e29a12a3509bc47a15
MATLAB
1,317
36
function [imgRGB, cmap] = grid2RGB(map, mask, cmapInfo) % Converts a scalar map shaped like an image into an RGB 3 channel image % based on the desired colormap type specified by the shape/type of % colorInfo cmapRes = 256; nY = size(map,1); nX = size(map,2); imgRGB = zeros(nY,nX,3); % RGB image to output values = map...
9a0b7359ba7f7bef5b86166220368bebde4555ef1572326e5e90e4554c249a9b
MATLAB
1,318
47
% Minimum volume ellipsoid covering a finite set % Section 8.4.1, Boyd & Vandenberghe "Convex Optimization" % Almir Mutapcic - 10/05 % (a figure is generated) % % Given a finite set of points x_i in R^2, we find the minimum volume % ellipsoid (described by matrix A and vector b) that covers all of % the points by solvi...
7f63d77ab3065eb112610d1024bf2c49a98aae045390474845e68a866665c395
MATLAB
1,319
51
function writestreamstring5( WS , WO , ncharsperline , maxlines , fid , x , z , thr , NC , T ); L = []; N = length( WS ); NL = 0; for i=1:N if (WS( i ) == 0) L = [ L '. ' ]; spanst = 'normal'; word = '. '; else word = WO{ WS( i )}; probs = x( : , ...
8338044d8f617ac2ab0dedf81a96532f4ef90dcc08ccdd9f4e127cb8e0a195f1
MATLAB
1,319
43
EXCLUDE_DEMO_TRIALS = 1; % also set in globalsConditions.m all_subjects = [1:10 12:15 17:26 28:41 57 62 64 65 69 72 77 78 82 90 91 94 101:106]; excluded_subjects = [1 3 4 13 21 25];% [1 3 4 13 21];% low performance in control task or only one session subjects = setdiff(all_subjects,excluded_subjects); group{1} = su...
88056b2f24839135a82316caefe24a21e3764f0ff6a8f298773a2fbb036328c2
MATLAB
1,319
26
function ea_add_unifiedmapping(~,~,leadgroup,resultfig) % small function to open ea_unifiedmappingexplorer. lead group can be a path to % either lead group analysis file or saved fiber explorer. if ismember('M', who('-file',leadgroup)) % Add new network mapping analysis exp = ea_unifiedmappingexplorer(leadgroup,re...
acc9fee4a8bab7b73893154af0dc05e82095166458c72be5da4cb61d51812fb8
MATLAB
1,319
44
function surface_connectivity = calc_surface_connectivity(surface) % calc_surface_connectivity.m % % Calculate surface-based connectivity matrix % % Input: surface : surface structure with fields % vertices and faces % % Output: surface_connectivity : surface connectivity ma...
39f68ae8278a09b03dd174a477272080ea9b1f422d95cc796abe8647a085e6f3
MATLAB
1,320
52
% load data file ('dataf') preprocessed with fieldtrip % and show in eeglab viewer % % This function is provided as is. It only works for some specific type of % data. This is a simple function to help the developer and by no mean % an all purpose function. function [EEG] = fieldtrip2eeglab(dataf) [ALLEEG EE...
65192894a3da3146b64b3a27f140658d7e56a4bdae28de23f8d3c79c1a6ef9f9
MATLAB
1,321
63
function [X,Y,polygon] = UISelect %UISelect - Interactively select polygon zone in an existing plot. % % USAGE % % [X,Y,p] = UISelect % % X,Y polygon coordinates % p handle for polygon object in figure % % SEE % % See also UIInPolygon % % Copyright (C) 2009-2011 by Michaël Zugaro...
bd9e919885d2e9af77249f8f14d7035f47bdc50ac5d0a9507c419891b646fb83
MATLAB
1,321
52
% Euclidean distance between polyhedra in 2D % Section 8.2.1, Boyd & Vandenberghe "Convex Optimization" % Joelle Skaf - 10/09/05 % (a figure is generated) % % Given two polyhedra C = {x | A1*x <= b1} and D = {x | A2*x <= b2}, the % distance between them is the optimal value of the problem: % minimize || x ...
c89e7573c278e33349af2b5f27da53414951997d089b6cf4d76177512009cc03
MATLAB
1,321
40
function bz_EditSessionMetadata(basepath) % Sets up to allow user to edit session meta data in the specified session % basepath. Looks for a metadata file, if it doesn't find it, it creates a % copy of the default template in the basepath. Then opens the basepath % .SessionMetadataText.m file in the editor for user i...
fbbd41ea72f5c8371676f3c59db881829e26db1fdae627d9fdf0af04a1d450d6
MATLAB
1,321
37
function Y2d = palm_conv4to2(Y4d) % Convert a 4D dataset (x,y,z,t) into a 2D array (t,x*y*z) % that can be used in a multivariate GLM % % Usage: % Y2d = conv4to2(Y4d); % % _____________________________________ % Anderson M. Winkler % FMRIB / University of Oxford % Sep/2012 % http://brainder.org % - - - - - - - - - -...
0aab15f05ebd96f380dbfaf4468b9ddf9023458920f93b147b0867ad3c8486a6
MATLAB
1,322
40
function plotROItSNE(allROIs, color) % Plots tSNE coordinates for allROIS, all with one coloring if nargin < 2 color = 0.5*[1, 1, 1]; end % Create plot fig; axis square axis off % Get data allCoords = cat(1,allROIs.tsneCoords); % Get axis boundaries xLims = [min(allCoords(:,1)) + 0.2*min(allCoords(:,1)), max(al...
5723f5999fd486cf754a60acea30996f83d5954fd00f3e6856f2956a1eba1117
MATLAB
1,322
52
function [] = PL2Print(cellArrayOfStructures) % PL2Print(cellArrayOfStructures): prints cell array of structures % % PL2Print(cellArrayOfStructures) % % INPUT: % cellArrayOfStructures - cell array of identical structures % % OUTPUT: % prints specified cell array if nargin ~= 1 error 'expected 1 inp...
b552f2ebc9d38a9e844ef80eb858f7005c6dcfaf04dd8995e4fd56affbf4ca39
MATLAB
1,322
38
function y = avg_abs_dev_med( x, dim ) %AVG_ABS_DEV_MED Average absolute deviation about the median. % For vectors, AVG_ABS_DEV_MED(X) is the average absolute deviation of X % about its median; that is, AVG_ABS_DEV_MED(X)=MEAN(ABS(X-MEDIAN(X))). % For matrices, AVG_ABS_DEV_MED(X) is a row vector containing the...
d72bec24fb67b6294c0eaf09ac95f26ceb48683a9f8859b889f0df4ac55c8f68
MATLAB
1,322
42
% Euclidean projection on a hyperplane % Section 8.1.1, Boyd & Vandenberghe "Convex Optimization" % Joelle Skaf - 10/04/05 % % The projection of x0 on a hyperplane C = {x | a'*x = b} is given by % minimize || x - x0 ||^2 % s.t. a'*x = b % It is also given by P_C(x0) = x0 + (b - a'*x0)*a/||a||...
3fbe3f1ee06e796e94ebcb5358c7eac57c17722504bb973cccae3b8378d77bb1
MATLAB
1,323
40
function y = avg_abs_dev( x, dim ) %AVG_ABS_DEV Average absolute deviation (about the mean). % For vectors, AVG_ABS_DEV(X) is the average absolute deviation of X % about its mean; that is, AVG_ABS_DEV(X)=MEAN(ABS(X-MEAN(X))). For % matrices, AVG_ABS_DEV(X) is a row vector containing the average % absolute de...
88f111b2fc5d728356ee5fb9f614662564df26a5fac0182dc35d3c6909f69564
MATLAB
1,323
42
close all; clear; clc; addpath(genpath('../../functions/')); %% Read in Mem and EF subInfo = csvread('../../subInfo/rid_sex_mDoB_yDoB_mExam_yExam_ageExam_dx_icv_bl.csv'); rid_dx = subInfo(:, [1 8]); rid_viscode_examdate_mem_ef = CBIG_get_mem_ef(rid_dx(:, 1), 0); % all data of 810 subjects %% Compute normalization ...
4d9e79fda089720a13779192d1621a3f908c888408b3c218c1d606db63f723e7
MATLAB
1,325
35
function ea_atropos2segmask(rawSegmaskFile, anchorModality) % Convert atropos segmask (indices ordered by intensities) to standard OSS % segmask % By Butenko, konstantinmgtu@gmail.com arguments rawSegmaskFile % path to segmask generated by atropos anchorModality % first image used for atropos segment...
f86a4febca5f7cbcb1a8860ca971529f4b028a7b1273e8da96ae9cdb66ef9314
MATLAB
1,325
32
%CustomDefaults - User-defined custom default values for function properties. % % The behavior of most FMAToolbox functions can be modified using optional % property-value pairs, e.g. GetPositions returns position samples in different % coordinate systems depending on the property 'coordinates'. Such properties % u...
2e0ef8afbf95c40e65cf04f9b8b8cecc96607cd289964d20cc8d788dd8becff5
MATLAB
1,326
45
function x = cvx_collapse( x, keeptemp, tocell ) if nargin < 2, keeptemp = false; end if nargin < 3, tocell = false; end while true, sx = size( x ); nx = prod( sx ); switch class( x ), case 'cell', if nx == 1, x = x{1}; continue; end ...
9eceaf1aea5996a3f43bfbcc7ed778155801e2edfb06e31ae874f2335b501d45
MATLAB
1,326
33
function obj = set_text_options( obj , varargin ) % set_text_options Provide text size and font options % % 'name',value pairs: % 'base_size': Base text size, corresponds to axis ticks text size (default is 10) % 'interpreter': 'none'(default), 'tex' or 'latex' % 'label_scaling': Scaling of axis label sizes relative to...
ddfd83d333081ccbb259b2cc42661a87a7f39257498388e294ddb0c42b881d31
MATLAB
1,326
37
function [dtd err] = nifti_to_DTD(data_names,T) tensor = nifti_to_mrstruct('series3D',data_names); evals = zeros(size(tensor.dataAy,1),size(tensor.dataAy,2),size(tensor.dataAy,3),3); evecs = zeros(size(tensor.dataAy,1),size(tensor.dataAy,2),size(tensor.dataAy,3),3,3); for x = 1:size(tensor.dataAy,1), for y = 1:si...
12dd635994899d243a9a8aa13d72e26133ce28589f222d19d8b0966df3b7adcb
MATLAB
1,327
32
function cvx_optval = log_det( X ) %LOG_DET Logarithm of the determinant of an SDP matrix. % For a square matrix X, LOG_DET(X) returns % LOG(DET(X)) % if X is symmetric (real) or Hermitian (complex) and positive semidefinite, % and -Inf otherwise. % % When used in a CVX model, LOG_DET(X) causes CVX's s...
272d13efebafdf7ef5ce39ff0c047ff0778007e9a1735a323b4b7d0b6bfa025a
MATLAB
1,327
62
function [fnameArray] = path2array(fname) % function [fnameArray] = path2array(fname) % % takes in a string representing the path to a file or folder and breaks it % into a cell array in which each cell holds the portions of the filename % that were between file seperator symbols ('/' or '\'). % % This will help use ...
b231fcf289c6e773de0a5ba2eb4989a3191be8c6a32ab24366870223be1b62a2
MATLAB
1,327
51
function varargout= make_maximal_planar(A,varargin) % MAKE_MAXIMAL_PLANAR Add edges to construct a maximal planar graph % % M = make_maximal_planar(A) generates a new graph M with additional edges % so that adding any other edge will make a non-planar graph. % % [ei,ej] = make_maximal_planar(A) returns the additional...
dab6e971cb5c9f20e1f57366c2429bb1859312a3af0b431903130a3df23c75ac
MATLAB
1,327
51
function [res] = build_and_verify_mexPlex() % this script will build and verify mexPlex % % OUTPUT: % returns 1 if all verification tests passed % returns 0 if some of the verification tests failed % % if ReadingPLXandDDTfilesinMatlab-mexw.zip was inzipped to % % C:\PlexonMatlab % % this script should b...
4f3b383cfbcc4aa638600101b8b0f4b9251b8acc8fd0246d69686912aeda6002
MATLAB
1,328
36
function []=CBIG_gwMRF_create_FSL_LUT(filename,colors) % [] = CBIG_gwMRF_create_FSL_LUT(filename,colors) % % This function takes a nx3 colors vector, where n is the number of colors % and creates a FSL compatible LUT file. %input % - filename: the output .lut file % - colors: nx3 colors vector, where n is the number...
e92408d1f8f34560077efe372c04a224663a7f531f67d5932204ef934fb54022
MATLAB
1,328
40
function Yp = myPLS_permuteY(Y,grouping,grouped_perm) % This function permutes the Y matrix during permutation testing % % Inputs: % - Y : N x B vector, N is #subjects, B is #behavior/design % scores, behavior/design data (normalized) % - grouping : N x 1 vector, subject groupi...
2714d7498807d38162603f4cd673e6cf1b042ce951d518716f1293257ab425f2
MATLAB
1,329
38
function plot_matrix(X,t,f,plt,Xerr) % Function to plot a time-frequency matrix X. Time and frequency axes are in t and f. % If error bars are specified in Xerr, % it also plots them. Xerr contains upper and lower confidence intervals % on X. % Usage: plot_matrix(X,t,f,plt,Xerr) % Inputs: % X: input vector as ...
2d5bb59ad836690e8a572194f03ee5278d58a9cef3d80dc798cbe6d2d684793e
MATLAB
1,329
47
%% Optimization of a simple (Rosenbrock) function, with no constraints rosen = @(x) (1-x(1)).^2 + 105*(x(2)-x(1).^2).^2; % With no constraints, operation simply passes through % directly to fminsearch. The solution should be [1 1] xsol = fminsearchbnd(rosen,[3 3]) %% Only lower bound constraints xsol = fminsearchbnd(...
654a3cdc632aae15136e6b3482d39052b3d16863eba77a39bf5d4bb38bf47f4b
MATLAB
1,330
54
function write_vtk(fn, pnt, tri) % WRITE_VTK writes a triangulation to a VTK (Visualisation ToolKit) format file. % Supported are triangles, tetraheders and hexaheders. % % Use as % write_vtk(filename, pnt, tri) % % See also READ_VTK, WRITE_PLY % Copyright (C) 2002, Robert Oostenveld % % $Id$ fid = fopen(fn, 'wt')...
ade67a729cecfeac8d4e952ccc16200a290ea153736bd34a82994b414feb63d6
MATLAB
1,330
49
function cvx_optval = huber_pos( x, M, t ) %#ok %HUBER Internal cvx version. % % Check arguments % narginchk(1,3); if ~cvx_isconvex( x ), error( 'Disciplined convex programming error:\n HUBER_POS is convex and nondecreasing in X, so X must be convex.', 1 ); %#ok end if nargin < 2, M = 1; elseif isa( M, ...
1d4a344a8494592f146f830c2baec638055ab5546ee872adaedf006c033d8bb4
MATLAB
1,331
44
function [s] = keepfields(s, fields) % KEEPFIELDS makes a selection of the fields in a structure % % Use as % s = keepfields(s, fields); % % See also REMOVEFIELDS, COPYFIELDS % Copyright (C) 2014, Robert Oostenveld % % This file is part of FieldTrip, see http://www.fieldtriptoolbox.org % for the documentation and d...
32482d224d14697956a438eee6a50f153cf4729b69d5f1028eb25258cd403a2c
MATLAB
1,331
25
% demo_SOFAplotHRTF - script demonstrating the usage of SOFAplotHRTF % Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences % Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License") % You may n...
672dab7b09d35adefd14830899a9d46aac8182cbe4398389ba69f337adaa8692
MATLAB
1,331
51
function RecreateTspFile(fbasename) tspdata=load([fbasename '.tsp']); tspdata = tspdata(:,1); if size(tspdata,2)>1 warning('tsp has data in it! Are You sure you want to continue?') % keyboard end nFramesTsp = size(tspdata,1); tspnew = [tspdata -1*ones(size(tspdata,1),6)]; %readerobj = VideoReade...
a962c377a91858fa92f57ddf37f79077a3c1213e1aef45bc025320fd46c68efa
MATLAB
1,331
39
function [] = ea_defaultview(varargin) % saves and sets default view preferences % there must be Electrode-Scene figure % % ea_defaultview() saves current view as default view % % ea_defaultview(v,togglestates) sets view and togglesates H = findall(0,'type','figure'); resultfig = H(~cellfun(@isempty,strfind({H(:).Name...
48f7b13ba770c30ad2de90125be6a08de95de6f0a7c6e2b5fc4c263a2e92447f
MATLAB
1,332
54
function y = nanmean(x,dim) % FORMAT: Y = NANMEAN(X,DIM) % % Average or mean value ignoring NaNs % % This function enhances the functionality of NANMEAN as distributed in % the MATLAB Statistics Toolbox and is meant as a replacement (hence the % identical name). % % NANMEAN(X,DIM) calculates the mean ...
affa54eb7a9157c2167852b3c9387807163b23db18b8c4bf66f522602c7a0ce5
MATLAB
1,332
42
function [linehandles, patchhandles] = errorarea(x,y,l,u) %ERRORAREA Plot with confidence region. % ERRORAREA(X,Y,L,U) is similar to ERRORBAR(X,Y,L,U), except that the % confidence bounds are drawn as a shaded patch above and below the % plot. ERRORAREA(X,Y,E) and ERRORAREA(Y,E) are similarly allowed and...
f8fa5d0e74ce426ac886a44bfde28c2c3aaf576a0e2c199851818aa7a38e06c8
MATLAB
1,332
49
function outpoints = mni2tal(inpoints) % MNI2TAL - MNI to Talairach coordinates (best guess) % % outpoints = mni2tal(inpoints) % % inpoints - Nx3 or 3xN matrix of coordinates % (N being the number of points) % % outpoints - the coordinate matrix with Talairach points % % See also, TAL2MNI, MNI2TAL_MATRI...
273f9dfe09eef30779760f5a8507fa7ed921a8410601b2d733c5212e89af2e16
MATLAB
1,333
48
% Expand a multiple-scan NIFTI file into multiple single-scan NIFTI files % % Usage: expand_nii_scan(multi_scan_filename, [img_idx], [path_to_save]) % % NIFTI data format can be found on: http://nifti.nimh.nih.gov % % - Jimmy Shen (jimmy@rotman-baycrest.on.ca) % function expand_nii_scan(filename, img_idx, newpath) ...
ef3f97eaaa30ea7298729b2528a167d19c29dd9e6c3242b05f077747da504224
MATLAB
1,333
47
function ea_Bmap(varargin) % creates a regression nifti file + intercept term given a set of images and a % regressor % ea_Rmap(fis,regressor,outputname,mask,sk,corrtype) % sk can be 'k','s','sk' % for smoothing and normalization options. Mask only necessary if % choosing 'k' option. re...
ff775284f4faad8d221008a09db77c111ffa6d1347d181d0bc8265e3a5c410a0
MATLAB
1,333
45
% Sparse covariance estimation for Gaussian variables % Joëlle Skaf - 04/24/08 % (a figure is generated) % % Suppose y \in\reals^n is a Gaussian random variable with zero mean and % covariance matrix R = \Expect(yy^T), with sparse inverse S = R^{-1} % (S_ij = 0 means that y_i and y_j are conditionally independent)....
055ae485fc5d74f89f67ed6cc8f3dbd36ee43aa8093b313061241876ed07927b
MATLAB
1,335
56
darn=[] dar=reshape(rr1([1:nimtr*ntr]+noff,:),[nimtr ntr size(rr1,2)]); for mm=1:4, darn(:,:,mm)=dar(:,:,mm)./(ones(150,1)*squeeze(mean(dar(1:25,:,mm),1))); end; %figure; plot(dar(:,:,1)) spacing = 1; figure; hold on yshift=0; wROI=1; for iii = 1:size(dar,2) plot(tt,dar(:,iii,wROI)+yshift) yshift=yshift+spa...
65c98fa530307fee71bd725ff7daeae62a64b0e4f5e84fe035658e10e6d67f4f
MATLAB
1,335
33
function [dx, dy] = pbc_dist_LE(dx_old, dy_old, box_L, strain_value) % PBC_DIST_LE Minimum-image displacement under Lees-Edwards (sheared) % periodic boundary conditions. % % [dx, dy] = PBC_DIST_LE(dx_old, dy_old, box_L, strain_value) applies % the Lees-Edwards convention: when a displacement wraps across the top ...
9693ba1518e41e1fca457022c15cb2d3cb1807f34aac5f4bec3f8a37739a9ce6
MATLAB
1,335
28
function dbPath=SOFAdbPath(newPath) % dbPath=SOFAdbPath % % dbPath=SOFAdbPath returns the path to the directory containing % HRTFs for demos and applications. The default path is: this_directory/../HRTFs/SOFA % % [...]=SOFAdbPath(Path) sets the path to the directory for further calls % of SOFAdbPath. ...
f2f66c2c2672bab0c8ec8dce1c3cd2d5031913e2e5a1c6ea815e9ec0aacb1ba3
MATLAB
1,335
47
function [FinalImage, medTime] = j_load_downsample_TiffStack_3(FileTif, n, factor, verbose) if(nargin<4) verbose = true; end if(nargin<3) factor = 1; end InfoImage=imfinfo(FileTif); mImage=InfoImage(1).Width; nImage=InfoImage(1).Height; if(isinf(n) || n>le...
fad56bd235017ee7ce92d374370624cc92659d3d21349b2faddbbc8fb15791e3
MATLAB
1,335
50
function [relPath] = relativePath(basePath,newPath) % function [relPath] = relativePath(basePath,newPath) % % Returns the relative path from 'basePath' to 'newPath' % eln 100415 % compute where all the file seperators are in the basepath bp = fullfile(basePath,'.'); bpDirMrks = ismember(bp,filesep); bpDirMrks = cumsu...
2207d8e8d04a9cefca06eeff9e618a3940913343a9c24c981bc3bd0ca3c3e0c7
MATLAB
1,337
32
function lambdaGrid = enetLambdaGrid(opts) % enetLambdaGrid Resolve the Elastic Net lambda path from an options struct. % % lambdaGrid = enetLambdaGrid(opts) returns opts.lambdaGrid if present and % non-empty, otherwise the family default logspace(-3,1,25). % % This exists so that the point estimate (ENet_neuroi...
3894cb6af17eda30189b62d21ea6c7f6a7e54823fb20537aa75467c2d879efe2
MATLAB
1,337
44
function [s] = removefields(s, fields) % REMOVEFIELDS makes a selection of the fields in a structure % % Use as % s = removefields(s, fields); % % See also KEEPFIELDS, COPYFIELDS % Copyright (C) 2014, Robert Oostenveld % % This file is part of FieldTrip, see http://www.fieldtriptoolbox.org % for the documentation a...
689ceac54e845b02d89d9dbf20a4685e53d360b82c99e16c0d1892dea91c15ac
MATLAB
1,337
39
temIMG = imread("cc_AC_sulcus_large.jpg"); cc_AC_sulcus_large = temIMG(1:5:end, 1:5:end, :); temIMG = imread("cc_PFC_sulcus_large.jpg"); cc_PFC_sulcus_large = temIMG(1:5:end, 1:5:end, :); temIMG = imread("cc_AC_sulcus_square.jpg"); cc_AC_sulcus_square = temIMG(1:3:end, 1:3:end, :); temIMG = imread("cc_PFC_sulcus_squ...
8eedb9413bcc6194322bb47b31a52f34621d4bbce3d74b9333479beb5cac5d9c
MATLAB
1,338
25
function ANN_default_settings = ea_get_default_ANN_settings() % pathway settings ANN_default_settings.connectome = 'Multi-Tract: M1LowerExDS'; ANN_default_settings.pathway = 'M1_cf_lowerex'; ANN_default_settings.fiberDiameter = 4.0; % in um ANN_default_settings.axonLength = 15.0; ...
49722030f8772ea4e97afbcdbac6f747aa79e5e4f9caa4357c42b4fed3da2bc0
MATLAB
1,339
34
function [fibidx,peakvals,meanvals,sumvals,peak5vals,binvals] = ea_explorer_efoverlapfiber(vol,img,fibers) fibers = single(fibers); if ~isequal(sort(fibers(:,4)),fibers(:,4)) keyboard end %% convert fibers to vx-coordinates fibersorg = fibers; fibers = vertcat(fibers(:,1:3)',ones(1,size(fibers,1))); fibers = round(...
5217b3b14224b429339ea80e79c2f80ed22f3dfb9cad74a054907ca8f0d4f6c7
MATLAB
1,339
42
function [betas, stats] = CBIG_fitGLM_3t(subInfoFile, GMICVFile) % [betas, stats] = CBIG_fitGLM_3t(subInfoFile, GMICVFile) % What is the subtype order? % Offset by 1, the RID column % % Written by CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md SUB_COL = 1+3; COR_COL = 1+1; fprintf...
a9e72d3cbddbd900a7de820fafb69fd1508569aff184c3ee8febee815ef642b7
MATLAB
1,339
20
tmptmptext = strvcat(' EEGLAB 1997-2010 (compiled version)', ... ' ', ... ' ', ... 'The EEGLAB electrophysiological data analysis software is an open source research', ... 'project developped at the Swar...
2176d8da23b7341e66b2e2a9ec849877e66a0dfb243cd47b7b0d3bb69ef05681
MATLAB
1,340
24
% CVX: A system for disciplined convex programming. % CVX is a modeling framework for building, constructing, and solving % disciplined convex programs. % % cvx_setup - Sets up and tests the cvx distribution. % cvx_error - Formats text for inclusion in error messages. % cvx_license - Licen...
ba789ee1a032abd47c5842b0fa78fa9aca788bd2d85d75c1996ee6fb6dd79dc0
MATLAB
1,340
53
function [] = gen_logbf_barplot(logbf, modelnames, outpath) if nargin > 2 ifSave = true; else ifSave = false; end % Prepare data nSubjects = numel(logbf); for i=1:nSubjects ytl(i) = strcat("m", num2str(i+1, '%02i')); end f = figure('Renderer', 'painters', 'Posit...
08297401e469e1a5a80d6249436294addce0bd0a85e35c10d391521ca8860fa9
MATLAB
1,341
54
function [x,yp_out,xi_mid,yi_mid]=calcRadius3b(proj,mii) % Usage ... x=calcRadius3b(proj,mii) if (nargin<2), mii=[]; end; if (isempty(mii)), plen=length(proj); pleni=ceil(0.05*plen); %mii=[1 pleni+1 plen-pleni plen]; mii=[1 2 plen-1 plen]; mii_std0=std(proj(mii)); if (plen>8), for mm=3:4, tmp_mi...
319c5daa6169056417907224e8e1a26409c39d5535dfb0a87215b5ce15609fd1
MATLAB
1,341
49
function CBIG_pMFM_dwell_time_empirical() % This function is used to compute the dwell time distirbution for empirial % data % % Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md load('../../../part1_pMFM_main/output/step5_STDFCD_results/STD_FCD_empirical_r...
555bfe5ece1a99c064cdb0c95b55e4602c9d2f04a7c841d2203a33cdd240efca
MATLAB
1,341
43
% nan_mean() - Average, not considering NaN values % % Usage: same as mean() % Author: Arnaud Delorme, CNL / Salk Institute, 16 Oct 2002 % Copyright (C) 2001 Arnaud Delorme, Salk Institute, arno@salk.edu % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General P...
b7215a07eb10e946d0e5ae9634734e8f37e2bcc05cdd30ca968d7a5db24dc9b4
MATLAB
1,341
36
function data_out = Trinh_loadConditionData(filename,eventtype,eventvalue,prestim,poststim) %% load and cut condition data % insert name of the file: filename, e.g., 'MUSICOM_001.vhdr' % eventtype, e.g., 'Stimulus' or 'Trigger' % eventvalue, e.g., 'S 1' in cell % define how much to cut before and after trigger %...
b79fa46a91b83b7e42222f1c0835e3361304f42f5aee9b0d93832d52edf9acf5
MATLAB
1,341
40
function [tra, presentfiles] = ea_assignpretra(options) % Stub function for BIDS compatibility % Returns anatomical files present in the patient directory directory = [options.root, options.patientname, filesep]; % Check for BIDS preprocessing/anat files preprocAnatDir = fullfile(directory, 'preprocessing', 'anat'); ...
b863b7672e8f1d636c15ac2a741f6c0a8d9e1400c79dd0c2cffc16bdda9699eb
MATLAB
1,341
47
function varargout = outselect(index,sub_idx,func,varargin) %OUTSELECT Select output arguments of a function. % OUTSELECT(I,FUNCTION,P1,P2,...) returns one or more of the outputs, % as selected by the integer(s) in vector I, resulting from the % function call FUNCTION(P1,P2,...). FUNCTION can be a handle or ...
a02ebaf81c416548448af4d4cb149e5ee7219bbc31b4367efa851af84fa366ec
MATLAB
1,342
48
function [varsel] = Selfeature(handles, ttlabel, mainfig_pos) varsel = []; scrsz = handles.scrsz; pos = mainfig_pos; pos(1) = pos(1)+100; pos(3) = pos(3)-300; hplot = figure(25); clf('reset') set(hplot, 'NumberTitle', 'off', ... 'MenuBar', 'none', ... 'ToolBar', 'none', ... ...
c0eeece724809c6b03180bba4843453aee7b75d24fc26c5d739877c996403746
MATLAB
1,342
40
function numSegments = getNumSegmentsPerTrack(tracksFinal) %GETNUMSEGMENTS gives back the number of segments in each compound track % %SYNPOSIS numSegments = getNumSegmentsPerTrack(tracksFinal) % %INPUT tracksFinal: Output of trackCloseGapsKalman %OUTPUT numSegments: Vector of number of segments in each compound track...
18de3aa037c3466b4a01505ca3a88cf860b67e3b00eafd319115208bd8d2208d
MATLAB
1,343
47
function [ X,T ] = OUNoise(theta,sigma,duration,dt,save_dt,numsignals) %[ X,T ] = OUNoise(theta,sigma,duration,dt,save_dt,numsignals)) simulates %Ornstein-Uhlenbeck noise with standard deviation sigma and characteristic %frequency theta. %Initial conditions: random value from normal distribution around 0 with %std=sigm...
85f59126fb6e7d00968a64633c4fa693e980e0ea400c7181a9c793071243f803
MATLAB
1,343
39
function dFoF = dFoFcalc(rawF,baseIDX,traceDim) % dFoFcalc output deltaF/F for a vector, matrix, or cell array of raw F. % dFoF = dFoFcalc( % rawF, --> raw fluorescence as vector, matrix, or cell array % baseIDX, --> [first last] indices of rawF to be used for F0 calculation % trace...
ad525d16a48304ec63a4364c7dc19cdb566b85ecbb21c4adefa3ee38475f1c93
MATLAB
1,343
29
function ea_atlas2conn(atlasFolder, connectomeName) % Convert atlas that contains fiber tracts into normal dMRI connectome % Retrieve left side tracts leftTracts = ea_regexpdir([atlasFolder, filesep, 'lh'], '^(?!\.).*\.mat$', 1); [~, leftTractNames] = cellfun(@fileparts, leftTracts, 'Uni', 0); leftTractNames = strcat(...
1d7158e6dd2d8c996433b6517f83650909cc15f92eb959cd5563dd9a63e7a506
MATLAB
1,344
42
%%************************************************************************* %% ToeplitzApproxSQQ: find the nearest symmetric positive definite Toeplitz %% matrix to a given symmetric matrix F. %% %% max -y0 %% s.t. y0*B + T(y) (S>=) 0 %% [y0; gam.*y] + [0; q./gam] ...
d64d0814fce23858bb74af13bd5073576d3d0bb3d62f7db250f63731f42dc696
MATLAB
1,345
57
%XMLDEMO3 Demonstrate how to convert an XMLtree in a simple structure % % Description % This script demonstrates the use of the xmltree class to % convert an XMLtree (when possible) in a simple structure. % This can only be performed when the XML file is simple enough % (one element cannot have more tha...
699ee468fe53a20942dbfa64cb87cdc6e155b33e2efdcb2be8397c22d18192d0
MATLAB
1,346
33
function plotModulatedROIsCCF(dorsalMaps, allROIs, modField) % Plots the ROI centroids colored by modulated and unmodulated % Figure allenMapSMc(dorsalMaps, [-3.6, 0, -2, 3]) % Creates figure by itself % Set sizes % Paper ready figure/axis formatting panelWidth = 1.699*1.1; panelHeight = 2.2*1.1; % This is the only w...
1a6e4a85cf990f6c414a543729a930a563a391f71057644dba09bc6ba99ebafe
MATLAB
1,347
46
function [v,data,namelist] = Dynamic_read_dir_NIFTI_sparse(sub_dir,filter_str) if nargin==1 filter_str = ''; end flag = 0; [fpath,name,ext] = fileparts(sub_dir); if strcmp(ext,'.nii')||strcmp(ext,'.img')||strcmp(ext,'.hdr') if strcmp(ext,'.hdr') niiname.name = [name,'.img']; else niiname.nam...
55c8f7ee284e69e0fd21deec5694d23487194a04863d4f5e99b943dcf1467f24
MATLAB
1,347
27
plugin_find_master_script_directory; %% SUMMARY % Load and print summary of study from study_info.json and contrast info % ------------------------------------------------------------------------- scriptname = which(fullfile('Second_level_analysis_template_scripts', 'core_scripts_to_run_without_modifying', 'b_reload_...
6504ffdedf0730722a6c8c639e660169f2488a04fe3959cbba9653efb8d2ea6d
MATLAB
1,347
49
function [A] = clique_graph(n,varargin) % CLIQUE_GRAPH Generate the clique graph or bipartite clique graph % % The clique graph is a graph with as many edges as possible. % % A = clique_graph(n) generates a clique with n vertices and returns the % adjacency matrix A. % % A = clique_graph([m n]) generates a bipa...
132c01903f87434714d8a36ff2df4e9e97465b1330641146b15902555a04c684
MATLAB
1,348
37
function [fMRI_CM,gmtc] = ea_createCM_fmri(options) expfolder=[options.root,options.patientname,filesep,'connectomics',filesep,options.lc.general.parcellation,filesep]; % check if rest_preprocessing has been performed: [~,restfname]=fileparts(options.prefs.rest); [~,anatfname]=fileparts(options.prefs.prenii_unnormaliz...
e8a3b591ef18c843726fc4158ed8d4ab87ad84f6f4c0184b73f219675c1f838e
MATLAB
1,348
44
function t = toeplitz( c, r ) % Disciplined convex/geometric programming information for TOEPLITZ: % TOEPLITZ imposes no convexity restrictions on its arguments. % Instead of using the TOEPLITZ function, however, consider % creating a matrix variable using the 'toeplitz' keyword; e.g. % var...
583fdaf4d9612d658827c5a0d4298e5ce63d911397af136e51c5cb6376179053
MATLAB
1,349
30
function [lh_grad_matrix,rh_grad_matrix]=CBIG_gwMRF_gradient_vertices_to_matrix(lh_grad,rh_grad,fsaverage) %% this function creates two 6xN GradientMatrices from two 1xN GradientVectors % - Input % - lh_grad = left hemisphere vector % - rh_grad = right hemisphere gradient vector % - fsaverage = t...
76e09fc3c3cc055e13e7fcc6a6bc5facbf767fa2fc63eaa7c52ce721b50fa475
MATLAB
1,349
26
function ea_add_networkmapping(~,~,leadgroup,resultfig) % small function to open ea_networkmappingexplorer. lead group can be a path to % either lead group analysis file or saved fiber explorer. if ismember('M', who('-file',leadgroup)) % Add new network mapping analysis exp = ea_networkmappingexplorer(leadgroup,re...
29525b6ebcc7ed4f5879833904dc14d0085a15469be24f0138e44a01724cee14
MATLAB
1,350
34
% Local Regression and Likelihood, Figure 6.1. % % Derivative (local slope) estimation, for the Old Faithful Geyser Data. % The 'deriv' argument specifies derivative estimation, % 'deriv',1 First-order derivative. % 'deriv',[1 1] Second-order derivative. % 'deriv',2 For bivariate fits, part...
50dd746dbdd37bf910b01734ef181b05ddf2cea1db8c434cbde37d53d74d1b25
MATLAB
1,350
28
function [azi,ele] = sph2nav(azi,ele) %SPH2NAV Coordinate Transform % [azi,ele] = sph2nav(azi,ele) converts spherical coordinates to % navigational coordinates. % % Input: % azi ... azimuth (0 <= azi < 360) % ele ... elevation (-90 <= ele <= 90) % % Output: % azi ... azimuth (-180 <...
6a3ba2eafec57e75d5cc8c7570aa770712e75a31484a4e34f50afa28429a98ec
MATLAB
1,350
44
function tree = copy(tree,subuid,uid) % XMLTREE/COPY Copy Method (copy a subtree in another branch) % FORMAT tree = copy(tree,subuid,uid) % % tree - XMLTree object % subuid - UID of the subtree to copy % uid - UID of the element where the subtree must be duplicated % % Copy a subtree to another branch. %...
866f89f4d28010822d5d92c1385d15c635b454e9ba56205c1f0e92ae8d164341
MATLAB
1,350
39
function test_spanning_trees msgid= 'matlab_bgl:test_spanning_trees'; %% mst % make sure mst('kruskal','root') fails load('../graphs/clr-24-1.mat'); try T = mst(A,struct('algname','kruskal','root',5)); error(msgid,'mst(kruskal,root) did not report an error'); catch end %% prim_mst load('../graphs/clr-24-1.m...
a603b101ede85d13600e8920e7c95547fdbab6fa6809547fc5a751d4ba4e1db9
MATLAB
1,350
50
function printFigure(fh,size,type,fileName,fileType,subindex,crop) % parameters: % 1: figure handle % 2: position and size in cm [left, bottom, width, height] % 3: formatting ('paper','poster','presentation','icon') % 4: filename % 5: graphic format as in print, i.e '-dpng', '-depsc' % 6: panel labels ('lcletter...
b94818507ae17d35ec5be02d557003c66549dd1db9ed16670f67afb9eda4067e
MATLAB
1,350
44
% pop_runscript() - Run Matlab script % % Usage: >> pop_runscript; % >> pop_runscript( filename ); % % Input: % filename - [string] name of the file. % % Author: Arnaud Delorme, SCCN / INC / UCSD, August 2009 % Copyright (C) Arnaud Delorme, August 2009 % % This program is free software; you can redistribute i...
131fbe64450431942e6abb4aec73ff865dd0c21827b682acf7e7cf2c767c69ae
MATLAB
1,351
47
%%*********************************************************** %% lmiexamp1: generate SDP data for the following LMI problem %% %% max -eta %% s.t. B*P + P*B' <= 0 %% -P <= -I %% P - eta*I <= 0 %% P(1,1) = 1 %%*********************************************************** %% Here is ...
ad034ef84a70a5572485f40b4baa167bb64bdd1174f6be7c54302f1ced3785ed
MATLAB
1,351
42
function y = istrue(x) % ISTRUE ensures that a true/false input argument like "yes", "true" % or "on" is converted into a boolean % Copyright (C) 2009-2012, Robert Oostenveld % % This file is part of FieldTrip, see http://www.fieldtriptoolbox.org % for the documentation and details. % % FieldTrip is free software:...
084a75e0d6777cc0eaaa3b447f5f616bcc7b0393f635c8b2c60d8d8a87aa8b8a
MATLAB
1,352
38
% erpregoutfunc() - sub function of erpregout() used to regress % out the ERP from the data % % Usage: % totdiff = erpregout(fact, data, erp); % % Inputs: % fact - factor % data - [float] 1-D data (time points). % erp - [float] 1-D data (time points). % % Outputs: % t...
3b3bda8f5e6814344834d433795ddc3f0c6df5fd4569fb030f2978dfa0a6c8dd
MATLAB
1,352
37
function [rid_diagnosis, rid_ICVoverGM, rid_prob, rid_age, rid_sex, rid_edu] = CBIG_get_data(subInfoFile, GMICVFile, K) % [rid_diagnosis, rid_ICVoverGM, rid_prob, rid_age, rid_sex, rid_edu] = CBIG_get_data(subInfoFile, GMICVFile, K) % Subject information % % Written by CBIG under MIT license: https://github.com/Thomas...
502eb9c1197ea8a428ccd9f8be1810514c8ccdc6c30a97e61ca2a05429f24072
MATLAB
1,352
40
% At startup, matlab will find a file startup.m assumed to be located in directory specified by % the environmental variable MATLABPATH (see http://www.mathworks.com/help/matlab/ref/startup.html). % % Written by CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md if (~isdeployed) ...
9d7dc94ce180b7bc476ca392adbafb871f16d2a1cd292706759fba57e1071bc7
MATLAB
1,353
53
function f = CBIG_plotCmp(A, xlimCmd) % f = CBIG_plotCmp(A, xlimCmd) % % Written by CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md no_comparisons = size(A, 1); y_max = (no_comparisons-1)*2+1+1; % Decide figure height if no_comparisons == 3 % K = 2 dy_fig = 295; elseif no_com...
7f90551cedf910616fedae74b12185ade9aa16b2ec3d23bc9aa6bd29cb83869b
MATLAB
1,354
36
function CB_logmenu(handle, event) %CB_LOGMENU Callback for UIlogmenu. %%%%%%%%%%%%%%%%%%%%%%%% Determine toggle state %%%%%%%%%%%%%%%%%%%%%% userdata=get(handle, 'UserData'); checked = onoff2bool(get(handle,'Checked')); if (checked), scale = 'linear'; else scale = 'log'; end; set(handle, 'Checked', bool2o...
f1cec68adb109f13e455940330fc4259a7a2c8f1fa579fa0eb2f83675a2492f1
MATLAB
1,354
59
function ea_3dgauss_from_pointlist(ptlist,fname) [gauss3d,mat]=d3gauss(ptlist(:,1),ptlist(:,2),ptlist(:,3)); V=ea_synth_nii(ea_niigz(fname),mat,[16,1],gauss3d); gauss3d=gauss3d/max(gauss3d(:)); gauss3d(gauss3d<0.001)=0; spm_write_vol(V,gauss3d); function [P_Gaussian,mat]=d3gauss(var1,var2,var3) Data=[var1,var2...