sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
21338b993f8faa32e7754093c94486df4792a713943c14f35358d1c8a42f9f3f
MATLAB
287
13
function [ XY_coords ] = centroids( CONTS ) %UNTITLED Summary of this function goes here % Detailed explanation goes here N=length(CONTS); %centros for j=1:N a{j}=mean(CONTS{j}); end XY_coords=cell2mat(a'); %abrir y salvar las coordenas en un archivo de texto normal
808644f69c332610ffb219d3a791c360163c899dbc54771b01bdd09be75236ca
MATLAB
287
14
function nii_save(nii,niifile,vartype) %author EML if nargin > 2 nii.hdr.dime.datatype = vartype; nii.hdr.dime.bitpix = vartype; end if isfield(nii, 'untouch') disp('Untouch option found'); save_untouch_nii(nii,niifile); else save_nii(nii,niifile); end
4d24d155142c44c88d9892f99e0e4dee4cf5f0617b9cded1253d67f2be683641
MATLAB
288
12
function matlab_version = icatb_get_matlab_version % Get matlab version matlab_version = version('-release'); [startInd, endInd] = regexpi(matlab_version, '\d+'); if ~isempty(startInd) matlab_version = matlab_version(startInd:endInd); end matlab_version = str2num(matlab_version);
7f08792c5e5acc5fe8f916624dc344ef45557de87865d04faac153642c05e2b0
MATLAB
288
10
%{ # list of speakers in various setups id : int # some number that identifies the speaker rig : char # setup name location : tinyint # 1 = Left, 2 = Right %} classdef Speakers < dj.Manual end
b610b33d29c36c6624ce6c8bd241df85cab5b5e3993dc98293ca425879eb3333
MATLAB
288
11
function reader = getGalvoReader(key) [path, filename] = fetch1(experiment.Session*experiment.Scan & key, ... 'scan_path', 'filename'); fprintf('Loading from %s\n', path); path = getLocalPath(fullfile(path, sprintf('%s*.tif', filename))); reader = ne7.scanimage.Reader5(path); end
fb5304c4b82600857bec0dce247bae333a49b1339615650184c3adaea178269b
MATLAB
288
19
%{ # -> tune.STAMap --- snr : float # RF contrast measurement %} classdef STAQual < dj.Computed methods(Access=protected) function makeTuples(self, key) %!!! compute missing fields for key here self.insert(key) end end end
6c8d2001a8bea5ae7ae5e2482cfd297ed54d1960d3bf9307e242106000c04baa
MATLAB
289
11
classdef nnsigmoid < nntest methods (Test) function basic(test) x = test.randn(5,5,1,1)/test.range ; y = vl_nnsigmoid(x) ; dzdy = test.randn(size(y)) ; dzdx = vl_nnsigmoid(x,dzdy) ; test.der(@(x) vl_nnsigmoid(x), x, dzdy, dzdx, 1e-3) ; end end end
8ae12e9573b94fd9ed6e0cbf6ab5889d72cf65fec1e78ebb0d2ef3b4b3bab781
MATLAB
291
10
%{ trk.VideoGroup (lookup) # table that groups videos into groups that can be tracked by the same SVM videogroup_id : tinyint # id of the video group --- group_name : char(20) # name of the group %} classdef VideoGroup < dj.Relvar end
df6cc31bc720f2e7baff00f3cd7eecdd633c7489f119c28601f05bd621bd4fbe
MATLAB
291
14
colors = wes_palettes('FantasticFox2'); close all figure set(gcf,'color','white') nbars = size(colors,1); hold on for i = 1:nbars bar(i,nbars+0.5,1,'FaceColor',colors(i,:),'EdgeColor',[1 1 1]*1); end set(gca,'xtick',[],'ytick',[]) xlim([0.5 nbars+0.5]) ylim([0.5 nbars+0.5]) axis square
fd634ec30ca33fc69ffeca2753c054982c603655196c6a4db67a7389048ae3ed
MATLAB
291
10
%{ # Inspected movie clips that are not that bad -> stimulus.MovieClip --- judge : enum('human','machine') # was it a man or a machine? notes : varchar(256) # a little explanation for the inclusion process %} classdef ClipInspected < dj.Manual end
3cd46bddd4c482d21169a813b391f9d0eec99ec69e44905abff2878586333dc1
MATLAB
292
10
function arrFeatures = returnFeatures(param_arr) measure_set = {'Mean','Median','StDev','Skewness','Avg_Signal'}; arrFeatures = zeros(1,5); arrFeatures(1) = mean(param_arr); arrFeatures(2) = median(param_arr); arrFeatures(3) = std(param_arr); arrFeatures(4) = skewness(param_arr);
84fda6f11669044f5a15ba3328c165469216903d2325808d059c164ddfbea12b
MATLAB
292
11
% Mex version to compute C*A*C' % Where C is the pairmatrix of K*(K-1)/2 x K size % This consitutes the main time sink in RSA-based computations, % for example for varianceLDC % INPUT: % A: KxK matrix: single or double % % OUTPUT: % B : K*(K-1)/2 x K matrix % % (c) Joern Diedrichsen
8bc5deb8d0a42beb7c8044136847bd90470bd0598f3bdb33e86390a2fbfc7c61
MATLAB
292
15
function [nptheta] = init_ptheta(ptheta, htheta, pars) % Precompute certain quantities nptheta = ptheta; if isfield(ptheta, 'prepare_ptheta') nptheta = ptheta.prepare_ptheta(ptheta, htheta, pars); end if ~isfield(ptheta, 'sm') nptheta.sm = tapas_ti_zeromat(nptheta.jm); end end
95c982c85442c0c40a60944616dedff6ce8b64d6618bce5c51a40e35c9b03d57
MATLAB
292
9
function [] = remove_errorbarticks() % remove errorbar ticks xlims = get(gca, 'xlim'); ylims = get(gca, 'ylim'); hold on; plot(xlim*100000, ylim*10000); % fool matlab into thinking we have much more data, which will automatically resize the errorbars xlim(xlims); ylim(ylims); hold off; end
16a7a071a8557b38e1c21ae728825418f29e5ac9e7fd8784100eae20eec90b22
MATLAB
293
18
%{ # summary images for each slice and channel after corrections -> reso.MotionCorrection -> shared.Channel %} classdef SummaryImages < dj.Computed methods(Access=protected) function makeTuples(self, key) %!!! compute missing fields for key here % self.insert(key) end end end
66bf83d9c87b97cf230a394a10f5302aac8de654dc735c79660ae1023db5f21e
MATLAB
293
3
function x = check_1d_distributed(x) standard_distributions = {'bino','chi2','exp','ev','f','gam','gev','gp','geo','hyge','logn','nbin','ncf','nct','ncx2','norm', 'poiss','rayl','t','unif','unid','wbl'}; x = is_1d_distributed(x) && any(strcmp(x{1},standard_distributions)) && isnumeric(x{2});
6b0ea3b64b72c9b438f0742faf2245ddeb4647057d92429ba50fb5ee29d2e0be
MATLAB
293
15
function y = Cfunc(x) % y=Cfunc(x) % Testfunction defining a linear operator applied to x. % Used for testing laneig. % % y = [ 0 A ] * x % [ A' 0 ] % Rasmus Munk Larsen, DAIMI, 1998 global A MxV [m n] = size(A); y = [A*x(m+1:end,:); A'*x(1:m,:)]; MxV = MxV + 2;
9b275f07698d6925672ee5d7d43b89b7a17bbe09b6320201386a3e46234cf3d9
MATLAB
293
18
%{ # summary images for each field and channel after corrections -> meso.MotionCorrection -> shared.Channel %} classdef SummaryImages < dj.Computed methods(Access=protected) function makeTuples(self, key) %!!! compute missing fields for key here % self.insert(key) end end end
abce3b47835bc1acec6eeab34e7229bb3d08073d41b18f3f27f5b467c5df6b1b
MATLAB
293
22
function r = uplus(p) %UMINUS: this function applies a unary minus to the x, y, and z values of the structures that I use in % the FVtool. % % SYNOPSIS: % % % PARAMETERS: % % % RETURNS: % % % EXAMPLE: % % SEE ALSO: % % Copyright (c) 2012-2016 Ali Akbar Eftekhari % See the license file r=p;
03adcb15310cc031dac719cc1b0c8ef7e302c5d176f95dcdba1693ef1b4cd9ef
MATLAB
294
1
% CreateQuest.m function q = CreateQuest(InitGuess) tGuess = log10( InitGuess ); tGuessSD = 3; pThreshold = 0.82; beta = 3.5; delta = 0.01; gamma = 0.5; grain = 0.01; %grain = 0.0001; range = log10( 1000 ); q = QuestCreate( tGuess, tGuessSD, pThreshold, beta, delta, gamma, grain, range);
6a900352680fd55e08718a8aa6f8706f9450358a9a3f957180e960dae50a9292
MATLAB
294
21
%{ pre.ExtractTraces (imported) # my -> pre.Segment ----- %} classdef ExtractTraces < dj.Relvar & dj.AutoPopulate properties popRel = pre.Segment end methods(Access=protected) function makeTuples(self, key) self.insert(key) makeTuples(pre.Trace, key) end end end
a5265bcc038209450863fb7892e730a587b27d4fe3a3b70b1304a1bd45f7e782
MATLAB
295
8
function ek = parse_echo_from_name(fp) [~,name,ext] = fileparts(fp); if strcmpi(ext, '.gz') [~,name] = fileparts(name); % strip .nii end tok = regexp(name, '[_-]echo-([0-9]+)(?:[_-]|$)', 'tokens', 'once'); if isempty(tok), ek = ''; else, ek = tok{1}; end end
c1d35bccaca13f550c0948e4c5a361853410316d8cc01d7d7faef0783e7fd6f7
MATLAB
295
13
function tm = getFrameTimes(info, Nplanes) Npts = round(numel(info)./Nplanes); cnt = 0; tm = zeros(Npts, Nplanes); for i = 1:Npts for j = 1:Nplanes cnt = cnt+1; tm(i,j) = getMetaVal(info(cnt).ImageDescription, 'frameTimestamps_sec'); end end tm = tm(:,1);
e94cf1244a70b6e04f96700cb5a75bbd659f48a4ad31d844b9fd817f06a489fc
MATLAB
295
19
%{ # -> preprocess.ComputeTraces (spike_method_1) -> preprocess.Spikes (spike_method_2) -> preprocess.Spikes %} classdef SpikeMethods < dj.Computed methods(Access=protected) function makeTuples(self, key) %!!! compute missing fields for key here %self.insert(key) end end end
ed53680f01bb82818c008d19e8c0d0168b2edc89962ccb2ea405bf9cae1c2aa0
MATLAB
295
7
% populate tables related to eye position clustering cd /mnt/lab/home/atlab/pipeline/pipeline/matlab/scripts/Eye_Movements startup parpopulate(preprocess.CirclesLookup) ; parpopulate(preprocess.CircleMap) ; parpopulate(preprocess.EyePosClusterCenter) ; %parpopulate(preprocess.ClusteredEyePos) ;
4a023ff11a5f40d10c64d34b8025e792cbe10d15c0aa659124d586249636f1e2
MATLAB
296
17
function y = extendswt(x, lf) %EXTENDSWT extends the signal periodically at the boundaries % Parameters % ----------- % x : % lf : % % Output % ------ % y : [r,c] = size(x); y = zeros(r+lf,c); y(1:lf/2,:) = x(end-lf/2+1:end,:); y(lf/2+1:lf/2+r,:) = x; y(end-lf/2+1:end,:) = x(1:lf/2,:); end
544bfa99ad9b771f3bed1509d5972b9db6e8d30eec53261fa6ae3635929fd623
MATLAB
296
15
function [rez] = cleaning(rez,i,channel,Th) del = []; id_i = find(rez.st(:,end)==i); i_chan= rez.Merge_cluster{i,5}; cha_id= find(i_chan==channel); PDF = rez.PDF{i,cha_id}; del_id = find(PDF<Th); id = id_i(del_id); rez.st(id,:) = []; end
d0af77a97a2e00a531e3557929b1220f9d5d300697e78682517cc7d5e970c33f
MATLAB
296
20
%{ # -> preprocess.MaskClassification -> preprocess.ExtractRawGalvoROI --- -> preprocess.MaskType %} classdef MaskClassificationMaskType < dj.Computed methods(Access=protected) function makeTuples(self, key) %!!! compute missing fields for key here %self.insert(key) end end end
d75f69a0aea9d9d4a5302a93401fda4a7c0e5ab7c0fa91e7211e57897028f3db
MATLAB
296
12
% load HRF parameters load('hrfparams.mat','params'); % 20 different HRFs x 7 parameters % visualize figure; hold on; cmap0 = copper(20); for p=1:size(params,1) temp = spm_hrf(0.1,params(p,:)); temp = temp / max(temp); plot(0:0.1:50,temp,'k-','Color',cmap0(p,:)); end xlabel('Time (s)');
ef84e4f2caec915707db2d2ff6254f4b8da472dd446bf43ec4b934c7bccbf0fe
MATLAB
296
10
function output = image_center(input, window_size) output = zeros([window_size window_size]); size1 = size(input,1)-1; size2 = size(input,2)-1; offset1 = round((window_size-size1)/2); offset2 = round((window_size-size2)/2); output(offset1:(offset1+size1), offset2:(offset2+size2)) = input; end
f1f705d8c28845c222480582e4b3d810e4adc35f80bfd8f80d0ed3584a824b6c
MATLAB
296
12
function combinedMagnitude = ComputeOptimalCombinedMagnitude(te,r2s,magn) % Compute weights wTE = zeros(size(magn)); for kt=1:length(te) wTE(:,:,:,kt) = te(kt)*exp(-r2s.*te(kt)); end % combine magnitude weighted by normalised weights combinedMagnitude = sum(magn .* (wTE ./ sum(wTE,4)),4); end
0f2fe63f9c2a3867d2c783444c13b7f998191347de2e2fd8bb355314a4e78f20
MATLAB
297
14
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
77a00af2bfb84797dd1a484a6afc84acbe8b4e83262a406f05ead7844ce8f9e8
MATLAB
298
17
function [ndims] = tapas_sem_seria_ndims() %% Return the number of dimensions of the seria family of models. % % Input % % Output % ndims Number of dimensions of the parameters. % % aponteeduardo@gmail.com % copyright (C) 2016 % [ndims] = c_seria_ndims(); end % tapas_sem_seria_ndims
99833530d26c5901a24af1abc9c054f84a62e89177b5075ddf286da7469a941a
MATLAB
298
11
function createFolders(PATH) %% createFolders % check whether folders specified at all fiels of PATH structure exist, if % not create them FIELDNAMES = fieldnames(PATH); for fi = 1:length(FIELDNAMES) if ~ exist(PATH.(FIELDNAMES{fi}), 'dir') mkdir(PATH.(FIELDNAMES{fi})); end end end
0045edfca4cafd4ca3ee4b13e0c35e3366f396c268f54a77fd0b49aad8827787
MATLAB
299
18
for i=1:20 i n1=num2str(900+i); file=strcat('fort.',n1); x=load(file); Fs=100000; inh=x(:,1)-mean(x(:,1)); amp=x(:,2)-mean(x(:,2)); nmd=x(:,3)-mean(x(:,3)); an=(amp+nmd)/2; pin=rms(inh)^2; pan=rms(an)^2; ar(i)=pan/pin; end arm=mean(ar) arstd=std(ar)
927b61689dc95f5f31e4e9ca9286212cc8f92fd349c81007fd54b461268c85b0
MATLAB
299
13
function subplot2(nrows, ncols, i, j) sz = [nrows ncols]; k = sub2ind(sz(end:-1:1), j, i); subplot(nrows, ncols, k); if 0 ncols_plot = ceil(sqrt(Nplots)); nrows_plot = ceil(Nplots/ncols_plot); Nplots = nrows_plot*ncols_plot; for p=1:Nplots subplot(nrows_plot, ncols_plot, p); end end
9faf88efccf6240cb4b79493325fcf810564230c16542bf3100dadcdf23d4526
MATLAB
299
7
function [infGrad, genGrad] = modelGradients(encoderNet, decoderNet, x) [z, zMean, zLogvar] = sampling(encoderNet, x); xPred = sigmoid(forward(decoderNet, z)); loss = ELBOloss(x, xPred, zMean, zLogvar); [genGrad, infGrad] = dlgradient(loss, decoderNet.Learnables, ... encoderNet.Learnables); end
6134aefc423ccc8797671290abfadab3fad6e383d6f9d723a295410cb25e5e5f
MATLAB
300
6
px2cm = 0.169; reg1 = mean(abs(WholeTestResult(:, 3) - WholeTestResult(:,4))) * px2cm reg2 = mean(abs(WholeTestResult(:, 3) - WholeTestResult(:,5))) * px2cm reg3 = mean(abs(WholeTestResult(:, 3) - WholeTestResult(:,6))) * px2cm reg4 = mean(abs(WholeTestResult(:, 3) - WholeTestResult(:,7))) * px2cm
7800146941975dad48ee5be59adc5d440bcc3d03bbb4433088000e9429e1e729
MATLAB
300
13
function A = loaddiag(A) % FORMAT A = brca.utils.loaddiag(A) % A - A square matrix % % Load A's diagonal until it is well conditioned for inversion. factor = 1e-7; while rcond(A) < 1e-5 A = A + factor * max([diag(A); eps]) * eye(size(A)); factor = 10 * factor; end end
12c0fc39940c239a1bba44d739f79f8f6c5865e1512b8027c4d81919959a9e8e
MATLAB
301
11
function x = z1(y) % linear normalize between 0 and 1 x = (y-min(y(:)))/(max(y(:))-min(y(:)))+eps; % for multidimensional stuff, this normalizes each column to between 0 and % 1 independent of other columns % T=length(y); % y=y'; % miny=min(y); % x = (y-repmat(miny,T,1))./repmat(max(y)-min(y),T,1);
5e63a061ff8d86eee9803e186976f3454878c2c797ba585b5d90bae223301228
MATLAB
301
10
%{ # current speaker configured in the setup rig : char # name of setup --- speaker_id : int # some number that identifies the speaker location : tinyint # 1=Left, 2=Right %} classdef CurrentSpeakers < dj.Lookup end
8773f4e598798aab0fbd806b0e7c883bf5ff16255e9e7d5916be7a79e73dd84c
MATLAB
301
10
%{ trk.SelectionProtocol (lookup) # groups of filtering steps to reject bad frames filter_protocol_id: int # id of the filtering protocol --- protocol_name : char(50) # descriptive name of the protocol %} classdef SelectionProtocol < dj.Relvar end
af61f83139e15a2fc5b3f285d41d8c71471f3c1b5cbe538eb7f489a751a1e426
MATLAB
301
13
function C=pairMatrix(K) % function C=pairMatrix(K) % function to make the pairs % C= indicatorMatrix('allpairs',[1:K]); % % Joern Diedrichsen 2016 C=zeros(K*(K-1)/2,K); where = 1; for i=1:K C(where:where+K-i-1,i)=1; C(where:where+K-i-1,i+1:end)=-eye(K-i); where = where+K-i; end;
01df742fe27338e7e9f5050630e40ac55bac9a152b27dbd9ec61bd3ec3ea2fdc
MATLAB
302
19
%{ # brain area membership of cells -> `pipeline_preprocess`.`_extract_raw__galvo_r_o_i` --- -> experiment.BrainArea %} classdef AreaMembership < dj.Computed methods(Access=protected) function makeTuples(self, key) %!!! compute missing fields for key here %self.insert(key) end end end
2d67cba6817fcc8a1fdd870de50de27c4d904cdf8c552661fdf119899970bc56
MATLAB
302
20
%{ # -> tuning.MonetRF -> preprocess.SpikesRateTrace --- map : longblob # %} classdef MovieRFMap < dj.Computed methods(Access=protected) function makeTuples(self, key) %!!! compute missing fields for key here %self.insert(key) end end end
7173774dc8bcf76afe32fd0c511dce9aa23b9f7e6b7ef4090c0d94fb81f2a6c9
MATLAB
302
17
function [ndims] = tapas_sem_prosa_ndims() %% Return the number of dimension of the gamma family of models. % % Input % % Output % ndims Number of dimensions of the gamma family models % % aponteeduardo@gmail.com % copyright (C) 2016 % ndims = c_prosa_ndims(); end % tapas_sem_prosa_ndims
89597c2d189a5b80a87cde9fb54f7bd07cc6b937c41fc967492d13680c9f0138
MATLAB
302
17
function stars = get_stars_for_P (P) if P<0.0001 stars = '****'; else if P<0.001 stars = '***'; else if(P<0.01) stars = '**'; else if (P<0.05) stars = '*'; else stars = 'n.s.'; end end end end end
8ab665ca97fc5dd25284694fd3dfb1f871469a1feaebf7a311e153e4fe8f1a19
MATLAB
302
15
function tick = SecToTick(sec) % Converts seconds to tick in microseconds % % function tick = SecToTick(sec) % % Input: % sec - Time in seconds % % Output: % tick - seconds converted to microseconds. % % (c) 2016 by Multi Channel Systems MCS GmbH tick = sec * 1e6; end
b4d64a66c9d59c0b7f2b0cf0edb35678e095afa57f5accb9c7d3838f0ea25e0b
MATLAB
302
15
function obj = init_data(obj, dataset) obj.data = struct; N = numel(dataset); [obj.data(1:N).x] = deal([]); [obj.data(1:N).z] = deal([]); [obj.data(1:N).zz] = deal([]); [obj.data(1:N).Az] = deal([]); for n=1:N obj.data(n).x = dataset(n); end end
01b88bf85504c9a40654048cf150020ef789830e4875c87432f4159522d64bf8
MATLAB
303
9
function reader = getReader(key) [path, basename, scanIdx] = fetch1(rf.Session*rf.Scan & key, ... 'scan_path', 'file_base', 'scan_idx'); fprintf('Loading from %s\n', path); path = getLocalPath(fullfile(path, sprintf('%s_*%03u_*.tif', basename, scanIdx))); reader = ne7.scanimage.Reader5(path); end
2227dabd0f6bae4edccfd5721508f2e2c05f7c2439432dc4c23de337ef39126c
MATLAB
303
8
function [elbo, rcLoss, klLoss] = FD_clVAE_ELBOloss(x, xPred, zMean, zLogvar, beta) reconstructionLoss = sum((xPred - x).^2, 1); KL = -0.5 * sum(1 + zLogvar - zMean.^2 - exp(zLogvar), 1); rcLoss = mean(reconstructionLoss); klLoss = mean(beta*KL); elbo = rcLoss + klLoss; end
25c421ea596b95084c33c8b4a56ebc836e1e3f54772b22a58bec1e5dd43d63e4
MATLAB
303
9
% List of open inputs nrun = 1; % enter the number of runs here jobfile = {'/Volumes/IqraMacFmri/visTac/fMRI_analysis/code/calcSearchlight/createMeanAnat_job.m'}; jobs = repmat(jobfile, 1, nrun); inputs = cell(0, nrun); for crun = 1:nrun end spm('defaults', 'FMRI'); spm_jobman('run', jobs, inputs{:});
319db4a94acd75b53fde01f60c45269d174933e6a69cb4abb701b83a242df512
MATLAB
303
17
function [tr, t] = sero_srr_w_to_tr(w, t_shot) % function [tr, t] = sero_srr_w_to_tr(w, t_shot) t = w .* (1:size(w,1))' * t_shot; tr = nan(size(t)); for i = 1:size(t,2) ind = find(t(:,i)); ds = diff([-inf; ind]); % FIXME!!! tr(ind, i) = ds * t_shot; end tr(isnan(tr)) = 0;
67f17b1dea5268ed783ceaf75865d929e2dd9cb8017cf43072a88671fec209d1
MATLAB
303
20
function [B,l,k ] = mat_extend( A,it ) m=size(A,1); n=size(A,2); kk=ceil(m/4); ll=ceil(n/4); k=abs(kk*4-m); l=abs(ll*4-n); if it col_add=ones(m,l); row_add=ones(k,n+l); C=[A,col_add]; B=[C;row_add]; else col_add=zeros(m,l); row_add=zeros(k,n+l); C=[A,col_add]; B=[C;row_add]; end end
a5b66ed91cb82417410f5a1277250c549ee347d6a1c3a082816d525e84691755
MATLAB
304
14
function tapas_BLT_initCogent(store) % tapas_BLT_initCogent starts cogent which is needed for the response box % % About: % Coded by F.Petzschner 19. April 2017 % Last change: F.Petzschner 19. April 2017 if ~store.keyboard config_serial(store.scanner.boxport, 19200, 0, 0, 8); start_cogent; end end
e8a75e27d812340e1d943b6572de3bd9b219daa10b679cc021dccb8842cdc374
MATLAB
304
14
function this = eegobj(EEG); if nargin == 1 if isa(EEG, 'eegobj') this = EEG; return; end for index = 1:length(EEG) TMP(index).EEG = EEG(index); end else TMP.EEG = eeg_emptyset; end this = class(TMP, 'eegobj');
7cda38f7231a42dbdf70e23583b9025b6ed250201455cbe17905a58300ecc08d
MATLAB
305
25
function Step1_getExpInfo() clc; close all; addpath('Wavesurfer-master'); pth = 'C:\Users\economom\Dropbox (Personal)\Analysis\VoltageImaging\2021-01-28'; tokens = {'_opto_0'}; nums = 1; fn.si = getImFiles(pth, token, nums); fn.ws = getWSFiles(pth, token, nums);
f7376bb65db461c88b01803784571e231452cb861b82650fa21a56aa462b6813
MATLAB
305
8
function [pathname, filename, ext] = myfileparts(filename) % FUNCTION [pathname, filename, ext] = myfileparts(filename) % % Robust against .nii.gz file extension [pathname, filename, ext2] = fileparts(filename); [~, filename, ext1] = fileparts(filename); ext = [ext1 ext2];
55d00b94f3d4e622ab4ec049adb89b80d96dca6cacfcf1ff1f023feaeb3a6a07
MATLAB
306
9
function roiMovedCallback(rectangle,evt) % This runs when a box's rectangle is resized or moved hObject = get(rectangle,'Parent'); handles = guidata(hObject); tag = str2double(get(rectangle,'Tag')); handles.data.calls{tag,'Box'} = rectangle.Position; SortCalls(hObject, [], handles, 'time', 0, tag); end
a2eafd0b83f981beee3bb9f88add4795abf6e792ee78f0c25c970cd5d95d1303
MATLAB
306
3
function res = is_symbolic_lambda(x) % internal: a symbolic lambda function is one which generates expressions when invoked with arguments (this is what exp_symbol generates) res = isa(x,'function_handle') && ~isempty(regexp(char(x),'@\(varargin\)struct\(''head'',\{.*\},''parts'',\{varargin\}\)','once'));
0e74a8d672916029d3dc04149745907c073d5209513070f4bb91c34a12db0335
MATLAB
307
17
function [gt] = tapas_trans_mv2gt(mu, sigma2) %% Transforms to the scaling of the gamma distribution % % Input % mu -- Means % sigma2 -- Variance % % Output % gk -- K parameter of an gamma distribution % aponteeduardo@gmail.com % copyright (C) 2015 % gt = mu ./ sigma2; end
28c7f22b21b52152afc821ce8648d9faca3fc4e01b781603fac1d97b977378da
MATLAB
307
14
function isnum = afni_ni_is_numeric_type(t) ni_def=afni_ni_defs(); if (isnumeric(t)), isnum = ( (t) >= 0 & (t) <= ni_def.NI_RGBA ); elseif (isnumeric(afni_ni_rowtype_name_to_code(t))), isnum = ( (t) >= 0 & (t) <= ni_def.NI_RGBA ); end isnum = prod(single(isnum)); return;
30ecc237a7526e6825ca5ad9789d0b01e7ba7b3ff62933c10be8b0ff97b18856
MATLAB
307
13
function colors = colorPalette(n) % defines colors for n elements as rgb tripplets % (c) Jiri, May12 if n < 4 colors = [0 0 1; % b 1 0 0; % r 0 1 0]; % g else func = @(x) colorspace('RGB->Lab',x); colors = distinguishable_colors(n,'w',func); end
37ef93b209188696e60c90cac1f5abd6c86fdfdc98c44e9d131f1a572d4d499f
MATLAB
307
14
function ind = sero_pulseq_getAllRFBlockInd(seq) % function ind = sero_pulseq_getAllRFBlockInd(seq) % % Function returns a list of indices that correspond to RF events. nBlock = numel(seq.blockEvents); ind = []; for i = 1:nBlock if all(seq.blockEvents{i}([2 5])) ind(end+1) = i; end end
526edcf024a50112a185701f32333ab0595c9c9e99c22422f55ef2f66043d87e
MATLAB
308
20
%{ # -> reso.Fluorescence -> reso.SegmentationMask --- trace : longblob # %} classdef FluorescenceTrace < dj.Computed methods(Access=protected) function makeTuples(self, key) %!!! compute missing fields for key here % self.insert(key) end end end
9b4893a4a16b069647ed41aeea928bb930f08b2a8d94206fd288b21da7aa556e
MATLAB
308
20
%{ # -> meso.Fluorescence -> meso.SegmentationMask --- trace : longblob # %} classdef FluorescenceTrace < dj.Computed methods(Access=protected) function makeTuples(self, key) %!!! compute missing fields for key here % self.insert(key) end end end
006af446e674826f2b856c31bc271a4a5cf3b985f00d9b9aff0036be3acc673a
MATLAB
309
10
function b = ctx_dec2col(X, n) if nargin < 2 n = max(X(:)); end b = zeros(length(X),n); % Create an empty array w/ as many rows as X, and as many cols as the max val of X for i=1:length(X) b(i,X(i)) = 1; % In that array, for each row and the corresponding column where X=that row, put a 1 end end
0c0e4a711e9d0c2608d2a88f0e734ef259f4bde5b1da69f2e0ab0507f2002493
MATLAB
309
16
function y = getBoxVal(x) quartile=prctile(x,[25,50,75]); iqr=diff(quartile([1,3])); minMax(1)=min(min(x(x>=quartile(1)-iqr*1.5)),quartile(1)); minMax(2)=max(max(x(x<=quartile(3)+iqr*1.5)),quartile(3)); y.lower=quartile(1); y.median=quartile(2); y.upper=quartile(3); y.iqr=iqr; y.minMax=minMax; y.raw=x;
4e857f3a8c020f3a077c1fa5dc860ac72d8fb2037dd12177a522e908a08c0a40
MATLAB
309
5
function nodal_stats2(Nodalmetric,Pathnewxsl,opthub,Pathnewplot,Scalev1,Nname,pthretype,restulsmat); result_name=Nname; load(restulsmat); FourModelsigthre=arrange_nodal_Slope(Nodalmetric,indminNodalStrmdall,indminNodalStr,notenoughNodalStr,Pathnewxsl,opthub,Scalev1,Pathnewplot,pthretype,result_name); end
8550e1b6ee573bfb3c8cb04bab51605179918eb290a0424817a63be23157d289
MATLAB
309
15
function hline(y, varargin) % HLINE plot a horizontal line in the current graph abc = axis; y = [y y]; x = abc([1 2]); if length(varargin) == 0, varargin = {'color', [0.5 0.5 0.5]}; elseif length(varargin)==1 varargin = {'color', varargin{1}}; end h = line(x, y); set(h, varargin{:});
9f8ff1a165a010d2f68a2db6db1d3e145ba2108cbae41f80554d4cbfdd23c27f
MATLAB
309
14
function feature_maps = spiking_conv(spike_trains) feature_maps = spike_trains; kernel = [1 0; 0 -1]; threshold = 1.5; for layer = 1:2 conv_out = conv2(feature_maps, kernel, 'same'); [~, spikes] = spiking_neuron(conv_out(:), threshold); feature_maps = reshape(spikes, size(conv_out)); end end
dd59727f4e812fe0eb9d5db24946ea400a712b7eb60d2caf66c0e0a54fb89f76
MATLAB
310
14
function vline(x, varargin) % VLINE plot a vertical line in the current graph abc = axis; x = [x x]; y = abc([3 4]); if length(varargin) == 0, varargin = {'color', [0.5 0.5 0.5]}; elseif length(varargin) == 1, varargin = {'color', varargin{1}}; end h = line(x, y); set(h, varargin{:});
f31ee421e4f0100c095f6be71a03ec4b2239bb9c441b07ddb352b386fd420352
MATLAB
310
19
function ans = is_row (v); % ans = is_row (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;
1e3a05d8fe61883d3b4a18d52d53c3f2a5e76cd10422004f7d617311543b5285
MATLAB
311
23
function r = not(p) %UMINUS: this function applies a unary minus to the x, y, and z values of the structures that I use in % the FVtool. % % SYNOPSIS: % % % PARAMETERS: % % % RETURNS: % % % EXAMPLE: % % SEE ALSO: % % Copyright (c) 2012-2016 Ali Akbar Eftekhari % See the license file r=p; r.value = ~p.value;
ce5635d50935e66b6ea8d2e3786431765a7fdd6dc5035e6658f10ae269c4229c
MATLAB
311
16
function [nvCell] = struct2NV(s) % Converts a struct s into a cell of name-value pairs. fieldNames = fieldnames(s); numFields = length(fieldNames); nvCell = cell(1, 2*numFields); i = 1; for field = 1:numFields nvCell{i} = fieldNames{field}; nvCell{i+1} = s.(fieldNames{field}); i = i+2; end end
0d3d4aa51bf53332b38edac1e410cbcae0fcc32f01bbe5cc23a5c60760a47f0a
MATLAB
312
11
function StateNumber = mfunc_GetStateNumber(binarizedData) % Get State Number from binarized Data % if binarizedData is N x M matrix, binarizedData(N,:) is MSB. % Need to flipud. %dat = (binarizedData > 0); dat = flipud(binarizedData > 0); StateNumber = bin2dec(num2str(dat')); StateNumber = StateNumber + 1;
228a029f411148de20e7f48a9b399818d0d55073a1254b66655ff7be4b370430
MATLAB
312
10
%{ # list of piezostimulators in various setups id : int # some number that identifies the piezostimulator rig : char # setup name location : tinyint # 1 = Left, 2 = Right %} classdef Piezostimulators < dj.Manual end
5525cbffeed631aa1f5ef14bc0aaace39bdbcdd19b96c519bebb6bdb6ac2605a
MATLAB
312
8
% Wrapper to apxGrid to remain backwards compatible. % % Note that covGrid is not a valid covariance function on its own right. % % Copyright (c) by Hannes Nickisch and Andrew Wilson 2016-08-25. function varargout = covGrid(varargin) varargout = cell(nargout, 1); [varargout{:}] = apxGrid(varargin{:});
7468d934e9a72ea33c34803d4b36f63f93feb716e04dd296053e6b32f1b4e36b
MATLAB
313
10
function xcov_values = xcov_signals(input_signal1, ... input_signal2) % assumes network signals are in each *column* xcov_values = []; for ii=1:size(input_signal2,2) [c,lags] = xcov(input_signal1, input_signal2(:,ii), 10, 'coeff'); xcov_values(ii) = max(c); end
756f037acd69b9e944e54ddb1fd87da033060ba1cf40dccc4084f453dbb406cc
MATLAB
313
16
function [gt] = tapas_trans_mv2igt(mu, sigma) %% Transforms to the scaling of the inverse gamma distribution % % Input % theta Matrix with parameters % % Output % ntheta Transformation of the parameters % aponteeduardo@gmail.com % copyright (C) 2015 % gt = 1./((mu .^ 3 ./ sigma ) + mu); end
763e1bf1989bfc62cb73be2d64f42ef5dec5cb028608a7850448476ebc600e4c
MATLAB
313
9
cd('C:\Users\MysticSocialist\Documents\GitHub\CLOOSE_MS'); % Point to the main script or entry point of your project [~, requiredToolboxes] = matlab.codetools.requiredFilesAndProducts('stream_send_data.m'); % Display required toolboxes for k = 1:length(requiredToolboxes) disp(requiredToolboxes(k).Name) end
a1eddefc158cf3b7484ffd7bca0f0205e53b739a65d0ac77222febf60012407c
MATLAB
313
23
function r = atan(p) %atan: this function calculates the atan of a x, y, and z values of % the structures that I use in the FVtool. % % SYNOPSIS: % % % PARAMETERS: % % % RETURNS: % % % EXAMPLE: % % SEE ALSO: % % Copyright (c) 2012-2016 Ali Akbar Eftekhari % See the license file r = p; r.value = atan(p.value);
c1b0526217dbe6b67fba79147902afd61a04d65e066528e165b9a2f78d631284
MATLAB
313
9
function j = replace_ext(pathIn, newExt) if endsWith(lower(pathIn), '.nii.gz') j = regexprep(pathIn, '\.nii\.gz$', newExt, 'ignorecase'); elseif endsWith(lower(pathIn), '.nii') j = regexprep(pathIn, '\.nii$', newExt, 'ignorecase'); else j = [pathIn newExt]; end end
1d8542ff8a99b58e6d4c53029adfbc9cf2d3d9d10e7f4cf040fe12aae40812f9
MATLAB
314
5
function nodal_stats3(Nodal_metrics,Pathnewxsl,opthub,Pathnewplot,Scalev1,Nname,pthretype,restulsmat); result_name=Nname; load(restulsmat); FourModelsigthre=arrange_nodal_Slope2(Nodal_metrics,indminNodalStrmdall,indminNodalStr,notenoughNodalStr,Pathnewxsl,opthub,Scalev1,Pathnewplot,pthretype,result_name); end
5da68d4384d24d44599b33d9367d5a0e54ab52d8e1498eae69957fcae157131a
MATLAB
314
14
function [ rmse ] = rmse( in, true, use_abs ) %RMSE Summary of this function goes here % Detailed explanation goes here if nargin < 3 rmse = 100 * norm(in(:) - true(:)) / norm(true(:)); end if (nargin == 3) && (use_abs == 1) rmse = 100 * norm(abs(in(:)) - abs(true(:))) / norm(abs(true(:))); end end
d431308749ac872ee6432bc005ada9cbc947d7ac552d1575312b5488dcc708f7
MATLAB
314
14
function [ranknum] = getRank(input) % function to estimate the optimal rank for denoising % Adapted from LESS denoising, Jizhou Li [nx, ny, B] = size(input); Y = reshape(input, nx*ny, B)'; [~,~,V]= svd(Y,'econ'); Vt=V'; rankindx = getRankIndex(Vt); realindex = find(rankindx==1); ranknum = numel(realindex); end
db3755c696068fa9a90dc7f5066dc573b0bff6df4e683f6c48faa41b8da7bc82
MATLAB
314
23
function r = uminus(p) %UMINUS: this function applies a unary minus to the x, y, and z values of the structures that I use in % the FVtool. % % SYNOPSIS: % % % PARAMETERS: % % % RETURNS: % % % EXAMPLE: % % SEE ALSO: % % Copyright (c) 2012-2016 Ali Akbar Eftekhari % See the license file r=p; r.value = -p.value;
33f739576b9d8d11f9e53f7ef10a44cd501d9fb2f19b5e5073e8652ec97878a3
MATLAB
315
25
function ans = eq_str (s1,s2); % % ans = eq_str (s1,s2); % % returns 1 if strings are equal % 0 if they're not % % Ziad Saad July 20 97 ls1 = length (s1); ls2 = length (s2); if (ls1 ~= ls2), ans = 0; return; else ans = 1; for i=1:1:ls1, if (s1(i) ~= s2(i)), ans=0; end; end; return; end;
ab41f1335792ec6aba56c4f2f6b27a712e6dc4d86d59fedb934eff42e53b3868
MATLAB
315
20
%{ # -> preprocess.Eye -> preprocess.TrackingParameters --- tracking_ts=CURRENT_TIMESTAMP: timestamp # automatic %} classdef EyeTracking < dj.Computed methods(Access=protected) function makeTuples(self, key) %!!! compute missing fields for key here %self.insert(key) end end end
cc30d6a7eda70a588ebbc77ec285c6864ec3de19ba5499ab798d4cfca3e5648d
MATLAB
315
11
%{ experiment.SessionFluorophore (manual) # Fluorophores expressed in prep for the imaging session -> experiment.Session -> experiment.Fluorophore --- notes : varchar(255) # additional information about fluorophore in this scan %} classdef SessionFluorophore < dj.Relvar end
0ad765e686768237dea7f11addf5d19c085d206d855ac53b10d921506d9e5b13
MATLAB
316
15
function sec = TickToSec(tick) % Converts tick in microseconds to seconds % % function sec = TickToSec(tick) % % Input: % tick - Time in microseconds % % Output: % sec - microseconds converted to seconds. % % (c) 2016 by Multi Channel Systems MCS GmbH sec = double(tick) * 1e-6; end
c5882d55845dcdde196757c6190137c4b784169f9672e3562fd5e29eea35305e
MATLAB
316
16
function v2 = prod_vf_sf(v1,s) % prod_vf_sf - compute the product of a vector field by a scalar field. % % v2 = prod_vf_sf(v1,s) % % The result is the vector field defined by pointwise product. % % Copyright (c) 2004 Gabriel Peyré v2 = zeros(size(v1)); for i=1:size(v1,3) v2(:,:,i) = v1(:,:,i).*s; end
d4a1a83df55a0bb7d18d3d7fcdd90b773cf0d35051edafa8f94887f02d3aedb1
MATLAB
316
16
function [gk] = tapas_trans_mv2gk(mu, sigma2) %% Transforms to the scaling of the gamma distribution% % Input % mu -- Means % sigma2 -- Variance % % Output % gk -- K parameter of an inverse gamma distribution % aponteeduardo@gmail.com % copyright (C) 2015 % gk = mu.^2 ./ sigma2; end
42b9e639b2397d0090aae637b25adfcd1d669beeb9a4693915b7cd78924684bf
MATLAB
317
12
%{ # -> eye.ManuallyTrackedContours frame_id : int # frame id with matlab based 1 indexing --- contour=null : longblob # eye contour relative to ROI %} classdef ManuallyTrackedContoursFrame < dj.Manual % Implemented in Python end
7b9dacfc7a0eabbebff54847c4d41408733cccb98d9b667ba13c7bbe05d3dfab
MATLAB
317
12
%{ # laser parameters for the stack -> experiment.Stack --- wavelength : int # (nm) max_power : float # (mW) to brain gdd : float # gdd setting %} classdef StackLaser < dj.Manual end
e0389cd15089e345bc11e7094d8bda0cc60502fa695051907056c32e94891b71
MATLAB
317
17
function pred = pack_pred_struct(D, neighbors, w, dc, varargin) pred = struct(); pred.D = D; pred.neighbors = neighbors; pred.w = w; pred.dc = dc; if nargin >= 5 && ~isempty(varargin{1}) pred.class_pred = varargin{1}; end if nargin >= 6 && ~isempty(varargin{2}) pred.y_pred_weighted = varargin{2}; end end
46704597ec8bbff3031d166c7bb5fa8e78b24dc135a76db0480fc1c25a1efc21
MATLAB
318
12
function val = getMetaVal(metadata, field) ind1 = strfind(metadata, field); if (~isempty(ind1)) ind2 = strfind(metadata(ind1:end), 10); ind2 = ind2(1); line = metadata(ind1:ind1+ind2-2); val = sscanf(line,[field ' = %f']); else disp('Error - Invalid metadata field'); val = 100; end
7147b369dafc2b367c928adc2d633ed1468556af4fe7d5bdf04d05a17d04f7b5
MATLAB
318
15
function [colorMapSort] = FindColorMap() load(fullfile('..', 'Figure4','data', 'log10EC50.mat')); log10EC50(isnan(log10EC50)) = 0; [~, score, ~,~,~, ~] = pca(log10EC50); [~, I] = sort(score(:, 1)); myColorMap = jet(34); colorMapSort = zeros(34, 3); for i =1:34 colorMapSort(I(i), :) = myColorMap(i, :); end end
f69d0b6c687243aa7adb666886176ecdffab13e65c3b01d55029dd927f84c05a
MATLAB
318
10
%{ # current piezostimulators configured in the setup rig : char # name of setup --- speaker_id : int # some number that identifies the speaker location : tinyint # 1=Left, 2=Right %} classdef CurrentPiezostimulators < dj.Lookup end
1569c4f5c9be2345629ff8d0fe8b19965d05a8f31dab328a4b3039fc196292e3
MATLAB
320
19
%{ # l6-norm of each pixel across time -> meso.SummaryImages --- average_image : longblob # %} classdef SummaryImagesAverage < dj.Computed methods(Access=protected) function makeTuples(self, key) %!!! compute missing fields for key here % self.insert(key) end end end