sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
ad911c068a1bdd0068f3e1f35b5197c633c384c2614bc14d4bf831e27a47034b
MATLAB
290
17
% - This function is part of ERPLAB Toolbox - % function ind = beh_scripts_good_cells(mycell) % Find good cells if ~iscell(mycell) mycell = {mycell}; end ind = cellfun('isempty', mycell); % Good cells ind = (ind == 0); % Convert ind to row vector ind = ind(:)';
232594f8aca28f1c65e7581c0e653cb09241837cb31f36a1eef114b15adafc79
MATLAB
291
11
function physicsTag = find_physics_tag(FEM, baseTag) physicsTags = cellstr(string(FEM.physics.tags)); match = matches(physicsTags, baseTag + digitsPattern(0, Inf)); if any(match) assert(sum(match) == 1); physicsTag = physicsTags{match}; else physicsTag = []; end end
46b75d5fd9fdeafb418d3229299aa19d788a3dd6cbb83afa5c1dad6285260239
MATLAB
291
13
function Allman_TOJ_2AFC_Launch global RUNTIME for i = 1:RUNTIME.NSubjects fobj = findobj('type','figure','-and','name',sprintf('TOJ Box ID: %d',RUNTIME.TRIALS(i).BoxID)); if ~isempty(fobj), close(fobj); end Allman_TOJ_2AFC_Monitor(RUNTIME.TRIALS(i).BoxID); end
c27aacb80bc839d7609a3047fbb6920280f45ad41da1b09f6f125a80c4e28ac2
MATLAB
292
9
function model = select_and_load_model() %LOAD_MODEL Summary of this function goes here % Detailed explanation goes here [nerveModel, electrodeType, electrodePlacement, paramSet] = select_model(); model = Model.load(nerveModel, electrodeType, electrodePlacement, paramSet); end
f61a1efa46b71c58276fd7f11b5434eaa4643c1ecc4d8ff53139d8fb2c9c7bb3
MATLAB
292
9
function display_instructions(window,fontSize,instructions) Screen('TextSize', window, fontSize);%use a big font size Screen('TextStyle', window,0);%normal DrawFormattedText(window, instructions, 'center', 'center', [0, 0, 0]); Screen('Flip', window); KbStrokeWait; end
5700ac00d1806efe7d6869b363e1998681834408c402cb43afc4e293346fc9ce
MATLAB
293
12
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); if length(size(im)>2), im = mean(double(im),3); end;
d87d5ba4716332dd4a5ffd0d4dd4bc1eba7e6a0d1bbf87b4c4efa076cb7efa21
MATLAB
294
9
function fname=tpfilename(tpfileparams,cycle,channel,frame) % TPFILENAME - Determine a 2-photon file name for TIFFSTACK data % ignore channel for now cycle_string = ['Cycle_' int2str(cycle)]; fname= getfield( getfield(tpfileparams,cycle_string), 'filename' ); fname(8) = int2str(channel);
16f53f87d0015969385af98298482a061212e613f7f6c5402f10196dfc1ff5c3
MATLAB
295
11
function TPPreviewImageFunctionListClear % TPPREVIEWIMAGEFUNCTIONLISTCLEAR - Clear the PI function list % % TPPREVIEWIMAGEFUNCTIONLISTCLEAR % % This function removes all PreviewImage functions TPPreviewImageFunctionListGlobals; TPPreviewImageFunctionList = TPPreviewImageFunctionList([]);
2746a64a6d416a77dbe83f3a2d9e86f4c51d469c694b4a88c0f435520f85557c
MATLAB
295
15
function [x,Sx] = make_row_vector(x) % Transpose x if size(x,2) == 1 % Input : % - x : vector or matrix % Output : % - x : x transposed if size(x,2) is 1 % - Sx : size(x) after x has been transposed if needed Sx = size(x) ; if Sx(2) == 1 x = x' ; Sx = size(x) ; end end
783e376e310bc259ef46c428ca2dd2f7cd3e807d41c770254875f4e869c328e2
MATLAB
297
15
function [x,Sx] = make_col_vector(x) % Transpose x if size(x,1) == 1 % Input : % - x : vector or matrix % Output : % - x : x transposed if size(x,1) is 1 % - Sx : size(x) after x has been transposed if needed Sx = size(x) ; if Sx(1) == 1 x = x' ; Sx = size(x) ; end end
928bb035ff4a08d006e7ca2b132ffcf2116a10cfd804505620060e892480e982
MATLAB
298
21
% Add paths to the different toolboxes at the beginning of a session % useful functions to do the scalp plots addpath(genpath('../Colormaps')) ; addpath(genpath('../IdealObserversCode')) ; % Low resolution on plot set(0, 'DefaultFigureRenderer', 'painters') ;
d25089ecb4bd9b38e612026df3b743d13cbf1013a69c79f9890e3f2c5d3ae1e5
MATLAB
299
12
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,frame); if length(size(im)>2), im = mean(double(im),3); end;
d9910fdb3c92e5b325d48c16fed0d36cf807972ce553768cb12e225655e5acb2
MATLAB
300
17
function [ v ] = svd_shrink(w, t, dim) if nargin == 3 L = reshape(w, dim); else L = w; end [U,S,V] = svd(L, 'econ'); s = diag(S); S = diag(sign(s) .* max(abs(s) - t,0)); L = U*S*V'; if nargin == 3 v = L(:); else v = L; end end
a19af668cbd07e5a54b40e02a4d83f3286cac1aa1c9b033dbffed51b039ace10
MATLAB
301
12
function ind_values = msec_to_ind(time_vec, msec_values) % Convert msec times to indices within the input time vector. nval = numel(msec_values) ; ind_values = zeros(size(msec_values)) ; for i_val = 1:nval [~,ind_values(i_val)] = min(abs(time_vec-msec_values(i_val))); end end
a76df46960dc4bbab5d1173c0fbcc60214c0b7f49d651ba0e46303391a8cee12
MATLAB
301
9
function fname=tpfilename_linescansource(tpfileparams,cycle,channel,frame) if isfield(tpfileparams,'digits'), D = tpfileparams.digits; else D = 3; end; fname=[tpfileparams.fnameprefix '-Cycle' sprintf(['%.' int2str(D) 'd'],cycle) '_' 'Ch' int2str(channel) 'Source' tpfileparams.extension];
cd15311998a28082c08849e9b9cebe7c4ab651dd3a83faee77b1cc5bc034f039
MATLAB
301
11
classdef SigmoidActivation < nnet.layer.Layer methods function layer = SigmoidActivation(name) layer.Name = name; layer.Description = 'Sigmoid Activation Layer'; end function Z = predict(layer,X) Z = sigmoid(X); end end end
0ac8fb78a75a268ce5c4b2eb3129dd410d73f822be7380a84cea00f5353e0053
MATLAB
303
9
function update_config(config_name,option_string) eval(['global ,' config_struct,';']); for i=1:size(option_string,1) fieldname=option_string(i,1:strfind(option_string(i,:),',')-1); evalin('base',[config_name,'.',fieldname,'=',option_string(i,strfind(option_string(i,:),',')+1),';']); end
818a730e8dec9f9e741fa1a8b5274e4490c5b4fe38b0e094ecad237ee34ef269
MATLAB
303
17
function [wfa, wfb] = dib_wf_lte() % function [wfa, wfb] = dib_wf_lte() % % By Filip Szczepankiewicz % % Linear tensor encoding (LTE) % for the "data in brief 2019" project. % The LTE is the first chanel of the STE [stea, steb] = dib_wf_ste(); wfa = stea; wfa(:,2:3) = 0; wfb = steb; wfb(:,2:3) = 0;
fc8aa211d319a89980867e0c65c40032a32910caa3eceefec3f743da4e5148e3
MATLAB
303
11
function [h] = nice_gscatter(x,y,g,c,varargin) h = gscatter(x,y,g,c,varargin{:}) ; sz = h(1).MarkerSize ; for i = 1:length(h) set(h(i), ... 'MarkerFaceColor','flat',... 'LineWidth',1.5,'MarkerSize',sz*3,... 'MarkerFaceColor',c(i,:),... 'MarkerEdgeColor',[0.5 0.5 0.5]) end
591c03152554d5bdbfe60e279a3fc8eb0f19fc848621fff840530bd9758265ed
MATLAB
304
11
% TPASSOCIATELISTGLOBALS - Associates that are added to tpstack cells % % Establishes a global variable, TPASSOCIATELIST. % global tpassociatelist if isempty(tpassociatelist), tpassociatelist = struct('type','','owner','twophoton','data','','desc',''); tpassociatelist = tpassociatelist([]); end;
e03119ec84f90820f893ad9eb97b64c2b6965b7286426001bf22ef972049ba25
MATLAB
304
13
function [a, b] = BetaMomentsToParams(m, s) % Equivalent parameters for a Beta distribution with mean m and sd s % Apply formula v = s.^2; a = ((1-m)./v -1./m).*(m.^2); b = a.*(1./m - 1); % round up to a given precision to avoid degeneracy a = round(a*1e5)/1e5; b = round(b*1e5)/1e5; end
14529c14050ae6b147e98b3382b1b3beb55de68ab065eea30ac57153a851d7e9
MATLAB
305
12
function [ V2D ] = ProjectPointsToPlane( Normal, V ) %PROJECTPOINTSTOPLANE Given a normal and a matrix of nx3 points, % project the points to the 2D plane %Find the largest component of the Normal. This is the axis we will ignore [~, iMax] = max(Normal); iV = [1 2 3] ~= iMax; V2D = V(:,iV); end
b3ae3d836be030bf794361268071c2cbabda8f397cd0c73c39b789fa1035c591
MATLAB
305
15
function [x,y] = matchLevels(x,y) % Get levels xLevels = unique(x.Atten); yLevels = unique(y.Atten); % Identify shared levels sharedLevels = intersect(xLevels, yLevels); % Filter xTrials = ismember(x.Atten, sharedLevels); yTrials = ismember(y.Atten, sharedLevels); x = x(xTrials,:); y = y(yTrials,:);
cc153003d58b9b3c82fceee371392c651c50c3571b59c70ea109da2a8af33707
MATLAB
305
11
function tpfileparams=tpfnameparams(dirname,channel) fname = dir([dirname filesep '*.lsm']); if isempty(fname), error(['Cannot find any .lsm files here.']); end; strind = findstr(fname(end).name,'.lsm'); tpfileparams.fnameprefix = fname(end).name(1:strind(end)-1); tpfileparams.extension = '.lsm';
f1cc4b35d214e67aa9cbb95d9eb0966d7833b156dac8b1614126a2adae94a054
MATLAB
306
13
function [ Bounds ] = BoundingBox( Verts ) %BOUNDINGBOX Returns a mx2 matrix of bounding box information, % [minX minY minZ; maxX maxY maxZ] [~, nDims] = size(Verts); Bounds = zeros(2, nDims); for iDim = 1:nDims Bounds(1, iDim) = min(Verts(:,iDim)); Bounds(2, iDim) = max(Verts(:,iDim)); end
23eaff3871e58b4fae13d4c594b7091d7cece00bf61a12aa876029cbd15bc439
MATLAB
307
15
function run_all(model) if ~exist('model','var') model = select_and_load_model(); end log = model.getLogger('model'); try fiber_pop(model); load_potential(model); disconnect_FEM(); % Optional, just to save memory recruitment(model); catch ex log.handle(ex); end end
65b16668515499c2c065f97de120857203061323b01657600e844a2486cd2215
MATLAB
308
12
function [magnitude] = extract_magnitude(data) magnitude = zeros(size(data,1),1); for item = 1:1:size(data,1) %Time steps sum = 0; for vector = 1:1:size(data,2) sqr = data(item,vector)^2; sum = sum + sqr; %a*a+b*b+c*c end magnitude(item) = sqrt(sum); end return; end
d238f8321222c1d9c9c30b052bd801639a19f04459961e2ba6eb3418c0528fed
MATLAB
308
10
function recruitmentCurve = recruitment_curve_from_data(model) fiberType = 'Ia'; Charge = model.Q'; Recruitment = model.recruitment_motor_by_type(fiberType)'; [Recruitment, iUnique] = unique(Recruitment); % remove doubled points Charge = Charge(iUnique); recruitmentCurve = table(Charge, Recruitment); end
68e1b1e7fee71e2ab95177e86c8c4438c5e02e49a8eca65d11c712f459ae5ec2
MATLAB
309
10
function [Q,logQ]=Qfunction(x) % function [Q,logQ]=Qfunction(x) calculates probability that Gaussian variable N(0,1) takes value larger than x if x<37.5, Q = 1/2*erfc(x/sqrt(2)); logQ = log(Q); else Q = 1./sqrt(2*pi)./x.*exp(-(x.^2)/2); logQ = -(x.^2)/2 - log(x)-1/2*log(2*pi); end
056c75aab7c31eeb90019f982e8a64283bfc79be620c5a6319986b5e7ea4da17
MATLAB
310
9
function fname=tpfilename(tpfileparams,cycle,channel,frame) % TPFILENAME - Determine a 2-photon file name for Insopix data % ignore channel for now if channel>1, error(['Only 1 channel.']); end; cycle_string = ['Cycle_' int2str(cycle)]; fname= getfield( getfield(tpfileparams,cycle_string), 'filename' );
bb0f70f9df0461e66f5264b2411968936c2b147388f5375fed59408c60ceecf1
MATLAB
311
13
function levels = calculate_harmonics_levels(f0_level,weights_relative_to_f0) levels = zeros(size(weights_relative_to_f0)); for ih = 1:numel(weights_relative_to_f0) levels(ih) = f0_level + (10 * log2(weights_relative_to_f0(ih))); if ~isfinite(levels(ih)) levels(ih) = 0; end end end
0522f4579030ba002e62ec053b8aaa195591e7138f7c22bb39d740435670898d
MATLAB
312
13
function checkOutputs(bits) %This function is expandable to any number of sensors global DA gf h for j = 1 : length(bits) signal = invoke(DA,'GetTargetVal',sprintf('%s.bit%d',gf.stimDevice,bits(j))); %update gui handle = eval(sprintf('h.bit%d',bits(j))); set(handle,'val',signal) end
16a4805f2a4dc564b394cea880261722c5f21c9203d62f298d788420efd53399
MATLAB
314
19
function h=figure1(varargin) % function loads a figure for plotting h=figure; set(gcf, 'units', 'centimeters') pos1=get(gcf, 'position'); if nargin==0 width_=19;height_=8; else width_=varargin{1}; height_=varargin{2}; end pos2=[pos1(1) pos1(2)-10 width_ height_]; set(gcf, 'position', pos2)
a3211500d18f73191640715e87df7d5a91e9f30f0a8d74b6e03c2508bd61f402
MATLAB
315
11
function [ dp, c] = dprimeFromBinary( isHit , isFalseAlarm ) %DPRIMEFROMBINARY Calculate dprime and response bias from zeros and ones % Detailed explanation goes here hitRate = sum(isHit)/size(isHit,1); falsAlarmtRate = sum(isFalseAlarm)/size(isFalseAlarm,1); [dp, c] = getdprime(hitRate,falsAlarmtRate); end
519e28120eddf906f29659c3356afaf18eefb5a917b3ee2eebca49a00d1e1483
MATLAB
316
12
function s = perlin2D (m) s = zeros([m,m]); % Prepare output image (size: m x m) w = m; i = 0; while w > 3 i = i + 1; d = interp2(randn([m,m]), i-1, 'spline'); s = s + i * d(1:m, 1:m); w = w - ceil(w/2 - 1); end s = (s - min(min(s(:,:)))) ./ (max(max(s(:,:))) - min(min(s(:,:)))); end
597ccb0e894188db5a9cbe1daf71b1be7e4f551adb45f7bbbfa19c0e11044425
MATLAB
318
10
function [Genes,Genes_compressed] = findGenes(IND,xp,yp,inputSize) IND_xyp = sub2ind(inputSize,xp,yp); parfor j=1:length(IND) Genes{j} = findGenes_sub(IND_xyp,IND(j)); Genes_compressed{j} = findGenes_compressed(IND_xyp,IND(j)); end Genes = cell2mat(Genes)'; Genes_compressed = cell2mat(Genes_compressed)'; end
93f7a58a52eb54a4b520ecffafbe45624e1b8481b2f4170942867e0ebea4ac45
MATLAB
318
13
function checkOutputs_WE(nSensors) %This function is expandable to any number of sensors global DA gf for j = 1 : length(nSensors) signal = DA.GetTargetVal(sprintf('%s.sensor%d',gf.stimDevice,j)); %update gui % handle = eval(sprintf('h.bit%d',nSensors(j))); % set(handle,'val',signal) end
add3b2b280edba7f4d4e6d535091922366e6c6cda4b98dfd7184ec069d9be744
MATLAB
318
13
% qtiplus_setup script function qtiplus_setup() % call this function from within the qtiplus folder % simply add all folders to path addpath(genpath(pwd)); if ispc || ismac savepath; fprintf('Path set! qtiplus folder added permantently to Matlab path!\n') else fprintf('Path set!\n') end end
aebaddfa0b63e1677d1bb56c73910d6ff47036ae3d95adc6c5a65db333a0d2b5
MATLAB
318
14
function flags=padflags(EEG,flags,npad) for np=1:npad; for i=1:size(flags,3)-1; %forward... if any(flags(:,:,i+1))==1 flags(:,:,i)=1; end %backward... if any(flags(:,:,(EEG.trials-(i-1))-1))==1 flags(:,:,EEG.trials-(i-1))=1; end end end
e0fc34be03f0061df7012d1863cb9f5be12f630ac0c8f58f405af4a7f345cff5
MATLAB
318
18
function [y]= fitCic180(params,x) % y = cg(x,params(1),params(2),params(3),params(4),params(5),180); % (x,b,a,po,tw,c,P) b=params(1); a=params(2); po=params(3); tw=params(4); P=180; y=zeros(size(x)); for i=1:length(x(:)) y(i)=b; for j=-4:4 y(i)=y(i)+a*exp(-(x(i)-po-j*P)^2 / (2*tw^2)); end end
abad606f17b1cc84eb30193aa93183f78156565485850a83da1af2c858d378b2
MATLAB
319
11
function [numIaFibers, numIbFibers, numAlphaFibers] = default_I_fibers_count(idIFibers) numPrimaryFibers = numel(idIFibers); % Subpartition of primary fibers numIaFibers = ceil(0.16 * numPrimaryFibers); numIbFibers = ceil(0.12 * numPrimaryFibers); numAlphaFibers = numPrimaryFibers - numIaFibers - numIbFibers; end
69a10e0586913012a66cd29c4560ec574108a2cf5e1fb0e737fdc97accaf9a32
MATLAB
320
14
function [cellData] = convertToCell(data) if size(data,3) > 1 cellData = cell(size(data,3),1); for i = 1:size(data,3) cellData{i} = data(:,:,i); end else if ~iscell(data) cellData{1} = data; else cellData = data; end end end
7270c67d9f34c2255ce6e28ebbb9431d7d79a9c347a0a7368c70794e2eeb63ef
MATLAB
320
14
function [navcent] = nav_centrality(navdist,paths) n = size(navdist,1); navcent = zeros(n,1) ; for idx = 1:n for jdx = 1:n if isinf(navdist(idx,jdx)) || idx == jdx ; continue ; end pa = paths{idx,jdx} ; navcent(pa(2:(end-1))) = navcent(pa(2:(end-1)))+1 ; end end
f88e3f86ce301a624f6ea26c871d0c017a00c9ce8e6785a04a0719eca78b053f
MATLAB
321
10
function [p] = get_param() %GET_PARAM Summary of this function goes here % Detailed explanation goes here p.voxel_size = [.25, .25, .25]; p.bbox = [zeros(1, 3); [256, 312, 200] .* p.voxel_size]'; p.origin_index = [128.5, 112, 33]; p.offset = [128.5, 112, 33] .* -p.voxel_size; p.bbox_shifted = p.bbox + p.offset'; end ...
40d7dc1c827a87e85179034b82125abd01f4d1b29e6c0ba0bd4dd13b832368d8
MATLAB
322
8
% run latin hypercube ub=[-60,-60,5000,5000,1000,1000,2,2,1,0.5,150,150,0.5,0.5,-40,-40,7,7,10,-65,10,10,0.1,0.1,10,zeros(1,10)]; lb=[-80,-80,2000,2000,100,100,0.1,0.1,0.1,0.01,5,5,0.05,0.05,-55,-55,2,2,-20,-90,0,0,0,0,0,zeros(1,10)]; p1 = lhsdesign_scale1(npop, npars_est, [lb(paramstoest);ub(paramstoest)]); ...
a5754287447a8ad1579b4bd016701ec3dcc4250d7da9f603ea39599a2de3a5a7
MATLAB
323
15
function subjs = getSubjects(niipath) % subjs = getSubjects([niipath]) % % Return cell array of strings with subject names; i.e. subdirectories % under the 'NII' path. % % Daniel.Stolzberg@gmail.com 2016 if nargin == 0, niipath = fullfile(pwd,'NII'); end D = dir(niipath); D(~[D.isdir]) = []; subjs = {D(3:end).name}';...
3fa0e64af8488b675e421d039cbcfe941543e85851c8ec0767ee4a8e023e63ca
MATLAB
325
17
function [x] = soft_threshold(x0, tau) % returns argmin_x (tau||x||_1 + 1/2||x - x_0||) len = size(x0, 1); x = x0; for i=1:len if x(i) < -tau x(i) = x(i) + tau; elseif x(i) > tau x(i) = x(i) - tau; else x(i) = 0; end end ...
9e0af7421856f8df0c59636b8078df5365d1b3de1c10558b47d8648e3efa6c95
MATLAB
326
13
function struct = MergeStructs(struct, varargin) % varargin - struct2, struct3, struct4, etc. for i = 2:nargin currStruct = varargin{i-1}; fields = fieldnames(currStruct); for j = 1:length(fields) currFieldName = fields{j}; struct.(currFieldName) = currStruct.(currFieldName); end e...
f0e39ddea0aeb1f210e530a286102bbc6a1ecdcb550f7a4d48020c43cdd397a0
MATLAB
327
9
%% "Exclude" units on database with fewer than minspikecnt spikes minspikecnt = 200; % "exclude" units with spikes fewer than this updatestr = sprintf(['UPDATE units AS ua INNER JOIN units AS ub ', ... 'ON ua.id = ub.id SET ua.in_use = FALSE ', ... 'WHERE ub.unit_count < %d'],minspikecnt); mym(update...
f2828f95c0e4e611e986eb4236446abd75c915eebb74b86f750bc354bd107e99
MATLAB
327
9
function placements = get_placements_list(nerveModel, electrodeType) [modeList, electrodeTypeList, placementList] = get_models_list(); iModel = find(strcmp(modeList, erase(nerveModel, 'Subject')), 1); iType = find(strcmp(electrodeTypeList{iModel}, electrodeType), 1); placements = placementList{iModel}{iType}; ...
0524a80c9a682c262413a8153b98c2ad4711bd565a31cab8f426384aa2134faa
MATLAB
329
10
% part of https://github.com/LudgerS/MRSartifactRemoval % function line = complexVoigtWithPhase(specAxis, area, center, fwhm, mixingRatio, phase, pCorr1) line = area*exp(-1i*phase*pi/180)*complexVoigt(specAxis, center, fwhm, mixingRatio); % 1st order phase correction line = exp(-1i*specAxis*pCorr1).*line; ...
562635b20dec5bbb42567b17036e5cdb3f0069a36741c6f3a6c301e434ca540e
MATLAB
329
18
function x = compareFixate2(curHeading) % x = compareHeading(curHeading,Headings,Tol) % % Compare the current heading value to a 1xN vector of target Headings +/- % a specified tolerance. % % Stephen Gordon 2016 if abs(curHeading(1)) < 3 && abs(curHeading(2)) < 5 x = 8; return else x = 0; return end ...
6c4ffac9bb4112606b9949e0563eadc1ec8dad7d1fa173c3fd567f9cbbc54fe6
MATLAB
330
10
function[name] = dbcurr % dbcurr Current MySQL database [mym utilities] % Example dbname = dbcurr if ~myisopen error('No MySQL connection active; use ''myopen'' to connect') else % new compilation of mym returns structure DJS 1/2013 d = mym('select database() as db'); name = char(d.db...
803c26ed421314d4c5d3a8b8ee5eeb614ed5c80fd241ea8e5f21eba5bd232dea
MATLAB
331
13
function [ Locs ] = ReadLocationsFromFile( filename ) %READLOCATIONSFROMFILE Read locations from a tab-delimited text file fileID = fopen(filename); Locations = textscan(fileID, '%f %f %f %f %f %f %f %f%*[^\n]','MultipleDelimsAsOne',1,'CommentStyle','#'); fclose(fileID); Locs = horzcat(Locations{:,...
abbba07e890fd988dc4c6f0663696f3ea79e6296111d09a8488475976c4fb909
MATLAB
331
9
function fname=tpfilename(tpfileparams,cycle,channel,frame) if isfield(tpfileparams,'digits'), D = tpfileparams.digits; else, D = 3; end; fname=[tpfileparams.fnameprefix '_Cycle' sprintf(['%0.' int2str(D) 'd'],cycle) '_' tpfileparams.myconfigstr 'Ch' int2str(channel) '_' sprintf('%.6d',frame) tpfileparams.e...
46934c814027a368a9968d72d57e6b210378c0519df1dcbac2f7eeaac04f1ca8
MATLAB
332
11
function [ho,r,p] = nice_scatter(x,y,varargin) h = scatter(x,y,... varargin{:},... 'MarkerFaceAlpha',.6,'MarkerFaceColor','flat',... 'MarkerEdgeAlpha',.9,'LineWidth',1.5) ; [r,p] = corr(x(:),y(:),'type','s','rows','complete') ; disp([ 'spearman rho: ' num2str(r) ', pval: ' num2str(p) ]) if nargout > 0 h...
25d457f379e9a39641f59da08bb34b075b40cbf385ff77308d0c823474657e78
MATLAB
334
18
function F=KDens(Z,X,h) % Kernel density convolution % Z = time bins % X = spike times % h = kernel S.D. % F = convolved output N=length(Z); F=zeros(1,N); a=1/sqrt(2*pi*h); for i=1:N for j=1:length(X) dt=Z(i)-X(j); F(i)=F(i)+exp(-dt^2/(2*h)); end; end; % F=a*F./length(X); F=a*F...
0129a39aedea087b80caeccaa1b4c40b35261653f2f6fb9d2abf6413f5732c35
MATLAB
336
10
function [y] = sem(x) %SEM Calculation of the standard error of the mean % For vectors, Y = SEM(X) returns the standard error of the mean. For % N-D arrays, SEM operates along the first non-singleton dimension of X. dim = find(size(x) ~= 1,1,'first'); % find first non-singleton dimension y = std(x,0,dim)/sqrt(size...
4edfe449c82baa9e8870d98623603be71d158263d62d61df38ecd81ddd6a9ca0
MATLAB
336
13
function[i] = istable(name) % istable True if MySQL table exists [mym utilities] % Example if istable('junk'), tbdrop('junk'), end if ~myisopen error('No MySQL connection active; use ''myopen'' to connect') else try i = false; [a,b,c,d,e,f] = myms(['describe ' name]); %#ok i = true; catc...
d50ac60561bf61634454a18e98c1b8837228788474c70f9aa1b4c8e00f73127c
MATLAB
336
12
function dbdrop(name) % dbdrop Delete MySQL database [mym utilities] % Example dbdrop('junk') if ~myisopen error('No MySQL connection active; use ''myopen'' to connect') else try mym(sprintf('drop database if exists %s',name)) catch error('Database %s could not be deleted',name)...
9db6c0a4f84ed5f64250c8dcc6ef8bd7a63c3757ef5beb60a3425ed8e9dd732e
MATLAB
337
17
function TDTmultiSet(tag, val) % Space saving function allows multiple parameter tags to be assigned % values. global DA gf for i = 1 : length(tags) if DA.SetTargetVal(sprintf('%s.%s', gf.stimDevice, tag{i}), val(i)) ~= 1, warning(sprintf('Failed to set %s.%s', gf.stimDevice, tag{i})) end ...
f2760c87fca61aac260aa768b6d0c007a1df690ae932a129c0952a021d247fed
MATLAB
337
16
% Modified Gram-Schmidt Orthonomalization % (Source) http://elliottback.com/wp/modified-gram-schmidt-orthogonalization-in-matlab/ % function Q = GSOrth(A) n = size(A,2); Q = A; for k = 1:n-1, Q(:,k) = A(:,k) ./ norm(A(:,k)); A(:,k+1:n) = A(:,k+1:n) - Q(:,k) * (Q(:,k)' * A(:,k+1:n)); end; Q(:,n) = A(:,n) ./ n...
61329e65dcc71e704c3a5ec5664e6fcc56591a6793335fe22ca0785846f5a2d9
MATLAB
339
9
% compilation instructions for the CUDA code % requires CUDA version 11.6 % on Ubuntu or Windows (Linux commands may work similarly on MAC, but never attempted) % first, check paths in +kgmlm/+CUDAlib/myCUDAPaths.m % then run % kgmlm.CUDAlib.buildGMLMCUDALibrary; % % If a link error occurs, try 'clear mex' a...
5b3560fd56b0ec72edf602d33117082a89d9f7b4ccc54db8c415d07c4cfec9a1
MATLAB
341
19
function model = view_run(model) addpath('matlab'); if nargin == 0 [file, path] = uigetfile('data/runs/*.mat'); load([path file], 'model'); end figure; tiledlayout(2, 1); nexttile; prepare_plot_cross_section(gca()); plot_cross_section(model, gca()); nexttile; prepare_plot_recruitment(gca()); plot_recruitment(...
d2c9f1d04dc7ff8dda32b3c11290bf0cc306579ae560de45a8d0231cffebce3e
MATLAB
341
15
function outcell = object2varargin(inobj,exclude) keys = fieldnames(inobj); j=0; for i=1:length(keys); if ~isempty(eval(['inobj.',keys{i}])) if isempty(find(strcmp(keys{i},exclude))); j=j+1; outcell{j}=keys{i}; j=j+1; outcell{j}=eval(['inobj.',keys{i}]); ...
d6f37c8d5445f8ae84ae25c466fd1e930fe177f756943ba6c7228f341a67930f
MATLAB
342
23
function h1=offplot1(time_series,diff,t1,color) % function offplots a time series signal if size(time_series,1)>size(time_series,2) time_series=time_series'; end for j=1:size(time_series,1) h1(j) = plot(t1,time_series(j,:)+diff*(j-1),'color',color(j,:),'LineWidth',1); hold on end hold off ...
0a2ee016231ea94f75fa6964fcedb4ffe629d7537ba2a8caa5c4f791fc287296
MATLAB
343
16
function [messgStr,bestpanelIndex]= f_check_decodetab_panelchanges() messgStr = ''; bestpanelIndex = 0; MyViewer_chanbin = estudioworkingmemory('ERPTab_plotset'); if ~isempty(MyViewer_chanbin) && MyViewer_chanbin==1 messgStr = char( 'Changes on "Plot Setting" have not been applied'); bestpanelIndex =1; ...
7dc519efccbb15ec677771b59c88b6ed7f255af15ec5b2ba1995851b17388962
MATLAB
343
12
function imgData = readBin(filename, width, height, numFrames, dataType) fid = fopen(filename, 'rb'); assert(fid ~= -1, strcat('[Error] Cannot open file: ', filename)); imgData = fread(fid, width*height*numFrames, ['*', dataType]); fclose(fid); imgData = reshape(imgData, width, height, numFrames); imgData = permute(...
a3287489a1a61eedc670bea0d54f96174352555af6674fb3aaa071f2081be6c9
MATLAB
343
12
function [params_group] = getPriorVariance(params_group, prior_setup) dim_S = numel(params_group.T); params_group.V(:) = 1; for ss = 1:dim_S if(strcmpi(params_group.dim_names(ss), prior_setup.groupName)) H = double(params_group.H); params_group.T{ss}(:) = exp(2*H); else params_group.T{...
c3ff5a3bd0a316eef4b37643baf2f6114dab56c7e21c741a9a40f6de18726bff
MATLAB
343
11
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)); cycle_string = ['Cycle_' int2str(cycle)]; im=imread(fname,frame,'info',getfield(getfield(fnameprefix,cycl...
5c8420d4773a9b4e65c0d3f5cae97971ec705e77cce67dc5ed160950ff36edae
MATLAB
344
13
function erb = cf2erb(cf,lowFreq,fs,numChannels); % function erb = cf2erb(cf,lowFreq,fs,numChannels); humanfactor = 1; EarQ = 9.26449*humanfactor; % Glasberg and Moore Parameters minBW = 24.7; EB =EarQ*minBW; erbnum = log( (cf+EB)/(fs/2+EB) ); erbden = ( -log(fs/2 + EB) + log(lowFreq + EB))/numChannel...
8d73a686b4ceeca10644b1436efd69ef1aa5b5f640d80f1fa238ba4496f9a65a
MATLAB
344
11
function [split_by_module] = split_by_module(betas_modules,fun) %SPLIT_BY_MODULE split data by modules and apply a function (fun) arguments betas_modules fun = @(x) {x} end [t_groups, t_ids] = findgroups(round(betas_modules(:,2))); assert(isequal(t_ids,[0,1,2]')); split_by_module = splitapply(fun, betas_modules...
ad716690f681cdeca06fb25458b094fbc5d15a7072568598769799eb1542a374
MATLAB
344
17
function rstr = get_string(hObj) % rstr = get_string(hObj) % % Get currently select string in a gui control such as popup menu or % listbox % % Daniel.Stolzberg@gmail.com 2013 v = get(hObj,'Value'); s = cellstr(get(hObj,'String')); if isempty(s) rstr = ''; elseif length(v) == 1 rstr = s{v}; else ...
52d7ca9d9a397d839a5ba7568e3cbbb859552b78678277e66af8ed3cd21c6d88
MATLAB
346
13
function [ LocLinks ] = ReadLocationLinksFromFile( filename ) %READLOCATIONSFROMFILE Read locations from a tab-delimited text file fileID = fopen(filename); Locations = textscan(fileID, '%d %d%*[^\n]','TreatAsEmpty',{'#'},'MultipleDelimsAsOne',1,'CommentStyle','#'); fclose(fileID); LocLinks = horzc...
98bb180e9417b4931712b4b4b5a199fcf9b75858763c3013d2b896e2a013ed07
MATLAB
346
18
function InitializeAnnotations(self) if self.VerboseLevel > 0 fprintf(' Initializing annotations: ') end vidNames = GetVideoNames(self, 'videos'); for i = 1:length(vidNames) annot = Annotation(self, vidNames{i}); annot.InitializeAnnotation() if self.VerboseLevel > 0 ProgressBar(i, length(v...
e7970a369e460352cf3ded42a56a62d5a95398d60abe0a6a3033a0b03cad8564
MATLAB
346
13
% Script to Rename Images clc;clear all;close all % Input Directory input1= './bandage/'; input = imageDatastore(input1,'IncludeSubfolders',true,'LabelSource','foldernames'); % Loop for i=1:1:size(input.Files,1) currentimage = imread(input.Files{i}); imwrite(currentimage,sprintf('%s0%01d.jpg', input1,i)); ...
25c45688c660c21f9a179136874104aaf062ae3ece1a8c7486f7f94762c3f93e
MATLAB
347
15
function s = dist_sd(val, pgrid) % Compute the standard deviation (s) of a probability distribution (val) % over a discrete grid (pgrid). % % Usage: % s = dist_var(val, pgrid) % % Copyright 2016 Florent Meyniel & Maxime Maheu % check that a grid is provided if nargin == 1 error('pgrid is missing'); end s = s...
11ac0e5c782807a4c8c26e3cf61c7cb63d3eeb872789f60d67041596ae4d4f39
MATLAB
348
13
function [ Structs ] = ReadStructuresFromFile( filename ) %READSTRUCTURESFROMFILE Read structures from a tab-delimited text file fileID = fopen(filename); Structures = textscan(fileID, '%f %f %f%*[^\n]','TreatAsEmpty',{'#'},'MultipleDelimsAsOne',1,'CommentStyle','#'); fclose(fileID); Structs = horz...
64be76d3b5bb99b65b812fc253652c934c13dc6273d2d592b4d31995938bb5f2
MATLAB
348
12
function UpdateAnnotations(self, updatedAnnotT) self = Load(self); updatedFrame = updatedAnnotT.Frame; updatedType = updatedAnnotT.Type; updatedLabel = updatedAnnotT.Label; [~, loc] = ismember(updatedFrame, self.AnnotationTable.Frame); self.AnnotationTable.Type(loc) = updatedType; self.AnnotationTable.Label(loc) = up...
4c8a10e0aa7c9ac9eb314cf8d0d1b66f1d0fe9c3899b8cdb140583663babc356
MATLAB
349
14
function signal = qtip_predict(model,bten) % function qtip_predict() % % returns the signal values as implied by the QTI model given the model % parameters and the b-tensors % if size(model,1) == 28 model = model'; end bt2 = convert_1x6_to_1x21(bten); signal = model(1) * exp(- bten * model(2:7)' + 0.5 ...
9a2f3c3f92248f3013c0cfb8e9c5ac44ed2657e8888485c92a3067d702722648
MATLAB
350
15
function plot_all(model, Q) if ~exist('model','var') model = select_and_load_model(); end if ~exist('Q','var') Q = linspace(0, get_max_threshold(model, 0.99)); end plot_cross_section(model); plot_fascs_recruitment(model, Q); plot_thresholds(model); plot_selectivity(model, Q); plot_selectivity_and_r...
acdd8e9c1ccfb2da1032ff954dd1f730c87026176dbade98f923203faf69fe6e
MATLAB
350
13
function Spikes = pp_fullprocess( BLOCKS, subject, session ) % % Run full processing workflow. Take data from raw (epData) format, % through automatic spike sorting steps. % % Note: user input is required in the middle, to select clean trials. % pp_prepare_format( BLOCKS, subject, session ); Spikes = pp_sort_ses...
2ed80ce4f288f285a0bbaf1152b48c61157b2ac2215b43c61130af93e849e036
MATLAB
351
12
function scalar = ScalarForUnitConversion( source_units, desired_units ) %SCALARFORUNITCONVERSION Given metric units, returns the scalar to convert source_unit_scalar = ScalarForUnitToMeters(source_units); desired_unit_scalar = ScalarForUnitToMeters(desired_units); scalar = source_unit_scalar / desire...
a6c00d228dc6c75690574bad3e190da6571b2d3ffeeca4b903ed4eaa8b5c03a9
MATLAB
351
12
function dbadd(dbname) % dbadd Create MySQL database [mym utilities] % Example dbadd('newdb') if ~myisopen error('No MySQL connection active; use ''myopen'' to connect.') else try mym(sprintf('create database if not exists %s',dbname)) catch error('Database %s could not be c...
c986a14eaa484b8ec69bd8ccdb92adcfc1234277329535ebe2c81696efd1cf22
MATLAB
351
19
function F = communicability_wei(CIJ) %inputs % CIJ weighted connection matrix % i row % j column % %outputs % F communicability %================================================= N = size(CIJ,1); B = sum(CIJ,2); C = diag(B); D = C^(-(1/2)); E = D * CIJ * D;...
128d1b4a5e1b03a266bf44773cc837ac3d4bfcf20810c65d483f0a09b05ce1c0
MATLAB
352
13
% part of https://github.com/LudgerS/MRSartifactRemoval % % Normalized Absorption and Dispersion mode Gaussian curve % See subfunctions for documentation function lineShape = complexGaussian(frequencyAxis, f0, fwhm) lineShape = Gaussian(frequencyAxis, f0, fwhm) -... 1i*dispersiveGaussian(fre...
f778f5a58f71ac5ab32dfa107fe43f8559c763f84a9f7f0177e2d3a698835ce1
MATLAB
354
12
%% projectFolder = '/Users/harriscaw/Documents/Behavior classification/Projects/JuangSetup'; project = DeepActionProject(projectFolder); %% % feat = Feature(project, '20080324115556', 'spatial', []) % feat = Feature(project, '20080324115556', 'temporal', []) feat = Feature(project, '20080324115556', 'spatial', []) ...
69b4d2f19309b5962cf98b9c15f1db6ded8fd719197bfcd2ecad99e68dfa7ef8
MATLAB
356
22
function outPnts=mrgOvlPnts(inPnts) j=0; for i=1:size(inPnts,1); if inPnts(i,2)>0; j=j+1; trmPnts(j,:)=inPnts(i,:); end end j=1; outPnts(1,:)=trmPnts(1,:); for i=1:size(trmPnts,1); if trmPnts(i,1)<outPnts(j,2); outPnts(j,2)=trmPnts(i,2); else j=j+1; outPnts(j,:)...
724e547fa9e3091249b73494e85fba820226d83d35090a57ee855fa044c9ede2
MATLAB
357
18
function test_Visual(x) figure xlim([-90 90]); ylim([-90 90]); for i = 2:length(x) plot([-40 -25 -20 -15 -10 -5 5 10 15 20 25 40],[0 0 0 0 0 0 0 0 0 0 0 0],'bd') hold on plot(0,0,'gd') plot([-2 2],[0 0],'k+') plot(x(i,5),x(i,6),'k*') hold off xlim([-50 50]); ylim([-90 90]); pa...
bf57c32e6612c5e31d635e15d63c88332dd29f9924d07ccd89162a0533129ade
MATLAB
357
13
function dbopen(name) % dbopen Make MySQL database current [mym utilities] % Example dbopen('new') if ~myisopen error('No MySQL connection active; use ''myopen'' to connect') else try a = mym(['use ' name]); %#ok catch error('Database %s not found; use ''dblist'' to list available ...
1629cd6cb58354a93bc9b4a18e0cc6132bfcadd6b6f52e5ca6824a42d671e7d0
MATLAB
358
12
function [] = add_template(name, alpha) %ADD_TEMPLATE add the template given the name if ~exist('alpha','var') || isempty(alpha) alpha = 1; end f_name = fullfile(util.get_data_dir, ... 'template_surfaces', name); this_surface = util.get_surface_from_gifti(f_name); color = [244,229,206] ./ 255; util.display_surf...
b48fae0c0c672ac35ba2b7968e2283f0f1b3d9e8984ae52d9bc7292f1c7a88a3
MATLAB
358
14
function idx = rParamIdx(TRIALS,param) % idx = rParamIdx(TRIALS,param) % % Helper function returns index to a read parameter (param). % % Returns empty if the parameter is not found in TRIALS.readparams. % % See also wParamIdx % % Daniel.Stolzberg@gmail.com 2016 % Copyright (C) 2016 Daniel Stolzberg, PhD idx = fi...
d456e940129b3fef1685635ea3d322959c1f9d31b9a23d64b7d4c23007e89a18
MATLAB
358
12
function [] = clearAll() % CLEARWORKSPACEFIGURES Clear all variables in the base workspace and close % all figure windows. % Note: this function is usually called in the begining of a script to % clear the workspace and close all figure windows % Author: Ali Karimi <ali.karimi@brain.mpg.de> evalin('base','clearvar...
0fed3c69b89f549b57eaf3358146daf9df9f4649cf0a65d74994cfb2f083b664
MATLAB
359
9
function [T] = create_empty_table(template_T) %CREATE_EMPTY_TABLE Create an empty table of type cell var_types = varfun(@class, template_T(1,:),'OutputFormat', 'cell'); T = table('Size', size(template_T),... 'VariableTypes', var_types,... 'VariableNames', template_T.Properties.VariableNames,... 'RowNames', ...
5fb8175685cbb665af77df44c0f3b5cca24d5458a36a1295fe33ec64977e9336
MATLAB
360
15
function FEM = load_FEM(model, FEM) % If called with one argument, it just loads the model. % If called with two, it closes the given one first (or at least tries to). import com.comsol.model.util.*; if exist('FEM', 'var') && ~isempty(FEM) ModelUtil.remove(FEM.tag); else comsol_connection(); end FE...
90a0f1f6bc7102087318d91fb2eea1792dd61cf6898f16fce54ccd90aea34967
MATLAB
360
11
function Pr=prob(data, nR) PrPos = zeros(1,nR-1); % diff of find of diff trick for counting number of elements temp = sort(data(data>0)); % want vector excluding P(0) dtemp = diff([temp;max(temp)+1]); count = diff(find([1;dtemp])); indx = temp(dtemp>0); PrPos(indx)= count ./ numel(data); % probability Pr = [max(1-s...
d0963e926090f290a0f05aeb00079d1492721052b26a5bfcafd1577dd1037157
MATLAB
360
10
function [Matrix] = Order(MatrixOld, patient, Order) Matrix = []; Matrix(:, 1) = MatrixOld(:, Order(patient, 1)); Matrix(:, 2) = MatrixOld(:, Order(patient, 2)); end % Here I didn't distinguish between when I have or not an SCR file because % in this case in all conditions I measure SCR % (so, Order...
f612e6c81078c92301c05d1f37327b25c59ad7d4791e639653c042185f50fad9
MATLAB
360
18
function out = convert_3x3_to_1x6(in) % function convert_3x3_to_1x6 % % converts a tensor from a 3x3 to a 1x6 representation % picks up the upper triangular elements to be used in the Cholesky % formulation xx = in(1,1); yy = in(2,2); zz = in(3,3); xy = in(1,2); xz = in(1,3); yz = in(2,3); f = sqrt(2); ...
02a0827c8ae0c143514567bc653cdb80fcb3a5c757e592455704be7d6d309a25
MATLAB
362
16
function output = getVal(handle) %Custom function for SanesLab epsych % %This function retreives the user-selected value of a GUI handle % %Input: % handle: GUI handle % %Example: To obtain the user-selected dBSPL value- getVal(handle.dBSPL) % %Written by ML Caras 7.28.2016 str = get(handle,'String'); val = get(han...
5ce37b7f03baf5838e736f431158db09c930ffab1766ddc7928b6152d98b3555
MATLAB
364
14
function felec = export_electrode_stl(model) direlec = model.paths.elec; prefix_elec = 'electrode'; if isempty(dir([direlec prefix_elec '*.stl'])) if ~exist(direlec, 'dir') mkdir(direlec); end felec = export_stl(model, direlec, prefix_elec); else files = dir([direlec prefix_elec '*.stl'...