sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
cb08b5e9c0422f17307d7b3ff20f330574b69910eb43292c5b1022ea2bcf9185
MATLAB
1,125
37
function S = FromParamsToSignal_RicianBiased(params, b, delta, smalldelta, sigma) % params are the SANDI estimated model parameters, specifically: % % params(:,1) = fenurite % params(:,2) = fsoma % params(:,3) = Din in um2/ms % params(:,4) = Rsoma in um % params(:,5) = De in um2/ms % % b: the b value, in ms/um2 % delt...
731a50be2aab53acfca0a04d2536f8f953c34f259ea5a5a2be8555dae5df8204
MATLAB
1,127
35
%CountInIntervals - Count samples that fall in each of a list of intervals. % % The equivalent Matlab code is trivial % % for i = 1:length(intervals), % j = find(values>=intervals(i,1)&values<=intervals(i,2)); % counts(i) = length(j); % end % % but becomes extremely slow when dealing with very...
9c0b92aa0e986312e061663d4bcd5e372e28788ea9a9751dae52eb8e21d64b94
MATLAB
1,127
37
function tree = flush(tree,uid) % XMLTREE/FLUSH Flush (Clear a subtree given its UID) % % tree - XMLTree object % uid - array of UID's of subtrees to be cleared % Default is root % % Clear a subtree given its UID (remove all the leaves of the tree) % The tree parameter must be in input AND in ou...
d7cc5834bf3c6ce0ea7d519d80fc7bf5ec550377e79c45fea79bfbc8df1b911f
MATLAB
1,127
43
function ftData = danalyzer2fieldtrip(psg) % Convert a danalyzer psg struct to a FieldTrip 'raw' structure. % Currently does not support conversion of electrode %% % Authors: Dan Denis % Date: 2023-12-12 %% % Electrode positions if ~isempty(psg.chans) ftData.elec.elecpos = zeros(length( psg.chans ), 3); f...
666d2b9e48142747ca8aa35cac0a83d49a23fbf41f18ae89efb117a7560ba2c5
MATLAB
1,128
26
function [f,findx]=getfgrid(Fs,nfft,fpass) % Helper function that gets the frequency grid associated with a given fft based computation % Called by spectral estimation routines to generate the frequency axes % Usage: [f,findx]=getfgrid(Fs,nfft,fpass) % Inputs: % Fs (sampling frequency associated with the d...
7a68fe631a43a80d58aeec4a5cc09c3ae334001b9c43f2d4008271c352a5c459
MATLAB
1,130
29
function [ephysProperties, unitClassif] = runAllEphysProperties(ephysPath, savePath, rerunEP, region) %% compute ephys properties ephysPropertiesExist = dir(fullfile(savePath, 'templates._bc_ephysProperties.parquet')); if isempty(ephysPropertiesExist) || rerunEP paramEP = bc.ep.ephysPropValues; [spikeTimes...
96bc88f8cb66927f54a3e2fa40a7f22a0466fde118666da83e2cc7116e436c5c
MATLAB
1,130
33
function [event] = PL2EventTsBySource(filename, source, channelInSource) % PL2EventTsBySource(filename, source, channelInSource): read event timestamps from a .pl2 file % % [event] = PL2EventTs(filename, source, channelInSource) % [event] = PL2EventTs(filename, "KBD', 1) % [event] = PL2Event...
0bbd2686534282aec4db00f415be9adbcf6f5ff55d98e901cb9732666e9bf002
MATLAB
1,132
39
% Section 7.1.1: Covariance estimation for Gaussian variables % Boyd & Vandenberghe "Convex Optimization" % Joëlle Skaf - 04/24/08 % % Suppose y \in\reals^n is a Gaussian random variable with zero mean and % covariance matrix R = \Expect(yy^T). We want to estimate the covariance % matrix R based on N independent s...
0c1826fecc9816f288001573150b4b8675e6fa18e92620dc1e0358bc643dd647
MATLAB
1,132
41
function [major,minor,patchnum,extra]=iso2meshver % % [major,minor,patchnum,extra]=iso2meshver % or % v=iso2meshver % % get the version number of iso2mesh toolbox % % author: Qianqian Fang, <q.fang at neu.edu> % % output: % if you ask for a single output: % v: a string denotes the current version number; t...
406f927e7b2e7ae96c4be7fdd886c4e423490f3dffec5fa7cb461f7b91e6e288
MATLAB
1,132
47
function [returnVar,msg] = RemoveDCfromDat_AllDat(varargin) % USAGE: % RemoveDCfromDat_AllDat(fbasename) % % removes DC offset in all channels from all dat files starting with % 'fbasename'. Assumes that there is at least one xml file associated to % one the dat file (must be created before with Neuroscope...
adcf19be4625f365c6653fc08ded183183d3574f05594bf989c272a2121e5157
MATLAB
1,132
27
function Z = CORE_histxy(c,r,cmax,rmax) %CORE_HISTXY Core computational routine for HISTXY. % Z = CORE_HISTXY(C,R,CMAX,RMAX) returns an RMAX x CMAX matrix Z such % that Z(i,j) = #[R(a)=i,C(b)=j]. % % CONDITIONS % ---------- % R and C must be column vectors of the same length. % R and C must only conta...
f108f5ea546a10f2d92135b3eb554f8ee3b8e4dec4951c623fa50850d155c74a
MATLAB
1,132
30
function [dip, p_value, xlow,xup]=hartigansdipsigniftest(xpdf,nboot) % function [dip,p_value,xlow,xup]=HartigansDipSignifTest(xpdf,nboot) % % calculates Hartigan's DIP statistic and its significance for the empirical p.d.f XPDF (vector of sample values) % This routine calls the matlab routine 'HartigansDipT...
f2a987295e7b4ff8df0d60c4f6ef1393d1b30ca253db787ed20aaeb1c485484c
MATLAB
1,132
40
function [Pr, prMax] = placeBayes(Cr, rateMap, binLength) %function out = placeBayes1(Cr, rateMap, binLength) % Inputs: % Cr = [nTemporalBin X nCell] matrix of binned firing rates % rateMap = [nSpatialBin X nCell] firing rate 'template' % binLength = scalar of the duration of the bins in 'Cr' % Outputs: % Pr = [nTempor...
006c800aaeca777703919ff8914376b5e215d849a0eccd6b07eb5ec970c6787f
MATLAB
1,133
29
function I = mat2cell_ov(X,xx_s,xx_f,yy_s,yy_f,zz_s,zz_f,overlap,sz) % converts a matrix into a cell array with overlapping elements % INPUTS: % X: Input matrix % grid_size: size of each element without overlap % overlap: amount of overlap % sz: spatial size of X % OUTPUT: % I: ...
0dfdadde167b22729f931aa6861f50ce62b27fc1d11066a7f7751f7d3bf706f8
MATLAB
1,134
37
% Minimal phase spectral factorization % % A PSD matrix is found which minimizes a weighted trace while obtaining % fixed sums along the diagonals. Notice the use of a FOR loop to access % the diagonals of X. A later version of CVX will eliminate the need for % this by allowing the use of the SPDIAGS function in side m...
7c05ffff9394cc3581b30aec35976dffaa8f86fe927a2a6b6e16470b849065fc
MATLAB
1,134
55
function [y,ff]=myfilter(x,ncu,dd) % Usage ... y=myfilter2(x,ncu_or_fco,ts) % or ... y=myfilter2(x,filt_fd) xft=fft2(x); if prod(double(size(ncu)==size(x)))==1, disp(' Simple filtering...'); ncu=fftshift(ncu); yft_m=abs(xft).*abs(ncu); yft_a=angle(xft)-angle(ncu); y=ifft2(yft_m.*exp(i*yft_a...
d04fc13eacd8b825511df73ccdf278b38913660828318897c479465ab1aa21b5
MATLAB
1,134
40
function [x,varargout] = ZeroToOne(x,varargin) %ZeroToOne - Normalize values in [0,1]. % % USAGE % % [y,b0,b1...] = ZeroToOne(x,a0,a1,...) % % x array to normalize (vector OR matrix) % a0... additional inputs to transform using the same % scale as x % Copyright (C) 20...
e913d24a177b41eaf7b088dd78e802594757d76945a7bfaf735c8e8a0cf2a527
MATLAB
1,134
42
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; %------- Which quantity? - Q % 2 for MEM, 3 for EF Q = 2; % Requirement for x-axis: auto, auto-center...
a4d6cd4ecf7cf3caf0da224be96c0a6b8cbe2636d51a1fea1279cb3c512e7406
MATLAB
1,135
30
function [dip, p_value, xlow,xup]=hartigansdipsigniftest_ss(xpdf,nboot) % function [dip,p_value,xlow,xup]=HartigansDipSignifTest(xpdf,nboot) % % calculates Hartigan's DIP statistic and its significance for the empirical p.d.f XPDF (vector of sample values) % This routine calls the matlab routine 'HartigansD...
bd7d22609e163e4e7f9111fe92c84225d4470d196b1a24f8cb8e91fa32654dfc
MATLAB
1,135
36
function [channelNumber] = plx_ad_resolve_chennel(filename, channel) % plx_ad_resolve_chennel(filename, channel): returns .plx file raw a/d channel number for the specified channel name % % [channelNumber] = plx_ad_resolve_chennel(filename, channel) % % INPUT: % filename - .plx file name % channel - 0-based ...
933bcc50abcc017b7b6fcddf4ee48085b32e442ab4160d4a7301a084ebfd1db7
MATLAB
1,136
49
function cvx_optval = det_rootn( X ) %DET_ROOTN Internal cvx version. narginchk(1,1); n = size( X, 1 ); if ndims( X ) > 2, %#ok error( 'N-D arrays are not supported.' ); elseif size( X, 2 ) ~= n, error( 'Matrix must be square.' ); elseif nnz( X ) <= n && nnz( diag( X ) ) == nnz( X ), ...
67e412b2806846a6cc785edb51715bcb0f5147cb8040839be16ff658cc4aac2d
MATLAB
1,137
39
function [cbar, clims] = smart_colorbar(clims, cmap_style) % SMART_COLORBAR - Generates a colorbar for mapping holes in data % % Finds the proper value for null data points to be plotted as white in an % IMAGESC plot, or similar. % % [CBAR,CLIMS] = SMART_COLORBAR(CLIMS, CMAP_STYLE) % % ARGUMENTS % * CLIMS: Th...
0e8c587ac0916b56d881a045581cb0ac32d7fcba577c7475162ad8ea6b846611
MATLAB
1,138
43
function dcor = distcorr(x,y) % This function calculates the distance correlation between x and y. % Reference: http://en.wikipedia.org/wiki/Distance_correlation % Date: 18 Jan, 2013 % Author: Shen Liu (shen.liu@hotmail.com.au) % Check if the sizes of the inputs match if size(x,1) ~= size(y,1); error('Inputs mus...
60ec60c563d5431cba68e7a29b0c09f64408b1a29cf6005de7beb1d70c0288c4
MATLAB
1,138
34
function LaBGAScore_clean_sourcedata(path_to_superdataset) % % cleans sourcedata subdataset depending on whether DICOMs are gitignored % or not % % see % % OPTIONAL INPUT % path_to_superdataset : absolute or relative path to superdataset % if not specified, present working directory is used % % AUTHOR % Lukas Van Oude...
9887665f034c0d537a1c91a8e43a458bdd96a2ed447eb923bff2d03d7434251f
MATLAB
1,138
44
function plotSlipTraces(i,data,typerange,figtitle,Ylimits,colorset) % This takes the dF/F calculated data from calc_dFF() and plots the mean % (bold) and the individual traces (thin dashed lines) for each trial type % in the dataset. figtitle should reflect the dataset you're plotting. % typerange is the range of...
469d13d95c442c24d0050a6af3887d894ddfb0c3031dfb8a76e4016484fa03f4
MATLAB
1,139
33
function copydata2target(PGout,ROIdirs,IMGdirs,namelist) for i = 1:length(namelist) [pth1 fil1 ext1] = fileparts(IMGdirs{i}); [pth2 fil2 ext2] = fileparts(ROIdirs{i}); Outdirs = [PGout,filesep,namelist{i},filesep]; mkdir(Outdirs); if strcmp(ext1,'.nii') copyfile(IMGdirs{i},[Outdirs,'image.ni...
91cfe845c553796c5f65cce86c079e931200116ae0fcd98fcc413ee7d8ce9dcf
MATLAB
1,139
41
function [mintime, maxtime]=minmaxsptimes(data) % Find the minimum and maximum of the spike times in each channel % Usage: [mintime, maxtime]=minmaxsptimes(data) % Input: % data (spike times as a structural array of multiple dimensions e.g. channels; channels x trials; % can also accept a 1d matrix of spike ti...
b86074fbf3d39e3e46b44733fbcabfa1c00edde58cdc0d1875d69f56abd7cf08
MATLAB
1,140
10
%Graphic interface builder functions (guifunc folder): % <a href="matlab:helpwin errordlg2">errordlg2</a> - Makes a popup dialog box with the specified message and (optional)... % <a href="matlab:helpwin finputcheck">finputcheck</a> - Check Matlab function {'key','value'} input argument pairs... %...
cdb6f8d697270108cd6901acb2814a4129dcbc7345320b75b700033dff159abe
MATLAB
1,140
49
function vol=thinbinvol(vol,layer,nobd) % % vol=thinbinvol(vol,layer,nobd) % % thinning a binary volume by a given pixel width % this is similar to bwmorph(vol,'thin',n) except % this does it in 3d and only run thinning for % non-zero elements (and hopefully faster) % % author: Qianqian Fang, <q.fang at neu.edu> % % ...
4644915345dc35afafbabdab165fbb22b8c4de5ff3bb3db5f071de91f0082ca8
MATLAB
1,141
47
function [vertices, edges] = line_pieces(vertices_all, piece_size, dashratio) % % See also u3d_pre_line, u3d_pre_contourgroup. % % File: line_pieces.m % Author: Ioannis Filippidis, jfilippidis@gmail.com % Date: 2012.06.10 - % Language: MATLAB R2012a % Purpose: generate vertices and edge arrays ...
d0237433df89293f8890e309b90b0a2c25898eb29484afcd39bdd50278e7a6e8
MATLAB
1,142
30
function [avgfluor,stdfluor]= avgROIs(fluordata) %I think the first frame should basically always be skipped? avgfluor={}; stdfluor={}; for k=1:15 %for each of the fifteen trial types fn=fieldnames(fluordata); [ROInum,triallength]=size(fluordata.(fn{1})); dirROIs=[]; for kk=1:ROInum% for ...
820995e4535fe811340d4b7a76370acc63ba0bf20ccf9dae210367a487d78b18
MATLAB
1,143
52
function [m,ssq] = issq(x,n,m0,ssq0) % Increment the mean and the sum of squares after a new % observation is included in the sample. % To obtain the variance, divide the ssq by n or by n-1. % % Usage: % [m,ssq] = issq(x,n,m0,ssq0) % % Inputs: % x = New observation % n = Observation sequential number (n > 1) % m0...
da77bc390c7fa90b616f10839f8e5f8a0e6cafbae85767d27025283f0cdd5917
MATLAB
1,143
37
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Merge multiple surfaces and remove self-intersection elements %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % generate a mesh for load rat_head.mat [node0,face0]=v2s(volimage,0.5,2); c0=mean(meshcentroid(node0...
dd2c2389a4b810dcb46cf33de591661ebdd27a8ffc337278e8edb5500e6fc975
MATLAB
1,143
33
function edges=meshedge(elem,varargin) % % edges=meshedge(elem,opt) % % return all edges in a surface or volumetric mesh % % author: Qianqian Fang, <q.fang at neu.edu> % date: 2011/02/26 % % input: % elem: element table of a mesh (support N-d space element) % opt: optional input, giving the additional options. I...
c61a90f99a2fe11957428af063af72747f1be69ee5af9a5e395d6bf38e371180
MATLAB
1,144
30
function I = palm_perm2idx(P) % Convert a permutation matrix into % a set of indices. % _____________________________________ % Anderson Winkler % FMRIB / University of Oxford % Feb/2012 % http://brainder.org % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % PALM -- Permutation Analysis of Li...
f8cef654ad99c9423de74d76ed4bfe9741927761edee49e7a4a68c4d9940bb47
MATLAB
1,144
27
function X = cell2mat_ov(I,xx_s,xx_f,yy_s,yy_f,zz_s,zz_f,overlap,sz) % converts a cell array to a matrix when the cell elements overlap % INPUTS: % I: cell array % grid_size: true size of each element % overlap: amount of overlap in each direction % d1: number of rows of matrix % d...
37c09768e41b25dc4e290a30ddbcb45e1e2a0db428756e6cc55cc436ce714d04
MATLAB
1,145
30
function [usevat,dimensionality,currentseed,sides]=ea_checkvatselection(handles) % small helper function that will check whether left, right or both vat % checkboxes are true. if (get(handles.rvatcheck,'Value') && strcmp(get(handles.rvatcheck,'Enable'),'on')) && ... (get(handles.lvatcheck,'Value') && strcmp(ge...
049a8fee2dad4421249b643191e3ef0fa3d88a5113b84ca8733b0ae92ef591f6
MATLAB
1,146
33
function worked = seek(vr,fnum) %WORKED=SEEK(VR,FNUM) % Attempts to go to frame number FNUM in video VR. Returns 0 if the user % attempts to seek past the end of the video. For most video plugins, the % first frame is 0 (not 1), thus in the following example, both IM1 and % IM2 should be the same for most plugins...
2462f4a6d91feea023179af6bd932c8ee6856d72f00a1fafc9a8cdbfd2b9dbdc
MATLAB
1,146
42
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; %------- Which quantity? - Q % 1 for MMSE, 2 for MEM, 3 for EF Q = 2; % Requirement for x-axis: auto,...
0df965803b19299c1d8549e4f6e67e124894cc16468721f983789df59587e77a
MATLAB
1,147
28
clc clear % Navigate to the target folder containing all .h5 files ds = imageDatastore(pwd, "IncludeSubfolders", true, 'FileExtensions', '.h5'); dsFiles = ds.Files; for di = 1:length(dsFiles) tarFile = dsFiles{di}; % Load h5 file info and data info = h5info(tarFile); data_PiezoMonitor = h5read(tarFil...
163fff474f2ef714564f2fabed6dcda6f06365f85d1210f327d8284595513a08
MATLAB
1,147
43
function [Efield] = ea_get_efield(perc,standard_efield,amp,conductivity,amp_mode,impedence) % inputs: % percentage on each contact % standard_efield: the standard efield is provided in the resources folder % of the fastfield % amp: stimulation amplitude % Electrode_type: the name of the stimulation electrode % conducti...
b24501616b04b2df8e889716b0835ca9ce908a79f361d954f050a43de566b8f8
MATLAB
1,147
21
function out = check_log_rec_v2(monkey,date,datadir,block_number,instances,hubs,stimbit,log_prefix) disp(['%%%%% Block: ',num2str(block_number)]); for instance_idx = instances for hub_idx = hubs instance_name = ['\Hub',num2str(hub_idx),'-instance',num2str(instance_idx),'_B',sprintf('%03.0f', block_num...
4ada56105e758edfaa863d969c4a785e876620644b67dbe6d55d8253501a6228
MATLAB
1,148
48
function peaks = fun_spectral_peaks(data, freqs, peakRange) % Peak detection in a power spectrum % Required inputs: % % data: A frequency x channel power spectrum (e.g. from the output of % fun_spectral_power) % % freqs: Array of spectral power frequencies (must match first dimension of % data % % peakRange: [min max]...
d5c62101977683dfea24589c59b8effadc1068b9db2fe46da11f51bac32ccafb
MATLAB
1,148
35
function result = attenuateBordersGBVS(data,borderSize) % attentuateBorders - linearly attentuates the border of data. % % result = attenuateBorders(data,borderSize) % linearly attenuates a border region of borderSize % on all sides of the 2d data array % This file is part of the SaliencyToolbox - Copyright (C) 20...
1070c69f63a8a06f761e7a6a3d7f075a057b287998a291490710cbb912252f52
MATLAB
1,149
36
function [w,rho] = max_deg(A) % Computes the maximum-degree heuristic edge weights % % [W,RHO] = MAX_DEG(A) gives a vector of maximum-degree edge weights for a % graph described by the incidence matrix A (NxM). N is the number of % nodes, and M is the number of edges. Each column of A has exactly one +1 % and one -1. ...
a1c46bf07e4e72400b129b9ddc5350b172ad0c305f6b37aff78d612ab872a114
MATLAB
1,149
37
% Plot a polar plot of an antenna array sensitivity % with lines denoting the target direction and beamwidth. % This is a helper function used in the broadband antenna examples. % % Inputs: % X: an array of abs(y(theta)) where y is the antenna array pattern % theta0: target direction % bw: total beamw...
8f3e41a8b1d969707895ea591247edc7ad4fb3edb87739e55d86ccc2ea48b5f3
MATLAB
1,150
54
function plotMetricPDFSubpops(allROIs, metricField, minmax, kdeBW) % Creates KDE plots for metric value distributions separated by subpops if nargin < 5 minmax = []; end if nargin < 6 kdeBW = []; end % Colormap cmap = cmapSubpops(); % Create figure fig; hA = gca; hold on; % Get data values = cat(1, allROIs...
83ea7a325041852c7a5f2f306deb7699d1513b4865ff359abbe4fea5da0d21f1
MATLAB
1,152
25
function cifti = cifti_struct_create_sdseries(data, varargin) %function cifti = cifti_struct_create_sdseries(data, ...) % Construct an sdseries cifti struct around the 2D data matrix. % % To control the contents of the scalar and series diminfo, use 'start', % 'step', 'unit', 'namelist', and '...
ae3405ed388e07b7939ae247669d4818f5020ae9e6526da1bd53550825dc1dc3
MATLAB
1,153
48
function writestreamstring3( WS , WO , ncharsperline , maxlines , fid , c , z , proba , focustopics , thr ); if (nargin<4) error( 'Not enough arguments' ); end L = []; N = length( WS ); NL = 0; for i=1:N if (WS( i ) == 0) L = [ L '. ' ]; spanst = 'normal'; word = ...
d33f3b1521e367a4cb955d090ec5be5950bbc7d5a4fd6afc1061c9aa7cc4ef12
MATLAB
1,153
42
% Exercise 4.47: Maximum determinant PSD matrix completion % Boyd & Vandenberghe "Convex Optimization" % Almir Mutapcic - Jan 2006 % % Given a symmetric matrix A in R^(n-by-n) with some entries unspecified % we find its completion such that A is positive semidefinite and % it has a maximum determinant out of all possib...
d7ad8750183666a4e994fc10af88cbb40027b0cf654c50909e7f4384f4bac7c1
MATLAB
1,153
25
rr1a_percentmeansC=[]; rr1a_percentmeans=[]; rr1a_percentmeansSM=[]; rr1a_percentsemC=[]; rr1a_percentsem=[]; rr1a_percentsemSM=[]; figure; bar([nanmean(rr1a_percentmeansC) nanmean(rr1a_percentmeans) nanmean(rr1a_percentmeansSM)]) hold on errorbar([nanmean(rr1a_percentmeansC) nanmean(rr1a_percentmeans) nanmean(rr1a_p...
33f071567f8a3bee1892a212a177476801c6697a1af1a2740bda9da49c392d73
MATLAB
1,154
35
function [aL aR] = alignDataSines(allflies,types,frame) % first, load 'allflies' data, e.g. 'SS52244_exp1_5_n7.mat' for type = types L = []; R = []; B = allflies([allflies.trtype]==type); for tr = 1:length(B) % Ldata = B(tr).dFFfluor(3:10,frame); % Rdata = B(tr).dFFfluor(11:18,fra...
6518a0bb9fefce4213b508b81ce88c79fe016ac6672dd9ba7d2f07f3c5145cd8
MATLAB
1,154
40
%islmatrix - Test if parameter is a logical matrix (>= 2 columns). % % USAGE % % test = islmatrix(x) % % x parameter to test % % NOTE % % To be considered logical, the matrix should contain only values 0 and 1, but it % does not need to actually be of class 'logical' (class(x) could be e.g. '...
a241a545f67e00fb7af2a8829bb5ecb6d87df65f0dfa06f30d098bae59982efa
MATLAB
1,154
47
function [mu, sigma] = medianIQR_to_meanSD(medianVal, IQR, n) % medianIQR_to_meanSD % % Approximate mean and standard deviation from median and IQR. % % INPUTS % medianVal : median % IQR : interquartile range (Q3 - Q1) % n : sample size (optional but recommended) % % OUTPUTS % mu : estimate...
0b2efbbfb1c74680c43d8e69b89d6c1e82c876c9e743e5625527d58b47ff4fda
MATLAB
1,155
40
% Euclidean projection on a rectangle % Section 8.1.1, Boyd & Vandenberghe "Convex Optimization" % Joelle Skaf - 10/07/05 % % The projection of x0 on a rectangle C = {x | l <= x <= u} is given by % minimize || x - x0 ||^2 % s.t. l <= x <= u % It is also given by P_C(x0)_k = l_k if x0_k...
30401303ec773ff6ba42b722c9d7f951438d2e1fd52e24c6a8bed70a3386bb17
MATLAB
1,155
27
function GCO_SetVerbosity(Handle,Level) % GCO_SetVerbosity Print status messages during Expansion/Swap. % Level 0 prints no output (full speed). % Level 1 prints cycle-level status messages. % Level 2 prints expansion/swap-level status messages. % The current energy is printed as % E=Total (E=Dat...
d58845981439b1623bbea9715c5330f72179c3a266fcff914aa547a4a5512632
MATLAB
1,155
38
function channels = GetChannels(groups) %GetChannels - Get list of channels for one or more spike groups. % % USAGE % % channels = GetChannels(groups) % % group one or more optional electrode groups (default = all groups) % % EXAMPLES % % all = GetChannels; % list all channels % channe...
eec050164af9066847a49f2345d5512c0ddc76c9df271afd7caea264061238d0
MATLAB
1,155
46
function hdi = calc_HDI(samples, q) % function hdi = calc_HDI(samples, q) % % Calculates highest-density interval on chain of MCMC samples % See Kruschke (2015) Doing Bayesian Data Analysis % % INPUTS % % samples - vector of MCMC samples % q - credible mass, scalar between 0 and 1, default is 0.95 % for 95% HDI % % Bas...
0446add7a26f59442cae899e46e1dabb95f4f9296ff8eb5dc6788b3bd31393de
MATLAB
1,156
40
function watsonsu2 = HDWatsonsU2(self, cel) % Returns U2 head tuning score for current cell % % watsonsu2: Watson's U^2 test for uniformity in circular data. See % redish, % hippocampus 2005 to learn how it applies to head direction cells % see % http://www.ncbi.nlm.nih.gov/pmc/articles/mid/NIHMS71281/table/T2/ % for ...
183c083f47925c736cf463b7c87c5ba0a7a45da8ed3419cb7313efc028fcb70d
MATLAB
1,156
35
function data=createdatamatpt(data,E,win) % Helper function to create an event triggered matrix from a single % channel of spike times. % Usage: data=createdatamatpt(data,E,win) % Inputs: % data (input spike times as a structural array or as a column vector) - required % E (events to use as triggers) - r...
ec4626a844da8f5f68bc12b921ddd699b0ff3fe6e32365896ce356be484d8ac8
MATLAB
1,156
37
function [newnode,newelem]=highordertet(node,elem,order) % % [newnode,newelem]=highordertet(node,elem) % % generate high-order straight-edge tetrahedral mesh from % the 1st order tetrahedral mesh % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % node: list of nodes % elem: list of elements (each row are...
8827bc755bb021be263407915b73cf616637f28f4a4f02fb739480c38323df11
MATLAB
1,157
18
function cifti_write_sdseries(data, filename, varargin) %function cifti_write_sdseries(data, filename, ...) % Write a new sdseries cifti file from a 2D data matrix. % % The cifti extension on the filename should always be '.sdseries.nii'. % % To control the contents of the scalar and serie...
2bb5048dfb7006ae341587bfe6e3a58aa1e0acc2a04fffec13844d6dbef6cff1
MATLAB
1,158
41
function smoothedVals = irregularGaussianSmooth(X, vals, sd) % smoothedVals = irregularGaussianSmooth(X, vals, sd) % % Apply Gaussian smoothing to an irregularly sampled set of points. Point % coordinates X should be nPts x nSpatialDimensions. vals should be % nPts x nValueDimensions. sd is the standard deviation of ...
23ef35282ba69a83752e9386841826a68694330b6ab46e9bcce7d0d792e01e8f
MATLAB
1,159
30
% Plot the spent time time_table = readmatrix('TimeCount0.xlsx','Sheet',3); % time_table = time_table/ans; feature_number = 10:10:100; figure plot(feature_number,time_table(1,:)*100,'LineWidth',1.5,'Color','k','LineStyle','-','Marker','s') hold on plot(feature_number,time_table(2,:)*100,'LineWidth',1.5,'Color','k','Lin...
d9f1bbaff3b2535b3f55ba0f34b6ff7d42ba6020662be562ff958ec244959962
MATLAB
1,159
39
% fastif() - fast if function. % % Usage: % >> res = fastif(test, s1, s2); % % Input: % test - logical test with result 0 or 1 % s1 - result if 1 % s2 - result if 0 % % Output: % res - s1 or s2 depending on the value of the test % % Author: Arnaud Delorme, CNL / Salk Institute, 2001 % Copyright (...
2c07cc66eb3f5abd5567369b68bb0d28a0d8245f3245772fdc7f93b94cc23a50
MATLAB
1,160
31
function azimuth = itd2azimuth(itd,f) %ITD2AZIMUTH Convert ITD to azimuth % % AZIMUTH = IOSR.AUDITORY.ITD2AZIMUTH(ITD,F) converts the interaural time % difference ITD (in seconds) at frequency F (in Hz) to AZIMUTH (in % degrees) according to Kuhn's model [1]. % % References % % [1] Kuhn, G.F. (1977), Model ...
538d5235d5ff5695da271c82460785de6b172dc9bbc388fa1c50a54148a978e8
MATLAB
1,160
38
function [channelNumber] = plx_event_resolve_channel(filename, channel) % plx_event_resolve_channel(filename, channel): returns .plx file event channel number for the specified channel name % % [channelNumber] = plx_event_resolve_channel(filename, channel) % % INPUT: % filename - if empty string, will use File ...
d693d82ce46883f19525b6833bce3de5a4ca82c30ec65d396318a2da5955115a
MATLAB
1,160
28
function [wave] = PL2Waves(filename, channel, unit) % PL2Waves( filename, channel, unit ): read spike timestamps and waveforms from a .pl2 file % returns waveform values in millivolts % % wave = PL2Waves( filename, channel, unit ) % wave = PL2Waves( filename, 'SPK01', 1 ); % wave = PL2Waves( filena...
f2609dfe19c27b03672d4f2b6cd599ef2d25f26c13c21f0a3c1c11f650a06cc6
MATLAB
1,160
33
function ea_checkDocker(image) % Function to check docker installation [and docker image]. % If docker is installed, the specified image will be pulled. arguments image {mustBeTextScalar} = '' end % First check docker installation dockerPath = ea_findBinPath('docker'); if isempty(dockerPath) if ismac ...
093666a9005f8eccd236011c24b3bef768468bb615c31cc39552ccf9ffca3e6d
MATLAB
1,161
26
% display() - display an EEG data class underlying structure % % Author: Arnaud Delorme, SCCN, INC, UCSD, Nov. 2008 % Copyright (C) 2008 Arnaud Delorme, SCCN, INC, UCSD % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the ...
cd47e62d906ef95f1dae02090baedccaf0aabbc7cf538ec4647c808d4a063247
MATLAB
1,161
47
function mask=flatsegment(node,edge) % % mask=flatsegment(node,edge) % % decompose edge loops into flat segments alone arbitrary planes of the bounding box % % author: Qianqian Fang, <q.fang at neu.edu> % date: 2008/04/08 % % this code is fragile: it can not handle curves with many co-linear % nodes near the corner poi...
f9c00fa5cbe9d8b6058696c00757b42ae0d7335e8ba99829df93da166ed69e9d
MATLAB
1,161
41
function SurfStatWriteData( filename, data, ab ) %Writes data (e.g. thickness) to a single .txt or FreeSurfer file. % % Usage: SurfStatWriteData( filename, data [, ab] ); % % filename = .txt or FS file name, either new version binary or ASCII. % ab = 'a' for ASCII or 'b' for binary. % % data = k x v matrix of...
53d5063b828ab325a36834e9543c08f204856f5b8edfb10bcedeb03a5a016a99
MATLAB
1,162
46
function [f maxsize]=maxsurf(facecell,node) % % [f maxsize]=maxsurf(facecell,node) % % return the surface with the maximum element number or % total area from a cell arry of surfaces % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % facecell: a cell array, each element is a face array % node: optional...
18180476ac568e6a42997c912ca31d1deba0c3e79705da482ba5dfdd0a7649da
MATLAB
1,163
40
function varargout = DefaultArgs_ss(Args, DefArgs) % auxillary function to replace argument check in the beginning and def. args assigment % sets the absent or empty values of the Args (cell array, usually varargin) % to their default values from the cell array DefArgs. % Output should contain the actuall names of arg...
44e1820fa804f1bdb463640f77dabaf26f53b2b191dddd4277707f00a5213a90
MATLAB
1,163
26
function phi = rad2deg(phi) %RAD2DEG returns the given angle in degree % phi = rad2deg(phi) converts the angle phi given in radians to degree % % Input options: % phi - angle, can be a scalar or matrix (rad) % % Output options: % phi - angle (degree) % % See also: deg2rad % SOFA...
bc899855ba4ffa173ca5b960de7c125e98e4ebe7dc087b1d4224d5e3f7b01251
MATLAB
1,163
56
function element_node = gmsh_mesh2d_element_data_example ( element_num, ... element_order ) %*****************************************************************************80 % %% GMSH_MESH2D_ELEMENT_DATA_EXAMPLE returns element information for the example. % % Licensing: % % This code is distributed under the GNU...
e3c208fcbad9c151c80cc09af94460715f4d1df753ccc2099fdbe8c6b9cfa6bd
MATLAB
1,163
49
function [ ind, thres ] = FDR(p_list, alpha) % This code has been modified from the original version written by % Edden Gerber, lab of Leon Y. Deouell, 2012. This code computes the % False Discovery Rate according to Benjamini and Hochberg (1995). % % Inputs: % - p_list % A vector. This should be the co...
d21c33c672d7c536af1c518086bd3e0954b2fd61858d2f8a5d763a8d045aa47c
MATLAB
1,164
26
function phi = deg2rad(phi) %DEG2RAD returns the given angle in radians % phi = deg2rad(phi) converts the angle phi given in degree to radians % % Input options: % phi - angle, can be a scalar or matrix (degree) % % Output options: % phi - angle (rad) % % See also: RAD2DEG % SOF...
edc04ac0381772fd50af249941cc0fed13b0053b8a55f25e831fcbd1a3fa1e94
MATLAB
1,165
50
function [rho pval] = circ_corrcl(alpha, x) % % [rho pval ts] = circ_corrcc(alpha, x) % Correlation coefficient between one circular and one linear random % variable. % % Input: % alpha sample of angles in radians % x sample of linear random variable % % Output: % rho correlat...
964eb8d7219af28e2dc67549ef51d25ffaee125c234d3d67c6a88226bf693ac5
MATLAB
1,166
49
function y = nansem(x,dim) % FORMAT: Y = NANSEM(X,DIM) % % Standard error of the mean ignoring NaNs % % NANSTD(X,DIM) calculates the standard error of the mean along any % dimension of the N-D array X ignoring NaNs. % % If DIM is omitted NANSTD calculates the standard deviation along first % non-singl...
1ac78aa85a64042e56663b32dddfbfccc734534c43e799cf0853d57f3e0e14a3
MATLAB
1,167
26
function results = SOFAgetVersion(flag) %SOFAGETVERSION % version = SOFAgetVersion() returns the version of the SOFA API % version = SOFAgetVersion('API') does the same. % % version = SOFAgetVersion('SOFA') returns the version of the SOFA % supported by this API. % SOFA API - function SOFAgetVersion % ...
8436f58eddc3a37e93c2124dc7f2b82f37fd09e15a087076663121e517c99a0b
MATLAB
1,167
42
function sleepstagesOUT = yasa2danalyzer(sleepstagesIN) % Convert a YASA score file to a danalyzer score file. %% % Authors: Dan Denis % Date: 2021-12-15 %% sleepstagesOUT.stages = zeros(height(sleepstagesIN), 1); for i = 1:height(sleepstagesIN) if strcmpi(sleepstagesIN.Stage(i), 'W') sleepstage...
e444549a8828bf0ff266fa4385f089f7c063eef52ffb893952777f99abaec755
MATLAB
1,167
40
function [ y, x ] = cvx_check_dimlist( x, emptyok ) % CVX_CHECK_DIMLIST Verifies the input is a valid dimension list. % Copyright 2005-2016 CVX Research, Inc. % See the file LICENSE.txt for full copyright information. % The command 'cvx_where' will show where this file is located. if nargin < 2 || emptyok, xmin ...
e974c3772b480643a2df44ad52a21116b0d14e67a16fabedd4c711eab5717d2d
MATLAB
1,167
40
function [ sims , index , csims ] = AssociationTFIDF( WD , Q ) NW = size( WD , 1 ); % number of words ND = size( WD , 2 ); % number of docs NQ = length( Q ); % number of queries %--------------------------------- % Calculate TF-IDF weight % -------------------------------- df = full( sum( WD>0 , 1 )); idf ...
e583489cc07a24bb3fc7f4ac3c5e1913f2b819bbb30464a7a1cbbf77f62bb9cf
MATLAB
1,168
52
function mpgMean = apply_MLP_matlab(signal, trainedML, MLdebias) % Apply pretrained Multi Layer Perceptron regressor % % Author: % Dr. Marco Palombo % Cardiff University Brain Research Imaging Centre (CUBRIC) % Cardiff University, UK % 8th December 2021 % Email: palombom@cardiff.ac.uk method = 0; Mdl = trainedML.Mdl...
0327f1f6ea63cc57e0ed73969bf98376e160f7cef7496007af93d96b51ac1029
MATLAB
1,169
31
% ndims() - number of dimension of memory mapped underlying array % % Author: Arnaud Delorme, SCCN, INC, UCSD, Nov. 2008 % Copyright (C) 2008 Arnaud Delorme, SCCN, INC, UCSD % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by %...
0973b68b5021283bbaa03c93b85a0b332732e22f555ae287cfe33ed3202e668f
MATLAB
1,169
28
function y = pow_p( x, p ) %POW_P Positive branch of the power function. % POW_P(X,P) computes a convex or concave branch of the power function: % P < 0: POW_P(X,P) = X.^P if X > 0, +Inf otherwise % 0 <= P < 1: POW_P(X,P) = X.^P if X >= 0, -Inf otherwise % 1 <= P : POW_P(X,P) = X.^P if X >=...
636c45cc74b5480a919efa351536939b9b2f7ada91416a19b6aa02a38ae9d3ec
MATLAB
1,169
53
function T = vox2ras_tkreg(voldim, voxres) % T = vox2ras_tkreg(voldim, voxres) % voldim = [ncols nrows nslices ...] % volres = [colres rowres sliceres ...] % % Computes the 0-based vox2ras transform of a volume % compatible with the registration matrix produced % by tkregister. May work with MINC xfm. % % % vox...
90873bd0644ad2d2b68279df8924db855a4f36e6bcba7eae175af0bb0b20a63e
MATLAB
1,169
16
% eeg_options() - eeglab option script % % Note: DO NOT EDIT, instead use pop_editoptions() or the menu % /File/Maximize memory in EEGLAB gui % STUDY options (set these checkboxes if you intend to work with studies) option_storedisk = 0 ; % If set, keep at most one dataset in memory. This allows processing hund...
3f320c0a69a959b8834ecc4efb37fefeb65fb2eff445258057e8e14066ba2e2c
MATLAB
1,170
31
fig = figure('name', 'symbol_heatmap', 'numbertitle', 'off'); set(gcf, 'visible', 'on', 'unit', 'centimeters', 'PaperUnits', 'centimeters', 'position', [0 0 20 20], 'color', 'w', 'PaperSize', [20, 15]); for f = 3:3 row = ceil(f / 3); col = mod(f - 1, 3) + 1; x_offset = left_margin + (col - 1) * (pl...
4f87a01c01af32d371c395fef8bf01c5e4961aba26b245eaeaedcaeaf24565d7
MATLAB
1,170
42
function vatfv = ea_niiVAT2fvVAT(nii, smooth, smoothingfactor) if ischar(nii) && isfile(nii) nii = ea_load_nii(nii); end start = nii.mat * [1;1;1;1]; niisize = size(nii.img); stop = nii.mat * [niisize,1]'; gv = cell(1,3); for dim=1:3 gv{dim}=linspace(start(dim),stop(dim),niisize(dim)); end [xg,yg,zg] = meshgr...
495029ee15ab88d4fee934609eb7785ba3da089c6258486b915b271424d597f4
MATLAB
1,171
46
% Local Regression and Likelihood, Figure 4.3. % Author: Catherine Loader % % Residual plots for local likelihood. % Henderson-Shepherd Mortality Data. load morths; fit = locfit(age,deaths,'weights',n,'family','binomial','alpha',0.5); figure('Name','fig4_3a: Residual plots for local likelihood'); plot(age,r...
30d8ddaa368cc7c046f86ee750544195c9816ce6db940d037b5881b4f8e6fa27
MATLAB
1,173
38
function [no,el]=removeisolatednode(node,elem) % % [no,el]=removeisolatednode(node,elem) % % remove isolated nodes: nodes that are not included in any element % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % node: list of node coordinates % elem: list of elements of the mesh, can be a regular array o...
aff2d20f94667df0d19b0965e0ca1e87a4e9939dbecfe99ebbff905e75c09e92
MATLAB
1,173
43
function niiFiles = ea_dcm_to_nii(dicom_dir, output_dir, tool) % Simple wrapper that calls appropriate function to convert DICOM to NIfTI % tool can be name of the tool or 1 - 4 % (1 - dcm2nii, 2 - dicm2nii, 3 - SPM, 4 - GDCM via Slicer) if ~exist('output_dir', 'var') || isempty(output_dir) output_dir = fullfile(d...
bde7299335b6d6333a2a8e52303fb8ba26f556301fe9c2e8ecb716871bf17aa8
MATLAB
1,174
31
function D=createDistanceMatrix(M,N) % createDistanceMatrix calculates the distance matrix for two sets of points % % SYNOPSIS D=createDistanceMatrix(M,N) % % INPUT M and N are the matrices containing the set of point coordinates. % M and N can represent point positions in 1, 2 and 3D, as follows...
c6426016ad40282b8d255a61e0885f6482dc22b1a08a92880598255ce48c509e
MATLAB
1,175
39
function [x,V]=apply_kalman2D(ph,Q,R) % addpath(genpath([pwd '\KalmanAll'])); % X(t+1) = F X(t) + noise(Q) % Y(t) = H X(t) + noise(R) % ph=sin(1:.1:100)+.5*(rand(1,991)-.5); ss = 6; % state size os = 2; % observation size F = [1 1 .5 0 0 0; 0 1 1 0 0 0; 0 0 1 0 0 0; 0 0 0 1 1 .5; 0 0 0 0 1 1; ...
def230112f00ec1c783ecf10edeeebb6c44bd7d1d3094a3fdb631b977e816c45
MATLAB
1,176
39
% Equality constrained norm minimization. % % This script constructs a random equality-constrained norm minimization % problem and solves it using CVX. You can also change p to +2 or +Inf % to produce different results. Alternatively, you an replace % norm( A * x - b, p ) % with % norm_largest( A * x - b, 'larg...
34a6159197304aca328cb0fc711309251b6848a27c674c98de815d9220ef8801
MATLAB
1,177
29
function sanity_check_cdata(cifti) % %this calls cifti_diminfo_length, but that seems to work even without being on path if ~isfield(cifti, 'cdata') error('cifti structure is missing cdata field'); end if ~isfield(cifti, 'diminfo') error('cifti structure is missing diminfo field...
a743872d19be41fa8592e09a711a2949ad1bc32483d332cebc5b72b3baeda3d6
MATLAB
1,177
32
function [c,t] = quickfftxcorr(sptrain,stim,samprate,tstart,tend) % [c,t] = quickfftSTavg(sptrain,stim,samprate,tstart,tend) % calculate cross-correlation between two signals by multiplying in the Fourier Domain % returns a segment c around the spike times between tstart and tend (in sec) % tstart should be a negative ...
8f36963d7fedcfa27d0398c0ce42f640ad3bff3e938771a0af1b1a9214a35012
MATLAB
1,178
36
% At startup, matlab will find a file startup.m assumed to be located in directory specified by % the environmental variable MATLABPATH (see http://www.mathworks.com/help/matlab/ref/startup.html). % if (~isdeployed) if (~isempty(getenv('CBIG_CODE_DIR'))) % add all paths in CBIG_CODE_DIR subdirectories ...