sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
a71f81e547865dfe1fcd8ea4736d5210d66196e5f372845d05cb97fd526276b1
MATLAB
519
21
function g = netgrad(w, net, x, t) %NETGRAD Evaluate network error gradient for generic optimizers % % Description % % G = NETGRAD(W, NET, X, T) takes a weight vector W and a network data % structure NET, together with the matrix X of input vectors and the % matrix T of target vectors, and returns the gradient of the e...
12c47bef450e65db2fbdea64b7b0d14efa774e4885d822a49ea1674ba8d730d8
MATLAB
520
15
function ep = LoadEpochFromDatSeg(ix) % ep = LoadEpochFromDatSeg(ix) if exist('RecordingDuration.txt','file') datSegments = load('RecordingDuration.txt'); datSegments = intervalSet([0;cumsum(datSegments(1:end-1))]',[cumsum(datSegments)-1]); elseif exist('DatSegments.txt','file') datSegments = load('Da...
03f1870ea7a011a5995a5138882ec7c083a6ee65898fe978968f7424668a1871
MATLAB
522
14
% load all analyzed ccstep files and create analysis overviews for % inspection load('D:\Morphys\Data\Labbooks\NAG\MetadataABF\DataSummaryNAG2.mat') filelist=squeeze(struct2cell(Summary)); filelist=filelist(1,:)'; filelist=cellfun(@(x) strsplit(x, '.'), filelist, 'UniformOutput', false); filelist=cellfun(@(x) x{1}, fi...
82bc6d271abe414da1c12f37900c187d125f1eab050a7afe3712137ed4ee6057
MATLAB
522
12
function checked = check_software_afni(software) if strcmpi(software(1:4),'afni') if ~isempty(which('BrikInfo.m')) checked = true; else error('afni_matlab is not on your Matlab path! Please add a version of afni_matlab (http://afni.nimh.nih.gov/afni/matlab/) to your path using e.g. addpath or c...
b108b68fd75d3274db586a30ed0cb6c67365ad5d4701bae921306d826e1a6d98
MATLAB
524
22
function raster = Raster(S,center,TStart,TEnd, varargin) opt_varargin = varargin; defined_options = dictArray({ { 'BinSize', {10, {'numeric'}}}, }); getOpt; is = intervalSet(Range(center)+TStart, Range(center)+TEnd); sweeps = intervalSplit(S, is, 'OffsetStart', TStart); raster = z...
002e66133180133f3b1db9f7be8bbd43c0de2cbf826fc1a4f1d6e1eae07e1f8c
MATLAB
525
27
function pv=plot_pValLine(X1,X2,Y,Txt_dist,pVal) %plot_pValLine pv=plot([X1 X2],[Y Y],'color','k','linewidth',2); hold on; th=.2; c=1; % text(mean([X1,X2])-th,Y+Txt_dist,['p=',num2str(round(pVal,3))],'fontsize',10); pmarks={'n.s.','*','**','***'}; if pVal>.05 pix=1; c=2.2; elseif pVal<=.05 & p...
85da8f82e4aa2b341bb99fc75561ce4a44d970b56e769838248b51cceefe1746
MATLAB
526
23
cd(fullfile(pwd,'..','genmodel')); addpath(fullfile(pwd,'..','esns')); load ESN load amateur_postags possents minout = 1e-3; nrsize = length(Win); nrnet = size(Win{1},3); nrtest = length(possents); rawsurp_esn = cell(nrtest,nrnet); for n = 1:nrsize for i = 1:nrnet disp([n i]); ...
935bf597704d63e6450e4bdc5ebb1c3cc9d99ce2388f92460c4d0ad849335017
MATLAB
526
8
function [CurrentSlice] = RefreshImageBC(CurrentSlice,ContrastSliderValue,BrightnessSliderValue) %REFRESHIMAGEBC Scales the image intensity to [0 1] and applies contrast %and brightness % Takes current slice matrix and brightness and contrast scalars as % arguments CurrentSlice = (CurrentSlice - min(CurrentSlic...
eca0af2ddd6b515f4835a34d53b934c3817dd8dad12b4dde7f8c30d8553ab2e6
MATLAB
529
19
function wp = PTweight(p,type,varargin) % probability weighting function of prospect theory for i = 1:2:length(varargin) eval([varargin{i}(1),'=',num2str(varargin{i+1}),';']) end switch type case 'Tversky' % Tversky & Kahneman 1992 wp = (p.^g)./((p.^g+(1-p).^g).^(1/g)); case 'Goldstein' ...
21b3c8476c2608d550c2a06293489e475bea3cfee704cf282daf5ded89ffae2a
MATLAB
530
19
function C=correlation_matrix_gf(n,final_time) nen=numel(n); signals{nen,nen}=0; for i=1:nen signal = n(i).coords(100:final_time,5); % IMPORTANTE. PER I PRIMI VA A 2400 signal = signal - imgaussfilt(signal,80); signals{i} = signal; end for i=1:nen for j=i+1:nen signal1 = signals{i}; ...
60bc3845405f8f335487c1600501083245566f12302e07f0e801c028518ec5b5
MATLAB
530
22
function start=findstart(indicator,time) % generic funcion to find the start in a trace % SYNOPSIS % function start=findstart(indicator,time) % DESCRIPTION % indicator: a logical vector if the measurement is above threshold or not. % time number of times, that the indicator has to be one ind=find(indicato...
91fbe0754ea66d5969bc39500958228358cc2cace658c578b49cee23c434b3d4
MATLAB
530
29
function hdScore = HDScore(h,peak,B) % USAGE % HDScore = HDScore(S,peak,B) %Adrien Peyrache, 2016 hdScore = zeros(size(h,2),1); for c=1:size(h,2) totFR = sum(h(:,c)); [~,ix] = min(abs(B-peak(c))); ix = ix(1); ii = 0; ixA = ix; while sum(h(ixA,c))<totFR/2 i...
d9f3c10f15ed1d545797a2925d2ab8db5685ec0ce7d9df66802031979adf16bf
MATLAB
532
24
function img = imReColor(img, oldColor, newColor) % Change one color in image to a new one. works on RGB colors if (size(img,3) == 3) r = img(:,:,1); g = img(:,:,2); b = img(:,:,3); elseif (size(img,3) == 1) %Gray scale r = img(:,:,1); g = r; b = r; else error('Don''t know what...
dc620d088bfa98a55c43e0939f2bd36d899ea2fc9bb16722220e90b3af6da471
MATLAB
532
28
function v = subsref(O, S) % v = subsref(O, S) deals with { } references % % B = O{k} returns the value corresponding to key k, error if not % existing key % copyright (c) 2004 Francesco P. Battaglia % This software is released under the GNU GPL % www.gnu.org/copyleft/gpl.html if ~strcmp(S.type, '{}') erro...
e0e84d9a55273baae19297ddb1971a780db53728a667a14895a2a0a9f1253e6b
MATLAB
532
21
function [rightEp,leftEp] = LoadLinearTrackRuns(fbasename) [dir f1 f2] = fileparts(fbasename); fbasename = [f1 f2]; fbasename = [dir filesep fbasename filesep fbasename]; Fs = 1250/32; try load([fbasename '.whlL.mat']); ix = ismember(Lwhl.cont,'right medium'); t = Lwhl.Time{ix}; rightEp = intervalSe...
53378079ed21610c8acde90189ab7287203d42745de4361ef7c18db893164f75
MATLAB
534
19
% output = transres_ninputdim(decoding_out, chancelevel, cfg, data, varargin) % % This function returns the number of input dimensions (e.g. voxels of a % searchlight or ROI) from the last decoding. % % To use it, use % % cfg.results.output = {'ninputdim'} % % The number is retrieved from the dimensionality of the i...
b517248a9905196819db039516ffb25be310991dded4d551cac6955b186ce634
MATLAB
534
23
function plottracks_s_2 global display_matrix global ax global text_spot_num global framenum global plotted_neurons global colormap_s a=1; try delete(plotted_neurons); end plotted_neurons=[]; display_vector=squeeze(display_matrix(:,framenum,1:2)); % 2D for i=1:size(display_vector) hold on plo...
86147e1fa637c43bb7e662715e09d30ad1d2b1a415b7892c8e499124b78a54da
MATLAB
535
23
function [fractional_occupancy, mean_life, Counters] = summary_stats_fast(z,stateSet) K = numel(stateSet); T = length(z); fractional_occupancy = zeros(1,K); mean_life = zeros(1,K); Counters = zeros(1,K); for i = 1:K k = stateSet(i); ix = find(z == k); if ~isempty(ix) fractional_occupancy(i) = lengt...
04fdd02495ce4cca063bdc349589e165f773c7919057546ab801bc8290dcfb16
MATLAB
536
23
function SpatBits=SpatialInfo_1D(pf,occ) % USAGE % SpatBits=SpatialInfo(pf,occ) % % compute for each cells the number of spatial bits per spikes % % INPUT: % pf: placeField (In Hz per pixel), organized oolumnwise if multiple % occ: Occupancy probability % OUTPUT: % SpatBits: the spatial information (i...
1ea8dae47ce42f37e4dadd602eeb847ce418af11e5529ec6240683114c1f2e5b
MATLAB
536
28
function circlePlot(M, x, y, cmap) if length(x) ~= size(M, 1) | length(y) ~= size(M,1) | length(x) ~= length(y) error('x and y should have the same length as dimensions of M'); end mx = max(M); mn = min(M); ix = (M-mn)/(mx-mn); colIx = ceil(63*ix+1); colYT=mn; for i=1:4 colYT = [colYT mn+(mx-mn)*i/4]; end hold on...
54217d2229144a91094a5f32bfcf482dbaa76d0ae0c2ba174b2faaa04119a178
MATLAB
536
20
function r = MD_unirnd(a, b, N) % _ % Random Numbers from a Continuous Uniform Distribution % FORMAT r = MD_unirnd(a, b, N) % % a - the lower end of the uniform distribution % b - the upper end of the uniform distribution % N - the number of samples to be drawn % % r - an N x 1 vector of uniform rand...
716d71e2e8ab267873fc46ec8397d08facee590e8e4815bb518d7426f62cd473
MATLAB
536
22
function trial_dat = eye_extract_trials(run_dat, p) % Get number of timepoints n_tp = size(run_dat,1)/p.n_trials; trial_dat = []; % For each run ... for i_run = 1:size(run_dat, 3) % For each trial ... for i_trial = 1:p.n_trials % ... get the corresponding gaze data and append it to the % temp...
2d2346aecbd2d68eb4571a41295b2bf7597990d43c2c390026fefbc5ad7610e0
MATLAB
537
26
function r = gitRevert(repo) r = -1; if ~exist('repo','var') || isempty(repo) repo = pwd; end repoFull = filesepStandard_startup(repo,'full'); currdir = pwd; ii = 1; cmds{ii,1} = sprintf('cd %s', repoFull); ii = ii+1; cmds{ii,1} = sprintf('git checkout %s', repoFull); ii = ii+1; cmds{ii,1} = sprintf('git clean -fd...
7e5b74403b6a3d7fd5e36a169f56dfc91f8a33ec7d7fcbb0a12bbab026426b77
MATLAB
539
20
function [Sim, mphi] = autoregressionSim(Sig) % input Sig = [repeat time] nrep = size(Sig, 1); n = size(Sig, 2); Sim = zeros(nrep, n); phi = nan(nrep, 1); for i = 1:nrep a = Sig(i, :); X = [ones(n-1, 1) a(1:end-1)']; y = a(2:end)'; beta_hat = X \ y; ...
c087d3b91f0f17a2a5737d46dc326b2e76dbd896fc94d9447c0059c1526000d9
MATLAB
539
25
function [R,tau] = mcholinc(H,verbose) % Computes Cholesky of H+tau*I, for suitably large tau that matrix is pd p = size(H,1); beta = norm(H,'fro'); if min(diag(H)) > 1e-12 tau = 0; else if verbose fprintf('Small Value on Diagonal, Adjusting Hessian\n'); end tau = max(beta/2,1e-12); end while ...
5b420b7ff3799aa4721581234e2a0fc0e82b43374d24ef896975c9326a3d3161
MATLAB
540
17
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Authors : CHATENET Louis % Modified : Khoyratee Farad % Creation : 30/05/2018 % Modified : 26/10/2018 % Version : V5.0 % % Description : Neuotransmitter concentration calculation (T) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
43488030fd1686b8132d37542725429442bec1bdaf81338aa2a3f71d8ef46816
MATLAB
541
16
function [sizeLambda, sizeX, sizeY, AScanAvgN, BScanAvgN] = yOCTLoadInterfFromFile_DataSizing(dimensions) %This function extract sizing of the data from the dimensions structure sizeLambda = length(dimensions.lambda.values); sizeX = length(dimensions.x.index); sizeY = length(dimensions.y.index); if isfield(dimen...
49151c8ea388f081d78a79bd04f7663aea2906655b5cea7b7689b79ef63e3053
MATLAB
542
21
function y = solveWithIter(A, b, iter, breakOnConverge, x0) tresh = 1e-6; N = size(A, 1); y = zeros(N, iter); y(:,1) = x0; for i = 2:iter h = A * y(:, i-1) + b; y(:, i) = activation(h); if i>breakOnConverge converged = sum(abs(y(:, i-1)-y(:,i)))<tresh; %expensive,...
744622d06cfd3f31b422a3872f848113c356fd0f0bf8b17c8a53a119f01fbfb0
MATLAB
542
25
function m = bmean(x, dim, k) % BMEAN computes a skipped-estimator of location based on computing the % mean after removal of outliers, according to the boxplot rule. % % Use as % m = bmean(x, dim, k) % % Input arguments: % % x = data matrix % dim = scalar, dimension along which to operate, default: first non-...
bdf4a952ac6a19c6c4ea4f1adae2edd8691a621f4292f81145679ea6da0b28d0
MATLAB
542
12
function [s] = std(x, varargin) % [S] = STD(X, NORMALIZEFLAG, DIM, FLAG) computes the standard deviation % across all cells in x along the dimension dim. Normalizeflag = 1 normalizes % by N, normalizeflag = [] or 0 normalizes by N-1. % % X should be an linear cell-array of matrices for which the size in at % least ...
5c18b0c1db30fac01228d929d5c226e799d4f2770cd087ca95e779361fe0e9de
MATLAB
544
23
% *WAVE* % % PLOT VECTOR FIELD DISTRIBUTION unit test for the vector field plotting % functions % 12 january 2016 % clear all; clc %#ok<CLSCR> % parameters rotation_sign = -1; alpha = 1; center_point = [ 4 4 ]; % generate coordinate system [XX,YY] = meshgrid( 1:8, 1:8 ); [X,Y] = meshgrid( (1:8)-center...
549a34f90dba46c871128360752854f8a0da6ee42d9b29ebba942d3b03d8ccf9
MATLAB
545
21
function gapSeries = gap2Series(gap, length) %GAP2SERIES convert gaps to series representation % % E.g. % For a signal of length 10 % gap was defined from 3 to 6 (gap = [3 6]) % then, GapSeries = [1 1 0 0 0 0 1 1 1 1]; % % $Author: Peng Li % Division of Sleep Medicine % Brigham ...
81b3fbdd2026a07f298f42841d3ad992993cb61268a404e3c67ada9e8ae35ed4
MATLAB
547
23
% unit test of mv_stat_activation_pattern rng(42) tol = 10e-10; % Get Gaussian data nsamples = 200; nfeatures = 90; nclasses = 2; [X,clabel] = simulate_gaussian_data(nsamples, nfeatures, nclasses, [], [], 0); % Covariance matrix Sw= nsamples/2 * cov(X(clabel==1,:),1) + nsamples/2 * cov(X(clabel==2,:),1); %% if PCA ...
89abc4777fc290b362fdecff59e9128a088bd358a0c88fac4aaaa010fcb3a0f6
MATLAB
549
17
%determines the timestamp for all trials specified with inds from the event file % %inds is onset of stimulus %inds+1 is offset of stimulus % % %before/after Offset is in ms. it determines the length of the trial, relative to the timepoint specified by ind % %urut/jan07 % SSullivan july/17 slightly modified for SB anal...
02977653fd46eb02091a86a6246cfd832aacab89c80c801148843dea354b36f5
MATLAB
550
20
function [xFil1, yFil1, xFil2, yFil2] = DecomposedMexiHat(hatRadius) cylRadiusFac = 3; kernelSize = cylRadiusFac*hatRadius; x = -kernelSize:kernelSize; y = -kernelSize:kernelSize; sigR = hatRadius/sqrt(2); Gx = exp(-x.*x/2/sigR/sigR); Gx = Gx/sum(Gx(:)); Gy = exp(-y.*y/2/sigR/sigR); Gy = Gy/sum(Gy(:)); Fx = (1...
4e215af31866a2e4cb70986cbde7af7d7217044a842478febaf3b1aed89fe3c1
MATLAB
550
21
function [stack, stackinfo] = stackRead(stackpath) % % [stack, stackinfo] = stackRead(stackpath) % % Wrapper function for Fran�ois Nedelec's tiffread.m % This works on STK files as well as multipage TIFFs. % Outputs: % % stack : 3D data array % stackinfo : Any other information included in original file % % Fra...
71ce2098b25bdcda5fc765d1c8b9998030120f2faa0154d82424e3c8a3a56416
MATLAB
550
15
%% Distributions "Over Time" Script % The goal of this script is to create "over time" distributions of the % flow directions. % % This script is designed to be executed AFTER "ControlScript" has been % fully executed at least once. Thereafter, the only definitions needed % are in the pre-amble include "fileParams...
8b04897307f956cba540d91a88b18e99f22695699c8fd92906eb3c994388e7af
MATLAB
550
33
function [ets,time,f,S] = ETSpecgram(eeg,evt,nbBins,fq,movingwin); rg = Range(eeg,'s'); deeg = Data(eeg); deeg = WhitenSignal(deeg); % fq = [55 100]; params.Fs = 1/median(diff(rg)); params.fpass = fq; params.err = [2, 0.95]; params.trialave = 0; params.pad = 16; params.tapers = [3 5]; [S,t,f]=mtspecgramc(deeg,movi...
9abc204c3e3c0593791f18590ee88f4ba19f87511f5ebf1e262e9afc4480249a
MATLAB
550
12
function [gx] = g_Hampton_2games(x,P,u,in) game1 = in.game1; % player's payoff table game2 = in.game2; % other's payoff table player = in.player; % agent's role Po_game1 = VBA_sigmoid(x(1)); % P(o=1|game1) Po_game2 = VBA_sigmoid(x(2)); % P(o=1|game2) Po_game = VBA_sigmoid(x(3)); % P(game1) DV_game1 = fplayer(P...
c40d6b5857bc13c0480d94e407c0852e2b1d6f0243bab496308102bf748eca83
MATLAB
550
21
function SegSeries = seg2Series(seg, length) %SEG2SERIES convert segments to series representation % % E.g. % For a signal of length 10 % seg was defined from 3 to 6 (seg = [3 6]) % then, SegSeries = [0 0 1 1 1 1 0 0 0 0]; % % $Author: Peng Li % Division of Sleep Medicine % Brig...
cf0ade72c140ec102cf67d5cd58a6cf68a7eeacc730f254b250e97e2cca72ad4
MATLAB
550
21
function [d] = det4x4(x) %computes determinant of matrix x, using explicit analytic definition if %size(x,1) == 4, otherwise use matlab det-function siz = size(x); if all(siz(1:2)<2) error('size of x should be 4x4xsomethingelse'); elseif all(siz(1:2)==4) d = x(1,1,:,:).*det3x3(x(2:4,2:4, :,:)) - ... x(1,...
ec61b00ce334eea0b06e4d722e39c06071ad8496678ce65555801680767e4cad
MATLAB
550
22
function [errmsgs warnmsgs] = unit_and_bool_selectors() % [ERRMSGS WARNMSGS] = UNIT_AND_BOOL_SELECTORS() errmsgs = {}; warnmsgs = {}; a = round(rand(1,100)); b = round(rand(1,100)); c = round(rand(1,100)); subj = init_subj('unit_and_bool_selectors',''); subj = initset_object(subj,'selector','a',a); subj = initset_...
664fc3470a5d87b0f7d8558a223da31121cdb8ac0791125de81637c07dac649d
MATLAB
551
12
function [s] = nanstd(x, varargin) % [S] = NANSTD(X, NORMALIZEFLAG, DIM, FLAG) computes the standard deviation % across all cells in x along the dimension dim. Normalizeflag = 1 normalizes % by N, normalizeflag = [] or 0 normalizes by N-1. % % X should be an linear cell-array of matrices for which the size in at % ...
0ae6c657a178c53f9a2a7c1ff5a8324ec1dc54f37ff50e664de99668c048ea9b
MATLAB
553
16
function Y=acceleration_discr(A,sigma) % VELOCITY: calculates the velocity for one axis % Synopsis % v=acceleration_discr(A,sigma) % Description % A is a vector of position data (one or multi-dimensional) % (use cleandata first!) % if sigma is given, the data will be smoothed with % a gaussian kernel (SD=s...
90d803d87b7cd7f59bb9292ace665b4261d9560b511da96baa1e372ff457c0e0
MATLAB
553
19
function grad = solveWithIterBackProp(A, gradIn, xRaw, iter) AT = A'; grad = zeros(size(gradIn)); deltaX = deltaActivation(xRaw); grad = zeros(length(gradIn), iter); for i = 2:iter grad(:, i) = deltaX .* (AT * grad(:, i-1) + gradIn); grad(:, i) = gradCliping(grad(:, i)); end...
5080d5f3b56ba7c07b0651edc73160e39d01ac35a10a790e4fc4f9de2fe92c4d
MATLAB
554
28
function O = del(O,k) % D = del(D,k) deletes item with key k in dictArray D % % gives an error if k not present % copyright (c) 2004 Francesco P. Battaglia % This software is released under the GNU GPL % www.gnu.org/copyleft/gpl.html if O.keysReadOnly error('Keys are not modifiable'); end ix = key2id...
588df05bf15bb88d0417d8c1ded2e50e7b0a66d489f1061ed644dc4c18131283
MATLAB
554
15
function [n_cts, size_bins, dur_bins] = calculateJointHistogram(sizes, durations) % This calls histcounts2 using bins for discrete data: bins are all unique % sizes and durations from the observed data. % set bins dur_bins = unique(double(durations)); dur_edges = [dur_bins - 0.5 dur_bins(end)+0.5]; si...
aadd8883524ea4d2d483df1cd7e8edf1ddf30edb05e2edde5548a19237c6eebf
MATLAB
554
16
function dat = filter_eye(dat, p) % Filter the gaze data according to "Thielen, J., van Lier, R., & van % Gerven, M. (2018). No evidence for confounding orientation-dependent % fixational eye movements under baseline conditions. Scientific reports, % 8(1), 1-10." using a low pass butterworth filter of 5th order with 1...
c1603e800386b2b7cdcd2e5d13009b2847e3520332c20700c0987568b621c034
MATLAB
555
20
%Returns the color the condition should be (visual is orange, audio is %blue, audio-visual is green). %2024/02/25 function line_color=condition_color(condition) if iscell(condition) condition=condition{:}; end condition=regexprep(condition,'.+-',''); switch condition case 'V' ...
05fa915ed70f183e737c31d8cb7c0ecb96750c8bc534129b8338167eca2798ff
MATLAB
556
15
% %reference timestamps to beginning of the trial % %periods: each row is one trial. 3 columns: trial nr, from, to. %returns a cell array; each item contains the timestamps of one trial. the %number of trials is equal to the number of rows in periods. % %urut/dec07 function trialsTimestamps = getRelativeTimestamps(time...
392723ef84374e9a28a05de983de9cedf60a0da534b2f27595b78ae00ab8a042
MATLAB
556
16
% This functions is depricated. % % Because this function does not print but displays the design, it is now % called display_design(). Otherwise nothing changed. % % For convinience the function calls display_design(cfg) for you. function table = print_design(cfg) warning('print_design:deprecated', 'print_design() is...
4b4a2b880fd2876e1d61d93c4cf66bc3bcb05c8ae7719d369183cf0580b27ae8
MATLAB
556
27
function [gap, res, fmt] = calGap(actigraphy, epoch, quality) %CALGAP calculate gap percentage from gap file % % GAP = CALGAP(ACTIGRAPHY, EPOCH, QUALITY) % % $Author: Peng Li % gapseries = ~quality; if any(gapseries) gap = DetConstantOne(gapseries); else gap = []; end % request res...
4f864089e51299d7cc4f69f6ea9c27948dd416db5f505b282c4e94e6b6a183c8
MATLAB
556
13
% output = transres_primal_SVM_weights_nobias(decoding_out, chancelevel, cfg, varargin) % % Deprecated function use which is directed to transres_SVM_weights % % See also transres_SVM_weights.m % % Martin, 2014-10-27 function output = transres_primal_SVM_weights_nobias(decoding_out, chancelevel, cfg, varargin) wa...
b20655fa2e8bd08157b1fdd956e19e4af2a475f99c949fb919e7e0309dacdc95
MATLAB
557
25
% FIRFILT FIR filtering with zero phase distortion. % % matrix columns are filtered; % output is a column vector / matrix. % 19-Jul-02 ES % 27-jan-03 zero phase lag function Y = firfilt(x,W) if all(size(W)>=2), error('window must be a vector'), end if numel(x)==max(size(x...
3f0e5cb4895f6265f7ce1effc0ba4d0a0c20fb99fca57619be24971907cd6a5d
MATLAB
558
17
function [c] = cols(X) % 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 toolbox is available free and % unsupported to those...
5e357307132a0cd2124195175486609437f86b474953eb70ece4ecabacb12c20
MATLAB
558
18
function [XrandS] = SR_create_CCinformed_surrogates(data,U,nSurr) %% Create CC-informed graph signal surrogates by randomization of real eigenmodes Fourier coefficients clear XrandS X_hat_rand=zeros(size(data,1),size(data,2),size(data,3),nSurr); for s=1:size(data,3) X=data(:,:,s); for n=1:nSurr ...
642b80a6e8cc429795647abd5e50bb9da62b5f31a2e53ff7764d3b31bd3dd965
MATLAB
558
18
function changeFolderName(subjectPath) % This function renames a folder % Written at April 17, 2020. %% Input checks if ~exist('subjectPath','var') subjectPath = s3SubjectPath('01'); end oldFolderName = awsModifyPathForCompetability([subjectPath '\Log\14 Image Pair Quality Control\']); newFolderName = a...
94f73e5afa6c31024d667a5d7c1560ec62abbcbb6123274558c1e1512d1623f0
MATLAB
558
17
function [r] = rows(X) % 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 toolbox is available free and % unsupported to those...
f8be7733ea3918b298980887b5ad0ffb712958bd1245762cbd6d8f8146c5ecd4
MATLAB
558
17
%% Prepare Vidoe-based markers %% extract video coding information from coded csv files Extracting_video_coding_PT_EEG(); %% extract timing info from EEG and video coding and align them Extracting_EEG_timingtest_PT_EEG(); %% Align EEG and video and create new video-based marker file EEG_video_alignment_PT_E...
42f574dd0e446f3de78f1961edbeaad4c3f7da2e866bf9b5dbff2cd3494673e2
MATLAB
559
17
function model = ensemble_balance_train(labels_train,data_train,cfg) switch lower(cfg.decoding.method) case 'classification' model = ens_bal_tr(labels_train,data_train,cfg); case 'classification_kernel' model = ens_bal_tr(labels_train,data_train,cfg); ca...
6ff019e15b3798fa015dad855c34ff734473c82bfeece878c08c886b819f9432
MATLAB
559
19
function histogram_Jin(data, color, x_label, y_label, pic_title,output_path) % h=histfit(data); h=histogram(data,'LineWidth',2,'FaceColor',color./255); xlabel(x_label); ylabel(y_label); title(pic_title); set(gca,'FontSize',20,'LineWidth',3); ymax_value=round(max(h.Values)+max(h.Values)./8); ylim([0 ymax_value]); % xma...
7c2b0a18a0d023adb05bd990786174a7014281066f9095949673c31684dd2bdf
MATLAB
559
19
function struct = matrix_statistics(matrix, bsl_i1, bsl_i2) 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(matrix(:,bsl_i1:bsl_i2),0,2); [r,c]=size(matrix); stru...
423c68de0cf542dfb7041870d6f7c3550e16719a8d602cca06133eddb2b3733a
MATLAB
562
21
function out = yOCT2Tif_ConvertBitsData(in, c, isInputBits, maxbit) % isInputBits - when set to true will convert bits -> data % false convert data -> bits %% Input c = sort(c); if ~exist('maxbit','var') || isempty(maxbit) maxbit = 2^16-1; end %% Conversion if isInputBit...
d055aed8cd5977e1de6aebfc448b88aa777c88b488eab3e6d7d5acdd881b3742
MATLAB
562
32
function [AX, AY, A] = AngularAcceleration(VX, VY) t = Range(VX, 'ts'); ty = Range(VY, 'ts'); if length(ty) ~= length(t) error('VX and VY don''t have the same length'); end if any(ty ~= t) error('VX, and VY don''t have the same times.'); end dt = diff(t); vx = Data(VX); vy = Data(VY); ax = diff(vx) ./ dt; ax ...
27319c62b397baaead08ce810d8597070ba6e7cc7de7909f46b4b60005ab30a6
MATLAB
563
29
function v = get(O, k, varargin) % v = get(D, k, x) returns item in dictArray D with key k, if key present, otherwise x % % it doesn't give an error if key is not present. In that case, if x is % not passed, it returns the empty array % copyright (c) 2004 Francesco P. Battaglia % This software is released under ...
65582b25a958fd1425b8d2668b61f35ee170c25ccc20af83d7f5f5f165ddc8e3
MATLAB
563
26
classdef KnnClassifierModel < ClassifierModel properties NumNeighbors knnObject end methods function mdl = KnnClassifierModel(k) if nargin > 0 mdl.NumNeighbors = k; end end function mdl = train(mdl,X,...
cb41179229a5457ad26ff29ad1fedb29efb5032773467157cca4d0f317e39db1
MATLAB
563
17
function write_new_tunnel_pseudo_times(pseudo_sub_dir, spike_idx, time_idx,is_ff, channels_to_write) % you can restore original pseudo_times from % create_pseudo_times_files_220216.m spike_times=time_idx(spike_idx)*1e3; clus_num=ones(length(spike_times),1); cluster_class=[clus_num,spike_times']; for i=1:length(channe...
84e9a9e2c4f3aed825cb00c52bc66a25754ddbdc802d652d18aac419fb782636
MATLAB
564
14
% function distmatrix_s=makeDistMatrix_s(coords_t,maxtime_s) function distmatrix_s = makeDistMatrix_s(coords_t) num_neurons = size(coords_t,3); distmatrix_s = zeros(num_neurons, num_neurons, 1, 3); h = waitbar(0,'Building distance matrix ...'); for i = 1:num_neurons waitbar(i/num_neurons,h...
00e0f77a6cfdb9d1a03c4e6c12af162140e97d96a39a52916d7336f33ecca113
MATLAB
566
24
function [net, error] = mlptrain(net, x, t, its); %MLPTRAIN Utility to train an MLP network for demtrain % % Description % % [NET, ERROR] = MLPTRAIN(NET, X, T, ITS) trains a network data % structure NET using the scaled conjugate gradient algorithm for ITS % cycles with input data X, target data T. % % See also % DEMT...
29c7bd0b5e7ea8e76b74088aef9352c9ecf055d4d28d7ace385b00341939974c
MATLAB
566
21
function RGBimage = im2RGB(image, cmap, I_low, I_high) image = double(image); numColors = size(cmap, 1); intIm = (image - I_low)/(I_high - I_low); intIm(intIm(:) < 0) = 0; intIm(intIm(:) > 1) = 1; intIm = ceil(intIm*numColors); intIm(intIm(:) == 0) = 1; rIm = zeros(size(image)); gIm = zeros(size(image)); bIm = zeros(s...
64552721ff3cf9ef93c61294045be96b768df1fdf5c61383c369e7e7c03ce658
MATLAB
566
22
function [iserr] = iserror(cmd) % This is part of the MVPA test suite. It evals CMD inside a % try/catch block. If an error is raised, then returns true. If no % error is raised, returns false. % % This is useful if you're expecting/hoping that a function will % fail when it's supposed to fail, e.g. if you don'...
7b7f198b49b5a92a1cb15d513ee897725f0ec355a250874ec8d01e7de329de7d
MATLAB
567
23
function [errs warns] = alert_unit_errors(errs,warns) % Alerts if there are errors in a unit test % % [ERRS WARNS] = ALERT_UNIT_ERRORS(ERRS,WARNS) % % Ideally, you'd run all your unit tests en masse as part of % a suite, but if you have an individual unit test function % that you want to run, just call this at the end...
d749ff814e8e054e06044f7a4ba2f2c7a31de49f7c489d4c01c948470d7de86c
MATLAB
567
30
function [y_solved, sigmas] = simple_wiener_veryfast(data,rf, sigmas_only) [Nc, Nt, Nr]=size(data); data=reshape(data, Nc, []); C = data*data'/Nt; c=sum(diag(C))/Nc; C=C+c*rf*eye(Nc); W=inv(C); D=1./diag(W); sigmas=sqrt(D); if sigmas_only y_solved=[]; else y_solved=(diag(D)*W')*data; y_...
cff191545595843725edc12697635b229314db2d0a5bc1a16ece63e51492bec1
MATLAB
568
30
function PoSubPaper_GetCellTypesADN sdSmooth = 3; %% load data load(fullfile('Analysis','MeanFR')); load(fullfile('Analysis','HdTuning_moveEp')); hdi = hdInfo(:,sdSmooth+1); frate = rateS; gd = frate > 0.5; %% define groups % FS cells fs = zeros(length(frate),1); % ...
0f420f392c1fe895a2dcbbd6d6075bf865c258fa202b69db7bba0333953f4836
MATLAB
569
18
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Authors : CHATENET Louis % Date : 24/05/2018 % Updated : 30/05/2018 % Version : V2.0 % % Description : AMPA current calculation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [Isyn, r] = IsynAMPA2(dt...
2ca31a1c370a602e9ae52802574d7aebe6d63080274d75d0b402ae8445bb57d1
MATLAB
569
18
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Authors : CHATENET Louis % Date : 24/05/2018 % Updated : 30/05/2018 % Version : V2.0 % % Description : AMPA current calculation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [Isyn, r] = IsynAMPA4(dt...
4e8d6a986ca50ab50350e876a63e283f4ace76869a91a3bb798281a6fb0827a8
MATLAB
570
26
function [errmsgs warnmsgs] = unit_convert_maskpat_idx() % Tests CONVERT_MASK_TO_PAT_IDX and CONVERT_PAT_TO_MASK_IDX % % [ERRMSGS WARNMSGS] = UNIT_CONVERT_MASKPAT_IDX() % % Only a single, rudimentary confirmation that the one % undoes the other. errmsgs = {}; warnmsgs = {}; mask = round(rand(10,10,10)); keep_idx =...
4fb0804f7cfe85c9d81426e8a1839f45bc49a149cd5b1bfd0b10ce8db8db2345
MATLAB
570
15
function [loglik,phtgV1T,phthtpgV1T] = vbhmmEstep(v,stran,sprior,logOutputs) nSubjs = length(v); parfor ns=1:nSubjs [logalpha,loglik1]=VBHMMforward(v{ns},stran,sprior,logOutputs{ns}); logbeta=VBHMMbackward(v{ns},stran,logOutputs{ns}); [phtgV1T1,phthtpgV1T1]=VBHMMsmooth(logalpha,logbeta,logOutputs{ns}...
19ea63fd69f5a17f48e98dc7d4fef95d6fd9b4738eec9d936bf04921d5fefef6
MATLAB
571
21
function [xFil, yFil, zFil] = DecomposedGaussian3(sigR, numSig) if length(sigR) == 1 sigR = repmat(sigR, [1, 3]); elseif length(sigR) == 3 else error(''); end kernelSize = ceil(sigR.*numSig) + mod(ceil(sigR.*numSig), 2) + 1; x = -kernelSize(1):kernelSize(1); y = -kernelSize(2):kernelSize(2); z = -kernelSiz...
77e444a8226518174fc8844585efbcc0685454d6f939fa0ee6c081f11ec4e757
MATLAB
571
17
function C=xcorrelation_matrix(n) nen=numel(n); for i=1:nen for j=i+1:nen valid_times=intersect(n(i).coords(:,4),n(j).coords(:,4)); crrltn_p=max(xcorr(n(i).coords(valid_times,5),n(j).coords(valid_times,5))); crrltn_n=max(xcorr(n(i).coords(valid_times,5),-1.*n(j).coords(valid_times,5)))...
b092c9b2b427a057aa08ca6468a47a23ebf775c2af6b500f0e436679e10139e3
MATLAB
571
32
function K = kernelD(xp0,yp0,len) D = size(xp0,1); N = size(xp0,2); M = size(yp0,2); % split M into chunks if on GPU to reduce memory usage if isa(xp0,'gpuArray') K=gpuArray.zeros(N,M); cs = 60; elseif N > 10000 K = zeros(N,M); cs = 10000; else K= zeros(N,M); cs = M; end for i = 1:cei...
7db4a406df16c229c6bbb32ad3e1b51773792d04c1280c994b27525c35cd47cb
MATLAB
573
21
function lvl1_save(i_sub, p, model) data_dir = p.dirs.data; title = p.lvl1.title; sub_str = num2str(i_sub,'%02i'); out_file = fullfile(data_dir, 'Nifti', ['sub-' sub_str], 'lvl1', title, ['lvl1_log_' datestr(now,'yymmddHHMM') '.mat']); % only save if there are non-e...
85bf26444a0cde32b8e2280e0e71a40eb8e1bdaedf8046c14deeba736c4375c4
MATLAB
573
22
function S=tracerealign(T,align,at); % function S=tracerealign(T,align,at); % returns a realigned version of the timeseries in T % the point align(i) is shifted to at % T: NxT matrix of N timeseries % align: N*1 vector of align times % at: scalar S=T.*NaN; len=size(T,2); for i=1:size(T,1) if (~isnan(ali...
8cbd350e4e162e70f55a627539dbdd9db0c4a925adaaf92dc66fe837299ce152
MATLAB
574
21
function [delta_f, f0] = propagateErrorDxi(fun_handle, x0_vals, dx_vals) % fun_handle should be a scalar function of x0. x0 may have multiple % entries. dx_vals are the variations in each of the entries. delta_f is % the expected variation in the function output % error propagation method % df^2 ~ ((df/dx1)dx1)^2 + (...
acb8c9a1c3635fa15888585d000a938072ede9f9c14638827e8195fd7373dcfa
MATLAB
575
24
function posizione = verificaPosizionePunto_2(punto, planeCoeff) % Estrai i coefficienti del piano A = planeCoeff(1); B = planeCoeff(2); C = planeCoeff(3); D = planeCoeff(4); % Estrai le coordinate del punto x = punto(1); y = punto(2); z = punto(3); % Calcola Ax + B...
f1baa3b4d3a4b6f8c3c980532bbd890cc74fdae64717e12db79eced8b4a85b67
MATLAB
575
33
%res = digamma(X) % % Calculates the digamma function. % % Loops on rows of a matrix - could be optimized better % % Matthew J. Beal GCNU 06/02/01 % This is a hack (Rasmussen). function res=digamma(X); coef=[-1/12 1/120 -1/252 1/240 -1/132 691/32760 -1/12]; krange = [1:7]'; [n, m]=size(X); res=zeros(n,m); for i=...
63b1d025a27fac6dc2b16191118285bad05df69638991d61d34f0b2a3432f5f2
MATLAB
576
27
function [mat] = vol2mat(data, selected) selected = logical(selected); dim = size(selected); if (length(dim) == 3) N_samples = size(data, 4); mat = zeros(length(find(selected)), N_samples); vol_temp = zeros(dim(1), dim(2), dim(3)); for t = 1: N_samples vol_temp = data(:, :, :, t); mat(:, t) = vol_temp(selec...
4962b82d965bdd67817599e11b9c7e0427171f342f11077af80475802ebcb5e9
MATLAB
578
33
% %plot stop/start markers on a raster. % %plotModeBottom: if enabled (1), plot the lines at the back, not over what is in the plot % % function h = plotTrialMarkers( markerPos, col,lw, plotModeBottom ) if nargin<2 col='r'; end if nargin<3 lw=2; end if isempty(lw) lw=2; end if nargin<4 plotModeBottom=0;...
941f195cee63c9b8f09771a41debdc5d7a9f53474f756c4816dfe09f92aa8c65
MATLAB
578
18
function [y] = cellrowselect(x, rows) % [Y] = CELLROWSELECT(X, ROWS) outputs cell-array Y with the same dimensionality as X % Each cell in Y only contains the rows ROWS 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 same...
9c81645f7508e102eca88034ab79ba154cbcee5bc9c2a510fd5f73a271ee1e73
MATLAB
578
19
%% %Accuracy plots clear load('all_timesample.mat') m=squeeze(mean(resSall,1)); gpSize=[22,24,21,27]; for group=1:4 m2=squeeze(mean(m(:,:,:,group,1:gpSize(group)),5)); s=squeeze(std(m(:,:,:,group,1:gpSize(group)),1,5)); figure, errorbar(m2(:,1:3,2),s(:,1:3,2)./sqrt(gpSize(group))) ax = gca; ax.XTickLa...
51859de03a4af66c97578871b9041a89c0fa70c753cedb1d83f26503fb621bd4
MATLAB
579
27
function [y] = yuent(x1, x2, percent, dim) if nargin<4 dim = find(size(x1)>1, 1, 'first'); end if nargin<3 percent = 0.2; end n1 = size(x1, dim); g1 = floor(percent*n1); [mu1,thrlo1,thrhi1] = trimmean(x1, percent, dim); s1 = winvar(x1, cat(dim, thrlo1, thrhi1), dim); h1 = n1 - 2*g1; d1 = ( (n1-1)*...
c0d29dacf7f798d54ac4ebd33557554a8805c3cb3cb25bc177f20fd1c5163640
MATLAB
579
24
function [res, fmt] = detQC(actigraphy, epoch, varargin) %DETQC do actigraphy qc % % [RES, FMT] = DETQC(ACTIGRAPHY, EPOCH, STARTTIME) % performs QC on ACTIGRAPHY of epoch length EPOCH and % return results to the caller. % FMT request the format to write RES to file % % $Author: Peng...
c667179ec015dadfed1192240cee4667897fbc7e815b305ead3441ea02a04fab
MATLAB
579
25
function SI = PlaceFields_StabilityIndex(fr1,fr2) % USAGE: % SI = PlaceFields_StabilityIndex(fr1,fr2) % % Computes stability index between two place maps. % The index is definde as the average Hellinger distance between each bin, % assuming they are drawn from Poisson distributions. % % INPUTS: % fr1,2: ...
b8a1cf532c290ab734b33edf8bc35a558e482336d9e55563e880302441eb307e
MATLAB
580
25
clear clc close all addpath('data') addpath('src') dataset = {'1_mECS', '2_Kolod', '3_Pollen', '4_Usoskin'} for i = 1:4 % perform the analysis for the current dataset load(['Test_' dataset{i}]); C = max(true_labs); %%% number of clusters rng(i,'twister'); %%% for reproducibility [y, S, F, yda...
0e4d4abad661d7cc387fc4032dceb5fc377f04ade63514f8e51eece0c4c41bd7
MATLAB
581
23
function assign_fid_211118(folder_address,parent_dir,is_prestim) cd(folder_address) current_dir=dir; dir_names=string({current_dir.name}); folders=isfolder(dir_names); folders([1,2])=0; dir_names=dir_names(folders); for i=1:length(dir_names) fid=i; filename=dir_names(i); if is_prestim save(strcat(...
76dc59284196cdadb36ba75841adce856628598382412841f402c357a9832913
MATLAB
581
21
%% Load Data Files and add common functions folder to path load('../data/behavData.mat') % Extracting Behavioral data session_list = [4:15 18 20:45]; % sessions excluded: % [1,2,3] : no invalid trials tested % [16,17] : corrupted eye tracking data % [19] : no V4 recordings [beh_dat,~] = get_beh_dat(behav...
9da8a93abc7011a759281217d53514483dc537df1d59ac7acaa43bc17028a00f
MATLAB
582
20
function CalibrateLEDorientation_Moser() [~,fbasename,~] = fileparts(pwd); [X,Y,ang,wakeEp] = LoadPosition_Moser(fbasename); ang0 = atan2(diff(Data(Y)),diff(Data(X))); ang1 = Data(ang); angOffset = CircularMean(ang1(2:end)-ang0); if angOffset > pi angOffset = angOffset-2*pi; end figure(1),clf plot(mod(ang0,2*pi),...
305a1fac174f7e7b07e802c806b20ee51c5a4ea379145fce3f0d1b9f446f9afe
MATLAB
585
15
% This script generate datasets in multiple resolutions and scales % Set date time such that all dataset will carry same date dataSetInitDate_ = datestr(now,'yyyy-mm-dd'); call_scriptGenerateDataset('10x',dataSetInitDate_); call_scriptGenerateDataset('4x',dataSetInitDate_); call_scriptGenerateDataset('2x',dat...
b603ee7bc7536cb39467001ba6da120441c39ea277dbfe19bcb26f028417a565
MATLAB
585
17
%% Read Configuration Data, read all jsons jsons = s3LoadAllSubjectSectionJSONs(subjectPath_,sectionName_); %% Histology Image jsons.slideConfig.data.alignedImagePath_Histology = 'HistologyAligned.tif'; slideFolder = [fileparts(jsons.slideConfig.path) '/']; histFilePath = awsModifyPathForCompetability(... ...
ec0c86ce0615893791104aeeb6633ff9293769fdea1ae9fd753630f35393361f
MATLAB
586
20
function histogram_tutoring(data, color, x_label, y_label, pic_title,output_path) % h=histfit(data); h=histogram(data,5,'LineWidth',2,'FaceColor',color./255,'EdgeColor',[1 1 1]); xlabel(x_label); ylabel(y_label); title(pic_title); set(gca,'FontSize',20,'LineWidth',2); box off ymax_value=round(max(h.Values)+max(h.Value...