sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
5a4d88a64d3b7ff9261b15a96b222e72f8028f9bf880f69af9f87816eae27550
MATLAB
914
65
%Produce all NatureComm2024 figures' panels. %% Set dataset directory and dependent repos: [~,repo]=define_flicker_root_dir; for field_name=fieldnames(repo)' addpath(genpath(repo.(field_name{:}))); end %note: can use function fetch_flicker_subjectIDs to get list of sessions %and their details. %% clear all; clo...
996cca707e56040703efd2ea98f58e12619530b0c0e83a1c609ad32c7ccd682b
MATLAB
914
25
function [t, X] = em(f, sigma_noise, X0, T, dt, N_eq) % EM f, sigma_noise, X0, T, dt, N_eq % Euler-Maruyama method for SDEs dX = f(X) dt + sigma dW where the noise is % applied to the first N_eq equations (the first state variable of each neuron) % f drift function % sigma_noise noise coefficient...
e599cdd5c9d7a63bbfc5077e91fa59b2bd21e9289919e4a36292829f501b79eb
MATLAB
914
27
function ms = msSelectFluorThresh(ms) %MSSELECTFLUORTHRESH Summary of this function goes here % Detailed explanation goes here userInput = 'N'; while(strcmp(userInput,'N')) figure(102) clf plot(ms.minFluorescence,'y'); hold on % plot(ms.quant10Fluorescence,'m'); ...
453610d6d8fb0c666f0b2c8a979074129cb496591ab95b007d61919db872f0c5
MATLAB
915
35
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function Iexc = StimCurrentForm(Imax, t, dt, Period, DutyCycle, WaveForm) Iexc = zeros(1, length(t)); if strcmp...
cb48d83b36774137fc7580da386c6fe3bc1d65e9523b79ab53d61010d2620c6b
MATLAB
916
29
centroids1 = centroids(unassignedDetections, :); bboxes1 = bboxes(unassignedDetections, :); for i = 1:size(centroids1, 1) centroid = centroids1(i,:); bbox = bboxes1(i, :); % Create a Kalman filter object. kalmanFilter = configureKalmanFilter('C...
d91de08aa09953957456582347e590687f16ca95ffb5bb430c7f65d13aa8a5de
MATLAB
916
21
function [conds, tts, head, target, hevel, PC, sines, light] = addStep(I, conds, ... tts, head, target, hevel, PC, sines, light) % Add an ideal VORD step to enforce steady state tt_step = (1:round(I.T_step/I.dt))'*I.dt + I.T_step_start; % Step time vector step_in = I.scale_step * double(tt_step>0); step_in = filte...
92d0b108b5912cc95e94c7ef10166de2fb24348be54dbec45fd69e07f738d3ba
MATLAB
918
29
function [coords] = get_coords_from_mask(mask) % Create nVox x 3 matrix of x,y,z coordinates from mask % % [COORDS] = GET_COORDS_FROM_MASK(MASK) % % COORDS (nVox x 3) contains the x,y,z coordinate of each active voxel in the % boolean 3D mask MASK. As always, the order of the nVox % voxels is the same as that returned...
f0ee1eabcf6f01b65111564a0493b80695eeb2d9eeba2da88f6f08a8be57daa4
MATLAB
919
34
function [isthere] = exist_objfield(subj,objtype,objname,fieldname) % Checks whether the field exists % % [ISTHERE] = EXIST_FIELD(SUBJ,OBJTYPE,OBJNAME,FIELDNAME) % % Checks whether the FIELDNAME exists inside the object OBJNAME of % OBJTYPE. % % Returns true if it does, else false. % License: %=======================...
c15ba15f7347efc06ed654f76b3fde99382351492987aca275beba889a3d6d88
MATLAB
920
30
function [X] = sympad(X, pad) % Performs symmetric padding to expand signal X on both ends by n points. % % This is useful to avoid falloff when doing convolution. % X is an N x P matrix of signals. % License: %===================================================================== % % This is part of the Princeton MVPA...
d0fab5a81152e0c394370cfc9b01b1e418a386ab3e83a46477eb19b76809f63f
MATLAB
920
32
function guess=find_bpn1(sv_var,coords,C) for i=1:size(coords,1) stds(i)=std(sv_var(i).coords(:,5)); end [~, sorted_ids]=sort(stds,'descend'); guess=[]; selection=sorted_ids(1:50); num_neu=3; additional_factor=1; selection(ismember(guess(:),selection))=[]; combinations=nchoosek(selection,num_neu); qs...
03baf483df022804c6e35743b3e16922ec5e4927b7d88b965e1bc3d698457438
MATLAB
921
29
function imageArray = getColormapImageArray(height, width, colormap) temp_Array = zeros(height,width,3); switch colormap case "Greyscale" colormap_colors = gray(width); case "Turbo" colormap_colors = turbo(width); case "Hot" colormap_colors = hot(width...
14db4c1c80e84d7ecc79c26a2b18177452747d6245cd7bd097ee42b34b3dcb7c
MATLAB
921
29
function vbl = draw_missed(Experiment, flip, flipTime) % takes flipTime as additional argument to specify exact time of flip % (script waits until time is reached) Display = Experiment.Display; Stimulus = Experiment.Stimulus; pointList = Stimulus.missedTrials.pointList; pointList(:,1) = pointList(:,1)+Stimulus.shift...
b7a7144798861b7b559b7c60bc0f825e9df6274c3e77e53c07fb8288edc7589d
MATLAB
921
35
function [returnVar,msg] = RemoveDCfromSpk(fbasename,chan) % USAGE: % RemoveDCfromDat(fbasename,shankIx,chanIx) % This function removes DC from dat files by computing the average of % the first 1e6 samples (or less if file is smaller) % INPUTS: % fname: dat file name % nbChan: total number of chann...
b9f9f864680fa6edb8c69ff1afa6b56d0da4a7ef1edafc885a4a8e70ca1cf95d
MATLAB
921
36
function [Traj_cell_noTime, Traj_cell_Time, OccSum, OccSpread] = Occupancy(ptsx, ptsy, Traj, threshold) % Calculates the occupancy in X/Y for the selected trials %Traj Cell Time will be binary matrix of occupancy %Traj Cell NoTime will be matrix of 2d space, without binary switch nT=size(Traj,1); if nT == 0 ...
71d68c26d85c985bb8693cd079247db875d34ebb5567d70f1b2b75c857cddafd
MATLAB
922
24
function msBatchLinearSFR(dirName, speedThresh, binSize) %MSBATCHLINEARSFR Summary of this function goes here % Detailed explanation goes here dataFolders = msBatchFindBehavFolders(dirName,[]); for folderNum = 1:length(dataFolders) currentFolder = dataFolders{folderNum}; dirData = dir(currentF...
9fa0d616a3e86dbc4d6837da194fa35c0acd45ebd552e5b0c0c5da5572d94db5
MATLAB
922
35
% %prepare groups of trials for plotting of raster (with color info) % %indsOfGrps: cell array of list of periods (each a list of trials) % %urut/april13; initially derived from getTimestampsBubbles.m function [spikesToPlot, colortill, nrTrialsTot] = getTimestamps_forSortedRasterPlot( timestampsOfCell, indsOfGrps) spi...
f1d014fd5e515bf22a6e33f36a995e118ae8f9c4e926318ff5cd92585102fc67
MATLAB
922
41
function [thrlo, thrhi, ix] = percthreshold(x, percent, dim, outflag) % Helper function to determine the exclusive values of the % %percent percentile threshold (two-sided) used for % trimming, winsorizing etc. % % Implementation according to Wilcox; Robust Estimation % and Hypothesis Testing if nargin<4 || isempty(...
2a498114e233660507691c0051c9d6633de1d9b51c70e53063983bb4363107c8
MATLAB
923
38
function [ X ] = func_ARFIMA( n, d, eps, n_inf ) %UNTITLED31 Summary of this function goes here % Detailed explanation goes here switch nargin case 1 d = 0; eps = randn(n,1); n_inf = 100; case 2 eps = randn(n,1); n_inf = 100; case 3 n_inf = 100...
4a1c7b9606aa560eb52e7a01ec2e2076232df5ac69e566f30a61a14bde6a7c90
MATLAB
923
39
function [OutColor, OutIds, v] = GroupScatterColor(InVal, ColorMap, setrange) switch nargin case 1 nGradient = 256; Colors = jet(nGradient); setrange = []; case 2 Colors = ColorMap; nGradient = size(ColorMap, 1); setrange = []; case 3 Colors...
9f3177848442a84686af52d393c13ec3140787f135a6c6d9ca47e75a08496cd2
MATLAB
923
29
function jokes=random_json_joke(num, url) % this example shows how to use the _DataLink_ annotation defined in the % JData specification % (https://github.com/NeuroJSON/jdata/blob/master/JData_specification.md#data-referencing-and-links) % to define linked JSON/binary JSON data using external files or URL on the % web....
533ca7a841ae82e33d5d9fa4dd1878e84edcffac9388ccc4d9e12e2ccbacfdaf
MATLAB
924
23
function [err_eye, err_pc, Ehat_linear, Phat_linear] = plotLinearPredictions(S_eye, S_pc, R_eye, R_pc, Kb_eye, Kb_pc) Ehat_linear = S_eye*Kb_eye; Phat_linear = S_pc*Kb_pc; err_eye = sqrt(mean((Ehat_linear- R_eye).^2)); err_pc = sqrt(mean((Phat_linear- R_pc).^2)); tt_all = (0:length(Ehat_linear)-1); figure; subplot...
f92eabb38f6ee5caadbb94957dcf57b1b2d84efeda773b0b2eb31d2ae59ada37
MATLAB
924
22
function str_out = condenseAreas(str_in) % Remaps strings of brain areas stored in the SB NWB format to a % de-lateralized naming convension (e.g. 'amygdala_left' -> 'amygdala') % Input: A string of the lateralized brain area. % Output: A string of the de-lateralized brain area. str_mid = str_in; switch (str_mid) ...
dcbf76b505f0b229de1c748596e0d87ec032ae793ed78e543d215ddd8a1ac05d
MATLAB
925
24
function cdf_Paxm = computeCDFpowerlawdistribution(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(); ...
7f0b07ddcba10e3a5e667811406ec7b321a38558d96d460d9a0ca7da34dc75fc
MATLAB
926
24
function ms = msFluorFrameProps(ms) %MSFLOURFRAME Summary of this function goes here % Detailed explanation goes here ms.minFluorescence = nan(1,ms.numFrames); ms.meanFluorescence = nan(1,ms.numFrames); ms.maxFluorescence = nan(1,ms.numFrames); for frameNum=1:ms.numFrames frame = msReadFrame(m...
89c158964679260408de60e92b42371ad1d5dd4abd48a22f5ebdddcff389b17b
MATLAB
926
51
function s = horzcat(a, b, varargin) % Horizontal concatenation of TSD objects (overload of the [a, b] operator) % % USAGE: % % s = horzcat(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. Bat...
b417c331659a3f736379aaad60eb43e4e382648fe75047714f55450178e2f0d0
MATLAB
926
38
function [acts scratchpad] = test_svdlr(testpats,testtargs,scratchpad) % Generates predictions using a trained logistic regression model % % [ACTS SCRATCHPAD] = TEST_RIDGE(TESTPATS,TESTTARGS,SCRATCHPAD) % % License: %===================================================================== % % This is part of the Princeto...
c4d2a0a15a668607d6483f021d68af4fa8d3c6868da63110f3efbca15a136558
MATLAB
926
26
function [path] = genpathsafe(dir) % Generates paths while excluding directories that begin with a dot. % % [PATH] = GENPATHSAFE(DIR) % % Generates paths while excluding directories that begin with a % dot. This way it is possible to add source control repositories % to the path without adding tons of unnecessary paths...
faeb73163b23b7755d050099b49c7360f41c516588d38df3f559e5279280a47c
MATLAB
928
46
function input = get_input(transformer, data) % % % (C) Copyright 2022 BIDS-MATLAB developers assert(isstruct(transformer)); assert(isscalar(transformer)); verbose = true; if isfield(transformer, 'verbose') verbose = transformer.verbose; end tolerant = true; if isfield(transformer, 'tolerant...
45c062c8fa07cab68850cb0c8661f25bd2ac208ae67324808d85b697d809a3fb
MATLAB
929
45
function vec = ShapeLike(sig,proto) % ShapeLike -- Make 1-d signal with given shape % Usage % vec = ShapeLike(sig,proto) % Inputs % sig a row or column vector % proto a prototype shape (row or column vector) % Outputs % vec a vector with contents taken from sig % and same shape a...
6736b1780b0528655acfd59e693615d7252eb523296332f7645ff62a32337df9
MATLAB
931
44
function y = contrast(x,varargin) % % y = contrast(x) % makes values of y lying in the range [0 1] from the COLUMN vector % % y = contrast(x,minVal,maxVal) % 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 size(x,1)...
1935811c786a642fb95c27b4a764f9749b860b1e6dac0e657096c3acd52da64d
MATLAB
932
32
function y = ME_vMMM_sim(r, mu, ka, N) % _ % Simulate Date from a von Mises Mixture Model % FORMAT y = ME_vMMM_Sim(r, mu, ka, N) % % r - a 1 x K vector of mixture frequencies % mu - a 1 x K vector of means % ka - a 1 x K vector of precisions % % y - an N x 1 vector of response deviations % % Auth...
9840748668e37f913e9ef85e7d93e2336ba145ddeb9b20d7053abeb600b0d393
MATLAB
932
33
function [s, interval, idxs] = generateSnirfStim(obj, CondNames, nStim) if ischar(obj) s = SnirfClass(obj); s.stim = StimClass.empty(); end if ~exist('CondNames','var') CondNames = {1}; end if ~exist('nStim','var') nStim = zeros(length(CondNames),1); end if length(nStim) < length(CondNames) nStim = ...
6c36e96a43e3998b4e2e5009089e2530f82088a09e6a2e045d0996d330bedf70
MATLAB
934
28
function v=plot_zscore_violin(vectors_array,names_array,threshold) num_groups=length(vectors_array); vectors=[]; names={}; for i=1:num_groups vectors=[vectors;vectors_array{i}]; names=[names; repmat(names_array(i),[1 size(vectors_array{i},1)])']; end %note: function b...
c620d47f10bc76d110d5be81c45a1706a96475a86fc074716edbb841120ccac2
MATLAB
934
29
% function [predicted_labels decision_values opt] = ldapredict(labels,data,model) % % Predict unseen data using pre-calculated Fisher LDA. Currently, only % binary classification is implemented. % INPUT (n = n_samples, p = n_features): % labels: nx1 vector of labels of test data % data: pxn matrix of test d...
ac33743598c73614e736841b20387516463058e1bb5386bf2a18be6c1516f414
MATLAB
936
42
% [Fet, nFeatures] = LoadFet(FileName, BufSize, CluSubset) % % A simple matlab function to load a .fet file function [Fet, nFeatures] = LoadFet(FileName,varargin); [BufSize, CluSubset] = DefaultArgs(varargin,{inf, []}); Fp = fopen(FileName, 'r'); if Fp==-1 error(['Could not open file ' FileName]); end nFeatur...
1dc2823b8bd7628df8b85e882495b19e2f0f66459b221f8c72c9b2f4aa542848
MATLAB
937
54
function X = gaussFilt(X,N1,varargin) % Xsm = gaussFiltAng(X,N1) % % 1 or 2-d gaussian filtering with border correction % Input: % X: vector (or matrix) of angular values to smooth % N1: sd of gausswin for the first dimension. If N1==0, no smoothing % Output: % Xsm: smoothed matrix % % Adrien Peyrach...
e2d704f236b6912624cf558156d106914ac576d49058cb0b9264133eeac96445
MATLAB
939
24
function rearrange_data_220228(datafolder) %datafolder = "D:\Brewer lab data\HFS\Temporal Analysis\No Stim\AFR Output\"; % Rearrange data source_fb = load(datafolder+'FB_source_AFR_table.mat'); source_ff = load(datafolder+'FF_source_AFR_table.mat'); % Creating if_FF column source_ff.AFR_table.if_ff = ones(height(sourc...
395c71a80764786ca598e145ef02d6725f5c827355256cb1d670802e0b53d246
MATLAB
941
26
function FigureB_NoImages(fileExportFolder, FigureBParams, imageAshow, vxMatShowA, vyMatShowA, relMatShowA) xIdxB = FigureBParams.xIdx; yIdxB = FigureBParams.yIdx; imageBshow = cell(size(xIdxB)); vxMatShowB = cell(size(xIdxB)); vyMatShowB = cell(size(xIdxB)); relMatShowB = cell(size(xIdxB)); for i = 1:size(xIdxB, 1) ...
f29c1609af1c3e7084457a23ecc1cdfe0c227e72d31e00e78fc3ced3c77d236b
MATLAB
941
26
function msBatchMeanFrame(dirName,downsample) %MSBATCHMEANFRAME Summary of this function goes here % Detailed explanation goes here dataFolders = msBatchFindDataFolders(dirName,[]); parfor folderNum = 1:length(dataFolders) currentFolder = dataFolders{folderNum}; dirData = dir(currentFolder); ...
0af7d4b36999d854b099478dff360d6d9135e0892d81120fe342eb1d3dbec4a6
MATLAB
942
37
% scaledata.m % Hannah Payne % 12/04/2011 % % SCALEDATA % dataout = SCALEDATA(datain) scales datain to the interval [0 1] % dataout = SCALEDATA(datain, [minval, maxval]) scales to [minval maxval] % dataout = SCALEDATA(datain, minval, maxval) scales to [minval maxval] % dataout = SCALEDATA(datain, x1, x2, y1, y2...
2006fab89ff2dab62477ecc581982ea90c6323597bd9d746f231d564af62636a
MATLAB
942
29
function fh=conffig(y, t) %CONFFIG Display a confusion matrix. % % Description % CONFFIG(Y, T) displays the confusion matrix and classification % performance for the predictions mat{y} compared with the targets T. % The data is assumed to be in a 1-of-N encoding, unless there is just % one column, when it is assumed t...
9f44ecfc7afae938870f0082a320c0edb688b403e2c5671c557c34c9292421d8
MATLAB
942
40
function [vx, vy, relMat] = LKxOptFlow(I1,I2,sig,thresh) if nargin == 2 sig = 3; thresh = 0; elseif nargin == 3 thresh = 0; end sz = ceil(6*sig + 1) + mod(ceil(6*sig + 1) + 1, 2); w=fspecial('gaussian', sz, sig); I1 = double(I1); I2 = double(I2); % [dxI,dyI]=imgradientxy(I1,'central'); f = exp(-(-3*si...
ac6bba981c09cf387aaa975f3426b2c2dc140339f8e2753db2f1a139cfee74fc
MATLAB
942
42
%% Plot V4 MI Firing rates cued vs cue-opp (histogram) %% Code % cue epoch win_start = 500; win_end = 2500; win_str = num2str(win_start)+"_to_"+num2str(win_end); load(sprintf('data/V4_FR_full_%d_to_%d.mat',win_start,win_end)); monkey = ["G","B","Combined"]; metric = "MI_FR"; trial_type = "all"; bin_...
624159d3fdc65e004094307772abc550528fe20867c223db5505d76bf68ed2a1
MATLAB
944
39
function [res, fmt] = detUPMEMDperCycle(imf24, epoch, varargin) %DETUPMEMDPERCYCLE extract cycle to cycle amplitude of the ~24-h component % extracted from DETUPMEMD % % [RES, FMT] = DETUPMEMDPERCYCLE(IMF24, EPOCH, MINCYCLE) % FMT request the format to write RES to file % % $Author: Peng Li % ...
c6bba829be583891dca93f79339f9283b7f9f4de2b46ab082bf13e19671e9311
MATLAB
944
34
function pp_save(sub_id, p, model) % function pp_save(sub_id, p, model) % % Saves the 'model' structure that holds the parameters of all performed % preprocessing steps. % % Input: % - i_sub: ID of the current subject. % - p: Structure with analysis parameters. % - model: Structure with all SPM settings used dur...
dc6d3235c9eecd8af155f62f5a379370df14ed1fa70d73bab123f5e657612ea8
MATLAB
945
38
function ms = msExtractFiring(ms) %MSEXTRACTFIRING Summary of this function goes here % Detailed explanation goes here decayTime = 1; V.Ncells = 1;%ms.numSegments; V.T = ms.numFrames; V.dt = mode(diff(ms.time))/1000; V.fast_plot = 0; for segNum=1:ms.numSegments if (mod(segNum,30)==0) display(['Extracti...
7c3c6d90f1e7495ca567e452c2d3dd2fa2345dccc639472285ed07e393e913b4
MATLAB
946
51
function p = bootstraspWelchTTest(x, y) REPEATS = 10000; scores = [x,y]; labels = [zeros(size(x)),ones(size(y))]; t_real = statistic(scores,labels); t_dist = nan(1,REPEATS); for j=1:REPEATS prm = permVec(labels); t_dist(j) = statistic(scores,prm); end p = mean(abs(t_dist)>abs(t_real)); end function g...
bd6ecc60e39b3a0d0b870c58cee943fa445f4d4db8ab936f39fa15be26ca8807
MATLAB
946
29
function [subj] = statmap_glm_multiv(subj,data_patname,regsname,selname,new_map_patname,extra_arg) % much like STATMAP_SIMST_MULTIV, except using the GLM obj_funct % % [SUBJ] = STATMAP_GLM_MULTIV( ... % SUBJ,DATA_PATNAME,REGSNAME,SELNAME,NEW_MAP_PATNAME,EXTRA_ARG) % License: %====================================...
53df1a35e6e35491c03944d77b8cc5dc93e3e7cd562bf51c59095bd1e57eb46f
MATLAB
949
46
load(fullfile('Analysis','HDtuning_xval_moveEp')); hAllA = hAll1; hAllB = hAll2; hAllA_sh = hAll1_sh; hAllB_sh = hAll2_sh; [totBins,totC,totTh] = size(hAllA); %% calculate TC crosscorrs ac = nan(size(hAllA)); for nTh = 1:totTh h1 = zscore(hAllA(:,:,nTh)); h2 = zscore(hAllB(:,:,nTh))...
7f90ebe9a0ec10ac5e4c179c6be49847669f2fe44b57ae5b3f40cf21ff930533
MATLAB
950
31
function pSVR_save(sub_id, p, predictions, results, suffix) % function mtSVR_save(sub_id, p, predictions, results, suffix) % % Save final result file during ongoing analysis. Variables include: % - sub_id: ID of the current subject. % - p: Structure with analysis % parameters. % - predictions: Structure c...
abce5befb80de0db98b8bbc0e16ad93da0c4bf295277d8f802b3426c3d9940c7
MATLAB
950
40
function awsEC2TerminateInstance(ec2Instance,v) %Terminates instances %INPUTSL % - ec2Instance - instance created by awsEC2StartInstance % - v - verbose mode %% Input checks if ~exist('v','var') v = true; end origRegion = awsGetRegion(); %% Terminate the instance for i=1:length(ec2Instance) ...
2a21441f9e2e9ef53fce7944cf389b18affc2dae8a6dc1464a7c27e0b571eadb
MATLAB
951
37
% kernel unit test % % polynomial kernel tol = 10e-10; % Random data N = 10; F = 5; X = randn(N,F); X(1,:) = X(1,:) + X(2,:); % kernel parameters param = []; param.gamma = 1/F; param.coef0 = 1; param.degree = 1; %% polynomial_kernel(X) and polynomial_kernel(X,X) should yield the same result K1 = polynomial_kernel(pa...
b822194c90e4213b0df7a7d44fdabf94725c0ce2163596f47ed4a88916b0ccf3
MATLAB
951
44
function info=parse_filename(f,varargin) if isempty(varargin) info = parse_roman_filenames(f); else if strcmp(varargin{1},'Anna') info = parse_anna_filenames(f); elseif strcmp(varargin{1},'Roman') info = parse_roman_filenames(f); end end end fun...
f0ae387c5e16654645184851de0fd6b763496ad67de451efd6d10718a5682ff8
MATLAB
951
25
function [] = tutorial_hard(varargin) % This used to be a sample script to accompany % http://compmem.princeton.edu/mvpa_docs/TutorialAdv. % % We've removed it, because it was getting very long and % unwieldy, and TutorialAdv is designed to be run % interactively. So instead, just copy and paste the code % sni...
f9ccd9e1c2d565bcf1f8d31ccb2adf5b621e137806c04cdc46fb3db5ad33635b
MATLAB
951
34
function n2 = dist2(x, c) %DIST2 Calculates squared distance between two sets of points. % % Description % D = DIST2(X, C) takes two matrices of vectors and calculates the % squared Euclidean distance between them. Both matrices must be of % the same column dimension. If X has M rows and N columns, and C has %...
10139de2615b08c98cfcbd44256b405cd0c6c4964c4c9959a06b82e5f8e06076
MATLAB
952
39
function [x,y,button] = PointInput(varargin) %function [x,y,button] = PointInput(n,figh, axish) [n, figh, axish] = DefaultArgs(varargin,{1,gcf,gca}); if n>0 for i=1:n waitforbuttonpress; whatbutton = get(figh,'SelectionType'); mousecoord = get(axish,'CurrentPoint'); x(i)=mousecoord(...
d3d2d31c33dd89bc01175f5067303869f8a69eb3e8408bfae188c6c3f59d7eca
MATLAB
953
43
function [old_dirs,old_stps,Hdiag,Bcompact] = lbfgsUpdate(y,s,corrections,debug,old_dirs,old_stps,Hdiag) %B0 = eye(length(y))/Hdiag; S = old_dirs(:,2:end); Y = old_stps(:,2:end); k = size(Y,2); L = zeros(k); for j = 1:k for i = j+1:k L(i,j) = S(:,i)'*Y(:,j); end end D = diag(diag(S'*Y)); N = [S/Hdiag Y...
f3ddf6c6678b2a73682ecb97f3ef25bf92d39675a239cbe1f7304ca8bf7a5d04
MATLAB
953
26
numAssignedTracks = size(assignments, 1); for i = 1:numAssignedTracks trackIdx = assignments(i, 1); detectionIdx = assignments(i, 2); centroid = centroids(detectionIdx, :); bbox = bboxes(detectionIdx, :); % Correct the estimate of the object'...
3c8900be7f9a4eb5ecffa6ed6747ec095c46f7fbed56427ef00be77cb1d9b821
MATLAB
956
40
%% Wave Clus Output Plotting % load both the raw data and times files manually %clc %close all format long figure('Position',[0 0 1920 700]) hold on data=highpass(data,300,25000); x=[1:length(data)]; x=x./25000; plot(x,data,'Color','k') num_clus=(unique(cluster_class(:,1))); if any(num_clus==0) num_clus(num_clus==...
d0c0dc8a0b666b1f4e2283dd60f5075e490b520e9a84f0cb63b217cadbdcd8ce
MATLAB
957
47
function [pval, chisq, df] = CircularANOVA(th) % [pval, chisq, df] = CircularANOVA(sr) Circular Non-parametric ANOVA % % INPUTS: % th: a cell array, each for each group, each being an array of angular % values % OUTPUTS % pval: the p-value of the ANOVA % chisq: the chi-squared value % df: the number of degrees of free...
78102c173443c8d2c828604481fb2e407d01f737f5b18fa64b34132ae7457277
MATLAB
958
30
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() % ...
d867e68a5d1b07abc4f61d35c1f9d5ca8e0fb5e7cb9934a9d0e96590bc31d702
MATLAB
959
25
function [gx] = g_Hampton(x,P,u,in) % Hampton's "influence learning" model: observation function % function [gx] = f_Hampton(x,P,u,in) % Let P(o=1) be the agent's prediction of the other's next move, ie the % probability that the other will pick the first alternative option. The % "influence learner" bases her decision...
38fca4cffbdfb4657bf4680b6c3faccfe3ad71bd02723228d809e470d728eee2
MATLAB
960
40
function phi = CircularMazeAngularCoordinate(X, Y, center, zero_ang) % phi = CircularMazeAngularCoordinate(X, Y) % % gives an angular coordinate for the Warp circular maze used for rats % 7027, 6985 % INPUTS % X, Y: tsds containing rat's cartesian coords. % OUTPUT % phi: tsd containing the angular coord if nargin < 3...
3b6f2ec36dc088b32dbfcbc8453171104917bb31bb41aea48852be451ac4de3a
MATLAB
961
36
function Snirf2Tsv(rootdir, options) if ~exist('rootdir','var') rootdir = pwd; end if ~exist('options','var') options = pwd; end rootdir = filesepStandard(rootdir); files = DataFilesClass(rootdir, 'snirf'); files = files.files; for ii = 1:length(files) if files(ii).IsDir() continue end fname...
113c8ab69a30ff881e01ea88caa499e62061899ebf21d33bb939fd2fd98a1899
MATLAB
962
32
function top_signals = pca_top_signals(neurons,top_sel,zs,final_time) if nargin < 3 zs = 0; end if zs signal_data = []; for i_neu= 1:numel(neurons) signal_data(:,i_neu) = zscore(neurons(i_neu).coords(10:final_time,5)); end [coeff, ~, ~, ~, explained...
17799b5b5aa03c7cbf90ff14167c8e46c103557503c78cb44e2994ee487224d6
MATLAB
964
35
function [str] = estimate(t) % Gives an appropriately unitized string of a duration in seconds. % % [STR] = ESTIMATE(T) % % License: %===================================================================== % % This is part of the Princeton MVPA toolbox, released under % the GPL. See http://www.csbmb.princeton.edu/mvpa f...
c1487d3a55975af9b81de96b96c98bb7d11a90734390715ebfa4b12bc9ebf7a5
MATLAB
964
32
function Xi = Xi_diff_MT(Xi_T,Xi_L,diff,kmax,N) % Function to build Xi operator with diffusion effects for MT (4 states per % k-value). % This function efficiently uses spdiags to build the large band diagonal % matrix that results from applying Xi_L and Xi_T to each order of states. % Diffusion changes the matri...
3596ef65a594660ae7cea61d44effc93584a778636e986dadfd927d8762413c2
MATLAB
966
44
function out = roots_poly4(c,flag) if nargin<2 flag = false; end delta0 = c(:,3).^2 - 3.*c(:,2).*c(:,4) + 12.*c(:,5); delta1 = 2.*(c(:,3).^3) - 9.*c(:,2).*c(:,3).*c(:,4) + ... 27.*(c(:,2).^2).*c(:,5) + 27.*c(:,4).^2 - ... 72.*c(:,3).*c(:,5); p = c(:,3) - (3./8).*(c(:,2).^2); q = (c(:,2).^3)./8 -...
52952544b6d9936e5f88bf4736183010769f31687e3945518211b8d1b38cd04c
MATLAB
966
38
function [isok] = check_subj(subj) % This just runs some quickie tests to see whether your subj % structure appears to be constructed correctly % % Still under development. % License: %===================================================================== % % This is part of the Princeton MVPA toolbox, released under ...
ee3bed4eedd08ac1827ce03fe9010ce44fb6ab5baf15c22035aba2b8bdf70bc3
MATLAB
966
36
function [post, a] = gmmpost(mix, x) %GMMPOST Computes the class posterior probabilities of a Gaussian mixture model. % % Description % This function computes the posteriors POST (i.e. the probability of % each component conditioned on the data P(J|X)) for a Gaussian mixture % model. The data structure MIX defines th...
b1352b29cdbfecde59b15d345d066eb38dd544dabb37baf3ccd16268ca93aab7
MATLAB
967
40
function [ripTsd ripEp] = LoadRipples_Kenji(fbasename,varargin) % Load ripple times from Kenji dataset % % USAGE: % [ripTsd ripEp] = LoadRipples_Kenji(fbasename); % % INPUT: % fbasename: session file basename % % OUTPUT: % ripTsd: a tsd of ripple times % ripEp: a intervalSet of ripple events (beginnings a...
a3c06d5d72e13c78cb8b2292e61a01bc7506db84c9312280e95d2c098963235c
MATLAB
968
24
function frame = msReadFrame(ms,frameNum,columnCorrect, align, dFF) %UNTITLED Summary of this function goes here % Detailed explanation goes here vidNum = ms.vidNum(frameNum); vidFrameNum = ms.frameNum(frameNum); frame = double(ms.vidObj{vidNum}.read(vidFrameNum)); if (columnCorrect) ...
cd4fc1c4b11cd549a5691f16829714f743b081dedf43e93a3f5690b894ec1b2f
MATLAB
969
55
function [eta,etaSem,B] = ETAverage2(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 % cross correlations */ ...
e17c230f6e6e4652140cb6e80e90631f27514f809abc3d73d8b718b6e420cba2
MATLAB
969
33
function SO = map(S, cmd_string, varargin) % Applies function on each element of the array % % USAGE: % SO = map(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 array must be...
3c306d469868b6060079fba865beaf04bf2ad3afeb241279419de193ff103c68
MATLAB
970
34
classdef PsthAsEmClassifierModel < ClassifierModel properties EmPSTHs end methods function mdl = train(mdl,X,y) psthMap = containers.Map('KeyType','double','ValueType','any'); classes = unique(y); for i = 1:length(classes) ...
3a2f4b50b5b66b4c230d7b07be5c2ee467e8d232a2fcbba9f9ff437b051bdd0e
MATLAB
972
33
function plotInstability(I, K, c) % Generate input signals T_smooth = 0.025; % (s) tbefore = -0.1; % (s) Time before step tafter = 0.25; % (s) Time after step amp = 10; % (deg/s) Scale for step dt = K.dt; tt = tbefore:dt:tafter; % Generate smoothed step head_curr = double(tt>0)*amp; head_curr = ...
721737d9cba7ea3524db24633934c5b8fb37340979dd524fe5461632d227391d
MATLAB
972
24
function info_r_onespin = computeSingleSpinInfo(eta_vals, eps_vals, J_i) % J_i is the coupling strength and is fixed for each neuron, this in % information from single sample of single spin % %% Compute information for single neuron, using rates. r_h = @(h, eta_h, eps_h) (1 + exp(-eta_h*h*J_i + eps_h)).^(-1); info_r_o...
b16fdae7ad6fa733dc62a6f0fbfc56a37b8dd058b00e53d0b9f6b3cf9fbf3e51
MATLAB
973
38
function Plot_Ellipse(M,V) [Ev,D] = eig(V); d = length(M); if V(:,:)==zeros(d,d), V(:,:) = ones(d,d)*eps; end iV = inv(V); % Find the larger projection P = [1,0;0,0]; % X-axis projection operator P1 = P * 2*sqrt(D(1,1)) * Ev(:,1); P2 = P * 2*sqrt(D(2,2)) * Ev(:,2); if abs(P1(1)) >= abs(P2(1)), Plen = P1(1); e...
baa33f8e929a567af2cef644c327e7c64b5b17b432203a78aafbac0f3725c287
MATLAB
973
28
function ta = detTotalActivity(actigraphy, epoch, varargin) %DETTOTALACTIVITY calculate total activity % % TA = DETTOTALACTIVITY(ACTIGRAPHY, EPOCH, STARTTIME, WINDOWLENGTH) % calculate the total activity level in ACTIGRAPHY of epoch EPOCH second % with start time at STARTTIME. WINDOWLENGTH specifies the l...
aa1c2adcb2b719e19a9be124ac97106e5b566255a9903053e854a59a5df3c403
MATLAB
974
14
% function for calculating log-likelihood % inputs: % b : vector of model parameters. b(1) is the log of scale parameter. The rest are model parameters % DVH: function handle for calculating decision variable, which is Utility of option 1 minus that of optin 2 % data: a structure that contains variabl...
be5272df8ffa65344f0e9f4ec258f83b03437f00e768adc22d76153ca2d54dba
MATLAB
974
42
function yCI95 = get_ci95(y, dim) % function yCI95 = get_ci95(y, dim) % % Compute 95% confidence interval of input data y. % % Input: % - y: 2-D data array % - dim: Dimension along which to calculate 95% CI (default 1). % % Output: % - yCI95: 95% CI of y. % % Simon Weber, sweber@bccn-berlin.de, 2022 % Check id ...
1e7d57bf4a9147331c1b53929ff7b2f07948b9aa7f037e9871aa07dff2d2d522
MATLAB
975
33
function e = mdnerr(net, x, t) %MDNERR Evaluate error function for Mixture Density Network. % % Description % E = MDNERR(NET, X, T) takes a mixture density network data structure % NET, a matrix X of input vectors and a matrix T of target vectors, % and evaluates the error function E. The error function is the % negat...
e2d7e2eb98b445c505169524901c3ad1e8be041b87ffef1e78b9f088d0ce3601
MATLAB
975
36
function net = gpunpak(net, hp) %GPUNPAK Separates hyperparameter vector into components. % % Description % NET = GPUNPAK(NET, HP) takes an Gaussian Process data structure NET % and a hyperparameter vector HP, and returns a Gaussian Process data % structure identical to the input model, except that the covariance % ...
39f93dea262527bdcd9d03ab7cae1b9b2ae6e40411dbe1b0f0b08327d2865948
MATLAB
976
36
function [tx,g]=tsample(x,percent) % function [tx]=tsample(x,percent) % Returns the trimmed sample of x. % x must be a vector % percent must be a number between 0 and 100 % The trimmed sample is calculated by dropping the lower and upper g values from % x, where g=floor((percent/100)*length(x)). If x is empty, then Na...
76303735721bae17ace23305c2c4cc4945699b57cec4383b49cc7195e2a0c83b
MATLAB
976
27
function [rho,theta] = generate_noisy_oscillator( dt, T, base_amplitude, base_frequency, ... amp_noise_sigma, ... freq_noise_sigma ) % *WAVE* % % GENERATE NOISY OSCILLATOR generates an oscillation with defined % ...
dddeb733833ab4bd5979607bfbd0dc042246fcf462750e95ea2f039f41777124
MATLAB
976
48
function weights = ComputePeerHDPrediction(q,Q,ang,pf,x1,ep,varargin) % weights = ComputePeerHDPrediction(S,Q,ep) % S: ts of the cell % Q: binned spike train matrix (tsd object) of all other cells % ang: tsd of angles % ep: intervalset of interest q = Data(Restrict(q,ep)); Q = Restrict(Q,ep); rg = Range(Q); dt = med...
aef325999887d667c5c187c66c8c0492e95df8c25a2c9b76d895df731c5e7989
MATLAB
977
42
function [returnVar,msg] = MakeLEDFile(fbasename,varargin) % USAGE: % [returnVar,msg] = MakeLEDFile(filebasename,channel) % INPUTS: % filebasename: file base name % channel (optionnal): sync pulse channel. Default is last channel in the eeg file. % % Adrien Peyrache 2011 msg = ''; returnVar = 0; try ...
f622f6181acf103e80b374ad4d466cdbfe41ddb2ce78d5c017ec8ce8d05867df
MATLAB
978
58
function maxTsd = max(tsa,is) % Returns the maximal value(s) and time(s) of a TSD object (overoads the max function) % % USAGE: % maxTsd = max(tsa,epoch) % % INPUTS: % tsa - a tsd object % epoch (optional) - an intervalSet object where max values have to be looked for. % % OUTPUTS: % maxTsd - t...
30f4e3fd74942e59ed375592374887cef3b0c3cfd915717b480aafc7801e11cd
MATLAB
979
30
function inx_cell = getInxForNoiseCorr(data,epoch) PROBABILITIES = [25,75]; DIRECTIONS = 0:45:315; [~,match_p] = getProbabilities (data); [~,match_d] = getDirections (data); boolFail = [data.trials.fail] | ~[data.trials.previous_completed]; switch epoch case 'cue' inx_cell = cell(1,lengt...
92cab460987bce70803a1c02167c4518410b1ec071fbcec8e22f5677db7c2b7c
MATLAB
979
18
%% %% Script to load spike firing times for a cell %% c_ts: firing times, root.cel_x{1,1}: spike x coordinates, %% root.cel_y{1,1}: spike y coordinates %% reference: https://github.com/hasselmonians/CMBHOME/wiki/Tutorial-2:-Apply-an-epoch-and-get-theta-signal %% function [root c_ts] = load_spike_times() addpath /comp...
c45be3ceeb3d273f80f9cac4f654cf00d152db46b65b33eb2d3979e7a0348e2b
MATLAB
980
34
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Authors : Khoyratee Farad % Date : 28/11/2018 % Version : V1.0 % % Description : GABAb current calculation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [N, Yplot] = rasterplot(t, V, Threshold) N ...
e0b2f682a9ea369329387c355c8cb2c301f03fe874cf8a80fdd8fb921b095729
MATLAB
980
34
function p=s3SubjectPath(subject,lib,isCalibrationFolder) %This function returns the library path in S3 to subject %Example p=s3SubjectPath('01'); %If subject is empty will return the root folder of all subjects %isCalibrationFolder - when set to true will return the calibrations folder %in that lib if (~exist(...
317d7bdab4c35222fd2f63c8bbe58f81c645c84af05e21cd5925eac054b18e36
MATLAB
982
23
% This script is used to compile a few C-mex files necessary to run SIMLR large scale % first of all, mex projsplx_c.c and Kbeta.cpp cd src/ mex -largeArrayDims projsplx_c.c mex -largeArrayDims Kbeta.cpp % second mex tSNE mex -largeArrayDims compute_wtsne_obj_grad_repulsive_barneshut.c barnes_hut.c % next we ...
700b89e165c237ef90f4b6867b58711b16cef006513c63d63ceb16afa1adf04e
MATLAB
982
39
function resetGroupFolder(dirname, options) global maingui global cfg if isempty(getNamespace()) setNamespace('Homer3') end cfg = InitConfig(cfg); if ~exist('dirname','var') || isempty(dirname) dirname = [pwd,'/']; end if ~exist('options','var') || isempty(options) options = 'registry_reset'; end output...
e8cc93afe28d9a69314dee9b0bde8d59b42b1daa3d11e6a84504adf773d2c912
MATLAB
982
38
function dist=KLDiv(P,Q) % dist = KLDiv(P,Q) Kullback-Leibler divergence of two discrete probability % distributions % P and Q are automatically normalised to have the sum of one on rows % have the length of one at each % P = n x nbins % Q = 1 x nbins or n x nbins(one to one) % dist = n x 1 if size(P,2)~=size...
731681f273bf2c9474fc7166a02355516ec4d8b3b4d110cf27da4ea89a175875
MATLAB
983
34
function [dim] = pos2dim(pos) % POS2DIM reconstructs the volumetric dimensions from an ordered list of % positions. % % Use as % [dim] = pos2dim(pos) % where pos is an ordered list of positions. % % The output dim is a 3-element vector which correspond to the 3D % volumetric dimensions % % See also POS2TRANSFORM % ...
b3b983818f6fe4a555a87edf8f0c735a9c760600c6ddecb79ce87e902d167723
MATLAB
983
33
function [subj] = move_all_patterns_to_hd(subj) % [SUBJ] = MOVE_ALL_PATTERNS_TO_HD(SUBJ) % License: %===================================================================== % % This is part of the Princeton MVPA toolbox, released under % the GPL. See http://www.csbmb.princeton.edu/mvpa for more % information. % % The ...
746a9ad9b89266e6a2656bdbccd3d1b7a322d970f6291c5498775a40f0df087c
MATLAB
984
33
%% Pick the starting and ending points of object exploration figure plot(traj1.x1,traj1.y1),axis ij, hold on [Crd.xR, Crd.yR] = pol2cart(thetaR,median(traj1.rhoPosition,'omitnan')); scatter(Crd.xR, Crd.yR, 100,'+','r') disp('Click to pick the locations of objects, double click to finish.') [Crd.x2s,Crd.y2...
1753cb180eb1fe5e6eab3dbfd5198caa7ff13504439a34dc874ed273a416269c
MATLAB
985
24
function struct = matrix_statistics_zscored_event(matrix, bsl_i1, bsl_i2, event_bsl_mean, event_bsl_std) struct.matrix = matrix; struct.matrix_mean = mean(matrix); struct.matrix_std = std(matrix); struct.bsl_mean = mean(matrix(:,bsl_i1:bsl_i2),2); struct.bsl_std = std...
b63d6c8ca7e412baa2bdd690809d2492f5e9aa58c37b1fc60990c3929c1d6b6d
MATLAB
985
29
function deleteFineAlignmentIfNoHistologySection(slidePath) % This function deletes fine alignment information if slide doesn't have % histology section. It cannot be fine aligned! % Written at May 10, 2020. %% Load Data if ~exist('slidePath','var') slidePath = [s3SubjectPath('18','LE') 'Slides/Slide05_Sect...