sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
622f9c91e40568cdaaed6c16fcb1a4ff73e1709ee4d5ebc9d44c08e7bed21895
MATLAB
986
16
% output = transres_primal_SVM_weights(decoding_out, chancelevel, cfg, varargin) % % Calculates the weights in source space (primal problem), if a linear SVM % was used (otherwise no weights can be calculated for the primal problem). % Use this function if you want to plot results or do other calculations % that requ...
1d2868602a4a11f0187c422f1c3748ebc7bad7318f55ab129a3c27d5eb3e6de2
MATLAB
989
34
function E = E_diff(E,diff,kmax,N) % E = E_diff(E,diff,kmax,N) % % Function to build E operator with diffusion effects for standard EPG % 3 states per k-value). % % E = relaxation matrix (diag(E2 E2 E1)) % diff = structure with fields: % G - Gradient amplitude(s) % ...
0d9816e6de13fa8df9eea39e081554dc1a6bd8054a244b52d50f6f59b4d3c113
MATLAB
990
32
function [x, y] = MakeRoseplotData(xInt, yVec, int, distOption) if distOption == 1 %% Plot Roseplots from 0 to 90 x = xInt:xInt:(90 - xInt); x = [x', x', x']'; x = [0; 0; x(:); 90; 90]*pi/180; angList = xInt/2:xInt:(360 - xInt/2); angList = [angList; angList]; angList = angList(:)*pi/180; ...
f7b936866050c43ab339432d8054518e0e06700dff613026338a40acf2e701b2
MATLAB
990
39
function [X] = idwt1(approx, detail, g_i, h_i, len) % Performs a 1-dimensional single inverse discrete wavelet transform. % % [X] = idwt1(approx, detail, g_i, h_i, len) % License: %===================================================================== % % This is part of the Princeton MVPA toolbox, released under % the...
513b45b703d01d9cd28a8c43324f3a0e3b644391c939f925694ecbe3a270272d
MATLAB
991
33
function [dat,clabel, chans] = load_example_data(filename, do_zscore) % Loads an example dataset. % % filename - epoched1.mat, epoched2.mat, epoched3.mat % % Output: % dat - struct containing the data % clabel - class labels % chans - struct specifying the positions of the channels for plotting if narg...
c0532a99536696288cde3ae9041e6d97a5cb79482e637df25f19e83ddc303cf1
MATLAB
991
30
function [cc,pv] = phase_correlation_distance( pl, source, spacing ) % *WAVE* % % PHASE CORRELATION DISTANCE correlation of phase with distance % (circular-linear), given an input % phase map % % INPUT % pl - phase map (r,c) % source - source point...
cf23a1ee2adcf1240319198be32803d2911ee6f3c85762df8b04867569ecae97
MATLAB
991
37
function dat=kalmanfilter(t,inp); % Here's the matlab code - hope it makes sense - we run this on the encoder % values and I have lost th epape which say why we choose Q this way % Best wishes % Daniel % t is the time stamp of the input; % inp is the one dimensional input % Kalman filter settings w=30; % sd in acce...
215e8a2627370f8dd7f9fa2f2786e7c3a2dd5c702d4ae8cff513f73a0c6e8abf
MATLAB
992
57
function [eta,B] = ETAngAverage(t1,t2,data,binsize,nbins) nt1 = length(t1); nt2 = length(t2); % we want nbins to be odd */ if floor(nbins / 2)*2 == nbins nbins = nbins+1; end m = - binsize * (nbins / 2); B = zeros(nbins,1); for j = 1:nbins B(j) = m + j * binsize; end binsize = binsize*10; % cro...
bc7ba1d0f697d6d1eeb9da7614caa252ecbe09296adb1a981019410485940d46
MATLAB
992
42
function diff = derivativeCheck(funObj,x,order,type,varargin) % diff = derivativeCheck(funObj,x,order,useComplex,varargin) % % type = 1 (simple forward-difference) % type = 2 (central differencing - default) % type = 3 (complex-step deriative) if nargin < 3 order = 1; % Only check gradient by default if nargin < 4 ...
c92349eb227dd709dba6fbe6725767078cebddb7a6523e0d678bd9b45465a902
MATLAB
992
26
function [y, extra, invhess] = mlpevfwd(net, x, t, x_test, invhess) %MLPEVFWD Forward propagation with evidence for MLP % % Description % Y = MLPEVFWD(NET, X, T, X_TEST) takes a network data structure NET % together with the input X and target T training data and input test % data X_TEST. It returns the normal forward...
7136ede88b9dba2fadd358c908908e7278c62985331d743143192c959ee272ac
MATLAB
993
27
function stackConfig = scDeleteIterationsFromStackConfig(stackConfig, iterationsToDelete) % This function deletes iterations from stack config. enter which % iterations you would like to delete %% Input Checks if (length(iterationsToDelete) > 1) error('Cannot delete more than one iteration at a time'); end ...
7d69fc1b3249ce23c2fd63c75d1cb3f709e20af87cfa21ca59713a03b611256e
MATLAB
993
30
function MakeSpikeWidth(varargin) % MakeSpikeWidth - computes and saves cell waveform features : half peak width and peak to peak % both of them in ms. % % USAGE % % MakeSpikeWidth(fbasename) % % fbasename (optional) file base name (default: folder's name) % % Copyright (C) 20012-2018 by Adrien Peyrache % % ...
571c75439535594d4386c3e6f360c0d00680ee8e729432aeb248996179194a62
MATLAB
994
28
function [y, extra, invhess] = glmevfwd(net, x, t, x_test, invhess) %GLMEVFWD Forward propagation with evidence for GLM % % Description % Y = GLMEVFWD(NET, X, T, X_TEST) takes a network data structure NET % together with the input X and target T training data and input test % data X_TEST. It returns the normal forward...
cd152b7bfc82eb6e666dc6cee3018b23be043f9b9102b17c2223f1fa7cc14880
MATLAB
994
33
% X = vspharm(theta,phi,l,m) % % Vector spherical harmonic funtion (Arfken, p. 708) for quantum % numbers l and m. Angles theta and phi should be given in radians. % First component of X is the e_theta component and the second % component is the e_phi component. % function X = vspharm(theta,phi,l,m) scale = -1/sqrt(l*...
fa0ff8f2dd1881e9736550c22c1ee6941e98e949525d9eccc42c089b74d765fa
MATLAB
995
22
function smoothedTracks = SmoothTracks(tracks, numNearestNeighbors) idxArray = unique(tracks(:, 4)); smoothedTracks = zeros(size(tracks)); for i = 1:length(idxArray) idx = idxArray(i); currIdx = tracks(:, 4) == idx; currTrack = tracks(currIdx, 1:3); newTrack_x = []; newTrack_y = []; for j = 0:n...
04c062008423bdef002014e1d6dfad4cc11d9c22af15141466ca05e614d44dc5
MATLAB
996
26
function msBatchSelectFluorThresh(dirName) %MSBATCHSELECTFLUORTHRESH Summary of this function goes here % Detailed explanation goes here dataFolders = msBatchFindDataFolders(dirName,[]); for folderNum = 1:length(dataFolders) currentFolder = dataFolders{folderNum}; dirData = dir(currentFold...
a021da72a56bc3578b3bfede2713cd851f3e9e890faecd7768d07860ff1b1e89
MATLAB
996
30
function net = rbfsetfw(net, scale) %RBFSETFW Set basis function widths of RBF. % % Description % NET = RBFSETFW(NET, SCALE) sets the widths of the basis functions of % the RBF network NET. If Gaussian basis functions are used, then the % variances are set to the largest squared distance between centres if % SCALE is n...
c9c13b89668bfa48fdc566473bdcbca28902053b6566e0b15dcda340eb5838cd
MATLAB
997
39
function X = fast_pca(in_X, K) in_X = in_X - repmat(mean(in_X),size(in_X,1),1); [U, S, ~] = rsvd(in_X, K); K = min(size(S,2),K); X = U(:,1:K)*diag(sqrt(diag(S(1:K,1:K)))); X = X./repmat(sqrt(sum(X.*X,2)),1,K); end function [U,S,V] = rsvd(A,K) %--------------------------------------------------------------------------...
20a29b98e5b71f50f75d204a4cf266a5b8e961df79dff8ba374dba5050e9657c
MATLAB
999
26
%function [EegSegAv EegSegStd EegSTrange] = TriggeredAvM(data,T,chanIx,win,sr,nChannels,SignalType) % trigered averages subset of channels from file or matrix % within a window of win (in msec) % method : 1, to load all channels for each segment around trigger (if nChannels/nTriggers is large) % 2, to loa...
53ed4dd39b565f993e5c5ec852074a6d2657bce3574620e67cb6ba12564eb14f
MATLAB
999
40
function [Ehat, Phat] = getModelJR(K_or_F, I, head, target, light, sines) % function [Ehat, Phat] = getModelJR(K_or_F, I, head, target, light, sines) % % Get model predictions % Make sure its ok to use impulse response version of simulation if any(light) I.impulse_or_closedloop = 0; % Use closed loop version end...
5b7d1b1e6893a2552f2f063e73a4faf4b8d6256fae5108072ab3750d7aeef657
MATLAB
999
30
%Defines where flicker data is, as well as where dependent repositories %are. %2024/02/25 function [flicker_root_dir, repo]=define_flicker_root_dir() %root directories: if ispc root_dir='Z:'; repo_dir='C:/Users/lblanpa/Documents/Code'; elseif ismac root_dir='/Volumes/groups/'; ...
3c3040c7ce38f8e142757f56166cde2b477ec462e106c870709a9fc2f899f264
MATLAB
1,000
33
function y=CalcCSFpulse(targetpath,savepath,name_sub,name_epi,TR,TE,FA,GoFlag1,GoFlag2) nowtime_temp = datevec(datetime); year = num2str(nowtime_temp(1)); if nowtime_temp(2)<10 month = ['0' num2str(nowtime_temp(2))]; else month = num2str(nowtime_temp(2)); end if nowtime_temp(3)<10 day = ['0' num2st...
31220af1ed900dcaadd8e66e9b15de6f36c16c33c480a4457f8f6be6a571676b
MATLAB
1,001
34
function [gx] = g_BSL(x,phi,u,in) % observation function for a Bayesian sequence-learner (BSL) % function [gx] = g_BSL(x,theta,u,in) % BSL is guessing the next outcome y_t based upon P(y_t=1|y_{t-1}), ie her % bet actually depends upon the past sequence of outcomes. % IN: % - x: sufficient statistics of log-odds of P...
3752c40cc25e7d757e375f7de06f99f33bbe52770085bf23b34eb558172ba527
MATLAB
1,001
37
% learning wavelet wname = 'bior3.9'; fb = dwtfilterbank('Wavelet',wname); [Lo,Hi] = filters(fb); [RF,DF] = biorwavf(wname); [LoD,HiD,LoR,HiR] = biorfilt(DF,RF); % I don't understand how different lvls of wavelets are obtained, % interpolation? [psi, t] = wavelets(fb); [phi, t2] = scalingfunctions(fb); spsi = waveletsu...
eb983c05df0b4cebbd5aa5f52a9efa46c652e4925fc79e1df9fd8af424f663cf
MATLAB
1,001
45
function accuracy = accuracyInTimeBin(data,epoch,variableName,errorFunc) K_FOLD = 10; BIN_SIZE = 300; JUMP_SIZE = 50; boolFail = [data.trials.fail] | ~[data.trials.previous_completed]; if strcmp(data.info.task,'choice') boolFail = [data.trials.fail] | ~[data.trials.choice] |... ~[data.trials.previous_comp...
13910fbdc946e0e0d1bb842eebf21555aa8a53b7b50234e894c99c766b84ab49
MATLAB
1,002
33
function x_dot = dp(x,K,gNa,gK,gL,gKm,C,ENa,EK,EL,Vt,Vs,I) % SOURCE: https://journals.physiology.org/doi/full/10.1152/jn.1999.81.4.1531 N = length(x)/5; V = x(1:N); m = x(N+1:2*N); h = x(2*N+1:3*N); n = x(3*N+1:4*N); mK = x(4*N+1:5*N); % sodium am = -.32*(V-Vt-...
15c1c9e2677b80403bb333598b96b752cec484dc94d89507f57826cd4b7a88bf
MATLAB
1,002
63
function [Idx,C] = ClusterSpkTrain(data,n) % [Idx,C] = ClusterSpkTrain(data,n) clusters binned spike trains in data into n clusters % % INPUT : % data: a matrix in the form time bins x cells % n: number of clusters % OUTOUT: % Idx: cluster indices associated with each cell % C: simimlarity matrix % % ad...
8166e0267f78b0ed4399d85668d35e9ef2b32c658835123aaaaed6912b148f74
MATLAB
1,002
39
function S = EPGX_MT_shift_matrices(Nmax) % Generates shift matrices up to order Nmax for 4 component 2 pool MT case % Layout of state vector is [F0A F0*A Z0A Z0B F1A F-1A Z1A Z1B ... etc] % i.e. 4 states per n-value % % Shaihan Malik 2017-07-20 N = (Nmax+1) * 4; S = zeros([N N]); %%% F(k>=1) look @ state...
1258571f5527ed17467fc7d0f64120ee845911ba0a5be69610b6c13866b78505
MATLAB
1,003
29
function combine_hi_lo_wave_clus_211012(lo_times,hi_times) %inputs should be directories represented as char or string %when two thresholds are set for the same channel, this concatonates the %times files produced by wave clus lo=load(lo_times); hi=load(hi_times); % renumber clusters largest_lo_cluster=max(lo.cluster...
601a673828d8c4e073120f9a10cdf70ac48dc7f49c252d11a771d57ae8d8bf8a
MATLAB
1,003
36
function [wcov,g]=wincov(x,y,percent) % function [wv,g]=wincov(x,percent) % returns the winsorized covariance of x & y as wcov % returns number of winsorized observations at each tail of sample as g. % x must be a vector. % percent must be between 0 and 100; the function winsorizes the lower and % upper extreme g valu...
be21e89d923e62ef15e9cbe9822c51b20a16744f86c307c15b29b3d33be2ca8e
MATLAB
1,003
28
% Tutorial script containing the default parameters for use in the tutorial % % License: %===================================================================== % % This is part of the Princeton MVPA toolbox, released under % the GPL. See http://www.csbmb.princeton.edu/mvpa for more % information. % % The Princeton MVP...
dc2c4f41e3e76d756aef4dfa6989dfe97acfd09083ba38cecd9647b953c9d9c4
MATLAB
1,003
36
function threshMap = thresh2ClusterSize(map,nbrhood,clusSize,varargin) %Iteratively thresholds map till a particular cluster size is achieved - %works best (for now) if only 1 cluster is present in map nbrhood_mat=cosmo_convert_neighborhood(nbrhood,'matrix'); %mask data if it is provided (mask is a logical that is th...
1d5c21d409de764cb75759f1c2df7954375ec53d6c8690c494db5dc17fffcb9d
MATLAB
1,004
28
addpath(genpath('/Users/james/contamination/Toolbox/')); set(gcf,'visible','off') %% Global parameters DIR = {'NY717', 'NY718', 'NY869', 'NY857', 'NY786', 'NY720', 'NY744', 'NY758','NY837', 'NY733', 'NY741', 'NY751', 'NY802', 'NY756', 'NY723','NY781', 'NY830', 'NY721', 'NY753', 'NY863', 'NY763', 'NY743','NY838', '...
b9f30fdefc9f45475d298039cc041611002077da3319c4ecee8cadaba743cfd2
MATLAB
1,005
27
function cdf_Paxm = computeCDFpowerlawdistributionHZ(x_vals, a_hat, x_min) % computes the complementary CDF of a discrete power law distribution using % the generalized zeta function (Hurwitz zeta) % cdf_Paxm = hurwitzZeta(a_hat, x_vals)/hurwitzZeta(a_hat, x_min); % [glu_hurwitzZeta, ~] = loadhurwitzZetaLookup...
ffd5308c65fa1adff463d8934cb48b0c2d6277de6aebdb1397ffdfc1ce0b4b55
MATLAB
1,005
31
function [subj] = remove_objsubfield(subj,objtype,objname,fieldname,subfieldname) % Removes the subfield from an object. % % SUBJ = REMOVE_SUBFIELD(SUBJ,OBJTYPE,OBJNAME,FIELDNAME,SUBFIELDNAME) % % See remove_objsubfield for more information % License: %================================================================...
f26c84b7e64184686f72f37d7a2a7c514e41bdf17655d66c8ebbd904f04ec979
MATLAB
1,006
38
function [cov, covf] = gpcovar(net, x) %GPCOVAR Calculate the covariance for a Gaussian Process. % % Description % % COV = GPCOVAR(NET, X) takes a Gaussian Process data structure NET % together with a matrix X of input vectors, and computes the % covariance matrix COV. The inverse of this matrix is used when % calcul...
2173d8ca9039b3aef52b26ae87330324437a96603c172194ac5909951805d6f3
MATLAB
1,007
31
function net = mlpinit(net, prior) %MLPINIT Initialise the weights in a 2-layer feedforward network. % % Description % % NET = MLPINIT(NET, PRIOR) takes a 2-layer feedforward network NET and % sets the weights and biases by sampling from a Gaussian distribution. % If PRIOR is a scalar, then all of the parameters (weigh...
00570ba712f33ab8d346dfad7e4a4311e3ec8cfa40a6ad39c8f99e19fc857ee3
MATLAB
1,009
33
function MachSetStandardPriority % MachSetStandardPriority % % OS X: ___________________________________________________________________ % % Restores the standard priorty flavor THREAD_STANDARD_POLICY to the main % MATLAB thread. MachSetStandardPriority undoes previous calls to either % MachSetTimConstraintPolicy or...
c28b4ceeca33cf99b49d59da9b9df84bc7e7a3ac2e600e595cfa134c48868c68
MATLAB
1,009
50
function setup_directories(p) % Create all directories that are necessary for the following analyses. % This is where data/results are stored. base_dir = p.dirs.base; if ~exist(base_dir,'dir') mkdir(base_dir) end data_dir = fullfile(p.dirs.base, 'data'); if ~exist(data_dir,'dir') mkdir(data_dir) end analysis...
f652e3ea7d365639e5314316f32959b23847244253e2080d4a2ab830756fc38a
MATLAB
1,009
25
function as = build_step2_accumulation_structure(params, step1) % estimate sampling frequency to transform time values into array indices values t = step1.time; sfreq = round(1/median(diff(t))); as.sfreq = sfreq; %% signal will be cut in time_windows surrounding each event % the limit...
24d0d8b738fb635907e6a98ca008919f7046bf673b492b350c575758a5c76123
MATLAB
1,010
32
function S = makeHistoryMatrix(data, nt_filter, pad_data_or_zero, filtLP) % function S = make_history_matrix(data, nt_filter, pad_data_or_zero, filtLP) % Convert vector to matrix for for GLM use % Hannah Payne % % To do lowpass filter: % filtLP.dt % (s) % filtLP.f % (Hz) % Columize data = data(:); % Pad eit...
f2574cdc1107d199c2999e26cf3c7f5c6001651bc6955fdf04bbba9f1a0f6a2a
MATLAB
1,010
29
function combine_hi_lo_wave_clus_211020(lo_times,hi_times,lo_name) %inputs should be directories represented as char or string %when two thresholds are set for the same channel, this concatonates the %times files produced by wave clus lo=load(lo_times); hi=load(hi_times); % renumber clusters largest_lo_cluster=max(lo...
9399c120daf89ace6aa9466a4cb9d975546c4b5784b197613016fc79b0dbee23
MATLAB
1,011
35
function val = getHomer2_paramValue(funcName, paramName, file) val = []; DEBUG=0; if DEBUG fprintf('Searching Homer2 output %s for %s: %s value\n', file.name, funcName, paramName); end load(file.name); for jj=1:length(group.subjs) for kk=1:length(group.subjs(jj).runs) for iFunc=1:length(group.subjs(jj...
ec0b4d5c96fce7ab0a3ecdb42fa657555cf3223d7c4b725da457320e0598ec33
MATLAB
1,012
35
function lat = halfPeak(data,inx,raster_params,plot_option) psth = getPSTH(data,inx,raster_params); baselineRate = mean(psth(1:(raster_params.time_before))); response = psth((raster_params.time_before):end); if mean(response)>baselineRate [peakRate,inxPeak] = max(psth((raster_params.time_before):end)); inxPea...
5cf8f601585af488e0c29f75639cbb160068bc542ef04657f025fc5a95a8b9d3
MATLAB
1,014
26
% function output = transres_MSS_diff(decoding_out, chancelevel, varargin) % % Get the sum of squares difference between predicted and true labels. This % function is particularly useful for regression approaches, but can also % be used meaningfully for classification when neighboring classes are also % more similar to...
4d3f4ed51d3fe81c179bfeda7ed457189cc32e3ac4dca5480fcafa7f55b96210
MATLAB
1,016
58
function [Az,tp,fp,fc]=rocarea(p,label); % [Az,tp,fp]=rocarea(p,label) computes the area under the ROC curve % corresponding to the classification output p. Labels contain the truth % data {0,1}. tp and lp are the true and falce positive rate. If no output % arguments are specified it will display an ROC curve with th...
ca3708ec6cb64ce6f131e3435e9841d446a5b3f6b92c4de1420bdf2e75148587
MATLAB
1,016
42
function x = IWT_PO(wc,L,qmf) % IWT_PO -- Inverse Wavelet Transform (periodized, orthogonal) % Usage % x = IWT_PO(wc,L,qmf) % Inputs % wc 1-d wavelet transform: length(wc) = 2^J. % L Coarsest scale (2^(-L) = scale of V_0); L << J; % qmf quadrature mirror filter % Outputs % x 1-d signa...
def3c709bd8dc5614d42bb116c0671a99532b607829a1e46d50e7a12b8bcdade
MATLAB
1,016
29
function msBatchSelectAlignment(dirName) %MSBATCHSELECTALIGNMENT Summary of this function goes here % Detailed explanation goes here dataFolders = msBatchFindDataFolders(dirName,[]); for folderNum = 1:length(dataFolders) currentFolder = dataFolders{folderNum}; dirData = dir(currentFold...
51836923c638ebd2b09ec550854d7a781e53918ece032b6b74b59df1f463b0c2
MATLAB
1,017
36
function [vx, vy, vz, relMat] = LKxOptFlow3(I1,I2,sig,thresh) if nargin == 2 sig = 3; thresh = 0; elseif nargin == 3 thresh = 0; end [a, b, c] = DecomposedGaussian3(sig, 6); I1 = double(I1); I2 = double(I2); dxI = I1 - circshift(I1, [0, 1, 0]); dxI(:, 1, :) = 0; dyI = I1 - circshift(I1, [1, 0, 0]); dy...
e25be2ae81748780247527f92e62f5b9f89b9275c66f1a39ca7dccb5c20f7d07
MATLAB
1,017
24
function paperDefaults ill_scale = 1; % 1.28 scaling difference in font sizes in illustrator? num_font = 6; label_font = 7; font = 'Myriad Pro'; set(0, 'DefaultFigureColor', 'white', ... % Figure background white 'DefaultAxesColor', 'none', ... 'DefaultAxesBox', 'off',... 'DefaultAxesTickDir',...
3a20587d97c98a64ea795b1ba576c6a0e4172ffc1f05db7981a491ff78b1ff30
MATLAB
1,018
22
function [] = runTooSlow(taskStruct, dispStruct, trialStruct) Screen(dispStruct.wPtr, 'Flip'); Screen('TextSize', dispStruct.wPtr, 40); Screen('TextColor', dispStruct.wPtr, dispStruct.textColor); [~, ny] = DrawFormattedText(dispStruct.wPtr, '- Too Slow! -', 'center', 50); Screen('TextSize', dis...
4182024993119dc7ab76bdbe25116f5bbdb216f1094a0784b055e84bd6063714
MATLAB
1,018
36
function skullstrip_mean() clear filenames clear cfg cfg = load('neurovar_cfg.mat').cfg; expression = ['(']; n_subs = 44; for i_sub = 1:n_subs filenames{i_sub, 1} = fullfile(cfg.sub(i_sub).anat_dir, strcat('be_w', cfg.sub(i_sub).anat_fn)); expression = [expression, strcat('+ i', num2str(i_sub))]; end express...
4f53377b0f50657180b8a821c5cc4e4980851357003a55aa09b288708d367ddd
MATLAB
1,018
34
function [boi]=plot_freq_bins_bar_220210(time_idx,index,chan_2_plot,bin_width_sec,fs) bins_edges=[time_idx(1):time_idx(bin_width_sec*fs):time_idx(end),time_idx(end)]; index=index/1e3; vec_2_plot=[]; for pts=1:length(bins_edges)-1 freq=sum(index>bins_edges(pts)&index<=bins_edges(pts+1))/bin_width_sec; vec_2_plo...
5e8287f96bc4ec9c669c37e4dbdbeb6f0e442d0789416117ed7f06b298ff834f
MATLAB
1,018
55
function tsv = readTsv(filename, option) tsv = struct([]); if ~exist('filename', 'var') filename = ''; end if ~exist('option', 'var') option = ''; end [p,f,e] = fileparts(filename); if isempty(e) e = '.tsv'; end filename = [filesepStandard(p), f, e]; if ~ispathvalid(filename, 'file') return; end numstr...
89e0c9f326c19624221a2303a10e025e0c8a8e1671e838eee1af4824af36339a
MATLAB
1,018
33
xline([0 3000 10000],":r",{'LP/CS', 'US', 'Fin CS'},'LabelOrientation','horizontal',HandleVisibility='off',LineWidth=1.5, FontSize=15); %xline(0,":r",'Licking onset','LabelOrientation','horizontal',HandleVisibility='off',LineWidth=2.5, FontSize=15); yline(0,'-', HandleVisibility='off'); ylabel(['Z-Score of ∆F/F +/- S...
8b87349b9e4c8c7b3a92d88334dca3e6d1c7e7d0cfdc328ac70c4666cfec3e68
MATLAB
1,018
47
% MA_RMS moving average RMS of a signal. % % Y = MA_RMS( X, M, RMSFLAG ) % % RMS computed in a moving average window of M samples: % % RMS(n) = sqrt( 1 / M * sum( ( x(n-k) )^2 ) ) % % where the summation is over k=-M/2:M/2 (odd M...
c5a4e1179ffb9bb6c01c31079f76e85d29ed78d438b0cff6dc388d3efb85ead0
MATLAB
1,019
27
%{ Copyright (C) 2023 N. Suhas Jagannathan 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 Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed i...
0bfe58796b3ef733ff449d4a556770f0af50ab2a64e98420b23e9da9bbbb24bc
MATLAB
1,021
28
% dataClass1, dataClass2, dataClass3 featuresClass1 = extractFeaturesCSP3Classes(dataClass1, dataClass2, dataClass3, 0.1); featuresClass2 = extractFeaturesCSP3Classes(dataClass2, dataClass1, dataClass3, 0.1); featuresClass3 = extractFeaturesCSP3Classes(dataClass3, dataClass1, dataClass2, 0.1); % 创建特征和标签矩阵 featur...
916294bd4eb5017434107a99aac48347521f152706986d8d1e598fe15a3266d3
MATLAB
1,021
30
function SO = mapArray(S, cmd_string, varargin) % Applies function on each element of the array % % USAGE: % SO = mapArray(S, cmd_string, arg1, ..., argN) % % Similarly to Python's function, map applies the commands indicated in % cmd_stirng to each elements of the tsdArray S. In cmd_string, the input % tsd ar...
4182e38874d8a88b0b79f4670a94fcaefe07e518ea1c7a6a1aeb8a1b51b7b7fc
MATLAB
1,022
57
function TSO = oneSeries(S) % Sorts all the points in each element in the tsdArray, and returns a single tsd with all the points % % USAGE: % tso = oneSeries(tsa) % copyright (c) 2004 Francesco P. Battaglia % This software is released under the GNU GPL % www.gnu.org/copyleft/gpl.html sz = size(S.C{1}); ...
e9eea3ed0d24f9b8d7d6a02d102bd629523f3e01f94614147e103bda2db87e62
MATLAB
1,024
31
function recalibrate_eyetracker(Experiment) Display = Experiment.Display; if strcmp(Experiment.Mode.eyetracking,'Yes') el = EyelinkInitDefaults(Display.window); % Calibrate the eye tracker % setup the proper calibration foreground and background colors el.backgroundcolour = [0 0 0]...
32e10199aa4d35eb81ed2f751c2f3eef29d4a7b09d711cbb3cc002e3cf8177f7
MATLAB
1,025
35
function ph = firingPhaseHilbert(eeg, S,W,epoch) % ph = thetaPhaseHilbert(CRtheta,S) copmute firing phase of spikes with the Hilbert Transform % % INPUTS: % CR: tsd containing EEG filtered in the frequency domain of interest (e.g. % theta, or gamma % S (optional): tsd array of cells, the firing phase of each s...
64ba5def1be293c729d26d1caa4aed6e1fe40ec22962460f23f7bcbfd0ba3a81
MATLAB
1,026
41
clear [task_info,supPath] = loadDBAndSpecifyDataPaths('Vermis'); PLOT_INDIVIDUAL = 0; runningWindow = -300:300; %ms req_params.grade = 7; %req_params.ID = 4000:6000; req_params.remove_question_marks = 1; req_params.num_trials = 20; req_params.remove_repeats = false; req_params.cell_type = 'PC cs'; lines1 = findLi...
f50261bf3ff26b0daa0c686647bd7713bee52330817563029b42a222e6f04dae
MATLAB
1,026
37
% kernel unit test % % rbf kernel tol = 10e-10; % Random data N = 50; F = 10; X = randn(N,F); X(1,:) = X(1,:) + X(2,:); % kernel parameters param = []; param.gamma = 1/F; %% rbf_kernel(X) and rbf_kernel(X,X) should yield the same result K1 = rbf_kernel(param, X); K2 = rbf_kernel(param, X, X); print_unittest_result(...
8bf7b8238c744607bd2a8132b17d49d6126edcaf6b3cfbc8ba79b94088a66fb7
MATLAB
1,027
19
function decoding_out = liblinear_test(labels_test,data_test,cfg,model) if isstruct(data_test), error('This method requires training vectors in data_train directly. Probably a kernel was passed method is use. This method does not support kernel methods'), end switch lower(cfg.decoding.method) case 'classif...
fadf510d72184db0a7680de17f0ac6c15b6e86f3a79eaaa32f6aa40d244ce54a
MATLAB
1,028
26
function boris_events = load_boris_csv(filepath, camera_TTL_raising_times) % This function take a path to a boris csv file and return the headers % of the columns in header_raw as well as all the data n_line_header = 1; % In 2021 Doric csv file has two lines of header fp = fopen(filepath,'r'); % Open the csv file in re...
1bb4cfc205fe665b0a09e9e64591b701efafb5191a8affe51c1f9eb6d469e819
MATLAB
1,030
29
function [psth] = lickSimulation... (data,lickPSTH,window,alignTo,params,ind) ind_0_in_psth = params.time_before+length(lickPSTH); psth = zeros(params.time_after+params.time_before+2*length(lickPSTH),1); counter = 0; for t=1:length(ind) eventTimes = trialLickEvents(alignTo,data.trials(ind(t)),'full')... ...
ecf5333dcee3fb50687f06cfbff5bae6397a60f7f8396e83f249313460ca1462
MATLAB
1,030
29
% Preprocessing unit test % rng(42) tol = 10e-10; % Random data N = 100; X = randn(N,40); clabel = randi(2, N, 1); cfg = []; cfg.preprocess_fun = {}; cfg.preprocess_param = {}; oversample_param = mv_get_preprocess_param('oversample'); undersample_param = mv_get_preprocess_param('undersample'); zscore_param = mv_get_...
13e97c151d5b1a9318ce0081316a9ad0b4fe88adc3c421ddaf1c185c83879557
MATLAB
1,031
41
function [v,d] = eig2x2(x) siz = size(x); if numel(siz)>3 error('not yet supported for >3D matrices'); end if numel(siz)==2 [v,d] = eig(x); elseif all(siz(1:2)==2) d = zeros(siz); v = zeros(siz); aplusd = x(1,1,:)+x(2,2,:); detA = det2x2(x); Discr = aplusd.^2-4.*detA; d(1,1,:) = (aplusd+sqrt(...
f52278f7ba9f90e8791959541b92755ce2732ab5b60ffb87abecee42035634ce
MATLAB
1,031
27
function cqObj = ColorQuiver(vx, vy, cmap, lineWidth, varargin) ang = atan2(vy, vx); ang = mod(ang, 2*pi); ang = RenormalizeImage(ang); if isempty(varargin) numBins = size(cmap, 1); ang = round(ang*(numBins - 1)) + 1; angs = unique(ang(~isnan(ang))); cqObj = cell(length(angs), 1); for i = 1:length(a...
27fa7f6e93ed95da4a894d9fbd2d25a12c98f89bdad85a522f82390284b376fb
MATLAB
1,033
35
function [name obj] = get_name(subj,objtype,objno) % Internal function - gets the object's name from its cell index % % [NAME OBJ] = GET_NAME(SUBJ,OBJTYPE,OBJNO) % % Returns the name of an object if all you know is its number. Avoids % directly accessing the subj structure % % Useful if you're looping over all the mem...
db495695c1435c8bb0cf45e7c7fab9fbdb7f83c753e0c0aa7e4c63bdd1016a8f
MATLAB
1,035
42
function [PCcoeff, PCvec] = pca(data, N) %PCA Principal Components Analysis % % Description % PCCOEFF = PCA(DATA) computes the eigenvalues of the covariance % matrix of the dataset DATA and returns them as PCCOEFF. These % coefficients give the variance of DATA along the corresponding % principal components. % % PCCO...
b33085a41aee018054031c61eec8f23be6882460eb3695026bbd8225765cc27d
MATLAB
1,036
29
function g = demgpot(x, mix) %DEMGPOT Computes the gradient of the negative log likelihood for a mixture model. % % Description % This function computes the gradient of the negative log of the % unconditional data density P(X) with respect to the coefficients of % the data vector X for a Gaussian mixture model. The da...
e0ca9b08b0c57bd38c0cef6372c810503ba6fbe0e5dc40c317f53c47801dcb08
MATLAB
1,037
27
function download_example_data(dataset, target_dir) %Downloads datasets used in the examples. % %Usage: % download_example_data(dataset, target_dir) % %Parameters: % dataset - name of the dataset. Possible values: 'music_bci' % target_dir - target directory for the data. By default, the data % ...
66035279c42669ee59180fa7995cfe549e58a611839b27bf6d6cf32597671736
MATLAB
1,040
27
function [resultSave, resultShortsatSave]=fEPI_CSF_simul(RFnum) %% Simulate EPI saturation effect TRrepetition=42; % 100~4200 interTRrepetition=2000; % 1~2000 TErepetition=10; % 5~50 resultSave = zeros(TRrepetition,interTRrepetition,TErepetition,RFnum); resultShortsatSave = zeros(TRrepetition,interTRrepetition,TE...
8e4e196931bf58f07065768071065b031c4597305dca1ae7f8ccc28227324eb2
MATLAB
1,040
31
function w = mlppak(net) %MLPPAK Combines weights and biases into one weights vector. % % Description % W = MLPPAK(NET) takes a network data structure NET and combines the % component weight matrices bias vectors into a single row vector W. % The facility to switch between these two representations for the % network pa...
7adf17ea48740b3ee3c53cd6fa84967054afcb260df833552eda362531b0dd0f
MATLAB
1,041
28
function msBatchGenerateMS(dirName) %MSBATCHGENERATEMS Summary of this function goes here % Detailed explanation goes here dataFolders = msBatchFindDataFolders(dirName,[]); figureNum = 0; parfor folderNum = 1:length(dataFolders) currentFolder = dataFolders{folderNum}; dirData = dir(current...
4615588044058ad7bbf5fbabed683a1d6868c4e36c8e308ab1aeb3b91415fe8c
MATLAB
1,042
35
function [mu, kappa, p] = MixedVonMisesFit(angListInRadians, varargin) if isempty(varargin) cLevel = 0.95; else cLevel = varargin{1}; end %% Calculate Modified Bessel Functions of the First Kind xVec = 0:0.001:1000; I0 = besseli(0, xVec); I1 = besseli(1, xVec); I2 = besseli(2, xVec); A1 = I1./I0; A2 = I2./I0; ...
868e245e04de044d5da1050ecd593f7a34d54e4b02a3666c3cf2425701f429b8
MATLAB
1,042
40
function U = mv_repelem(V, N) %Drop-in replacement for Matlab's repelem function (which is not supported %by some earlier versions of Matlab). % %Usage: % U = repelem(V,N) % %Parameters: % V - [scalar or vector] elements to be repeated % N - [scalar of vector] number of times each element is repeated (if % ...
08ac942411e54ae6e900cc47bbf6848dd8b82eb8171715f1639508d935df372b
MATLAB
1,043
44
function val = getHomer3_paramValue(funcName, paramName, dataTree, igroup, isubj, irun) global procStreamStyle if ~exist('igroup','var') igroup = 1; end if ~exist('isubj','var') isubj = 1; end if ~exist('irun','var') || isempty(newval) irun = 1; end if includes(procStreamStyle,'nirs') funcName = [func...
d1ea7f8269c234a4411cc2659c4c3d38c35a3d484f1151f000c96989af8339ab
MATLAB
1,043
40
function out = charpoly4x4_sym(z) % compute coefficients of characteristic polynomial of hermitian 4x4 % matrices % !!!! no check of symmetry is performed out = zeros(size(z,1),5); z_abssq = abs(z).^2; tr1 = trace4x4_1(z); tr2 = trace4x4_2(z_abssq); tr3 = trace4x4_3(z, z_abssq); out(:,1) = 1; out(:,2) = -tr1; o...
19571bdc447060b829300e23c5ea98ff532a74ba527fae005c4735a6d03e3111
MATLAB
1,044
46
function [types] = get_typeslist(plurality) % Auxiliary function % % [TYPES] = GET_TYPESLIST(PLURALITY) % % Returns a cell array of strings % with the names of the main types % % % Set PLURALITY to 'single' or 'plural' % License: %===================================================================== % % This is part ...
61cd22c9ea403456df1e9bdc96280684f5e91e9fb8b163b43c64c8a8003f6bf8
MATLAB
1,044
38
% @title Generate neuron type array % @file gen_ntype.m % @author Romain Beaubois % @date 12 Aug 2021 % @copyright % SPDX-FileCopyrightText: © 2021 Romain Beaubois <refbeaubois@yahoo.com> % SPDX-License-Identifier: GPL-3.0-or-later % % @details % > **12 Aug 2021** : file creation (RB) function nt...
99aee8b341d208d60dd11a6f91b002e5893cdeb0fc357e3fa5ca1b20b2df363d
MATLAB
1,044
30
function run_analysis_step2(analysis_folder,animal_folder_listing) af_name = animal_folder_listing(ii).name; af_path = fullfile(analysis_folder,af_name); fprintf('Animal: %s\n',af_path); %LIST ALL RECORING SESSIONS FOR ONE ANIMAL recording_listing = dir([af_path filesep '*step1.mat']); rec_all_list = [rec_all_list;r...
50cdcb38e4f4c8e8f58baf2aff4cfc4d012147c3c4c1fd5595ca3135e28957fa
MATLAB
1,045
28
function tmass_stats = mri_tmass_stats(p) % Performs permutation-based cluster t-mass analysis to determine clusters % of subsequent time points with above-chance reconstruction accuracy based % on t-tests. First, permutation results are loaded for all subejcts. % Chance-level is removed (to allow testing against 0) a...
ddfafc315244b2e0e1a30aa91391fc485ab86ae8fb133f3a49714c19d4fe3357
MATLAB
1,046
39
clear [task_info,supPath] = loadDBAndSpecifyDataPaths('Vermis'); PROBABILITIES = [25,75]; req_params.grade = 7; req_params.ID = 5287; req_params.remove_question_marks = 1; req_params.num_trials = 10; req_params.remove_repeats = false; req_params.task = 'pursuit_8_dir_75and25'; raster_params.time_before = 399; raste...
80b166972e39a5bdc877a2e398423295c62014c5bd6f1477af7d73cd4f86547c
MATLAB
1,047
29
function [subj masknames] = union_masks(subj, newmask, varargin) % UNION_MASKS - Unions one or more masks together. % % Usage: % % [SUBJ MASKNAMES] = UNION_MASKS(SUBJ, NEWMASK, REGEXP) % [SUBJ MASKNAMES] = UNION_MASKS(SUBJ, NEWMASK, MASK1, MASK2, ...) % % This is a wrapper to COMBINE_MASKS with FUNC = @(A,B) A ...
dc6c0ca94e6eb6b0b099a68dfae3ece1f7a427ae84ec413f0e8c0beff4deb48d
MATLAB
1,049
40
function drawSlideStatus(im,FM) % Helper function to draw status on figure % Inputs: im - flourecense image, FM - Flourecense Microscope Json file L = get(gca,{'xlim','ylim'}); % Get axes limits. imagesc(im); axis equal; axis off; colormap gray; if (sum(L{1} == [0 1]) + sum(L{2} == [0 1]) == 4) %This...
6a2b08081611889d3090708d2645734cac0e51f49269de77a89aeafd6e099ef0
MATLAB
1,050
23
function [h_MLE_unc, f_info] = compute_h_unc(h_val, J_i, eta_val, eps_val, T) % Estimates the SE of the MLE for h at this value of epsilon, phi, and J, % Also returns the Fisher information (f_info = 1/sigma^2) % Computed from the second derivative w.r.t. h of the likelihood, which is % -1/sigma^2, the uncertainty aro...
2b120a914dd8b6c0f1b0ad1853230a1a4dd78517e4c99e59a6818eff63ad093f
MATLAB
1,051
28
function tracedata=load_raw_MF_data_to_LBV(fname) Data = fileread(fname); Data = strrep(Data, ',', '.'); cr=regexp(Data,'[\r]'); Dataarr=str2num(Data(cr(1):end)); datasize=str2num(Data(10:cr(1))); x=reshape(Dataarr(:,1),datasize(2),datasize(1)); y=reshape(Dataarr(:,2),datasize(2),datasize(1)); Lx=reshape(Dataar...
a8bfdb7a8edf4536b8267833d3f3e0b04286381cb8b77b9a28acab013010d82d
MATLAB
1,051
46
function [h,B,mu,p,kappa] = HeadDirectionField(tsa,ang,GoodRanges,varargin) % USAGE % [h,d,mu,p,kappa] = HeadDirectionField(tsa,ang,GoodRanges) % % Inputs: % tsa: a ts object (typically a cell!) % ang: a tsd object of head orientation % GoodRanges: an intervalSet object defining the time of va...
e9083f7acf0c7508e54625efd3c5a54a9774a9cb59e215f2d776d5b99b89ef11
MATLAB
1,051
45
function [q1, q2] = idealf(x, dim) % IDEALF computes the 'ideal fourths' according to Wilcox paragraph 3.12.5, % accounting for nans % % Use as % [q1, q2] = idealf(x, dim) % % Input arguments: % x = matrix containing the data % dim = dimension along which to operate, if not specified the first % non-si...
20640ff19d5470595388af3d6de77a7ba63bde5f273e710335b183fe661a49c3
MATLAB
1,052
50
function [stats]=calc_Cramer_vM(performance,id) stim={'Trans','Brown','White'}; coh_str=({'100','50','25','12.5','0'}); % allocate stats.cramer_vM=cell(3,5); % for stim_=1:length(stim) ids=id.st_id==stim_;%get subjects matching the current stimulus type cur_s=find(ids); for coh_=1:size(id.coh,2)...
0959516d01c52a04bef0192af209aa7bb7ab52184ff9dc599827996481ae3160
MATLAB
1,053
42
function [cmds, errs, msgs] = gitSubmodulesClone(repo, preview, options) cmds = {}; if ~exist('repo','var') || isempty(repo) repo = [pwd, '/']; end if ~exist('preview','var') preview = false; end if ~exist('options','var') options = 'init'; end repoFull = filesepStandard_startup(repo,'full'); ii = 1; su...
9b0c1541512c443877e574fcb4b6f28476f6b9eb101b281901d2b2db8f6f97c6
MATLAB
1,053
17
function tf = isHistologyToOCTTMakeSense(histologyToOCTT,OCTImageSize, HistologyImageSize) % This function will try to figure out if OCT image is somewhere in % histolgoy image, i.e. does it make sense? % OCTImageSize, HistologyImageSize are size(y), size(x) % Is any of the corners of OCT inside of the histology ...
586720c5f88b0220167cd4945e0d0824c50dccc52108eb37dcce221a88b9c1d7
MATLAB
1,054
42
function str = read_str(fid) % str = read_str(fid) % % :description % % A utility function that reads a C string from a binary file. % % :inputs % % fid file id of file already opened for reading % % :outputs % % str string of chars returned % % :history % % 2004.04.16 Ben Singer Edited slightly a ...
37dd7e2a1648ecb94e6feee7009ab1cde225d6770ecdcbff32b0d3cf89a0599e
MATLAB
1,056
48
%% 25-6-17: steady state SINGLE pool function [Mss] = ssSSFP(alpha, TR, dw, T1, T2) R1 = 1/T1; R2 = 1/T2; %%% Full system matrix - same notation as CX version E = diag([-R2 -R2 -R1]); W = diag([-1i*dw 1i*dw 0]); A = E + W; eA = expm(A*TR); C = [0 0 R1].'; % Assume RF is rotation around x-axis. Phase doesn't matte...
916578a6da5677cef44ed5e5281fe62d8e1a0f8d0d29a3d347b7fc68efe17c90
MATLAB
1,056
44
function leadfield = makesourcemodel_3dgrid(resolution) if nargin==0 resolution = 8; end load mri seg = removefields(mri, {'anatomy' 'inside'}); seg.brain = seg.mask; clear mri; seg = rmfield(seg, 'mask'); cfg = []; cfg.resolution = resolution; cfg.unit = 'mm'; cfg.mri = seg; %cfg.smooth = 'no'; s...
c04e49eb34176b36c99dd977cae0bdcdc74cbf52d8b4a15e8e26a202ef0cbe39
MATLAB
1,056
29
function msBatchAlignBetweenSessions(dirName) %MSBATCHALIGNBETWEENSESSIONS Summary of this function goes here % Detailed explanation goes here dataFolders = msBatchFindDataFolders(dirName,[]); refFolderNum = ceil(length(dataFolders)/2); currentFolder = dataFolders{refFolderNum}; temp = load([cur...
940280afd8b5ede8f077a934934a49f4accc93eb1570aad0fd37f601fbce3dee
MATLAB
1,058
40
function ende=findend(indicator,time,start) % generic funcion to find the end in a trace % SYNOPSIS % function start=findend(indicator,time,start) % DESCRIPTION % indicator: a logical vector if the measurement is above threshold or not. % time number of times, that the indicator has to be below threshold, ...