sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
8b97fd766c09ab21047771e16a619aeda177638bf538d31e158ace28cc06cd23
MATLAB
627
23
function [dp,c] = getdprime(h,fA) % dprime d' calculation from hit and false alarm rate % outputs: % dp = d' % c = criterion c (negative values -> bias towards yes responses) % check input narginchk(2,2); % check for values out of bounds, also issue errors or warnings if =1 or 0 if or(or(h>1,h<0),or(fA>1,fA<0...
2a73c8c2c22cca08345d9c47080ca8ba1d0ae4c3d852ce7e96987ec182afe6ba
MATLAB
628
19
function [Tcutout,cutout]=SelTimesAssem(twin,Tmtx,data,tRange) % Select specified time range around trial periods from continuous data in % workspace % % Aleksander PF Domanski PhD UoB 2016 % aleks.domanski@bristol.ac.uk if size(data{1},1)~=length(Tmtx) Tmtx=Tmtx(1:end-1); end for s=1:length(data) %...
e73bded5089e4da32e9ffac0b9c0ccc9b53353a30dedb9c54df78258ca588044
MATLAB
629
25
function [ T ] = CylinderFaces( NumPts, AAxis, BAxis ) %CYLINDERFACES Given a cylinder defined by two circles %with NumPts around their perimeters %Return a Nx3 matric defining faces required to render the cylinder %with the patch command T = zeros(NumPts*2, 3); N1 = AAxis ./ norm(AAxis); N2 = BAxis ...
0cdc000fb0e744ef351b051d7527e6441b3a72a358d4a1bc82140128465ed189
MATLAB
630
26
function [newdata,meandata]=tpfilter(data, timepoints) % TPFILTER - Filter two-photon data with high-pass filter % % [NEWDATA,MEANDATA] = TPFILTER(DATA, TIMEPOINTS) % % NEWDATA is a filtered version of DATA; the data are passed % through a high-pass filter with a 240s cut-off time. % The mean is then added back to th...
f9b7f9d4348e4e4b438726a4145d9d48156be2f98efa6d327c0b82c840e02ff0
MATLAB
630
27
function handles = setupNextTrial_SanesLab(handles) %handles = setupNextTrial_SanesLab(handles) % %Custom function for SanesLab epsych % %This function sets up the GUI next trial table % %Inputs: % handles: handles structure for GUI % % %Written by ML Caras 7.24.2016 global RUNTIME ROVED_PARAMS empty_cell = cell(...
0e79ee557d94e4a961c0a65f5eb85e493c90178be539929d92ee59e6dce0404a
MATLAB
632
21
function plotSwitchInitHeadingBias(frame, labels, bias_means, bias_stdevs) swAngles = unique(labels.obs_heading_drift); initHeadings = unique(labels.obs_heading_x); markers = ["^", "s", "o"]; colors = ["r", "g", "b"]; figure(5); for h = 1:numel(initHeadings) % Plot current frame error...
1485587fd6f97a1a5a52caa8934f1eb897dba39140b30bb59c751509440a8022
MATLAB
632
27
function runspksorter(Pname) clear all close all force clc % Run spike sorting functions. This is for after preprocessing steps. % Created 23 April 2016 JDY if( nargin < 1 ) subject = '255183'; session = 'ZA-54'; %'-#' = Block #% % subject = '253888'; % session = 'WA-51'; %'-#' = Block #% % ...
deabab919fbee23fb98f195c3a13700eddeca23ec7d0e3ceedffa56a680b12a2
MATLAB
633
17
function GFP = compute_GFP(scalp_data) % Compute the Global Field Power (GFP) for the input (real) vector. % % Cfr Skrandies1990_GFP or Khanna2015_microstates. % GFP: is helpful to identify overall ERP component from multichannel data. % GFP = spatial standard deviation; quantifies the amount of activity at % e...
a2015dc5ac7fd59aad907abd54b560639bd4faa017e7f0672180240b34ef8440
MATLAB
634
20
function info = DB_GetUnitInfo(unit_id) % info = DB_GetUnitInfo(unit_id) % % Retrieve lots of info about a unit's channel, block, tank, and experiment % % Daniel.Stolzberg@gmail.com 2016 narginchk(1,1); nargoutchk(1,1); assert(isscalar(unit_id),'DB_GetUnitInfo:unit_id must be a scalar value') info = mymprintf( ... ...
d22b05870eaa0e4e02ed94d5218cf9b873f5b1e3c2112be6fbc9af718b0cd4fe
MATLAB
634
25
function ImportAnnotations(self, importTable, varargin) if nargin == 3 overwrite = varargin{1}; else overwrite=false; end annotFolder = fullfile(self.ProjectPath, 'annotations'); for i = 1:size(importTable,1) currVideoName = importTable.VideoName{i}; currAnnotFile = importTable.FilePath{i}; a...
e03a75157f65656b45efcd8c91eb13c90cf944425d2f99b6b3d6e50b0c0a4bd1
MATLAB
634
21
function [upm,Momentum,InitialLearnRate,L2Regularization] = func_UsePreviousModel(PromptOption) %prompt = 'Do you want to use previous model parameters to avoid Bayesian Opt for CNN? Type Y for Yes and N for No.: '; %PromptOption = input(prompt,'s'); if strcmp(lower(PromptOption),'y')==1 upm = 1; model = load(...
d0bef0cf625670145ecf3d92d5abcc22d3360b2d1853db1533f05482dc7fd568
MATLAB
635
17
function cont = inStr(findStr, searchedStr) %inStr Shorter way to determine whether a string is contained in another % Usage: inStr(findStr, searchedStr) Find the findStr in one searchedStr % Usage: inStr(findStr, searchedStr) Find the findStr in list % findStr is searched for in searchedStr. % Return...
0232648f35ccde1add6186b93d7c48899be4a5f619733f34ce1deaafdf3fd01a
MATLAB
636
18
% part of https://github.com/LudgerS/MRSartifactRemoval % % Voigt curve with variable area. % Variable mixing of Lorentzian and Gaussian component, matched FWHM. % % Follows Bruce et al., "An Analytical Derivation of a Popular Approximation % of the Voigt Function for Quantification of NMR Spectra", Journal of...
30a7513c31f422f11e4b2037edc40e2c756f1ae14d9e604aec0dc0ae2a85c374
MATLAB
636
27
seconds = 1:1200; MLperMin_Steady = 0.3; consumed_Steady = MLperMin_Steady/60*seconds; flowRate_Pulse = 0.29; timeOn = 400; timeOff = 0; propSecON = timeOn / (timeOn+timeOff); MLperMin_Pulse = propSecON*flowRate_Pulse; consumed_Pulse = MLperMin_Pulse/60*seconds; figure; plot(seconds,consumed_Steady,'k', 'LineWidt...
63f68161c3dfa12404a87d5a7f213ac2fcf16ae4330f25058b727a68459b434c
MATLAB
640
25
function RT = get_RT_from_YAP_button(data, data_trigger, SR) % Fetch the reaction time (RT) from the NI input data from the YAP response % button. % Inputs % data: YAP RT trigger (data is a column vector). % data_trigger: trigger from the TCS2 (red plug). % data: is always O and then 5V when b...
38b866b22edbd016ae61daf416b3b9f10ff5a4ea850008e5340a5f1e5033f6b1
MATLAB
641
19
function [Tcutout,cutout]=SelTimesFRs(twin,Tmtx,data,tRange) % Select specified time range around trial periods from continuous data in % workspace % % Aleksander PF Domanski PhD UoB 2016 % aleks.domanski@bristol.ac.uk if length(twin)==1;twin =[-twin twin]; end for s=1:length(data) % across brain regions: PF...
9234b1ba9a290aef09d08537fcd52903448f3a094d1f346597ce7cc612ac585d
MATLAB
641
25
function t = TrigRPTrial(RP,trig) % TrigRPTrial(RP,trig) % t = TrigRPTrial(RP,trig) % % Use with EPsych experiments % % Returns an approximate timestamp from the PC just after trigger. Use % timestamps from TDT hardware for higher accuracy. % % See also, TrigDATrial % % Daniel.Stolzberg@gmail.com e =...
7b46692c7dbe82f7c4bd710dc5485e2b392f6825020784559b647051ae5c4074
MATLAB
643
32
function trial_type_ind = findTrialTypeColumn_SanesLab(colnames) %trial_type_ind = findTrialTypeColumn_SanesLab(colnames) % %Custom function for SanesLab epsych % %This function finds the column index for the trial type % %Input: % cellstring array of column names % %Output: % index specifying the TrialType Colu...
9559e4741a25ac70166eefe4d6e84636d43ac88717a71b248a7c6c111b1128c2
MATLAB
644
18
function [MAP, m_h, s_h] = bern_ComputeMAPandPrediction(... NA, NB, pNA, pNB) % Compute posterior MAP, mean and standard deviation, using the analytical formula for beta distributions. % % The advantage of using conjugate distribution is that posterior estimates % (mean, variance, MAP) have analytical solutions th...
208611c89b14491b218a1a6d80de9914e15bedfd7889bd9f21c987fb9529233a
MATLAB
645
28
%Author: Guanghui ZHANG %Center for Mind and Brain %University of California, Davis %Davis, CA, USA %Apr. 2024 % ERPLAB Studio function [EEGsetIndex,EEGchanindex, ERPsetindex, ERPchanindex, ERPbinindex,erpcom]= get_studio_indexes(); erpcom = ''; EEGsetIndex= estudioworkingmemory('EEGArray'); EEGchanindex= est...
e47352eaeba5b66c812429a3017ec401b21a8ca53cd0dc7a967c8d892da78772
MATLAB
646
20
function[tables] = tblist(varargin) % tblist List tables of MySQL database [mym utilities] % Inputs name - database name, string (optional, current database default) % Outputs tables - table names, (m*1) cell array % Example tblist('project') if nargin name = varargin{1}; if ~isdbase(name...
0c4102127c213851928264ffa762009b374d7e5eb3a74d82bc4d9edc88fcc030
MATLAB
647
21
% Fig7_bc % Code to generate MUA and PSTH example data from optogenetic stimulation of V6 % load MUA data from V1 and V6 addpath data load('Fig7_bc_data.mat') % plotting parameters preT = 0.6; % pre-stimulus time postT = 1.25; % post-stimulus time Fs = 1000; % sampling rate xlimPl = [-0.1 0.25+0.1]; % xaxi...
282702967c06c83ab3d41be6e8f1931450fc73843588899dd6feb3fbbba469a0
MATLAB
649
19
function [iso_surfaces_native] = extract_surface(volumes) %EXTRACT_SURFACE extract surfaces from a cell of volumes % create empty table to save final meshes iso_surfaces_native = util.create_empty_table(volumes); % extract isosurface iso_surfaces = cellfun(@(x) isosurface(x, 0), volumes.Variables, ... 'UniformOut...
450d7db66cd3af48be88f868fb7f9f86868d0e8d88606034189bfdd05fecb7bc
MATLAB
649
26
function t = TrigDATrial(DA,trig) % TrigDATrial(DA,trig) % t = TrigDATrial(DA,trig) % % Use with EPsych experiments % % Returns an approximate timestamp from the PC just after trigger. Use % timestamps from TDT hardware for higher accuracy. % % See also, TrigRPTrial % % Daniel.Stolzberg@gmail.com e...
302e5f70e4f5da7dda1042edfd9998bbc71fb23cf19cc9d938225c01a43c9645
MATLAB
650
24
function [ overlap] = TriangleIntersection( VertsOne, VertsTwo, epsilon) %I hit some rounding errors using the distanceToPlane test. Make sure %the bounding boxes overlap [numVerts, nDims] = size(VertsOne); overlap = true; for(iDim = 1:nDims) min1 = min(VertsOne(:,iDim)); max...
397c3ec82bee1a9c55927493c5ecf57324bc7fc956e003e483dd724a122f7094
MATLAB
650
20
function imageStack = imread3d(file) %IMREAD3D Reads 3D TIFF stack % Inputs: % file - file name of TIFF stack tiffInfo = imfinfo(file); % assert(tiffInfo(1).BitDepth == 8, sprintf('%s is not in 8-bit\n convert this image into 8-bit in ImageJ first\n', tiffInfo(1).Filename)) Width = tiffInfo(1)...
be93f4d728fef8d4b817de3de98b6b1bca6937e6edfa1bb70b87470f1ba5dda9
MATLAB
650
26
function xydiff = anglesubtract(x, y, angleFlag) % ANGLESUBTRACT 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 is false, returns a % non-angular subtraction. % % Rory Townsend, Oct 2017 % ro...
d38169f446e4ef8a1649929986d5c6a79b1fc275f5508f4d833253d1b3d7b6fb
MATLAB
650
22
% Converts a MatLab cell array of strings into a java.lang.String array. % % Input arguments: % str: % a cell array of strings (i.e. a cell array of char row vectors) % % Output arguments: % arr: % a java.lang.String array instance (i.e. java.lang.String[]) % % See also: javaArray % Copyright 2009-20...
f786048a979e46e3c69b8a34f2aa571d69ffbff5119ee64e41bcdeb105d6df36
MATLAB
650
23
function [fpr, fnr] = compute_error_rate_adjmat(gRefMat, gcMat) % function [fpr, fnr] = compute_error_rate_adjmat(gRefMat, gcMat) % % compare the GC network gcMat to the groundtruth gRefMat, and % output the false positive rate (fpr) and the false negative rate (fnr) nNodes = size(gRefMat,1); gRefMat = gRefMat - d...
1edee26a1b564d9ad73d946e08787f6dc21ab42d6e231313daa3ea7f1c8d7407
MATLAB
651
33
function Dab = adj_spect_dist(aij,bij,nComps,minkp) % adapted from: % https://github.com/aiavenak/matlab_code/blob/master/f_lap_dist.m if nargin < 3 nComps = 0 ; % if 0, all components end if nargin < 4 minkp = 2 ; % 2 -> euclidean distance end if nComps > 0 e_opts.tol = 1e-8; e_opts.disp = 0; e_o...
173fbeece2f244c54dc11aa5bd7d00fbbb1ec8522db3804b0d7871ac5e26a52c
MATLAB
652
27
function [CI_dp, CI_c] = getdprimeBootCI(nHits, nMiss, nFalseAlarms, nCorrectRejections) nReps = 10000; alpha = 0.05; %alpha value rng(1,'twister'); isHit = [ones(1,nHits) zeros(1,nMiss)]'; isFalseAlarm = [ones(1,nFalseAlarms) zeros(1,nCorrectRejections)]'; n1 = numel(isHit); %sample size 1 n2 = nu...
5c8e9e12fd010c2a96087fdf4015cb80fed07d7db2d4d8e179de88035037ac83
MATLAB
653
26
function handles = initializeTrialDelivery_SanesLab(handles) %handles = initializeTrialDelivery_SanesLab(handles) % %Custom function for SanesLab epsych % %This function initializes the GUI with trial delivery paused, and the %apply button disabled. % %Inputs: % handles: handles structure for GUI % % %Written by ML C...
b0979e4f7182280f4f5798694c18fb23c149e398b72aae1e49f4467601ad8704
MATLAB
653
36
axis = [0 0 1]; points = [0 0 0; 1 0 0; 0 1 0; 0 0 1; -1 0 0; 0 -1 0; 0 0 -1]; disp('Test no rotation') identity_rotmat = RotationMatrix(0, axis); identity_pts = points * identity_rotmat; assert(all(all(points == identity_pts))); disp('Test Z 90 degree r...
0ac053f21af01f1de595d4f3cbe4f9511dbfed6a2e194721088b9969cac0f118
MATLAB
654
18
function plot_first_cross(model) [epi, endo] = import_nerve(model, 'hide_plots'); load(model.paths.fibersCross, 'fibersPerFascicleCross', 'startCross'); for iFasc = 1:numel(fibersPerFascicleCross) idCross = startCross(iFasc); figure; hold on; plot(epi{idCross}(:,1), epi{idCross}(:,2),'k'); b...
298d00f4d61a207f98f708f006e2f82ef6b795c8b2f60154f1fd17ecace05d85
MATLAB
655
16
function sr = analyzetpstack_emptyslicerec % ANALYZETPSTACK_EMPTYSLICEREC - Empty slice record structure for analyzetpstack % % EMPTYSLICE = ANALYZETPSTACK_EMPTYSLICEREC % % The slice structure EMPTYSLICE has fields % dirname : the name of the directory % depth : ...
85720acfeb496772e9113ef11d5fcaa4b0524cb4fffbdfcd16fb673454d466c3
MATLAB
656
18
function [idx_by_module, module_idx] = sort_by_module(region_names) %SORT_BY_MODULE region_names = region_names(:)'; % get the row vector module_idx = modularity.get_frequent_partition(); % Sort the order of the regions in the modules to match the matrix [~,idx] = ismember(region_names, ... module_idx.Properties.V...
e334579a89a864fa6eface051018fd957123a956a21dd09255e518e67e74fa0d
MATLAB
656
27
PFC = [] CA1 = [] joint = [] %% figure;hold on % plot ((PFC./PFC(:,2))','-ob') % plot ((CA1./CA1(:,2))','-or') % plot ((joint./joint(:,2))','-og') m1 = nanmean((PFC./PFC(:,2))) m2 = nanmean((CA1./CA1(:,2))) m3 = nanmean((joint./joint(:,2))) e1 = nansem((PFC./PFC(:,2))) e2 = nansem((CA1./CA1(:,2))) e3...
82ac1762ad658a80b52aa4169c6d886737cb2488d77cb7d6eeb5c1ef4c880c40
MATLAB
657
18
function ret = crosscorr(array1, array2) %disp('run this you want'); % function ret = crosscor2(array1, array2) % Computes 2D crosscorrelation of 2D arrays % Function returns DOUBLE type 2D array % No normalization applied array1 = double(array1); array2 = double(array2); array1 = array1 - mean(array1(:)); arr...
0d0b2d5154183358b17adb44789d7af9c35a13313d2a2baa8aee32e79c625a0c
MATLAB
658
24
function qtiplus_invariants2nii(invariants, nii_h) % function qtiplus_invariants2nii(invariants, nii_h) % % writes the invariants in the structure into nifti file and attaches % the specified nifti header invs = fieldnames(invariants); n = length(invs); nii_h_mod = nii_h; nii_h_mod.ImageSize = horzcat(nii_h.ImageSize,...
b537c182f3a29acf5236d7b016f4c97a7b2303cc732d3e490bd0a3aa6778ab3d
MATLAB
658
23
function [ Structs, Locs, LocLinks ] = FetchLocalData(path) %FetchData - Collect data from a database Structs = []; Locs = []; LocLinks = []; Struct_filename = fullfile(path,'structures.txt'); Locations_filename = fullfile(path,'locations.txt'); LocLink_filename = fullfile(path,'loc...
90d396388509d97b0309d72e8ab23ab45b93ede527ba6b6285fc60de10765fe4
MATLAB
659
23
function Z1=JSD2_combined(parameter, parameters) % Function calculates the JSD from a given parameter set to a uniform % distirbuiton Liley_params; for i=1:length(parameters) ii=parameters(i); range=[lb(ii) ub(ii)]; pts=linspace(range(1),range(2),100); [kk1(i,:),x1]=ksdensity(parameter(:,ii),pts...
95c66ef915a5228a256fc0130fca195758d8177123fc516bc5a55d72a28f8451
MATLAB
660
38
function x = pollFastrak3(s,FZero,state) % x = pollFastrak3(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) ...
f58532b262ea148028686554b4a91d07f321335d9663ec060a10999c8dade759
MATLAB
660
21
function [patches] = display_multiple(iso_surfaces, colors) %DISPLAY_MULTIPLE display multiple isosurfaces in one figure % isosurfaces: Table or cell. With cell you have to provide the colors % yourself if ~exist('colors','var') || isempty(colors) region_info = util.get_region_info(); regions = iso_surfaces.Pro...
19bb1dc5b1c28edde3c70e8e47a65ea6a0968e16becc96e7351b2409eebe641d
MATLAB
661
37
function tphotonnoiseanalysis(filename, line_num,line_list); % line_num = 367 for mouse-2014-07-11-t00002-001.tif % line_num = 112 for testpollen.tif lines = []; for i=1:675, tf=imread(filename,i); lines(i,:) = tf(line_num,:); end; figure; image(lines); colormap(gray(2048)); figure; plot(lines(:,line_list(1)...
ae406a589e5af4b2c82668d3bb69d920fd1d2df7305c22d1f994ce748061b152
MATLAB
664
12
function exitSubApp(app) quitAnswer = uiconfirm(app.MainWindow,'Are you sure you want to quit?','Confirm close','Options',{'Yes','No'}); %ask user if sure they want to quit if strcmp(quitAnswer,'Yes') %if user answer was 'Yes', do the following: call_to_NIDAQ(app.CallingApp,'end'); %indicate in record...
bee70093ea5a96b85437ac1ec4fa131bbdcf96a0a9f7609c01cfa6bb01559670
MATLAB
664
27
function add_general_text(w, str_to_disp, xpos, ypos, formatted_text,... center_txt, txt_col, backgrd_col, yPositionIsBaseline) % Draw text on a screen with the Psychtoolbox. if nargin<9 yPositionIsBaseline = 0 ; end if nargin<8 backgrd_col = 0 ; end if nargin<7 txt_col = 255 ; end if nar...
14b3d3a8ee80e9539ddf89546f64fd9eaf1f83eb676c6be3b42cd293f2d3afe0
MATLAB
666
34
function self = LoadData(self, varargin) p = inputParser; addOptional(p, 'IncludeFeatures', true); parse(p,varargin{:}); inclFeats = p.Results.IncludeFeatures; verboseLvl = self.ConfigFile.GetParams('VerboseLevel'); if verboseLvl > 1 fprintf(' Loading clip data... \n') end clipT = self.ClipTable; if inclFea...
4d0a142ec55eb7a5fb1536ae02a61a8132dc538bee04eb3535f667b0e84273e9
MATLAB
666
17
function FP = compute_fp_from_path(res_list, img_size) % This function compute a fingerprint from a list of noise residuals. % INPUT: % res_list A list of residual file paths % img_size residual dimension % OUTPUT: % FP The fingerprint by simply averaging the noise residuals. Noise_sum = zeros([img...
663c5b5674267ef22764ec6d97394a84fc038d76bef763ad9cc8100dfc1d6779
MATLAB
666
32
function tanklist = TDT_RegTanks(TT) % tanklist = TDT_RegTanks % creates temporary connection to TTank.X and then closes it % tanklist = TDT_RegTanks(TT) % uses established TTank.X connection (TT) % % Returns list of registered tanks. % % DJS (c) 2010 c = false; if ~exist('TT','var') || isempty(TT) T...
db1703ad3e31d0261d70e2834c4da8b606ebf91112751f6650f4896f4a7c3c72
MATLAB
666
40
function [f,g,h] = softrec(lambda) xx_g = lambda > 30; f = lambda; f(~xx_g) = log1p(exp(lambda(~xx_g))); if(nargout > 1) g = ones(size(f)); g(~xx_g) = 1./(1+exp(-lambda(~xx_g))); if(nargout > 2) h = g.*(1-g); end end % f = arrayfun(@sr_0, lambda); % if(nargout > 1) % g = arrayfun(@drs_...
e2d29c9fd8b6a0a39d4c7356165d65dc9f4e6dc6fa90622621d147d1cac6fd29
MATLAB
666
27
function [pp, eb] = plotLineWithErrorRegion(ax, tts, y, eb_1, eb_2, color_c, lw, ls) if(nargin < 6 || isempty(color_c)) color_c = [0 0 0]; end if(nargin < 7 || isempty(lw)) lw = 1; end if(nargin < 8 || isempty(ls)) ls = '-'; end eb_y = [eb_1(:); eb_2(end:-1:1)]; eb_y(isnan(eb_y)) = 0; y(isnan(y)) = 0; %f...
67465c656b2afab9623758185c4118166c61ebc20a6f5421be9b050338167251
MATLAB
667
34
function [] = plot_smokey(xvals,yvals,ystd,color1,color2,plotpattern) if nargin < 4 color1 = [0.5 0.5 0.5] ; end if nargin < 5 color2 = [0.75 0.75 0.75] ; end if nargin < 6 plotpattern = [ 1 1 ] ; end if ~any(plotpattern) error('need to plot something yo') end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
89c8c08170d09fd7b3b611a4182633110bd57e198ebe329e77a9c522ba678da2
MATLAB
667
22
function [ Data, mainFolder, CSV_filepaths] = Load_data () mainFolder = uigetdir(); % Select your Main folder [~,message,~] = fileattrib([mainFolder,'\*']); fprintf('\n There are %i total files & folders.\n',numel(message)); allExts = cellfun(@(s) s(end-2:end), {message.Name},'uni',0); % Get exts CSVidx = ismemb...
bb0d69cfcdb20904062dfaf1077b5768bdd890b4c13ca6eb54c52b85dc7bb87c
MATLAB
668
17
function h = scree_plot(lambdas) % SCREE_PLOT Plot of the scaled eigenvalues. % % h = SCREE_PLOT(lambdas) plots the eigenvalues corresponding to a % gradient. Lambdas are scaled to a sum of 1. All graphics objects % created are stored in structure array h. % % For more information, please consult our <a % ...
c83320a5e7abcce1b75f8f3c7f47634325c1d7b0b6761c01e24e51ad3a40b329
MATLAB
670
23
function [newmask, goodinds] = removesmallspots(labeledmask, minsize) % REMOVESMALLSPOTS - Remove small spots from a labeled mask % % [NEWMASK, GOODINDS] = REMOVESMALLSPOTS(LABLEDMASK, MINSIZE) % % Removes discrete pixel blobs that are smaller than MINSIZE. The input % MASK should be labeled, such as with BWLABEL. ...
9f6f70d0a9831e0a38ae417591995a9ef0e2706cddcd8563f0bad10f34570e48
MATLAB
674
27
% Converts a MatLab array into a java.util.ArrayList. % % Input arguments: % array: % a MatLab row or column vector (with elements of any type) % % Output arguments: % list: % a java.util.ArrayList instance % % See also: javaArray % Copyright 2010 Levente Hunyadi function list = javaArrayList(array)...
c40d218ad9b7a980aaa921f1ee8325764e31d102f4fe9d8320dead9a45c06882
MATLAB
674
27
function x = correctAzi(FASTRAK) % x = correctAzi(FASTRAK) %Corrects azimuth based on translations of the head % % See also pollFastrak2, pollFastrak_InTrial2 % % Stephen Gordon 2016 x = FASTRAK; sideB = 100; sideA = sqrt(FASTRAK(9)^2 + FASTRAK(8)^2); if sideA < 0.5 || abs(atand(FASTRAK(9)/FASTRAK(8)) - FASTRAK(5)...
3c46705e5aeb38be8ce7afc273ad65473892f943519c3215d5c784430399b8a1
MATLAB
676
23
function [resultData]=jnh_FreqFilter(data,SDthreshold,Fs) %Copyright 2017, JN Hansen %data must be a two dimensional matrix %% filter by SD value - TODO only filter out if out of range resultData = zeros(size(data,1), size(data,2)); for i=1:size(data,1) for j=1:size(data,2) if(j==1||i==1||j==size(data,2)||i...
42ce09c358217a865db3d8e89d2b9df561b52c6fadba663db7b8889a590be9fb
MATLAB
678
14
function res = psignifitFast(data,options) % this uses changed settings for the fit to obtain a fast point estimate to % your data. % The mean estimate with these settings is very crude, the MAP estimate is % better, but takes a bit of time for the optimization (~100 ms) warning('You use the speed optimized version o...
8ead79da4592ec0c73c86a23237cf327a206aa48327609c4002fef0d9a7b52b6
MATLAB
678
19
function [Tcutout,cutout]=SelTimesCohereogram(twin,Tmtx,data,tRange) % Select specified time range around trial periods from continuous data in % workspace % % Aleksander PF Domanski PhD UoB 2016 % aleks.domanski@bristol.ac.uk % Tmtx=Tmtx(1:end-1); cutout=cell(1,length(data)); Tcutout=cutout; %len_ = []; ...
3799d1d3f4c157d43d5a649ed73d7f0548ecb3e17faa1afd8e5528359b05d136
MATLAB
679
34
function [L,Fr] = video_luminance(videofile) % Function calculates luminance of a video input. % Luminance (L) is returned for every video frame. Fr is video frame % rate % % % "Luminance" is approximated as rgb2hsv transformation where % Luminance ~ V = max{R,G,B} % % Severi Santavirta %% Video try obj = VideoR...
8857455ee62443c610e5322f374a54571be61abd0c2997c8e8b4ccb8d51a1b1e
MATLAB
679
38
function h = drawPerformance_CDF(X, ax, color) if isempty(X) h = nan; return end % Get signal levels attns = unique(X.Atten); nAttn = numel(attns); % Preassign N = zeros(1, nAttn); Y = zeros(1, nAttn); C = zeros(1, nAttn); % Get performance for j = 1 : nAttn rows = X.Atten == attns(j); N(j) = ...
a887e17ffe70a315b142b7feb0d984ef88112dccfeccfa318861bd50e671b72f
MATLAB
679
21
function [regions_T] = select_hemi_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 % hemispher...
3bd9898ead09ca4129f654cc9ac11ce5adb8da0ecd386d91acc030994a4d7ec9
MATLAB
684
26
function [vtxs,nvtxs] = fs_read_label(labelf) % [vtxs,nvtxs] = fs_read_label(labelf) % % Reads the indices of the vertices of a Freesurfer's label. % % Input % labelf: A Freesurfer's label file. % % Output % vtxs: Indices of the vertices (1-based). % nvtxs: The number of vertices in the label. % % $Revis...
5b4069e18b659971058529ee92723f6734c205e71f40573db5fd7354d964c91a
MATLAB
684
18
function FP = compute_fp_from_path(img_list, img_size, fp_path) % This function compute a fingerprint from a list of noise residuals. % INPUT: % res_list A list of residual file paths % img_size residual dimension % fp_path the path saves the computed fingerprint % OUTPUT: % FP The fingerpr...
ae3cefbccba26b613558a19b7999a5937313a96ba4545a2b4e5c76a27fe9e872
MATLAB
684
23
function [volume,row,col] = read_stack(img,depth,beginning_index) %READ_STACK reads the 3D tif forwardly from the beginning_index and for depth stacks % [volume,row,col] = read_stack(img,depth,beginning_index); % Inputs: % img - file to read % depth - number of slices to read % beginning_index - b...
c5210247974dea13e756c7fabc35530e500c6e255f199a8c811d653f4bcd07d9
MATLAB
685
24
% Filters matrix of signals using butterworth filter % Filters across rows (i.e. rows = channels) % If two frequencies provided, default to bandpass. If only one frequency, % must specify whether high or low pass. function [filtered_signals] = filter_butter(signals, freq, sample_rate, filter_order, varargin) n...
fa5152bb44bf81771f6989151bb06f4099e0aeab60b94aec9f3dfa65b91df481
MATLAB
685
33
function RUNTIME = ep_TimerFcn_Stop(RUNTIME,AX) % RUNTIME = ep_TimerFcn_Stop(RUNTIME,DA) % RUNTIME = ep_TimerFcn_Stop(RUNTIME,RP) % % Default Stop timer function % % Use ep_PsychConfig GUI to specify custom timer function. % % Daniel.Stolzberg@gmail.com % Copyright (C) 2016 Daniel Stolzberg, PhD % not...
d61e357710be7e2e6031d960fdd2e8a91bc3e0a5d9ddc9e2f11c7ed59fb69c1c
MATLAB
686
15
function stimulationParameters = compute_stimulation_parameters(spindleActivation, recruitmentCurve) % Input: % spindleActivation is a table with columns 't' [s], 'Recruitment' [%], and FiringRate [Hz] % recruitmentCurve is a table with columns 'Charge' [nC] and 'Recruitment' [%] % Output: % stimulationParameters is a...
61465603d8aed16ec4520e62371d2403a1a599bd64e57946fb26826e44f01e6b
MATLAB
688
31
function [chk, msgboxText] = f_ERP_chckerpindex(ALLERP, SelectedIndex) chk=0; msgboxText = ''; ALLERPinx = [1:length(ALLERP)]; if isempty(SelectedIndex) msgboxText = 'You have not specified any ERPset'; chk = 1; return end if any(SelectedIndex<=0) msgboxText = sprintf('Invalid ERPset index.\n Pleas...
8a76740e9f7024c1f155eefcd87a1f9467fedc3b862ac3e9c42d8a9532f29601
MATLAB
688
21
function [paramStruct_rescaled] = rescaleParamStruct(obj, paramStruct, scaled_WB, scaled_VT) paramStruct_rescaled = paramStruct; J = numel(paramStruct.Groups); for jj = 1:J S = numel(paramStruct.Groups(jj).T); if(scaled_VT(jj)) params_0 = obj.GMLMstructure.Groups(jj).scaleParams(paramStruct.Groups...
4618fcfbfa0565594e6dcd6f52520fffee1bc873e222b431f6eb177845d4cc89
MATLAB
689
23
function TRIALS = TrialFcn_externalStim_SanesLab(TRIALS) global TONE_CAL NOISE_CAL STIM_FILES %If it's the start if TRIALS.tidx == 1 %Load tone calibration file [fn,pn,fidx] = uigetfile('C:\gits\epsych\UserFiles\SanesLab\SpeakerCalibrations\*.cal','Select tone calibration file'); noise_calfile = fullf...
1b37f127c83dd2a936f81055cfc14d26239835f9df0d3f0dc50ed597c47e4c97
MATLAB
692
24
function t = zBUS_trig(DA) % t = zBUS_trig(DA) % % This will trigger zBusB synchronously across modules % Note: Two ScriptTag components must be included in one of the RPvds % circuits. % The ZBUS_ON ScriptTag should have the following code: % Sub main % TDT.ZTrgOn(Asc("B"))...
8e68143571af95ec56ca93bc5873896d3623041008ef0dd29f8f4cc9d80467ca
MATLAB
692
22
function [populations_tertiary_motor] = ... get_motor_fascicle_tertiary_pop(idFascicles, fibersCompart, numDisp) % output initialization populations_tertiary_motor.IIIFiberId = {}; % Generate Random seed for populations rng('default'); for iFasc = idFascicles for iDisp = 1...
1d1f556c2e6c03e2a722a6baf85690949047d7e7fe8339c349881871c104d091
MATLAB
695
28
% Add paths to the different toolboxes at the beginning of a session % VBA toolbox for Bayesian model selection. % https://mbb-team.github.io/VBA-toolbox/ addpath(genpath('./VBA-toolbox')); % EEGLAB functions useful to do the scalp plots addpath(genpath('./topoplots')) ; % Perceptually uniform colormaps a...
c549f6ebbedcc754df5153b5a0c040f8a31af82ede3ef297d3c24eb251fb026a
MATLAB
695
35
function Y = LDAproj(data,Labels) % function Y = LDAproj(data,Labels) J = func_LDA(data,Labels,'element'); t=size(J,1); %J=kmeans(data,3); %T = 20; %clusters N=300; if t<N N=t; end range=1:3:N; L=1:length(range); clust=zeros(size(J,1),length(range)); for j=L clust(:,j)=kmeans(J,range(j),'MaxIter',1000); end e...
cf10b3afc5e77e93baeb6ea6298527451902a46010d75a864f4adeabe693a821
MATLAB
695
22
function CreateCommonGeometryColladaFile(Path, FileName) %CREATECOMMONGEOMETRYCOLLADAFILE Summary of this function goes here % Detailed explanation goes here if(~isempty(Path)) if(Path(end) ~= filesep) Path = [Path filesep]; end end TargetPath = [Path FileName]; DO...
07da9e21b5891f100357c294125783c0033c82989ccc2c1cf3fbc32221afb4e5
MATLAB
696
20
% part of https://github.com/LudgerS/MRSartifactRemoval % % Normalized dispersive Gaussian curve % follows % "Dispersion corrections to the Gaussian profile describing the Doppler % broadening of spectral lines" % S. Wojtewicz, P. Wcis?o, D. Lisak, and R. Ciury?o % % lineShape = 2/fwhm*1/sqrt(log(2)*pi)*......
b2ee9c021e312abe85813aab5d367c71012aab7283bfd40551ca9c14f718a586
MATLAB
696
25
function [pgonEpi, pgonEndo, pgonElec, geomAS] = nerve_cross_section(model, args) arguments model (1,1) Model args.iActiveSites = [] args.projectAS = false; end [~, activeSites] = load_active_sites(model.paths); if isempty(args.iActiveSites) activeSitesSel = activeSites; else activeSit...
9d374557def7f83aafbd6ebc1be57668c5ec407334ba4bef750d3ed73fdb807e
MATLAB
698
20
% PURPOSE: uiputfile that leaves the calling window in front % % FORMAT: % % [filename, pathname, filterindex] = erplab_uiputfile(...) % % Takes and returns exactly what uiputfile does. The only difference is that the % windows that were in front before the dialog opened are raised again afterwards, % so a nested GUI s...
b3c009e21bd7acdb41d18fac4509b01740a9750a4116b3176a40bfdcd6c3c5a4
MATLAB
698
32
%% A function replacing MATLAB's dir % Returns a listing of files in a directory, not including '.' and '..' % (these are returned by the library version of the function dir). % % 3 December, 2021 function listing = dir2(varargin) if nargin == 0 name = '.'; elseif nargin == 1 name = varargin{1}; else e...
fa8ca7a97d89460b81c9a496e614ff7f850be6f4e27a8bca902d7ae33c748155
MATLAB
698
20
% PURPOSE: uigetfile that leaves the calling window in front % % FORMAT: % % [filename, pathname, filterindex] = erplab_uigetfile(...) % % Takes and returns exactly what uigetfile does. The only difference is that the % windows that were in front before the dialog opened are raised again afterwards, % so a nested GUI s...
542b0830089fc6c384fd662c9ce5311b7ab1206d78bf9679557c99a58167b126
MATLAB
699
32
%% tank = 'DILL_MU_Map'; channels = 1; block = 'Block-46'; % latest block if empty fcn = @SCRATCH_OnlineFRF; T = timerfind('Name','ONLINETIMER'); if ~isempty(T), stop(T); delete(T); end T = timer( ... 'BusyMode', 'drop', ... 'ExecutionMode','fixedRate', ...
3003136eae6fd803975d2bb7be46efcd9c0b4b1e7db4b29221967eca879c4948
MATLAB
700
26
%% A personal function for saving figures into specified formats (such as colour eps). % f is the handle of the figure to save % filename is the name to give the file without the file extension % extension is the file format in which to save the figure function savefigas(f,filename,extension) % Check if the chosen ex...
a8834128945fa0028f636bbc1a2320f8401b0ab9058b8897cabfea5bf6b14e35
MATLAB
702
27
function f = findFigure(tag,varargin) % f = findFigure(tag) % f = findFigure(tag,PROP1,VALUE1,PROP2,VALUE2,...) % % Find the handle to a figure by it's tag property. % % If a figure by the provided name does not exist, one will be created with % that name. Optionally, figure property-value pairs can be specifie...
d1eaceb9e80a0187c2989d469faad31e2968b160518faff077c5238bf2b9f63f
MATLAB
702
21
function [N_points_vox,v_vox,N_faces_vox,f_vox]=readvoxel(name) fileID = fopen(name,'r'); format='%s %f %s'; data = textscan(fileID,format,1,'HeaderLines',4,'Delimiter',' ','CollectOutput',1); N_points_vox=data{1,2}; %save points format=' %f %f %f'; data= textscan(fileID,form...
2ff10e63b52a32f5086754dba52b4be122f81c7450720e16f1995165db77bee9
MATLAB
703
14
%----------------------------------------------------------------------- % Job saved on 18-Jun-2022 17:06:39 by cfg_util (rev $Rev: 7345 $) % spm SPM - SPM12 (7771) % cfg_basicio BasicIO - Unknown %----------------------------------------------------------------------- clear matlabbatch subjfolder = dir('F:\fMRI_QC\fm...
c958eb37e094df1bab357bf6ada8f912c6f2826f267d5ed9f094de950af41f9d
MATLAB
703
27
function [Fp, overestimate] = computeISIViolations(st,tauR,tauC) %%% From Hill et al., 2011 N = numel(st); T = st(end) - st(1); a = 2 * (tauR - tauC) * N^2 / T; r = sum(diff(st) <= tauR); if r == 0 Fp = 0; overestimate = 0; else rts = roots([-1, 1, -r / a]); ...
5182c3d86632379a9dc69983a04640344f070a234775c5010f39d5fa487650ba
MATLAB
704
37
%inspect patterns used in RSA if 1 clear all %load saved rdm data rdmPath = '/data/hammer/space2/mvpaGoals/data/golsaRSA/'; rdmFile = '19-Oct-2017.mat'; load([rdmPath rdmFile]); layerNames = fieldnames(rdm); end %assumes rdm and patternData use same order of field names layerName = 'state';...
c16708f9fc7ac41c4a7bca82980681d1a1abcba69d0e5e5ed812ff25d59840e0
MATLAB
705
36
function [ angle, axis ] = AngleAndAxis( V1, V2 ) %UNTITLED2 Summary of this function goes here % Detailed explanation goes here if(V1 == V2) angle = 0; axis = [0 0 1]; return; end N1 = V1 ./ norm(V1); N2 = V2 ./ norm(V2); %Supposedly more precise than acos(dot(N1,N2)) near multiples of PI angle = ...
33cf67ff2606dbd875b1d5dafa4316cf739e233db3d4ed611342b16feccff2c9
MATLAB
710
23
% part of https://github.com/LudgerS/MRSartifactRemoval function areas0 = getAreaStartingValues(spectrum, frequencyAxis, centers0, FWHMs0) freqResolution = frequencyAxis(2) - frequencyAxis(1); areas0 = zeros(1, numel(centers0)); for ii = 1:numel(centers0) cutPeak = spectrum((frequencyAxis > (cent...
57b4900750bbc908edfe2449803e483eff4d9f61d5564dd422caaed241eadb0d
MATLAB
710
24
function t=Vec2Dof(dim,t,auxT) %% Transforms vector of tractions in array format (values of tractions % for each dof) into dof format: % t=[node direction[1,2,3] value] % INPUT: % auxT = array with displacement dof for each traction value % auxT(i)=displacement dof of traction in t(i) % t = a...
7b95d5d2eabd94d4fd669b64cdc0f0ec1a7a8cb8c227629a11c04f76be109a06
MATLAB
710
13
function [VsTimeintAnim_Perc]=VStimecourse(VsTimeintAnim,numint,int) %%% get procentual data %%% VsTimeintAnim_Perc=NaN(4,numint*5,size( VsTimeintAnim,3)); VsTimeintAnim_Perc(1:3,:,:)=( VsTimeintAnim(1:3,:,:)/(int*60))*100; VsTimeintAnim_Perc(4,:,:)=( VsTimeintAnim(3,:,:)./ (VsTimeintAnim(2,:,:)+VsTimeintAnim(3,:...
adc604481a0d2b31c6ed30ac26877d6d75d853d61706c71f2b90dc8b98a4044a
MATLAB
710
15
%%% download data file : "Fig7_PartialCorrelation_example.mat" %%% download code: "MR_Heading.m" and make sure it is included in the Matlab path for k=1:size(Spike_rate_relative,1) %%% 1:vestibular, 2:visual tmpp = cell2mat(heading_regr(k,:))'; XX{k}(:,1) = tmpp./sqrt(sum(tmpp.^2)/length(tmpp)); XX...
5f26c5e1ed4d718c69a9eeb9c6a733ad2a360ffc09fac3ee0fd9f263f09bc1ab
MATLAB
711
15
function writeplxdata(plx_id,ch,freq,ts,units,npw,wave) % now the spike waveforms, each preceded by a PL_DataBlockHeader n = length(ts); for ispike = 1:n fwrite(plx_id, 1, 'integer*2'); % type: 1 = spike fwrite(plx_id, 0, 'integer*2'); % upper byte of 5-byte timestamp fwrite(plx_id, ts(...
fd2fe17fd71942cc5fbdc81abb368c0442cda5b867c86aa16aecf2ecfc2856a5
MATLAB
711
34
function [circ] = circle(info, prec, closed) % CIRCLE Creates a circle from center point and radius. % % [circ] = circle(info, prec) % % Inputs: - info: vector containing xc, yc and radius % - prec: number of points for circle % - closed: close the shape (default true) % Output: - circ: ...
3096be7dc166af5059dfdf9f8c62588f47d58b84f8e6a750f1d4c2f260e7fdc6
MATLAB
712
34
function [D] = mydiv2d(PX,PY) [m,n] = size(PX); D = zeros(size(PX)); L = zeros(size(PX)); for yi = 2:m for xi = 2:n dvx = PX(yi,xi) - PX(yi,xi-1); dvy = PY(yi,xi) - PY(yi-1,xi); D(yi,xi) = dvx + dvy ; L(yi,xi) = L(...
23a0fba09736c4cbf8fd2f32e31fa33a07187886b4d85fb658be2204c3b25961
MATLAB
714
40
function x = pollFastrak2(s,FZero) % 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 tr...
b01de1632d2699fe9d76058f8f49ddfb5c291d291c9fb6b6cda290054f7ce99a
MATLAB
714
24
folder = uigetdir(get_conf().solutionsDir); choice = questdlg('Do you want to clear solutions and meshes?', '', 'Yes', 'No', 'Yes'); clearModel = strcmp(choice, 'Yes'); comsol_connection(); modelFiles = dir(fullfile(folder,'**', '*.mph')); [~, i] = sort([modelFiles.datenum]); % Sort by last modified date mod...
417d5a74d548a90d6600f505c5096fed76f4cbc566c0ba79bc5b88b3361777be
MATLAB
715
22
function out = slice_stl(in, planeP, planeV, roundPrec, solid) arguments in % Triangulation or filename of stl planeP (1, 3) % Point in plane, if given scalar it is auto-broadcasted to vector planeV (1, 3) = [0, 0, 1] % Vector perpendicular to plane roundPrec (1, 1) = 3 % Number of decimals to c...