sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
e82f618db001ff3820890d715a55e961f942e2ca76f728c25bb9b9432b07bcad
MATLAB
820
27
[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...
f6dead571ac00e235b93eb4ccdcb8f9d8408addb05fe68381b44023522fc5747
MATLAB
820
26
function [ CNRcm ] = subfun_merge_CNRm2CNRcm( data ) CMRcm_fisherz = zeros(size(data{1})); for k = 1:numel(data) tmpCNRm = data{k}; row_m = mean(tmpCNRm, 2, 'omitnan'); col_m = mean(tmpCNRm, 1, 'omitnan'); all_m = mean(tmpCNRm(:), 'omitnan'); C0 = tmpCNRm - row_m - col_m + all_m; row_mean ...
627dc4ce99236d3dcb8681830d0abb96ab86b282714f67ee880b0a4c79a619e2
MATLAB
821
38
function [node,elem]=readsmf(fname) % % [node,elem]=readsmf(fname) % % read simple model format (SMF) % % author: Qianqian Fang, <q.fang at neu.edu> % date: 2007/11/21 % % input: % fname: name of the SMF data file % % output: % node: node coordinates of the mesh % elem: list of elements of the mesh % % -- thi...
b8c89c8426dd46808f62139592bc656508a109b80517e358d3785fd61d79cff2
MATLAB
821
22
ccc; temp = dir("D:\Lab members\XHX\ECOG\MAT Data\pre (granger)\single\**\7-10Freq Active\**\ICA res_*.mat"); idx1 = contains({temp.name}', 'AC'); idx2 = contains({temp.folder}', '\CC\'); paths = arrayfun(@(x) fullfile(x.folder, x.name), temp, "UniformOutput", false); badChsCC_AC_all = cellfun(@load, paths(idx1 & id...
cff7b90998a6adc7fb861e54e742063d07ad4e7c05aebc1d676d14c757582977
MATLAB
821
33
function signal = loadEGF(f_name, ifScale) fid = fopen(f_name,'r'); if (fid == -1) error('Could not open file %s',f_name); end for ii = 1:8 textstring = fgetl(fid); end fs = sscanf(textstring,'%*s %f'); for ii = 1:2 textstring = fgetl(fid); end nosamples = sscanf(te...
dab63ede5807b7105a4cca3ce285993cff063de25804247baee703d37fcd81ef
MATLAB
821
39
function [sfile,roilist]=ea_handleseeds(sfile) % handle seed files if iscell(sfile) % already supplied in cell format if length(sfile)>1 roilist=1; else [~,~,ext]=fileparts(sfile{1}); if strcmp(ext,'.txt') roilist=1; sfile=ea_getrois(sfile{1}); else ...
426a29abd2c4bbe6d08a7c898e40042a50eacc2fd0b0ddf2d00b1069d96ea488
MATLAB
822
24
%% PostStim %idx=find(tt>=1&tt<2) tstart=1; tstop=3; %load 'StimSM' rr1a_percentmeansSM=nanmean(all_rr1a_percentSM(tt>=tstart&tt<tstop,:)); rr1a_percentsemSM=nanstd(rr1a_percentmeansSM)/sqrt(size(rr1a_percentmeansSM,2)); %load 'stimAllTrials'; rr1a_percentmeans=nanmean(all_rr1a_percent(tt>=tstart&tt<tstop,:)); rr1a_...
4e0986ce917af2fa243cbd7865729dd0a84c179811f89ce44f84356b99575db4
MATLAB
822
16
function [proj,u,s,v] = pcasvd(data) %PCASVD Principal Components Analysis via (mean-subtracted) SVD. % PROJ = PCASVD(DATA), where DATA is an M x N matrix, returns the M x N % matrix PROJ where the (M,N)th entry is the projection of the Mth row % of DATA onto the Nth eigenvector of the covariance matri...
361f275b7fc74eb13ea036dcd4f08f9613432d23ede0842aff7c071599d9538b
MATLAB
823
32
function dartest % pull out rr1 and SEM and make plot from all files %20190812 names={ 'TSer4772_res.mat' 'Tser4773_res.mat' } vessel{1} = 1; vessel{2} = 2 4 5; vessel{3} = 1 2 3 4; all_rr1a=[]; all_rr1nSEM=[]; for ii = 1:length(names) load(names{ii}) all_rr1a = [all_rr1a rr1a_percent]; all...
93e3999a186cf41dec26692975cae63b6b6396f39d4d3b61e3c8ba589cba53b8
MATLAB
823
28
function p = gaussian_prob(x, m, C, use_log) % GAUSSIAN_PROB Evaluate a multivariate Gaussian density. % p = gaussian_prob(X, m, C) % p(i) = N(X(:,i), m, C) where C = covariance matrix and each COLUMN of x is a datavector % p = gaussian_prob(X, m, C, 1) returns log N(X(:,i), m, C) (to prevents underflow). % % If X has...
ae3664f97f9f13d15ba85da824d0a4355033503c5074db0129025b6b49e16cf8
MATLAB
823
44
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); if isempty(BBB) ClusterNum = NaN; else for i = 1:length(BBB) noaaa(i) = length(find(AAA==BBB(i))); end...
0dfeb01fec54a101c0be3ac7b8384c68edd9de1deab0860da09b26ee22bc63fb
MATLAB
824
31
function eid=getintersecttri(tmppath) % % eid=getintersecttri(tmppath) % % get the IDs of self-intersecting elements from tetgen % call this when tetgen complains about self-intersection % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % tmppath: working dir, use mwpath('') in most cases % % output: % eid:...
8341f6ac4e5a21080093f27e4e37ce7904055669fd26c88048f2d8d315819983
MATLAB
824
32
%int2zstr - Convert integer to zero-padded string. % % USAGE % % s = int2zstr(n,digits) % % n integer to convert % digits optional total number of digits % % Copyright (C) 2012 by Michaël Zugaro % % This program is free software; you can redistribute it and/or modify % it under the terms...
d8961baed2f094606f73be1f3d951b1e2408be6040eb3540348eedbd6ab181fd
MATLAB
824
24
function y = pow_abs( x, p ) %POW_POS Power of absolute value. % POW_POS(X,P) = ABS(X).^P. % P must be real and greater than or equal to one. % % Disciplined convex programming information: % POW_ABS(X,P) is convex and nonmonotonic, so X must be affine. % P must be constant, and its elements must ...
f988b2d0380404be0e404d876c87babc93bb18a88e7e054036c635748980395d
MATLAB
824
37
function y=myaffine2d_m(im1,x0,y0,r0,sx0,sy0,type,imsize,mask) % Usage ... y=myaffine2d_m(im1,x0,y0,r0,sx0,sy0,type,imsize,mask) r0=r0*(pi/180); [nx,ny,nz,nt]=size(im1); [ii,jj,kk,ll]=ndgrid([1:nx],[1:ny],[1:nz],[1:nt]); % rotation matrix rmat=eye(4); rmat(1,1)=cos(zrot); rmat(2,2)=cos(zrot); rmat(1,...
e9d30be17fc50c6e22cbc6238ba0b4376bdfe32db59be88e1f220f66d5662ca4
MATLAB
830
27
function [isPopInfo] = bz_isPopInfo(PopInfo) % USAGE % [] = bz_isPopInfo(spikes) % % INPUT % PopInfo - struct with the following fields % .UID % .sessionName % .region % % OUTPUT % logical true if struct meets PopInfo criteria, false if otherwise % % wr...
1c4886280b1572e7a3db529fd81f883df886a1c494087088587a6ad45462749f
MATLAB
831
35
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % demo script to insert new nodes to a tetrahedral mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% load rat_head.mat [node,elem,face]=vol2mesh(volimage>0.05,1:size(volimage,1),1:size(volimage,2),... ...
5f4a7e42a814b532277ffa3ebf737fd80670d7cca8fa1924d441ad571b38a025
MATLAB
831
22
function obj=geom_abline(obj,varargin) % geom_abline Display y=ax+b reference lines in each facet % % Example syntax: gramm_object.geom_abline('slope',1,'intercept',0,'style','k--') % 'slope' and 'intercept' can be 1D arrays of the same size in % order to draw multiple lines. In that case, 'style' can % either be a sin...
88e84c69f2a2092bb93c6b8c65dbfc466e9582de417b923ad24335ce79266e0a
MATLAB
831
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 = ha...
8f3e52e960ebe40e0c7b201c02e4ccb38e02fb0a60db49aa2c3caee0f66d6049
MATLAB
831
37
function facecell=finddisconnsurf(f) % % facecell=finddisconnsurf(f) % % subroutine to extract disconnected surfaces from a % cluster of surfaces % % author: Qianqian Fang (fangq@nmr.mgh.harvard.edu) % Date: 2008/03/06 % % input: % f: faces defined by node indices for all surface triangles % % output: % fac...
b307c3c03a7debbb07d2b17eafc8d2effd0782b3cd2133cde93a68808b265f13
MATLAB
831
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...
472c017542959892b8a6754d2d36bc28626d7f3ab74987b413d915d8008c3a98
MATLAB
832
31
function [result] = verify_mexplex(mexPlexData, dataDir) result = 1; for i=1:length(mexPlexData.plxs) plx = mexPlexData.plxs{i}; fpath = fullfile(dataDir, plx.FileName); plxnew = get_all_from_plx(fpath); [r1 r2 er] = comp_struct(plx, plxnew,'old','new'); if(max(size(er)) > 0) result = 0; e...
489083531b2447c4e5ab82c88180c590e518bf49f7a833d18178f60e42d35c26
MATLAB
832
22
function obj2 = unitaryopp(f, obj1, varargin); % make new memory mapped data file (blank) % ---------------------------------------- newFileName = mmo.getnewfilename; data = memmapfile(obj1.dataFile, 'writable', obj1.writable, 'format', { 'single' obj1.dimensions 'x' }); fid = fopen(newFileName, 'w...
3d376d9d02f514c514c690e4e371930f3b119657f3c447c3c1f416a03e7df097
MATLAB
833
27
function movF = MovGaussFilter_v2(mov, G, subsample, workingclass, useGPU, handles) movF = zeros([size(mov, 1), size(mov, 2), length(1:subsample:size(mov,3))], workingclass); k = 1; if useGPU gpudev = gpuDevice(1); reset(gpudev) Mem_max = gpudev.AvailableMemory; batchsize = min(floor(Mem_max*0.8/handles...
92336c54e48008a3beaea2da8bea36a6cca60bfbf67bdb9efda4fef9b67fb06d
MATLAB
833
35
function CBIG_MMLDA_generate_MingHotColormap % Written by Xiuming Zhang and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md % create R G B for color table no_bins = 255*3; R = zeros(no_bins, 1); R(1:255) = 1:255; R(256:end) = 255; G = zeros(no_bins, 1); G(256:510) = 1:255; G(511:e...
1445c50a25d761d479f8879220a34a8077a757cf192d47b6952780c3699fb459
MATLAB
834
29
function [ imcollage , labels ] = createcollage( ims , nx , ny , nimsx , nimsy , gapx , gapy ) % ims is a K x W array, where ims( k,w ) has the intensity of pixel w of % image k nims = size( ims , 1 ); if (nims > nimsx*nimsy) warning( 'Not all images fit in this collage' ); end nxtotal = nimsx * (nx ...
2b0ca599c67a2b8d7e7f87826536445bbafcd300a3fa5c642d17cb87a443a2a7
MATLAB
834
24
function x = buncompress( xR, x, sx ) narginchk(2,3); if ~isa( xR, 'double' ) && ~isa( xR, 'sparse' ), error( 'First argument must be a structure matrix.' ); elseif size( x.basis_, 2 ) ~= size( xR, 1 ), error( 'Structure matrix incompatible with vector.' ); elseif nargin < 3 || isempty( sx ), sx = ...
4faf23b59f8a9353d91850a1ea193ab4a566e50f1d99afea08157f40463d9fee
MATLAB
834
31
% Section 4.3.1: Compute the Chebyshev center of a polyhedron % Boyd & Vandenberghe "Convex Optimization" % Joëlle Skaf - 08/16/05 % % The goal is to find the largest Euclidean ball (i.e. its center and % radius) that lies in a polyhedron described by linear inequalites in this % fashion: P = {x : a_i'*x <= b_i, i=1,.....
cee406cf62ba6c32248837e2a26361955162230104a1d09105916df4fc114f36
MATLAB
834
25
function [p]=SetALFAanalysisParameters() %% set analysis parameters % set DBSCAN parameters for identifying signals from the same channel p.MaxDistProtamers = 8;%e-9; p.MinNumProtamers = 2; % set DBSCAN parameters for identifying PIEZO channel clusters p.MaxDistWithinCluster = 65;%;e-9; p.MinNumChannelsPerCluster = ...
ffe8978239caf2edbff083c05805128ac496479baf6af0c1ebb4391126ad23c5
MATLAB
835
25
count = 1; figure; for type = 6:10 A = allflies([allflies.trtype]==type); answer = []; for i = 1:length(A) data = A(i).gaussianfluor(:,1:8); [m, ind] = max(data(44,:)); % alignedL = circshift(data',4-ind); alignedL = circshift(data(44,:),4-ind); data = A(i...
23f8866115fa167413e5474c9d65aa5576be4b50a00522c5d46f7509cbd79d5b
MATLAB
836
29
%% plotSphere - plot a sphere for given point % % Andreas Husch % Centre Hospitalier de Luxembourg, Dep. of Neurosurgery / % University of Luxembourg - Luxembourg Centre for Systems Biomedicine % 2014 - 2017 % mail@andreashusch.de, husch.andreas@chl.lu function graphicsHandle = plotSphere(point, diameter, color, parent...
ba140b5fb2303f71c543dac0c6ce5e51b901721602326f28ea37ea5e9f0af192
MATLAB
836
33
function y_line=runline(y,n,dn) % Running line fit (local linear regression) % % Usage: y_line=runline(y,n,dn); % % Inputs: % y: input 1-d time series (real) % n: length of running window in samples % dn: stepsize of window in samples % % Outputs: % y_line: local line fit to data y=y(:); nt=length(y); y_line=zeros(nt...
e248dbb28778b1464b5260cf7713e942f7f4eb3b423142d239cf9d1904ba0935
MATLAB
836
30
function res = prunePTResult_(res, saveSinglePerm) % Remove unnecessary large fields from mu_granger_wavelet_pt output. removeFields = ["dGC_obs_full", "resSTD", "resDEV", "opts"]; for i = 1:numel(removeFields) fn = removeFields(i); if isfield(res, fn) res = rmfield(res, fn); ...
59b2cd0ccfc47b29ac6735f04894b152fda0c16faa6c490ce037a7322cb299e8
MATLAB
837
34
function y_line=runline(y,n,dn) % Running line fit (local linear regression) % % Usage: y_line=runline(y,n,dn); % % Inputs: % y: input 1-d time series (real) % n: length of running window in samples % dn: stepsize of window in samples % % Outputs: % y_line: local line fit to data y=y(:); nt=length(y); y_line=zeros(n...
d3a723093d6a94944724708050a07a7321db78aae99e752f66c9dad0dd5b8936
MATLAB
837
25
function [p]=SetALFAanalysisParameters_V2() %% set analysis parameters % set DBSCAN parameters for identifying signals from the same channel p.MaxDistProtamers = 8;%e-9; p.MinNumProtamers = 2; % set DBSCAN parameters for identifying PIEZO channel clusters p.MaxDistWithinCluster = 65;%;e-9; p.MinNumChannelsPerCluster...
0a6c1e3bf978fe7bc8454a653c1d4955878f2ffc9318a7d3772b7f7314cb5360
MATLAB
840
21
function ans=erfi(x) % %erfi(x). The Imaginary error function, as it is defined in Mathematica % %erfi(z)==erf(iz)/i (z could be complex) using % %the incomplete gamma function in matlab: gammainc % %Using "@": erfi = @(x) real(-sqrt(-1).*sign(x).*gammainc(-x.^2,1/2)) % %Note: limit(x->0) erfi(x)/x -> 2/sqrt(pi) ...
16c7d84302e769bcbc7da0b1dad1e654e2e7c2054fccb8d33a378f930bee01de
MATLAB
840
27
function [errCode] = ddt_write_v(filename, nch, npoints, freq, d) % ddt_write_v(filename, nch, npoints, freq, d) Write data to a .ddt file % % [errCode] = ddt_write_v(filename, nch, npoints, freq, d) % % INPUT: % filename - if empty string, will use File Open dialog % nch - number of channels % npoints...
87582f565540ea6194293bb04a966d8ee11e70fc52f3a70d358731720b6fd9da
MATLAB
840
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_s...
a379ae81175f997c0df875463565489d8a9a393ab9c08b5a2901bc7500da0acf
MATLAB
840
17
% stitching single ROI over multiple trials % order doesn't matter! just need ROI's 3% lowest intensity values % why do this over just taking the max? % it really might not work because the ROIs are not equally active even % throughout an entire session with a fly % so an ROI that remains very dim throughout sho...
3b76b80e4bef556c9bec683cd723bd57720b0bf02277d1dd724550ef8156ead8
MATLAB
841
35
function handles = dan_adjust_channel(handles) %% % Authors: Dan Denis % Date: 2021-07-14 %% % Add and/or remove channel filters and references montage = handles.montage; chanProp = inputdlg({'Channel name', 'Channel type', 'New reference', 'Lower edge', 'Higher edge', 'Add notch'}, 'Channel property editor'); ...
e7e2a848a54252076d4bd8f0d675be425ab77ae8ba152628dd3ce5c8d88909ca
MATLAB
841
37
function ROIxyCoord = mask2polyCoord(mask) %takes binary image mask of shape imgWidth X imgHeight of type logical for %a given ROI and outputs the coordinates of the ROI outline in ROIxyCoord %Row1: x; Row2: y [r,c] = ind2sub(size(mask),find(mask)); [uC,~,ibC] = unique(c); [xC,yC] = deal(zeros(1,length(uC)));...
13de1e7790aa2933933655bd749566bfb2cbb65d10903c24bca45011325efbba
MATLAB
842
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 %____________________________________________________...
65b29a692ae712239429feddf8f6595d65a41fcccd4f1f6b9130df4b5c6dd21f
MATLAB
842
23
function [reconst, el_model_right, el_model_left, sides] = ea_get_reconstruction(reconstruction_file_path) try reconst = load(reconstruction_file_path); catch ea_warndlg('The reconstruction file was not found') return end if length(reconst.reco.props) == 2 sides = [...
1b413cfcd4ce6ee1970c15e5c31549ff18267bf55f1e705e6eb94b9ef3520fa8
MATLAB
843
24
function ea_Tmap(varargin) % creates a simple weighted T-map. % ea_Tmap(fis,regressor,outputname,mask,sk) % sk can be 'k','s','sk' % for smoothing and normalization options. Mask only necessary if % choosing 'k' option. regressor=varargin{2}; output=varargin{3}; [X,n]=ea_genX(varar...
42601d2a9622de97598d58601a357f86b50a4ac144450a1388260859c492a241
MATLAB
843
34
function [ OutTable ] = subfun_write_to_MapPlot_byR( MapData , DataLabel , atlasInfo , SaveName ) label = {}; score = -100*ones(size(atlasInfo,1),1); score(DataLabel) = MapData; for i = 1:size(atlasInfo,1) if atlasInfo.LR{i} == 'L' prefix = 'lh_L_'; else prefix = 'rh_R_'; end switch atl...
77b0b99020e65adc532cb6af205893c8bbbf87c5a3681dedec941684dc3a7892
MATLAB
843
31
function normpower = tfrnorm(rawpower, baseline, method) % Normaliise time-frequency power using one of the following methods: % % db = Decibel normalisation % pct = Percent change % div = Divide by baseline % z = z-score % % % Required inputs: % % rawpower: frequency x times matrix % baseline: Indices for baseline per...
9b1ae8a62c5ddb938047c4a17addb0adf75200a820464375881c5933023c50e1
MATLAB
843
31
%GetNextItem - Get next item from a Batch object (iterator mode). % % This is a helper class to easily read and parse batch files. % % USAGE % % [b,item] = GetNextItem(b); % % b batch object % Copyright (C) 2007 by Michaël Zugaro % % This program is free software; you can redistribute it and/or mod...
76638549c47fc58b70d5fe768fd6dd758f59af374052d1b1077d85b210117077
MATLAB
844
26
function dend_shaft = shaftloc(dend_shaft, dendriteROI) for i = 1:length(dendriteROI) if ~isempty(dendriteROI(i).dend_line) dend_line = dendriteROI(i).dend_line; dC = diff(dend_line,1,1); arc = cumsum(sqrt(sum([zeros(1,2); dC].^2,2))); dendriteROI(i).arc = arc; end end for k = 1...
d673da6d30ce4a919efdc743a637b298b8f573ed8712b28752c4305f1352ec92
MATLAB
844
31
function M = Q2M(Q) % Generate a rotation matrix from a quaternion xi+yj+zk+w, % where Q = [x y z], and w = 1-x^2-y^2-z^2. % See: http://skal.planet-d.net/demo/matrixfaq.htm % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: Q2...
fdb694c58993c11954df4554bdab9e991b577a0d47007f16b585ccf63cac30bb
MATLAB
844
24
function y = sum_square_abs( x, dim ) %SUM_SQUARE_ABS Sum of the squares of absolute values. % For real arrays, SUM_SQUARE_ABS(X) computes the same result as % SUM_SQUARE(X). For complex arrays, SUM_SQUARE(X) first computes the % magnitudes of the elements of X, so it compute SUM_SQUARE_ABS(X). % % Similarly...
b1c5aceb3d5c64ee8182ca5c2d417be36813f17fe0fd879277ce409dbafc633c
MATLAB
845
26
function ea_denoise_mri(input,output,sigma) basedir = [fileparts(mfilename('fullpath')), filesep]; ea_dispt(['Denoising: ',input]); UNLM = ea_getExec([basedir, 'UnbiasedNonLocalMeans'], escapePath = 1); if ~exist('sigma','var') sigma=5; end cmd=[UNLM,' --sigma ',num2str(sigma),' ',ea_path_helper(input),' ',ea_p...
5e2c5734e791bfc88f51970f256f057d11961e5806deb6360f19fe107769b00f
MATLAB
846
33
%COPYFIG Create a copy of a figure, without changing the figure % % Examples: % fh_new = copyfig(fh_old) % % This function will create a copy of a figure, but not change the figure, % as copyobj sometimes does, e.g. by changing legends. % % IN: % fh_old - The handle of the figure to be copied. Default: gc...
ba36bd1ece0cd15f741010d2d0a8c5293ece4fab71b9e6cf1bf77dab0971a93e
MATLAB
846
25
function fina=ea_dosk(fina,mask) [pth,fn,ext]=fileparts(fina); nii=ea_load_nii(fina); nii.img(~mask)=nan; nii.img(mask)=ea_normal(nii.img(mask)); nii.fname=fullfile(pth,['k',fn,ext]); ea_write_nii(nii); matlabbatch{1}.spm.spatial.smooth.data = {[fullfile(pth,['k',fn]),'.nii,1']}; matlabbatch{1}.spm.spatial.smooth.fwhm ...
ce8df601c535ea4e2e7a819c0ea2f9e45bd26dcd083adc5f49e2f6b0353845a8
MATLAB
846
31
function CBIG_ASDf_plotLoglike(inputDir, k, r) % CBIG_ASDf_plotLoglike(inputDir, k, r) % % This function plots the "climbing" of the log-likelihood. If the model % has converged, the plot should go flat. % % Input: % - inputDir: % Absolute path to the input directory where the model estimation % ...
dbcb0a2bdd2ac4886536cbfc23238af13a99573595f05747160e6ab13e475749
MATLAB
846
33
function [isSession, path] = bz_isSession(varargin) % USAGE % [isSession] = bz_isSession(event) % % checks that the path is a recording session % % INPUT % % % OUTPUT % % % written by david tingley, 2017 if nargin == 0 path = pwd; else path = varargin{1}; end pathSplit = strsplit(path,'/'); sessi...
ffe3ad9f0c6f48f2e864703af9748011f8914c62e7fb65e74721682aba8bb7e0
MATLAB
846
35
function root = AlignSpike2LFP(root) % Aligns Spike times to the LFP frames. Populates root.Spike(n,m).i_lfp % % For every root.b_lfp, aligns root.b_lfp.ts to spike times for all cells % in root.spike.ts. % % root = root.AlignSpike2LFP import CMBHOME.Utils.* root.cell_thresh = 0; if isempty(root.b_lfp) disp...
203a66316ee6cdac41fb566b877a21b048757e8e8fedc8e13f27f6a76956ccf4
MATLAB
847
26
function ea_init_normpopup(handles, defaultmethod, handlestring) % Initialize normalization methods popupmenu. % Set normmethod popupmenu by default % In checkreg window, we need to set coregmrmethod popupmenu if ~exist('handlestring','var') handlestring = 'normmethod'; end % Get functions and names funcs = ea_re...
4861b267204751ec8cbfeef7ca5e8b646d39c3810cab3fe2968af7b82e7d0e38
MATLAB
847
31
function snorm=surfacenorm(node,face,varargin) % % snorm=surfacenorm(node,face) % or % snorm=surfacenorm(node,face,'Normalize',0) % % compute the normal vectors for a triangular surface % % author: Qianqian Fang, <q.fang at neu.edu> % % input: % node: a list of node coordinates (nn x 3) % face: a surface mesh tr...
b87b521642abae246fabfacab0020b30fad9d07529085c450ba3879e6e37fc79
MATLAB
847
42
function [Atout,ttout] = DSBOfnRK4(Ai0,t_ini,t_final,t_step,QAi,etaAi,eta,ntout) % nt = floor((t_final-t_ini)/t_step); ni = length(Ai0); Ait = zeros(ni,nt); ttime = zeros(1,nt); % initialization tt = t_ini; Ai_old = Ai0; jj = 1; Ait(:,jj) = Ai_old; ttime(jj) = tt; while (tt<=t_final) % Runge Kutta 4 [Ai_K...
c17d62c8ae60844db399e1980f54a48dddce640152bb9a1c81058574f4dd2156
MATLAB
847
35
function [R,s]=rotmat2vec(u,v) % % [R,s]=rotmat2vec(u,v) % % the rotation matrix from vector u to v, satisfying R*u*s=v % % author: Bruno Luong % URL:http://www.mathworks.com/matlabcentral/newsreader/view_original/827969 % % input: % u: a 3D vector in the source coordinate system; % v: a 3D vector in the target co...
fee29043fac9a87221e9d394cf294efe3342de0895258053aa0c832385699084
MATLAB
847
27
[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 ...
6a7c548925a31f824847c702ffc25d8a78926f768f14c4d2374a84e99841959e
MATLAB
848
26
function [iscellinfo] = bz_isCellInfo(cellinfo) % USAGE % [] = bz_isCellInfo(spikes) % % INPUT % cellinfo - struct with the following fields % .UID % .sessionName % .region % % OUTPUT % logical true if struct meets cellinfo criteria, false if otherwise ...
692b912497dd41a987c2c659a23ee18cfd1d4d2931659ea85c309d5191c52cee
MATLAB
849
30
function stampsel = prepStampRespPlot(handles) scrsz = handles.scrsz; pos = round([50 scrsz(4)*0.4 400 300]); stampinfo = handles.stampinfo; N = length(stampinfo); hplot = figure(25); clf('reset') set(hplot, 'NumberTitle', 'off', ... 'MenuBar', 'none', ... 'ToolBar', 'none', ... 'Name', 'Set up fitting', 'P...
79db6653094b72610515dbc5e3975273defa285c2ea6826df1794420c7e68460
MATLAB
849
28
clc clear all close all addpath(['.' filesep 'eeglab2022.0' filesep]); eeglab; eeglab_template = EEG; % empty template of eeglab struct close all; % close eeglab EEG_dyad = pop_biosig('eegdata/dyad02.bdf'); % load one bdf of your dataset NB_EEG_CHAN = 64; % set number of EEG el...
3a0e3789a0b6c8d7d08bcad2de302973655abd9b64c06cca89e62d881fa108f1
MATLAB
852
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....
8ec4a85bf6e07569e181b158ae0ad7a9e5c8713a35394733c033e02cb27951e8
MATLAB
852
24
function [AllX] = ea_unified_networkmapping_recalcvals_sk(obj,sk) AllX=obj.results.networkmapping.(ea_conn2connid(obj.calcsettings.netmap_connectome)).connval; td=ea_getleadtempdir; % get nifti space switch size(AllX,2) case 902629 % 222 space=ea_load_nii(fullfile(ea_getearoot,'templates','spacedefinition...
efb69d05cdc6715fe4ed01c5e2ba0b217a820eb1c938700502ae8beca5c304c0
MATLAB
852
29
function X = chop(Xin,n,unit) %CHOP CHOP(X,n) rounds elements of X to n significant figures. % CHOP(X,n,unit) rounds the elements of X to n significant % figures whose digits (mantissa) are exactly divisible % by unit. % % e.g. chop(3.141592,5) returns 3.141600000.. % e.g. chop(3.14159...
671643af1c6e8b9cd2d851c6f59681718469ee6a2624d88f1956e8bdea04ab92
MATLAB
854
34
% Euclidean distance between polyhedra % Section 8.2.1, Boyd & Vandenberghe "Convex Optimization" % Joelle Skaf - 10/09/05 % % Given two polyhedra C = {x | A1*x <= b1} and D = {x | A2*x <= b2}, the % distance between them is the optimal value of the problem: % minimize || x - y ||_2 % s.t. ...
d5f9829cf312119d60e958c8dc43cdd2957f21e5b2a4f0d7d4f08baf02e9da34
MATLAB
854
36
function in = UIInPolygon(X,Y) %UIInPolygon - Find points in interactively defined polygon zone. % % Mouse buttons: % left = add polygon point % right = remove last polygon point % middle = close polygon % % USAGE % % in = UIInPolygon(X,Y) % % X,Y polygon coordinates % in ...
330fbaf622c7bb45fbaadbd1574c7537ec0151fd68ef679775b6a5612b3d40ae
MATLAB
855
33
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % demo script for surface repairing using surf2vol and remeshsurf %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% preparation % user must add the path of iso2mesh to matlab path list % addpath('../'); % user nee...
94a5032c9d13f9378462077c32750839558b664abcada1bb3c9c6e400a84512b
MATLAB
855
40
function oldcolor=setlinecolor(colors) % Usage ... setlinecolor(colors) % dlha = get(gca,'children'); if (nargin==0), colors=[]; end; if (isempty(colors)), getcol=1; colors=ones(length(dlha),3); else, getcol=0; end; if (length(dlha)>1)&(size(colors,1)==1), disp(' making all lines the sa...
994ec91d77affe948d457c522b31f0c748cf916b997a052e0e6402ca198eae51
MATLAB
855
24
function loglik = RicianLogLik(meas, signals, sig) % Computes the log likelihood of the measurements given the model signals % for the Rician noise model. % % loglik = RicianLogLik(meas, signals, sig) returns the likelihood of % measuring meas given the signals and the noise standard deviation sig. % % meas are...
97182b9c055b015a20434130c407f62df62a749dab6639e1a4e542a42e3b5028
MATLAB
856
41
plot(data_PiezoMonitor(100000:200000)); % Downsampling to 7.5Hz % 降采样到7.5,原始32k, pktemp = []; for i = 1 : 4911 pktemp(i) = mean(data_PiezoMonitor((4000*(i-1)+1):(4000*i))); end plot(pktemp); hold on plot(Cssimval0); plot(a11(:,2)); % i=8; % figure % plot(data_PiezoMonitor); % plot(data_PiezoMonitor(i*90*30000:(i+...
b94e83e9ebdafce4a058b6aa8ed0c815179331869c5baf081f73e700800e4e19
MATLAB
856
38
function roi2roi_correl(sublist,roilist,outfile) % read in text files to create matlab cells sID=fopen(sublist); sublist=textscan(sID,'%s'); sublist=sublist{1}; fclose(sID); rID=fopen(roilist); roilist=textscan(rID,'%s'); roilist=roilist{1}; fclose(rID); % iterate subjects/rois to create matrix. for sub=1:length(sub...
c37dc8076588b0557cc0faef26673ad6215bbee858dc1fb0b5191ba0f6f52d46
MATLAB
856
36
function intersect=CheckInputMesh(V,F,T) if(exist('T','var')) F1=T(:,[1 2 3]); F2=T(:,[1 4 2]); F3=T(:,[1 3 4]); F4=T(:,[3 2 4]); F5=F; F=[F1;F2;F3;F4;F5]; end [intersect1 FV]=CheckMeshInterSections(V,F); if(intersect1) warning('CheckInputMesh:Input','Mesh intersections...
19ea5cb22db98861640f857e5d1a40b2a947980bf2a946da58a3a176bf0bd600
MATLAB
858
33
function data=locsmooth(data,Fs,Tw,Ts) % Running line fit (using local linear regression) - 1d only, continuous % processes % Usage: data=locsmooth(data,Fs,Tw,Ts) % Inputs: % Note that units of Fs, movinwin have to be consistent. % data (single vector) % Fs (sampling frequency) - optional. Default 1 % Tw ...
1b97abdc07d5c7d3883b97b3c50e361258cab76f5df92b48b0bb9e36e7bb7af9
MATLAB
858
33
function plotProportionMapCCF(dorsalMaps, allROIs, propField, color) % Creates a binned and smooth map of cell count proportions based on the % field propField % Figure allenMapSMc(dorsalMaps, [-3.6, 0, -2, 3]) % Creates figure by itself % Plot params xLimits = [-4 0]; yLimits = [-2.35 3.3]; gridRes = 50; smoothSD = ...
667e419e727212a25365a59442cbfc3183769fb65eb9e50b2aeaf1bd626f83a8
MATLAB
858
30
function [whichnormmethod,template]=ea_coregmethod(directory) try load(fullfile(directory,'ea_normmethod_applied')); cnt=0; while 1 whichnormmethod=norm_method_applied{end-cnt}; switch whichnormmethod case {'ea_normalize_apply_normalization'} cnt=cnt+1; ...
cf7062885c6b5f5d422124e4f4f44776c764d0ed8d8b9d049939b8463dc5e609
MATLAB
858
25
% DLC.load % Read DLC in csv format into a MATLAB table. % 2022-07-13. Leonardo Molina. % 2023-11-09. Last modified. function data = load(path) fid = fopen(path, 'rt'); % Ignore first line. fgetl(fid); % Get header. line = fgetl(fid); columns = strsplit(line, ','); nColumns = nu...
e664a1ca15de50eaf5836343cc2042960405ac61708d95b2d84970826520391d
MATLAB
858
28
function plotPCsMapCCF(dorsalMaps, allROIs, PCnum, smoothSD, cmapInfo) % Wrapper for plotMetricMapCCF, to simplify plotting % Add PC values as a new field metricField = 'PCval'; for i = 1:length(allROIs) allROIs(i).(metricField) = allROIs(i).rotPCs(PCnum); end % Call mapping function plotMetricMapCCF(dorsalMaps, ...
23a9968ebf21a86b78ae238697b8d8501c85f3885b5b939751f2a4fadb272b93
MATLAB
859
34
function newnode=sms(node,face,iter,alpha,method) % % newnode=sms(node,face,iter,useralpha,method) % % simplified version of surface mesh smoothing % % author: Qianqian Fang, <q.fang at neu.edu> % date: 2009/10/21 % % input: % node: node coordinates of a surface mesh % face: face element list of the surface mes...
5677be88c988fe09ef900e6831ce720c31ab2ad3ce1c320e4cdc75b931ef300e
MATLAB
859
28
function Correct_all(headpath,fileexpnum) %give this function the path of the folder you want to start in as headpath %then give it the starter or the regex before the numbering starts %iterates through all files and does the motion corretion using %ADP_Motion_Correction3 cd(headpath); filelist=dir; for k=1:nu...
5ff6b3a6a0958a6c74863ccd7c863e55c34ebf9358f6d8088ed3110cbc647277
MATLAB
861
15
function S = NEXI(b,t,tex,Da,De,Dp,f) % full KM D1 = @(x,b,Da) Da*b'*x.^2; D2 = @(x,b,De,Dp) b'*Dp + (De-Dp)*b'*x.^2; Discr = @(x,b,t,tex,f,Da,De,Dp) (t./tex.*(1-2*f)+D1(x,b,Da)-D2(x,b,De,Dp)).^2 + 4*t.^2./tex.^2.*f.*(1-f); lp = @(x,b,t,tex,f,Da,De,Dp) (t./tex+D1(x,b,Da)+D2(x,b,De,Dp))/2 + sqrt(Discr(x,b,t,tex,f,Da,De...
a0c3122fea6402967d4d173c58900f5e6a0022c4d1022c748d6022b17fc7159d
MATLAB
861
36
function [varargout] = kruskal_mst(A,varargin) % KRUSKAL_MST Compute a minimum spanning with Kruskal's algorithm. % % The Kruskal MST algorithm computes a minimum spanning tree for a graph. % % This method works on weighted symmetric graphs. % The runtime is O(E log (E)). % % See the mst function for calling informatio...
a1385135a7efb3c236725d471ccf3d0edc019ed39a224d35fcfe10785d40057c
MATLAB
861
25
function matrix_output=padded_cell2mat(cell_input,pad) % Convert a ragged cell array of arrays in a padded matrix % Pierre Morel 2015. %With cellfun % ticID=tic; % maxLength=max(cellfun(@numel,cell_input)); % tempcell=cellfun(@(x)horzcat(2,x,NaN*zeros(1,maxLength-length(x))),cell_input,'Uni...
aa970b74a87d1d44ec907c30aa530c1d2c5105558cd2c11cf068a2ec2e99c521
MATLAB
861
43
function d = size(a,varargin) % Method 'size' for file_array objects %__________________________________________________________________________ % Copyright (C) 2008-2012 Wellcome Trust Centre for Neuroimaging % % $Id: size.m 5160 2012-12-21 16:58:38Z guillaume $ sa = struct(a); nd = 0; for i=1:numel(sa) nd = ...
d43f9f4119b4a6f98861bf8edc56e6cfaabd345fafe9910992a78b3feecd7753
MATLAB
861
22
function ciftisave(cifti, filename, varargin) %function ciftisave(cifti, filename, ...) % Compatibility wrapper for cifti_write. if ~isfield(cifti, 'diminfo') error('cifti structure has no diminfo field, maybe use the old ciftisave code instead?'); end tic; try cifti_write(cift...
ce834580b51471f17d2b228186722d1de28ecf2a05d149e86abc04bb7e988347
MATLAB
862
31
function obj=set_limit_extra(obj,x_extra,y_extra,z_extra) %set_limit_extra Add some breathing room around data in plots % % Example syntax gramm_object.set_limit_extra([0.05 0.2],0.05) % first argument is XLim extra, second is YLim extra, extra % room is expressed as ratio to original limits. It is possible to set % ex...
e8cf506fbfafa825ff5f9d8bd64f1b733f9d0285163626c613c28ab732b9b05a
MATLAB
862
30
function canlab_help_publish(pubfilename) % This function publishes a help file to HTML % % Enter the name of the script to publish as the input argument % canlab_help_publish('CANlab_help_examples_TEMPLATE') close all % clear all codedir = fileparts(which('CANlab_help_examples_TEMPLATE')); codedir = fileparts(codedi...
271aa6b693216d7036e7fab4767b0060ee55ddbb6e3d6a784dd32e75e1da8deb
MATLAB
863
36
function SaveEvents(filename,events) %SaveEvents - Write events to file. % % USAGE % % SaveEvents(filename,events) % % filename event file name % events event data % % SEE % % See also NewEvents, LoadEvents, SaveRippleEvents. % Copyright (C) 2004-2011 by Michaël Zugaro % % This p...
00a0644f0d0304d79c83df1e9d22e0d0ca7fe6b12b0e842b04bd72a57a47ff90
MATLAB
864
30
function Am = createModelSignalLUT_classical(ten,alpha,tissue_parameters,sinterp,Pstruc,fid) alpha = 0; dirs = sinterp.bDir; Da = tissue_parameters(1); Dp = tissue_parameters(2); vf = tissue_parameters(3); [~, W] = createWeightingScheme(ten,Pstruc.b_weighting); E = squeeze(sum(cmult(dirs,ten,1,1).*repmat(dirs',[1 ...
104a7f34be6f899360054e6fc4d6746208877bc57c58ec34e87f5a7bced1ca7f
MATLAB
864
24
function matout = CatCA(cellin)% % Converts a cell array of vectors 'cellin' of size MxN to a matrix padded by NaNs of % size max_vector x N x M. This is useful for data structures in CMBHOME. % If cellin is a matrix, matout = cellin. The reason M (epochs) gets pushed % back to 3rd dim is that it is more often the case...
f0de2d48d9f517a32ab808f9393f332addb9657b05940200801ca7af7b902101
MATLAB
864
29
%CheckChronux - Make sure chronux is installed and functional. % % USAGE % % CheckChronux % -or- % CheckChronux(functionname) where function name is a string of the % chronux function you want to check % Copyright (C) 2007-2010 by Michaël Zugaro % % This program is free softw...
aa700513bb1cdbaa88fe2ad30197a6d834b38ea945c7097b09798a4233af2d0e
MATLAB
865
29
function numfaces = nfaces(surface_name, hemisphere); % % Usage: % numfaces = nfaces(surface_name, hemisphere); % % Description: % Returns number of faces/triangles for a surface (author: @saratheriver) % % Inputs: % surface_name (string) - Name of surface {'fsa5', 'conte69'} % hemisphere (string) - Name of hem...
5910ecca151837163c42965b7091c57f129fc4f50de3665dee230faa6bc15851
MATLAB
866
29
function s = nansem(x) %nansem - Compute standard error of the mean (SEM), ignoring NaNs. % % USAGE % % s = nansem(x) % % s vector or matrix over which the sem should be computed % Copyright (C) 2008-2011 by Michaël Zugaro % % This program is free software; you can redistribute it and/or modify % ...
16943ec97bbb3718b641747e7451ad6e8cda121275d8e2894f81aa38dc5a58d2
MATLAB
867
32
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: 2007/01/10 22:55:09 $ % $Revision: 1.2 $ % % Copyright (C) 2002-2007, % The General Hospital Corporation (Boston, MA). % Al...
098c147ed05a17e0fdb9983a3da60835493b2fd3222c052b50d58f49972a39c9
MATLAB
868
30
function psgOut = fieldtrip2danalyzer(psgIn) % Converts a FieldTrip raw struct to danalyzer format. %% % Authors: Dan Denis % Date: 2024-01-12 %% psgOut.data = psgIn.trial{1, 1}; psgOut.hdr.srate = psgIn.fsample; psgOut.hdr.samples = size(psgIn.trial{1, 1}, 2); psgOut.hdr.recStart = []; if ~iscolumn...
48686a846260de95a53ea4e182604170f10574bcfb5f87d9998adc056c3764b1
MATLAB
868
34
function [n,names] = plx_adchan_names(filename) % plx_adchan_names(filename): gets the names of a/d channels in a .plx or .pl2 file % % [n,names] = plx_adchan_names(filename) % % INPUT: % filename - if empty string, will use File Open dialog % % OUTPUT: % names - array of a/d channel name strings % n - ...
560022988d15a065c87b5a1c2c243113b2742cd99b3afc3efab7e97435ece3da
MATLAB
868
19
function [phiWMS, phiWMS_c] = calculate_corrected_phiWMS(atoms) % Get all atoms using PhiIDFull % atoms = PhiIDFull(X1, X2, Y1, Y2); % Calculate ΦWMS using the atomic decomposition: phiWMS = -atoms.rtr + ... % -I{1}{2}→{1}{2} atoms.str + ... % Part of Syn(X1,X2;Y1Y2) ...
a275002172dc8506ccc3791f0b08363f46d399386298b0e366d4712b3dfd4523
MATLAB
868
21
function [intact_fractions] = LCN_calc_intact_tracer_hill(params,times) % % the function y(t) = b/(1+(a/t)^n) will be fitted with b set to 1 % b = asymptotic value, assumed 1 at time 0 (100% intact tracer) % a = t where the function reaches half of its maximum (b/2) % n determines the steepness of the slope % % FORMAT:...