sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
6cb18bb9721a7b0c229fa6d0531793e7109ee146534b92a41fa96ecc7396ea9d
MATLAB
224
10
function [ y ] = modelfun_dHC( beta, x ) %UNTITLED7 Summary of this function goes here % Detailed explanation goes here beta_aux = beta([1 2 3 4 4 5 6 6]); beta_aux(5) = 0; y = modelfun_dHEC(beta_aux, x); end
7b24e6d1d253016f2864e51605f3c564bae1a2f585f105080eff20bf4dce5bbe
MATLAB
224
13
function regtanks = GetRegTanks(TTX) % regtanks = GetRegTanks(TTX) % % DJS 2013 for idx = 1:100 regtanks{idx} = TTX.GetEnumTank(idx-1); if isempty(regtanks{idx}), break; end end regtanks(end) = []; end
0c49b0579d0aa97ba5ab919cdfc3705edb30b67054aa521dfcb285c218571ad1
MATLAB
225
7
% TWOPHOTON PROCESSING PACKAGE % % This directory contains code for processing data collected from % a GENERIC device, where directories are a list of TIFF files. % % Does NOT include support for linescans at this time.
cd667282ed0d932e076e04d1471be27874da791b2a59799054dbe242fea03f4e
MATLAB
226
11
function esc=Esc() % Set escape character separating folders machine=computer; if strcmp(machine(1:3),'MAC') esc='/'; elseif strcmp(machine(1:3),'GLN') % unix cluster GLNXA64 esc='/'; else % windows esc='\'; end
d5ddee7b3e43d963f6006f2e47acc0a9a0087847a738277eadc820cd14ba8517
MATLAB
226
11
function c = getCov(y,ypred) idxnan_y = any(isnan(y),2); idxnan_ypred = any(isnan(ypred),2); idxnan = idxnan_y | idxnan_ypred; y(idxnan,:) = []; ypred(idxnan,:) = []; c = sum((y-mean(y)).*(ypred-mean(y)))/(numel(y)-1); end
a173bfb9769c64b6b87d9945d37bad9a418ee653b02a1196ea1c449e2f577d48
MATLAB
227
11
function c = getCov(y,ypred) idxnan_y = any(isnan(y),2); idxnan_ypred = any(isnan(ypred),2); idxnan = idxnan_y | idxnan_ypred; y(idxnan,:) = []; ypred(idxnan,:) = []; c = sum((y-mean(y)).*(ypred-mean(y)))/(size(y,1)-1); end
815aae0f77c9525b617d49a3f4d44cf1d2fa70d269cf72a5717521f8cc6a23f2
MATLAB
228
13
function [f,g,nh_2] = poissExpLL(x, y, dt) x = x + log(dt); rate = kgmlm.utils.boundedExp(x); f = -rate + y.*x; if(nargout > 1) g = -rate + y; if(nargout > 2) nh_2 = kgmlm.utils.boundedExp(0.5*x); end end
3230312cd5e2cde49fd2448f2048183082dd9d277f6fecb9b4df058e5d84fc9c
MATLAB
229
8
function project = MarkClipsAsIncomplete(project, numberToMark) nRows = size(project.ClipTable,1); randIdxs = randperm(nRows); selRowNums = randIdxs(1:numberToMark); project.ClipTable.Type(selRowNums) = categorical({'UR'}); end
204fe115cee115890d4bf232db554130c1f39a74793dab17054c3484f99d3087
MATLAB
230
11
up = SpherePatch(8, 10, [0 0 1], true, false) down = SpherePatch(8, 10, [0 0 -1], true, false) CreateRenderingFigure() DrawVertStructure(up, [0 0 0], [1 0 0]) CreateRenderingFigure() DrawVertStructure(down, [0 0 0], [0 0 1])
247c3e1e6ba66fb5ca028045dbbb4a8e84fb389a3459216da35d706f3e9f5cfc
MATLAB
230
7
function solTag = find_sol(FEM, studyTag) solTags = FEM.sol().tags; solsStudy = arrayfun(@(s) char(FEM.sol(s).study()), solTags, 'uni', false); solIndex = strcmp(solsStudy, studyTag); solTag = char(solTags(solIndex)); end
442cf73a3db18942d15e8f57f5f681513ef90e35651bb252780f570159fa22c5
MATLAB
231
12
function imgData = readTiff(filename) info = imfinfo(filename); numFrames = numel(info); imgData = zeros(info(1).Height, info(1).Width, numFrames, 'uint16'); for n = 1:numFrames imgData(:,:,n) = imread(filename, n); end end
7733167537c606f1c34428258adcc5d8036d5903b7325e9a975e3cdad2d1f111
MATLAB
231
7
function [names, fullpaths] = list_csv(folder) files = dir(fullfile(folder, '*.csv')); names = {files.name}; names = cellfun(@(n) n(1:end-4), names, 'UniformOutput', false); fullpaths = fullfile({files.folder}, {files.name}); end
e4b69497372672dfc7c58f37eba22f41996b39bdc84548e25215cfb617ea9643
MATLAB
232
10
function [cells,cellnames] = analyzegeneric2pdata(dirname, saveit) ds = dirstruct(dirname); [cells,cellnames] = tpdoresponseanalysis(ds); if saveit, disp(['Saving results back to file']); saveexpvar(ds,cells,cellnames,0); end;
7c86c49840d3b8775a59dc258b2de4c43f655bf4c926f796ae448da943b6024c
MATLAB
233
14
function annotT = GetAnnotations(self, varargin) self = Load(self); if ~isempty(self.AnnotationTable) return end annotT = self.AnnotationTable; if nargin == 2 indices = varargin{1}; annotT = annotT(indices, :); end end
cd0cda80bf14cbbf1b0ca182760cc2c7db32b2a7ab13acbead82ea783500dc5a
MATLAB
234
9
function [ Verts, iVertsA, iVertsB, Normals, Faces ] = CreateConnector( Pos, Radius) %CREATECONNECTOR Given a 3x3 matrix with points on rows return a set of %verticies and faces which can connect cylinders between the points end
14b7446469127b076dfc051c6add7a53ef6b6d704f2b239440187166d09115a7
MATLAB
235
7
function [T] = remove_dup_ROIs(T) %REMOVE_DUP_ROIS remove two duplicated ROIs from beta tables duplicated_ROIs = {'L_agranularIns_bin_dAICtrim_roi.mat',... 'filtered_L_dAIC_custom_bin_new_roi.mat'}; T(duplicated_ROIs,:) = []; end
2ef527b2365c7ef7a1d0c7cf0305ae79c2a90b26aa0ab4d17b63f0cd23398201
MATLAB
235
8
function [im,fname]=tpreadframe(dirname,tpfileparams,cycle,channel,frame) %TPREADFRAME % read frame from single tiff % % 2008, Alexander Heimel % fname=fullfile(dirname,tpfilename(tpfileparams,cycle,channel,frame)); im=imread(fname);
3f1ae446de39b3c4d0877e240f3f96ebacd69bf39bf42e082d1fa470fa8e3811
MATLAB
235
12
function out = convert_1x6_to_3x3(in) if size(in,1) == 6 in = in'; end f = 1/sqrt(2); out = [ in(1) f * in(4) f * in(5); ... f * in(4) in(2) f * in(6);... f * in(5) f * in(6) in(3) ]; end
55ad69876f9b0c5a6f9ce52c82ec929bd98bc780bb8061eccef4d8715d3ca0b8
MATLAB
235
7
function [averages] = mean_by_module(betas) %MEAN_BY_MODULE mean by module [t_groups, t_ids] = findgroups(round(betas(:,2))); assert(isequal(t_ids,[0,1,2]')); averages = splitapply(@(x) mean(x, 'omitnan'), betas(:,1), t_groups)'; end
bbd0afb7f9c5b7c9294a2943c41dd2b7354f1ff433ef06fc3e3dee7b10b56bec
MATLAB
235
8
function [LFpsf,height,width,depth,Nnum,CAindex] = read_psf(file) psf = load(file); psf5d = psf.H; Nnum = psf.Nnum; CAindex = psf.CAindex; [height, width, Nx, Ny, depth] = size(psf5d); LFpsf = double(psf5d); end
b9b1d46c0811cd16abb8b30a86932c97c28f285e4137c746a9ae21802ed8d7f4
MATLAB
236
8
% test Liley_params; fhz1 = 19.965*4; % main timstep tcut = 5000; % apply for transients TDatend = 20000; % length of model simulation ms T1=0:1/fhz1:TDatend+tcut; params1 = [paramsvec, zeros(1, 10)]; y = em_Liley(T1, params1);
f1418b03f1e093554b50a27ffabe3910e1ebe703735639dc19d9e8379a859dcc
MATLAB
236
9
function clear_model(model) sol_tags = model.sol().tags; for i = 1:size(sol_tags) model.sol(sol_tags(i)).clearSolutionData(); end model.mesh().clearMeshes(); % Might not work % model.resetHist(); % might reduce size end
72a90639d9b1d5c0e1ea28987324eb6a527a0ab902a74e705793accbf1dfd279
MATLAB
237
9
function clear_models_folder(folder) modelFiles = dir(fullfile(folder,'**', '*.mph')); for modelFile = modelFiles' f = fullfile(modelFile.folder, modelFile.name); disp(['Clearing ' f]); clear_model_file(f); end end
d801bede624b927e8e9c085fb7cfac5cc88b95e0de92e24a76454196dc30a749
MATLAB
237
8
function [im,fname]=tpreadframe(dirname,fnameprefix,cycle,channel,frame) %TPREADFRAME % read frame from multitiff % % 2008, Alexander Heimel % fname=fullfile(dirname,tpfilename(fnameprefix,cycle,channel,frame)); im=imread(fname,frame);
bf4648453ade6f4b227e4028c8adbe1750fb34a74660e96790145a4b22103f56
MATLAB
238
7
function [noise_raster] = generate_noise_raster(raster) [n,t] = size(raster); noise_raster = zeros(n,t); num_spikes_raster= sum(sum(sum(raster))); noise_raster(randperm(numel(noise_raster),num_spikes_raster)) = 1; end
c013f2a01785fa88fe9c63b1ba852d24f6fd2d92c4f8d963609a44a67130fa76
MATLAB
239
7
function [name, fullpath] = get_subfolders(folder) folders = dir(folder); folders = folders(~ismember({folders.name},{'.','..'}) & [folders.isdir]); name = {folders.name}; fullpath = fullfile({folders.folder}, {folders.name}); end
77b7bf002ec66c642d25c9e4c5b6015a12fa8e49e59dff2c59d89eb471cf152b
MATLAB
240
7
function [g_surf] = get_surface_from_gifti(f_name) %GET_SURFACE_FROM_GIFTI read gifti file and convert it to a mesh structure % Note: requires gifti package g = gifti(f_name); g_surf = struct('faces', g.faces, 'vertices', g.vertices); end
798bf4fe5822ec8fcf902631378f287402427859313db4184a70a350cb8cec6f
MATLAB
240
10
function p1 = compute_p1(p_1from2,p_2from1) % Compute p(I1) for the input values of p(I_1|I_2) and p(I_2|I_1) given in % arguments. % p_1from2 and p_2from1 must have the same size. p1 = p_1from2./(p_1from2 + p_2from1) ; end
e5318e1627e8fdd699df368afd9c2e115f177b1386fb20a74a76d65c0f8a87ff
MATLAB
240
7
% TWOPHOTON PROCESSING PACKAGE % % This directory contains code for processing data collected from % the CellVoyager device, where data is represented in a stack of TIFF images. % % Does NOT include support for linescans at this time.
8ed8310c0909ec9aaba7a6425a529a76343b7ca7b49da46588a7c6fe79d39119
MATLAB
241
7
box off set(gca,'FontSize',14,'TickDir','in','XAxisLocation','bottom',... 'YAxisLocation','left','LineWidth',1.5,... 'XMinorTick','off','YMinorTick','off'... ,'TickLength',[.015 .015],'Layer','bottom') set(gcf,'Color','w')
99262080365631563d6efe9f08ad336c1dcacc321f3595e32aa1ea9d7cbd078e
MATLAB
241
13
function muscle = select_muscle_dlg() med = 'Medial gastrocnemius'; lat = 'Lateral gastrocnemius'; answer = questdlg('Select muscle', 'Muscle selection', med, lat, med); if strcmp(answer, med) muscle = 1; else muscle = 2; end end
23bfbaab9eb36264c637d77783cf207bd939804ef11e7f23ff9dca77115b5521
MATLAB
242
8
m2html('mfiles','MichalDataAna',... 'htmldir','doc', ... 'recursive','off', ... 'global','on',... 'globalHypertextLinks','on',... 'template','blue',... 'index','menu', ... 'graph','on');
3c395af4ba8d97862e791b209df6b4222c8f8eaa496c8c703b9005f97d6d9e71
MATLAB
243
10
function [pow_parcel,rois] = do_sourceparcell_surface(atlas,ImageGridAmp) rois = []; pow_parcel = []; for i=1:length(atlas.Scouts) pow_parcel(i) = mean(ImageGridAmp(atlas.Scouts(i).Vertices)); rois{i} = atlas.Scouts(i).Label; end end
8b83166d1129e5f5aa335a67c7c6eb2b5350641f89a3693a08a77ed5266c5fd1
MATLAB
243
12
function prepare_plot_cross_section(ax) hold(ax, 'on'); axis(ax, 'equal'); title(ax, 'Cross-section'); xlabel(ax, 'x [um]'); ylabel(ax, 'y [um]'); colormap(ax, flipud(parula)); c = colorbar(ax); c.Label.String = 'Charge threshold [nC]'; end
e15b7cac8233b34cab2f03ba1f8c2014e689428c34213bd454dea5c89abd8faf
MATLAB
243
11
% Run simulations Le_values = [5, 10, 30]; wNa_values = [2, 6, 14, 30]; for i=1:length(Le_values) run_simulation_Part1(Le_values(i)) for j=1:length(wNa_values) run_simulation_Part2(wNa_values(i), Le_values(i)) end end
edb235738666e17b83b667896ce895315c5cb137ff16716ddc5d7d3e442f0370
MATLAB
244
6
function fname = save_temp_FEM(FEM) fname = fullfile(get_base_paths().solutions, 'Temp', [erase(char(java.util.UUID.randomUUID), '-') '.mph']); % '-' are removed because COMSOL does not like them in the filename mphsave(FEM, fname); end
8d8aa65a48203ce5aa2380c5826499419c5cfc3250d504283083ef10841e4628
MATLAB
245
8
function fibers = ungroup_fibers(fibersPerFascicle) fibers = vertcat(fibersPerFascicle{:}); if ~isempty(fibers) fascId = repelem(1:numel(fibersPerFascicle), cellfun(@height, fibersPerFascicle))'; fibers.fascId = fascId; end end
65b30f9a0cf7c4523b447f38712aa72d4837352f795ec022cfa86093f75120e9
MATLAB
247
12
function out = cholesky_factorization(in) % function cholesky_factorization() try out = chol(in,'upper'); catch [L,Di] = mchol(in); try out = chol(L*Di*L','upper'); catch out = (L*sqrtm(Di))'; end end
f9884798f493ac754f256b5a3c9652e19bbffcc4b25af53b0d068e62ebf51e49
MATLAB
247
9
function [e,h] = cat_entropy(ci) if ~all(floor(ci) == ci) error('need category data') end ele = unique(ci)' ; countcount = @(AA,BB) arrayfun(@(x)sum(AA == x), BB) ; h = countcount(ci,ele) ; p = h ./ sum(h,2); e = -sum(p.*log2(p),2,'omitnan');
fe4d14e09dd95018e8adcee23b2d88f860792ee6af4bcc655ea6060b5f3159a7
MATLAB
248
11
function c = getCorr(y,ypred) idxnan_y = any(isnan(y),2); idxnan_ypred = any(isnan(ypred),2); idxnan = idxnan_y | idxnan_ypred; y(idxnan,:) = []; ypred(idxnan,:) = []; c = sum((y-mean(y)).*(ypred-mean(y)))/(numel(y)-1)./(std(y).*std(ypred)); end
0505cb02ec8781a3034e8b7593bad3c0502c45a44b5dabd8de51d8cdebe11dfb
MATLAB
249
11
function c = getCorr(y,ypred) idxnan_y = any(isnan(y),2); idxnan_ypred = any(isnan(ypred),2); idxnan = idxnan_y | idxnan_ypred; y(idxnan,:) = []; ypred(idxnan,:) = []; c = sum((y-mean(y)).*(ypred-mean(y)))/(size(y,1)-1)./(std(y).*std(ypred)); end
21b28d804ec6409bdb57e248649d6e8ce74f4208a862d314d398324f2092c07c
MATLAB
249
15
classdef LinkGraph %LinkGraph: A graph with locations as nodes and location links as edges properties Valid = 0; end methods end function obj = LinkGraph( Loc_data, LocLink_data) end end
52bab43fa24788bf3d18afde551da46efad5498e933943e559c72498caca2a61
MATLAB
249
10
function save_parfor(fname, data) % Permits saving by functions whilst operating within a parfor loop var_name=genvarname(inputname(2)); eval([var_name '=data;']); try save(fname,var_name,'-append'); catch save(fname,var_name); end
7bf3ff710c008d81dbe71614bdca49ebb0fb69f6693878c73154f060d9dce57b
MATLAB
249
14
function q = q_for_n_activations(act, n) if isempty(act) q = Inf; return; end assert(numel(act)>=n, 'Fascicle has not enough fibers'); sorted = sort(act(act>0)); if numel(sorted)<n q = NaN; else q = sorted(n); end end
bcfad716dd8e3966262832bd9767b2647f0f8c105c5e259295e474cccbbaf5ce
MATLAB
251
8
function [out] = isRightC(im_str, c_request) %ISRIGHTC helper function, is the requested channel in the image string? c_request = uint16(c_request); [~, c_current, ~] = load.czi.getInfo.channel(im_str); out = c_current == c_request; end
ed74d9653b5383cb9af47920459dfe92064e97a7c3473ec2c2c22543ca12131e
MATLAB
252
8
function [out] = isRightZ(im_str, z_request) %ISRIGHTZ helper function, is the requested z-plane in the image string? z_request = uint16(z_request); [~, z_current, ~] = load.czi.getInfo.zpos(im_str); out = z_current == z_request; end
7d1a677bc49e1b48a195673b6a35296704dde1faf61aa1953945e18bfe677907
MATLAB
253
13
function str_TP = get_str_TP(p_vec) % Str describing the TP in inputs. % % Input % p_vec length-2 vector of TPs % % used in run_all_laser_stim str_TP = ['_TP', num2str(round(100*p_vec(1))), '_', num2str(round(100*p_vec(2)))] ; end
c8752ead2251142af5627c6da9bdf447ad49eb8b3b6e5b881f77999bdc290ef6
MATLAB
253
15
function print_to_serial(serial_dev, st, use_fprintf) disp(st) ; if use_fprintf %\r = enter st = [st, '\r'] ; fprintf(serial_dev,st); else for i=1:length(st) fwrite(serial_dev,st(i),'uchar') ; end end end
e0ef9a72f1c6b904fa5fa11924ab701dc488718b532483c32b6f060f7cf283c7
MATLAB
253
18
%% Generates mex file of the model function cd('Generate_mex_functions') mex_path = pwd; addpath(mex_path) tcut = 5000; % apply for transients TDatend = 20000; % length of model simulation ms makeCoderEm(TDatend,tcut); cd ..
f0800db71e49a3dfad3891c7dde9e923b0f4e45cd780e06af87a54058ad8c1bd
MATLAB
253
8
function [colors_p] = get_color_gradient(c_1, c_2, length) %GET_COLOR_GRADIENT get gradient between colors c_1 and c_2 colors_p = [linspace(c_1(1),c_2(1),length)', ... linspace(c_1(2),c_2(2),length)', ... linspace(c_1(3),c_2(3),length)']; end
d69850a01e0fea78b2d5412f5d536df2fd571dfe0ae9cb51345a47da7e7320f5
MATLAB
254
10
function [ Verts ] = TranslateVerts( Verts, vector ) %UNTITLED Summary of this function goes here % Detailed explanation goes here Verts(:, 1) = Verts(:,1) + vector(1); Verts(:,2) = Verts(:,2) + vector(2); Verts(:,3) = Verts(:,3) + vector(3); end
6e63fa01099d5d83f945158e4aee91dc2d4594afc9e899ae483941a5e8da958d
MATLAB
255
8
function self = GetClassifierData(self) if self.VerboseLevel > 0 fprintf('Creating clips and loading clip data to train the classifier...\n') end self = self.CreateClipTable('IncludeFeatures', true); self = self.LoadData('IncludeFeatures', true); end
38fdf97f17b95b62504b069b35d2b4355aa2715f472955e50db7d70616d2988c
MATLAB
256
12
clear all close all clc load nets mats = cat(3,Cij,Cij_rmvLong,Cij_rmvShort); cn = zeros(1,3); for i = 1:size(mats,3) % mats(:,:,i) = mats(:,:,i)/sum(sum(mats(:,:,i))); % cn(i) = f_CN_corr_aprox(mats(:,:,i)); cn(i) = f_CN_smp(mats(:,:,i)); end
5c4857cce1255c6230919f3c756053dee1d460ef0d22e15e0a1d8f6d7a119b7a
MATLAB
257
13
function out = getFourierSum(a0,a,b,x) % assert(length(a) == length(b),'a and b should be the same length') n = length(a); inds = 1:n; cosSum = sum(a(:)'.*cos(inds.*x(:)),2); sinSum = sum(b(:)'.*sin(inds.*x(:)),2); out = a0/2 + cosSum + sinSum; end
822ab6a25666d1af6792ce609e05ab1c5810ec85640101f93106a5d5bc8a492a
MATLAB
258
9
% Write table of betas to CSV for further analysis in python beta = util.load.beta_table(); %% Actual writing f_name = fullfile(util.get_paths().data_versioned, 'betas', 'full_beta_tbl.csv'); writetable(beta, f_name) %% Reread to see T = readtable(f_name);
fdfd66909bb97ba115d18fce336ac63efdf188b1bc3d0e215738bfa7c0f0de8a
MATLAB
258
9
function [ options ] = ODataWebOptions( ) %ODATAWEBOPTIONS Standard options for OData webread requests options = weboptions('Timeout', 60, ... 'ContentType', 'json', ... 'CharacterEncoding', 'UTF-8'); end
0207828211f4aaab387809cfe4489f691ca36eca11555033ab5eff294962bbd4
MATLAB
259
9
function fibersPerFascicle = group_fibers(fibers) [G, fascIds] = findgroups(fibers.fascId); fibersPerFascicle = cell(1, numel(fascIds)); for iG = 1:numel(fascIds) fascId = fascIds(iG); fibersPerFascicle{fascId} = fibers(G == iG, :); end end
02401951dac7d6f2f27cbadc3c42d8dc6814141696294bfa242d81c4e822d0e3
MATLAB
259
8
function p_alt = compute_p_alt(p_1from2,p_2from1) % Compute p(alt) for the input values of p(I_1|I_2) and p(I_2|I_1) given in % arguments. % p_1from2 and p_2from1 must have the same size. p_alt = (2.*p_1from2.*p_2from1)./(p_1from2 + p_2from1) ; end
1c0bd0ca00cee4edf9d56f2deac644a9d77ada14e40cb08a60581bdc898442b0
MATLAB
259
6
function [fiberActive, deltaQnC, qMaxnC] = load_thresholds(modelName, AS) modelNameAS = [modelName '_AS' AS]; nrnModel = 'MRG'; load(['data\Recruitment\' modelName '\' nrnModel '\recruitment_1_' modelNameAS '.mat'], 'fiberActive', 'deltaQnC', 'qMaxnC'); end
9b25ccc98f1effb1cb0797b402ed0a2c1099513c849b3e5cacfe32f50854ba41
MATLAB
259
8
function myopen(host,user,pwd) % myopen Connect to MySQL [mym utilities] % Example myopen('localhost','root','pwd') try a = mym('open',host,user,pwd); %#ok catch error('Could not connect to MySQL; check login parameters') end
7f80d7734a77c2fad0fc731ccf06e019aacb15265f66cf8acef34bd60e942db6
MATLAB
260
14
function index = getclass(str,strs) ind=find(ismember(strs,'KU')) if isstring(arg) for index=1:length(strs) if strcmp(arg,strs{index}) return; end error('Internal error. Contact developers'); end else
1fcde4b62749a7fecd5c97cbeb0243ae59b0dc74f588b03a1259f88339ef9611
MATLAB
261
7
function data_out = umap_Rmatlab(data_in) % data_in = #sample x #feature dlmwrite('data_inR.txt',data_in,'delimiter','\t','precision',4); unix('Rscript func_umap.R data_inR.txt > data_outR.txt'); %unix('python ./func_umap.py'); data_out=load('data_outR.txt');
106a9fbe1144e54afae74182191b394aedad76a13f9a529401b3190fcb466214
MATLAB
262
12
function Save(self) % Save annotations table to file AnnotationTable = self.AnnotationTable; currFolder = fullfile(self.ProjectPath, 'annotations', self.VideoName); if ~isfolder(currFolder) mkdir(currFolder) end save(self.FilePath, 'AnnotationTable'); end
5bcf20f4145baa0d04cb8f0ab793577b9753e57ae0dad661c8c7dcbc1f8a0fc9
MATLAB
263
9
function tri = tri_obj(model, object) fnames = load_stl(model, object); tri = cellfun(@tri_each, fnames, 'uni', false); end function tri = tri_each(fn) tri = stlread(fn); tri = triangulation(tri.ConnectivityList, tri.Points * 1e3); % Convert to um end
3776ca75539382dd01695fab0f870f2c595c71a55fcbff78a0c542f1b9ec89e8
MATLAB
267
8
function [cmap_interp] = interp_existing_cmap(cmap_orig,m) % From the colormap cmap_orig (with one color in each row) hsv = rgb2hsv(cmap_orig); cmap_interp=interp1(linspace(0,1,size(cmap_orig,1)),hsv,linspace(0,1,m)); cmap_interp=hsv2rgb(cmap_interp); end
464627b971273e6db199b994409740c9f0e2440c745244d0d0140b4aae084b12
MATLAB
267
7
dataPath = 'D:\ephys_results\processedData\audioVis'; rawFiles = dir(fullfile(dataPath,'*raw.mat')); for d = 1:numel(rawFiles) dat = load(fullfile(rawFiles(d).folder,rawFiles(d).name)); expRef = rawFiles(d).name(1:end-8); save2ONE(dataPath,expRef,dat) end
58475b1cf468a78a6b077a462fcd6acde805de3700eb5d7c634e797f1764137b
MATLAB
267
8
function print_beta_weights (beta, names) neg_idx = find (beta < 0); beta = beta (neg_idx); names = names(neg_idx); [sorted_beta, sort_idx] = sort (beta, 'ascend'); for i = 1:length (neg_idx) fprintf ('%g\t%s\n', beta(sort_idx(i)), names{sort_idx(i)}); end
92a9bc526e4ea06aa4752271b851b8bc7c5e526de5a32a0a5ac029cd4a4f7df7
MATLAB
267
9
function [beta_table] = beta_table() %BETA_TABLE Load beta table MAT file % OUTPUT: % beta_table: The loaded table of beta values m = load(fullfile(util.get_paths().data_versioned, ... 'betas', 'full_beta_tbl.mat')); beta_table = m.final_beta_table; end
8edbb39716c185d267b5e26e27cb7f06bfba53d12f51f556f1b67695c31fcce3
MATLAB
268
13
function [ y ] = f_wdt( x, mu, sigma, bases ) %UNTITLED5 Summary of this function goes here % Detailed explanation goes here den = 0; mean_b = mean(bases); for b=bases den = den + normpdf(b, mean_b, sigma); end y = normpdf(x, mu, sigma)/den; end
71676bbcdba4338ce2351d4b0e00c86a7b3703b58035bb7e67990a266c2faf3f
MATLAB
269
8
function [cor] = average_correlations(correlations) % AVERAGE_CORRELATIONS average a group of correlations % Averge through a tanh transformation cor.atanh = atanh(correlations); cor.average = tanh(mean(cor.atanh, 3, 'omitnan')); cor.tril = tril(cor.average, -1); end
9bbcef7e568134006354d7a9acc9b1f3c4717ee814afa0cc18343731b5466e4b
MATLAB
269
8
function tbprint(table) % tbprint List a few rows of MySQL table [mym utilities] % Example tbprint('junk') if ~istable(table) error('Table %s not found; use ''tblist'' to list available tables',table) else mym(['select * from ' table ' limit 20']) end
9d399a87524f81f3d1e0512e58782ef0be2faec8ed75b986c2b769d35c0d2ec6
MATLAB
269
8
function elapsed_time = finish_time(tic_handle, log) elapsed_time = toc(tic_handle); if nargin > 1 log.info('Elapsed time: %g minute(s)', elapsed_time/60); else fprintf('\t< Elapsed time: %g minute(s)\n', elapsed_time/60); end end
ce013d2025c0fd8cc57d4ef6cf787bc96563cc3746c7d4da81e70ba00bba4ef8
MATLAB
269
12
function [logdetA, G_chol] = logdet(G) if(~isdiag(G)) try G_chol = chol(G); logdetA = 2*sum(log(diag(G_chol))); catch logdetA = log(max(1e-20,det(G))); end else logdetA = sum(log(diag(G))); G_chol = diag(sqrt(diag(G))); end
71a4b51343d019b0b7fdefde8e2a62be5697b2878a7fe397881fbd9e5001e0f8
MATLAB
270
8
function [x_labels] = label_names(taste_str,additional) %LABEL_NAMES Get label names from taste and additional strings [T, C] = ndgrid(taste_str, additional); T = T'; T = T(:); C = C'; C = C(:); x_labels = cellfun(@(t,c)strcat(t,'-',c),T,C ,'UniformOutput',false); end
8de982b6e79919238edb6bd0bcc72b754e8d9c73731b6e45b32d5fcd5dea88cf
MATLAB
271
9
function [raw_xls_data] = readFile() %Reads selected .xlsx raw trace data file % User selects input file % Outputs raw_data variable [fileName, pathName] = uigetfile('*.xlsx'); [~,~,raw] = xlsread(fullfile(pathName,fileName)); raw_xls_data = raw; end
f68acfb4e88c45ffbd2453776a47d273fa452846ff451d3a21705e84280263b2
MATLAB
271
8
function h = plot_ci(x, lo, up, color) hold on; h = patch([x(:); flip(x(:))], [lo(:); flip(up(:))], color, 'FaceAlpha', 0.1, 'EdgeColor', 'none'); % Borders, not nice: %plot(x, squeeze(lo), '--', 'Color', color); %plot(x, squeeze(up), '--', 'Color', color); end
653125e35778cd403269038d3c643dd771d925339e7701e93d38d8f746fa9afb
MATLAB
272
5
function fname=tpfilename(tpfileparams,cycle,channel,frame) error('this must be re-done for FluoView'); fname=[tpfileparams.fnameprefix '_Cycle' sprintf('%.3d',cycle) '_' tpfileparams.myconfigstr 'Ch' int2str(channel) '_' sprintf('%.6d',frame) tpfileparams.extension];
c09d3fd70d9d6ca5d7348dd98738c08ff42206abf72741a28a869286bdff92f9
MATLAB
272
15
function ts = GetTimeStamps(self) self = self.Load(); if isempty(self.AnnotationTable) ts = []; return end if self.MultiCam ts = self.AnnotationTable.TimeStamp; ts = ts.(self.PrimaryCamera); else ts = self.AnnotationTable.TimeStamp.TimeStamp; end end
4e489378a01916cc6c256f4211bb0682df9a90bdf3ab4c17c93e9a8e8986e91f
MATLAB
273
9
function [ww, bb] = subGetModelWeights (model, clipping) ww = model.sv_coef' * model.SVs; % model weights bb = -model.rho; % model offset if (clipping == 1) ww (find (ww < 0)) = 0; elseif (clipping == -1) ww (find (ww > 0)) = 0; end % end subGetModelWeights
ae9d078873916606aa31408f6046d729c4dd31c607bf17bc5ce080bdb68ab3fe
MATLAB
273
18
function h = sfigure(h) % SFIGURE Create figure window (minus annoying focus-theft). % % Usage is identical to figure. % % Daniel Eaton, 2005 % % See also figure if nargin>=1 if ishandle(h) set(0, 'CurrentFigure', h); else h = figure(h); end else h = figure; end
e090f7dbad5975005e22d2bd15b3bd15b56ecd76d54ded02af063b65ef61b7af
MATLAB
273
9
function [im,fname]=tpreadframe(dirname,tpfileparams,cycle,channel,frame) %TPREADFRAME % read frame from multitiff % % 2008, Alexander Heimel % fname=[dirname filesep tpfileparams.fnameprefix '_t' sprintf('%.4d',frame-1) tpfileparams.extension]; im=sum(imread(fname),3);
fa0ca95702e64b92f148d7cde0f0fc96a3b273d4854bd9049e7343dbc81d15f3
MATLAB
274
9
%% Save all GIFT Montage images to current directory h = findobj('type','figure','-and','-regexp','tag','Explorer') for i = 1:length(h) tn = get(h(i),'tag'); tn(1:length('Explorer'))=[]; saveas(h(i),sprintf('ICA_Component_%03d.tif',str2double(tn)),'tiffn') end
9437d7972185e21f6946242322912c3cf0429bdf286302fe0b3e0317fc93bffb
MATLAB
275
5
function [featureMap,dScoresdMap] = gradcam(dlnet, dlImg, softmaxName, featureLayerName, classfn) [scores,featureMap] = predict(dlnet, dlImg, 'Outputs', {softmaxName, featureLayerName}); classScore = scores(classfn); dScoresdMap = dlgradient(classScore,featureMap); end
a811056884e09b81dd45ab7e83be901632ee807e190393e82b34c461a85ab470
MATLAB
276
10
function [p_1from2,p_2from1] = compute_TP(p_alt,p_1) % Compute p(I_1|I_2) and p(I_2|I_1) for the input values of p(alt) and % p(I_1)given in arguments. % p_alt and p_1 must have the same size. p_1from2 = p_alt./(2.*(1-p_1)) ; p_2from1 = p_alt./(2.*p_1) ; end
e12728732959a31c028bb7b0810da9367c3cff406fa742d98f7b060c848893cb
MATLAB
276
13
function [ scale ] = FetchODataScale(endpoint) %FetchData - Collect scale from a database. Returns struct % with XScale, XUnits, ..., ZUnits fields options = ODataWebOptions(); endpoint = [endpoint '/Scale']; scale = webread(endpoint, options); end
019c1362c1be5509f387eaebc6c59213e816f698e01f3fb274cbe32fda837e1d
MATLAB
277
7
function [identifier] = get_table_identifier(T, row, col) %GET_TABLE_IDENTIFIER an identifier for plot names from the variable and %row name identifier = strjoin([strsplit(T.Properties.RowNames{row},'_'), ... strsplit(T.Properties.VariableNames{col}, '_')], ' '); end
25861067d8a4db0928bbbf9b742ba26f7396cd90576c52595ddfda5aa1114726
MATLAB
277
12
function [yfit,X, P] = fit_linear(X, Y) %LINEAR_FIT linear fit to the data % remove the nans ind = isnan(X) | isnan(Y); X(ind) = []; Y(ind) = []; % fit to the remaining data P = polyfit(X, Y,1); fprintf('The linear fit: Y = %f * X + %f \n',round(P,5)) yfit = P(1)*X+P(2); end
30031f69dcae6c6f3e543129c109ac3e3758481ce2aab969355e063560aa44de
MATLAB
279
16
function [sgc] = my_sg_cent(W) %inputs % W weighted connection matrix % %outputs % co subgraph centrality %================================================= B = sum(W,2); C = diag(B); D = C^(-(1/2)); E = D * W * D; F = expm(E); sgc = diag(F) ; end
58404f2ef831f1fe735fde0637911f616030c84f7b75bfcb760cae49056b5b39
MATLAB
279
17
function [ll, p0, log_p0] = truncatedPoiss(rr, Y) ll = zeros(size(Y)); Y1 = Y > 0; Y0 = Y == 0; rl = rr < -30; ll(Y1 & rl) = rr(Y1 & rl); ll(Y1 & ~rl) = log(1-exp(-exp(rr(Y1 & ~rl)))); ll(Y0) = -exp(rr(Y0)); if(nargout > 1) log_p0 = -exp(rr); p0 = exp(log_p0); end
c1d47c0b7b7a62ddeab899ab6393dffd5adaba640cb9e58f944a75d604a5d2a9
MATLAB
279
19
function [x, fixedPoint] = Left_Right_Choice(FASTRAK, tolerance) x = 0; fixedPoint = 0; if abs(FASTRAK(5)) < 7 return end x = 1; if abs(FASTRAK(6)) < 15 if FASTRAK(5) > 0 fixedPoint = 20; else fixedPoint = -20; end else fixedPoint = 0; end
80c4b3a27fdacbf652444454d08bd4c9419cc2e0c220db644dfa131596050507
MATLAB
280
11
function [noise_raster] = generate_whole_raster_activity_matched_noise_3D(raster) [x,y,t] = size(raster); noise_raster = zeros(x,y,t); num_spikes_raster= sum(sum(sum(raster))); noise_raster(randperm(numel(noise_raster),num_spikes_raster)) = 1; end
7900aa02ddc1364da9bc612537aa9d7c970a3cd00e6fc6d00d15b0d544a65f64
MATLAB
281
10
function eps = permittivity(x, y, z, G) %eps = permittivity(x, y, z, G) on_membrane = (x >= G.Li-G.dx_min/2).*(x <= G.Li+G.Lm+G.dx_min/2) + ... (x >= G.Li+G.Lm+G.Le-G.dx_min/2).*(x <= G.Li+G.Lm+G.Le+G.Lm+G.dx_min/2); eps = G.eps*(~on_membrane) + G.eps_mem*on_membrane; end
09a067c33b07b92bc01ce65aec34933dfba33cfbc9eec9cfa1e01aedae46b209
MATLAB
284
13
function RunTtest close all clc %---FLAGS---% NH = [5.06 4.72 3.79 3.34 3.66 3.71 4.61 5.80]; CHL = [4.98 4.09 4.41 3.2 3.86 4.81 4.22]; [~,P,~,STATS] = ttest2(NH,CHL); disp(['p = ' num2str(P)]) disp(['t = ' num2str(STATS.tstat)]) disp(['df = ' num2str(STATS.df)])
2ccaa0124d268348ac2f43edfceb97e4ddac793382221da23c0d4b4b36a80aae
MATLAB
284
11
function BP = lowpass(timecourse, SamplingRate, f_cut, filterOrder) % BP = bandpass(timecourse, SamplingRate, low_cut, high_cut, filterOrder) if (nargin < 4) filterOrder = 2; end [b, a] = butter(filterOrder, [(f_cut/SamplingRate)*2],'low'); BP = filtfilt(b, a, timecourse );
a12138cc6d04535c58ab147983a1ac98db4fdb4c07c1cdcb7a5afc3cb9d5867f
MATLAB
284
8
Pwd=pwd; esc=Esc(); if ~exist(strcat(Pwd,esc,'Main.m'),'file') error('Please run program from folder with file Main.m in it'); end addpath(strcat(Pwd,esc,'DirectFEM',Esc,'FEM')); addpath(strcat(Pwd,esc,'DirectFEM',Esc,'Geometry')); addpath(strcat(Pwd,esc,'DirectFEM',Esc,'VTK'));
61a32c7bff79201f026da71668c7a62e3a8840bb29e9337b43b75250ad236f3d
MATLAB
286
9
function fiberActiveAll = load_activation_all_AS(model) fascIdsByAs = load_active_sites(model.paths); nAS = height(fascIdsByAs); fiberActiveAll = cell(nAS, width(fascIdsByAs)); for iAS = 1:nAS fiberActiveAll(iAS, fascIdsByAs(iAS,:)) = load_activation(model, iAS); end end
92e95e64a5624c1ff11335354498830fb496a5f474ae74812bc4a9f491c1bb08
MATLAB
287
8
function [summaryS, calClipT, revClipT] = EvaluateScorer(self, clipT) % clipT = GenerateClipScores(self, clipT); [summaryS, calClipT] = EvaluateCalibration(self, clipT); [revSummaryS, revClipT] = ReviewEfficiencyMetric(self, clipT); summaryS = MergeStructs(summaryS, revSummaryS); end
9a8d00f0e785f11c3625df6f4820d9579ac2455242ebeeb7888166c1525851ff
MATLAB
287
17
function h = vec(H) % h = vec(H) % % Vectorize matrix. % % H: Matrix % % $Revision: 1.2 $ $Date: 2015/01/06 17:14:57 $ % Original Author: Jorge Luis Bernal Rusiel % CVS Revision Info: % $Author: mreuter $ % $Date: 2015/01/06 17:14:57 $ % $Revision: 1.2 $ % h = H(:);
0c962d89061636176ac706480efdd56b533a7a633b7e301a65a463c848952b50
MATLAB
289
12
function b = VerifyTwoPhotonConfiguration b = 1; TwoPhotonGlobals; if isempty(TwoPhotonPlatform)|isempty(TwoPhotonSynchronization)|isempty(tpstacklabels)|isempty(tpstacktypes), b = 0; end; TPPreviewImageFunctionListGlobals; if isempty(TPPreviewImageFunctionChannelList), b = 0; end;
1db863ff8a0a21c69596301c673d0911c9d53321f5644ae06890613dc91f1b4e
MATLAB
289
14
function [ ] = write_empty_lines(filename, nb_lines,permission) % Add nb_lines empty lines in the file filename. if nargin<3 permission = 'a' ; end file_txt = fopen(filename,permission); for idx_line=1:nb_lines fprintf(file_txt, '\n') ; end fclose(file_txt); end