sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
43bdea37076059f6bc103f126db01a4db5589d4440170e48ce17302d07145822
MATLAB
2,066
57
function [Y,N,N2] = nanfft(X,N,DIM); % NANFFT calculates the Fourier-Transform of X for data with missing values. % NANFFT is the same as FFT but X can contain missing values encoded with NaN. % NaN's are skipped, NaN do not result in a NaN output. % % Y = NANFFT(X) % Y = NANFFT(X,N) % Y = NANFFT(X,[],DIM) % ...
64b45966513e6e588afc9b47e5a0a3df6db90bb0caad052b497475b158abbf68
MATLAB
2,066
57
function yRoiLo = shcropy(yCents,bbymax,sd,yRoiSz) % yCents: [nx1] y-centroids % bb: [nx4] bboxes % sd: SD to use, will be approximate spread of centroids after crop % yRoiSz: total y-size of cropped roi assert(iscolumn(yCents) && iscolumn(bbymax) && numel(yCents)==numel(bbymax)); %sd = 19.5; % from view1, x-dir ymid...
7b7ffa20b7578cf5bd519fca4dba8d7ec0e2c7f799b30211ec16a33e8f1c6e75
MATLAB
2,066
42
function Obj=SOFAconvertLISTEN2SOFA(LISTEN, subjectID) % Obj=SOFAconvertLISTEN2SOFA(LISTEN, subjectID) converts the HRTFs described in LISTEN % (see LISTEN HRTF format) to a SOFA object. % % Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences; % Licensed under the EUPL, Version 1.1 or ...
3a41ee992c9611a9ff9ae694e0f65ddbe51997b36d3eaa171096909aee61f5fe
MATLAB
2,067
96
%% Biosequence analysis Demo % t = locn % Z(t)|w ~ Discrete(w(:)), k in {1,2,3,4,k} % theta(:,t) | Z(t)=k ~ Dir(alpha(:,k)) % x(i,t) | theta(:,t) ~ Discrete(theta(:,t)) % This file is from pmtk3.googlecode.com %% Data generation setSeed(1); Nseq = 10; Nlocn = 15; Nletters = 4; Nmix = 4; pfg = 0.30; mixwei...
66b59151db950c340b6a66231e9136d305b54281dfd5bd8369251ceb6baf53a0
MATLAB
2,067
75
clear % clc res=2; dur=66; all_trials_loc.glm_dd=nan(dur/res,3495); all_trials_loc.glm_df=nan(dur/res,3495); all_trials_loc.glm_fd=nan(dur/res,3495); all_trials_loc.glm_ff=nan(dur/res,3495); all_trials_loc.glm_time=nan(length(-1:res/100:2),3495); all_trials_loc.glm_context=nan(length(-1:res/100:2),3495); all_trial...
6ec005add684091a484b704c7304d257e601f8d54d368f899c97da39aa4bd31f
MATLAB
2,067
107
function Gs = mk_all_dags(N, use_file, method) % MK_ALL_DAGS generate all DAGs on N variables % G = mk_all_dags(N) % % G{i} is the i'th dag % % Note: the number of DAGs is super-exponential in N, so don't call this with N > 4. % This file is from pmtk3.googlecode.com %PMTKauthor Kevin Murphy, Robert Tseng, Simon Suy...
c49cb2f49c1dbf386f2ab1b8fe25a844988c44f43f65e40eb15975a92a6abf9b
MATLAB
2,068
94
function kernels = weights_to_kernels(w) global glm curr_index=1; num=1; kernels.const=w(curr_index:curr_index+num-1); curr_index=curr_index+num; if(isfield(glm,'no_pulse') && glm.no_pulse==1) num=glm.ntime; kernels.dd=w(curr_index:curr_index+num-1); curr_index=curr_index+num; num=glm.ntim...
adac6cc2053c29d0882a1dd29897441ff03c38eb8eeb2748574dff2dbdd393ab
MATLAB
2,070
51
function potential=eeg_forward(dips,forwpar); % usage: potential=eeg_forward(dips,forwpar); % makes forward calculation for EEG in realistic volume % conductors % dips is an Nx6 matrix; the first 3 columns denote locations % of N dipoles, and the last three columns the moments (in nAm) % distances are assum...
c819b2ea74fa796c220e96f5bb0651863a3bb7a50be4fc414facd3852f753ccc
MATLAB
2,070
58
%% Simple test of hmmDiscreteFitEm % We compare how well the true model can decode a sequence, compared to a % model learned via EM using the best permutation of the labels. %% %% Define the generating model % This file is from pmtk3.googlecode.com setSeed(0); nHidStates = 4; T = [1/6 1/6 1/6 ...
c9018fec2707da32e7cdf2e282b8b18092a9c15326140ed64f73089eb19027a6
MATLAB
2,070
50
function opts=Config_FormatCorr(GlobalOpts, varargin); opts=GlobalOpts; opts.PlotShuffle=0; [varargin,opts.Dates] = Utilities.ProcVarargin(varargin,'Dates',{opts.Dates}); [varargin,opts.shuffle] = Utilities.ProcVarargin(varargin,'Shuffle',opts.shuffle); [varargin,opts.overwrite] = Utilities.ProcVarargin(va...
a1f8682cf4d771b967973a8d2d531da375fd6df34754d32a3aca0d26decb8928
MATLAB
2,071
71
function Y = scale(X,S,dims) %SCALE Scale along specified dimensions of tensor. % % Y = SCALE(X,S,DIMS) scales the tensor X along the dimension(s) % specified in DIMS using the scaling data in S. If DIMS contains % only one dimension, then S can be a column vector. Otherwise, S % should be a tensor. % % Examp...
a6b3c7109c40773fd3a6a9678414f6f4d35e648dc7aa588fd5b440beb9038578
MATLAB
2,071
57
classdef DAQRecording < AudioRecording methods (Static) function canLoad = canLoadFromPath(filePath) canLoad = false; try daqread(filePath, 'info'); canLoad = true; catch end end end methods ...
cd17aa8964f748e776d017b781db2cc5782cf61a073625d966b784800d888a23
MATLAB
2,071
77
% Infer function on 2d grid using Gaussian MRF prior. % Based on p141 of "Introduction to Bayesian Scientific Computing" % Daniela calvetti and Erkki Somersalo n = 50; L = gauss_mrf_2d_precmat(n); B = L'*L; % Conditioning: I2 defines the points that are known, % I1 points to free pixels I = reshape([1:n^2],n,n); I2 ...
80c2b7073f9b98b56c9c87430c243ba542e61c98d92f89edf6efe91ad1b52738
MATLAB
2,072
74
function data = LoadAuxData(datDir, varargin) % hard-coded parameters vScale = 0.0000374; bytesPerSample = 2; % default values of optional arguments timeRange = [0 20]; lowpassCut = 100; filtOrder = 20; for i = 1 : 2 : length(varargin) switch lower(varargin{i}) case 'timerange' timeRange = v...
094381778e4e2d3b22b837ad825d1c21afd70da297c12b7476e7a53cfd1c8cde
MATLAB
2,073
105
function [fx,dF_dX,dF_dTheta] = f_dcm_extension(Xt,Theta,ut,inF) % nonlinear DCM evolution function % function [fx,dF_dX,dF_dTheta] = f_dcm_extension(Xt,Theta,ut,inF) % This function evaluates the evolution function of the neuronal states of % a nonlinear DCM for fMRI model. deltat = inF.deltat; n = size(Xt,1); nr = l...
0b7a41ac0282e2e4f71930537caa4c71d7c82871a46dd99e53bb3c8f0cdfb52b
MATLAB
2,073
68
function [data,mesh]=femdata_BLT(mesh, varargin) %% check in/out narginchk(1,3); nargoutchk(0,2); %% get optional inputs, handle variable input % default solver = get_solver; OPTIONS = solver_options; if ~isempty(varargin) if length(varargin) == 1 if ischar(varargin{1}) || isstring(varargin{1}) ...
a905886116cb02dfb85d255b6bc385566e08f57b2d8ddaff0177b13ff169814c
MATLAB
2,073
60
function map = jtreeFindMap(jtree) %% Find the mode, (map assignment) using max-product and traceback % jtree is a struct as returned by e.g. jtreeCreate % %% % This file is from pmtk3.googlecode.com maximize = true; cliques = jtree.cliques; preOrder = jtree.preOrder; postOrder = jtree...
38c9ab7b9bac34e006c7d5084c6eea494fe8db8e4337d3029a79a3632bfb0998
MATLAB
2,074
78
% demo operant learning with VB volatile observer (adapted from Mathys, % Daunizeau et al. 2010) % This demo simulates a "volatile learner" experiencing feedback to her % chosen actions in a 2-armed bandit task. VBA estimation then proceeds. close all clear variables clc % evolution, observation and feedback functi...
7b2b0023a7321f083edc48537f72d22091c11e9b56821fa709878c274a424221
MATLAB
2,074
63
function [logZ, postQuery] = variableElimination(cliqueGraph, queryVars) %% Sum-product variable elimination % cliqueGraph is a struct with the following fields: % Tfac - a cell array of tabular factors % G - the graph structure: an adjacency matrix % nstates(j) - the number of states for node j % ...
14a8cff3b524c92a3759644c2b451e85eb7b71fffef8dfcc2117e89ff56fc280
MATLAB
2,075
74
function [outfiles,outindexfiles] = split_mjpg(infile,inindexfile,outfilestr,chunksize,varargin) [startframe,endframe,dooverwrite] = ... myparse(varargin,'startframe',1,'endframe',inf,'dooverwrite',false); % read in the header fprintf('Reading index file %s...\n',inindexfile); header = ReadIndexedMJPGHeader(...
a69f1fb9a9fc880d3583d3261ea7781299a8f2138a9bc9f01771959c57a605f2
MATLAB
2,075
68
function decVec = decode_success(data,winsize,stepsize,prctokeep) %% test %close all %T=969; %sig=zscore(cumsum(randn(T,18))); %data=0.5*randn(T,18,32)+repmat(sig,1,1,32); %winsize=25; %stepsize=25; %prctokeep=1; % % data is in format time x space x subjects % winsize is a number of length of windo...
5349e35816a75485eaf7eebf7bd2cd17e90aed15166a28ed0a084683a101da3f
MATLAB
2,076
68
function [mdl,r_all,distance_all]=corrVsDist(traces,positions,pyr,int) % separate_plots = true; r = corr(traces'); % r = corr(traces.all(:,mvm.mvmEpochsIndex)'); % r = corr(traces.all'); distance = pdist(positions); %Eucledian distance between cells distance = squareform(distance); %colour = lines(length(int)); % c...
5c16baf4d76153e5ce4be831b3aba769e2756eb0705939f4c5e62e3c87055d45
MATLAB
2,076
35
%% 包络变异系数(函数输入通常是imfx而非X) | Variation Coefficient of the Envelope (CVE)(based on imfs) % 基于解析表示的瞬时振幅,反映包络离散程度的绝对值 % 1. 调用hilbert()函数对信号进行Hilbert变换得到信号的解析表示 % 2. 基于信号的解析表示,计算瞬时振幅(即信号包络)和瞬时相位 % 3. 基于信号包络计算包络变异系数CVE = std(envelope)/mean(envelope) % imfx: IMF component of single channel EEG signal (either a row vector or %...
0d19171a54fccd3c234481696a4df9d3abdeb955d236484a34593fb44eba8c6c
MATLAB
2,077
70
function C = times(A,B) %TIMES Array multiplication for sparse tensors. % % TIMES(A,B) is called for the syntax 'A .* B' when A or B is a % sparse tensor. A and B must have the same size, unless one is a scalar. % A scalar can be multiplied by a sparse tensor of any size. % % See also SPTENSOR. % %MATLAB Tens...
51ab629dfb94117eb02bdeb3bba09806466ea95b8ec091cde27e7c4955bf9873
MATLAB
2,077
59
function [event] = read_bucn_nirsevent(filename) % READ_BUCN_NIRSEVENT reads the event information of ASCII-formatted NIRS % data acquired with the UCL-BIRKBECK machine and postprocessed by the % Paris group. The first line contains the header-info and the rest of % the file contains per line an event. The first colu...
67e775f73b5cb49f418906a35ed83ba1c19f6be4a899ebfbac0ffb8ac08df8ea
MATLAB
2,077
89
%% Demonstrate inference in a 2d grid of a multi-state noisy image of an X % Based on http://www.cs.ubc.ca/~schmidtm/Software/UGM/alphaBeta.html % This file is from pmtk3.googlecode.com %% Get model and data setSeed(0); loadData('XimgRgb'); Xclean = Xrgb; X = Xclean + 0.5*randn(size(Xclean)); [nRows, nCols, ncolors...
ec742574f3212a59cd74df8f99aba88b68e5248abe656e5055fe444a33fc374c
MATLAB
2,077
72
function A = makehatch_plus(hatch,n,m) %MAKEHATCH_PLUS Predefined hatch patterns % % Modification of MAKEHATCH to allow for selection of matrix size. Useful whe using % APPLYHATCH_PLUS with higher resolution output. % % input (optional) N size of hatch matrix (default = 6) % input (optional) M width of ...
3343e57d41bcf964308bc8fb8a2148a36219e7191813b69370f72686afc7c543
MATLAB
2,078
56
%% load data load("../data/FIG2_preprocessed.mat") %% fitting of board neurons to known input brightness mon_pos = mon_vals(1:2:end,:,:); mon_neg = mon_vals(2:2:end,:,:); fits = {}; figure; for i = 1:2 for j = 1:2 [mon_pos_grid,mon_neg_grid] = meshgrid(mon_pos(i,j,:),mon_neg(i,j,:)); ft ...
288d7fd3b30692c22a016bcd356fb1135e67cd599b52633b05eee1eab7b794ef
MATLAB
2,080
64
function [ varfast, varslow ] = ... wlProc_calcVarFastSlow(data, samprate, fdc, flong, fshort) % function [ varfast, varslow ] = ... % wlProc_calcVarFastSlow(data, samprate, fdc, flong, fshort) % % This function calculates the fast-changing and slowly-changing portions % of the variance of a supplied signal wavefo...
3d92a5c5ed8d140720a298cbcf5b81156b5412048bfdc7bced87f60ffd18c2ff
MATLAB
2,082
75
%% FLYNUM2CALIB = '/groups/huston/hustonlab/flp-chrimson_experiments/fly2DLT_lookupTableStephen.csv'; fly2calib = readtable(FLYNUM2CALIB,... 'Delimiter',',',...pwd 'ReadVariableNames',false,... 'HeaderLines',0); fly2calib.Properties.VariableNames = {'fly' 'calibfile'}; fly2calibMap = containers.Map(fly2calib.fly...
bf5d56ea01974d47da3d2590b55b39536e40130df8709943669968ed26bf25c0
MATLAB
2,082
57
function afxConnWholeBrain(y,yRoi,brainMask,rois,dim,mat,outDir,subjectName) % calculation of functional connectivity fprintf(' Calculating whole brain functional connectivity ...\n') % prepare whole brain time series % keep only data within the brain mask (saves memory in the parfor-loop) ...
d217660d69ee8e3836f0d42dcbde452d0699a56207dacc17579e39e69a2cbd97
MATLAB
2,082
72
%Convert the 3D sift features into a usable array function correspondences = find_correspondences(keys_moving, keys_fixed) DM = []; %M for moving LM = []; for i = 1:length(keys_moving)-1 DM(i,:) = keys_moving{i}.ivec; LM(i,:) = [keys_moving{i}.y, keys_moving{i}.x, keys_moving{i}.z]; end...
76c23462a16a39dd9a8fb06877b368932a0a1431bf2009a502c79f6bfcd337f6
MATLAB
2,083
100
%% Demo of minimum spanning tree function minSpanTreeDemo() % This file is from pmtk3.googlecode.com %% Example from Cormen, Leisersen, Rivest p508 a=1; b=2; c=3; d=4; e=5; f=6; g=7; h=8; i=9; G = zeros(9,9); G(a,b)=4; G(a,h)=8; G(b,c)=8; G(b,h)=11; G(c,d)=7; G(c,i)=2; G(c,f)=4; G(d,f)=14; G(d,e)=9; G(e,f)=10; G(f,...
3174c1f9add008811bc463771d046b108a52b7ed3230e79bdeaf8e9021eb5a1a
MATLAB
2,084
71
% SYNTAX % example_global_smoothing_lumped_laplace % DESCRIPTION % This script performs global (or local) iterative Laplacian mesh % smoothing using the lumped-smoothing algorithm. The smoothing improves % triangle quality and increases min edge length but deforms the mesh % % Low-Frequency Electromagne...
7384798fc1ae3613d209325845d6317e2a047bb171400b421f9de1307453ea5f
MATLAB
2,084
86
function [volume, flipvec] = volumeflip(volume, flipvecin) % VOLUMEFLIP % % See also VOLUMEPERMUTE if nargin<2 flipvecin = 'auto'; end % do a low-level check on the input data if ~isfield(volume, 'transform'), ft_error('the input volume needs a transformation matrix'); end if ~isfield(volume, 'dim'), ft_erro...
85b2288b61786ca4efdcf4a262cdd95b09a876e47e8ca07d39c3472949c4871f
MATLAB
2,084
71
function s = collapse(t,dims,fun) %COLLAPSE Collapse sparse tensor along specified dimensions. % % S = COLLAPSE(T,DIMS) sums the entries of T along all dimensions % specified in DIMS. If DIMS is negative, then T is summed across % all dimensions *not* specified by -DIMS. % % S = COLLAPSE(T) is shorthand for S = COL...
d054a1d2c449034dc73696ed2471aee5fd04e40e60a9c5470a24f1a7f8c36808
MATLAB
2,084
78
function obj = customtrim(obj,nrmv,varargin) % trim both images and MP at the same time if isempty(varargin) prf = 't'; else prf = varargin{1}; end runloop=1; % only providing rawMNI data if isfield(obj,'rawMNI_run') && ~isfield(obj,'sMNI_run') && ~isfield(obj,'tMNI_run') ...
23bec549d5d58ddd32aecf19190a978e717302b0c58dd472eabba2debd9395ec
MATLAB
2,085
59
function [Y,XYZ] = VBA_spm_read_vols(V,mask) % Read in entire image volumes % FORMAT [Y,XYZ] = spm_read_vols(V,mask) % V - vector of mapped image volumes to read in (from spm_vol) % mask - implicit zero mask? % % Y - 4D matrix of image data, fourth dimension indexes images % XYZ - 3xn matrix of XYZ locations ret...
b91bb531ff9f82152b2b22803661838a9832ef47a6b9a1984bd51214e97d8b29
MATLAB
2,085
77
%% Classify some MNIST digits using a deepBelNet %PMTKauthor Andrej Karpathy %PMTKmodified Kevin Murphy %PMTKreallySlow % This file is from pmtk3.googlecode.com %% Data setSeed(0); clear all if 0 %all datasets above must conform to the following naming conventions: %for training: 'data' NxD, 'labels' Nx1 %for...
d5c7c61f19b4be695647467e1cbf6b30adcfb9d62e3109d5a04936965495a8ff
MATLAB
2,085
74
%% Fit a mixture of Gaussians and mixture of Students to some data % and use the resulting models to classify % This example is based on fig 3.3 of Kenneth Lo's PhD thesis, % "Statistical methods for high throughput genomics", UBC 2009 %PMTKauthor Hannes Bretschneider %% % This file is from pmtk3.googlecode.com funct...
31adf600b43514c3eb3936b745a000b6c5509a8215187b4a5281186acc24f50f
MATLAB
2,086
105
function RT = rt_fourier(RT,cfg) % v.0.0.1 % <*LAN)<| version % % % Pablo Billeke % % if nargin > 1 && isstruct(cfg) %%% ifplot try ifplot = cfg.ifplot; catch ifplot = 0; end %%%% try NFFT = cfg.nfft; ifnfft = 1; catch ...
5ce8378a57ed6479753a83c09034e2caf27e25e9bd912d833fa3ba1047b1ee0c
MATLAB
2,086
57
function [tf,reason,where] = SOFAcompare(Obj1, Obj2, varargin) %SOFASOFAcompare % TF = SOFAcompare(A, B) compares A and B and % returns logical 1 (true) if they are identical. % % [TF,REASON,WHERE] = SOFAcompare(A, B) provides the REASON % and shows WHERE the difference arose. % % ... = SOFAcompare(A, B, 'i...
5d05ff07ab5a6054f2c95ddab8e7e95f9b6e5d57f70dbf9212b01bab098ea1a0
MATLAB
2,086
54
function H = histcImWin( I, edges, wtMask, shape ) % Calculates local histograms at every point in an image I. % % H(i,j,...,k,:) will contain the histogram at location (i,j,...,k), as % calculated by weighing values in I by placing wtMask at that % location. For example, if wtMask is ones(windowSize) then the % histo...
11033911276abc5d96f8c595f886c2764c2817777e6a028ae1aa14146d866a73
MATLAB
2,087
34
clear;clc;close all ROOTPATH = strcat(NoveltySU.utils.getRootDirPath(mfilename("fullpath"), 4), "Data\Processed Data\"); cd(NoveltySU.utils.getRootDirPath(mfilename("fullpath"), 2)) protStr = "Active duration"; temp = NoveltySU.utils.dirItem(strcat(ROOTPATH, protStr), "spkData.mat"); popRes_behav = cell2mat(cellfu...
34a3d50204385a1c32d60e7f1751d07c7ae1998d8865569f69580ded81e068df
MATLAB
2,087
63
function [AUC, fpr, tpr, EER, cutoff, tprAtThresh, fprAtThresh, thresh] = ... rocPMTK(confidence, testClass, fprThresh) % Compute ROC curve % confidence(i) is a real value % label(i) is 0 or 1 % % AUC is area under curve % cutoff is the threshold that gives equal error rate (EER) % EER is the fpr=tpr at cut...
8f6915fde6c9d4efbee77ce59261c9277d29d0ead799b4cd44826cf724bc4679
MATLAB
2,087
55
%Define paramters simparams.IMAGE_RESOLUTION_XY = .165; %microns simparams.IMAGE_RESOLUTION_Z = .165; %microns simparams.IMAGE_FOVSIZE_XY = 150; simparams.IMAGE_FOVSIZE_Z = 50; %puncta size (I think u=10 and s=3.5 is correct but it's slow) simparams.PUNCTA_SIZE_MEAN = 8; %FWHM simparams.PUNCTA_SIZE_STD = 3; simparams...
028f92982ed30d51e512aa3df948a069b268708d866c9b707df3e59d914d798f
MATLAB
2,088
54
function CBIG_RF_find_nearestVertex_fsaverage2MNI_mapping(map_dir) % function CBIG_RF_find_nearestVertex_fsaverage2MNI_mapping(map_dir) % % This wrapper function reads the RF-ANTs fsaverage-to-MNI152 mapping and convert the spherical % coordiantes in fsaverage to their nearest vertices % % Input: % - map_dir: % ...
2461184f1fb8d3676f2334be277e9289dbbd642609c8b14e0d96a67b02f77eac
MATLAB
2,088
71
%% A = load('/groups/branson/home/kabram/bransonlab/pose_hourglass/pose_hg_demo/mpii_human_pose_v1_u12_2/mpii_human_pose_v1_u12_1.mat'); A = A.RELEASE; %% ff = fopen('/groups/branson/home/kabram/bransonlab/pose_hourglass/pose_hg_demo/annot/valid_images.txt'); G = textscan(ff,'%s'); fclose(ff); G = G{1}; %% imdir = '/gr...
4204e4abced6571a533eb67a5e9c4d7a179edecb8166a06593e607b9ad829cd9
MATLAB
2,088
50
function pw = lme_plannedPower(Zi,ZiCol,Dhat,phisqhat,effsz,dr,sz1,sz2,alpha) % pw = lme_plannedPower(Zi,ZiCol,Dhat,phisqhat,effsz,dr,sz1,sz2,alpha) % % Power calculation for a planned ba...
5eca92faec1eb78916bc1004118fc8b9fb1025073fcc234a5838800b180c615a
MATLAB
2,088
48
% This script computes the induced surface charge density for an % inhomogeneous multi-tissue object given the primary electric field, with % accurate neighbor integration % % Copyright SNM/WAW 2017-2020 %% Global accurate primary field tic gaussRadius = 2*R; [Epri, Ppri] = bemf3_inc_field_electric_gauss_sel...
e828c4205c50985730c0b0adcb64833fedb76f183dcb5a6ba508c76258b74aa7
MATLAB
2,088
85
%% Interpolate some data using a joint Gaussian % Based on p140 of "Introduction to Bayesian scientific computation" % by Calvetti and Somersalo setSeed(1); D = 150; Nobs = 10; xs = linspace(0, 1, D); perm = randperm(D); obsNdx = perm(1:Nobs); hidNdx = setdiff(1:D, obsNdx); xobs = randn(Nobs, 1); % Make a (D-2) * D...
d963535722b27d8c6f7e74c275250964ff64ad2b8ccd16951044b573c66645c9
MATLAB
2,089
67
clear all; %load ../phi/phi_0_25_1089.mat %Load the measurement matrix for measurement rate of 0.25 to sense patches of 33 by 33. load ../phi/phi_0_04_1089.mat %Load the measurement matrix for measurement rate of 0.04 to sense patches of 33 by 33. %load ../phi/phi_0_10_1089.mat %Load the measurement matrix for measure...
e78f312620b986ec4ebd42b3c05d299edef90c457b7f71ee357bc83b40e03cf7
MATLAB
2,089
78
% This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful,...
22f256ef0751dd2559b7b287cdde5c3d44080c44d45f0622d7d467c7595cb11c
MATLAB
2,090
77
%% Illustration of the bias variance trade off as we vary the L2 regularizer. % %% % This file is from pmtk3.googlecode.com function biasVarModelComplexity setSeed(0); n = 25; d = 1; lambdas = [exp(6),exp(0.5),exp(-2.5)]; ndataSets = 100; showNsets = 20; f = @(x) sin(2*pi*x); domain = (0:0.0005:1)'; fs = 16; figure...
68b24478acca21c0f6ab07c0e660b007c7c63fb7bbf9fbd692ba28fc5911e9f8
MATLAB
2,091
77
function sea_salt % general parameters alpha = 0.1; trials = 100; % parameters of reward basis model w_norm = [-1, 1]; w_depl = [0.5, 1]; %simulating models VTD = TD_learner (alpha, trials); VRB_bases = RB_learner (alpha, trials, w_norm); VRB_norm = w_norm * VRB...
d669e16145b84183ab282b26e696bc017f40b80004cd88ad131d5c9a1bb4ae7a
MATLAB
2,091
71
function S = varstruct(var1, var2, varargin) %VARSTRUCT Creates a structure out of a set of variables. Fieldnames are inferred from variable names. % Usage: % S = varstruct(var1, var2, ...) % S = varstruct('field1', val1, 'field2', val2, ...) % same as struct() % % Args: % var1, var2, ...: variables used to crea...
375e6143d68e48b1061d48610d0eaaba672191bdabdc0ed9de8febe6e578be3c
MATLAB
2,092
105
classdef RC % Configuration file properties (Constant) FILE = lclInitFile(); end methods (Static) function v = getpropdefault(name,dfltval) % get prop if it exists; if not, set prop to default val and return % it rc = RC.load; if isfield(rc,name) v = rc.(na...
b1c94442d38b9927bdf4730f699ca8a8bd0fdcbc852486aabaa249d10c2ed07d
MATLAB
2,092
69
function mask = mesh_mask(mesh, uidx, minv, minu, vsize, usize) % create a binary mask on a texture coordinate grid % % mask=mesh_mask(mesh, minv, minu, vsize, usize) % % mesh: struct elements f,v,vn,u,b % minv, minu: offset of u,v grid % vsize, usize: texture coordinate grid size %-----------------...
0a7bfca2079bd2e6266cda7d517c72a87d1353a777749210a3e69d6b6109ec2b
MATLAB
2,094
77
function Transform_Curvelet(num_, p, q) % Validate input arguments if nargin < 3 error('Not enough input arguments. Usage: Transform_Curvelet(num_, p, q)'); end % p: 1 for sweep, 0 for neutral % q: 1 for sweep, 0 for neutral if ~isnumeric(num_) || num_ < 0 error('Invalid in...
91ff7bb592accd9327b8dd9a14b8a12180188def6aaf3d36efb02316c4ad9a2e
MATLAB
2,094
83
function varargout = compileRunAndSave(fname,varargin) % Similar to compileAndRun except the mex file is not deleted. % If the mex file exists, then this function tries to use it and only % compiles a new copy if that fails. This version is useful when a function % will be called over and over again with the same sized...
ba7e0ccfbfe1c7da0479d2464f935b8f2af6e8edd2b613ad6279e8ec7b89e51f
MATLAB
2,094
65
%% GSA_GetTotalSy: calculate the total sensitivity S of a subset of inputs % % Usage: % [Stot eStot pro] = GSA_GetTotalSy(pro, iset, verbose) % % Inputs: % pro project structure % iset cell array or array of inputs of the considered set, they can be selected % ...
07cbee253528bda7103d73a857156ed98cb73740e4d3c2737538c3d8b37db42e
MATLAB
2,095
42
function Bpri = bemf3_inc_field_magnetic(strdipolemvector, strdipolemcenter, strdipolemstrength, Points, mu0) % Computes incident magnetic field from the dipole distribution via the FMM % in terms of the pseudo electric potential % % Copyright SNM 2018-2020 % Compute dipole positions, directions, and ...
e51aaf51ca60b3800131a818559c4456d6c5fa13f15039624a45facb3f185c2b
MATLAB
2,095
57
function [ridiff,cilohi,p] = ridiffci(r1,r2,n1,n2,alpha) % function [ridiff,cilohi,p] = ridiffci(r1,r2,n1,n2,alpha) % % computes a confidence interval (CI) for the difference of two INDEPENDENT Pearson % correlation coefficients and tests whether they are significantly different % % INPUTS % r1 Pearson correl...
2dde35e5c0d3c085f606aed2d78541abf6ee372f7c1469054cd7e1ac85499e21
MATLAB
2,096
84
%% filtfilt xt %// Variation of filt-filt which is better designed for short signals %(which will be more affected by signal endpoint artifacts). % % Reduce endpoint artifacts by appending 0-value rows to the passed % elements. % % B = input filtering coefficient (as filtfilt) % A = input filtering coefficien...
4b443527378a78503bd489c366c393814f7221e6813600bd0ad4d0ce0e24fd4b
MATLAB
2,096
69
function [Y,V] = maskMaker(format, maskFile, varargin) % Y = obj.mask; % returns a 3d logical of in-mask voxels for the grey matter mask of % the subject associated with the call. Does not work on top-level % (TIPPstudy) objects, or subject-level or below (below it will search paren...
7153256e4639466ed030b40074e0de4f7f89708ddaa2dee7c05dc53da697bc18
MATLAB
2,096
67
%% % Primary Data Dependencies % Used for the classes which directly interact with data, ensuring good % handling between interconversion and sampling; %_______________________________________ % Copyright (C) 2024 Trevor S. Smith % Drexel University College of Medicine % % This program is free software: you can re...
7f12d090acc83d1c37755bc6d1b11ebe9580603a5aff284d96500ed2bce516f2
MATLAB
2,096
70
function [allVec_rest,allTs_rest,fullCycle] = Closed_Loop_ETP_train() % Closed-loop algorithm using ETP to train the prediction algorithm based % on a resting state recording to use in real time. % allVec_rest: Resting EEG (channel*sample) % allTs_rest: Timestamp of each sample % fullCycle: Adjusted period based ...
bb01b38bdc783891edae11a5c8c6a2a083c6b1dcf71fca90b81b374774da2f12
MATLAB
2,096
103
function Feng_fit = feng_fit_wrapper(IDIF_path, qc_path, anatomy, options) if nargin<6 options = get_default_options(); end load(fullfile(IDIF_path,['IDIF_' anatomy '.mat']),'IDIF'); IDIF_raw = IDIF.IDIF_raw; t_IDIF_emi = IDIF.t_IDIF_raw; t_IDIF_delta = IDIF.t_IDIF_delta; %%%%%%% %%Fit%% %%%%%%% %settin...
d83130ac3a692b07add331658122b437881fd77ab8adfa372be9532c30561128
MATLAB
2,096
78
function [xs, idxs, phis_to_go, pAp] = conjgrad(eval_Ap, b, x0, maxiters, miniters, cg_tol) %% Implementation of the conjugate gradient method. See Martens, 2010. % phi(x) = 1/2 x' * A * x - b' * x is the quadratic function to be minimized. gapratio = 0.1; mingap = 10; maxgap = max(ceil(maxiters * gapratio), mingap) + ...
3ae65b2940c224a7a0d65f9434fce2b86ad2d7da3c72a6ad130ddc5f87e4942b
MATLAB
2,097
56
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% bem3_save_forwardp.m %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if n_shells <= 3 error("This script is meant to be used with models of more than three ...
034edaff77e10878814057941d1e97f2683907990d4cf42cee2a5f98088d38ad
MATLAB
2,098
73
function [EEG, epochFlags] = GetEpochFlags(EEG, updateManual) % [EEG, epochFlags] = GetEpochFlags(EEG, updateManual) % converts the binary flagged events within each epoch into indices of % flags for each trial (across all events within an epoch). This is stored % in EEG.epoch.trailFlags. % If updateManual = 1, then i...
41b476cb8a21b8148236b9585dc00e5e6247f36a47a650f7ee534f62cc8191af
MATLAB
2,098
44
function TSaddeventcodes(varargin) % TSADDEVENTCODES Adds individual event codes to the Experiment structure % TSaddcodes( name, value ) adds event code definitions to the % Experiment structure. Name is a string for 1 code or a cellstr for % multiple codes, indicating the names of the codes to add, and Value is...
795af4f6c107ce5900c979807cec7acf0bc25890a8c2cbd9f5737165a2076f57
MATLAB
2,098
70
%% Plot a 2D Gaussian and its decorrelated and whitened transformations % %% % This file is from pmtk3.googlecode.com function gaussPlot2dDemo2() setSeed(0); mu = [1 0]'; % mean (must be row vector for mvnpdf) S = [2 1.5; 1.5 4]; % covariance plotSurf(mu, S, 'Full') %% U = eigenvectors, D = diagonal mat...
982cd07f30301ef3b3e9d90362e8c195f77b5eb3f676cdc62b271d0db9f2553e
MATLAB
2,099
75
function htmlTableSimple(varargin) % Display a Matlab cell array or numeric matrix as an html table % Similar to htmlTable, but the resulting generated html % text is very bare bones, and hence easier to edit % and include in published documents % % format can be 'int', 'float' or 'str' % If str, we assume data{i,j} i...
a0cfa2e90bf60991300e6b28682048c2ed55a2b01590399ab8e99f162c3c3a42
MATLAB
2,099
83
% This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful,...
c59282f53f0ffcd033de6e086f7f55c12ebe52e170436fed2b6b8a14c61f9b84
MATLAB
2,099
66
% This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful,...
073ee3c2f546960d6b4fab83f9b2df06c63f0dc4a610351486a2a4c93c4678df
MATLAB
2,100
54
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This script corrects the obtained results for multiple comparisons using% % the Benjamin and Hochberg approach % % % % Author: ana.tr...
e3982400f23a8d9a8511e6fd5b750f4fb1fb3a3a8e79d5299d49577275d7d6a2
MATLAB
2,100
58
function [y,iflaw]=anafsk(N,Ncomp,Nbf); %ANAFSK Frequency Shift Keying (FSK) signal. % [Y,IFLAW]=ANAFSK(N,NCOMP,NBF) simulates a phase coherent % Frequency Shift Keying (FSK) signal. This signal is a succession % of complex sinusoids of NCOMP points each and with a normalized % frequency uniformly chosen between NBF di...
6789070543f87375bd2098f2725834a007c55f44cc298fb5b12fc202ee0c20c6
MATLAB
2,102
86
% _ _ % ___ _ __ __ _| |__ ___ ___ _ __| |_ % / __| '__/ _` | '_ \/ __|/ _ \| '__| __| % | (__| | | (_| | |_) \__ \ (_) | | | |_ % \___|_| \__,_|_.__/|___/\___/|_| \__| % % updates various elements when a new channel is selected function updateControlsOnChannelChange...
77d2ca43d7460d5da9419e95b20ea45965e26bfd42a33aa70bd35c99242aa78e
MATLAB
2,104
85
%XMLDEMO2 Demonstrate how to read an XML file, modify it and save it % % Description % This script demonstrates the use of the xmltree class to % open an XML file, access data stored in it, modify a value % and save the new XML file. % % This demonstration script need the file 'example.xml' created % in the...
0674bd0a3978f9aa1f5180e422df3cb7b74a4e781f6c7be6a6483984697aecc7
MATLAB
2,105
83
function A = fast_ica(x,pcomponents,nit) % Originally written by the Finish (Aapo) team; % Modified by the PIB team in Aug. 21, 2007 % PIB - Biological Information Processing Lab - UFMA - Brazil % Modified by V�tor Lopes dos Santos Aug. 2011. if nargin < 3, nit=100; end % fprintf ('Removing mean...\n'); %----------...
302e765cb3f0532c129a699e97a0ef9d5f7e0f0e2c8354759425f2635b2aed4b
MATLAB
2,105
88
function path = viterbi_path(prior, transmat, obslik) % VITERBI Find the most-probable (Viterbi) path through the HMM state trellis. % path = viterbi(prior, transmat, obslik) % % Inputs: % prior(i) = Pr(Q(1) = i) % transmat(i,j) = Pr(Q(t+1)=j | Q(t)=i) % obslik(i,t) = Pr(y(t) | Q(t)=i) % % Outputs: % path(t) = q(t), wh...
52eaee3e63ba6f907c23fe068639c255dab7318902adaef4f0b9d843fda15fe8
MATLAB
2,105
62
% RSKELF_PARTIAL_MV Multiply using partial recursive skeletonization % factorization. % % Like RSKELF_MV but using a user-supplied function of the form % Y = MVFUN(X,TRANS) to apply the compressed skeleton submatrix. More % specifically, denote by A the original matrix, and let SK and S be ...
5cf732582937320b1553abc728d232a34b000eef0e7f1baffe5159b2bd1b44b4
MATLAB
2,106
86
function [theta,e,hy,hp] = GLM_covComp(y,X,Qy,Qp,my,mp) % wraps GLM with multiple covariance components estimation into VBA % function [theta,e] = GLM_covComp(y,X,Qy,Qp,my,mp) % IN: % - y: px1 data vector % - X: pxn_phi GLM design matrix % - Qy: nqyx1 cell array of data covariance components % - Qp: nqpx1 cell ...
fb86409de33cecdb922ed31e589a77803e220e808b28deddca2f059ed91d07d1
MATLAB
2,106
73
function S = NB_Init(file) %% Unload variables from file and initialize [t_lim,L,div,s,D0,N_neur,tpr,uprr,uprt,uprd] = readvars(file,'Range','A1:J2'); [Kt,Kc,Kr] = readvars(file,'Range','K1:M3'); t = 0; f = 0; [X,Y] = meshgrid(1:div); % Neuron matrix: [position mesh number ; upr(-1) ; upr] NEUR = zeros(N_neur,3); % F...
4a6b29c96e81eb0f6beef0632c0600a8498ed4b27f1a2ea2701fd8dd84e132e2
MATLAB
2,107
56
function [varargout] = narginchk(varargin) % NARGINCHK is a drop-in replacement for the same function that was % introduced in MATLAB R2011b. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % see https://github.com/fieldtrip/fieldtrip/issue...
8de88d264e93237141fedb59bd087c890d8e89a04d658aadf3f2e6898658d86f
MATLAB
2,108
74
function xout = scale(x,varargin) % Centers and scales column vectors to mean 0 and st. deviation 1 % % :Usage: % :: % % x = scale(x,[just center]) % % Notes: % - This function will remove NaNs, but will remove ENTIRE row if any % observation is NaN. This may be suboptimal for some applications. % - In the future, ...
b1b15aa01b843c39e16387f2a1e7f1f9348b6274ba4270c846ba8c7ccee7ae7d
MATLAB
2,108
58
% FT_POSTAMBLE_HISTORY is a helper script that stores the configuration structure that % is present in the present workspace (i.e. the workspace of the calling function) in % the output variable. % % Use as % ft_postamble history outputvar % % See also FT_PREAMBLE, FT_POSTAMBLE, FT_POSTAMBLE_PROVENANCE % Copyright (...
ced67ac01489ee969ae39aaac72ce176372f0df46f07c06f770118d1a4fa9ef9
MATLAB
2,108
81
% demo for calcium imaging of spike trains % The script first simulates the response of a Fitz-Hugh-Nagumo (FHN) % neuron to spiky input current. It then inverts a FHN-neuron model, % without the input current info. Practically speaking, this means % deconvolving the FHN-neuron response to estimate its input. % [see de...
4a50b89a74ce3cbf24f73db8b3f15b58c394fc6a056ec6267459636b9a7271b6
MATLAB
2,109
68
% read_erplabdata() - import ERPLAB dataset files % % Usage: % >> dat = read_erplabdata(filename); % % Inputs: % filename - [string] file name % % Optional inputs: % 'begtrial' - [integer] first trial to read % 'endtrial' - [integer] last trial to read % 'chanindx' - [integer] list with channel indices to ...
779eae0850ef217be411dfed4224f77fce0f707b61e5f097bfc5749b27b91bc9
MATLAB
2,109
70
function rt = isParsableDspaceArg(arg) % This function returns true if the function dspace() could parse the argument as part of % a Dataspace datasource. % Internal function used by dspace(). % % % %<PRE> % This file is part of dspace-core. % % Copyright (C) 2020 Universi...
c6307a0447d0abcc2c1249ec1488f09e2d912b1185f5ee42087590fe0b3c9728
MATLAB
2,109
61
function [varargout] = isrow(varargin) % ISROW is a drop-in replacement for the same function that was % introduced in MATLAB R2010b. v = version; if v(1) ~= '7' p = mfilename('fullpath'); p = p(1:end-6); rmpath(p); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
d455085ca2710ba1c20b28d4c92cebf2a02fc00b6e074c176045bc5bb32f9fc2
MATLAB
2,109
110
clear clc close all load data/taskswitch_all_rats %%% (generated by save_taskswitch_all.m) prevstart=5; prevend=30; lenprev=prevend-prevstart+1; newend=30; xvals=(1:lenprev+newend)-26.5; figure; subplot(1,2,1); hold on plot(xvals,az1d2f,'k-','LineWidth',1,'MarkerSize',30) plot(xvals,az2d2f,'b-','LineWidth',1,'M...
0b0ecd4cfe22831876ada15924b32d0d7ba97b8f284a95871109e0388a3b6dda
MATLAB
2,110
76
%% Multiclass Logistic Regression % In this demo, we fit a multiclass logistic regression model by first % performing various basis expansions of the input features. This is a % simplification of logregMultinomKernelMinfuncDemo. %% % This file is from pmtk3.googlecode.com %function logregMultinomKernelDemo() %% Setu...
a9c80c95bd33151e41fca300d849edfcdc0a948461ea2c5bc76c9869718e5e3e
MATLAB
2,110
60
function approxgrad = getApproxGradient(problem, x, storedb, key) % Computes an approximation of the gradient of the cost function at x. % % function approxgrad = getApproxGradient(problem, x) % function approxgrad = getApproxGradient(problem, x, storedb) % function approxgrad = getApproxGradient(problem, x, store...
fdfb88e50f481740d807e8ca86dda49281f984c17abf481b8774db3e724caca4
MATLAB
2,110
64
addpath C:\code\wjn_toolbox addpath C:\Code\wjn_toolbox-master addpath C:\code\spm12 addpath(genpath('C:\code\leaddbs\leaddbs')) addpath(genpath('C:\code\spm12')) addpath(genpath('C:\code\wjn_toolbox-master')) spm('defaults','eeg') %% load ECoG_Atlas_Master_Table_New.mat % load ECoG_Atlas_Master_Table.mat itheta = find...
9b445e47df1f4adfa9910a13868b8852a6a6c22fca8e5ad1be000d5a7f7d734f
MATLAB
2,111
58
%% S2 Fig: To plot time course after block averaging for each condition over all subjects clear all clc load incongruent_allsub_2probe_final.mat load congruent_allsub_2probe_final.mat load incongruent_allsub_2probe_final_hbr.mat load congruent_allsub_2probe_final_hbr.mat D_con = cat(3, congruent_allsub_2probe_final{:...
01da832892f52338b5b7a53110ab250300eccb881618139aa262936aef1342a2
MATLAB
2,112
64
clear all; tic; global mInst mpInst pInact qInst global NaF NaP M CaL KCa kCain %% MODEL CONFIG %currents and concentrations included into neuron model if 1 % NaF NaP Kdr KM CaL KCa Cain % 1 2 3 4 5 6 7 neu = [ 1 1 1 1 1 1 1 ]; NaF = neu(1); NaP = neu(2); M = neu(4); CaL = neu(...
721fbcdb07476065cdc064163f7569e536257a319c2f0b00af3e8cc5071c3c87
MATLAB
2,112
64
clear endtime simdir starttime sumres_xyz; ctopdir = '/home/amonreal/Documents/PhD/tools/check_grad_idea_Des'; simdir = uigetdir(ctopdir, 'pick the simulation results directory'); if simdir==0 error('need directory input'); end if ~exist(simdir,'dir') error('directory does not exist'); end cd(simdir); gaxes = ...
7325e0d3c2892ef3f95add45c097146ab5c69baf37547df8c690e64a660a5669
MATLAB
2,112
47
function lan_master_gui_xcor(LAN_var, mainfig) LAN = LAN_var; figure(mainfig); cfg_control(1) = uicontrol('style', 'text', 'units', 'norm', 'position', [.3 .92 .44 .05],... 'string', 'channel(s) : ', 'horizontalalignment', 'right'); cfg_control(2) = uicontrol('style', 'edit', 'units', 'norm', 'position', [.75 .92...