sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
18c081a5f601c0d5e556507b76f5fafb18b8bab5824a02587c06ef78d8c23033
MATLAB
189
9
function make_nice_figure(name_plot,fontSize_4figures) box off set(gca,'TickDir','out'); set(gca,'FontSize',fontSize_4figures) set(gca, 'Color', 'None'); save_plots(name_plot) end
54ea6a73ec11631415c7179ef5f2ef4208328aea1c8c5d869a0bf892fbeb5045
MATLAB
189
12
function tmp_str=cat_str(cellstrs) tmp_str=[]; for c_idx=1:length(cellstrs) if ~isempty(tmp_str) tmp_str=[tmp_str '_']; end tmp_str=[tmp_str cellstrs{c_idx}]; end end
7b554d281f18b270e9ce076458caccb2b3dc05a3bbee919f67db3259b62a83bb
MATLAB
189
9
function delaunay_one(A, U) hold on; gplot2(A | A', U, '-', 'LineWidth', 0.1, 'Color', 0.6 * [1 1 1]); gplot2(A | A', U, '.', 'Color', [0.7 0.3 0], 'MarkerSize', 50); axis off equal;
a101d90cca90e02e71f2a3e8a33e903b7b03d1358571212afec852cdc4b368b2
MATLAB
189
8
function [c, lags] = mycorr(x,y,maxlag,Fs) % plots corr(y->x) c(m)=(y(n)x(n+m) % maxlag in frames % plots in s, based on Fs [c lags] = xcorr(x,y,maxlag,'coeff'); plot(lags/Fs,c);
134d0db2042745019634c64f9025b14cf0a4c6a062f480893051bb1cd0162d65
MATLAB
190
7
function ml_motion_convert_nvt_to_h5( nvtFilename, outputFilename ) motionData = ml_motion_load_nvt( nvtFilename ); ml_motion_save_h5( motionData, outputFilename ); end % function
3d0119b301342d15a9edc8ea2a1064d5b944b7fa39e523f7241faf5ead5a47f5
MATLAB
190
11
function [PDF,lags] = isiPDF(delta_mat) %isiPDF.m 5/28/22 ISI = getISI(delta_mat); edges = [1:max(ISI)+1]'; cts = histcounts(ISI,edges)'; PDF = cts./sum(cts); lags = edges(1:end-1); end
9095c4d971d3f55a6402267bd25b1e0476d560bf2457aedb377e3adfa1ba2c79
MATLAB
191
8
function [uz,cz] = ml_alg_cumdist(z) uz = sort(unique(z)); cz = zeros(1,length(uz)); for i = 1:length(uz) cz(i) = sum( z <= uz(i) ); end cz = cz ./ length(z); end
199b1a12e209472da7563e7d07f6740f7d2029a6887272ba2f7af5087e409df8
MATLAB
193
7
function R2adj = adjustedR2forNumParams(R2,numDataPoints,numExplanatoryParams) n = size(R2,1); R2adj = 1- ( (1 - R2)*(numDataPoints-1) ) ./ (numDataPoints - numExplanatoryParams -1); return
534d68ff9c343ef71c54b1a1ac75726b991dcabf4ab7b0bde0f6dc6147e0c844
MATLAB
193
10
function maskOut = masksmooth(maskIn, r) % function newMask = masksmooth(oldMask) if nargin < 2 r = 1; end % do some mask smoothing se = strel('sphere', r); maskOut = imclose(maskIn, se);
dd51621ba486a4259c7b0ac4264584b85d5bbcaa07ec9a50865201cc3abd67e9
MATLAB
193
8
function k = strfindi( text, pattern ) % k = strfindi( text, pattern ) % % a case-insensitive version of the built-in strfind() % % JAB 3/23/10 k = strfind( lower( text ), lower( pattern ) );
65640787a8bf87dc3d209c4a9ec6361f18193f16e11edeb9e880151e9eeef8bf
MATLAB
194
7
function [similarity indSim] = SSSimFlowSize(a, b, blobStruct) % Flow + Size indSim(:,1) = SSSimFlow(a, b, blobStruct); indSim(:,2) = SSSimSize(a, b, blobStruct); similarity = mean(indSim, 2);
691b6ce39e244e8d96adf65ea09607038991f529d67f4a903eebc6aacb389325
MATLAB
194
10
function [] = printDescFile(fidDesc, ftest) if issparse(ftest) ftest = full(ftest); end %if isssparse(ftest) for t = 1 : numel(ftest) fprintf(fidDesc, '%f\n', ftest(t)); end %for t
e6bbb827e8eb2c6233e36a8aef732fb2b2fc328baeb368a5062d11cb03969a99
MATLAB
194
13
% main_script % Comment: Just run this script and it will do everything % bem0_load_model; bem1_setup_coil; bem2_charge_engine; bem5_volume_XY_big; bem5_volume_XY_zoom; bem5_volume_YZ_zoom;
f83b4280ec80b3892b185451c92b5ef896e7547f316d16f4eac43b6843da692a
MATLAB
194
10
function X=SNR(s,n); % Compute the signal-to-noise ratio in dB % X=SNR(signal,noise); % (it does not subtract the means). es=sum(sum(abs(s).^2)); en=sum(sum(abs(n).^2)); X=10*log10(es/en);
233b1e83cf41bde693cde1ef85489150cb02c7fc73bef4cd67f4b8942dbc279a
MATLAB
195
7
function text_survivors=make_text_survivors(handles) temp=sum(handles.mc.surv_ix,1); text_survivors{1}=['std: ' num2str(temp(1),'%4.0f')]; text_survivors{2}=['mb: ' num2str(temp(2),'%4.0f')];
7da190b70b97b29de20421bce78f7abed35aabda9f455a4e52dda4d0839570a9
MATLAB
196
6
% calcMFR.m function mfr = calcMFR(peakTrn, acqTime, th) nspikes = sum(peakTrn > 0); mfr = nspikes/acqTime; % all the channels whose mfr < 0.1 spikes/s are considered not active mfr(mfr < th) = 0;
6b82a9544d1af378008fed48f83d407429c5caf172ba22fbb861b8fc5fcf2aef
MATLAB
197
8
function str = toSetField(str, fieldName, fieldVal) % function str = toSetField(str, fieldName, fieldVal) for k = 1 : length(fieldName) str = setfield(str, fieldName{k}, fieldVal(k)); end end
b5b0fa2d73276191bd955739ac7bfd9908c25eb149c90b891038310fdc2c73bf
MATLAB
198
13
function dist = doPariwiseDistP(x,y,z) xm = x*ones(1,numel(x)); ym = y*ones(1,numel(y)); zm = z*ones(1,numel(z)); dx = (xm-xm').^2; dy = (ym-ym').^2; dz = (zm-zm').^2; dist = sqrt(dx+dy+dz); end
4d9f8f7187178944d87743096978d0353341177c904d190bfd024ef0810e453b
MATLAB
199
10
function top = RectTop % yTop = rect(RectTop) % % RectTop returns the rect index of yTop. % Also see PsychRects. % 5/12/96 dgp wrote it. % 2/25/97 dgp changed to agree with Apple's rects top = 2;
d0d2ace4bbc9d96c471cfdb621457fac5b6f600cd292bc6f50d45b20367d087c
MATLAB
199
11
% % Convert a complex number to a RGB value for visualization. % function [rgb] = complex2rgb(value) h = angle(value) / (2*pi) + 0.5; s = 1; v = 1 - 1 / (abs(value) + 1); rgb = hsv2rgb([h s v]);
4952b28774a3e35ffb6f4d25e61dee4f194b5ec384cba531a2ca16b4fb7098ae
MATLAB
200
7
function [similarity indSim] = SSSimColourSize(a, b, blobStruct) % Colour + Size indSim(:,1) = SSSimColour(a, b, blobStruct); indSim(:,2) = SSSimSize(a, b, blobStruct); similarity = mean(indSim, 2);
99a051ffcc2b720fa1de7ce6bab589d3435ee6af15184c4898a26a81eed1e897
MATLAB
200
9
function results = vl_test_slic(varargin) % VL_TEST_SLIC vl_test_init ; function s = setup() s.im = im2single(vl_impattern('roofs1')) ; function test_slic(s) segmentation = vl_slic(s.im, 10, 0.1) ;
b31e787066c20c1cb89d50354a4f1275fc96ee90995fcb94f28e21836bd3a1b2
MATLAB
200
9
function label_counts=my_label_count(label_values, label_data) tmp_counts=accumarray(label_data, ones(size(label_data)), [max(label_values) 1]); label_counts=tmp_counts(label_values); end
d002976e406cdcdcf1c7f11ea472745006166abf3f61e847a71f793acf5d115c
MATLAB
200
12
% main_script chamber_dim = 135; %15; %45; %135; %<---- SELECT CHAMBER DIMENSION HERE bem0_load_model; bem1_setup_coil; bem2_charge_engine; bem4_define_planes; bem5_figure_scales; bem5_volume_XY;
dc0a66b2f9adbc1b0429cdb3dfe0c09a33e64a2e1fc08da1cf15ac63d35e6ba7
MATLAB
202
5
function ensure_parent_folder_exists(raw_file_path) file_path = absolute_filename(raw_file_path) ; parent_folder_path = fileparts(file_path) ; ensure_folder_exists(parent_folder_path) ; end
a71e2390b900ddcbb0763bd8d8310c0f188a51e079e01df588a525ce4174e43b
MATLAB
203
6
function [neuronDataset] = ml_cai_neuron_h5_read( filename ) neuronDataset = ml_cai_core_h5_read_header( filename ); neuronDataset.neuron = ml_cai_neuron_h5_read_timeseries( filename ); end % function
ad53c874874dee8bd480fb7eeea0e105612e68ca790da8bfcd81ccd024d1d88d
MATLAB
203
11
function [raster] = one_event_raster(spk_t,stevt,endevt) %one_event_raster.m - % bounding and start-subtracting % 5/22/22 inbd = @(d,l,u) d(d>=l & d<u); raster = inbd(spk_t,stevt,endevt)-stevt; end
c23ef2bdfce586a65f65862003537be96c340e736133601ecae1449331930354
MATLAB
203
7
function [similarity indSim] = SSSimTextureSize(a, b, blobStruct) % Texture + Size indSim(:,1) = SSSimTexture(a, b, blobStruct); indSim(:,2) = SSSimSize(a, b, blobStruct); similarity = mean(indSim, 2);
05f77f8496e1051def1789fc4d8cfb32422da66e8d4faa8e2c8e0f3eb05d5a7c
MATLAB
204
8
function max_v = absolutevalue_maximum(v) %calculates the maximums of the absolute value for A [max_v, max_index] = max(abs(v),[],2); signs = sign(v); max_v = max_v .* signs(max_index); end
676131ae39f38237279d1ae456cc2c50a8c6e326bf4eb117c998fef4cf973747
MATLAB
204
7
function blobs = BlobAddSizes(blobs) % This function add size fields to the blobs. Doing this once saves % computation time. for i=1:length(blobs) blobs{i}.size = sum(sum(blobs{i}.mask)); end
dbc18b3536117b7756bbb6304918b453fc9772486c42de2e7b21d133ab38b0ce
MATLAB
204
14
% main_script % Comment: Just run this script and it will do everything % bem0_load_model; bem1_setup_coil; bem2_charge_engine; bem4_define_planes; bem5_figure_scales; bem5_volume_XY; bem5_volume_YZ;
fab6ea78fd2732b351de4a49806997e117cc9a6ac36359f01d1919d47efaa043
MATLAB
204
10
function interrupt = keyboard_interrupt() interrupt = 0; if exist('testkeypress')==3 if testkeypress(' ') interrupt = 1; end; end if exist('Keytest')==8 if Keytest.test(' ') interrupt = 1; end; end
ad87785f867189ed5513f95558a6e0a9f9ae33a9273adbc8453c4ddb4f626d25
MATLAB
205
7
function [Z] = ml_bs_probxy_xy(bs, x, y) % Compute the probability for the positions in (x,y) Z = ml_bs_accumulate_xy(bs, x,y, 1); s = nansum(Z, 'all'); Z = Z ./ s; Z(isnan(Z)) = 0; end
bb50d5b21c4c509a09bd986384ed460b104dc1c1ae3eb3b9def6bed93bdc78e7
MATLAB
205
11
% show vars el=4; un=1; eee=1; %Varr=nose.do2 Varr=Xin; % squeeze(STA(el,un,eee,:,:)) % squeeze(STS(el,un).sts(eee,:,:)) figure(1) h=hist(Varr,xBins); xlim([min(xBins), max(xBins)]); hist(X)
d515b715b32d75409fc434a1704d4c044f59d011c7e21ee4494a3b7420921d89
MATLAB
205
10
function left = RectLeft % xLeft = rect(RectLeft) % % RectLeft returns the rect index of xLeft. % Also see PsychRects. % 5/12/96 dgp wrote it. % 2/25/97 dgp changed to agree with Apple's rects left = 1;
bcc4b109157ac50be141e0b767b736e01e11ea1a40922483f8f7ac5988d7e6ba
MATLAB
206
8
function [ translatedxys ] = translateCoordinates(xys, translate_amount) %TRANSLATESHAPE Summary of this function goes here % Detailed explanation goes here translatedxys = xys + translate_amount; end
2689977814fc517af7dacf04e3298a54b6e391b65e8525ed02d6a28b1aed1c14
MATLAB
207
6
function str = toSetField(str, fieldName, fieldVal) % function str = toSetField(str, fieldName, fieldVal) for k = 1 : length(fieldName) str = setfield(str, fieldName{k}, fieldVal(k)); end end
a52208c0965866016c2280fef133c417a2e3561bdf1ee250f3fd22d7b0852bf1
MATLAB
207
13
function result = linearSmooth1(data,smooth_res) r = size(data,1); c = size(data,2); ci = 1:smooth_res:c; result = zeros(r,length(ci)); for i = 1:r result(i,:) = interp1(data(i,:),ci,'spline'); end
32a211a58da819543ca80d3a9c56e7b53d8037d45dd1ab5727de332d64102348
MATLAB
208
8
function parsave1(filename, data, dataname) if strcmp(filename(end-3:end), '.mat') eval([dataname,'=data;']); save(filename,dataname, '-v7.3'); else error('filename must end with ".mat".') end end
8d3b07d7b8dcef9766d11e0d44b0b1086eb2caa8902c7f22c42ad8a5b44cc613
MATLAB
208
16
% % Compute mean average precision. % % PARAMETERS % p (e*1) Predictions % T (e*3) To be predicted % % RESULT % value MAP value % function [value] = measure_compute_map(p, T) value = konect_map(p, T);
c4b1e797580db026d0aae1e6c1c801f4e16dadb3b30959006d480923674894e8
MATLAB
209
10
function [PDF,lags] = isiPDF_vector(delta_vec) %isiPDF_vector.m 5/26/22 ISI = getISI_vector(delta_vec); edges = [1:max(ISI)+1]'; cts = histcounts(ISI,edges)'; PDF = cts./sum(cts); lags = edges(1:end-1); end
e369a80f9a4fc842d099f689cc3c669bfa49924f5c2d32a901d4ec78a9663ede
MATLAB
209
14
function iarr = unitn2i(narr) globals; if isempty(narr), iarr=[]; return; end [I J] = size(narr); for ii=1:I i1(ii) = find(goodElectrodes==narr(ii,1)); end iarr = [i1',narr(:,2)];
f961a76c763c65b19ef6df5279c1448bf25aa5c3a2dee86d23e8f812464f789d
MATLAB
210
9
function [lb_idx] = select_labeled_nodes(Y,num_lb) lb_idx = []; for c = 1:size(Y,2) idx = find(Y(:,c) > 0); rand_idx = randperm(length(idx)); lb_idx = [lb_idx; idx(rand_idx(1:num_lb))]; end
3701c303a1541b4786a07dbbeb533f50f9e1e0e352b18a61614c440898cf4109
MATLAB
211
9
%% save analysis information vars.mag1 = mag1; vars.mag2 = mag2; vars.vid = vid; pathname = cd; [~, filenameroot]= fileparts(pathname); save(fullfile(cd, [filenameroot '_analysis.mat']),'mag1', 'mag2', 'vid');
7e7287a86563005aed85f7ab95f46332536b906fa4089e536deff8d80ea20cbc
MATLAB
212
10
function right = RectRight % xRight = rect(RectRight) % % RectRight returns the rect index of xRight. % Also see PsychRects. % 5/12/96 dgp wrote it. % 2/25/97 dgp changed to agree with Apple's rects right = 3;
ef6aaec801157b89df31d1c5f786d0be203274cec8bb2b66a4503dd2934fca83
MATLAB
212
4
% Marc Normandin, Muzzio Lab, Psychological & Brain Sciences, University of Iowa, 2024 function [fieldSets] = helper_load_bfo180_fieldsets_to_record() fieldSets = helper_load_bfo90_fieldsets_to_record(); end
80c1718349dc14cb8d3be542b3c832ac9cff015c8a57dfd9795faa751535352f
MATLAB
213
15
function spikes = spikesCellToVec(s,dt,numt) if(nargin<2) dt = 0.01; end if(nargin<3) numt = ceil(max([s{:}])/dt); end spikes = false(length(s),numt); for i = 1:length(s) spikes(i,ceil(s{i}/dt)) = 1; end
3fdc19dfa431798fa5aa824b7c57433b21dab9746d2140c2612fd0d8beeed93b
MATLAB
214
5
% Marc Normandin, Muzzio Lab, Psychological & Brain Sciences, University of Iowa, 2024 function [colours] = colour_matrix_yellow_green() colours = [1, 1, 0; ... 0, 1, 0]; end % function
6155c0569b6769c3ff16159df9611db40d1190656897ed68fd86a884459083a9
MATLAB
214
14
% % Compute average precision. % % PARAMETERS % p (e*1) Predictions % T (e*3) to be predicted % % RESULT % value Average precision % function [value] = measure_compute_ap(p, T) value = konect_ap(p, T(:,3));
846b83230595709f6f6d3d34968958f6fe70e97048d99c92f4ff183511cb7c72
MATLAB
214
10
function DVAR=dvars_from_cifti(X); % This function calculates dvars based on grayordinates (WM and non brain excluded) %% Check size [g tr]=size(X); if g<tr X=X'; end dx=diff(X,[],2); DVAR=sqrt(mean(dx.^2));
a5e3a8b1750bf201d06ea9c524c6c16172261204644b3e8a71a1d267be4367c8
MATLAB
214
5
function result = replace_extension(file_name, ext) [folder_name, base_file_name] = fileparts(file_name) ; result_name = horzcat(base_file_name, ext) ; result = fullfile(folder_name, result_name) ; end
fa7a28ae3c8fa3ef7bfd82a1c492573dba4d7ae33152015be9013ec8ccdf8664
MATLAB
214
10
% This code runs the genTrialList function to generate param files % Specify the list numbers and it will run them for you. list = 10300:10399 for ii = 1:length(list) num = list(ii) genTrialList(num) end
e614f216b351de6b8a3432a2399fad94a254ab0ddcc6224ba120f32f6fe24f20
MATLAB
215
14
%% plot simple spikes in range of xlims xlimits = xlim(); spikeTimes = (recData(8).data); spikeTimes(spikeTimes < xlimits(1)) = []; spikeTimes(spikeTimes > xlimits(2)) = []; vline(spikeTimes, 'k') diff(xlim)
0073c188ca22f16fb5b0863c29199d65ac5f57943d2e216c64f577ac4ae393ae
MATLAB
216
5
function out = morletConjFT(w,omega0) %morletConjFT is used by fastWavelet_morlet_convolution_parallel to find %the Morlet wavelet transform resulting from a time series out = pi^(-1/4).*exp(-.5.*(w-omega0).^2);
c8bd611a8885deaf3f568aba7332c983f220f775f8815639c0c0d3948ea4bdd8
MATLAB
216
8
function [xpred,ypred,thetapred] = cvpred(x2,y2,theta2,x1,y1,theta1) dx = x1 - x2; dy = y1 - y2; dtheta = modrange(theta1-theta2,-pi,pi); xpred = x1 + dx; ypred = y1 + dy; thetapred = modrange(theta1+dtheta,-pi,pi);
afb4d1286e29aa190052f26b980fb674e8a669db1740cbf79b05bfbe261286e2
MATLAB
217
10
function bottom = RectBottom % yBottom = rect(RectBottom) % % RectBottom returns the rect index of yBottom. % Also see PsychRects. % 5/12/96 dgp wrote it. % 2/25/97 dgp changed to agree with Apple's rects bottom=4;
b89c27e551daf0113f66bd0e0fb4ddde8ed2219cb3666f8424ff05614b2ebfdb
MATLAB
217
16
% % Compute mean area under the curve. % % PARAMETERS % p (e*1) Predictions % at (e*3) To be predicted % % RESULT % value MAUC value % function [value] = measure_compute_mauc(p, at) value = konect_mauc(p, at);
467e958945657314e9e6171ce8109ff6e399fdd7f1990ce45b44de607309bc62
MATLAB
219
9
function SONCleanUp() % SONCLEANUP File cleanup. Not used in Windows % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 calllib('son32','SONCleanUp'); return;
732861e55d2b05711c9ffc28fb3981437a6bc4cfb407336c88c3c85d2618cab6
MATLAB
219
10
function [varargout] = size(ipa) % INPLACE/SIZE Size of array % % [m,n] = size(ipa) Juse like SIZE for matrices and vectors. % % Example: % ipa = inplace(ones(10,3)); % size(ipa) varargout{:} = size(ipd.get_a());
6f8cf84422cd255deaaf825c054c6c66eaf6e57165438693777a25490e3f3ed7
MATLAB
220
6
function gammaPower = getGammaPower(inputArg) %GETBANDPOWER get gamma power of the signal % Detailed explanation goes here sampleFreq = 100000; gammaPower = bandpower(inputArg, sampleFreq, [25 100]); end
2f01580b079c6e70eddcf9f222577605148eedc30b8944c69b0e113f62c7d5c8
MATLAB
221
7
function [edgesX] = ml_it_edges_x_uniformly_spaced(x) N = length(x); zi = (8+324*N+12*sqrt(36*N + 729*N^2))^(1/3); nBinX = round( zi/6 + 2 / (3*zi) + 1/3 ); edgesX = linspace(min(x), max(x), nBinX+1); end
c89637b63f625b230b618aa89f302c00fa94267d974ffb6d109cb19278451a92
MATLAB
222
6
function [nose, theta, irmv] = removeFrames(nose, theta, condtxt); globals; irmv = find(eval(condtxt)); % find frames to remove [nose, theta] = removeFramesExplicit(nose, theta, irmv); end % function removeFrames
1157d2133ed29358d976feccc940f14e14fdfd47b73fa62af646a540551311fb
MATLAB
225
19
% % Format the value of a statistic. % function [text] = format_statistic(statistic, value) [l i] = konect_data_statistic(); if i.(statistic) text = format_number(value); else text = sprintf('%.3f', value); end
1f6cd32b97ff6142470c4591b64b4199156b12cd35b92c7aca828abb52467ceb
MATLAB
225
14
% % Compute area under the curve. % % PARAMETERS % p (e*1) Predictions % at (e*3) To be predicted % % RESULT % value Area under the curve % function [value] = measure_compute_auc(p, at) value = konect_auc(p, at(:,3));
bb462f978db8764564896c619eeea6c996266f948911e698a757cb252f070009
MATLAB
225
6
function powerMapF = computePowerMaps(resF, gaborBank) powerMapF(numel(gaborBank)).value = []; for g = 1 : numel(gaborBank) powerMapF(g).value = (resF(g).even .^2) + (resF(g).odd .^ 2); end %for g = 1 : numel(gaborBank)
647ec9b5e452de4cda866cdc9a343bdeb9c0c66adfcf1a7116a2d68fcdbc802a
MATLAB
226
6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% stub for mglPrivateDigIO if it is not compiled %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function retval = mglPrivateDigIO(a,b,c) retval = [];
7aedf5dc6649f5c608c8a2c282224aab885ece262ea8811b9161136de6005593
MATLAB
226
4
function [climerICS] = ml_cai_climer_information_rate_smoothed(probXYS, traceXYS) meanTraceS = nansum(probXYS .* traceXYS, 'all'); climerICS = nansum( traceXYS .* probXYS .* log2( traceXYS ./ meanTraceS ), 'all' ); end
a956204941196879722a6912a5a895a480854420b122b218ee67ef1173529435
MATLAB
227
14
function gids = ml_util_group_points_v2(x) gids = zeros(1,length(x)); k = 1; gids(1) = k; for i = 2:length(x) if x(i) ~= x(i-1) k = k + 1; end gids(i) = k; end end
f1e34e446c7f2ab581c9606d5cd0921d0017b9dd97f9760a7165957732b32afb
MATLAB
228
9
function SONCleanUp() % SONCLEANUP File cleanup. Not used in Windows % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 calllib('son32','SONCleanUp'); return;
01aff20aa749e771043d021afacdfd529e1d24e294dd22985655cdc491b201a6
MATLAB
229
5
function displacement = find_displacement_between_two_centerlines(K, Old_K) %finds the difference in euclidean distance between two centerlines Kdis = (Old_K - K).^2; displacement = sum(sqrt(Kdis(:,1)+Kdis(:,2))); end
a7b8838a6d13d0103beb97f21848d3cf2e48694f9a8c48df6bb5227c2d383452
MATLAB
230
6
function [SC,OPT_S] = had_wind_size_change(SC,OPT_S) OPT_S.mid_pix = OPT_S.mid_pixes(OPT_S.ind_change_windw); OPT_S.mask_wind = had_set_mask(OPT_S.mid_pix,OPT_S.mask_wind_exp); OPT_S.ind_change_windw = OPT_S.ind_change_windw+1;
b42ae2039eddd99c41b6275839829a8043b38c149c8442850ed69dc9f296621a
MATLAB
230
10
function n=end(ipa,a,n) % INPLACE/END Allow inline "end" indices to work. % % n=end(ipa,a,n) Returns the ending index along dimension a. % % Example: % ipa = inplace(cumsum(ones(5,1))); % ipa(3:end) n = size(ipa.get_a(),a);
e0f138b9d8b8b3bd6c691ec7e078a982ef2161f22936e872373c164c38dc469a
MATLAB
230
4
% Marc Normandin, Muzzio Lab, Psychological & Brain Sciences, University of Iowa, 2024 function [colours] = colour_matrix_blue_red_yellow_purple() colours = cat(1, colour_matrix_blue_red(), colour_matrix_yellow_purple()); end
10fe30f3b8e993645412582898da1ac1e4486710439f745e9467225e05553fcc
MATLAB
231
14
function VOCopts = get_voc_opts(path) tmp = pwd; cd(path); try addpath('VOCcode'); VOCinit; catch rmpath('VOCcode'); cd(tmp); error(sprintf('VOCcode directory not found under %s', path)); end rmpath('VOCcode'); cd(tmp);
9d8fd132c73859a5b2366c53ec14702bdeb8d0f56e6378c5e7ac1fc050b8dc84
MATLAB
232
4
% Marc Normandin, Muzzio Lab, Psychological & Brain Sciences, University of Iowa, 2024 function [fieldNames] = helper_possibleScalar1FieldNames() fieldNames = {'trialId', 'contextId', 'mfr', 'pfr', 'infoRate', 'infoSpike'}; end
e91694342423ab53fa9f2af492e3507f5dfdb7aa4b770a3e1a6b0b0949301ecf
MATLAB
232
9
function time=SONMaxTime(fh) % SONMAXTIME returns the maximum time for data in a file % % TIME=SONMAXTIME(FH) % where FH is the SON file handle. TIME is returned in clock ticks % % ML/05/05 time=calllib('son32','SONMaxTime', fh);
f1a0d5b55e11311926202e2c0332f7260f38b081375db2a046bc8bdd50493e22
MATLAB
232
11
xx=[1:10]; yy=[1:10]; xBins=0:2:10; yBins=0:2:10; [N] = histcounts2(xx,yy,xBins,yBins); figure(2) surf(N) view(0,-90); colormap('jet'); colorbar('EastOutside'); set(h,'CDataMapping','scaled'); set(gca,'Ydir','reverse');
695d0a597dec1a6ef7286733240301d05ca8ef5eabcc0bf4ea1c029b389c2547
MATLAB
233
10
function [S,lags] = spikeSurvivor_vector(delta_vec) %spikeSurvivor_vector.m ISI = getISI_vector(delta_vec); edges = [1:max(ISI)+1]'; cts = histcounts(ISI,edges)'; S = cumsum(cts,'reverse')./sum(cts); lags = edges(1:end-1); end %fn
cf9baf636db4c1063591903525fcd2a02383547b093f29abd08ef94f9353212e
MATLAB
233
10
function [ind_data] = Indicator(data,NumInd,eps) ind_data = zeros(size(data,1),NumInd); data_prt = linspace(min(data),max(data)+eps,NumInd); for i=1:NumInd-1 ind_data(:,i) = [data>=data_prt(i) & data<data_prt(i+1)]; end end
e15f041b51d500aac87557f24b84f7e3fc896968ba01d1340bd337c6d1e225c5
MATLAB
233
14
function [tDup, nDup] = men_timestamp_find_duplicates( t ) u = unique(t); [n,bin] = histc(t, u); ix = find(n > 1); % The value that is duplicated tDup = u(ix); % The number of instances of the value nDup = n(ix); end % function
f4231217e22f798c71981a4121059d9da13b74c92370e51c6e59eda4ebf0640d
MATLAB
233
8
function [labels, numImagesAll] = computeLabels(files) numImagesAll = numel(files); labels = zeros(numImagesAll, 1); for i = 1 : numImagesAll filename = files(i).name; labels(i) = str2double(getIndName(filename)); end %for i
f6e7a18918ff8e2bc09bee94f077e33386d85e521e1424d7ffea96a39be0f17c
MATLAB
233
13
function d = qLength( Q ) % qLength: quaternion length (norm) % d = qLength( Q ) % IN: % Q - input quaternion % % OUT: % d - quaternion's norm (length) % % VERSION: 03.03.2012 d = sqrt( sum( Q .* Q ));
213849bcd279efd95cf207a270145bc92bbac2cf665e87af603d8ba466e4541f
MATLAB
234
7
function [groupExp, groupMaxExpVal,groupMaxExpIdx] = getGroupExp(x,y) binsExp = 0.1:0.1:1; [groupMaxExpVal,groupMaxExpIdx] = max( reshape(y(:,x,:), size(y,1),[])); groupExp = binsExp(groupMaxExpIdx); end
34eac72c849229313d184eb0568e616b3bc58c664223e3ba9ea07a1abc8186fc
MATLAB
235
5
% Marc Normandin, Muzzio Lab, Psychological & Brain Sciences, University of Iowa, 2024 function [colours] = colour_matrix_blue_red() colours = [0, 0.4470, 0.7410; ... 0.8500, 0.3250, 0.0980]; end % function
5ac591664e278dcdda5b89fbea046d77cb52de738726be074f2689671e87fe10
MATLAB
235
15
function [xs] = runMvAvg(x,smooth_w) %runMvAvg.m % 5/22/22 flt = ones(1,smooth_w)/smooth_w; if mod(smooth_w,2) == 0 xsraw = conv(x,flt); xs = xsraw(1:end-1); else % odd window xs = conv(x,flt,'same'); end %if mod end
8970ad3bb25f8dd40114ab79448a0182bdb9f75c3fdb735bd826af0695adafdd
MATLAB
235
8
function result = realpath(file_name) if ispc() , result = GetFullPath(file_name) ; else stdout = system_from_list_with_error_handling({'realpath', file_name}) ; result = strtrim(stdout) ; end end
95b52fc612a0dd21159af35837e52933c028eca0170005058d0f2f088cf189b8
MATLAB
235
11
function FE=findFrameForEvent(frame,event) %paried arduino event to 2p frame ttl for t=1:length(event(:,1)) a=find(frame>event(t,1)); if ~isempty(a) FE(t,:)=a(1); else FE(t,:)=nan; end end end
fe5fdfb29b456df55fe3fb3e7b613590ec7b5a019d338f2ae2404e85078ba21c
MATLAB
236
10
function ipa = assign(ipa,y,varargin) % INPLACE/ASSIGN Assign an entire inplace array. % % assign(ipa,y) overwrites the contents of ipa with y. % % Example: % ipa = inplace(ones(5,1)); % assign(ipa,pi*ones(5,1)); ipd.assign(y);
9c47fe8516b91def82d29783eff309e88d791e3e3652114489fffafa083123fb
MATLAB
237
11
function fix_EnablePanel(h,v) % set the enabled state for a handle and all its children % splintered from fixerrorsgui 6/23/12 JAB children = get(h,'children'); for hchild = children, try set(hchild,'enable',v); catch end end
3e6bd66bb1cbeacda2ecdd8b7fbb5c497c560a79813cc32721a4f2cb629891b7
MATLAB
238
13
function Q = qConj( Q1 ) % qConj: quaternion conjugation % Q = qConj( Q1 ) % IN: % Q1 - input quaternion % % OUT: % Q - output quaternion % % VERSION: 03.03.2012 Q1 = reshape( Q1, 4, 1 ); Q = [Q1(1);-Q1(2:4)];
bed2a738d612d1c73708c51c4cbc91f6285c98d9d8451f08c67bd8996d11b575
MATLAB
238
15
% % The key used for sorting datasets. % % PARAMETERS % network % function ret = network_key(metadata) name = metadata.name; name_no_space = regexprep(name, ' ', '-'); ret = sprintf('%s:%s', metadata.category, name_no_space);
86844827979b9ec7f989892ecc5a60501a4881bfc26ade101250d68e0b7086d3
MATLAB
239
10
function Av = updateAvalanche(Av, t, clusterSize) if t > Av.endTime Av.endTime = single(t);%Av.avtime(end);%X(2,end); end Av.duration = Av.endTime - Av.startTime +1; Av.size = Av.size + clusterSize;%(X,2);%size(Av.event,2); end
3baab21349d5e1ee09da1683a3dbe29556cd47cb02d6ded319f48d5a67ac3c76
MATLAB
240
13
function rval=rtest_5_henderson() rval = 0; try rand('state',0); A = erdos_reyni(100,.1); if full(max(max(A))) > 1 error('erdos_reyni.m does not return an adjacency matrix.'); end rval = 1; catch lasterr end
5877ab807969b8733dd4da70eb7e42d9b1bffc269fe6a10b1b9295dfa7c88b67
MATLAB
240
12
function out = countprint(x) % prints \b x, returns string for printing this as an output if nargout == % 1 if x == 1 out = num2str(x); else out = [repmat('\b',1,length(num2str(x-1))) num2str(x)]; end if nargout == 0 fprintf(out) end
2368af8babd2a359a204fe1f0b48706386d6bf2f78512f33f62fb6b45486e3d0
MATLAB
241
9
function time=SONMaxTime(fh) % SONMAXTIME returns the maximum time for data in a file % % TIME=SONMAXTIME(FH) % where FH is the SON file handle. TIME is returned in clock ticks % % ML/05/05 time=calllib('son32','SONMaxTime', fh);
90252fb021673d955870ca03ca5f30d3565f3bfc728b2a98cdac9142bf9d5b42
MATLAB
241
7
function I=take_unsaturate_photo(SC,cam_str,mean_num) %take photo with cam_str camera, make sure it is not saturated %number of mean images is mean_num %% delete this - just for the function to return something I = rand(101);
bc165e682c3aee9deb8e51c1ea0991512e30565a76a94712239fbac622b6bb99
MATLAB
241
6
function [I] = ml_it_mutual_information(x,y, binMethod) entropyX = ml_it_entropy(x, binMethod); entropyY = ml_it_entropy(y, binMethod); entropyXY = ml_it_entropy_joint(x,y, binMethod); I = entropyX + entropyY - entropyXY; end
2191ad5529669ba9143e413703910fa44a6a178d0e9981fcac801bd59db2bc32
MATLAB
242
11
function results = vl_test_mser(varargin) % VL_TEST_MSER vl_test_init ; function s = setup() s.im = im2uint8(rgb2gray(vl_impattern('roofs1'))) ; function test_mser(s) [regions,frames] = vl_mser(s.im) ; mask = vl_erfill(s.im, regions(1)) ;
15578092351a2aec2a69171bbae2893309353cc68bd9f3cd31720ab01d94b3a4
MATLAB
243
11
function [retVal, retValInd]= removeNanRows(Val) NanRemovedVal = Val; NanRemovedVal_index =~isnan(nanmean(Val,2)); NanRemovedVal = NanRemovedVal(NanRemovedVal_index,:); retVal = NanRemovedVal; retValInd = NanRemovedVal_index; end
a1ef49bb6b2d3bebe8700e2554b3393c5e9c531340a13250474eda23a8cb1ffa
MATLAB
243
9
function [userfolder]= selectfolder (string) % % by Michela Chiappalone (7 Febbraio 2006) userfolder = uigetdir(pwd,string); % if strcmp(num2str(userfolder),'0') % errordlg('Selection Failed - End of Session', 'Error'); % return % end