sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
4cd2ea9cc33921507fd3f0ef09fd485abb4bb1eb1e67d00f74f7750c4116a4e0
MATLAB
488
13
function ea_resliceanat(preopAnchorImage) % Reslice the pre-op anchor image if the resolution is not sufficient V = spm_vol(preopAnchorImage); dim = V.mat(logical(eye(4))); dim = abs(dim(1:3)); if any(dim>0.7) fprintf('\nInterpolating pre-op anchor image to increase resolution to 0.7...') ea_resample_image_by...
7bc96a6acc807ee54e6ff6bbf8b078bd80afda59e31986866ae2be5b88c74125
MATLAB
488
25
function test_gifti N = 31; [x, y] = meshgrid (1:N); tri = delaunay (x(:), y(:)); z = peaks (N); p = struct ('faces', tri, 'vertices', [x(:) y(:) z(:)]); g = gifti(p); basename = tempname; file = [basename '.gii']; save(g,file,'ASCII'); g = gifti(file); delete(file); save(g,file,'Base64Binary'); g = gifti(file); del...
866a94806ded55b5290d3f6ebd60bc60787b939133032b8d9382bf8b3edd7527
MATLAB
488
24
% Example Bayesian meta-d fit (single subject) clear all close all Ntrials = 1000; c = 0; c1 = [-1.5 -1 -0.5]; c2 = [0.5 1 1.5]; d = 1.5; meta_d = 1; mcmc_params = fit_meta_d_params; mcmc_params.estimate_dprime = 0; % Generate data sim = metad_sim(d, meta_d, c, c1, c2, Ntrials); % Fit data fit = fit_meta_d_mcmc(sim...
ac1d7f240ae8f1a25a9faa8da6c2c3678fe6f26bbb203467897ee9b777af6502
MATLAB
488
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...
021076c73cdb948ca1a69a4e8808300d95257d9d20c53593f1b63310cf75251e
MATLAB
489
23
function disp(obj) % Disp a NIFTI-1 object % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: disp.m 4136 2010-12-09 22:22:28Z guillaume $ sz = size(obj); fprintf('NIFTI object: '); if length(sz)>4, fprintf('%d-D\n',lengt...
23cd006b78214bb7c240d783678e1f02ce78f396d09c9ba1235881ef68803a5a
MATLAB
489
14
function CFA_TransToBCBLQT PG = uigetdir(pwd,'Normalized ROI Directory'); dir2 = [PG,filesep,'NormROI',filesep]; dirout = [PG,filesep,'NormROI_BCBLQT',filesep]; mkdir(dirout); disp('translation start!') [pth nam ext] = fileparts(which('CFA_TransToBCBLQT.m')); refimg = fullfile(pth,'MNI152_T1_1mm_182218182.nii'); files ...
2865b75e5873ed651ecfe04b88dbb4e32207126889b73f2c717d8887e363563d
MATLAB
489
24
function paths = sortCwtPathByChannel_(paths) % Sort paths according to the last integer in filename. if isempty(paths) return; end chNum = nan(numel(paths), 1); for i = 1:numel(paths) [~, name, ~] = fileparts(paths{i}); nums = regexp(name, '\d+', 'match'); if isempt...
3a5436230269eb7c1ff9feb20e7b5bc57a51d87a3595fe78861170007acfd770
MATLAB
489
18
function v = value( x, data ) global cvx___ if nargin == 1, data = cvx___.x; end nx = size( data, 1 ); nb = size( x.basis_, 1 ); if nx < nb, data( end + 1 : nb, : ) = NaN; elseif nx > nb, data( nb + 1 : end, : ) = []; end v = cvx_reshape( data.' * x.basis_, x.size_ ); if any( x.size_ == 1 ), v = full( v ); ...
617491302680730e2b5766bf2ac736c65a158104d76daf301e90ea6b5d796bf7
MATLAB
489
22
function id=ea_explorer_method2methodid(obj,efm) if ~exist('efm','var') efm=obj.statsettings.efieldmetric; end switch obj.statsettings.stimulationmodel case 'VTA' id='peak'; case {'Electric Field','Sigmoid Field'} switch efm case 'Mean' id=['mean']; ...
cfdd77688eae62a9e9c5ba098da385b138dc7fa8ede65b5e826aa4310da5738e
MATLAB
489
23
function [vec,I]=greatsort(x); %GREATSORT sorts the vector x in descending order. % % Required input arguments: % x : vector to be sorted % % Output arguments: % vec : sorted vector % I : index => x(I)=vec. % % I/O: [vec,I]=greatsort(x); % % This function is part of LIBRA: the Matlab Library f...
f550ae12348f342da89d6a2602bd46f525ddec24c64510bab726b77cb9184a56
MATLAB
489
18
% CHECKLINE check a line of TOML data for validity % % CHECKLINE(toml_line) tests that line for invalid forms, and raises % an exception if one of them is applicable. function checkline(in) % check for unspecified value if in(end) == '=' error('toml:UnspecifiedValue', ... 'TOML keys must have a c...
1764b520a9791a4e55fdce356ab92efc9adf44e63a6f67b175779b4fa075d3f3
MATLAB
490
18
function allROIs = addSpectralMetrics(allROIs, metricField, fieldStr, numEigs) % Creates feature/metric values from spectral embedding of the specified % feature field switch metricField case 'metrics' metrics = getMetrics(allROIs, 1); case 'PCs' metrics = cat(1, allROIs.PCs); case 'rotPCs'...
edfb3b71bc2c423711138c7738f7eb96bc666b23159becb95790e6aa669d2803
MATLAB
490
19
function mymessage(param,s,varargin) if (param.verbose == 1 ) s = [ '\t' s ]; if ( strcmp(param.verboseout,'screen') == 1 ) if ( nargin == 2 ) fprintf(s); else fprintf(s,varargin{:}); end else fido = fopen(param.verboseout,'a'); ...
0b964a288164c5630b896910a35c16d49ef13068cf9d0a74553292689f8eda96
MATLAB
491
13
function getBinaryClassifiersTestMix(blockTagsAC,features,folderpath,nameTag,featureNum) classes = ['OC';'OH';'OW';'CH';'CW';'HW']; numType = zeros(6,4); for cla = 1:6 class1 = classes(cla,1); class2 = classes(cla,2); [perfMat,numType0] = binaryClassTestMix(class1,class2,blockTagsAC,features,folderpath...
0c2e0257b7e71f1dde9e8475ec266c5bcc8fb80796fc91ec9ba10edfc602fb94
MATLAB
491
18
function v=jUpperTriMatToVec(m,offset) % converts the upper-triangular part of a matrix to a vector % % IN: % m: matrix % offset: offset above leading diagonal, fed to triu function % OUT: % v: vector of upper-triangular values % % v1.0 Oct 2009 Jonas Richiardi % - initial release % v2.0 Feb 2011 Jona...
ab368410f603002022668a435e986b2ccbac70ad658da2e4f06a0cb50017bb02
MATLAB
491
23
function filepath = ea_path_helper(filepath) % handle special characters in the path for cli compatibility if ischar(filepath) % support char or cell input filepath = {filepath}; waschar = 1; else waschar = 0; end for i=1:length(filepath) filepath{i} = GetFullPath(filepath{i}); if ispc fi...
05ea5c0ae7d65b5d7f94bd2e374510d53faa946f4bb7a2755d9df5648c6d1ac0
MATLAB
492
22
function hashnum = createDWIHashnum(datastruct,Pstruc) ten = datastruct.original_bTensor; alpha = Pstruc.alpha + Pstruc.restrictions*2 + 8*Pstruc.sphericalDiscNumber; ordermax = Pstruc.ordermax; tissue = datastruct.fixedTissueMode; for k = 1:5, hashnum(k) = sum(ten(:).^k); end; if isempty(tissue) tissue = ...
216263b1513d00411df0b856ba80a30c2d690b2e847cfad81e9232619d2bd3ce
MATLAB
492
17
function z = newtemp( prob, siz ) % NEWTEMP Creates a temporary variable. global cvx___ vstr = cvx___.problems( prob.index_ ).variables; if isfield( vstr, 'temp_' ), ndx = length( vstr.temp_ ); else ndx = 0; end base = struct( 'type', { '.', '{}' }, 'subs', { 'temp_', { ndx + 1 } } ); z = newvar( prob, base, ...
d3acba77dccf5a3642fe9976893593ecec9ef833090fbb155786d96d2de57814
MATLAB
492
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;' ); lfplo...
bc5b78e83ddead18886171e18478d91ba60f72d9132868033417e0462053f77e
MATLAB
493
19
function DynamicBC_write_NIFTI(dat,vm,outname) datdims = size(dat); if length(datdims)==3 v1 = vm(1); v1.dt = [16,0]; v1.n=[1,1]; v1.fname = outname; spm_write_vol(v1,dat); elseif length(datdims)==4 for i = 1:datdims(4) v1(i) = vm(1); v1(i).dt = [16,0]; v1(i).n=[i,1]; ...
32d455296762b1ac72fb1f2fc9e94b483a43def4d4ebac16cffc2ffe2f7ab008
MATLAB
494
19
% Local Regression and Likelihood, Figure 11.1 % % Variable degree fit, uses module 'vord'. Note there is % no `lower' degree here; it defaults to 0. % % Author: Catherine Loader load ethanol; figure('Name','fig11_1a: Variable degree fit'); fit = locfit(E,NOx,'deg',3,'nn',0.3,'module','vord'); lfplot(fit); figure('N...
b685b3f1831ed96462c9b2ab51a2b8a06457efa85d6953bf768b361a2229c0d2
MATLAB
494
14
function varargout = Ent_Ap(varargin) %ENT_AP (deprecated) Use ent_ap instead. % Ent_Ap has been renamed to ent_ap. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Silence with: warning('off','Ent_Ap:deprecated') % % See also ENT_AP...
bfc968fa7468f7ac60c56407e6798b4fc1ae154fe07085f661ff956ba1f1e338
MATLAB
494
28
function plotSamples(samples) % function out = plotSamples(samples) % % Plots chains and histograms of samples to check mixing % % INPUTS % % samples - vector of MCMC samples % % Steve Fleming 2015 stephen.fleming@ucl.ac.uk figure; set(gcf, 'Position', [200 200 800 300]) subplot(1,2,1) plot(samples'); xlabel('Sample'...
e02abebfa77a3f418b8c18dfacff4a0b9a428842be91f5798f01772b0a5f3b43
MATLAB
494
20
function t = structn(obj) % Convert a NIFTI-1 object into a form of struct % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: structn.m 1143 2008-02-07 19:33:33Z spm $ if numel(obj)~=1, error('Too many elements to convert...
44033cb8ea03f04c417c98ead2ccd9d73c25416e0db9f318a36e9a78465b212e
MATLAB
495
18
function plotRawAudio() % Navigate to a folder full of mic data from one experiment and run as: % plotRawAudio() tn = dir('*.mat'); [~,index] = sortrows({tn.date}.'); tn = tn(index); clear index names = {tn.name}; figure; hold on for n = 1:length(names) load(names{n}) for s = 1:2 subplot(6...
1a22a2ff228bf25374a7ca0c5f06ca0a976f039e933c4d0a553d13e74f3d3502
MATLAB
496
14
function varargout = RQA(varargin) %RQA (deprecated) Use rqa_legacy instead. % RQA has been renamed to rqa_legacy. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Silence with: warning('off','RQA:deprecated') % % See also RQA_LEGACY...
6f2c228143829486e91c31914e6b683897dd0394b144ffeda55dadaa6d035cd5
MATLAB
496
19
function [isoctave verinfo]=isoctavemesh % % [isoctave verinfo]=isoctavemesh % % determine whether the code is running in octave % % author: Qianqian Fang, <q.fang at neu.edu> % % output: % isoctave: 1 if in octave, otherwise 0 % verinfo: a string, showing the version of octave (OCTAVE_VERSION) % % -- this function...
26478d8d08815893eca3dbcced01204cd1047264b4e582fa1edccf0ca33cf9de
MATLAB
497
21
function savesmf(v,f,fname) % % savesmf(v,f,fname) % % save a surface mesh to smf format % % author: Qianqian Fang, <q.fang at neu.edu> % date: 2007/11/21 % % input: % v: input, surface node list, dimension (nn,3) % f: input, surface face element list, dimension (be,3) % fname: output file name % % -- th...
2ee6ddcc27a0b74c2c16e58e6c1a124b0fa88f7b17c72dc0020d508b01f0e8d4
MATLAB
497
14
function varargout = RQA021525(varargin) %RQA021525 (deprecated) Use rqa instead. % RQA021525 has been renamed to rqa. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Silence with: warning('off','RQA021525:deprecated') % % See also ...
05ab11d41c96269d4f61d72a91ce1ac48ccd7ed382521a7091fb833556510999
MATLAB
498
16
function arrout = DownSampleSum(arrin,binsize) %% This function takes an array and sums its elements as per binsize. %% It trims off the cells at the end that do not constitute a full bin % andrew 8 oct 2009, inspired by neat trick somewhere in the www arrin=arrin(1:end-rem(length(arrin),binsize)); numbins=length(...
9263f7f81a1b82657540d82caf94233b13ababd5b13e0de2aec099a1e93013cf
MATLAB
498
21
% Local Regression and Likelihood, Figure 6.5. % Author: Catherine Loader % % Local smooth of CO2 dataset. % Use bivariate fit to capture the two trends. % % bonus plot: fitted values vs year. load co2; fit = locfit([month year+month/12],co2,'alpha',0.2,'style','an','scale',[6/pi,10]); figure('Name','fig6_5a: Local s...
9cae8078e2b5e926dcdd237a4eaa6a4475488481be6cd9c1144e5e3034f03772
MATLAB
498
21
function elem=removedupelem(elem) % % elem=removedupelem(elem) % % remove doubly duplicated (folded) elements % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % elem: list of elements (node indices) % % output: % elem: element list after removing the duplicated elements % % -- this function is part of is...
f93a83c216ffc67e3b9ae659dd24c30f44d1ae8d0094550106c9b4ddee934b5f
MATLAB
498
16
function RATIO_dosl_approx = cal_RATIO_dosl_approx(R, T2b, T1d, dw, w1, B1, B0) w1 = w1*B1; dw = dw+B0.*2*pi; D = 1/sqrt(15)/T2b; N_scale = 5; Rrfb1 = RF_MT(T2b, w1, dw, 'SuperLorentzian'); Rrfb2 = RF_MT(T2b, w1/N_scale, dw/N_scale, 'SuperLorentzian'); numerator = (R + Rrfb2...
197e85791a3618b0e61edcae2d48236fbba466af14fc9701296630ffc59b9c66
MATLAB
499
17
% Local Regression and Likelihood, Figure 6.6. % Author: Catherine Loader % % Penny data, estimating jump size using left and % right smooths. % load penny; midp = (1945:1988)'+0.5; fitl = locfit(year,thickness,'style','l','alpha',[0 10],'ev',midp,'deg',1); fitr = locfit(year,thickness,'style','r','alpha',[0 10],'ev',...
cba74c8c123a8f1f5422434ec4f32f058eec07bfbb7d6b74f53ca4bdc5cd59be
MATLAB
499
18
function o = niftistruc(fmt) % Create a data structure describing NIFTI headers %__________________________________________________________________________ % Copyright (C) 2005-2012 Wellcome Trust Centre for Neuroimaging % % $Id: niftistruc.m 4967 2012-09-26 18:19:23Z guillaume $ if ~nargin, fmt = 'nifti1'; end swit...
e004cb05e9cb0fc93f9b8d0603811abba7cf9dfd0663d5256ff589f477964e51
MATLAB
499
9
x0=xlsread('E:\Data Analysis\2P Imaging\2024 June Data processing\Mice9_ACC_old\Data\d28_mean.xlsx'); %¶ÁÈ¡Îļþ % x1=xlsread('intensity_30min.xlsx'); %¶ÁÈ¡Îļþ % x2=xlsread('intensity_2h.xlsx'); %¶ÁÈ¡Îļþ % x3=xlsread('intensity_24h.xlsx'); %¶ÁÈ¡Îļþ % x4=xlsread('intensity_7d.xlsx'); %¶ÁÈ¡Îļþ % x5=xlsread('intensity_...
2dc2afdd3d95c8c16a0631324ca4ad83d07341e6f81f8b784f6f36f71cc16b5b
MATLAB
500
20
function z = ea_nanzscore_sampled(data, NumSamples) % zscore samples from input data excluding NaNs % Data without NaNs datawonan = data(~isnan(data)); if isempty(datawonan) warning('Input data are all NaN'); % Return the original input z = data; return; end % Sampling if NumSamples<1 % percent given ...
6861b1363d52dfa4b1c40222e230b6ce84302f980f19e0d0656b911978960fd2
MATLAB
500
16
function [ y, symm ] = cvx_s_upper_hankel( m, n, symm ) % CVX_S_UPPER_HANKEL Upper Hankel matrices. c = 0 : n - 1; c = c( ones( 1, m ), : ); r = ( 0 : m - 1 )'; r = r( :, ones( 1, n ) ); v = abs( r + c ) + 1; temp = v <= min( m, n ); y = sparse( v( temp ), r( temp ) + m * c( temp ) + 1, 1, min( m, n ), m * n ); ...
f39b7620940ec67792da540d31565ac533d525a1cdeb64ea5d2a1a8f37ec43aa
MATLAB
500
19
%% Figure 9 supp 2 % RUN fig9_analysis, then return here fig9_analysis %% Panel A: % Subpopulation troughs along difference axes in feature space plotSubpopTroughs(allROIs, subpopGMMs, 'logistic') %% Panel B: % Subpop distributions in tSNE space contConfig.thresholds = [98 95 90]; contConfig.alpha = 0.5; contConfig.l...
10befe87bed30d120859cf54f2aec3e718d470ad08123ea793c6291d93e82971
MATLAB
501
19
function [V2 F2 ID2] = InsidePoints3D(V,F) % Remove points outside the contour pointOutside=true(size(V,1),1); for i=1:size(F,1) pointOutside(F(i,1))=false; pointOutside(F(i,2))=false; pointOutside(F(i,3))=false; end for i=1:size(V,1) if(pointOutside(i)) if(CheckPointOutInside3D(V(i...
7a3c886ff2dd512be806194ab5447a94b2d13a26570862e6e94ee53ac7a02705
MATLAB
501
29
% example of how to call gbvs with default params img = imread('samplepics/4.jpg'); out_gbvs = gbvs(img); out_itti = ittikochmap(img); subplot(2,3,1); imshow(img); title('Original Image'); subplot(2,3,2); show_imgnmap(img,out_gbvs); title('GBVS map overlayed'); subplot(2,3,3); show_imgnmap(img,out_itti); title('I...
ebab06f4181b968de8dfbdd5ee7a1a314821041cf2886269a20e95d8d49dfbb8
MATLAB
501
15
function folders = CollectFolders(base_path) % returns full path to directories within base_path in_base_path = dir(base_path); folders = []; counter = 1; for folderi = 1:length(in_base_path) if in_base_path(folderi).isdir && ~strcmp(in_base_path(folderi).name,'.') && ~strcmp(in_base_path(...
5aa0042dbdf64fdc998b691757376fbecbb7f41ba86b4e54c6ecb409c4bd6a49
MATLAB
502
33
function [f,p,r] = compute_f(T,H) if length(T) ~= length(H), size(T) size(H) end; N = length(T); numT = 0; numH = 0; numI = 0; for n=1:N, Tn = (T(n+1:end))==T(n); Hn = (H(n+1:end))==H(n); numT = numT + sum(Tn); numH = numH + sum(Hn); numI = numI + sum(Tn .* Hn); end; p ...
6432487c3505b84812a7818f526969a8b1d4188f53e90cb7d9f0aea27284343f
MATLAB
502
33
function z=backtr(y,fit) % % Inverse-link transformation of y. fali = fit.fit_points.family_link; link = fali(2); switch link case 3 z=y; case 4 z=exp(y); case 5 z = y; i = find(y<=0); if (length(i)>0) z(i) = exp(y(i))./(1+exp(y(i))); end; i = find(y>0); if (length(i)>0) ...
bde4903327848841570d8fd7f320624341fe507949bfe7d55b75aa5b54fe3544
MATLAB
502
13
function obj=set_datetick(obj,varargin) %set_datetick Specify that the x axis has dates % % This function can receive the same optional arguments as the % datetick() function of matlab. In gramm versions before March 2018 the % behavior was to force the 'keepticks' options. Now the options % 'keepticks' or 'keeplimits'...
dbf20e1430e04ab8c05b250c1d4a69046ea35e568ecf0ec7f57fd9dbd2997c63
MATLAB
502
16
function tree = move(tree,uida, uidb) % XMLTREE/MOVE Move (move a subtree inside a tree from A to B) % % tree - XMLTree object % uida - initial position of the subtree % uidb - parent of the final position of the subtree % % Move a subtree inside a tree from A to B. % The tree parameter must be in input AND in o...
f059364a0b563ebc10047b9ce26f4c1bb2adc15302085a322347a88b15f99136
MATLAB
502
9
% Figures, examples, and exercises from the book <a href="http://stanford.edu/~boyd/cvxbook">Convex Optimization</a> % % Ch04_cvx_opt_probs/ - Chapter 4: Convex optimization problems % Ch05_duality/ - Chapter 5: Duality % Ch06_approx_fitting/ - Chapter 6: Approximation and fitting % Ch07_statistica...
36df7c8700a7a43688684de58712f57c8861bc3bd6fba2e6681bb03452c020e9
MATLAB
503
16
function [ts] = PL2StartStopTs(filename, startOrStop) % PL2StartStopTs(filename, startOrStop): read recording start or recording stop event timestamps from a .pl2 file % % [ts] = PL2StartStopTs(filename, 'start') % [ts] = PL2StartStopTs(filename, 'stop') % % INPUT: % filename - if empty string, will use File O...
210995f816b0a04b2feecc8a4e77d14f3adf182c8f617ce51d6658edb70a1ed7
MATLAB
505
16
function y = apply( func, x ) y = do_apply( func, x.value_ ); function y = do_apply( func, x ) switch class( x ), case 'struct', y = cell2struct( do_apply( func, struct2cell( x ) ), fieldnames( x ), 1 ); case 'cell', y = cellfun( func, x, 'UniformOutput', false ); otherwise, y = fev...
d46749dd20b05c187258893b90cc3a35240b7164b7b665f5c6787d0d593ee1ab
MATLAB
505
14
function varargout = Ent_xAp(varargin) %ENT_XAP (deprecated) Use ent_xap instead. % Ent_xAp has been renamed to ent_xap. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Silence with: warning('off','Ent_xAp:deprecated') % % See also ...
f3b8117e4c3fd22b05dc2c8c1eeff3b2bb664da6e38e8c9f0f321ba8d7a63844
MATLAB
505
20
function [ varargout ] = nanInterp1( varargin ) %UNTITLED2 Summary of this function goes here % Detailed explanation goes here % Jason Climer 2012.01.08 import CMBHOME.Utils.* varargin(cellfun(@isnumeric,varargin)) = cellfun(@nanInterp,varargin(cellfun(@isnumeric,varargin)),'UniformOutput',false); varargout = cell...
fa800696a417f21d68a66730a7a1391ddf711f42600bea39d15094b0a34ad01d
MATLAB
505
18
% Andreas Husch % 2018 function binaryMask = largestConnCompSliceWise(img3d) binaryMask = false(size(img3d)); for i = 1:size(img3d,3) % z cc = bwconncomp(img3d(:,:,i)); ccProps = regionprops(cc, 'Area', 'PixelIdxList'); [~, idx] = sort([ccProps.Area]); brainMaskIdxs = []; if (~isempty(idx)) ...
3931ef95d2770f55fae8916eb1375fa83f1f783ed39b25aa2985010bc0a90f0b
MATLAB
506
22
function n = selectLocalTetrode(self,cel) % Returns the index of the lfp that corresponds to the local LFP of your cell. % wchapman 20130403 for i = 1:length(self.b_lfp) t{i} = self.b_lfp(i).channel_name{end}; end if strfind(t{1},'ncs') %Neuralynx for i = 1:length(self.b_lfp) u = t{i}(4:end); ...
cd97356989a97548de12cb888cd3f7005d883bac8bc15dbedfccb3b8d3e35ddb
MATLAB
506
22
function ea_concat_fMRI(directory,sessions,output) if ~exist('output','var') output=[directory,'rest.nii']; end for sess=1:length(sessions) nii=ea_load_untouch_nii([directory,sessions{sess}]); if ~exist('allnii','var') allnii=nii; sessvec=ones(size(nii.img,4),1); else allnii.img=cat(4...
796bae84147ab9fa94df726ba7714e5d91a2d5c180516c99878bfd86f7417ac8
MATLAB
507
17
function [lfpCat] = catLFPstruct(lfp) % [lfpCat] = catLFPstruct(lfp) % % Concatenate inervals from an buzcode lfp structure lfpCat = lfp(1); lfpCat.data = []; lfpCat.timestamps = []; lfpCat.duration = []; lfpCat.interval = []; for i = 1:size(lfp,2) lfpCat.data = cat(1,lfpCat.data,lfp(i).data); lfpCat.times...
8319bf0980ba4a80c849f9f64bf48369f492a25e31c8fec0ed562144ed08ec94
MATLAB
507
27
function [ X ] = nanInterp( X, method) if ~exist('method','var'), method = 'nearest'; end; if all(isnan(X)) X=zeros(size(X)); return elseif isscalar(X)||isempty(X) return else if isnan(X(1)) X(1:find(~isnan(X), 1 )-1) = X(find(~isnan(X), 1 )); end if isnan(X(end)) X(f...
9ca4d861b79a2fcac5cd4523e99d7b2641d5cd887b60278f1b1fbdba95a09550
MATLAB
507
15
function GCO_LoadLib() % GCO_LoadLib Attempt to load the GCO_MATLAB library. % GCO_LoadLib is used internally by all other GCO_MATLAB commands % to compile (if necessary), load, and bind the wrapper library. if (isempty(getenv('GCO_MATLAB'))) GCO_BuildLib(struct('Force',false)); if (exist('gco_mat...
e0b1ad849e0f089f7abe0ffe50476aa4d6453eefe5985bcda73ddc7fee0ce470
MATLAB
507
16
% neural_net() - computes clusters using Matlab Neural Net toolbox. % Alternative clustering algorithm to kmeans(). % This is a helper function called from pop_clust(). function [IDX,C] = neural_net(clustdata,clus_num) nmin = min(clustdata); nmax = max(clustdata); net = newc([nmin ;nmax].',clus_num); ...
3cbfbb4e18eb991d553fa8c22345e02c4549720d96a701559f0eccdf40c44d06
MATLAB
508
14
function varargout = JRQA021525(varargin) %JRQA021525 (deprecated) Use jrqa instead. % JRQA021525 has been renamed to jrqa. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Silence with: warning('off','JRQA021525:deprecated') % % See...
7d9da63a88255087fe1a00be247ea82c3decaef3efe4bfaba55b6138368279d2
MATLAB
508
32
function stackplot(x,y,parms) % Usage ... stackplot(x,y,options) if nargin==1, y=x; x=[1:length(y)]; end; if ~exist('parms','var'), parms=[1]; end; mean_plot = parms(1); if length(parms)==1, ym=mean(y,2); ymin=min(ym); ymax=max(ym); spacing = 1.5*(ymax-ymin); end gcf=figure; clf, yshift=0; for...
8ab28ad52a012e30394e04153330f3a0ed3193acb022f6993f13cc03a0e83a13
MATLAB
508
14
function varargout = CRQA021525(varargin) %CRQA021525 (deprecated) Use crqa instead. % CRQA021525 has been renamed to crqa. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Silence with: warning('off','CRQA021525:deprecated') % % See...
b7fb454809a6738f939596ddc51be129cf3c49917fa12a859956834a7c2c67f0
MATLAB
508
11
function BFoutput = BFuDBcalc(BFoutput,PkResponseVar) nCell = size(BFoutput.(PkResponseVar),1); [~,BFfqIDX] = max(cell2mat(cellfun(@(c) nanmean(reshape(c,[numel(BFoutput.dBlist) numel(BFoutput.freqList)]),1),... mat2cell(BFoutput.(PkResponseVar),repmat(1,[1 nCell]),numel(BFoutput.freqList)*numel(BFoutput.dBlist)...
e17d7f4a8ba0fd1ee18d50d109ce7c63fdd73b7f4e5e83878835625d797df92a
MATLAB
508
25
function [ face_color , face_alpha , edge_color , edge_alpha ] = parse_fill (fill,color) face_alpha=1; edge_alpha=0.8; switch fill case 'edge' edge_color=color; face_color=color; face_alpha=0; case 'face' edge_color='k'; edge_alpha=1; face_color=color; case '...
7761251eee9395598e3495e9fd3eb8e9efd0b4c9028bfcd5543a72a7d7278f50
MATLAB
510
18
function [XX, t] = icp_init_translation(XX, YY) % tri = delaunayn(YY'); % [idx, D] = dsearchn(YY', tri, XX'); % data_match = [idx, [1 : size(XX,2)]', D]; % % distTh = mindist; % data_match = sortrows(data_match, [1, -3]); % [~, ii, ~] = unique(data_match(:,1)); % data_match = data_match(ii,:); % x0 = mean(XX(:...
d4df74b18b8a47286f7e824ffd0dd5f561e2b8c1852b0224980c3ed9f8e942eb
MATLAB
510
14
function varargout = corrdim(varargin) %CORRDIM (deprecated) Use corr_dim instead. % corrdim has been renamed to corr_dim. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Silence with: warning('off','corrdim:deprecated') % % See als...
9c2e5f3fabf1a69b4aa7cba64ad3d0cf0ff4ea7df8e4f3a3c3ac90e0b2591b66
MATLAB
511
15
function ea_segmask_cleanup(options) % removes all segmentations if co-registration / normalization were re-done % this is a "safety" feature % By Butenko and Li, konstantinmgtu@gmail.com arguments options % Lead-DBS options for the subject end pattern = '(segmask|-C123_mod|label-(GM|WM|CSF)_mask)'; maskFiles...
842932c7a50b35c339f2bb7c1a9986d08fd96f92a2d900d7dfc4218611565df7
MATLAB
512
22
function ea_surfice_heatmap_menu(~,~,handles,sides,manualcontrast) % exports heatmaps from selected niftis via surfice. [fis,path]=uigetfile({'.nii'},'Select files to visualize...','Multiselect','on'); if ~iscell(fis) fis={fis}; end for fi=1:length(fis) fullfi{fi}=fullfile(path,fis{fi}); end if manual...
b5de9f66823cfc2354df1d416b9c6b741c266a0a91c29429a85f9dc4e045acf7
MATLAB
512
25
function ea_savefibertracts(outputFTR,fibers,idx,voxmm,mat,vals) ftr.fourindex=1; ftr.ea_fibformat='1.1'; ftr.fibers=fibers; ftr.idx=idx; ftr.voxmm=voxmm; if exist('mat','var') if ischar(mat) % Path to the reference image provided ftr.mat = ea_get_affine(mat); else ftr.mat = mat; end end ...
df353b00526bbb8891fffbb4e26be9590694c9e4f313c6720610f47538146cb1
MATLAB
512
23
function [t,p,Z,P] = VLSMsubfunc(DAT,GROUP1,GROUP2,COVterm,VALt) g1 = find(DAT); group = GROUP2; group(g1) = GROUP1(g1); GROUP = term(group); SLM = 1+GROUP; contra = [0 1 -1]; for i = 1:size(COVterm,2) A = full(COVterm(:,i)); COVT = term(A); SLM = SLM+COVT; contra = [contra,0]; end SLMnew = SurfStatLinM...
292bb27788c1cd42219ff9c43151ee67b4fa41ecbee56ff0bea55e7da1e46ee1
MATLAB
513
15
function data_out = Trinh_interpolateChannels(data_in,missingchannels,neighboursfile,method) if ~isempty(missingchannels) cfg = []; cfg.method = method; cfg.missingchannel = missingchannels; cfg.senstype = 'eeg'; cfg.neighbours = neighboursfile; ...
5c3758f6d3c942ed5b4b94cdf90d74e90dbfdd489f865fd5e7f589da7fd3daaa
MATLAB
513
16
function arrout = DownSampleMean(arrin,binsize) %% This function takes an array and gives the mean of its elements as per binsize. %% It trims off the cells at the end that do not constitute a full bin % andrew 8 oct 2009, inspired by neat trick somewhere in the www arrin=arrin(1:end-rem(length(arrin),binsize)); n...
c5ba288ca0ad6c0f63f8eb2ff0d66a6f3beddfd94d557707580ea9b278d0ecf4
MATLAB
513
23
function xpsr = psr(x,tau,dim) % Phase space reconstruction % Input % x : Time series that needs phase space reconstruction % tau : Optimal time delay % dim : Optimal embedding dimension % Output % xpsr : M x dim*DIM matrix % Get time series size N = height(x); DIM = width(x); % Compute leng...
f504417a66516acdbb7a9848fbffb30854fb1a16140f8f99d580aa52513ff8ef
MATLAB
513
17
% remove all path with a given parent path % varargin contains a list of path to exclude function removepath(parentpath, varargin) if isempty(parentpath), return; end; folder = path; if ispc, sep = ';'; else sep = ':'; end; indSep = find(folder == sep); indSep = [ 0 indSep length(folder)+1 ]; for iSep = 1:length(ind...
337ae6ac758788686b8b0cd96eb296bd3a1889e1c0dd89b2ef305fe8c40ae686
MATLAB
514
26
function num = CBIG_pMFM_count_func(array) % This function is used to compute number of time points for high and low % states % % Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md num = []; count = 0; for i = 1:length(array) if array(i) == 1 cou...
930576547986090bc0c4a3c577c83886673b19e630212903959381ce00a98998
MATLAB
514
19
% Local Regression and Likelihood, Figure 6.6. % Author: Catherine Loader % % Penny data, piecewise smoothing. % load penny; u = find(year <= 1958); fit1 = locfit(year(u),thickness(u),'alpha',[0 10],'deg',1); u = find((year>1958) & (year <= 1974)); fit2 = locfit(year(u),thickness(u),'alpha',[0 10],'deg',1); u = find(y...
d8f98b37c213861ea8e145b97f31bdc5275b0acf648fff99c85ce0f25778fb62
MATLAB
514
13
X = randn(1000,3)*1.5; scatter3(X(:,1),X(:,2),X(:,3),4,[1 1 1],'filled'); hold on; t = [0:0.0001:2]; h = plot3(1.4*cos(t*164),1.4*sin(2+t*131), 1.4*sin(154*t)); set(h,'Color',[0 1 1]); camproj('perspective'); daspect([1 1 1]); camtarget([0,0,0]); campos([9,9,9]); camva(10); set(gcf,'renderer','opengl'); set(gca,'Colo...
67e94b3172e62212e2a7d8726c8454ced6daa19579b10a166f0ce5fb59b5214e
MATLAB
515
24
function out = gammacon(val,whichway) %Convert rgb to luminance or vive versa using a gamma function %values taken on 12/12/2018 in lab 4 %String argument can be either 'rgb2lum' or 'lum2rgb' a = 3.4590; b = 128.492; g = 1.81; if strcmp('rgb2lum',whichway) out = a+b.*(val.^g); elseif strcmp('lum2...
d76d5ced3f2ed4d645cb279f009a1a5a6fe15b81034907f4f04ca824f9798425
MATLAB
515
10
function structure = structindex(structure, index) %STRUCTINDEX Indexes each field in a structure of arrays. % STRUCTOUT = STRUCTINDEX(STRUCTIN, INDEX) takes a structure STRUCTIN % in which every field is a cell or numeric array and returns a % structure with the same fields with the data rearranged acc...
e32d82bfd62d8d5d7731827da36984ed850bde3c8dd081781360fdfe41f8c937
MATLAB
515
15
function maxChannels = getWaveformMaxChannel(templateWaveforms) % JF, Get the max channel for all templates (channel with largest amplitude) % ------ % Inputs % ------ % templateWaveforms: nTemplates × nTimePoints × nChannels single matrix of % template waveforms for each template and channel % ------ % Outputs % ---...
18ab31d0640fc718f95319d28faed3e557e3dea778278e4f8e2f9f7f86cd9946
MATLAB
516
14
function varargout = Ent_Samp(varargin) %ENT_SAMP (deprecated) Use ent_samp instead. % Ent_Samp has been renamed to ent_samp. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Silence with: warning('off','Ent_Samp:deprecated') % % See...
736fabe35a90c2bd04033eb90a8fd6bbfda560e1296ccd88b7bc23dbd90b9771
MATLAB
516
21
function [U,labels, Z] = frid_edit(X,k,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',[],[],[],[],-ones(r,1),ones(r,1),[...
8461314d65a7a32c080c5f07e707b29847fc645ddb84104ae76a0e7496820356
MATLAB
516
14
function varargout = RQA_plot(varargin) %RQA_PLOT (deprecated) Use rqa_plot instead. % RQA_plot has been renamed to rqa_plot. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Silence with: warning('off','RQA_plot:deprecated') % % See...
9e58385189ba6ffbdfe78ef3b8fb3251e5147387e8bf890a2eb981024d3bde5f
MATLAB
516
17
% Local Regression and Likelihood, Figure 6.6. % Author: Catherine Loader % % Penny data, estimating jump size using left and % right smooths. % load penny; midp = (1945:1988)'+0.5; fitl = locfit(year,thickness,'style','l','alpha',[0 10],'ev',midp,'deg',1); fitr = locfit(year,thickness,'style','r','alpha',[0...
1420c94b79be558baf000b122845134364c549b05c36020ce4c95b9a14fae7b8
MATLAB
517
12
function hndl=my_errorbar(X,L,U,width,color,linewidth) %Make all sizes work X=shiftdim(X)'; L=shiftdim(L)'; U=shiftdim(U)'; nanarray=nan(1,length(X)); %Construct the lines of the errorbar by separating all components with %NaN points xcoords=[X ; X ; nanarray ; X-width/2 ; X+width/2 ; n...
811c19d890d4c28d8c52febea1e33a2738b10de77f401833ff3535239a5dd640
MATLAB
517
14
%% MetaTrajectory - Maker interface marking all sorts of classes represeting trajectories, and forcing them Copyable % including non-straight line trajectories % % Andreas Husch % Centre Hospitalier de Luxembourg, Dep. of Neurosurgery / % University of Luxembourg - Luxembourg Centre for Systems Biomedicine % 2017 % mai...
b9f2e69d51a2dae87540599902e7661f7871abaf256a1ba62f7b2028f8edd679
MATLAB
517
18
%% Example 1 to visualize topic model results % This example shows how to visualize topics in a 2D map. % % load a document-topic count matrix saved for the nips dataset load 'ldasingle_nips'; load 'words_nips'; %% % extract the topics in a cell array of strings [S]=WriteTopics( WP,BETA,WO,5,0.6 ); fprin...
c144995b863f5e13f10d34fab222fd7bfe5b5f114b87f0ea6c07d97f2d6afb46
MATLAB
517
19
%% Figure 4 main YOURDATAPATH = ''; % Load ROIs and PETHs data fileList = searchFilesRecursive(YOURDATAPATH, 'allROIs.mat'); load(fullfile(fileList.folder, fileList.name)) load('allenDorsalMap.mat'); % Using only cue-modulated henceforth allROIs = allROIs([allROIs.modCue] == 1); % Areas to plot areas = {'M2', 'M1', 'S...
e47d4da1268add07557c463da8d6e28ad99dab35a88356356f4e1892c29bad36
MATLAB
517
18
function [PatientID, patientPath] = ea_get_patient_folder(patientlist, pt_i) if isempty(patientlist) [selpath]=uigetdir(' ','Please Choose a Patient Folder'); if strcmp(string(selpath),'0') waitfor(msgbox('No Patient Folder was chosen!')); return; else pa...
2d8527941ff96dad061c5db147fcd2a48cbe2e6799441247a31fbd32c8473860
MATLAB
519
15
function [ lfpdown ] = bz_DownsampleLFP( lfp,downsamplefactor ) %[ lfpdown ] = bz_DownsampleLFP( lfp, downsamplefactor )takes a buzcode lfp %structure and returns a buzcode lfp structure downsampled by a factor of %downsamplefactor %% lfpdown = lfp; lfpdown.downsamplefactor = downsamplefactor; lfpdown.data = downsamp...
43e2a40be92a08282de095ab8102e254e461941a0fe1f2a06c00eec20f6c32b4
MATLAB
519
11
%% converts orientation angle from CT slice to roll angle of the lead according to yaw and pitch function roll = ea_diode_angle2roll(angle,yaw,pitch) roll = (sin(angle) * cos(pitch)) / ((cos(angle) * cos(yaw)) - (sin(angle) * sin(yaw) * sin(pitch))); % see Sitz et al. 2017 roll = atan(roll); ...
dc568b482a7a9be290498bb1e3f1931733e3fd498439bdccc6f4a67aebf533cf
MATLAB
519
13
function y = imag( x ) %Disciplined convex/geometric programming information for IMAG: % IMAG(X) may be freely applied to any CVX expression. Of course, % IMAG(X)=0 for all real expressions (including convex, concave, % log-convex, and log-concave), so it is primarily useful in the % complex affine case. y = ...
f27f632811f936632bf7030b5aeda1cf8df94f70ff3af96694e2524d1ba6ff20
MATLAB
519
21
% Local Regression and Likelihood, Figure 6.5. % Author: Catherine Loader % % Local smooth of CO2 dataset. % Use bivariate fit to capture the two trends. % % bonus plot: fitted values vs year. load co2; fit = locfit([month year+month/12],co2,'alpha',0.2,'style','an','scale',[6/pi,10]); figure('Name','fig6_...
fc03b8bdb157f264b0c2652d245e1c4c3aff9b70a4573690b9387bcb02da604e
MATLAB
519
14
function varargout = MDRQA021525(varargin) %MDRQA021525 (deprecated) Use mdrqa instead. % MDRQA021525 has been renamed to mdrqa. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Silence with: warning('off','MDRQA021525:deprecated') % %...
1e4f90841033ac717da65a250141285486d97c9df9b56fab51c0ab8603979e1a
MATLAB
520
32
function c = ch_cap ( c ) %*****************************************************************************80 % %% CH_CAP capitalizes a single character. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 23 April 2011 % % Author: % % John Burkardt % % Parameters: % % ...
e770ead7623346cb6ed2c7c76dbbeb028b5886461b600bf456595e3af2534d96
MATLAB
520
16
close, clear, clc % select directory that contain the raw ImageJ save files cd 'E:\Data Analysis\2P Imaging\2024 June Data processing\Mice3_ACC_vgatAi9'; files = dir('*.xlsx'); for i = 1:length(files) file_name = files(i).name; data = readcell(file_name); col = data(1,:); index = zeros(1,length(col)); ...
6d3aedc33e39aae2a61bb733d4dcb05f2121b4ec330b63470ea8083462c27daa
MATLAB
521
14
function varargout = linehist(varargin) %LINEHIST (deprecated) Use line_hist instead. % linehist has been renamed to line_hist. This shim forwards every argument and % output unchanged, so existing scripts keep working, and warns once per % session. % % Silence with: warning('off','linehist:deprecated') % % S...
9690516979e5ff13b60aac5ed3cb0d453ac3d3be19cb264c98f3d9b94b989c15
MATLAB
521
17
function Vols = CBIG_MMLDA_single_image_vol(gm_image) % Calculate the volume of single image. % Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md V = spm_vol(gm_image); Vols = zeros(numel(V),1); for j=1:numel(V) tot = 0; for i=1:V(j).dim(3) img...
9e0db19ffa4652254aec02ba65f97247ad8757bc38acc809de4b2893e37bfce8
MATLAB
521
18
function ea_dispercent(varargin) % __________________________________________________________________________________ % Copyright (C) 2014 Charite University Medicine Berlin, Movement Disorders Unit % Andreas Horn percent=varargin{1}*100; if nargin==2 if strcmp(varargin{2},'end') fprintf(1,[repmat('\b',1,...
b3cd2c8bd42f8b97e4de7ec34f4506f117776649c3991ed7fed62ea906a1de11
MATLAB
521
17
function angulo = angleBetweenLines(m1,m2,radDeg) %ANGLEBETWEENLINES returns the angle in degrees between the lines given %their slopes. % The function accepts only two arguments: the slope for each line and % returns the angle between them according to the following formula: % $\alpha = \atan{\f...
baf0dc7ee7c703cebcdb9272a0f84d964a4dbdd62c4e6ee2c2fb3d77a51caf5c
MATLAB
521
19
function raise_me (hObject, event, me) % Pulls the clicked object to the top of the ui stack; useful % for raising partially masked objects to the front of a plot. % GUI-shortcut for 'uistack': Left-clicking brings to the top, % right-clicking sends to bottom. myfig = gcf; oldptr = get(myfig, 'Pointer'); set(myfig, '...