sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
d1edb5de51a19ec6142dc8e706bd366895deb9a4d1011eb443742c9a0719328d
MATLAB
560
31
% op_complexConj.m % Jamie Near, McGill University 2014. % % USAGE: % out=op_complexConj(in) % % DESCRIPTION: % take the complex conjugate of the data; % % INPUTS: % in = Input data in matlab structure format. % % OUTPUTS: % out = Output following conjugation. function out=op_complexConj(in); fids=in.fids; fid...
ffb0ba41dc299dd3831342a207472b8410843a9828179d86dffcac6afb748b5e
MATLAB
560
18
function dphidmu = rspnsFuncDeriv(trp, tau, a, b, sigma, k2) % Derivative of neuron's current-frequency response function % % Input: % trp - refractory period time % tau - membrane time constant % sigma - standard deviation of synaptic noise % a,b,k2 - constants provided ...
b0d233676c11630fe371dcee5927ca38b85927ce623f65bb05227fc7c7ab6faf
MATLAB
561
30
function varargout = isDAQmx_Assembly_added % Return true if NI .NET assembly has been added % % function isAdded = nidaqmx.isDAQmx_Assembly_added % % Inputs % None % % Outputs % isAdded - true if NI DAQmx assembly has been added. false otherwise % % % Rob Campbell - SWC 2022 assemblies = System.AppDomain.CurrentDomai...
91002c35650b7e91d9ce13ffbb1cee26a68d0ed17d92acabf90637ae96f11a59
MATLAB
562
17
function runThroughAllStimPoints % Present stimulus at each location for one second hZP = zapit.utils.getObject; % Get API object from base workspace if hZP.isReadyToStim == false return end for ii = 1:length(hZP.stimConfig.stimLocations) % Does not wait for a hardware trigger: st...
dbed7659288479da2ee54a6c97799d1fa8b975aaeac4134c60a1fbeddfbe5880
MATLAB
562
16
function [U, S, V, variances, pcaCoords, dataReduced] = doPCA(data) % This uses other function than the matlab default. Data has samples in % rows and variables in columns. % For reproducible results. rand('seed', 4); % PCA of centered data. Here 20 components only. [U, S, V] = pca(data - mean(data), 20); % Calc...
67bfc9394531c1ed0dae0ec3f84b2ad56e001144a167f01af7e29e9e5779d485
MATLAB
563
22
% op_CSIapplymask.m % Emile Kadalie, Sunnybrook 2025. % % USAGE: % out=op_CSIB0Correction_v2(in); % % DESCRIPTION: % Applies precomputed brain mask to MRSI data to spatially remove % surrounding lipids. % % INPUTS: % in = MRSI struct % % OUTPUTS: % out = MRSI struct with masked data function MRSIStruct = op...
b545c4b539510d1b2665345e6c547345fd283a1c97486a2b573fe1d493b450d3
MATLAB
563
17
function figure5(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(ba...
b86c907e7206132caf7725f6948c2ecacdb74136c8837d32b46ab45d4f20c378
MATLAB
563
24
%% check_dA_tree %% test 1 clf; hold on; axis off dLPTCs = load_tree ('dLPTCs.mtr'); for counterN = 1 : 10 for counter = 1 : length (dLPTCs{1}) tree = dLPTCs{1}{counter}; dA_tree (tree, rand (1, 3)); end end %% test 2 clf; dA_tree (sample2_tree, [1...
076bde752920e26e10ff606582ccfaacf4ea329e5e155c193ee9b7a0274cd579
MATLAB
564
19
function varargout = figureNB(x,y) if(nargin==0) x=8.9; y=8.9; end set(0,'units','centimeters'); SS = get(0,'screensize'); fig = figure('color','w','units','centimeters','ToolBar','none'); fig.Position = [SS(3)/2-x/2,SS(4)/2-y/2,x,y]; set(fig,'PaperPositionMode','Auto','Pape...
536b212f715531c4926a3530f80c9033ec46cc6ab33f6f443bd89f870989e05c
MATLAB
566
12
function [T, G, Map, Ang, Pos, wake, rem, sws] = load_mouse_data(data_path, mouse_name) % Load data from all electrodes [T, G, Map, ~] = LoadCluRes([data_path mouse_name '\' mouse_name]); Ang = LoadAng([data_path 'AngFiles\' mouse_name '.ang']); Pos = LoadPos([data_path 'PosFiles\' mouse_name '.pos']); ...
54b417096ab37e1af47d5ea8c49165f8388c9c5e239cb376d978abf3d4b2373f
MATLAB
566
17
% the pattern separation toolbox: analyse spike train ensembles % Copyright (C) 2022 Alexander D Bird function [RR_sum] = compute_RR(joint_distribution,input_distribution,output_distribution) id_norm=sum(input_distribution(:)); od_norm=sum(output_distribution(:)); jd_norm=sum(joint_distribution(:)); PXY=...
8c436413a07fba8824af61448441b9063a94a22aef9cc094d631b202693e1a65
MATLAB
567
25
%% check_flatten_tree %% test 1 dLPTCs = load_tree ('dLPTCs.mtr'); for counterN = 1 : 10 for counter = 1 : length (dLPTCs{1}) tree = dLPTCs{1}{counter}; flatten_tree (tree, 'none'); end end %% test 2 flatten_tree (sample_tree, '-m'); %% test 3 flatten_tree (sample_t...
d5ddf1edf0beb9cd8cc2177c29a16cfcf2290c12cb7f562636ec630283860263
MATLAB
567
21
function idx = LK_log2idx(logVec) % % LK_log2idx converts a logical vector into an n x 2 matrix with indices % that denote the start and end samples of true values in the logical % vector. % % Lukas Kunz, 2021 % check whether input is logical if ~islogical(logVec) error('Input is not logical.'); end % check wheth...
f6d871ec61ea94717226241cc67cdc4ceddf553ebbd81e09c2f080c52c4951a4
MATLAB
567
17
% the pattern separation toolbox: analyse spike train ensembles % Copyright (C) 2022 Alexander D Bird function [MI_sum] = compute_MI(joint_distribution,input_distribution,output_distribution) id_norm=sum(input_distribution(:)); od_norm=sum(output_distribution(:)); jd_norm=sum(joint_distribution(:)); PXY...
23999fd1e4509ec453faf95380a8c59c9688e1eeaf447a364d4346cc76355f79
MATLAB
568
32
classdef utils_tests < matlab.unittest.TestCase % Simple tests of the utils module properties end %properties methods(TestClassSetup) end methods (Test) function getDesktopPathExists(obj) obj.verifyEqual(exist(zapit.utils.getDesktopPath,'dir'),7) end end...
810ce70565c894c453dec00b8e5b32d1c0a1518e7ac1ba2dbc42e711b50d64c6
MATLAB
568
13
% load('PINES.mat') [~, stats] = predict(discovery, 'algorithm_name', 'cv_svr', 'nfolds', 1, 'error_type', 'mse'); % Haufe_pattern = cov(discovery.dat')*stats.weight_obj.dat/cov(stats.weight_obj.dat'*discovery.dat); % however, the covariance matrix is huge and we probably couldn't get it % done in this % ...
340c69b14b4c903d0891efff633bdd0b091d54a2fd52fcc4b493ac312df20aaa
MATLAB
570
36
%% clear; close all; clc fig = openfig('channel21Pulse0002s10Hzstim7_simplified.fig'); %% scaleX = 30000; dataObjs = axObjs.Children; Y = dataObjs(1).YData'; Y = Y(round(min(xlim)):round(max(xlim))); X = dataObjs(1).XData'; X = X(round(min(xlim)):round(max(xlim)))/scaleX; outData = [X Y]; ...
3aebc0e194044bb958ec6284833122fff047aa883c96d16650fcaaef7ae874b1
MATLAB
570
25
function [inter_mod_LD, rho, pval] = longDistanceConnections_modules(net, coords, comm) N = size(net, 1); ind_conn = find(triu(net,1)); [row, col] = ind2sub([N N], ind_conn); ED = EuclideanDistance([coords(row,1) coords(col,1)],... [coords(row,2) coords(col,2)],... [coords(row,3) coords(col,3)]);...
23079564af3e804e6e10f22ad31fc6615ffd813a38af3676abb94810d5b0353f
MATLAB
575
17
function figureS6(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(b...
9987dffd0bc663d0f7cbd78e48466ba8cc8d429bf25431cb6a1a33d1fc179ea1
MATLAB
575
17
function figure8(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(ba...
9e9c6ab33b869e2081156585caa9d34e5965f0d1db76872a636f7035ad398d9f
MATLAB
575
18
function figure3(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(ba...
aca4ce0f50093684916327c6df856eb12ecc466e04e1a8a2a0addde3865203e3
MATLAB
575
17
function figure9(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(ba...
231b7db8d87398d62685b8380d805e7b848248423dfc2d3b0103e7dedd638063
MATLAB
576
19
function r = corr2_new(a,b) %CORR2 2-D correlation coefficient. % R = CORR2(A,B) computes the correlation coefficient between A % and B, where A and B are matrices or vectors of the same size. % Class Support % ------------- % A and B can be numeric or logical. % R is a scalar double. % Example ...
90fef036fe4557887a9da77e738630f41fe33c8c88f694973782452d92304b34
MATLAB
577
15
function MRSIStruct = removeDimension(MRSIStruct, dimLabel) dimNumber = getDimension(MRSIStruct, dimLabel); dimLabels = fieldnames(MRSIStruct.dims); %updating MRSI parameters for iName = 1:length(dimLabels) curDimLabel = dimLabels{iName}; curDimNumber = getDimension(MRSIStruct, curDimLa...
fe649f3dd618bd2ef116a0366e5ef7ec5e8c738740c68f83ad63587c4c913827
MATLAB
579
25
function isReady = isReadyToStim(obj) % Return true if Zapit is ready to stimulate % % zapit.pointer.isReadyToStim() % % Purpose % Returns true if the scanners are calibrated, and the the % sample is calibrated, and a stimConfig file has been loaded. % % Inputs % none % %...
ffae0146e4c241e0c97ddebf0ef8d9a6d454d599e72d3b21e42d38aa5e29d426
MATLAB
579
21
function F = root_lambda_omega(x) % LS equations for solving instability growth rate and oscillation frequency % % Input: 2 unknowns % x(1) - instability growth rate % x(2) - oscillation frequency % % Output: l.h.s. of 2 equations % F(1) - LS eq 1 % F(2) - LS eq 2 global ...
630e7a82a9296b1ffc9951fd632dbaf0529703269eaeff4f3a7672c59952b922
MATLAB
580
28
function Y = FuncWoNGaussianCirc1D(P,X) %% function Y = FuncWoNGaussianCirc1D(P,X) % % 1-D circular Gausian function WithOut Normalization for orientation tuning % % P = [Amp,X0,Base,Sigma] --- parameters % Y = Amp*exp(-(X-X0)^2/2/Sigma^2)+Base; % % Note: X-X0 must be circularly ranged within -90~90 degree %...
01124a028ceec92165936ec6f0d4671f81c6f44a30122363e31dad020e958514
MATLAB
582
12
%example code for comparing CC1 decoding to optimal decoding % here 'cxdat' and 'lgdat' would be (num trials)x(num neurons) matrices. Each matrix entry % is one spike count response to one trial of stimulus. And 'stimtype' should be % (num trials)x1 matrix. Each matrix entry should be +1 or -1, which are labels ...
b23468d3000295657774ae9771faf5661e9fcb95fdcfbc5b1291ef0fe412ba0f
MATLAB
584
27
function [filtered_data] = filter_pass(data, fs, fl, fh, order) % operates on columns fv = []; if ~isempty(fh) fv = [fh]; filt_str = 'low'; if ~isempty(fl) fv = [fl, fh]; filt_str = 'bandpass'; end else if ~isem...
e54ca66965aca32801cb17eff2434e87aae15ba9a06cc0093293cdcecc5b0edf
MATLAB
584
32
function B = BinND(A,BinSizeVector) %% Bin A in N dimentions % BinSizeVector must be a vector with positive integers. % % % YC at ES lab % Created on Apr. 17, 2008 % Last modified on Apr. 17, 2008 %% Parameters nBinSizeVector = length(BinSizeVector); SizeA = size(A); nSizeA = length(SizeA); N = min(...
dbcd75009e5e834ba1eadc1b757d298ed06ee280a27c2b95a98ca698acbc67d1
MATLAB
587
18
function figureS4(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(...
ad287e1e868ce884bf11a3f8443bef99ed25760e13593b2de70fc06e724ba3d7
MATLAB
588
28
function ExpDesign = mkExpDesign(nSpace,nTemporal) % counterBalance spatial and temporal conditions. % Tries to minimize presentation order bias % nSpace = 36; nTemporal = 9; % output % ExpDesign: temporal sequence of [Run X Spatial Loc] % % [space, time] = BalanceFactors(1, 1, 1:nSpace,1:nTemporal); for steps = 1:3...
b4b2fbbbd073c01a7d927823ad653b1df828b57024de0cd6d8982d869ce77927
MATLAB
588
25
function setPath % Add all subdirectories to path % % (c) Corey Baron % Delete any parallel pools, because the workers won't get the new path otherwise if(exist('gcp')) poolobj = gcp('nocreate'); delete(poolobj); clear poolobj end topPath = mfilename('fullpath'); topPath = topPath(1:end-length(m...
bdf6a50878004da93b6d6bb000e9990c44659071ccf6588212636193a101400a
MATLAB
589
11
function allNeuronsOnOffTraces = getOnOffTracesCellArraysFromTable(StimTableNeuronStim) allNeuronsOnOffTraces = cell(1, size(StimTableNeuronStim, 1)); for iNeuron = 1: size(StimTableNeuronStim, 1) allOnOffTracesCell = cat(1, StimTableNeuronStim{iNeuron, 1}.paddedEpochStacks{:}); allOnOffTracesCell = cell...
c1b514d2a58c04294c13347c752a8fc7215e73daa9beb813b22f161363ba7adc
MATLAB
589
29
% RAD2DEG Transposes from radians to degrees. % (scheme package) % % result = rad2deg (x) % -------------------- % % Simple equation: result = mod ((x / (2 * pi)) * 360, 360) % % Input % ----- % - x ::vector: vector of values in radian % % Output % ------ % - result ::vector: vector of values in degrees % % ...
df3b7d70e6ce3dddcb1a6bd72c146d45bbfcb39e8a2daddde95085420460057b
MATLAB
590
21
function Hd = LFP_bandpass_filter %LFP_BANDPASS_FILTER Returns a discrete-time filter object. % MATLAB Code % Generated by MATLAB(R) 9.8 and Signal Processing Toolbox 8.4. % Generated on: 23-Oct-2021 15:27:22 % Butterworth Bandpass filter designed using FDESIGN.BANDPASS. % All frequency values are in Hz. Fs = 30000;...
a95eb9b754f91f7039767f7db61df01face408810b1eec7f4a70175f03ed9b9a
MATLAB
591
17
function figureS7(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(b...
a6453dfb4691b649013aebdc892e135bb50c49cc891946d6be5a3dcac57b01b0
MATLAB
592
26
%% CHIPS: Cellular and Hemodynamic Image Processing Suite % Welcome to CHIPS! %% % % <html><a href="./getting_started.html"><b>Getting Started</b></a> % <br> % Introduction to the basics of CHIPS</html> %% % % <html><a href="./id.html"><b>Image Data</b></a> % <br> % Documentation and examples related to image data</h...
ed5b719d163f69e0a83c459692e98b12c71987c0c5d291a47323f0fb5dc3db8c
MATLAB
592
23
function[Matten]=M_atten_tree(tree,thres) if (nargin < 2)||isempty(thres) thres = 0.13995; end N=length(tree.X); sse = sse_tree (tree); sseC = sse > thres * max (max (sse)); sseCM = sseC * 0; for counter = 1 : N sseCM (find (sseC (:, counter), 1, 'first') : ... find (sseC (...
5fcdf7ec67804a4cd59fd0882f0d8cd2abbeacdcbd400f489e463bea27104445
MATLAB
593
29
% DEG2RAD Transposes from degrees to radians. % (scheme package) % % result = deg2rad (x) % -------------------- % % Simple equation: result = mod ((x / 360) * 2 * pi, 2 * pi); % % Input % ----- % - x ::vector: vector of values in radian % % Output % ------ % - result ::vector: vector of values in degrees % ...
a8f57c4def0502c49695bba42c7d9ae62ece9e4d887179b96f053c259ccac1c4
MATLAB
593
17
function figureS8(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(b...
f9b0fa02c828dd8eca826a87e800868094e44bf8ab5e81044b318b51074e595b
MATLAB
593
22
function logVec = LK_idx2log(idx, num) % % LK_idx2log converts an n x 2 matrix with indices that denote the start % and end samples of true values into a logical vector of length num. % % Use as: logVec = LK_idx2log(idx, num); % % Lukas Kunz, 2021 % create a logical vector of length num logVec = false(1, num); % if ...
b0ec003115500bcce8f6b2c1b4356776da97730724e0e9d5480095f6acacf516
MATLAB
594
24
function outMatrix = LK_resizem(inMatrix, augFac) % % LK_resizem resizes matrix "inMatrix" using the augmentation factor % augFac. inMatrix is an n x m matrix. % % Output is the resized matrix "outMatrix". % % Lukas Kunz, 2021 % size of input matrix [n, m] = size(inMatrix); % initialize output matrix outMatrix ...
d18c5a73326ba316d5d38d90a62461fe194b0264c33c2ad557eccefa737b7dfc
MATLAB
595
21
function [ avgs ] = applyMasks(masks, img ) %APPLYMASKS Extract mask-wise averages from an image % masks an MxNxD matrix where D is the number of masks % img the MxN image to apply the masks to [M, N, D] = size(masks); avgs = zeros(1, D); if D == 1 avgs = mean(mean(img(masks))); else for i = 1:D ...
76836cc57e082b287b0e9718b3a6cd113cfe0274c16e40340f71c90a68974e5f
MATLAB
598
21
function oct = draw_oct(x, y, w, h, fill_col, line_col) % Plots an octogon centered at (x, y) of width 2w and height 2h % INPUTS % 1) x: x-axis value of octogon origin % 2) y: y-axis value of octogon origin % 3) w: width from origin to horizontal extremes % 4) h: height from origin to vertical extremes %...
bca7a212e51fe0749398c8764f5bb1e3cdf1504d6edf7ec495d90eb25620dc49
MATLAB
598
23
function [ Pnew ] = makepi( P, trans_prob) %makepi - Calculate probability matrix % % This function serves as basis for the MEX-file makepi_mex. Use codegen % makepi.m to compile the mex file. % % See also utils.hmm % Checks for P assert ( isa ( P, 'double') ) assert(all(size(P)<=[1 1681])); % Checks for trans...
4c7ec9b1391780c9f3bc3f909506625423d53894cc6d78459f2f4b347ac7979e
MATLAB
600
27
classdef Mock_RawImg < RawImg & IMock %MOCK_RAWIMG Summary of this class goes here % Detailed explanation goes here properties end properties (Dependent, Access = protected) fileFilterSpec end methods function Mock_RawImgObj = Mock_RawImg(varargin) ...
628a2f0d1a6a518ec9609b6765071e3a455eb3f9664ddf89300684be28c1408b
MATLAB
600
17
function [predictedClass,probability] = mdmDecoder(decoder,eegCovariance) distanceClass1=distance_riemann(decoder.classification.model.parameters{1},eegCovariance); distanceClass2=distance_riemann(decoder.classification.model.parameters{2},eegCovariance); %% Prediction of the classLabel and probabilities ...
58cc7db946281522b973a32b48cefdcdb830f67a1b2b494df76449eaf4219395
MATLAB
601
18
function figure4(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(ba...
e0042fd64565d2ac351af79a43280bfcc189f078f0c5e9732eeb8de6cea5d1ad
MATLAB
604
21
function [W_NBS, Clist_NBS, CID] = NBS(Wp, threshhold_NBS) % a simple implementation of the network-based statistics % Chuan Wp_NBS = Wp; Wp_NBS(Wp_NBS<threshhold_NBS) = 0; % Wp_NBS(Wp_NBS>=threshhold_NBS) = 1; % find Connected graph components [Cindx,comp_sizes] = conncomp(graph(Wp_NBS)); [CID, C_size] = s...
b414f6a7ddaeeb12e76b501551211f2dc183e56778ea852deec67761b343912c
MATLAB
609
26
% rf_timeReverse.m % Jamie Near, Sunnybrook Research Institute 2022. % % USAGE: % RF_out=rf_timeReverse(RF_in); % % DESCRIPTION: % Time-reverse the RF pulse. % % INPUTS: % RF_in = Input RF pulse definition structure. % % OUTPUTS: % RF_out = Time-reversed version of the input RF pulse. function RF_out=rf_...
c1533ae1eef5b6f1ed4b011ff4a4fd6d0c203d5f546c7a07ae2dad3221eb7eb2
MATLAB
610
23
% convolution and plotting % Last modification:02/16/2023 %% addpath('files') figure(1) % montage(final_I) Con_final = imgaussfilt3(final_I,1); % xz MIP xzMIP_F = squeeze(max(E_measure,[],1)); figure(2) subplot(1,2,1);imshow(flip(xzMIP_F,1),[]);xlim([0 15]) xzMIP_J = squeeze(max(final_I,[],1)); % subplo...
624b714429c7cfddc6fcf38742185b6b6937ec29e409c7bbff0ce231bca8179a
MATLAB
611
21
function [pred,beta,R2]=stReFit(params,stim,data,t) %% fracAlpha = params.analysis.optim.ridgeAlpha; nChan = getChanNumber(params); predictions = stPredictBOLDFromStim(params, stim); predBOLD = predictions.predBOLD; if size(stim,3) ==1 predBOLD = squeeze((predBOLD)); else p...
635bc45910f4960809c4447a16d2f78824a30120195a50844eef3104a24bda81
MATLAB
615
18
function figure5(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(ba...
c6d582f678a642b77736ec077e06fb13355ba2196d6b4507d79d9a6baf3625ae
MATLAB
615
24
function res = listExchBetweenCT(model, sol, lowerLimit) if nargin < 3 lowerLimit = 0; end %just list all communication with the [s] compartment sComp = find(strcmp(model.comps,'s'));%1 sMets = model.metComps == sComp; rxnsWithsMets = sum(model.S(sMets,:) ~= 0, 1) > 0; sum(rxnsWithsMets)%11529 fluxSel = sol.x >...
22cfc9954302a24af0de6ace20c82c914ae30dc0073ba10b3fbfb9d7ebb52407
MATLAB
618
23
% Spk = LoadSpk(FileName, nChannels, SpkSampls, SpikesToLoad) % % Loads a .spk file % % returns a 3d array Spk(Channel, Sample, Spike Number) % % nChannels will default to 4 % SpkSampls will default to 32 % Spikes2Load will default to [] - i.e. load them all,except noise function Spk = LoadSpk(FileName, nChannels, Spk...
261b0a69e7b9bdefca3b8698e08538765e0c519fe1e6d061977bbe8b22d2fafe
MATLAB
619
24
function rotMat = rotationMatrix(theta) % Return the affine rotation matrix corresponding to the angle theta % % function rotMat = zapit.utils.rotationMatrix(theta) % % Purpose % Return the affine rotation matrix corresponding to the angle theta % % Inputs % Theta - (in radians) ...
ec5c1c81dfbf819de176dce0f13bbdb2dd9fb24659e0715059c8161f212b0cf5
MATLAB
621
18
function filterOrder = LK_FIRFilterOrderEstimation_20220319(cfg) % % LK_FIRFilterOrderEstimation_20220319 computes the filter order for an FIR % filter using the Fred Harris rule, given some settings in the input % structure: % - Fs = sampling rate of the filter % - deltaF = transition band, in the same units as Fs % -...
e5d1ae97a357ccf2fc4f8234bde9731e72b6c1b79aa3fd9a573ec28366d64d0a
MATLAB
622
29
function [t1, C1, preloaded] = man_fit_v4(filename, peak_guess1, ran1, span1, preloaded) start = datetime; tic; %% Data reading if ~preloaded{1} [t1, ~, wl, spectra1, ~] = InsRead2DT_v6(strcat('..\Data\43rd experiment SSPv12\Data\',filename,'.ins')); else t1 = preloaded{2}; wl = preloaded{3}; spectra1 =...
041936431deafff31442974e46908579f247e7b992021bc0967ba207ea80a298
MATLAB
623
18
function selected_images = mkStImages(image_dir,nstim) image_list = imageDatastore(image_dir,'IncludeSubfolders',true); % get db of images fileNames = image_list.Files; randomlySelectedFiles = {}; % Initialize an empty cell array to store selected files for i = 1:length(nstim) pattern = sprintf('loc_%d_img', ...
eee918d36964fad17c92a2f46587f017e6caa49eeaa7a10969d15e8f2458c8ac
MATLAB
623
19
function resultant = AngularResultant( Theta, Radius, varargin ) % Given a polar data set, calculate angle and magnitude, as well as normalized magnitude, of the resultant. if nargin > 2, show = varargin{1}; else, show = false; end [xTemp, yTemp] = pol2cart( Theta, Radius ); [resAngle, resMag] = cart2pol( sum...
53005f2de736fc882afc097c6eda790f3eebf38be5413103c163253caf02ac19
MATLAB
624
22
function [hLine, hErrorPatch] = plotErrorPatch(hAx, x, y, error, lineColor, patchColor, varargin) if nargin >= 7 faceAlpha = varargin{1}; else faceAlpha = 0.5; end x=x(:)'; y=y(:)'; error = error(:)'; yUpper = y + error; yLower = y - error; yLower = yLower(end:-1:1); % Flip lower bound coordin...
73744bad49752d3f5c4284af40f3d4a177404ce54f9e93f242e97660e64d1628
MATLAB
624
33
clear;clc;close all T = readtable('XXX.csv'); X = T{:, 1:22}; Y= T(:,23); y = table2cell(Y); insket = strcmp(y,'Sal'); SVMket = fitcsvm(X, y, "KernelFunction","linear"); Wket = SVMket.Beta; Sigmax=cov(X); Sigmass=Wket'*Sigmax*Wket; Aket=Sigmax*Wket*inv(Sigmass) T1 = readtable('YYY.csv'); X1 = T1{:...
a24e8202a973ddca00ce8ea25fba9faf2e16109360365708b7f029f5b857fc5d
MATLAB
624
33
function storeLastFrame(obj,~,~) % This callback is run every time a frame has been acquired % % function zapit.pointer.storeLastFrame() % % Purpose % Stores the last acquired frame in an observable property % % if obj.cam.vid.FramesAvailable==0 return end tmp = ...
cba7f81bc6835f960295ddc660451b81dc0d92a7d511c4ccdeeadd5fef85d276
MATLAB
624
16
classdef test_harmonics < matlab.unittest.TestCase methods (Test) function designMatrixHasExpectedOrder3Columns(testCase) mask = true(4, 5, 3); basis = fmriPhase.harmonics.designMatrix(mask, [1 1 1], 3); testCase.verifySize(basis, [numel(mask), 16]); end ...
698513a90929a15c9824baf71037ad0420d88fd71eae799a5c5d09e9381d8b11
MATLAB
625
18
function figure8(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(ba...
ae6f8c3b8f2496f360140702d0da7c8a470e4da4f1631e94777b272b444e0501
MATLAB
625
48
%% Sigmoid Calculation % % Y=Bottom + (Top-Bottom)/(1+(IC50/X)^HillSlope) % clear % manually input parameters params = []; %% Calculate y values bottom = params(1,:); top = params(2,:); IC50 = params(3,:); slope = params(4,:); N = size(params,2); x = 1:0.1:20; y = zeros(N,length(x)); for...
ad828e20b8cd1fa694bcca1e089c80784ef6ff79dcaf67accb7c3ec6c7bc44d5
MATLAB
626
17
function figure7(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(ba...
ee4b3dd82c3a74cede0beb81ede320fa2e0ec341a611f5280e4deb1da8d99526
MATLAB
626
20
% the pattern separation toolbox: analyse spike train ensembles % Copyright (C) 2022 Alexander D Bird function [input_spiketimes] = independent_poisson(max_time,n_trial,rate) %INDEPENDENT_POISSON Generates an uncorrelated set of spike times. input_spiketimes=cell(n_trial,1); for trial_ind=1:n_trial these...
60a724694ee21b55a7aed610a2878bb8f4cddfd60ba92c94d205e73521c40e4e
MATLAB
627
18
function figureS6(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(b...
e34702dbd7bdd660ec0aa8d88215deb764b97431a8f878b82ffcad0d78309544
MATLAB
627
19
function figure3(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(ba...
20bf0e32868fc287e923f40febb23593127e8de64c5000b74b76c7811086c0ea
MATLAB
628
28
function fix_lighting(fig_handle,~) % Set the light source of the selected figure (default: current figure) to % originate from the viewing direction ("headlight"). If there is no light % source, a new one is created. % Get figure handle if nargin<1 fig_handle = gcf; end % Find the light object l_handle = findob...
526d462b4c27d99fa44078942ec71070be5aa8f73c73ca839167113e42595d39
MATLAB
629
12
function [ reduced_data ] = create_reduced_data( neuron_firing, p_neightbors_vec, number_of_reduced_dimensions_vec ) reduced_data = {}; reduced_data{1} = neuron_firing; for iteration_index = 1:length(number_of_reduced_dimensions_vec) reduced_data{iteration_index + 1} = reduce_data_by_lapla...
d2ddff2c4e4b4d57164de44ceccf354d6771d6a1a3e41d408156cb014d585cd3
MATLAB
632
29
function nifti = io_CSIload_nifti(niftiFileName) arguments niftiFileName (1, :) char {mustBeFile} end matlabError = []; try fileID = fopen(niftiFileName, 'r'); size = fread(fileID, 1, '*int32')'; catch matlabError end if(~isempty(matlabError)) ...
e0ca73dbc688de0453540b8e0c2b59188eae16827e20e6423752ed41f4a06060
MATLAB
632
24
function newDT = tableOutlier(DT,targetParam,outMethod) if notDefined('outMethod') outMethod = 'median'; end for jj=1:width(DT) paramName = DT.Properties.VariableNames{jj}; if strcmp(targetParam,paramName)%%|| isempty(params.(paramName)) if iscell(DT.(paramName)) rows = ~is...
0aae557e1da1f9464b6ea372fae2a2c7c4eb2b2acaaa1c4e16c26706eb154eba
MATLAB
635
26
%% check_flip_tree %% test 1 dLPTCs = load_tree ('dLPTCs.mtr'); for counterN = 1 : 10 for counter = 1 : length (dLPTCs{1}) tree = dLPTCs{1}{counter}; flip_tree (tree); end end %% test 2 flip_tree (sample_tree, 1, '-s'); tprint ('./panels/flip_tree1', ... ...
43af425c59a76c3501204c430fec238d37e8fcbdb30703332070924f2d8da495
MATLAB
639
24
function res = listExchBetweenCT(model, sol, lowerLimit) if nargin < 3 lowerLimit = 0; end %just list all communication with the [s] compartment sComp = find(strcmp(model.comps,'s'));%1 sMets = model.metComps == sComp; rxnsWithsMets = sum(model.S(sMets,:) ~= 0, 1) > 0; sum(rxnsWithsMets)%11529 flux...
90d44db6468ed17abbcf8ae811e808c200cb1ff39242a15f693ff260a45d9b79
MATLAB
639
25
%% check_sse_tree %% test 1 dLPTCs = load_tree ('dLPTCs.mtr'); for counterN = 1 : 100 for counter = 1 : length (dLPTCs{1}) tree = dLPTCs{1}{counter}; tree.Ri = 100; tree.Gm = 1 / 2500; tree.Cm = 1; sse_tree (tree, [], 'no...
f9f6b9daed07bac8e11bd9d7fc1e8561cd91cb37ee55c61aba587db32e181f6b
MATLAB
639
19
function figureS4(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(...
abd3918035c12159ecf9bc07ad613b1e121b423284eb5069616a7e7f2232ea31
MATLAB
642
26
% DEMOs reference %% pov1_tree pov_tree (sample2_tree, 'pov1.pov', [], '-b -s1 -w ->'); %% pov1_tree pov_tree (sample2_tree, 'pov2.pov', [], '-b -s2 -w ->'); %% pov1_tree pov_tree (sample2_tree, 'pov3.pov', [], '-b -s3 -w ->'); %% pov1_tree pov_tree (sample2_tree, 'pov4.pov', [], '-b -s4 -w ->'); %% pov1_tree pov_...
0aa690bd13f00bdb9e56575eae97a59b316c74b5718db9b11a866849de95b5ff
MATLAB
644
12
function [triangle_normals]=mesh_get_triangle_normals_new(m) % Calcuates the normals for each triangles. If the orientation of the % triangle edges is ccw to a viewer, then the normal points to the viewer. % USAGE: triangle_normals=MESH_GET_TRIANGLE_NORMALS(m) % Mirko Windhoff, 2009 % $Id: mesh_get_triangle_n...
33baf16904d945a28a9a1694c9bb09a2c169e6de07a6449762ddab5f8e4f2957
MATLAB
644
16
function [saveFolder, figDir, stimSetCellStr] = parseDatasetVars(datasetInd) switch datasetInd case 1 saveFolder = 'D:\Data_LGRTL\Tm9GCaMP6f_2016-2017\'; figDir = 'P:\Documents\Figures\Paper\Tm9\fffOld\'; stimSetCellStr = getStimSetCellStr(1); case 2 saveFolder = 'D:\Dat...
11d938aa5e4bdc1383ae09ee899639044fc4b244cb483ab91c62aff19f989b80
MATLAB
645
21
%% check_load_tree %% test 1 dLPTCs = load_tree ('dLPTCs.mtr'); spread_tree (dLPTCs{1}, [], [], '-s'); tprint ('./panels/load_tree1', ... '-jpg -HR', [10 10]); %% test 2 clf; hss = load_tree ('25HSS.swc'); plot_tree (hss, [], [], [], [], '-b'); tprint ...
ffbd575bf149995e3768dde11dca4856348c576ac8fcbe68e07b066c6dfecafc
MATLAB
645
20
function combine_unitary_spectra baseFolder = '/lustre04/scratch/nbrake/data/simulations/parameter_sensitivity_analysis2'; addpath('/lustre04/scratch/nbrake/code/simulation_code'); pars = zeros(9,2e4); m = 1e3; for iChunk = 1:20 filename = fullfile(baseFolder,['analyzed_results_' int2str(iChunk) '.mat']); lo...
a269b37829b379ba9c3aaf8a89067dc305c8cf20bbdd2af3491aea74a6fc0c04
MATLAB
648
26
%% READ ME: % % Written by Zachary Sanger, M.S. % University of Minnesota % Biomedical Engineering Department % May 16th, 2023. % IF YOU FEEL THERE ARE ERRORS, please reach out at sange019@umn.edu! % please cite if you use the code % % For informal use only, please double check your code for validity and proper imp...
ee929cce7b088411118fc0b13ea209807472707ccb2f63a89456e00fd1ee2e69
MATLAB
648
19
function [mouseDescriptor,mouseIdUnique] = GetAvgPerMouse(DataMatrix,LabelVec,mouseIDVec) mouseIdUnique = unique(mouseIDVec); mouseDescriptor = zeros(size(DataMatrix,1),length(mouseIdUnique)); labelUnique = unique(LabelVec); for m=1:length(mouseIdUnique) cnt = 0; avgPerMouse = 0; for k=1:leng...
17fd67426380f819c65c675fb4bef14f0434591b7826fd6cffb2c36a2652d2da
MATLAB
649
22
function [All, outVars] = calcTuningCircular(All, outVars) % settings numExps = numel(All); if ~isfield(All(1).out.anal, 'oriCurve') error("No ori curve, can't calculate OSI.") end for ind = 1:numExps [tune_result, var_result, curves_result] = tuningByCircular(All(ind).out.anal.oriCurve); All(ind).out.an...
6b0297beb3fcaf8f492ba7275972c25428470343f39e629ee0792e05206c102e
MATLAB
653
19
function figure4(dataFolder) if(nargin<1) error('Path to data required as input argument. Data can be downloaded from link in README file.'); end % Add paths for function execution myPath = mfilename('fullpath'); basePath = fileparts(fileparts(myPath)); addpath(fullfile(basePath,'auxiliary')); addpath(fullfile(ba...
163f06feb438bf8680a728ec73173eb680f4b507abb0e3d2b1192efa16965b15
MATLAB
658
24
%% check_spines_tree %% test 1 tree = resample_tree (sample_tree, 1, 'none'); spines_tree (tree, [], [], [], [], [],[], '-s'); tprint ('./panels/spines_tree1', ... '-jpg -HR', [10 10]); %% test 2 tree = resample_tree (sample2_tree, 0.2, '-d'); clf; HP = plot_tree ( ...
2fa8e697ebdd0ebff8171a9da1b3f2559b735c6c760ae7fe69b5fd59b3c0bfd9
MATLAB
658
18
% STACKS % % functions to deal with image stacks % % Files % fitD_stack - get cylinder diameter values from image stack. % imload_stack - load image into a 3D matrix. % load_stack - load stack file into a stack structure. % loaddir_stack - load images from a folder into a stack structure. % loadtif...
3ed34601ac7805961aa89d9af6a69e4493d99efff266361a6c6377fd0519f37c
MATLAB
658
22
%% check_elimt_tree %% test 1 dLPTCs = load_tree ('dLPTCs.mtr'); for counterN = 1 : 100 for counter = 1 : length (dLPTCs{1}) tree = dLPTCs{1}{counter}; iB = find (B_tree (tree), 1); dtree = redirect_tree (tree, iB); elimt_tree (dtree, '...
e5951d79b8785312d325e9a94bddd479f830815188e575c8e788d3424c28b4a5
MATLAB
660
29
function [outVars] = detectShotRedCells(All,outVars) numExps = numel(All); c=0; for ind = 1:numExps us = unique(All(ind).out.exp.stimID); for i = 1:numel(us) % s = us(i); h = All(ind).out.exp.stimParams.roi{i}; if h==0 htg=[]; else ...
69d141175ece23dabbb5805d1326dcc052fe1b7e316c0657c922133430841a78
MATLAB
661
28
function stage_base_calling() loadParameters; [ret,messages] = check_files_in_base_calling(); if ret fprintf('already processed puncta extraction\n'); fprintf('[DONE]\n'); return end %TODO: include base calling confidence etc. into this function % currently this min...
7652b0bfaa17403c3bcb5a3f7f7b3e572a09a75700a8cdf121112fbc9c535c88
MATLAB
662
20
function [blank_field,new_x,new_y] = draw_2(Image, Cores_Stats,radii) %create a blank image [row, col] = size(Image); blank_field = zeros(row, col); new_x = Cores_Stats(:,2); new_y = Cores_Stats(:,3); new_centers = [new_x, new_y]; % centers = Cores_Stats(:,[2,1]); % testing the location of the two aper...
e54aed184de7c0cf82685b12146749727a9161659c15a427d40ea6a757040220
MATLAB
663
23
%% check_elim0_tree %% test 1 dLPTCs = load_tree ('dLPTCs.mtr'); for counterN = 1 : 100 for counter = 1 : length (dLPTCs{1}) tree = dLPTCs{1}{counter}; tree.X (5) = tree.X (4); % setting coordinates same means tree.Y (5) = tree.Y (4); % making a zero length segment ...
4147b46274cec0023918313bfa27e1962f2932683f319dbdbe2b8e8db4a6d82c
MATLAB
666
24
%% check_MST_tree %% test 1 X = rand (100, 1) * 100; Y = rand (100, 1) * 100; Z = zeros (100, 1); tree = MST_tree (1, ... [50; X], [50; Y], [0; Z], 0.5, 50, 1000, [], 'none'); clf; hold on; axis off HP = plot_tree (tree, [0.75 0.75 0.75], [], [], [], '-b...
548e8137dba0eeba00170f16a9c74c4e67daaad18babbb5e3d0917449fd5de2b
MATLAB
666
23
%% check_syn_tree %% test 1 dLPTCs = load_tree ('dLPTCs.mtr'); for counterN = 1 : 100 for counter = 1 : length (dLPTCs{1}) tree = dLPTCs{1}{counter}; tree.Ri = 100; tree.Gm = 1 / 2500; tree.Cm = 1; syn_tree (tree, 100, 9...
3a32e0db0874d09ccca2d8eed55b58d0f1d47ffb54bb9bb63d2d678bb2462077
MATLAB
667
31
function devExists = deviceExists(devID) % Return true if an NI device of a given name is connected % % function devExists = nidaqmx.deviceExists(devID) % % Purpose % Returns true if DAQmx reports that a device called devID is attached to the PC. % If the device is not present, false is returned. % % Inputs % devID - S...
896655120d7a6187839f33c5e6f8090f99f661ae054663521896d37eafbb32dc
MATLAB
670
15
% Sample callback function for real-time processing of signal data. % data - double. new single data point % channel - string. channel corresponding to the data point. a value of % "test" is used to ensure the callback works. function sample_callback(data, channel) figure(5); if strcmp(channel,'signal') sub...
57553f3fe09f30a9d40c4dc3dccfdf7e3f99ec1e00a860db772a3054eae303cc
MATLAB
671
37
function E=error_pred(X,Y) E{9,2}=[]; R=X-Y; T=length(Y); E{1,2}=sum(abs(R))/T; % MAE E{1,1}='MAE'; Y2=find(Y==1); R2=sum(X(Y2)==1)/length(Y2); % TP: true positive E{2,2}=R2; % MAE E{2,1}='TP'; R3=sum(X(Y2)==0)/length(Y2); % FP: false positive E{3,2}=R3; E{3,1}='FP'; Y3=find(Y==0); E{4,2}=sum(X(Y...