sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
41ae2d1d5e000b5f224abf472a534421e004e8430e0ff364164646ce368d4084 | MATLAB | 252 | 10 | function X = wrapangle(Y, bound)
% X = WRAP(Y)
% Maps Y values onto circular space (-PI <= X < PI).
% X = WRAP(Y, BOUND) specifies alternative bounds (default is PI).
%
% --> www.paulbays.com
if nargin<2, bound = 180; end
X = mod(Y, bound*2);
|
7b8a825cb6bdf35cff0d6548f07845fbbdd999019df33e0572baf86efc9317fc | MATLAB | 252 | 8 | function isRelative = isRelativePath(pathStr)
% Check if the path is absolute
if ispc % Windows
isRelative = isempty(regexp(pathStr, '^[A-Za-z]:\\', 'once'));
else % Unix/Mac
isRelative = pathStr(1) ~= '/';
end
end
|
a60d722199409bbc80b67a612575094036731712e27b921288bc09b45e5b09d7 | MATLAB | 252 | 13 | function [states] = tapas_mcmc_init_states(data, model, inference)
%% Initilizes the cell containing the states.
%
% aponteeduardo@gmail.com
% copyright (C) 2016
%
nf = numel(inference.sampling_methods);
states = cell(nf * inference.niter, 1);
end
|
289ba11eb9e2b26cc4ffd3d06099f120c034a07bc35c5741fd77bd370cfae55f | MATLAB | 253 | 15 | function grid_nirs_short(namei)
try
load(..) % Load NIRS
frex = logspace(log10(0.01),log10(5),50);
conv_res = morlet_convolution(nirs,100,frex,8);
save(sprintf('....mat',namei),'conv_res',"-v7.3")
catch
disp('Error')
end
end
|
89be622b61ebbcc117e2c7b7993c3cceec211cc9f99cb953b33608ae531589e2 | MATLAB | 253 | 11 | %{
trk.ROI (manual) # table that stores the correct ROI of the Eye in the video
-> rf.Eye
x_roi : int # x coordinate of roi
y_roi : int # y coordinate of roi
---
%}
classdef ROI < dj.Relvar
end |
a9e4272dac31e43a534a35a6f4566f4e7ac4b37e8084428e6aa01c1b48a2a843 | MATLAB | 253 | 8 | function trace=getPointProjection(movie)
% perform point projection of a movie and return the time trace
% trace=pointProjection(movie)
dim=size(movie);
temp=reshape(movie,dim(1)*dim(2),dim(3));
trace=mean(temp,1);
trace=trace'; % to be a row vector
end |
3f6aa8dc16e359992d12bce6862558fe37b6bb80491ddbbdb2dfebcc2322142c | MATLAB | 254 | 10 | %{
# single filters to reject frames
filter_id : tinyint # id of the filter
---
filter_name : char(50) # descriptive name of the filter
%}
classdef FrameFilter < dj.Lookup
end |
74b03ce385ba7ab7474a9aee543807cb62c6513e429c3e9f2032f4c74a948a25 | MATLAB | 254 | 10 | function obj = elbo_latent(obj)
N = numel(obj.data);
obj.lbZ = trace(obj.A * (obj.ZZ/N + obj.iAz)) ...
+ brca.utils.logdetPD(obj.Az) ...
- obj.logA ...
- obj.M;
obj.lbZ = - 0.5 * N * obj.lbZ;
end
|
d5835aedb7da5cd57b8a2b0d5a15ca536560249b2826538dc21061b6ad801f87 | MATLAB | 254 | 10 | function theta = getHyperplaneAngle(A,B)
%theta = getHyperplaneAngle(A,B)
%each column vector is one vector defining the plane (i.e., 1 PC)
% Compute the projection
B = B - A*(A'*B);
% Make sure its magnitude is less than 1.
theta = asin(norm(B));
end
|
dece43e6a1b5365afab766e52ecf59331afd10ddf75efc83184e37e9e73905bc | MATLAB | 254 | 17 | %{
# grouping table for cell selections
-> preprocess.ExtractRaw
%}
classdef MaskClassification < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
%self.insert(key)
end
end
end |
6e9c176f3f5a4a1e07f5d7b9d04ea91d43a2d6d47911a9f36f651ba8ea933d9b | MATLAB | 255 | 10 | %{
experiment.ScanBehaviorFile (manual) # file with info about synchronization, wheel, timestamping
-> experiment.Scan
---
filename : varchar(50) # filename of the h5 file
%}
classdef ScanBehaviorFile < dj.Relvar
end |
d4902562d9664b6b8114a2cd80c2eb8a9e0971092e38997dd053146ae1a0e481 | MATLAB | 255 | 7 | function [regressed_tc, regressed_fc] = regress_tc_non_zscored(network_signals, regressor_signals)
X = appendOnes(regressor_signals);
B = pinv(X)*network_signals;
yhat_tc = X*B;
regressed_tc = network_signals - yhat_tc;
regressed_fc = corr(regressed_tc); |
25e196be79ec3e9fee0f447f83e985f14ec36b941da358e4d6742c5b43113d95 | MATLAB | 258 | 10 | function troughs = FindLocalMinima(signal)
%FindLocalMinima - find local min
if isdmatrix(signal,'@2'),
iTroughs = FindLocalMinima(signal(:,2));
troughs = signal(iTroughs,1);
return
end
d = [nan;diff(signal(:))>0];
troughs = strfind(d',[0 1])';
|
420c8ca995a57edc919ad958bda2e256c8b67fa4faf10bd76e2c44396a8a2250 | MATLAB | 258 | 14 | %{
pre.Channel (lookup) # two-photon channels
channel: tinyint # channel number 1=green, 2=red'
-----
%}
classdef Channel < dj.Relvar
methods
function fill(self)
self.inserti({1})
self.inserti({2})
end
end
end |
92f43223a8d79649cd8f4cc2a1e6f537a19e7b4f6e4c13fd3c809a775f53177c | MATLAB | 258 | 7 | function version()
fprintf(['This is version 1.2.0 of the McsHDF5 Matlab toolbox. (26/02/2018)\n'...
'Newer versions will be available at \n\n'...
'\thttp://www.multichannelsystems.com/software/multi-channel-datamanager \n']);
end |
1b729c63982364338a59a2a3f0fa01ce1b8d8fd602e0fc1875166607395e5551 | MATLAB | 259 | 10 | %{
# stimulus protocol run during scan
-> experiment.Scan
---
protocol : varchar(255) # name of the protocol
scan_ts=CURRENT_TIMESTAMP : timestamp # don't edit
%}
classdef ScanProtocol < dj.Manual
end |
2ca5f482d8f9e1bd89fd8281ce5c6834f33c2071780b90d119fe2e9be67bd02e | MATLAB | 259 | 17 | %{
# different quality metrics for a scan (before corrections)
-> reso.ScanInfo
%}
classdef Quality < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.insert(key)
end
end
end |
47393e7069520fad3c7bf9967d0824e6d29b4aa11d827c22e883444f5576de9d | MATLAB | 259 | 17 | %{
# different quality metrics for a scan (before corrections)
-> meso.ScanInfo
%}
classdef Quality < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.insert(key)
end
end
end |
9ed52c7a254f492aaebdcdb86e2c3b508c8daff8da0bc5d49da02d3391336553 | MATLAB | 259 | 5 | function r = invpearson(p,n)
% from p-value to Pearson's linear correlation value . just return positive
% corr value . r = [r,-r]; formula deduced by t-distribution: t = rho.*sqrt((n-2)./(1-rho.^2)).
t = tinv ( 1-p/2, n-2) ;
r = sqrt(t^2/(n-2 + t^2)) ;
|
c4902af249128de2573143a6d977a363eba1aad8f801e9e9d05b892ed1a64109 | MATLAB | 259 | 16 |
function [V, spikes] = spiking_neuron(input, threshold)
tau = 10;
V = 0;
spikes = zeros(length(input),1);
for t = 1:length(input)
V = V + (-V + input(t))/tau;
if V >= threshold
spikes(t) = 1;
V = 0.5*(V-threshold);
end
end
end
|
0fe799d9818bc02b86fb0f9aaf74b18eb50a620a4e5f024bb1264e7edca8c003 | MATLAB | 260 | 3 | function res = has_function_symbol(x)
% internal: a function_handle from which we can obtain a function symbol: every function handle except for non-symbolic lambdas.
res = isa(x,'function_handle') && (isempty(strmatch('@',char(x))) || is_symbolic_lambda(x));
|
476fc634c0e9397d93132992b5cc58bbd896b221806a42a143aa70fe7f36a66b | MATLAB | 260 | 11 | % Set Program Path
function set_dir
%root_dir = getenv('MFILE');
%prog_dir = [root_dir '/VBtool/prediction'];
prog_dir = pwd;
addpath([prog_dir]);
addpath([prog_dir '/test']);
addpath([prog_dir '/basic_func']);
addpath([prog_dir '/../mex_prog']);
|
ffbc1e85201b0f2893f253892eccb88c2e5cf0c66b9b5c467a129e5682b686cc | MATLAB | 260 | 7 | function m = termsnotcontained(t)
%TERMSNOTCONTAINED Creates a logical matrix indicating term containment
% m(i,j)==1 iff t(i) is not contained by t(j)
% set diagonals to 1 because we want proper containment
m = (t*~t') > 0;
m(1:(size(t,1)+1):end) = 1;
|
13a95b4ca5a3d5e06af73f37d890a6b23890db54f894bec5d3b5b63cd221e631 | MATLAB | 261 | 11 | function [dep_vars, start, lower, upper ] = selectVars( vary, dep_vars, start, lower, upper )
% comments here
% last change: 2014/04/09 by PS
dep_vars = dep_vars(vary==1);
start = start(vary==1);
lower = lower(vary==1);
upper = upper(vary==1);
end
|
2e8d46e320138f60a15565482603ba9bb888c1010c8484c4c215cb4956fbf1f5 | MATLAB | 261 | 15 | clc
clear all
load('Tensormap_TM05.mat')
n=4;
theta=THETA{n};
angles=theta.*180/pi;
angles(angles>180)=angles(angles>180)-180;
puntas=PUNTAS{n};
mag=sqrt(puntas(:,1).^2 + puntas(:,2).^2);
mag=mag.*0.06;
angulo_medio=angulo_medio_axial(angles); |
73a24658cfc92f921f798b3869b3a9126873ced11c463a69d02de34d8ac6c938 | MATLAB | 261 | 14 | %{
aodpre.Channel (lookup) # two-photon channels
channel: tinyint # channel number 1=green, 2=red'
-----
%}
classdef Channel < dj.Relvar
methods
function fill(self)
self.inserti({1})
self.inserti({2})
end
end
end |
06da61539facec766ae4435d802b142f914ab4675f0230c5cd022938eb68fb04 | MATLAB | 262 | 11 | function [Result] = iFeta(eta,d1,d2);
%Implemented by Christian Beckmann
res = d1*(1-Feta(eta,d1/d2));
Result = zeros(1,d1);
for k= 1 : d1;
%Result(k) = eta(max(find(res>=k)));
Result(k) = eta(find(res>=k,1,'last'));
end;
|
07cca2a71ca58483544bcd090a4f1d3c212b7b14b1ed42bb07853e6bc9288372 | MATLAB | 262 | 10 | function Q = iqr(X,d)
% calculates the inter-quartile range of X along the dimension d
% (c) Jiri, May17
if size(X,d) == 1
warning(['Computing inter-quartile range along a singleton dimension d = ' num2str(d)]);
end
Q = prctile(X,75,d) - prctile(X,25,d);
|
2c4bdc1cf7be9606ae8854706c27141d7f392b86f638113ac64c9e5c602ead69 | MATLAB | 262 | 11 | function [Chan] = Chan_cluster2(U,N_clust,criteria)
U = U(:,:,1);
Chan = cell(N_clust,1);
for i =1:N_clust
U(:,i) = U(:,i)/max(U(:,i));
id = find(U(:,i)>=criteria);
[~,chan_order] = sort(U(id,i),'descend');
Chan{i} = id(chan_order);
end
|
3e9bbcddde0d981e103e31d73aa396e21e7626812f6c551af540cadedf1e26e8 | MATLAB | 262 | 10 | function pluginpath = activate_matconvnet()
% get path information
pluginpath = fileparts(which('pop_iclabel'));
% activate matconvnet
if ~exist(['vl_nnconv.', mexext()], 'file')
addpath(fullfile(pluginpath, 'matconvnet', 'matlab'));
vl_setupnn();
end
|
3edebd478b48f03930402fa0f7781049140c73ea3087145e4a19425bd680d8b1 | MATLAB | 262 | 18 | %{
# oracle for repeated videos
-> stimulus.Sync
-> `pipeline_fuse`.`__activity`
%}
classdef MonetOracle < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
self.insert(key)
end
end
end |
64216c827a0600253e56d9a582ccfd3e558beda5b032c18903e4946fee2f00cf | MATLAB | 262 | 18 | %{
# oracle for repeated videos
-> stimulus.Sync
-> `pipeline_fuse`.`__activity`
%}
classdef MovieOracle < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
self.insert(key)
end
end
end |
aafc38c0ebc3c2dbc9b18399d7dcff48f6171c7a5f0b20c4b1bac5a617883e27 | MATLAB | 262 | 9 | % Generate some numbers to test if STTC is running
spike_times_1 = [1, 5, 3];
spike_times_2 = [1, 7, 8, 10];
N1v = length(spike_times_1);
N2v = length(spike_times_2);
dtv = 0.1;
Time = [1, 10];
tileCoef = sttc(N1v, N2v, dtv, Time, spike_times_1, spike_times_2); |
d4fd41811d8d890b84f853fafdc7a6f961d83fe56affdb93ba8028b9ca703403 | MATLAB | 262 | 10 | function X = wrap(Y, bound)
% X = WRAP(Y)
% Maps Y values onto circular space (-PI <= X < PI).
% X = WRAP(Y, BOUND) specifies alternative bounds (default is PI).
%
% --> www.paulbays.com
if nargin<2, bound = pi; end
X = mod(Y + bound, bound*2) - bound;
|
dcf634f812a8afd789105ae3517b26fe13372281d72cd22f3ff7b632675e36d5 | MATLAB | 262 | 6 | function cmat = generate_color_gradient(c1, c2, nlines)
% Generates color gradient from c1 to c2 (as RBG vectors) for nlines
cmat = [linspace(c1(1), c2(1), nlines)',...
linspace(c1(2), c2(2), nlines)',...
linspace(c1(3), c2(3), nlines)'];
end |
96da091327776f51a1c7a140a225c8be1d590630992e2df91928658633858ecf | MATLAB | 263 | 12 | function rndSeeds = generate_randomStream(randSeed, iter)
% generate_randomStream generates random stream for loop.
if randSeed ~= -1 % -1 refers to random shuffle.
set_seed(randSeed);
else
set_seed('shuffle');
end
rndSeeds = randi(1e+9, iter, 1);
end
|
9f7897e36437b753acc28cb5176f56953f45c55a07f13fb5b6985fd1dbea2f98 | MATLAB | 263 | 14 | function nStates = count_number_of_sequences(sequence)
sequenceLength=length(sequence);
nStates=0;
if sequence(1)==1
nStates=1;
end
for i=1:sequenceLength-1
if(sequence(i)==0 && sequence(i+1)==1)
nStates=nStates+1;
end
end
end
|
e213b822de330f53ce814fb6d942cbae9978055164233d86f1f4968574c165fb | MATLAB | 263 | 11 | %{
# versions for the meso pipeline
-> shared.PipelineVersion
---
description : varchar(256) # any notes on this version
date=CURRENT_TIMESTAMP : timestamp # automatic
%}
classdef Version < dj.Manual
end |
e41a7751b5415775978f3fa8449253f3acf6bb1a9215a313a01abc91c445ee7b | MATLAB | 263 | 10 | function time_series = getTimeSeriesBinaryMask(im, mask)
time_series = zeros(size(im, 3), 1);
for i = 1:size(im,3)
temp = im(:,:,i);
time_series(i) = mean(temp(mask>0.5));
end
mu = median(time_series);
time_series = 100.*(time_series - mu)./mu; |
fe1e80ac7b58616229e4ad305c629ccf71f03173abea135f1252aad10cbcb484 | MATLAB | 263 | 11 | %{
# versions for the reso pipeline
-> shared.PipelineVersion
---
description : varchar(256) # any notes on this version
date=CURRENT_TIMESTAMP : timestamp # automatic
%}
classdef Version < dj.Manual
end |
1027ba642142572651006928a8cafa1b6e02dfd6146014a3d13b3f7d00c752ef | MATLAB | 264 | 10 | %{
trk.FrameSelector (lookup) # single filters to reject frames
filter_id : tinyint # id of the filter
---
filter_name : char(50) # descriptive name of the filter
%}
classdef FrameSelector < dj.Relvar
end |
1e95ed14b2aef8aedda0ec97bcda7dd8e638a36db06d593a5864633d5c9a37b6 | MATLAB | 264 | 7 | function [nbBlocks, nbRepet, nbEventsBlock, maxTargBlock] = getInput(cfg)
nbRepet = cfg.design.nbRepetitions;
nbEventsBlock = cfg.design.nbEventsPerBlock;
maxTargBlock = cfg.target.maxNbPerBlock;
nbBlocks = length(cfg.design.names) * nbRepet;
end
|
f86989fb75bfa0f3bb391507a456af1a3a4022822e23625d8947ca95c660da39 | MATLAB | 264 | 11 | %{
# versions for the stack pipeline
-> shared.PipelineVersion
---
description : varchar(256) # any notes on this version
date=CURRENT_TIMESTAMP : timestamp # automatic
%}
classdef Version < dj.Lookup
end |
9adb8d33d07e3eab0f7fa145a76613b5c265a50f6ac2bba8a9fcf415412e2425 | MATLAB | 266 | 13 | function [tBreak,a,b,c,m,p]=essential_distMinAnglePair_discontinuityDistance(Q21)
a=Q21(1,1)+Q21(2,2);
b=Q21(1,2)-Q21(2,1);
c=Q21(3,3);
m=norm([a;b]);
p=sign(a)*acos(clip(b/m));
%tBreak=modAngle(3/2*pi-p);
tBreak=-0.5*pi-p;
function v=clip(v)
v=min(1,max(-1,v));
|
b408fff4af22edb738c7ece0780c01578b201f3277fcf2aac555ad8b03f1879b | MATLAB | 266 | 13 | function E = mfunc_Energy(h,J)
% Calculate energy
nodeNumber = size(h,1);
vectorList = mfunc_VectorList(nodeNumber);
numVec = size(vectorList,2);
E = -diag((0.5*J*vectorList)' * vectorList) ...
- sum(((h * ones(1,numVec)) .* vectorList)', 2);
|
10d138f73f8b26b7091203e89eb893ec4e948b55a78013303d94fca3f3fd6a89 | MATLAB | 267 | 15 | function [c3] = concatenate_structs(c1,c2)
c3 = c1;
fds = fields(c2);
if ~isempty(fields(c1))
sz1 = size(c1,2);
else
sz1 = 0;
end
for f = 1:numel(fds)
fd = fds{f};
for c = 1:size(c2,2)
c3(c+sz1).(fd) = c2(c).(fd);
end
end
end |
1387f9ef39fc0040eeade4ae33bc9ac718098fde07d23b64b2f5760726bc7a47 | MATLAB | 267 | 17 | %{
# fluorescence traces before spike extraction or filtering
-> reso.Segmentation
%}
classdef Fluorescence < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.insert(key)
end
end
end |
4d78bce861953fb95f1675a1f6db25b5824be6cd449bb748dfac708794d8faf2 | MATLAB | 267 | 10 | function [ts_spectra] = pwelch_ps(ts)
%pwelch spectrum estimation for a single timeseries
grot=ts';
blah=pwelch(grot,[],[],length(grot));
ts_spectra=[];
ts_spectra(:,1)=blah(1:end-1,:);
F_end=mean(ts_spectra(end-9:end,1));
ts_spectra(:,1)=ts_spectra(:,1)/F_end;
end
|
f0bd7e12502325993c3aed42bf274b7c5063dc95b226a6aa58da1eac0b7ba9f3 | MATLAB | 267 | 17 | %{
# fluorescence traces before spike extraction or filtering
-> meso.Segmentation
%}
classdef Fluorescence < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.insert(key)
end
end
end |
9b1dedd2614bc97e6ca534e15f4ccd21e0e91943e7ec9dc89bfbab18551104f0 | MATLAB | 269 | 13 | function [llh, nx] = tapas_ti_llh_state(y, x, u, theta, ptheta)
%% Generate state space and compute the likelihood.
%
% aponteeduardo@gmail.com
% copyright (C) 2016
%
nx = tapas_ti_gen_state(y, x, u, theta, ptheta);
llh = tapas_ti_llh(y, nx, u, theta, ptheta);
end
|
0bea6f66e3fbee6f9adb2fec4f5c745871584cdd30c072e5defc630061ac0b9f | MATLAB | 270 | 8 | function wsl_path = win2wsl(win_path)
% °Ñ \ »»³É /
wsl_path = strrep(win_path, '\', '/');
% ÌáÈ¡ÅÌ·û (C:, D:, ¡)
drive_letter = lower(wsl_path(1));
% È¥µô "X:/"
wsl_path = ['/mnt/' drive_letter wsl_path(3:end)];
end
|
1ed1678202dc10504f3db3256c64fa40449355a6a97f46ba497ba11dd0526116 | MATLAB | 270 | 6 | function tapas_BLT_runBuffer(params)
% tapas_BLT_runBuffer runs an initial fixation cross
Screen('DrawTexture', params.screen.window, params.text.imgiti, [], params.screen.fit, 0);
Screen('Flip', params.screen.window);
wait2_escapeOption(params.dur.introiti , params);
|
088ea558454ebdb6857f05e66f002a72f61765d595df7ca4a4794fa136dede55 | MATLAB | 271 | 12 | function [ output_args ] = largest_positive( input_args )
%LARGEST_POSITIVE( input_args )
%
%
% === Jan Moelter, The University of Queensland, 2017 ===================
%
[ ~ , iM ] = max( abs( input_args ) );
output_args = input_args / sign( input_args( iM ) );
end
|
5259a56893df89ec162bd58cf06814926f193cc5c466f8af57e0f5500057be29 | MATLAB | 271 | 15 | %{
#
-> eye.ManuallyTrackedContours
---
tracking_ts=CURRENT_TIMESTAMP: timestamp # automatic
%}
classdef FittedContour < dj.Computed
% Implemented in Python
methods(Access=protected)
function makeTuples(self, key)
end
end
end |
e4cd11b8b4d78d3e29f8181d4b5a743bd719a3621949ef9882a041d0c825bdec | MATLAB | 271 | 11 |
function durect(rect, edge_color, face_color, face_alpha)
% Rectangle annotation in data units.
x = rect(1);
y = rect(2);
w = rect(3);
h = rect(4);
patch([x x+w x+w x], [y y y+h y+h], face_color, EdgeColor=edge_color, FaceAlpha=face_alpha, LineWidth=1.5) |
5de728df292d678f8434b06e68671325279cb659621d18aefd41d2cb5e0ba832 | MATLAB | 272 | 18 | function TF=TransFun_EO(tf,LN)
for i=1:LN+1
switch tf(i)
case 1
TF{i}='purelin';
case 2
TF{i}='logsig';
case 3
TF{i}='tansig';
case 4
TF{i}='elliotsig';
end
end
|
97af712a3c5ee85ba41d5ae024270c8cb410d3c3c6bdd871c2c9bb9b094578fb | MATLAB | 272 | 12 | %{
vis.MovieStillCond (manual) # a still frame condition
-> vis.Condition
---
-> vis.MovieStill
pre_blank_period : float # (s)
duration : float # (s)
%}
classdef MovieStillCond < dj.Relvar
end |
ed4adcd022b1c2a2a3279a8787eba17fd1ca730c758eb252e6c90e604f32170e | MATLAB | 272 | 11 | M = spherefactory(5);
x = M.rand();
v = M.randvec(x);
h = logspace(-20, 1, 251);
g = zeros(size(h));
for k = 1 : numel(h)
g(k) = M.norm(x, M.log(x, M.exp(x, v, h(k))));
end
loglog(h, abs(g-h)./h);
xlabel('h');
title('Relative error: (norm(Log_x(Exp(x, h*v))) - h)/h'); |
3a2e633fbd3e4de0061e9847655406acb305353814272683a3200d99b9ee6daa | MATLAB | 275 | 20 | %{
#
-> reso.MaskClassification
-> reso.SegmentationMask
---
-> shared.MaskType
%}
classdef MaskClassificationType < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.insert(key)
end
end
end |
3ee0797e7ab825e3f36299731d52ea45be322f15b39f1ed3b02d85776c2411e9 | MATLAB | 275 | 14 | function [wght, w] = sero_srr_weight_f(TR, edg)
% function [wght, w] = sero_srr_weight_f(TR, edg)
if nargin < 2
w = max(sum(TR>0,2));
edg = 1 * w;
end
p = sero_srr_tr2position(TR);
mid = (max(p)+min(p))/2;
dfe = mid - abs(p-mid);
wght = dfe/edg;
wght(wght>1) = 1;
|
890a3827cae7fe3fc2d546b27e526dd572e997712d85200e4b942bb9d207c06c | MATLAB | 275 | 10 | function dat = gsmooth(dat,sd)
% smooth data (dat), where sd the standard deviation of the
% Gaussian funciton. The units depend on sample rate. I.e., if 1kHz, then the sd
% is in msec
edge = sd*10;
b=normpdf(-1*edge:edge,0,sd);
c = conv(dat,b);
dat = c((edge+1):end-edge); |
acd3a7da9f8e02418d24b64b1e0ffd55dab658ce48f903887c8bcc04f2710f03 | MATLAB | 275 | 20 | %{
#
-> meso.MaskClassification
-> meso.SegmentationMask
---
-> shared.MaskType
%}
classdef MaskClassificationType < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.insert(key)
end
end
end |
ae98df42d036db5d7857f32d605674cfd032f9631a910187009e8acaaf9a01a8 | MATLAB | 275 | 9 | % setup PsychToolbox
home_dir = getenv('HOME');
pt_path = fullfile(home_dir, 'toolbox/Psychtoolbox');
if exist(pt_path, 'dir') && ~any(regexp(path, [filesep 'Psychtoolbox']))
fprintf('Psychtoolbox is not installed. Please run "configPsychtoolbox"\n');
end
setPath;
setDJ;
|
53c63377bdfa27425523f912da99fc5bbaba73a8aa8fb1df6360761311d67e4c | MATLAB | 276 | 16 | function KL = kldiv(A,B,normalize,dim)
%KL = kldiv(A,B,normalize,dim)
if nargin < 4
dim = 2;
end
if nargin < 3
normalize = false;
end
%%
if normalize
A = bsxfun(@rdivide,A,sum(A,dim));
B = bsxfun(@rdivide,B,sum(B,dim));
end
KL = sum(A .* (log(A./B)),dim);
end |
77a302b3140b7b20ca78f156fcc29410e0b1864ae8fca9d0f403872fb2a331ce | MATLAB | 276 | 8 | function res = unassigned
% Special keyword that can be used in arg*() specifications.
% Used for the default values of arguments that do not show up in the function's workspace (or the GUI) unless explicitly assigned
%
% See also:
% arg_define
res = '__arg_unassigned__'; |
1d974b7882fe00108aa7ca8166660be4be629057376b975b3bea6ff9755f1588 | MATLAB | 277 | 16 | function newmap=colormap_interpol(map,fak);
% creates a finer colormap consisting of fak times more colors)
[n,ndum]=size(map);
newmap(1,:)=map(1,:);
m=1;
for i=2:n;
for k=1:fak
m=m+1;
newmap(m,:)=((fak-k)*map(i-1,:)+k*map(i,:))/fak;
end
end
return; |
2a9bb818ee22cb78551edfbc27e2e2afb1a026491c178122edacdb504302d83d | MATLAB | 277 | 7 | function isImage = isImageFile(extension)
% Define valid image extensions
validExtensions = {'.png', '.jpg', '.jpeg', '.bmp', '.tif', '.tiff', '.gif'};
% Check if the file has a valid image extension
isImage = any(strcmpi(extension, validExtensions));
end
|
4b269049aeb7a2e5e860dca40e3ed26ad078e071df2541f48a2b1f97a5932871 | MATLAB | 277 | 11 | function [im, info] = loadRegIm(imfn)
[filepath, fname, fext] = fileparts(imfn);
regfn = fullfile(filepath, ['reg_' fname fext]);
if exist(regfn, 'file')
[im, ~] = loadTifFast(regfn, 'standard');
else
[im, ~] = loadTifFast(imfn, 'scanimage');
end
info=imfinfo(imfn); |
c0fa508d8448f6065cf04363b47924f7fb1929806b2ffd52d85a207983a61716 | MATLAB | 277 | 19 | clear; close all; clc;
n = 500;
complex = true;
A = randn(n);
X0 = randn(n);
if complex
A = A + 1i*randn(n);
X0 = X0 + 1i*randn(n);
end
A = A+A';
C = A*X0+X0*A;
X1 = lyapunov_symmetric(A, C);
norm(A*X1+X1*A-C, 'fro') / norm(C, 'fro')
norm(X0, 'fro')
norm(X1, 'fro') |
c2c8a92f60e139a7731930b9a1c23bcb4542f2bdf7bc6d5166b673927615c3c4 | MATLAB | 277 | 16 | function y = ch2prdf(x,v)
if nargin < 2,
error('Requires two input arguments.');
end
[errorcode x v] = distchk(2,x,v);
if errorcode > 0
error('Requires non-scalar arguments to match in size.');
end
% Initialize Y to zero.
y=zeros(size(x));
y = gammpdf(x,v/2,2);
|
ecb0bffabcc04a550e744599a316dac96251609b76fe228cc79ffb2667776a28 | MATLAB | 277 | 14 | function clusternames = getclusternames(SU,varargin)
if isempty(varargin)
for i = 1:length(SU)
clusternames(i,1) = SU{1,i}.cluster_id;
end
else
goods = varargin{1};
for i = 1:length(varargin{1})
clusternames(i) = SU{goods(i)}.cluster_id;
end
end
end
|
f4ba4056cbccb39042ea26202a93d90e72cd6436c3f1c7a51ca42935962b141b | MATLAB | 277 | 10 | function coord=centerofmass(data);
data=abs(data);
dims=size(data);
for k=1:length(dims)
% datatemp=permute(data,[k ]);
dimsvect=ones([1, length(dims)]);
dimsvect(k)=dims(k);
temp=bsxfun(@times,(data),reshape(1:dims(k),dimsvect));
coord(k)=sum(temp(:))./sum(data(:));
end;
|
3e0c1911a2c9086c9a024b101997359979c078df44b549c44e13cc262c5f2f29 | MATLAB | 278 | 9 | function out = replace_part_token(inPath, fromTok, toTok)
[p,n,e] = fileparts(inPath);
if strcmpi(e, '.gz')
[p,n2,e2] = fileparts(fullfile(p,n));
n = n2; e = [e2 '.gz'];
end
n = strrep(n, fromTok, toTok);
out = fullfile(p, [n e]);
end |
82f726cb31b68de7902555f58216ca5c44f5973fb943ea7011d4ba76af09b9e2 | MATLAB | 278 | 12 | function BasinNumber = mfunc_GetBasinNumber(StateNumber, BasinGraph, LocalMinIndex)
% Get Basin Number
BasinNumber = zeros(length(StateNumber),1);
Nmin = length(LocalMinIndex);
tmp = BasinGraph(StateNumber, 3);
for i=1:Nmin
BasinNumber(tmp == LocalMinIndex(i)) = i;
end
|
d5d48612328d370b6a58e76eafc7595d138037a5712b0fd8a7b7591ff67f7856 | MATLAB | 278 | 18 | %{
# fields that have been processed in the current scan
-> meso.ScanDone
-> meso.Activity
%}
classdef ScanDonePartial < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.insert(key)
end
end
end |
f2c14de22173826dad449f1646ec8d19a10aff0e6d6bf9fe6423cfebd166cb54 | MATLAB | 278 | 18 | %{
# slices that have been processed in the current scan
-> reso.ScanDone
-> reso.Activity
%}
classdef ScanDonePartial < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.insert(key)
end
end
end |
7c815967482b11e6c6842699d7374df28fefb6bcded089c0b8670f8f7a0b6b8c | MATLAB | 279 | 6 | function varargout = arrow( varargin )
disp('The arrow function was removed from EEGLAB')
disp('because of lack of compatibility with Matlab 2019')
disp('An updated version of the function is available at')
disp('https://www.mathworks.com/matlabcentral/fileexchange/278-arrow')
|
330d0bb23dbc41f4ddbf01b186abbe1229075d68568dcbe3de591077ed519630 | MATLAB | 280 | 10 | function Calls = Automerge_Callback(Calls1,Calls2,AudioFile)
%% Merges two detection files into one
Calls=[Calls1; Calls2];
% Audio info
audio_info = audioinfo(AudioFile);
%% Merge overlapping boxes
Calls = merge_boxes(Calls.Box, Calls.Score, Calls.Type, audio_info, 1, 0, 0);
|
666d9e904fbc65c0a1a9e6fda977c80ddee82f36c1575a567515d8c28c96599e | MATLAB | 280 | 13 | function config_io
global cogent;
%create IO64 interface object
cogent.io.ioObj = io64();
%install the inpoutx64.dll driver
%status = 0 if installation successful
cogent.io.status = io64(cogent.io.ioObj);
if(cogent.io.status ~= 0)
disp('inp/outp installation failed!')
end
|
9962bf99824dc9078899ed6baad2147c47bd7a52e657645969f16391cd9bfa99 | MATLAB | 280 | 18 | function [model] = tapas_linear_prepare_model(data, model, inference)
%%
%
% aponteeduardo@gmail.com
% copyright (C) 2016
%
% Number of regressors
nc = numel(model.graph{2}.htheta.T);
nb = size(data.u{1}, 2);
% Shrink priors
y = zeros(nb, 1);
model.graph{4}.htheta = y;
end
|
a9867f15387b00350f48e10caf98400747b5d90c521ddda8af71287b503466e0 | MATLAB | 280 | 6 | function [ssx, y2] = dofit(y, Qd)
%DOFIT Do constrained least squares fit and reduce data for subsequent fits
% Fit y to design matrix in null space
y2 = Qd' * y; % rotate y into that space: predicted y value
ssx = norm(y2)^2; % sum of squares explained by fit
|
dfdb699328734c03806a8dea4acc41c8a8e14fcbf3de3c67a4b721e36e498156 | MATLAB | 280 | 8 | function [ff, pp, fi] = uiget1Dfile()
% open a gui for 1D file selection
% returns the same output as uigetfile
[ff, pp, fi] = uigetfile( {'*.1D;*.1D.dset' , ...
'AFNI 1D Files (*.1D, *.1D.dset)';},...
'Select 1D file' );
return
|
210998cc3382d5b723a34cd9c69a24d42ff424c5bf9959be8de5a47e8ee2c6d0 | MATLAB | 281 | 9 | function biosigpathlast()
% Add BIOSIG at the end of the path to avoid overloading Matlab functions
str2doublepath = fileparts( which('str2double') );
str2numpath = fileparts( which('str2num') );
if ~strcmp(str2doublepath,str2numpath)
addpath(str2numpath,'-begin');
end
|
af2d77f556890cb81e8027c6a4d5d15fc3deffa21e6f59a7e0a11425c8185f5e | MATLAB | 281 | 19 | function [PROSACCADE, ANTISACCADE] = tapas_action_codes()
%% Returns the codes for pro and antisaccades.
%
% Input
%
% Output
%
% aponteeduardo@gmail.com
% copyright (C) 2016
%
codes = c_action_codes();
PROSACCADE = codes(1);
ANTISACCADE = codes(2);
end % tapas_action_codes
|
d048b8f5a28a133d0d95087311668328f7d79699823d1cb9675010d6c4ed6a20 | MATLAB | 281 | 25 | function y = rescale(x,a,b)
% rescale - rescale data in [a,b]
%
% y = rescale(x,a,b);
%
% Copyright (c) 2004 Gabriel Peyr?
if nargin<2
a = 0;
end
if nargin<3
b = 1;
end
m = min(x(:));
M = max(x(:));
if M-m<eps
y = x;
else
y = (b-a) * (x-m)/(M-m) + a;
end
|
d6f62f4442c3584135049f32d619bb8169283c8fb3178757b41ad8e758db8b2b | MATLAB | 281 | 16 | n = 10;
m = 20;
k = 1000;
X = randn(n, m, k);
t = tic();
Xt1 = multitransp(X);
toc(t)
t = tic();
Xt2 = multitransp_ez(X);
toc(t)
fprintf('Relative difference: %g\n', norm(Xt1(:) - Xt2(:))/norm(Xt2(:)));
% mutlitransp is better here (it's doing the right thing, calling permute) |
186ffc6c0819491e769c14a5d9ac43aa65c535d055461c7d5ff8a019f1ab15dc | MATLAB | 282 | 14 | %Creado por Luisca Mayo09. Numera en forma ascendente una matriz de 1´s
%tomando cada columna como un elemento
function [RN]=RasNum(Rasterbin)
% Rasterbin 1 frame de resolución.
N=size(Rasterbin,2); %Número de picos
for i=1:N
RNa=Rasterbin(:,i);
RN(:,i)=RNa*i;
end;
|
0816ec6f44180d9cde90f3a62ba1294d8e97fb7483dee631c2d50274687de491 | MATLAB | 283 | 12 | % erase cluster around the center
function outmap = eraseCluster(map, center_x, center_y, radius)
outmap = map ;
[rows,cols] = size(map) ;
for ii=1:rows
for jj=1:cols
if (ii-center_y)^2 + (jj-center_x)^2 < radius^2
outmap(ii,jj) = 0 ;
end
end
end |
6d8d41a617b9148eff6573720b724aa18bac47f89a7098615184a28ef9ed907c | MATLAB | 283 | 11 | %{
trk.SVM (lookup) # table that stores the paths for the SVMs for each VideoGroup
-> trk.VideoGroup
version : int # version of the SVM
---
svm_path : varchar(200) # path to the SVM file
%}
classdef SVM < dj.Relvar
end |
72a13f63220a02cea5fc6bc556e4c10349236a2204129267436d16f9dac11820 | MATLAB | 283 | 8 | function obj = getSchema
persistent schemaObject
if isempty(schemaObject)
conn2 = dj.Connection('127.0.0.1', getenv('DJ_USER'), getenv('DJ_PASS'));
query(conn2, 'status');
schemaObject = dj.Schema(conn2, 'pipeline_behavior', 'pipeline_behavior');
end
obj = schemaObject;
|
78fdad87a0cc68148d49ccd0ebf2df5483f25f4393421f96ae0f8e37c93c32e7 | MATLAB | 283 | 18 | function grid_eeg_short(namei)
try
load(...) % load data.
frex = logspace(log10(0.01),log10(5),50);
conv_res = morlet_convolution(eeg,50,frex,8);
save(sprintf('...mat',namei),'conv_res',"-v7.3")
catch
disp('Error')
end
end
|
860c72cd5e767075212ca9505cae41aeff9e8f8c98c01686cad1c865c77bfacc | MATLAB | 283 | 11 | function reader = getStackReader(key)
[path, filename] = fetch1(experiment.Session*experiment.Stack & key, 'scan_path', 'filename');
fprintf('Loading from %s\n', path);
path = getLocalPath(fullfile(path, sprintf('%s_*.tif', filename)));
reader = ne7.scanimage.Reader5(path);
end |
f2647a2d9e2e8035af02f250b5868d4c2bf99b0690613cc09bcc6eac4163f2da | MATLAB | 283 | 11 | %{
vis.MovieStill (lookup) # cached still frames from the movie
-> vis.Movie
still_id : int # ids of still images from the movie
---
still_frame : longblob # uint8 grayscale movie
%}
classdef MovieStill < dj.Relvar
end |
ffb38e914e24f0577596a6ddcf3ce8b3eabef6eeb2430b3dc542a559e459b5c3 | MATLAB | 283 | 14 | % each script can be run independently, all will save data to ./results
%% Perform MLE fitting to find distributions for A, x0, n
MLEScript; %very slow
%% Perform Fitting to find parameters for each trial
invMLEFit;
%% Plot distributions in Figure S4D-G
plotInvDistributions;
|
743bc0d5f5c732b5d5933b9362f225ee8a9c582d9fbbba0df44e6b755d854374 | MATLAB | 285 | 9 | %% load mov
DaqRate = 10000; sz=get(0,'screensize');
Info=textscan(fopen('experimental_parameters.txt'),'%s');
nrow = str2num(Info{1,1}{6,1}); ncol = str2num(Info{1,1}{3,1});
binName='movReg.bin'; [mov nframes] = readBinMov(binName, ncol, nrow);
%
[ROI,Fclicky]=clicky_faster(mov); |
aa94e7d360615df17f067aa1d4b2af01682d2809cb1d78d697684a3c8b93d8ec | MATLAB | 285 | 10 | while true
parpopulate(aodpre.ExtractSpikes)
parpopulate(aod_monet.DriftTrialSet)
parpopulate(aod_monet.DriftResponseSet)
parpopulate(aod_monet.VonMises)
parpopulate(aod_monet.RF)
parpopulate(aod_monet.CleanRF)
parpopulate(aod_monet.Fit)
pause(1000)
end |
f5266386f897f32432e54f51d3cabf20363bae83f10f4b6ba13c68c95d3c17d0 | MATLAB | 285 | 8 | function a = angle_dist_nc(p2, p1)
%function to calculate the angle on the sphere going from from OP1 to OP2
%for a companion function, see RotateAboutAxis
%equivalent in SUMA code is macro : SUMA_ANGLE_DIST_NC
m_cr = cross(p1, p2);
a = atan2(sqrt(sum(m_cr.^2)),dot(p2, p1));
return;
|
c69aa0513113da5ae35a6fb20b0876be3f9890ebc8454aa9af16ee1d90683954 | MATLAB | 286 | 13 | function [Xsm] = causal_smooth(X,win)
%simple code to do smoothing using data from future only
Xsm = zeros(size(X));
ns = numel(X);
for j = 1:ns
if j < win
Xsm(j) = 1/j*sum(X(1:j), 'omitnan');
else
Xsm(j) = 1/win*sum(X(j-(win-1):j), 'omitnan');
end
end |
eef8010c4cce2685faa990ec041db2952d18fd795fc4888fe5696b58a32844b0 | MATLAB | 286 | 10 | function tensor = put_tensor(tensor_base, p_center, p, mode)
angle = atan((p_center(2)-p(2))/(p_center(1)-p(1)));
if mode==1
angle = angle + pi/2;
elseif mode==2
angle = 3*pi/2 - angle;
end
R = rotate2D(angle);
tensor = R' * tensor_base * R;
end
|
1a1edf131bfaf7d0e6b818db0667969131c145ebde9fe89346388d181f46faf1 | MATLAB | 287 | 11 | %% Standard script to save SEPIA header to the a variable structure for IOwrapper
%
% Kwok-shing Chan @ DCCN
% k.chan@donders.ru.nl
% Date created: 22 Jan 2021
% Date modified: 13 August 2021
%
%
headerAndExtraData = struct();
headerAndExtraData.sepia_header = sepia_header;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.