sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
0b67fdc319806aef46a6d3d774d906d901c4940b184a576287a089b38c6afe7a
MATLAB
650
20
function y = square_pos( x ) %SQUARE_POS Square of positive part. % SQUARE_POS(X) is the square of the postive parts of the elements of X; % i.e., SQUARE_POS(X)=MAX(X,0).^2. X must be real. % % Disciplined convex programming information: % SQUARE_POS(X) is convex and nondecreasing in X. Thus when used i...
5314a43476ffb1775d6662bcb63ebd70ab67e1986de04ae85c79e92b1cb6e45f
MATLAB
650
27
RandPhi = 2 * pi * rand(100000,1); RandTheta = pi * rand(100000,1); RandPts = [cos(RandPhi), sin(RandPhi).*cos(RandTheta), sin(RandPhi).*sin(RandTheta)]; tic [tmp, tmp, TreeRoot] = kdtree(RandPts, []); TestPhi = 2*pi*rand(100,1); TestTheta = pi*rand(100,1); TestPts = [cos(TestPhi), sin(TestPhi).*cos(TestThet...
dd4cbc126828682a5c10e0a2d4a68ef4a5aed6f8dbe013f8e51fa7aad0c1bc42
MATLAB
650
18
%this function loads a scanimage type tif but ignores metadata %this doesn't handle 2 channel tifs function justImgData = justLoadTif(TifFile) tifInfo = imfinfo(TifFile); nFrames = length(tifInfo); warning('off','MATLAB:imagesci:tiffmexutils:libtiffWarning'); warning('off','imageio:tiffmexutils:libtiffWarning'); ...
de1b0437b70277d30b7cffbc0ef921976339f25ea962a3b916354a434b970a33
MATLAB
650
19
function [HR, bad, nCh] = estimate_hr_snr_bad(dOD_hp, Fs, snr_thr) %NIRSPROC.ESTIMATE_HR_SNR_BAD HR (Hz) from spectrum and SNR-based bad channels. % [HR, bad, nCh] = ESTIMATE_HR_SNR_BAD(dOD_hp, Fs, snr_thr) % channel count per wavelength nCh = size(dOD_hp,2)/2; [freq,amp] = get_spec(Fs, mean(dOD_hp(:, std(dO...
24446ac96754e64b70f61254dc7939141a6a9c7cf6b7641a11aa992d2dd159ff
MATLAB
651
36
function truefalse = ch_eqi ( c1, c2 ) %*****************************************************************************80 % %% CH_EQI is a case insensitive comparison of two characters for equality. % % Example: % % CH_EQI ( 'A', 'a' ) is TRUE. % % Licensing: % % This code is distributed under the GNU LGPL licen...
f8c4b92413bdffc976ac0ed72f145a27cf28ea95b0d6a95f90f8eb562c0bc324
MATLAB
651
26
function [wMean, wStdDev] = CBIG_compute_weightedMeanStdDev(X, y) % [wMean, wStdDev] = CBIG_compute_weightedMeanStdDev(X, y) % % Written by CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md no_subtypes = size(X, 2); %--------- Compute weighted mean wMean = zeros(1, no_subtypes); fo...
a49f05150d70208f5e5f08e675ada6f44eda0a597b32ecb5b7272d2436bfbd43
MATLAB
653
18
function s = char(tree) % XMLTREE/CHAR Converter function from XMLTree to a description string % FORMAT s = char(tree) % % tree - XMLTree object % s - a description string of an XMLTree %__________________________________________________________________________ % % Return a string describing the XMLTree: % ...
20bd1716887c6a148f2f705acd882cf8b52927afefa8a363d5f1d89743b24ca4
MATLAB
655
25
%%*************************************************** %% qprod: %% %% Input: A = [A1 A2 ... An] %% x = [x1; x2; ...; xn] %% Output: [A1*x1 A2*x2 ... An*xn] %% %% SDPT3: version 3.1 %% Copyright (c) 1997 by %% K.C. Toh, M.J. Todd, R.H. Tutuncu %% Last Modified: 16 Sep 2004 %%**************************************...
2ba9da755c98548a3514000d7dd3f215341a88de890acc42310ba5fcbeffcd25
MATLAB
655
30
function [p,s] = project2surf_V7(p,s, subnr) % [p,s] = project2surf(p,s, subnr) % % % %setenv('FREESURFER_HOME','/home/inverse/freesurfer/freesurfer') Hemis={'lh', 'rh'}; FS_surfDir = fullfile(p.FS_subDIR, p.subNames{subnr}, 'surf'); % make cellarray with scannames scanlist = cell(1,2); for ii = 1:length(p.ppscanNam...
bbe00bad6d2617fa6779180c30392d3b8a88d986e3ec4a13f144e0729fbf84a6
MATLAB
655
18
function [handles] = get_spineROImask(handles) roi_mask = zeros(size(handles.im_norm)); handles.size = size(handles.im_norm); if ~isempty(handles.roi) if size(handles.roi,3) ~= size(handles.spine_trace,2) waitfor(msgbox('Number of trace and number spine ROI inconsistent',... 'Warning', 'warn'))...
4bd3eec14d14776cd51ae319e5a8136d22a43816a0cf31ba96d60c5aea85d2f4
MATLAB
656
28
function [A,sumV] = quadcof(N,NW,order) % Helper function to calculate the nonstationary quadratic inverse matrix % Usage: [A,sumV] = quadcof(N,NW,order) % N (number of samples) % NW: Time bandwidth product % order: order (number of coefficients, upto 4NW) % % Outputs: % % A: quadratic inverse coefficient ...
c987923b1f7a21ec774c2604f3457f142708ac50452036b35528d619ffdaccb7
MATLAB
656
23
function [labels_cell, Z] = frid_edit_multiple_k(X,k_list,H,alpha) num=size(X,1); [r,~]=size(H); options = optimset( 'Algorithm','interior-point-convex','Display','off'); A=2*alpha*eye(r)+2*H*H'; A=(A+A')/2; B=X'; parfor ji=1:num ff=-2*B(:,ji)'*H'; ff = double(ff); Z(:,ji)=quadprog(A,ff',[],[],[],[],-on...
476497d35b53d6bd2b974d06eae3ec2f1638b3989c7a4c8d4234dccdd6ee1317
MATLAB
658
24
% Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md % reorient all images in the raw folder spm_tool_dir = [spm_dir '/toolbox/OldNorm/'] addpath(spm_dir) addpath(spm_tool_dir) % roughly translate the image x = load(reorient_sample); f = strtrim(image_path); N ...
bd2aa057b89012f163461876c6936865d51d78e7f66e35e4b980455a1679b9a9
MATLAB
658
22
function model = fitAllROIsGMM(allROIs, metricField, options) % Fits Gaussian mixture model distributions to all feature vectors, area % agnostic % Get metrics z-scored for all neurons switch metricField case 'PCs' metrics = cat(1, allROIs.PCs); metrics = metrics ./ std(metrics); % z-score case...
62dcd80e52832706d7cc65fa5e51c6e7502b684421e5763e865aec8fcb1ab9ca
MATLAB
659
25
function [y] = cut_line_to_pieces(x, nperpiece) % File: cut_line_to_pieces.m % Author: Ioannis Filippidis, jfilippidis@gmail.com % Date: 2012.06.21 - % Language: MATLAB R2012a % Purpose: calculate vertex groups to break a line into multiple segments % Copyright: Ioannis Filippidis, 2012- [nrow...
e7143c887bef25b2cc371b9eac6bbe7ee0d8a02e20693db4b5c4ccf713637d52
MATLAB
659
31
function nodevol=nodevolume(node,elem) % % nodevol=nodevolume(node,elem) % % calculate the Voronoi volume of each node in a simplex mesh % % author: Qianqian Fang, <q.fang at neu.edu> % date: 2009/12/31 % % input: % node: node coordinates % elem: element table of a mesh % % output: % nodevol: volume values...
05524df0c48d00db7d9878056ae9fd6ac43e92c2a37f3b4175cf819fa7bf610b
MATLAB
661
22
function display(tree) % XMLTREE/DISPLAY Command window display of an XMLTree % FORMAT display(tree) % % tree - XMLTree object %__________________________________________________________________________ % % This method is called when the semicolon is not used to terminate a % statement which returns an XMLTree. %_____...
803572ef40b914baf5270bfee048a168bf3639100264f948a0889e51d3b7d231
MATLAB
663
18
function [adfreq, n, ad] = plx_ad_span_v(filename, ch, startCount,endCount) import CMBHOME.PLX2Mat.* % plx_ad_span_v(filename, channel): Read a span of a/d data from a .plx file % % [adfreq, n, ad] = plx_ad_span_v(filename, ch,startCount,endCount) % % INPUT: % filename - if empty string, will use File Open dialog % ...
9e16a65e13eef525b2477ee1e4d5b3542ff5d1d8d67341a05d1855cc67c1b480
MATLAB
663
19
function metadata = cifti_metadata_set(metadata, key, value) %function metadata = cifti_metadata_set(metadata, key, newvalue) % Set the value for a specified metadata key. % % >> cifti.metadata = cifti_metadata_set(cifti.metadata, 'Provenance', 'I made this'); if ~isstruct(metadata) ...
a15ab36d244b85aedcf95fa8dd28a5f773ea1dfc86d81473347a8678a973e816
MATLAB
663
22
function [ normalised ] = normalise( map ) % [ normalised ] = normalise( map ) % % ---------------------------------------------------------------------- % Matlab tools for "Predicting human gaze beyond pixels," Journal of Vision, 2014 % Juan Xu, Ming Jiang, Shuo Wang, Mohan Kankanhalli, Qi Zhao % % Copyright (c...
ae8e22bc17b430b8ad19ff524073becf88e85964832352994cfa796ef58844d8
MATLAB
664
25
function plot_rsa_results(stats) figure;imagesc(stats.RDM); colorbar; xlabel 'Subject Number'; title 'Brain RDM' %show bootstrap distribution for generalization indices figure; subplot(3,1,1) distributionPlot(stats.bs_gen_index(:,2:19)); title 'Study' ylabel 'Generalization Index' subplot(3,1,2) distributionPlot(st...
cc9c90908cbbfe8a86f78f8680a953a344510d8f99956038cacaafb17b0113e1
MATLAB
664
22
function [newnode,newface]=surfreorient(node,face) % % [newnode,newface]=surfreorient(node,elem) % % reorder nodes in a single closed surface to ensure the norms of all % triangles are pointing outward % % author: Qianqian Fang, <q.fang at neu.edu> % date: 2012/07/06 % % input: % node: list of nodes % face: list ...
fafcb928262ed79d673bece00d80f32f54e9565aafdf83b51fc563815756594d
MATLAB
664
22
% feature_calc_script tmp=dir; nfiles=length(tmp); names=cell(nfiles,1); for j=1:nfiles, names(j)=cellstr(tmp(j).name); end; wavnames=regexp(names,'.*wav$','match'); ind=~cellfun('isempty',wavnames); wavnames=wavnames(ind); segnames=regexp(names,'.*wav.seg.txt$','match'); ind=~cellfun('isempty',segnames); segnames=se...
63d92fc77a1dc2751e3d1f1cb0508ce489051d398aef8acf9da1f516db157e0a
MATLAB
665
25
function g=aicplot(alpha,varargin) % % Computes and plots the -2*AIC % for local fits with different smoothing parameters. % % The first argument to aicplot(), alpha, should be a matrix with one % or two columns (first column = nearest neighbor component, second % column = constant component). Each row of this matrix i...
aae936c201af1c0587a82beae788f11a792a541cd981e75223c9f37be09de0b3
MATLAB
665
19
function flip = spm_flip_analyze_images % Do Analyze format images need to be left-right flipped? The default % behaviour is to have the indices of the voxels stored as left-handed and % interpret the mm coordinates within a right-handed coordinate system. % % Note: the behaviour used to be set in spm_defaults.m, but t...
bc188f9d55c7918014bc2196d6723138b5e9740e010643a76dbde4de3a9dd1f8
MATLAB
665
19
function z = lambda_min( Y ) % LAMBDA_MIN Minimum eigenvalue of a symmetric matrix. % For square matrix X, LAMBDA_MIN(X) is MIN(EIG(X)) if X is Hermitian % or symmetric and real; and -Inf otherwise. % % An error results if X is not a square matrix. % % Disciplined convex programming information: % ...
fad26c22e60bad1d89686d6f06e3d1135baaaa31ec8428e6cdf3cc5b7920724a
MATLAB
665
27
function [xx,yc]=mydftreg_vol(im,refim,parms) % Usage ... [x,imc]=mydftre_volg(vol,volref,parms) % % parms=[scalef smwid] upscalef=parms(1); smw=parms(2); if nargout==0, verbflag=1; else, verbflag=0; end; if length(parms)==3, verbflag=parms(3); end; for mm=1:size(im,4), im1=refim; im2=im(:,:,:,mm); ...
832488287ff3818a5ec450c8eaad36ef6e2f130ffffd15a07f7fdb8f4b4dabdd
MATLAB
666
16
connMap = imread('Empty.tiff'); % Create all reference nodes for node = 1:size(channelPos,2) if sum(contains(electroSele, electrodes{node})) ~= 0 connMap = insertShape(connMap,'FilledCircle',[channelPos(1,node) channelPos(2,node) 5],'Color',[0 127 127]); connMap = insertText(connMap, [channelPos(1,node)+5...
83ffb1fb03a190f423f6c37253cee820801e41838d52f6c7ac8da3e1dd43fd0f
MATLAB
666
21
function ea_lcm_struc(options) if strcmp(options.lcm.struc.connectome,'No structural connectome found.') return end disp('Running structural connectivity...'); useNativeSeed = options.prefs.lcm.struc.patienttracts.nativeseed; if strcmp(options.lcm.struc.connectome, 'Patient''s fiber tracts') connBaseFolder = ...
20e56c43dd7afc75813fd89f731e49876b55d961e2ec7ba6eb3314c7def028e6
MATLAB
667
22
function [AIC,SC] = LCN_calc_model_selection(N,SS,P) % format [AIC,SC] = LCN_calc_model_selection(N,SS,P); % % This script will calculate criteria for model selection % INPUT % N = the number of samples % P = the number of parameters in the model % SS = the sum of squared differences between measurement and mode...
27b25ece2f5b495796d83598d3f46503f9aa2ece92d5fbe6d1843648bdef8cc8
MATLAB
668
18
% Local Regression and Likelihood, Figure 7.2. % % Conditional Hazard Rate Estimation. % When hazard rate estimation is performed with multiple x variables, % the result is an estimate of the conditional hazard rate for the % first variable, given the levels of the remaining variables. % % The surface plot looks more d...
d41c699e9ad5711779b19e437899ec56383ab0b7f349d4ef59955f98777f5977
MATLAB
668
25
function my_system(command) %like call_fsl, but without sourcing fslconf if ismac() ldsave = getenv('DYLD_LIBRARY_PATH'); else ldsave = getenv('LD_LIBRARY_PATH'); end %restore it even if we are interrupted function cleanupFunc(ldsave) if ismac() setenv('DYLD_L...
e04234752e66c92a03a1cd40749b7b30a1cb5409ae49aea2f7be5ebfe0084fd0
MATLAB
668
34
function [] = alignAudio() audioFolder = dir('*audio*'); if isempty(audioFolder) error('no audio folder found'); elseif length(audioFolder)>1 error('too many folders?'); end cd(audioFolder(1).name) audioFiles = dir('*WAV'); audio = []; for i=1:length(audioFiles) [wav fs{i}]=audioread(audioFiles(i).name,'n...
e08093ae1d6b8377724ab0efb01b43c0b49f7fe51477c86457d2886c1bc123c1
MATLAB
668
24
%% scatterSpheres - plot scattered points as spheres % % Andreas Husch % Centre Hospitalier de Luxembourg, Dep. of Neurosurgery / % University of Luxembourg - Luxembourg Centre for Systems Biomedicine % 2014 - 2017 % mail@andreashusch.de, husch.andreas@chl.lu function graphicsHandle = scatterSpheres(points, diameter, c...
ed74dfda48b5b264ac50436892a469604e39ce520f228ec57cfccf9718f504bb
MATLAB
668
21
function tree = set(tree,uid, parameter, value) % XMLTREE/SET Method (set object properties) % FORMAT tree = set(tree,uid,parameter,value) % % tree - XMLTree object % uid - array (or cell) of uid's % parameter - property name % value - property value % % Set object properties given its uid and pairs par...
c038c313167ada5367983f064e65474f14f9276d957bb955a55894ee5f51f8ed
MATLAB
669
17
opts = struct(); opts.spm_dir = 'PATH_TO_SPM12'; opts.max_runs_per_task = 1; opts.echo_preference = []; opts.vox = [3 3 3]; opts.skip_if_w_exists = true; opts.write_tsv_confounds = true; opts.verbose = true; bids_root = 'PATH_TO_DATASET'; subj_list = {'sub-01','sub-02','sub-03','sub-04','sub-06','sub-08','su...
cbfd79bf2a786e9656a99109372a81ae328247359df258e5346bf474558a47aa
MATLAB
669
29
function [vertex,face] = check_face_vertex(vertex,face, options) % check_face_vertex - check that vertices and faces have the correct size % % [vertex,face] = check_face_vertex(vertex,face); % % Copyright (c) 2007 Gabriel Peyre vertex = check_size(vertex,2,4); face = check_size(face,3,4); %%%%%%%%%%%%%%%%%%%%%%%...
1df44ad3b7e966c5f063c72d56560b0a82558f5e017bee4fed71cb31fba08ad3
MATLAB
670
31
function [ h ] = point_patch(x,y,s,c,resolution) %point_patch Create nice looking scatter plot %Example point_patch(0:pi/19:2*pi,sin(0:pi/19:2*pi),(1:39)/40,[0 0 1],20) if nargin<5 resolution=10; end persistent circlex persistent circley persistent res if isempty(res) || res~=resolution res=resolution; ...
34c90aa6108f102669366fdb110149c391079b7e3212ccd070f9e0c4b3e808da
MATLAB
670
16
function Labeling = GCO_GetLabeling(Handle,varargin) % GCO_GetLabeling Retrieve the current labeling % GCO_GetLabeling(Handle) returns a column vector of all labels. % GCO_GetLabeling(Handle,i) returns the label of site i. % GCO_GetLabeling(Handle,i,count) returns labels i..i+count-1 GCO_LoadLib(...
8a33b7b237d8b8e08379e29c287f1260224e4a6544c4282fec1f4f167ee32363
MATLAB
670
16
function y = logsumexp( varargin ) %LOGSUMEXP log(sum(exp(x))). % LOGSUMEXP(X) = LOG_SUM_EXP(X) = LOG(SUM(EXP(X)). We have replaced this % function with LOG_SUM_EXP to better match our function naming % conventions. Please start using it instead. warning( 'CVX:Renamed', [ ... 'The function "logsu...
d5d70daeb0cb7219b74db2e7330ca4df0c1c58765e329bf96c7ec6c65f5c6f7a
MATLAB
670
15
% CVX_CLEAR Clears all active CVX data. % CVX_CLEAR clears the current CVX model in progress. This is useful if, for % example, you have made an error typing in your model and wish to start % over. Typing this before entering another CVX_BEGIN again avoids the % warning message that occurs if CVX_BEGIN ...
0d9376bdb3fed51ab7d6151d8a7e366f254ffd250aef36256d314975b7ff532b
MATLAB
671
18
function s = char(tree) % XMLTREE/CHAR Converter function from XMLTree to a description string % FORMAT s = char(tree) % % tree - XMLTree object % s - a description string of an XMLTree %__________________________________________________________________________ % % Return a string describing the XMLTree: % ...
56b3c7d5507f16719270669facc48b915ba942fe905717634afe2b495a7cde02
MATLAB
671
28
function output = ntrodeGroups(ccf) % ntrodeGroups % % This script takes in a CCF file and displays the information on the % ntrode groups within the data file. % % ccf: Pass the CCF of interest. If no CCF is passed, the user will % be prompted to choose a CCF file. % DEFAULT: Will op...
97b476169024da382ab459f138c5ff4527692910a571479cea22760254bf3c88
MATLAB
671
27
function res=combnan(dat) %Combines data in single array with NaNs separating original arrays if originally in cells if iscell(dat) %Remove empty cells dat = dat(~cellfun(@isempty,dat)); if isempty(dat) res = NaN; return; end if ~iscellstr(dat) if max(cellfun('size',dat,...
f60d0945ff649f1bf275de384c63729b6751207c584a0d98652c29561a380953
MATLAB
671
25
function epoch = FilterEpochs(epoch, mindur, minsep) % For an Nx2 array of epoch values (time or otherwise), merges those closer % than 'minsep' and removes those less than 'mindur' % % andrew 6/29/2011 % epoch = CMBHOME.Utils.Filterepoch(epoch, mindur, minsep) [~, inds] = sort(epoch(:,1)); % sort ascending epoch =...
c2e3b9fe51977f31500723348084211d2cc9c34cbfcb820c4244cb875b15d75f
MATLAB
672
25
%% Figure 7 main % Run fig7_analysis, then return here fig7_analysis % Params colors = [[37,109,141];[78,167,160];[127,174,112];[223,189,104];[246,145,110]]/256; % Contour params contConfig.thresholds = [98 95 90]; contConfig.alpha = 0.5; contConfig.lw = 0.9869; contConfig.ls = {'-', '--', ':'}; % Areas to plot areas ...
9c13acedaf840d3e28f8598a659a8aadd4f1062d339ffdde3c867a2787566422
MATLAB
673
18
% List of open inputs % CAT12: Segmentation: Volumes - cfg_files % Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md addpath(spm_dir) nrun = 1; % enter the number of runs here jobfile = {[script_dir '/CBIG_MMLDA_segment_job.m']}; jobs = repmat(jobfile, 1, nrun...
53e8b6547b9020120dbcf9ded2ae35078f9c2746389a0184260ae74312b82c4e
MATLAB
674
22
function slope = calSlope(trialsECOG, fs, t, foi, windowSlope) % fs in Hz % window, windowSlope in ms % slope: [nch x 1] in s^-1 T = 10e3; % ms, total pad duration segNum = 20; chMean = mu.calchMean(trialsECOG, "tail"); % [nch x ntime] [cwtres, f] = mu.cwt(chMean, fs, segNum, "tPad", T / 1e3, "mode", "GPU", "outType"...
9e882f39b6a3d12ac03e710b8e6e19c10fdf4376bc5d972d08e3f6b4bd38ed9b
MATLAB
674
11
% Chapter 5: Duality % % qcqp.m - Section 5.2.4: Solves a simple QCQP % matrix_games.m - Section 5.2.5: Mixed strategies for matrix games % matrix_games_LP.m - Section 5.2.5: Mixed strategies for matrix games (LP formulation) % norm_approx.m - Examples 5.6,5.8: An l_p norm approximation problem % ...
10ed9c0bddd5f95010b7fb5b0cd353d5578a6f0944f291c653c5201b11ea20da
MATLAB
675
17
function dim = isvectord(vect) %ISVECTORD Returns the orientation of a 1-D vector. % ISVECTORD(VECT) is non-zero if exactly one dimension of VECT has % length greater than 1. The return value is then the index of that % dimension. Note that NDIMS can not be used to decide this question, % because it r...
117152ba226f96836a618178de5794c129e1416613145ab659e521a81ce6f2e7
MATLAB
675
19
if ismac compflags = ''; elseif isunix compflags = ' COMPFLAGS=''$COMPFLAGS -static-libstdc++'''; % compflags = [' COMPFLAGS=''$COMPFLAGS -static-libstdc++''', ... % ' -DPARALLEL_OPENMP', ... % ' CXXFLAGS=''$CXXFLAGS -fopenmp''', ... % ' LINKLIBS=''$LINKLIBS -...
1dfa5990cdf2a704d918a1e6f3e1a8d417506e80f3463759062a7c2ad74780c2
MATLAB
676
23
function updateSpatialDecaySlope(kilosortSavePath, qMetricSavePath) % load in quality metrics [~, qMetric] = load.loadSavedMetrics(qMetricSavePath); % load in relevant kilosort files [~, spikeTemplates, templateWaveforms, ~, ~, ... ~, ~] = load.loadEphysData(kilosortSavePath); uniqueTemplates = unique(spikeTe...
49453368a600d9626cb4fe4f20842fd88c20b3327b52b652bc0815ca725b85ae
MATLAB
676
21
function spineROI = saveSpine(roi_seed, roi, trace, im_norm, savepath, savename) if ~isempty(roi_seed) clear spineROI k1 = 1; for k = 1:size(roi_seed,1) if ~isnan(roi_seed(k, 1)) spineROI(k1).roi_seed = roi_seed(k,:); bw = roi(:,:,k); spineROI(k1).spine_pixel = fi...
5ce7a7b9cf45d3bd77ca18b325a467b1594773c54386f2c79d905311fc0ef00c
MATLAB
676
32
% SaveFet(FileName, Fet, BufSize) % % Saves a feature file function SaveFeatures(FileName, Fet, BufSize); if nargin<3 | isempty(BufSize) BufSize = inf; end nFeatures = size(Fet, 2); formatstring = '%d'; for ii=2:nFeatures formatstring = [formatstring,'\t%d']; end formatstring = [formatstring,'\n']; outputfile...
749d2f02def4aa2806b63a34e1023dd2e29d71404084234199c2c326a3350dde
MATLAB
676
21
function P=ar1spectrum(ar1,period) % AR1 power spectrum... % % power=ar1spectrum(ar1,period) % % % (c) Aslak Grinsted 2002-2004 % % ------------------------------------------------------------------------- % Copyright (C) 2002-2004, Aslak Grinsted % This software may be used, copied, or redistributed...
f8e4ed6f3139a5e623f50eae2c80f0c7ad7d3b9db0a1fc2d1b36f2ba17176e06
MATLAB
676
18
function cmapVal = colormapVal(colormap, valMultiplier) if size(colormap,1) ~= length(valMultiplier) if size(colormap,1) == 1 colormap = repmat(colormap, length(valMultiplier),1); % create colormap from a single color else error('Colormap should be either a single color to create a map out of, o...
f7ad460835c6052d1975b8bf37f0af281895490e6cdcdf1cf5920c6e453d0212
MATLAB
677
30
% VOLTYPE determines the type of volume conduction model % % Use as % [type] = voltype(vol) % to get a string describing the type, or % [flag] = voltype(vol, desired) % to get a boolean value. % % See also COMPUTE_LEADFIELD % Copyright (C) 2007, Robert Oostenveld % function [type] = voltype(vol, desired) if isfie...
33b1ba1394c3e04c38bf0537ae99b2193ecb1578d678793d3c2f3f752e5a2b9d
MATLAB
678
23
function head = loadHeadTetraMesh(meshMatPath) %LOADHEADTETRAMESH Load a 5-layer head tetrahedral mesh produced upstream. % Returns struct with fields: % node (Nx3), ele (Mx5+) where column 5 is region id (1..5) % Notes % - This wraps whatever upstream saved as genmesh/node/ele into a standard form. S = load(me...
a2f53d6a0d709201f7cc7be8205829823c593b675a3e847f33fa7bea99ccd293
MATLAB
678
23
function data=extractdatac(data,Fs,t) % Extract segements of continuous data between t(1) and t(2) % Usage: data=extractdatac(data,Fs,t) % % Input: % data: continous data in the form samples x channels or a single vector % Fs: sampling frequency % t : time as a 2d vector [t(1) t(2)] % Note that sampling frequency and...
f10a5fea1fe992c105d3c586e05c975fd4f17c09adfe3e538b086fd175a3c995
MATLAB
678
18
opts = @(outputDir) struct(... 'format','html',... 'stylesheet',fullfile(pwd,'../doc/','mxdom2mbgl-html.xsl'),... 'outputDir', fullfile(pwd,['../doc/html/' outputDir '/'])); try cd ('../examples'); publish('red_black.m', opts('red_black')); publish('record_alg.m', opts('record_alg')); cnopt...
7448693504121606736ae4c679df9a79e48f35125ce16abd94c4d5dc4234694c
MATLAB
679
25
function display(this) % Display method for GIfTI objects % FORMAT display(this) % this - GIfTI object %__________________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % Guillaume Flandin % $Id: display.m 4182 2011-02-01 12:29:09Z guillaume $ d...
afdfa043c2a29e358f9800cbb8b1c4ddedf97509b85f622ef77ab2b43cacd372
MATLAB
679
26
function tf=insurface(node,face,points) % % tf=innersurf(node,face,points) % % test if a set of 3D points is located inside a 3D triangular surface % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % node: node coordinates % face: surface triangle list % points: a set of 3D points (Nx3 array) % % out...
3e262caf7fc5c7ba2c66f695aa55e909d43601e07ccc449905c685b08c8161ce
MATLAB
680
16
function struct12 = structcat(dim, struct1, struct2) %STRUCTCAT Concatenates two structures field by field. % STRUCT12 = STRUCTCAT(DIM, STRUCT1, STRUCT2) takes two structures with % with identical fields and returns a new structure in which each field % contains the concatenation of the corresponding fiel...
7aebc0e889007d4c1e0ba20b4e31402424af7c10b03565bb50682179fbc6089d
MATLAB
680
28
function [A,sumV] = quadcof(N,NW,order) % Helper function to calculate the nonstationary quadratic inverse matrix % Usage: [A,sumV] = quadcof(N,NW,order) % N (number of samples) % NW: Time bandwidth product % order: order (number of coefficients, upto 4NW) % % Outputs: % % A: quadratic inverse coe...
7f97ca8e18c265518d3588ffdd9dc2affda7977579702befffc389ae23722765
MATLAB
680
28
function r = circ_dist(x,y) % % r = circ_dist(alpha, beta) % Pairwise difference x_i-y_i around the circle computed efficiently. % % Input: % alpha sample of linear random variable % beta sample of linear random variable or one single angle % % Output: % r matrix with differences % %...
13faf9107f2e22c920f54d438f79be393525ad3a023cb60dfa39157e3b0421ce
MATLAB
681
20
function AUC_PR = quickCV_PLSDA_PR(X, Y, C, opts) % quickCV_PLSDA_PR Fast tuned cross-validated precision-recall AUC for PLS-DA. % % AUC_PR = quickCV_PLSDA_PR(X, Y, C, opts) % % Thin wrapper over quickCV_PLSDA_core with metric 'pr'. Note that the chance % level for precision-recall AUC is the positive-class prev...
702751aea7002399c5eb29d91e0785f5ab71cd695e85c8e46908a6b1c49c52a9
MATLAB
682
30
function yred=rednoise(N,g,a); % REDNOISE: A fast rednoise generator using filter. % % example: rednoise(N,g); % % Description: generates a rednoise series % with zero process mean. % note: statistical mean&variance will be different. % % Inputs: n - desired length of time series % g - lag-1 autocorr...
b6ded9cad99fc91c03a25cbdb5f5bbbe534d0aad81458171a400b33f3f9ee684
MATLAB
682
16
%Several EEGLAB plugins (not included by default) are available to import %specific data formats. To download these plugins use EEGLAB menu % %File > Manage Plugins > Manage data import plugins % %The FILEIO and BIOSIG toolboxes interface also allow to import in EEGLAB a wide variety %of EEG/MEG data file formats -- i...
2e31a6c03316455302856cfecd64a97972c07c57ae2f4e9f800ee2b472e04318
MATLAB
683
22
function display(tree) % XMLTREE/DISPLAY Command window display of an XMLTree % FORMAT display(tree) % % tree - XMLTree object %__________________________________________________________________________ % % This method is called when the semicolon is not used to terminate a % statement which returns an XMLTree...
9ff384e39a67e41ac71ba689c9597b75139b5a66fc8b7bef7b73f393215514d6
MATLAB
685
20
function x = subsref( x, S ) % Disciplined convex/geometric programming information for SUBSREF: % The use of subscripts to extract elements or "slices" of any CVX % variable is identical to their use with numeric arrays. All % conventions are preserved, including the colon ':' and 'end'. narginchk(...
c0681637abc1b8cb895112fc8e7b907b6af03e4bd54d7194646b8cc43b26c16b
MATLAB
685
18
function plotconcats(flies,concat,colorrange) % This is to just combine all data linearly through time, even if it's from % different experimental protocols. Still need to match stimulus next to it % but that's hard so it'll be for another day. % example inputs: % flies = ['oct1322_f2';'oct1422_f3';'oct1422_f4...
d7094542f66a9c189ecbc2f4d06ff76d9c2d9b54c88d7b8111a9e85a2ee45eea
MATLAB
685
19
function mcmc_params = fit_meta_d_params() % mcmc_params = fit_meta_d_params() % % Returns default mcmc_params for fit_meta_d_mcmc_group and fit_meta_d_mcmc % % SF 2015 mcmc_params.response_conditional = 0; mcmc_params.estimate_dprime = 0; mcmc_params.nchains = 3; % How Many Chains? mcmc_params.nburnin = 1000; % How M...
0d26f1a95bae24552fd0177c6efa67e8a47de34735ca9a93455e55634bc6a8bd
MATLAB
686
27
function x = Clip(x,m,M) %Clip - Clip values. % % Clip values between specified extrema. % % USAGE % % clipped = Clip(x,min,max) % % x array to clip % min minimum value % max maximum value % Copyright (C) 2004-2011 by Michaël Zugaro % % This program is free software; y...
0e1d762454dd379fb391cbdbce92d2625181aaaffe140da760fb82744c309eb6
MATLAB
686
22
function tracks = segmentTracks(data) % SEGMENTTRACKS Split a tracking table (X Y Z T) into a cell array of % individual track tables. A new track begins each time the T column % resets to 0. if ~istable(data) || ~ismember('T', data.Properties.VariableNames) error('segmentTracks:invalidInput', ... ...
34db81797d0aa6abf3658cdaf6389905642374dde402500ec35272fbd6c09ef7
MATLAB
686
20
function PDIFF = chisquare_solve(XGUESS,P,V); %CHISQUARE_SOLVE Internal function used by CHISQUARE_INV % % PDIFF=chisquare_solve(XGUESS,P,V) Given XGUESS, a percentile P, % and degrees-of-freedom V, return the difference between % calculated percentile and P. % Uses GAMMAINC % % Written January 1998 b...
373634c40d16f39e77c98d20add0d6448c87b8c70eff493a9d5e2b7822175244
MATLAB
686
28
function x = tril( x, k ) % Disciplined convex/geometric programming information for TRIL: % TRIL imposes no convexity restrictions on its arguments. % % Check inputs % if nargin < 2, k = 0; end s = x.size_; if length( s ) > 2, error( 'The first argument must be 2-D.' ); elseif ~isnumeric( k ) || length(...
92d14df7684442a5ab2d20fac7e569734906537148dbedcb2d6db0530392a879
MATLAB
686
38
function formatSubplot(handle,varargin) args.fs = 7; args.xl = []; args.yl = []; args.box = []; args.ax = []; args.lim = []; args.tt = []; args.xt = []; args.yt =[]; args = parseVarArgs(args,varargin{:}); set(handle,'fontsize',args.fs) if ~isempty(args.xl) xlabel(handle,args.xl) end if ~isempty(arg...
a16455b1d86f1ff18286c779d4178f9eacfed3e303b08fdbe24b3f1f604997e8
MATLAB
686
28
function x = triu( x, k ) % Disciplined convex/geometric programming information for TRIU: % TRIU imposes no convexity restrictions on its arguments. % % Check inputs % if nargin < 2, k = 0; end s = x.size_; if length( s ) > 2, error( 'The first argument must be 2-D.' ); elseif ~isnumeric( k ) || length(...
abad9d03ca466f8dc3b835d0877a1eaacb1ae99b535ea172671c25efadcea391
MATLAB
686
26
function h5_2_bin(path_to_file,output_name,precision,batch_size) info = hdf5info(path_to_file); dims = info.GroupHierarchy.Datasets.Dims; T = dims(end); if nargin < 4 || isempty(batch_size); batch_size = T; else batch_size = min(batch_size,T); end if nargin < 3 || isempty(precision) precision = 'uint16'; e...
db07c9709fc25ff4c392e308f476e29e0d26cedeaf72cbe25ffc6739901cd957
MATLAB
686
18
% Local Regression and Likelihood, Figure 7.2. % % Conditional Hazard Rate Estimation. % When hazard rate estimation is performed with multiple x variables, % the result is an estimate of the conditional hazard rate for the % first variable, given the levels of the remaining variables. % % The surface plot looks...
fff2650bc4e9e0c37d3a85b35e391731e81142aef218123bd9aa3ef8cbad4e16
MATLAB
686
27
function z = ea_nanzscore(data, robust, dim) % Computes zscores for input data % % data: row vector, column vector, or matrix % If data is a matrix, z-scores are computed over columns by default % or by specified dim. % robust: if set to 'robust' as second argument, mean is computed excluding % ...
ab4f05a6a84af5c5e88bb2e24179d056f4d62c8716d64ac00c5dd228976f368b
MATLAB
687
32
function b = subsref(ipd,index) % INPLACE/SUBSREF Support Matlab subscript references. % % This function supports subscript references just like Matlab matrices. % % Example: % ipa = inplace(cumsum(ones(5,1))); % ipa([2 4]) % ipa(3:end) if (length(index) > 1) error('Indexing operation not s...
c658b3e1e5e800e9fa9c54f086ef2f7d637845f7d9a090fa2e1504033e63bc7b
MATLAB
687
36
D = dir; numtests = 0; results = []; for di = 1:length(D) f = D(di); if f.isdir continue; end [pathstr,name,ext] = fileparts(f.name); if ~strcmp(ext,'.m') continue end; if strcmp('rtest_all.m', f.name) continue; end if strmatch('r...
fe76f09736a0ac32de792ecec06b781254397b2424d9b22eda9ff9255759b76f
MATLAB
687
26
function saveasc(v,f,fname) % % saveasc(v,f,fname) % % save a surface mesh to FreeSurfer ASC mesh format % % author: Qianqian Fang, <q.fang at neu.edu> % date: 2009/04/02 % % input: % v: input, surface node list, dimension (nn,3) % f: input, surface face element list, dimension (be,3) % fname: output fil...
5650b9cccde3c52d6c71070549a92b0635e3fe677bb86e901e0e9b1fda695602
MATLAB
688
18
% publish script % run to print results to PDF file cd('/Users/tor/Google_Drive/Wagerlab_Single_Trial_Pain_Datasets/Data/Tor_bmrk3_datashare') scriptsdir = '/Users/tor/Google_Drive/Wagerlab_Single_Trial_Pain_Datasets/scripts/BMRK3'; addpath(scriptsdir) % ---------------------------------------------------------------...
e31d01a4e66af3cd2ae5f4dbc226528f1e2519393e7b8f861dc0b3eeac87b54f
MATLAB
688
35
function varargout = fname(varargin) % Format % For getting the value % dat = fname(obj) % % For setting the value % obj = fname(obj,dat) % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: fname.m 1143 2008-02-07 19:33:33Z spm ...
832cef2eb6ddbc493660085ed77f18af569434a9a58baee1640f244983c2a8ae
MATLAB
689
14
function cbarax = find_colorbar(ax) %FIND_COLORBAR Finds the colorbar associated with a given axes. % CBARAX = FIND_COLORBAR(AX) returns the handle of the colorbar % associated with the axes AX. If no colorbar is found, CBAR_AX will be % empty. %%%%% TMW's COLORBAR function creates a hidden proxy text objec...
8b4031409d408cbe8cd0b51492cfaa47949676f3535656cc4b68199940e66eaf
MATLAB
689
19
function [samplelength, fileid] = ... savesubtif(handles, sampledreg, RegPara, fileid, sample_maxL, samplelength) if handles.savesubsampletif == 1 % save reg sample sampledreg = max(single(sampledreg)-RegPara.I_min, 0); sampledreg = uint8(min(ceil(sampledreg/(RegPara.I_max*1.5)*255),255));...
34d57bf822a95989c9261911fc5221121920f6705a1f55bb5669c79ef86caf64
MATLAB
690
21
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % demo script for mesh generation from surface patches and bounding box %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% preparation % user must add the path of iso2mesh to matlab path list % addpath('../'); % us...
7e1a811c127a98566cff377045caa0841b90e983f5343c05d1df7a1a6456d98a
MATLAB
690
15
%% Extract and Plot all NPS sub regions % Once the CANlab second level batch prep_* sequence has been run, this % script will identify all NPS subregions in the DAT object and then % extract and plot those subregions one by one. Figures will automatically % be saved in the figsavedir, which is set in a_set_up_paths_alw...
1097dcbbf71a761914d168990ed8b33d44c83f4212d9f647c399d641123a491a
MATLAB
691
22
function frame = getframe(vr) %FRAME=GETFRAME(VR) % Returns the current frame that has been read in from video VR. Calling % GETFRAME does not automatically advance the current frame so the user % must first call NEXT, STEP, or SEEK before calling GETFRAME the % first time. This makes it easy to write loops such ...
1f9d2e4b11289f0a3ac95295471873f6a8c8903ffaac5e7397eaf498a10f4d7e
MATLAB
691
27
function [a,b,c,d]=getplanefrom3pt(plane) % % [a,b,c,d]=getplanefrom3pt(plane) % % define a plane equation ax+by+cz+d=0 from three 3D points % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % plane: a 3x3 matrix with each row specifying a 3D point (x,y,z) % % output: % a,b,c,d: the coefficient for plan...
53a823f1d39b8394ab3d5d3b86923950f005d80c0006eb58a40974af51ccc020
MATLAB
691
9
function ret = str2vec(in) %dodge all the weirdness in str2num, or replace it with something more bulletproof if needed in(in == char(10) | in == char(13) | in == ';') = ' '; %try to prevent str2num from seeing any row separators, so that non-rectangular encodings don't cause errors ret = str2num(in)'; %#ok...
6dc6e2dd6cd3fa184265bbd96c155fdc6288c770a45765097a0c42d1d96f0713
MATLAB
692
32
function [P bins] = JointDist(x,y,nbins) %JOINTDIST % Usage: [P bins] = JointDist(x,y,nbins) % %This function calculates the joint distribution of the variables x and y. %It is simply a normalized histogram using hist3. nbins can take any form %of bins that hist3 can take, but no other hist3 options. %Written by Da...
b03ea62b6d51bd815f25d047c6a921fb0504e6e5d37c2b06b0e62b512216b71c
MATLAB
692
26
function [rawFroi,nFrames,varargout] = TifROImask2rawFroi(img,roiStruct) %process tif file if input is not an image matrix if ischar(img) || isstring(img) %always load channel 2 containing green channel [img,imHeader] = readSCIMtif(img,2); nFrames = imHeader.nFrames; varargout{1} = round(imHeade...
80c25ceb16c1682a434fbbcd02d26e54105ae53f09d78d0ac921a6dacf87b6a7
MATLAB
693
23
function str = cvx_replicate_structure( str, sz ) %CVX_REPLICATE_STRUCTURE Apply matrix structure to N-D arrays. szs = size( str ); nmat = prod( sz ); omat = ones( 1, nmat ); [ r, c, v ] = find( str ); nelm = length( r ); oelm = ones( 1, nelm ); r = r( : ); nvec = ( 0 : nmat - 1 ) * szs( 1 ); r = r( :, omat ) + n...
81a3fe2e93213b9480e53849d471cd37627ba885a35be09465ca4febf39ee506
MATLAB
693
22
function plotPolygonROIsCCF(dorsalMaps, allROIs, polygon) % Plots the ROI centroids that fall within a supplied polygonal shape % Figure allenMapSMc(dorsalMaps, [-3.6, 0, -2, 3]) % Creates figure by itself % Paper ready figure/axis formatting panelwidth = 1.5; panelheight = 2; leftoffset = 0.5; bottomoffset = 0.5; fo...
a657fcc295989232e18e7621fbb51e4c5e43de4026f90c02d3ee2bf740e7f8a6
MATLAB
693
33
function p=getvarfrom(ws,name) % % p=getvarfrom(ws,name) % % get variable value by name from specified work-space % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % ws: name of the work-space, for example, 'base' % name: name string of the variable % % output: % p: the value of the specified variable,...
f81e9e01c157df95ea7e2ebc9d53ae2dd292d6ac06900225b3c20d01009202b0
MATLAB
693
26
function [nch, npoints, freq, d] = ddt(filename) % ddt(filename) Read data from a .ddt file % % [nch, npoints, freq, d] = ddt(filename) % % INPUT: % filename - if empty string, will use File Open dialog % % OUTPUT: % nch - number of channels % npoints - number of data points for each channel % freq -...
6e099c7fba35894cdabc5cb5e25887493e5728209076e11a25827ac0f57bdb37
MATLAB
694
31
function Visible=CheckVisiblePoint3D(V,F,i,j) Visible=true; P1=V(i,:); P2=V(j,:); if(any(any(F==i,2)&any(F==j,2))), return, end for k=1:size(F,1) CF=F(k,:); if(any(CF==i)||any(CF==j)), continue, end O1=V(CF(1),:); O2=V(CF(2),:); O3=V(CF(3),:); inter=LineTriangleIntersection(O1,O...