sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
9b59ceb2aab050e098cb353c2d7d8965e8c7b2ddc7df8d22c60d9c205c4ac861
MATLAB
295
17
% bem5a_figure_scales A = 40; Emax = A; Emin = -A; Eprimax = A; Eprimin = -A; n_ELevels = 40; %% Define dimensionless radius of the integration sphere (for precise integration near boundaries) R = 2; %% Define observation points in the cross-section (MsxMs observation points) Ms = 800;
c22885defe4dbd64f4621e81d7e94b7a630793786f2d1945dbc5ff7e5668f6e1
MATLAB
295
7
function [meanFiringRate, peakFiringRate] = ml_placefield_firingrate(meanFiringRateMap, positionProbMap) % Compute the mean firing rate across all of the locations meanFiringRate = sum( meanFiringRateMap .* positionProbMap, 'all' ); peakFiringRate = max(meanFiringRateMap(:)); end
01bb2924f737462b9226f45b6dc75057bb2e2cca94dffe5e0e46b60924b202ee
MATLAB
296
14
function[la,LLopt] = get_lambda(Y,zDimList,numFolds,M) dim = crossvalidate_fa(Y, 'zDimList', zDimList,'showPlots',false,'numFolds',numFolds); sumLL=[dim.sumLL]; LLopt= find(sumLL== max(sumLL),1); L=dim(M).estParams.L; LL=L*L'; [V,D]=eig(LL); la=diag(D); la=sort(la,'descend'); la=la(1:M); end
d563bbc1d98b57d0192bc7d420915855b3a34d88414798001885cde2da0b9cfb
MATLAB
296
8
function mask_f = had_get_mask(SC,HAD_S,i_it) mask_f=HAD_S.had_mat(HAD_S.row_i(i_it),:)'*HAD_S.had_mat(HAD_S.col_j(i_it),:); mask_f = (mask_f+1)/2; mask_f=interp2(HAD_S.XM,HAD_S.YM,mask_f,SC.gfx,SC.gfy,'nearest',0); mask_f(isnan(mask_f(:)))=0; mask_f(isinf(mask_f(:)))=0; mask_f=exp(mask_f*1i);
daa6c147eeb7332b6e3f492b3f4b86b67724921b0d640c83e3562240d6961760
MATLAB
296
8
function type_list = nexterrortype_type() type_list = {'Track Birth','birth', 'Track Death','death', 'Match Cost Ambiguity','swap', 'Large Jump','jump', 'Large Change in Orientation','orientchange', 'Velocity & Orient. Mismatch','orientvelmismatch', 'Large Major Axis','largemajor'};
1557010cfb5aca9ce4289e076829320ea72c19c9534ca14c98d792b3c0e2ed6e
MATLAB
298
11
% VL_GETPID Get MATLAB process ID % VL_GETPID() returns MATLAB process ID. % % Algorithm:: % VL_GETPID() returns the result of the getpid() system call on % UNIX-like operating systems and of GetCurrentProcessID() on % Windows. % % See also: VL_HELP(). % Authors: Andrea Vedaldi
25b16e9a97768772a042df00118edb92fe82f640b80a5d73ff44a065234fbc18
MATLAB
299
11
% Author: Zachary Chiang, Buenrostro Lab, Harvard University % Writes a 3D .tif file with the given filename function[] = write_3d_tif(filename, img) imwrite(uint16(img(:,:,1)),filename); for z=2:size(img,3) imwrite(uint16(img(:,:,z)),filename,'WriteMode','append'); end end
390c4f66541cdb8f2863b5925a78159992dd533a952aaba4e114bf452eac745b
MATLAB
300
11
function plotmyhist(Var,Nbins,VarRange,Mode,NN) % not sure what was this function. calls myhist (without NN) if nargin<4, Mode = 'lin'; end; if nargin<3, VarRange = [0,1]; end; if nargin<2, Nbins = 20; end; if isempty(VarRange), VarRange = [0,1]; end myhist(Var, VarRange, Nbins, Mode);
ed4fe42858a610b24fc28b3538f6ed8e9f96551edd467d1ffc2f24b031b6a349
MATLAB
300
11
function [similarity indSim] = SSSimBoxFillSize(a, b, blobStruct) % Calculate similarity for a single edge. % a is blob a. % b is blob b. % blobStruct is the list of blobStruct indSim(:,1) = SSSimBoxFill(a, b, blobStruct); indSim(:,2) = SSSimSize(a, b, blobStruct); similarity = mean(indSim, 2);
1a6d1bbfbfababb09fbd780a77c51c06ff9dbb38fcedbeb111ed15fcbae10782
MATLAB
301
14
function [map] = assignTextons(fim,textons) % function [map] = assignTextons(fim,textons) d = numel(fim); n = numel(fim{1}); data = zeros(d,n); for i = 1:d, data(i,:) = fim{i}(:)'; end d2 = distSqr(data,textons); [y,map] = min(d2,[],2); [w,h] = size(fim{1}); map = reshape(map,w,h);
93b4692227dbd6f87b6b027deb51d8071685ed5f08d23b024754b8e4ca82c5a4
MATLAB
301
17
function [tl] = tlcompact(nR,nC,titlestr,tftsz) %tlcompact.m %title string and title font size are optional tl = tiledlayout(nR,nC,'Padding','compact','TileSpacing','compact'); n = nargin; if n >= 3 tl.Title.String = titlestr; if n > 3 tl.Title.FontSize = tftsz; end end end
a68dda92c3ff8a71e0d11b043d3a567497b71bc363bb30505a970bca25b6e2a2
MATLAB
301
8
function post_install (d) fprintf ('The statistics-resampling package was installed into the directory:\n'); fprintf ('%s\n', d.dir); fprintf ('License and copyright information can be found at:\n'); fprintf ('https://github.com/gnu-octave/statistics-resampling/blob/master/COPYING\n'); end
4ffdc1ac94a033cf54f3d74d5c7e790a52fdc57e8d108b18601bd278459a1af7
MATLAB
302
14
function Ind = IndexOfMultiples(A) T = true(size(A)); off = false; A = A(:); for iA = 1:numel(A) if T(iA) % if not switched already d = (A(iA) == A); if sum(d) > 1 % More than 1 occurrence found T(d) = off; % switch all occurrences end end end Ind = find(~T); end
8911f7f02ca4320b94032151dd8a80facf3f1cf2116a640f91ff90039506359d
MATLAB
302
9
function Params = permuteParams(Params) Params.fov = Params.fov([2,1,3]); Params.sizeVol = Params.sizeVol([2,1,3]); Params.voxSize = Params.voxSize([2,1,3]); if isfield(Params, 'sizeRecAll') Params.sizeRecAll = Params.sizeRecAll([2,1,3:length(Params.sizeRecAll)]); end end
edce67e3453106294e3870352d44c9a81b2c261866bcd2f934fdd9ffdfb7cb22
MATLAB
302
6
function [center_bins_deg] = ml_alg_chist_center_bins(n_bins) % Computes the center bins for a circular histogram (equal bin widths). dtheta_deg = 360.0 / n_bins; center_bins_deg = (0:n_bins)*dtheta_deg; center_bins_deg(center_bins_deg==360) = []; % drop if 360 included end % function
ef723b624dfe5a4bc156a44ad2f5d4c642187dda92d9dbad7209fed2f0655794
MATLAB
302
11
function o = vertcat(varargin) % Vertical concatenation of file_array objects. % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: vertcat.m 8776 2013-11-14 09:04:48Z roboos $ o = cat(1,varargin{:}); return;
769a1fe77fe3a8ba959fb0e1687a1dd6fbdca8756cbf4d68c866f6b8d04fb9b1
MATLAB
303
11
function out = gaussianfilterdata(data,sigma) %convolves a data set with a gaussian of width 'sigma' L = length(data); xx = (1:L) - round(L/2); if iscolumn(data) xx = xx'; end g = exp(-.5.*xx.^2./sigma^2)/sqrt(2*pi*sigma^2); out = fftshift(ifft(fft(data).*fft(g)));
99f269f10b95dd0f2c10641b33e7ac3376eda49ca4a7c2ec579fd8b86f0054d3
MATLAB
303
10
function varargout = permute(varargin) % Can not be permuted. % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: permute.m 8776 2013-11-14 09:04:48Z roboos $ error('file_array objects can not be permuted.');
45061cad6f8b5c5c4bc850f5ed494e4482e07d0d6d4591c9811a43ebda63811d
MATLAB
304
12
function n=SONMaxChans(fh) % SONMAXCHANS returns the number of channels supported by a SON file % % N=SONMAXCHANS(FH) % where FH is the SON file handle % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 n=calllib('son32','SONMaxChans',fh);
0b8fe277c6044cf32c9edab1ad118c3b030f2946bb5e584a7b025e944ac667d4
MATLAB
306
11
function o = horzcat(varargin) % Horizontal concatenation of file_array objects % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: horzcat.m 8776 2013-11-14 09:04:48Z roboos $ o = cat(2,varargin{:}); return;
19d1a3413353a583df3be23546c378544712d7930b02958d8d8b4b6ab06de634
MATLAB
306
7
%% Chi2stat and pval sub-function function [pval, chi2stat_out] = calc_chi2(metric_use, bins_use) n = histcounts(metric_use, bins_use); e_unif = sum(n)/length(n); % Expected count in each bin for uniform distribution chi2stat_out = sum((n-e_unif).^2/e_unif); pval = chi2pdf(chi2stat_out,length(n)-1); end
4f712f96f6daf1dc1deac75a16a0bdbb0924207d2f98726b7f6e04e9de8d473b
MATLAB
306
8
%data是想要滤波的矩阵,Fs实际采样率,f滤波半径(截至频率),按列滤波 function [output]=zero_filter_lowpass(data,Fs,f) Mix_Signal=data; Wc=2*f/Fs; %生成Butterworth滤波函数 [b,a]=butter(2,Wc); Signal_Filter=filtfilt(b,a,Mix_Signal);%滤波 output=Signal_Filter; end
f1bdce865122b687215bf48fe2ea02db3cd6c329b5dacf3fb77a67557672fae7
MATLAB
307
13
% plot ephys Files = dir(cd); Files(~contains({Files.name}, {'.mat'})) = []; for i = 1:length(Files) figure() load(fullfile(Files(i).folder, Files(i).name)) timeVec = 0:(1/50000):(length(ephysData)-1)/50000; plot(timeVec, ephysData); title(Files(i).name); disp(Files(i).name); end
02878225b75ecbe5c7465de2a043d67b77b7c5ed7c064721bbe1b5f18285ad48
MATLAB
308
10
function NuOut = Phi(NuIn, Net) % sigmoid = @(x)1./(1+exp(-4*x)); % Logistic function as a shifted hyperbolic tangent. sigmoid = @(x)tanh(x); % As in (Sompolisky et al., PRL 1988). if size(NuIn,1) == 1 NuIn = NuIn'; end NuOut = sigmoid(Net.CParam.J*NuIn + Net.MParam.IExt)./Net.MParam.Tarp;
12335948f3e3104571c6ce33f36d2c1599ff3d89ce413cf94ecb8954d407a6f2
MATLAB
308
11
function [similarity indSim] = SSSimBoxFillOrigSize(a, b, blobStruct) % Calculate similarity for a single edge. % a is blob a. % b is blob b. % blobStruct is the list of blobStruct indSim(:,1) = SSSimBoxFillOrig(a, b, blobStruct); indSim(:,2) = SSSimSize(a, b, blobStruct); similarity = mean(indSim, 2);
40151304d8131673a1216bc1c328f986cceb9e43ae49ec50ff27d1bb0fdaaafa
MATLAB
308
11
% send triggers via USB to serial adapter (e.g. USB 2.0 Adapter [1x RS485-Stecker - 1x USB 2.0 Stecker A] Weiß Digitus) USBTTL_2('Open' ,'USB0'); triggerDur = 0.01; % send trigger after e.g. Screen(window, 'Flip') command triggerOnset = sendTrigger( p.triggerDur); USBTTL_2('Close' ,'USB0');
c3ba9c908b1ef23a5f49c6f8c76a91293ac6e01f4b0462e86f16acb4bff133c3
MATLAB
308
12
function d = double(ipa) % INPLACE/DOUBLE Return the data as a Matlab double type. % d = double(ipa) returns a double array. Changing d will not change the % ipa data. % % Example: % ipa = inplace(cumsum(ones(5,1))); % d = double(ipa); % d(2) = 10: % Doesn't change ipa % ipa d = ipa.get_a();
e89ee913a40a5390916f653110445270863716099736879e2c8155d5a1dec7f0
MATLAB
308
20
function maxV = findMaxLength(fpr_iter, fnr_iter) %init maxV = -1; for i = 1 : numel(fpr_iter) l = length(fpr_iter{i}); if l > maxV maxV = l; end %if l end %for i for i = 1 : numel(fnr_iter) l = length(fnr_iter{i}); if l > maxV maxV = l; end %if l end %for i
b4cb545fca06615633520b25ee9e5a68058c6f40f9f5449516a34814d2af650b
MATLAB
309
11
function bytes=SONFileSize(fh) % SONFILESIZE Returns the expected size of a file % BYTES=SONFILESIZE(FH) where FH is the file handle % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 bytes=calllib('son32','SONFileSize',fh); return;
de827b8f7a2a3ce7fb46a73c96656783e02874e0718da9a7e03fa76695799194
MATLAB
309
20
function minV = findMinLength(fpr_iter, fnr_iter) %init minV = 1e9; for i = 1 : numel(fpr_iter) l = length(fpr_iter{i}); if l < minV minV = l; end %if l end %for i for i = 1 : numel(fnr_iter) l = length(fnr_iter{i}); if l < minV minV = l; end %if l end %for i
f627dbdfb09bec6dffc64516e0e57d61cc962367088c8c3b045ca95ae9c158d1
MATLAB
309
14
function display(obj) % Display a NIFTI-1 object % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: display.m 8776 2013-11-14 09:04:48Z roboos $ disp(' '); disp([inputname(1),' = ']) disp(' '); disp(obj) disp(' ')
0e7e1b3f455cfd13cc651876c3df6a1606be73953d20f909f43a0cd08453c9da
MATLAB
310
23
function [FD cat_FD FD_TR]=get_frame_removal(filename,ticks); if nargin<2 ticks=51; end load(filename); try mot=FD_data; end try mot=motion_data; end cat_FD=mot; FD_TR=mot{1}.epi_TR; [r c v]=size(mot); if v==1 FD=zeros(1,ticks); end for j=1:ticks FD(j)=mot{j}.remaining_frame_count; end
440951b5ba564e4bc0be8bd9175b3ddb8d8e5cafc3d27595480f85d5aa354aea
MATLAB
310
15
function n=num_vertices(A) % NUM_VERTICES The number of vertices in a graph. % % n = num_vertices(A) returns the number of vertices in graph A. % % Example: % A = sparse(ones(5)); % n = num_vertices(A); % % See also NUM_EDGES % David Gleich % Copyright, Stanford University, 2006-2008 n = size(A,1);
71d5979b04b14637d04018284f37ef29774f1bf9bbb69f579017e1c0b9bd271c
MATLAB
310
10
function [similarity indSim] = SSSimColour(a, b, blobStruct) % Calculate similarity for a single edge. % a is blob a. % b is blob b. % blobStruct is the list of blobStruct % Histogram intersection similarity = sum(bsxfun(@min, blobStruct.colourHist(:,a), blobStruct.colourHist(:,b))); indSim = similarity;
38a23d1e71f0c5bacf9932155f0c312df5c6a961ee2a5a4bdcac0b368ffad698
MATLAB
311
11
function [spiketrain,ytrue] = SimulateSpike(splinematrix,theta,lastknot,nsteps) spiketrain = zeros(nsteps,1); for i=lastknot+1:nsteps lambda(i) = exp(theta*[1; splinematrix'*spiketrain(i-1:-1:i-lastknot)]); spiketrain(i) = min(poissrnd(lambda(i)),1); end ytrue = glmval(theta',splinematrix,'log'); end
dcd2b1b4be04378511fd42453dd406699b04aa893291d344b5b622c1a82458d0
MATLAB
311
13
function [xs] = ml_alg_circ_movmean(x, M) if mod(M,2) ~= 1 error('Windows size needs to be odd-valued'); end MH = (M-1)/2; y = [x(end-MH+1:end), x, x(1:MH)]; % Older versions of MATLAB do not have "movmean" z = movmean(y, [MH, MH]); xs = z(MH+1:end-(MH)); end
41e479d4764e926fe0f24a5250aaffd983a500479147b6787a70d57edb967172
MATLAB
312
19
% choice of tissue_dim: 4x4, 4x2, 4x1 (for Fig5) % For supplementary: % 1x1, 1x2, 1x4 % 2x1, 2x2, 2x4 % 4x1, 4x2, 4x4 % just set tissue_dim accordingly % tissue_dim = '4x4'; %<---- bem0_load_model; bem1_setup_coil; bem2_charge_engine; bem4_define_planes; bem5_figure_scales; bem5_volume_XY; bem5_volume_YZ;
8f7b56d93087c268fdc79c4091aa00b585e48a94bebdd77bd22c0220c65a8cf2
MATLAB
312
14
function display(obj) % Display a file_array object % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: display.m 8776 2013-11-14 09:04:48Z roboos $ disp(' '); disp([inputname(1),' = ']) disp(' '); disp(obj) disp(' ')
db8ea2587a6813d3d0af2c246161e10a247554577f29b19a949eb275ce7f3903
MATLAB
312
10
function [similarity indSim] = SSSimTexture(a, b, blobStruct) % Calculate similarity for a single edge. % a is blob a. % b is blob b. % blobStruct is the list of blobStruct % Histogram intersection similarity = sum(bsxfun(@min, blobStruct.textureHist(:,a), blobStruct.textureHist(:,b))); indSim = similarity;
084e243ac9a33000bee52c2eff064333d2bbb6b174c34309d1bc38f7aa72f1fa
MATLAB
313
8
function w = padded_conv(u, v) %This function takes variables u and v, convolves them like %conv(u,v,'same') but without the edge effect of the sharp jump padded_u = [repmat(u(1),1,length(v)), u, repmat(u(end),1,length(v))]; w = conv(padded_u, v, 'same'); w = w(length(v)+1:length(v)+length(u)); end
41ea483583ceb1e6d107188b88727ad6511c8c7a5a4a8acce6374bb45c67f1fb
MATLAB
313
12
function out = double(fa) % Convert to double precision % FORMAT double(fa) % fa - a file_array % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: double.m 8776 2013-11-14 09:04:48Z roboos $ out = double(numeric(fa));
a9a911101468c7931ce628055d0966dd4b10dfd5d7862e0de76e31eaba1eb856
MATLAB
313
7
% Marc Normandin, Muzzio Lab, Psychological & Brain Sciences, University of Iowa, 2024 function [hFig] = plot_average_rate_differences_within_across_bars(T) R = compute_average_rate_differences_within_across_for_table(T); hFig = plot_average_rate_differences_within_across_bars_table(R); end % function
edbcd12829dec82a31e07c0efde11b9b783fc96cebb851a63c17ae4f59363c2b
MATLAB
313
9
function varargout = ctranspose(varargin) % Transposing not allowed % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: ctranspose.m 8776 2013-11-14 09:04:48Z roboos $ error('file_array objects can not be transposed.');
091445f217916d6d746bce5db242b513ade581b001de52314104be5ecba8a233
MATLAB
314
10
function [similarity indSim] = SSSimFlow(a, b, blobStruct) % Calculate similarity for a single edge. % a is blob a. % b is blob b. % blobStruct is the list of blobStruct % Histogram intersection similarity = sum(bsxfun(@min, blobStruct.flowHist(:,a), blobStruct.flowHist(:,b))); indSim = similarity;
b0100a244e067baa9dd8ce531d501fea8457a408c59739312c08c6f618845a2d
MATLAB
314
11
function v=SONGetVersion(fh) % SONGETVERSION returns the SON file system version number for a file % % VERSION=SONGETVERSION(FH) % where fh is the SON File handle % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 v=calllib('son32', 'SONGetVersion', fh);
0d470a2c0ea1414ec507d3add4217c1567780adb7210cd1cb6e748c8973ced25
MATLAB
315
18
% Vertical Investigation for calibration issues %% Open Files file = 'G:\My Drive\Expmt Data\2019_09 - Kiah Calibration\Calibrations Modified'; fileInfo = dir([file '/*/*videoresults.mat']); for i = 1:length(fileInfo) cd(fileInfo(i).folder); findmagscaleVel end %% Plot x and y values of video
7cb0b45efaacb409a90d1c2fdd24061022e8b0f86e4e11e9eca06c94993949d6
MATLAB
315
15
function [head,tail] = period(r,multiFreq) %PERIOD Get last period % Detailed explanation goes here head = zeros(5,1); tail = zeros(5,1); if multiFreq idx = 2; else idx = 1; end for i = 1:5 [pks,locs] = findpeaks(r(5,:,i)); head(i) = locs(end-idx); tail(i) = locs(end); end end
369e6120b45a1fcadf8da7af68726e0bf4b45630b710ed5a94ca7078d2774d11
MATLAB
316
11
function result = get_scratch_folder_path() if ispc() , result = tempdir() ; elseif ~isempty(getenv('LSF_BINDIR')) , % We assume we're on a cluster node user_name = get_user_name() ; result = fullfile('/scratch', user_name) ; else result = tempdir() ; end end
36a646b572d9550ca96aec999fb46e8840b3266fc7a1f94855f083a5b3683b04
MATLAB
316
16
function err=SONEmptyFile(fh) % SONEMPTYFILE Deletes data written to file FH % % ERR=SONEMPTYFILE(FH) % - see CED documentation for details % % % Malcolm Lidierth 05/05 % Copyright © The Author & King's College London 2005-2006 if nargin<1 err=-1000; return; end; err=calllib('son32','SONEmptyFile',fh);
8ab1e894b8053f522660b0825f5f85876469cba555dc2e98fc617401c698a41d
MATLAB
316
12
function n=SONMaxChans(fh) % SONMAXCHANS returns the number of channels supported by a SON file % % N=SONMAXCHANS(FH) % where FH is the SON file handle % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 n=calllib('son32','SONMaxChans',fh);
cdce1009eaed9a685c84faf98d6b96a923a4a7f6eeee1fe37e569ee32a7359c6
MATLAB
316
10
function varargout = transpose(varargin) % Transposing is not allowed. % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: transpose.m 8776 2013-11-14 09:04:48Z roboos $ error('file_array objects can not be transposed.');
1c0075132d2a0153fda6c589141414049b7da09f2d03e2f327e071bfa0042444
MATLAB
317
6
clear load('P:\MSEv1.0\000000000200894\Genuine\000000000200894_Genuine_000000000200894_1_7268_11.5251.mat'); epoc_length=subject.EpochLength; chanlocs = '.\insightCED.ced'; eegData=subject.EEG; [d,eegICAprunned]=preProcessingPipeLine2(eegData,epoc_length,chanlocs);%% 'eegICAprunned' IS YOUR PREPROCESSED SIGNAL.
e7df1d3e0d5f7fcf2ee9152108864e31147faff531e3de8673b51e4dab9ae74d
MATLAB
317
15
function [map,textons] = computeTextons(fim,k) % function [map,textons] = computeTextons(fim,k) d = numel(fim); n = numel(fim{1}); data = zeros(d,n); for i = 1:d, data(i,:) = fim{i}(:)'; end [map,textons] = kmeansML(k,data,'maxiter',30,'verbose',0); [w,h] = size(fim{1}); map = reshape(map,w,h);
08cb1200360bfd2ef8d1a68347e8946a286212220d5b0b7b16b06debd6d56112
MATLAB
318
11
function bytes=SONFileBytes(fh) % SONFILEBYTES Returns the number of bytes in the file % BYTES=SONFILEBYTES(FH) where FH is the file handle % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 bytes=calllib('son32','SONFileBytes',fh); return;
a09639f7cab31b6993a505ea8b7c6dabf116b49329e2cfa9c529143551943fa6
MATLAB
318
11
% SONFACTIVE tests filter mask layers to see if they are active % % Implemented through SONFActive.dll % % ANS=SONFActive(FilterMask) % % Bits 0 to 3 are set in ANS if filter mask layers 0 to 3 are active. % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006
dea52071a67b0c17b4eddb92be8adcc5b724d3ddbff6ee1fced18533706b7234
MATLAB
318
10
function bytes=SONGetExtraDataSize(fh) % SONGETEXTRADATASIZE returns the size of the extra data area of file FH in bytes % % BYTES=SONGETEXTRADATASIZE(FH) % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 bytes=calllib('son32', 'SONGetExtraDataSize', fh);
e1ac87f29e519aa908a53cc7dd0257e40b35c588b007fc8ff52ed630a752543e
MATLAB
318
14
function gen_or_imp = checkGenOrImp(fileName_1, fileName_2) %IITD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ind1 = getIndName_IITD(fileName_1); ind2 = getIndName_IITD(fileName_2); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if strcmp(ind1, ind2) == 1 gen_or_imp = 'gen'; else % if strcmp gen_or_imp = 'imp'; end %if strcmp
fd8c5c1f293a1e4c6a6ed5ddf8b853e1f6dbcc80051f3fc856cebfd4aca89b7c
MATLAB
318
9
function [similarity indSim] = SSSimTextureFlowSizeFill(a, b, blobStruct) % Texture + Flow + Size + Fill indSim(:,1) = SSSimTexture(a, b, blobStruct); indSIm(:,2) = SSSimFlow(a, b, blobStruct); indSim(:,3) = SSSimSize(a, b, blobStruct); indSim(:,4) = SSSimBoxFillOrig(a, b, blobStruct); similarity = mean(indSim, 2);
4ea936535d20950af39abc7ac680b08411633a209dd0636a79af4a3b009ead23
MATLAB
319
15
function [bases,phi] = RaisedCos(t,a,b,nbases,cntrspace) input_cos = a*log(t + b); phi_srt = min(input_cos); phi_end = max(input_cos); phi = phi_srt:cntrspace:phi_end; bases = zeros(length(t),nbases); for i = 1:nbases bases(:,i) = ( cos( ... max(-pi, min(pi,(input_cos - phi(i)) )) ) ... + 1) / 2; end end
e75db6526b261bf2d90a7f566914dfdc92a1d9d3dd4af919ae196038bbbce837
MATLAB
319
11
function bytes=SONFileSize(fh) % SONFILESIZE Returns the expected size of a file % BYTES=SONFILESIZE(FH) where FH is the file handle % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 bytes=calllib('son32','SONFileSize',fh); return;
0a513a8a572e1ffb76eceef9243f2cf3b444afc73865973cbd38f499ab0fa83f
MATLAB
320
13
function [dr,ds] = getDistancesForEachSegment(data) data = sortrows(data,'hg38_pos'); dx = abs(data.x_um(1:end-1)-data.x_um(2:end)); dy = abs(data.y_um(1:end-1)-data.y_um(2:end)); dz = abs(data.z_um(1:end-1)-data.z_um(2:end)); ds = abs(data.hg38_pos(1:end-1)-data.hg38_pos(2:end)); dr = sqrt(dx.^2+dy.^2+dz.^2); end
84c6a52801c673607b1c1e8e851e46cff78a2654989c9154ce1f93a385848de7
MATLAB
320
9
function [similarity indSim] = SSSimColourTextureSizeFill(a, b, blobStruct) % Colour + Texture + Size + Fill indSim(:,1) = SSSimColour(a, b, blobStruct); indSim(:,2) = SSSimTexture(a, b, blobStruct); indSim(:,3) = SSSimSize(a, b, blobStruct); indSim(:,4) = SSSimBoxFill(a, b, blobStruct); similarity = mean(indSim, 2);
d0504617f6ca52b510664af8f7ddac7c05b226e08d0d7cde71d40d46fdbf3b49
MATLAB
321
16
% % Compute a link prediction measure. % % PARAMETERS % measure Name of measure % p (e*1) Predictions % T (e*3) To be predicted % % RESULT % value Link prediction measure ; higher is better % function [value] = measure_compute(measure, p, T) fh = str2func(sprintf('measure_compute_%s', measure)); value = fh(p, T);...
485f975d212fd49792d3f58c29d9c2508de361a6dffbfc0d27c07ceb08c7f890
MATLAB
324
11
function v=SONGetVersion(fh) % SONGETVERSION returns the SON file system version number for a file % % VERSION=SONGETVERSION(FH) % where fh is the SON File handle % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 v=calllib('son32', 'SONGetVersion', f...
86ff2b7434ad27d6e2d898114f71d759407cfddd5a3e061aad80d88bf20d351e
MATLAB
324
11
function chan=SONGetFreeChan(fh) % SONGETFREECHAN returns the number of the first free channel in a file % % CHAN=SONGETFREECHAN(FH) % where FH is the SON file handle % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 chan=calllib('son32', 'SONGetFreeChan', fh...
198b0e647a1d6ae7cdd36737b900e5826a2dcf6c8c55d8010d5f82ac399b5db8
MATLAB
325
6
function behavcam_roi_create( obj, session, trial ) % Ask the user to define the ROI [pROI] = ml_cai_behavcam_roi_create( trial.getAnalysisDirectory(), 'verbose', obj.isVerbose(), 'includeOtherROI', obj.Config.includeOtherRoi==1 ); save(fullfile(trial.getAnalysisDirectory(), 'pROI.mat'), 'pROI'); end % fun...
6943d8c7f2d85b6e3241824057259a7c9ed9ae18283aebf801f4c6457e7fc08a
MATLAB
325
11
SessionName = '20150906Thalamus36'; base_folder = SessionName; Files = getFiles(base_folder); filename = sprintf('%s\\%s',base_folder,Files{mm}); [spikes, LFP, theta, nose,Fs] = getSpikes(filename); Nframes = length(nose.x); [Nelecs, Nunits]=size(spikes); save ('tessdata1','Fs','spikes','theta','nose','LFP')...
6c70a1c0152785dfafa50bb495b5ae037bbec2a3a5bdcd2e79e3f948c2c95b45
MATLAB
325
11
function chan=SONGetFreeChan(fh) % SONGETFREECHAN returns the number of the first free channel in a file % % CHAN=SONGETFREECHAN(FH) % where FH is the SON file handle % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 chan=calllib('son32', 'SONGetFreeChan', f...
2baab1f1742123de05b1fcaba86d9f1464c887b62f81c1221f667ce44f9c4c70
MATLAB
326
17
function [ynn_t,nn_stat] = TrainNLS(Imat_t,dsr_t,nh,no) u = Imat_t; net_s = newff(Imat_t,dsr_t,nh,{'logsig','logsig'},'trainlm'); net_s.trainParam.max_fail = 1000; net_s = init(net_s); net_s.trainParam.epochs = 5000; [net_s,tr_s] = train(net_s,u,dsr_t); nn_stat = net_s; ynn_t = (sim(nn_stat,u))'; ...
d0677c5dde4a0285d3453d99e7b9d58f17cf91dd630fa48a4890d14d26991b1c
MATLAB
326
12
function [cycleMat, cycleMean] = VOR_breakTrace(cycleLength, startpt, vector) [cycleMat, ~] = vec2mat(vector(startpt:end), cycleLength, NaN); % Remove first 5 cycles (to account for drift) %cycleMat(1:5,:) = []; % Remove final (partial) cycle cycleMat(end,:) = []; % Calculate Cycles Mean cycleMean = nanmean(cycleMa...
18f9c131f3473bfb386466f72937e1a7ad06fd8d439df1a9cd86f370bd173791
MATLAB
327
12
function [edgesX] = ml_it_edges_x_uniform_density(x) nBinsX = 100; x = reshape(x, 1, numel(x)); nSamples = length(x); minX = min(x, [], 'all'); maxX = max(x, [], 'all'); nSamplesPerBinX = ceil(nSamples ./ nBinsX); sx = sort(x); edgesX = unique([minX, sx(1:nSamplesPerBinX:end), maxX...
2fa99da262f0bd67ad66d01e22d25936ea3e6e42ea71f3c3c75275d568078eaf
MATLAB
327
9
OCVRoot = 'D:\OpenCV2p49\opencv\build'; IPath = ['-I',fullfile(OCVRoot,'include')]; LPath = fullfile(OCVRoot, 'x64','vc12','lib'); % lib1 = fullfile(LPath,'cv210d.lib'); lib2 = fullfile(LPath,'opencv_core249d.lib'); lib3 = fullfile(LPath,'opencv_highgui249d.lib'); mex('edgesDetectMex.cpp', IPath, lib2, lib3, ...
4468c8ce40b296fdf4f788a6c3bdadba665266a845546ec56eb15053cf371c04
MATLAB
327
10
function bytes=SONGetExtraDataSize(fh) % SONGETEXTRADATASIZE returns the size of the extra data area of file FH in bytes % % BYTES=SONGETEXTRADATASIZE(FH) % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 bytes=calllib('son32', 'SONGetExtraDataSize'...
f615240a663be3f8f4d7fa750b02058f19f02e4a4099af44d946a6a5ee84045b
MATLAB
327
12
'20160601Thalamus45_opF' '20160602Thalamus48_opF' '20160602Thalamus49_opF' '20160603Thalamus39_opF' '20160603Thalamus44_opF' '20160730Thalamus43_opF' '20160730Thalamus44_opF_Nw' '20160730Thalamus45_opF_Nw' '20160730Thalamus48_opF_Nw' '20160801Thalamus43_opF_Nw' '20160904Thalamus40_opF' '20160905Thalamus40_op...
2f3b0822ee3ec54075a4ccb8e465846831aa67fab8b7eaa08d8f122b70698495
MATLAB
328
22
function ynn_v = ValNLD(Imat_v,dsr_init,nn_dyn,Xi,Ai,tv,no) u_v = Imat_v; X = tonndata(u_v,true,false); yv = nn_dyn(X,Xi,Ai); yn = zeros(no,tv-1); for i = 1:tv-1 yn(1:no,i) = yv{i}; end ynn_v = zeros(tv,no); ynn_v(1,1:no) = dsr_init; for i = 1:no ynn_v(2:tv,i) = (yn(i,:))'; en...
4d8494f702d46db4a04e95e5b02a2568f48e5bfee301e1b4cc0ad9c5ed321cf2
MATLAB
328
11
% SONFACTIVE tests filter mask layers to see if they are active % % Implemented through SONFActive.dll % % ANS=SONFActive(FilterMask) % % Bits 0 to 3 are set in ANS if filter mask layers 0 to 3 are active. % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 20...
5ef13266c5798318deea2b41b3bed7924cbff9f26545623f6cb913cb85df2b97
MATLAB
328
9
function [similarity indSim] = SSSimColourTextureSizeFillOrig(a, b, blobStruct) % Colour + Texture + Size + Fill indSim(:,1) = SSSimColour(a, b, blobStruct); indSim(:,2) = SSSimTexture(a, b, blobStruct); indSim(:,3) = SSSimSize(a, b, blobStruct); indSim(:,4) = SSSimBoxFillOrig(a, b, blobStruct); similarity = mean(ind...
c2e9f3f4a93379109cd2549f0718cedb9a556b1db5afb0932187ba4585083ed6
MATLAB
328
16
function output_valid=check_valid_net_output(output_info) % output_valid=true; if isempty(output_info) output_valid=false; else output_valid=output_info.forward_finished; % if isfield(output_info, 'valid_data') % if ~output_info.valid_data % output_valid=false; % end % end ...
c39a3443fda0040bb89d6d58657599e9e3a4cdb13c8d05e23c840c7339e62590
MATLAB
328
12
function [theta_max,A,theta_A,B] = had_fit_sin(OPT_S,ints) X=OPT_S.H_hat*ints; phases = OPT_S.phases; % ints = A*cos(phases + theta) + B A = sqrt(X(1)^2+X(2)^2); theta_A = atan2(X(2),X(1)); B = X(3); theta_max = -theta_A; x_est = A*cos(phases+theta_A)+B; figure(1251234);plot(phases,ints);hold on; plot(phases,x_est);hol...
ed8723904039309dadc4d2c0c7d1dceda0da1061278cdfd92e0b956532bbf32a
MATLAB
328
11
function bytes=SONFileBytes(fh) % SONFILEBYTES Returns the number of bytes in the file % BYTES=SONFILEBYTES(FH) where FH is the file handle % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 bytes=calllib('son32','SONFileBytes',fh); ...
fd36f456f9352e4581c9797559a7a442cca7e9b408de18771494d9db2f882429
MATLAB
328
12
function DPF = age2DPF(age, wl) % This function calculates the DPF based on age and wavelength(wl) as given by the formula of % Scholkmann & Wolf, 2013 (https://doi.org/10.1117/1.JBO.18.10.105004) a = 223.3; b = 0.05624; g = 0.8493; d = -5.723 * 10^(-7); e = 0.001245; z = -0.9025; DPF = a + b*age^g + d*wl^3 + e*wl^2 ...
13d696d6c3e6e7937bffb43683f1efcf20fc0b96130d824bd25140802f3e07c3
MATLAB
329
15
function labelidx = FlyTrackerBouts2LabelIdx(bouts,nframes) nflies = numel(bouts); labelidx = zeros(nflies,nframes); for fly = 1:nflies, if isempty(bouts{fly}), continue; end labelidx(fly,:) = 2; for i = 1:size(bouts{fly},1), t0 = bouts{fly}(i,1); t1 = bouts{fly}(i,2); labelidx(fly,t0:t1) = 1; ...
111a5f4d8f1bf6a37cc09f28a8e4d2e99dd7548ac2c57316c95d2d36524a955c
MATLAB
330
6
%capture ground truth from validation camera SC = set_PG_BP(SC); SC = laser_set(SC.laser_settings.laser_big_FOV,SC); %set laser to big area I = capture_PG_area_ramps(SC,FOV.TS_scan(end)/4,FOV.TS_scan(3)-FOV.TS_scan(1),'Ground Truth'); FOV.big_FOV_PG_finish = I; figure;imagesc(I);title('Big a...
2f8908366de949faca820c93446ed8dd17c0f3ea9d2b28a9a90a66745e026962
MATLAB
331
16
function err=SONEmptyFile(fh) % SONEMPTYFILE Deletes data written to file FH % % ERR=SONEMPTYFILE(FH) % - see CED documentation for details % % % Malcolm Lidierth 05/05 % Copyright © The Author & King's College London 2005-2006 if nargin<1 err=-1000; return; end; err=calllib('son32','SONEmpty...
7ad7c1abf4e33ad9f8e82395db4def2e21e4b069974abb6aa24787243555d9aa
MATLAB
331
18
function [cell_stat,redcell_vect,Fall]= convert_to_isCell(Fall,redcell_vect) % convert stat and redcell_vect to be in isCell==1 coordinates stat=Fall.stat; iscell=Fall.iscell; cell_stat=stat(iscell(:,1)==1); % reduce stat to only iscells redcell_vect=redcell_vect(iscell(:,1)==1); Fall.redcell_vect=redcell_ve...
c31f57e032394f13cf9238bcd6ecb787c1dca00cfaa5fc7e5c39a028cf84a098
MATLAB
332
8
function stabilityI = stability(xmat) [R C] = size(xmat); half1 = nanmean(xmat(1:floor(R/2),:),1); half1 = smooth(half1,3); % Nachum (and all other head dir people) use 3 half2 = nanmean(xmat(floor(R/2+1):end,:),1); half2 = smooth(half2,3); % Nachum (and all other head dir people) use 3 stabilityI = corr(half1,ha...
ca12d3c3bf7191a4e8ced951fd5b1c8493ba952595c9c645ba83b6b53e30d936
MATLAB
332
4
function s = zasoFxysum(zaso, fct, varargin) % This may look stupid, but it is to reduce a very likely and hard to debug problem where one calls z1.fxsum(z2, fct) which is nonsensical. This function makes the interface more Python-like and requires only one reference to the object. s = zaso.fxysum(zaso, fct, vararg...
6aa3462aa1c8ee6be67d5ec105405969342d1cf4217672d5b412bd679e9ac125
MATLAB
333
15
% Close an open video. % % video_close(vinfo) % % closes any open files associated with the video specified by vinfo. % function video_close(vinfo) % check video type if (strcmp(vinfo.type,'seq')) vinfo.seq.sr.close(); elseif strcmpi(vinfo.type,'ufmf'), try fclose(vinfo.ufmf.fid); end %#ok<TRYNC...
5ac7f19a280ba154ee3954d84cd429720d8ad51bfe491e66df56e2651ef7f706
MATLAB
334
26
for i=1:50 ExampleCreateFile clear end disp('Create done') for i=1:50 ExampleCopy clear end disp('Copy done') for i=1:50 ExampleMask clear end disp('Mask done') for i=1:50 ExampleFilter clear end disp('Filter done') for i=1:50 ExampleDownSample clear end clear functions disp('Dow...
a939722580471e0011deed9a72bdd81c6e951a86cedc047b2288af59fef1c37c
MATLAB
334
24
function my_check_valid_numeric(feat_data) try tmp_check=any(isnan(feat_data)) | any(isinf(feat_data)); while numel(tmp_check)>1 tmp_check=any(tmp_check); end assert(~gather(tmp_check)); catch err_info disp('my_check_valid_numeric failed'); dbstack; keyboa...
b97cf3123467a03fd08b64b5455a0939614bce32ff97dfd5430b337bc17363bd
MATLAB
334
18
% pDataPath.m % % Function that returns pDataPath as string. pDataPath is hard-coded into % this function. % % INPUT: % none % % OUTPUT: % pdPath - full pData path, as string % % CREATED: 8/28/19 - HHY % UPDATED: 8/28/19 - HHY % function pdPath = pDataPath() pdPath = '/Users/hyang/Dropbox (HMS)/2PAnalysis-Hel...
11e6c0206e20dc91800b1e9288775028c3e17359f129ac7530be77dbe850ed11
MATLAB
335
10
% Marc Normandin, Muzzio Lab, Psychological & Brain Sciences, University of Iowa, 2024 function [J] = ml_alg_entropy_prep_image(I, NUM_BINS) % J will be discrete valued minI = min(I, [], 'all', 'omitnan'); maxI = max(I, [], 'all', 'omitnan'); J = (I - minI) ./ (maxI - minI) * NUM_BINS; J =...
7084901b867408a619e5c09564060d02c628c66ac918ff0d3f58b19c1158b20f
MATLAB
335
8
function [ triggerOnset] = sendTrigger( triggerDuration ) %send a trigger via USB-serial adapter using USBTTL function % triggerDuration: in seconds (minimum 4ms trigger is needed for vision recorder to recognize trigger) triggerOnset = GetSecs; USBTTL_2('Set', 1);%default 1 WaitSecs(triggerDuration);% USBTTL_2('Set', ...
80d43c3fadb2e8aba2c3577eb940bf1210da60bcabe1ce292a27ee0efb023f26
MATLAB
335
11
function chan=SONGetFreeChan(fh) % SONGETFREECHAN returns the number of the first free channel in a file % % CHAN=SONGETFREECHAN(FH) % where FH is the SON file handle % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 chan=calllib('son32', 'SONGetFre...
22e49a1585322c9aed489790e2976b86a8eba9fffb16f922d2c5705c726f0dcc
MATLAB
336
18
% patternsDir.m % % Function that returns path where visual patterns live % % INPUTS: % none % % OUTPUTS: % patternDir - full path to visual patterns % % CREATED: 1/18/24 - HHY % % UPDATED: % 1/18/24 - HHY % function patternDir = patternsDir() patternDir = '/Users/hyang/Documents/EphysCode-Helen/Visual Stimul...
5323aecbd72bf4a0b2b729994b62c9155873385eb23f0e3cf1c10e30ebec07f4
MATLAB
336
22
function ynn_v = ValNLD4ParECNN(Imat_v,dsr_init,nn_dyn,Xi,Ai,tv,no) u_v = Imat_v; X = tonndata(u_v,true,false); yv = nn_dyn(X,Xi,Ai); yn = zeros(no,tv-1); for i = 1:tv-1 yn(1:no,i) = yv{i}; end ynn_v = zeros(tv,no); ynn_v(1,1:no) = dsr_init; for i = 1:no ynn_v(2:tv,i) = (yn(i,:)...
6f5c67efab055564dfb98c71f7666c1660c80eecf0e2fcba9599f8a9cdea8846
MATLAB
336
11
function chan=SONGetFreeChan(fh) % SONGETFREECHAN returns the number of the first free channel in a file % % CHAN=SONGETFREECHAN(FH) % where FH is the SON file handle % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 chan=calllib('son32', 'SONGetFr...
494abaf199545964ac6556e1cc9c979221d64dcf6151e1dbfab1dcda4031dff7
MATLAB
337
12
function SONCommitFile(fh, bDelete) % SONCOMMITFILE flushes data to disc % FH is the SON file handle % BDELETE ,if non-zero, causes the data buffers to be deleted % % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 calllib('son32','SONCommitFile', fh, bD...
555957c9680f8796962047ea73d27ade32a4179f50b169a05b7c22c22105272e
MATLAB
337
10
% mglShader.m % % $Id: mglShader.m,v 1.4 2007/01/17 15:49:49 justin Exp $ % usage: mglShader('command', [args]) % by: Christopher Broussard % date: 11/13/07 % copyright: (c) 2006 Justin Gardner, Jonas Larsson (GPL see mgl/COPYING) % purpose: Performs various shader functions. % usage:...
8ef844eafdfdf0f32fbd43cbb8eaee05371630c6a57c4ca91d9070fd10dd8ef5
MATLAB
337
9
function [h] = ml_imagesci(I) % This plots the data like imagesc, but uses pcolor so interpolation % can be used. We have to flip the coordinates to match imagesc. M = nan(size(I,1)+1, size(I,2)+1); M(1:size(I,1), 1:size(I,2)) = I; h = pcolor( M ); shading interp; set(gca, 'ydir', 'reverse')...