sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
89273bcc221fbb4771ae8d2c5a62b6e0bc8a38c30e77a9ec13651748210280a5
MATLAB
431
17
function [ paddeddata ] = NanPadJumps( timestamps,data,minjump ) %UNTITLED3 Summary of this function goes here % Detailed explanation goes here jumpstarts = find(diff(timestamps)>minjump); jumpstops = jumpstarts+1; paddeddata = data; paddeddata([jumpstarts jumpstops]) = nan; %% % figure % plot(timestamps,paddeddata...
cab999d074df984929ea44682186160473923663f74a9abe0fe5125d6ee116d1
MATLAB
431
24
% gauss() - return a smooth Gaussian window % % Usage: % >> outvector = gauss(frames,sds); % % Inputs: % frames = window length % sds = number of +/-std. deviations = steepness % (~0+ -> flat; >>10 -> spike) function outvec = gauss(frames,sds) outvec = []; if nargin < 2 help gauss return end ...
fd74e33bc9507194dee36c39479e4000444fdf589d1a0ad3b7727f8e34689dbb
MATLAB
431
15
function [maxes positions] = getBumpPos(ang,sine) % This function computes the bump position for all timepoints in some % columnar imaging data. ang and sine are outputs from % sinefit_columnardata() % example script: % [x2 s2] = sinefit_columnardata(d); % [m2 pos2] = getBumpPos(x2,s2); % figure; scatter([1:l...
945de07ba5cf1fcc5040f82c65207e111dd5e66445ad789a39f5a4c02eff0cb8
MATLAB
432
30
% load a trial of mic data % 1000 Hz sample rate assumed load(trialname); figure; plot(trial) figure; spectrogram(trial,500,250,'yaxis') %% [b a] = butter(4,[180 360]/1000); filttrial = filtfilt(b,a,trial); figure; plot(filttrial) [up,lo] = envelope(filttrial); figure; plot(up) figure; sp...
0c4ee1d64ebe79754c77ab9efb22a3f0e937acc2a664a21b7313ae20eb19e8a2
MATLAB
434
15
function [avgfluor,stdfluor]=averagedirections(fluordata) fn=fieldnames(fluordata); for k=1:5 if isnan(fluordata.(fn{k})) avgfluor.(fn{k})=NaN; stdfluor.(fn{k})=NaN; else avgfluor.(fn{k})=nanmean(fluordata.(fn{k})); stdfluor.(fn{k})=nanstd(fluordata.(fn{k})); end end end %yo...
44066e61745ae09f973a3aacdc455b02b6808aaea313331b2ef603ebdf0480b6
MATLAB
435
10
function [HbO_pred, HbR_pred, Hb_all] = predict_channel_hb_from_muA(J_chrom_brain, mu_a760, mu_a850) %PREDICT_CHANNEL_HB_FROM_MUA Apply spectral J to brain µa vectors → channels. % [HbO_pred, HbR_pred, Hb_all] = PREDICT_CHANNEL_HB_FROM_MUA(Jc_brain, mu760, mu850) mu_vec = [mu_a760(:); mu_a850(:)]; Hb_all = J_ch...
67e38701a3dad36bcfbb51d5e89acc3f0a4cdcf94e8442bfef3f8b763b80e2b8
MATLAB
435
10
function [Zx] = find_zc(x,y,threshold) % positive slope "zero" crossing detection, using linear interpolation y = y - threshold; zci = @(data) find(diff(sign(data))>0); %define function: returns indices of +ZCs ix=zci(y); %find indices of + zero crossings of x ZeroX = @(x0,y0,x1,y1) x0 - (y...
630207f652aba7f02654d96558fd95afe29d1e8333e34ae64d4842a923436b75
MATLAB
436
20
function b = padImage( a , vpad , hpad ) if ( nargin == 2 ) hpad = vpad; end u = repmat( a(1,:) , [ vpad 1 ] ); b = repmat( a(end,:) , [ vpad 1 ] ); l = repmat( a(:,1) , [ 1 hpad ] ); r = repmat( a(:,end) , [ 1 hpad ] ); ul = repmat( a(1,1) , [ vpad hpad ] ); ur = repmat( a(1,end) , [ vpad hpad ] ); bl = repmat( ...
12bc276d75dcba1b5cafa3fd86d976b0cd68b887086648a3d54bee23d04dfb12
MATLAB
437
23
function [trans check full2sparse] = get_matlab_bgl_options(varargin) % % Internal private function. % % Example: % Don't use this function! % %% History % 2008-09-26: Changed to use merge_options instead %% doptions = set_matlab_bgl_default(); if nargin>0 options = merge_options(doptions,varargin{:}); else ...
ca9914a8533f8dabc367bb39e557b18a4ad8166ecc673ba1cc76ff99062266f8
MATLAB
437
18
function nsols = numevalsol(sols,varargin) for k = 1:(nargin-1)/2, eval(sprintf('%s = varargin{%i}; ',varargin{2*k-1},2*k)); end; nsols = struct; fn = fieldnames(sols); strr = @(x) strrep(strrep(strrep(x,'*','.*'),'^','.^'),'/','./'); for k = 1:length(fn), f = getfield(sols,fn{k}); clear res for ...
48cd3a2b382627b79095db253b0fe203301a1c94b439b29a6ea9fe508be6d826
MATLAB
438
13
function disp( x, prefix ) if nargin < 2, prefix = ''; end disp( [ prefix, 'cvx ', cvx_class( x, true, true, true ), ' expression (', type( x ), ')' ] ); dual = cvx_getdual( x ); if ~isempty( dual ), disp( [ prefix, ' tied to dual variable: ', dual.subs ] ); end % Copyright 2005-2016 CVX Research, Inc. % See...
7e134218726fcc5e9802c852b186dc536b1baa88d2bfd2d107ef2a077780e8c9
MATLAB
438
17
function T1D_dic=cal_T1d_dictionary(Rdosl, B1, dictionary) all_inhom_b1=dictionary.all_inhom_b1; all_jtmt=dictionary.all_jtmt; var_T1d=dictionary.var_T1d; % match B1 b1_check = abs(B1 - all_inhom_b1); num_b1 = find(b1_check == min(b1_check)); % match T1D if (Rdosl > 0) && (Rdosl < 5) yy_check = abs(Rdo...
ea68ce43f318c83becbf22bfba8049df75b5e917a778149ae42ed9216ce29ba7
MATLAB
439
17
function xfit = lfmarg(fit) % computes grid margins from a locfit object, used for plotting. % this function is called from lfplot and lfband, will not normally % be called directly by users. box = fit.fit_points.fit_limits; d = size(box,1); xfit = cell(1,d); mg = 10*ones(1,d); if (d==1) mg = 200; end; if ...
4e67933a24c1355e53f9bd08fad5d18c0c4e1ce4087d83a2a250984b7def3968
MATLAB
440
13
function tf = isfield(this,field) % Isfield method for GIfTI objects % FORMAT tf = isfield(this,field) % this - GIfTI object % field - string of cell array % tf - logical array %__________________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimagi...
47e0317a3e175d767878742422f8adca5addce3b6696ba698edb592e3c042cf0
MATLAB
441
18
function formatCCF(ARfactor, fontSize, leftOffset, bottomOffset) if nargin < 2 fontSize = 6; end % Set sizes % Paper ready figure/axis formatting panelWidth = 1.699*ARfactor; panelHeight = 2.2*ARfactor; % This is the only way to get the right aspect ratio from the paper if nargin < 3 leftOffset = 0.5; end if ...
54896b79e018a9cd16d79d43bfee2ff2ab7abe3f5a523caed9400d999e93baca
MATLAB
442
15
function hm = makeSpeedHeatmap(ivc) % [7:9] AF slow % [10:12] AF mid % [13:15] AF fast % For each row, first column is slowest OF and last/third column is fastest % OF speed. a = [mean(ivc(:,7)), mean(ivc(:,8)), mean(ivc(:,9))]; b = [mean(ivc(:,10)), mean(ivc(:,11)), mean(ivc(:,12))]; c = [mean(ivc(:,13)), me...
a39a0dbc0a012169aa7a912e98786712390a65e05187d6f0e65ddbc6a4302c88
MATLAB
442
12
function data_out = Trinh_freq_normalize(data_in, mean_freq) % removes background noise from each frequency bin by subtracting the % averaged amplitude measured at neighboring frequency bins from each % frequency bin as seen in Moureaux et al., 2011, Norazadan et al., 2012, % Cirelli et al., 2019 % Trinh Jan 24 d...
3d2a442c021007dd55082b753d0df3fcc8fca39cf702597b0a20e40e53096354
MATLAB
443
14
function [n,samplecounts] = plx_adchan_samplecounts(filename) import CMBHOME.PLX2Mat.* % plx_adchan_samplecounts(filename): Read the per-channel sample counts for analog channels from a .plx file % % [n,samplecounts] = plx_adchan_samplecounts(filename) % % INPUT: % filename - if empty string, will use File Open dialo...
8d1cf7c873ade90638951a875fd2f5075a3296d0ae0e2caeed3526e4c72b0ab7
MATLAB
443
14
function rsquared = getRsquared(data,model) %%% A function to calculate Rsquared even though it's invalid for nonlinear %%% regression. Can use alongside other tests of goodness of fit. data is %%% the observations; model are the model predictions from the same %%% independent variable values as data. SSR = su...
c4be2297d688a3e4f32bd6d7295bf6ffbc4802ddcb28b46b97e07f8dc605d6be
MATLAB
443
12
function [ data_out ] = Trinh_MovingMeanSpectra(data_in, window ) % % This function computes a moving window of the data (FT format) calling % another function 'movingmean'. % %% Giacomo Novembre data_out = data_in; for tr = 1:length(data_in.trial) data_out.trial{tr} = movingmean( data_in.trial{t...
ceb7da6752370bbfcb07272b44b9f2206d5e98eb0528e7f9b9c07152a0031d5f
MATLAB
443
19
function [Cleaned,beta_hat,nnanix]=ea_regressout(S,Cova) % simple function that regresses out one variable from another nnanix=any(isnan(Cova),1); nnanix=nnanix+(isnan(S)); nnanix=~nnanix; Cleaned=S; Cova=Cova(:,nnanix); S=S(nnanix); Cova=zscore(Cova')'; S=zscore(S); beta_hat = (Cova*Cova')\Cova*squeeze(S'); % or...
56e5bca2b5442aa0b4c7e9f434d9b483ef873797cc2c888c6692b2cd2611fd8e
MATLAB
444
19
function [p] = get_line_xyz(h) % File: get_line_xyz.m % Author: Ioannis Filippidis, jfilippidis@gmail.com % Date: 2012.06.15 % Language: MATLAB R2012a % Purpose: get line point coordinates and fix z if empty % Copyright: Ioannis Filippidis, 2012- % get defined data-points x = get(h, 'XData'); ...
3eb9e8efbef0bdaf1d2985706a64cfddba52e903f29f2b322b2a93be893b9ac5
MATLAB
445
12
function outDir = ea_connectome_normparams_dir(directory) % Return directory where Lead-Connectome SPM norm params (y_ea_*.nii) are stored. % BIDS: normalization/transformations; legacy: subject root. if nargin < 1 || isempty(directory) outDir = ''; return; end if contains(directory, 'derivatives') || contains(...
de5db6f7f663da911b89764bc0a1a4f90026c9d076809aaa68a905d758cdc54e
MATLAB
445
15
%% getFilenameFromWildcard % % Florian Bernard % Centre Hospitalier de Luxembourg, Dep. of Neurosurgery / % University of Luxembourg - Luxembourg Centre for Systems Biomedicine % 2014 - 2017 function filepath=getFilenameFromWildcard(folder, wildcard) theFile=[folder filesep wildcard]; filepath=dir(theFile); ...
3120dda6f4f01d607a353df67f13a68f025b6e05be63d82a76ed3e99817991b8
MATLAB
446
12
masterscriptdir = what(fullfile('CANlab_help_examples', 'Second_level_analysis_template_scripts')); if isempty(masterscriptdir) error('Add Second_level_analysis_template_scripts folder from CANlab_help_examples repository to your path'); else masterscriptdir = masterscriptdir.path; end if isempty(masterscri...
88b41f507521f75ca58f678075b776dcc5e8375d832bcf7d2abdcbf15138bda5
MATLAB
446
15
function plugin_remove(foldername); % get plugin path % --------------- fullpluginfolder = fullfile(fileparts(which('eeglab.m')), 'deactivatedplugins', foldername); if ~exist(fullpluginfolder) error([ 'Could not find folder ' foldername ' in deactivatedplugins folder' ]); end; disp([ '...
19087b061c6c38ab11897a7967f4d5ebf3bc1e502f248f8d9f682cb8cfb366f9
MATLAB
447
20
function [no,el]=fillsurf(node,face) % % [no,el]=fillsurf(node,face) % % calculate the enclosed volume for a closed surface % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % node: node coordinates % face: surface triangle list % % output: % vol: total volume of the enclosed space % % -- this func...
bcf59dc719b8e6ac3afea900c7c99cf2468810a7916b99f4a9143b9296bb4af1
MATLAB
447
22
function [L, Lnorm] = calc_LaplacianMatrix(W) % calc_LaplacianMatrix.m % % Calculate Laplacian and normalized Laplacian % % Input: W : connectivity matrix [NxN] % % Outputs: L : Laplacian matrix [NxN] % Lnorm : normalized Laplacian matrix [NxN] % % Original: James Pang, Monash University, 2021 %% d...
0190f866aea7da5429f9c76fee0b9e7340e8cf62d3a5edeac7146807c3ebc144
MATLAB
448
24
%% Plot close all; sourceArea = 'AC'; targetArea = 'PFC'; topoArea = 'AC'; section_granger_subplotImpl_population; close all; sourceArea = 'AC'; targetArea = 'PFC'; topoArea = 'PFC'; section_granger_subplotImpl_population; close all; sourceArea = 'PFC'; targetArea = 'AC'; topoArea = 'AC'; section_granger_subplo...
0756a817883150d946564e38e120f6cc0f9ff4604997589719e881a70b5cd465
MATLAB
448
26
function volume=CheckVolumeTetraMesh(V,T) volume=0; for i=1:size(T,1) a=V(T(i,1),:); b=V(T(i,2),:); c=V(T(i,3),:); d=V(T(i,4),:); a=a-d; b=b-d; c=c-d; k=cross(b,c); v = abs(a(1)*k(1)+a(2)*k(2)+a(3)*k(3))/6; volume=volume+v; end function c=cross(a,b) a=a(:...
821468e81b9eb64a8fd45356f6878d3d71fbfa8474d759441803435d5bcfa2d9
MATLAB
448
14
function [pks, locs, varargout] = ea_findpeaks(data, varargin) has_findpeaks = ~isempty(which('has_findpeaks')); if has_findpeaks [pks, locs, w, p] = findpeaks(data, varargin{:}); varargout = {w, p}; else slope_sign = sign(diff(data)); locs = 1 + find(slope_sign(1:end-1) > 0 & slope_sign(2:end) < 0); ...
d2823d4c4c643c5373b5a146c8244b19e679ef856b398d62af1714cf3e075b03
MATLAB
448
20
function res = bumpmdl_de(params,thetavec,t,h,init) % thetavec and res are now in radians % parameters as of 20231017 (from fitting or no?) % [ 2 ] % tau only % x = [ 10/26:10/26:10 ] % parameters tau = params(1); res(1) = thetavec(1)*h(1); res(1) = init; for i = 1:length(t)-1 coeff = -wrapToPi(th...
09632b8d7d093c4fbc1d0d4fd189c19b42febabe45a7decb5cbeedd5f5fa9463
MATLAB
450
14
function metadata = cifti_metadata_remove(metadata, key) %function metadata = cifti_metadata_remove(metadata, key) % Remove a metadata key and its value. % % >> cifti.metadata = cifti_metadata_remove(cifti.metadata, 'Provenance'); %looping over length handles empty just fine for i = 1:l...
b951bc3ad85fbb5f3d49faa768bedfd785866f5553f6619e5207d8d4c71c9697
MATLAB
451
13
function y=rot2d_nf(im,rang,itype,rtype) % Usage ... y=rot2d_nf(im,rang,itype,rtype) % % rang is [theta] in degrees (positive is CCW, rot2d_f is CW) % (based on imrotate; x=+elevates-left,y=+elevates-top) % itype is interpolation type -- default is linear % rtype is rotation option -- cropping is default if ...
cb91b80c51cbfd78f7a9fb5b8407f35041e3d611d87a0e6f0ed85f51b027fc53
MATLAB
451
19
function [ OutGeneSym ] = subfun_replace_dateGenes( DateSym ) tmploc = find(DateSym=='-'); if isempty(tmploc) tmploc = find(DateSym=='.'); end switch DateSym(tmploc+1:end) case 'Mar' OutGeneSym = ['MARCH' DateSym(1:tmploc-1)]; case 'Jun' OutGeneSym = ['JUN' DateSym(1:tmploc-1)]; case 'S...
498e4f2612b8d639a1873f72c1d13a0d3ab5f177121f6824d6a69dc3f2286adc
MATLAB
452
16
function y = testall( func, x ) y = do_test( func, x.value_ ); function y = do_test( func, x ) switch class( x ), case 'struct', y = do_test( func, struct2cell( x ) ); case 'cell', y = all( cellfun( func, x ) ); otherwise, y = feval( func, x ); end % Copyright 2005-2016 CVX Researc...
937d4c5fa90876df91b0ac4cba09ac407727b087bacb2a713689923f63440a82
MATLAB
453
13
function tf = isfield(this,field) % Isfield method for GIfTI objects % FORMAT tf = isfield(this,field) % this - GIfTI object % field - string of cell array % tf - logical array %__________________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neu...
eb5bba08679764e8dffff467994d53d1d739155dfda5af534a68ba17e1940f3f
MATLAB
453
18
function imgShift = shiftImage( img , theta ) Worig = size(img,2); Horig = size(img,1); pad = 2; imgpad = padImage(img,pad); W = size(imgpad,2); H = size(imgpad,1); xi = repmat( [ 1 : W ] , [ H 1 ] ); yi = repmat( [ 1 : H ]', [ 1 W ] ); dx = cos(theta * pi / 180 ); dy = -sin(theta * pi / 180); imgpa...
f4cdb0eef65acf650dc070cc504c822c78d3eb7cffd69e983f64bf3659e3863d
MATLAB
453
20
function cmap = cmapTargs() % A simple turbo/jet-like colormap for motorGrab reaching targets cmap = [[0.705, 0.000, 0.000]; [0.873, 0.138, 0.000]; [1.000, 0.399, 0.000]; [0.806, 0.436, 0.000]; [0.899, 0.663, 0.000]; [0.957, 0.918, 0.000]; [0.000, 0.572, 0.027]; [0.143, 0.775, 0.000]; [0.502, 0.944, 0.000]; [0.000, 0....
4d62ff0a18b94f5f04ecb13407612bd65a155cd62acfc6d0fb74aa99a843c039
MATLAB
455
13
function cvx_optval = sum_square( x, varargin ) %SUM_SQUARE Internal cvx version. narginchk(1,2); if ~isreal( x ), error( 'Disciplined convex programming error:\n The argument to SUM_SQUARE must be real and affine.', 1 ); %#ok end cvx_optval = quad_over_lin( x, 1, varargin{:} ); % Copyright 2005-2016 CVX Res...
bc0174cc04ae5eca2ea2b5bc897e976aa38d698091ca9d83ba337f12b6f12651
MATLAB
455
12
function y = conj( x ) %Disciplined convex/geometric programming information for CONJ: % CONJ(X) imposes no convexity restrictions on its arguments. However, % since CONJ(X)=X when X is real, it is only useful for complex % affine expressions. y = cvx( x.size_, conj( x.basis_ ) ); % Copyright 2005-2016 CVX Res...
f1a6181f67d919ebff1341f145d218ab75ba20eeefad8e4e7d8956de692bcd3c
MATLAB
455
23
% T-tests for each condition separately % ------------------------------------------------------------------------ k = length(DATA_OBJ); t = cell(1, k); for i = 1:k t{i} = ttest(DATA_OBJ{i}); t{i} = threshold(t{i}, .01, 'unc'); end o2 = canlab_results_fmridisplay([], 'multirow', 2); for i = 1:k ...
3eb5d677dd5bea6dc5c1be0a9802f461467b1ae20145a603b38eca18570097ed
MATLAB
456
22
clear; clc; close all; addpath(genpath('../functions/')); SUBINFO_FILE = '../../subInfo/rid_sex_mDoB_yDoB_mExam_yExam_ageExam_dx_icv_bl.csv'; GMICV_FILE = '../../vbm_810bl/gmVolAndICV/rid_gmVol_icv_bl.csv'; K = 3; % Requirement for x-axis: auto, auto-center, or manual-center xlimCmd = 'auto-center'; if K == 2 ...
72879d8d83cbea6c6505caf5f656a746e751259a5690f006da77c024d9583bc9
MATLAB
456
13
function z = logitSafe(p) % logitSafe Logit transform guarded against 0 and 1. % % z = logitSafe(p) % % Clamps p away from the open-interval endpoints before taking % log(p./(1-p)), so probabilities of exactly 0 or 1 give large finite values % rather than -Inf or +Inf. Used when converting Elastic Net predicte...
d5b5bf9df1eaa72005c928ed39186d7c859a63a3bb24abb61dea3a977381de58
MATLAB
456
16
function [ results ] = pass_index( self, varargin ) % How far through the field? if isempty(self.cel) self.cel = varargin{1}; varargin = varargin(2:end); end if isempty(self.active_lfp) self.active_lfp = self.cel(1); varargin = varargin(2:end); end results = CMBHOME.PASS_INDEX.pass_in...
b032df4ccadb09f6e2b12f3fcfaf6fdc1856318995c5d92977e42530558dac80
MATLAB
457
22
function s = CBIG_MMLDA_pvalue2str(p) % s = CBIG_MMLDA_pvalue2str(p) % % Convert p value to string % % Input: % - p : double number % % Output: % - s : string % % Example: % s = CBIG_MMLDA_pvalue2str(0.0001); % % Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/m...
e628b49ab8050deab6d60f6d7f80fedc3feb989dc932b04839fcfb0fdf2ab481
MATLAB
457
19
function uisettxt(fig, tag, str, varargin); alltmpobj = findobj(fig, 'tag', tag); for tmpobj = alltmpobj' tmppos = get(tmpobj, 'position'); delete(tmpobj); axes('position', tmppos); axis('off'); if ~iscell(str), str = { str }; end; maxX = 0; for index = 1:length(str) tmp = text...
0817cf9f3b1d5d0372cb52a418594b20ec1c4be17f4d181f3c1b7067444312c1
MATLAB
458
16
function ftr = selectCortexFibers(finame,gm,oversamp,Nsz) gm = nifti(gm); gm = double(gm.dat); ftr = ftrstruct_read(finame); fibs = ftr.curveSegCell; terms = cellfun(@(x) [x(1,:); x(end,:)]-1,fibs,'UniformOutput',false); terms = cat(1,terms{:})'*oversamp; idxbol = SelectCorticalFibers(single(gm),double(Nsz),single...
1010f8d87a5ca741b8ef12210046dfa51d5647bc620992d40e968e76aa32d3b5
MATLAB
458
13
clear; %Motion corrected tiff stacks must all have the same name, defined in line %10 of register_rois2.m baseFolder = ''; % Folder with your reference motion corrected tiff stack and RoiSet.zip otherFolders = {''; % Folders to register the ROIs to. Each needs to contain a motion corrected tiff stack...
30a311851418d8621a2fd0efadcd63b8f0b32f60d6e0e538b778ca199080af6e
MATLAB
458
14
% Local Regression and Likelihood, Figure 11.5. % Author: Catherine Loader % % Local Adaptive Smooth - Dopler example. % Adaptive fitting using Katkovnik (et al) ICI criterion. % % NEED: Improve plot - curve is hard to see. x = (0:2047)'/2047; m = 20*sqrt(x.*(1-x)) .* sin(2*pi*1.05 ./ (x+0.05)); y = m + normrnd(0,1,20...
628541f023f6178f4d5b7d1ce5e2916a1a858da9fb3f43da9cfb407fb24650d6
MATLAB
458
20
function F = isfield(tree,uid,parameter) % XMLTREE/ISFIELD Is parameter a field of tree{uid} ? % FORMAT F = isfield(tree,uid,parameter) % % tree - a tree % uid - uid of the element % parameter - a field of the root tree % F - 1 if present, 0 otherwise % % Is parameter a field of tree{uid} ? % % See ...
e6b9918e7b3260f0a3cde48869f82c5164604d7ce049acdb5906fa701c6ffe4e
MATLAB
459
15
function [new_clu log] =renumberclu(clu,log) % re-orders clu to start from index 1 and iterate through the number of % clusters % rewritten by David Tingley, 2017 new_clu = zeros(length(clu),1); cluster_names = unique(clu); for i=1:length(cluster_names) if cluster_names(i) ~= 0 % keep cluster 0 (noise) as 0 ...
3ea8f3945e6a8f543c6b3195c94264c9893cf8ecb915079326a3cb24c151c871
MATLAB
460
16
function [ outData ] = subfun_GlobalMeanOffsetCorrection( inData ) % correct left-right bias (Global Mean Offset Correction) globalMean = nanmean(inData,1); leftMean = nanmean(inData(1:end/2,:),1); rightMean = nanmean(inData(end/2+1:end,:),1); leftOffset = leftMean - globalMean; rightOffset = rightMean - globalMean; ...
86a227f20755c4079a3e684f7650319a8d9facfcc84fcff23258562cb749c0f9
MATLAB
460
23
function ifcell=ea_checknoerrorfolders(ifcell) cnt=1; ecnt=1; for f=1:length(ifcell) errfiles=dir([ifcell{f},filesep,'*.err']); for e=1:length(errfiles) fid = fopen([ifcell{f},filesep,errfiles(e).name]); A=textscan(fid,'%s'); A=A{1}; fclose(fid); if length(A)<2 ...
8e21061152754a028a355f1ab73ba92691b4f9edf33ac5c72dc763792ac9cca0
MATLAB
460
16
%% Abstract Class - configurablem marker interface % % A subclass has to implement a config panel to allow % graphical confiuration of it's features % % Andreas Husch % Centre Hospitalier de Luxembourg, Dep. of Neurosurgery / % University of Luxembourg - Luxembourg Centre for Systems Biomedicine % 2013 - 2017 % mail@a...
f4acaddbc3f5d6c648c3f629508197ab9f17443fb4bef8c2ce34a9274e06d63e
MATLAB
460
18
% This function calculates the threshold for Holm (stepdown Bonferroni) % multiple testing correction based on the following inputs % % base_alpha alpha value you want to start from, typically 0.05 % num_dvs number of dependent variables/univariate tests function threshold = holmthreshold(base_alpha,n...
255b7eec93420b99e90d23a9615cc1c6ae39751afb17f8d37cb09934ef1ec908
MATLAB
461
14
function z = norm_nuc( x ) %NORM_NUC Nuclear norm of a matrix. % NORM_NUC(X) = SUM(SVD(X)). X must be a 2-D matrix, real or complex. % % Disciplined convex programming information: % NORM_NUC(X) is convex and nonmontonic in X, so X must be affine. narginchk(1,1); z = sum(svd(x)); % Copyright 2005-2016 CV...
7c03fe8134cfface6b1795f0109e372cd1cd5886a5269fdd96ffe4d1ef540bc1
MATLAB
461
14
function varargout = FNN(varargin) %FNN (deprecated) Use fnn instead. % FNN has been renamed to fnn. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Silence with: warning('off','FNN:deprecated') % % See also FNN. warning('FNN:depre...
354c7688f09aaf3ad2c878791f2a8e1df132085d57a6061915f266c39d399607
MATLAB
463
23
function [ STATEints ] = IDStateEpisode(STATEints,maxintdur,minSTATEdur) %UNTITLED Summary of this function goes here % Detailed explanation goes here % %INPUTS % STATEints % maxintdur maximum interruption % minSTATEdur minimum state duration %% %SWSints = stateintervals{2}; [STATEints] = MergeSeparatedInt...
b17a38bc7a28fd0e51da72f2b68d5fe103a10bf38145a0b0e8e34ccf8eaa23c7
MATLAB
463
20
function is_planar = test_planar_graph(G) % TEST_PLANAR_GRAPH Test if a graph is planar % % This function is just a convinence wrapper around % boyer_myrvold_planarity_test. % % Example: % A = clique_graph(5); % test_planar_graph(A) % A(4,5)=0; A(5,4)=0; % make K_5 into a planar graph % test_planar_graph(A) % ...
327d4c32894982ba8368ba0b9b5d92a8b340ad498111e6b5df249c7bcd0478f6
MATLAB
464
20
function eeg_files = dacq_eeg(basePath, prefix) %Provides list of eeg files with the defined prefix int eh defined datapath %folder. file_list = listfiles(basePath); file_list = alphabetizeEEGfnames(file_list); required = [prefix,'.eeg']; count=1; for i = 1:length(file_list) iseeg = strfind(file_...
c6b72906d69b85b54543eeb1d9090841052bba937073314d247db26b207c243d
MATLAB
464
21
function root = FixTime(root) % Aligns the session to start at time 0. % % root = root.FixTime; for i = 1:numel(root.spike) root.spike(i).ts = root.spike(i).ts - root.b_ts(1); end for i = 1:numel(root.b_lfp) root.b_lfp(i).ts = root.b_lfp(i).ts - root.b_ts(1); end root....
6580a3085f454a4d83d2108d3d0a9ea8a22f7555a4ed224aceded272a7ff612e
MATLAB
465
25
function out=locfit_all(varargin) % Smoothing noisy data using Local Regression and Likelihood. % % This is a combination of the locfit and predict functions % % Minimal input validation if nargin < 1 error( 'At least one input argument required' ); end predict_args = {}; locfit_args = varargin{1}; if nargi...
b5a473ae021c02a2991fea1e7cddd31427a0f349f55e5a0973d1f6d8d23d6b89
MATLAB
465
19
function bz_RunAnimalMetadata(basepath) %% Initial variable parsing if ~exist('basepath','var') basepath = cd; elseif isempty(basepath) basepath = cd; end basename = bz_BasenameFromBasepath(basepath); %% bz_EditAnimalMetadata(basepath) %% notesname = [basename,'_AnimalMetadataText']; notesfullpath = fullfil...
e92370a749a45ddcba2d4a0942fefa06f22aa8e415d2a5267592c89033733424
MATLAB
465
5
function CBIG_outof_limit() % Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
29b01465895776834144489528f7c300e3e07784a02adc52154c430c86cd2120
MATLAB
466
11
load('/Users/tor/Dropbox/A_A_CURRENT_DRAFTS_TO_REVIEW/Anjali_BMRK4_painTasteVision_extracted_pexp/bmrk4_pain_specific_PTV_overall.mat') XX = X_pain_all; YY = Y_pain; names = [{'Intercept'} X_col_names {'Interaction'}]; % mean-center and create interaction XX = cellfun(@(x) scale(x, 1), XX, 'UniformOutput', false); XX...
36d972194ba31498b63bc299190bd860194d3c86764ac2c772d9d2955caa3fa2
MATLAB
467
15
function [nch, npoints, freq, d] = ddt_v(filename) import CMBHOME.PLX2Mat.* % ddt_v(filename) Read data from a .ddt file returning samples in mV % % [nch, npoints, freq, d] = ddt_v(filename) % % INPUT: % filename - if empty string, will use File Open dialog % % OUTPUT: % nch - number of channels % npoints - numbe...
60c8bd94da928a0f1a79de13ae7b06e6c4902b57ab98791f77e76bd2a352dbc2
MATLAB
467
15
function [angle, intensity,vectornew] = ea_diode_intensityprofile(artifact,center,pixdim,radius) radius = radius * 2; vector = [0 1] .* (radius / pixdim(1)); vectornew = []; for k = 1:360 theta = (2*pi/360) * (k-1); rotmat = [cos(theta) sin(theta); -sin(theta) cos(theta)]; vectornew =vertcat(vectornew,...
c0f12b246244498846e5a89792dd973a443f0acf30cad70673bedd0714980c32
MATLAB
467
24
function [ WS , DS ] = SparseMatrixtoCounts( WD ) %% Function SparseMatrixtoCounts %% % [ WS , DS ] = SparseMatrixtoCounts( WD ) %% % [ ii , jj , ss ] = find( WD ); ntokens = full( sum( sum( WD ))); WS = zeros( 1,ntokens ); DS = zeros( 1,ntokens ); startindex = 0; for i=1:length( ii ) nt = ss(...
f0e555458c533ce23d3d9923cc1874893741abf34d7378513591ca7083f92aa9
MATLAB
467
15
function COG = ea_diode_calculateCOG(data,Xslice,Yslice,Zslice) data(isnan(data)) = 0; values = data(:)'; % [x,y] = ind2sub(size(data),[1:numel(data)]); % xval = Xslice(x,y).*values; % yval = Yslice(x,y).*values; % zval = Zslice(x,y).*values; xval = Xslice(:)'.*values; yval = Ysl...
7029d2e0d73c3df26caee07c56d21704749e4381a6f9e6b7258f5085c6f0ecc2
MATLAB
469
15
files = dir('*stack.mat'); for n = 1:length(files) load(files(n).name); figure; subplot(4,1,1); plot(leftstack); ylim([-5 5]) subplot(4,1,2); plot(rightstack); ylim([-5 5]) subplot(4,1,3); plot(rawstack'); ylim([-5 5]) subplot(4,1,4); plot(turns); ylim([-3 3]) figure; set(gcf,'Posit...
7d9bff4c1e8cfdffa3ebae6628059fb96408309bbbe085cf845cb6ec8aab82b7
MATLAB
469
19
function data=padNaN(data) % Creates a padded data matrix from input structural array of spike times % pads with NaN % Usage: data=padNaN(data) % Input: % data : structural array of spike times % Output: % data : data matrix (zero padded) NC=length(data); fnames=fieldnames(data); for c=1:NC; eval(['Nsp(c)=length(da...
94b3afcfbeed28b54ecb50e3a7f09f1a300d6fe9fbba698b8994bc668b59192d
MATLAB
470
25
function writeNPY(var, filename) % function writeNPY(var, filename) % % Only writes little endian, fortran (column-major) ordering; only writes % with NPY version number 1.0. % % Always outputs a shape according to matlab's convention, e.g. (10, 1) % rather than (10,). shape = size(var); dataType = class(var); hea...
b9b195f14e123a97ca3a33e229ba1d7557c4843aff7a7c3f57296fa79a657609
MATLAB
472
14
% Local Regression and Likelihood, Figure 11.5. % Author: Catherine Loader % % Local Adaptive Smooth - Dopler example. % Adaptive fitting using Katkovnik (et al) ICI criterion. % % NEED: Improve plot - curve is hard to see. x = (0:2047)'/2047; m = 20*sqrt(x.*(1-x)) .* sin(2*pi*1.05 ./ (x+0.05)); y = m + norm...
b4dba9f668612a064731ccedfd2e7ad967d5a08f7f757e89e3d5da1e72697118
MATLAB
473
19
% Local Regression and Likelihood, Figure 7.3. % % Censored local regression. % % Author: Catherine Loader % % NEEDS: Kaplan-Meier based estimate. Identify curves and cens/uncens. data load heart; fit = locfit(age,log(0.5+surv)); figure('Name','fig7_3: censored local regression Kaplan-Meier based;' ); lfplot(fit); xla...
171324e707813b5b6d6a55a039213d23f93da9591f994f1278df0f1b81cb52c4
MATLAB
474
21
function showROI_3D(Ly, Lx, rois, Img, rin) if max(Img(:)) - min(Img(:))>0 Img = imadjust(Img); Img = Img + 0.2; Img(Img>1) = 1; end Sat = ones(Ly, Lx); % r = [0.1 1]; rois2 = bsxfun(@times, rois, reshape(1:size(rois,3),1,1,[])); ROImap = max(rois2,[],3); if nargin <5 r = rand(size(rois,3)+1,1); else ...
3ca9a808b91e137dfa4552c508f38680cbf82d4aeb6029f6bc5098f5502e189b
MATLAB
474
21
function needstobebuilt=ea_checktpmresolution options.earoot=ea_getearoot; options.prefs=ea_prefs(''); needstobebuilt=1; if ~exist([ea_space,'TPM.nii'],'file') return end load([ea_space,'spacedef']); if isfield(spacedef,'tpm') if strcmp(spacedef.tpm,'custom_fixed') needstobebuilt=0; return end ...
95f3268b5615e4935fdbd8792ca9e2177fedf1c94a10e8fee22f91941f9b1aac
MATLAB
474
14
function outstring = cifti_metadata_get(metadata, key) %function outstring = cifti_metadata_get(metadata, key) % Get the value for a specified metadata key. % % >> provenance = cifti_metadata_get(cifti.metadata, 'Provenance'); outstring = ''; %looping over length handles empty just fine ...
e611fe7fb407e1801d1d51da39a19d0f3498956ad2aac47c5bf38d15501ed4f2
MATLAB
474
12
function T = read_main_text_source_table(sheetName) % Read a source-data table from the consolidated manuscript workbook. % % The workbook is generated by: % manuscript_figure_source_data/code/build_source_data_workbook.py matlabDir = fileparts(mfilename('fullpath')); dawnRoot = fullfile(matlabDir, '..', '..', '..')...
a0828175dd38d7dbc39392fb8ebc7d8876652e37d3f664ca17d83d2879f785a4
MATLAB
475
12
%% SETUP_PACER - add all PaCER subdirectories to your MATLAB path % % Andreas Husch % Centre Hospitalier de Luxembourg, Dep. of Neurosurgery / % University of Luxembourg - Luxembourg Centre for Systems Biomedicine % 2017 % mail@andreashusch.de, husch.andreas@chl.lu %% RUN this file once (F5) to automatically make sure...
cb5622fff1e17670b3ce40f2e8204b0dffb0e7b07a5592a986b9054bdafa7ebf
MATLAB
476
20
function noisemap = normalize_noisemap(noisemap_filename, data_filename, mask_filename, bvalues_filename) tmp = load_untouch_nii(noisemap_filename); noisemap = double(tmp.img); tmp = load_untouch_nii(mask_filename); mask = double(tmp.img); se = strel('cube',9); mask = imerode(mask, se); tmp = load_untouch_nii(data_f...
4e0eceb605e9bbe3c02774a620f4333e04bdb883b8964a73e84fec967694d5fd
MATLAB
478
14
function disp( x, prefix, iname ) if nargin < 2, prefix = ''; end if nargin < 3, iname = ''; end nm = cvx_subs2str( x.name_ ); nm = nm(2:end); if ~isequal( nm, iname ), disp( [ prefix, 'cvx dual variable ', nm, ' (', type( x ), ')' ] ); else disp( [ prefix, 'cvx dual variable (', type( x ), ')' ] ); end % Copy...
6d25a78456b0ef1a5604a0064b421541ec8670a9378bb518bb7a1def7e1f2754
MATLAB
478
20
% Local Regression and Likelihood, Figure 2.5. % % Using different smoothing parameters. load ethanol; alp = [0.2 0.4 0.6 0.8]; f=['a','b','c','d']; for (i=1:4) figure('Name', sprintf( 'figure2_5%c: Smoothing parameters', f(i) ) ); fit = locfit(E,NOx,'alpha',alp(i)); res = residuals(fit); fit2 = locfit(E,res,...
cedeedfc2f3228ec23de2413781c72a592f03e5564c6c31c2341ae423cbff975
MATLAB
478
17
function CBIG_plotSetup % CBIG_plotSetup % % Written by CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md set(0, 'DefaultAxesTickDir', 'out'); % Change default axes fonts. set(0, 'DefaultAxesFontName', 'Arial'); set(0, 'DefaultAxesFontSize', 16); % Change default text fonts. set(0,...
d94651b9a06a22fedf23d637fd061ee91a0ba77b70baf50bd6a7f8f480fec6b9
MATLAB
478
13
%% polyval3 - evaluate an (independent component) polynomial in R3 % % Andreas Husch % Centre Hospitalier de Luxembourg, Dep. of Neurosurgery / % University of Luxembourg - Luxembourg Centre for Systems Biomedicne % 2014 - 2017 % mail@andreashusch.de, husch.andreas@chl.lu function val = polyval3(polyCoeffs, evalAt) ...
dd981d1d6ba48cf8b6c0dbeb4b6da5f5ffc862e3bbe793e0a80373df64d0f49b
MATLAB
478
19
function cvx_optval = quad_pos_over_lin( x, y, varargin ) %#ok %QUAD_POS_OVER_LIN Internal cvx version. narginchk(2,3); if ~isreal( x ), error( 'First input must be real.' ); end x2 = []; cvx_begin variable x2( size(x) ) minimize quad_over_lin( x2, y, varargin{:} ); x2 >= x; %#ok cvx_end % Copyri...
f8dab5f2b6eb6e84cf72a8096275b9a8a7f09a7cc55bb868f9729fcf3c8887b2
MATLAB
478
18
function ea_add_trajectory(~,~,options,pobj,side) d=load([options.root,options.patientname,filesep,'reconstruction',filesep,options.patientname,'_desc-reconstruction.mat']); if ~exist('side', 'var') if isfield(d.reco,'electrode') side=length(d.reco.electrode)+1; else options=ea_detsides(options...
9ac541602ed5cd94be2e9651a26dc7cfae5d05f832b10b86b57b2fab453d46fb
MATLAB
480
15
function signal_filtered = DeltaFilter(signal, Fs) %% Takes 'signal' and bandpasses it for delta frequencies (2 to 4 Hz) % Arguments % signal - arbitrary signal to be filtered % Fs - sample frequency (specific to your recording rig) ex. Mark's % Neuralynx system has a sampling period of .000528, or 1893.9393... Hz ...
e8594be2e3a880cea1f9d2ddfffa37f58b977c0da91182f2eee232e5b484668d
MATLAB
480
14
function pos_and_neg = ea_check_for_SSE_tracts(connectomeFolder,slider_names) % check for which symptoms negative tracts were also exported pos_and_neg = zeros(size(slider_names,2),1); pathways_files = dir([connectomeFolder,filesep,'*.mat']); for slider_i = 1:size(slider_names,2) for pathway_i = 1:size(pathways_f...
14c5610d0d287f0bd59522274a44ca2ba5fb3902758ca69ad3b68d0a6b31bdba
MATLAB
482
18
function z=scb(x,y,varargin) % Simultaneous Confidence Bands % % Example: % load ethanol; % z = scb(E,NOx,'h',0.5); % % result (z) is a matrix with four columns: evaluation points, % fitted values, lower confidence limit, upper confidence limit. % Most locfit arguments should work. fit = locfit(x,y,'ev','grid','m...
2020dc03cde7a434e496393d606dbae4ddeba53081d7fde3179ccd718b55d0b3
MATLAB
482
19
function [ varargout ] = nanInterp1( varargin ) %function [ varargout ] = nanInterp1( varargin ) % Detailed explanation goes here import CMBHOME.Utils.* varargin(cellfun(@isnumeric,varargin)) = cellfun(@nanInterp,varargin(cellfun(@isnumeric,varargin)),'UniformOutput',false); varargout = cell(1,nargout); [~,temp]=...
a384df54a7eb0b4750dcab67ed820285d6365cb1cc6beb6c85f63042ba20d583
MATLAB
482
13
function [ROI, names] = readRoiSet(filename, height, width) [sROI, ROI] = ReadImageJROI_C(filename, [height, width]); ROI = zeros(size(ROI)); [aa,bb] = meshgrid(1:height,1:width); for i_roi = 1:size(ROI,3) temp = inpolygon(bb(:),aa(:),sROI{i_roi}.mnCoordinates(:,1),sROI{i_roi}.mnCoordin...
ff8968eb17695524fb02c503b992b858e9c80ccdd7b774b14973e78ec9276523
MATLAB
482
15
function [n, ts] = plx_ts(filename, channel, unit) import CMBHOME.PLX2Mat.* % plx_ts(filename, channel, unit): Read spike timestamps from a .plx file % % [n, ts] = plx_ts(filename, channel, unit) % % INPUT: % filename - if empty string, will use File Open dialog % channel - 1-based channel number % unit - unit n...
1218660dd0f3ad40a01260ca77e85c38f21ece30df155f20e31de306ac50264c
MATLAB
483
23
function [ ] = UnityLine( varargin ) %Makes a unity line in a plot %Options % 'linetype' % 'linecolor' % 'negative' %% p = inputParser; addParameter(p,'linetype',':') addParameter(p,'linecolor','k') parse(p,varargin{:}) linetype = p.Results.linetype; linecolor = p.Results.linecolor; %% xrange = get(gca,'xlim');...
4fbeeb5cb33d25a6ab9569c5fe83ccbdc588a9aa85612eb890962d2eef7b03bc
MATLAB
483
18
function elem=delendelem(elem,mask) % % elem=delendelem(elem,mask) % % delete elements whose nodes are all edge nodes % % author: Qianqian Fang, <q.fang at neu.edu> % date: 2007/11/24 % % input/output: % elem: input/output, surface/volumetric element list % mask: of length of node number, =0 for internal nod...
5bedb9da91d630e7b3460ff127c4215b16301859a4742f40c1f10ec68dfcde9b
MATLAB
483
14
function varargout = LyE_R(varargin) %LYE_R (deprecated) Use lye_r instead. % LyE_R has been renamed to lye_r. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Silence with: warning('off','LyE_R:deprecated') % % See also LYE_R. warn...
8eae4d332e50a04ebde5519c8791152db108a557344a66192533e4c166eed423
MATLAB
483
20
function cwt = loadCwtOneChannelCrop_(filePath, trialIdx, fIdx, tIdx, useSingle) % Return: nTrialSelected x 1 x nFreqSelected x nTimeSelected if islogical(trialIdx) trialIdx = find(trialIdx); end m = matfile(filePath); info = whos(m, "cwtres"); if max(trialIdx) > info.size(1) erro...
bdf24823617591b80f87509f3208fbc4fa99adc6e7d7bfda3d54d8716b47c196
MATLAB
483
14
function varargout = LyE_W(varargin) %LYE_W (deprecated) Use lye_w instead. % LyE_W has been renamed to lye_w. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Silence with: warning('off','LyE_W:deprecated') % % See also LYE_W. warn...
c08bef02c9a8cad83ffefe01469bc31ea72f92a7e87086d618ab625d6dae09f8
MATLAB
484
29
function data = data_IFNAGRKO_raw() % TOTAL NSC COUNTS (FACS) data.NSC.times = [60 180 660]; data.NSC.raw = { % 60 days [584, 691, 1022.5, 601.5, 378, 494, 383, 393], ... % 180 days [178, 255, 113], ... % 660 days [119, 162, 196] }; % FRACTION OF ACTIVE NSCs (IHC) data.fr...
0e541534cf2a066e9ca436dfd92ce08db13c1fd9170e37a09162ea60b97a8805
MATLAB
486
18
function folder = layoutRoot() %layoutRoot Folder containing the GUI Layout Toolbox % % folder = layoutRoot() returns the full path to the folder containing % the GUI Layout Toolbox. % % Examples: % >> folder = layoutRoot() % folder = 'C:\tools\layouts2\layout' % % See also: layoutVersion % Copyright 200...