sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
c6fd2b7171de3a712cffa79502e025526a1386eb0e2252d356d9cc7c427d59a9
MATLAB
1,059
34
function [subj] = remove_mat(subj,objtype,objname) % Sets the mat field of the OBJNAME of OBJTYPE to empty. % % [SUBJ] = REMOVE_MAT(SUBJ,OBJTYPE,OBJNAME) % % N.B. This doesn't change the subj.x strings. If subj.x refers to % the object that was just removed, remember to update subj.x % accordingly. % License: %======...
546a1625ec60a55f15f979ebfc9d27c598d7c32d04fedebd960344f273307c0c
MATLAB
1,060
42
function [y] = create_legendre(timepoints, N, norm) % Generates legendre polynomials of specified order. % % Usage: % % [Y] = CREATE_LEGENDRE(N, POLORT) % [Y] = CREATE_LEGENDRE(N, POLORT, NORM) % % Generates legendre polynomials of order up to POLORT with norm NORM % (default NORM 'unnorm'). Spaces the polynomial ac...
5581fe4762106fb6f1ffd7f01395acf3d6f3dc6755d96f38d2bafdb003ba20c8
MATLAB
1,060
33
function [z, sd, m] = cellzscore(x, dim, flag) % [Z, SD] = CELLZSCORE(X, DIM, FLAG) computes the zscore, across all cells in x along % the dimension dim, normalising by the total number of samples % % X should be an linear cell-array of matrices for which the size in at % least one of the dimensions should be the ...
9a4fd0750e7f22f2e0b97d9156a72acf5b1b97307d469070c0e253a4c5868973
MATLAB
1,060
26
% shuffle local features function % October 26 2022 % Amirhossein Farzmahdi function [insertion_images, fc6_selected_units_ins_res_image] = insertion_feature(nview,selected_percent,img_size,bckg,sum_maps,images,net,layer,unit) for i_view = 1:nview one_pixel = find(sum_maps{i_view}(:)); [~, sort_ind] = sort(ab...
b60ed8fde915c5fecd09c59a49e3bf0e4e1c987aeaf4c7e16efc5545ebdb77b5
MATLAB
1,060
23
% function output = transres_rsa_beta(decoding_out, chancelevel, varargin) % % Calculate a GLM using cfg.files.components.matrix as regressors and % decoding_out(cfg.design.components.index) as data. The resulting betas are % returned as output. For multiple calculations, these are faster when the % inverse of cfg.des...
2be78008bcf57e3de0b8383281bab5a3142846a0706dfc68147d408c4ed66b8a
MATLAB
1,063
34
function [status,txt] = scp(cmd, isRunAsync) % USAGE: % [status,txt] = scp([cmd, isRunAsync]) % INPUTS: % - If no inputs provided will return true or false indicating, is scp % installed on this computer. % - cmd - scp command to run. % - isRunAsync - when set to true will execute scp command and ret...
5d6094c4ad3e661fff8d27a93ada0fe99493ae235bc3383d63f8a5cad0b8da83
MATLAB
1,063
37
function [subj] = change_objgroup(subj,objtype,objnames,new_group_name) % Change group name of multiple objects at a time % % [SUBJ] = CHANGE_OBJGROUP(SUBJ,OBJTYPE,OBJNAMES,NEW_GROUP_NAME) % % This goes through each object in OBJNAMES, changing their % GROUP_NAME to NEW_GROUP_NAME % % OBJNAMES is a cell array of objec...
d8b62a98c410824f7a3ddbb087d4cb0f08822795bdead5a04effe6cc7286c594
MATLAB
1,063
50
function circleColor(M, x, y, cmap) if nargin < 5 Mcol = M; end if length(x) ~= size(M, 2) | length(y) ~= size(M,1) error('x and y should have the same length as dimensions of M'); end n = 100; l = linspace(0, 2*pi, n); th = linspace(0, 2*pi, n); r = 1; ...
b42d9d534b841350d55eabe106aef9a205e923a5a64faff85974f82e3e3ac5e1
MATLAB
1,064
29
function angle_degrees = angle_between_vectors(vector1, vector2, type) if nargin == 2 type = 'cosine'; end % Calculate the dot product of the two vectors switch type case 'cosine' dot_product = dot(vector1, vector2); % Calculate the norms of ...
238f228b825a08652169e50655c20518197065a5638c7f6258997d1f6d86f564
MATLAB
1,066
39
% 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_AO(theta,phi,l,m) scale = -1/sqrt...
0feb02f3edbef6c709b69a5bb8c595541e8a76ac5b84b6e68b8046d3db2b83da
MATLAB
1,067
36
function [g, gdata, gprior] = glmgrad(net, x, t) %GLMGRAD Evaluate gradient of error function for generalized linear model. % % Description % G = GLMGRAD(NET, X, T) takes a generalized linear model data % structure NET together with a matrix X of input vectors and a matrix % T of target vectors, and evaluates the grad...
5bc4365a0d1a94d1299d4a91fee12aa397bd6d6e4acd4bc94e5b8231435f1263
MATLAB
1,068
39
function vviq = vviq_load(p) % function vviq = vviq_load(p) % % Load data of the Vividness of Visual Imagery Questionnaire (Marks, 1975) % used for recruitment for all participnats that met the inclusion % criteria (i.e. the recruitment pool). % % Output: % - vviq: Table of questionnaire data. % % Simon Weber, swebe...
9927841bd63b11f5603180879ec872bc49208415ab526a7e43a73a7ee269227c
MATLAB
1,068
25
function model = similarity_train(labels_train,data_train,cfg) % This function passes the data for calculations of similarity carried out % in similarity_test. switch lower(cfg.decoding.method) case 'classification' % do nothing except return an data and labels as model model.vectors...
795dd3957f10842f1b7153eb01d14482af7221d5b6bb621ef16ada00e52a7877
MATLAB
1,069
45
function [mdt, n_missing] = median_dt(tsa, TimeUnits) % Find the median value of inter-event interval % % USAGE: % [mdt [, n_missing] ] = median_dt(tsa) % % Intended for tsd that are sampled at regular intervals, this function % returns the mean inter-event interval. % % INPUTS: % tsa - a ts...
48998ae4a94d980a2a54ddb3eb76bbaf158fd2d85bc08e4993846acb06a1521a
MATLAB
1,070
31
function create_schaefer1000_gifti(schaefer1000vector,name) % script to create schaefer1000 gifti files for rendering % schaefer1000vector is a 1x1000 vector with a value for each schaefer1000 region % name is the base name of the output file (without .func.gii) base='/Volumes/LASA/TBI_OpenNeuro/Shared_code/Turbulen...
9c9f922b60cb929201d10f31991156cf57ea33d7a9523b9358a38bba6258e920
MATLAB
1,071
45
function wcoef = FWT_PO(x,L,qmf) % FWT_PO -- Forward Wavelet Transform (periodized, orthogonal) % Usage % wc = FWT_PO(x,L,qmf) % Inputs % x 1-d signal; length(x) = 2^J % L Coarsest Level of V_0; L << J % qmf quadrature mirror filter (orthonormal) % Outputs % wc 1-d wavelet transform of x. %...
9bd443b1317945b733f30b18608714a8aeadfda73e1f93a435175a18724657dc
MATLAB
1,072
44
function [Merge_Trajs] = Merge_AnyTraj(Traj1, Traj2) %This will merge all of the trajectories into one cell array %ordered cell array of every trajectory numTraj1=size(Traj1,1); numTraj2=size(Traj2,1); nTraj=numTraj1 + numTraj2; Merge_Trajs=cell(nTraj); %make an empty cell array the length of %go throug...
04d3bfa388d93025712caa927a70bcf90a9475ca53de9e44e7c38c31e58f089d
MATLAB
1,073
26
if isempty(tracks) return; end invisibleForTooLong = 20; ageThreshold = 10; % Compute the fraction of the track's age for which it was visible. ages = [tracks(:).age]; totalVisibleCounts = [tracks(:).totalVisibleCount]; visibility = totalVis...
a80fe547c044241f2a459b1124f298d3c3185f51881349427ad0fea917122bc7
MATLAB
1,073
29
% Create histogram of firing rates from combined distributions. % Plot using custom bin width. % d1, d2, etc. are distributions of firing rates. bin_width = 0.4;%0.4;%0.43;%0.4;%0.3;%0.3;%0.4;%0.5;%11; fr_data3; %dc=[d1,d1,d1,d1,d1,d1,d1,d2,d3,d3,d3,d3,d3,d3,d4,d4,d4,d5,d5,d5,d5,d5,d5,d6,d6,d6]; % combined distributi...
ca54a313944be12b046da764d85a746fb8d25b3e46fb287f3afeac7d2f05a095
MATLAB
1,073
29
function [y, extra, invhess] = netevfwd(w, net, x, t, x_test, invhess) %NETEVFWD Generic forward propagation with evidence for network % % Description % [Y, EXTRA] = NETEVFWD(W, 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...
ce2e22114038b8ee691e94053b3b1d816be1d19fbe05b7d3badc6680e1bf18de
MATLAB
1,074
60
% Compare Rprop to fminunc % % Copyright (c) 2012 Roberto Calandra % $Revision: 0.55 $ %% Init funcgrad = @onehump; minfunc = 10e-6; niter = 10; p.verbosity = 0; % Increase verbosity to print something p.MaxIter = 10000; % Maximum number of iterations p.d_Obj = minfunc; p.m...
e2a0f130e3a35bc999b2ba3cee94de496c3e6ac74bbb63af41f88e3c25c3159c
MATLAB
1,074
30
function [y, extra, invhess] = rbfevfwd(net, x, t, x_test, invhess) %RBFEVFWD Forward propagation with evidence for RBF % % Description % Y = RBFEVFWD(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...
16ecbf2382bd4ef06cbdb80230e855928b5c65f27be5bf44a5ca4408ba829743
MATLAB
1,078
42
function s = plus(a,b) % Overload of the + operator % % USAGE: % s = plus(a,b) % % the + operaetor is defined to return a tsd with same timestamps and % data that are the sum of the data. Returns error if timestamps of the % two object don't coincide. One of the two operands may be a scalar % copyrig...
deda30af2ab80527c2141f073a4c2827e38198efd408dc0c577a650be1bf3ca4
MATLAB
1,078
36
function [wv,g]=winvar(x,percent) % function [wv,g]=winvar(x,percent) % returns the winsorized variance of x as wv % 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 values of x, where...
f81f080b7dcbc2efd231849c70d52ab960083628ff1ed66677056a110f71e797
MATLAB
1,079
35
% Crossings = SchmittTrigger(Signal,UpThresh,DownThresh) % % finds all those points where the signal crosses UpThresh in the % upwards direction, but only for the first time after each time % it was below DownThresh function Crossings = SchmittTrigger(Signal,UpThresh,DownThresh) % this is the sort of thing that would...
9f51131086d2701bb8bafe33bcd398023f0e2037fd8fd00429665f539fc94c85
MATLAB
1,080
31
function [gx] = g_kToM_2modes(x,P,u,in) % wrapper around recursive k-ToM observation function % function [gx] = g_kToM(x,P,u,in) % A k-ToM learner bases her decision (a=1 or a=0) upon her prediction of % her opponent's next move, given the game payoff table. % IN: % - x: hidden states (see indexing in inG.indle...
590b79e0b14667e777829d0c8c79703f0e63ed857a709a2784387da1f56559cd
MATLAB
1,082
26
function isFileInSt = findFilesInST(filePaths,st,additionalFilter) % Auxilary function returning filePaths index which are of sections to % search for % INPUTS: % filePaths - cell array of filepaths to match % st - st structure of all sections % additionalFilter - vector to filter. Sections will be picked o...
083d976d9ef9aa81c3effab7eac18a696f94c3e0f8ebdb6ace0b56d715bb8c82
MATLAB
1,083
39
function [newpat] = apply_filt(pat, varargin) % Filter the run of a pattern. % % [NEWPAT] = APPLY_FILT(PAT, ...) % % Used in conjuction with apply_to_runs.m. % % Arguments: % % FILT (optional) the filter to be used. If none is provided, the % default is a box filter of size 3. % License: %===========================...
263b6fb12e5622e1ce29a5690c094f17424004091407ff6a937211068a057366
MATLAB
1,083
27
function y=fCSFpulse_Raw(targetdata,targetpath,savepath,calendar,save2) %% Save CSF pulsation metric (CSFpulse) in time course. realtargetpath = targetpath; realtargetdataq = targetdata; isDir=0; for sbjc=1:length(realtargetdataq) dataset = realtargetdataq(sbjc).name; cd([savepath '\' dataset]); ...
d15d837849db4701ab5c20230a83d1505af71a8598c403db5de9b6fc2488af8a
MATLAB
1,083
34
function [clabel,dval] = test_liblinear(cf,X) % Applies a LIBLINEAR classifier to test data and produces class labels % and decision values. % % Usage: % [labels,dval] = test_liblinear(cf,X) % %Parameters: % cf - classifier. See train_liblinear % X - [number of samples x number of features] ...
12d423e42bdab629d74af5b43fa806d59629942783e61b7d3afd71608b13d389
MATLAB
1,084
27
% script to run all. Can take up to 2-4 hours. % Preprocess nirs data for Figure 3, 4, 7 and 8. prompt = 'Warning. It'' take 1-3 days to run the whole thing. Are you sure? (Y/N)'; x = input(prompt); if strcmp(x,'Y') sbjList = {'12','13','14','15','16','19','21','22','23','24','25'}; rawDir = 'C:\Users\m...
934b1fa5285c6a87a0d924920a0bff6063195a281b318a32ef92faa1d588bcd2
MATLAB
1,084
35
function [dprime logp] = dprimestats(true_labels,predicted_labels) labels = unique(true_labels); if numel(labels)~=2 error('Number of labels must be 2.') end hits = predicted_labels == labels(1) & true_labels == labels(1); misses = predicted_labels == labels(2) & true_labels == labels(1); false_alarms ...
717e1acd0f1ca9abd6abe37722d4f29088ba1774a5b1bd0f1b2149be72a5a3ae
MATLAB
1,086
37
function varargout = DefaultArgs(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 argume...
acb8727e645219fb97f62f0a89a9bfbb29899d28f48efe9dc1e5aac60710d3ff
MATLAB
1,086
52
function O = units(inp, varargin) % O = units(quantity, unit) constructor for unit % % quantity is the physical quantity measured by unit (e.g. time, length) % and unit is the unit of meaasure % copyright (c) 2004 Francesco P. Battaglia ?M Odified by A Peyrache, 2014 % This software is released under the GNU GPL %...
27b0d6273c3eac761550048ff265a10a3d3da873ca11cd2bd5b2075b9cc7f62a
MATLAB
1,089
35
function [vectorField] = backward(vectorField) % BACKWARD Flips the direction of a given vector field % % [vectorField] = backward(vectorField) % % INPUT ARGUMENTS % vectorField - Vector field to flip % % OPTIONAL INPUT ARGUMENTS % N/A % % OUTPUT ARGUMENTS % vectorField - Flipped vector field % Copyright (c) 2012 Da...
737b18a035ccae831031d10f7561a3e466cad72ed806433ee828500d897156b8
MATLAB
1,090
40
function [planeCoeff, normalVector] = fitPlaneAndPlot_2(points) % At least 3 points if size(points, 1) < 3 || size(points, 2) ~= 3 error('Deve essere fornito un array con almeno 3 punti e dimensione Nx3.'); end % Get coordinates x, y, z x = points(:, 1); y = points(:, 2); z...
85bcfc06b8c0482daed9c81a38ffad0eb8d2f7fc59fc3bf91d86bcd43987f27b
MATLAB
1,090
32
function [SimRes] = doModel(KSD,tt,W,baseTime,modelTime,thrs,SortedStim,NDTimes) % project to PC PCs = projectPC(KSD,W); % calculate crossing time [CrossTime] = calcCrossing(PCs,tt,baseTime,modelTime,thrs); % crossing time -> respDelay (add non-decision time) respWin = 1; offset = 1; ...
c7d0b93f99b0dde1125e266f2c31501b2e64d33dbf995f61e3f90c16d25d0d91
MATLAB
1,092
39
function [ssmp] = sum(x, dim) % [S] = SUM(X, DIM) computes the sum, across all cells in x along % the dimension dim. % % X should be an linear cell-array of matrices for which the size in at % least one of the dimensions should be the same for all cells D = checkinput(x); if nargin==1 dim = find(D,1,'last'); el...
a60b6a4209f3a8009a7c19e617c93e3030b6e7dccf342a4acf46adfe385f745f
MATLAB
1,093
30
function msBatchAlignmentFFT(dirName,plotting) %MSBATCHALIGNMENT Summary of this function goes here % Detailed explanation goes here %--------- Alignment parameters ---- dataFolders = msBatchFindDataFolders(dirName,[]); for folderNum = 1:length(dataFolders) currentFolder = dataFolders{folde...
fda045c9b85563923e0dab45405402b5e9a660e1dc7a34a297fa607010b32114
MATLAB
1,093
45
function [is_pos,max_r,save_fig]=seed_tunnels_with_direction_220321(source,target,fs) % This function uses xcorr to determine the direction of spike lags to % determine if a well is ff or fb from a tunnel. This is used if a tunnel % cannot be determined from NMI but an electrode is still active. This is % to be used so...
263548f9e419f2c846ba88721af2509e58e338653f5bc225b6f60b1baa210d88
MATLAB
1,095
44
function modules = parseGitSubmodulesFile(repo) modules = cell(0,3); if ~exist('repo','var') || isempty(repo) repo = [pwd, '/']; end currdir = pwd; repo = filesepStandard_startup(repo); filename = [repo, '.gitmodules']; if ~ispathvalid_startup(filename) return; end cd(repo); fid = fopen(filename, 'rt'); str...
7995463bd922954b0d8f6df9313eec6cf8c18b06fc0edc1a1e304f95cc686565
MATLAB
1,096
37
function axh = PlotTS(TSA, varargin) opt_varargin = varargin; defined_options = dictArray({ { 'MarkerSize', {5, {'numeric'}}}, { 'Marker', {'k.', {'char'} } }, { 'Offset', {0, {'numeric'} } }, ...
3f4afa5c1ab3ad54ef6cf474cd17a2c5152fe8f2f72d757ccef52f29c30f5b39
MATLAB
1,097
39
function [t] = iscategorical(mat) % Returns true if the matrix is a categorical regressors matrix. % % [T] = ISCATEGORICAL(MAT) % % This function will eventually replace CHECK_1OFN_REGRESSORS in % in a future MVPA release. % License: %===================================================================== % % This is p...
b1edaf1bebb53eb822c2b81d17351d29a8d481a19a5b4a116eefbbe9abc17de8
MATLAB
1,098
36
function [perfmet] = perfmet_template(acts,targs,scratchpad,args) % This is the template perfmet function for creating your own % % [PERFMET] = PERFMET_TEMPLATE(ACTS,TARGS,SCRATCHPAD,ARGS) % License: %===================================================================== % % This is part of the Princeton MVPA toolbox,...
c902f68d9cfcd5db976bfc8bda81c401719b4bbef2ffe6717efd262dbdcca34b
MATLAB
1,098
51
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % use linear regression to fit the 'slope', i.e. noise scaling needed to % get the coh0 and coh aligned function [a,r,m,n] = fitslope(x,y) xorig = x; x = abs(x); y = abs(y); %[t1, t2] = percthreshold(x, 0.5, 1, 0); %t1 = prctile(x, 95); if...
2d5a8e5124c106e5eecce35bc7de0a8bc835c8882b4b5f743e682838606c72fc
MATLAB
1,099
22
%Fetches unique subject IDs for various experiments. function [subjectIDs,sessions]=fetch_flicker_subjectIDs(root_dir,task_name) metadata_tbl=readtable([root_dir '/FlickerStudyMetadata.xlsx'],'Sheet','Sessions','PreserveVariableNames',1); metadata_tbl=metadata_tbl(:,{'Subject_ID','Experiment','Session','Sessio...
98c7c523063616c112648796d999097bd090fcdec42ed495bbed260abf8776b1
MATLAB
1,100
28
function h_MLE_pars = compute_hMLEpars_forsim(h_vals, prob_s_fun, J_i, eta_val, eps_val, n_obs) % simulates the system H = eta_val*J_i*h*s_i + eps_val*s_i, drawing n_obs % samples for the "true" h values provided in h_vals. From samples, % computes the MLE parameters (estimate and SE of estimate). % prob_s_fun is (1 +...
91f14e2bfd3d4a6ff649e9f2f774b77fbe498646ab73a6e7d3c6082e2e6bc630
MATLAB
1,101
51
function S = timeDeriv(tsa, varargin) % TimeDerivative of a tsd % % USAGE: % S = timeDeriv(tsa, OptionName, OptionValue, ...) % % This is intended for continuously sampled tsd-s, % If there are some missing values, they are interpolated before smoothing % % INPUTS: % tsa - a tsd object % % ...
4ebbeeb44755e7dd79f4471e61c53bcc3d49e3dbb65de7ec257bd26c78de4fa2
MATLAB
1,102
26
function [ t1, t2, t3 ] = PointsMaxCurvature_4CoE( Coefficients ) %% PointsMaxCurvature Find the frames of maximum curvature for a trace fit %with a sigmoid curve (see createFit_sigmoid20210816) as described in %Fedchyshyn and Wang, 2007. JPhysiology 581.2(581-602) % Set the fourth derivative of the sigmoid equat...
c695f36152ddada0bc9bad481c7047fc3d71a96630d23e108b533fa72787cc2a
MATLAB
1,102
21
function decoding_out = lda_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 'classificatio...
08b4f32d2ab1fa57442f4da92deb26437383533427fbb3408eae52adac3a1321
MATLAB
1,103
44
function s = minus(a,b) % Overload of the - operator % % USAGE: % s = minus(a,b) % % % the - operator is defined to return a tsd with same timestamps and % data that are the difference of the data. Returns error if timestamps of the % two object don't coincide. One of the two operands may be a scalar ...
321c8857eaabe4417f25b71f7e1ba298075704b6fda1da54d73698d1a2525d78
MATLAB
1,103
26
function [ave_sizes, se_sizes, dur_bins, num_obs] = calculateAveSizeByDuration(sizes, durations) % Calculates the average avalanche size by duration of avalanche. Allows % creating duration bins larger than 1 (default dur_bin_size is 1). The % min_obs_cutoff drops all duration bins with fewer than the specified % numbe...
6fe93a15da47406cd3abcc9b81892299dd3e048d752f6555c59d25c7a06683e7
MATLAB
1,103
60
function B = subsref(A, S) % overload of operator {} for element referencing. if subscripts are % numieric, the correspondign elements of the array are returned, if % subscript is a string, all the tsd's are returned that contain that % string in their name % copyright (c) 2004 Francesco P. Battaglia % This softwar...
c63d6af62b14f424663f07377c7d6011db156d2b19beffeb43e27afafe151996
MATLAB
1,104
42
ndip = 20; snr = [0.6 0.5]; snr2 = 0.8; amp = [0.7 0.8];%[0 0.2 0.3 0.4 0.5 0.6];%[0.2 0.4 0.6]; phs = 2.*pi.*[1/17 2/17 4/17 8/17]; patchsigma = 0; N = 200; state = rng; %state = output.state; for i0 = 1:100 for i1 = 1:numel(ndip) for i2 = 1:numel(snr) for i3 = 1:numel(snr2) for i4 = 1:numel(amp) ...
288d0c85ee347ff30d89a960fd994b14ecf3bbc301d3e10e4c0f621532ff514d
MATLAB
1,105
57
function [amp, phase, offset, rsquare, residuals, stdresid, trace] =... fitsine(time, data, freq, const,ploton) % [amp, phase (deg), rsquare, residuals, stdresid] = fitsine(time/dt, data, freq, const, ploton) %% Parameters if ~exist('const','var') || isempty(const) const = 1; end if ~exist('ploton','var') ...
2e36af5996baee4e18a00381f467592a153e408c6ee3c8f01ce618b21776d598
MATLAB
1,105
58
function tsv = SnirfFile2Tsv(src, dst, options) tsv = {}; % Parse args if nargin==0 return end if ~isa(src, 'SnirfClass') s = SnirfClass(src); else s = src; end if s.IsEmpty() s.LoadStim(s.GetFilename()); end if ~exist('dst','var') dst = ''; end if isempty(dst) dst = s.GetStimTsvFilename(); en...
5c7c4df05f7d9e76bf451bfac956bde33e9f712dda2ef40edeca4887bbe6f37a
MATLAB
1,105
46
function [syncZ,cchZ,cchP,cch,bxc] = SyncScore(t1,t2,bins) % Computes a sync score for two spike trains (i.e. the number of z-values % above the cross-correlogram when all fine temporal coordination % is removed. % % USAGE: % syncZ = SyncScore(t1,t2,bins,nbins) % % INPUTS % t1 spike tr...
dc4c4b5e37594a2af7bb74af5070052c750e0ed2c1529e441d05431bff639db5
MATLAB
1,105
26
function events = left_trim_events(events, t, duration_sec) fields = fieldnames(events); nFields = size(fields,1); for iField = 1:nFields tmp=[]; cmd = sprintf('tmp = events.%s.on_ts;',fields{iField});eval(cmd); i = find(tmp>duration_sec,1,'first'); cmd = sprintf('events.%s.o...
7075b6c02a1927b59621dc9462751a9f386a2dc58d0f28cd23e4a24dee6b2dfc
MATLAB
1,106
35
blobDataNames={'Volume','Mean Intensity','Max Intensity','Convex Envelope','X',... 'Y','Elevation','Cell length','Cell width','Cell height',... 'OX Orientation','OY Orientation','OZ Orientation',... 'Cell fine elements','Length to width ratio','Distance traveled','Solidity','Ratio of volume to eq. diamet...
169f8ab6936c9a749b5c4a4b080383b99e8d9afc294948bc1873ca3dedc2c561
MATLAB
1,110
57
function a = gaussian_app(side, dims, sigma) % A = GAUSSIAN_APP(SIDE, DIMS, SIGMA) % % Construct a Gaussian applicability. % % SIDE - Size of neighborhood along each dimension, should be odd. % DIMS - Number of signal dimensions, must be between 1 and 4. % SIGMA - Standard deviation of the Gaussian. % % Author:...
c62619d8855f3382191af5295960b3abc7f5b8b3bc47c36fe848068677ae0583
MATLAB
1,112
35
function [pmIM, alpha] = generateOverlayPhotobleachedLineOnOCT(json, y_um) %Draw photobleach lines image to be overlayed ontop of OCT %Onvert OCT image grid to original image [xx_um,zz_um] = meshgrid(... json.sectionIterationConfig.data_um.x.values, ... json.sectionIterationConfig.data_um.z.values); pmI...
4a188ac80d0c2c4f50ac1ecbcd08645062879344a4a2fe3b0715c8ac576064ab
MATLAB
1,113
55
function [S,shank] = LoadMUAData(fbasename,varargin) % Loads MUA data (cluster 1) % % USAGE: % [S,shank] = LoadMUAData(fbasename) % % INPUTS: % fbasename: file base name % % OUTPUTS: % S: tsdArray of MUA (one cell element per electrode group) % groups: electrode groups associated with each element % % OPTION: % [S,s...
4ea1235e3bc31b8101e0db00109c21fb23986bfee9dbe1ec1ff5a57926d16d9d
MATLAB
1,113
40
%function [State, hmm, decode] = gausshmm(Fet, nStates, updateOM, verbose) % train HMM software using a Gaussian observation % model of Fet. nStates - number of mixtures/states % updateOM - if to update the observation model function [State, hmm, decode] = gausshmm(Fet, varargin) [nStates, updateOM, verbose] = Default...
68a9db69655b10d7064eaa53245e62a98583139e37a0b827c6a9dfb58c79a346
MATLAB
1,113
68
function O = union(varargin) % Computes the union of intervalSet's % % USAGE: % O = union(O1, O2, ..., On) % % INPUTS: % O1, O2, ..., On - intervalSet objects % % OUTPUTS: % O - union intervalSet object % copyright (c) 2004 Francesco P. Battaglia, debugging by Adrien Peyrache 2007 % This softwar...
a77f072188024fd5653ca5ca5c2ecbd61bdee3e6a25eff80ecd5e0a96ac83cde
MATLAB
1,113
46
% videoPath = 'E:\NAS_SD\SuiviClient\Triffilieff\AnnaRoman\DataAnna_Baseline\M27322\M27322_20210709_sess4_rec3_SWE.avi'; videoPath = 'E:\NAS_SD\SuiviClient\Triffilieff\AnnaRoman\DataAnna_Baseline\Msp446\Msp446_20210721_sess9_rec2_SWE.avi'; v = VideoReader(videoPath); nFrames = 100; beginningOffset_sec = 120; interFr...
d14b7950c6eb7d9a7f4fe4c9a2f40df662574caaab841f9e55d0180915ee9e71
MATLAB
1,113
36
%% Frechet Distance calculation % Run AFTER full Block and Experiment code was run % Written by Alice Mosberger and Leslie Sibener % Version Jan 2021 % Groups are treated separately load(DataPath); %% First reorganize the data and clear unnecessary variables for g = 1:NumGroups for a = 1:Main(g).Num...
0f1ad2b47f6cb1b0387bc3d23db915ad4d4d6a3aef88ab3e41a9f8088be6c2b2
MATLAB
1,114
39
function [isthere] = exist_objsubfield(subj,objtype,objname,fieldname,subfieldname) % Checks whether the subfield exists % % [ISTHERE] = EXIST_SUBFIELD(SUBJ,OBJTYPE,OBJNAME,FIELDNAME,SUBFIELDNAME) % % Checks whether the SUBFIELDNAME exists inside the FIELD of the % object OBJNAME of OBJTYPE. % % Returns true if it doe...
14af37524511f474e7459054b02ebc5457a6f1273f9056cf2174b264ba324e63
MATLAB
1,114
44
function plotmat(matrix, textcolour, gridcolour, fontsize) %PLOTMAT Display a matrix. % % Description % PLOTMAT(MATRIX, TEXTCOLOUR, GRIDCOLOUR, FONTSIZE) displays the matrix % MATRIX on the current figure. The TEXTCOLOUR and GRIDCOLOUR % arguments control the colours of the numbers and grid labels % respectively and s...
2e5935050724d078d84313e883de82f35edec415aa1d19f68f4b31c98544f929
MATLAB
1,114
31
function [clabel,dval,prob] = test_lda(cf,X) % Applies an LDA classifier to test data and produces class labels, % decision values, and posterior probabilities. % % Usage: % [clabel,dval] = test_lda(cf,X) % %Parameters: % cf - struct describing the classifier obtained from training % dat...
1ff6aac43cd7992c3f12b6d11a2067bd4e291ec3ff517efec0486bc2ba4d8c5d
MATLAB
1,115
29
% reshape index from (chn x cond x conc) to just chn % mlList is list of all (chn x cond x cond) and can be found in dcAvg.measurementList % given list of chn index, find all conditions and conc belonging to chn % list. % mlList increase conc first, next increase chn, next increase cond function [reshapeIdx] = reshape...
ed84477aaef4340dadc07efabfeae0c2c2e5132a803c8734399601434662036c
MATLAB
1,115
42
function DistributionWholeImage(exportFolder, fileExportFolder, fileParams, flowDistParams) %% Import Parameters % File Parameters thetaInDegrees = fileParams.thetaInDegrees; thetaInRadians = fileParams.thetaInRadians; % Figure Parameters dataBinWidth = flowDistParams.dataBinWidth; %% Load Files % Main Analysis Ima...
05cc23dd357440910698615c172e51e2d28703e7bb102f623bf19a047f9b330c
MATLAB
1,116
43
function net = rbfunpak(net, w) %RBFUNPAK Separates a vector of RBF weights into its components. % % Description % NET = RBFUNPAK(NET, W) takes an RBF network data structure NET and a % weight vector W, and returns a network data structure identical to % the input network, except that the centres C, the widths WI, the...
91f23a15241a42533195528727ab7f6f0226fe69b6c6babe4e91b733f32d664c
MATLAB
1,116
34
function ciplot(lower,upper,x,colour) % ciplot(lower,upper) % ciplot(lower,upper,x) % ciplot(lower,upper,x,colour) % % Plots a shaded region on a graph between specified lower and upper confidence intervals (L and U). % l and u must be vectors of the same length. % Uses the 'fill' function, not 'ar...
b4152559580d9314543cfebe5e4b67b6a1f410ca09a591afa2d30fc43ff78307
MATLAB
1,116
60
%% This script generates panels of figures from source data % Please make sure the folder "Data" from the source data is extracted % directly at the root directory of the github code, so that it contains: % github_dir\Data\ % github_dir\Data\Neuro\ % github_dir\Data\Behavior\ % etc. % and from the code repository: %...
b041ec69004eea895e904678b0ed2ceb37edc579480dba2c66c00e49daa997f0
MATLAB
1,118
32
function [subj new_regsname] = binarize_regressors(subj,old_regsname,thresh,varargin) % [SUBJ NEW_REGSNAME] = BINARIZE_REGRESSORS(SUBJ,OLD_REGSNAME,THRESH, ...) % % Takes in a regressors object, and sets all values below THRESH to 0, % and all values above THRESH to 1. % % Gets called by CONVOLVE_REGRESSORS_AFNI. % % ...
43ac2453dfff89db4677b5688f4b88a41ac1e32c1d5619c8b886d33ce3fc23f6
MATLAB
1,119
41
function [xf] = generate_target_wave( image_size, dt, T, frequency, lambda, varargin ) % *WAVE* % % GENERATE TARGET WAVE TEST DATA generates a simple test dataset for % use with the functions in WAVE % % data description: a 2d target wave % % INPUT % image si...
6de64f4b5e163cc71c8188dd28b5bb414e8745190ebd5186cf8a19a6064601f5
MATLAB
1,119
47
function [st, clu, neuronPos] = mhpSim(N, muMaxN, numSpikes, maxEig, conType, varargin) if conType == "random" if nargin == 6 Y = double(rand(N, N) < varargin{1}); Y = Y*maxEig/max(abs(eig(Y))); neuronPos = []; else disp("Error: invalid input."); return; end ...
6e00ede3273de0c069eabe4c464b8c043795ab10346fbaddc6bebde7ea4dfc7f
MATLAB
1,121
36
function net = glminit(net, prior) %GLMINIT Initialise the weights in a generalized linear model. % % Description % % NET = GLMINIT(NET, PRIOR) takes a generalized linear model NET and % sets the weights and biases by sampling from a Gaussian distribution. % If PRIOR is a scalar, then all of the parameters (weights and...
30801c074ecaa1ded3f6d1e40e960ffb3e3a16709b2b27a4cfec7037edd1ee85
MATLAB
1,123
33
function [mappedX, W, mu_X] = prewhiten(X) %PREWHITEN Performs prewhitening of a dataset X % % [X, W, mu_X] = prewhiten(X) % % Performs prewhitening of the dataset X. Prewhitening concentrates the main % variance in the data in a relatively small number of dimensions, and % removes all first-order structure from the...
9d486c2f9302a1fe71300b848a55cf016bc0dde2547ebb34fe74ecaad0676fb4
MATLAB
1,123
58
function [pval, chisq_dat, chisq_rnd, Or_list] = randomization_test(Oi, Ei, niter) %tic if ~exist('niter', 'var') niter = 1e4; end %Oi(Oi == 0) = 0.5; Ei(Ei == 0) = 0.5; Oi = round(Oi); % from Ei get pi, which is the model Oi is being compared against ntr = repmat(sum(Ei, 2)', size(Ei, 2),1)'; pi = Ei./ntr; nO...
e4b227b95cad9d6b234a050a069c2c498e506502a131a2b478399d5b7f6fdbaa
MATLAB
1,124
43
%% Plot V4 MI Firing Rate d' and bias split at cued and cue-opposite locations (histogram) %% Code loc = ["cued","opp"]; loc_flag = 1;% input('neural data at cued location or cue-opposite location: 1-cued, 2-opp: '); % loc_flag = 1 for Fig 2D, loc_flag = 2 for Fig 3B % cue epoch win_start = 500; win_end = 2500; win_s...
b0151d7e8af838638f9210e19b37387ade6cfff91e73475ecf749d7846568d95
MATLAB
1,125
29
function histologyToOCTT = knobesToTransform( ... scale_percent,rotation_deg,xTranslation_um,zTranslation_um, histologyScale_umperpix, octScale_umperpix) % For explanation about the tranformation see website: % scale_percent - negative is shrinkage % histologyScale_umperpix - size of histology image scanned, ...
b82f75c1a0bacb73e9b21a37a667f41ad4f2a9ef1cb156bf64eb08ec1cb450a1
MATLAB
1,125
44
function covf = gpcovarf(net, x1, x2) %GPCOVARF Calculate the covariance function for a Gaussian Process. % % Description % % COVF = GPCOVARF(NET, X1, X2) takes a Gaussian Process data structure % NET together with two matrices X1 and X2 of input vectors, and % computes the matrix of the covariance function values CO...
fb566c7cf75898a69de5c4132b24cd7610671a9ef5bab6886adac0f40decf043
MATLAB
1,125
37
function [tv,g]=tvar(x,percent) % function [tv]=tvar(x,percent) % Returns the estimated squared standard error of the trimmed mean of x. % x must be a vector. If x is empty, then NaN is returned. % percent must be a number between 0 and 100 % % The trimmed variance is calculated from the winsorized variance, vw, % acc...
d87ee163f1fdcda69dc9fe31a86f4cc2ffa3b418fa10f4b59d69e07542947a21
MATLAB
1,127
39
function net = mlpunpak(net, w) %MLPUNPAK Separates weights vector into weight and bias matrices. % % Description % NET = MLPUNPAK(NET, W) takes an mlp network data structure NET and a % weight vector W, and returns a network data structure identical to % the input network, except that the first-layer weight matrix W...
018a8feed7a8de1a3f1b00224f930d733c6462d9a14951b7665ba0a692b75e83
MATLAB
1,128
24
function step1 = analysis_step1(f, step1) %% LOAD DORIC DATA [step1.raw_signals, step1.dein_signals] = doric_tools.open_doric(f, step1); plot_tools.photo_plots(step1, 'deinterleaved signals'); %% LEFT TRIM TO REMOVE STRONG PHOTOBLEATCHING AT THE BEGINNING step1.left_trim_dur_sec = 15; [step1.dein_signals.time, step1....
24119cacf015934a15805a7213e7f2895e275721c3c803c0b7bda617ceda897e
MATLAB
1,130
39
% Preprocessing unit test % % demean tol = 10e-10; % Random data X = randn(145,40,20,3) - 10; % Get default parameters param = mv_get_preprocess_param('demean'); %% demean along dimension X should result in all mean = 0 for dd=1:ndims(X) param.dimension = dd; [~, Xd] = mv_preprocess_demean(param, X); m ...
b5705dffbc4b5f3d6126f625420d9a5f25e4f5f4b19a55c51279da771cde5a25
MATLAB
1,130
36
function [regs] = fake_smooth_regs(nConds, nTimepoints, noisiness) % [REGS] = FAKE_SMOOTH_REGS(NCONDS, NTIMEPOINTS, NOISINESS) % % Randomly generates nConds' worth of sine waves at roughly % the same frequency, shifted relative to one another. % % e.g. regs = fake_smooth_regs(3, 240, 0.1); % choose a random frequenc...
dd6bf072c3a58eec3bd4529203af28572237f53e5062d51c30c1d222e8f41f6c
MATLAB
1,130
66
function [err,p,f] = GetPath (s, allmc) % % [err,PathString,FileString] = GetPath (s, allmc) % %Purpose: % Breaks the string s into a path and file part % % %Input Parameters: % s is a string like How/Didley/Doo % allmc : 1 --> search for path using both types of file-separators / and \ % 0 --> ...
f8769d7d56f9f9b8f3e732253e00ca7469791115c5181fa8cc599bedfb2eded7
MATLAB
1,130
44
% % calculates the coefficient of variation metric CV2, as described in Holt et al 1996, J Neurophysiol % % ISIs are in sec and expected to be in order % % %returns: %CV2: mean CV2 over all ranges %CV2_all: CV2 for each pair of consecutive ISIs %CV2_all_diff: the difference between each consecutive ISIs, useful to calc...
84e5ec45ce900b70aab2733c0b09132f3fb23c6808063352f1048d59e0d9b1ab
MATLAB
1,133
61
function ac = compressLogicalArray(a) ac = []; if isempty(a) return; end if all(a==1) ac = [1,length(a), 1]; return end if all(a==0) ac = [1,length(a), 0]; return end k = find(a==0); kk = 1; % Generate all zero intervals for ii = 1:length(k) if ii == 1 iS = k(ii); iE = k(ii); ...
3af387ba8937cec37bed339411a32019a734f1a35cf51b897ff59b3711d2240b
MATLAB
1,134
40
function Z=module_degree_zscore(W,Ci,flag) %MODULE_DEGREE_ZSCORE Within-module degree z-score % % Z=module_degree_zscore(W,Ci,flag); % % The within-module degree z-score is a within-module version of degree % centrality. % % Inputs: W, binary/weighted, directed/undirected connection matri...
4b8896584474034958e44814453b396354465b9b114a0ecb5fab425eb03b608d
MATLAB
1,134
34
function test_suite = test_bids_query_nirs %#ok<*STOUT> try % assignment of 'localfunctions' is necessary in Matlab >= 2016 test_functions = localfunctions(); %#ok<*NASGU> catch % no problem; early Matlab versions can use initTestSuite fine end initTestSuite; end function test_bids_query_emg_basic() % ...
465b9016562dac7f8401161fc890a5c6c08541523a48ec7165b935927ea6e0c5
MATLAB
1,135
42
function DistributionWholeImageOverTime(exportFolder, fileExportFolder, fileParams, flowDistParams) %% Import Parameters % File Parameters thetaInDegrees = fileParams.thetaInDegrees; thetaInRadians = fileParams.thetaInRadians; % Figure Parameters dataBinWidth = flowDistParams.dataBinWidth; %% Load Files % Main Anal...
5c2a4849eded2fbd0916e1a824fb55ffcaa9a169f643688de75efdcf75f41e20
MATLAB
1,135
39
function [ssmp] = nansum(x, dim) % [S] = NANSUM(X, DIM) computes the sum, across all cells in x along % the dimension dim, accounting for NaNs. % % X should be an linear cell-array of matrices for which the size in at % least one of the dimensions should be the same for all cells D = checkinput(x); if nargin==1 |...
b6c09b3bf816b591f8d0af87c99831b71e20c9159104bf28f1aa23b9347e031b
MATLAB
1,135
54
function O = regularIntervals(start, stop, i_length, step, varargin); % O = regularIntervals(start, stop, length, step) returns an intervalSet % with intervals of constant length % % INPUTS: % start, stop: of the period spanned by the intervalSet (intervalSet % guaranteed to cover the period) % length: length of each...
df13727aae682bf7768a98df77853e4b377183e36264dd059123f23c1ed640a1
MATLAB
1,135
37
% zeke barger % 070419 % create a multi-taper spectrogram of EEG data % s is the spectrogram, t is the time axis, f is the frequency axis function [s, t, f] = createSpectrogram(EEG, SR, winstep) window = max([5, winstep]); params = struct; params.pad = -1; params.Fs = SR; params.fpass = [0 64]; params.tap...
64efcfd354684ec05e0371c32aadd74af1a4d22ac7fd0ce42e8753ee625c24f9
MATLAB
1,136
36
function [hh,fg,cb] = plot_vector_field( ph, varargin ) % *WAVE* % % PLOT VECTOR FIELD % % INPUT % ph - complex-valued scalar field representing vector directions % % OUTPUT % vector field plot % % checks assert( ~isreal(ph), 'complex-valued input required, ph' ) % set defaults if nargin > 1, plot_option = varargin{1...
f4c024c8aff618c316bb5e8a97941ce18bcc64cfc0c35f53735a77aafe262535
MATLAB
1,137
55
function R = regIntervals(ep,N) % Split an intervalSet object in N segments of equal length % % USAGE % R = regIntervals(ep,N) % % INPUTS: % ep: original intervalSet % N: number of desired segments % % OUTPUT: % R: a cell array of splitted intervalSet objects % copyright (c) 2004-2011 Francesc...
a144295d907c06a86c60f7efed454f9c18a43cb534949f6dbd51611bfd1636f0
MATLAB
1,138
29
function [datasetPath, datasetName] = s3GetPathToLatestDataset (imageResolution,datasetTag) % imageResolution can be '2x','4x','10x' etc % datasetTag can be additional search phrase, or can be empty (default) %% Inputs if ~exist('datasetTag','var') datasetTag = ''; end datasetTag = strtrim(datasetTag); ...