sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
c213ab6ad78a64cc86f2de21cc024d79674b3c1abde72211a90cd531ffaeae70
MATLAB
779
35
function acqTag = ea_checkacq(pixdim) % check image acq tag (iso, ax, cor or sag) % Input can be the pixdim or the path of the image if ischar(pixdim) header = ea_fslhd(pixdim); pixdim = [header.pixdim1, header.pixdim2, header.pixdim3]; end if range(pixdim) < 0.05 acqTag = 'iso'; return; end [C,~, ic...
04cee57ba5cd03c553959589029adf256a3aa613e6c44dd92128200cedb448c7
MATLAB
780
26
function potential_outliers = canlab_simple_find_outliers(DATA_OBJ, condition_names) % potential_outliers = canlab_simple_find_outliers(DATA_OBJ) % % Get outliers based on mahalanobis distance for each condition and print a short report % % e.g., potential_outliers = canlab_simple_find_outliers(DATA_OBJ, DAT.conditions...
10672b4c756be458d7bd2b0f81f946a669d6e6496f643488f2b4f7980c98ded2
MATLAB
780
23
function ea_init_coregctpopup(handles, defaultmethod, handlestring) % Initialize CT coregistration methods popupmenu. % Set coregctmethod popupmenu by default % In checkreg window, we need to set coregmrmethod popupmenu if ~exist('handlestring','var') handlestring = 'coregctmethod'; end % Get functions and names ...
8a6152694acc3a841a958c78c9a5d4bb5f96b1905c11cf14a6f522fecedc7950
MATLAB
780
35
function y = transpose( x ) % Disciplined convex/geometric programming information for TRANSPOSE: % The transpose operation may be applied to CVX variables without % restriction. % % Determine permutation % s = x.size_; if length( s ) > 2, error( 'Transpose of an ND array is not defined.' ); end % %...
9667de3d6ed6246d3c754c52b642d804be808a5de1f2da3ce3e19468e411d7c5
MATLAB
780
30
function X=ar1noise(n,c,g,a) % AR1NOISE - Generate zero-mean red noise. % Syntax: X=ar1noise(n,c,g,a); % % Inputs: n - desired length of time series % c - number of time series to generate % g - lag-1 autocorrelation % a - noise innovation variance parameter % % Output: X - n by c ma...
aad41d539974392a866e1d9b1c1dccc17ae4035fc28e8b6074ed8d122787b73b
MATLAB
781
34
%sz - Show sizes for any number of variables. % % USAGE % % sz(x,y,...) % % x,y,... variables % % Copyright (C) 2011-2012 by Michaël Zugaro % % 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 F...
bcc2d0f6eb2ca33907c189e7566f5c6ce204f174e81f7cab865245ed0d631f84
MATLAB
781
26
classdef ( Hidden, Sealed ) FigureData < event.EventData %uix.FigureData Event data for FigureChanged on uix.FigureObserver % Copyright 2014-2015 The MathWorks, Inc. % $Revision: 1435 $ $Date: 2016-11-17 17:50:34 +0000 (Thu, 17 Nov 2016) $ properties( SetAccess = private ) OldFigure...
47d0e5b8e3521ebde4a3c8cd31c8f91d8fcc16e89f4751adc6decb44821ac3e4
MATLAB
782
20
% List of open inputs % Apply deformations (many subjects): Deformation Field - cfg_files % Apply deformations (many subjects): Images - cfg_files % Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md addpath(spm_dir) disp(deformation_field) disp(image_path) nru...
adc3d6a99211160c859b9a78ff31b57a261e8fa1d98bcc314f93f39ea88965c0
MATLAB
782
20
opts = struct(); opts.spm_dir = 'PATH_TO_SPM12'; opts.max_runs_per_task = 1; opts.echo_preference = []; opts.vox = [3 3 3]; opts.skip_if_w_exists = true; opts.write_tsv_confounds = true; opts.verbose = true; bids_root = 'PATH_TO_DATASET'; subj_list = {'sub-03','sub-04','sub-05','sub-06','sub-07','sub-08','su...
bb38122327d1fc97823f1b45129c965e78184399d0743db35fd8b61ac496655f
MATLAB
782
32
function [n, freqs] = plx_adchan_freqs(filename) % plx_adchan_freq(filename): read the per-channel frequencies for analog channels from a .plx or .pl2 file % % [n, freqs] = plx_adchan_freq(filename) % % INPUT: % filename - if empty string, will use File Open dialog % % OUTPUT: % freqs - array of frequencie...
e90ce0a7f8913a03b73db451e7d29ceb8e7fec2cf73309fbb24fb895095d665b
MATLAB
783
26
function Vind=make_left_vertice_list(V,F,nF,Options) % Make list with all vertices which have not collapsed yet Vind=unique(F(1:nF,:)); %sortvalue=zeros(size(Vind)); % for i=1:length(Vind) % % Get Neighbours % ne=unique(F(any(F(1:nF,:)==Vind(i),2),:)); % Vne= V(ne,:); % % dx=repmat(Vne(...
376abc4b28f8089ec0bd031da98cc4fa3e067040d685b3f5e3aeaceadb988396
MATLAB
784
36
load('XYZV'); for save=1:500 for iter=1:2 dat=XYZV; if iter<2 dat(:,4)=dat(randperm(length(dat)),4); end Peuc=squareform(ea_pdist(dat(:,1:3))); % distance matrix Pval=squareform(ea_pdist(dat(:,4))); % distance matrix % exp Peuc(logical(eye(size(Peuc,1))))=1./exp(Peuc(logical(eye(size(Peuc,1))...
8955c0dfb5e1d24c9b2bcb4f863ed0b28a42a57a3d647f4a833d7ca073b0328f
MATLAB
784
19
function outlength = cifti_diminfo_length(diminfo) %recompute length from diminfo contents, in case .length is wrong switch diminfo.type case 'dense' modelends = zeros(length(diminfo.models), 1); for i = 1:length(diminfo.models) modelends(i) = diminfo.models{i}.st...
a9a57db62a7130372efe0ad01c98abe09e44c79ee7cc4747af006e859d1225b2
MATLAB
784
31
function ea_fix_runtimepath % In some installation, MATLAB run-time library path might be missing in % the environment variable. This function will fix it when needed. % The path is neccesary to run some binaries. runtimePath = {fullfile(matlabroot,'bin',ea_getarch)}; if ispc envname = 'PATH'; else if ismac ...
abb66ad8cda102eadf9ec3e075befb4ab820ac713c6f580fab49fbdcaf3c93cb
MATLAB
785
27
function betas = fit_glm(Y, X, Fs, opts) %GLMPROC.FIT_GLM AR-IRLS GLM fit for multichannel time series. % betas = GLMPROC.FIT_GLM(Y, X, Fs, opts) % % Inputs % Y : T×M matrix (time × channels) % X : T×p design matrix % Fs : sampling rate (Hz) % opts : struct with field % .Pmax...
b1697b8fa402a030a683001dd5d3baa8411f6e3db0744cc2fbfa77809db35f10
MATLAB
785
30
function [xx,yc]=mydftreg_1d(im,refim,parms) % Usage ... [x,imc]=mydftreg_1d(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>...
26a9dded719e2802442cc3c6b3eaf43fc2c67ef31ca33f1cbe0925e2a3f8eb64
MATLAB
786
33
function s=mergestruct(s1,s2) % % s=mergestruct(s1,s2) % % merge two struct objects into one % % authors:Qianqian Fang (q.fang <at> neu.edu) % date: 2012/12/22 % % input: % s1,s2: a struct object, s1 and s2 can not be arrays % % output: % s: the merged struct object. fields in s1 and s2 will be combined in s....
83cf6e5f447fcb463313b06de38387eb20ed5230b2e571cb75de7d0f718575cd
MATLAB
786
22
function tree = move(tree,uida, uidb) % XMLTREE/MOVE Move (move a subtree inside a tree from A to B) % % tree - XMLTree object % uida - initial position of the subtree % uidb - parent of the final position of the subtree %__________________________________________________________________________ % % Move a subtr...
f644a0745ec3446f42f4325dc3fcbb7276304e6d3e0e0751179abf7f971a8c0a
MATLAB
786
19
opts = struct(); opts.spm_dir = 'PATH_TO_SPM12'; opts.max_runs_per_task = 1; opts.echo_preference = []; opts.vox = [3 3 3]; opts.skip_if_w_exists = true; opts.write_tsv_confounds = true; opts.verbose = true; bids_root = 'PATH_TO_DATASET'; subj_list = {'sub-01','sub-02','sub-03','sub-04','sub-05','sub-06','su...
ffb94c6f51177dfbfc0e66731288311d6c5f060fab8f2c7f879468b337639755
MATLAB
786
31
function [ PS1_cs ] = subfun_ProfileSimilarity_mri2mri( DataScan , DataScan2 ) %% profile similarity [N_region, N_layer] = size(DataScan{1}); % 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) % No...
187dedc1733e64e1e8de917b6994e2e220ed5ac2688f404fe9f812af9e45a10a
MATLAB
787
8
function W = construct_weights(regular_grid,extended_grid) xx = [linspace(1/(regular_grid(1)-extended_grid(1)+1),1,regular_grid(1)-extended_grid(1)),ones(1,regular_grid(2)-regular_grid(1)+1),fliplr(linspace(1/(extended_grid(2)-regular_grid(2)+1),1,extended_grid(2)-regular_grid(2)))]; yy = [linspace(1/(regular_grid(3)-...
dcb0a44f4beb616d0222e0939083730c294a280cba29dcc3fc189adf26e4a5de
MATLAB
787
22
function GCO_SetLabeling(Handle,Labeling) % GCO_SetLabeling Sets the current labeling % GCO_SetLabeling(Handle,Labeling) sets the entire labeling. GCO_LoadLib(); if (isnumeric(Labeling)) NumSites = gco_matlab('gco_getnumsites',Handle); NumLabels = gco_matlab('gco_getnumlabels',Handle); if (...
d84ee046c5f11ecee82c1689d7c9e7359902dcaa8f367051bb31d81075551528
MATLAB
788
44
function im=readlsm(fname,imno,chName) % Usage ... function im=readlsm(fname,imno,chName) if nargin<3, ch_flag=0; else, ch_flag=1; end; if nargin<2, imno=1; end; if isstr(imno), found=0; cnt=1; tmpim=0; while(~found), tmpstk=tiffread2c(fname,cnt); if isempty(tmpstk), found=1; else, ...
440737b92d21378bc2ae685dd7f731622646cd94e3c326217c9c545eb5de5345
MATLAB
789
19
function errmsg = printf(format,varargin) %PRINTF Macro to display formatted text. % PRINTF(FORMAT,A,...) is equivalent to DISP(SPRINTF(FORMAT,A,...)), % displaying formatted text to the Matlab prompt. Thus, e.g., % % PRINTF('repeat %d.', 1); % DISP(SPRINTF('repeat %d.', 1)); % ...
5fdb4e6ade9ee995e404ff6537989aa4cfac7bbd6c589f4d4bbf9c82ac8de9e6
MATLAB
789
38
function dreg = register_movie(data, ops, ds) orig_class = ops.RawPrecision; % orig_class = class(data); if ops.useGPU reset(gpuDevice); data = gpuArray(single(data)); end [Ly, Lx, NT] = size(data); Ny = ifftshift([-fix(Ly/2):ceil(Ly/2)-1]); Nx = ifftshift([-fix(Lx/2):ceil(Lx/2)-1]); [Nx,Ny] = meshgrid(Nx,Ny...
801b0f3c00d5003df2e34203e3af5243702d45a843d16ac4861d12200f11684e
MATLAB
789
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: % pva...
b17c854cb8a501b1a753976666cb984bcd3cf05461fdc7d6c7f8c74624f90d5a
MATLAB
790
25
% SETTINGS % % This variable holds all settings for FMAToolbox. % % Type 'SETTINGS' to display the default values, or 'edit Settings' to change them. % Copyright (C) 2004-2009 by Michaël Zugaro % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public Licen...
6ed20449a94f02cd22da7944ff36862c41e2e53a5558271687153d5c7f30ecee
MATLAB
791
29
function rawAmplitude_uV = getRawAmplitude(rawWaveforms, peakChan, scalingFactors) % JF, Get the amplitude of the mean raw waveform for a unit % ------ % Inputs % ------ % rawWaveforms: nTimePoints × 1 double vector of the mean raw waveform % for one unit in mV % peakChan : % scalingFactors : % ------ % Outputs % -...
b9f930bc8839f9ba94e0bd7d13fd0d6d33824725f0beab02831bb55391ddde39
MATLAB
791
37
function y=twop_imfilt(x,mfp,smp) % Usage ... y=twop_imfilt(x,mfp,smp) if ~exist('mfp','var'), mfp=[]; end; if ~exist('smp','var'), smp=[]; end; if isempty(mfp), mfp=0; end; if isempty(smp), smp=0; end; xdim=size(x); if length(mfp)==1; mfp=[mfp mfp]; end; if nargout==0, if length(xdim)==4, x=x(:,:,:,...
e4da1054deaf59599317f73d6e02fab889029dd548246f6b4cbf2c6265657e76
MATLAB
791
26
%% load allflies from an `img&beh` mat file thing = []; count=1; for f = 1:7 A = allflies([allflies.flyID]==f); figure; for a = 1:length(A) subplot(6,7,a); plot(A(a).flightstates_corr); ylim([-1 9]) title(int2str(a)); end trial = input('which trial?'); start = inpu...
ea50c6b7d6133d82fd645c813c7e18a06083e9c6c62e1825dcebf43703d3af54
MATLAB
791
26
function info = getinfo(vw) %INFO=GETINFO(VW) % Returns a structure whose fields contain information about the opened % video object. This structure may be flattened to a cell array and used % with the videoWriter constructor to recreate the current video file. % %SEE ALSO % videoWriter % %Copyright (c) 2006 Gera...
3a9974ca73c7b8c39cd7638ebd20c07fc54ec66ebde0664ed1af15e6dc4de3bd
MATLAB
792
19
function errmsg = printf(format,varargin) %PRINTF Macro to display formatted text. % PRINTF(FORMAT,A,...) is equivalent to DISP(SPRINTF(FORMAT,A,...)), % displaying formatted text to the Matlab prompt. Thus, e.g., % % PRINTF('repeat %d.', 1); % DISP(SPRINTF('repeat %d.', 1)); % ...
bca04beddc8ed8570cabd7387a5c70eb4324e2117fa1c8c05103e4cac419c268
MATLAB
792
21
function scoresOUT = updatestages(scoresIN, srate, epochLength) % Update a sleepstages struct %% % Authors: Dan Denis % Date: 2021-07-14 %% epochSampleIdx = indexepochs(epochLength * srate, (length(scoresIN.stages) * epochLength) * srate); epochSecIdx = indexepochs(epochLength, (length(scoresIN.stages) * ...
f7da7f8e37cda4602d64abafee2dad86727787539cd88431a09a7ec6dec5bb84
MATLAB
792
30
function [retval] = fd3(fid) % [retval] = fd3(fid) % read a 3 byte integer out of a file % % fread3.m % % Original Author: Bruce Fischl % CVS Revision Info: % $Author: nicks $ % $Date: 2011/03/02 00:04:12 $ % $Revision: 1.3 $ % % Copyright © 2011 The General Hospital Corporation (Boston, MA) "MGH" % % Terms ...
215e95dafd94e5b02851c51a04690383ac54831b55e2c35c44e81c78e5af3b5c
MATLAB
793
30
function [newnode,newelem]=removedupnodes(node,elem,tol) % % [newnode,newelem]=removedupnodes(node,elem) % % removing the duplicated nodes from a mesh % % author: Qianqian Fang <fangq at nmr.mgh.harvard.edu> % % input: % elem: integer array with dimensions of NE x 4, each row contains % the indices of all the...
bf654c80b48d002367ad1473d278440a1fc9554d54d1eb07f2f1cd40fe494e5a
MATLAB
793
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 t...
fd2592f4076abffd5c4bfed07658cb2f736311587baf2ad0ccdc825d3d5ac4ec
MATLAB
793
29
% Exercise 4.38(b): Linear matrix inequalities with one variable % From Boyd & Vandenberghe, "Convex Optimization" % Joëlle Skaf - 09/26/05 % % Finds the optimal t that would maximize c*t while still having A - t*B % positive semidefinite by solving the following SDP: % minimize c*t % s.t. ...
1944f5c1c325a49c93dffd434f605ce22dfb169139ed1ecfbc06af7e37fa98b8
MATLAB
794
8
function W = construct_weights(regular_grid,extended_grid) xx = [linspace(1/(regular_grid(1)-extended_grid(1)+1),1,regular_grid(1)-extended_grid(1)),ones(1,regular_grid(2)-regular_grid(1)+1),fliplr(linspace(1/(extended_grid(2)-regular_grid(2)+1),1,extended_grid(2)-regular_grid(2)))]; yy = [linspace(1/(regular_grid(...
b6ea5ea9d960513ae590e97906a5a274ea2d0ef79fc0eecf9ad686c139cdb67b
MATLAB
794
28
function T = tree_from_pred(pred) % TREE_FROM_PRED Convert a predecessor array into a tree % % T = tree_from_pred(pred) returns the predecessor array as an % unweighted adjacency matrix % pred(i) = 0 if vertex i is a source vertex u, % pred(i) = 0 if vertex i has no predecessor associated with it, or % pred(i) ...
3fe65b6a6ed88f31fbca529d7dfe64a13b9824338cdd0cead9609b65681dd428
MATLAB
795
34
function [intersect FV]=CheckMeshInterSections(V,F,nMax,findall) FV=[]; nF=size(F,1); if((nargin<3)||isempty(nMax)) nMax=nF-1; else nMax=min(nMax,nF-1); end if(nargin<4) findall=false; end FV.vertices=V; intersect=false; k=1; for j=1:nMax O1=V(F(j,1),:); O2=V(F(j,2),:); O3=V(F(j,3),:);...
93fb95fbb27ea923f86ed654d9d75c7e7885e9cc7f0b6656217494226211c56a
MATLAB
795
40
function dreg = translate_ROImask(data, ds, ops) if nargin<3 ops.useGPU = 0; end orig_class = class(data); if ops.useGPU reset(gpuDevice); data = gpuArray(single(data)); end [Ly, Lx, NT] = size(data); Ny = ifftshift([-fix(Ly/2):ceil(Ly/2)-1]); Nx = ifftshift([-fix(Lx/2):ceil(Lx/2)-1]); [Nx,Ny] = meshgrid...
bf3b6dc582184763c016cd33be62fa15f2b75e6d6d6606e27129a80afee5d28a
MATLAB
795
20
%% Multi-level kernel density (MKDA) meta-analysis example: Agency database % The starting point for coordinate-based meta-analysis (CBMA) is a text file % with the information entered from published studies. In this example, the % information is contained in the file "Agency_meta_analysis_database.txt" % It is in th...
4fdfc03f29dde06a35712dd174d1d8085fc2340a83b2f898fc4aabdc72b35ac1
MATLAB
798
20
function ea_gen_models(uipatdirs,typemap,regressor,fdmri,fis) load([ea_getearoot,'predict',filesep,'models',filesep,'horn2017_AoN',filesep,'modeldata.mat']); % here only needed to get a mask odir=[fileparts(uipatdirs{1}),filesep,'predictive_model',filesep]; if ~exist(odir,'dir') mkdir(odir); end for pat=0 opa...
527ccd10c72799dcf378158ee279e78ae0f069b5e3dd0d5dd238e94dfa62152d
MATLAB
798
35
% makegausslpfir Gaussian LP filter % % win = makegausslpfir( Fc, Fs, s ) % % Fc corner frequency [Hz] % Fs sampling frequency [Hz] % s support [SD], minimum 3, default 4 % % win fir % % see also firfilter % 02-oct-13 ES function gwin = makegausslpfir( Fc, Fs, s ) nargs = nargin; if nargs < 1 || ...
b2f0cfbbf1d520b2a6c37085db9c12e55bfd6ea23eb96711eb32e91a0303d697
MATLAB
798
37
function cb = colorbar_range( clim ); %Sets the colour limits for SurfStatView. % % Usage: cb = colorbar_range( clim ); % % clim = [min, max] values of data for colour limits. % % cb = handle to new colorbar. a=get(gcf,'Children'); k=0; for i=1:length(a) tag=get(a(i),'Tag'); if strcmp(tag,'Col...
f9e048848f05d5fe86d8c6239a42d614d575dbe9c9db615de5d0dcd5bdab71bb
MATLAB
798
19
function ea_prepare_hardi(options,redo) % build HARDI in new way: if ~exist([options.root,options.patientname,filesep,options.prefs.HARDI],'file') || redo; hr=ea_DPS_nifti_to_hardi([options.root,options.patientname,filesep,options.prefs.dti],... [options.root,options.patientname,filesep,options.pr...
007358fc65ee9200af803460a0af37474b7cfa76af86f892dc8dc02d13613921
MATLAB
799
24
function Mask(input_brain_path) % Hardcoded mask image path mask_path = 'data/masks/BrainMask.nii.gz'; % Load the brain image and its header brain_nii = load_nii(input_brain_path); brain_image = brain_nii.img; brain_image(isnan(brain_image)) = 0; % Load the mask image and its ...
9d7b5ef33c44c9a6996e700b9fcce7ae55db5f9fe17b588bfca69ac746dc4b97
MATLAB
799
24
% sample script to create volumetric mesh from % multiple levelsets of a binary segmented head image. % % Author: Qianqian Fang <fangq at nmr.mgh.harvard.edu> % load iso2mesh image img=imread('iso2mesh_bar.tif'); img=fliplr(img); fullimg=repmat(1-img,[1,1,30]); fullimg(:,:,31:60)=repmat(ones(size(img)),[1,1,30]); %...
e648d44689a93f88750f3d1588cbab649c4edfcfddbd275cb88cf4d6029f6896
MATLAB
799
28
% Create compact overlay and add gray/CSF and mean data figtitle = 'slices showing coverage'; create_figure(figtitle); axis off o2 = canlab_results_fmridisplay([], 'multirow', 2); o2 = addblobs(o2, region(fmri_data(which('gray_matter_mask_sparse.img'))), 'outline', 'color', 'r', 'wh_montage', [1:2]); o2 = addblobs(...
5a2f6b80167c03d31430776521dddccad96af7abbb4f39c16886e80090302f01
MATLAB
800
37
function coordinate = mni2cor(mni, T) % function coordinate = mni2cor(mni, T) % convert mni coordinate to matrix coordinate % % mni: a Nx3 matrix of mni coordinate % T: (optional) transform matrix % coordinate is the returned coordinate in matrix % % caution: if T is not specified, we use: % T = ... % [-4 0 ...
76401a7e0ff6cc9742cd15ac3062fbb607466a07fe03aa07253a6e3ddbf142c1
MATLAB
800
28
function [outR, outID] = makeBayesWeightedCorr1(Pr, bID, varargin) %function [outR, outID] = makeBayesWeightedCorr1(Pr, bID, preComputedQ (optional)) outID = unique(bID); h = histc(bID, outID); if isempty(varargin) Q = makeQForWeightedCorr(h, size(Pr, 2)); else Q = varargin{1}; end outR = zeros(length(outID),...
8be9a0e9aa7faae13ea6e7200ba01ff8b827fabc146d0ab970288a1c45355153
MATLAB
800
37
function varargout = dim(varargin) % Format % For getting the value % dat = dim(obj) % % For setting the value % obj = dim(obj,dat) % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: dim.m 1143 2008-02-07 19:33:33Z spm $ if n...
e9e1d0b02e7b27ee3c531c82fa83e7fadb8025d3809a0b23e37107ce46d7dfd4
MATLAB
800
33
function b = padImageOld( a , vpad , hpad ) if ( nargin == 2 ) hpad = vpad; end if ( (size(a,1) > (2*vpad)) && (size(a,2) > (2*hpad)) ) u = a(vpad:-1:1,:); b = a(end:-1:end-vpad+1,:); l = a(:,hpad:-1:1); r = a(:,end:-1:end-hpad+1); ul = a(vpad:-1:1,hpad:-1:1); ur = a(vpad:-1:1,end:-1:end-hpad+1); ...
061f3a274969765be6c0fc5463303051c96ac5cdf700418035c79f8e31939c03
MATLAB
801
24
function [AllX] = ea_networkmapping_recalcvals_sk(obj,sk) AllX=obj.results.(ea_conn2connid(obj.connectome)).connval; td=ea_getleadtempdir; % get nifti space switch size(AllX,2) case 902629 % 222 space=ea_load_nii(fullfile(ea_getearoot,'templates','spacedefinitions','222.nii.gz')); case 7221032 % 111 ...
2d1b81baf6f9711852f557c0dcaa0a067e8f100ec621808394ae5995054af397
MATLAB
801
34
function [transform] = pos2transform(pos, dim) % POS2TRANSFORM reconstructs a transformation matrix from an ordered list % of positions. % % Use as % [transform] = pos2transform(pos, dim) where pos is an ordered list of positions % and should specify a full 3D volume % % The output transform is a 4x4 homogenous tr...
36bd1e3f1595f3c0002dd201211d9d91f8d5d6563cbf5e6faa9a882f442c6429
MATLAB
802
30
function beta = CalcReorientAngle(vtheta, moves_indx) %CALCREORIENTANGLE % Usage: beta = CalcReorientAngle(vtheta, moves_indx) % % This function calculates the reorientation angle, or the change in angle % of progression after the fly stops. The inputs are the angle of the % velocity vector, vtheta, and an index ...
1b73e134b7cd9773568c49216cf1b8d927f8fbf73e6c96a530f30f5236eb09cb
MATLAB
803
26
function ks = ksstat(x,y) % ks = ksstat(x,y) % Computes the two-sample Kolmogorov-Smirnov statistic. % x & y are two independent groups. % ks is the maximum of the absolute differences between the two empirical % cumulative distribution functions (CDF). % % No p value is returned. % % Based on Rand Wilcox's ks & ecdf R...
66721deaf2aa324421ed85172382ef2be5db992cb44c103542fec29b673b461f
MATLAB
803
35
function y = ctranspose( x ) %Disciplined convex/geometric programming information for CTRANSPOSE (.): % The complex conjugate transpose operation may be applied to CVX % variables without restriction. % % Determine permutation % s = x.size_; if length( s ) > 2, error( 'Transpose of an ND array is not define...
96df02f344c114ce99429846166c61ce832233ba72fb6bcae30ea013ece7813a
MATLAB
803
29
function [seedsurf]=ea_showseedpatch(resultfig,pV,sX,options) set(0,'CurrentFigure',resultfig) bb=[1,1,1;size(sX)]; bb=ea_vox2mm(bb,pV.mat); gv=cell(3,1); for dim=1:3 gv{dim}=linspace(bb(1,dim),bb(2,dim),size(sX,dim)); end [X,Y,Z]=meshgrid(gv{1},gv{2},gv{3}); fvs=isosurface(X,Y,Z,permute(sX,[2,1,3]),0.5); % seed...
ff06e3dfa20c422a542632e2baa5f311e36273df881696ba7cd15478a3d23841
MATLAB
803
26
function err=dimacserrors(At,b,c,K,x,y) %Compute the DIMACS error measures for a given solution in SeDuMi format %Reload the original coefficients if ~isfield(K,'f') K.f=0; end s=c-At*sparse(y); %To make s sparse cx=sum(c.*x); %faster than c'*x by=sum(b.*y); xs=sum(x.*s); normb=norm(b,1); normc=norm(c,...
0eebc40ed009bfb77a361aba5a5846ca77976c9ba537b3f49d03ed2ddff6ce13
MATLAB
804
37
function y3=volbin(x,bsize) % Usage y=volbin(x,binsize) if bsize==1; y2=x; if nargout==0, show(y2), clear y2, end; return; end if length(bsize)==1, bsize=[bsize bsize bsize]; elseif length(bsize)==2, bsize=[bsize 1]; end; imdim=size(x); iend1=floor(imdim(1)/bsize(1))*(bsize(1)); iend2=flo...
e6e2a1bca38477794bd4fcf046c66284a1823e50ec94544b200e457f0fde1164
MATLAB
804
38
function [ts, data] = dacq_inp(fname) %% Header fid = fopen(fname,'r','b'); fseek(fid,0,-1); for i = 1:15 header{i} = fgetl(fid); end timebase = str2num(header{10}(10:end-3)); numPackets = str2num(header{15}(17:end)); % "datastart" for i = 1:10 fread(fid,1,'uint8=>char'); end dataStart = ftell(fid); %% Each ...
57f5b869ce55ae19bdb258a4f4dbf7780cf39b0d0501fadd093a5a5f51fb64fa
MATLAB
805
30
function [n, samplecounts] = plx_adchan_samplecounts(filename) % plx_adchan_samplecounts(filename): read the per-channel sample counts for analog channels from a .plx or .pl2 file % % [n, samplecounts] = plx_adchan_samplecounts(filename) % % INPUT: % filename - if empty string, will use File Open dialog % % O...
741db91d64bd709a00de32a23350cf9916297dd0c358bbc62055bbb80da9123c
MATLAB
805
30
function [arc, kymo_cordinate] = line_expand(cspoints, linewidth, arc_grad) [dC] = diff(cspoints,1,2); arc = cumsum(sqrt(sum([zeros(2,1) dC].^2,1))); dC = [dC(:,1) dC]; normC = sqrt(sum(dC.^2,1)); dC = dC./repmat(normC,[2 1]); if nargin<3 arc_grad = length(arc); end arc_cord = linspace(0, floor(max(arc)), arc_gr...
83358dc1656318007496bf5da2098000d639fe596e570fd2d5485ce49d099140
MATLAB
805
32
function k = anglediff(varargin) % Finds angular difference between two vectors p = inputParser; p.addRequired('A',@isnumeric); p.addOptional('B',NaN,@isnumeric); p.addParamValue('r',pi,@(x)isnumeric(x)&&((isscalar(x)&&x>0)||(numel(x)==2&&x(2)>x(1)))); if nargin==3&&~any(cellfun(@(x)isequal(x,'r...
8638c9051dc79a6c72e61f75cb178fb2dda5e6c5448fa315d482f7e1aea3f518
MATLAB
807
29
function gw = gridWidth(self,cel) % Returns the diameter of the grid field % based on the center peak in the % spatial autocorrelogram. Width is in PIXELS (divide by 2 to get spatial % rather than autocorr spatial) % % Methods from: % Anisotropic encoding of three-dimensional space by place cells and grid % cells. Heym...
8e5a5258b2a0e8a1ad21535019975debd6396fb059add3ac2a1f9186d3e67b37
MATLAB
807
36
function resimg=fillholes3d(img,maxgap) % % resimg=fillholes3d(img,maxgap) % % close a 3D image with the speicified gap size and then fill the holes % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % img: a 3D binary image % maxgap: maximum gap size for image closing % % output: % resimg: the image f...
d271659a378175a53d1f666a7579eb0beaa2ae964b678ee7c5130bf935214da6
MATLAB
807
26
function bz_EditAnimalMetadata(basepath) %% Initial variable parsing if ~exist('basepath','var') basepath = cd; elseif isempty(basepath) basepath = cd; end basename = bz_BasenameFromBasepath(basepath); %% Value setting - humans must do this. Will be asked to edit a _NoteText.m file notesname = [basename,'_An...
4351c5ca98e06cdc97d4f7fc81e65a9576a4a2fc8d70c4162407cb3296044319
MATLAB
808
32
function [n,thresholds] = plx_chan_thresholds(filename) % plx_chan_thresholds(filename): read channel thresholds from a .plx or .pl2 file % % [n,thresholds] = plx_chan_thresholds(filename) % % INPUT: % filename - if empty string, will use File Open dialog % % OUTPUT: % thresholds - array of tresholds, expr...
b595fb476d896593c8c7409b69fb6bfae4c99d55a2f81fbe9215889579a90bf0
MATLAB
808
22
function tree = move(tree,uida, uidb) % XMLTREE/MOVE Move (move a subtree inside a tree from A to B) % % tree - XMLTree object % uida - initial position of the subtree % uidb - parent of the final position of the subtree %__________________________________________________________________________ % % Move...
7b7b3a89741354dd07417e8074e589f4e931b2a3f4bf67d09764372fdb7ae4e7
MATLAB
809
34
function vol=thickenbinvol(vol,layer) % % vol=thickenbinvol(vol,layer) % % thickening a binary volume by a given pixel width % this is similar to bwmorph(vol,'thicken',3) except % this does it in 3d and only does thickening for % non-zero elements (and hopefully faster) % % author: Qianqian Fang, <q.fang at neu.edu> ...
0103424a249e57b1b231b26865465192dee4143da5c6eab357f6b06847b0babe
MATLAB
810
22
function y = han(x,frac) % apply a hamming window to signal x of length x*(1+frac). % equivalent to zero-padding, windowing and then truncating. if nargin < 2 || isempty(frac) frac = 0.5; end if isinf(frac); y = x; else sx = size(x); h1 = hamming(sx(1) ...
a07b59e498cc274c68bafbd03435bf8b54cda7e5896bcf03a4e3dbc73efca108
MATLAB
810
22
function [HbO_thr, HbR_thr, thres_HbO, thres_HbR] = threshold_predictions(meas_HbO, meas_HbR, all_HbO_pred, all_HbR_pred, alpha) %THRESHOLD_PREDICTIONS t-test across subjects + align with measured masks. % [HbO_thr, HbR_thr, thres_HbO, thres_HbR] = THRESHOLD_PREDICTIONS(...) if nargin<5 || isempty(alpha), alpha ...
f875d3099f2e2271f46bbfcfa2a8728f35c1542af1910b640002cbe8edb7f05b
MATLAB
810
28
function allROIs = getLogProbsSubpopGMMs(allROIs, metricField, models) % Computes log probabilities for all neurons under the GMMs for each subpop % using all GMM components % Get metrics for all neurons switch metricField case 'PCs' metrics = cat(1, allROIs.PCs); case 'rotPCs' metrics = cat(1,...
41be6d354c613c330fe95b9c3de0741f8380c81e9d27815de3236f3b910e4bc0
MATLAB
811
29
function val=getoptkey(key,default,varargin) % % val=getoptkey(key,default,opt) % or % val=getoptkey(key,default,'key1',val1,'key2',val2, ...) % % query the value of a key from a structure or a list of key/value pairs % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % key: a string name for the target str...
7095094a2896d7cc61b9f50a621f546f90a30188ceaca29b7d475a87b589e654
MATLAB
811
29
function [out filenames] = AF_OF_importer(varargin) % to make a struct (out) of all trial metadata in an experiment % and their names % works like this: % [data, filenames] = rotoball_importer('210619','f3e2','210619','f3e4') n = 1; for i = 2:2:length(varargin) refs(n).date = varargin{i-1}; refs(n)....
7ef75f20cee8599471a9ceffe05de52744a6530a677c2411eb732cb74efd677d
MATLAB
811
23
function AUC = quickCV_PLSDA(X, Y, C, opts) % quickCV_PLSDA Fast tuned cross-validated ROC AUC for PLS-DA. % % AUC = quickCV_PLSDA(X, Y, C, opts) % % Thin wrapper over quickCV_PLSDA_core with metric 'roc'. Used by the % permutation, learning-curve and matched-observed stages of % PLSDA_neuroimaging_pipeline. %...
fd472afcc4b2a28a0d1641249d24505812dcea23f8401a2525bec28c30d57db7
MATLAB
811
30
%%****************************************************** %% randmat: generate an mxn matrix using matlab's %% rand or randn functions using state = k. %% %%****************************************************** function v = randmat(m,n,k,randtype) try s = rng; rng(k); if strcmp(randtype,...
a45917192faa399fd1c851665d39c1190005d1d3999e28c788afea7458fcc671
MATLAB
812
26
function cvx_clearpath( arg ) %#ok %CVX_CLEARPATH Clears the cvx path. % CVX_CLEARPATH removes the internal cvx directories from Matlab's path. CVX % does this automatically when a model is completed (i.e., after CVX_END), in % order to reduce potential naming conflicts with other packages. There is no % nee...
54a9a25f6380de3c431d3b1d0e5fa17dec19288c0a4f46b1912bbda19f4286ed
MATLAB
813
23
function formatFigure(hF, panelWidth, panelHeight, leftOffset, bottomOffset, fontSize) % Formats a figure to dimensions useful for illustrator figure making if nargin < 6 fontSize = []; end % Figure resize figureWidth = panelWidth + leftOffset*2; figureHeight = panelHeight + bottomOffset*2; set(hF, 'Units', 'inche...
b912d004e981a769c00921c3a271188143d39e94d70bb416d641ab04485c2c22
MATLAB
813
28
function patches = construct_grid_even(grid_size,overlap,dim,min_diff) N = length(dim); start_point = cell(N,1); end_point = cell(N,1); for i = 1:N start_point{i} = [1:grid_size(i):dim(i)-grid_size(i)-overlap(i)+1,max(dim(i)-grid_size(i)-overlap(i)+1,1)]; end_point{i} = [grid_size(i)+overlap(i):grid_size(i):d...
ce3e924150ed8ceff514df2ad60fe0800ea7e0b9c235a78f7ab6a47899bde644
MATLAB
813
26
function prob = CBIG_get_prob(gamma_file) % prob = CBIG_get_prob(gamma_file) % % Subtracting alpha (optional) % % From Blei: % % "we (sometimes) subtract alpha to find a less smooth representation % % of the topics within each document. if you are looking for an % % estimate of \theta_{doc} then you don't have to sub...
d90b2229366906a0aa759b2235f1bc60e975aed6e1cc54a797686433481d122e
MATLAB
813
20
function [changedstates,ret]=ea_checkfschanges(resultfig,fibersfile,seedfile,targetsfile,thresh,mode) % small helper function that determines changes in fibertracking results. ret=1; ofibersfile=getappdata(resultfig,'fibersfile'); % mode independent oseedfile=getappdata(resultfig,[mode,'seedfile']); otargetsfile=getapp...
dccbb4dc707b24f5105058450eecb4e19df604d816576f9d59b87478c50c5d9c
MATLAB
813
24
function [cov, metr1_SubVol, metr2_CortThick, metr3_CortSurf] = load_example_data() % % Usage: % [cov, metr1_SubVol, metr2_CortThick, metr3_CortSurf] = load_example_data() % % Description: % Loads the ENIGMA example dataset (from one site - MICA-MNI Montreal; % author: @saratheriver) % % Outputs: % cov (ta...
86c9d6436a5ef0b29a5a7802f166cd11a824dcd60d2863120f28c1782c8da109
MATLAB
814
27
%%***************************************************** %% viewgraph: plot the graph of an adjacency matrix. %% %% SDPT3: version 3.0 %% Copyright (c) 1997 by %% K.C. Toh, M.J. Todd, R.H. Tutuncu %% Last modified: 2 Feb 01 %%***************************************************** function viewgraph(B); ...
8919ff3af69d665e7dd4159f797c65f4160ca900e4d8380056a3f214ac649026
MATLAB
814
28
% this example demonstrates how to mesh a gray-scale volume directly. % the data set is a Jacobian matrix obtained by multiplying two % Green's functions % see Appendix in Qianqian Fang, Computational methods for microwave medical imaging. Ph.D. % Dissertation, Dartmouth College, Hanover, NH, U.S.A., Dec 2004. [xi,yi,...
8c6c96341c79e7a38428b70370f786949e884853fcb1d327360704202a79d64a
MATLAB
814
31
%% id - add a unique id to an object % e.g. to be used as a key % % Florian Bernard, Andreas Husch % Centre Hospitalier de Luxembourg, Dep. of Neurosurgery / % University of Luxembourg - Luxembourg Centre for Systems Biomedicne % 2014 - 2017 % mail@andreashusch.de, fbernardpi@gmail.com classdef id < handle proper...
ea254b8e2be4ae45f37738f17705a97e8ca7bc5487e151afe63b6fe027eca5b5
MATLAB
814
34
function sOut = keepFields(sIn, keepList) %KEEPFIELDS Keep only specified fields in a struct. % % sOut = KEEPFIELDS(sIn, keepList) % % Inputs: % sIn - Input struct. % keepList - Cell array of field names to retain in sIn. % % Output: % sOut - Struct containing only the specified fields...
1cbdf6341d138a962a77ea8c020888b6b7970dd08c1a9861aba1eea51186cfa7
MATLAB
815
38
function out = FindDuration(indx); %FINDDURATION % Usage: out = FindDuration(indx) % % This is a short little function that finds a jump in the indx vector % and then spits out the number of elements before that jump. It does % this for all jumps it finds. By a jump, I mean a discontinutity in the % index. For ex...
71710d5d3ad04c0286b3db33a5e48f095c0c9f59525eb8fed0f59fc9590b30cb
MATLAB
816
20
%order coordinates of ellipse along ellipse curve %IMPORTANT NOTE: will likely only work on smooth ellipses without folds, %otherwise the problem becomes a nearest neighbor problem like the traveling salesman %based off of: https://www.mathworks.com/matlabcentral/answers/431568-how-to-effectively-reorder-data fun...
9f7f825fe130bc241ea77118cb40d9a0011dfe5eb2aee83afb2be719aa0e1dae
MATLAB
816
29
function [path,name,ext] = LeG_lastPath(filterspec,dialogtitle) savedpath = fullfile(fileparts(which('LeG_lastPath.m')),'LeG_lastPath.txt'); startpath = ''; if exist(savedpath,'file') fid = fopen(savedpath,'r'); %read only startpath = fscanf(fid,'%s'); fclose(fid); end if ~exist(startpath,'dir')...
8f9c5e78e8a4a993e01412c9de8e65a6786144e35cdb1ade98591f5b130631fd
MATLAB
817
32
function SD = sd_from_ci(CI_low, CI_high, n) %SD_FROM_CI Compute standard deviation from a 95% CI around the mean. % % SD = SD_FROM_CI(CI_low, CI_high, n) % % Inputs: % CI_low - lower bound of the 95% confidence interval % CI_high - upper bound of the 95% confidence interval % n - sample s...
d5ee7fcbcc0e61a54305106e62e919a49c7e14c436ce9f6efd667dca706ed0e7
MATLAB
817
25
function this = read_freesurfer_file(filename) % Low level reader of FreeSurfer files (ASCII triangle surface file) % FORMAT this = read_freesurfer_file(filename) % filename - FreeSurfer file % % See http://wideman-one.com/gw/brain/fs/surfacefileformats.htm %__________________________________________________________...
dad2f399cb37490f008310461db67c7602b2acedfceca2f3def58f083b1af72b
MATLAB
817
26
function info = getinfo(vw) %INFO=GETINFO(VW) % Returns a structure whose fields contain information about the opened % video object. This structure may be flattened to a cell array and used % with the videoWriter constructor to recreate the current video file. % %SEE ALSO % videoWriter % %Copyright (c) ...
e305cdf0253a643c10b3e60aae350b47461c1e9dab4fdb67e24dc62cb648cde4
MATLAB
817
25
function allROIs = tSNEallROIsPCA(allROIs, perplex) % Performs tSNE dimensionality reduction on the z-scored feature matrix, % then returns the original struct with tSNE space coordinates for each % cell included % Note: pass in only valid allROIs, perplexity depends on struct size if nargin < 2 perplex = length(a...
0fd1fe055499bbd8df6e9b6146ffec45f0d577ff54a78f45f1476ce52c479430
MATLAB
818
31
function AddSpikeTimes(spikes) %AddSpikeTimes - Add spike timestamps. % % USAGE % % AddSpikeTimes(spikes) % % SEE % % See also ThresholdSpikes. % Copyright (C) 2012 by Michaël Zugaro % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public Licens...
6d74a96977e7761c83cb7cd0395ecbc64d3fe44d4d9a305b1a84ac6de18bfe41
MATLAB
819
34
function [xo yo R] = circle_fit(x,y) % A function to find the best circle fit (radius and center location) to % given x,y pairs % % Val Schmidt % Center for Coastal and Ocean Mapping % University of New Hampshire % 2012 % % Arguments: % x: x coordinates % y: y coordinates % % Output: % xo: circ...
7e50170c8b51d10936a6f05ce21271641aac73a1736746d63adc2514ab255a75
MATLAB
820
34
% Exercise 5.1d: Sensitivity analysis for a simple QCQP % Boyd & Vandenberghe, "Convex Optimization" % Joëlle Skaf - 08/29/05 % (a figure is generated) % % Let p_star(u) denote the optimal value of: % minimize x^2 + 1 % s.t. (x-2)(x-2)<=u % Finds p_star(u) and plots it versus u. fprintf(1...
8ebd9ceeff49015ff1c3f404c5cdb3fe4c777534cd5cb5722fa7601c5ddc1af3
MATLAB
820
22
function ea_backuprestore(file) % Restore file from preprocessing if preprocessing exists. % Backup file to preprocessing if preprocessing doesn't exist. % Used mainly for coregistration pipeline. space_tag = regexp(file, '(?<=space-).+(?=desc)', 'match', 'once'); backup = strrep(file, [filesep 'coregistration' files...
b901173e6f701145ee33fa7835cf80c62eee733ddbd4891a81b9d4c2b07cce79
MATLAB
820
26
function [ spkpos,spk_i ] = spk_pos( vid_ts,pos,spk_ts ) %SPK_POS Finds spike positions % Finds the spike positions given tracking data in a N-dimensional state % space % % SPKPOS = SPK_POS(VID_TS,POS,SPK_TS); % % ARGUMENTS % * VID_TS: A vector of the timestamps for the state data % * POS: The position at e...