sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
5f547280ab9933eb490e8d71e5db57e42e12eb79a2669b82245d74290412b6a9
MATLAB
733
32
function y = permute( x, order ) % Disciplined convex/geometric programming information for PERMUTE: % PERMUTE(A,ORDER) imposes no convexity restrictions on A. ORDER % must be constant. % % Determine the permutation % s = x.size_; ndxs = 1 : prod( s ); ndx2 = permute( reshape( ndxs, s ), order ); % % Pe...
75303615c8338d2dc6227bd7a7ecf42a720acbb5e58f4130ae7b9bb87814910e
MATLAB
733
32
function cvx_optval = norm_nuc( X ) %#ok %NORM_NUC Internal cvx version. narginchk(1,1); if ndims( X ) > 2, %#ok error( 'norm_nuc is not defined for N-D arrays.' ); elseif ~cvx_isaffine( X ), error( 'Input must be affine.' ); end % % Construct problem % [ m, n ] = size( X ); %#ok W1 = []; W2 = []; cvx_be...
a291f4969512aaf5c3db05200fd09bce86475263c02e7fc79c7ef0a191928398
MATLAB
733
24
function PI = freqMulti(f) %FREQMULTI Calculate frequency coefficient for ITD-azimuth warping % % PI = IOSR.AUDITORY.FREQMULTI(F) calculates the coefficient PI for % frequency F for use in converting between ITD and azimuth in Kuhn's % model [1]. % % References % % [1] Kuhn, G.F. (1977), Model for the inter...
e83600bdc8fc11167417aabf8394cba4a6ba76aa6af5bb3aadb21473dd15b269
MATLAB
733
26
function d = getdict % Dictionary of GIfTI/NIfTI stuff %__________________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % Guillaume Flandin % $Id: getdict.m 4505 2011-09-30 11:45:58Z guillaume $ persistent dict; if ~isempty(dict) d = dict; ...
f2f70d6a3946370fcb8580a0dacf8bf9c48850dbb213d2188165bf24c19bdbcb
MATLAB
733
26
function res = PFNa_integ(params,inputs,inits) % params = array where first row is AF, second row is OF % inputs = array where: % [ AF directions; % AF speeds; % OF directions; % OF speeds; % time ] % Calculate single-half PB OF response OF = A_response_de(params(2,:),inputs([3:5],:),inits(2));...
fa3408eb44a37951b671898521cb2d0b735b8871fc0b2554171589d7847e6f08
MATLAB
733
19
function s = structpack(names) %STRUCTPACK Copies workspace variables into the fields of a structure. % S = STRUCTPACK(NAMES) takes a cell array NAMES of strings containing % the names of variables in the current workspace. It returns a % structure with field names and contents copied from those variables...
123317b362db09431c922e55bbff934b76448bf5b40e4d389addb874bcd3cdae
MATLAB
734
26
function [ cfgVISUAL ]= RFT_EEG_Visualise( data, channels, range, layout_file) % % PREPARE LAYOUT load(layout_file); % this normally load a 'lay' structure cfg.layout = lay; layout = ft_prepare_layout(cfg, data); % VISUALIZE DATA cfgint = []; cfgint.blocksize = 10; ...
85ba482089d81a90040a9339e1e99470ae1f8590e813df0f21cfd503629dc611
MATLAB
734
24
%% Example 3 of Running Collocation Topic Model (LDACOL) %% %% % How to convert stream data into collocation stream data %% % Choose a dataset dataset = 1; % 1 = psych review; 2 = nips if (dataset==1) % example 1: load in PSYCH REVIEW word stream and convert to % collocation data load 'psych...
569d1818ac6613ee7ef04e213c8b234286726edc73a68f24f827081ed7c09726
MATLAB
735
27
clear; clc; close all; addpath(genpath('../functions/')); SUBINFO_FILE = '../../subInfo/rid_sex_mDoB_yDoB_mExam_yExam_ageExam_dx_icv_bl.csv'; GMICV_FILE = '../../vbm_810bl/gmVolAndICV/rid_gmVol_icv_bl.csv'; [rid_dx, ~, ~, ~, rid_sex, ~] = get_data(SUBINFO_FILE, GMICV_FILE, 3); % Stats maleAD = sum(rid_sex(rid_dx(:,...
6d180ac1c345c56def29e99d8a21508f1542fe127850e28e8f7e768b14d6fe6e
MATLAB
735
34
function convertmatfiles savedir = 'matlab6files'; % take all mat files in the current directory whdir = dir( '*.mat' ); nfiles = length( whdir ); for iiii=1:nfiles filenow = whdir( iiii ).name; fprintf( 'Working on file: %s\n' , filenow ); % first, get the variables from thi V = wh...
8c95a417e293e23a00e7f2fc95b1d37eaa28c7daf2d809f3fb9fcf1b39d6c526
MATLAB
735
31
function csd = CSD(lfp) %CSD - Compute current source density. % % USAGE % % csd = CSD(lfp) % % lfp local field potential samples % % SEE % % See also PlotCSD. % Copyright (C) 2008-2011 by Michaël Zugaro % % This program is free software; you can redistribute it and/or modify % it under the term...
e436a42f9251ba2109a73fe6a71369277fcd34151f64436053a1261e7915ff30
MATLAB
735
20
% Local Regression and Likelihood, Figure 6.4. % Author: Catherine Loader % % Local smooth of CO2 dataset. Estimate the main trend, % then use periodic smoothing of the residuals to estimate % the annual effect. Add main trend and periodic components % to get overall smooth. % % A periodic smooth is specified by 'style...
f04b7b2c9334379bee8186d0393b604d02ccb95bd48ea7f70df6d025e2c64817
MATLAB
735
21
function bumpsmooth(data, sigma_a, sigma_b) % sigma_a=0.5; %smoothing across rows % sigma_b=0.5; %smoothing down columns for k = 1:length(sigma_a) figure subplot(1,length(sigma_b)+1,1) imagesc(data) title('original data') hold on for j= 1:length(sigma_b) a=imgaussfilt(data,[sig...
7fdf12b59c2ec7609786ff1e2b411b8ace2d3eb189fd0de102808e4a09041591
MATLAB
736
27
function coords=ea_findcoords(goodz,trajectory,trajvector,dist,correction,options) trajectory=ea_genhdtrajectory(trajectory,options); onecoord=trajectory(abs(trajectory(:,3)-(goodz+correction(3)))<0.001,:); %% add correction term orth=null(trajvector); orth=[orth,trajvector']; orthx=orth(:,1); orthy=orth(:,2); try ...
f004260ac88dbe866b4549a31c5492bb752c473a79161e214f2301afea847a1c
MATLAB
737
33
% Imbed a zoom menu to any figure. % % Usage: rri_zoom_menu(fig); % % - Jimmy Shen (jimmy@rotman-baycrest.on.ca) % %-------------------------------------------------------------------- function menu_hdl = rri_zoom_menu(fig) if isnumeric(fig) menu_hdl = uimenu('Parent',fig, ... 'Label','Zoom on', .....
8f8502928fc4458cae882d2af5b6de7585b361c8c52108e346bb4d79bbb02da6
MATLAB
738
35
function varargout = offset(varargin) % Format % For getting the value % dat = offset(obj) % % For setting the value % obj = offset(obj,dat) % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: offset.m 1143 2008-02-07 19:33:33Z ...
b98ea21bac1ca6a9fcf484ea1fed4115ca3f37c69ebc6e84c9c511ee71ba48bd
MATLAB
738
25
function o2 = canlab_simple_mean_image_montage_by_condition(DATA_OBJ, image_set_names) % o2 = canlab_simple_mean_image_montage_by_condition(DATA_OBJ, image_set_names) % % DATA_OBJ = cell array of fmri_data objects % image_set_names = cell array of names for each image set (e.g., DAT.conditions) % % e.g. % canlab_simple...
d897bcc934d4dd57dcc2bdbde85acdb595255e5aea10eb3ef84e9c2c7856bcf1
MATLAB
739
30
%% Figure 8 main % Run fig8_analysis, then return here fig8_analysis % Load map load('allenDorsalMap.mat'); % Params cmap = 'L20'; smoothSD = 0.15; %% Panel B: % CCF with log probabilities for M2 GMM plotMetricMapCCF(dorsalMaps, allROIs, 'lpM2', smoothSD, cmap) %% Panel C: % CCF with log probabilities for M1 GMM pl...
dd2e771308431fe4545b8a11c2ef5713d36a72db2ff381dc55cf6711e06edecd
MATLAB
739
13
[fname,pname]=uigetfile('*'); eval(['load ' pname '\' fname]); params.tapers=[5 9]; params.pad=2; params.Fs=1000; params.fpass=[0 100]; params.trialave=1;params.err=[1 0.05]; movingwin=[0.5 0.1]; % duration of moving window used to evaluate spectrograms win=[2 2]; % window around events fignum=[2 3 6 9 8 7 4 1]; %...
f7af3d8029f9a5259a6515af67d646b7402b0655e93a2808c35de981443398c9
MATLAB
739
35
function [ INT ] = IDXtoINT_ss( IDX ,numstates) %IDXtoINT(IDX) Converts state indices to state on/offsets % %INPUT % IDX: [t x 1] vector of state indices, where states are identified by % integers starting from 1. Times with IDX 0 will not be counted % in any interval INT % numstates (optiona...
197cdb1b1240ea4c1028cacf7477ff2c061ac880e1619c0edd42d7b2e6d422fa
MATLAB
740
22
%% This function calculates the angles of a triangle and returns them as a 1 X 3 array % – Sep 11th 2024, Stefan G. Lechner (s.lechner@uke.de) – % Input arguments: % PointA, PointB and PointC as 1 x 3 double function [TrimerAngles] = CalcTrimerAngle1(PointA, PointB, PointC) AB = PointA-PointB; ...
3d97a48e206b3edea8bd1056f55fa06ecf024684ec6c645b40657d8660e87be7
MATLAB
740
11
% Examples from <a href="http://stanford.edu/~boyd/papers/gp_tutorial.html">A Tutorial on Geometric Programming</a> % % max_volume_box.m - Box volume maximization % simple_dig_ckt_sizing.m - Digital circuit sizing % simple_dig_ckt_sizing_vect.m - Digital circuit sizing (vectorized) % elmore_interco...
24593f0b96878c3796e844cba31b32da8156cf61a459af2ba392ab51571c5ab9
MATLAB
741
26
function M = CBIG_MMLDA_auto_reorient(path) % This code is from https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=SPM;d1f675f1.0810 % Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md spmDir = which('spm'); spmDir = spmDir(1:end-5); tmpl = [spmDir 'canonical/av...
2fdb0e18196339a2033b58f5eeab97c305cb670f031bbc363982efba13e655a5
MATLAB
741
28
function ab=fill_abline(ab,varargin) ab.on=true; l=max(cellfun(@length,varargin(1:5))); ab.slope(end+1:end+l)=shiftdim(varargin{1}); ab.intercept(end+1:end+l)=shiftdim(varargin{2}); ab.xintercept(end+1:end+l)=shiftdim(varargin{3}); ab.yintercept(end+1:end+l)=shiftdim(varargin{4}); ab.extent(end+1:end+l)=shiftdim(varar...
64ef96b64c7fdadbacf70a8035dfdcda19f8622da19f80dd0114baf3c4086e96
MATLAB
742
34
function DBListVariables(query) %DBListVariables - List variables matching certain criteria. % % USAGE % % DBListVariables(query) % % query optional database query (WHERE clause) % % EXAMPLE % % DBListVariables('name="Spectrogram"'); % % SEE % % See also DBGetVariables, DBGetFigures. % % Copyr...
6be71122fe3af47492c232a8f0391aff7ddd513d017b8803d0faa063ad27fe46
MATLAB
742
13
img = which('keuken_2014_enhanced_for_underlay.img'); img = fmri_data(img); histogram(img, 'by_tissue_type'); % This uses the extract_gray_white_csf method, which in turn % currently uses the images % 'gray_matter_mask.img' 'canonical_white_matter.img' 'canonical_ventricles.img' % These images ...
6cfcaf508fd2e6925bd09d11542820b2b9e4272f97a24809fe1ceff5d679fe42
MATLAB
742
26
function F = isfield(tree,uid,parameter) % XMLTREE/ISFIELD Is parameter a field of tree{uid} ? % FORMAT F = isfield(tree,uid,parameter) % % tree - a tree % uid - uid of the element % parameter - a field of the root tree % F - 1 if present, 0 otherwise %________________________________________________...
dd0ef57e65a36d26d7d6165df841fbfa11d4e5644b1cd0dbc8aab79700a0cf3f
MATLAB
742
27
function bz_RunSessionMetadata(basepath) % Wrapper to edit and then run SessionMetaData creation. % This executes the metadata script created in bz_EditSessionMetadata.m % after it is created and the user hits a key to indicate as much. % % See bz_EditSessionMetadata for much more info. T % % Brendon Watson 2017 %...
e0e0734a0c4f3cb462805de53d56040e896c82cf4569a404b1b7224ba46c3a90
MATLAB
742
27
function epochs = IntersectEpochs2(varargin) % Finds the intersection of all sets of epochs. % epochs = IntersectEpochs2(epochs1, epochs2, epochs3...) % % Must pass at least % import CMBHOME.Utils.* if length(varargin)<2, error('you must pass at least 2 input arguments of type ''epoch'''); end if any(cellfun(@isempty...
8d48c13939939e3ef6eaf1c755fb874aa20af57a14260401122879056503268d
MATLAB
743
30
function f=pixtoim(pix_list,im_size,x_list,filter) % Usage ... f=pixltoim(pix_list,im_size,x_list,filter) % % x_list=data (vector), pix_list=corresponding pixels(2 col) % x_list and pix_list must be the same length % x_list must be a vector and pix_list is a 2col vector % filter is a binary vector which indicates inclu...
4a9633d2b3091882426c59a37608111c7002cc7d0b15c4c5316365d12517f58b
MATLAB
744
29
% some video sequence i = 1; for imgi = 85 : 88 fname{i} = sprintf('samplepics/seq/%03d.jpg',imgi); i = i + 1; end N = length(fname); % compute the saliency maps for this sequence param = makeGBVSParams; % get default GBVS params param.channels = 'IF'; % but compute only 'I' instensity and 'F' f...
c99f3c4212642c59c818146fccf632ec0731d5f66ae2a643c81eaeacd3e20ebe
MATLAB
744
30
function cmap = cmapAreas(nAreas, type) if nargin < 1 nAreas = 5; end if nargin < 2 type = 'manual'; end if nAreas ~= 5 % Scale colorcet map values so they are more distinguishable cmap = colorcet('I2', 'N', nAreas); if nAreas == 5 vals = [0.55, 0.75, 0.95, 1, 1]; else vals = ...
204e91a75b6d21091a76b36ffb022a9d44e693d71c275e7a69a803b554c299b4
MATLAB
745
27
function metrics = getMetrics(allROIs, zscore) % Simple function to extract a matrix of features from a peths struct if nargin < 2 zscore = 0; end % Validate valid = [allROIs.valid] == 1; allROIs = allROIs(valid); % Concatenate each sharpness = cat(1,allROIs.sharpness); linearity = cat(1,allROIs.linearity); persi...
502f8429629a3800f36d0b6c17112b5764605d9d4b4c84151bcec749c305f2b7
MATLAB
745
27
%% Number Shuffling % ================ % The syntax is % y = shuffle(X) % where % X: an m by n matrix or a 1 by n vector % y: an m by n matrix or a 1 by n vector containing shuffled numbers of % m by n matrix X or 1 by n vector X function t = shuffle(X) %% Created by: Aamir Alaud-din %% Create...
504b460495cd23a1b06c86978b0bad7b4f70165504cc7cefd8092d0371d5ec83
MATLAB
747
29
close all; clear; clc; %% Factors estiamted with 147 amyloid+ MCI resultDir = '../../lda/postprocess/147blApMCI/k3/'; r = dir([resultDir 'r*']); beta_apMCI = exp(load([resultDir r.name '/final.beta'])); %% Factors estiamted with 188 AD resultDir = '../../lda/postprocess/188blAD/k3/'; r = dir([resultDir 'r*']); beta...
fda9a7ba1a9f2e652a3bfb8933735745f5c82d1bccb764f38b00db087fabe60b
MATLAB
747
31
function data_parcellated = calc_parcellate(parc, data_input) % calc_parcellate.m % % Parcellate data % % Inputs: parc : parcellation [Nx1] % data_input : data to parcellate [NxM] % % Output: data_parcellated : parcellated data [num_parcelsxM] % % Original: James Pang, Monash University, 2021 %% n...
0fcfe4353190645f2623ce05bb31e81ab4bfb8f51fecba5b97ecc0359b124fa9
MATLAB
748
21
function rt = rt_analyze(e,s,b,TYPE) globalsConditions; optionsMinsearch = optimset('MaxFunEvals',50000, 'MaxIter',50000, 'TolFun',1e-12, 'TolX',1e-12); data = dlmread(sprintf('e%dv%db%dc0/e%dv%db%dc0.log',e,s,b,e,s,b)); if (size(data,2)>COL_MAX) && EXCLUDE_DEMO_TRIALS data = data(data(:,COL_MAX+1)==0,:); e...
d89ab886c3626fe00139d41414dbcf8f35cb4cb2c7f0f52c0725214bd10b06af
MATLAB
748
29
% eyelike() - calculate a permutation matrix P and a scaling (diagonal) maxtrix S % such that S*P*E is eyelike (so permutation acts on the rows of E). % E must be a square matrix. % Usage: % >> [eyelike, S, P] = eyelike(E); % % Author: Benjamin Blankertz (blanker@first.gmd.de) 3/2/00 fun...
19d79c9fd120f0a84a8de9de6e4449e10efa1050597483869ec01e4f219001f9
MATLAB
749
29
function [xx,yc]=mydftreg(im,refim,parms) % Usage ... [x,imc]=mydftreg(im,refim,parms) % % parms=[scalef smwid] upscalef=parms(1); smw=parms(2); if nargout==0, verbflag=1; else, verbflag=0; end; if length(parms)==3, verbflag=parms(3); end; for mm=1:size(im,3), im1=refim; im2=im(:,:,mm); if smw>0, ...
96c8490f9125904fe3951b9b50d12f14492807ec410480e0443e8047c239fa80
MATLAB
749
27
%%**************************************************** %% gppschur: compute schur matrix of HKM direction %% for GPP problems. %% %% schur = gppschur(X,Zinv,schurfun_par); %% %% Ak = -e*e' if k = 1 %% = -ek*ek' if k > 1. %% %% SDPT3: version 2.1 %% Copyright (c) 1997 by %% K.C. Toh, M.J. Todd, R.H....
dedb4d4ea574ce9b12373c1a20029a6115dc8b08f12cabad17bc0913c275ceb4
MATLAB
749
20
function err = muA_obj_scalar(x, mean_mu_a760, mean_mu_a850, thres_HbO, thres_HbR, ... epsilon_mm_uM, J_chrom_brain, meas_HbO, meas_HbR, lambda, relative_beta_SNR) %MUA_OBJ_SCALAR Scalar-only wrapper for fmincon. % err = muA_obj_scalar(...) % % Ensures the fmincon objective returns...
f2a1b53be01b63402bd339bcd840d5af879c53f751dbabfce6e80be444d81327
MATLAB
749
37
function r = circ_dist2(x,y) % % r = circ_dist(alpha, beta) % All pairwise difference x_i-y_j around the circle computed efficiently. % % Input: % alpha sample of linear random variable % beta sample of linear random variable % % Output: % r matrix with pairwise differences % % Refe...
88cc314ad792282863e763f87f6e3ae323822bad74d7016ae575352639d21890
MATLAB
752
29
% intersect_bc - intersect backward compatible with Matlab versions prior to 2013a function [C,IA,IB] = intersect_bc(A,B,varargin); errorFlag = error_bc; v = version; indp = find(v == '.'); v = str2num(v(1:indp(2)-1)); if v > 7.19, v = floor(v) + rem(v,1)/10; end; if nargin > 2 ind = strmatch('legacy', varargin...
3790fad4b4337b280da06f671990c29d5a44cf58ba11ee3a0531ebadcc78b0f9
MATLAB
753
16
function sleepstagesOUT = hume2danalyzer(sleepstagesIN) % Convert a Hume score file to a danalyzer score file. %% % Authors: Dan Denis % Date: 2021-07-14 %% sleepstagesOUT.stages = sleepstagesIN.stages; sleepstagesOUT.hdr.srate = sleepstagesIN.srate; sleepstagesOUT.hdr.win = sleepstagesIN.win; sle...
fef347f5cfd56d03b3f136e903a86509b1ec3310346ba33bf37f35380c2e391c
MATLAB
753
28
function w = lapwin(L,b) %LAPWIN Laplace window. % % IOSR.DSP.LAPWIN(N) returns an N-point Laplace window. The window w(x) is % calculated for -10<=x<=10. % % IOSR.DSP.LAPWIN(N,B) returns an N-point Laplace window using scale parameter B. % If omitted, B is 2. % % See also GAUSSWIN, CHEBWIN, KAISER, TU...
7196a8cc6f43d2e43a592e8864b2140274a5dbd4c93bf1fafc2d8c20b66b453d
MATLAB
754
22
function basename = bz_BasenameFromBasepath(basepath) % gets basename from a basepath input to a function. Uses name of the last % directory on the path to give basename. Takes care of the problem of the % fact that if a fileseparator is on the end of the basepath, you have to % take it off first. % % INPUTS % basepa...
aa90ba7832ef61e96bea95416ca936f3f06c9701bb4d976ab5939cfe3c00ecd9
MATLAB
754
17
function a = eq( x, y ) %Disciplined convex programming information for EQ (==): % Both the left- and right-hand sides of an equality constraint must % be affine (or constant). If either side of the constraint is complex, % then the real and imaginary portions are constrained separately. % %Disciplined geometric...
512665de800f33030ff797ddc880849deaced398a4f4aae0c99a4a9722892ec5
MATLAB
755
20
% Local Regression and Likelihood, Figure 6.4. % Author: Catherine Loader % % Local smooth of CO2 dataset. Estimate the main trend, % then use periodic smoothing of the residuals to estimate % the annual effect. Add main trend and periodic components % to get overall smooth. % % A periodic smooth is specified b...
5bbea38781b2593f827307e33de32b2a7d8174eb16cfdec8965457ded5afab16
MATLAB
755
23
% Example implementation of memory mapping an NPY file using readNPYheader filename = 'data/chelsea_float64.npy'; [arrayShape, dataType, fortranOrder, littleEndian, totalHeaderLength, npyVersion] = readNPYheader(filename); figure; if fortranOrder f = memmapfile(filename, 'Format', {dataType, arrayShape, 'd'},...
8055703b184fe02c1b3a5869b24704aff34a5d87a15f5b1b4f2cce0c6d47d5a6
MATLAB
755
29
function saveoff(v,f,fname) % % saveoff(v,f,fname) % % save a surface mesh to Geomview Object File Format (OFF) % % author: Qianqian Fang, <q.fang at neu.edu> % date: 2007/03/28 % % input: % v: input, surface node list, dimension (nn,3) % f: input, surface face element list, dimension (be,3) % fname: out...
7af347f7476a7aebd9ffa4a160f4bcea05cb7c0546765235b5dfaa6cf1748e79
MATLAB
756
27
function [ xR, x, sx ] = bcompress( x, mode, nsrt ) narginchk(1,3); if nargin < 2 || isempty( mode ), mode = 'full'; elseif ~ischar( mode ) || size( mode, 1 ) ~= 1, error( 'Second argument must be a string.' ); end if nargin < 3 || isempty( nsrt ), nsrt = 0; elseif ~cvx_check_dimension( nsrt, t...
7d31fc93d15c9b0e30273183d594a82baba738b696280fa0d65313f4bb7a2b1f
MATLAB
756
17
function output = resetintegrator(input, reset) %RESETINTEGRATOR Running counter with resets. % OUTPUT = RESETINTEGRATOR(INPUT, RESET), where INPUT and RESET are % length N vectors, returns a length N vector OUTPUT equal to the % cumulative sum of INPUT, reset to zero on each sample k for which % RESET(k) ==...
c1b914d6a25a50fa50a1c5afdf3a5ade728c86cb54fe5492385b204070778fe1
MATLAB
756
34
function z = fun_cramer_von_mises(data) % Cramér-von Mises test of coupling strength. Tests the degree to which the % phase distribution shows a preferential peak relative to a uniform % distribution. Value close to 1 when the coupling phase is consistent % across spindles % % Required input: % % data: Coupling phases ...
2f5ccfa88157152bf950ce2819272523da1ea654e89dbe3eddaf87bf13daeca2
MATLAB
758
26
function signal_filtered = BandpassFilter(signal, Fs, Fpass) % Takes 'signal' and bandpasses it to Fpass frequencies % % Arguments % % signal - arbitrary signal to be filtered % Fs - sample frequency % Fpass - 1x2 vector of F_low and F_high indicating passband % % signal_filtered = BandpassFilter(signal, Fs, Fpass) if...
41a27f48b42b434ed37ec6fbf24f820770f5eb95ccf057d7fc7141a7ed0e2ddc
MATLAB
758
32
% Section 8.5.3: Analytic center of a set of linear inequalities % Boyd & Vandenberghe "Convex Optimization" % Joëlle Skaf - 04/29/08 % % The analytic center of a set of linear inequalities and equalities: % a_i^Tx <= b_i i=1,...,m, % Fx = g, % is the solution of the unconstrained minimization p...
7fe3fd12dad1ac20eb04c06b61c83ae294ff8435166200ed46c2a9407cd1f2b2
MATLAB
758
24
rawPath = 'D:\aperiod\eeg\'; savePath = 'D:\aperiod\eeg_clean\'; fileList = dir(fullfile(rawPath, '*.vhdr')); if isempty(gcp('nocreate')) parpool(16); end parfor k = 1:length(fileList) [ALLEEG, EEG, CURRENTSET, ALLCOM] = eeglab('nogui'); filePath = fullfile(rawPath, fileList(k).name); ...
d9754d28d09cd7167c4759d132db0af3aa3f29047d4edd8f07fa2292bc933fc2
MATLAB
758
26
function d = getdict % Dictionary of GIfTI/NIfTI stuff %__________________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % Guillaume Flandin % $Id: getdict.m 4505 2011-09-30 11:45:58Z guillaume $ persistent dict; if ~isempty(dict) d =...
04bfd5896425b99d525332315a70be45afbb07c9b0874398e0c17b700df4a7f4
MATLAB
759
22
function options = merge_options(default_options,varargin) % MERGE_OPTIONS Merge a set of default options with options from varargin % The set of options in varargin can be a list of key,value pairs, or a % struct with the same information. % David F. Gleich % Copyright, Stanford University, 2008 %% History % 2008-0...
d44d0814299984de78f675fe90ae86aac015883c45c8ac718fcfd21ce9a2569d
MATLAB
759
38
function [th, fp, sp] = auto_threshold(rotcorr, rrcorr, nz) maxcor=nz*(nz-1); loop_step=[0.1 0.01 0.001 0.0001]; new_start=0.1; new_end=1; c=1; for j=1:length(loop_step) % Smaller steps around 0.5 --> 0.1 tempi=zeros(length(new_start:loop_step(j):new_end),2); for i=new_start:loop_step(j):new_end %bin=rrcorr; ...
1162f39cce55be07802ecd2b6f062898fa74a03937e1f4f1e857a3b10259b9ca
MATLAB
760
38
function [th, fp, sp] = auto_threshold(rotcorr, rrcorr, nz) maxcor=nz*(nz-1); loop_step=[0.1 0.01 0.001 0.0001]; new_start=0.1; new_end=1; c=1; for j=1:length(loop_step) % Smaller steps around 0.5 --> 0.1 tempi=zeros(length(new_start:loop_step(j):new_end),2); for i=new_start:loop_step(j):new_end %bin=rrcorr; ...
3793d9db1c449b04f1d1ec08c33498a2b479bfc620289877ca85628e1cf40027
MATLAB
760
20
function X = attenuate_spikes(X, win, min_peak_dist, min_peak_height) %NIRSPROC.ATTENUATE_SPIKES Heuristic spike squashing via derivative energy. % X = ATTENUATE_SPIKES(X, win, min_peak_dist, min_peak_height) if nargin<2, win=30; end if nargin<3, min_peak_dist=30; end if nargin<4, min_peak_height=0.02; end ...
479328559ea297e8ca0e56554b894d1aa0907627fe5b2982093df63fa8164339
MATLAB
760
31
function l = length(tree,r) % XMLTREE/LENGTH Length Method % FORMAT l = length(tree,r) % % tree - XMLTree object % r - 'real' if present, returns the real number of nodes in the % tree (deleted nodes aren't populated) % l - length of the XML tree (number of nodes) % % Return the number of nodes of an XML...
d01f604b30a09b0a9ce7df31e729d07de2716ee2f461bbb813d2e2de1c5e6ab0
MATLAB
760
23
function [filename,go] = LCN_check_filename(dir_data,template_string) % This script will check if we find uniquely a filename in a directory % dir_data using the template_string as search string. % If we find a unique file, this filename will be given as output. The % variable go is also an output which is 1 if we find...
d8ab4876f960bea01f9009eb3c037a2f785ef69ff749837dce901e94a8c35b61
MATLAB
760
31
function [handles, loadData] = dan_clear_data(handles) %% % Authors: Dan Denis % Date: 2021-07-14 %% if ~isempty(handles.psg.data) loadData = questdlg({'Clearing existing data. All unsaved progress will be lost', 'Do you want to continue?'},'Clear','Yes', 'No', 'Yes'); end if strcmp(loadData, 'Yes') ...
0afe478aaf392582b2e71782e60bce62db3f3b057a80cc3c258eef1f016a7afb
MATLAB
761
17
function indices = cifti_vox2ind(dims, voxlist1) %function indices = cifti_vox2ind(dims, voxlist1) % Convert a list of 1-based voxel indices to linear indices. % This function exists because matlab's sub2ind requires the % subscripts for each dimension to be separate arguments. % This is inc...
1fe5a5d07585de9dff978701cbe999ba5ef644abcc061a5fff3da04f46e834d8
MATLAB
762
19
function ea_run_HMS_Orchestra(options) % This is a function that runs code for each subject on a cluster. It needs % to be adapted to suit your needs. Then, you can "Export code" using % Lead-DBS and simply change the command ea_run to ea_run_cluster. jobFile = [options.root, options.patientname, filesep, 'job_', ea_...
37a7110a04291447b6eec9ab608a53b95f8817b7607e8b4e42ced7f9cabb33e7
MATLAB
763
22
function vv=rot3d_nf(vol,rang,itype,rtype) % Usage ... v=rot3d_nf(vol,rang,itype,rtype) % % rang is [x y z] in degrees (positive is CCW, rot2d_f is CW) % (based on imrotate; x=+elevates-left,y=+elevates-top) % itype is interpolation type -- default is linear % rtype is rotation option -- cropping is default ...
b49a9bb3aa37f850bd7fb6582224773173cfaf2476b8da58fa8bdae8f28cec01
MATLAB
763
19
function init(fname, nbytes, opts) % Initialise binary file on disk % FORMAT init(fname, nbytes[, opts]) % fname - filename % nbytes - data size {bytes} % opts - optional structure with fields: % .offset - file offset {bytes} [default: 0] % .wipe - overwrite exisiting values with 0 [default: false] % ...
0db26fe4100e36df38226633c08d5aaf85b03d50182442461f6b280fd23d33ed
MATLAB
764
29
function [m,jsd]=jackknife(x) % Compute jackknife estimates of the mean and standard deviation of input data x % Usage: [m,jsd]=jackknife(x) % % Inputs: % x : data in the form samples x trials % % Outputs: % m : estimate of the mean (across trials) % jsd: jackknife estimate of the standard deviation (across trials) [...
3191eacae3215c8f116636a1edea02f1b495277716f74fb4392b5ab72aa688f1
MATLAB
764
31
function [ PS1_cs ] = subfun_ProfileSimilarity( DataScan , DataBB ) %% profile similarity [N_region, N_layer] = size(DataBB); % delete the layer 1 (it's about 10% of cortical thickness) Num_Layer1 = max([1 round(N_layer/10)]); % compute cosine similarity PS1_cs = []; for k = 1:numel(DataScan) % Normalize each reg...
7c16ec96a8e126e3537149b6384292c371d36a7fac2be2c736bde12e8dc81693
MATLAB
764
30
function out = InsertDate(in) %InsertDate - Insert date into string. % % Replaces %y, %m, %d and %t with current year, month, day and time. % % USAGE % % out = InsertDate(in) % % in string to modify % Copyright (C) 2013 by Michaël Zugaro % % This program is free software; you can redistribute it an...
202709b3b456bdd96cb16e50dd3b52b484768bd4224302df9cd7df4fc370aba0
MATLAB
765
27
function [chosenfluor]=removemotion(chosenfluor,chosenred,thresholdstd,chosenframerate) %THIS FUNCTION REMOVES FROM EVERY FLY %TO DO A SINGLE FLY CALL THE HELPER RMmotion %remove any trial where the red channel is moving too much since in %practice this has not been something that is easy to correct. %go through each...
2a36a1e452067033a858191a13c6323ed77d8bfc025b021612a11c14e94c998b
MATLAB
765
23
function ACG = computeACG(theseSpikeTimes, ACGbinSize, ACGduration, plotThis) % Handle empty or insufficient spike times if isempty(theseSpikeTimes) || numel(theseSpikeTimes) < 2 halfBins = round(ACGduration/ACGbinSize/2); nBins = 2*halfBins+1; ACG = zeros(nBins, 1); return end [acg, ~] = bc.ep.helpers...
c9628dbfdc0df02843dab855e61520c19201147e661ba3919f85f474bd5c88f0
MATLAB
765
31
function mask = makeFixationMask( X , Y , origimgsize , salmapsize ) % % this maps (X,Y) fixation coordinates to fixation mask % % given fixation coordinates X and Y in original image coordinates, % produces mask of same size salmapsize where each location contains % an integer count of the fixations lying at that lo...
e76ea6675ba9a55cfc4b4579f4f6976c5d24a2fe90af7fedd2ba2e1601531afd
MATLAB
765
19
function ea_run_HMS_Orchestra_long(options) % This is a function that runs code for each subject on a cluster. It needs % to be adapted to suit your needs. Then, you can "Export code" using % Lead-DBS and simply change the command ea_run to ea_run_cluster. jobFile = [options.root, options.patientname, filesep, 'job_'...
2af5b11076823316ae9a98c4c5e58550739b053602fdaab7d1d9304f707aeb8b
MATLAB
766
31
function cvx_optval = lambda_max( x ) %LAMBDA_MAX Internal cvx version. narginchk(1,1); if ndims( x ) > 2 || size( x, 1 ) ~= size( x, 2 ), %#ok error( 'Input must be a square matrix.' ); elseif cvx_isconstant( x ), cvx_optval = cvx( lambda_max( cvx_constant( x ) ) ); elseif cvx_isaffine( x ), z = []; ...
431a096261dcbbc3b01366268e3551ead06362cd8e1e7cb47acf4e85d3a0f60a
MATLAB
766
40
function ip = inplace(a) % INPLACE Convert to a type that supports inplace modification % ipa = inplace(v) creates an inplace double object from any matrix v. % % Example: % ipa = inplace(ones(5)); if nargin == 0 error('inplace:invalidParameter', ['ipdouble must be created with an initial .']); elseif ...
4dae11eaec14c9173b5fad9b2bf589b8c36809cad475fddae61f76735568b4f2
MATLAB
766
19
function ea_run_HMS_Orchestra_max(options) % This is a function that runs code for each subject on a cluster. It needs % to be adapted to suit your needs. Then, you can "Export code" using % Lead-DBS and simply change the command ea_run to ea_run_cluster. jobFile = [options.root, options.patientname, filesep, 'job_',...
50f956f1eccc36b53a66b5a489ee9b838297c2d7e84d6177a7ccdaf5a4bf4f95
MATLAB
768
25
function ind = CBIG_MMLDA_find_cell_in_cell(source_cell, target_cell) % ind = CBIG_MMLDA_find_cell_in_cell(source_cell, target_cell) % % Find source cell array in target cell array and return the index in order. % % Input: % - source_cell : source cell array % - target_cell : target cell array % % Output: % ...
aedba77d66ef3cc37f68d3e5e72b32d48d84113952c7f9b41a92ff490017d8ba
MATLAB
768
16
function markers = leadingedges(data) %LEADINGEDGES Marks 0 -> NONZERO transitions along data columns. % EDGEMARKERS = LEADINGEDGES(DATA) takes an M x N matrix DATA and % returns a M x N matrix EDGEMARKERS, containing a '1' in each location % that corresponds to the first nonzero value in a DATA column follo...
dc55734d756b0bb871ccd700963d00f1f2ab8d20de08eaaf3d0d16efa311de3b
MATLAB
768
26
function F = isfield(tree,uid,parameter) % XMLTREE/ISFIELD Is parameter a field of tree{uid} ? % FORMAT F = isfield(tree,uid,parameter) % % tree - a tree % uid - uid of the element % parameter - a field of the root tree % F - 1 if present, 0 otherwise %________________________________________...
6cc9c8b694ca97a98b439ab8a6bb995748740cdd0bfde94d5054caf8d27f582e
MATLAB
769
39
function r = circ_dist2_abs(x,y) % % r = circ_dist(alpha, beta) % All pairwise difference x_i-y_j around the circle computed efficiently. % % Input: % alpha sample of linear random variable % beta sample of linear random variable % % Output: % r matrix with pairwise differences % % ...
9f1a1f771755d2760819ab7f5bfa156f80bccbb5ea7c5ea4e026844a8b81e610
MATLAB
769
19
function ea_run_HMS_Orchestra_medium(options) % This is a function that runs code for each subject on a cluster. It needs % to be adapted to suit your needs. Then, you can "Export code" using % Lead-DBS and simply change the command ea_run to ea_run_cluster. jobFile = [options.root, options.patientname, filesep, 'job...
e1c92a37f012d0bbcde12fab76919665b83dfe401aa218e3d43627697deea7b0
MATLAB
769
29
function threshold = ea_sfc_getautothresh(images) % Calculate thresholds for visualization in SufIce if ischar(images) images = {images}; end threshold = nan(length(images), 4); for f=1:length(images) nii = ea_load_nii(images{f}); nii.img(nii.img==0) = nan; imgstd = ea_nanstd(nii.img(:)); if min(...
2fdfe31b31b1ac197ae84e2fd5255710ca3f62309815e8bfb3a70a0290ce4741
MATLAB
770
30
function [P,T,L,r,centerX,cX]=classSVD(x) %CLASSSVD performs the singular value decomposition of a matrix with more % rows than columns (uses svd.m) % % Required input: % x : data matrix of size n by p where n>p % % This function is part of LIBRA: the Matlab Library for Robust Analysis, % available ...
483758298f4e7c010905e421c13c14570e5fdce6136cdb731f9df38f790aa019
MATLAB
771
23
function [PTbaseIDX,t] = baseIDXfromPTonset(framesPerTrace,frameRate,PTsOnset,trigDelay) if nargin==3 trigDelay = 0; end % t = 0:1/frameRate:framesPerTrace/frameRate-1/frameRate; t = 0+1/frameRate:1/frameRate:framesPerTrace/frameRate; PTonsetFromStart = trigDelay+PTsOnset; PTonsetIDX = find(t==PTonsetFromS...
c8ba876a81376fd54f215c923f2234307dab0eefc55d813518115c3d24d00747
MATLAB
772
35
function len = strlen(str) % len = strlen(str) % compute the # of characters in str (ignoring 0s at the end) % % strlen.m % % Original Author: Bruce Fischl % CVS Revision Info: % $Author: nicks $ % $Date: 2011/03/02 00:04:13 $ % $Revision: 1.3 $ % % Copyright © 2011 The General Hospital Corporation (Boston,...
f0a4f476e8d3c12167a3160edc2c34fbffb9a5814a4b5b0ff9669cd8a219b19c
MATLAB
772
41
% Demonstration of hierarchical model fits % % SF 2014 clear all close all Ntrials = 1000; Nsub = 10; c = 0; c1 = [-1.5 -1 -0.5]; c2 = [0.5 1 1.5]; group_d = 2; sigma = 0.5; noise = [1/3 2/3]; for i = 1:Nsub % Generate dprime d(i) = normrnd(group_d, sigma); % Generate data sim = type2_SDT_...
3c93ca99daf8eadc98d080abce2514423387da7036e8d3268405e04dab608f7c
MATLAB
774
28
function X = circle_graph_layout(G,radius) % CIRCLE_LAYOUT Layout the vertices of a graph on a circle % % X = circle_layout(G) generates a layout of graph with vertices uniformly % placed on the circle. This function does no interesting layout and just % places the vertices around the circle in order. % % X = circle_...
c79936aeafe51379e03dd845dc4f3c86da289a712451fa015c92a0920808aab5
MATLAB
775
20
function [TE] = calculate_TE(atoms, source_to_target) % Calculate Transfer Entropy based on atoms decomposition % TE(1→2) = Syn→Red + Syn→Un2 + Un1→Red + Un1→Un2 if source_to_target == "1to2" % Transfer Entropy from X1 to X2 TE = atoms.str + ... % Syn→Red atoms.sty +...
db46e5749eb7575ee0aabf0481c9035da34a75cfe866bca2aaf19b87e73d825e
MATLAB
775
12
%----------------------------------------------------------------------- % Job saved on 11-Apr-2016 11:34:23 by cfg_util (rev $Rev: 6460 $) % spm SPM - SPM12 (6470) % Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md %-------------------------------------------...
034d9ae6859a43cfd902162f851d23f14d357feb4c983aefcf5dec8045e9db31
MATLAB
776
28
function plotOnsetPDFAreas(allROIs) % Wrapper to plotMetricPDFAreas, for onset data % Offset Y axis slightly in post, no need to do so here % Plot areas = {'M2', 'M1', 'S1-fl', 'S1-hl', 'S1-tr'}; plotMetricPDFAreas(allROIs, 'onset', areas, cmapAreas5(), [-200 400]) % Format figure panelwidth = 2; panelheight = 1.25; ...
8b431aa1a461abad4bd0d1cad7243b49dfe5b022369dd43d6728a7ec95a9ce18
MATLAB
776
40
function ClusterNum = PermClusterInfo(PvalpermV0001Ct) for i = 1:length(PvalpermV0001Ct) Pvaltemps(i,1:length(PvalpermV0001Ct{i})) = PvalpermV0001Ct{i}; end AAA = Pvaltemps(Pvaltemps>0); BBB = unique(AAA); for i = 1:length(BBB) noaaa(i) = length(find(AAA==BBB(i))); end CCC = cumsum(noaaa)/sum(noaaa); inds = m...
aa9a8173671a9babeef41929a79129cbbececc5eeeeb62a4f8c2c8ce21dc0e94
MATLAB
776
40
function pval = circ_symtest(alpha) % % [pval, z] = circ_symtest(alpha,w) % Tests for symmetry about the median. % H0: the population is symmetrical around the median % HA: the population is not symmetrical around the median % % Input: % alpha sample of angles in radians % % Output: % pval p-value %...
c2bce6a7574703602b6992f4e2737a49da504769a290e00367be925c6dc34b93
MATLAB
776
25
function [cbar, clims] = SmartColorbar(clims, cmap_style) % finds the proper value for null data points to be plotted as white in an % IMAGESC plot, or similar. % % ARGUMENTS % clims (1x2 vector) either the range of the data, or the prefered range of the % colorbar % cmap_style stri...
703602044268e88e1c5f278bc8e68c8660e20300acb207a9f1679b0e1ad6e9d5
MATLAB
777
24
function dists = eucDists(X) % dists = eucDists(X) % % Pairwise Euclidean distances between columns, with no preprocessing. % The below works because linear algebra. I stole it from tsne.m (and % swapped the dimensions), but also checked the math. % It is much, much faster than the more obvious way to do this. I thin...
881d74381da6d3ce86ea00af49f5364542bba873c13c848d090e7bca388ee1d3
MATLAB
777
19
function inter=CheckPointsInsideTetrahedron(V,F_Local_new, Vertex_id) for j=1:size(F_Local_new,1) P1=V(F_Local_new(j,1),:); P2=V(F_Local_new(j,2),:); P3=V(F_Local_new(j,3),:); P4=V(Vertex_id,:); % Box around tetrahedron mi=[min([P1(1) P2(1) P3(1) P4(1)]) min([P1(2) P2(2) P3(2) P4...
85c59e1c88582c8fcedb78495c64a7968cd18f39e06d3ada5441951e7c5de6f4
MATLAB
778
28
classdef( Hidden, Sealed ) ChildEvent < event.EventData %uix.ChildEvent Event data for child event % % e = uix.ChildEvent(c) creates event data including the child c. % Copyright 2009-2015 The MathWorks, Inc. % $Revision: 1165 $ $Date: 2015-12-06 03:09:17 -0500 (Sun, 06 Dec 2015) $ ...
0324cb92d204cc20364b81f7253673850ca3b51c20f17b9260cddb10dee574ca
MATLAB
779
24
function eventsOut = dan_convert_csv_events(eventsIn) % This function converts an Excel, CSV events file into the correct format % for danalyzer %% % Authors: Dan Denis % Date: 2021-07-14 %% % Read in events table eventsTable = cellfun(@num2str,... table2cell(readtable(eventsIn, 'ReadVariableNames', 0)),... ...
7d5d80793e5eb7886cd601574515d7007eb71710bdccbee566968f8a47448153
MATLAB
779
21
function S = SANDImodel(p,x,delta, smalldel, Dsoma) Dis = Dsoma; fellipse = @(p,x) exp(-x.*p(2)).*sqrt(pi./(4.*x.*(p(1)-p(2)))).*erf(sqrt(x.*(p(1)-p(2)))); fstick = @(p,x) fellipse([p,0],x); fsphere = @(p,x) exp(-my_murdaycotts(delta,smalldel,p,Dis,x) ); fball = @(p,x) exp(-p.*x); %S = p(2).*fstick(p(3),x)...