sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
d39519cd5d63b14a9e9f66f711efc38ba47d1e5572dd822a608d23effb250ee5
MATLAB
695
30
function ok_to_run = plugin_check_required_fields(DAT, required_fields) % Plugin helper function for Second_level_analysis_template_scripts % See those scripts for usage. % % Example: % ok_to_run = plugin_check_required_fields(DAT, {'EMO_CAT_SIG_conditions'}); nfields = length(required_fields); isok = false(nfields, 1...
01518709658490353cdc4bb22ac5d33cf3c3e9686f574309757336b7438a2b22
MATLAB
696
20
function [outstruct, unknowns] = myargparse(myvarargs, allowed, allow_unknown) unknowns = {}; if nargin < 3 allow_unknown = false; end for i = 1:length(allowed) outstruct.(allowed{i}) = ''; end for i = 1:2:(length(myvarargs) - 1) %need to allow for a solitary 'recursed' on the en...
12042ef97aef9c7983159b4dce6a1416bcf8a433f5982c883011edee8de8dc43
MATLAB
696
28
function [smp1_gauss,idxi_1]=fib_gauss(smp1,sig,trgt_coor,vcnty_thr,dim) % Min Jae Kim (mkim@bwh.harvard.edu) %% Step 1: Imposing Vicinity Threshold % Running Fibertract 1 rmv_1=[]; for hh=1:length(smp1) vc_euc=sqrt(sum((smp1(hh,:) - trgt_coor) .^ 2)); if vc_euc>vcnty_thr rmv_1=[rmv_1;hh]; end e...
123b3d68d74d6bee25faea6a342332d00ad69de4f7f0d02b124e321a88a9b252
MATLAB
696
18
if exist('paramBC','var') %for unit match param = paramBC; end spikeFile=dir(param.rawFile); fname = spikeFile.name; dataTypeNBytes = numel(typecast(cast(0, 'uint16'), 'uint8')); try %hacky way of figuring out if sync channel present or not n_samples = spikeFile.bytes / (param.nChannels * dataTypeNBytes); ...
5a73497b2d48b454c3e5fa5894e8e959914d2d0b0e6481a6477e19133cfcafa5
MATLAB
696
21
function y = inv_pos( x ) %INV_POS Reciprocal of a positive quantity. % INV_POS(X) returns 1./X if X is positive, and +Inf otherwise. % X must be real. % % For matrices and N-D arrays, the function is applied to each element. % % Disciplined convex programming information: % INV_POS is convex an...
06f5a162d38bda4cd1359e0a89f96c85867331f75e3bbafa4512e27d7e72bfdb
MATLAB
697
30
function [OnOffs] = findOnsetsAndOffsets(boolVec) % Returns list of aligned start and stops of chunks of 1's in a vector of % 1's and 0's. % % INPUTS % boolVec - vector of 1's and 0's % % OUTPUTS % startEnds - Nx2 list of indices of the first and last 1's for the N % contiguous blocks of 1's. % % % func...
b5ddf0ac53f0de50fa1af1706978111ba75f59f2df5cda60b7efe433e6557065
MATLAB
697
25
function [out, segmentLength] = suprathresh(V, thresh) % This subroutine determines suprathreshold values %%% INPUTS %%% % V: a Nx1 (checked) vector of values % thres: a scalar threshold % %%% OUTPUTS %%% % out: a Nx2 array with the 1st column indicating first suprathreshold % values and the 2n...
3903d9e525ed5497cb6a270cdde0071564ee8a82d28b129ca37bb4bc045c9f76
MATLAB
698
25
function g=lcvplot(alpha,varargin) % % Computes and plots the Likelihood Cross-Validation score (LCV) % for local fits with different smoothing parameters. % % The first argument to lcvplot(), alpha, should be a matrix with one % or two columns (first column = nearest neighbor component, second % column = constant comp...
9adbcd2d0c54ff39fb8ee30acd7361f43f3e3f81551ab91e506147391985e0cc
MATLAB
698
27
function p = circ_iqr(alpha) % CIRC_IQR - estimates the interquartile range of circular data % % INPUT & OUTPUT % ------------- % alpha - input data (in radians, not binned) % p - estimated iqr % % METHOD % ------------- % For normal distributions IQR can be estimated from the % standard deviation of th...
5446676187eeb5492fff3086ad01cad26c20b92614a9f7aabfdab628e133d625
MATLAB
699
25
function g=gcvplot(alpha,varargin) % % Computes and plots the Generalized Cross-Validation score (GCV) % for local fits with different smoothing parameters. % % The first argument to gcvplot(), alpha, should be a matrix with one % or two columns (first column = nearest neighbor component, second % column = constant com...
f187e02106b17ecad6b1b9486f2e349e391445f9fcf5ca8ffde13cbc8340a557
MATLAB
699
18
function ncoords_mm=ea_extrapol_coords(coords_mm,options) % simple iterative extrapolation for more than 4 contacts % __________________________________________________________________________________ % Copyright (C) 2014 Charite University Medicine Berlin, Movement Disorders Unit % Andreas Horn ncoords_mm=zeros(opt...
1d61de6b1a9ae09308034df099813aee0412772af689f73e2c9f0f911a7253ee
MATLAB
700
23
function data=extractdatac(data,Fs,t) % Extract segements of continuous data between t(1) and t(2) % Usage: data=extractdatac(data,Fs,t) % % Input: % data: continous data in the form samples x channels or a single vector % Fs: sampling frequency % t : time as a 2d vector [t(1) t(2)] % Note that sampling frequ...
42c984aec0a3900753f176fe09e2bf25c3b23fb9f65a96222392287b3be10e03
MATLAB
700
19
%% Figure 7 analysis YOURDATAPATH = ''; % Load ROIs and border classifier data fileList = searchFilesRecursive(YOURDATAPATH, 'allROIs.mat'); load(fullfile(fileList.folder, fileList.name)) % Using only cue-modulated allROIs = allROIs([allROIs.modCue] == 1); % Using only cells within the 5 main areas areas = {'M2', 'M1'...
50b4cdc71af3c6ca15145f243c9102fda5b50ce71ff6c2940d8f24b9da4bd241
MATLAB
700
24
function S = ea_activecontacts(S) for pt=1:length(S) for side=1:2 switch side case 1 sidec='R'; case 2 sidec='L'; end S(pt).activecontacts{side} = zeros(1,S(pt).numContacts); for source=1:4 for c=1:S(pt).numContac...
5adbc22465ff9087ee73a325609f1bf33754247400de72100f174ce97c25e5f0
MATLAB
700
13
% CVX: Keywords for declaring variables and objectives % dual - Declares one or more dual variables. % epigraph - Declares an epigraph variable. % hypograph - Declares a hypograph variable. % maximize - Specifies a concave (or affine) objective to be maximized. % minimize - Specifies a convex (or affi...
969878cec8e0888362e6d0e119c5bcf19580b139a4ac5af2aece379d1ec2b39a
MATLAB
700
17
function ea_apply_normalization(options) % Wrapper to apply normalization to the unnormalized files. % __________________________________________________________________________________ % Copyright (C) 2014 Charite University Medicine Berlin, Movement Disorders Unit % Andreas Horn json = loadjson(options.subj.norm.log...
d1ec9e01622929a487a3fd6e98cf25ab7adeca958df227a68b308bce4f604278
MATLAB
700
21
function res = PFNd_integ(params,inputs,initconds) % params = array where first row is AF, second row is OF % inputs = array where: % [ AF directions; % AF speeds; % OF directions; % OF speeds; % time ] AF = D_response_de(params(1,:),inputs([1:2,5],:),initconds(1)); OF = D_response_de(params(2,...
17aa4ff1df0ff25b2d9f865acd64d1c9e81f76faa789b66cfae3468466f81510
MATLAB
701
13
% CVX: Keywords for declaring variables and objectives % dual - Declares one or more dual variables. % epigraph - Declares an epigraph variable. % hypograph - Declares a hypograph variable. % maximize - Specifies a concave (or affine) objective to be maximized. % minimize - Specifies a convex (or affi...
b53a05dc890fb4f821e3361551f85fe05d42095cab185952ce154d9397a1540e
MATLAB
701
22
function root = AlignSpike2Session(root, force) % Aligns Spike times to the Session frames. Populates root.Spike(n,m).i if ~exist('force','var') force = 1; end % % For every spike object in root.spike, realigns spike times to root.b_ts, % and deletes the rest of the cells information other than label for j = 1:nu...
e1cacc97a2b5c71b01532852da99da38993575f6269f2fe920530990a7bc9fcb
MATLAB
701
29
function [n,filters] = plx_chan_filters(filename) % plx_chan_filters(filename): read channel filter settings for each spike channel from a .plx or .pl2 file % % [n,filters] = plx_chan_filters(filename) % % INPUT: % filename - if empty string, will use File Open dialog % % OUTPUT: % filter - array of filter...
48ca9d6a14d94b5045c3d5960ddfbf40fdac4fffd221e09154632e028872ef7a
MATLAB
702
16
function Energy = GCO_Swap(Handle,MaxIter) % GCO_Swap Run alpha-beta-swap algorithm. % GCO_Swap(Handle) runs alpha-beta-swap until convergence. % GCO_Swap(Handle,MaxIter) runs at most MaxIter swap cycles. % Returns the energy of the computed labeling. % The labeling itself can be retrieved via GCO_Ge...
9e45ab462843d09d958f03e55841e6413c161df8e2d3cdcc64fd21d2604b6937
MATLAB
702
22
% Returns the total number of edges given the adjacency matrix % Valid for both directed and undirected, simple or general graph % INPUTs: adjacency matrix % OUTPUTs: m - total number of edges/links % Other routines used: selfloops.m, issymmetric.m % GB, Last Updated: October 1, 2009 function m = numedges(adj) sl=sel...
ad5adf330f2059d3b1b3a2c09a4d340612c6fc16f85e3b0220a9e856c2d6c74e
MATLAB
703
25
function display(this) % Display method for GIfTI objects % FORMAT display(this) % this - GIfTI object %__________________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % Guillaume Flandin % $Id: display.m 4182 2011-02-01 12:29:09Z guilla...
bc75e398146c71898449da928f07f40111972e23056add456cc9191ac9341587
MATLAB
703
19
function scoresOUT = updatestages(scoresIN, srate, epochLength) %% % Authors: Dan Denis % Date: 2021-07-14 epochSampleIdx = indexepochs(epochLength * srate, (length(scoresIN.stages) * epochLength) * srate); epochSecIdx = indexepochs(epochLength, (length(scoresIN.stages) * epochLength)); epochSecIdx = epochSecIdx(...
c80f534f59d446dd249dc6b012ab2d3f39d82f6f4a24a77ffa90ab698c9c2b4b
MATLAB
703
27
function extras = read_extras(fname) % Read extra bits of information %__________________________________________________________________________ % Copyright (C) 2005-2011 Wellcome Trust Centre for Neuroimaging % % $Id: read_extras.m 4492 2011-09-16 12:11:09Z guillaume $ extras = struct; [pth,nam,ext] = fileparts(fn...
5ab96537494000c051622af194c27e3255885f321caa7f7a33c3d78c13bba27c
MATLAB
704
21
function cfs = makeErbCFs(mincf,maxcf,numchans) %MAKEERBCFS Make a series of center frequencies equally spaced in ERB-rate. % % This function makes a vector of center frequenies equally spaced on the % ERB-rate scale. % % CFS = IOSR.AUDITORY.MAKEERBCFS(MINCF,MAXCF,NUMCHANS) creates NUMCHANS % centre frequen...
76daaa6ef68aea8b3b22ac476cb76a59f38a1fc8ba0dd279f1e58a400071cb0f
MATLAB
704
29
% setdiff_bc - setdiff backward compatible with Matlab versions prior to 2013a function [C,IA] = setdiff_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); if...
2905244fb2ba4d67797f2bd3f37941c07e60645134c08d8f85ac280bf63b4e61
MATLAB
705
33
function cvx_optval = trace_sqrtm( X ) %#ok %TRACE_SQRTM Internal cvx version. narginchk(1,1); if ndims( X ) > 2, %#ok error( 'trace_inv is not defined for N-D arrays.' ); elseif ~cvx_isaffine( X ), error( 'Input must be affine.' ); end n = size(X,1); if n ~= size( X, 2 ), error( 'Matrix must be square....
4b86754ce8ca9b827ad59c629cc1591122bebc52f82242fc17447c1b8a75332d
MATLAB
705
18
% HTMLREPORTDEMO % Generates a demo report in the Output directory of this module % % clear r = report_generator('Test Report', 'Output'); r.open(); r.section('A Demo Report'); r.add_text('This is an example HTML report generated from Matlab. Discuss what you did here, maybe give a few example calculations:'); ...
7ae4b058d142b38afc1b16421bfca1d63a6b0c8c0048d25d55a38d24e1fb6ca2
MATLAB
705
30
function [n,gains] = plx_adchan_gains(filename) % plx_adchan_gains(filename): read analog channel gains from .plx or .pl2 file % % [n,gains] = plx_adchan_gains(filename) % % INPUT: % filename - if empty string, will use File Open dialog % % OUTPUT: % gains - array of total gains % n - number of channels ...
7ced24f3663cc1f66dd960791b19779636f66c5e439efe6f5fd86e915a44a42c
MATLAB
706
24
function data=extractdatapb(data,Fs,t) % Extract segements of binned point process data between t(1) and t(2) % Usage: data=extractdatapb(data,Fs,t) % % Input: % data: binned point process data in the form samples x channels or single % vector % Fs: sampling frequency % t : time as a 2d vector [t(1) t(2)] % Note that...
f808b3529a8fb4c08ae2d55cc0735daed9db08eec71068d3cf82cbfbbcc775f2
MATLAB
706
18
function out = M_motion( param, img , img_prev, prev_img_shift , ti ) if ( nargin == 1 ) out.weight = param.motionWeight; out.numtypes = length( param.motionAngles ); for i = 1 : length( param.motionAngles ), out.descriptions{i} = sprintf('Motion Direction %g',param.motionAngles(i)); end el...
0655c6346dfcdcf336e7f35526b77060a5e80e4e224f10a64237c9b79e493c2d
MATLAB
707
23
function maxChannels = getWaveformMaxChannelEP(templateWaveforms) % JF, Get the max channel for all templates (channel with largest amplitude) % ------ % Inputs % ------ % templateWaveforms: nTemplates × nTimePoints × nChannels single matrix of % template waveforms for each template and channel % ------ % Outputs % -...
61b8638430f89b7aded7f5385cf682cb5c444fbe8c83b15293fe8791b4e06d2a
MATLAB
707
28
function r = circ_dist(x,y) % % r = circ_dist(alpha, beta) % Pairwise difference x_i-y_i around the circle computed efficiently. % % Input: % alpha sample of linear random variable % beta sample of linear random variable or one single angle % % Output: % r matrix with differences % %...
bfdc419393040445b44ce05040459847d2483dd0bfae734836aa05638d51050e
MATLAB
707
22
function Output = A_applyfilter_decimate(Data,Lowcut,Highcut,fs,dsfs); % Apply filter between Lowcut and Highcut (Hz) for Data sampled in given % frequency (fs). % "Data": data source ready to be filtered % "fs": sampling frequency (Hz) of Data % "Lowcut": lowcut frequency (Hz) of filtering % "Highcut" Hig...
f88c285549b06b779ae537c7e709924d4391f16b79ea6a85221ba38d96842d44
MATLAB
707
27
function data_r = reorder_sctx(data) % % Usage: % data_r = reorder_sctx(data) % % Description: % Re-order subcortical volume data alphabetically and by hemisphere (left then right; author: @saratheriver) % % Inputs: % data (table) - Data matrix % % Outputs: % data_r (table) - Re-ordered data % % Sara Lariviere ...
4dc0b15490cea647fcf75a9fd5ed0ff24e8ccfd2b0d639a25880466757291770
MATLAB
708
27
function ea_init_coregmrpopup(handles, defaultmethod) % Initialize MR coregistration methods popupmenu. % Set methods names = {'ANTs (Avants 2008)' 'BRAINSFit (Johnson 2007)' 'FLIRT (Jenkinson 2001 & 2002)' 'FLIRT BBR (Greve and Fischl 2009)' 'Hybrid SPM & ANTs' 'Hybrid SPM & BRAINSFIT' 'Hybrid...
7b3e2fcbf55ddb9813cf8dc546cb3894c9a5755f600b9600b7893a002307c8af
MATLAB
708
26
function pvalue_text = extract_pvalue_text(pval, is_corrected, correction_subscript) if nargin<3 correction_subscript = 'FWER'; end if nargin<2 is_corrected = 0; end if ~is_corrected if pval>=0.01 pvalue_text = sprintf('p = %.3f', pval); elseif pval<0.01 && pval>=0.001 pvalue_text ...
d0db5164cb747abd20084d4b18ff9fc407f6e4cfc49451ef7f82b0aa2b10daac
MATLAB
708
29
function models = fitAreaGMMsPCA(allROIs, options, metricField, areas) % Fits Gaussian mixture model distributions to the PC coefficients of % neurons specific to a given anatomical area % Get metrics switch metricField case 'PCs' metrics = cat(1, allROIs.PCs); case 'rotPCs' metrics = cat(1, al...
443050d4ec6865812f6a0e98a81c3e6868542948443bb99a0b0e0daccb5dd712
MATLAB
709
23
function move_inside=CheckMoveInside3D(V,Fnew,Vertex_id) % Orignal vertex position P=V(Vertex_id,:); move_inside=false(1,size(Fnew,1)); for i=1:size(Fnew,1) A=V(Fnew(i,1),:); B=V(Fnew(i,2),:); C=V(Fnew(i,3),:); normal = -cross(A-C,B-C); normal=normal./sqrt(sum(normal.^2)); % Calculate...
5c6d3cdc737bf40f3b5a97f04f3935fbfe6d0b3b0a024110b0ed3b7c1542be95
MATLAB
709
25
function S = struct_mfile_reference(mfile,struct_name,strs) % S = struct_mfile_reference(mfile,struct_name,strs) % AF 11/1/01 pattern = [struct_name '.']; if (~isempty(mfile)) strs = grep(mfile,pattern); end S = []; for i = 1:length(strs) inds = strfind(strs{i},pattern); for j = inds(:)' ...
6674441bdda6e03adbfb5beddd2bec3b24fe3500520632c82b7c3f44c91dd672
MATLAB
709
36
function [newL2] = bestMap(L1,L2) %bestmap: permute labels of L2 to match L1 as good as possible % [newL2] = bestMap(L1,L2); % % version 2.0 --May/2007 % version 1.0 --November/2003 % % Written by Deng Cai (dengcai AT gmail.com) %=========== L1 = L1(:); L2 = L2(:); if size(L1) ~= size(L2) error('size...
acaa4236015b272eb85e7807e705b0374ec6243477c9b43f84ed76f022f4d298
MATLAB
709
29
% helper function for CrossCorrelationsOnCombinedData.m function corrVals = crosscorr_nan_safe_prachi(x, y, maxLag) nLags = 2*maxLag + 1; corrVals = nan(nLags, 1); lagOffsets = -maxLag:maxLag; for i = 1:nLags lag = lagOffsets(i); if lag < 0 xLag = x(1:end+lag); ...
7362b9842d19348f4f1fd309e36490c7a8d53d80583e2625cf2aef7af097e2b8
MATLAB
710
19
function zx = cvx_expand_dim( z, dim, nx ) %CVX_EXPAND_DIM Expands an N-D array along a specified dimension. % CVX_EXPAND_DIM( X, DIM, NX ) stacks NX copies of the matrix X along the % dimension NX. It is equivalent to CAT( DIM, X, X, ..., X ), where X is % repeated NX times. % % This is an internal C...
df157bfdb517622f49f459b97a68bf525edf0091565a3ce30c52bbed83396da6
MATLAB
710
33
function cvx_optval = trace_inv( X ) %#ok %TRACE_INV Internal cvx version. narginchk(1,1); if ndims( X ) > 2, %#ok error( 'trace_inv is not defined for N-D arrays.' ); elseif ~cvx_isaffine( X ), error( 'Input must be affine.' ); end n = size(X,1); if n ~= size( X, 2 ), error( 'Matrix must be square.' );...
261f64dc32fd606e7d9d79742cf2d474b3682c71f2cda208319bd33ddad8936e
MATLAB
711
27
function [inface, outface]=innersurf(node,face,outface) % % outface=innersurf(node,face,outface) % % extract the interior triangles (shared by two enclosed compartments) of a complex surface % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % node: node coordinates % face: surface triangle list % out...
67baa23a676c7e1be7d3e4319e3db0c8918d081032c1edca4240da0a49d70ee5
MATLAB
711
26
function h5_2_bin(path_to_file,output_name,precision,batch_size) info = hdf5info(path_to_file); dims = info.GroupHierarchy.Datasets.Dims; T = dims(end); if nargin < 4 || isempty(batch_size); batch_size = T; else batch_size = min(batch_size,T); end if nargin < 3 || isempty(precision) precision = ...
cbec3415aa5bdf85cb464f0c2773c8a5227f6d958840f6cff2307280ec9ec2dd
MATLAB
711
29
% ismember_bc - ismember backward compatible with Matlab versions prior to 2013a function [C,IA] = ismember_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); ...
5d711cc0f308123ee5f290edfb5f29a57bd6d9dab921b3e27d66ab45ce4fdf9a
MATLAB
712
26
function v = getOr(s, field, default) %getOr Returns the structure field or a default if either don't exist % v = getOr(s, field, [default]) returns the 'field' of the structure 's' % or 'default' if the structure is empty of the field does not exist. If % default is not specified it defaults to []. 'field' can a...
bff639f07a77e3ca858dbf91934bb61aff3b41d47fbd7aef12b172bbaa0df779
MATLAB
712
22
function outStr = LeG_dialogCellstrHelper (inputStr) % Copyright 2010-2011 The MathWorks, Inc. % Helper used by MSGBOX, ERRORDLG, WARNDLG, QUESTDLG to parse the input % string vector, matrix or cell array or strings. % This works similar to the CELLSTR function but does not use deblank, like % cellstr, to eliminate ...
149c6750e4b9461f3a87e8b758acec0736ea94cc9a3c6b036b39245c4498728f
MATLAB
713
35
function [ WS , DS , n ] = convertimstocounts( ims ) % count the total number of pixels activated n = sum( sum( ims > 0 )); w = zeros( n , 1 ); d = zeros( n , 1 ); c = zeros( n , 1 ); nims = size( ims , 1 ); ii = 0; for di=1:nims imnow = ims( di , : ); % find activated pixels wh = fi...
3548dec97de2de560a8f15adbd581dd36531bc9a0b8dd306008a79e3597d952b
MATLAB
713
23
% datasets = Doric.getDatasets(filename) % List datasets within Doric's h5 datafile. % 2023-02-03. Leonardo Molina. % 2024-01-22. Last modified. function datasets = getDatasets(filename) root = h5info(filename, '/'); datasets = get(filename, root); datasets = datasets.cellstr(); end function lo...
4232f242bfe46f97eb622f1eaa09b247d776ba2e4cec807392d7682aff3ebe6d
MATLAB
713
22
function frame = getframe(vr) %FRAME=GETFRAME(VR) % Returns the current frame that has been read in from video VR. Calling % GETFRAME does not automatically advance the current frame so the user % must first call NEXT, STEP, or SEEK before calling GETFRAME the % first time. This makes it easy to write loops ...
9d7294aeadb7d81a03c8e3d39d40a99dfa8aa9490b9f706c3846324d0e0f2c26
MATLAB
713
17
function [colors,contrastID] = getContrastDRCvars() % Initialize variables for operations on contrast DRC data contrastID = {'LowContrast','HighContrast'}; %COLORS for sound level contrast plots colors.lohiPre = [0 0.4510 0.7412; ... %light blue: 0 0.4510 0.7412 0.8510 0.3294 0.1020]; %light red/orange...
f6197bc1bf69e88d8a683dd4d09ca1233dd0f19bddd7cd692c7479c8dc74b576
MATLAB
713
24
function [pth,nam,ext,num] = spm_fileparts(fname) % Like fileparts, but separates off a comma separated list at the end % FORMAT [pth,nam,ext,num] = spm_fileparts(fname) % fname - original filename % % pth - path % nam - filename % ext - extension % num - comma separated list of values %___________________...
0fd29171b6c126602e2b73554a36247314e191944aba59831c3ddff09784c47b
MATLAB
714
19
[fname,pname]=uigetfile('*'); eval(['load ' pname '\' fname]); params.tapers=[5 9]; params.pad=2; params.Fs=1000; params.fpass=[0 100]; params.trialave=1; 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]; % figure numbers for parti...
96c8cdc861dd5f0dd20cbb020efcef0c42c02e18f6085e844089ffc96a88060c
MATLAB
715
26
function p = SquareSubplot(n,i) %SquareSubplot - Layout subplots in a square arrangement. % % % USAGE % % p = SquareSubplot(n,i) % % n total number of subplots % i current subplot % Copyright (C) 2008-2011 by Michaël Zugaro % % This program is free software; you can redistribute it...
9d44bb65596c708d1add36b0b84235327187f7056e01ff0dc14b5191d82298cc
MATLAB
715
27
function plotOnsetPDFSubpops(allROIs) % Wrapper to plotMetricPDFSubpops, for onset data % Offset Y axis slightly in post, no need to do so here % Plot plotMetricPDFSubpops(allROIs, 'onset', [-200 400]) % Format figure panelwidth = 2.25; panelheight = 1.35; leftoffset = 0.5; bottomoffset = 0.5; formatFigure(gcf, panel...
8b6c5727e721db4a823958d1f0b456e638b53543695b0020e27e25c51ab48280
MATLAB
716
23
% Run this after example.m in order to write the detected event times to disk ts_data = []; num_subj = numel(timeseries); num_trials = 200; event_times = cell(num_subj * num_trials, 1); for subj_idx = 1:num_subj ts_data = [ts_data, timeseries{subj_idx}]; trial_idxs = specEvents(subj_idx).Events.Events.trial...
f12f57f937f2d4dcb426ab88e9b8e58dc260ab2af06b9c5959958c65a011d736
MATLAB
716
18
function showregresult(RegPara, imagefilename) scrsz = get(groot,'ScreenSize'); meanImg_PreReg = RegPara.meanImg_PreReg; meanImg_PostReg = RegPara.meanImg_PostReg; if isempty(findobj('type','figure','number',10)) pos = round([10 20 scrsz(3)/3*1 scrsz(4)/2*1]); else h1_handles = get(figure(10)); pos = h1_han...
4e348c873d222b062991c6a7d6702c3c23ce96a9f3c1399306d8c5a58c36c090
MATLAB
717
35
%% %syms k t %/ ((3.1416^(1/2)*erfi((k)^(1/2)))/(2*(k)^(1/2)))) %int(exp(k*t^2)*orthpoly::legendre(12,1.0*t),t,0,1) for l = 2:2:14, x = evalin(symengine,sprintf('simplify(int(exp(k*t^2)*orthpoly::legendre(%i,1.0*t),t=0..1) / ((PI^(1/2)*erfi((k)^(1/2)))/(2*(k)^(1/2))));',l)) y = strrep(char(x),'erfi','tm...
a49e61f4ce89138f8f966b06225382d0874e4f660a6b046d830f5beecb91a615
MATLAB
717
29
% unique_bc - unique backward compatible with Matlab versions prior to 2013a function [C,IA,IB] = unique_bc(A,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); if ~...
0c24eee388b3a94e27ecb032948b773bafc3c642aa50c81c4048ec721da6c51b
MATLAB
718
20
function ea_hyperlink_label(label, url, position) % Creates a clickable hyperlink label % % USAGE: % % ea_hyperlink_label(label, url, position) % % INPUTS: % label: label text % url: linked URL % position: position of the label labelStr = ['<html><a href="">' label '</a></html>']; jL...
9e8a2edcf255aef78ec8a782ab27c3f33065a02e74c838bd7fd5623599d0d2e8
MATLAB
718
18
function y = square_abs( x ) %SQUARE_ABS Square of absolute value. % For real X, SQUARE_ABS(X) produces the same result as SQUARE(X); that % is, it squares the elements of X. For complex X, SQUARE_ABS(X) returns % a real array whose elements are the squares of the magnitudes of the % elements of X; that is, ...
d09670c1c2da22ed8bfca9315641107a396ce26c133438b7c9669e9909e25439
MATLAB
718
18
function [power_log, freq, time] = analysis_lfp(data, bin, window, noverlap, nfft, fs, pre) % data: K x Nsamp(每行一个trial) % 输出 power_log: (power - baseline_mean) ./ baseline_mean,逐 trial 做基线 % 基线定义:time-pre <= 0(把 spectrogram 的时间轴左移 pre 秒) % ---- 计算每个 trial 的时频功率 ---- K = size(data,1); [~, freq, time...
15a62fdca6e179068ab956e9c526201f7a8a7bd88b500f2aec35a5dd66ebd7bd
MATLAB
719
29
function cm=ea_export_CM_png(varargin) X=varargin{1}; name=varargin{2}; options=varargin{3}; cm=figure('color','w','NumberTitle','off','Name',name); if nargin==4 % BIDS FIX: Ensure valid color limits clim = varargin{4}; if length(clim) == 2 && clim(2) > clim(1) imagesc(X, clim); else %...
bd7f015d1f39baeac7714b376a1b5189075c38614b2cdfe74ffff2c5d5651283
MATLAB
720
25
% % Input data % data = [201:240]; % Sample data % indices = [3 4 5 6 10 11 12]; % Vector of indices micsampsperframe = 23.6; data = flydata(1).gaussianfluor; indices = bouts{13}{1}; imginds = floor( bouts{13}{1} / micsampsperframe ); % Chunk data based on consecutive sequences of indices chunks = {}; curr...
ca55693d8598e4c09e3c383578f2b8047e80d2d88782932093d269dceeb9ffb5
MATLAB
720
18
function [Theta_global] = doMLRRInference(cfg, data_counts_filtered, ... total_biomass, perturbations, T) params = cfg.ridgeRegression; mesh = logspace(params.min, params.max, params.N); [F,time,ID,U,taxa_data,time_data,ID_data,U_data,F_prime,X, magnitude]=... import_data_and_construct_matrices(data_counts_filter...
6a4142862ae148d3a5df2c1891750f594115bc999cc61ad39338a315eec5f1b8
MATLAB
721
35
% V = idwt3(W) % % Implements the inverse discrete 3D wavelet transform, using Matlab 2D % functions. % % See also: dwt3 % Code written by Iman Aganj. function V = idwt3(W) sC = size3(W.dec{1,1,1}); for i=1:3 s(i) = length(idwt(zeros(sC(i),1), zeros(sC(i),1), W.wl)); end V = zeros(s); F = cell(...
7dd64059e0c0cf5ee15eab1670a9950b7f98cd01581849a3dac5aeb8e49728eb
MATLAB
721
36
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...
b5417f9380b879d541e2648c8c6dacfc2a4d950cb502675bc8352650016ef290
MATLAB
721
20
function subject( to ) %SUBJECT Implements the "subject to" keyword. % The keyword % SUBJECT TO % is a "no-op"---that is, it has no functional value. It is provided % solely to allow CVX models to read more closely to their mathematical % counterparts; e.g. % MINIMIZE( <objective> ) % SUBJECT TO...
eea5d319ed25954ffea24b09139745e26838bfaf80fe0985012e07c2b149d70c
MATLAB
721
33
function vol_res = reslice(vol,hdr,hdrref,oversamp) T1 = getMat(hdr); T2 = getMat(hdrref); SC = diag([[1 1 1]/oversamp 1]); T2 = T2*SC; if isfield(hdrref,'dataAy'); destdim = size(hdrref.dataAy)*oversamp; else destdim = hdrref.dime.dim(2:4)*oversamp; end; [X Y Z] = ndgrid(1:destdim(1),1:destdim(2),1:dest...
0ec5190faf04513b875e1d19afca942848d6df6bbfc879084fb35663375182b6
MATLAB
723
21
function cvx_clearspath %CVX_CLEARSPATH Clears the cvx solver path. % CVX_CLEARSPATH removes the internal solver directories to the Matlab % path. CVX automatically clears the solver path after completion of a % model computation, so calling this function should not be necessary. % Nevertheless, we provide i...
34e7b71be2282e8ef7b6e18c8d93017d9d5bd3a425d43bce04ca69fa571848ff
MATLAB
723
39
% rmsave() - return the RMS in each channel, epoch % % Usage: % >> ave = rmsave(data,frames); % Scott Makeig, CNL/Salk Institute, La Jolla, 9/98 function ave = rmsave(data,frames) if nargin<1 help rmsave return end if nargin<2 frames = size(data,2); data = reshape(data, size(data,1), size(data,2)*size...
8b9463744bb01283d638b7503ca1cf7d41e88a3460d416414a360bb9f175e527
MATLAB
723
28
function extras = write_extras(fname,extras) % Write extra bits of information %__________________________________________________________________________ % Copyright (C) 2005-2013 Wellcome Trust Centre for Neuroimaging % % $Id: write_extras.m 5451 2013-04-26 14:03:05Z guillaume $ if ~isstruct(extras) || isempty(fie...
eb7749e2ac86b1bd3e237a4b2639e86896ebe797da7fa4fdc5cfd90f22ce669f
MATLAB
723
17
function cellByTRFlinIDX = repFreqMask2linTRFidx(freqMaskByCell,nAmplInTRF) % compileAnimalDataTable compiles data table of all ROI for all animals % respective to stimulus parameters and TRF % % INPUT: % freqMaskByCell --> logical mask of frequencies of interest % ...
ef48ddb21ebaffa52cedf09b093a7d327447e5470b5028fa2bedcdfa4b4e6adc
MATLAB
723
22
function rms = rms(x,dim) %RMS Calculate the rms of a vector or matrix % % RMS = IOSR.DSP.RMS(X) calculates the Root Mean Square of X along the % first non-singleton dimension of vector or matrix X. For vectors, % IOSR.DSP.RMS(X) is the RMS value of the elements in x. For matrices, % IOSR.DSP.RMS(X) is a row v...
344cdbbf30cd774b3dc17c03d83a75ca593fe98112c8b30d21e749aa173bc657
MATLAB
724
29
% union_bc - union backward compatible with Matlab versions prior to 2013a function [C,IA,IB] = union_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); if ~i...
ab70f2ba957a724f5281185cf4bec174bb6b78fa09d83e0af18a62eb1f2ebedf
MATLAB
724
32
function [P bins] = JointDist(x,y,nbins) %JOINTDIST % Usage: [P bins] = JointDist(x,y,nbins) % %This function calculates the joint distribution of the variables x and y. %It is simply a normalized histogram using hist3. nbins can take any form %of bins that hist3 can take, but no other hist3 options. %Writ...
e8a54a757f7ead6ae145ec7ce152b2cb3f785404ef352d3a2b753fca21b165c0
MATLAB
724
35
function varargout = scl_slope(varargin) % Format % For getting the value % dat = scl_slope(obj) % % For setting the value % obj = scl_slope(obj,dat) % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: scl_slope.m 1143 2008-02-0...
10581f5e7dc5b976dc1fa1a58201980cacd8e30523a8e137e08c5a22eb22f3f5
MATLAB
725
36
function varargout = scl_inter(varargin) % Format % For getting the value % dat = scl_inter(obj) % % For setting the value % obj = scl_inter(obj,dat) % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: scl_inter.m 1143 2008-02-0...
6f20f2c0fde15ea211efe78bbc95cdf4649c061e1a9c3ad990967b8bc02726ac
MATLAB
725
32
function y = ipermute( x, order ) % Disciplined convex/geometric programming information for IPERMUTE: % IPERMUTE(A,ORDER) imposes no convexity restrictions on A. ORDER % must be constant. % % Determine the permutation % s = x.size_; ndxs = 1 : prod( s ); ndx2 = ipermute( reshape( ndxs, s ), order ); % ...
ad0b25a80ada2d66c6b29faeebcf43898f52e58585a3c7c7296c4a2a84ff95c2
MATLAB
725
21
% ttl = Inscopix.loadTTL(filename, ttlTarget) % Returns timestamps where tllTarget changes from low to high and high to low in Inscopix DAQ. % 2019-02-01. Leonardo Molina. % 2023-11-09. Last modified. function [rise, fall] = loadTTL(filename, ttlTarget) % Get time of transitions from low to high. fid = ...
debedf315073b2b3791a1b43ca1e9cc48034a93a5c33c1f291c58c624166daf9
MATLAB
725
29
function error = sem(x,varargin) % error = sem(x,varargin): Compute the standard error of the mean(SEM) % % Syntax % error = sem(x,varargin) % e.g. sem(magic(3)); sem(magic(3),1); sem(magic(3),2); % % Input % x: vector or matrix % varargin: none or 1 or 2 % % Output % SEM if isempty(varar...
14cc834bd4b7153afb9401eb67e05277526afe75a7718991365439914e2cd100
MATLAB
726
30
function handles = dan_prepare_specData(handles) % Function to plot spindle detections etc. specDataIn is a struct % containing detections from fun_sleep_spindles and fun_slow_oscillations %% % Authors: Dan Denis % Date: 2021-07-14 %% % Now for each channel, find the start & end IDX of the event, look % up the ch...
ff57f339f848ba97ca2b9cc818b9260f7341941d7e57a76a96b03ca86043bf11
MATLAB
726
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]; % figu...
1e392959c98458d4fb7c74b98f766d19dfb29cd54afb40c4c0bfa8ccd190ca1d
MATLAB
727
32
function [n,gains] = plx_chan_gains(filename) % plx_chan_gains(filename): read channel gains from .plx or .pl2 file % % [gains] = plx_chan_gains(filename) % % INPUT: % filename - if empty string, will use File Open dialog % % OUTPUT: % gains - array of total gains % n - number of channels if nargin ~=...
936c10b023635c69c4a5709babd9102679f3664e3851417e66b31bf80519fca5
MATLAB
727
25
% Copyright 2009-2013 The MathWorks Ltd. f = figure(); % Box Panel p = uix.BoxPanel( 'Parent', f, 'Title', 'A BoxPanel', 'Padding', 5 ); % HBox b = uix.HBox( 'Parent', p, 'Spacing', 5, 'Padding', 5 ); % uicontrol uicontrol( 'Style', 'listbox', 'Parent', b, 'String', {'Item 1','Item 2'} ); % Grid Flex g = u...
966bb744286d3a3a9053a83f43ac1591ada34ce08ed0ebf58a1d9e958e0171ab
MATLAB
728
31
function [A xy] = star_graph(n) % STAR_GRAPH Generate the star graph of order n % % The star graph is a simple star with n vertices. Vertex n is the center % vertex. % % [A xy] = star_graph(n) generates a star graph with n vertices and % returns the adjacency matrix in A. The matrix xy stores two-dimensional ...
e384359cbe3c24d80ed94d93f074319c4563b655dc16ed226350fec367b74d31
MATLAB
729
17
function z = lambda_sum_smallest( Y, k ) % LAMBDA_SUM_SMALLEST Sum of the k smallest eigenvalues of a symmetric matrix. % For square matrix X, LAMBDA_SUM_SMALLEST(X,K) is SUM_SMALLEST(EIG(X),k) % if X is Hermitian or symmetric and real; and +Inf otherwise. % % An error results if X is not a square matri...
0f24fd807f95ca7de60b63acdc53975fa5dda81f4273f2253bd5861b8062de10
MATLAB
730
24
function data=extractdatapb(data,Fs,t) % Extract segements of binned point process data between t(1) and t(2) % Usage: data=extractdatapb(data,Fs,t) % % Input: % data: binned point process data in the form samples x channels or single % vector % Fs: sampling frequency % t : time as a 2d vector [t(1) t(2)] % ...
d88cd69e5cae9889e9cdcea9e31937cfd949c5a3f3d1718afca131bcb856d899
MATLAB
730
34
function DBListFigures(query) %DBListFigures - List figures matching certain criteria. % % USAGE % % DBListFigures(query) % % query optional database query (WHERE clause) % % EXAMPLE % % DBListFigures('name="Spectrogram"'); % % SEE % % See also DBGetVariables, DBGetFigures. % % Copyright (C) 2...
da9a2a66c17a6b6b60ccb4c915483f41ee99e7e40aa8bebd82569cd724365e8d
MATLAB
730
34
function islands=bwislands(img) % % islands=bwislands(img) % % return the indices of non-zero elements in a 2D or 3D image % grouped by connected regions in a cell array % % author: Qianqian Fang (fangq <at> nmr.mgh.harvard.edu) % % input: % img: a 2D or 3D array % output: % islands: a cell array, each cell records t...
e4141f1fab870335a6ac32aa6469a2afd1dee8e983a5029de9ddaa8c38244403
MATLAB
730
25
%%******************************************************************** %% checkdense : identify the dense columns of a matrix %% %% SDPT3: version 3.1 %% Copyright (c) 1997 by %% K.C. Toh, M.J. Todd, R.H. Tutuncu %% Last Modified: 16 Sep 2004 %%******************************************************************** funct...
427811ee003c3bc6ca825c53c5bbe17d4b73268dc455124a38dd9a40157bf608
MATLAB
731
19
function ea_run_Martinos_Launchpad(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_'...
5042b8c66b152c972ef7fddf7b39a5f7c39d7904108078813e032044378884cc
MATLAB
731
26
function [nch, npoints, freq, d] = ddt_v(filename) % ddt_v(filename) Read data from a .ddt file returning samples in mV % % [nch, npoints, freq, d] = ddt_v(filename) % % INPUT: % filename - if empty string, will use File Open dialog % % OUTPUT: % nch - number of channels % npoints - number of data point...
524862188f31c0ad40f5070fbcef2c4752790dac93bcb9c61966ab07bf1cb48e
MATLAB
731
27
function newelem=meshreorient(node,elem) % % newelem=meshreorient(node,elem) % % reorder nodes in a surface or tetrahedral mesh to ensure all % elements are oriented consistently % % author: Qianqian Fang, <q.fang at neu.edu> % date: 2010/05/05 % % input: % node: list of nodes % elem: list of elements (each row a...
a4323f100bf02a220d477c6f9d9c5fa0040df04cbb789e6591a1459abc9e46f4
MATLAB
731
18
function score=ea_exportscore() % for now static sample export: score.studyOrigin='Earlystim'; % Tag label study name score.studyDoi='10.1056/NEJMoa1205158'; % Tag label study name score.metric='UPDRS-III'; % clinical score label score.dbsOff.vals=[1,2,0,0,0,0,0,0,0,0,0,0,0,0,2,3,2,2,3,3,1,1,1,2,2,2,2]; score.dbsOff....
144aabd5060284e8df40ee1114d257562d4b2361ee49ddef13ef31de29e68a53
MATLAB
732
28
function ringRemoval(niinames) for k = 1:length(niinames), [pa na ext] = fileparts(niinames{k}); if strcmp(ext,'.nii'), im = nifti(niinames{k}); for i = 1:size(im.dat,4), v = double(im.dat(:,:,:,i)); v = ringRm(v,[1 3 10]); im.dat(:,:,:,i) = v; f...
279f862d7508ff80d12b839d22169f06dd1c0a776687cf34a3541a4afb87eec5
MATLAB
733
19
[fname,pname]=uigetfile('*'); eval(['load ' pname '\' fname]); params.tapers=[5 9]; params.pad=2; params.Fs=1000; params.fpass=[0 100]; params.trialave=1; 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]; % figure numbers for ...