sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
08128a862cbf01a24c4ff9c1fc3b56a487b9eff1b101140a1fb29e81653f4108
MATLAB
305
18
function fi=remove_field_string(fi,fieldn,ind_to_remove) for k=1:length(fi) str = getfield(fi(k),fieldn); if isnumeric(ind_to_remove) str(ind_to_remove)=''; else [i1,i2] = regexp(str,ind_to_remove); str(i1:i2) = ''; end fi(k) = setfield(fi(k),fieldn,str); end
7381fbae65118c5438d44dbd026693c6d1d74b8cd8ff50dd1c4bc1a3f65c84cb
MATLAB
305
17
function stim = get_stim(session, channel, unit, fold) % Get stimuli of specific neuron % % Parameters % ---------- % % - fold: integer scalar % Fold number % % Returns % ------- % - stim: 2D matrix % (trial x time) response result = load_result(session, channel, unit, fold); stim = result.stim; end
5c205a919997557672d3e816c8c4e3173e12a6de3a925664cd0643fd2cd55cb4
MATLAB
306
11
function lines = readLines(filename) %READLINES Read the lines of a text file into a cell array assert(exist(filename, 'file') == 2, '''%s'' is not a file', filename); fid = fopen(filename, 'r'); lines = textscan(fid, '%s', 'Delimiter', '\n'); fclose(fid); lines = lines{1}; end
d45b16c8e45775a825eacdaf5bcc01aa9029297ed63f1ae898a2a1f95ce989fb
MATLAB
306
13
function disp_highest_tvalue(Stats, Chanlocs, String) % if ~any(Stats.sig) % return % end t = Stats.t; % t(~Stats.sig) = nan; Stats.p_fdr = Stats.p_fdr(:); Stats.N = repmat(Stats.N, numel(Stats.p_fdr), 1); [~, Indx] = max(abs(t)); disp_stats(Stats, [Indx, 1], [String, ' ', Chanlocs(Indx).labels]);
2dd0192e9b02b0789c5a0b0f68a4d384f1007da669a13a18378aa0861aeb3fa8
MATLAB
307
16
t=-20:0.01:30 figure; hold on tau=3; plot(t,(t.*exp(-t/tau)/max(t.*exp(-t/tau)).*(t>0)/tau^2)) plot(t,(exp(-t/tau).*(t>0)/tau)) tau=5; plot(t,(t.*exp(-t/tau).*(t>0)/max(t.*exp(-t/tau))/tau^2)) plot(t,(exp(-t/tau).*(t>0)/tau)) % tau=10; % plot(t,t.*exp(-t/tau)/max(t.*exp(-t/tau))) % plot(t,exp(-t/tau))
35d95022a5ae2261139c5818a81c0c3cab601ba18016d6acda1ab31f371eb4d6
MATLAB
307
9
function [Dis,Dis_coord] = distance(scale,coord1,coord2) Dis_coord = zeros(1,2); A = coord1(1,2) - coord1(1,1); Dis_coord(1,1) = floor((coord1(1,2) + coord1(1,1))/2); Dis_coord(1,2) = floor((coord2(1,2) + coord2(1,1))/2); B = coord2(1,2) - coord2(1,1); AB = sqrt((A^2)+(B^2)); Dis = AB * scale; end
56b9be1ad5148a0a7ad3b32eda8ed40d8961e996969c995c772fc52d5b1a509f
MATLAB
307
25
function fo = average_series_fid_spec(fids) fo=fids(1); for nbser = 1:length(fids) fid = fids(nbser).fid; fid1m = mean(fid,2); if ~exist('fm1') fm1 = fid1m; else fm1 = fm1 + fid1m; end end fo(1).fid = [fm1] ./ nbser; if exist('descr') fo(nbser).Serie_description=descr; end
f9b0a6178d61019ab41dd87a6bd05394ed21aebb7a531e9485351ef934f6ac3d
MATLAB
307
17
function fr = get_s_fr(session, channel, unit, fold) % Get firing rate of specific s-model % % Parameters % ---------- % % - fold: integer scalar % Fold number % % Returns % ------- % - resp: 2D matrix % (trial x time) firing rate result = load_result(session, channel, unit, fold); fr = result.fr; end
3f14c4f432e703b747191d7089a553a8872086865f9875a74348cbd8f0209ccb
MATLAB
309
11
function mouseClickFigSim(obj, xyPos, clickType) %MOUSECLICKFIGSIM Handle callbacks for mouse clicks in sim view if obj.isWorking return; end xyPos = max(round(xyPos), [1 1]); if strcmp(clickType, 'normal') % left click obj.updateSelect(obj.showSubset(xyPos)); end end
51195d2fe7365de93d997c4a44fd4028f700e6aa318ef6e10ec298f009c085c4
MATLAB
309
11
function Time = peaks2time(Peaks, StartVariable, EndVariable, Pnts) % turns structure of peaks into a time vector, based on variables indicated Time = zeros(1, Pnts); Starts = [Peaks.(StartVariable)]; Ends = [Peaks.(EndVariable)]; for Indx_P = 1:numel(Starts) Time(Starts(Indx_P):Ends(Indx_P)) = 1; end
dafeda2df9cd8170980e881804717c859e06cf611d210e93d7a261d850c1b9f1
MATLAB
310
13
% TODO: test for properties: values should be in certain ranges, so plot % their distribution, and give test problem (eventually) if they're outside % of range Properties = fieldnames(AugmentedCycles); for Property = Properties' figure histogram([AugmentedCycles.(Property{1})]) title(Property) end
04120a4d4aaedc7d2bdfa3e62ad470d2288533392be7dc2458e0a4d24a4df5ec
MATLAB
311
13
function ob = power(ob, sup) %function ob = power(ob, sup) % array "power" method (A.^2) % matrix power (mpower) would be for A^2 if isempty(ob.handle_power) error 'no power method for this object' end ob = ob.handle_power(ob, sup); if isfield(ob, 'scale') && ob.scale ~= 1 ob.scale = ob.scale .^ sup; end
a131b67d11d7b49d3940d9b86716a7b92788abcdc76a0db4aa0258c011c59a12
MATLAB
311
12
function Omega = matern_type_kernel(num_dim, h) % See main paper for definition. assert(isfloat(h), 'h must be a float') assert(h>0, 'h must be positive') assert(num_dim > 0, 'num_dim must be positive.') x = [0 : num_dim - 1]; Omega = (1 + sqrt(3) * abs(x' - x) / h) .* exp(-sqrt(3) * abs(x' - x) / h);
d35a6fe7fac5f395cf6b21196390b469094e03b3aeddfbc2e05ff268bef6812a
MATLAB
311
8
function res = figApply(obj, hFun, varargin) %FIGAPPLY Apply a function to all figures if nargout == 0 % "Too many output arguments" cellfun(@(k) hFun(obj.hFigs(k)), keys(obj.hFigs), varargin{:}); else res = cellfun(@(k) hFun(obj.hFigs(k)), keys(obj.hFigs), varargin{:}); end end
da49acc6b58f98a351b52c13b9ae4d6d2f953756355b02ec2bff6d7a65d986ab
MATLAB
311
7
function y = gauss_smooth(x, win) % Gaussian smoothing win = win + mod(win + 1, 2); k = (6 / sqrt(2 * pi) / win) * exp(-0.5 * (6 * linspace(-win / 2, win / 2, win) / win) .^ 2); conv_value = conv(x, k, 'full'); y = 1000 * conv_value((win - 1) / 2 + 1:length(conv_value) - (win - 1) / 2); end
ebb32b659913c711978d2229d5492e108e8a066c23cfa326662260c0ceb53c6f
MATLAB
311
5
function [ECGmean, ECGsd] = ECGBeatVariance2(x, peaks, wlen) % ECGBeatVariance2 has been deprecated. Use avg_beat_calculator instead. warning('ECGBeatVariance2 has been deprecated. Use avg_beat_calculator instead.'); offset_method = 'peak'; [ECGmean, ECGsd] = avg_beat_calculator(x, peaks, wlen, offset_method);
f6e5c3e98e16579c58c41354a7b49aa61524e3d43e2be5ccc69af1ac1d1a5344
MATLAB
312
17
function resp = get_resp(session, channel, unit, fold) % Get true responses of specific neuron % % Parameters % ---------- % % - fold: integer scalar % Fold number % % Returns % ------- % - resp: 2D matrix % (trial x time) response result = load_result(session, channel, unit, fold); resp = result.resp; end
414917f5d77fbf65b8ebef1d12784b68ef647e7abd27551911d47096f917636d
MATLAB
313
14
function [success, errmsg] = closeFiltForWriting(obj) %CLOSEFILTFORWRITING Close the filtered file success = 0; errmsg = ''; if obj.filteredFid < 3 errmsg = 'Filtered file is not open'; return; end success = (fclose(obj.filteredFid) == 0); obj.filteredFid = -1; end
e7e3d1bc7569d102d34462ebd939606d2a669a2b05d5d552da1dc58e9defab77
MATLAB
313
13
function [normalized] = normBOlDtimeseries(subttimeseries) % This program is intended to % % input: % subtimeseries: % % output: % normalized: % % by Hiroaki Hamada, Araya Inc., 2019/08/29th subttimeseries = (subttimeseries-mean(subttimeseries))./mean(subttimeseries); normalized = detrend(subttimeseries);
364f0d5463439f557a84744c7331f0b5a10b44cc8b3ce452a7a2d19e1520af42
MATLAB
314
12
function weights = genweights(layers, params, type) if (strcmp(type, 'cpu') || strcmp(type, 'gpu')) weights = genweights_mex(layers, params); elseif strcmp(type, 'matlab') weights = genweights_mat(layers, params); else error('"%s" - wrong type, must be either "cpu", "gpu" or "matlab"', type); end; end
58df46d3c95f2b1512e81bcbedb4e0666ad0bea771407350dcd0b8968ec1086d
MATLAB
314
9
%% Function of histamine inhibition of synthesis of histamine. %autoreceptors and depends on levels of g-coupled proteins activated (b) by %histamine and basal levels of g-coupled histamine (c). % Units in uM. function a = inhibsynHAtoHA(b, c) min_a = 0; a = 1 - (0.1).*(b - c); a(a<min_a) = min_a; end
aa391bf20a91d4f1242de8f713c9d0a2f901908fac95a2b0c299e560193d7023
MATLAB
314
15
function Struct = cat_struct(Struct1, Struct2) % concatente structures, also when potentially empty. if isempty(Struct1) || numel(fieldnames(Struct1)) == 0 Struct = Struct2; elseif isempty(Struct2) || numel(fieldnames(Struct2)) == 0 Struct = Struct1; else Struct = cat(2, Struct1, Struct2); end
2374a09787182a3ef644e62807e5b7441b915eb625805d4a01fde0606a8e3f4e
MATLAB
315
8
% Finder Spiker for Calcium Imaging % Initial interface to select % - Multiple-Condition Experiment % - - Detect Spikes from original .AVI videos and % - - List of Coordinates (ImPatch) or % - - ROI coordinates (ImageJ) % - Single-Condition Experiment % - - Detect Spikes from Fluorescence Traces (.CSV)
9afc42b89be4911b443af7f14897861d259347283885315a3b64fc23f3bf0895
MATLAB
315
10
function [e] = groupedErrorBar(y, err) hold on, ngroups = size(y, 1); nbars = size(y, 2); % Calculating the width for each bar group groupwidth = min(0.8, nbars/(nbars + 1.5)); for i = 1:nbars x = (1:ngroups) - groupwidth/2 + (2*i-1) * groupwidth / (2*nbars); e(i) = errorbar(x, y(:,i), err(:,i), '.'); end
f8cc4b2d8bf48b067bf842f9cecd8f4d26a66e0ea94eb094986d93b12fd4969a
MATLAB
315
17
function Q = GramSchmidt(A) % applying a Gram-Smidt orthogonalization % http://web.mit.edu/18.06/www/Essays/gramschmidtmat.pdf [m,n]=size(A); Q=zeros(m,n); R=zeros(n,n); for j=1:n v=A(:,j); for i=1:j-1 R(i,j)=Q(:,i)'*A(:,j); v=v-R(i,j)*Q(:,i); end R(j,j)=norm(v); Q(:,j)=v/R(j,j); end
ad155cedfef5e9d120249e9c44aaa8643bb918a8ba4b57579edcabacb01729bb
MATLAB
316
14
function [cmap]=mnl_GenerateShuffledColourmap(n) %Generates a shuffled hsv map so that each point would be a unique colour % n=number of colours wanted % % cmap - the colourmap outputted tcmap=colormap(jet(n)); % h=gcf; % close(h) order=randperm(n); cmap=nan(n,3); for i=1:n cmap(i,:)=tcmap(order(i),:); end end
cb2e5c18dab697f4fef834cab029c3076c17603d9c28fdf0db92ac74e09a7d73
MATLAB
316
14
function hAx = addAxes(obj, axKey, varargin) %ADDAXES Create and store new axes for this figure if ~obj.isReady obj.hFig = figure(); end if obj.hasAxes(axKey) return; end hAx = axes(obj.hFig, varargin{:}); obj.hAxes(axKey) = hAx; obj.axApply(axKey, @hold, 'on'); end
dde63d4fdc49296d7a224704f750c96d347c464a8693da8ecd334ceec500acab
MATLAB
316
5
function [A, B, ang] = RandomMatrices(angle, dim1, flag) % RandomMatrices has been deprecated. Use random_mat_max_col_space_ang instead. warning('RandomMatrices has been deprecated. Use random_mat_max_col_space_ang instead.'); Kmax = 10000; [A, B, ang] = random_mat_max_col_space_ang(angle, dim1, 3, flag, Kmax);
ed50235053aa756109f4f4bf630525b4deea9b87a8acd5a5401fe3d36b29ef24
MATLAB
316
25
function y = dmatrix(x) % d=dmatrix(data =[N x p]), %INPUT: x = [nodes x dimensionality of the coordinates] %OUTPUT: distance = distance matrix %NIKOLAOS LASKARIS %see http://users.auth.gr/~laskaris/index.htm [m,n]=size(x); a=x*x'; e=ones(m,m) ; d=diag(diag(a))*e + e*diag(diag(a))-2*a ; y=d;
3b51acc3927617db62a06f248954455a9c21e33f1d1c9f2062a03c223735665a
MATLAB
317
6
function [peaks, r] = PeakDetection4(ref, fs, h, fmax, varargin) % PeakDetection4 has been deprecated. Use peak_det_matched_filter_robust instead. warning('PeakDetection4 has been deprecated. Use peak_det_matched_filter_robust instead.'); [peaks, r] = peak_det_matched_filter_robust(ref, fs, h, fmax, varargin{:});
ecff6ee77bcdca936837ede3ddf914675a5212c52d894dec7b5370341e52c9a1
MATLAB
317
11
function out = matrix2vols(data,mask) %function out = matrix2vols(data,mask) % % takes 2d matrix [space x time] and 2d/3d mask [x y (z)] % and returns 3d/4d data [x y (z) time] mask2= reshape(mask,numel(mask),1)>0; out=zeros(numel(mask),size(data,2)); out(mask2,:)=data; out=reshape(out,[size(mask) size(data,2)]);
4adc82e41c4a2052f89f32864e8bef869ec72362f2a54582e597ff8cf80f92f3
MATLAB
318
4
function y = TikhonovRegularization(x, diff_order_or_filter_coefs, lambda) % TikhonovRegularization has been deprecated. Use tikhonov_regularization instead. warning('TikhonovRegularization has been deprecated. Use tikhonov_regularization instead.'); y = tikhonov_regularization(x, diff_order_or_filter_coefs, lambda);
afd8b75b0290e106380fabd37a459ea85d4df1ce8de0ac20702946e9fb841695
MATLAB
318
6
function index = ChannelIndex13(x,ff,fs, wlen) % ChannelIndex13 has been deprecated. Use sqi_pseudo_periodicity instead. warning('ChannelIndex13 has been deprecated. Use sqi_pseudo_periodicity instead.'); method = 'TRACE'; num_peak_det_itr = 1; [index, ~] = sqi_pseudo_periodicity(x, ff, fs, method, num_peak_det_itr);
3f280324f70ab2cd473e562fe4574534288baf5bebda2a6b6c44281512c17998
MATLAB
319
11
function [BC] = bimodalCoeff(inData) % function [BC] = bimodalCoeff(inData) % Returns bimodal coefficient for inData. % alex.teghipco@uci.edu m3 = skewness(inData, 0); m4 = kurtosis(inData, 0) - 3; n = (m3.^2) + 1; d1 = ((length(inData)-1).^2 / ((length(inData) - 2)*(length(inData) - 3))); d2 = (m4+3)*d1; BC = n/d2;
0fb13dc42c1d6b5df0ae747cadbd6faeff1064e415423d9b05332e93fa5ca52d
MATLAB
320
16
function i = vararginmatch(v,str) % Copyright 2009-2011 Thomas Koenig % distributed under the terms of the GNU AFFERO General Public License if iscell(v(1)) for i = 1:numel(v) if strcmp(v{i},str) return end end else if strcmp(v,str) i = 1; end end i = 0;
ae1b1fccfeb8e51525b10d598627ce6a12c170e331c7302dd22348ed46b16068
MATLAB
320
24
function out = end(ob, k, n) %function out = end(ob, k, n) % % handle calls of the following forms, for example: % ob(:,end) % ob(end,:) % ob(end) % % see 'doc end' for more explanation switch n case 1 if k ~= 1 fail 'bug' end out = prod(size(ob)); case 2 out = size(ob, k); otherwise fail 'unknown "n"' end
b5578b19b90a987c016b7688983f1ae42bd5330437f5666843e85df6a49d207a
MATLAB
320
18
function [dim, varargout] = size(ob, varargin) %function dim = size(ob, varargin) % or [dim1 dim2] = size(ob) % "size" method for this class dim = ob.size; if numel(varargin) == 1 dim = dim(varargin{1}); return elseif numel(varargin) ~= 0 error 'bug' end if nargout > 1 varargout{1} = dim(2); dim = dim(1); end
406c79c01ebd4b2fcbd2c243bd8b4517d6710bf1eb8733969fddbefee372e34e
MATLAB
321
17
function varargout = svd(ob, varargin) % compute svd of object by converting it to full matrix. % this will be very slow for big objects ob = full(ob); [u s v] = svd(ob, varargin{:}); switch nargout case 1 varargout = {diag(s)}; case 2 varargout = {u, s}; case 3 varargout = {u, s, v}; otherwise fail 'eig bug' end...
15b24dff0953b346ca5b4d1bb74aac0af8e251bf8b078e5bc1d7e324e98aa5cf
MATLAB
322
14
function [ zmean, zstd ] = z_mean_std( C ) % each col of C is a partition, C is of pxRep [~,rep] = size(C); count = 0; zVec = zeros(rep*(rep-1)/2,1); for i = 1:rep-1 for j = 2:rep count = count + 1; zVec(count) = zrand(C(:,i), C(:,j)); end end zmean = nanmean(zVec); zstd = nanstd(zVec); en...
352a089961327a1e75a627dea0557abc984096cc8c378a18d85e3aab73fe9a7d
MATLAB
322
13
function lim1 = trimLim(lim1, lim0) %TRIMLIM Find intersection of two limit ranges dx = diff(lim1); if lim1(1) < lim0(1) lim1 = lim0(1) + [0, dx]; end if lim1(2) > lim0(2) lim1 = lim0(2) + [-dx, 0]; end lim1(1) = max(lim1(1), lim0(1)); lim1(2) = min(lim1(2), lim0(2)); en...
89dbc02930d0219cae411dc9cac8991d39c09f43386eac9c4fcf2d93342276f9
MATLAB
322
4
function [y1, y2, Pbar, Phat, PSmoothed, Kgain] = KalmanARFilter(x, b, a, varargin) % KalmanARFilter has been deprecated. Use arma_kalman_filter instead. warning('KalmanARFilter has been deprecated. Use arma_kalman_filter instead.'); [y1, y2, ~, Pbar, Phat, PSmoothed, Kgain] = arma_kalman_filter(x, b, a, varargin{:}...
b04c319dd23bc35f70983eb6d5d68cc67aaf972ae046aa2d3f76c9a6f64255dc
MATLAB
323
4
function [dipole, teta]= DipoleGeneratorAbnormal(N,fs,f,alphai,bi,tetai,teta0,STM,S0) % DipoleGeneratorAbnormal has been deprecated. Use vcg_gen_abnormal instead. warning('DipoleGeneratorAbnormal has been deprecated. Use vcg_gen_abnormal instead.'); [dipole, teta]= vcg_gen_abnormal(N,fs,f,alphai,bi,tetai,teta0,STM,S...
43a34aeb6c5c82058ae7545d4269a2a7d3e0c573441748c55d15f38e9b8deaa1
MATLAB
324
15
function out = fft3s(data, useRescale) % function out = fft3s(data, useRescale) % % Do 3D FFT on first 3 dims of data and fftshift if nargin < 2 useRescale = 0; end out = fft1s(fft2s(data),3); if useRescale nx = size(out,1); ny = size(out,2); nz = size(out,3); out = out / sqrt(nx) / sqrt(ny) / sqrt(nz);...
75fee6134de8db2b7411ed83c13f020505b75b6672ad8931fa136ab5144ba19e
MATLAB
324
18
function out = ssos(in,dim) if nargin > 1 out = sqrt(sum(in.*conj(in),dim)); else if size(in,4)==1 if size(in,3)==1 out = sqrt(sum(in.*conj(in),2)); else out = sqrt(sum(in.*conj(in),3)); end else out = sqrt(sum(in.*conj(in),4)); end ...
ca59f2006fc00c102d2cc4759e32a6197428f480da07d83495d788af65c1886c
MATLAB
324
4
function [peaks, peak_indexes] = PeakDetectionAdaptiveHR(x, ff, fs, varargin) % PeakDetectionAdaptiveHR has been deprecated. Use peak_det_adaptive_hr instead. warning('PeakDetectionAdaptiveHR has been deprecated. Use peak_det_adaptive_hr instead.'); [peaks, peak_indexes] = peak_det_adaptive_hr(x, ff, fs, varargin{:}...
cd0555e16bf0f936b299260c5ecd2a69151621b7cb7f6fcffd89b5bfa21fc5d2
MATLAB
324
10
function E = ECGModelError(X,ECGmn,Phasemn,flag) % ECGModelError has been deprecated. Use ecg_gen_from_phase instead. warning('ECGModelError has been deprecated. Use ecg_gen_from_phase instead with required changes.'); Z = ecg_gen_from_phase(X, Phasemn); if flag==0 E = Z - ECGmn; elseif flag==1 E = Z; ...
68281932b9ebe8155ae7ae830c6adf982c801e982a4f679e32b79abb0d35a5e3
MATLAB
325
25
function [f1 f2 ] = split_fid(f) for k=1:length(f) exa = f(k).examnumber; switch exa case {'E1','E3'} if ~exist('f1') f1(1) = f(k); else f1(end+1) = f(k); end case {'E2','E4'} if ~exist('f2') f2(1) = f(k); else f2(end+1) = f(k); end end end ...
9904b676586c4cfabcdda0fce48f54de8a0501302f36456df9990782190aafd8
MATLAB
325
4
function [ARCoefsKF , ARCoefsKS] = TimeVariantAR(data, order, x0, q, R, p0, alpha) % TimeVariantAR has been deprecated. Use time_variant_ar_kalman instead. warning('TimeVariantAR has been deprecated. Use time_variant_ar_kalman instead.'); [ARCoefsKF , ARCoefsKS] = time_variant_ar_kalman(data, order, x0, q, R, p0, al...
995031f77d37f639f370fde4abd78a0b539a29e012251ff088a684d655fca681
MATLAB
325
14
clear clc cd('I:\My Drive\ELYASHIV\PFC_paper_results_after_revision\eopn3\clusters\clusters_control') %% load("intensities_mean.mat") load("intensities_sem.mat") %% psth_highest.mean = squeeze(intensities_mean(:,1,:)); psth_highest.sem = squeeze(intensities_sem(:,1,:)); %% cd .. save('psth_highest_control'...
2f2d23a48be1af2964a61e9e1aafb392f764932cc61dfafbbfabc1d7aa1f7dc2
MATLAB
326
19
function [y] = dphi(x, param) % Derivative of scaled/biased logarithmic sigmoid: a * s(x - b) (1 - s(x - b)) % % Parameters % ---------- % - x: array % Input % - param: [scalar, scalar] % Scale and bias parameters % % Returns % ------- % - y: array % Output s = logsig(x - param(2)); y = param(1) .* s .* (1 - s);...
623290e7b2b0724bcff8cdced30856b7ac0cf412411c4f553a6417f03d8651da
MATLAB
326
11
function [leny,yes_rowvec] = get_len_yvec(y) % function [leny,[yes_rowvec]] = get_len_yvec(y) sizey = size(y); if length(sizey) > 2 || ((sizey(1) > 1) && (sizey(2) > 1)) error('y must be either a row or column vector'); end leny = max(sizey); if nargout > 1 if sizey(1) > 1, yes_rowvec = 1; else, yes_rowvec = 0; en...
686347ecfa1cd65ee4ef4a8de5c7841d53733a178a4998054ad0b55a46011b71
MATLAB
326
16
function Struct = remove_empty_fields_from_struct(Struct) % removes empty fields if isempty(Struct) warning('empty struct') return end Fieldnames = fieldnames(Struct); for Indx_F = 1:numel(Fieldnames) if isempty(Struct.(Fieldnames{Indx_F})) Struct = rmfield(Struct, Fieldnames{Indx_F}); end e...
338e554761a6559d5d2b831ae51ee6fba7327ac3a7f451db1fa6f85fc873f641
MATLAB
328
12
function car = getCAR(samplesIn, CARMode, ignoreSites) %GETCAR Get common average reference for samples (mean or median) if ~isempty(ignoreSites) samplesIn(:, ignoreSites) = []; end if strcmpi(CARMode, 'median') car = median(samplesIn, 2); else car = mean(samplesIn, 2); ...
b5205297d24007f379d5cc58733bd7379f276bfa236938c785c7b512c5bafa2c
MATLAB
328
11
function y = RemoveEEGSeizureNoise(x, fsx, probth, wlen, keep) % NSCA lx = round(wlen*fsx); Ex = sqrt(filter(ones(1, lx), lx, x.^2, [], 2)); eex = mean(Ex, 1); thx = quantile(eex, probth); Ix = find(eex >= thx); Jx = 1:length(Ex); %find(eex < thx);% [s , ~, A] = NSCA(x, Ix, Jx); y = A(:, end-keep+1:end)*s(end-keep+1:e...
6eb86c0650e8db5fe3e75ff34138fa37ac563b77545fded65da92b11a797e114
MATLAB
329
16
function out = ifft3s(data, useRescale) % function out = ifft3s(data, useRescale) % % Do 3D FFT on first 3 dims of data and fftshift if nargin < 2 useRescale = 0; end out = ifft1s(ifft2s(data),3); if useRescale nx = size(out,1); ny = size(out,2); nz = size(out,3); out = out * sqrt(nx) * sqrt(ny) * sqrt...
b0e6af42bf64b081bdd36a82cb22c26fa78a9087639cfcb3d6e882b0624432c8
MATLAB
329
13
function Find_Longitudinal_Axis_Segments(Workspace,Cxy) % List CB vertices: F1 = find([Workspace.Vertices.Order] < 0); S = struct('Branch_index',{},'Segments',{},'Vertices',{}); for i=1:length(F1) % For each CB vertex (also CB branch). while % Trace the branch until a termination condition is met. end...
d8cb3b78edd4bc04991b509f9442644c500ab4e0e913eee3bcf1558fd7c75ac7
MATLAB
329
16
function [map_states] = mapstates_mode(st_post) NT = size(st_post,1); nsubs = size(st_post,2); map_states = zeros(NT, nsubs); for sub = 1:nsubs for i = 1:NT tbl = tabulate(squeeze(st_post(i,sub,:))); counts = tbl(:,2); [~,ind] = max(counts); map_states(i,sub) = tbl(ind,1); end ...
f2f0586fd926689e0f7b1af417a61d0337bb3d78a5bd965f18ea72d3ed80f139
MATLAB
329
13
function [err, bad, pred] = cnntest(layers, weights, params, test_x, test_y, type) pred = cnnclassify(layers, weights, params, test_x, type); [~, pred_ind] = max(pred, [], 2); [~, y_ind] = max(test_y, [], 2); bad = find(pred_ind ~= y_ind); err = length(bad) / size(pred_ind, 1); %bad = []; %err = sum((pred - y).^2) /...
0682a007a9840f19038faee81f290b045bd684389d90b638e805e95226cf8e75
MATLAB
330
19
function T2 = find_T2(f) for k=1:length(f) te(k) = f(k).TE/1000; y1(:,k) = f(k).integral_real; y2(:,k) = f(k).integral_real_all; y3(:,k) = f(k).integral_fid_abs; end [a,b] = fit_ax_b(te,log(y1)); T2(1,:) = -1./a; [a,b] = fit_ax_b(te,log(y2)); T2(2,:) = -1./a; [a,b] = fit_ax_b(te,log(y3)); T2(3,:)...
2a9b947c97decadda8c00d39b2443eca54a27762538dcdc55ac09cb400e720a4
MATLAB
330
7
function ExcludedCycles = is_only_exclusion_criteria(CyclesMeetCriteria, IdxCriteria) % identifies all cycles that were excluded only because of this criteria I = 1:size(CyclesMeetCriteria, 2); I(IdxCriteria) = []; Remaining = all(CyclesMeetCriteria(:, I), 2); ExcludedCycles = Remaining & ~CyclesMeetCriteria(:, IdxCrit...
89a8ebc8c08ddd3c0e50a671f5d0962af03b03deafe1473e8a58d2d9ee91e727
MATLAB
330
8
function metafile = findMeta(binfile) %FINDMETA Given a path to a recording (.bin, .dat), find its meta file % Returns absolute path to meta file if it exists, otherwise empty % string. [dirname, filename] = fileparts(binfile); metafile = jrclust.utils.absPath(fullfile(dirname, [filename '.meta'...
402d7e1f9aa8ad3c3516dc7a8e4d5aefcefd1c809a7eab4f1830f2b25891e730
MATLAB
331
14
function out = fft2s(data,useRescale) % function out = fft2s(data,useRescale) % % Do 2D FFT on each slice of data and fftshift if nargin < 2 useRescale = 0; end out = fftshift(fftshift(fft2(ifftshift(ifftshift(data,1),2)),1),2); if useRescale nx = size(out,1); ny = size(out,2); out = out / sqrt(nx) / sq...
9564ef0e8a83166eb59c8fe8a758fbed40ea9bfb6b132e35e0be5ecd8c6eceab
MATLAB
331
11
function im = warpIm(im,mask) targetRowLen = size(im,2); % go through rows and do interpolation for i = 1:size(im,1) startIdx = find(mask(i,:),1,'first'); rowLen = targetRowLen - (startIdx-1); im(i,:) = interp1(1:rowLen,single(im(i,startIdx:end)),linspace(1,rowLen,targetRowLen)); ...
85c300690ed4fa4f5705794471c89aeffef086275f3c50b44acd95fcc9b2a7e5
MATLAB
332
16
function SaveITS global ITS fname tfile FLName dpath3 tfiletrim=strtrim(tfile); fnametrim=strtrim(fname); FLName if strcmp(fnametrim(end-7),'C'); OLD=cd; path=[dpath3,'\R_LPhaseFolder']; cd(path); FLname=[tfiletrim(1:end-2),fnametrim(1:end-4),'ITS']; ITS save(FLname,'ITS'); c...
7cbf78721d076550fc1f4073ebb507a6ccea792ca0b7d18d513e7dc4b3818072
MATLAB
333
12
function StructMain = add_fields_to_struct(StructMain, StructNew) % add all fields and their respective values of StructNew % to every struct in StructMain. Fieldnames = fieldnames(StructNew); for n = 1:numel(StructMain) for Fieldname = Fieldnames' StructMain(n).(Fieldname{1}) = StructNew.(Fieldname{1}); ...
e7e9750adc5a3661f761c098def33ead00c50d7e7b288a8f23ea18a64d45b0ae
MATLAB
334
10
function status = spmup_check_matlab_version() status = 0; % matlab 2019a % see https://en.wikipedia.org/wiki/MATLAB#Release_history matlabVersion = '9.6.0'; if verLessThan('matlab', matlabVersion) warning('Some features are not implemented for MATLAB version < R2020a.'); status = 1...
07bbe4519c2b155534d65be61791fdd89b7903f58156f315f30ed4e999c0f808
MATLAB
335
13
function [spikeMin, spikeMax, vpp] = spikeMinMax(spikeWindows) %SPIKEMINMAX Summary of this function goes here spikeMin = shiftdim(min(spikeWindows))'; spikeMax = shiftdim(max(spikeWindows))'; if nargout == 3 vpp = spikeMax - spikeMin; end spikeMin = abs(spikeMin); spikeMax = abs(s...
26c47e02cb95444d94b4d4deb75fca696725a080e1fbf7baa458e48a4e405dfd
MATLAB
335
14
function out = ifft2s(data, useRescale) % function out = ifft2s(data, useRescale) % % Do 2D FFT on each slice of data and fftshift if nargin < 2 useRescale = 0; end out = fftshift(fftshift(ifft2(ifftshift(ifftshift(data,1),2)),1),2); if useRescale nx = size(out,1); ny = size(out,2); out = out * sqrt(nx) ...
a24defcd3d4002e4260f188c46ca4746c47e78e04137ff5a7bf19e9b17d0e9d9
MATLAB
335
7
function rescaleFigTime(hFigTime, timeScale) %RESCALEFIGTIME YLim = hFigTime.axApply('default', @get, 'YLim'); hFigTime.axApply('default', @set, 'YLim', [0, YLim(2)*timeScale]); hFigTime.axApply('histogram',@set,'YLim', [0, YLim(2)*timeScale]); imrectSetPosition(hFigTime, 'hRect', [], [0, YLim(2)*ti...
c88584dd715c2bb6b565ef1346f9111f2b2f4dfbcf0f8b0b4018fb0e9d00a320
MATLAB
335
14
% loop over folders and call get celltype_parameters_function clear clc n = 1;% number of experiments to cell for i =1:2 [file{i}, path{i}] = uigetfile('temp_wh.dat'); exp_id{i} = inputdlg(path{i}, 'PHB',[1 50], "PHB"); end %% for i =1:2 get_celltype_parameters_function(path{i}, file{i}, exp_id{i}...
f22682714aafb0a1123798354a0619463e2198302e7a64b5ccab85f79cfc3c63
MATLAB
335
4
function [stacked_events, num_non_zeros] = EventStacker(signal, event_indexes, event_width, varargin) % EventStacker has been deprecated. Use event_stacker instead. warning('EventStacker has been deprecated. Use event_stacker instead.'); [stacked_events, num_non_zeros] = event_stacker(signal, event_indexes, event_width...
fb2225450929167d163e1a060803d3da6866acea6b3ae7cb7cc9f9d3fb004c79
MATLAB
335
13
%% devide right and left %load brain render table clc clear [filename, path] = uigetfile("MultiSelect","off", ".csv"); datafile = fullfile(path, filename); %save path cd(path) T = readtable(datafile); %% right_T = T(T.x < 5500, :); left_T = T(T.x > 5500, :); writetable(left_T, 'left_cells.csv') writetable(right_T, 'rig...
72d29c750b35c208a9d210b9a49343774608e6fd4690ae244868e903a51830d3
MATLAB
336
15
function ShowProgress(Prog,handle) % Copyright 2009-2011 Thomas Koenig % distributed under the terms of the GNU AFFERO General Public License if ~ishandle(handle) return end axes(handle); h = barh(0.5,Prog); set(h,'BarWidth',1,'EdgeColor',[1 0 0],'FaceColor',[1 0 0]); set(gca,'XTick',[],'YTick',[]); axis([0 ...
bc49eb64462fbebaf9eb78ddf3e1a8f94383e1b70e061427e325023a5a68b016
MATLAB
336
14
function [coef,pval ] =nancorr(x, varargin) if nargin == 1 x = x(~any(isnan(x),2),:); [coef,pval] = corr(x); else if ~ischar(varargin{1}) y = varargin{1}; vidx = ~any(isnan(x),2) & ~any(isnan(y),2); x = x(vidx,:); varargin{1} = y(vidx,:); end [coef,pval] = corr(x,var...
c7b5be9bef51fe508a6aa8d5bd9552aada1fb664a4825b302e715cfef1399267
MATLAB
336
11
function [train_x] = normalize(firstlayer, train_x) if (isfield(firstlayer, 'norm')) datanorm = sqrt(sum(sum(sum(train_x.^2, 1), 2), 3)); datanorm(datanorm <= firstlayer.eps) = firstlayer.norm; train_x = train_x ./ repmat(datanorm, [firstlayer.mapsize firstlayer.outputmaps 1]); train_x = train_x * firstlayer.n...
2c8afbfd3815e886ae7a917ccb8c284c2bc6a707fd2184a57de50e8fbda1c108
MATLAB
338
15
function knl = get_a_knl_stm(session, channel, unit) % Get average of estimated stimulus kernels of specific a-model % % Parameters % ---------- % % % Returns % ------- % - knl: 4D array % (width x height x time x delay) stimulus kernel of s-model model = load_avg_model(session, channel, unit); knl = model.set_of_ke...
7312bd7ece238a1c234c31c1770e5653d09d4e845fa884507cfc68685b24cf41
MATLAB
338
4
function [theta_min, theta_max, theta_mean, theta_med, ang] = ColumnSubspaceAngle(A, B) % ColumnSubspaceAngle has been deprecated. Use column_subspace_angle instead. warning('ColumnSubspaceAngle has been deprecated. Use column_subspace_angle instead.'); [ang, theta_min, theta_max, theta_mean, theta_med] = column_sub...
3b68fe90a7d6ff499a0b35e54142528890016b02ba808ce6b3c9a123c90c8df0
MATLAB
339
12
function plotAuxRate(obj, selectedOnly) %PLOTAUXRATE if selectedOnly corrData = jrclust.views.plotAuxCorr(obj.hClust, obj.selected(1)); else corrData = jrclust.views.plotAuxCorr(obj.hClust, []); end if ~isempty(corrData) jrclust.utils.exportToWorkspace(corrData, obj.hCfg.ver...
543aef4754a6f8867e1506458c028e6f320680ecf392e215c924511b740898d9
MATLAB
339
7
for k=1:size(P,1) [p f] = fileparts(P(k,:)) ; [p f] = fileparts(p); mkdir(fullfile('/home/romain/tmp/MM_for_g',f)) cmd=['!cp -pr ' P(k,:) ' ' fullfile('/home/romain/tmp/MM_for_g',f...
c2196a8bb489fc694750b99bce89226bf818e2794e22594cdf57072d19f3df86
MATLAB
339
14
function data = XxReadTiffSmallerThan4GB(TiffPath) pic_info = imfinfo(TiffPath); [frame_CCD,~] = size(pic_info); row_CCD = pic_info.Height; colum_CCD = pic_info.Width; data = zeros(row_CCD,colum_CCD,frame_CCD); for frame_temp = 1:frame_CCD data(:,:,frame_temp) = imread([TiffPath],'Index',frame_temp); end % data =...
04e67aa574d4acea62d81e38e9f2ca95ddd00134a0adca0b9c0ea3d39cf15eb8
MATLAB
340
4
function [e, n] = AdaptiveFilterMultipleDelay(x, mindelay, maxdelay, taps, mu) % AdaptiveFilterMultipleDelay has been deprecated. Use adaptive_filter_multi_lag instead. warning('AdaptiveFilterMultipleDelay has been deprecated. Use adaptive_filter_multi_lag instead.'); [e, n] = adaptive_filter_multi_lag(x, mindelay, ...
095019ab996ab31178501968a5c8099161abad9455a6f053529e8dc5fc3274f6
MATLAB
340
13
function success = writeFilt(obj, filteredData) %WRITEFILT Write filtered data to a file success = 0; if ~obj.openFiltForWriting() warning('Failed to open filtered file'); return; end count = fwrite(obj.filteredFid, filteredData, ['*' obj.dataType]); success = (count == numel(f...
0ebd36fdcce7eb338222b98d560a812651febb68585b4d0b90b7e1a8f41989c5
MATLAB
340
16
function r = InstCorr (x,tau) % Instantaneous signal correlation calculator % Reza Sameni, 2010 x = x(:); N = length(x); M = ceil(max(abs(tau))/2); xx = [zeros(1,M) x' zeros(1,M)]; r = zeros(N,length(tau)); t = 1:N; for i = 1:length(tau) tt1 = t - round(tau(i)/2); tt2 = t + round(tau(i)/2); r(:,i) = xx(tt...
b697f8cf2178dc6f32d1025ac24599d52ee179012e9c3d5abcb180e47cd81df5
MATLAB
340
20
function file = load_file(filename) % Load file % % Parameters % ---------- % - filename: char vaector % Filename which would be loaded % % Returns % ------- % - data: structure array % Loaded data fprintf('Load `%s`: ', filename); tic(); file = load(filena...
6516fd199643cb8e4fdea2d8de0fdbaa81de7945d19579c720a6f8554e452ad0
MATLAB
343
14
function [Xout, Yout, Zout] = surfscale(q,X,Y,Z) %surfscale - takes a surface scalar and surface vectors as input, returns %input grid scaled by q as output. Ensure X,Y,Z is 3D and has equal %dimensions. siz = size(X); assert(length(siz) == 2,'Surface dimensions != 2'); assert(siz(1) == siz(2)); Xout = q.*X; Yout = ...
45d689c922e978fc31d9408167532172b12540a68aa46d664f9eee87226684c3
MATLAB
344
12
A = all_psthT.position; B = T.acronym; for i = 1:length(A) idx(i) = contains(A{i}, B{i}) end T2 = readtable("cells_coordinates_map.csv"); T2.in_struct_prob = T.in_structure_prob; for i = 1:length(T2.id) rowname{i}= [T2.exp_name{i} '_cell_' num2str(T2.id(i))]; end T2.Properties.RowNames = rowname; row...
7c0e6f79b14fe0f0efe87d4282658548088e96188a290b42dfef3ee6299bbdad
MATLAB
344
4
function [lambda, AIC, MDL, NEW, ENSTh, ENS, fhand] = EstimateDimension(x, noisevar, flagplot) % EstimateDimension has been deprecated. Use dimension_estimation instead. warning('EstimateDimension has been deprecated. Use dimension_estimation instead.'); [lambda, AIC, MDL, NEW, ENSTh, ENS, fhand] = dimension_estimation...
60a15e731ca8ac648a28c1a468099b6464f005405c57264b4552e3e41cb67189
MATLAB
345
16
n_state = 2 n_covariate = 4 Xi_old = rand(n_state,n_state+n_covariate) Z = [0,1;0,1;0,1;1,0;1,0;0,1;0,1;1,0;0,1;1,0] Exo = randn([n_covariate,10]) a = 0 b = 10 S = 2 Y = [randn(4,1);5*randn(6,1)] Omega = reshape([1,5],[1,1,2]); Xi_new = Holsclaw_Param(Xi_old, Z, Exo, a, b) [states, probs, t_prob] = Holsclaw_State(Xi...
ed2ed57aa6cef249a3768ffd74a194020bfe2de701cccdf1c74a7157433feeaf
MATLAB
345
12
function hRec = newRecording(rawPath, hCfg) %NEWRECORDING Create a new RawRecording based on recordingFormat switch hCfg.recordingFormat case 'Intan' hRec = jrclust.detect.IntanRecording(rawPath, hCfg); otherwise % SpikeGLX .bin/.dat hRec = jrclust.detect.Recording(rawPa...
22325412d7c986006dbea9878de3ce80597329c88cd9c0b24ea6d88d9e690981
MATLAB
347
16
function supp_fig1_experiments(save) %% Supplemental Figure 1: Auto- and cross-correlation figures if nargin == 0 save = ""; end autocorrelatemap('100140949'); if save get_save_figure(gcf, 'Figures', 'supp_fig1_auto'); end crosscorrelatemaps('100140756', '100140949'); if save get_save_figure(gcf, 'Figure...
b7a45ea1303690043f35715f3eb984450b3d87ec0ce384499cbf8364db37e5b9
MATLAB
347
15
function fo = remove_first_points(fi,numberofpoints) if ~exist('numberofpoints') numberofpoints=1; end fo = fi; for nbs = 1:length(fi) fo(nbs).fid = fi(nbs).fid(numberofpoints+1:end,:); fo(nbs).spectrum.np = fo(nbs).spectrum.np -numberofpoints; fo(nbs).spectrum.n_data_points = fo(nbs).spectrum.n_data_poin...
3bba0cea9e12152cf52af2d6cd4387cf6c29fabd6140171feab3866abd9ba76e
MATLAB
348
10
function sampleRMS = estimateRMS(samplesIn, nSubsamples) %ESTIMATERMS Estimate RMS of samples using median if nargin < 2 || isempty(nSubsamples) sampleRMS = median(abs(samplesIn)); else sampleRMS = median(abs(jrclust.utils.subsample(samplesIn, nSubsamples, 1))); end sampleRMS = sing...
07d9f7c3ea66ba8ac522ec1df011bb1a074284643528b23f3f90345795e445ed
MATLAB
349
12
function tracesOut = bit2uV(tracesIn, hCfg) %BIT2UV Transform collected trace values to uV if strcmp(hCfg.filterType, 'sgdiff') nrm = sum((1:hCfg.nDiffOrder).^2) * 2; elseif strcmp(hCfg.filterType, 'ndiff') nrm = 2; else nrm = 1; end tracesOut = single(tracesIn) * single...
74eed7c15df4c48b5bb7342ae9e8298a0b8aefc6a10d151e1f555e7887bf04d9
MATLAB
349
11
function openRaw(obj) %OPENRAW Open the raw recording file for reading if obj.rawIsOpen return; end obj.rawData = memmapfile(obj.rawPath, 'Offset', obj.headerOffset, ... 'Format', {obj.dataType, obj.dshape, 'Data'}, ... 'Writable', false...
55357bb952a1e831a1847b642a9414ec8b0ce1d3ee23902378dadd2ca2b8786d
MATLAB
350
10
function process_segs_batch(foldernames, Fs) % process segments by the batch % foldernames : cell array of strings % Fs : in seconds % Assumes that the working directory is where this matlab file is for i=1:length(foldernames) fprintf("----SEG %d\n----", i); process_single_segment(fo...
aa0f8c257bc69ddcebc68494f7e8c64a3128dc13e1f7e8a8a8fa58679beed899
MATLAB
350
11
function updateFigWav(obj) %UPDATEFIGWAV if ~obj.hasFig('FigWav') return; end hFigWav = obj.hFigs('FigWav'); obj.showSubset = 1:obj.hClust.nClusters; jrclust.views.plotFigWav(hFigWav, obj.hClust, obj.maxAmp, obj.channel_idx, obj.showSubset); setFigWavXTicks(hFigWav, obj.hClust, ...
028009226d6829784dea0052c1508b7bb14e29157f8856f6dd87d6e32d1e45b3
MATLAB
351
7
m = loadMovie('G:\E7_2DAA\miniscope\subject13\session1\preprocessed\preprocessedMovie.h5',1,1000); savePath = 'G:\E7_2DAA\misc\example_movie_data\preprocessed.h5'; saveMovie(m,savePath) m = loadMovie('\\DROBO6\Public\E7_miniscope_concat\M13\Session1\rawMovie.h5',1,4000); savePath = 'G:\E7_2DAA\misc\example_movie_data\...
0a3a03b4722dd51e662f42c433e3e60a407da59c68bd8f2f94622f120b7460a9
MATLAB
351
17
function display(ob) %function display(ob) % "display" method for this class name = inputname(1); printf('"%s" is an object of class "%s":', name, class(ob)) ob = struct(ob); disp(ob) fnames = fieldnames(ob); for ii=1:length(fnames) fname = fnames{ii}; if isstruct(ob.(fname)) printf('%s.%s :', inputname(1), fnam...
e30a8df0faf93801693271d4ebc7b422f78ca24f01a01b9eefd2f81f77b6ac79
MATLAB
351
20
function W = tukey(n,kc,w) % function W = tukey(n,kc,w) % % Tukey windowing function, as described on p496 of Bernstein2004 if nargin < 3, w = 0.15; end if nargin < 2, kc = 0.85; end if length(n)==1 kvals = linspace(-1,1,n); else kvals = n; end W = cos((pi*(abs(kvals)-kc))/(2*w)).^2; W(abs(kvals) < kc) = 1; ...
1be95d994973454959493a5867764dd698778bf99cf4a85b4717773726f74dbb
MATLAB
352
11
function [logdet] = matrix_cholesky_logdet(A) % Compute the logarithm of the determinant of a positive definite symmetric % matrix (i.e. log|A|) based on the cholesky factor of A, i.e., L L' = A. assert(ismatrix(A), 'A has to be a matrix of size (M X M)') assert(isreal(A), 'Please check A') L = chol(A,'lower'); logd...