sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
cc3b1e0c2559139153e10690b8c4345fd4b53a8b9a7b0bac5d246ca0d8e24c1e
MATLAB
450
19
function BackupAnnotations(self) t = now; d = datetime(t,'ConvertFrom','datenum'); d.Format = 'yyyy-MM-dd_HH-mm-ss'; backup_folder = fullfile(self.ProjectPath, 'annotations_backup', char(d)); mkdir(backup_folder) if self.VerboseLevel > 1 fprintf('Backing up annotations to ./annotations_backup/%s... ', char(d)) e...
5e7a88cec7c6a58f7944f78fecc1c72741d702a8518051a9c3db7f54bd80c985
MATLAB
453
18
function mptag = ModifyParamTag(ptag,c) % mptag = ModifyParamTag(ptag) % % Helper function that takes a string and replaces non-alphanumeric values % with underscores (or optionally, c). % % Daniel.Stolzberg@gmail.com if nargin == 2 assert(ischar(c) && isscalar(c), 'If specified, c must be a single char...
0aa20079c1061e71875cc776a65c8d40ee39e58f2b1d297cae0d2d4f89e5c199
MATLAB
454
18
function [f,g,nh_2] = poissSoftRecLL(x, y, dt) if(nargout > 2) [rate,drate,d2rate] = kgmlm.utils.softrec(x); g = -drate*dt + y.*(drate./rate); nh_2 = sqrt(max(0, -1 * (-d2rate*dt + y.*((d2rate.*rate - drate.^2)./(rate.*rate))))); elseif(nargout > 1) [rate,drate] = kgmlm.utils.softrec(x); g = -drat...
d5d6499d04395dfb9609c18e6e5b8362d685f44b45552f95f02e0f8204e82e63
MATLAB
455
12
function [svm_predict_TGM,tst_target_TGM,svm_scores_TGM] = f_test_all_times_TGM(blockDat_filtData,blockNum,train_b,mdl,tstl) for t_test = 1:size(blockDat_filtData,3) dataAtTest = squeeze(mean(blockDat_filtData(:,:,t_test),3)); tstD = dataAtTest(blockNum==train_b,:); [preds, scores] = predict(mdl, tstD...
842519ec75281483a85f61eca5c5719599cf885db551b69f9dec4069bc3a92dd
MATLAB
456
23
datadir = 'E:\RawData\PPP_236393\'; filenames = dir(fullfile(datadir,'*.mat')); filenames = {filenames.name}; for ii = 1:numel(filenames) load(fullfile(datadir,filenames{ii})); if isfield(epData.epocs,'DLAM') epData.epocs.dBSP = epData.epocs.DLAM; epData.epocs = rmfield(epData.epocs...
e8e75343bbe5391501d6f0eda60cb346fb7a015cb061c6df6432da2860637992
MATLAB
456
15
function [control, cooled] = filterByTemperature(X, options) if isempty(X) [control, cooled] = deal([]); return end % Split by temperature coolThreshold = options.coolThreshold; warmThreshold = options.warmThreshold; controlRows = X.LeftTemperature >= warmThreshold & X.RightTemperature >= warmThreshold; cooledRo...
54d7b5e1ac57c1e3c49d1e04855bda2ccf9e0930bbbdfa9d99cd7e81e272aeb8
MATLAB
458
18
cd('/data/hammer/space0/model/nz_goals/tests/mgTask/') clear all mgNet; mgRunTrial(n, e, 1, 2, 2); plotItems = {'state', 'adjFuture', 'proxPast', 'next', 'stateSim', 'goalOut',... 'qIn', 'qStore', 'qOut', 'n_bg', 'motorIn', 'motorOut', 'conjDes',... 'conjObs', 'conjOut'}; times = [.05,30]; fileName = ''; %...
6a26da5d99846b6ed3c7fcd34b6c29e2a69e192d8e72cd3f8daa6aebafa77fd1
MATLAB
458
18
function UpdateAnnotationsFromClipTable(self, varargin) if nargin == 2 clipTable = varargin{1}; else clipTable = self.ClipTable; end uniqueVids = unique(clipTable.Video); for i = 1:length(uniqueVids) isCurrVid = strcmp(clipTable.Video, uniqueVids{i}); currVidT = clipTable(isCurrVid, :); currAnnotT...
7978e5fa9018127a078f9a2e2aec8774f9eeddd990e8339e9a3a1055ba78a42e
MATLAB
458
15
function build_neuron_dll(nrnModel) pathToModFiles = ['neuron-demo\neuron\' nrnModel]; pathToDLL = fullfile(pathToModFiles, 'nrnmech.dll'); if ~isfile(pathToDLL) pathToNrnivmodl = '%NEURONHOME%\bin\nrnivmodl.bat'; [status, cmdout] = system(sprintf('cd %s & %s', pathToModFiles, pathToNrnivmodl)); if status =...
cc7c1e72254c8571c00cf3fae4c71d5a71388137c97b6de251470bb4ac9cd5e2
MATLAB
458
18
% Textual representation of any MatLab value. % Copyright 2009 Levente Hunyadi function s = var2str(value) if islogical(value) || isnumeric(value) s = num2str(value); elseif ischar(value) && isvector(value) s = reshape(value, 1, numel(value)); elseif isjava(value) s = char(value); % calls java....
1644ddb5abe06e387b74476c5b6d7a8ecb4edd8bb8d709615ac651a375e8a1fc
MATLAB
459
22
function self = Load(self, varargin) % Load annotation table from file if nargin == 2 includeAll = true; else includeAll = false; end if ~isfile(self.FilePath) return end s = load(self.FilePath, 'AnnotationTable'); self.AnnotationTable = s.AnnotationTable; if self.MultiCam && ~includeAll ts = self.A...
9e6757615e3d576c0952bfe140d9bac75806a14bb6d8ac2d485c21b5e5dbe05d
MATLAB
459
25
function ind = findColumnIndex_SanesLab(handles,colnames,colstr) %Custom function for SanesLab epsych % %This function finds the index of colstr in colnames %Inputs: % colnames: cell array of column names % colstr: string containing column name of interest % % %Written by ML Caras 8.4.2016 global RUNTIME if RUN...
3516168ce2b3517f1a6584e30db50f2347ddbd93cfdf414a07ac003e0fcc09dc
MATLAB
460
20
function handles = updateNextTrial_SanesLab(handles) %handles = updateNextTrial_SanesLab(handles) % %Custom function for SanesLab epsych % %This function updates the GUI Next Trial Table %Input: % handles: GUI handles structure % %Written by ML Caras 7.27.2016 global USERDATA %Create a cell array containing the in...
6c8b407759c92fee3c47151511233c03ec5a404fdb4e7eae185a410d69ede076
MATLAB
460
17
function plot_nerve_section(model, args) [pgonEpi, pgonEndo, pgonElec, geomAS] = nerve_cross_section(model, args); figure; hold on; axis equal; plot(pgonEpi); plot(pgonEndo); plot(pgonElec); cellfun(@(as) plot(as(:,1),as(:,2), 'r', 'LineWidth', 3), geomAS);%plot(pgonAS); % for iLineAS = find(lineAS) % ...
fd9f11312c0b3cebb231ddca2001b6ea24e535997297508f6c243103d629e80d
MATLAB
461
16
function folder = make_dated_folder(parentFolder, baseName) if ~isfolder(parentFolder); mkdir(parentFolder); end if exist('baseName', 'var') folder = fullfile(parentFolder, [baseName ' ' datestr(now, 'yyyy-mm-dd HH.MM.SS')]); else folder = fullfile(parentFolder, datestr(now, 'yyyy-mm-dd HH.MM.SS')); end ...
756c4cb30c8deb15ef573e16bd1993e7b46b833c73e4538889782dea6c356afe
MATLAB
462
9
function myelinfiber_density = builtin(nerve) myelinfiber_density_file = dir([get_base_paths().dist 'myelinfiber_density*' nerve '*.mat']); if isempty(myelinfiber_density_file) fiber_distribution.builtin.myelinfiber_densityVSage_generator; myelinfiber_density_file = dir([get_base_paths().dist 'myelinfiber_d...
27af6e9b9bd2da0f66eb9a02ca03f8317277d5c124815bbe462be45ca511a82f
MATLAB
463
26
function x = correctAzi_1D(FASTRAK) % x = correctAzi_1D(FASTRAK) %Corrects azimuth based on translations of the head % % See also pollFastrak2, pollFastrak_InTrial2 % % Stephen Gordon 2016 x = FASTRAK; sideA = FASTRAK(9); if abs(sideA) < 1 return end if sideA > 0 angleB = 90 + FASTRAK(5); angleA = asi...
ec26243d085702023bcc8bd1bdc42484650359e20e4be26aa08f4570da2454b6
MATLAB
463
15
function [annotIdxs, unannotIdx] = GetAnnotationIndices(self) self = self.Load(); if isempty(self.AnnotationTable) annotIdxs = []; unannotIdx = []; return end isAnnot = self.AnnotationTable.Type == categorical({'I'}) | ... self.AnnotationTable.Type == categorical({'A'}) | ... self.Anno...
4094935d9135747fb1e80b527c613453faee9627a7d64a07b060bad09e0c6974
MATLAB
466
20
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 = '231516'; session = 'B'; Pname = '/Users/justinyao/Sanes Lab/Experiments/PROJECTS/AM RATE/Ephys/processed_data/'; end H = Spi...
9b52c625e13a1fb56533057d55d0311898f8ec153115741b881c43fa8c8361e2
MATLAB
466
18
function x = compareHeading(curHeading,Headings,Tol) % x = compareHeading(curHeading,Headings,Tol) % % Compare the current heading value to a 1xN vector of target Headings +/- % a specified tolerance. % % Stephen Gordon 2016 Hvec = repmat(Headings,2,1)+Tol*[-ones(size(Headings)); ones(size(Headings))]; for x = 1:le...
fd6587c43979acec2ef89c3983adb4a4abb3b18e733d4432910dcbd75cc41820
MATLAB
466
20
function dnrg = video_differentialEnergy(videofile) % Function calculates the difference between voxels between adjacent frames % Estimate of "movement/change" of image % % Severi Santavirta & Juha Lahnakoski vidIn = VideoReader(videofile); dnrg = zeros(vidIn.NumFrames,1); imLast=zeros(vidIn.Height,vidIn.Width,3); t...
8e44fc9b7179e05be274f219ebfc55e1353a29b7cdfeec6b68bc8316ab532dfc
MATLAB
467
13
function [im,fname]=tpreadframe(dirname,fnameprefix,cycle,channel,frame) %TPREADFRAME % read frame from multitiff % % 2008, Alexander Heimel % 2017, Steve Van Hooser % fname=fullfile(dirname,tpfilename(fnameprefix,cycle,channel,frame)); cycle_string = ['Cycle_' int2str(cycle)]; %im=imread(fname,frame,'inf...
39aa4c78fc35c51e3123e02dee817a7739f4042716b558ffa2995f732f34d74a
MATLAB
468
13
function [subjects, electrodes] = scrape_stored_data() subjects = {dir('data\Nerve\*_noElectrode').name}; subjects = cellfun(@(n) n(1:end-12), subjects, 'UniformOutput', false); electrodes = cell(1, numel(subjects)); for iSubject = 1:numel(subjects) subj = subjects{iSubject}; electrodes{iSubject} = {dir(['dat...
22c094ba52e593203807c36f9e92f111726bad6fc17eeb9184009103eabc5c65
MATLAB
469
23
function testFASTRAK() try if isempty(FASTRAK) || ~isa(FASTRAK,'serial') || isequal(FASTRAK.Status,'closed') FASTRAK = startFastrak; set(FASTRAK,'BaudRate',115200); %fprintf(FASTRAK,'u'); end catch me if isequal(me.identifier,'MATLAB:serial:get:invalidOBJ') FASTRAK = startFa...
1090a56b388c22a65028d71837dcf7c696aeb8d6950c54a83426dfc1b7c052a2
MATLAB
470
15
function [ci] = getBootCI(vals, alpha) %getBootCI Calculation of bootstrap confidence intervals for 'vals' %times, 10000 bootstrap samples per default % 'vals' are the input values. First dimension are observations % (e.g.trials): vals = [trials x time] nBoots = 10; bootType = 'per'; % 'per' or 'bca' (slow) f =...
151f62078b32d7d0c28017fdc425430cc0d7b5d23d323f09faac3958cd7744ef
MATLAB
470
15
close all hidden; exportResults = true; [swEsts, nswEsts, swLabels, nswLabels, bias_means, bias_stdevs] = simulateSwitchNoSwitch(runParallel=true); plotFrame = 34; plotSwitchInitHeadingBias(plotFrame, swLabels, bias_means, bias_stdevs); if exportResults expPath = 'results/switchExp'; % Labels writet...
2af91799b2c018e8ba7ba85c98f7469980aca7755d451853a097c01ffc530d42
MATLAB
470
18
function RUNTIME = ep_TimerFcn_Error(RUNTIME, AX) % ep_TimerFcn_Error(RUNTIME, RP) % ep_TimerFcn_Error(RUNTIME, DA) % % Default Error timer function % % Use ep_PsychConfig GUI to specify custom timer function. % % Daniel.Stolzberg@gmail.com 2014 % Copyright (C) 2016 Daniel Stolzberg, PhD % not doing a...
29690728712e0319f32fc545e0808909c25f5c864d1becc50c86c6aaee35c62a
MATLAB
471
10
function SeeProgress(i) % SeeProgress(i) outputs i without performing carriage return % This function is designed to be used in slow for-loops to show how the calculations progress % If the first call in the loop is not with i=1, it's convenient to call SeeProgress(1) before the loop. if i==1 | i==0, fprintf('\n ...
cb483390a5d04a01ef78e45dbfbce4e496c07025c19a87cc1449af0a5b682d7f
MATLAB
471
16
function AddFloatElement( DOM, Node, Name, Matrix ) %ADDFLOATELEMENT Summary of this function goes here % Detailed explanation goes here ChildNode = DOM.createElement(Name); numCols = size(Matrix, 1); if(numCols > 1) ChildNode.appendChild(DOM.createTextNode(num2str(reshape(Matrix', 1,[]), '%g ') ...
2d13c6131d872f6c88ed8c880b472fc6759a0147aa28fee09f18483242588c70
MATLAB
472
26
function diffStr = f_setdiffstr(StrLarger,StrSmall) diffStr = ''; S_index = []; count = 0; for Numofstr = 1:length(StrSmall) [C,IA] = ismember_bc2(StrSmall{Numofstr},StrLarger); if C==1 && IA<=length(StrLarger) count = count+1; S_index(count) = IA; end end diff_index = setdiff([1:len...
5300548313ef7e2e8b9b0dfe1cb5a3cebec1f0d732303d11c7c5ba78bf5473eb
MATLAB
472
14
function [region_info] = get_region_info() %GET_REGION_INFO return region info m = load(fullfile(util.get_paths().data_versioned,'region_info',... 'initial.mat')); region_info = m.initial; region_info.RGB_normalized = region_info.RGB ./ 255; region_info.Properties.RowNames = cellstr(region_info.Name); % Merge, X, ...
686b15e35f15ed16680d5148a053d06d319f3863efd269c9d67befa08005ed58
MATLAB
472
19
function auto_reorient(p) if ~nargin [p,sts] = spm_select(Inf,'image'); if ~sts, return; end end p = cellstr(p); vg = spm_vol(fullfile(spm('Dir'),'canonical','avg152T1.nii')); tmp = [tempname '.nii']; for i=1:numel(p) spm_smooth(p{i},tmp,[12 12 12]); vf = spm_vol(tmp); M = spm_affreg(vg,vf,struct('...
9137aea7aeb37da7589332ec9be2d3831b4b9d386de43a412eadf56d7b3dc104
MATLAB
472
11
function fn = analyzetpstack_getrawfilename(ds,stackname,dirname) % ANALYZESTPACK_GETRAWFILENAME - Returns the filename of the raw F analysis % % FN = ANALYZETPSTACK_GETRAWFILENAME(DS,STACKNAME,DIRNAME) % % Where DS is a DIRSTRUCT for the experiment directory, STACKNAME is the % ANALYZETPSTACK stack name, and DIRN...
4dc68f6becd1da6a72eb3a93e85486eab33d2ec596a3cac93437262525b80f0e
MATLAB
473
18
function tpcheckroidriftls_matchx(tagname) % TPCHECKROIDRIFTLS_MATCHX - Matches X axis on all windows that match tagname % % tpcheckroidriftsls_matchx(tagname) % % Checks the figure that was clicked on and matches the X axis for all % figures that share the name 'tagname'. fig = gcbf; ax = findobj(fig,'type','axes'...
5546751bb808a699c231c4c12e3be7b914cd9b7bbc4587bc549caa94ae2ae4e1
MATLAB
473
12
util.clearAll; outdir = fullfile(util.get_paths().data_versioned, 'betas'); util.mkdir(outdir) %% load the data and combine betas % Read beta values and calculate their correlation beta_tables_taste = util.load.all_taste_betas(); beta_merged = connect.preprocess.merge_into_large_tbl... (beta_tables_taste.sep_table)...
c07952bec407adc84aeeab583c7d9e1585afaec1a3f189587f2164ca3b9cdf5a
MATLAB
474
18
function [x, y, z, x_idx, y_idx, z_idx] = x_y_z_from_idx(idx, G) %[x, y, z, x_idx, y_idx, z_idx] = x_y_z_from_idx(idx, G) x_idx = rem((idx-1), G.Nx)+1; y_idx = rem(floor((idx-1)/G.Nx), G.Ny)+1; z_idx = floor((idx-1)/(G.Nx*G.Ny))+1; x = zeros(length(idx), 1); y = zeros(length(idx), 1); z = zeros(length(idx), 1); for n...
ac78b4fbec0d18e410bcdbc4b4fc71372debd1b28f659f1f5c92447babd97ebd
MATLAB
475
18
function nontp = nontpdirname(dirname) % NONTPDIRNAME - Return test directory associated with a given two-photon directory % % NONTPDIR = NONTPDIRNAME(DIRNAME) % % Given a 2-photon directory name DIRNAME, return the associated test directory, % which may or may not be the same. This is the inverse of the functio...
05730399130ca1e6daf8bd0606856a468531014eb3135e5f7262cacf2dc2ecc5
MATLAB
476
11
function fn = analyzetpstack_getsavedfilename(ds,stackname,dirname) % ANALYZESTPACK_GETSAVEDFILENAME - Returns the filename of the saved F analysis % % FN = ANALYZETPSTACK_GETSAVEDFILENAME(DS,STACKNAME,DIRNAME) % % Where DS is a DIRSTRUCT for the experiment directory, STACKNAME is the % ANALYZETPSTACK stack name, ...
0ec7267da839db10781b54d7d317284f5f2adc60dd1b35e47b210f14669cdc47
MATLAB
477
17
function TRIALS = TrialFcn_AMRate_SanesLab(TRIALS) global NOISE_CAL %If it's the start if TRIALS.tidx == 1 %Load noise calibration file [fn,pn,fidx] = uigetfile('C:\gits\epsych\UserFiles\SanesLab\SpeakerCalibrations\*.cal','Select noise calibration file'); noise_calfile = fullfile(pn,fn); dis...
376bba501ee81e2b9914e8a7ea2ce9e4ac5de85aecc0778aaafb127eeda512b1
MATLAB
477
17
function TRIALS = TrialFcn_FreqTuning_SanesLab(TRIALS) global TONE_CAL %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'); tone_calfile = fullfile(pn,fn); d...
79702f41ddf7a26a1de4b51446aa2e3f31a7534bb88dcb4465217c771295e1b8
MATLAB
479
17
function TRIALS = TrialFcn_AMRate_jitter_SanesLab(TRIALS) global NOISE_CAL % if it's the start if TRIALS.tidx == 1 % Load noise calibration file [fn,pn,fidx] = uigetfile('C:\gits\epsych\UserFiles\SanesLab\SpeakerCalibrations\*.cal','Select noise calibration file'); noise_calfile = fullfile(pn,fn); ...
864d3b304b8409d53fcbe955fd796b30bafb4ee934778c72e6b2d899e18d3640
MATLAB
479
8
function [startend epidur]=VsEpisodes(vs,maxep,mindur,ba) vs=find(vs>0); vs=[vs maxep]; dif=diff(vs); dif1=find(dif>ba); endvs=vs(dif1); startvs=dif1+1; startvs=[1 startvs maxep]; nepivs=diff(startvs); nepi1vs=find(nepivs>mindur); % episodes longer than interruption epidurvs=nepivs(nepi1vs); startep=vs(start...
ee16102f0e267bca23b628d27034ec4792e73e896569ca8b9a7279f1f056c6d0
MATLAB
481
17
function TRIALS = TrialFcn_HarmsTuning_SanesLab(TRIALS) global TONE_CAL %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'); tone_calfile = fullfile(pn,fn); di...
440f71dec2aa8a22088f670a37005f6995cf1eb8cacc87d0ed6983bddb6e0e1e
MATLAB
482
15
% part of https://github.com/LudgerS/MRSartifactRemoval function line = doubleVoigtSpectrum(specAxis, areas, centers, fwhms, mixingRatios, phases, pCorr1) % add two complex voigt lines line = complex(zeros(size(specAxis))); for ii = 1:2 line = line + areas(ii)*exp(-1i*phases(ii)*pi/180)*... ...
62148c04a26e46baecc86ba4b0ef11d616f1cb83ea1c45cb80e718510c4b87ba
MATLAB
482
23
function coef = find_coeff(x, y, prec) % FIND_COEFF Finds polynome coefficient for a set of x and y values and a % given precision. % % coef = find_coeff(x, y, prec) % % Inputs: - x: input values % - y: output values % - prec: precision of coefficient % % Outputs: - coef: vector of polyn...
a3d39b66aea33b8b1f09eafd67d6471c58d23060b4fec11d22efe7fa4b88db65
MATLAB
482
19
% X: data matrix, each row is one observation, each column is one feature % D: pair-wise distance matrix % Copyright by Quan Wang, 2011/05/10 % Please cite: Quan Wang. Kernel Principal Component Analysis and its % Applications in Face Recognition and Active Shape Models. % arXiv:1207.3538 [cs.CV], ...
41469e8041bb6332aa17c2b9e11e279cb3703ca9e0e5f1d92ec1f852c59358c6
MATLAB
483
29
function remove_motion_artifact(fn) %% noisy_f = load([fn '.txt']); [nNodes, nSamples] = size(noisy_f); %% Step 1: remove motion artifact ma_corrected_f = nan(size(noisy_f)); for i = 1:nNodes ma_corrected_f(i,:) = filloutliers(noisy_f(i,:),'linear','movmedian',5); end %% fn2 = [fn '_ma_corrected.txt']; fp2 ...
e00d6b8b0276af777e6474374e798e90d48d70b9cbbbfd488ccbd9e6b974dec4
MATLAB
483
17
function [s, trials_resp] = load_extract_sequence_info(fn_test) % Load the useful information about the sequence of stimuli. % Similar to load_extract_ratings.m, but without loading the ratings and % without fitting any model. % % s: sequence with entries in {1, 2}. % trials_resp: vector of the indices of the ...
153aaf11abf47e37b240a6ed324a1da628071cc809295099904375cc881640b9
MATLAB
486
12
function clips = clip_signals3(multichannel_signal, time_stamps, sample_rate, clip_length) n_samples = round(clip_length * sample_rate); clips = nan(size(multichannel_signal,1), n_samples, length(time_stamps)); i_time_stamps = round(time_stamps * sample_rate); for i = 1:length(time_stamps) ...
3cdfcbf3405b62bbafc515c9e7df8e285511cbf05e0e22b520fcef5d70449c02
MATLAB
486
14
function [detr_data] = detrendData(data, poly_num) % Detrends inputed data based on the polynomial order input num_cells = size(data,2); % number of cels detr_data = cell(1,num_cells); % preallocate space for vargOut t = data{1}(:,2); % time vector % Detrend each trace using the polynomial input ...
3d2923d6ad98eefe36f77bf2ef88b3e171530d1f033eaa2e030c21571215a406
MATLAB
486
17
function mae = CalMAE(smap, gtImg) % Code Author: Wangjiang Zhu % Email: wangjiang88119@gmail.com % Date: 3/24/2014 if size(smap, 1) ~= size(gtImg, 1) || size(smap, 2) ~= size(gtImg, 2) error('Saliency map and gt Image have different sizes!\n'); end if ~islogical(gtImg) gtImg = gtImg(:,:,1) > 128; end smap = ...
717f5bff95d5b07c2dec2f0a6a41ff4a19a6882dc8b914d75bc201924bc63dd2
MATLAB
486
17
function [volume] = sub_volume(volume, hemisphere) %SUB_VOLUME select the hemispheres to keep in the volume lateral_size = size(volume, 2); assert(rem(lateral_size, 2) == 0); center_line = lateral_size / 2; switch hemisphere case 'right' volume(:, 1: center_line, :) = 0; case 'left' volume(:, ce...
8464b61fb9b1271c8864b2f679c5a39774a745f589a5da8c70d7180a36348f23
MATLAB
486
14
function studyTag = find_study(FEM, elecIdOrLabel, asId) if nargin == 3 pattern = sprintf('%d.%d$', elecIdOrLabel, asId); else assert(nargin == 2); pattern = ['^' elecIdOrLabel '$']; end studyTags = FEM.study().tags; studyLabels = arrayfun(@(tag) char(FEM.study(tag).label), studyTags, 'uni', false);...
01ea4a3a3b87b61c4a887199c70b92946a6053870e6d70bac1f39e4251525424
MATLAB
487
17
function save_stack(stacks, filename) %SAVE_STACK saves stack in uint8 format % save_stack(stacks, filename) % Inputs: % stacks: data(uint8) to save % filename: filepath+filename to save assert(max(stacks(:)) <= 255, 'image data to be saved must be in 8-bit') stacks = uint8(stacks); depth ...
4f633c12587f585365b667024c10b8cc0c35d924256b192732533c7b27fc7830
MATLAB
487
16
% part of https://github.com/LudgerS/MRSartifactRemoval % function line = tripleVoigtSpectrum(specAxis, areas, centers, fwhms, mixingRatios, phases, pCorr1) % add three complex voigt lines line = complex(zeros(size(specAxis))); for ii = 1:3 line = line + areas(ii)*exp(-1i*phases(ii)*pi/180)*... ...
6d49cf4442b9828e18e730d3734734320a1174ec1a2e23c73c384983f9667030
MATLAB
488
20
function Vars = getQdecVars(Qdec) % Vars = getQdecVars(Qdec) % % Returns a one dimensional cell string array with the name of the variables % in Qdec. % % Input % Qdec: Two dimensional cell string array of Qdec data. % % Output % Vars: One dimensional cell string array. % % $Revision: 1.2 $ $Date: 2015/01/06 17:14:53 ...
b68852e8a769ac0ce44b2862cc0c8ee1c962b0ea26f2c060b5d9876b4e9bd0c6
MATLAB
488
18
function e = enow(n2,n1) % e = enow(n2,n1) % % Helper function to compute elapsed time between scalar values returned % from calls to NOW function. % % Inputs can also be matrices of equal number of elements. % % Converts NOW values to [y,m,d,h,min,s] and calls ETIME. % % Daniel.Stolzberg@gmail.com 2015 assert(num...
c1c4d0a7b386ea1bdb16650af98d949fd93360cf4291a0a945d5d49416400851
MATLAB
488
17
% Demonstrates how to use the matrix editor. % % See also: MatrixEditor % Copyright 2010 Levente Hunyadi function example_matrixeditor fig = figure( ... 'MenuBar', 'none', ... 'Name', 'Matrix editor demo - Copyright 2010 Levente Hunyadi', ... 'NumberTitle', 'off', ... 'Toolbar', 'none'); e...
dbb6c950b1f21e033abf5af2a96ac154a435a16ec01951aaade28dc1f60fad5b
MATLAB
490
14
function basePaths = get_base_paths() conf = get_conf(); dataPath = conf.dataDir; basePaths = struct(); basePaths.data = dataPath; basePaths.MRG = fullfile(dataPath, 'MRG', filesep); basePaths.models = fullfile(dataPath, 'Models', filesep); basePaths.dist = fullfile(dataPath, 'Dist', filesep); basePaths.compa...
dde10767e7da85a21b5d5205bff6d9121ab0ad74d1a48d5a8ac40b75b2013fbb
MATLAB
490
17
% Demonstrates how to use the property editor. % % See also: PropertyEditor % Copyright 2010 Levente Hunyadi function example_propertyeditor % create figure f = figure( ... 'MenuBar', 'none', ... 'Name', 'Property editor demo - Copyright 2010 Levente Hunyadi', ... 'NumberTitle', 'off', ... ...
009133db1accfbfffb95338920461fbb94bf29d0f5622e245aa635886857ea71
MATLAB
491
17
function [gradient_c] = colors_modules() %COLOR_SHADE Create the color map for regions involved in the modules % get colors and module names for each module regions = util.str.chord_ROIs().modules; colors = util.plot.getColors().modules; gradient_c = cell(size(regions)); % Color gradient for each module for i = 1:le...
1e2f3e4813eee964a9c46290c22e096d771c78b5b0194fae72337c9e544dd5bd
MATLAB
491
28
%% PROJECT CONFIG PROJECT_DIR = pwd ; % put base path to project her cd(PROJECT_DIR) %% add to the path projPathDirs = { 'src' 'data' 'bin' } ; for idx=1:length(projPathDirs) addpath(genpath(strcat(PROJECT_DIR,'/',projPathDirs{idx}))) end clear projPathDirs %% setup global vars OUTSTR = 'run1' ...
1c4fc4b4fd77a46260c0a81706d8a968338e2483f39c720866b85ce0d2554c2b
MATLAB
493
19
function [EEG,com]=pop_epochs2continuous(EEG) com = ''; % this initialization ensure that the function will return something % if the user press the cancel button % display help if not enough arguments % ------------------------------------ if nargin < 1 help pop_epochs2continuous; return; en...
28cb564527fb28b01e2cc8de5fc3bb506f6210d6b837720313038ae7362e6c53
MATLAB
494
22
function i = findincell(m,n) % i = findincell(m) % i = findincell(m,n) % % Helper function finds first n indicies of values in cell array m where % there may be empty cells. CELL2MAT is ineffective in this case because it % can not translate the empty cells to a numerical (logical) matrix. % % % Daniel.Stol...
af3d5898ad50f8881428f2d91699eb02f4af60bcf2971f2e7c84c8ab9fdca0ad
MATLAB
494
21
function mask = Bits2Mask(bits) % mask = Bits2Mask(data) % % Converts an array of bits to a bitmask. % % Input must be a 1xn or nx1 array of integers or logical values. % % Output is a scalar unsigned integer (uint32). % % ex: bits = [0 1 1 1 0]; % mask = Bits2Mask(bits) % % See also, Mask2Bits %...
e460f56f4a7830dd2cdb1fe47626a07458b59cedd05d6bbb2a21a71759586024
MATLAB
494
21
function [chan_idx_pos, all_pts_pos] = keep_positive_clusters(chan_idx, all_pts,time_vec) % Onle keep cell entries in chan_idx and all_pts when clusters are across % positive times. [~,idx_0] = min(abs(time_vec-0)) ; n_cells = length(all_pts) ; chan_idx_pos = {} ; all_pts_pos = {} ; for i_c=1:n_cells ...
2cb4a3383dcd616cb25b674ef5096dc899e46640a567733c43a5d1ee4d17995c
MATLAB
495
20
function [ step_init ] = bb_init(problem, w) % % Barzilai-Borwein step-size initialization: % % % This file is part of SGDLibrary, GDLibrary and SparseGDLibrary. % % This file originally comes from https://github.com/bodono/apg. % Modifeid by H.Kasai on Apr. 17, 2017 grad = problem.full_grad(w); step = 1 / no...
123e28b38d96e5d562692fb0b268d7f5e29cc9ac092b018d9cd05e971fd032b7
MATLAB
497
15
function [out_data] = channel_zpos(data, ch_request, z_request) %CHANNEL_ZPOS extracts the image from the data structure "data" for a %particular channel "ch_request" and z-plane "z_request". data structure %is that comming from bioformats im_info_list = data(:,2); tmp = cellfun(@(x) isRightZ(x, z_request),...
9e5eb25ecc1d56888903bf6b707282b3d342bc092e52ae05b128803ec0f31561
MATLAB
497
12
%% README % Codes related to Karkali et al Developmental Cell 2022 % Contact: % Sham Tlili <krystalysham@gmail.com> % Timothy Saunders <timothy.saunders@warwick.ac.uk> % Jose Munoz <j.munoz@upc.edu> % if you have questions. Test data sets are provided. % Test sets should be unzipped prior to use. % Provides code for...
af139e652ccc6af63d32ba6901110bd5c1c2571935b9f7a5176a38c68ee2e9ad
MATLAB
497
30
%% Vb= spm_vol(Pn{1}); Yb= spm_read_vols(Vb); V = spm_vol(Dn{1}); Y = spm_read_vols(V); x = 20:size(Y,1)-20; y = 20:size(Y,2)-20; colormap gray % colormap jet for i = 1:size(Y,3) % imagesc(Yb(x,y,i)); % set(gca,'clim',[0 1e6]); % contour(Y(x,y,i),-6:0.5:6); % set(gca,'clim',[-6 6]) %...
7cf5fef5907c0f46a9d482e6403e4588faed292fac01afe1fadd10affc0a737e
MATLAB
498
15
function sensation = group_sensations(sensation) %GROUP_SENSATIONS Summary of this function goes here % Group sensations in macro areas sensationNew = sensation; sensationNew(ismember(sensation, [1 3 5 6])) = 1; sensationNew(ismember(sensation, [2 4 7])) = 2; sensationNew(ismember(sensation, [8 9 12])) = 3; ...
04e3c2519f1320dace9d6f492ac104dab26d8c7d3217b8e9aa887a1dbbf1997a
MATLAB
499
19
function [ccStudyTag, ccSolTag, ccDsetTag] = find_cc_tags(FEM) ccStudyLabel = 'CC study'; ccStudyTag = find_study(FEM, ccStudyLabel); if nargout > 1 if isempty(ccStudyTag) ccSolTag = []; else ccSolTag = find_sol(FEM, ccStudyTag); end if nargout > 2 if isempty(ccSolTag) ...
a364e5d80a99a49a00678d421bb8bfd0a987352293a89b0bf45deadae6bdf57d
MATLAB
499
12
function [avg_corr] = write_matrix_from_table(beta_tbl, ... var_string, f_name) %WRITE_MATRIX_FROM_TABLE write table from table of beta values avg_corr = connect.correlations(beta_tbl, ... {{'L', 'R'}, {'L', 'R'}}, [], var_string); avg_corr = avg_corr.full; % necessary for the community detection that matrices ...
7f8c81fbe1b05f66d4d03b29e4992c1bab6e9674857058f1f9aa5e65966137c9
MATLAB
501
16
function xyoffset = analyzetpstack_getxyoffset(ud,dirname) % Return the X/Y offset of a slice relative to the stack as a whole % % [X Y] = ANALYZETPSTACK_GETXYOFFSET(UD, DIRNAME) % % Where UD is USERDATA for analyzetpstack window and % DIRNAME is the directory name to examine. myparent = analyzetpstack_getrefdirna...
272511cd67ec6a36f10348dc7d7ba1dbae65aee79ae9ac8b4df6423307838231
MATLAB
502
18
function sp = create_figure( file_name); % New figure figure('name',file_name) sp(1) = subplot(2,3,1); title('Signal Only') sp(2) = subplot(2,3,2); title('Colocalized') sp(3) = subplot(2,3,3); title('Separated') sp(4) = subplot(2,3,4); title('Across Attn') sp(5) = subplot(2,3,5); title('Control') sp(6) = subplot(2,3,...
e1bdce23a788d622027073b6f2dfc686e3496698e43c2c64575aff0af771a3ac
MATLAB
502
13
util.clearAll; beta = util.load.beta_table(); beta = renamevars(beta, {'reset_session_index', 'session_index', ... 'only_animal_idx', 'animal_idx'}, ... {'session_index', 'old_session_index', ... 'animal_index', 'date_tag'}); %% write beta table to mat and csv files outdir = fullfile(util.get_paths().data_...
fcc173faf125d0e6030532056387c80c2a761b20428efa9cba9319c194b9f2f0
MATLAB
502
12
function [high_low_betas] = get_conc_array(tbl) %GET_CONC_ARRY Concatenate the high and low taste betas into an array high_low_betas = cellfun(@(x) {x.high_Betas(:), x.low_Betas(:)}, ... tbl.beta_table, 'UniformOutput', false); % turn it into an array high_low_betas = cat(1, high_low_betas{:}); high_low_betas = ......
21a1439fbcabde5208f003d000e026c593b94b5761561d6a795ed94a893a60f1
MATLAB
503
30
function zscore_f(fn) %% ma_corrected_f = load([fn '_ma_corrected.txt']); [nNodes, nSamples] = size(ma_corrected_f); %% Step 1: remove motion artifact zs_f = nan(size(ma_corrected_f)); for i = 1:nNodes zs_f(i,:) = (ma_corrected_f(i,:) - mean(ma_corrected_f(i,:))) ... / std(ma_corrected_f(i,:)) ; end ...
0149bcf5edabf4008b9e76c5c0ad7ddd19848e9392da3641e2387114149bba44
MATLAB
504
16
% Filter elements of array that meet a condition. % Copyright 2010 Levente Hunyadi function array = arrayfilter(fun, array) validateattributes(fun, {'function_handle'}, {'scalar'}); if isobject(array) filter = false(size(array)); for k = 1 : numel(filter) filter(k) = fun(array(k)); end...
9f0fafaa330dd7475e2e3f18e53e4c3fb8c6aec639fd7c4a42f06dcd0c7c2f48
MATLAB
505
14
function[names] = dblist % dblist List MySQL databases [mym utilities] % Example dbs = dblist if ~myisopen error('No MySQL connection active; use ''myopen'' to connect') else % new compilation of mym returns structure DJS 1/2013 dbs = mym('show databases'); names = dbs.Database; ...
4bd66c40bdf42492ab6a3395d82ceb9a09db844395c8d6f785e20eeb57b2ed53
MATLAB
506
16
function [compartSelectedV, nNodeSelected, varargout] = select_v_comparts(V, nNodesMax, nComparts) % if there are more voltage values than allowed compartments ... nNodesAvailable = (length(V) - 1) / nComparts + 1; if nNodesAvailable > nNodesMax [compartSelectedV, I] = max_v_comps(V, nNodesMax, nComparts); nNode...
b77fd900afb62393ec99d3567012c606d523eab4ee8943f7d806fdad874c241a
MATLAB
506
24
function [lp_log_x, dlp_log_x, d2lp_log_x] = inverseGaussianPrior(log_x, a, b) % x = exp(log_x) is an inverse Gaussian % %when nu = 1, is half cauchy lp_log_x = zeros(size(log_x)); log_x = log_x(:); nx = DMC.utils.boundedExp(-log_x); a = a(:); b = b(:); lp_log_x(:) = a .* gammaln(b_c) - (a+1).*log_x - b.*nx + lo...
ed196bfb9add4477cc3466ae36d32066d76af16625d1000153a33b357004c305
MATLAB
506
17
function [ FixedIndicies ] = AdjustVerticies( ValidIndicies, IndiciesToChange ) %ADJUSTVERTICIES Input is a set of valid indicies which is a subset of %indicies to change. FixedIndicies = IndiciesToChange; memberVerts = ismember(ValidIndicies, IndiciesToChange); nonmemberVerts = ~memberVerts; indexToSkip = iSorted...
43609cd516c393bcae0df9458aa000d9c5bd41a84e2021e0476d6878abd4389d
MATLAB
507
14
function [ Locs ] = ScaleLocations( Locs, scale_struct ) %SCALELOCATIONS Scale the locations structure %Keep a copy of the original data and scale the coordinates. [Locs(:).UnscaledX] = Locs.X; [Locs(:).UnscaledY] = Locs.Y; [Locs(:).UnscaledZ] = Locs.Z; [Locs(:).UnscaledRadius] = Locs.Radius; ...
da52f4931820ba9df87954cb3feb6037ff074a5ad57eab522ae61c8f9ee579fc
MATLAB
507
14
function [A, b, x0, lambda, lambda_max] = generate_lasso_data(n, d, k, noise_level) [A,~] = qr(randn(n,d),0); A = A'; p = randperm(n); p = p(1:k); % select location of k nonzeros x0 = zeros(n,1); x0(p) = ra...
15dec7ec967627c1c0596f03b3f1a9bb212f7b9a8d5ff6719701b664fc00d089
MATLAB
508
15
function self = TrainConfidenceScorer(self) method = self.ConfigFile.GetParams('ScoringMethod'); confScorer = ConfidenceScorer(self, method); if strcmp(method, 'TemperatureScaling') isSet = self.ClipTable.Set == categorical({'Validate'}); confScorer = TrainConfidenceScorer(confScorer, self.ClipTable(isSet, :...
ae914a92ad0c7e941f37141d613ba451514fe6e986fb593f77002ef2030e5cb8
MATLAB
509
14
function result = objectEDT(constructor, varargin) % Auto-delegate Java object method calls to Event Dispatch Thread (EDT). % Copyright 2010 Levente Hunyadi error(nargchk(1, 256, nargin)); validateattributes(constructor, {'char'}, {'nonempty','row'}); v = sscanf(version, '%u.%u'); % major and minor version ...
f4fad6262cbdc488864278bfa5c8d0262a2b8f9e1b35aa7b477523650527de82
MATLAB
509
23
function [lp_log_x, dlp_log_x, d2lp_log_x] = inverseGammaPrior(log_x, a, b) % x = exp(log_x) is an inverse Gamma % lp_log_x = zeros(size(log_x)); log_x = log_x(:); invx = DMC.utils.boundedExp(-log_x); a = a(:); b = b(:); lp_log_x(:) = a .* log(b) - gammaln(a) + (-a-1).*log_x - b.*invx + log_x; if(nargout > 1) ...
b25549d7bf715710dd8c9d77ec72a1e2ba9f422f888c4921b1a43a9d92832c7f
MATLAB
510
18
function G = rgb2gray1(X,datatype) % function G = rgb2gray1(X) Convert RGB-like real data to gray-like output. if size(X,3)==1; G=X; return, end if nargin<2, datatype = 'double'; end [M,N,three] = size(X); X = reshape(X,[M*N,three]); % Calculate transformation matrix T = inv([1.0 0.956 0.621; 1.0 -0.272 -0.6...
5c24843b69c51735aefa87c2a7aa835addd8d8b7a6413141261efb12924a5001
MATLAB
511
15
% PURPOSE: subroutine for pop_continuousartdet.m % % Author: Javier Lopez-Calderon % Center for Mind and Brain % University of California, Davis, % Davis, CA % 2011 function [WinRej chanrej] = movesegments(WinRej, chanrej, winoffsetsam, pnts) fprintf('\nWARNING: Marked segments will be displaced in %g samples.\n\n', w...
f678526c82c0a7b09875bd325643697d22a93bbda5d5e5792a3f29c7e59b44b6
MATLAB
511
14
function [ um,vm ] = resizeFlow( um,vm,new_size ) %RESIZEFLOW Summary of this function goes here % Detailed explanation goes here % resize flow scaling = single([new_size(1)/size(um,1),new_size(2)/size(um,2)]); a = linspace(1,size(um,2),new_size(2)); b = linspace(1,size(um,1),new_size(1)); [xi,yi]...
031c1e9c2f6be52bf8d4bf7349572276e3458484edd48b6daf44efb81d90f907
MATLAB
513
27
% Get data from a figure function t = getDataFromFigure(fn,name1,name2) fig = openfig(fn); axObjs = fig.Children; dataObjs = axObjs.Children; x = dataObjs(3).XData; y = dataObjs(3).YData; % This is the age data from the previous experiment [tmp1,tmp2] = xlsread('subjectdata_previous.xlsx'); t = table; t.age = x'; %...
35f90974cd9f85e4ec2abb5130f9500dee058f13db83ff1d137154f53d7badaf
MATLAB
513
13
function [pgon, line] = slice_obj(model, object, planeP, planeV, roundPrec) arguments model (1,1) Model object (1,:) char 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; end % Ca...
4c5368af38fad8e4bda51bb27a94729cc6e90b94ff9f2f6a02436faa55702321
MATLAB
513
26
function L = laplacian(A) % NLAPLACIAN Compute the normalized Laplacian matrix for a graph. % % L = nlaplacian(A) computes the weighted normalized Laplacian matrix for a % symmetric adjacency matrix A. % % If A has unit weights, then the Laplacian is unweighted. % % % David Gleich % October 29th, 2005 % % % Histor...
d8433bb88c5b345078b88d73075ccdad67b5f7cea0d67dcb690576a3472f9231
MATLAB
514
14
function [region_order] = ROI_name_consistency(corr_atanh) %ROI_NAME_CONSISTENCY Get the roi names after checking they are consistent % across tastes % row and column order the same assert(all(cellfun(@(x) isequal(x.Properties.RowNames,... x.Properties.VariableNames'), corr_atanh))); % compare across tastants to b...
3c34f25cfee397f30c10e74689ca25eac8e4a0594950b3d16d4d564817f20b6d
MATLAB
516
22
% gets the number of hyperparams for the horseshoe prior function [dim_H] = getDimH(R, prior_setup) dim_H = R + 2; D = numel(prior_setup.T) + 1; % order for ss = 1:D if(ss == 1) prior_setup_ss = prior_setup.V; else %T{ss-1} prior_setup_ss = prior_setup.T(ss-1); end if(prior_setup_ss.o...
4c419fb2c43b509ef3b22da694a3c1dfc2a07cf46a526c6649e427568c7ae549
MATLAB
516
22
function subpath = getSubpath(loc,subj,niipath) % structpath = getPath2Structurals(loc [,subj] [,niipath]) % % ** NEEDS IMPROVEMENT AND ERROR HANDLING % % Daniel.Stolzberg@gmail.com 2016 narginchk(1,3); assert(ischar(loc)); loc = upper(loc); if nargin < 3, niipath = fullfile(pwd,'NII'); end if nargin < 2 || isempty...
7bb3728328ffe54876d52eff5d0bad620b3d4e5fd3ebcb15d8c2ee3dd79b8d74
MATLAB
516
20
function SyncAnnotationCategories(self) folders = GetValidSubFolders(fullfile(self.ProjectPath, 'annotations')); behaviors = {}; for i = 1:size(folders,1) currVideo = folders.name{i}; currAnnot = Annotation(self, currVideo); currBehaviors = currAnnot.GetBehaviors(); behaviors = [behaviors; currBehavi...
dd006789ebaf91b706564a979fce6605a1719232d84ed29e4cb82c4e0e34162d
MATLAB
517
13
function [paths] = get_paths() %GET_PATHS Summary of this function goes here % Detailed explanation goes here paths.main_dir = '/Users/karimia/code/Brain_Network/'; paths.main_code_dir = '/Users/karimia/code/Brain_Network/matlab'; paths.figs = fullfile(paths.main_code_dir, 'figs'); paths.data_versioned = fullfile(pat...
16aae50f8356dc9417d487a204112142167420b64b82ea33a88c3c7b89182158
MATLAB
518
21
function shiftdriftcorrect(dirname, x, y) % SHIFTDRIFTCORRECT - manually move the drift correct results % % SHIFTDRIFTCORRECT(DIRNAME, Xshift, Yshift) % % Perform a manual shift of the drift correct results for a % two-photon directory. % Example: % % SHIFTDRIFTCORRECT('e:\myexper\mydir-001',0,0) % % ma...