sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
45b16ea3634e9aa361cb262d5d1f1b17eef28242a297064b50df6b7c8aeb59ea
MATLAB
652
22
function SIG=mour_Psig_v1(input,CaCBVTime) % input=[LgFlow,LgLambda,delay]; Ca->AIF+CBV+time log_F=input(1); LgLambda=input(2); delay=input(3); estCBV=CaCBVTime(1,end); t=CaCBVTime(2,1:length(CaCBVTime)-1); Ca=CaCBVTime(1,1:length(CaCBVTime)-1); Sig0=CaCBVTime(3,1); k=CaCBVTime(3,2); TE=CaCBVTime(3,3); % F(F<0)=0; ...
645705a46fdf59822d511e0dd594652833cb0e52ab08b1ad07c91d129d79fa07
MATLAB
652
32
function y = contrast2(x,varargin) % % y = contrast(x) % makes values of matrix y lying in the range [0 1] from the input matrix x % % y = contrast(x,maxVal,minVal) % makes values of y lying in the range [minVal maxVal]. Any value outside % those boundaries will be set to boundary value % % Adrien Peyrache 2012 if ...
a9450380db3c222decae4ebe0eb47c6b30026c3fc1541120f90203d70692d1cf
MATLAB
652
19
function startup_MVPA_Light % Adds MVPA-Light and its subfolders to the MATLAB path MVPA_path = fileparts(fileparts(mfilename('fullpath'))); addpath(MVPA_path); addpath(fullfile(MVPA_path,'examples')); addpath(fullfile(MVPA_path,'external')); addpath(fullfile(MVPA_path,'kernel')); addpath(fullfile(MVPA_path,'model'))...
8355506fd8ade1c2e1bc7a6b44a9daf1210076c3e34b10bd1d3bf7727f816d4f
MATLAB
653
20
function wave_clus_GUI_quick_open_211004(folder_address) % This function opens the times files in the Wave Clus GUI for manual % fixing of clusters. Upon closing the Wave Clus GUI this function will % open a the next times files specified in folder_address. The input % folder_address should be a string or char vector p...
4e8bb718adcfb27031eb4d0289cd229a5994825456f100450dd074a6bbb22250
MATLAB
654
26
function [M, SM, B, center, R] = PETH(X, Y) binsize = 40 * 10; nbins = 160 + 1; M = zeros(nbins, 1); SM = zeros(nbins, 1); B = -(nbins - 1) * binsize / 2: binsize: (nbins - 1) * binsize / 2; B = B / 10; R = zeros(nbins, length(Y)); for i = 1: length(Y) edges = Y(i)- nbins * binsize / 2: binsize : Y(i) + nbins * ...
769075c15637e94970d2910382cae0db90aae24075ccde5740ce85f48fa829c3
MATLAB
654
30
function dat = octFromTifCash(filePath, yI) %This fuction returns an OCT plane but reads it slowly from cash persistent gFilePath; persistent gCashData; %% Make sure cash is up to date if isempty(gFilePath) || ~strcmp(filePath,gFilePath) % Time to clear cash gCashData = {}; gFilePath = filePath;...
e94b52c336a322f7d65a4f079e1bf22d531061db47d0b803fc115a673934cf1e
MATLAB
654
23
function setupParpolOCTPreprocess() %Setup parallel pool, attach everything we need p=gcp('nocreate'); if ~isempty(p) %kill prev parpool before starting this one if it has SpmdEnabled flag if (p.SpmdEnabled) delete(p); end end if isempty(p) %Parpool didnt start yet, start it p...
0e5d659e72bb12597ae45cefe3f55a34697b1580a6f05a3b05359c3c376490c4
MATLAB
655
30
function matrix_math(x,Ylabel,pic_size,output_path) x = x([(size(x,1):-1:1)],:); x = [x zeros(size(x,1),1)]; x = [x;zeros(1,size(x,2))]; figure; m=pcolor(x); m.LineWidth = 3; J = customcolormap(linspace(0,1,2), {'#000000','#ffffff'}); h=colormap(J); l=colorbar('southoutside','FontSize',15,'Box','on','LineWidth',1...
a1ae850f3ed36880ed4c8267e38c2e763538710671d29a048aaa0d8731ca5078
MATLAB
655
20
function tracks_out = ApplyMaxAngleDeviation(tracks_in,max_angle_dev) tracks_out = tracks_in; a = unique(tracks_in(:,4)); for i = 1:length(a) b = tracks_in(tracks_in(:,4) == a(i),[1,2]); c = nan; for j = 2:size(b,1)-1 p1 = b(j - 1,:); p2 = b(j,:); ...
e46ba35817d35491e53e5fe3abc506823edacb73cbe630a2fa9ad6242bd8d528
MATLAB
655
20
function [new_idx] = exclude(idx, N) % function [new_idx] = exclude(idx, N) % 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 MVPA...
b0d37bf57209c3c546d416f6082a93d08235be94ca4b2d4059ba869fac7f970b
MATLAB
656
21
function [dirmap,exy,jxy] = anaskel(wsk); % Performs some analysis on the skeleton provided, % which should be thinned to a single pixel width. % % dirmap returns a cell array with masks of the skeleton % pixels that are north, northeast, east, and southeast % or opposite. % % exy and jxy return the pixel coo...
0d1daed2811e831e05b3914c7efc202efe57c5397ed7cbedf1cc7c5644247677
MATLAB
657
28
% allS is trials x 1. doubles % stim.state is function [movieList] = updateMovieListStates(movieList,rejTrOp,stim) movieList(:,7) = ones(1,size(movieList,1)); if rejTrOp numStimClasses = length(stim); for stimClassI = 1:numStimClasses thisStimClass = stim(s...
8d0f6a5d13d2a98e72a505d548b2eaa61fd1696b8a7f8aade03cf5624c4ad2b2
MATLAB
657
36
function S = End(O, TimeUnits) % Ending time of the intervalSet object % % USAGE: % S = End(O, TimeUnits) % % INPUTS: % O - a ts object % TimeUnits - a units object or the abbreviation string % copyright (c) 2004 Francesco P. Battaglia % This software is released under the GNU GPL % www.gnu.org/copyl...
c7ad7bfca541713942d9ab49af0a7cd370f9af24428a27a46e18affeef618338
MATLAB
657
26
function [mod_val,fit_val]= plot_sel_fit(mod,fit,flag,num) %% Plot Sel Fit n_fit=sum(sum(fit)); n_mod=sum(sum(mod)); cnt=1; for iRow=1:5 for iCol=1:5 hold on if (flag(iRow,iCol)==0) figure(num) scatter(log(mod(iRow,iCol)....
f7fef3b16a334a2cc0fce7bcb2d7803940879b04d2da7e5a1f1ac7e0d433a493
MATLAB
658
17
function [AFR_vec, time_vec] = compute_AFR_200722 (peak_train, bin_s, fs) % Computes Average firing rate from the peak_train vector given by % spike_train within time-bin of width bin_s (sec) binsample = bin_s*fs; % bin [# of samples] bin_num = floor(length(peak_train)/binsample); len_s = length(peak_...
9729fabdad8c8cd6b5f8992ab7c8908633ab03c30cde29eabcd2cdde3a1d1e23
MATLAB
659
23
function ave_accuracy = trainAndTestClassifier... (classifierType,response,labels,crossValSets,PD) kFold = size(crossValSets,1); accuracy = nan(kFold,1); for k = 1:kFold training_set = response(:,crossValSets{k,2}); training_labels = labels(crossValSets{k,2}); test_set = response(:,crossValSets{k,1});...
ab0b682746eb8d9743d09aab2f84febfc4d42f2ce296a30c9fc8750abe129e35
MATLAB
659
38
function pv=plot_SignificantMark(X1,X2,Y,Txt_dist,pVal) %plot_pValLine pv=plot([X1 X2],[Y Y],'k','linewidth',2); hold on; th=.03; % th=.015; ns=0; p=pVal; if p>.05 ns=1; mark='n.s.'; Txt_dist=Txt_dist*.8; th=th*11; elseif p<=.05 & p>.01 mark='*'; th=th*4; Txt_dist=Txt_...
44ae86f03205ec9012534b33c4e53ce06e2c44f46348626ab3539b32aec33ffe
MATLAB
660
22
function [y] = cellcolselect(x, cols) % [Y] = CELLCOLSELECT(X, COLS) outputs cell-array Y with the same dimensionality as X % Each cell in Y only contains the columns COLS from the original corresponding cell in X % % X (and Y) should be linear cell-array(s) of matrices for which the number of rows % should be the s...
71c1e69f3816683cc9aabc21e810ec1e819dab0b5a3cfe396992ef0ba5222798
MATLAB
660
34
% MYDETREND remove DC and detrend columns of a matrix/3D array % % Y = mydetrend( Y, dflag ) % % dflag {1}; dc removal flag (if off, only detrends) % 28-mar-11 ES % revisions % 28-apr-11 fast matrix implementation % 03-sep-13 dflag added function Y = mydetrend( Y, dflag ) [ M N ] = size( Y ); if nargin ...
976615e36de68025eec36bab43f9ab10f6cc35b149ae0fc7d0adb57ec1417d19
MATLAB
661
27
function out = sampleParameters(mstruct,nSamples,option) out = []; if strcmp(option,'empprior') display('sampling from empirical priors...') for i = 1:nSamples draw = mstruct.samplehandle_empprior(1); while any(draw>mstruct.ub) || any(draw<mstruct.lb) draw = mstruct.sa...
30a1f115d42005e71de65a73d3f24c272cd5579ff74dc39d9fdc068a7cc3f84f
MATLAB
662
23
function y_pred = test_kernel_ridge(model, X) % Applies an kernel ridge regression model to test data and outputs % predicted responses. % % Usage: % y_hat = test_kernel_ridge(model, X) % %Parameters: % model - struct describing the regression model obtained from training % data. % X ...
89955dcbb8cda2af90f242546b77aeb0e81544659ddcd03ebe78cff2cdcc4b7f
MATLAB
664
24
% Test Significance of Linear Regression Model of firing rate vs. % grid3score. % A small p-value indicates that the model fits significantly better than a % degenerate model consisting of only an intercept term. % This is a linear hypothesis test on linear regression model coefficients. % reference: https://www.mathw...
90c6c215f1eb34f86e23d7e37d1ee53b63e2303b9d0b7cfa531174d79eb9ddd6
MATLAB
664
24
function line_pre_post(pre,post,doc_color,mean_color,Ylim_range,YTick,YTicklabel, XTicklabel, pic_title,y_label, output_path) data_mean = [mean(pre) mean(post)]; data = [pre post]; % pics for dis c=plot(data','LineWidth',3,'Color',doc_color) ; hold on d=plot(data_mean','LineWidth',4,'Color',mean_color) ; set(gca,'YLi...
d911d2e698b518d88993d6e011ff65eb77c647e5d6d8b4d8a25857aa1015f88d
MATLAB
664
32
function [d] = lbfgsProd(g,S,Y,YS,lbfgs_start,lbfgs_end,Hdiag) % BFGS Search Direction % % This function returns the (L-BFGS) approximate inverse Hessian, % multiplied by the negative gradient % Set up indexing [nVars,maxCorrections] = size(S); if lbfgs_start == 1 ind = 1:lbfgs_end; nCor = lbfgs_end-lbfgs_start+1; e...
3efef25ce10b603f6208a6ea9782a60aee6c6f3dcc8070db083b541d66fe47a1
MATLAB
665
23
function cca_mode_scatter(x,y,Xlabel1,Ylabel1,output_path) figure('position',[100,100,430,420],'PaperPositionMode','auto') scatter(x, y, 120, 'MarkerEdgeColor','k','MarkerFaceColor',[217,237,232]./255,'LineWidth',1.5); hold on set(gca,'FontSize',25); set(gca,'LineWidth',4); xlabel(Xlabel1); ylabel(Ylabel1); xticks([-3...
76be77433212c2b84166665a98b1c3987688c0ae97f33a7f98a70a5351475824
MATLAB
665
22
%% addpath(genpath('.\functions\')) %% generate KSD and PSTHs from spike times createKSDs; % trial-averaged KSD (for PCA) and individual-trial KSD for model createPSTHs; % PSTHs for display and PCA %% perform diff PCA performDiffPCA; % perform diff PCA with different inputs %% Model % simulate response latencies w...
c4b574a64d55b3f499b6fed872142d9d9d6aa935f67cfc9cb21da61148dc97fb
MATLAB
665
25
function net = mdnunpak(net, w) %MDNUNPAK Separates weights vector into weight and bias matrices. % % Description % NET = MDNUNPAK(NET, W) takes an mdn network data structure NET and a % weight vector W, and returns a network data structure identical to % the input network, except that the weights in the MLP sub-stru...
0b57da25c2841c94a7043a2698f481746fcb097455bf9af9d4d9785d00d89447
MATLAB
667
21
function msBatchSegmentCentroids( dirName ) %MSBATCHSEGMENTCENTROIDS Summary of this function goes here % Detailed explanation goes here dataFolders = msBatchFindDataFolders(dirName,[]); for folderNum = 1:length(dataFolders) currentFolder = dataFolders{folderNum}; temp = load([currentFolder '...
eb6ce7ab97371ca0f9353922424883934929736908af5ef6c139431612ec4aa6
MATLAB
667
38
function T1 = EndTime(tsa, tsflag) % Returns last timestamp % % USAGE: % T1 = EndTime(tsa, tsflag) % % OPTIONS: % tsflag - if 'ts' returns time in timestamps (default), % if 'sec' returns time in sec % if 'ms' returns time in ms % ADR 1998 % version L4.0 % status PROMOTED T1 = tsa.t(end); unit...
60b76b2f079ca1cb523fe1b06b40e4e6bf75757dcd7cf308762cd4fefc2be40f
MATLAB
668
29
function p = TimeExcludeRanges(tInc,t) p=[]; mdiff = diff(tInc); tidx1 = find(mdiff==-1); tidx2 = find(mdiff==1); % If excluded time points are at the extremes of the time range, % then add inflections at the beginning or end. if tInc(1)==0 tidx1 = [1;tidx1]; end if tInc(end)==0 tidx2 = [tidx2;length(tInc)];...
83b6eab7daadcc81d32537bfec933b3825a4abbb3d86d6d9bdaa80f856804654
MATLAB
670
29
%% 22-7-2017 Steady state SGPR for MT function Mss = ssSPGR_MT(theta,b1sqrdtau, TR, T1x,f,ka,G) M0b = f; M0a = (1-f); kb = ka * M0a/M0b; R1a = 1/T1x(1); R1b = 1/T1x(2); %%% Relaxation-exchange matrix for Longitudinal components Lambda_L = [[-R1a-ka kb];[ka -R1b-kb]]; Xi_L = expm(TR*Lambda_L); % For inh...
338031f57feaba5fa887f7111de28250ed3fb04be2429adbb566475a760d6c12
MATLAB
671
31
function r = MD_multrnd(p,N) % _ % Random Numbers from the Multinomial Distribution % FORMAT r = MD_multrnd(p,N) % % p - a 1 x K vector with multinomial probabilities % N - an integer specifying the number of samples % % r - an N x 1 vector with multinomial random numbers % % Author: Joram Soch, BCCN Be...
8c37d8e8094640be28f60873f87051235a4de37dff9cb463f5056abedad2826c
MATLAB
671
28
function Residual=MRes(CBV,F,LgLambda,t) % Mouridsen Residual Function (2006, Neuroimage); % it is a gamma cumulative distribution function from t>Inf % typical values: CBV=2; CBF=10; Lglambda=0; t=0:99; % CBV=2; CBF=10;Lglambda=4.65;t=0:99; lambda=exp(LgLambda); CBF=F; alfa=lambda; beta=CBV./(lambda*CBF); for i1=1:...
947decc47b5d0dca68c279f4262ff4437e1a68c3546b335aacbf4d10cb0a3149
MATLAB
674
36
function [nll,g,H,T] = LogisticLoss(w,X,y) % w(feature,1) % X(instance,feature) % y(instance,1) [n,p] = size(X); Xw = X*w; yXw = y.*Xw; nll = sum(mylogsumexp([zeros(n,1) -yXw])); if nargout > 1 if nargout > 2 sig = 1./(1+exp(-yXw)); g = -X.'*(y.*(1-sig)); else %g = -X.'*(y./(1+exp(yX...
a5d5d36256273bb18cbd81eea4c884dded6d1bd11273536c2ab3522d7d42ffb2
MATLAB
679
27
function Snirf2Nirs(rootdir, options) if ~exist('rootdir','var') rootdir = pwd; end if ~exist('options','var') options = 'sort'; end rootdir = filesepStandard(rootdir); files = DataFilesClass(rootdir, 'snirf'); files = files.files; for ii = 1:length(files) if files(ii).IsDir() continue end f...
02d2eb3203033c1da162c59519a92d2d814868cb1c0917bb9aa7ff974424ee0f
MATLAB
680
30
function [gap, res, fmt] = detGap(actigraphy, epoch) %DETGAP detection gap % % GAP = DETGAP(ACTIGRAPHY, EPOCH) detects gaps in ACTIGRAPHY with epoch % length EPOCH second % % $Author: Peng Li % minDuration = 60 / epoch * 60 * 2; gapseries = actigraphy <= 0; if any(gapseries) gap = ...
4d98bc8c4a3f59c315b355a22ea8231e059d95c56064608de8c51bf5f56c46be
MATLAB
680
34
% y = Filter0(b, x) % % filters x with a fir filter so it has zero phase, i.e. shifts the % filtered signal to the right half of the length of b. % % for now it zero pads the original signal % later it might also do reflecton boundary conditions. % % be careful about the order of b! % for even filters it is not exact ...
e4968303fe8242e63155c18472daf691082b6cf06402f3d02f585bb29284f7bf
MATLAB
680
24
const char * UnityAdsCopyString(const char * string) { char * copy = (char *)malloc(strlen(string) + 1); strcpy(copy, string); return copy; } /** * Returns the size of an Il2CppString */ size_t Il2CppStringLen(const ushort* str) { const ushort* start = str; while (*str) ++str; return str - st...
273278c3784a872c3fb3dc212f7a17ea2f7dcc0fdb71f5fa7276d2b9acebc5bf
MATLAB
681
26
function [y] = cellvecmult(x, v) % [Y]= CELLVECMULT(X, V) - multiply vectors in cell-array V % to all rows or columns of each matrix in cell-array X % V can be a vector or a cell-array of vectors nx = size(x); if ~iscell(x) || length(nx)>2 || all(nx>1) error('incorrect input for cellvecmult'); end if ~iscell(v) ...
da136e88fd93ec92ff50fffaf407d2760fd7d37e2dbd0d8c5f20ec1b42539c4c
MATLAB
683
28
function bool = CheckTS(varargin) % bool = [c]tsd/CheckTS(X0, X1, X2, ...) % % checks to make sure that all timestamps are identical for all tsds included. % works with combinations of ctsd and tsd % ADR 1998 % version L4.0 % status: PROMOTED adrlib; R0 = Range(varargin{1},'ts'); for iX = 2:length(varargin) R1 =...
710ac2748145d9533d226702326d669aedefb0f5356cf5bf1dcc3d587e6b1b54
MATLAB
684
27
function mags = gtmmag(net, latent_data) %GTMMAG Magnification factors for a GTM % % Description % MAGS = GTMMAG(NET, LATENTDATA) takes a GTM structure NET, and % computes the magnification factors for each point the latent space % contained in LATENTDATA. % % See also % GTM, GTMPOST, GTMLMEAN % % Copyright (c) Ian T...
332db7f98c48591d6a0c1c86e35506cffdb744b926fd124062cf994aaff5671e
MATLAB
685
21
function [tracks,keepTracks] = initializeTracks() % create an empty array of tracks tracks = struct(... 'id', {}, ... 'bbox', {}, ... 'kalmanFilter', {}, ... 'age', {}, ... 'totalVisibleCount', {}, ... 'consecutiveInvisibleCount...
5b24f0d2c55fc0dce242360d99746ae42e822e9d620ffe1322958f469449023c
MATLAB
685
22
function [] = dispf(varargin) % Like calling disp(sprintf(X)), or fprintf('...\n') % % function [] = dispf(...) % License: %===================================================================== % % This is part of the Princeton MVPA toolbox, released under % the GPL. See http://www.csbmb.princeton.edu/mvpa ...
9ce1885b3901f529e39196a35f9fc3358b4162def8eaac3cb82e270c45c69a59
MATLAB
685
26
function [fpath,fname,suffix,fext] = tdt_fileparts(fullfname) % This function is like fileparts, but with a third output suffix which is % important for AFNI (e.g. +orig). If no + exists in the filename, suffix % will be empty. % Martin Hebart 16/07/06 % History: % 2017-02-05: replaced strsplit with regexp for downw...
00393604f2b4ba69334e383c2b2bccb13b7d0fbe70504c839ed946ad929f952a
MATLAB
686
26
function [post, a] = gtmpost(net, data) %GTMPOST Latent space responsibility for data in a GTM. % % Description % POST = GTMPOST(NET, DATA) takes a GTM structure NET, and computes % the responsibility at each latent space sample point NET.X for each % data point in DATA. % % [POST, A] = GTMPOST(NET, DATA) also return...
0e040e45498dfd0887b9708571e1fa5cc7ed07e0238560b9191836c1b01bdcf4
MATLAB
686
27
prompt='Enter path: ' path=input(prompt,'s'); path=strcat(path,'\') prompt='Enter filename: ' filename=input(prompt,'s'); file=strcat(path,filename); [header,Aout,imgInfo,rawStream] = scanimage.util.opentif(file); %frameTimestamps_sec=header.frameTimestamps_sec; starttime=string(datetime(header.epoch{...
999194afe9682523dd5e3617e914d8869d7d05cdb6a9498ed28fa1bf9eddd105
MATLAB
686
22
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Authors : CHATENET Louis % Date : 24/05/2018 % Version : V1.0 % % Description : AMPA current calculation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [Isyn, r, T] = IsynAMPA(dt, Vpre, Vpost, rpre) ...
0c027757c049d58a9303a6792ccf06f771bb71089afc230febf8ca5695d44aca
MATLAB
687
36
function s = vertcat(a, b, varargin); % Vertical concatenation of TS objects (overload of the [a; b] operator) % % USAGE: % % s = vertcat(a, b) % % INPUTS: % % a, b (and eventually as many other ts as needed): TS objects % % OUTPUTS: % % s: the concatenated TS object % % copyright (c) 2004 Francesco P. Battag...
9da95369954913c96ffa516940c4ad465a3d423e80ddf8373c9c176674e08d45
MATLAB
687
31
function [n,J] = dyadlength(x) % dyadlength -- Find length and dyadic length of array % Usage % [n,J] = dyadlength(x) % Inputs % x array of length n = 2^J (hopefully) % Outputs % n length(x) % J least power of two greater than n % % Side Effects % A warning is issued if n is not a power of 2...
335b326d0060958141a09fe323823b0752757e38d2241a13d17dbe780e74d147
MATLAB
688
38
function pf = sx_fx_perf_ftr(Feature,data) %%%% a simple function to compute conjunction (mixed) and per-fearture %%%% performance (i.e. probability correct) global data ProbCorr=[]; for i=1:size(data,1) OS=data(i,1); CS=data(i,2); Tru_C=data(i,3); Sb_C=data(i,4); rew_t=data(i,end)...
8b729ade7278b57b9a77a36a40471eae71f997b799ea6a7fa44c2c5f7dbe54fd
MATLAB
688
19
function out = RenormalizeImageStacks(input, varargin) input = double(input); [l, w] = size(input); if isempty(varargin) minMat = min(min(input, [], 1), [], 2); maxMat = max(max(input, [], 1), [], 2); out = (input - repmat(minMat, [l, w, 1]))./(repmat(maxMat - minMat, [l, w, 1])); else minMat = zeros(1,...
aa951177872eadc77341f79765a737383e1f010818a97a1fe445dd884f7c0dc6
MATLAB
688
28
function tsa = ts(t, varargin) % Constructor of TS object % A TS object represents a time series of events. It is a subclass of tsd, with empty Data, reimplements only the Data % function, for compatibility issues. % % USAGE % ts = ts(t) % % INPUTS: % t: a sorted (in ascending order) vertical vector of timesta...
3d5fa2b2123d3278ce7acd5b396567155bb221a416f6919c810718e0a806a45d
MATLAB
689
26
function [cellx_spchecked] = check_spiking(binActivity,CellDif,explap,ObjBin) %CHECK_SPIKING ´Ë´¦ÏÔʾÓйش˺¯ÊýµÄÕªÒª % ´Ë´¦ÏÔʾÏêϸ˵Ã÷ neuronBinLapS = binActivity.neuronBinLapS; neuronBinL = CellDif.neuronBinL; cellX1 = CellDif.cellXid; n1 = numel(explap.explap1); cellx_spchecked = []; for j = 1:numel(ce...
d120203f0f5e8af8ca39885bd3124260bd2afd185300910e245185002b1fa4ef
MATLAB
689
20
%Calculates significance value using repeated shuffling of trials. %2024/02/25 function p_value=pval_randomshuffle(two_col_vector,num_shuffles) x=0; for i=1:num_shuffles %for number of shufflings %randomize trials conditions temp=two_col_vector(:); temp=temp(randperm(length(temp))); ...
b5288aa3780bed5e7520b95bc83181337c565609e828c6d54496c7ba0c7edbbc
MATLAB
690
31
function awsSetRegion(newRegion, level) %This function sets the active region used by AWS %For the meaning of levels see awsSetCredentials if ~exist('level','var') level = 0; end %Set environment varible setenv('AWS_REGION', newRegion); if (level > 0) %Set for CLI %Create a temporary f...
c096cf326d54d26775cda18189dea24cb6bc4a5e93213f24f6d7efb35df5f38f
MATLAB
690
32
% firFreqs frequencies from fir filter % 04-apr-13 ES function freqs = firFreqs( hBP, Fs ) if isa( hBP, 'numeric' ) hBP{ 1 } = hBP; end nfBins = length( hBP ); T = zeros( nfBins, 1 ); for i = 1 : nfBins ah = abs( hBP{ i } ); minval = max( ah ) / 2; iStart = max( find( ah > minval, 1, 'first'...
6b0e15254d2b1b1b10307b06592755b15a7ae2960594c92e9cd7941e4770ba96
MATLAB
691
19
function compareOutputs_subjs(group_h2, group_h3, type) prec = -10; if isempty(group_h2) || isempty(group_h3) return; end for qq=1:length(group_h3.group.subjs) yavg_h2 = eval( sprintf('group_h2.group.subjs(qq).procResult.%s;', type) ); yavg_h3 = eval( sprintf('group_h3.group.subjs(qq).procStream.output.%s;...
0e0e6d2d45cc75ad8840f1c0f24ed08103f197d5f88d8c1d893a1e60363b278e
MATLAB
692
36
function [errmsgs warnmsgs] = unit_volumize_pattern() % Tests VOLUMIZE_PATTERN % % [ERRMSGS WARNMSGS] = UNIT_VOLUMIZE_PATTERN() % % Assumes you've run the confirm_number_of_voxels % function built in to volumize_pattern errmsgs = {}; warnmsgs = {}; nVox = 10; nTimepoints = 20; pat = rand(nVox,nTimepoints); vol_len...
6bc17a8605bc7055d0095d54aeae4b644d53137fa45808625a6c970fd305e9a5
MATLAB
692
19
% output = transres_other_meandist(decoding_out, varargin) % % This function averages other output that was generated across decoding % steps (in the field decoding_out.opt), but works only if this other % output is numerical. This is useful if you have a similarity matrix per % cross-validation step and want to avera...
82995130978b293be119a1c35c3d682114effd55bf23b94529f4f3efe9661c0b
MATLAB
692
29
function [data,dim] = yOCTFromMat (filepath) %This function loads a mat file if it is in the cloud or on local %directory. Opposit of yOCT2Mat %OUTPUTS: % data - data saved from tif % dim - dimention structure, if present as meta data %% Do we need AWS? if (awsIsAWSPath(filepath)) %Load Data from AWS ...
f1be12172af4a83195c98b9229e40826d207c6e1931e00b999f0d847091b3d58
MATLAB
692
24
function r_i = computeFRatEtaEpsVal(eta_val, eps_val, J_i) n_neur = length(J_i); % J_i = randn(n_neur, 1); prob_s_fun = @(h, J1) 1./(1 + exp(eta_val*J1*h + eps_val)); %% Compute, for fixed eta, epsilon, J, h_MLE and SE_h_MLE as h_true varies. % fixed parameters % h_true_vals = linspa...
8949c4fc1a24515629cdf49af6432ef913c78eac2dc526e9a48cf33ffa44eba9
MATLAB
695
18
function b_pdf = binopdf_approx(n, T, p) % shape variables rep_n = repmat(reshape(n, numel(n), 1), 1, numel(p)); rep_p = repmat(reshape(p, 1, numel(p)), numel(n), 1); b_pdf = 0*rep_p; % condition for normal approximation to be good n_a_inds = rep_n > 9*(1 - rep_p)./rep_p & rep_n > 9*(rep_p...
95b4ecb32f2b60e01ccf8608a5ee8f13b812f59b5c78b9526723ffae14768f15
MATLAB
697
18
% This file is part of the Matlab Toolbox for Dimensionality Reduction v0.7.2b. % The toolbox can be obtained from http://homepage.tudelft.nl/19j49 % You are free to use, change, or redistribute this code in any way you % want for non-commercial purposes. However, it is appreciated if you % maintain the name of th...
d314c55953222b18741f15dce15dfe6b8d9b7463fe177aff4c42abbb3bb9e94d
MATLAB
697
23
function [allTracks,fileName,obj] = motionTracking(MinSize,MaxSize,bkgProb,MotionThresh,vid,roi) obj = setupSystemObjects(MinSize,MaxSize,bkgProb,vid); fileName = obj.reader.Name; [tracks,keepTracks] = initializeTracks(); % Create an empty array of tracks. nextId = 1; % ID of the next track % Detect moving objects, and...
8da181513670f69a40e312b96a7b5fb1abe36ae7c55d0c85de23f8c9e492591c
MATLAB
698
24
function [roi_data, roi_mask] = load_fmri(sub_id, p) roi_data = []; roi_mask = []; % Load fMRI data sub_str = num2str(sub_id,'%02i'); data_dir = fullfile(p.dirs.data, 'analysis', ['sub-' sub_str], 'fmri'); data_file = fullfile(data_dir, ['fmri_' p.psvr.roi '.mat']); if exist(data_file, 'file') % Load ROI data ...
f930c48c128a834ca6dda06d7163beb26539800ec3ced07384939e146d4c17af
MATLAB
698
23
function varargout = read_image(software,varargin) % function varargout = read_image(software,varargin) % IN % software: String with software to read header in cfg.software (e.g. 'SPM8') % varargin: header (struct variable generated with read_header) and % potentially more % % OUT % im...
e31a0a291a34c96c72f7be775ae989e3d357f1898828e611e7df0b6d49a57ca5
MATLAB
699
26
function [v,V]=tangvelocity(A,sigma) % TANGVELOCITY: calculates the tangential velocity from position data % Synopsis % [v,V]=tangvelocity(A,sigma) % Description % A is a two (x,y) or three-column (x,y,z) matrix of position data % if sigma is given, the data will be smoothed with % a gaussian kernel (SD=sigma) % ...
2ba0e042cb38fee81c28e0ca5528caeed81d4e38f5c804c6947dbe4a8228e5ec
MATLAB
700
20
function varargout = read_image_spm12(varargin) % read_image: % input: header (struct variable generated with read_header) % output: image in neurological space (left = left, view from top) hdr = varargin{1}; if nargin >= 2 % if subvolumes in 4D file should be selected if any(varargin{2}>s...
8e6cefaeda621c9431a90e606cb316ba36502d65ae7624135456d62bb15f4dda
MATLAB
700
20
function varargout = read_image_spm8b(varargin) % read_image: % input: header (struct variable generated with read_header) % output: image in neurological space (left = left, view from top) hdr = varargin{1}; if nargin >= 2 % if subvolumes in 4D file should be selected if any(varargin{2}>s...
b10d58e4b8a62bbd49b281a2739b91e523f4523dc8982622c1298c05a3b6b61f
MATLAB
700
24
function [Idx, minid] = kmeancluster(X, distType) if nargin == 1 distType = 'sqeuclidean'; end nIter = 20; nX = size(X, 1); nd = size(X, 2); maxk = round(sqrt(nX)*10); maxk = min([maxk 200]); kranges = 1:1:maxk; for k = 1:length(kranges) [idx, C, sumd] = kmeans(X, kranges(k), 'Distance', distType, 'R...
34bbe1369b571e216e914a3f297f90963b840165358e8521b76f92563fb5c1de
MATLAB
701
24
function [r,p_val] = NB_corr_with_prev_outcome... (data,raster_params,directions,ind) spikes =[]; RTs =[]; boolFail = [data.trials.fail] | ~[data.trials.previous_completed]; boolFail(1) = true; [~,match_d] = getDirections (data); % substract RT average in direction to reduce directional variance for d = 1:length(...
c58ed0dda892d619f08a12fd4b2d5808c37ec6bc5bfd39998bdb7f473a4d2b0c
MATLAB
701
30
function [x, Y, E] = fss_sim_generate_data(v, t) % 1. Generate labels x = MD_unirnd(0, 2*pi, t); % 2. Generate data L = gamrnd(2,2,[1 v]); % tuning smoothness prec = 1; % prediction precision x0 = [(prec/180)*pi:(prec/180)*pi:2*pi]'; Yt = zeros(numel(x0),v); for i = 1:v K0 = ME_GPR_...
46f493c9a9ca68a9741ae409b4e7400feb75d119160a4f9360c13afc0e67c17f
MATLAB
702
25
%kl = klgamma(pa,pb,qa,qb); % %Calculates KL(P||Q) where P and Q are Gamma distributions with %parameters {pa,pb} and {qa,qb}. % % KL(P||Q) = \int d\pi P(\pi) ln { P(\pi) / Q(\pi) }. % %This routine handles factorised P distributions, if their parameters %are specified multiply in either 'pa' or 'pb', as elements of a ...
261e5597065f9c52db29bfadc0e6ab356504a9e35c2f1d2faf4c203a2053c0e7
MATLAB
703
30
function A=movload(fname) % movload: loads a mov file, parsed into single trials % checks for consequtive numbering of the trials % and warns if trials are missing or out of order % Synopsis % M=movload(fname) % Description % fname: filename fid=fopen(fname,'rt'); if (fid==-1) error(sprint...
8233d8ed2ac482d2f44a8f1a58f9cc0cfabac7c521a3524e98979d2d14d015ad
MATLAB
703
37
function pv=plot_SignificantMark(X1,X2,Y,Txt_dist,pVal) %plot_pValLine pv=plot([X1 X2],[Y Y],'k','linewidth',2); hold on; th=.002; %% change to adjust significant mark level on the line ns=0; p=pVal; if p>.05 ns=1; mark='n.s.'; Txt_dist=Txt_dist*.8; th=th*6; elseif p<=.05 & p>.01 ...
84bfbd0e0b6b6aa2c5766578fdc172f7e34a27f47bf220d1132c29510593a552
MATLAB
703
27
function O = find(tsa, find_string) % Selects points in a TSD object based on conditions % % USAGE: % O = find(tsa, find_string) % % INPUTS: % tsa - a tsd object % find_string - a string that represent a condition, in which the data is % substituted by the symbol 'Td', and the timestamps %...
a86b767b82469cb74d977f669286d58fd2f44b1a7afa7af1815a9b3c37afac3e
MATLAB
703
20
function varargout = read_image_spm8(varargin) % read_image: % input: header (struct variable generated with read_header) % output: image in neurological space (left = left, view from top) hdr = varargin{1}; if nargin >= 2 % if subvolumes in 4D file should be selected if any(varargin{2}>si...
fd97a868562b2f6bbd7e85e84fc7d1e0e90815411e30609af0a13c6c7a68012d
MATLAB
703
29
function varargout = read_image_afni(varargin) % read_image: % input: % header (struct variable generated with read_header) % volume range (optional, starting to count at 1) % output: image in neurological space (left = left, view from top) hdrname = varargin{1}.RootName; ...
27db58ab268bf090299efbb6b6a221643669b6ee3332224c88fc78be3a3c0d05
MATLAB
705
20
function varargout = read_image_spm12b(varargin) % read_image: % input: header (struct variable generated with read_header) % output: image in neurological space (left = left, view from top) hdr = varargin{1}; if nargin >= 2 % if subvolumes in 4D file should be selected if any(varargin{2}>...
22ca88bf16c669057812f8ece981f6921dd0dd5a3e9a051d7bc30dd02b67662b
MATLAB
708
30
%clear all; addpath /comp_neuro/Software/Github/CMBHOME_github/ time_convert=1/0.02; % 1/<sampling_rate_in_ms> Xs=[];Ys=[];spk_t=[];spk_x=[];spk_y=[]; fprintf("Using T:%d C:%d\n",tetrodes(file_number),cells(file_number)); % load file load(filenames(file_number)); % load epoch root.epoch=lightON; % load cell root.cel...
be87cfe486346fbebaf0c28aa261aa607e7765832f6c59a2b00d2a6285416354
MATLAB
708
21
function [t] = titlef(varargin) % Like calling title(sprintf(X),'Interpreter','None') % % This is just a shortcut for plotting graphs. % License: %===================================================================== % % This is part of the Princeton MVPA toolbox, released under % the GPL. See http://www.csbmb.prince...
629b2e8c863125b65689f94b6d4a7e522eaddf2bc280481cf51f737917bac97f
MATLAB
709
36
function Y = geninv(G) % Returns the Moore-Penrose inverse of the argument % Transpose if m < n [m,n]=size(G); transpose=false; if m<n transpose=true; A=G*G'; n=m; else A=G'*G; end % Full rank Cholesky factorization of A dA=diag(A); tol= min(dA(dA>0))*1e-9; L=zeros(size(A)); r=0; for k=1:n r=r+1; ...
1f850548f5a9d44df2519addde3110336f1a8e2ca9894789abe34d0c68f08108
MATLAB
710
25
function [errmsgs warnmsgs] = test_extent() errmsgs = {}; warnmsgs = {}; fakedata = zeros(10,10,10); fakedata(1,2,2) = 1; % size 1 fakedata(1,2,4:5) = 1; % size 2 fakedata(1,2,7:9) = 1; % size 3 fakedata(3,2:3,2:3) = 1; % size 4 fakedata(3:4,5:6,5:6) = 1; % size 8 fakedata(6:9,1:4,4:8) = 1; % size 80 subj = init_su...
3195b331c887c84006c38b756e1ea34fe14455c75cad5110e6b3a795cbf6a56a
MATLAB
711
21
% find connectivity thresh=.001;%.002; %weights=readmatrix('/home/nmsutton/Dropbox/CompNeuro/gmu/research/sim_project/code/gc_can_1/scripts/generate_params/synapse_weights.csv'); weights=readmatrix('/home/nmsutton/Dropbox/CompNeuro/gmu/research/sim_project/code/gc_can_1/data/synapse_weights.csv'); %tot_conn=find(weig...
c835b79473ec6f8e868971614b7a767638659a04bf5f4c842998ec7528e1bec6
MATLAB
712
17
function [ YVal_LAremoved ] = RemovingLightArtifacts( YVals, start_frames, end_frames) %% RemovingLightArtifacts removes the light artifact in a fluorescence trace, given that the light artifact is the brightest thing in the t-series % YVals = the raw fluorescence trace % start_frames = # of frames to remove before ...
eed2cdb0d88f28a05181c7cad2fb878783880a2436724ec4835ef4e1de180259
MATLAB
714
32
function out = boxplotrule(x, dim, k) % BOXPLOTRULE identifies outliers according to the boxplotrule described in % Wilcox 3.13.2. It uses the ideal fourths, rather than the interquartile % range from the actual data. % % Use as: % out = boxplotrule(x, dim) % % Input arguments: % x = data matrix % dim = dimens...
1bbbc2f61ee7da96d5fa58eef70d9d4dd340c6a0d7e9e44151bf2e466c9f5e66
MATLAB
715
38
% psine pulsed sine waveform % % x = psine( n, f ) % % a psine with (n,0) is a perfect sine wave % a psine with (n,1) is a perfect pulse % a psine with (n,0.5) is a n/2 pulse flanked by an n/2 sine cut into two halfs % % all are scaled to the 0-1 range % 03-feb-13 ES function x = psine( n, f ) x = []; ...
2c4f988ff7bcbee51b3f71e18f0d3eedf609cd8668dfe6640cacd24646234d3a
MATLAB
715
36
function lt = LastTime(O, TimeUnits) % Returns last time of an intervalSet % % USAGE: % lt = LastTime(is, TimeUnits) % % INPUTS: % O - an intervalSet object % TimeUnits - a units object or the abbreviation string % % OUTPUTS: % lt - the last time of the intervalSet % copyright (c) 2004 Franc...
511ecf3c0d1951500f25c5bc1185275cc5ce81cfcb92079c584697f02184e00a
MATLAB
715
45
function [R rdw rup] = Clinear(linVar,theta) nbIterations = 1000; n = length(theta); C = cos(theta); S = sin(theta); r12 = corrcoef([linVar C]); r12 = r12(1,2); r13 = corrcoef([linVar S]); r13 = r13(1,2); r23 = corrcoef([C S]); r23 = r23(1,2); R = (r12^2+r13^2-2*r12*r13*r23)/(1-r23^2); Rrand = []; for i=1:nbIter...
35dc88bdc4f6a93578244ba297707b3988c083bd5c79e9e24447f58591491d22
MATLAB
716
30
function out = madmedianrule(x, dim, k) % MADMEDIANRULE identifies outliers according to the madmedianrule described in % Wilcox 3.13.4. % % Use as: % out = madmedianrule(x, dim, k) % % Input arguments: % x = data matrix % dim = dimension along which to operate, default: first non-singleton dimension % k ...
581509c9dd1d0ef5b41617b2b358046068f390d20feeb405bfb5bbd66f2b13ce
MATLAB
716
18
function checked = check_software_spm8b(software) if length(software)>=3 && strcmpi(software(1:3),'spm') try spm_ver = spm('ver'); catch %#ok<CTCH> error('SPM is not in your path!\nPlease add a version of SPM to your path or change cfg.software to another software') end if ~strcmpi(spm_...
b2bda9f6cb26d4e9235dcdb2f025ac141722cc7b001a2a59f3d326948ef732e0
MATLAB
716
18
function checked = check_software_spm12(software) if length(software)>=3 && strcmpi(software(1:3),'spm') try spm_ver = spm('ver'); catch %#ok<CTCH> error('SPM is not in your path!\nPlease add a version of SPM to your path or change cfg.software to another software') end if ~strcmpi(spm_...
097ab3cfa4dc16896987abf450088bb079325c14bbd846c17f6b9c45d7bacc67
MATLAB
717
19
function msBatchCleanSegments(dirName,corrThresh,distThresh,overlapThresh) %MSBATCHCELANSEGMENTS Summary of this function goes here % Detailed explanation goes here dataFolders = msBatchFindDataFolders(dirName,[]); for folderNum = 1:length(dataFolders) currentFolder = dataFolders{folderNum}; ...
371ff66d7028a5004c2ee856d8446e7abea53320eeee6eb85d9c1b5dc5c1cb81
MATLAB
717
17
function cleanupSharedLibs() submodules = parseGitSubmodulesFile(); for ii = 1:size(submodules,1) submodulepath = submodules{ii,3}; [~, submodulename] = fileparts(submodules{ii,1}); if ispathvalid_startup(submodulepath) if ispathvalid_startup([submodulename, '.old/']) fprintf('Dele...
670c18ddfa4e8badfb9f6fc006253fd11f7b0760858c8a01d400adaf20e6677e
MATLAB
717
18
function checked = check_software_spm12b(software) if length(software)>=3 && strcmpi(software(1:3),'spm') try spm_ver = spm('ver'); catch %#ok<CTCH> error('SPM is not in your path!\nPlease add a version of SPM to your path or change cfg.software to another software') end if ~strcmpi(spm...
a7fbc0e74a0ce2a1f1cc582682c187cd2da912af7bfb3510a46d665b087f2049
MATLAB
717
33
function ir = instantRate(tsa, TimeUnits) % Computes instantaneous rate as the inverse of inter-event interval % % USAGE: % ir = instantRate(tsa, TimeUnits) % % INPUTS: % tsa - a tsd object % TimeUnits - a units object or the abbreviation string % % OUTPUT: % ir - a tsd object where the data...
9bf83ba96041827cbe0cbb34bb1d276b2e11b350c8ba0f2aa68e02466690d92e
MATLAB
718
29
function [fx] = f_fictious(x,P,u,in) if VBA_isWeird (u) % e.g., 1st trial fx = x; return; end o = u(1); % opponent's last choice (o) a = u(2); % agent's last choice (a) p0_game1 = VBA_sigmoid(x(1)); % previous estimate of P(o=1|game1) eta = VBA_sigmoid(P(1)); % weight of PE % derive first-o...
abe7aca3c31759af7fb89fed610b7dbeba911a5c5494a7ad05de8271639125d6
MATLAB
718
25
function K = getK(n,epsilon) %GETK n, epsilon % Returns a coupling matrix with given characteristics. % n number of vertices within each group % epsilon coupling between groups of vertices k = length(n); % number of groups N = sum(n); % number of vertices s = size(epsilon); ...
b547fd532dece7ea26d40ded256c57e222f1d40e92ee05f6b2d4edcc63ea4bb3
MATLAB
718
24
n = size(Y,2); p = size(Y,1); s = size(Lm,2); nSubjs = length(Ycell); for ns = 1:nSubjs col = 0; logQns = []; for t = 1:s col = col + 1; kt = size(Lm{t},2); LmpsiiLm = Lm{t}'*diag(psii+eps)*Lm{t}; temp = LmpsiiLm + reshape(reshape(Lcov{t},kt*kt,p)*psii,kt,kt); tempXm = Xm{t}(:,1+(ns-1)*n/nSubjs:(ns*n/nSubjs)...
5f124eb4e2feaed4793cf3b597ca11abfca3bac5678bcce61ecba3940b1eb7e1
MATLAB
719
18
function checked = check_software_spm2(software) if length(software)>=3 && strcmpi(software(1:3),'spm') try spm_ver = spm('ver'); catch %#ok<CTCH> error('SPM is not in your path!\nPlease add a version of SPM to your path or change cfg.software to another software') end if ~strcmpi(spm_v...