sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
4a1ada28387c468ddad8c60f47907fca0b74f01ae8aee7c2f921335ba11d2bfd
MATLAB
857
31
function [Zw, T] = whitenRows(Z) % % Syntax: [Zw, T] = whitenRows(Z); % % Inputs: Z is an (d x n) matrix containing n samples of a % d-dimensional random vector % % Outputs: Zw is the whitened version of Z % % T is the (d x d) whi...
782ebf897133f563b47481ae83415f4baebf6ba9b562a6f4c6db71ec5069c642
MATLAB
857
27
function [Signal,State,Gwave,Trans,b] = InitialisationAmplitude(alpha,phi,E1,E2,Scenario) %% if strcmp(Scenario,'First') %Initialise First Dictionary %Obtain initialisation amplitude Lrec=1-E1; LtoL=E1.*cosd(alpha); A=Lrec/(1-LtoL); %Calculate rotation matrix [rotMat] = EPG_Operator(alpha,ph...
8e4dba0a82373ba66748a2dc6b93d561eb5a457e4f396e3c50740ea00fdb15b9
MATLAB
857
42
% The values used in the latex pstricks figure x11 = 5; x12 = 3; x21 = 7; x22 = 3; % Values for the tree in each region r = 2:2:10; % Create a mesh for X1 and X2 h = 0.1; M = 10; X1 = 0:h:M; X2 = 0:h:M; % The matrix to store the values of the tree tree = zeros(length(X1),length(X2)); % The five regions - manually ...
d71aaa843ac6262748b9a00ef55e545243e906ffde85276551c386240ed7c9d1
MATLAB
857
30
function [familyBels, logZ, nodeBels] = dgmInferFamily(dgm, varargin) %% Compute the beliefs for the family of every node % Optional args are the same as for dgmInferQuery % % If requested, nodeBels{i} is the ith marginal, if the ith node has a local % CPD, and empty otherwise, (used by dgmTrainEm). %% % This file is ...
dcffdf93a82dde2f37674c57d5d5c39012e353d3f8f500a2fac41ec5da7c63fe
MATLAB
857
32
function [new_faces new_points]=boundfaces(points,tet,renumber_flag) % boundfaces Find boundary faces from tetrahedral mesh % bdy_faces = boundfaces(tet) % if renumber_flag is not specified or if it's true then % the returned faces and points are renumbered and % the node numbers in 'new_faces' does not follow...
f89a1441ed64b42e2443d3b72ef8f2d21e67c014d5a21157db1ee28ea67a2ffe
MATLAB
857
20
function ImageArrayRegBC_NoStim = BleachCorrectArray(ImageArrayReg_NoStim, Vector_AllNoStim_GFPAvg, AllBoutonsRegion) ImagesPerSequence = length(Vector_AllNoStim_GFPAvg); NumOfSequences = size(ImageArrayReg_NoStim, 3) / ImagesPerSequence; for SeqNumber=1:NumOfSequences FirstIndex = (ImagesPerSequenc...
50f1bbe449409e96cfcf53ae026db0ab755020db3b5d76e8c685e2ab540ea799
MATLAB
858
25
fov = zeros(d1,d2); figure; imagesc(fov) colormap(white) hold on; for assemblyCounter = 1:length(ICA_results.assemblyMembers) %subplot(4,4,assemblyCounter); %title(['Assembly' num2str(assemblyCounter)]); color = rand(1,3); for assemblyMembCounter = 1:length(ICA_results.assemblyMembers{1,assemb...
51889b1cfe39646637e143b0512b7db6eb1391c4292355d27733b125d930ba92
MATLAB
858
40
function voxels = mask2voxel(mask) % convert from 3-D mask to voxel list in canonical orientation % % :Usage: % :: % % function voxels = mask2voxel(mask) % % [i j k] = row, column, slice % % [x y z] in brain if brain is in analyze format % % (x is rows, y is columns, z is slices) % % .. % Tor Wager, 10/17/01 % %...
bb04ab66bf35523592a7abc54136f8aa2fa68f1cedba3a89151a3df3eca88a5e
MATLAB
858
29
function mscmd_normalize_channels(input_path,output_path,opts) %MSCMD_NORMALIZE_CHANNELS - Normalize each row (channel) to have unit variance % % This is a wrapper to the command-line mountainsort procedure. It has % identical functionality to ms_normalize_channels.m % % Syntax: mscmd_normalize_channels(input_path,out...
bfa1683be2210ed9d2bc6a8b5eb0d5875ef17ba2a758419a288ca519c7095a91
MATLAB
858
35
%% Demonstration of the Central Limit Theorem, based on Bishop 2.6 % %% % This file is from pmtk3.googlecode.com function centralLimitDemo samples = 100000; bins = 20; N = [1 5 10]; for i=1:length(N) figure(i); convolutionHist(N(i),samples,bins); printPmtkFigure(sprintf('cltBeta%d', N(i))); end %% %Plot a...
d00b62cb1f2a3bfda05f19530d746748edeedbb2537ea045b851142d96b8e02f
MATLAB
858
29
function [W, Z] = fisherLdaFit(Xtrain, ytrain, K) % Optimal linear projection from D dimensions to C-1 % Xtrain is N*D, ytrain(i) is in {1,2,...,C} % W is D*K, where K <= C-1 % Z is the project of Xtrain onto W, i.e. Xtrain*W %% % This file is from pmtk3.googlecode.com C = max(ytrain); if C==2 ndx1 = find(ytrain=...
d14379366be2f77b2956132a1d5c92e12e394a1d37a873a703ebe023920a96c9
MATLAB
858
39
function [V,Y] = readVol(fname) V = spm_vol(fname); visstruct = false; if nargout > 1 if isstruct(V) visstruct = true; V = {V}; end for i = 1:length(V) Y{i} = spm_read_vols(V{i}); for j = 1:length(V{i}) V{i}(j).dt = [16 0]; %cast structure to FLOAT32 so we...
e50e0020c9e19a337e0c23161c64f4e42fc380805027f24f71d82edd73e7f48e
MATLAB
858
26
function [theta_o,phi_o] = refract_ray(theta_i, phi_i, theta_n, phi_n, n1, n2) x_i = [sin(theta_i).*sin(phi_i),sin(theta_i).*cos(phi_i),cos(theta_i)]; x_n = [sin(theta_n).*sin(phi_n),sin(theta_n).*cos(phi_n),cos(theta_n)]; % Compute the dot product between the incident direction and the norma...
1617f2ebcad1eeab87ee7a03df84158ec6325a66054c69574dcb782855be70c7
MATLAB
859
31
function [indexout]=contiguousframes(index,nframes) % contiguousframes: takes a binary index and locates contigous sections % that are at least nframes long % % Input: % index: binary index % nframes: min number of contigous frames you wish to have % % Output: % indexout: new inde...
2990915daf3b9bffdbd67323ec38e1cb4b566a62a515d2406eb65987261f246c
MATLAB
859
31
function [SNReff] = DWSE_SNREfficiencyOscillating(x,optSample,optScanner,tau,~) %% % calculates DW-SE SNR Efficiency % % input: % x = array with diffusion gradient (mT/m) and repetition time (ms) % optSample = T1 (ms), T2 (ms) & D (um^2/ms) % optScanner = Maximum readout duration (ms) & Minimum time between end o...
2d884eb707e80480f738b3a738e50508ee1debd893a162d2985426abd8e93a30
MATLAB
859
38
%% Conjugate Function Lower Bound % %% % This file is from pmtk3.googlecode.com function conjugateFnExpLowerBound f = @(x) exp(-x); domain = 0:0.01:3; xi = 1; offset = 0.015; t1 = @(x) -exp(-xi)*x + f(xi)+exp(-xi)*xi-offset; t2 = @(x) -exp(-0.5)*x + f(0.5)+exp(-0.5)*0.5-offset; t3 = @(x) -exp(-2)*x + f(2)+exp(-2)*2-...
6a20e872178cdbe54f8ad23a9a4dca133aae373fc2b00d10f35ffdb69e3374ee
MATLAB
859
18
function [dim, options] = setPriors(options, dim, priorType,varargin) switch priorType case 'theta' [options.priors.muTheta,options.priors.SigmaTheta, options.inF.thetaLabel] = feval(@priorUglyfier, varargin{:}); nTheta=length(options.priors.muTheta); dim.n_theta = nTh...
88bd9839d47a0eb9c7de3c56e241cbad0d56fc9e8f2ff30668479697875f76b1
MATLAB
859
23
function correlation_coefficient = corrcoefNew(matrixA, matrixB) % Check if the matrices have the same dimensions if ~isequal(size(matrixA,2), size(matrixB,2)) error('Input matrices must have the same dimensions.'); end % Calculate the coefficient coef = 1/(length(matrixA(1,:))-1); % Cal...
d56320a5cad21f952c85e2be07a6bc91fc939395efe40b4f033ec47b674e8f96
MATLAB
859
33
function Y = clfKnnFwd( clf, X ) % Apply a k-nearest neighbor classifier to X. % % USAGE % Y = clfKnnFwd( clf, X ) % % INPUTS % clf - trained model % X - nxp data array % % OUTPUTS % Y - nx1 vector of labels predicted according to the clf % % EXAMPLE % % See also CLFKNN, CLFKNNTRAIN % % Piotr's Imag...
09f3638e9141713772c36761607f2247f8d930850d52d5c32f8ab7d877caf2aa
MATLAB
860
36
function [gx,dgdx,dgdp] = g_DCMwHRFext(Xt,P,ut,in) %- initializations idX1 = 1:in.n5(end); nreg=length(in.n5); nresp=length(in.r); gxr=zeros(nresp,1); dgdxr=zeros(length(Xt),nresp); dgdpr=zeros(length(P),nresp); %== compute gradients [gxn,dgdxn,dgdpn] = g_HRF3(Xt(idX1),P,ut,in) ; for iR = 1:numel(in.sourceRespIdx)...
15605ec3185cd8a2ac9bf3f61c8c88d7ff54861b2078a3f3b6049f0ff5439671
MATLAB
860
31
% Event-triggered average of signal function [avg, nEvs] = ev_trig_avg(event, signal, windowSize, varargin) event(1:windowSize/2)=0; event(end-windowSize/2:end)=0; nEvs = sum(event); % n events evIdx = find(event); %event times avg = zeros(1,windowSize+1); %preallocation x = -windowSize/2:1:windowSize/2; % x axis (...
17632066f6ee53a670ff3ee221b46995a21f1cfef58d79b2facd71f49333b228
MATLAB
860
29
function [Fastqstructs] = saveExSeqToFastQLike(transcripts,confidences,headers) %SAVEEXSEQTOFASTQLIKE % Write to standard sequencing format for analysis in FASTQC etc. %initialize the fastq structs Fastqstructs(size(transcripts,1)) = struct; mapping_base = 'ACGT'; mapping_quality = '!"#$%&''()*+,-./0123456789:;<=>?@A...
14102c5745f33126df25843db734db31c4ccae982c14ac85b142259090beebb7
MATLAB
861
28
function egrad = essential_egradE2egrad(X, egradE) % Converts the gradient in essential matrix E to the gradient in X. % % function egrad = essential_egradE2egrad(X, egradE) % % egradE is the function handle for the gradient in E. % % The output is a matrix in the space of X. % % See also: essential_costE2cos...
359454cfc7db86d748b9cb34dbf16e390913a0e350527138a93278d8feaf45fa
MATLAB
861
29
function compute_aec(params,bidsID,freqBand) % Load EEG data data = load_preprocessed_data(params,bidsID); % Band-pass filter the data in the relevant frequency band cfg = []; cfg.bpfilter = 'yes'; cfg.bpfreq = params.FreqBand.(freqBand); data = ft_preprocessing(cfg, data); % Load source reconstruction data load(full...
40ad61189b4cccd5f7472d6edb4e2d4242214981c5c533dc5f05c619a612c86b
MATLAB
861
28
function FiringBVC = firingBVC(RatX,RatY,Dist2Walls,OptD,OptA,SigAng,Beta,Sig0) SigRad = zeros(size(Dist2Walls)); SigRad = Dist2Walls./Beta + Sig0; TwoSigRadSqr = 2.*(SigRad.^2); Step = 2/length(Dist2Walls); Bearings = (0 : Step*pi : (2-Step)*pi); TwoSigAngSqr = 2*(SigAng^2); AngDif = zeros(size(Bearings...
5af379be8c3b605edcb91c5b30cd1fd528e08cc2e3fa475b87ce996803be5540
MATLAB
861
19
function plot_sectors(this_center, circle_rad, sector_endpoints, random_color_red_colony, theta) num_sectors = length(sector_endpoints)/2; sector_points = zeros(length(theta) + 2,2); sector_points(1,:) = this_center; sector_points(end,:) = this_center; for this_sector = 1:num_sectors sector_arc = linspace(se...
5efaca3dc254d233d1284bded128282ae17fe7f4f90b4459822943c3d6ff6364
MATLAB
861
29
function [] = violinPlots(data,yl,plotdist,plotLegend) [f,~] = ksdensity(data,data,'Support','positive'); [f_dens,x_dens] = ksdensity(data,linspace(yl(1),yl(2),200),'Support','positive'); m_f = max(f_dens); f = f./m_f; x = (rand(size(data))-0.5).*f; scatter(x,data,'k','LineWidth',1);hold on; plot([-0.5 0.5],mean...
79efa70de8e82b65d2bc6593d7e2eb7f07bfcde441e5528689c59202b9d1c7b9
MATLAB
861
32
function Image_Crop=SmartCrop(Image,Crop_XCoords,Crop_YCoords) Crop_XCoords=round(Crop_XCoords); Crop_YCoords=round(Crop_YCoords); ImageHeight=size(Image,1); ImageWidth=size(Image,2); ImageDepth=size(Image,3); Fixed_XMin=Crop_XCoords(1); if Fixed_XMin<1 Fixed_XMin=1; e...
8baca77cbc5670d14dc5d308302481a1345cba250d33cfbd134f7539f1e9c7c9
MATLAB
861
24
function targetPresentationTimes = choosePseudoRandomTargetTimes(targetPeriodDur, nTargets, targetCushion) if nargin==0 targetPeriodDur = 10; nTargets = 1; targetCushion = 1; end isi = targetPeriodDur/(nTargets+1); possibleTargetOnsets = isi:isi:targetPeriodDur + targetCushion; targetChoices = randperm(nu...
d7c05d6fcbf2f2e7364d4bf76066ea97f688dbfb7c92a6e3d9bbfeb96c088205
MATLAB
861
30
function [edges] = nodal_distance_tetrahedron(a,b,c,d) % NODAL_DISTANCE_TETRAHEDRON Calcultes tetrahedron edges length. % % SYNTAX: % [EDGES] = NODAL_DISTANCE_TETRAHEDRON(A,B,C,D) % NODAL_DISTANCE_TETRAHEDRON(A,B,C,D) % % [EDGES] = NODAL_DISTANCE_TETRAHEDRON(A,B,C,D) % - A, B, C and D - are m by 3 matrices of (x,...
db794e069139e271bf6ec1c49b4cda5735a830f727b9c68bfa2fa3f41f99645c
MATLAB
861
25
function unit = ExportToUnit(spkDat, rat, date, trode, implantSide) spkDat.waves = double(spkDat.waves); [wL, ~, ~] = size(spkDat.waves); wP = spkDat.wavePad; wL = wL - 2*wP; pts = (1:wL) + wP; clustList = setdiff(unique(spkDat.id), 0); for i = 1:length(clustList) loc = find(spkDat.id == clustList(i)); unit(i)...
7845b28bceb735d552a6095d80eb8f4d1b76797177092909129ef428c65cd2f8
MATLAB
862
32
function ndx = greedySpan(set, subsets) %% Greedily build up a set from a minimal number of disjoint subsets % Example: greedySpan(1:10, {[2 3], [2 5 7], [1 4] [1 3 4 6 10], [8], [9]}) % will return indices [2, 4, 5, 6] in the subsets cell array % % If no solution can be found, [] is returned. %% % This file is from p...
aca7236575c580243191dc3ce6ca0fccfdd02b1be3993db4b373b4bf8c1b5b8f
MATLAB
862
21
clear;clc;close all params.RDIdef = 1; % 1: onset[100 200] offset[-100 0]; 2: [200 250] [250 300] params.Win.early=[100 200]; switch params.RDIdef case 1 params.Win.late=[-100 0]; params.Win.RDIearly = [100 200]; params.Win.RDIlate = [-100 0]; case 2 params.Win.late=[200...
bc63251002951f275590a503154c7c93f788b2bbc6240bdb47f65c3b8459c722
MATLAB
862
31
function [f, xsp] = lan_cspd_mt(LAN, chn1, chn2, tapers, nomean) %***************DEPENDENCIES*************** % - mtfftc (chronux toolbox) % - dpsschk (chronux toolbox) if nargin < 5 nomean = false; end if LAN.trials == 1 disp('Se requiere señales segmentadas') f = []; xsp = []; else N = LAN.pnts(1...
ddcd5d2396d1f8237c11a43a443c553557a5b491ac9cd29bc558266bb1ffebe6
MATLAB
862
25
function [ fout, J] = nakarushtonbase( params, x ) %LOGISTICFUN evaluates modified logistic with params at x % Detailed explanation goes here %========================================================================== %define inputs x = x(:); Rmax = params(1); n = params(2); kappa = params(3); b ...
32f81e5651d180201d8feccae2c5102542b81e06b4e85dbacce441d785e25d8d
MATLAB
863
39
%% Bayesian Probabilistic PCA Imputation Demo % Reproduce Bishop fig 12.14 % Needs BPCAfill package from http://hawaii.sys.i.kyoto-u.ac.jp/~oba/tools/ %% % This file is from pmtk3.googlecode.com setSeed(0); %n = 100; n = 300; d = 10; %sigma = [5,4,3,2,1*ones(1,6)]; % ICANN'99 sigma = [1,1,1,0.5*ones(1,7)]; % book ...
38194b6a45297b3a3fd95ed53c707f9ac1da7dd3c0012c6a60d86b38c021f1d0
MATLAB
863
19
function prec_ssc(input_fn,ref_fn) for i = 1:numel(input_fn) matlabbatch{1}.spm.spatial.coreg.write.ref = {ref_fn}; matlabbatch{1}.spm.spatial.coreg.write.source = {input_fn{i}}; matlabbatch{1}.spm.spatial.coreg.write.roptions.interp = 4; matlabbatch{1}.spm.spatial.coreg.write.roptions.wrap = [0 0 ...
7a9ddb12ccc07fcca1b93588dba6289e9e47cfeef5236c16eb239126e346ccfe
MATLAB
863
37
check_active_images; for kk = ind_active, if ~exist(['x_' num2str(kk)]), fprintf(1,'WARNING: Need to extract grid corners on image %d\n',kk); active_images(kk) = 0; eval(['dX_' num2str(kk) ' = NaN;']); eval(['dY_' num2str(kk) ' = NaN;']); eval(['wintx...
cee8e05107e666f48366a396acecfbff86b20ba90251e3c0b4333d83168e71d3
MATLAB
863
28
function S=capitalize(S,skipset) %function S=capitalize(S) % Capitalize the first character in every word (excluding short words) in input % string S, or in every word in every string in input cell array S. The first word % is always capitalized. % % Default set of words to skip is {'a','an','and','or','in','th...
4b362134b734628060c2cc68cabe9e1b6a5cd2f5107ef1eeaf2d0742406dcd0f
MATLAB
864
30
function s = catString(c,delim) % Convert a cell array of strings to a single concatinated string % i.e. single-row character array). The specified delimiter, delim, is % added between each entry. Include any spaces you want in delim. If delim % is not specified, ', ' is used instead. If c is already a string, it is % ...
90606803c5303c86cd23a17b47f0afcaff0fc2b5cb75fed0c2c4b323f69316ba
MATLAB
864
23
% Geometric Distortions Correction - merge volumes to compute topup data = dir('/DATAPOOL/ERRORMONITORING/SEM_mri_data/P*'); %% for i = 1:size(data,1) data_func = dir([data(i).folder, '/', data(i).name, '/mri/SEM_', data(i).name, '/nifti/func/run*']); fprintf(data(i).name); for j = 1:size...
a992ca8c86352b24467cabeb4f3644b2e71b9cf9ee28b7eac11021b0dbfe33e7
MATLAB
864
33
% Copyright Christopher Fricke, University Leipzig Medical Center, % Neurology 2024 srcf1 = 'data\prep'; srcf2 = 'data\prep\coreg_indiv\datscan_normalized'; % klinische Daten laden [~,~,r] = xlsread(fullfile(srcf1,'clinicaldata.xlsx')); % Indices of interest binds = 4; % Datensatz vorbereiten pats = {}...
af5ea7e1db4b59c9b93423ded398007a07b7569c4c4b2bf029ffaa79ec744a80
MATLAB
864
20
% Get the -3dB cutoff frequency value using filtfilt.m % % WARNING: For working with filtfilt.m function! % % filtfilt result has the following characteristics: % a) Zero-phase distortion % b) A filter transfer function, which equals the squared magnitude of the original filter transfer function % ...
110c6090e5b4fc6e2d87cb3d261fda6476cb1cc9b5ecf9e9e00bb53fdda00d4e
MATLAB
865
37
function [nbrs, sepSets] = computeNeighbors(cg) %% Compute the neighbors, for each clique % %% Input % % cg - a cliqueGraph see cliqueGraphCreate % %% Output % % nbrs - cliques(N{i}) are the neighbors of the ith clique, i.e. the % cliques whose domain overlaps with clique i. % % sepSets ...
64852872ab83289468aa186eaa7736f3fc37ad2609ed3f899b1167038330f2d3
MATLAB
865
23
function X = redistribute(X,mode) %REDISTRIBUTE Distribute lambda values to a specified mode. % % K = REDISTRIBUTE(K,N) absorbs the weights from the lambda vector % into mode N. Set the lambda vector to all ones. % % See also KTENSOR, NORMALIZE. % %MATLAB Tensor Toolbox. %Copyright 2015, Sandia Corporation. % T...
7aca6a0d2671e835f6cacc6540294948971b41d954d39191e5cf1ef49cee8f29
MATLAB
865
19
%% 非线性特征 | nonlinear features %% Mean teager energy (MTE) % X: single channel EEG signal (either a row vector or a column vector) % See also: % feat_ShannonEntropy, feat_LogEnergyEntropy, feat_TsallisEntropy, feat_RenyiEntropy, feat_MeanEnergy %% Reference % [1] Şen, B., Peker, M., Çavuşoğlu, A., and Çele...
996ccf7d898962dcfa8ef64d1164e5cc82a4f98fd39ab2545942d25cd815ae6b
MATLAB
865
38
function [X,idx] = cellcat(C, dim) %CELLCAT Unpacks and concatenates a cell array. Shorthand for: cat(dim, C{:}) % Usage: % X = cellcat(C) % X = cellcat(C, dim) % [X, idx] = cellcat(_) % % Args: % C: cell array % dim: dimension along which to concatenate (default = 1) % if empty, finds first dimension a...
c221d241af5fde96191541df6b32ddc7e30ec7c27fad4ce99cbb11b93e287d8a
MATLAB
865
23
% Plot fig 9 of Blei'03, "latent dirichlet allocation" x = [1,3,8,20,50,100,200]; unigram = [5800, 5800, 5800, 5800, 5800, 5800, 5800]; mix_unigram = [5150, 4900, 3950, 3850, 3650, 3675, 3700]; LDA = [5200, 4850, 3800, 3450, 3250, 3100, 3050]; pLSI = [6750, 6500, 6250, 5600, 4600, 4250, 3450]; figu...
f700077847b2a5cc46fbe87df1e33af28c2438292318d8f80f8bd3ead9b7c52c
MATLAB
865
32
% crabsort plugin % plugin_type = 'dim-red'; % plugin_dimension = 2; % % _ _ % ___ _ __ __ _| |__ ___ ___ _ __| |_ % / __| '__/ _` | '_ \/ __|/ _ \| '__| __| % | (__| | | (_| | |_) \__ \ (_) | | | |_ % \___|_| \__,_|_.__/|___/\___/|_| \__| % % this is a plugin for cr...
4cd8ccfde157dab4a52b8d691b6ab1eadd86929dfdf3fb66f62bcafb1745ab07
MATLAB
866
16
function result = localFileExistsAndIsNonempty(file_name) % Force NFS attribute cache refresh by listing the parent directory before % checking the file. Without this, exist() can return stale "not found" % for up to acregmax seconds (typically 30-60s) after a remote process writes % the file -- causing false ...
8596376b164112f1a32cc1cae13b84e23d9655f2b1dbf75631d751e20e651bb8
MATLAB
866
40
function [varargout] = test1(ik,npu,norder,iker) radii = [1.0;2.0;0.25]; scales = [1.2;1.0;1.7]; nu = npu; nv = npu; nosc = 5; if(ik == 1) zk = 0.97; else zk = 0.97*nu/10; end fname = ['diary_ik' int2str(ik) '_np' int2str(npu) '_norder' int2str(norder) '_qtime.dat']; diary(fname); S = wtorus(radii,scales,nosc,...
891412e17b7d6d5c7e94e71f3e38dc5ae8c0456da0fb7ee2f0b9c019d63826dc
MATLAB
866
33
function matches = dir_ext(path, extensions, return_paths) %DIR_EXT Returns files in a directory with the matching extension. % Usage: % matches = dir_ext(path, extension) % matches = dir_ext(path, extensions) % cell array of strings % matches = dir_ext(path, _, true) % returns full paths % % Note: The leading '....
e57d50255048a82c6414b99ad3af082a38584df51375e1093607b6d034831701
MATLAB
866
22
function e = GetSORWSite(x0,indNeigh,p,n) % x -> state of this node % neigh -> col vector: list of neighbor indices of this node % p -> col vector: connection weight between this node and each neighbor in neigh list (probability of taking a step) % n -> col vector: number of steps from this node to each...
1626881c8e06011ebe90db7a1e9a23aad641d33c153762997893b27b9080f307
MATLAB
867
32
%% Compute the full L1 regularization path for a classification % version of the prostate data set % This file is from pmtk3.googlecode.com clear all if ~glmnetInstalled fprintf('cannot run %s without glmnet; skipping\n', mfilename()); return; end load prostateStnd mu = mean(y); y = (y>mu); % dichotimize [N,...
755f28ed7858c264f5a11445e80b1c4ba46f60f030f0d30fed61fe79bd2e1ceb
MATLAB
867
37
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Settings file for MATLAB PREP pipeline %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Important filenames and paths sep = '/'; filename = 'S004R01.edf'; montage_name = 'standard-10-5-cap385.elp'; package_dir = 'deps'; artifact_dir = 'artifacts'; eeglab_path ...
8690a73abe0726993ca965b14c56403caad8b1a7b4b44f1a66ed446e1ea384f9
MATLAB
867
24
function candoit = canGetApproxHessian(problem) % Checks whether an approximate Hessian can be computed for this problem. % % function candoit = canGetApproxHessian(problem) % % Returns true if an approximate Hessian of the cost function is provided % in the given problem description, false otherwise. % If a Hes...
e0150037a2ea5fb34e568b707394030f28f986987a217264e9d3897b7749252c
MATLAB
867
27
% GAUSSPDF Normal probability density function. % % This is a compatibility wrapper for NORMPDF in case MATLAB's Statistics % Toolbox is not available. % % Y = GAUSSPDF(X) returns the probability density function (PDF) at X of the % standard normal distribution. % % Y = GAUSSPDF(X,MU) returns the PDF at...
5040c9249e1525a0810c72edc29161adf7d64d1fb9b01f51a21fa1c9aa7296a9
MATLAB
868
30
%% Load the tiny images from file clear all; saFlag = imread('saFlag.jpg'); saFlagGray = rgb2gray(saFlag); figure; imagesc(saFlag); figure; imagesc(saFlagGray); colormap(gray); matlabIcon = imread('matlabIcon.jpg'); matlabIconGray = rgb2gray(matlabIcon); figure; imagesc(matlabIcon); figure; imagesc(mat...
60f5bcced3f4061435c17eacab98a585d758be780594e78c15ac30f047e6c660
MATLAB
868
32
%% Forwards Backwards Algorithm Demo % This file is from pmtk3.googlecode.com K = 3; %initDist= [1 0 0]'; % start in state 1 initDist= normalize(ones(3,1)); % could start anywhere % Left to right HMM 1->2->3 where 3 has a self-loop with prob 1 % So stationary distribution of the unobserved chain is [0 0 1] p = 0.9; ...
77240af2722a2caf3151ab14cb01026d7f0a0b84a61aae4f68af3152847af4cd
MATLAB
868
30
function option = VBA_check_struct(option, varargin) % compare and fill-in input structure with default structure if isempty(option) option = struct(); end if numel(varargin) == 1 && isempty(varargin{1}) % if nothing given, do nothin return; elseif numel(varargin) == 1 && isstruct(varargin{1}) % defau...
934906a83e182cea8b21c0d9af165c6d4abcf09a4e47ccebdd603eedb643b641
MATLAB
868
23
function scoreFeatures= ... replaceScoreFeatureClassifierFileNames(scoreFeatures, ... scoreFeatureMatFileNames, ... scoreFeatureJabFileNames) % scoreFeatures a 1xn structure array with fields: % classifierfile: the name of the classi...
c0c39ea1853f3a909da477b995be9017cb1a6d6f55789c95108e56875e70df70
MATLAB
868
40
function res = bmmFit_1(con,lb,ub) rng default nIter = 5; %number of initial search conditions %param vector = [mu sd] if ~exist('lb','var') || isempty(lb) lb = [0 0]'; end if ~exist('ub','var') || isempty(ub) ub = [1 400]'; end ubSet = [1 100]'; maxfeval = 10000; options = optimset('TolX',1e-8,'maxfuneval...
d801e475847ae07997958eb42a3716b0e2db54dde7ec330d6a505f138abca221
MATLAB
868
35
function ldQ = VBA_logDet(Q,indIn,t) % computes the log-determinant of matrix Q % function ldQ = VBA_logDet(Q,indIn,t) % IN: % - Q: nxn matrix % - indIn: vector of indices that defines a submatrix of Q, whose % determinant is computed {1:n} % - t: threshold on the eigenvalues of the submatrix {eps} % OUT: % -...
5db447ee8c10f0f51e253c968d748f7d6d5c9e537fdbdb6a1092f6db89672449
MATLAB
869
25
function [cropped_indices,cropped_logical] = crop_in_time(data_matrix,timestamps,track_num) % data_matrix should be arranged with each column is a variable % corresponding timestamps figure; max_trace= 0; for i=1:size(data_matrix,2) plot(timestamps,data_matrix(:,i)+ max_trace); hold on; max_trace= max(data_mat...
8d76169f5a57653fb6dd3c3d83897e2ba01e1cac454fca385188e73abc5f535a
MATLAB
869
20
function afxLnmMean(input,output) if exist(output,'file') fprintf('afxLnmMean: %s already exists.\n', output) else [pth,name,ext] = fileparts(output); if ~exist(pth,'dir'), mkdir(pth); end matlabbatch{1}.spm.util.imcalc.input = input; matlabbatch{1}.spm.util....
ded3e558f2d7f2059d99cad56ddcd55b88054e9ae5ac06276896d880e24c82af
MATLAB
869
39
%% Posterior Predictive Distribution for Beta-Binomial model % %% % This file is from pmtk3.googlecode.com N = 10; N1 = 4; N0 = 1; xs = 0:N; %% Prior Predictive prior.N = N; prior.a = 1; % 2; prior.b = 1; % 2; priorPred = exp(betaBinomLogprob(prior, xs)); figure; bar(priorPred); set(gca,'xticklabel', xs); title('...
197d8cbdea1b1f241d2ea09e77e0c599e00342e4bf93ce769d1afa401a242289
MATLAB
870
27
% Author: Birgit Nierula (May, 2020) % nierula@cbs.mpg.de %% Define individual interpolation windows % This script follows SRMR1_01_prepro_3_removeDoubleDetections.m srmr_nr = 1; ana_dir = '/data/pt_02068/'; cfg_path = [ana_dir 'analysis/manuscript_sep/scripts/cfg_srmr1/']; % here is important info for the analysis...
221aa85407069e69303049edbf7369bba46a214227b05af235942257509defcf
MATLAB
870
1
function [f,g,H,T] = autoTensor(x,useComplex,funObj,varargin) % [f,g,H,T] = autoTensor(x,useComplex,funObj,varargin) % Numerically compute Tensor of 3rd-derivatives of objective function from Hessian values p = length(x); if useComplex % Use Complex Differentials mu = 1e-150; diff = zeros(p,p,p); for j =...
50f2bdc9a0557290c0836711b1a5a8809fb8b45a14d30a698b8217209892324d
MATLAB
870
48
%% Linear Regression L1 Fit Test %% % This file is from pmtk3.googlecode.com function linregFitL1Test() %% Make some data setSeed(0); N=100; %N=20; D=50; % dinensionality rho=.5; correl=zeros(D,D); for i=1:D for j=1:D correl(i,j)=rho^(abs(i-j)); end end X=randn(N,D)*chol(correl); % true weight vect...
5fea78f596d14b6353a8221f2be6e713d7c2fd271df9c8d54204d818fd895ec7
MATLAB
870
23
% ELE_AREA_C Calculates FEM mesh elements area (2D - triangles) or volume % (3D - tetrahedra). % % SYNTAX: % [AREA] = ELE_AREA_C(NODES,ELEMENTS) % % [AREA] = ELE_AREA_C(NODES,ELEMENTS) % AREA - is m by 1 vector of m FEM mesh elements area (2D) or volume % (3D), expressed in the input units squared (2D) or q...
5c08f86766f1037b5300f050d4e0337693b86d1fc314784cfa2757ca8061264e
MATLAB
871
15
function test_ratcity_MA_magrone_nocrop_training() linux_project_file_path = '/groups/branson/bransonlab/apt/unittest/ratCity_round12_movie_size.lbl' ; [project_file_path, replace_path] = localize_test_project_path(linux_project_file_path) ; % backend = docker_unless_janelia_cluster_then_conda() ; backend = 'bs...
096b3b55497911761239fd290e5c2feb36cc208b8a3d4f5af8792a0a8a046b32
MATLAB
872
30
function options=get_default_options() options.mask_volume_ICA = 1300; %mm3 options.mask_volume_CCA = 25000;%30000;%22500;%mm3 options.mask_volume_SSS = 4790; %mm3 % options.nvoxs_ICA = 80; % options.nvoxs_CCA = 1400; % options.nvoxs_SSS = 300; options.selected...
596472a2a9617ae8eff21e8a60733ed971bfc71e2ede0b9c19c642717aa24ab6
MATLAB
872
28
function eegByWindow = EEGSplitByWindow(data, times, windows) % function eegByWindow = EEGSplitByWindow(data, times, windows) % Split the EEG data by time windows, for taking SD across time within a % window % Inputs: % data = EEG data [chans, time, bin, pp, ses, trial] % times = [1 N] vector of times % windows =...
d04346c4f5a7f1c5a82376548477922f62d3f0c29a9f115f7e18e0152f0ec556
MATLAB
873
29
%% Multi-class logistic regression on iris data % This file is from pmtk3.googlecode.com loadData('fisherIrisData') X = meas; % 150x4 [y, support] = canonizeLabels(species); pp = preprocessorCreate('standardizeX', false, 'addOnes', true); % MLE model = logregFit(X, y, 'lambda', 0, 'preproc', pp); [yhat, p] = logre...
2667826761c048ddd6f5e2e64fde69e83d3420c912875d2f106da0627369943b
MATLAB
874
41
%% Sensor Fusion Demo 2D % %% % This file is from pmtk3.googlecode.com function sensorFusion2d() Sigmas = {0.01*eye(2), 0.01*eye(2)}; helper(Sigmas) printPmtkFigure('demoGaussBayes2dEqualSpherical') Sigmas = {0.05*eye(2), 0.01*eye(2)}; helper(Sigmas) printPmtkFigure('demoGaussBayes2dUnequalSpherical') Sigmas = {0...
32c4e14365ef85728e173676fa044742113227ed6aacd733ea5cc478fa2ddca3
MATLAB
874
26
function fx = f_HGFinGame(x,P,u,in) % HGF-learner in a dyadic game % function fx = f_HGFinGame(x,P,u,in) % HGF stands for "Hierarchical Gaussian Filter" (cf. Mathys et al. 2014). % In a dyadic game, HGF tracks P(o=1), i.e. the probaiblity that the % opponent choses the option o=1 [see f_VBvolatile0.m]. % IN: % - x: t...
6ac922545985ad25b49309d7761184fe57700addcdf1e9b4189c2205be522686
MATLAB
874
28
function interp_times = fill_in_missing_timestamps(timestamps,distances) % given a set of incomplete timestamps (such as thosed used for syncing), % and a set of distances between an independent timestamp source % (distances), fill in the missing timestamps. % example % sync_ts = digitalIn.timestampsOn{1, 7}; % fro...
953376dcc04ec4a33111f9b9209c7ccd234f2a2aa22509e78904e2e946981fcd
MATLAB
874
32
function mat = NavPrefsNewMat() mat = cell(1, 3); mat{1} = struct(); mat{1}.active_h = []; mat{1}.taginfo = struct; mat{1}.taginfo.figure = 2; mat{1}.taginfo.text = 9; mat{1}.taginfo.popupmenu = 5; mat{1}.taginfo.edit = 6; mat{1}.taginfo.pushbutton = 3; mat{1}.taginfo.uipanel = 2; mat{1}.override = 0; mat{1}.release =...
eea6e93a63922c8958a4dd75da047f34268ecbeaec2fc7171ea861270c6d9c2b
MATLAB
874
34
function out = wrap(f, out_indices) % out = wrap(f, out_indices) % % If you've ever needed multiple outputs from a function wrapped up in a % cell array, you may have felt it was a bit awkward to accomplish without % doing something like this: % % [a, b, c] = f(...) % x = {a, b, c}; % % That's not always desirable. %...
15addacefd2ca41cd342a3fd40b5765d87057672aafb9dbbef5bb6ae58d016a1
MATLAB
875
29
function [vnew, fnew]=patchslim(v, f) % PATCHSLIM removes duplicate vertices in surface meshes. % % This function finds and removes duplicate vertices. % % USAGE: [v, f]=patchslim(v, f) % % Where v is the vertex list and f is the face list specifying vertex % connectivity. % % v contains the vertices for all triangles...
95a9bef1c9aca25210e4b89017daf480ee449d3185f5d1e06725ef939307798f
MATLAB
875
33
%% Phase locking value for ripple band for q=1:64 q LowGammaData_70_100(q,:) = bandpass(LFPRawAll(q,:),[70,100], DecFS); end for chan = 1:64%length(good_chan) the_chan = chan%good_chan(chan) phase_envelope_70_100(the_chan,:) = unwrap(angle(hilbert(LowGammaData_70_100(the_chan,:)))); end set(0,'Defau...
b44d09f9c00e440e04b1b1a38f669ed82c2bec631bac41f628fa44e3aa2ef0e8
MATLAB
875
33
function cvalue=DOTNB_cdf(k,r1,p1,r2,p2) % calculate the cumulative probability of k that is the difference of two NB distributions (r1,p1) and (r2,p2) % k is the observed number of difference %sum pvalue for <= k, %use a small stop_pvalue as threshold for stop condition of interation stop_pvalue=1.0e-20; cv...
f2989804e3804aa7cfbe92ba1899a82d424d0069bb00eb18c23486fa46a84945
MATLAB
875
26
function t = full(t) %FULL Convert a ktensor to a (dense) tensor. % % T = FULL(C) converts a ktensor to a (dense) tensor. % % Examples % X = ktensor([3; 2], rand(4,2), rand(5,2), rand(3,2)); % Y = full(A) %<-- equivalent dense tensor % % See also KTENSOR, TENSOR, KTENSOR/DOUBLE. % %MATLAB Tensor Toolbox. %Cop...
08b19cfbaeaa0327b3f8c136dd878384b9651536e23860d6426f50fb3f58b7c3
MATLAB
876
24
function [gx] = g_Kalman4bandits (x, P, ~, in) % // VBA toolbox ////////////////////////////////////////////////////////// % % [gx] = g_Kalman4bandits (x, P, u, in) % softmax decision rule for N-armed bandit task as in Daw et al. 2006 % % ///////////////////////////////////////////////////////////////////////// % Get...
2ad479f15467e3ca1fc7bd07594cedfeedfdcbeda2434a0ea111c690cbb1e811
MATLAB
876
41
function f = fmf_frame_count( filename ) % frames = fmf_frame_count( filename ) % % counts the number of frames in a FlyMovieFormat file % and writes it into the file header if it's not already there % % JAB 6/30/04 fp = fopen( filename, 'r' ); version = double( fread( fp, 1, 'uint32' ) ); if version ~= 1, error(...
2f0baca6e2129084055b93cd729ac862ba0cc87c4d03a820611aca2d46860828
MATLAB
876
30
% TSERROR % function TSerror(errorstring) stack = dbstack('-completenames'); [thisfile calledfile callingfile] = stack.file; [thisfun calledfun callingfun] = stack.name; [thisline calledline callingline] = stack.line; disp(sprintf('\n*** TS SYNTAX ERROR ***\n\n')); temp = sprintf('<a href = "matlab: opentoline('...
8b1b93172bc04302b3b8631202b2a5eecc078f02a7d2010a858b2bb8193fbfa4
MATLAB
876
28
function [ outputImage_interp ] = TPS3DApply(in1D,out1D,imgToWarp,outdim) %TPS3DAPPLY applies the warp to a vectorized version of the image data, %then returns an interpolated version of the data %now that we have the pixel->pixel mapping from the TPS, apply it to a %data channel, interpola...
923bda52045934143a01ad8b738e87b0449e803cae3ac7aed4aa24b40171cc47
MATLAB
876
39
% AUTHORSHIP % Primary Developer: Stephen Meehan <swmeehan@stanford.edu> % Math Lead & Secondary Developer: Connor Meehan <connor.gw.meehan@gmail.com> % Bioinformatics Lead: Wayne Moore <wmoore@stanford.edu> % Provided by the Herzenberg Lab at Stanford University % License: BSD 3 clause % function out=u...
d998c3e9cd1ab053956724b2ccd9c7353167e8332dc18603df09eb030ed8af00
MATLAB
877
34
function [Y,mri] = fs_read_Y(Y_fname) % [Y,mri] = fs_read_Y(Y_fname) % % Reads Freesurfer's .mgh or .mgz data files (eg. cortical thickness data % files generated with mris_preproc). % % Input % Y_fname: A Freesurfer's cortical data file. % % Output % Y: Data matrix (nmxnv, nm total # of maps, nv #vertices). % mri: ...
5dd1dcb8c39412b0ec83db72780424b67acb954efe931c229cb65694e6e7f026
MATLAB
878
27
for iside = 1:2 ps = (iside-1)*0.45+0.08; pos = [ps 0.4 0.38 0.535]; subplot('Position',pos); for ip = 1:2 ipop = ip+(iside-1)*2; bl = NaN(Npar,1); pr = NaN(Npar,1); if Nb(ipop) > 1 for ipar = 1:Npar bl(ipar) = ave_Blength(ipop,ipar); ...
616e1a3103123375c064e7549a52f9b76d0332e2e7feadee6ca5fd61515b6545
MATLAB
878
46
function r=rbmPlotImg(X, doTranspose) % X(:,i) is i'th data case or weight vector. % If possible, reshape it as an image and make % a composite image of all of them. % If no return argument is request, plot image, % otherwise return it. % This file is from pmtk3.googlecode.com if nargin < 2, doTranspose = false; end...
7e300b60a71b20320769ba63e4bd0bff39a639be9e1303886b046ef9a4515cc6
MATLAB
878
26
function [mri] = align_fsaverage2mni(mri) % ALIGN_FSAVERAGE2MNI performs an affine alignment of the anatomical volume from % FSAVERAGE towards MNI coordinates. Only the homogeneous transformation matrix is % modified and the coordsys-field is updated. % % Use as % mri = align_fsaverage2mni(mri) % where the first inp...
822ea11ee181a6a857f92747a9c6e34d7320918df174eb88bc86860bdef1da6d
MATLAB
878
33
function indexlocptr = ... sbfmf_write_header(fp,version,nframes,... differencemode,bgcenter,bgstd) BGTYPE_DARKONLIGHT = 0; BGTYPE_LIGHTONDARK = 1; BGTYPE_OTHER = 2; [nr,nc] = size(bgcenter); switch lower(differencemode), case 'dark flies on a light background', differencemode = BGTYPE_DARKONLIGHT; case ...
ba5d39084cafcb502df863bdb4775e48ac919868c17c060f8919aacc18a9efd8
MATLAB
878
15
%% 非线性(动力学)特征:基于时域的熵 | nonlinear features: time-domain-based entropy %% Log Energy Entropy % 表征时间序列数据的复杂性(complexity)In some studies, the log energy entropy is used as a feature to distinguish focal(病灶的) and non-focal EEG signals. % X: single channel EEG signal (either a row vector or a column vector) % See also: % ...
fdef1f62d052b83636a4055324cfb2855be87cd377e65bb0ed4140b6c79e8e6a
MATLAB
878
21
function [max_pool_size] = concurrency_size_in_puncta_roicollect(cond) loadParameters; if ~isfield(params,'PUNCTA_MAX_POOL_SIZE') main_mem_usage = cond.imgsize_dbl + params.MATLAB_PROC_CONTEXT; par_worker_mem_usage = cond.imgsize_dbl + params.MATLAB_PROC_CONTEXT; max_pool_size = min(pa...
27849090a00a800c60338c72a7716e99d89eb2506924858443ddb6a15bef436e
MATLAB
880
37
function [data, stamp] = fmf_read_frame( fp, h, w, bytes_per_chunk, data_format ) % [data, stamp] = fmf_read_frame( fp, f_height, f_width, % bytes_per_chunk, data_format ) % % reads image data for the next frame in the file pointer FP % % DATA is specified by data_format, as below, F_HEIGHT x F_WIDTH % STAMP is the tim...
2b0d3cc925d43acd666a45ad2f524f7faf627564d1c87a11a5dcea39258afa23
MATLAB
880
43
% axisalmosttight(border,varargin) function axisalmosttight(border,varargin) if nargin < 1 || isempty(border), border = 1/20; end if numel(varargin)>=1, hax = varargin{1}; else hax = gca; end ax = [inf,-inf,inf,-inf]; for i = 1:numel(hax), axis(hax(i),'tight'); ax1 = axis(hax); nd = numel(ax1)/2; if i ...
a809534c28aed8b059c27cfb85f210f8c8500dd496bb43eebb85dccc8b3fd19a
MATLAB
880
19
function [P, E] = bemf4_surface_field_electric_plain(c, Center, Area) % Computes potential/continuous electric field on a surface facet due to % charges on ALL OTHER facets using plain FMM % Self-terms causing discontinuity may not be included % To obtain the true field, use E = E/eps0; % % Copyright SNM 2018...
fd53daa6ad8b7ac1803467c3b2c8a6da0769f48aa1b7d0fc5cf984f673d4e996
MATLAB
880
24
% This script plots the electric potential of the primary, secondary, or % the full field for any brain compartment surface % % Copyright SNM/WAW 2017-2020 %% Graphics tissue_to_plot = 'Skin'; objectnumber = find(strcmp(tissue, tissue_to_plot)); temp = Ptot(Indicator==objectnumber); PtotSkin ...
3ae88e3ccdcd36167ec0144f3e000b439c3fff81ced2111efb33b5a73affed80
MATLAB
881
40
function MoveAxisToOrigin(ha) % move axes TO origin % function MoveAxisToOrigin(ha) % IN: % - ha: axes' handle % GET TICKS X=get(ha,'Xtick'); Y=get(ha,'Ytick'); fs = get(ha,'fontsize'); % GET LABELS XL=get(ha,'XtickLabel'); YL=get(ha,'YtickLabel'); % GET OFFSETS Xoff=diff(get(ha,'XLim'))./40; Yoff=diff(get(ha,'YLi...