sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
aea3eaa6a3542174fad89ea4f08dac9987d60d1f2df131a1763ae295fabf8a03
MATLAB
827
39
% Get data from a figure with multiple data sets function t = getDataFromFigureMultiple(fn,name1,name2,name3,name4) fig = openfig(fn); axObjs = fig.Children(2); dataObjs = axObjs.Children; x1 = dataObjs(8).XData; % index y1 = dataObjs(8).YData; % index x2 = dataObjs(6).XData; % middle y2 = dataObjs(6).YData; % midd...
ca01d374000a98f1020e1b3744e40dc4a0890dece4123d233ba1fb9b44d150e2
MATLAB
828
27
function show_some2d(folder, n, cmap, savefig, save_path, save_name) img_names = dir(folder); assert( length(img_names) >= (n+2)); figure; set(gcf, 'Units','pixels', 'Position', [0, 0, 400*n, 400]) for i = 3 : n+2 axis equal; img = imread(fullfile(folder, img_names(i)...
337e1974b4d895dc078fc2dd9a1af21ea29fb6af1c7998cf28a34408f5636c05
MATLAB
837
36
function [z_info, currentZ, totalZ] = zpos(im_str) %ZPOS gets z-plane information from the image string of bioformats idx_1 = strfind(im_str,'Z='); if isempty(idx_1) warning('No Z information available, assuming 1 Z plane'); z_info = "Z=1/1"; currentZ = uint16(1); totalZ = ...
fc147bff0497004ab056f338a66034b356d3c6bec16cd057b4b4f6e4a2bcf6d0
MATLAB
838
27
function [percepThresholds, locations] = load_percep_thresh(nerveModel) %LOAD_PERCEP_THRESH Summary of this function goes here % Detailed explanation goes here dataPath = get_data_dir(); load(fullfile(dataPath, ... 'Validation\perceptual thresholds\perceptual threshold experimental data.mat'), ... '...
1442ee2d250148b03d7fdf410cf481a030f8c8599fd8d1615697914f54fb1a82
MATLAB
839
40
function [a1,a2,d2,eegz] = fitness_calc_swd(A1) % Simulate model for SWD Liley_params; fs = 255.5661; tcut = 2; % apply for transients TDatend = 2.3047; T1=0:1/fs:TDatend+tcut; T2 = 0:1/fs:TDatend; T1 = T1*1000; % cnvert to ms or=-1; paramstoest = 1:22; paramsinput = [paramsvec, zeros(1,10)]; paramsi...
96db6e77cc9c4a4b1afd72e96af826bdd1a95b4494df3b69ae4431b55860865d
MATLAB
839
39
function [meas] = get_comm_corr(wei,dist) inv_wei = 1./wei ; meas = nan(4,1) ; m = logical(triu(ones(s+ize(wei,1)),1)) ; % eff (inv shortest path) try sp = 1./distance_wei_floyd(inv_wei) ; meas(1) = corr(sp(m),dist(m),'type','s') ; catch warning('could not comput eff') end % -search information try ...
348c44c4a1b93532c3b67ae32588671e8fec0f5948f3415262a2b117b5001da9
MATLAB
840
23
function [cutout,Tcutout]=SelTimesAssem2(twin,Tmtx,data,tRange,bw) % Select specified time range around trial periods from continuous data in % workspace % % Aleksander PF Domanski PhD UoB 2016 % aleks.domanski@bristol.ac.uk nTrial = size(tRange,1); LTr = length([-twin:bw:twin]); if size(data{1},1)~=length(Tmtx) Tm...
065cd82e16f96749f0880329a8880aae45b7d1872ed132dbbe43a9a1715d76f8
MATLAB
842
23
function [response] = inputvalue(prompt,dlg_title,num_lines,def) BackERPLABcolor = erpworkingmemory('ColorB'); if isempty(BackERPLABcolor) || numel(BackERPLABcolor)~=3 || any(BackERPLABcolor(:)>1) || any(BackERPLABcolor(:)<0) BackERPLABcolor = [0.7020 0.77 0.85]; end ForeERPLABcolor = erpworkingmemory('ColorF')...
ceb594fa6b28c2e1beeb54a1838be55e1d9644f88e29b77f9775850ff425bd76
MATLAB
842
25
function TRIALS = TrialFcn_BasicCharacterization_SanesLab(TRIALS) global TONE_CAL NOISE_CAL %If it's the start if TRIALS.tidx == 1 % if TRIALS.TrialIndex == 1 %Load tone calibration file [fn,pn,fidx] = uigetfile('C:\gits\epsych\UserFiles\SanesLab\SpeakerCalibrations\*.cal','Select tone calibration file');...
c37cae37a0e25a46597d58e90ce25b8e23cbab16321a8e76db15ebf4768307f7
MATLAB
843
35
function makevisible_SanesLab(h,dev,module,param) %makevisible_SanesLab(h,dev,module,param) % %Custom function for SanesLab epsych % %This function makes certain GUI text and dropdown menus visible if the %correct parameter tags are available in the circuit. % %Inputs: % h: handles of dropdown menu or text % dev: ...
b1c7d149289edbd02e3ff2511d716b30a2ea87d28202bd2681c7afce6cf59d03
MATLAB
844
28
function [extrema,inds] = minmax(X) % UltraMegaSort2000 by Hill DN, Mehta SB, & Kleinfeld D - 07/08/2010 % % minmax - Simultaneous overall smallest and largest components. % % Usage: % [extrema,inds] = minmax(X) % % Description: % Y = MINMAX(X) returns the minimum and maximum values, of the array X % such that...
578914ce7ad34eab43a2cb9bd623a37c6c9b945a3181291ed04ad954c2884889
MATLAB
845
37
function [Ix,Iy] = forward_gradient_2d(I) % Iy = volshift(I,1,0,0) - I; % Ix = volshift(I,0,1,0) - I; % Iz = volshift(I,0,0,1) - I; % Ix(:,n,:) = 0; % Iy(m,:,:) = 0; % Iz(:,:,o) = 0; [m,n] = size(I); Ix = zeros(size(I)); Iy = Ix; for y = 1:m-1 for x = 1...
7c4053d3aeec9ff9f31546d5ce5621dd882a7b95191a04075483ba9d735815a8
MATLAB
845
36
function [c_info, currentC, totalC] = channel(im_str) %CHANNEL gets channel information from the image string of bioformats idx_1 = strfind(im_str,'C='); if isempty(idx_1) warning('No channel information available, assuming 1 color image'); c_info = "C=1/1"; currentC = uint16(1); ...
a3f7bffa35d0355a9fe42c84874fc175b3706c867c091bbdd30170eb766a6877
MATLAB
845
32
function [semValue] = sem(array,weight,dim) %SEM measure the standard error of the mean for array along a specific %dimension(dim) % Author: Ali Karimi <ali.karimi@brain.mpg.de> if ~exist('dim','var') || isempty(dim) dim = 1; end if ~exist('weight','var') || isempty(weight) weight = ones(size(array,1),1); end ...
8cc8cd778d4db1b77f294a6db5d5b8bd6b580297f1ba9c71c00365c84f79a69a
MATLAB
846
23
function [cross_coords,xCenter,yCenter]=initialize_fixation_cross(window,theRect) [screenXpixels, screenYpixels] = Screen('WindowSize', window); % Set up alpha-blending for smooth (anti-aliased) lines Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA'); % Setup the text type f...
a85e4092d600d1df1135e0aa7166504dc2d9648da66229100538e38d575ebb09
MATLAB
847
33
function Qdec2 = getQdecVarData(Qdec1,Vars) % Qdec2 = getQdecVarData(Qdec1,Vars) % % Returns the data for the variables in Qdec table Qdec1 that are named in % Vars. % % Input % Qdec1: Two dimensional cell string array of Qdec data (eg. read with % fReadQdec). % Vars: One dimensional cell string array. % % Output % Q...
3f692d7a1a575835f9a8aee40f7c49c5bba13e85bc1046a477e212256cc01c27
MATLAB
849
26
function [fft_feature] = extract_fft(sig,SR) L = size(sig,1); Y = fft(sig); P2 = abs(Y/L); P1 = P2(1:round(L/2)+1); P1(2:end-1) = 2*P1(2:end-1); f = SR * (0:round(L/2))/L; block_11 = mean(P1(f<=50)); block_21 = mean(P1(f>50 & f<=100)); block_31 = mean(P1(f>100 & f<=150))...
5e30c1697023c6d2068e5ab34d6546c4a2015222c5b200b1f8e963dcc428b187
MATLAB
851
33
function xc = getCrossCorrelogram(dat1,dat2,lags,noResign) if ~exist('noResign','var') noResign = 0; end % get cross-correlogram nMice = numel(dat1); xc = cell([1,nMice]); for k = 1:nMice lagbins = int64(lags{k}/(lags{k}(2)-lags{k}(1))); xc_tmp = nan(numel(lagbins),1); sTot = size(dat1{k},1); for ...
5e88e36488b0a159ecf5bd63068bc24dd903f24f98a6ad4a0d7f10b8c14e1a7d
MATLAB
851
40
function [C,Cthr] = get_cohesion_matrix(D, sym) % https://www.pnas.org/content/119/4/e2003634119 % https://github.com/moorekatherine/pald/blob/main/R/pald_functions.R if nargin < 2 sym = 1 ; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% n = size(D,1) ; C = zeros(size(D)) ; for ...
588d8abb484b49d105b3019b3a76f83150d2e58afc4bb4f7ee22564f8a99a93c
MATLAB
854
26
function Name=RegionLabeltoName(Label) % Creates the name of a folder that will contain the analysis results % % INPUTS: % - Label: region of interest in the analysis. Initialized in RunQUIQI.m. % OUTPUTS: % - Name: cell array of strings. %_____________________________________________________________...
4a34348cfc386cac308b754995029307e748bbd2e4e34c294df5bda62246521b
MATLAB
855
34
function out = FCLSU(HIM,M) % Fully Constrained Linear Spectral Unmixing % Perform a Linear least squares with nonnegativity constraints. % -------------------------------------------------------------------- % Input: HIM : hyperspectral image cube [nbands x nsamples] % M : set of p endmembers [nbands...
11ab7b38e0b6a804f2a865c51b4906252e1fd4e8fa150cee4cfcb27d1e4ebeea
MATLAB
858
43
function DI=dunns(distM,ca) %%%Dunn's index for clustering compactness and separation measurement % dunns(clusters_number,distM,ind) % clusters_number = Number of clusters % distM = Dissimilarity matrix % ind = Indexes for each data point aka cluster to which each data point % belongs uu=unique(ca) ; nn=length(uu...
b20166d2b97d88b6746fc816c7d2ff63b95cb64bc5e5875169b9bb727524f573
MATLAB
858
37
function [TT,tanks,TDTfig] = TDT_SetupTT(TT) % TT = TDT_SetupTT % [TT,tanks] = TDT_SetupTT % [TT,tanks,TDTfig] = TDT_SetupTT % TDT_Setup(TT) % % Initialize TDT TTankX activex control in invisible window and return % handle to control (TT), registered tanks, and a handle to the invisible % figure (should close ...
025f434df614a1808af7c959e3f5c4770390a3f08bf7435c363bd3ab8312e594
MATLAB
859
33
function AddFileAnnotations(self, annotFilePath, overwrite) % Add annotations contained in 'annotFilePath' to annotations % table self = Load(self); if isempty(self.AnnotationTable) return end fileAnnots = readtable(annotFilePath); annotT = self.AnnotationTable; if overwrite labelsStr = repmat({'UL'}, size(...
078dda5fc678603a0290fee31339fef2434d6fb18ae8db8a92ddc6d1fbe156e4
MATLAB
859
26
function [out_dataSorted,out_forceSteps] = dose_responseSort(in_sweeps, in_sweepsCol,in_row, in_forceSteps,in_sortByForce) % Sorts force-response data from sweeps{} array by force level % in_sweeps: sweeps{} array with all data % in_sweepsCol: column of interest from sweeps{} (7=AUC, 9=peaks) % in_forceSteps: 1x5...
52b6fc7a337a906b157f4b2698eaf3253053ac8073308699a6839d62220054a9
MATLAB
859
20
% part of https://github.com/LudgerS/MRSartifactRemoval % % Normalized Gaussian curve % follows Bruce et al., "An Analytical Derivation of a Popular Approximation % of the Voigt Function for Quantification of NMR Spectra", Journal of % Magnetic Resonance (1999) % % lineshape according to Bruce et al. % lineS...
f0297684677383ff12410b6e296e5674eae4c9d7d223ceba7b6dd85c7c3a3b79
MATLAB
860
33
function [pband,ptot,per_power] = bhpower(filepath, Fs,freqRange) %BHPOWER % Calculates percentage of power in a specified frequency range, such as % that of a breath-hold task. % Reference: https://www.mathworks.com/help/signal/ref/bandpower.html %%%%%%%%%%% % Inputs: %%%%%%%%%% % filepath = full path to input ...
63572ff7b8701e829a79c7de112e3186c1b224acf8a42f0b8590d0ffcb810d1d
MATLAB
863
37
function d=spkd(tli,tlj,cost) % % d=spkd(tli,tlj,cost) calculates the "spike time" distance % (Victor & Purpura 1996) for a single cost % % tli: vector of spike times for first spike train % tlj: vector of spike times for second spike train % cost: cost per unit time to move a spike % % Copyright (c) 1999 by Daniel Re...
abc16043abad8cf07c47fcfceb8432fca8bfc1619692b90cac69e2f8ff7918d5
MATLAB
863
35
%% Initialize the critic curr_input = input{1}; critic.rewTime = round(find( [0 diff(curr_input(2,:))]>0 , 1 ) / 100); critic.cueTime = ceil(find( [0 diff(curr_input(1,:))]>0 , 1 ) / 100) + 1; critic.steps = size(curr_input,2) / 100; % 100 ms long boxcar basis set critic.rpe_rew = 0; critic.rpe_cue = 0; critic.w = zer...
0d3c1de40557c4cca2879bdf48b2f0e79d68ed4c00a8376ed52b7091d308c93e
MATLAB
864
21
% Signal Processing Toolbox check % axs Nov 2020 function SigProcT_here = SignalProcessingToolboxCheck % Get Toolbox list from ver tbxs = ver; [a, tbxs_n] = size(tbxs); tbx_cell = cell(1,tbxs_n); tbx_cell = {tbxs.Name}; SigProcT_here = any(ismember(tbx_cell,'Signal Processing Toolbox')); if SigProcT_here == 0 % ...
cb93fb5291abedd3fdd5df6b8678f1e76311163613c83e65dd03a9e0f5b68edf
MATLAB
864
38
function plot_qti_invariant(s,inv_name,disp_range) % function to plot one invariant for different fits/protocols % n_fits = max(size(s)); % by default, we take the middle slice to be shown tmp_inv = getfield(s{1},inv_name); slice = round(size(tmp_inv,3)/2); % open a figure figure() % for each fit (invariant structu...
77cde14f7b39436d32092d5359953f2ffbc4f202175b57d596fd0f0c6e163c6f
MATLAB
868
41
function output = erpgettoolversion(field) output = []; if nargin<1 help erpgettoolversion; return end if nargin==1 % read try output = erplab_session_state('get', field); if ~isempty(output) return end paths = erplab_user_paths; if ~isempty(paths.legac...
89d00edcf82123476ba59ad6d4425efa7c5d271461b16f6d98e01b9594510a7e
MATLAB
868
36
function varargout = SelectTrial(TRIALS,parameter) % val = SelectTrial(TRIALS,parameter) % [val,i] = SelectTrial(TRIALS,parameter) % % Select values from a particular trial index in the structure TRIALS. For % use with custom Trial Selection functions. See help DefaultTrialSelectFcn % for more info. % % NOT...
eb44565fb4230f78b910684c1f9aa0ec0cdc59ee27274795e35ae8e6ec69b032
MATLAB
869
28
function in_use = DB_InUse(table,id,state) % in_use = DB_InUse(table,id) % in_use = DB_InUse(table,id,state) % % Use to retrieve or alter 'in_use' field of a table. Always returns % current value of 'in_use' field before changing the state. % % state: 'yes','no','toggle' % % DJS 2013 if nargin < 2 || nargi...
23455617432fcd7cd75b99d3fd2558bff4225d810a6f361da37821826771bf08
MATLAB
871
28
function FigOnTop(figh,state) % FigOnTop(figh,state) % % Maintain figure (figure handle = figh) on top of all other windows if % state = true. % % No errors or warnings are thrown if for some reason this function is % unable to keep figh on top. % % Daniel.Stolzberg 2014 % narginchk(2,2); assert(ishand...
b4282c9d7acb0380a3e6bc14287b214da810e6dc859fac77d961204a92c7bde4
MATLAB
872
47
function [X,fixedPoint] = checkDuration3(currentValue, Target, initBuffSize) % [X,fixedPoint] = checkDuration3(currentValue, Target [initBuffSize]) % %Takes in the current region number and adds it to a list of default size %20. When the standard deviation of the list of values is < 1 then X = 1, %otherwise X = 0. % %...
514cd58cc9bff2b06640085c8093fcf7b854881d423fa913f1b2d54286ca8425
MATLAB
873
29
function [band_sig] = ieeg_butterpass(signal,band,srate) % function to dobandpass filtering for specified band % input: % signal = time X channels; % band= [start:stop] or [start stop]; %automatic stuff: num_chans=size(signal,2); % number of channels Rp = 3; Rs = 60; % third order Butterworth delta = 0.001*2/srate; lo...
445017558e68a3ee8cd2dbea82dd2440a8232e5397ad88e77d3dd4ade3c0800f
MATLAB
874
39
function h = drawPerformance_SNR(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); % Get performance for j = 1 : nAttn rows = X.Atten == attns(j); N(j) = sum(rows); Y(j) =...
4e221fe3b3fed8e4f16546a545ef0a4c74e4289392e7f017aa6f532f8be1013a
MATLAB
874
21
function [XTrainNewClass,YTrainNewClass] = augmentDeepInsightClass(XTrain,YTrain,num,j,inx) inx_class = inx(double(YTrain)==j); cnt=1; for k=1:length(inx_class) for n=k+1:length(inx_class) XTrainNewClass(:,:,:,cnt) = uint8(0.5*(double(XTrain(:,:,:,inx_class(k)))+double(XTrai...
d76dae6d935c506cf978059ae33bf1152fdbe90fa4e729a4bf6294b6ef1a703f
MATLAB
874
34
function [Y,mri] = fs_read_Y(Y_fname) % [Y,mri] = fs_read_Y(Y_fname) % % Reads Freesurfer's .mgh or .mgz data files (eg. cortical thickness data % files generated with mris_preproc). % % Input % Y_fname: A Freesurfer's cortical data file. % % Output % Y: Data matrix (nmxnv, nm total # of maps, nv #vertices). % mri: ...
44dad4001fbc1697f4ac5f12aa272ee9362129cff6d16bf99451eba3baadb968
MATLAB
875
30
function Plot_individual_VSspecs(DoseColors,FigureID,mousenames,numanim,f,WAKEspec_dose_anim,NREMspec_dose_anim,REMspec_dose_anim,PlotConditions) VS_spectra_allVS={WAKEspec_dose_anim,NREMspec_dose_anim,REMspec_dose_anim}; pcolor=cell(length(PlotConditions),1); for pcol=1:length(PlotConditions) pcolor{pcol}=rgb...
29a7bad622bcbf715459f1688753befa95b47a47a99c519a05d49890e3ca66f9
MATLAB
879
36
function [yticksLabel, msgboxText]= f_decimal(yticksLabel,ytick_precision) msgboxText = ''; if nargin<1 help f_decimal; return; end if isnumeric(yticksLabel) yticksLabel = num2str(yticksLabel); end if nargin<2 ytick_precision=0; end yticksLabel = char(yticksLabel); if isempty(str2num(yticksLabel...
82dddbe963bfe2be5f2c7d2559cff8b4ea0cd95ee17c059d7ed17fd00dbd0865
MATLAB
880
26
function [mti2,starttime] = tpcorrectmti(mti, filename,globaltime) % TPCORRECTMTI - Correct NewStim MTI based on recorded times % % [MTI2,STARTTIME] = TPCORRECTMTI(MTI, STIMTIMEFILE,[GLOBALTIME]) % % Returns a time-corrected MTI timing file given actual timings % recorded by the Spike2 machine and saved in a file na...
1c6d01c7f6df9c0b3878c9cca90b9538f0f8334c5f0bdfa15991ab37e53140fa
MATLAB
883
30
function [RestEMG]=ExtractRestEMG(address,ID, begin, opt) % in=[address '\EMG\' ID '\' ID '_S1R' int2str(run)]; %in=[address '\EMG\' ID '\' ID '_S1REST']; in=[address '\EMG\' ID '\' ID '_S1R0']; load(in); % Ancho de la ventana de inactividad Window=0.25; % Índices de comienzo de señal de EMG a considerar ...
a6f0c8ae9711ee77327c645c84bd2eab3d8243a9bcdaf9920d8db0fbf82d2a4f
MATLAB
884
30
function CreateProject(self) %CREATEPROJECT Creates new DeepActionProject % CREATEPROJECT(SELF) creates project folder in SELF.PROJECTPATH and % config file (if already exists, asks user whether to overwrite) if ~isfolder(self.ProjectPath) mkdir(self.ProjectPath) else msg = sprintf('Project with path %s al...
16f444c2425f781761b6bbab925d5e12b9bcff94ad6addd2fcb0e8cd8e1fe3c2
MATLAB
885
30
function criticals = compute_criticals(perm_cluster_t, n_betas) % Compute the criticals based on the distributions in perm_cluster_t. % % perm_cluster_t: (n_perm, n_betas, 2, 2) cluster_threshold = 95 ; % indices: % n_betas % 2: I1 and I2 % 2: mean cluster, max cluster criticals = zeros(n_beta...
78d7a4e6c92728376ba08b31fa2dd010e758a989d461f754f8fc3a32b34a10c9
MATLAB
885
37
function [n,J] = quadlength(x) % quadlength -- Find length and dyadic length of square matrix % Usage % [n,J] = quadlength(x) % Inputs % x 2-d image; size(n,n), n = 2^J (hopefully) % Outputs % n length(x) % J least power of two greater than n % % Side Effects % A warning message is i...
715e045c82d400da48124ebf2b7356403646d52548084b932d7e591ac5a5316c
MATLAB
888
28
function Gradient=gradientinterpol_noGPU(Gradient_ori,node_iris,pointsTetra,bar) DT=Gradient_ori(pointsTetra,:); DT1=reshape(DT',3,node_iris,4); DT2=permute(DT1,[3 1 2]); bar2=reshape(b...
8bb41457b771eab45fb11d49e16a3d1a97f00abe3ba7d555bcc0a9aefe8dc7c8
MATLAB
888
32
function tH = ieeg_RenderGifti(g,varargin) % function to render a gifti % % input: % g: gifti file with faces and vertices % varargin{1}: sulcal_map, can be loaded with read_curv('lh/rh.sulc') % % Viewing Angle: can be changed with ecog_ViewLight(90,0), changes both % angle and light accordingly % % DH 2017 % co...
a0568a29ac440e23dfd21bae56f1d9cde4c841d6a9fcd9857dbc24c85759ceb9
MATLAB
890
28
function [n, npw, ts, wave] = plx_waves(filename, channel, unit) % plx_waves(filename, channel, unit): Read waveform data from a .plx file % % [n, npw, ts, wave] = plx_waves(filename, channel, unit) % % INPUT: % filename - if empty string, will use File Open dialog % channel - 1-based channel number % uni...
a6ca899fc757ca8c44bfcec0342cdcb13aaed22a449858ca324c3db35fddd789
MATLAB
890
31
%% Set some variables tank = 'TankName'; block = 1; %% Read continuous LFP from tank cfg = []; cfg.tank = tank; cfg.blocks = block; fullLFP = ft_read_lfp_tdt(cfg.tank,cfg.blocks); %% Call custom trial function (trialfun_tdt) to segment continuous LFP data cfg = []; cfg.tank = tank; cfg.blocks ...
85031d5fa0b1137be33bea02bb474eb7b52a513c78ae497aebf097cf77a05c6e
MATLAB
896
35
function [prior_setup] = getNscales(prior_setup, dim_T, dim_P) D = numel(prior_setup.T) + 1; for ss = 1:D if(ss == 1) % V prior_setup_ss = prior_setup.V.setup; dim_U = dim_P; else %T{ss-1} prior_setup_ss = prior_setup.T(ss-1).setup; dim_U = dim_T(ss-1); end NS = 0; ...
4e9fa5e1f026145ba23d5a8595b0ee01420bc6ed7b6cac7aeef13ffd6af77152
MATLAB
898
34
function cvals = Calibrate(vals,C) % cvals = Calibrate(vals,C) % % This function uses the Matlab PCHIP function in order to estimate values % between points (e.g. tone frequencies) which were measured. % % C is a calibration structure saved from a call to the CalibrationUtil GUI % % vals : value to calibrate ...
7a9705be766aa913be0ea3809e762b2c21cc2125d2ad4b8b2d9b568cf9c1fd1e
MATLAB
898
39
function step3a_getCooling_nTrials if nargin ==0 pathname = Cloudstation('Vowels\Perceptual_Constancy'); end pathname = fullfile( pathname, 'Cooling\Data\Cross-referenced Behavior'); % Get files files = dir( fullfile(pathname, '*.mat')); % For each file for i = 1 : numel(files) % Load data load( fu...
e8c4b7656fd2b1ab2829579e80085f382772ab5f5c21f9041193557ab0892602
MATLAB
898
22
function NoiseClean = WienerInDFT(ImNoise,sigma) % function g = WienerInDFT(ImNoise,sigma) removes periodical patterns (like the blockness) from input noise in frequency domain % Used to remove blockness and other artefacts from noise extracted from JPEG images % INPUT: % ImNoise noise extracted from one i...
846da0d5cbae6d99cedcc574a3bfbcc85733ba5d5a6aaabe7128f1137c0c97d3
MATLAB
899
29
function point = random_point(shape) % See https://it.mathworks.com/matlabcentral/answers/483706-generate-random-number-inside-a-closed-area %% Triangulate tri = triangulation(shape); XY = tri.Points; %% Calculate areas v1 = XY(tri(:,1),:); v2 = XY(tri(:,2),:); v3 = XY(tri(...
b8fd404784a2222a29d927f442c9b47813275b3768b98b98f4738823f2cd35b1
MATLAB
900
23
% TWOPHOTONGLOBALS - Declares global variables for TWOPHOTON analysis package % % Parameters for configuration -- See help SETTWOPHOTONCONFIGURATION % % TwoPhotonPlatform - The name of the Platform we are using % TwoPhotonSynchronization - The name of the Synchronization method we are using...
2577e75447a7c27a6dfae326d9f9824ce1f3c7399a92e70aaf5ea0f0d07e594c
MATLAB
902
33
p = 0.5:-0.1:0; for id=1:length(p) [k,alpha,f]=stability_anesthesia_fieldmodel(p(id),'bottom'); [TheoryWaveVol(id),TheoryWaveVol_largeWave(id)]=speed_by_LR(k,alpha,f); end % figure; % plot(p,TheoryWaveVol,'o-');hold on; % plot(p,TheoryWaveVol_largeWave,'o-');hold on; % set(gca,'xdir','reverse'); % ylabel('10...
f7cb9f3e9a6e64324fa967db64f85da6c71b081ceb8caa003d7d48e50c55a1a3
MATLAB
902
35
function save_plot(dirPlots, name, painters) arguments dirPlots, name = [], painters = true end if isempty(name) t = sgtitle(); if isempty(t) name = gca().Title.String; else name = t.String; end end if ~isfolder(dirPlots); mkdir(dirPlots); end if painters ...
1cb6e463c81973ad3081a8b854b9d60917a78f82ebb7c15fb470802ebad144e7
MATLAB
903
26
function [volumes] = read_nifti_folder(nifti_path, hemisphere) %READ_NIFTI_FOLDER read nifti files within a folder % get .nii and .nii.gz files nifti_dir = dir(fullfile(nifti_path, '*.nii*')); nifti_dir_T = struct2table(nifti_dir); row_names = cellfun(@(x) extractBefore(x, '.nii'),... nifti_dir_T.name, 'UniformOut...
815d1ae702283857523c51dfc0b5e467ad102a701a41767af79bf8a806601c65
MATLAB
903
35
function handles = findRewardType_SanesLab(handles) %findRewardType_SanesLab(handles) % %Custom function for SanesLab epsych % %This function sets GUI parameters based on the reward type. % %Inputs: % handles: GUI handles % %Example usage: findRewardType_SanesLab(handles.module,handles.dev) % %Written by ML Caras ...
f629f03a8133671f8f74ee5ef66b23a6620e9b42c0598243a6309c27592fd51a
MATLAB
904
21
function [outputArg1,outputArg2] = plot_epineurium(epiData) %PLOT_EPINEURIUM Plot the extracted geometry from STL files. % can deal with several epineurium regions % By Carla Hetreau - 10.2021 hold on; for idCross = 1 : length(epiData) if ~isempty(epiData{idCross}) nan...
c320cca8f268c8022e386f60ba41fe7dd2809aed04da25a681a39a808898a113
MATLAB
906
37
function fWriteQdec(fname,Qdec) % fWriteQdec(fname,Qdec) % % Writes cell string array Qdec to a Freesurfer's Qdec table data file. % % Input % fname: The name of a Qdec table data file. % Qdec: Two dimensional cell string array with the data. % % $Revision: 1.2 $ $Date: 2015/01/06 17:14:53 $ % Original Author: Jorge ...
edb7371719fd0f8910d970565491189a464d1fb73089bf1ca26c268f7cdf6cf7
MATLAB
906
25
function TGM_erp = f_compute_TGM_mvpa(mvpc,svm_predict_TGM,tst_target_TGM,svm_scores_TGM,OutcomeMetric) % fprintf('Computing Temporal Generalization Matrices (ACC & AUC)...\n'); nTestT = size(svm_predict_TGM,3); TGM_erp = nan(nTestT, nTestT); for Numoftest = 1:nTestT tst_target = squeeze(tst_target_TG...
ee61acd691b8b0fb6598cebe73ccf63c76f713bc7d8d524bd8b5639045e449c1
MATLAB
906
29
function theseSubs = ccep_getSubFilenameInfo(myDataPath) % input: bids datapath where derivatives from av_ccep are saved % returns list with all subject names, sessions and runs % % dhermes 2020 theseSubs = []; % get all subjects tempSubs = dir(fullfile(myDataPath.output,'derivatives','av_ccep','sub-*')); for kk = 1:...
5d79594fd342a21373f60ee723269dd0b1c01a48de2a1e1b9eac11736eec85aa
MATLAB
909
37
function [xmin, xmax, ymin, ymax] = rect_approx(poly, plotr) % RECT_APPROX Approximates a polygon to a rectangle that passes through its % farest vertices. % % [xmin, xmax, ymin, ymax] = rect_approx(poly, plotr) % % Input: - poly: vector of x and y coordinates of the polygon in columns % - plotr: t...
f5d404bc33bbd5e1e96a09bbf7fd66b9afd43be432823513a3960ef6dab81d51
MATLAB
910
36
function time_idx = compute_time_CC(all_h) % Based on a h-mask, compute connected components of 1's accounting for % channel topography. % % Inputs % all_h: (n_chan, nT_data) ; % % Outputs % time_idx: time index of the cluster including all input channels. [nchan, nT] = size(all_h) ; h_tot = sum(...
68c1ceb82085dd381b5f2f41569a739a25917613e25b381fecf3c799829c544a
MATLAB
912
38
clc; clear; close all Fig5b=figure(); Ntrials_3=20000; %Ntrials_3: number of learning cycles to learn the background. %There is no embedded pattern in afferents. %(Note initial conditions in this step are from step 2) N_mu=500; %There are \mu independent embedded patterns, 500 simulations (number of simula...
26f48570651390e9e2a15bc736a2e9c448e079bba1b4c88280069e3ec4b5d300
MATLAB
916
26
function cm_data = my_blues2(m) % Copied from %https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/_cm.py % cm = [... 0.96862745098039216, 0.98431372549019602, 1.0 ; 0.87058823529411766, 0.92156862745098034, 0.96862745098039216; 0.77647058823529413, 0.85882352941176465, 0....
485fad032c3aac533a9d1da4e03c1eea9f43be79f2304605dac6baf4028f0d7a
MATLAB
916
36
clc; clear; close all Fig5a=figure(); Ntrials_3=20000; %Ntrials_3: number of learning cycles to learn the background. %There is no embedded pattern in afferents. %(Note initial conditions in this step are from step 2) N_mu=500; %There are \mu independent embedded patterns, 500 simulations (number of simula...
a887a523fd17306a3b50079b7652aa2c0a2211f0b23f825d39ba490f8cf3f36a
MATLAB
917
23
% Quality control Q5 % Display the functional image after normalization with reference to the MNI template % Xin Di, July 13, 2022 clear subjfolder = dir('F:\fMRI_QC\fmri-open-qc-rest_bias_corrected\sub*'); for subji = 1:length(subjfolder) imgs = char(['F:\fMRI_QC\fmri-open-qc-rest_bias_corrected\' subjfolder(su...
2d6e0ed926f5d95aca677b8c28b97f31679a84f3d5a69e03005b54c2d1bf4d44
MATLAB
924
20
function [MAP, m_h, s_h] = mar_ComputeMAPandPrediction(NBgA, NAgB, NAgA, NBgB, pNBgA, pNAgB, pNAgA, pNBgB) % 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) ...
79fe618a122a07a6543cb04d0b09ff2c29b1450551acc134b9c5fdf31099b244
MATLAB
924
23
% Quality control Q1c % Plot the first functional image and check its intitial position with reference to the MNI template % Xin Di, July 13, 2022 clear subjfolder = dir('F:\fMRI_QC\fmri-open-qc-rest_bias_corrected\sub*'); for subji = 1:length(subjfolder) imgs = char(['F:\fMRI_QC\fmri-open-qc-rest_bias_corrected...
0520c8b74269d407740c9542bde5905e1b7e3c0e3ea934fb2e4920a785ac5024
MATLAB
927
34
function pthresh = lme_mass_FDR(p,fdr) % pthresh = lme_mass_FDR(p,fdr) % This function has slightly modified the freesurfer's fast_fdrthresh % function (jbernal modification 2010) % % p = list of p values between -1 and 1 % fdr = false discovery rate, between 0 and 1 % % Based on Tom's FDR.m from % http://www.sph.um...
1251ee8dce4a2335c6aa6c326bab83d23b9467d5572bfb1db41852b36e20210c
MATLAB
928
35
function motif_class = network_motif_classification(n1, n2, t1, t2) vec = [0,n1,n2]; n_distinct_neurons = length(unique(vec)); list_vec = [n1, n2, t1, t2]; if t1 < t2 n1_new = n1; n2_new = n2; t1_new = t1; t2_new = t2; else n1_new = n2; n2_new...
851daa87f6dbb30a5804e6b9efaac4217cd59cd7bb9e83a4fca8c4a2a734e92c
MATLAB
929
25
function [tc, coefVar]=WaveNoise(coef,NoiseVar); % Model each detail wavelet coefficient as conditional Gaussian random % variable and use several two-dimensional moving windows to estimate the % variance of each wavelet coefficient in conjunction with a Wiener-type % denoising filter %Input: % coef: ...
8c9a166a8474de1d65b1f36929dec285a025efe29db62c4d362ff4213b038220
MATLAB
929
31
function [params, precomputedPortion] = scaleWB3(params, couplingGroup) % i.i.d non-mean Gaussian over spike history coefficients & constant K = size(params.B,1); H = double(params.H); w_mu_idx = 1; w_mu = H(w_mu_idx); w = double(params.W); params.W(:) = w + w_mu; precomputedPortion.T = []; %% linear terms if(K ...
de3b2286c65e7c28dc86e60653424b7d6a6b5cc4c8909b3c4104651becd23b20
MATLAB
932
21
function [roi_info] = get_roi_info(roi_names) %GET_ROI_INFO get the information about hemisphere and ROI name roi_info = cellfun(@(x) regexp(x,'([L, R])_(\w*)_roi.mat', 'tokens'), ... roi_names, 'UniformOutput', false); roi_info = cellfun(@(x) {x{1}{1}, x{1}{2}}, ... roi_info, 'UniformOutput', false); roi_info ...
2bb629e47896b31393f9f96e1ec9b7c523c3ccbf40edda2ccbbb568565ff95ca
MATLAB
933
34
function pthresh = SStat_mass_FDR(p,fdr) % pthresh = SStat_mass_FDR(p,fdr) % This function has slightly modified the freesurfer's fast_fdrthresh % function (jbernal modification 2010) % % p = list of p values between -1 and 1 % fdr = false discovery rate, between 0 and 1 % % Based on Tom's FDR.m from % http://www.sp...
9b389782ac5581f811f269f3b0efce6cd344f92cd631751d760a6ae8f317166e
MATLAB
933
27
%% read cortex surface from gifti gifti_name = dir(fullfile(util.get_data_dir, ... 'template_surfaces/*.gii')); template_surf = cell(size(gifti_name)); for i = 1:length(template_surf) cur_name = gifti_name(i); template_surf{i} = util.get_surface_from_gifti... (fullfile(cur_name.folder, cur_name.name...
68d59b421c998593a0823f08148df04c61bee32f4b3bb93d9cd0c844b92afacc
MATLAB
934
36
function [pid P] = calcpid(SA, Na, SB, Nb, T, Nt, Ntrl) % Sample probablity distributions from discrete data and use them % to calculate a PID with Iccs % SA - source A (integer values in range [0, Na-1] % Na - number of bins for SA % SB - source B (integer values in range [0, Nb-1] % Nb - number of bins for SB % T -...
21af4e4d16945881dbe01828dba9183114aa116754c8e9b33d3fcd318321a660
MATLAB
935
27
function [p_anova_corr, pvals_T] = anova1(cur_split, taste_names, stub_rows) %ANOVA1 arguments cur_split taste_names stub_rows = '' end g_ids = cellfun(@(taste_names, beta_array) repmat(categorical({taste_names}), ... length(beta_array), 1), taste_names, cur_split,'UniformOutput', false); cur_split_arr...
736648b068d4aa33a58d57ec81073da0098829b7f864ae5bedcaf65339188a99
MATLAB
935
31
function R=shuffwei_partial(W,frac) % R = shuffwei_partial(W,frac) % Shuffle a fraction frac of the weights in connectivity matrix W to give % random matrix R, preserving adjacency matrix (i.e., zeros do not move). % % Inputs % W = weighted connectivity matrix % frac = scalar 0<frac<=1, shuffle thi...
65212be934ea76bff79c8a5a075e74e0a18d856e81598dd757f57b35b218f940
MATLAB
936
37
function [ ] = show_state(params, res_file, fr, cm, range) %show_state(params, res_file, fr, cm, range) % Display linear drive in 3D % % Input: params - model parameters (with cells' coordinates) % res_file - path to a file containing the simulation results % fr - simulation step to display ...
6c652f130bec8481410b66213a7232bd469a30d6e87dab567c55a1b120c96e6b
MATLAB
936
48
function run_simulation_Part1(Le) filename = sprintf('rest_Ly300nm_Li1000nm_Le%dnm', Le); % Set up parameters Li = 1000; % nm Lm = 5; % nm Ly = 300; % nm Lz = 300; % nm w_K_channel = 6; % nm w_Na_channel = 2; % nm dx_min = 0.5; % nm dy_min = 1; % nm dz_min = 1; % nm dt = 2e-8; % ms Tstop = 1e-2; % ms G ...
8aa068850fd3084f53db78123d0f3dde67af9823e961b172e465f45126dfd573
MATLAB
936
28
function mydata = analyzetpstack_loadrawfile(ds,stackname,dirname) % ANALYZETPSTACK_LOADRAWFILE - Load a raw tuning curve file % % MYDATA = ANALYZETPSTACK_LOADRAWFILE(DS,STACKNAME,DIRNAME) % % will attempt to load raw tuning curve data from the experiment data % that is being read by a DIRSTRUCT object DS, with ANA...
3e6ff88d3836de09e5b15ae4a8cbbc95278c6dd38d742022887d7fb882fc4067
MATLAB
938
29
function [overlap_raw,overlap_norm,labelnum]= maskoverlap(labeledmask1,mask2) % MASKOVERLAP - Compute overlap of spots from 2 masks % % [OVERLAP_RAW,OVERLAP_NORM,LABELNUM]=MASKOVERLAP(LABELEDMASK1,mask2) % % Computes the 'overlap' of each spot in the labeled mask % LABELEDMASK1 (labeled with a function like BWLABE...
89deffcb7d8cc85cbdc4cdf3fbb125909ed48013514fde8c490f4943e921758e
MATLAB
938
31
% Publicly accessible dependent properties of an object. % % See also: meta.property % Copyright 2010 Levente Hunyadi function dependent = getdependentproperties(obj) dependent = {}; if isstruct(obj) % structures have no dependent properties return; end try clazz = metaclass(obj); catch %#ok<C...
86deeaeb815fe7db66fd3d49569cee0b77407a4a0719a9bcbc932f585de27741
MATLAB
939
34
function Cov_comp = getCompCov(X,code,P) dataA = getOrgData(X,code,P); s = size(dataA); nStimImp = s(2); [nfold,folds] = getFolds(s,P.foldtype); Cov_comp = nan(max(P.dim.pcL),nfold); for ff = 1:nfold idxfold = folds{ff}; % Get train set spkData_train = dataA; spkData_train(idxfold) = nan; % Ge...
fe896200efe2beee0f2a2d0bd817799750dbf8f8d37bbc7a6bdcfba96b394545
MATLAB
939
31
function d = DB_GetRIFResp(unit_id) % d = DB_GetRIFResp(unit_id) % % Retrieves Rate-Intensity Function analysis (RIF_mdanalysis) of unit_id of % the currently selected database. % % The function also sorts the subfields by stimulus level in ascending % order. % % June 2014 Daniel.Stolzberg@gmail.com ...
1f829a00b6ef24fd469381ad55565eecc28ab06f6db1f6792d8d7ace5b1f5af5
MATLAB
940
22
% Quality control Q4 % Check registration between the functional and anatomical images % Xin Di, July 13, 2022 clear subjfolder = dir('F:\fMRI_QC\fmri-open-qc-rest_bias_corrected\sub*'); for subji = 1:length(subjfolder) imgs = char(fullfile('F:\fMRI_QC\fmri-open-qc-rest_bias_corrected', subjfolder(subji).name, '...
36572aed205fc119a38e841b66ed73f6ea3988f02d297f10a7f4d9ad9ed0379b
MATLAB
940
26
function [xpos_data,ypos_data] = get_data_from_normalized_units(ax_orig,X_norm,Y_norm) % Convert the xpos_data and ypos_data vectors, expressed in data units, in % normalized units. ax_ylim = ylim(ax_orig) ; ax_xlim = xlim(ax_orig) ; % Annotation: normalized units so that (0,0) is the lower left corner % of...
332ffde090518a2e6f40711c707854ff0ad115fff0eb3a92a525d781edef4d02
MATLAB
943
34
function [Dataout, EPStr]= f_checktable_gridlocations_waviewer(Data,LabelStr) countEp = 0; EPStr = ''; Dataout = cell(size(Data,1),size(Data,2)); Data = string(Data); for ii = 1:size(Data,1) for jj = 1:size(Data,2) count = 0; try [C,IA] =ismember_bc2(strtrim(char(Data(ii,jj))), string(L...
898a140b31e0efb6775894db52dc34abc62c074094ae52b5c88391c2b810b295
MATLAB
943
27
function dirtpexp_assocs fitzlabtestid; % make sure this is in tpassociatelistglobals; s = input('Should we clear current associate list? (y/n) :','s'); if s=='y'|s=='Y', tpassociatelist = tpassociatelist([]); end; r = input('What is PND of ferret? (enter -1 to skip) :'); if r>0, tpassociatelist = [ tpassociatelis...
24ba230c96d89cee0111148e70fd385bb79c82541ab91576b3b45d2367195dfb
MATLAB
945
39
function my_save_fig(fig_h, fn_save, eps_fig, fig_fig, pdf_fig) % Save figure fig_h. if nargin<5, eps_fig = 0 ; end if nargin<4, fig_fig = 0 ; end if nargin<3, pdf_fig = 0 ; end if eps_fig file_extension = '.eps' ; format_to_save = 'epsc' ; elseif fig_fig file_extension = '.fig' ; for...
ad9b3e48840181198cfeb9edafc419169e69d4c19dfb9b2dfcdd0372f1785dab
MATLAB
945
29
function plotPerformance global gf if sum([gf.abortTrials, gf.performance(1,:), gf.performance(2,:)]) > 0, axes(handles.axes2) cla % clear all current objects n = 100./gf.TrialNumber; %Percentage conversion up here to save repetition hold on bar(1,gf.abortTrials*...
70cbd833f2bdb19914dbdbe6135bccb20f2cb3f4d5593da296f8801df5d969de
MATLAB
946
34
%% Produce a Bland-Altman plot for two measures % Also known as mean-difference plots. The title, axis labels, and legend % can be produced by uncommenting the appropriate lines. % % 6 December, 2021 function f = blandAltmanPlot(x,y,xString,yString,titleString) average = mean([x y],2); difference = x-y; f = figur...
5f5056ae84ef6e7548f325b3262c9da4ad0894acae8c8482c79ba568a2b1994e
MATLAB
947
32
function [user_input] = dlgPrompt(context) %UNTITLED7 Summary of this function goes here % Detailed explanation goes here switch context case 'baseline window' prompt1 = sprintf(' Already pre-set to (-5s to 0.1s).\n Change to:\n\n Baseline start (s):'); prompt_full = {prompt1, 'Baseline end (s):'...
b644633ee11abfd9107542a517289e6ae0e80356e23f3279de9e23e0f0de581c
MATLAB
949
35
function portlist = scanports(portlimit) % Function that scans for available serial ports. % Returns cell array of string identifiers for available ports. % Scans from COM1 - COM15 unless portlimit is specified, % then scans from COM1 - COM[portlimit]. % version 1 by Robert Slazas, October 2011 % check for existing se...
d06ac8c55dbd6ade9640c8cda0f81ab948c89bf19a3a8b91e3f8e2004ee97563
MATLAB
949
32
function [version, version_string] = readPVScanVersion(fid) % readPVScanVersion - Read the version of the PrairieView scanning program from a file % % [VERSION,VERSION_STRING] = READPVSCANVERSION(FID) % % Given a file ID number FID of a PairieView/PrairieScan XML file, % this function reads the file and looks for...