sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
c51a263a3039f7a63f48a99f56c7413a1cd5815b2e7882e45e028112d577ae89
MATLAB
518
17
function fascSel = fasc_selectivity(model, Q, iElec) arguments model (1,1) Model Q = linspace(0, get_max_threshold(model)); iElec = []; end if isempty(iElec) fascIdsByAs = load_active_sites(model.paths); iActiveSites = 1:size(fascIdsByAs, 1); else [~, activeSites] = load_active_sites(m...
01591b7f547a26c7807a2bde686486dd0545c382ab7b9a5fb398d7d31cdb0c31
MATLAB
519
24
function [params, precomputedPortion] = scaleWB2(params) % i.i.d non-mean Gaussian over spike history coefficients & constant K = size(params.B,1); w_sig_idx = 1; b_sig_idx = 2; H = double(params.H); log_w_sig = H(w_sig_idx); log_b_sig = H(b_sig_idx); w = double(params.W); precomputedPortion.w_sig = exp(log_w_si...
488d745edaf091d8d6b213f8b4370a1b79145e0e1c43f650616d3a3f7bafe865
MATLAB
520
31
function FormatTableToTxtFile(t, path, varargin) % Write table t to file path p = inputParser; p.KeepUnmatched=true; addOptional(p, 'Append', false); parse(p,varargin{:}); formatted = FormatTable(t, varargin{:}); formattedJoined = strjoin(formatted, '\n'); [~, ~, ext] = fileparts(path); if isempty(ext) path ...
33a37d7f6b545593ebba8e1e8260570a01fd2fd3b86367c5858e8dd0c57809ed
MATLAB
522
25
function SaveClassifier(self) if isempty(self.Network) fprintf('No classifier has been trained!'); return end t = now; d = datetime(t,'ConvertFrom','datenum'); d.Format = 'yyyy-MM-dd_HH-mm-ss'; destFolder = fullfile(self.ProjectPath, 'classifiers', char(d)); mkdir(destFolder) if self.VerboseLevel > 1 fp...
3fea9a439f3ce2ad0df2c1a25a46bc027dbba8fd87de23d763b1cf604fd339c3
MATLAB
524
11
function filenames = listDirectory(dirPath) %LISTDIRECTORY Lists all folders in the `dirPath` that might contain stimuli (not train/test/image folders). stimuliSubfolders = dir(dirPath); folderNames = {stimuliSubfolders.name}; isFolder = {stimuliSubfolders.isdir}; isFolder = cell2mat(isFolder); filena...
5853a740698b887dd9b7dfca33da9aa2d5e0d41491667775701c52764ec41e8d
MATLAB
524
14
function [nifti_paths] = get_nifti_folders() %GET_NIFTI_FOLDERS Get the directory of nifti folders sub_1_dir = {'subcortical', 'cortical'}; sub_2_dir = {'bilateral'}; % {'left_hem', 'bilateral'} nifti_paths = cell2table(cell(length(sub_1_dir), length(sub_2_dir)),... 'RowNames', sub_1_dir, 'VariableNames', sub_2_dir...
a3e91386737f00963329907c4238159305a5b6580ea6e62cc29d178f76910b56
MATLAB
525
22
function pshape = slice_geom(tri, z, angleX, angleY) arguments tri z (1,1) angleX (1,1) = 0 % deg angleY (1,1) = 0 % deg end roundPrec = 6; planeP = [0 0 z]; x = cosd(angleX); y = cosd(angleY); planeV = [x y sqrt(1-x.^2-y.^2)]; segments = generic_cross_section(tri, planeP, planeV, roundPrec)...
ddd8c041fb59357065ebbe95cf2c1eddf2e760cb01aaff340ba1fd0aad981f8a
MATLAB
525
26
function [ BoundingBox ] = AddBoundingBoxes( Boxes ) %ADDBOUNDINGBOXES Given a matrix of concatenated bounding boxes, add them together %Boxes = % [MinX1 MinY1 MinZ1; % MaxX1 MaxY1 MaxZ1; % MinX2 MinY2 MinZ2; % MaxX2 MaxY2 MaxZ2; % MinX3 MinY3 MinZ3; % MaxX3 MaxY3 MaxZ3;] [nRows, nDim] = size(Boxes); iMins = 1:2:...
3533203bfae0d83f43f3b99e41a7db6e5ae56903e1cac7e775ea3c465f3ec14d
MATLAB
526
16
function dsetTag = find_dset(FEM, solTag) % Solution can have an existing empty dataset (isEmpty is true), in that case do not return it: if FEM.sol(solTag).isEmpty() dsetTag = []; return; end solinfo = mphsolinfo(FEM, 'soltag', solTag); dsetTag = solinfo.dataset; if isempty(dsetTag) % This happens...
38d85b6c9b9bdc798132cebe7155e01344819d463400c8edd10c06db77cd913e
MATLAB
527
25
function ds = DB2dataset(dbquery) % ds = DB2dataset(dbquery) % % Converts the results of a mysql search query to dataset format. % % Requires Statistics toolbox % % Daniel.Stolzberg@gmail.com 2014 narginchk(1,1); assert(ischar(dbquery),'Input must be a string.'); t = mym(dbquery); if isempty(t), ds = ...
ee642c74ed34dfad20b23e819aa7754e37c1d48c608c878916da5d5624fdc9ef
MATLAB
528
27
function W = generate_SingleMatrix(A,n_perc) fc_mat = A; % keep only positive values fc_mat = fc_mat .* (fc_mat > 0); fprintf('- top percent\n') fc_mat = fc_mat .* (fc_mat > repmat(prctile(fc_mat,n_perc,2),1,size(fc_mat,2))); fc_mat(fc_mat<0) = 0; fprintf('- kernel \n') W = normcorr(fc_mat', fc_mat'); W = sparse(do...
fa32621e716d81e54078b5eb2b09952b3cab91ff231b31e66648a4a4ca028f7e
MATLAB
528
89
function index = get_index; IDX1 = [11 18 31 13 19 17 26 27 3 23 15 25 2 22 9 21 30 28 7 24 4 20 10 12 6 16 5 32 8 14 1 29 33 34 36 37 38 39 42 40 41 35]; IDX2 = [60 67 80 62 68 66 75 76 52 72 64 74 51 71 58 70 79 77 56 73 53 69 5...
4254b1fbb068fb8ec5fc1605793b88ea3e0eb30ecafb8cce287c9f6c46af9677
MATLAB
529
16
function erpsinglecolorbar(haxes, hcolorbar, nlat) if isempty(hcolorbar) || ismember_bc2(0, hcolorbar) fprintf('erpsinglecolorbar() got an invalid colorbar handle...\n'); return end % % When single colorbar is requiered (custom scale) % cbpos = get(hcolorbar, 'Position'); cbwidth = cbpos(3); % as c...
0e9ed6044c5c4883ee5b0d9f7e4436cf89db2dbaf592e28be6db22537c3d8778
MATLAB
530
21
function xydiff = anglesubtract(x, y, angleFlag) % Subtracts the matrix y from the equally sized matrix x and returns a % value between -pi and +pi. This is valid if x and y both contain angular % data in radians. If angleFlag == 0, return a non-angular subtraction. if nargin < 3 angleFlag = 1; end if angleFlag =...
b8c98e270fea8f00b4ecc6c5dca7adbedd15807a4677099e97723622a6b5ce6c
MATLAB
530
16
% part of https://github.com/LudgerS/MRSartifactRemoval % % see https://en.wikipedia.org/wiki/Dawson_function % % dawson(z) = sqrt(pi)/2*exp(-z^2)*erfi(z) % = -i*sqrt(pi)/2*exp(-z^2)*(1 - exp(z^2)*w(-z)) % = -i*sqrt(pi)/2*(exp(-z^2) - w(-z)) % % where w(z) is the Fadeeva function % implem...
d6026a0fc61e0bde0918a48a76aa1ca6aa949553e184d542702cc89edce44e10
MATLAB
530
25
%% Connect to database DB_Connect; %% Display researchers mym('SELECT * FROM db_util.researchers') %% Add researcher NAME = 'First Last'; INITIALS = 'FL'; EMAIL = 'first.last@lab.com'; mym(['INSERT db_util.researchers (name,initials,email) ', ... 'VALUES ("{S}","{S}","{S}")'],NAME,INITIALS,EMAIL...
f0268be7aae3118044b994eac2a5f2a34c6a1b1554ed7567425e143ff0a3a1c8
MATLAB
530
21
function plotSpectrogram global DA gf axes(handles.axes2) cla % clear all current objects L = invoke(DA,'GetTargetVal',sprintf('%s.stimNPoints',gf.stimDevice)); y = invoke(DA,'ReadTargetVEX',sprintf('%s.Sound_data%d',gf.stimDevice,gf.side),0,L,'F32','F32'); NFFT = 2^nextpow2(L); Y = fft(y,NFFT) / L; f = (gf.f...
709e6672cfa48d93eca674b5e5163089c016895f0509966e5f71d9c587814ebc
MATLAB
534
20
%% AFFECTS ALL UNITS OF ALL TANKS % % Update units table so that units with low spike counts are marked as not % "in_use". This is useful to hide relatively unresponsive units from the % DB_Browser GUI and also from custom batch processing scripts. % % DJS 2015 units = mym('SELECT id,unit_count FROM units'); ind = u...
3b002d36ad83f6d1ad6ad6bacfd6f4cd7f15d2b473e359238b658d0ab4270e3f
MATLAB
535
13
function c0 = is_sodium_channel(x, y, z, G, dy_end) %c0 = is_sodium_channel(x, y, z, G, dy_end) dz_end = dy_end; c0 = (x >= G.Li).*(x <= G.Li+G.Lm).*... (y > G.Na_channel_start_y-dy_end/2).*(y < G.Na_channel_end_y+dy_end/2).*... (z > G.Na_channel_start_z-dz_end/2).*(z < G.Na_channel_end_z+dz_end/2) + ... ...
cf90f98a62da01007bc58c27b4b9feac2c7f249571b3db646f998d9746072e3a
MATLAB
535
11
function [] = buildGMLMCUDALibrary(lib_num) if(nargin < 1) kgmlm.CUDAlib.compileCUDAMexLibs(); %compiles the c++/CUDA code using a direct call to nvcc (note: this code is not matlab dependent) kgmlm.CUDAlib.compileCUDAMexFunc(); %compiles the MEX API functions that call the GMLM CUDA code kgmlm.CUDAlib.lin...
984a65f1b1e9bc697f0133e68651f1793d76675b07577f00af281220b57a8fe3
MATLAB
537
15
function tpfileparams =tpfnameparams(dirname,channel,params) % TPFNAMEPARAMS - Returns any parameters that might be needed to create filenames % % TPFILEPARAMS = TPFNAMEPARAMS(DIRNAME,CHANNEL,PARAMS)% % % Examines the directory DIRNAME and returns any information that would be % required for the program to open...
dbbbf63f46d239f34e87598678745a5120ad2fa91907e73b735c2de8a17aff5c
MATLAB
537
21
function fs_write_Y(Y,mri,fname) % fs_write_Y(Y,mri,fname) % % Writes volume Y to a Freesurfer's .mgh or .mgz data file. % % Input % Y: Data matrix or vector. % mri: Mri structure (read with fs_read_Y). % fname: Output file name. % % $Revision: 1.2 $ $Date: 2015/01/06 17:14:50 $ % Original Author: Jorge Luis Bernal...
f5ca03719edcf0a838b12a665ba3c5c492320bc844266dcdc2ecdcd7dc4ec26e
MATLAB
537
20
function [ RotMat ] = RotationMatrix( angle, axis) %RotationMatrix Return a matrix that rotates points around an axis by the specified angle iX = 1; iY = 2; iZ = 3; P = [axis(iX) * axis(iX) axis(iX) * axis(iY) axis(iX) * axis(iZ); axis(iX) * axis(iY) axis(iY) * axis(iY) axis(iY) * axis(iZ); axis(iX) *...
3c54da1bb1fd9fe52bced9948d7bea2181e2496dddc3f683a4dd840d310f564b
MATLAB
538
19
function erpcom = f_erp_save_history(erpname,fname,pname) % fname = [fname ext]; erpcom = sprintf('%s = pop_savemyerp(%s', 'ERP','ERP'); if ~isempty(erpname) erpcom = sprintf('%s, ''erpname'', ''%s''', erpcom, erpname); end if ~isempty(fname) erpcom = sprintf('%s, ''filename'', ''%s''', erpcom, fname); end if...
073450491cd46172cd587c867c9cb9abe7787a09889d3fae70c540394c3c2f9d
MATLAB
539
13
function TPPreviewImageFunctionListDeleteItem(i) % TPPREVIEWIMAGEFUNCTIONLISTDELETEITEM - Delete a function from PI function list % % TPPREVIEWIMAGEFUNCTIONLISTDELTEITEM(ITEMINDEXES) % % This function removes all PreviewImage functions with index values in % ITEMINDEXES. For example, pass [1 2] to remove the firs...
c298cfcb9b6bab4993b15e79854eb76500a964037d2b77e45e1a786f87885b9a
MATLAB
539
17
function [ dpDiff, cDiff ] = dprimeDiffFromBinary( isHit1 ,isHit2, isFalseAlarm1, isFalseAlarm2 ) %DPRIMEFROMBINARY Summary of this function goes here % Detailed explanation goes here hitRate1 = sum(isHit1)/size(isHit1,1); falsAlarmtRate1 = sum(isFalseAlarm1)/size(isFalseAlarm1,1); [dp1, c1] = getdprime(hitR...
03cc2c808c2ea9089804fd394241ee6075cf9e5b124f93cfd96e252dfe27e0a3
MATLAB
541
18
%% Merge two structures with matching fields into a new struct % The resulting structure contains all the same fields and entries, but as % a 1x1 struct. % % 6 December, 2021 function mergedStruct = mergeStructs(struct1,struct2) fields = fieldnames(struct1); for i=1:length(fields) if isstruct(...
375abd11a6f1c1321c955bcbc592065b4e144edf8c25d3bb40d54dc3af49b1e4
MATLAB
541
15
function pce_list = compute_pce_with_fingerprint(res_list, fp) % For each residual in a list of noise residuals, compute its pce correlation with a fingerpint. % INPUT: % res_list A list of residual file paths % fp the fingerprint % OUTPUT: % pce_list a list of PCE values pce_list = zeros(1, ...
48f0b8ec90f93db69a5bfa8d72292590e1de93cf7619b6496cd6911ee6f92593
MATLAB
543
26
function fncdirs = getFncDirs(niipath) % fncdirs = getFncDirs([niipath]) % % Returns valid functional directories % % Daniel.Stolzberg@gmail.com 2016 if ~nargin niipath = pwd; if ~strcmpi(niipath(end-2:end),'NII') niipath = fullfile(niipath,'NII'); assert(isdir(niipath),'Unable to find NII pat...
a79e954751f47a41b8988d860d684d6cccef31bb5f2db861f2f82a993052e5a7
MATLAB
543
27
function copyPrairieViewData(oldtarget, newtarget, ignoredriftcorrect, doit) if nargin<3, ignoredriftcorrect = 0; end; if nargin<4, doit = 0; end; d = dir([oldtarget filesep '*']); for i=1:numel(d), if ~d(i).isdir, if ~strcmp(d(i).name,'driftcorrect') | ~ignoredriftcorrect, fname_source = fullfile(oldtarget,...
a357ac3f93aeb929558b8eb6f9c2f95cefc92ebd0b9efee4c311d003731459dc
MATLAB
544
19
function scalar = ScalarForUnitConversion( source_units) %SCALARFORUNITCONVERSION Given metric units, returns the scalar to convert %to meters scalar = 1; if strcmpi(source_units, 'nm') scalar = .000000001; elseif strcmpi(source_units, 'um') scalar = .000001; elseif strcmpi(source_units,...
86e3a200d47f422a21d5c720467ed691d2dd3c23d8c49bf58116ae19ca53c57b
MATLAB
545
22
function M = Qdec2num(Qdec) % M = Qdec2num(Qdec) % % Attempts to convert the two dimensional cell string array Qdec to numeric % matrix M. % % Input % Qdec: Two dimensional cell string array of Qdec data (eg. read with % fReadQdec). % % Output % M: Numeric matrix (without the name of the variables). % % $Revision: 1.2...
f506192d48e82e2529ca751cbde26fce2558ccd5aecfcd47f7ec52e8ee9ae8ee
MATLAB
548
20
function refdirname = analyzetpstack_getrefdirname(ud, dirname) %dirname, getpathname(ud.ds), namerefs = getnamerefs(ud.ds,dirname); match = 0; for i=1:length(ud.slicelist), nr = getnamerefs(ud.ds,ud.slicelist(i).dirname); mtch = 1; for j=1:length(nr), for k=1:length(namerefs), mtch=mt...
47b60d10058d6e8e70d73dbb3bc277bfc5ec291869b7b906bd6cb6fb93b4626e
MATLAB
549
24
function [ Faces ] = FlipFaces( Normal, Verts, Faces ) %UNTITLED Summary of this function goes here % Detailed explanation goes here for(iFace = 1:size(Faces,1)) iA = Faces(iFace,1); iB = Faces(iFace,2); iC = Faces(iFace,3); A = Verts(iA,:); B = Verts(iB,:); C = Ve...
19939ea365a807ee4dfb4b8287863018697d4ed8e9b0c84b9cd09c1f1c0f49fb
MATLAB
551
27
function [mse,rmse] = compute_mse_rmse(x,y) % Compute mean squared error and root mean squared error between vector x % and y % Input % - x, y : vectors of same length % Output : % - mse : mean squared error % - rmse : root mse [x,Sx] = make_col_vector(x) ; [y,Sy] = make_col_vector(y) ; if max(min(Sx),min...
8f839f5a76f8fb72368bce6381cfda49600e61ebca79248a08d833c6b52b6a34
MATLAB
552
25
% PURPOSE: build the default Classic ERPLAB working-memory structure % % FORMAT: % % s = erplab_default_memory_struct(mshock) function s = erplab_default_memory_struct(mshock) if nargin < 1 || isempty(mshock) mshock = 0; end erplab_default_values s = struct('erplabrel', erplabrel, ... 'erplabver', erplabver...
3c7c25eabf3a16a0ca7cc94283a629a18dfd1bc1199bb2583aa5784f39e1b08c
MATLAB
553
19
function h = setFigureHandle(h, x_width, y_width, margin,num_axes) % Sets handle properties according to figure size % INPUT: h: Figure handle % figure size displayed on screen real_x_width = x_width*num_axes; set(h, 'Units','centimeters', 'Position',... [0 0 real_x_width+(2 * margin * num_axes) y_width+2*margi...
fd0da1d781e64b2c446d66c87e8cdf6c4c506828b6dc48e6caa10134564bee34
MATLAB
553
28
%% cd(dataPath) load(fileNames(len).name) %% RandTrials = StoreType==2; Predict = StoreType ==1; ControlPredict = StoreType ==3; Expected = [1 diff(StoreX2(Predict))]; Sequence = StoreX2(Predict); ExpectedA=abs(Expected); AlwaysZeros = sum(sum(Store,1),3)==0; Store= St...
bb5d9f28634268fe470af2abc1ebee370c207610c8701d8b9de0dcfaf95864d0
MATLAB
554
14
function [x, y, z, r, s] = get_fib_geom(fibers, fibId) % GET_FIB_GEOM returns the geometrical data of a fiber from fiberPop % COORDS = GET_FIB_GEOM(fiberPop, fascId, popId, fibId) returns a list % with 3d coordinates, radius and longitudinal shift of the fiber with ID % fibId from the population with ID po...
4e2c5a4f59c0db88de245fdc4379d8f79e9ce1ef3be37fe64a2ee98d1565437f
MATLAB
557
36
clear all close all clc load('../../data/Streamline_60_group.mat'); N = 40; D = 0.25; M = round(D*N*(N - 1)/2); w = normrnd(0.5,0.15,M,1); w(w < 0) = -w(w < 0); K = 4; G = N/K; p = 0.8; A = zeros(N); ci = repmat(1:K,[G,1]); ci = ci(:); for i = 1:M [u,v] = find(triu(A == 0,1)); idx = (v - 1)*N + u; end % % ...
f63e0d2b82333889542bbc00498c7b5a7a15db594e05aaa4840024fa5e51ac77
MATLAB
561
10
% REMOVE BAD CHANNELS - LOW SIGNAL Formula % function low_sig_range_all_channels_val_logical = bst_ast_remove_bad_channels_low_signal(all_amp_data) %take out any channels with low signal more than 10% of the trials low_sig_range_all_channels_val = all_amp_data(3:end,2:end) <= 40; low_sig_range_all_channels...
ff4167aabf0ec6d27ca89fd21c7c42e9321dbb8e33c045c6e1e5a74550d5cfb2
MATLAB
561
12
function [session_info] = get_session_info(session_str) %GET_SESSION_INFO Get session information from the folder name string session_tokens = cellfun(@(x) regexp(x,'session(\w*)_(\w*)', 'tokens'), ... session_str, 'UniformOutput', false); session_info = cellfun(@(x) {str2num(x{1}{1}), x{1}{2}}, ... session_tok...
931f73b8d535aeda2e727e17e9ca7bda467faa0f3c23234b060ac4be54c743d0
MATLAB
563
17
function recruitmentCurve = logistic_recruitment_curve(Q, recruitment) errFun = @(k_x0) sum((logistic(k_x0(1), k_x0(2), Q) - recruitment).^2); k_x0 = fminsearch(errFun, [1 1]); Charge = linspace(0, 1/k_x0(1)*12)'; Recruitment = logistic(k_x0(1), k_x0(2), Charge); [Recruitment, iUnique] = unique(Recruitment); % remove...
0ec633d57bd8994093ee72c358a9e27d16cd434faf156f5f023839487f7f2e66
MATLAB
564
20
function maxQ = get_max_threshold(arg, quant) % Can get as input the model or the already loaded fiberActiveAll % the second argument (quant) is optional if iscell(arg) fiberActiveAll = arg; else fiberActiveAll = load_activation_all_AS(arg); end fiberActiveAll = vertcat(fiberActiveAll{:}); if nargin >...
ebcc841ca8fcac9f1954f623a5d73f97ae876805161337ec271ee29915485f9b
MATLAB
565
14
util.clearAll; beta = util.load.beta_table(); %% Get the first three letters representing the animal only_animal_idx = char(beta.animal_idx); only_animal_idx = categorical(cellstr(only_animal_idx(:,1:3))); beta = addvars(beta,only_animal_idx,'Before','animal_idx'); %% write beta table to mat and csv files outdir = fu...
3d8982f6aa0f61a315fc3921ffaa75773fd7c04997dfbbed6496358e05aa3a46
MATLAB
566
19
% PURPOSE: Loads current ERP structure (if any) from de the workspace. % Otherwise, load ALLERP(CURRENTERP); Otherwise ERP = []; % % To avoid clearing an already filled ERP structure after an interrupted % process (for instance, after an error) % % *** This function is part of ERPLAB To...
958a445f0f945799a9024ec31ff1fb0715c893a767c0b1db5f768cedb024fc75
MATLAB
566
14
function [most_consistent] = get_frequent_partition() %GET_FREQUENT_PARTITION Summary of this function goes here % Detailed explanation goes here % read the communities module_csv = fullfile(util.get_paths().python_datadir, 'repeat_modularity',... 'unique_partitions.csv'); module_idx = readtable(module_csv,'ReadR...
7ee18d579a869c7c3ae73626e63b568e24ce7b16fde28a367a05f06d542e9af8
MATLAB
568
26
function [TheoryWaveVol,TheoryWaveVol_largeWave]=speed_by_LR(k,alpha,f) % compute theoretical wave speed by linear regression % 1. use the whole range q=k/(2*pi); Y=f'; A=[ones(length(q),1),q']; sig=max(abs(alpha)); % w=exp(-alpha.^2/(2*sig^2))'; A=w.*A; Y=w.*Y; b=(A'*A)\(A'*Y); TheoryWaveVol=-b(2); % 2. only use the...
3ef008bb3d1af0f1cd389d9f7c67fbfacf8dcf016720566cc6ebd4c2aae7bdf6
MATLAB
569
25
function theta = SCM_fwdSim(Ts,T0,a,zeta,theta0,N) %%% 26-01-23 first commit %%% iterative simulation of the sine circle map with %%% zeta = dithering level %%% Ts = average stimulation period %%% T0 = period corresponding to the natural frequency %%% a = stimulation amplitude %%% N = number of stimulation pulses ...
84cbc94deae2ecaec580a3576dc299121d15a862b26c42170caf98a6e141d870
MATLAB
569
18
function [ MappedVerts, MappedFaces] = RemoveUnusedVerts( Verts, Faces ) %REMOVEUNUSEDVERTS Given a list of verticies and faces, returns a list %of verts with unused verticies removed and face indicies adjusted UsedVerts = unique(Faces); %Returns sorted list UnusedVerts = setdiff(1:size(Verts,1), UsedVerts); ...
a6ddc9fe5482f2584ae732a063522d21514b5ebf8ac3bfc13654f42dbb5a7310
MATLAB
569
22
function maximize(fig) % MAXIMIZE Size a window to fill the entire screen. % % maximize(HANDLE fig) % Will size the window with handle fig such that it fills the entire screen. % % Modification History % ??/??/2001 WHF Created. % 04/17/2003 WHF Found 'outerposition' undocumented feature. % % Original...
d27f1c74f5f7db2548ddf6b467d3b8b880b39540fb9d250cec5c3c9a1f8491ff
MATLAB
569
21
function [ out_struct ] = readin_mammal_dat(filename) if isfile(filename) ll = load(filename) ; else error('file does not exist') end % spatial out_struct.dist_mat = squareform(pdist(ll.cents)) ; out_struct.leng_mat = ll.LmatT ; out_struct.node_adj = get_seg_spatial_adj(ll.seg,1:200,6) ; out_struct.cents =...
05e8cf0b9ed4a58f73f6e4798d1ed5d86f89ecb01e92cd512ad62a1b7975bcb3
MATLAB
574
28
%% Create folder structure S = {'BASS','BLACKFOREST','CC','LEIA','LUKE','MARIE','MINNOW','PAUL','HALIBUT','GEORGE','TROUT','BISCOTTI'}; G = {'NH' 'ED' 'ED' 'ED' 'NH' 'NH' 'NH' 'NH' 'ED' 'ED' 'ED' 'ED'}; % groups C = {'RSS'}; % conditions for i = 1:numel(S) r = [G{i} '-' S{i}]; if ~isdir(r), mkdir(r); end ...
6b90b49fec2ccf6f807f10406d82052049c64279d3843ddacd18d5afd8f0348f
MATLAB
575
23
% Splits a string into a cell array of strings. % % Input arguments: % string: % a string to split into a cell array % adjoiner: % string separating each neighboring element % % See also: strjoin % Copyright 2008-2009 Levente Hunyadi function strings = strsplit(string, adjoiner) if nargin < 2 ...
a13efebfc0f01fcb86312a1a41647b9819e5d348ae80b6add1e0dce00ccedeef
MATLAB
575
19
function motif = one_neuron_motif_classification(n1, n2, t1, t2) % All neurons are the same % Assume t1 <= t2 vec = [0,t1,t2]; n_distinct_times = length(unique(vec)); if n_distinct_times == 1 % All neurons and times are the same motif = 1; elseif n_distinct_times == 2 ...
f3d69654d9b0eb4486bcba8816a5cf7f9e5bbd9bb1f0132a268d613da93e6eec
MATLAB
576
26
function self = LoadSavedClassifier(self, varargin) parentFolder = fullfile(self.ProjectPath, 'classifiers'); if nargin == 1 subfolders = GetValidSubFolders(parentFolder); version = subfolders.name{end}; else version = varargin{1}; end srcFolder = fullfile(parentFolder, version); if ~isfolder(srcFolder) ...
ffb5f2df37574548b98ae6aff2f21aaeb34d8b76a4357e3540a299ff725c6b37
MATLAB
577
11
function [stimPatch] = plotRegionForStimulus(ax, stim_on, stim_off, y_0, y_1) stimPatch = patch(ax, [stim_on stim_on stim_off stim_off], [y_0 y_1 y_1 y_0], [0 0 0]); plot(ax, [stim_on stim_on ], [y_0 y_1], ':k', 'linewidth', 0.5, 'HandleVisibility', 'off'); plot(ax, [stim_off stim_off], [y_0 y_1], ':k', 'linewidth',...
26cd6e42f2a639f2606e7609f06da7faa84650f881db1f7390a91ed5b8d3c593
MATLAB
578
21
function [Mask] = create_mask(mask,signal_size) % Create mask using image-analysis tools % % Convert the mask into a logical one mask = ~isnan(mask); % Find pixels that are connected to one another B = bwconncomp(mask,8); % Select only parts that are sufficiently large MASK = cellfun('length',B.PixelIdxList)> signa...
99da6f9e1e05d7978cbc26c44ab16c69a2a1cc064ce639c5851c4b87413b1e08
MATLAB
579
24
function out = tongueMask_slopeBased(w,p,q,tol_w,tol_dw,df,spanFact,method) %%% mask for Arnold tongue p:q based on rotation number w %%% (see Methods section of the paper for more details) %%% 26-01-23 first commit [n_a,n_f] = size(w); w_sm = NaN(n_a,n_f); dw_sm = NaN(n_a,n_f); dw_sm(:,1) = zeros(n_a,1); dw = Na...
c079b7765d8051d2f763493500cd5aa51ede243d841ac632fb82f30b9ec4ded9
MATLAB
581
23
function create_logfile_SanesLab %Custom function for SanesLab epsych % %This function creates an log file for documenting errors and other %important information. % %Written by ML Caras 7.28.2016 global GLogFID GVerbosity CONFIG GVerbosity = 2; %see vprintf.m for more info %Close any existing log files if ~isempty...
15c1aec7421459ea8abec966f2ff36c0e6cd9acdd7d07f1d873f85ba11b068e5
MATLAB
586
20
function tpfileparams=tpfnameparams(dirname,channel, params) tpfileparams.extension = '.tif'; fname = dir([dirname filesep '*_t*1.tif']); if isempty(fname), tpfileparams.extension = '.TIFF'; fname = dir([dirname filesep '*_t*1.TIFF']); if isempty(fname), tpfileparams.extension = '.tiff'; fname = dir([d...
3ca62977a445a8f4277ea055af5f0425cc9e31ed57c98d28680eb751005d8974
MATLAB
587
16
function [regions_T] = select_regions(T, region_names, hemisphere) %SELECT_REGIONS select a set of regions within a hemisphere in the beta %data table % INPUT: % T: the beta data table with region_names and hemisphere information % region_names: a cell string array with the name and order of ROIs % hemisphere: th...
c9ca923ab3168c69844a959e5d159c67d628d2b2a25254237da80bcf5ab87a31
MATLAB
587
20
function [ dataSmooth ] = gaussSmooth( data, Fs, sigma_ms ) %GAUSSSMOOTH Smoothes inputdata with sampling rate Fs along first dimention with a gaussian %kernel of sigma milliseconds % % Mar 2021: modified to use smoothdata.m, P. Jendritza sigma_s = sigma_ms/1000; % one sigma in seconds gCut = 2.5; % gauss window is ...
0e2757a880b9c03241d0b3de1c7589f0bf06eba2c09294769c3a0b439b36687b
MATLAB
588
19
function motif = one_neuron_motif_classification_3D(x1, x2, y1, y2, t1, t2); % All neurons are the same % Assume t1 <= t2 vec = [0,t1,t2]; n_distinct_times = length(unique(vec)); if n_distinct_times == 1 % All neurons and times are the same motif = 1; elseif n_distinct_times...
1750d3860fc760d9a17e1284e9d1af01db7a539948faf3fd78021940de108b90
MATLAB
588
18
%% Batch offlineSpikeDetect tank = 'D:\KingKong_Cloud (HIDEME)\BIG_DATA\ChronicEphys\HANSOLO\HANSOLO_20160519'; blocks = TDT2mat(tank); minSpikesPerSecond = 1; %% for b = blocks fprintf('Processing ''%s'' of tank ''%s''\n',char(b),tank) d = TDT2mat(tank,char(b),'NODATA',true,'VERBOSE',false); d = datevec...
0124e555765cc1379420cec99c53a1a4a5339af03d15225046278e6bd8474496
MATLAB
592
37
function h = drawPerformance_bar(X, ax, color) if isempty(X) h = nan; return end % Specify required number of stimuli Nt = 6; % Get signal levels attns = unique(X.Atten); nAttn = numel(attns); % Preassign N = zeros(1, nAttn); Y = zeros(1, nAttn); h = nan(1,nAttn); % Get performance for j = 1 : nAttn r...
e7c8dd44b17178491c7b37fc3781229d3607ee06afe0cb156da5c2e314a23fd4
MATLAB
592
41
function X = checkFixate(FASTRAK, initBuffSize) % [X,fixedPoint] = checkDuration(currentValue, [initBuffSize]) % %Takes in the current region number and adds it to a list of default size %20. When the list fills up with identical values X = 1. % % %Stephen Gordon 2016 persistent P i X = 0; if nargin == 1 init...
a35b40a2971447af38c1d24269009a8d67827fdfe36db5b56775c5b2dbcf00f2
MATLAB
593
23
%generates dirichlet random variables % inputs % a = dirichlet parameters. If scalar (alpha = constant for all parts), p is the size of the vector % n = number of draws function r = drchrnd(a,n,p) if(numel(a) > 1 || nargin < 3) p = length(a); else a = repmat(a(1), 1, p); end r = gamrnd(repmat(a,n,1)...
346b6c419cc04493d7a808bc6680dc5de7ac5eecebe2e44819ba890e9bb8abad
MATLAB
595
26
function [data,vox_add,R,Q] = reshape_data_for_multivoxfit(data,nvox) % function reshape_data_for_multivox() % % reshape the input data for multivoxel SDP computation % data must be in the shape [#meas, number_voxels] if nargin < 2 nvox = 50; end % get quotient and reminder siz = size(data); R = rem(s...
862583f8e841140e24f778a116b25a0525395980d0bd8eadad887ac086fb2e20
MATLAB
597
22
function plotWaveform global DA gf axes(handles.axes2) cla % clear all current objects xmin = str2double(get(handles.xMinEdit,'string')); xmax = str2double(get(handles.xMaxEdit,'string')); ymin = str2double(get(handles.yMinEdit,'string')); ymax = str2double(get(handles.yMaxEdit,'string')); updateAxis(xmin,xmax,ymin...
e46b39c92564fda7d2fb5448205bd54100d14aba29ad2157f0b91983f1226c8d
MATLAB
597
17
function [trialNumPerStim,labelsGroupsSnd,labelsGroupsVid,nGroupsSnd,nGroupsVid] = getTrialNumPerStim(audiovisuoCode) % get labels labelsGroupsSnd = unique(audiovisuoCode(2,:)); labelsGroupsVid = unique(audiovisuoCode(1,:)); nGroupsSnd = numel(labelsGroupsSnd); nGroupsVid = numel(labelsGroupsVid); % get number of tri...
792704a2cd226a61f7af9caa0b4325af39c884d6e2dad4c1dbc0a92d03ad132c
MATLAB
598
25
function [f,g,nh_2] = truncatedPoissExpLL(x, y, dt) x = x + log(dt); if(numel(y) == 1) y = repmat(y, size(x)); end spks = y > 0; rate = kgmlm.utils.boundedExp(x); expNrate = kgmlm.utils.boundedExp(-rate(spks)); f = -rate; f(spks) = log(1.0 - expNrate); if(nargout > 1) exm1 = kgmlm.utils.boundedExp(rate(sp...
0907444fb2de8b8efdc53e4e292f299e0d1d202f4368b2ed1232808ae2544e50
MATLAB
600
23
function output_signal = envelope(signal,samples) % This function tries to remove the transients in the signal by enveloping % the first and last 5ms % envelope(signal,samples) x = -pi:pi/samples:0; y = 0:pi/samples:pi; output_signal = signal; % prepare the envelope functions envelope_function(1:samples) = cos(x(1:s...
8beb2f328075d940ccc8ebd4e3840ab4bde3c03275fccd69cc98384d7485f04f
MATLAB
601
37
function x = pollFastrak(s,Azi,Ele) % x = pollFastrak(s) % % % See also startFastrak, endFastrak % % Stephen Gordon 2016 timeOut = 2; flushinput(s); fprintf(s,'P'); pause(0.01) noData = 0; c = clock; while s.BytesAvailable < 47 noData = etime(clock,c) >= timeOut; if noData, break; end pause(0.001) end t...
5443d8ed60e01ee0ed1e5d54cfe255e13eb4419b5454a3bd751ef1a4f73d3489
MATLAB
602
17
function [Y,LP]=ZeroMeanTotal(X) % function Y=ZeroMeanTotal(X) subtracts mean from % all black and all white subsets of columns and rows in the checkerboard pattern % X 2-D or 3-D matrix Y = zeros(size(X)); [Z,LP11] = ZeroMean(X(1:2:end,1:2:end,:),'both'); Y(1:2:end,1:2:end,:) = Z; [Z,LP1...
f3a4633a56d612cf23898e33763109c1bfc20e70b5ba1c3967816b4f4b6009d6
MATLAB
603
18
function [trl, event] = wsws_trialfun_train(cfg) % triggers load(cfg.triggerfile) % behav load(cfg.behavfile) event=[]; trl=[]; nTr=1; if ~isempty(findstr(cfg.triggerfile,'S416')) trl(nTr, :) = [round([Trai_onset(1)-cfg.trialdef.prestim*cfg.Fs cfg.nSamples -cfg.trialdef.prestim*cfg.Fs])]; else trl(nTr, :) = [...
1d5c327b4f6f75090ee613671c28f4d0840330dc9b329818ec59f2ce4692a07c
MATLAB
605
12
function [recrsFascAbs, recrsFascNorm] = ... compute_fasc_recrs(fiberActive, Q) % function handle counting the number of fibers whose threshold is % surpassed in all current steps threshReachedCurrStepFun = @(fascThreshs) arrayfun(@(currStep) ... sum(currStep >= fascThreshs), Q); % compute absolute recruitment ...
df49caa46c854ef3efab21b745f4955a5012c4fead109ff86e2c81bc68e17f67
MATLAB
607
18
function Surfaces = make_sphere_surf(coords, diameter) % Create sphere surfaces from an numeric array of coordinates % Author: Ali Karimi <ali.karimi@brain.mpg.de> num_spheres = size(coords, 1); Surfaces = cell(num_spheres, 1); for i=1:num_spheres % Get unit sphere [X, Y, Z] = sphere(30); cur_surf = surf2pa...
80f8ba04451d72d7d2316c882c9abd50d1cc149c4fe08f41e98b416b0cd4e897
MATLAB
608
36
function x = pollFastrak_InTrial(s,Azi,Ele) % x = pollFastrak(s) % % % See also startFastrak, endFastrak % % Stephen Gordon 2016 timeOut = 2; flushinput(s); fprintf(s,'P'); pause(0.01) noData = 0; c = clock; while s.BytesAvailable < 47 noData = etime(clock,c) >= timeOut; if noData, break; end pause(0.001...
9a7868f1988782f7acb328e9519548f00bfd77fdf4e037bd46fcd53104a2c45d
MATLAB
608
38
%% PROJECT CONFIG PROJ_DIR = pwd ; % put base path to project her cd(PROJ_DIR) %% add to the path projPathDirs = { 'src' 'data' 'bin' } ; for idx=1:length(projPathDirs) addpath(genpath(strcat(PROJ_DIR,'/',projPathDirs{idx}))) end clear projPathDirs %% setup global vars OUTSTR = 'mamv3' ; LOADST...
2edf25b5d31b0250f7a83b6101d3756dd1c9b938b19b78e67d6f3f6d2542f9fa
MATLAB
609
28
%%This function is used to create/save the parameters applied in each step. function S_OUT = createrplabstudioparameters(S_IN,varargin) if isempty(varargin) S_OUT = []; return; end S_OUT = S_IN; current_var = varargin{1}; current_var_field = current_var{1}; for Numoffilename1 = 1:length...
126a950d2cfcd0a9b955886f3964cbf390c6fd53c85e6f46dc026011592a6061
MATLAB
610
11
function [listofcells,listofcellnames,cellstructs] = analyzetpstack_getcurrentcells(ud,refdirname) % ANALYZETPSTACK_GETCURRENTCELLS - get all cells that are 'current' in a particular directory listofcells = {}; listofcellnames = {}; cellstructs = analyzetpstack_emptycellrec; cellstructs = cellstructs([]); for i=1:lengt...
a9063166b7fa536936c192051a81a6d671627d9b7ed781e8c60a155740c49e31
MATLAB
610
26
function [closestvalue,index]=findclosest(vec,value) if length(value)==1 vecdiff=vec-value; index0=find(abs(vecdiff)==min(abs(vecdiff))); if isempty(index0) closestvalue=[]; index=[]; else index=index0(1); closestvalue=vec(index0(1)); end else for k=1:length...
d329ebd8fbadb1db100b8a5841c8562ab8b7ec18f7522980e33d4887a0ba78d2
MATLAB
611
33
%Boresight the FASTRAK system when the cat fixates. function boresightFASTRAK(FASTRAK) %5th column is azimuth and 6th is elevation x = pollFastrak(FASTRAK); FASTRAKdata = x; for i = 1:10 x = pollFastrak(FASTRAK); FASTRAKdata = [FASTRAKdata;x]; end deviation = std(FASTRAKdata); if (deviation(5) < 2) && (dev...
d98a0ab72b4d125ce266e0e18498ebfd5f5c05fd52b4f26c8856110ccffb94b6
MATLAB
611
19
function[varargout] = tbattr(table) % tbattr List columns of MySQL table [mym utilities] % Inputs table - table name, string % Outputs names - column names, (m*1) cell array % types - column types, (m*1) cell array (optional) % Example [names,types] = tbattr('project.orders') if ~istable(table...
02d9e2e6ffd1b5c312c2153b7e6aca9af1a2094a69b7248067bb8b71ad6de92b
MATLAB
612
25
function X = getXpred(x,lagbins,pad) % will shape X predictor matrix with certain lags % pad = 1 if need to pad with last/bext value, nan if want to pad w/ nan if nargin<3 pad = nan; end nT = size(x,1); nPC = size(x,2); X = nan(nT,numel(lagbins)*nPC); for l = 1:numel(lagbins) if lagbins(l) < 0 pred...
764efe53db75eea7c6b2a79cd129f439817addef7bc147265c20f63fc6d4455b
MATLAB
613
29
function sigma=covdiag(x) % x (t*n): t iid observations on n random variables % sigma (n*n): invertible covariance matrix estimator % % Shrinks towards diagonal matrix % as described in Ledoit and Wolf, 2004 % de-mean returns [t,n]=size(x); meanx=mean(x); x=x-meanx(ones(t,1),:); % compute sample covariance matrix s...
1dca4521e44d68e1ca727793388857c67c3920a53c574fd0cbdc1971a508c2d8
MATLAB
614
18
function [beta_tbl] = avg_betas_session(beta_tbl) %AVG_BETAS_SESSION add averages to the beta table per session arr_vars_to_avg = {'rinse_Betas', 'high_low_betas'}; for i=1:length(arr_vars_to_avg) cur_var = arr_vars_to_avg{i}; beta_tbl.([cur_var, '_avg']) = mean(beta_tbl.(cur_var),2); end cell_vars_to_avg = {'l...
05d87cce649d2e866d2e031df9967dfd25687894a746269fe13ae3985596f7ab
MATLAB
618
24
%% GIFT Subjects % load('gSubject.mat') conn_preproc_dir = 'H:\DataProcessing\conn_project_170107\results\preprocessing'; d = dir(fullfile(conn_preproc_dir,'niftiDATA_Subject*.nii')); dn = cellfun(@(a) (fullfile(conn_preproc_dir,a)),{d.name},'uniformoutput',false); SPMFiles = struct('name',[]); modalityType = 'fMR...
21f858b512b8dd6524eeb2c47272eac062e9e5b5b390a22c51829424538293e6
MATLAB
618
22
function Pa = do_sourceparcel(sFiles_in,atlas,bsdir) Pa = []; for iii=1:length(sFiles_in) d = []; clc disp([num2str(iii),'/', num2str(length(sFiles_in))]); tmp = load(fullfile(bsdir,'data',sFiles_in{iii})); % tkz = tokenize(tmp.Comment,'/'); % sub_all{iii} = tkz{1}; % tmp = load('20062...
425cc43e377930a123d64f5a362bd77ff5dcb7da33b7606f074a8d056a848864
MATLAB
619
15
function add_bar_plot(sp, COctrl, COcool, SPctrl, SPcool, SOctrl, SOcool) % Bar plot myBar = @(x) mean(x).*100; axes(sp(4)) b(1) = bar(1, myBar(SOctrl.Correct),'FaceColor','k'); b(2) = bar(2, myBar(SOcool.Correct),'FaceColor',[0.5 0.5 0.5]); b(3) = bar(4, myBar(SPctrl.Correct),'FaceColor',...
fea3bb2baad16f71b9f18baa48bd96266bca6f815962440af6fea4c0beb0cf22
MATLAB
619
26
% PURPOSE: build the default ERPLAB Studio working-memory structure % % FORMAT: % % s = estudio_default_memory_struct(mshock) function s = estudio_default_memory_struct(mshock) if nargin < 1 || isempty(mshock) mshock = 0; end % Keep Studio defaults aligned with the current runtime behavior. erplab_default_values...
566984647c3bc8c77e4c31874e9c2d3956dce0ba36f450bc6fb67172e2e0f1db
MATLAB
621
42
function x = boreFastrak(s, LEDuino) % x = boreFastrak(s) % % % See also startFastrak, endFastrak % % Stephen Gordon 2016 persistent P i timeOut = 2; flushinput(s); fprintf(s,'P'); pause(0.01) noData = 0; c = clock; while s.BytesAvailable < 47 noData = etime(clock,c) >= timeOut; if noData, break; end ...
856e7160a1cb6284818046e6ef4cc955e7d0812ed8aaac9eb9acaaf88fc476c3
MATLAB
621
26
function Qdec2 = rmQdecCol(Qdec1,col) % Qdec2 = rmQdecCol(Qdec1,col) % % Removes the specify column from cell string array Qdec1. % % Input % Qdec1: Two dimensional cell string array of Qdec data (eg. read with % fReadQdec). % col: Column to be removed. % % Output % Qdec2: Two dimensional cell string array of Qdec da...
e7f9c460ff3226d59ad31346dfba643f968eecf1d47cba2fa06e57dff7c0c4ac
MATLAB
621
45
%% P = 'H:\DataProcessing\PREPROC\DENOISED_DATA\wsrrmRSS_02.nii'; V = spm_vol(P); Vd = V; Yi = zeros([V(1).dim length(V)],'uint16'); % figure for i = 1:length(V) fprintf('%d of %d\n',i,length(V)) Y = spm_read_vols(V(i)); % subplot(121) % imagesc(Y(:,:,40)) Vd(i).fname = spm_file(V(i).fname...
93a69044c69c2c934750608986afa6702da6c95731a3ac57111c9ce83e9ec237
MATLAB
624
33
function out = multi_median(volumes,radius,passes) % function multi_median() % % reproduces the multi_median function from Dipy % % default values, as recommended in dipy: % passes = 4 % radius = 4 switch nargin case 1 radius = 4; passes = 4; case 2 passes = 4; end % i...
372707352a34275ddd3f228dee74c7e5ffe2fe4edb9273b2dfaf2fd823af4c87
MATLAB
625
18
pause(2) % Take screen capture robot = java.awt.Robot(); pos = [320 90 900 900]; % [left top width height] rect = java.awt.Rectangle(pos(1),pos(2),pos(3),pos(4)); cap = robot.createScreenCapture(rect); % Convert to an RGB image rgb = typecast(cap.getRGB(0,0,cap.getWidth,cap.getHeight,[],0,cap.getWidth),'ui...
4c9aa76c21c4d3d31c6d9f3784c41e27f8dc65988e0ad39833c7ce7a2c6f5c72
MATLAB
625
18
% ANALYZETPSTACK_GLOBLALS Global variables that serve ANALYZETPSTACK % % Globals for analyzetpstack % % analyzetpstack_draw_devs : a structure list of available draw devices % analyzetpstack_active_draw_devs : a structure list of active draw devices % % analyzetpstack_drift_devs : a structure list o...
c7bfe0e876e44c0325feecb8fbc3182b2ed0276a8e117966656d01ecaaea8966
MATLAB
625
13
function [performance] = ComputePerformance(train_data,test_data,training_label,testing_label) % class is the predicted target label from the test_data [class,~,~,~,~] = classify(test_data,train_data,training_label); fitcdiscr % Checking how different the predicted label is from the actual label for % all the test...
a473c7979587ba420af33f32697876e5389f3f9d857595275a94ba26dd860120
MATLAB
626
31
function out = mymprintf(sqlstring,varargin) % [out] = mymprintf(sqlstring,[A],[...]) % % Simple help function for MyM that incorporates sprintf functionality % % ex: % theID = 3; % out = mymprintf('SELECT * FROM mytable WHERE id = %d',theID); % % See also, sprintf, mym, myms % % Daniel.Stolzberg@gmail.com ...