sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
f9e075004df031693d72f55fd4e1def94d0bb99acecada021b8643e2672226f2
MATLAB
276
9
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function tau_n = tau_n(v, VTraub) tau_n = 1/(an(v, VTraub) + bn(v, VTraub)); end
d61f7e62813fb453bae8037adb2d9c6ac5332aa468fc7d7549445e4a858ff2ec
MATLAB
277
8
function [vcondition]=load_condition_InfoCapON_tbi_mask2SD_weight(trial,cond) for i=1:trial load(sprintf('Wtrials_%03d_%d_err_hete_ON_tbi_mask2SD_weight.mat',i,cond)); vcondition.infocap_all(i,:)=infocapacity; vcondition.suscep_all(i,:)=susceptibility; end
ee08ee8395edf2733d1c6b217904021deaeda35959ce67a416935225ada6adde
MATLAB
277
9
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function h_exp = h_exp(v,Dt, VTraub) h_exp = 1 - exp_t(-Dt/tau_h(v, VTraub)); end
f1d1e3e71f50c6a2d932c12847b9cf0658b7e21f2462790bb8a3521e16091931
MATLAB
277
10
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function Minf = Minf(Vpre) Minf = 0.1 + 0.9 / (1 + exp(-1000*(Vpre+0.04))); end
48d7df3cfc93011c6764b4b63aea64b070116c044afb5cc1e77cc7012710dea7
MATLAB
278
9
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function m_exp = m_exp(v, Dt, VTraub) m_exp = 1 - exp_t(-Dt/tau_m(v, VTraub)); end
69e83843e02631b0de3d4f8f3a34a1ca035a1bcd197b848540229a3d084d6834
MATLAB
278
9
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function tau_m= tau_m(v, VTraub) tau_m = 1/(am(v, VTraub) + betam(v, VTraub)); end
a575b8fb2af81163396b76cbcc6dfe04ee6a4aca35c82bdaddc8f8560ed0335b
MATLAB
278
14
function p = t_cdf(t,df) % A little slower and a little less precise (1e-12) than the statistics % toolbox version. % 2014/08/01 Martin (inspired by polyparci.m by Star Strider) x = df./(t.^2 + df); z = df/2; w = 0.5; p = 0.5*betainc(x,z,w); p(t>0) = 1-p(t>0);
0ea59652e563a8bb44ce967bfb28936139dc9be6581fc982d41647e9e348de02
MATLAB
279
11
function cmap = Rainbow(n) stdev = n/4; m1 = n/4; m2 = n/2; m3 = 3*n/4; x = 1:n; y1 = exp(-(x - m1).^2/2/stdev/stdev); y1 = y1/max(y1(:)); y2 = exp(-(x - m2).^2/2/stdev/stdev); y2 = y2/max(y2(:)); y3 = exp(-(x - m3).^2/2/stdev/stdev); y3 = y3/max(y3(:)); cmap = [y1', y2', y3'];
e72cd15ec3605b6e7ef79fc7f1f350753240f07c7eb03600db78708997177f1e
MATLAB
279
10
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function s_inf = s_inf(v) vx = 7; s_inf = 1/(1+exp(-(v+vx+57)/6.2)); end
23a39e22ba8d1bba6cfa46110c8ec5d1ff71bc1bd3e63ab69cf7290e15d9b4ff
MATLAB
280
17
function P = verify_stron_con(W) % Verify the directed graph with strong connected n_ROI = size(W,2); P = zeros(n_ROI,n_ROI); for k=1:n_ROI C1 = W^k; P = P + C1; end P = (P~=0); if P ~=1 sprintf('This is a not strongly-connected graph') end end
454775ea0df1e3282effa0026b558fe95d3c1df717ddab212b5d901f078eb959
MATLAB
280
9
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function tauFunc = tauFunc(a, b, c, d, v) tauFunc = c + d./ (1 + exp(a.*(v+b))); end
75e65c10efa02ac94331749566547bd061cf18d6ae29ae0529848ab523562120
MATLAB
280
19
function SO = merge(S1,S2,offset) % Merges tsd's in tsdArray % if length(S1)~=length(S2) error('must the same length') end SO = cell(length(S1),1); for ii=1:length(S1) keyboard SO{ii} = ts([Range(S1.C{ii});Range(S2.C{ii})+offset]); end SO = tsdArray(SO);
09f65da30eed1e014fedf67018c42d179df953276bbbdae0c5685553c532cf4d
MATLAB
281
11
% loading stack load('.\..\wholestack.mat'); % loading cleaned tracks load('.\neurons_cleaned.mat'); % specifying output folder outputpath='.\..\output\'; % running the identification step identification_step(wholestack, neurons_cleaned, outputpath,[0.267 0.267 2]);
ae07ee4ad78aaaa51d5d0d34cd1b48d0585719f4ee2279e2240c96989ccb31fb
MATLAB
282
14
function spd = angSpeed(ang,win) if length(ang)>1 ang = ang(:); da = diff(ang); da(da>pi) = da(da>pi)-2*pi; da(da<-pi) = da(da<-pi)+2*pi; da = abs(gaussFilt(da,win)); spd = gaussFilt(da,win); spd = [spd(1);spd]; else spd = zeros(length(ang),1); end
f5a41a27ec002113a55b3a12d9bb7fd8fd6c944415f6d615b4189db4077fe483
MATLAB
282
9
function niiFile = select_nii_wbepi(cfg, subject, prefix) %SELECT_NII_ANAT Get the filename of the wholebrain EPI image % Detailed explanation goes here niiFile = fullfile(cfg.sub(subject).wbepi_dir, strcat(prefix, ... cfg.sub(subject).wbepi_fn,',1')); end
2f7a0a000b6ea5f0b341411272dd4cf4156d46f7c647e57b7e8ee0ca8b599a17
MATLAB
283
12
function l = length(tsa) % Returns number of elements in tsa (overoads length function) % % USAGE: % l = length(tsa) % % copyright (c) 2004 Francesco P. Battaglia % This software is released under the GNU GPL % www.gnu.org/copyleft/gpl.html l = length(Range(tsa));
4576df5eed525b9362e9e8593067f57d4eace90f076b8e73389f25190fad80c1
MATLAB
283
16
% INDENT Indent text % This function is used to indent a text that will be printed to the % standard output, depending on the verbose level. % % Copyright (c) 2011 Roberto Calandra % $Revision: 0.11 $ function indent(verbose) for i=1:verbose fprintf(' ') end end
70bf65560cd6857770be38acd45cb73b36dc4a3dd28bdc0e1f6cc105dafddb79
MATLAB
283
8
function dominant_states = getDominantStateIdsGroup(temporal_evolution_of_states, max_nstates) K = max_nstates; sc =zeros(1,K); for j=1:K sc(j) = sum(cell2mat(temporal_evolution_of_states)==j); end counts_post = sc/sum(sc); [~, dominant_states] = sort(counts_post,'descend');
4b8f1c6801fb0729954a1173a9859458754b946271a9c58a7bbd2402731b51db
MATLAB
284
8
function boris_data = rename_roman_events(boris_data) boris_events = boris_data.events; n_events = max(size(boris_data.events)); % Loop on each event category for i_event = 1:n_events boris_data.events(i_event).name = boris_tools.key2name(boris_data.events(i_event).name); end end
8c68bad0973d1283773859f524322f72144a5ef4d3ff0107cb5e51b7aa7d5045
MATLAB
284
14
function sz = size(TSA) % Return the size of the data component (overoad of the size function) % % USAGE: % sz = size(tsa) % copyright (c) 2004 Francesco P. Battaglia % This software is released under the GNU GPL % www.gnu.org/copyleft/gpl.html sz = size(TSA.data);
1e117bb4ff3780b60babd7256fdf0899a888ebe9346fc7a8b647a8114d10147e
MATLAB
285
14
function s = minus(a, b) % Returns the set difference of two intervalSet (overload of the - operator) % % USAGE: % s = and(a, b) % copyright (c) 2004 Francesco P. Battaglia % This software is released under the GNU GPL % www.gnu.org/copyleft/gpl.html s = diff(a, b);
d9d5e3af4d44450ed73a08db44c6757273990c7d320f07db240d6f6745cb74c1
MATLAB
285
15
function clear(O) % remove all items from dictArray O % copyright (c) 2004 Francesco P. Battaglia % This software is released under the GNU GPL % www.gnu.org/copyleft/gpl.html if O.keysReadOnly error('Keys are not modifiable'); end O.keys = {}; O.values = {};
034147eaf120166390a3be17a8eed6caad6cfa6ca619274fbc22878812b965e2
MATLAB
286
10
% %produces a gaussian kernel, for use by conv(....) %sig: sigma (in terms of # datapoints) %n: nr datapoints (symmetric) % %urut/march05 function gaussKernel = getGaussianKernel(sig, n) k=-n:n; gaussKernel=1/sqrt(2*pi*sig^2)*exp(-k.^2/sig^2); gaussKernel=gaussKernel/sum(gaussKernel);
25b46e61c503e8077ebf8396ef05f280c1f0e79f46f7f557276bdfa60e1176d6
MATLAB
286
8
function y = nancellfun(cell_arr, field_name) % extracts the specified field (must be a scalar) from the cell array % cell_arr y = nan(size(cell_arr)); isnotempty = cellfun(@(x) ~isempty(x), cell_arr); y(isnotempty) = cellfun(@(x) x.(field_name), cell_arr(isnotempty)); end
67e7bb082bf21a49436d02d497f16bbebfc2d63bacb3e6cd9efb9d301a16fdcb
MATLAB
286
9
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function h_inf = h_inf(v, VTraub) h_inf = ah(v, VTraub)/(ah(v, VTraub)+bh(v, VTraub)); end
a7f4af04d4fbaf7c672357a64fb834d679a2363f553b5c12397fff561c470312
MATLAB
286
8
function [vcondition]=load_condition_InfoCapON_tbi_mask1halfSD_bin(trial,cond) for i=1:trial load(sprintf(['Wtrials_%03d_%d_err_hete_ON_tbi_mask1halfSD_bin_corr.mat'],i,cond)); vcondition.infocap_all(i,:)=infocapacity; vcondition.suscep_all(i,:)=susceptibility; end
22e6b50f2b77512fc7c7b7eb62cbb22acde95d73abb861b06b34d747220041c5
MATLAB
287
11
function cmap = usa(N) % American flag colors colormap if nargin == 0 N = 100; end cmap = zeros(2*N,3); cmap(:,1) = [linspace(0,1-1/N,N) linspace(1,0.8784,N)]; cmap(:,2) = [linspace(0.0032,1-1/N,N) linspace(1,0.0863,N)]; cmap(:,3) = [linspace(0.6471,1-1/N,N) linspace(1,0.1686,N)];
27a51721f09c6f5346e8cf7160352307791bbb8419d7ce90c040a785980634fe
MATLAB
287
11
function d = KullbackLeibler(c2,c1) % D(P||Q) = KL(Cp,Cq) is the Kullback-Leibler divergence between distribution of covariance Cp and Cq % mean are assumed to be 0 % Adrien Peyrache 2007 N = size(c1,1); warning off d = 0.5*(log(det(c2)/det(c1))+trace(inv(c2)*c1) - N); warning on
8f792c0525a5c5f537bcd05b68af3aa3dbae2a36f342339df346ba192864acdf
MATLAB
287
8
function [vcondition]=load_condition_InfoCapON_tbi_mask1halfSD_weight(trial,cond) for i=1:trial load(sprintf(['Wtrials_%03d_%d_err_hete_ON_tbi_mask1halfSD_weight.mat'],i,cond)); vcondition.infocap_all(i,:)=infocapacity; vcondition.suscep_all(i,:)=susceptibility; end
a367688ab0206714bebfa151de0e423ac04ea2b576031da1214ee43c248edb95
MATLAB
287
14
function s = and(a, b) % Intersection between two intervalSet objects (overload of the & operator) % % USAGE: % s = and(a, b) % copyright (c) 2004 Francesco P. Battaglia % This software is released under the GNU GPL % www.gnu.org/copyleft/gpl.html s = intersect(a, b);
bb2ce409350ac760fa0bfa0351ab3686d46a83439ad0252b6d72e6c52720843b
MATLAB
288
9
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function m_inf= m_inf(v, VTraub) m_inf = am(v, VTraub)/(am(v, VTraub)+betam(v, VTraub)); end
fe0924a2899670ca20cdbcaa4646252341eb4b2e049143fe3e21d3cb90a75ecf
MATLAB
288
9
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function fhinf = fhinf(v) fhinf = 1/ (1 + 2*exp(180*(v+0.047)) + exp(500*(v+0.047))); end
b95ad4a1236bdff6825205928ae5baa5db9ff3d83d5a68938db9065969600d7b
MATLAB
289
13
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function v = exp_t(x) if (x < (-100)) v = 0; else v = exp(x); end end
dd0794ddf24a1789b8f86e1e3a400f3d252579041c8455a07da3786ae0d80529
MATLAB
289
16
function [dist] = euclidn(x,y) % [DIST] = EUCLIDN(X,Y) % % Calculate the Euclidean distance between two n-dimensional % vectors X and Y. if ~compare_size(x,y) ~isvector(x) error('X and Y must be vectors of the same length'); end dist = sqrt( ... sum( power(x-y, 2) ) ... );
12fefd0f5d4a00cdbefd5d145db193860dbe691c5a5a395b3d01b8d287f942a4
MATLAB
291
9
function varargout = read_voxels(software,varargin) % read_voxels varargin: % inputs: header, coordinates (n x 3 (XYZ)) % output: 1 x n vector of voxel values check_software(software); fname = [mfilename '_' lower(software)]; varargout{1} = feval(fname,varargin{:});
d7c10a94f6d0389a14579b743d6cf31c9ba3c530be3ca60401be42d336fa8204
MATLAB
292
13
% Should cut down from 756 to 378 % mlList/mlActAuto isn't affected function [hrf_GLM,mlList] = rmvSingleCond(hrf_GLM,numConds,mlList) condList = [1 3 5]; [reshapeIdxToRmv] = reshapeIdxByCond(condList,numConds,mlList); hrf_GLM(:,reshapeIdxToRmv) = []; mlList(:,reshapeIdxToRmv) = []; end
3253c266494a6916d318d90de1b687bc29c655dfb817df76ece05da224c3faf4
MATLAB
293
13
% function U = unity(A) % A is n x m matrix, and each column is a signal. % the function gives a unity signal for each column % i.e. [signal-mean(signal)] / std(signal) function U = unity(A) meanA = mean(A); stdA = std(A); U = (A - repmat(meanA,size(A,1),1))./repmat(stdA,size(A,1),1);
a459e7e912407909027f7797e2b903b06894dae93a0e96654a824c6515873195
MATLAB
294
15
pi=3.1415926535897932384626433832795028841971; x=3;y=4; t=1; % time s=1*t; % speed * time a=0; % angle of movement a=a/360 * pi*2; % convert to radians x=cos(a)*s+x; y=sin(a)*s+y; %fprintf("%f %f\n",x,y); deltaX = 0 - 0; deltaY = 0 + 4; angle = atan2d(deltaY,deltaX); fprintf("%f\n",angle);
ef70b15784208bc679a7cdb0fdc6741cbe4fbc265082a09f64c50752bd8bb534
MATLAB
295
18
function z = mdivide(x,y) if iscell(x) && iscell(y) z = cell(size(x)); for k = 1:numel(x) z{k} = x{k}\y{k}; end elseif iscell(x) z = cell(size(x)); for k = 1:numel(x) z{k} = x{k}\y; end elseif iscell(y) z = cell(size(y)); for k = 1:numel(y) z{k} = x\y{k}; end end
82c91cbc8a9a76a2310b4f55d3d1224fed1c91bef91cc9e68f26b03a2c4bf1f8
MATLAB
296
9
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function taumCaFFunc = taumCaFFunc(v) taumCaFFunc = 0.011 + (0.024/cosh(-330*(v + 0.0467))); end
a8d1f7e216e02314b245516e622ac1a2cc34ff5b2c5cc1f06f1c831b4220ad63
MATLAB
296
11
function [f_max] = fmax(x,dt) %FMAX x, dt % Returns the estimation of maximal frequency [kHz] in the given signal x % x signal % dt time step size [ms] [P_smoothed,f] = periodogram(detrend(x),[],2^18,1/dt); [~,P_max_ind] = max(P_smoothed); f_max = f(P_max_ind); end
600e81e7cc846817b9c08c283a36ab01130570477f103b1705ec76a39721f428
MATLAB
297
15
function s = cell2str_new(c) s = c; if iscell(c) maxlen = 0; for ii = 1:length(c) if length(c{ii}) > maxlen maxlen = length(c{ii}); end end s = char(zeros(length(c), maxlen)); for ii = 1:length(c) s(ii,1:length(c{ii})) = c{ii}; end end
744435ab3e283ee6f2debd4e94ea593b1c441013c945225ea075a5e480e16776
MATLAB
297
9
resultPath='/home/dichang/code/related_work/u-mvsnet/dtu_eval/TotalStat_mvsnet.mat'; x=load(resultPath); data=x.BaseStat; varacc = mean(data.VarData) varcomp = mean(data.VarStl) varoverall = (varacc+varcomp)/2 medacc = mean(data.MedData) medcomp = mean(data.MedStl) medoverall = (medacc+medcomp)/2
8a60833801ad8480f010e8cd95fca2f2e87a8529295f1b5b0f8889e9a4605f54
MATLAB
297
9
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function simplified_sV2= simplified_sV2(v) simplified_sV2 = (2^-1)*tanh(((2^-4)+(2^-6))*v+5)+0.5; end
d468c819e6ff18715ae6c35890966f2b36f962614ac72fab11bf7026f8f2354a
MATLAB
297
10
function im = awsimread (impath) % This function is aws equivalent of imread. reads an image using datastore % locally or from the cloud. if awsIsAWSPath(impath) awsSetCredentials(); % Read credentials are required end ds = fileDatastore(impath,'ReadFcn',@imread); im = ds.read();
fd7a001ea4f55c48b27d14449ee318b9c3a102b28933de0d0fd163815bca44e7
MATLAB
297
10
function C=correlation_matrix(n) nen=numel(n); for i=1:nen for j=i+1:nen valid_times=intersect(n(i).coords(:,4),n(j).coords(:,4)); crrltn=corrcoef(n(i).coords(valid_times,5),n(j).coords(valid_times,5)); C(i,j)=crrltn(2); C(j,i)=crrltn(2); end end
581bf2f4062714817f8d59866bd0a24d3d42b2feeffebbed4fced94cd1ba9281
MATLAB
298
13
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function y = exptable(x) if ((x> -25) && (x<25)) y = exp(x); else y = 0; end end
9eaa78eeed55b7ba5e02ee1260e52e72c78cf5214bb76c18f07d037adfae666e
MATLAB
298
11
% loading stack load('.\..\wholestack.mat'); % loading tracking results load('.\..\output\neurons_reconstructed_max_2.mat'); % specifying output folder outputpath='.\..\output\'; % running manual correction GUI remove_and_add_neurons(wholestack,neurons_reconstructed_max_2,outputpath);
1c82a74e46337ba2cf8ae243a6398088b14e23033196dd4e32720bf5b16877f3
MATLAB
301
3
function [vxOut, vyOut] = RotateQuiver(vx, vy, thetaInDegrees, thetaInRadians) vxOut = imrotate(vx, thetaInDegrees)*cos(thetaInRadians) - imrotate(-vy, thetaInDegrees)*sin(thetaInRadians); vyOut = -(imrotate(vx, thetaInDegrees)*sin(thetaInRadians) + imrotate(-vy, thetaInDegrees)*cos(thetaInRadians));
792aa7d6b4bcf00a753886c220fce4c0fdcd705bba720b1a83aeb28acc6eefe3
MATLAB
301
12
% H = coarse_grain(data, times, bincenters) % builds an histogram of the data with centers specified by bincenters % % INPUTS: % data: a vector with the data % times: a vector with the times relative to the data % bincenters: a vector of the bincenters % % OUTPUTS: % H: the histogram % batta 2000
eeb7b40ac9483aad0256dcbbded52b9505500058a412abe3e3546f2e0e9a67ee
MATLAB
301
20
function binOut=de2bi2(inp) % de2bi only for 2 bin values binOut=[]; for i=1:size(inp,1) ix=inp(i); if ix==0 bx=[0 0]; elseif ix==1 bx=[0 1]; elseif ix==2 bx=[1 0]; elseif ix==3 bx=[1 1]; end binOut=[binOut;bx]; end end
268c710853d1a10742feea71eee141524015f97d9085aabdaa52fa29576ba03e
MATLAB
302
13
function [x] = demedian(x, dim) % Helper function to subtract the median across dimension dim. if nargin<2, dim = find(size(x)>1, 1, 'first'); end pvec = [dim setdiff(1:ndims(x), dim)]; x = permute(x, pvec); siz = size(x); mx = nanmedian(x, 1); x = x - mx(ones(siz(1),1),:,:,:,:,:);
311449b9eacec51a216d02de62a387d9bfde4d955a88dfee37ea170eecaf0f23
MATLAB
302
12
function combine_all_clusters_211026(folder_address) cd(folder_address) times_dir=dir('times_*.mat'); times_name=string({times_dir.name}); for j=1:length(times_name) file=load(times_name(j)); file.cluster_class(file.cluster_class(:,1)~=0,1)=1; save(times_name(j),'-struct','file') end end
66e7ddf0fa80288cb213bc9b165b20cc3726851caa372fdefb81a84ab68248e7
MATLAB
302
10
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function pinf = p_inf(v) pinf = 1 / (1 + exptable(-(v+35)/10)); %pinf = 1 / (1 + exp(-(v+35)/10)); end
c18b32ecb807dc0f4e14eacfa54c370a8315dce1bf93dd0cde8f997d9d77db03
MATLAB
302
10
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function Mfunc = Mfunc(Vpre, Mpre, Dt) dMval = dM(Vpre, Mpre); Mfunc = Euler(dMval, Mpre, Dt); end
701db826552175915eafdd50d8ba4e27951297ca3a57d529b551666057eafa5f
MATLAB
303
14
function update_bar_colors(b, colors) % updates the colors of a bar plot % b : handle of the bar plot % colors : colors to use, has to match data size for ii = 1:length(b) b(ii).FaceColor = colors(ii, :); % b(ii).EdgeColor = "none"; % also change the width b(ii).BarWidth = 1.0; end
728c4edf976b8bc1cb02fa0cd4f941641ff7f74cd1cf7c42c3fdc1b19580ad3c
MATLAB
303
10
function SpiderPlotTracks(tracks) idxs = unique(tracks(:, 4)); for idx = 1:length(idxs) currIdx = idxs(idx); currTrack = tracks(tracks(:, 4) == currIdx, 1:3); plot(currTrack(:, 1) - currTrack(1, 1), currTrack(:, 2) - currTrack(1, 2)); hold on; end axis equal; axis([-50 50 -50 50]); drawnow;
96a009ad78e5d4088787b2f7af0298ce981577964fcb21cdedb2895f776ac7a2
MATLAB
303
16
function randomVec = randshuffle(origVec) %Randomly permute the n*m vector along the row. %Keeping the mean of each row unchanged % [n,m] = size(origVec); newVec = zeros(n,m); for i=1:n temp = origVec(i,:); idx = randperm(m); newVec(i,:) = temp(idx); end randomVec = newVec; end
1508fc20ad4510a9817fd8bf12ede726f3fd448c94e7e1086cb36fbbe50d0b2d
MATLAB
304
12
% function design = make_design_similarity(cfg) % % Function to create a design for a similarity analysis. The function calls % make_design_rsa (representational similarity analysis). % % See also MAKE_DESIGN_RSA function design = make_design_similarity(cfg) design = make_design_rsa(cfg);
38e494ad8154cb823e45a677b94044a021a8826540371c3baf68b2eb40f49fd0
MATLAB
305
8
function grad = solveWithLinSolveBackProp(xRaw, gradIn, rowI, colI, rowII, colII, v, Ival) N = size(xRaw,1); deltaX = deltaActivation(xRaw); DL = deltaX .* gradIn; Amod = sparse(rowII, colII, [-v .* deltaX(rowI); Ival], N, N); %grad = linsolve(full(Amod), DL); grad = Amod\DL; end
5682eddb8b85440ea5bed0a5280d6c6436ab14b5cee1fd2add3f1a7fda450155
MATLAB
306
10
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function Mfunc = MfuncV2(Vpre, Mpre, Dt) dMval = dMV2(Vpre, Mpre); Mfunc = Euler(dMval, Mpre, Dt); end
0d6f8cc25ff7040a5bff498d1ff1af5e0bd45bcbc0444874074c1829d45a4b95
MATLAB
307
9
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function hchan = hchan(v, hpre, Dt, VTraub) hchan = hpre + h_exp(v,Dt, VTraub) * (h_inf(v, VTraub) - hpre); end
26082ec501eb3eb666089844622c172f6ea1566ffeaaf11239c95d465c945802
MATLAB
307
20
function cout = lighten(cin, factor) % function cout = lighten(cin, factor) % Default 50% % Hannah Payne if ~exist('factor','var') factor = .5; end if ischar(cin) if strcmp(cin, 'none') cout = 'none'; return else cin = colorspec(cin); end end cout = (1-cin)*factor+cin;
26477154b08695e36b88309d193b5522b10430b6db2ae088f8eafa9c13a3a7bd
MATLAB
307
16
function p_silence = computeSilenceProb(eta_val, eps_val, J_i, h_vals) %% prob_s_fun = @(h, J1) 1./(1 + exp(eta_val*J1*h - eps_val)); % vectorize J_i = J_i(:); h_vals = h_vals(:)'; p_active = prob_s_fun(h_vals, J_i); p_silence = exp(sum(log(1 - p_active), 1)); end
87745d394c3e0de424b07b17548b36e13ea4379238a3f35cc538775e6b9ba17e
MATLAB
307
13
function y_out = interp1dec(x,y,x_out) % Alternative version of interp1q that might be slower, but does not % require the signal processing toolbox y_out = zeros(size(x_out)); y_out(x) = y; vals = diff(x); for i = 1:length(x)-1 y_out(x(i):(x(i+1))) = linspace(y(i),y(i+1),vals(i)+1); end
ac191e9f5a878817c33f57b66815342769ac183f72ce30f0f2b7becb00430e91
MATLAB
307
10
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function uchan = uchan(v, upre, Dt) du = (u_inf(v)- upre)/tau_u(v); uchan = Euler(du, upre, Dt); end
dc1d5760d735c8ecb9b70fa5035f32036f24c904e150fb19cca5737355288a91
MATLAB
308
19
function ans = isrow (v); % ans = isrow (v); %returns 1 if v is a row vector %returns 0 if v is a column vector %returns -1 if v is a matrix % % Ziad Saad July 20 97 if (size (v,1) ~= 1 & size (v,2) ~= 1), ans = -1; end; if (size (v,1) == 1), ans = 1; elseif (size (v,2) == 1), ans = 0; end; return;
e7d520c97b3fa934042442765837782e6b3f99cf72458fcb85fb79c91902b284
MATLAB
309
7
function [dataPath,resultsPath]=getPaths() % make sure the paths point to the data and where you want the results to be stored dataPath='/ssddata/zmiaa/mvs-net/binary-mvs-exp/testing_20210221_2/collected_points'; resultsPath='/ssddata/zmiaa/mvs-net/binary-mvs-exp/testing_20210221_2/collected_points_eval';
61981dda828ca1b7b3cd3cfeb78cb5db5b0f5bb5f27e07f51ae4ef50cced3afc
MATLAB
310
9
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function tauhNa = tauhNa(v) tauhNa = 0.004 + (0.006/( 1 + exp(500*(v+0.028)))) + (0.01/(cosh(300*(v+0.027)))); end
7961e89bfdc84610ba367f7cbb53d9728bad4ff75e99929d93a59c6364ef1511
MATLAB
311
9
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function pchan = pchan(Vprev, ppre, Dt, TauMax) pchan = ppre + ((p_inf(Vprev)-ppre) / tau_p(Vprev, TauMax))*Dt; end
deecc720062b3b16cd6b08468f5eef1300e2867201dfa9e32c487f4995cdaf6b
MATLAB
311
10
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function rchan = rchan(v, rpre, Dt) dr = ar(v)*(1-rpre) - (br(v)*rpre); rchan = Euler(dr, rpre, Dt); end
fb5de2a0524d314417243493debaf5dbc493f76f84fe6e4a09151a8b16847eb9
MATLAB
311
10
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function qchan = qchan(v, qpre, Dt) dq = aq(v)*(1-qpre) - (bq(v)*qpre); qchan = Euler(dq, qpre, Dt); end
0b0c2ff01102fac206610158bf9e1418114e8994738acb2ae67fb1d0c48da983
MATLAB
312
13
function y = generateOUProcess(tau, dt, T) % y = generateOUProcess(tau, dt, T) simulates a mean-zero OU process with % variance 1 and autocorrelation timescale tau. Simulation resolution is % dt. N = ceil(T/dt); y = zeros(N, 1); for i_t = 2:N y(i_t) = (1 - dt/tau)*y(i_t-1) + sqrt(2*dt/tau)*randn; end end
a54af7047882a5c4f4f3fbd51c1b75db4fe9b3896957bdfbf54d4e97aacf3974
MATLAB
312
17
function [dateNum, dateStr] = datestr2datenum(dateStr) dateNum = 0; c = str2cell(dateStr, ' '); if length(c)<2 return end dateStr = c{1}; timeStr = c{2}; dateStr(dateStr=='-')=''; timeStr(timeStr==':')=''; timeNum = str2num(timeStr); dateNum = str2num(dateStr) + timeNum/1e6; dateStr = [c{1}, ' ', c{2}];
aa306a0a79ba4479987c6d78e872bcf4b5751024bac887812c267010343c9074
MATLAB
313
11
function opt_vect = foptions() % FOPTIONS Sets default parameters for optimisation routines % For compatibility with MATLAB's foptions() % % Copyright (c) Dharmesh Maniyar, Ian T. Nabney (2004) opt_vect = zeros(1, 18); opt_vect(2:3) = 1e-4; opt_vect(4) = 1e-6; opt_vect(16) = 1e-8; opt_vect(17) = 0.1;
598d00ee132e1a7709e7cb4b1bffd0d99abe2b09041be48c296bd3dafecb5661
MATLAB
314
17
function ac = TCcrosscorr(h1,h2) if rem(h1,2) == 1 % if odd number of bins then make even h1 = h1(1:end-1); end if rem(h2,2) == 1 h2 = h2(1:end-1); end nBins = length(h1); ac = nan(nBins,1); for nR = 0:nBins-1 hs = circshift(h2,nR); ac(nR+1) = corr(h1,hs,'Type','Pearson'); end
2e6f2b7d16aebd163defc0c375f711a9a8785b98af741c7a78c5cdf654cb7353
MATLAB
315
16
function s = getSlice(ind_k, mask) [N_row, N_col, N_slice] = size(mask); slice_dim = zeros(N_slice, 1); for k = 1: N_slice slice_dim(k) = length(find(mask(:,:,1:k))); end s = zeros(size(ind_k)); for k = 1: length(ind_k) s(k) = find(slice_dim>=ind_k(k), 1, 'first'); end s = reshape(s, length(s), 1); end
08bd53443e20a23e32a09ea372f81c80e214ca72df6fe64f0a45d7b8970f37fe
MATLAB
316
15
s = size(Lm,2); if s>1 temp_mcl = cat(3,Lm{:}); temp_mcl = squeeze(temp_mcl(:,1,:)); temp_Lcov = cat(4,Lcov{:,:,:}); mean_mcl = mean(temp_mcl,2); nu_mcl = s./( sum(squeeze(temp_Lcov(1,1,:,:)),2) ... + sum(temp_mcl.^2,2) ... - 2*mean_mcl.*sum(temp_mcl,2) ... + s*mean_mcl.^2 ); end
1d4508aafd52cf749290699530de95be5089c5036d703000e49cc5fe29ff3204
MATLAB
316
12
% function design = make_design_similarity_cv(cfg) % % Function to create a design for a similarity analysis. The function calls % make_design_rsa (representational similarity analysis). % % See also MAKE_DESIGN_RSA_CV function design = make_design_similarity_cv(cfg) design = make_design_rsa_cv(cfg);
38fd425f8a56ac87ca51d25e3261a702f51da54d050c2b552cf61d4aa6817244
MATLAB
316
16
% [Clu, nClusters] = LoadClu(FileName) % % A simple matlab function to load a .clu file function [Clu, nClusters] = LoadClu(FileName); Fp = fopen(FileName, 'r'); if Fp==-1 error(['Could not open file ' FileName]); end nClusters = fscanf(Fp, '%d', 1); Clu = fscanf(Fp, '%d'); nClusters = max(Clu); fclose(Fp);
4767047fda98ecc64cf80be0155d9fc90ad8b9e4145f92cb772c512675895fcb
MATLAB
316
15
function showStdErr = GetShowStdErrEnabled(handles) showStdErr = []; if nargin==0 return end if isempty(handles) return end if strcmp(get(handles.menuItemViewHRFStdErr, 'checked'), 'on') showStdErr = true; elseif strcmp(get(handles.menuItemViewHRFStdErr, 'checked'), 'off') showStdErr = false; end
85a522d95a8e18b128930fac78b93c52d9489db7d11edd603140d7c09efb048b
MATLAB
316
11
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function Pfunc = Pfunc(ICa, Pprev, Dt) B = 10; dP = ICa - (B * Pprev); Pfunc = Pprev + dP * Dt; end
8b5a7cc00bee5e29d97b2632c39ca886b955e5f44287ed53e54bb8da1c7587d7
MATLAB
316
10
function estimateVolumeStatisticsAdvance(subjectPath) % This function advances estimateDepthOfPenetration. Writen for LG. % Written at July 18, 2020. if ~exist('subjectPath','var') subjectPath = s3SubjectPath('04','LG'); end OCTVolumesFolder_ = [subjectPath '\OCTVolumes\']; estimateDepthOfPenetration
24c8e516d275ed956d2d9220233440e74ee3409c4303ab3ae04bf7ce42335a29
MATLAB
318
14
M = gifti(fullfile(spm('dir'), 'canonical', 'cortex_8196.surf.gii')); ir = find(M.vertices(:,1)<0); M.vertices(ir,:) = []; A = spm_mesh_adjacency(M.vertices) ii=[]; for i= 1:size(M.faces,1) if any(intersect(M.faces(i,:),ir)) ii = [ii i]; end end M.faces(ii,:) = []; figure;spm_mesh_render('Disp', A);
b44073bc015093436fe757a64f10a31344dc59b14e4a92e0bb61b4ffa314553c
MATLAB
319
12
function awsRmFile(myFile) %This function will remove file if it exists, in AWS or Windows if ~awsIsAWSPath(myFile) if exist(myFile,'file') delete(myFile); end else awsSetCredentials(1); myFile = awsModifyPathForCompetability(myFile,true); awsCmd(['aws s3 rm "' myFile '"']); end
78bf147897250c12905d14fa291de249f3ac6cc089c73b74c3030f2dbaa5c7f4
MATLAB
320
15
function box_out = threeclass_probability_Matrix_Initialize(box_in) disp('Box settings are:') for i=1:size(box_in.settings,2) fprintf('\t%s : %s\n',box_in.settings(i).name, num2str(box_in.settings(i).value)); end box_in.user_data.is_headerset = false; box_out = box_in; end
14256ad5eae393350791e6082b641b6dcd4592ddb2c7d26b26882bdf37b0e9a8
MATLAB
321
11
function ms = msSegmentCentroids(ms) %MSSEGMENTCENTROIDS Summary of this function goes here % Detailed explanation goes here ms.segCentroid = []; for segNum=1:ms.numSegments bwProps = regionprops(ms.segments(:,:,segNum),'Centroid'); ms.segCentroid(segNum,:) = bwProps.Centroid; end end ...
ffbb3b5fd94dd33bacc338504ed6bdbb5ee2c8bf4ac4016838a0464d482807ac
MATLAB
321
23
function O = time_units(inp) if isa(inp, 'units') % copy constructor O = inp; return end if ~isa(inp, 'char') error('argument must be string'); end l = get_lookup; if ~has_key(l, inp) error('unrecognized unit'); end l.tag = inp l = class(l, 'time_units'); ...
1366638f7818ac38835c4b1a4573617aafbf2afc5c7bdf3db9ac481ce2f786d9
MATLAB
322
12
function ang = meanAngle(inputangles) inputangles = inputangles(:); inputangles = inputangles(~isnan(inputangles)); x = mean(cos(inputangles*pi/180)); y = mean(sin(inputangles*pi/180)); % keyboard; if abs(x) < 1e-6 ang = 90; else ang = atan2(y, x)*180/pi; end e...
431efe74eb0d59f3057714a750b75bbe86a4de08113cbb5a7e7f1680362e0834
MATLAB
322
15
function [y] = cellvecadd(x, v) % [Y]= CELLVECADD(X, V) - add vector to all rows or columns of each matrix % in cell-array X nx = size(x); if ~iscell(x) || length(nx)>2 || all(nx>1) error('incorrect input for cellvecadd'); end if ~iscell(v) v = repmat({v}, nx); end y = cellfun(@plus, x, v, 'UniformOutput', 0)...
917deae7902974dd8f07cc3d93dbd498b001e9d55afe22ca509f318c405a32fd
MATLAB
322
10
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function Afunc = Afunc(Vpresyn, Aprev, Dt) dA = ( A_inf(Vpresyn) - Aprev ) / 0.2; Afunc = Euler(dA, Aprev, Dt); en...
92a12524c6396fb756a4d692c771ab178fa34e61a5f94130ff23aa679baf82e4
MATLAB
322
10
function order = get_homology_MMP(raw_ROI_label,homology_ROI_label) %% find homology index order =zeros(max(unique(homology_ROI_label)),1); for i = 1:length(raw_ROI_label) for j=1:max(unique(homology_ROI_label)) ind = find(homology_ROI_label ==j); order(j) = raw_ROI_label(ind); end end...
68e1e8cfc9bc8f7771b4701579ce5d8de43b9c86f6f871a6878a712a86cc128d
MATLAB
323
14
function [p]=bernoull(x,eta); % [p] = bernoull(x,eta) % % Computes Bernoulli distribution of x for "natural parameter" eta. % The mean m of a Bernoulli distributions relates to eta as, % m = exp(eta)/(1+exp(eta)); e = exp(eta); p = ones(size(e)); indx = find(~isinf(e)); p(indx) = exp(eta(indx).*x - log(1+e(indx))...
7d636a2943cad6f945f8a9481320308077ff40aab205c94f5b459f400ea3751f
MATLAB
323
10
% Called by minimization functions to update weights function K_out = updateKp(K_in, B, I, S, p_new, mask_tune) Kb_eye_pc_new = K_in.Kb_eye_pc; Kb_eye_pc_new(mask_tune) = p_new; Kb_eye = Kb_eye_pc_new(1:length(K_in.Kb_eye)); Kb_pc = Kb_eye_pc_new(length(K_in.Kb_eye)+1:end); K_out = updateK(B, I, S, Kb_eye, Kb_pc); e...
1acc3c158814bc9af172bc4e39ad851dfe3182184b1508a23233df41831640ac
MATLAB
324
16
function [mu] = winmean(x, percent, dim) %Compute the %percent Winsorized mean across dimension dim. %Implementation according to Wilcox; Robust Estimation %and Hypothesis Testing if nargin<3, dim = find(size(x)>1, 1, 'first'); end if nargin<2, percent = 0.2; end x = winsorize(x, percent, dim); mu = mean(x, di...
e4783b687f6a596107297563b57be4bd651c9652c1e6fd5de6738c082e511f07
MATLAB
324
21
% lin_expand linear expansion without any filtering % % y = lin_expand( x, f ) % % see also: fft_upsample, interp1, linint % 03-jan-13 ES function y = lin_expand( x, f ) f = round( f( 1 ) ); sx = size( x ); sy = sx; sy( 1 ) = sy( 1 ) * f; x = x( : ); y = repmat( x, [ 1 f ] )'; y = reshape( y, sy ); return %...
f369f4f67e8fc83dda8e55efbb3c52d80ecd2efce24b5c2a30219ee88a015fae
MATLAB
324
13
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function v = vtrap(x,y) if (abs(x/y) < (1*10^-6)) v = y*(1- x/(y*2)); else v = x/(exp_t(x/y)-1); end ...
df223cc79efc32975b5f7f052229993ef2879cd18d6d2eb59aa8510ab5b80a42
MATLAB
326
12
function stat = intergroupVar(smpl,match) groups = unique(match,'rows'); for i=1:length(groups) if size(match,2)==1 ssw(i) = mean(var(smpl(match==groups(i),:))); else ind = find(sum(match==groups(i,:),2) == size(match,2)); ssw(i) = mean(var(smpl(ind,:))); end stat = mean(ssw); ...
611bdd720efe167186bdddd7114a49c371ef0adb8c89ae782fe417bb4708133e
MATLAB
327
14
% loading stack load('wholestack.mat'); % loading tracking results load('neurons_reconstructed_max_2.mat'); % specifying output folder outputpath='.\output\'; % specifying voxel size voxel_size=[0.267 0.267 2]; % running manual correction GUI parameter_selection_and_tracking(wholestack,outputpath,voxel...
8ab6892519205321b23ce6a3d3c25abb8167c579d1f537920b0e8a9c4410a944
MATLAB
327
13
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function [aq] = aq(v) if v == -27 aq = 0.2090; else aq = 0.055 * (-27-v) / ((exp((-27-v)/3.8))- 1); e...