sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
80f260fc1d248a7e1248afcf80dc225e25f0b0e70fe3e3b4653acb371f747894
MATLAB
1,652
55
%% Plot test error vs C for differnet gammas in an SVM % Same as Figure 12.6 in "The elements of statistical learning" 2e % by Hastie, Tibshirani, Friedman %% % This file is from pmtk3.googlecode.com if ~svmInstalled fprintf('cannot run %s without svmfit; skipping\n', mfilename()); return; end data = loa...
8394787ba9b8a28b72790c41a467465e0df438f37f9d9cf2364dd4417adf3d92
MATLAB
1,652
62
function [style, colors] = meg_manuscriptStyle % parameters for reproducing manuscript figures style.widthTS = 470; style.widthScatter = 300; style.height = 300; style.ebLineWidth = 0.2; % line width of shaded error bar edges % scatterplots style.xBuffer = 1; style.xBufferSml = 0.2; style.scatter.MarkerSize...
c996b5c808a7a5b76f36a209bdfcdc49d149448852862e43f5ce5d52982a4b8b
MATLAB
1,652
65
function pin = GetOneInteriorNode(t,p) % Asssuming a closed manifold surface is defined in 't' and 'p' % this routine returns coordinates of a point within the surface. % It assumes the surface is oriented and the normals of the triangles are % pointing outward. pin = []; bbx1=max(p); bbx2=min(p); ld=min(bbx1-bbx2); ...
28db03bc1d18ed30ed9e65cde75385ce5365a2cd7a785e5b6d4591285148f0a4
MATLAB
1,653
61
% model 4 load test_minentest4; x = randn(2000000,2); vXEdge = linspace(-5,5,70); vYEdge = linspace(-5,5,70); xHist2d = hist2d(x,vYEdge,vXEdge); nXBins = length(vXEdge); nYBins = length(vYEdge); vXLabel = 0.5*(vXEdge(1:(nXBins-1))+vXEdge(2:nXBins)); vYLabel = 0.5*(vYEdge(1:(nYBins-1))+vYEdge(2:nYBins)); Sigma = [1...
e80ba21842ac7f8c82e7906ffd910fed6b98f78a2bb1f2445104fb522e8360bc
MATLAB
1,653
53
% HIFDE_CHOLMV Multiply using generalized Cholesky factor from hierarchical % interpolative factorization for differential equations. % % Typical complexity: about half that of HIFDE_MV. % % Y = HIFDE_CHOLMV(F,X) produces the matrix Y by applying the generalized % Cholesky factor C of the factor...
eb8630b3ace01d6507472989f67012885a54aa29b731a98d1fe05eb426814485
MATLAB
1,653
47
function output = cellfetch(cellinput, field, branchindex) % searchresults = cellfetch(input, field) % % This function parces a nested cell variable 'input', and assumes nothing about % the structure of the internal cell tree. It returns a structure with the value of the % field variable in the field 'field' at the en...
5aa56adf2d60564794f5d4926f915b6576c6b4da87f5419e94a6b6f78f0a66bf
MATLAB
1,654
50
function y = amgauss(N,t0,T); %AMGAUSS Generate gaussian amplitude modulation. % Y=AMGAUSS(N,T0,T) generates a gaussian amplitude modulation % centered on a time T0, and with a spread proportional to T. % This modulation is scaled such that Y(T0)=1 % and Y(T0+T/2) and Y(T0-T/2) are approximately equal to 0.5 . % % N...
66cc45cbdc4dae765a00838da4737f21ff89643c8daf427c72c231387dd67f18
MATLAB
1,654
51
function se = strel3D(shape, size) % 3D version of matlabs 2d strel function % Implements 'sphere' and 'cube' % % strel3d(shap,size) % % see also strel %--------------------------------------------------------------------- % license %--------------------------------------------...
7fe28eeaf29e76379a8aa1424b90beb4bc7104b93d12363fb60dc7015c6893d8
MATLAB
1,654
54
% Example using lsqnonlin optimizer and registration error image % instead of value. % clean clear all; close all; clc; % Add all function paths addpaths % Read two greyscale images of Lena I1=im2double(imread('lenag1.png')); I2=im2double(imread('lenag2.png')); % b-spline grid spacing in x and y dire...
a3896ce8c814c9fcbd5e2dd38530a8364804c5fcf471d796399993f43ac48d9d
MATLAB
1,654
60
% 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,...
7bd057385b2bddda637c386a87927ba5f798026d7945f5d45cb55a78a8b962a3
MATLAB
1,655
72
function hintonDiagram(w,max_m,min_m) % Display a matrix W where the square's area represents W(i,j) % and red = negative, green = positive % % Examples % % W = randn(4,5); hintonDiagram(W) % This file is from pmtk3.googlecode.com % Based on hintonw function from Mathworks neural net toolbox if nargin < 1,error...
f4f3a02501f939800c4c3d1ffb9efd1b39e891c177450e67c57fc1d0cc496daf
MATLAB
1,655
91
function EEG = lan2eeglab(LAN) % v.0.2 % provisorio % para guarda en .set y hacer ica % % 12.12.2022 EEG = lan_check(LAN); %EEG = LAN; ref_field = { 'trials',... 'srate',... 'xmin',... 'xmax',... 'data',... 'event',......
35505d1c9095dc06e060b93229219a3f7f5f0c106d295e234ce4b200fe3ee90a
MATLAB
1,656
49
%% Function for PRx analysis function [PRx] = func_PRx(ICP, MAP) % Input: % ICP: Continuous intracranial pressure time series % MAP: Continuous mean arterial pressure time series % Time series should be synchronized and span the same timeperiod, and % optionally filtered to remove noise from pulse ra...
46220a9bdf8defec6010af75d152cf167a727268846ba63958bd914316bb7ba7
MATLAB
1,656
57
%{ Copyright (c) 2025 Axion BioSystems, Inc. Contact: support@axion-biosystems.com All Rights Reserved %} classdef EntryRecordID < uint8 %ENTRYRECORDID Values for entry record types used in headers / % subheaders % % Terminate: Used to indicate the end of the record entries in % he...
de3ac3670132c655b77509d405005879f42fa3109d4284f565df8c8c4c27149a
MATLAB
1,658
64
function meg_multiplot(vals, layout, cmap, highlightChannels) % % function meg_topoplot(vals, [layout], [cmap], [highlightChannels]) % % INPUTS % vals is an N x t matrix one value per channel, where N is number of channels % layout is an ft layout (see ft_prepare_layout). will generate layout from % custom file if not ...
0d83ee9eea461358ed6f28c629d22795402495f68496c79ee51d5e1674d61af1
MATLAB
1,660
50
function [list, badnodes]=GetListofConnectedTetsToNodes(t,p,verbose) % list=GetListofConnectedTetsToNodes(t,p) % This function assumes that the mesh in 't' is a valid mesh and has been % checked by our diagnostic tool CheckMesh3D. It then returns a cell array % whose members are list of elements attached to each node. ...
1d44096d0de9bf22d301d49cb3f4fda837844958508fa1b237656bc0af0b7cf3
MATLAB
1,660
66
function h_searchAndRemoveFromGroup3(handles) global h_img3; UData = get(handles.h_searchForGroupGUI3, 'UserData'); structName = ['I', num2str(UData.instanceInd)]; pathname = get(handles.pathName,'String'); basename = get(handles.fileBasename,'String'); fileExtension = get(handles.fileExtensionOpt,'String')...
a82c467f305b0f28400da5403db59a8e9a4f4d8be93d9120824323052fb6ad0d
MATLAB
1,660
47
function model_fit = predict_venous_model(t_fit,covariates) % Predict FDG venous radiotracer concentration from subject's covariates, % % Volpi T et al., Modeling venous plasma samples in [18F] FDG PET studies: a nonlinear mixed-effects approach. % Annu Int Conf IEEE Eng Med Biol Soc. 2022 Jul;2022:4704-4707. doi: 10....
c8c1efd8b852a0a11dd3d79f20fc27366b0b3d6f410d1efe60136aaa85475562
MATLAB
1,660
44
function si = import_simulation_files(fileNamePtrn,sort_by_par) if (nargin < 2) || isempty(sort_by_par) sort_by_par = ''; end f = dir(fileNamePtrn); assert(numel(f)>0,'No file found that matched the pattern'); fn = fullfile(f(1).folder,f(1).name); si(1) = import_single_file(fn); for ...
751d72c63d6da9250c733dce7e4934a1f1a4ace7a244b51f0dd5253c80d62485
MATLAB
1,661
51
function [st badtets badfaces] = check_tetrahedron_faces(e) % check faces to make sure every face is only used by 1 or 2 tetrahedrons % Returns: % 0: OK % 2: invalid mesh with more than 2 tetrahedron per face % % Written by: % Hamid Ghadyani, 2009 st = 0; fprintf('\nChecking tetrahedral faces..... ') faces=[e(:,[...
77a65a7800a0d13e4df0a760bb7468a7d15d7df11437bc0e173b3256cadd704d
MATLAB
1,661
67
function varargout=savebnm(fname,varargin); % a compact binary format for saving a matrix. (using float) % % % savebnm(fname,M1[,M2,M3,...]); % % Can save multidimensional matrices containing: Nans,Imaginary numbers and Inf % % see loadbnm % % Aslak Grinsted 2004 april % % --------------------------------------------...
8f81856626bb4e6c6402589f103f3b706dc7ff209735c72bfb3c22878a062a16
MATLAB
1,661
88
%% Demo of error correcting code % ----- % | | % | v % x1 x2->x3 % | | | % y1 y2 y3 % % x3 = even parity bit % yi = noisy copy % This file is from pmtk3.googlecode.com %% Build model xs = 1:3; ys = 4:6; G = zeros(6,6); G(xs(1:2), xs(3)) = 1; for i=1:3, G(xs(i), ys(i)) = 1; end ns = 2*ones(1,6...
aec5aa7046770eb58b01b2e4fa383b84a31f37f61b88e150ac8613abf679d38b
MATLAB
1,661
91
function [events, mappings] = fiff_read_events(source, tree) % % [events, mappings] = fiff_read_events(source, tree) % % Read the events % % If tree is specified, source is assumed to be an open file id, % otherwise a the name of the file to read. If tree is missing, the % meas output argument should not be specified. ...
c5ffdb0070f325250b65df4b0823e49dd0905bc3eb31333ef466d411964ca43f
MATLAB
1,661
53
function [cRow, cCol, ra, rb, phi] = gauss2ellipse( mu, C, rad ) % Creates an ellipse representing the 2D Gaussian distribution. % % Creates an ellipse representing the 2D Gaussian distribution with mean mu % and covariance matrix C. Returns 5 parameters that specify the ellipse. % % USAGE % [cRow, cCol, ra, rb, phi]...
6b387f2e4b4ae36041904ee186bdf735f98a506b6833cfae7ca2649c8d29123f
MATLAB
1,662
57
function tests = test_VBA_sqrtm % Unit Tests for VBA_sqrtm tests = functiontests (localfunctions); % ------------------------------------------------------------------------- function test_empty (testCase) actual = VBA_sqrtm ([]); testCase.verifyEmpty (actual); function test_scalar (testCase) C = ...
a9d857dca21e8943b46ef23432953578fa1c1de1182655bf3decff28c07aefdd
MATLAB
1,662
50
function logstack = LOG(stack, sigma) % Laplacian of Gaussian in 2 or 3 dimensions % % LOG(stack,sigma) %--------------------------------------------------------------------- % license %--------------------------------------------------------------------- % Copyright 2015 Idse Heemsker...
90533e95849628785eeb231d34baff0aab0ba95ec32a9d8115dae40ebf41d46d
MATLAB
1,663
74
function [video,n_frames] = mat_to_video(array,filename,frame_rate) % % >>> OPERATION >>> % Converts series of TIFF files into an AVI video. Uses MPEG-4 compression by default. %% % >>> USE >>> %Select first TIFF file in the folder. The remaining files will be %automatically found and concatenated %If not provided, f...
6ee4923e43462cc022464c6bea870b2640b22e7af8e9f7cfd7c8a4302c95d0b8
MATLAB
1,665
51
function hdrols = deconvTseries(scm,dat,err) % hdrols = deconvTseries(scm,dat,err) % % computes a ordinary least squares estimate % of hemodynamic response function from % from ER-fMRI time series (dat) and stimulus convolution % matrix (scm) % % dat = scm * hdr + noise % hdr_ols = inv(scm' * scm) * scm' * dat %...
70351ad7d8898bf83602d24d08c670c56dd6e1b0bedfd0c3035a1704fdb2e892
MATLAB
1,665
60
function [error, devs, s, STEP, DELAY] = fiterror (param, model, startpar, g, typestat, d, iter, statweight, parange) % This function calculates the cost function. penalty = 0; if nargin >= 9 & ~isempty (parange) difmin = param .* startpar - parange(:,1)'; penalty = sum (abs(difmin)-difmin); difmax = parange(:,2)'...
e18ce83b83b2701ea2e24f2282bbcd1398e22a8b85ad36b8831cf6c5078cd35e
MATLAB
1,665
53
% HIFDE_CHOLSV Solve using generalized Cholesky factor from hierarchical % interpolative factorization for differential equations. % % Typical complexity: about half that of HIFDE_SV. % % Y = HIFDE_CHOLSV(F,X) produces the matrix Y by applying the inverse of the % generalized Cholesky factor C o...
9d9831d633ea15d689e816a26b009ec61af9af3b1ce56b889e24936be6c1b599
MATLAB
1,666
58
function address = getaddress(hostname) % GETADDRESS returns the IP address % % Use as % address = getaddress(); % or % address = getaddress(hostname); % % See also GETUSERNAME, GETHOSTNAME % Copyright (C) 2015, Robert Oostenveld % % This file is part of FieldTrip, see http://www.fieldtriptoolbox.org % for the do...
10b12d92301f44577062e03db5035340c2ab4be31745a56b1a75959d923cf3d1
MATLAB
1,667
52
function [OutputArray]=String2Array3(InputString) %Handles Negatives and Decimals NumChar=length(InputString); OutputArray=[]; Count=0; position=2; NegVal=0; DecimalCount=0; DecimalOn=0; while position<=NumChar isvalue=1; CurrentNum=[]; while isvalue ...
6709da8d71886f8fde5436097ed8a1d4066c6b09c9356436811ff4982ee59e07
MATLAB
1,667
66
function [Y,dYdom,dYdT] = rigid_motion(X,om,T); %rigid_motion.m % %[Y,dYdom,dYdT] = rigid_motion(X,om,T) % %Computes the rigid motion transformation Y = R*X+T, where R = rodrigues(om). % %INPUT: X: 3D structure in the world coordinate frame (3xN matrix for N points) % (om,T): Rigid motion parameters between worl...
7211651ebc6df1cd66b492f15e44082f11aa0eca1d1cef47fbea353e7f3d73ca
MATLAB
1,668
44
function I3=movepixels(I1,T,mode) % This function movepixels, will (backwards) translate the pixels % of an 2D/3D image according to x, y (and z) translation images % (bilinear interpolated). % The function is a wrapper around mex files movepixels_2d_double.c and % movepixels_3d_double.c and movepixels_3d_single...
f9d8487bba59749c51748e3f4556be46b3cb4893bb3f3959f3a1fb1d0e79fc28
MATLAB
1,668
58
function ts_shift = AlignWave(wave, peakLoc, varargin) % REQUIRED ARGUMENTS % wave - clip of data containing a single spike waveform, # samples % peakLoc - target location of waveform peak % OUTPUT % ts_shift - timing shift, in sample numbers, required to align the spike % waveform to peakLoc [...
0883be360b93485048c1f58683616adce9143657b31617882aa25d9a53829146
MATLAB
1,669
53
function [] = VBA_pause(options) % used to pause the VB inversion from the GUI interactively % NB: when paused, the inversion allows interactive diagnosis... if ~ options.DisplayWin return; end try dt = toc(options.tStart); timeString = sprintf('Elapsed time: %d min and %d sec', floor(dt/60), round(rem(dt,...
1012ea9e52e409b192d03b05ea977e34fc75641b86be62de6653b0b43090e855
MATLAB
1,669
80
%% sample from a DP mixture of 2D gaussians %PMTKauthor Yee Whye Teh %PMTKurl http://www.gatsby.ucl.ac.uk/~ywteh/teaching/npbayes/mlss2007.zip %PMTKmodified Kevin Murphy % Originally called DPmixgenerate clear all seeds = [2 3]; for trial=1:numel(seeds) seed=seeds(trial); setSeed(seed); aa = 2; % alpha nn = 1000; %...
097ba45038c50b969550e3c6fd683204aae038f50b4633382611acf5acc32294
MATLAB
1,670
51
function [rho,pval]=MySpearman(x,y) % This function is to be a dedicated super-fast Spearman correlation % calculation for the input data X(col vector) and Y(matrix). Inputs are % assumed to have the same number of rows and have no NaNs or Infs. Y is % also assumed to have no duplicates within a column. % Steps:...
92f0795d4036f6bf7af8a20047a1da8f2a8805d56075d24dcaa0ee5a46604823
MATLAB
1,671
44
% FHN evolution function: % % [fx] = f_CaBBI_FHN(Xt,Theta,Isyn,inF) % % this function contains the equations and parameters of the FHN neuron % model, and the over-time integration scheme function [fx] = f_CaBBI_FHN(Xt,Theta,Isyn,inF) dt = inF.dt; Tau_Ca0 = inF.Tau_Ca0; % Hidden variables V = Xt...
a7b6a578d4b38055dd7b23380514c2b5a815af3a29e7917dd5e6eb37799fc3a4
MATLAB
1,671
53
% function coreg_check( ... % bkgnd_file, ... % out_path ... % ) function coreg_check(bkgnd_file,out_path,tpm) % Make a nice at-a-glance image to check registration between structural % and functional. Works great with the mean functional as the background % and the gray matter segmented image as the overlay....
114290cef83cdb330f4d7201b498373d22a65dda173ce2060e3326c4153ccf2f
MATLAB
1,672
66
%% Demonstrate inference in a small 2d grid of a noisy image of an X % Based on % http://www.cs.ubc.ca/~schmidtm/Software/UGM/linprog.html %% %PMTKrequireOptimToolbox linprog is called by UGM_Decode_LinProg %PMTKrequireOptimToolbox bintprog is called by UGM_Decode_IntProg % This file is from pmtk3.googlecode.com %...
2e5ea4acddd1003a58a9d710b08510edd037e39f20164cab44e699ddb23c8b26
MATLAB
1,672
70
function motion_filt = CBIG_preproc_motion_filtering(motion, TR, f_min, f_max) % MR_filt = CBIG_preproc_motion_filtering(motion, TR, f_min, f_max) % % This function filters out respiratory pseudomotion from motion estimates % % Inputs: % % - motion: % N by 6 matrix of the motion estimates. N is the number of fra...
33f425aa348d09222c361bca0eb1103c8c567402e118792e1ce3ec04a2a136c8
MATLAB
1,672
33
function y_ZStandardization_Bilateral_Surf(InFile_LH, InFile_RH, OutputName_LH, OutputName_RH, AMaskFilename_LH, AMaskFilename_RH) % y_ZStandardization_Bilateral_Surf(InFile_LH, InFile_RH, OutputName_LH, OutputName_RH, AMaskFilename_LH, AMaskFilename_RH) % Calculate z-standardized data for bilateral hemispheres % Input...
441940630b2256b80f83d86d8690710532bf801c6667e82c5c3b7711c04ad3ca
MATLAB
1,672
64
function fp_linsys = analysis_fixed_points(model,fixed_points) unpackStruct(model); unpackStruct(fixed_points); n_units=length(wO); %%% output at fixed points fp_linsys.o1=f1*wO'+bO; fp_linsys.o2=f2*wO'+bO; % fp_linsys.sat1=nan(n_units,size(f1,1)); % fp_linsys.jacs1=nan(n_units,n_units,size(f1,1)); fp_linsys.in11=...
62f6e92f1a6dd85c50ec887e7a2e82bd11d42927247dcb2a1f57c48df3724540
MATLAB
1,672
52
function [myhist precomp_grads] = buildOriHists(x,y,z,radius,pix,fv,sift_params, precomp_grads) if (sift_params.Display_flag ==1) figure; hold on; axis equal; for i=1:sift_params.nFaces tmp(1,:) = fv.vertices(fv.faces(i,1),:); tmp(2,:) = fv.vertices(fv.faces(i,2),:); tm...
d0c6ec8a438cc63e9e1280e196c8bf2952a59d76c7bfda72642d01653b20b74b
MATLAB
1,673
53
function G = mkRndDag(nnodes, maxFanIn, maxFanOut, sparsityFactor) %% Make a random, directed, weakly connected, topologically ordered, acyclic graph % % A directed graph is called weakly connected if replacing all of its % directed edges with undirected edges produces a connected (undirected) % graph. From http://en....
795d3435cd8a0382d0e21da83ecbbc5c7ba3ef82bcc849ca67585b625f9bad27
MATLAB
1,674
53
% % This code will calculate the MSD from relative displacement value for the 2d glass. call this function after loading your data in run_relativeDisp_2d. function [wmsd_eps,wmsd_aveps] = caculate_window_dmin(small_x,big_x,small_y,big_y) af = '70'; ns = length(small_x(:,1)); nb = length(big_x(:,1)); Np=ns+nb; savepat...
ee8b2cab7acac6c0be5723aad30f92939ffaf3b5f2ac1e3572c15cf198f5c9bd
MATLAB
1,674
51
function jtree = mcsCliques2Jtree(clqs) % input: clqs, a 1 x t cell array of nonempty cliques % of a chordal graph in the order produced by maxCardinalitySearch % This is algo 4.8 of Cowell 1999 except % we exploit the fact that the clqs were generated by mcs % This file is from pmtk3.googlecode.com % This is...
78eb4bef90459c4a826062ea0b6e2fdd455b8d4054575e1abe60fe6d49c6c65e
MATLAB
1,675
65
function [f, cxy, scxy95] = lan_coherence_shuffle(LAN, cfg, samples) %***************DEPENDENCIES*************** % - hann (Signal Processing Toolbox) % - hamming (Signal Processing Toolbox) % - lan_cspd (LAN toolbox) % - lan_cspd_mt (LAN toolbox) # See Dependencies (Chronux) if ~isfield(cfg, 'twin') disp('Setting ...
95030d8f9939fc988306619f34380480e40345670d2e41c1ecc6285198589665
MATLAB
1,676
51
%% force_delete % % force_delete(filename) % % does what it says on the tin. No 'permission denied' nonsense. % function force_delete(filename) fID = find_fID_for(filename); % find all file IDs for meta file, might be open for reading and writing so may have more than one file ID if ...
10dac7cfdb9a843c22413e3d7e3ac133769624dc0a81214858e460287e3caea5
MATLAB
1,677
53
function [assignment, cost] = assignmentsuboptimal2(distMatrix) %ASSIGNMENTSUBOPTIMAL2 Compute suboptimal assignment % ASSIGNMENTSUBOPTIMAL2(DISTMATRIX) computes a suboptimal assignment for the % given rectangular distance (or weight) matrix, for example the assignment % of tracks (in rows) to observations (in ...
ed53fe7ea8de90fe0345c6058b0e62d80a9779e3a3ce0a91aec23e175d984c4c
MATLAB
1,677
38
function nc_spm_group_newsegment(SPMFilePath, newseg_jobmatfile, subj_t1files) % SPMFilePath='G:\guobin\spm12\'; nsubj=length(subj_t1files); parfor i=1:nsubj [fpath, ~, ~]=fileparts(subj_t1files{i}); yfile=nc_get_specific_file_path(fpath, 'y_', ''); if exist(yfile, 'file') == 2 continue ...
a2ff41b7ef427bd96578c0f841781be8c310242b774d0d0a85200983403b61ff
MATLAB
1,678
62
%% init clear all addpath(genpath('src')); parameters; %% files = dir(fullfile('input', '*.tif')); % Display the names names = {files.name}; n_files = max(size(names)); disp(['number of files: ' num2str(n_files)]); results = {'Name', 'Sholl, k', 'Determination R^2', 'Volume, um^3', 'Edge Lengths, um'}; %% Run loop ...
22feb54a59a3a46cac08f4b600839fae9060e1283653e0267162e2570379a6a3
MATLAB
1,679
36
% SOFA API - demo script % Load HRTF in ARI format and save as SOFA format % Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences % Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License") % You m...
335803e7916c2025a569161c9a4694ee42ff1bc512f40edcd12778468c7d7b43
MATLAB
1,679
73
function sz = figsize(h, width, height) %FIGSIZE Resizes the specified figure while keeping it on screen. % Usage: % figsize([width, height]) % figsize(width, height) % figsize % returns figure [width, height] % figsize(h, ...) % % Args: % h: handle of figure to resize (default: gcf) % width: new width ([]...
91db44d765f340756db5d74b418e0ba7c6311e0211bd2a3708c5c46f90db15ce
MATLAB
1,679
58
% 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,...
026a95368a238dde73b729fd7b0e066fb8f740600894828c47b63a5b99e4f90b
MATLAB
1,680
52
function [grid] = sel50p(cfg, grid, sens) % This function will add the field "subspace" to the grid definition. % % The subspace projection corresponds to selecting 50% of the % channels that are the closest to the dipole. % set the defaults if ~isfield(cfg, 'feedback'), cfg.feedback = 'text'; end Ninside = ...
959ab70ef768f40073e0034b5d366256aa9cf2fa7b9a92cc9400843fbc24d379
MATLAB
1,680
52
%% Plot performance of linear regression vs sample size % %% % This file is from pmtk3.googlecode.com setSeed(0); degrees = [1, 2, 10, 25]; for d=1:numel(degrees) deg = degrees(d); lambda = 0; %1e-3; ns = linspace(10, 200, 10); Nns = length(ns); testMse = zeros(1, Nns); trainMse = zeros(1, Nn...
4790da3e20f4e568b48a14cf45eeec922eded9081dc8cdbc34532b9b5457a408
MATLAB
1,681
53
function [S] = FreedDWSSFPOscillating(TR,alpha,D,T1,T2,b) % % calculates steady-state magnetization with diffusion weighting % for oscillating diffusion gradient based on the Freed model. (Appendix 2) % % input: % G = strength of diffusion gradient (mT/m) % TR = repetition time (ms) % alpha = flip angle (degrees) % ...
5ce277b0e8953a62c8b06231dfb8a715410151dd12fbe8c13bbceaa3d8a801a1
MATLAB
1,681
61
function [idx1 idx2] = CorrespondingSpikes(spk1, spk2, maxDiff) % 8/30/2016 M. Farries % This function tries to find a one-to-one correspondence between elements % of two arrays, "spk1" and "spk2." Elements of one array are "matched" to % the closest elements of the other array, but no element in one array is % a...
73aa764205eb4b2a7c62893dd610513841498a3edfdb88e4bad685cad4c7901b
MATLAB
1,681
56
function [ newftdata cropdefs ] = wlFT_trimTrials(oldftdata, limitsfunc) % function [ newftdata cropdefs ] = wlFT_trimTrials(oldftdata, limitsfunc) % % This function truncates trial records to limits computed by "limitsfunc", % adjusting "sampleinfo" appropriately. % % "oldftdata" points to a Field Trip data structure...
05ee7ceea71e6666d92a764284ca52dbbbd2a952301df0fc18ebd7e6b1428795
MATLAB
1,682
63
function [fx] = f_Kalman4bandits (x, P, u, in) % // VBA toolbox ////////////////////////////////////////////////////////// % % [fx] = f_Kalman4bandits (x, P, u, in) % % Kalman filter learning rule for the N-armed bandit task as in % Daw et al. 2006 % % ////////////////////////////////////////////////////////////////...
57ce7be65621c24515cc2049a2eaadca09360d461ed1b254f3b96ee8571fe16e
MATLAB
1,682
58
%% warn_supp % % Suppress printing of Matlab warning message % % <matlab:open('warn_supp.m') code> % %% Syntax % % oldstate = warn_supp(warnid) % %% Arguments % % _input_ % % warnid Matlab warning identifier (default: 'all', for all warnings) % % _output_ % % oldstate previous state of warning corresp...
6938220581c0640b889ecb841abb6f547ac84d1b91dee32e9219ca7f6ac6f88e
MATLAB
1,682
54
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % To remove the frequency components of the signal above a threshold % (median of the frequency power + 5 standard deviations. % Input: % signal: row-wise signal % fsamp: sampling frequency % Output: % filteredsignal: row-wise filte...
6add182ddc3a7d7318d6db72daecb629f1d74661a1e64bcf2f88c9f90622b26a
MATLAB
1,682
63
Q = load('~/temp/stephen_fly325/Dropbox__fly325__0020_front.mat'); P = load('~/Dropbox/talks/labMeetingSep21_extra/basepredfly325.mat'); readfcn = get_readframe_fcn(Q.expname); %% fnum = 406; im = readfcn(fnum); llocs = [394 358; 332 336; 407 321; 351 294; 357 374]; f = figure('position',[675 171 1000 400]); axis('ti...
0fa78bc3a13c96dbf728be88deee0976ee4456847cf4e61a59167788af8f3ca1
MATLAB
1,684
43
ind = 1; 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*']); data_anat = dir([data(i).folder, '/', data(i).name, '/mri/SEM_', data(i).name, '/nifti/anat']); fprint...
ce2cf1616346b6064dceee0a3435d975380696cee8a00141407f5f0ca8717908
MATLAB
1,684
56
function m = medianw( x, w, dim ) % Fast weighted median. % % Computes the weighted median of a set of samples. % http://en.wikipedia.org/wiki/Weighted_median % "A weighted median of a sample is the 50% weighted percentile." % For matrices computes median along each column (or dimension dim). % If all weights are equa...
fee86d88918fd669b355ab7b545b02f3c81155e3d4967df64af9098a05432895
MATLAB
1,684
43
function [wfunc_file,wmeanfunc]=normalise_4d(cfunc_file,deformation,cmeanfunc_file) cfunc_vols=[]; for i=1:length(cfunc_file) [other_p,other_n,other_e] = fileparts(char(cfunc_file{i})); cfunc_vols= [cfunc_vols; cellstr(spm_select('ExtFPList',other_p,['^' other_n other_e '$'],inf))]; end %normalise all the fun...
6e1152521c4898a60d77a4be0ae6f4f0cac4beae9cafb9f4e658518637cd7cdf
MATLAB
1,685
62
%% Demo of mlcomp % This file is from pmtk3.googlecode.com addtosystempath('C:\Octave\3.2.3_gcc-4.4.0\bin'); %localdir = tempdir(); %'C:\users\matt\desktop'; localdir = fullfile(pmtk3Root(), 'data'); %% regression % This is pure matlab code and works fine if 1 setSeed(0); N = 10; D = 3; X = randn(N,D); w ...
57799b51dafaff3711b2531103fa9f0edccbd48be379a25c2c6477aeab497594
MATLAB
1,687
83
function A = convn_custom(A, B, power2flag) % CONVN_CUSTOM FFT-BASED N-dimensional convolution. % C = CONVN_CUSTOM(A, B) performs the N-dimensional convolution of % matrices A and B. If nak = size(A,k) and nbk = size(B,k), then % size(C,k) = max([nak+nbk-1,nak,nbk]); % % METHOD: CONVN_CUSTOM uses Fourier transfo...
bbf3696944f690bfc3c9d4332b642079a6752db482709f7dbb05855c16377ea2
MATLAB
1,687
46
function score = circleloss_score(mapper_path, tr_names) % This score computes the length for each node to the low and up % states. The loss is the subtraction of the distances to the two % low and up states. The loss is computed and added for transition_plus % and transition_minus. datapath = fullf...
d162e0e183317c1badd85b3884ae222eab6f399440958183d1e0ec2e994a0185
MATLAB
1,687
44
% Preprocess neuropixel data % Extract and reformat behavioral data and spikes for each session % Output structures: % beh, behMap, behView: behavioral indicators by trial in RDM, mapping % and motion viewing tasks % spk, spkMap, spkView: neural data by trial in RDM, mapping % and motion viewing tasks %% Loa...
152e6501e94fc3acd15e1828249b6b92d090d5a6be70ff2fb96e061e9668f4cb
MATLAB
1,688
62
function [order, chordal, cliques, numpa] = perfectElimOrder(G, initNode) %% Compute the perfect elimination order of a chordal graph % Uses the Maximum Cardinality Search algorithm % chordal = false if graph is not chordal % Also returns maximal cliques of the graph, in an order % that satisfies running intersection ...
ce86636d04d213bf5ecb3d0691f0b938ff8de316af0c9c450ccb90305c3d8e3b
MATLAB
1,688
41
function mscmd_remove_noise_subclusters(timeseries_path,firings_in_path,firings_out_path,opts) %MSCMD_REMOVE_NOISE_SUBCLUSTERS - Remove noise subclusters by splitting clusters %into shells and comparing the subcluster template waveforms with the %expected waveform shape in the situation of pure noise detected via %ampl...
930d24c82aeeddd30b22c30ac3a5ba918499cf4f7f6726917576dbd3c4539338
MATLAB
1,690
47
function [Iall,Icombo] = load_and_combine_and_mask_multiplexed_channels(parentfolder,fov,fnames,refch,threshpct,medfilt) %Loads multiple channels of the same image, e.g. from multiplexed data. %Assumes all are the same width, height, and z-stack length %fnames = list of filenames to load %Iref = name of reference c...
a2bf43b1e50da22dc0722ef37826e22d3e173c9cc7228afb9b0258de0cf8ab27
MATLAB
1,691
39
function flag=istfr2(method); % flag=istfr2(method) returns true is method is a % time frequency representation of type 2 (only positive frequencies). % See also istfr1, istfraff. % F. Auger, may 98 % Copyright (c) CNRS - France 1998. % % This program is free software; you can redistribute it and/or modify % it und...
c895643e7dd03c084912200fddc78bb4c438e7eb85de9612598e48dc122a3055
MATLAB
1,691
48
function [a, b] = VBA_guessHyperpriors (y, rangeEV) % // VBA toolbox ////////////////////////////////////////////////////////// % % [a, b] = VBA_guessHyperpriors (y, rangeEV) % propose shape and scale parameters to use as hyperpriors for the % measurement noise precision, based on the part of the variance one can % exp...
e4a6cb17c4ad4e0f861da878be0c9983afd2cad842ca0bb1ac2f0eb2329d9ae1
MATLAB
1,691
66
function V = sphere_project(v,r,c) % sphere_project - project point X,Y,Z to the surface of sphere radius r % % V = sphere_project(v,r,c) % % Cartesian inputs: % v is the vertex matrix, Nx3 (XYZ) % r is the sphere radius, 1x1 (default 1) % c is the sphere centroid, 1x3 (default 0,0,0) % % XYZ are converted ...
4ab2a050cc7ae82abaffc8459fad7dd33f6503a91f3e0ba2b2ea7a4e475b1098
MATLAB
1,692
77
function data = ReadChoreSpineFile(filename) nspinepts = 11; nparams = 2*nspinepts + 2; data = []; fid = fopen(filename,'r'); if fid < 1, error('Could not open file %s for reading',filename); end ids = []; expname = ''; while true, l = fgetl(fid); if ~ischar(l), break; end if isempty(l), continue;...
cb60eb715a36112ad8df0d466fd29bbfa0c142622fedf82c88edb19c398c377f
MATLAB
1,692
54
classdef FileLogger < handle properties filename_ % name of log file, or 1 for stdout, or 2 for stderr tag_ % string added to start of each log message is_fid_valid_ % if true, fid_ is valid. If not, fid_ is empty, and obj is a "null logger". fid_ % a file_object of the log file end methods ...
da71d51f6547415311f7126be221f347fa5685cd0fbcd39258675c311fd21a40
MATLAB
1,692
52
function [ret,messages] = check_files_in_calculateDescriptors() loadParameters; if params.DO_DOWNSAMPLE filename_root = sprintf('%s-downsample_',params.FILE_BASENAME); else filename_root = sprintf('%s_',params.FILE_BASENAME); end ret = true; messages = {}; for r_i = 1:para...
df11878ab99e197b114a52e425db040920f00c679da95ea64c3515d02c5693be
MATLAB
1,692
65
% Author: Birgit Nierula % nierula@cbs.mpg.de %% EEG preprocessing wrapper script clear; clc delete(gcp('nocreate')) % clear parallel pool %% variables that need to be changed % loop loop_number = 2 % subject, condition, and block info subject_idx = []; condition_idx = []; %% define variables and paths % experim...
3d708d65a1dd490edd241816501297ff8a612ded2055c9e4213fde7937e02c0c
MATLAB
1,694
48
function mappedX = diffusion_maps(X, no_dims, alpha, sigma) %DIFFUSION_MAPS Runs the diffusion map algorithm % % mappedX = diffusion_maps(X, no_dims, alpha, sigma) % % The functions runs the diffusion map algorithm on dataset X to reduce it % to dimensionality no_dims. The variable sigma is the variance of the Gauss...
e103ed0d97fee8d13f4a90c31b9516e594419cfe044eb658d45b8dbf949849cf
MATLAB
1,694
54
clear; basefolder = fileparts(fileparts(fileparts(mfilename('fullpath')))); codefolder = [basefolder,'/code']; toolsfolder = [basefolder,'/tests/tools']; addpath(genpath(codefolder)); addpath(genpath(toolsfolder)); res = load([basefolder, '/tests/fixtures/cme/mapper/res.mat']).res; task_path = [basefolder, '/tests/f...
5b56df34b03604282e429513a58f36fb8d64f982b533771a493f4dac05281a11
MATLAB
1,695
55
function FC_cov = make_staticFCcov(datadir, n_sess) % FC_cov = make_staticFCcov(datadir, n_sess) % % make subject-wise static FC (covariance) matrices for HCP rsFMRI % This script uses groupICA50 parcellation % Requires that both the behavioural data and the timecourses in groupICA50 % parcellation can be found in the ...
061615cc73a42c1569a5c692e8f2d686c7eff2e74a0e3ff7cfe95c7a50692cd0
MATLAB
1,696
78
% Demo for stable heteroclinic channel (SHC). % This demo inverst a model of hierarchical SHC partly observable. The % model has no observation/evolution parameters (except initial % conditions). clear variables close all % Choose basic settings for simulations n_t = 5e2; f_fname = @f_SHC; g_fname = @g_Id; u = ...
89f2f7e4049f6588341dcf3a43b16bdc81e1747ec6dd6ec364fbc8ee32908121
MATLAB
1,696
45
function [ind, int_func] = mytsearchn_fast(mesh, coord) % MYTSEARCHN_FAST carries out a spatial point location search. It uses % triangulation search algorithm that locates the triange/tetrahedron % enclosing a query point. This is an interface for NIRFAST mesh format. % This function also compensates for numeric...
988cf408db8f2bacaf97947be2cc0cfdd6612d0ae2d700c64b47f33c65cad7d0
MATLAB
1,696
58
function b = renamefields(a, old, new) % RENAMEFIELDS renames a selection of the fields in a structure % % Use as % b = renamefields(a, old, new) % which renames the fields with the old name to the new name. Fields that % are specified but not present will be silently ignored. % % See also COPYFIELDS, KEEPFIELDS, RE...
e01b5f8b78b30c22420d700cdafddffab3e169e4c3d3f77592ffe9ec327d9826
MATLAB
1,696
61
%% Plot the full L2 regularization path for the prostate data set % %% % This file is from pmtk3.googlecode.com loadData('prostateStnd'); setSeed(0); %[X, y] = shuffleRows(X, y); %X = centerCols(X); NL = 20; lambdas = [logspace(4, 0, NL) 0]; [n, d] = size(X); nlambdas = numel(lambdas); w = zeros(nlambdas, d); ...
e43a73f43366009665d2cac7f8a67e25cb2db20bc6264c6589ff1b6dc4605172
MATLAB
1,696
70
function [Tte,W,Va]=flinreg_l2(lambda,X1X1,Xtr_1,Ttr,Xte) % linreg_ml -- perform linear regression by maximum likelihood estimate % [Tte,W,Va]=linreg_ml(Xtr,Ttr,Xte) % % [Input] % -Xtr: training data [N x M] % -Ttr: target vector [N x 1] % -Xte: test data [N2 x M] % % % [Output] % -Tte: prediction from the Xte...
195e0da762daef47dc8249d418ffaae681a377ee95f973aec4257182349350de
MATLAB
1,697
56
%% Linear Regression Demo % %% Make data % This file is from pmtk3.googlecode.com [xtrain, ytrain, xtest, ytestNoisefree, ytest] = polyDataMake('sampling','thibaux'); Xtrain = xtrain; Xtest = xtest; %% Fit using Matlab's functions Xtrain1 = [ones(size(Xtrain,1),1) Xtrain]; w = Xtrain1 \ ytrain Xtest1 = [ones(size(Xt...
198e100ee1b741b257cc87d61213b6747bd94695809d18770f07d312b3466d26
MATLAB
1,697
65
function javaTable(data,columnNames,tableName) % Display a cell array of strings in a java JTable % PMTKneedsMatlab %% % This file is from pmtk3.googlecode.com if(isempty(data)) fprintf('\ndata cannot be empty\n'); return; end if(nargin < 2) columnNames = cell(1,size(data,2)); columnNames(:) = {''}; ...
cdbdf794ac7d6f982bcfc195143f1284482fd5fe72c338965d75689a3293daba
MATLAB
1,697
57
% AverageCircularData.m % Sarah West % 7/20/23 function [parameters] = AverageCircularData(parameters) % Display progress message to user. MessageToUser('Averaging ', parameters); % Pull out data. data = parameters.data; % Pull out weights if isfield(parameters, 'weights') weights =...
e2d5941a1da89d7da09f9dce780fefab1f789aa21485662171487e46f56055de
MATLAB
1,697
67
function A = lan_smooth(A, span, fact, times) % span = 0 : no change if nargin<2 span=4; end if nargin<3 fact=0.5; end A = squeeze(A); if nargin == 4 if size(A,3)>1 for i3=1: size(A,3) for i = 1:(times) A = lan_smooth(A, span, fact); end end return end end if size(A,3)>1 for i3=1: siz...
2a3cb9d33f2a9472a267341af9d934e631f0d4f4d37698d9bcc9a287da3440ad
MATLAB
1,698
46
function [] = averageVelocitiesAcrossMice(parameters) % Give parameters their original names dir_exper = parameters.dir_exper; periods_long = parameters.periods_long; periods_transition = parameters.periods_transition; full_transition_flag = parameters.full_transition_flag; periods_ful...
2dc9e521ffd7e9677ce076187d1adb1e2fb7db8d687be492eed6760ea5bcaef0
MATLAB
1,698
38
% This script loads and processes model parameters for a single cell from % a specified experiment. It reads the parameters from a text file in the repository, % extracts relevant information (grid centers, model parameters, pixel size), % and then converts the parameters into a structured format using either % 'pa...
4bed4e6f71cc1f7880fd353de915ab8337cde10db9d13ad63a41c5e628c8916f
MATLAB
1,698
46
% Example 2 % % % Citation: Cannavo' F., Sensitivity analysis for volcanic source modeling quality assessment and model selection, Computers & Geosciences, Vol. 44, July 2012, Pages 52-59, ISSN 0098-3004, http://dx.doi.org/10.1016/j.cageo.2012.03.008. clear clc % create a new project pro = pro_Create(); % add 3 i...
c4ef625e11f0b5ee5cedbea45faa32d054e08dfe38d20616e850235a95f1300d
MATLAB
1,698
51
%% sdoAnalysis_testPxParams % Utility to test the state mapping and filtering parameters on the % background distribution of state. Useful for testing different parameters % to optimize the state transitions % % NOT RECOMMENDED: Use 'xtDataCell' class w/ 'plot' method to test % different state defintions %____________...
59898d380c4dfc9d8eded3edf2d03ad3a732bcd19aa01f69c2c5543a4117c0de
MATLAB
1,699
80
%% Visualize the effect of change the hyper-params for a 2d GP regression % Reproduces fig 5.1 from Rasmussen and Williams %PMTKauthor Carl Rasmussen %PMTKslow %% % This file is from pmtk3.googlecode.com n = 61^2; D=2; [x1,x2]=meshgrid(-3:0.1:3,-3:0.1:3); x=[x1(:),x2(:)]; h = figure(1); clf set(gca,'FontSize',24); ...
b2e33e18098fc79827c03221550936b4574de5fe0e74925e3f0df7236e161dc6
MATLAB
1,699
54
% PadMissingMouse.m % Sarah West % 1/20/23 % A quick and dirty function to concatenate data across conditions for the % correlation fluor vs corr pipeline function [parameters] = PadMissingMouse(parameters) % Inputs : % parameters.correlations -- 7 x 16 (mice x unique nodes) % parameters.fluorescence --...