sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
57a1c4eca05a7fa3b2ef2a9d9ff70669d882bd42332ca72d2a459c0f6828a0ee
MATLAB
1,117
49
function [fitresult, gof,output] = createSplineFit(timeStamps, trace) %CREATEFIT1(TIME,TEST) % Create a fit. % plotFigure % Data for 'untitled fit 1' fit: % X Input : time % Y Output: test % Output: % fitresult : a fit object representing the fit. % gof : structure with goodness-of fit info. % % ...
d8231e9f9baa3dedae41099a50ee65a879b29873ae0d2683ad342c230bd5aee7
MATLAB
1,117
32
function h = plotvert(vert,ptcolor,varargin) % function h = plotvert(vert,pointcolor,vertices[opt],lncolor [opt]) % % draws lines optionally, if you specify verties list and linecolor h(1) = plot3(vert(1),vert(2),vert(3),ptcolor,'MarkerSize',4,'MarkerFaceColor',ptcolor(1)); if nargin > 3 vertices = varargin{1}; lnco...
e67f4d7d2dffa2a7c9a2c765b8c54e86cf679a30fb44be75f1f87ce9b36312f0
MATLAB
1,117
42
%% relPath = get_relative_source_path(baseDir, fullPath) % % Input % -------------- % baseDir : the output directory the JSON sidecar will live in % fullPath : full filename of a source (input) file % % Output % -------------- % relPath : fullPath expressed relative to baseDir when possible, % ...
d8ea2abbcc4dcfdde1dc431eb1d06e6ace1a97397d8f468e311383f813e72aae
MATLAB
1,118
40
function [T,rez] = estimate_snr(rez,T) [~,~, U, ~] = SVD_template(T,3,rez.ops.Chan_criteria); [~,~,Nclust] = size(T); [Chan] = Chan_cluster2(U,Nclust,rez.ops.Chan_criteria); sigma = rez.sigdata; mu = rez.mudata; Nbatch = length(sigma); nt0 = rez.ops.nt0; th = rez.ops.snr_th; snr_coeff_batch = zero...
4cdbf38f18d35bc737a056756003edc6eb095e1e139e8f2d3410d0cc1313880d
MATLAB
1,119
34
function [w, g_sqr] = rmsprop(w, g_sqr, grad, opts, lr) %RMSPROP % Example RMSProp solver, for use with CNN_TRAIN and CNN_TRAIN_DAG. % % Set the initial learning rate for RMSProp in the options for % CNN_TRAIN and CNN_TRAIN_DAG. Note that a learning rate that works for % SGD may be inappropriate for RMSProp; th...
299fc8225a8b48ff124a3a6e7838136ad84c15db04fe9f6964df0f885a983078
MATLAB
1,120
28
function res = search(varargin) % Special keyword to declare parameter values to search over. % search(x,y,z,...) or search([x,y,z,....]) or search({x,y,z,...}) expresses % a parameter range (i.e. set of possible parameter values, to be searched for) in a grid search. % % Note: % search() may also be nested ins...
76c9546c264e5ced13071e08105c6b575be29f8cb57a43bfea61fc071ff33be2
MATLAB
1,120
34
function A = suma_stitch(imaname) % A function to put together a series of suma recorder images % Very crude, only for the intrepid. % Example: A = suma_stitch('imageseries_'); %The would be the images as spat out by the recorder window after % a suma 'r' key stroke with SUMA_SnapshotOverSampling > 1 figure(1); clf [e...
b04c378d8e622dfa6f2cffb81cb1a9f7b3fe48349d294c62e7817c0e9a3944e8
MATLAB
1,120
37
function exportTrials(params, trials2export) % exports trials from trigger analysis % exports selected channels (selCh_H_resp) & header structure H % (c) Jiri, Mar21 - for bachelors at CVUT %% trials trials = struct; trials.data = trials2export.data; trials.time = trials2export.time; trials.labels = trials2export.lab...
9f270786f8f31cef7abb086c31318c47559fedef9cf55a6c0b29b903ca8b530a
MATLAB
1,121
38
function MultiRunCalc(type) f1 = uigetdir([],'select one folder') ; ListSubj = uigetfile('.txt') ; f3 = uigetdir([],'select output folder') ; f1list = dir(f1) ; Subj = importdata(ListSubj); % no '_Run*' in the list name for i = 1 : length(Subj) csubj = 0 ; mkdir([f3,filesep,Subj{i}]) ; for j = 3 : length(f...
a884c42292856baa3baed39f9e3e42adbb464f4f6c4b63ede3536ccd10bf9901
MATLAB
1,121
33
function getTriggers_locaVisu_stimuliTypes(params) % determines trials which contained the selected keyword (in params.thisCategory) % saves result into respective column of 'trials_events' in each sessionCacheFile % - rows = trials % - values = zeros (event not found) and ones (event found) % (c) Jiri, Mar16 dis...
b80d7cf1fbbd3be6b8431e036a0ee90b3b7cadb149d9639d072b8313a00f2236
MATLAB
1,121
41
function [output]=bpFilter2D(input,low,high,varargin) options.parallel=true; %% UPDATE OPTIONS if nargin>=4 options=getOptions(options,varargin); end stack=double(input); fwhm_scaling=2*sqrt(2*log(2)); output=stack; sz=size(stack); if length(sz)==2 sz=[sz,1]; end if options.parallel parfor ii=1:sz(3) ...
c234aad56e69101e571d0d4a59b531be1d5e51bbd9561632f853f4c0f2c262df
MATLAB
1,121
42
function [ptheta] = tapas_sem_mixed_prepare_ptheta(ptheta, theta, pars) %% Thin layer of preparations for the hierarchical model. % % aponteeduardo@gmail.com % copyright (C) 2016 % % Number of parameter data sets. nvals = size(ptheta.jm, 1); ndims = ptheta.ndims; npars = nvals / ndims; assert(floor(npars) == npars,...
16e79261d7b89169e157c08524cb2e2c5259fe01951156fc0bb4fdf7b8aa728c
MATLAB
1,122
40
function [posterior] = tapas_mcmc_estimate(data, model, inference) %% Estimate a model specified. % % aponteeduardo@gmail.com % copyright (C) 2016 % nfuncs = numel(inference.sampling_methods); [states] = inference.initialize_states(data, model, inference); [state] = inference.initialize_state(data, model, inference);...
5f289ec4e68ecc0b0c37e9829ff98b78c3bc22e1e19b2874a0e1a4bd1d74b4e8
MATLAB
1,124
53
function weighted_sum_image(P,Pout,w) %weighted_sum_image(input file names,output file name); % % Creates a weighted sum of images based on weights for each image % % weighted_sum_image(DB.PP,'Activation.img',DB.studyweight); switch spm('Ver') case 'SPM2' % spm_defaults is a script disp('WARNING: s...
b95f5afd7aefdc0e4b1995fd96c3fe7b873a8b1661251d87183ddc55c3959435
MATLAB
1,124
30
% disp() - This file overrides disp with our custom logging function % use logging_override_disp to disable or enable this, do not add % this folder to path directly % Usage: % >> disp(data) % % Inputs: % data - The data to display formatted % matlog - a Matlab and Octave compatible logging libra...
ef48bb90cce4068ba3bf22b93b862839d23335003056eac2e71b4416790d8a77
MATLAB
1,124
53
function [map]=sh_PowerMap(movie, freqrange,fs) options.plot=false; % RC if freqrange(2)==inf band=[1 4;... 5 9;... 10 24;... 25 50;... 51 110;... 120 fs/2-1]; nFB=6;[i,j]=find(band>(fs/2-1)); if ~isempty(i) jj=find(j==2,1,'first'); nFB=i(j...
f1e769e2f987e349d6d29f20be4483015df43cdb23391e854f1d122c3fb215bb
MATLAB
1,124
32
%% key = sepiatest.unwrap_method_toolbox_key(unwrapMethod) % % Description: maps a phase-unwrapping method name (as it appears in % methodUnwrapName, sepia_universal_variables.m) to the field name in % sepiatest.discover_toolboxes()'s output struct that gates whether it % can run on this machine. See sepiatest.qsm_meth...
68a7e302ef1c236673286e39a3763df851ccee7b408d3697f8d1030cdad69a7f
MATLAB
1,125
33
function Q = DK_theilerQ(x) % DK_theilerQ Computes Theiler's Q statistic % % theilerQ calculates Q=<(x_t + x_{t+1})^3> normalized by <x^2>^{3/2} % on a vector x % % ------------------------------------------------------------------------------ % Copyright (C) 1996, D. Kaplan <kaplan@macalester.edu> % % This function is...
25058d5aa2f05d79b25858d29ec888b710e443cc9209afd98a3528d2523d69f9
MATLAB
1,126
34
function cnn_imagenet_minimal() % CNN_IMAGENET_MINIMAL Minimalistic demonstration of how to run an ImageNet CNN model % Setup MatConvNet. run(fullfile(fileparts(mfilename('fullpath')), ... '..', '..', 'matlab', 'vl_setupnn.m')) ; % Download a pre-trained CNN from the web. if ~exist('imagenet-vgg-f.mat', 'file') ...
377b2a59aa2022e38b12ce5d28fb44fed0e37d5fb9f23887e5ef24bbd426b6e6
MATLAB
1,126
36
function save4Dnii(nii,V,filename) % nii: 4D or 3D matrix to save. % V: either an SPM structure or just the output of spm_vols - i.e a % structure with NIFTI header information. if ndims(nii) == 3 T = 1; % no 4th dimension elseif ndims(nii) == 4 T = size(nii,4); end if isempty(V) dim = [size(nii,1),si...
3dbcc295d70c123a705004685e170c1225abe95905f317420309b12e7e3eab5c
MATLAB
1,126
42
function this = plot(this, module, varargin) % Plots different aspects of MrSeries using MrImage-plot functions % % Y = MrSeries() % Y.plot(inputs) % % This is a method of class MrSeries. % % IN % % OUT % % EXAMPLE % plot % % See also MrSeries % Author: Saskia Klein & Lars Kasper % Created: 2014-07-08 % Cop...
4955845e10afc3f6eb6eba3fff74c30ab616fe72f2565849c287ac84a1580240
MATLAB
1,126
34
function [rawdata, header] = readforcecurve_3_4_15 (filename) %% OPEN THE FILE forcefile=fopen(filename{1,1}); %% count the number of headerlines headerline_index = 1; headerline_counter = 0; while headerline_index == 1 headerindicator = textscan(forcefile, '%c%*[^\n]', 1); if strcmp(headerindicato...
85fefa52f68872ec1c3b5623908ce2e6ecc1b23cc454edf1a69edcef93ab17bd
MATLAB
1,126
40
function [shuffleDist, trueDiff, pvals, trueParams] =... myLambdaShuffleTest(dataLo, dataHi, nPerms, twin) niters = 10; xs = -(twin-10):(twin-10); % myNorm = @(x) x-mean(x(1:twin)); myNorm = @(x) x; [group1Params, group2Params] = deal(nan(size(dataLo, 1), 4)); dataAll = [dataLo; dataHi]; dataAll = dataAll(:, 11...
d3ab0fa09db92606bb7908584bf28c1d745bee26a8ee371211180eb842180571
MATLAB
1,126
51
function [ace_out] = ace_ss_detector(hsi_img,tgt_sigs,mask) % %function [ace_out] = ace_ss_detector(hsi_img,tgt_sigs,mask) % % Adaptive Cosine/Coherence Estimator - Subspace Formulation % % inputs: % hsi_image - n_row x n_col x n_band hyperspectral image % tgt_sigs - target signatures (n_band x M - column vector) % ...
1cd720c961e2002e985418f2e72fccdc553059005d39b7d35100a083d05a9d11
MATLAB
1,127
32
function [ModelOutput] = fit_LCModelParamsToModel(fitParams) % This function returns the complete fit, the baseline, the residual, % individual contributions from each basis function, the data that are % being fit, and the frequency axis. % % USAGE: % [ModelOutput] = fit_LCModelParamsToModel(fitParams) % ...
a639709eb11cc98f628a210e037122ed51c3f43e0c43fd6b4d70c5c60b7ffd0f
MATLAB
1,127
41
%% function fiter = computeFiter(s,shat,NUM_MAGN) % s - measured signal % shat - simulated signal % NUM_GAGN - no. of phase corrupted echoes: % NUM_MAGN=0 : complex fitting % NUM_MAGN=length(s) : magnitude fitting % NUM_MAGN (0,length(s)) : mixed fitting % % Description: Compute the fitter for lsqnonlin % % Kwok-s...
fb4f400d9f274ad53ba91aa3ac4e52cf0e42b5e9e9fee70188956a9afd433071
MATLAB
1,127
25
function c = BrainNet_GenColormap(Nmax,Nmin,Pmin,Pmax,original_color_map) if isempty(original_color_map) original_color_map = jet; end color_length = length(original_color_map); if color_length < 64 original_color_map = interp1(linspace(1,64,10),original_color_map,1:64,'nearest'); color_length ...
83aca161b9ad634317d4ba949e08f1cfb320a05c5268dcf10880e57bae85e990
MATLAB
1,128
30
function eta_matrix = eta_calc_pair(zmapa, zmapb) if length(size(zmapa)) > 2 || length(size(zmapb)) > 2 || size(zmapa, 1) <= 1 || size(zmapb, 1) <= 1 error('inputs must be column vectors or 2D matrices'); end m = size(zmapa, 2); n = size(zmapb, 2); eta_matrix = zeros(m, n, 'singl...
19c477d41395941b7e70c45dd0a832208f8af43a428db05f8616d7c552b22834
MATLAB
1,129
36
function label_AA = msSEI_get_label_AA(brainAtlas) % returns labels of anatomic area atlas (e.g. Yeo7) % (c) Jiri, Nov23 label_AA_yeo7 = { 'Visual', 'VIS'; 'Dorsal Attention', 'DAN'; 'Somatomotor', 'SMT'; 'Ventral Attention','VAN'; 'Frontoparietal', 'FPN'; 'Limbic', ...
9852a30f8a2588cde21b4267653a6f53d38ac2e7033d16cc4cd5cb67a5d25723
MATLAB
1,130
40
function [Pr, prMax] = placeBayes(Cr, rateMap, binLength) %function out = placeBayes1(Cr, rateMap, binLength) % Inputs: % Cr = [nTemporalBin X nCell] matrix of binned firing rates % rateMap = [nSpatialBin X nCell] firing rate 'template' % binLength = scalar of the duration of the bins in 'Cr' % Outputs: % Pr = [nTempor...
f1408f377fa97855aeaddda9b48f6a15d0d8c3bb475e29769894bd0abd269524
MATLAB
1,130
62
function [err, g, b] = TellAfniCheck (w) % % [err, g, b] = TellAfniCheck (w) % %Purpose: % Parses AFNI's returned string from plugout_drive % % %Input Parameters: % w the string output by plugout_drive % % %Output Parameters: % err : 0 No Problem % : N N Problems % g : Number of OK tokens % b : N...
1ea272ef27737d609408521b705b51feef39fed5ba45c145c0c529c1aead8a2e
MATLAB
1,131
39
function this = save(this, fileName) % saves object as struct (to be readable if code is not in path or % outdated) in .mat-file , variable named 'objectAsStruct' % % Y = MrCopyData() % Y.save(fileName) % % This is a method of class MrCopyData. % % IN % % OUT % % EXAMPLE % save % % See also MrCopyData MrCopyDa...
359db6f6b8359e4d49fe7fa88fd81b0c28eea4a9df640282a2c64c7447810b13
MATLAB
1,131
37
function fout = mrvWaitbar(x,varargin) % mrVista wrapper for waitbar % fout = mrvWaitbar(x, varargin) % % The purpose of the wrapper is to check whether VISTA preferences for % 'verbose' are set to true or false, and if false, then to skip calling % the waitbar. % % EXAMPLE 1 % setpref('VISTA', 'verbose', true); % fou...
db76b974edb3ae7ba79288447c5106274d15369c3173728d05ad876d0a260851
MATLAB
1,131
41
%% get_set_bfr_lbv(h,mode,input) % % Input % -------------- % h : structure contains all handles of SEPIA % mode : 'set' - extract information from GUI to config file % 'get' - extract information from config file to GUI % input : if mode is 'set' then input should be fid % ...
f19e38ea7083302b768f22afed43e380fbcf3a797ec858eb8c64c81dc1774bcc
MATLAB
1,131
42
% op_addNoise.m % Jamie Near, McGill University 2014. % % USAGE: % [out,noise]=op_addNoise(in,sdnoise,noise); % % DESCRIPTION: % Add noise to a spectrum (useful for generating simulated data). Normally % distributed random noise is added to both the real and imaginary parts of % the data. Real and imaginary noise p...
440e5fd27af042951ecb0706a18871dfaf5f89f540992ab3ef614ad37c606eec
MATLAB
1,132
30
function runScript = naj_scriptModified(scriptName, outputFile) % check whether output file exists, if so, only run script if it has % been modified in the meantime % also check scripts that are being called! % % INPUT % - scriptName - [string] fullfile of script that should be checked % - outputFile - [cel...
79772968b30391c0210e0c685b2077e637344f5c41203ee681c9e1b777e6c72c
MATLAB
1,132
41
function [major,minor,patchnum,extra]=iso2meshver % % [major,minor,patchnum,extra]=iso2meshver % or % v=iso2meshver % % get the version number of iso2mesh toolbox % % author: Qianqian Fang, <q.fang at neu.edu> % % output: % if you ask for a single output: % v: a string denotes the current version number; t...
d3bf51c8880326c6b84b61e187a16ea6b53219d822a978532867fdb39b212365
MATLAB
1,132
43
%% str_new = remove_bids_key(str,key) % % Input % -------------- % str : BIDS compatible filename % key : key to be removed, string % % Output % -------------- % str_new : new filename without the specified key % % Description: remove a specific key from BIDS compatible filename % % Kwok-shing...
755c13e97676a45652f38ef90b4680ce9c0bf20c4c08a651be587a69970f72bc
MATLAB
1,133
35
function [ par ] = tapas_rdcm_ep2par(Ep) % [ par ] = tapas_rdcm_ep2par(Ep) % % Vectorizes Ep structure % % Input: % Ep - parameter structure % % Output: % par - vectorized version of parameters % % ---------------------------------------------------------------------- % % Authors: Stefan...
be444503818bc6fee5d6e14d5136111fd812f87ff28918958ef127b7ef254020
MATLAB
1,133
36
function kinematicsAll = loadMultilockKinematicsAll(datasets, dataPath) % Loads multiple datasets, locks the kinematics and creates a single data % struct combining across trials kinematicsAll = []; for dataset = datasets mouse = dataset{1}{1}; session = dataset{1}{2}; % Load and lock kinemat...
ee43f960f66de83545a2c17ba7b7a5302232512d9e5e0b96e7616a7431562d54
MATLAB
1,133
41
%function perf =projeval(x,v,m,c,f) function perf = projeval(result,param) %projeval(result.PCAproj.P,result.PCAproj.vp,param.m,param.c,result.data.f); x = result.proj.P; v = result.proj.vp; m = param.m; c = param.c; f = result.data.f; %calculation of the membership for j = 1 : c, % for all clu...
bfd704f13bcc38105e8d43d6a821adb51c6c87f77ca1c461514695b970171a35
MATLAB
1,134
49
function [e1] = tripleErrorBars(av, er, col, barwidth, linewidth, middle_bar) % Takes a mean, its error(s) and plot error bars with a particular style % % % for testing___________________ % clear all % close all % clc % load 'scatdistTestData.mat' % col=4; % vec=vecs{col}; % av=mean(vec); % stdvec=std(vec); % er=stdv...
c8d3608a54af5acde428d28314be371b8112f8dee6c9b32f5e39e8a10c07701b
MATLAB
1,134
40
function recastMrImage = recast_as_MrImage(this) % recasts an MrImageSpm4D as a 4D MrImage, changes available methods etc. % % Y = MrImageSpm4D() % YasMrImage = Y.recast_as_MrImage() % % This is a method of class MrImageSpm4D. % % IN % % OUT % % EXAMPLE % recast_as_MrImage % % See also MrImageSpm4D % Author: ...
d8fded099073e79659c2214094ae88a3adc7ead3293dad5536e97d38dc3b2011
MATLAB
1,134
33
function val = littleendian % LITTLEENDIAN returns 1 (true) on a little endian machine, e.g. with an % Intel or AMD, or 0 (false) otherwise % % Example % if (littleendian) % % do something, e.g. swap some bytes % end % % See also BIGENDIAN, SWAPBYTES, TYPECAST % Copyrigth (C) 2007, Robert Oostenveld % % This...
1b3e4e4fcd3fb386ede8cbb3ef2742cd30ba2556c8a2f31f737ab916660495eb
MATLAB
1,135
46
function cr = pwidentification(simmat, labels) % pwidentification Perform pairwise identification from similarity matrix % % Inputs: % % - simmat : Similarity matrix [pred x correct] % - labels : Index matrix % % Outputs: % % - cr : Correct rate % % % Author: Tomoyasu Horikawa <horikawa-t@atr.jp>, Shuntaro C. Aok...
e6fd68f779c34e1f827d4c3d8334b97627fdb81330744b6f5c432ed52dbef039
MATLAB
1,135
48
function [model] = tapas_sem_hier_prepare_model(data, model, inference) %% % % Input % % Output % % aponteeduardo@gmail.com % copyright (C) 2016 % model.graph{1}.htheta.model = ... tapas_sem_hier_prepare_ptheta(model.graph{1}.htheta.model); nc = size(model.graph{2}.htheta.T, 2); ns = numel(data); ...
3f6481f99d83e3bc5c317a5ac881bf3adfb4d6da994fd3eb15dcbc9ba3674646
MATLAB
1,136
39
function [this, saveFileNameArray] = save(this, varargin) % Saves data to file(s), depending on which loop-dimensions have been % selected % % Y = MrDataNd() % Y.save('fileName', fileName, 'splitDims', 'unset') % % This is a method of class MrDataNd. % % IN % % OUT % % EXAMPLE % save % % See also MrDataNd MrDat...
773df83a76200bd5c991f8c6431d91bc34a38463b859bb966df34983efbf58e0
MATLAB
1,136
39
function [] = create_parallelPool(numCores) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % create_parallelPool creates a parallel processing pool using given number % of CPU cores. % % Arguments: % numCores = Number of CPU cores to use % % Last edited by Emin Serin, 26.02.2022 % %%%%%%...
dfd111f31c82e633ecc55ac55b7d82092e59c7a691d407f37714927cfbaaa843
MATLAB
1,136
39
function [sel, mobj] = get_properties_to_update(obj) % Returns all properties which are mutable for update, cloning etc. % (and the metaobject of property information) % % Y = MrCopyData() % [sel, mobj] = Y.get_properties_to_update() % % This is a method of class MrCopyData. % % IN % % OUT % % EXAMPLE % get_prope...
e491a7a58da42910ca5eb609512c66804800878e405b369cab906cbc96191802
MATLAB
1,137
28
function candoit = canGetSqrtPrecon(problem) % Checks whether a square root of preconditioner was specified in problem. % % function candoit = canGetSqrtPrecon(problem) % % Returns true if the problem structure allows for applying the square root % of a preconditioner to tangent vectors at a given point. The square roo...
08a1f686ad1cddc24517d2f345aadc2f9de6459e1fc262de2dab02569e56666b
MATLAB
1,138
10
%Graphic interface builder functions (guifunc folder): % <a href="matlab:helpwin errordlg2">errordlg2</a> - Makes a popup dialog box with the specified message and (optional)... % <a href="matlab:helpwin finputcheck">finputcheck</a> - Check Matlab function {'key','value'} input argument pairs... %...
f8c9667f30162d1b1cd83c8964b659dbc1abe07ff1ca5818e4043f5602fdd58d
MATLAB
1,138
52
%isastring - Test if parameter is an (admissible) character string. % % USAGE % % test = isastring(x,string1,string2,...) % % x item to test % string1... optional list of admissible strings % % SEE ALSO % % See also isdmatrix, isdvector, isdscalar, isimatrix, isivector, isiscalar, % is...
4271c721eb3848954a3ff38572c8d005e1dad13bfec34bbba013d84cb8ecf0bc
MATLAB
1,139
51
function varargout=sigstar_vertical(xpos, p) % Adds a vertical significance bar at xpos % Anne Urai, 2015 hold on % determine the y positions for this xpos h = findobj(gca,'Type','line'); x=get(h,'Xdata'); y=get(h,'Ydata'); ymin = min([y{1}(floor(xpos)) y{2}(floor(xpos))]); ymax = max([y{1}(floor(xpos)) y{2}(floor(...
93c75f70b4804d817a9c27fdebbfaf983f06b080715639744ff4da3a481505c7
MATLAB
1,139
42
function G_rewired = rewireNetwork(G, p) %REWIRENETWORK Summary of this function goes here % G : network adjacency matrix % p : re-wiring probability % select edges to replace numNodes = size(G, 1); edgePairs = nchoosek(1:numNodes, 2); edgePairIdx = 1:length(edgePairs); edgePairIdxRandomised = edgePairIdx(randpe...
db7548c8bd11140913b2311b1dceee99e66291e78c57a30d8d0574c5cb70a7f0
MATLAB
1,139
34
%{ aod_monet.DriftResponse (computed) # calcium responses to drift trials -> aod_monet.DriftResponseSet -> aod_monet.DriftTrial -> aodpre.Trace ----- response: float # averaged response %} classdef DriftResponse < dj.Relvar methods function makeTuples(self, key) disp 'preparing traces...' ...
f2272f3ba17d0f1c7c9edcbc5de2ee0397cb5bc6a893252345241f6f06dc7fd5
MATLAB
1,139
37
function [ y ] = tapas_huge_logit( x ) % Numerical stable calculation of logit function. % % INPUTS: % x - Array of double. % % OUTPUTS: % y - logit of x. % % Author: Yu Yao (yao@biomed.ee.ethz.ch) % Copyright (C) 2019 Translational Neuromodeling Unit % Institute for Biomedical Engineering, %...
0cf5ef7587fce4327b57b12e58a5c07b8ce19610405b568866eee6431da8e2fc
MATLAB
1,140
42
function [B1vector Intensity Signal]=B1mappingSa2RAGElookuptable(nimage, MPRAGE_tr ,invtimesAB,flipangleABdegree,nZslices,FLASH_tr,varargin) % usage % [B1map]=B1mappingSa2RAGE(Rationii,nimage,MPRAGE_tr,invtimesAB,flipangleABdegree,nZslices,FLASH_tr,varargin) % varargin{1} is a phase image %varargin{2} is the T1averag...
5266c95d3b85b4b941ebcf42a01e965801313f22d8a76fb9f9e9909785a434ab
MATLAB
1,140
41
function generate_manopt_reference(target_html_dir_relative_to_manopt_root) % This code assumes it's run from its own directory; could be improved % using mfilename('fullpath') and pwd() for example. % Add m2html tool to the Matlab path cd m2html/; addpath(pwd()); cd ..; % Go back to...
6e1bcaf5919cef53c04942342a3d8c955e459f9cc3a830ac723d6c7d32ef7aff
MATLAB
1,140
26
function checkIfAnySpikes(spikeTimes, ExpName) spikeDetectionMethodUsed = fieldnames(spikeTimes{1}); all_method_spikes_detected = 0; for nmethod = 1:length(spikeDetectionMethodUsed) methodName = spikeDetectionMethodUsed{nmethod}; method_detected_spikes = 0; for channel = 1:length(...
0ffe9dc2e106dbfa064b7f6ff0caa01aad7c365de4ef52a3a8f8997ea843b893
MATLAB
1,141
39
function c = tapas_quasinewton_optim_config %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Contains the configuration for the Broyden, Fletcher, Goldfarb and Shanno (BFGS) % quasi-Newton optimization algorithm % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
1844c5f8cb7e3cf48826a56a15df8049e7c69ee24cc2fa6200d2d7630cf9ca3c
MATLAB
1,141
40
function cols=RDMcolormap % this function provides a convenient colormap for visualizing % dissimilarity matrices. it goes from blue to yellow and has grey for % intermediate values. %__________________________________________________________________________ % Copyright (C) 2012 Medical Research Council import rsa.* i...
4bc6987d59790d503817461ac40b95e7207481926f28f3ca16fbf75f3b6b2dec
MATLAB
1,141
35
function getTriggers_emoReco_button(params) % finds events when subject pressed a button on a joystick to indicate hirs choice: % left (=L), right (=R) or nothing (=n.a.) % (c) Jiri, Mar16 display([' - finding events for: ' params.thisCategory]); %% per session: load trials, find events and save for sess = 1:size(...
aa9180dd2b8a6b82fc68dccc1cd2e9000ee032bf64ae79d2a3501bed6cf218ea
MATLAB
1,141
41
function RDMs=squareRDMs(RDMs_ltv) % converts set of row-vector RDMs_ltv to square form (despite being % rows, RDMs are stacked along the 3rd dimension, just as square RDMs % would be. this avoids ambiguity when the RDMs_ltv is square and could % be either a single RDM or a number of vectorized RDMs.) % RDMs may be bar...
693ca085f880d0586fca7950d830148ba2c1b5f714833896c7fcc3ec7a0f8690
MATLAB
1,142
57
function [llh] = tapas_mdlinear_hier_llh(data, theta, ptheta) %% Likelihood of the nodes of a linear multivariate model with diagonal % precisions on each parameter. % % It is the likelihood of % % p(y|x, beta, pi) = N(y - x*b, 1/pi) % % Note that this is a multivariate regression problem, so beta is a matrix % in w...
6e2679cfc28721b44c31d1cb3f4e1a3038d72523a737da885d42c7f2ee9a5dd1
MATLAB
1,142
28
function [values] = ave_control(A) % FUNCTION: % Returns values of AVERAGE CONTROLLABILITY for each node in a % network, given the adjacency matrix for that network. Average % controllability measures the ease by which input at that node can % steer the system into many easily-reachable ...
951a138c263406964ee9c5d40b3f5eace776fd177907df45060a700ff6364190
MATLAB
1,142
59
function [c] = ROIcol(i,nc, verb) % [c] = ROIcol(i,nc); % returns a color from an ROI colormap. % useful for autocoloring of multiplots % i: index of color, starts at 1 % nc: number of colors in map. Default is 32. % larger numbers cause longer delays at map generation. % returns % c: The color RGB triplets...
a92d39cbdc13145a930a2ae40d05d7c16e58df4ad6a285c0bd0e3c42da34f906
MATLAB
1,142
40
function [fitresult, gof] = createSpikeFit(tsFit, toFit) %CREATEFIT(TSFIT,TOFIT) % Create a fit. % % Data for 'untitled fit 1' fit: % X Input : tsFit % Y Output: toFit % Output: % fitresult : a fit object representing the fit. % gof : structure with goodness-of fit info. % % See also FIT, CFIT, ...
3777b9756d4d160a1ccca905921914f9d7f1dad94ae8e242e573ddbccdc12a06
MATLAB
1,143
25
% I need a model that has different rhos for gain trials than loss trials. % I don't think that this implementation of prospecet theory gives me that. c1 = 10; c2 = 5; p1 = 0.5; rho = 0; alpha = 1;%.7; % alpha is the weight of the probability u_CARA = @(c, rho) (rho ~= 0) .* (1 - exp(-rho .* c)) ./ ( rho + (rho...
72b44f3ceb8ba9d6d76708c43d4341d021e7572aea26a4b32a05d1b0acaa99ae
MATLAB
1,143
54
function [model, param] = tapas_sem_identify_model(fllh) %% Identifies the model from the likelihood function. % % Input % fllh -- Funcion handle with the likelihood of the model % Output % model -- String. Name of the model (seria or prosa). % param -- String. Name of the parametri...
d46dccf4e9ee67cb1557ac47c917e2ccef2b50ae419592da1144c806b1242117
MATLAB
1,143
37
% setup nsdsetup; % find all DWI preprocessed results files0 = matchfiles(sprintf('~/nsd/nsddata_diffusion/ppdata/subj*/run*/dwi/dwi.nii.gz')); assert(length(files0)==8*2); % load in the data allvols = {}; for zz=1:length(files0) a1 = load_untouch_nii(files0{zz}) % img: [320x320x320x98 single] for Run 1 % avera...
f747bef7118ad9c8395629b5eeb0a607bedacfa29fdf8111d598dddbc8c620c9
MATLAB
1,143
33
function [m,dm] = meanPow(d, mean, hyp, x) % meanPow - compose a mean function as the power of another mean function m0. % % m(x) = m_0(x) ^ d % % If the degree d is not a strictly positive integer, we use % m(x) = sign(m_0(x)) * abs(m_0(x)) ^ d % to stay within the reals % % The hyperparameter is: % % hyp = [ hyp_m0...
7e193056b9539bfaa2a90ef169017de045efaee8e7efb3c46d5ae9f1d71c0ae5
MATLAB
1,144
64
function [state] = tapas_mcmc_meta_adaptive_ti(data, model, inference, ... state, states, si) %% % % Input % % Output % % aponteeduardo@gmail.com % copyright (C) 2016 % if state.nsample > inference.nburnin || mod(si, inference.ndiag) return; end % Number of subjects and chains [ns, nc] = size...
82b85406a48ec7b05ce399c404a2fde920868eb4102a09524ea78a7f80ef8163
MATLAB
1,144
41
% Simulate t=0:1/Fs:23389/Fs; signal=sin(2*pi*t*10)+1*randn(1,length(t)); reference=2*sin(2*pi*t*10)+0.1*randn(1,length(t)); % plot(signal, reference) win=[0.5 1 2]; for iWin=1:length(win) [output]=pieceWiseUnmixing( reference,signal, Fs, 'umxMethod','pca','window',win(iWin)); a_pca(iWin,:)=output.coefficient; [outp...
82d9828d0ada608d54fee76d7c25ba0e6c9343e239a5dd166887ab2b1d7a996a
MATLAB
1,144
39
function [m,dm] = meanPoly(d, hyp, x) % meanPoly - compose a mean function as a polynomial. % % The degree d has to be a strictly positive integer. % % m(x) = sum_i=1..D sum_j=1..d a_ij * x_i^j % % The hyperparameter is: % % hyp = [ a_11 % a_21 % .. % a_D1 % a_12 % a_22 % ...
99ebea01bcf32969fba5fe1b46ea016c29dbcbe8e90f7ec86b2de494379c132b
MATLAB
1,144
28
function [lp,dlp] = priorT(mu,s2,nu,x) % Univariate Student's t hyperparameter prior distribution. % Compute log-likelihood and its derivative or draw a random sample. % The prior distribution is parameterized as: % % p(x) = ( 1 + (x-mu)^2/(s2*(nu-2)) )^(-(nu+1)/2) / Z, where % Z = gamma(nu/2) * sqrt(pi*...
00862beae9ab773fcc88b82e8cc54ebffe4b0828323d8675358ea2f21fcf1686
MATLAB
1,145
32
function plot_pc_init(PC,Nchan,i) figure; ki =0; for k=1:Nchan subplot(Nchan,3,1+ki) plot(squeeze(PC(k,1,:)),squeeze(PC(k,2,:)),'*') title(['Cluster:', num2str(i)]); ylabel('PC2') xlabel('PC1') xlim([min(squeeze(PC(k,1,:))) max(squeeze(...
670662cb2bbce9d9e367ca3dfe9f9e9606768af8cab82131e4a7c9e4a1f2bae4
MATLAB
1,146
44
%% B0_dir = get_B0_dir_from_nifti(nii) % % Input % -------------- % nii : NIfTI format structure from load_untouch_nii.m % B0_dir : default B0 direction (optional, default in z-direction [0;0;1]) % % Output % -------------- % B0_dir : main magnetic field direction with respect to imaging % ...
9ef206c6880305b53216bc7246c8ae96c197232ef3af45dd18ec5a9c822012bb
MATLAB
1,146
52
function [out err] = semangle(in,sens); % MEANANGLE will calculate the mean of a set of angles (in degrees) based % on polar considerations. % % Usage: [out] = meanangle(in,dim) % % in is a vector or matrix of angles (in degrees) % out is the mean of these angles along the dimension dim % % If dim is not specified, th...
c28fa908a81bb830aa63f093dfb6600b8f7d9834cd379ec035a4e1440e921585
MATLAB
1,146
48
function [llh] = tapas_mdlinear_llh(data, theta, ptheta) %% Likelihood function of a multivariate linear model where we assume that % the covariances are diagonal. % % This is the likelihood of a Gamma Gauss model % of the form % % p(beta| beta0, pe)p(pe) = N(beta; X*beta0, 1/pe) Gamma(pe; a, b) % % Note thet beta is ...
c7dd3b1fa2e909fdf3042c9e9c3c469f901a462752cfe9af5aee110d0802129e
MATLAB
1,146
44
function [ptheta] = tapas_sem_multiv_prepare_ptheta(ptheta, theta, pars) %% Thin layer of preparations for the hierarchical model. % % aponteeduardo@gmail.com % copyright (C) 2016 % % Number of parameter data sets. nvals = size(ptheta.jm, 1); ndims = ptheta.ndims; npars = nvals / ndims; assert(floor(npars) == npars...
d07bfc5633437fe59647df10c1a8bfe10be9b6a199511b0b619fee8a890a23f7
MATLAB
1,146
38
function namesMatlabbatchMethods = get_all_matlabbatch_methods(this) % Returns cell of string identifiers of all methods using a matlabbatch % % Y = MrSeries() % Y.get_all_matlabbatch_methods() % % This is a method of class MrSeries. % % IN % % OUT % nameMatlabbatchMethods cell(1,nMethods) of string identifiers ...
d820a259a3ea3e5e02ea294be101e726879b7c599b41db9f8c7465472bee6f0a
MATLAB
1,146
61
function [sigma,mu,A]=mygaussfit(x,y,h,optionStab) % % [sigma,mu,A]=mygaussfit(x,y) % [sigma,mu,A]=mygaussfit(x,y,h) % % this function is doing fit to the function % y=A * exp( -(x-mu)^2 / (2*sigma^2) ) % % the fitting is been done by a polyfit % the lan of the data. % % h is the threshold which is the fraction % from...
ff8b24894aa5708ada147f0cf819fcbb6528a1e2c2f84643f4fe7bcb8c6e93a8
MATLAB
1,146
39
function crc = neuralynx_crc(dat, dim) % NEURALYNX_CRC computes a cyclic redundancy check % % Use as % crc = neuralynx_crc(dat) % % Note that the CRC is computed along the first dimension. % Copyright (C) 2007, Robert Oostenveld % % This file is part of FieldTrip, see http://www.fieldtriptoolbox.org % for the docum...
3e793eb66a84d43428fc189213f261855cce9bf6240833eaebdd838901345e6c
MATLAB
1,147
27
function [pvec, pstruct] = tapas_ehgf_binary_transp(r, ptrans) % -------------------------------------------------------------------------------------------------- % Copyright (C) 2012-2020 Christoph Mathys, TNU, UZH & ETHZ % % This file is part of the HGF toolbox, which is released under the terms of the GNU General P...
6c3922247d3484132a08ac07a0fa66aa6b4ff403afccf997a8aef7ce6718497e
MATLAB
1,147
39
function y = tapas_condhalluc_obs2_sim(r, infStates, p) % Simulates responses according to the condhalluc_obs model % % -------------------------------------------------------------------------------------------------- % Copyright (C) 2016 Christoph Mathys, TNU, UZH & ETHZ % % This file is part of the HGF toolbox, whic...
afa942d34482934af39952fb97aaf04a631e6c2e74b6a1ab7b513fa70e49e957
MATLAB
1,147
37
function y=surfing_uniqueidxsperrow(x) % returns unique indices per row % % UNIQUEIDXS=SURFING_UNIQUEIDXSPERROW(IDXS) % % INPUT: % IDXS: NxP matrix, for N rows with P indices each. % OUTPUT: % UNIQUEIDXS: NxQ matrix, Q<=P, where each row contains the unique % values in the corresponding row fro...
f35fc5eba5b4c219776924f14ed6983419667c80babd1010fd7cca58e277653d
MATLAB
1,147
29
function FWHM_map = calculate_2D_FWHM(target_plane,target_point) maxValue =target_plane(target_point(1), target_point(2)); row_peak = target_point(1); col_peak = target_point(2); FWHM_map = zeros(size(target_plane)); for view_degree = 0:359 view = pi*view_degree/180; vector = [cos(view),sin(view)]; step_vie...
fcc52515deceffcd69416ea879f9a9b083187c9fe33d88dfd48708b63fd88c08
MATLAB
1,147
53
function this = save(this, filename) % saves the data in MrRoi % % Y = MrRoi() % Y.save(inputs) % % This is a method of class MrRoi. % % IN % % OUT % % EXAMPLE % save % % See also MrRoi % Author: Saskia Bollmann & Lars Kasper % Created: 2014-11-21 % Copyright (C) 2014 Institute for Biomedical Engineering % ...
25113bb468156db1cb83674d074d765c8642028539a133697bd6ca7c3f9183e2
MATLAB
1,148
40
function namesMatlabbatchMethods = get_all_matlabbatch_methods(this) % Returns cell of string identifiers of all methods using a matlabbatch % % Y = MrImage() % Y.get_all_matlabbatch_methods() % % This is a method of class MrImage. % % IN % % OUT % nameMatlabbatchMethods cell(1,nMethods) of string identifiers of...
2b5d100f4a02f9eb01aeaa2930996a6dd247167f83b76a2b7988df98ac85d205
MATLAB
1,148
46
function opt = sero_pulseq_SERO_opt(opt) % function opt = sero_pulseq_SERO_opt(opt) % % 1. Call this functions without input arguments to get default structure - % e.g. opt = sero_pulseq_SERO_opt() % 2. Change the options as you like % e.g. opt.TE = 100e-3; % 3. Call this function again with the options as input to upd...
4746b38ac5dd532008c88bea40f6228dc8f02a4e3c59d2d271f40e86a6a2e6d7
MATLAB
1,148
61
function [numcl,rad,nclusts] = recover_choose_radius(varargin) % [numcl,rad,nclusts] = recover_choose_radius([plot color]) % % input of an argument signals to plot. color = input argument % % tor wager % % d = dir('dens*clusters.mat'); d = str2mat(d.name); for i = 1:size(d,1), load(deblank(d(i,:))) numcl(i) =...
9831010a4df60dbcdaad1956932f6acc93b0461a98d9aaf3e5d983b2af85d690
MATLAB
1,148
37
function getTriggers_gameType(params) % extracts only defined paradigm from each session % based on the keyword 'gameType' which should be loaded into sessionCache % via params.load_D % (c) Jiri, Nov16 display([' - finding events for: ' params.thisCategory]); %% per session: load trials, find events and save for ses...
bd854cfed813a764da86c03728c5f9a114d8046102892ce14d80e8e4ef2ef9c4
MATLAB
1,148
43
for explictMexReset = [false] % reset the same GPU device for t = 1:6 if explictMexReset, clear mex ; end if mod(t-1,2) == 0 disp('vl_test_gpureset: resetting GPU') ; gpuDevice(1) ; else disp('vl_test_gpureset: not resetting GPU') ; end if t > 1, disp(a) ; end a = gpuA...
65fe05261279c3b0246362a2997acab4a5012cb4292249bf2f3a8765c916926e
MATLAB
1,149
50
function h = sero_pulseq_plotBlocks(seq, blockInd) % function h = sero_pulseq_plotBlocks(seq, blockInd) if nargin < 2 || isempty(blockInd) blockInd = [1 numel(seq.blockEvents)]; end [gwf, rf, dt, ti, rwf] = sero_pulseq_getBlockWaveforms(seq, blockInd); col = pulseq_colXYZR(); tStart = sum(seq.blockDurations(1:(...
94d603c79b11957348b053cb7ef76b3a95d492c668808cf64034c84f4b890ea2
MATLAB
1,149
36
function p = chsqcudf(x,v) %CHI2CDF Chi-square cumulative distribution function. % P = CHI2CDF(X,V) returns the chi-square cumulative distribution % function with V degrees of freedom at the values in X. % The chi-square density function with V degrees of freedom, % is the same as a gamma density function with ...
a6f0bdc680c04b57b0d368db16c75bd991e35a97941b5632d86035b87ecc2f54
MATLAB
1,149
31
function [re_ordered_corrected] = FDR_correct(uncorrected_values) %Perform FDR correction on multiple p-values calculated from same figure % list of uncorrected p-values is the input argument % the function will rank order and correct scaled to the number of comparisons % then, it re-orders the values to matc...
b624651ba22151a34cba998a58f08f8bda4de015922954e0f2c500e3df93e48a
MATLAB
1,149
28
%{ # field-specific scan information -> meso.ScanInfo -> shared.Field --- px_height : smallint # height in pixels px_width : smallint # width in pixels um_height : float # height in microns um_width ...
018ed400496f148edd9387dbafc5d1c1bb127da7eda9bf694a3dd1f688afec74
MATLAB
1,150
30
%{ stk.StackInfo (imported) # header information -> stk.Stack --- nchannels : tinyint # number of recorded channels nslices : int # number of slices (hStackManager_numSlices) frames_per_slice : int ...
847052dd3edd5f47c0b7e1baa5e44aa6cd8aeca86544c191b9a0f215da18900a
MATLAB
1,150
27
function [pvec, pstruct] = tapas_hgf_binary_transp(r, ptrans) % -------------------------------------------------------------------------------------------------- % Copyright (C) 2012-2013 Christoph Mathys, TNU, UZH & ETHZ % % This file is part of the HGF toolbox, which is released under the terms of the GNU General Pu...
91bac55e5bdbe8f68dac5bc7b7d21372875428c782b30945679707e3222a751d
MATLAB
1,150
36
%% addon_config % % Description: Addon script to incorporate new method to the SEPIA framework % % Kwok-shing Chan @ DCCN % k.chan@donders.ru.nl % Date created: 27 June 2020 % Date modified: % % DO NOT change the variable names, update the variable value instead % %% main % This name will be used thorough the SEPIA f...