sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
20b642de371f7bc0af6e1ebb523e4049a7e0e391fcfad284745ae7f650ee333d
MATLAB
411
25
function save_figure(session, channel, unit, name) % Save figure % % Parameters % ---------- % % - name: char vector % Name of saved figure info = get_info(); folder = fullfile(... info.folders.results, ... get_id(session, channel, unit)); if ~isfolder(folder) mkdir(folder); end saveas(... gcf...
20be06091413ce372d978630a28323f40d3ec25b687b8f225a6c47127a0b9246
MATLAB
411
28
function [ww] = find_ser_descr_watter_width(f,desc,exa) found=0; ind=[]; ww=0; for k=1:length(f) if findstr(desc,f(k).SerDescr) if findstr(exa,f(k).examnumber) found=found+1; ind(found) = k; end end end for k=1:length(ind) ww(k) = f(ind(k)).watter_widht; end if length(ww)>1; ...
ae7e50e94f184e8ce46824e27902fca4271e9d624ae3a50c0dac0f4b65433e9c
MATLAB
413
12
function interp1_table1_import libname = 'interp1_table1.a'; type11r = ['double[K1] r_ck, double[K1] i_ck, int32 K1, ' ... 'double[J1*L1+1] r_h1, int32 J1, int32 L1, ' ... 'double[M] p_tm, int32 M, double[M] &r_fm, double[M] &i_fm']; myimport(libname, 'interp1_table1_real_per', 'void', type11r); function myimport...
856d284ca297cbb768e338757ebccf0931ce1bf29b5c407af37c21e1f8c69a18
MATLAB
414
18
function file_writer = editFile(file_path,varargin) %x Open a file for editing % % file_writer = adi.editFile(file_path) % % if ~exist(file_path,'file') error('File to edit doesn''t exist:\n%s',file_path) end file_h = adi.sdk.openFile(file_path,'read_and_write',true); data_writer_h = adi.sdk.createDat...
341fe6bd380de3bc3686d66f9d05c86758a3d61fb1170036665d643a91e174e4
MATLAB
415
5
function [dipole, teta] = DipoleGenerator3(HR, fs, alphai, bi, tetai, teta0) % DipoleGenerator3 has been deprecated. Use vcg_gen_var_hr instead with additional input parameter method = 'LOOP'. warning('DipoleGenerator3 has been deprecated. Use vcg_gen_var_hr instead with additional input parameter method = ''LOOP''')...
378f5edf5eb1d218c03be6b49ed107d9c74b1c4e48ee89421e296c6324cc77c7
MATLAB
415
14
function Tags_Struct = TIF_Init(Image_Size) Tile_Size = 64; Tags_Struct.ImageWidth = Image_Size(1); Tags_Struct.ImageLength = Image_Size(2); Tags_Struct.Photometric = Tiff.Photometric.MinIsBlack; Tags_Struct.BitsPerSample = 8; Tags_Struct.SamplesPerPixel = 1; Tags_Struct.TileLength = Tile_Size; Tags_Struct....
391caf24e786013a678b4061747c4ed660266fbc72eee9b48dece4c94f9994dc
MATLAB
415
28
% test IIR filter in C++ and in Matlab clear; close all; x = load('testinput.txt')'; y = load('testoutput.txt')'; hcoefs = fopen('filtercoefs.txt','r'); data = fscanf(hcoefs,'%g'); M = data(1); b = data(2:M+1); N = data(M+2); a = data(M+3:M+2+N); fclose(hcoefs); s = filter(b,a,x); figure; hold o...
5339af1df39a3c1973aeef9195dd75da049b795b246906b1687b464f4dee932d
MATLAB
416
8
function save_activitydata(FolderNamePD,New_Index,Raster_Condition,RASTER_WHOLE_Clean,XY_clean) % Call Global Variables global Experiment; % Direcotry to Save: Up from this one (pwd) FileDirSave=getDir2Save(); save([FileDirSave,FolderNamePD,Experiment,'.mat'],'New_Index','Raster_Condition',... 'RASTER_WHOLE_Clean'...
dd20e618c8176ae7de2bfac0b58ba9a97a6f71dd706abaa6f5c83d1fa680779b
MATLAB
416
10
function [peaks, peak_indexes] = PeakDetection20(x, ff, th, varargin) % PeakDetection20 has been deprecated. Use peak_det_amp_threshold instead. warning('PeakDetection20 has been deprecated. Use peak_det_amp_threshold instead.'); if nargin > 3 && ~isempty(varargin{1}) flag = varargin{1}; else flag = 2; e...
e7d392daa3842f46d9548b974afd727b88ce264de269453299b0b8aeb3ff7806
MATLAB
416
18
function move2front(hax_or_h,h) % function move2front([hax],h) % move h to the front of hax if nargin < 2 || isempty(hax_or_h) h = hax_or_h; hax = gca; else hax = hax_or_h; end axkids = get(hax,'Children'); ih = find(axkids==h); if isempty(ih), error('handle(%f) not a child of hax(%f)', h, hax); end remh_axkids...
49334ddeabffb9d841c01d15cd76b3a880d2c44ad269af3772a7da64cf8f3b3c
MATLAB
417
20
function y = DNN_Index() if isunix cd ../..; else cd ..\..; end addpath(genpath(pwd)); Frame_Half_Size = 10; % 21X21. [Training_Frames,Training_Classes] = Generate_Training_Set(Frame_Half_Size); display(1); [Testing_Frames,Testing_Classes] = Generate_Testing_Set(Frame_Half_Size); display(2); y = C...
ac450d8ab2914e1ce3505957e4e86c6a0bd95a12804e2a7c0b01cab626ed8067
MATLAB
417
22
function success = autoMerge(obj) %AUTOMERGE success = 0; if obj.nEdits > obj.editPos % not at tip of edit history, back out warning('cannot branch from history; use revert() first'); return; end obj.orderClusters('clusterSites'); for iRepeat = 1:obj.hCfg.nPassesMerge % single-pass vs dual-pass correction ...
c43b8d9badc06c90abb12dd1e8ff650f58790787604537aa2c61e90378ead97d
MATLAB
417
10
function interpulated_psth = bin_psth(psth, downsampling) cut_end = floor(length(psth)/downsampling)*downsampling; binned_psth = mean(reshape(psth(1:cut_end), downsampling, [])); y = 1:length(binned_psth); xq = 1/downsampling:1/downsampling:length(binned_psth); interpulated_psth = interpn(y, binned_psth, xq, 'li...
173ec9582ab605786f861de55065e46e3ebeeed38ae506e6d969a492bfbc3c3e
MATLAB
418
6
function linearRegression global SpikeArray SpikeArrayWon DrinkOnArray FirstWaterOn FirstWaterOff WaterOnArrayOriginal... WaterOffArrayOriginal RpegTouchallWon LpegTouchallWon RpegTimeArray LpegTimeArray tbl=table(SpikeArray,DrinkOnArray,RpegTouchallWon,LpegTouchallWon,RpegTimeArray,LpegTimeArray); lm...
60dd4163c0a887007f9cf1bd879a743759b5f33b950cf3ebf955914820582923
MATLAB
418
8
function [centeredSpikes, whichCentered] = getCenteredSpikes(obj, iCluster) %GETCENTEREDSPIKES Return subset of spikes which occur on center site of cluster iClusterSite = obj.clusterSites(iCluster); centeredSpikes = obj.spikesByCluster{iCluster}; clusterSites_ = obj.spikeSites(centeredSpikes); whic...
b9ad82964c63bacec2eb2cabb2952ed861f6f60d301920421cc171a09c05a33c
MATLAB
418
15
% update the object with the type of distribution to fit % ------------------------------------------ % This file is part of the adaptative_threshold SPM plug-in % Copyright (C) Cyril Pernet and Chris Gorgolewski 2012 classdef Distribution < handle properties(Constant,Abstract) free_parameters end ...
ea425dfaa8c1283d0c49d18a850b580e5173bb836a58ab1607e5d89851ee1ba3
MATLAB
418
14
function xRange = getXRange(iCluster, nSamples, hCfg) %GETXRANGE Get the x-values of iCluster waveforms for main view if hCfg.showRaw evtWindowSamp = hCfg.evtWindowRawSamp; else evtWindowSamp = hCfg.evtWindowSamp; end xOffset = iCluster - 1 + evtWindowSamp(2)/nSamples; xRange =...
073da9ec6a579cc0313aad8e12bf0e8a475368fea970c214c463a09d19334ba4
MATLAB
419
18
function move2front(hax_or_h,h) % function move2front([hax],h) % move h to the front of hax if nargin < 2 || isempty(hax_or_h) h = hax_or_h; hax = gca; else hax = hax_or_h; end axkids = get(hax,'Children'); ih = dsearchn(axkids,h); if isempty(ih), error('handle(%f) not a child of hax(%f)', h, hax); end remh_axk...
87d65d4beb2b6283c2d74b91a6554007899f1fc616da0b8565e0cc07a31a1ed8
MATLAB
419
11
function [Xmax,Ymax] = quadpeaks(X2,Magspec) % function [Xmax,Ymax] = quadpeaks(X2,Magspec) uses quadratic interpolation % to create refined estimates (Xmax,Ymax) of original peak estimates X2 in % spectrum Magspec. X1 = X2 - 1; X3 = X2 + 1; Y1 = Magspec(X1); Y2 = Magspec(X2); Y3 = Magspec(X3); A = 0.5*(Y3 - 2*Y2 + Y1...
b95240c05dc73de2298968c4ef6b439b87fc16efcbae661c5f22b53fe545dbbb
MATLAB
419
11
function pathnameMSHS = getMSHSpath(pathnameHeadModel) if isunix tmp = strfind(pathnameHeadModel,'/'); filename = pathnameHeadModel(tmp(end)+1:end); pathnameMSHS = fullfile(pathnameHeadModel,[filename '.mshs']); elseif ispc %need to test this! tmp = strfind(pathnameHeadModel,'\'); filename = pathna...
d3f153ba8058fcab3d71ffcb4d254e60684d7013ac89758cf11849059bbc2698
MATLAB
419
12
%% Script to Run Colocalization function ---------------------------------- % run afte selection: % Decalare New Variables Experiment=Experiment(Experiment~='\'); % NAMES PATCH global XY_merged; % global dyename; % global ColocateIndx; global MetaDataColocaliation; [XY_merged,MetaDataColocaliation]=get_merged_coord...
f87b136b02946f046127e973d72171e185d7508a0203eaa23b2f83955764e1e1
MATLAB
420
21
function outputArray = permuteArrayMaintainMarginals(A,N) % A is input array % N is number of rearrangements to perform [n, m] = size(A); %N = 10000; for k = 1:N r = randperm(n,2); r1 = r(1); r2 = r(2); c = randperm(m,2); c1 = c(1); c2 = c(2); d = randi([-min(A(r1,c1),A(r2,c2)),min(A(r1,c...
fb078270502f3fb0807f34113e141bf01fc3cc8b3fea22440a29d4775c01cbd2
MATLAB
420
13
function varargout = subsExt(filename, varargin) %SUBSEXT Substitute the extension of a file for a new extension % [out1, out2, ..] = subsExt(filename, ext1, ext2, ...) [dirname, filename, ~] = fileparts(filename); if isempty(dirname) dirname = '.'; end for i = 1:numel(varargin) ...
a628c789f0d53b86b09df8a16a81f5defd9f783e90dc63e1917c9a56016cdb07
MATLAB
421
5
function [dipole, teta] = DipoleGenerator4(HR, fs, alphai, bi, tetai, teta0) % DipoleGenerator4 has been deprecated. Use vcg_gen_var_hr instead with additional input parameter method = 'MATRIX'. warning('DipoleGenerator4 has been deprecated. Use vcg_gen_var_hr instead with additional input parameter method = ''MATRIX...
c8c8ce54ccccf64e1ccf12e5f2a73a4e0685662b472dff39652ba5bdf5430173
MATLAB
421
18
function [deg] = degrees_und(CIJ) % input: % CIJ = connection/adjacency matrix % output: % deg = degree for all vertices % % Computes the degree for a nondirected binary matrix. Weights are % discarded. % % Olaf Sporns, Indiana University, 2002/2006/2008 % ========================================...
09ae261f888014da9712ceddcea79aed93dd2fa8891f43c96b82a211be099cbe
MATLAB
422
19
function [totXrad_mean totXrad_min totXrad_max] = ComputeLatency(radX) for i=1:length(radX(1,:)) totXrad_mean(i)= mean(nonzeros(radX(:,i))); if sum(radX(:,i))>0 totXrad_min(i)= min(nonzeros(radX(:,i))); totXrad_max(i)= max(nonzeros(radX(:,i))); else totXrad_min(i)=0; totXrad_max(i)=0; end end totXrad_mean(is...
b01766e8f7355832c152fca7599235c009817cee93d483362f8712a1dbf83c38
MATLAB
422
18
function fVis = setVisible(obj, plotKey, fVis) %SETVISIBLE Set visibility of plot by key if isempty(plotKey) || nargin < 3 return; end if iscell(plotKey) cellfun(@(pKey) obj.setVisible(pKey, fVis), plotKey); return; end if ~obj.hasPlot(plotKey) return; end ...
e2b988729437b7db8cdb07a7bce4d19aa6b99eaa1606e7a52b84c523ad5897f4
MATLAB
422
18
[cols,alpha] = chooseColors; %% FINAL PLOT FOR FIGURE figure('Position',[100 100 300 300]) imagesc(mean(weight_corrs_null,3),[-.3 1]) set(gca,'XTick',[5 10 15 20]) set(gca,'XTickLabel',[-2 -1 0 1]) set(gca,'YTick',[5 10 15 20]) set(gca,'YTickLabel',[-2 -1 0 1]) xlabel('Time (s)') ylabel('Time (s)') if saveFig...
ec6f7945cdbbd9bad7c6435a6818047b07d3979213e1014bdd6a7e410890bb7a
MATLAB
422
28
function A = edgelist2sparse(E) % lone nodes look like this: % 1 NaN % 2 NaN % throw-out lone nodes E = E(~isnan(E(:,2)),:); I = E(:,1); J = E(:,2); B = sparse(I,J,1); padding = max(size(B)) - size(B); if sum(padding) == 0 A = B; else if padding(1) == 0 padding(1) = max(size(B)); A = [B zeros(padding...
cd729433ea75656b6930dd50a8f47e38573f7294500d2fd010465c47d6e14671
MATLAB
423
22
% Funtion to label multiple data from seveeral experiments of accumulated % cell groups by drug action % data: raw data % index: vector howmanypointsperexp % Output % x: data % y: experimetn label: '1','2',etc % function [x,y]=getcluslabs(data,index) Ndata=numel(data); Nexp=numel(index); y=cell(Ndata,1); x=data; a=1;...
5c566cca83e5462bbb3a73a80466d48e40501f8a9e6088d08deb30a02caf71f7
MATLAB
425
14
% runn all codes for the study main_COPE_session1_TestandPlot main_COPE_session34_TestandPlot main_corr5HTprojAndCOPE supp_consistencyBetweenSession1AndSession2 supp_contractBetweenSession3vs4 supp_contrastBetweenSession1vs2 supp_peaktimingANDBOLDconsistency visualizeAllTimeSeriesSession1st visualizeAllTimeSeriesSessi...
919d7282376710a26384402f594c1a6b07937778d8eff73fb02c5296605225e6
MATLAB
425
7
function subSpikes = getMidmostSpikes(spikes, spikeTimes, nClusterIntervals) %GETMIDMOSTSPIKES Get the spikes closest to the center spike middlemost = round(numel(spikeTimes)/2); % index of middlemost spike nearestToCenter = jrclust.utils.rankorder(abs(spikes - middlemost), 'ascend'); nSpikesInterval = ...
5959e9efaeb3697313014a6c2531a317b277ec1472b83e9e8ccabfbadef4a9d2
MATLAB
426
8
function score = FSCost(XT, yT, Xt, yt) svmStruct = svmtrain(XT, yT, 'kernel_function', 'rbf', 'rbf_sigma', 100, 'boxconstraint', 5); % svmStruct = svmtrain(r_train, types(train_index_subset), 'kernel_function', 'mlp');%, 'rbf_sigma', rbf_sigma, 'boxconstraint', length(interictal_train_index_subset)/length(preictal_tr...
c956f85bc80d469a68c07d1269737b8331804cc46a93b5e56b2e2d11e2ea4b0f
MATLAB
426
11
% HBF_DI_LC makes a LC double-layer matrix between two meshes % % D=HBF_D_LC(fieldmesh,sourcemesh,verbose) % fieldmesh: mesh, where double-layer potential is evaluated, hbf struct % sourcemesh: mesh, where the double layer is spanned, hbf struct % verbose (optional, default 0): give 1 for intermediate outp...
87c325c777e71513eb887dcb620d13ab893448622673030c1d43a8fd9310521c
MATLAB
427
15
function [CI_lower, CI_upper] = medianCI(vals, z) vals = vals(~isnan(vals)); n = numel(vals); % get lower and upper indexes based on z and number of elements lowerCIidx = round(n/2 - (z*sqrt(n))/2); upperCIidx = round(1+n/2 + (z*sqrt(n))/2); % sort vals into ascending order. ordered_vals = sort(vals); % index into ...
a8d6a2fd5b9fe102dca6a2f1f0fc5cc175ac6378ea4ccf6cc6c369212e8d61cd
MATLAB
428
16
function rsc = calc_PairwiseCorrs(spikes1, spikes2) % Uses the method of Kohn and Smith, 2005, simple % pearson's correlation between two neurons responses to repeats of the % same stimulus. Sig. faster than corr(x,y). % force spike counts to column vectors spikes1 = spikes1(:); spikes2 = spikes2(:); % calculate r_...
b208c55cb6e4abad4d54f2213ed0a17fafe8ffc7ad8105fdbac82d1376b861b4
MATLAB
428
21
%Function to evaluate multivariate normal liklihood function llike = mvnloglike(X, mu, omega) %% Input %X nxp matrix of observations %mu 1xp vector of means %omega pxp precision (inverse covariance) matrix %% Output %llike scaler log likelihood %% Begin Code [n,p] = size(X); like = zeros(n,1); c = -p/2*log(2*pi)+.5*...
e2d3c9f4f8c011c6213086356cb248716dc8bcf734ebeee882a7a854cdf14e07
MATLAB
428
15
function fatrix2_check_dim1(x, dim) %|function fatrix2_check_dim1(x, dim) %| %| check that array x has dimensions "dim" %| account for the "trailing 1" of size() for 1d column vectors if nargin < 2, help(mfilename), error(mfilename), end siz = size(x); if numel(siz) == numel(dim) + 1 && siz(end) == 1 siz = siz(1:e...
631f4e37e7647390f40e07e50cd973ff5e31e15965d50f2d3e9305fa8356267e
MATLAB
429
1
232363.0 11844.0 44277.0 7322.0 71470.0 8513.0 25053.0 37930.0 136245.0 24174.0 35224.0 107297.0 1718.0 6729.0 15662.0 36241.0 20039.0 63499.0 112352.0 119411.0 79229.0 97667.0 46381.0 120707.0 162703.0 24990.0 80576.0 129225.0 17844.0 52924.0 91001.0 102823.0 111317.0 3736.0 17426.0 33098.0 40403.0 64052.0 110737.0 55...
23de3954ac1402c5b6310472a8cd2a8b80992872dd253f2df5b3b6cf2c2836b3
MATLAB
430
17
function [myState myMap]=StateClear(myState, myMap) N=length(myState.state_history); myState.index=1; % current index myState.state_history=zeros(N,1); myState.state_history(1,1)=1; myState.action_history=zeros(N,1); myState.reward_history=zeros(N,1); myState.RPE_history=zeros(N,1); myState.SPE_history=ze...
4b3a7b845e2fe19189851224b88316746fe7473f33779de3415051bbc6586b4c
MATLAB
430
9
cd 'C:\Users\Admin\Git\repo\ZS-DeconvNet\Python_MATLAB_Codes\data_augment_recorrupt_matlab'; addpath(genpath('./XxUtils')); data_folder = 'F:/ZS-DeconvNet datasets/2D data/Lysosome/train_data'; % set data_folder to the folder you keep your raw data bg = 100; % background offset, used in re-corruption DataAugmFor2D(dat...
028b07f8c7c2de36301932ffa1312e33838c792372ce04c2c5e48a5db9209538
MATLAB
431
22
function z = fatrix2_embed(mask, dim, x) %function z = fatrix2_embed(mask, dim, x) %| %| version of embed that handles an empty mask %| %| in %| x [N L] %| dim [] size(mask) if mask is nonempty %| mask [(dim)] possibly empty %| %| out %| z [(dim) L] %| %| Copyright 2010-12-21, Jeff Fessler, University of Michigan i...
26b67b960b41a002ab0a6262cc4295cb1dbdecd95d3744f3ce0ef109ce9a88db
MATLAB
431
23
function chan=unit2ch(unitID,subject) %outputs channel number from unit ID in character form and subject ID ie. %'C' or 'PB' neuron=unitID; if subject=='C' if (neuron(12))=='_' chan=(neuron(11)); else chan=(neuron(11:12)); end elseif subject=='PB' if (neuron(13))=='_' ...
c080582b05edb29ffd667f49a39ea380e5d4c3b3ec0abd38bf4e73ffca363016
MATLAB
431
12
function [peaks, peak_indexes] = PeakDetection5(x, ff, varargin) % PeakDetection5 has been deprecated. Use peak_det_local_search instead. warning('PeakDetection5 has been deprecated. Use peak_det_local_search instead.'); if nargin > 2 && ~isempty(varargin{1}) flag = varargin{1}; else flag = abs(max(x)) > abs(m...
63cae0a3082afcce2e746c59b1be9904014050c87be02a58cf4d40a8c13d48db
MATLAB
432
14
function loadingSimilarityVector = getLoadingSimilarity(loadingMatrix) % based on Umakantha et al., 2021 % inputs: % loadingMatrix is a matrix of size n x D where n is the number of neurons % and D is the number of dimensions. % outputs: % a vector of size D where each element is the loading similarity of that % dim...
7a1da798318f01528721d3c4ddf0174e196187ec6bbea867d525e66d4e4c87ae
MATLAB
433
16
data =cell_data.intensities(1).intensty_data; data = data(:); interpulated_psth = bin_psth(data, 2); f4 = figure; set(f4,'position',[50 50 2000 250]); plot(interpulated_psth) hold on for i = 1:40 plot([(-70 + 100*i) (-70 + 100*i)],[0 65],'--k'); end for j = 1:20 patch([(30 + 200*(j-1)) (130+ 200*(j-1)) (13...
d72bc601f55b26cbf5eed7820c8de23cde750970a4194d9c85b5ef08e4fdeecc
MATLAB
433
16
% Select_Raster Script for POSIVE CELLS % Update_Directory; % Get Coordinates XY_nomerged=XY_selected(MetaDataColocaliation.NegativeCells,:); % Indexes of the Original Denoised Signals and Vectors [CleanSignals,IndexSorted]=Retrieve_Selected_Signal(Onsets,R_Condition,ESTSIGNALS,XY_nomerged,XY); Select_Raster_for_NN...
0d00fc4ab76d10f7b0b9fa6f0ed48fdbf6755f6cb70b60a6b6294be1f96c79dc
MATLAB
434
10
function indices = findContinousLogical(logicalVector, nElements) spanLocs = bwlabel(logicalVector); %identify contiguous logical true elements spanLength = regionprops(spanLocs, 'area'); %length of each span of true elements spanLength = [spanLength.Area]; goodSpans = find(spanLength>=nEl...
7465b00b3c8f256b0aa95a23131640ab0dfc6209527feb6143f86b1bf07139f3
MATLAB
434
21
function [ q ] = get_quadrant( cent ) %GET_QUADRANTS Summary of this function goes here % Detailed explanation goes here % 1: NW % 2: SW % 3: NE % 4: SE %% get quadrant if cent(2) < 424 && cent(1) < 208 q = 1; elseif cent(2) < 424 && cent(1) >= 208 q = 2; elseif cent(2...
7e79fb4ca28d1dde1b536c0309697032216a5bade368699b17a9d48adfa6dac9
MATLAB
434
21
function h = create_figure(name) % Create `full screen` figure % % Parameters % ---------- % - name: string % Name of figure % % Return % - h: matlab.ui.Figure % Handle of created figure h = figure(... 'Name', name, ... 'Color', 'white', ... '...
f328188866c30110e747cacf2853a065c32f7761d659ec419d3be291293a4c8c
MATLAB
434
26
% Implementations of the nearest orthogonal matrix (the Orthogonal % Procrustes problem) % Refer to: https://en.wikipedia.org/wiki/Orthogonal_matrix % % Reza Sameni, Jan 2019 N = 5 M = randn(N) % The SVD approach [U,S,V] = svd(M); Q = U*V' % The SVD approach [U,S,V] = svd(M); R1 = U*V' % The square root method R2 ...
f55d6cc6589f65c11552071e624f30dcb69f587a036e1e4d7f6d42e5bb76dbd9
MATLAB
434
22
function [model, fullfilename] = load_avg_model(session, channel, unit) % Load average neural model % % Parameters % ---------- % % % Returns % ------- % - model: struct (todo: need more details) % Neural model % - fullfilename: char vector % Filename of saved model info = get_info(); fullfilename = fullfile(... ...
462df5838d29e0b9ed73610b33ba3cc4f33fa5b089e57b94bd5db8019ebc944c
MATLAB
435
25
function DIV = new_divergence(f,g,h) %fourth-order accurate computation of divergence %inputs: f g h deformation fields %outputs: DIV divergence if isempty(h) [dfdx,~]=new_gradient(f,'fourth'); [~,dgdy]=new_gradient(g,'fourth'); DIV = dfdx + dgdy; else [dfdx,~,~]=new_gradient(f,'fourth'); ...
9e7322f39edad82fe97fc02c5d6b65db95e36eeda4829f221cce46125cb2ef96
MATLAB
435
4
function [dipole, teta]= DipoleGeneratorStochastic(N, fs, f, f_deviations, alphai, delta_alphai, bi, delta_bi, tetai, delta_tetai, teta0) % DipoleGeneratorStochastic has been deprecated. Use vcg_gen_stochastic instead. warning('DipoleGeneratorStochastic has been deprecated. Use vcg_gen_stochastic instead.'); [dipole...
e91b3eae774c21aab59c69f5056ca01a6d55c42d355eaf43da29993ee5c5e587
MATLAB
435
12
%% Function of monoamine transporter in vesicles. % Transport of histamine from cytosol to vesicles. % b = cha % c = vha function a = VMATH(b,c) k = 24; V = 10552; %31500 a = (V.*(b./(k + b)) - 5.*c); a(a<0) = 0; %Make sure a is not negative. %merickel95 reports 24 micromolar and also 3 micromolar from pre...
eef0cbc8675ef19375f63c8c103d8195e1c4f1135737331968422fda7e5d68dd
MATLAB
435
17
%% Rate of production of c5ht from 5htp. %Follows conventional michaelis menten mechanism. % b = 5htp %UNITS in uM and uM/h. function a = VAADC(b) km = 160; vmax = 400; %Vmax (vitamin B6 is a cofactor and will affect Vmax) a = vmax.*b./(km + b); %4.1.1.28 AADC %Km = 160 muM for 5HTp Chico06 (wrong in BRENDA) ...
094041bf0eaaf1737dc4658920689a240bc65641e20272a71710420de3856330
MATLAB
436
16
function [psdPower, psdFreq] = getPSD(traces, sampleRate, nSkip) %GETPSD Compute power spectral density of traces if nSkip > 1 traces = traces(1:nSkip:end, :); end n = size(traces, 1); n1 = round(n/2); psdPower = fft(jrclust.utils.meanSubtract(single(traces))); psdPower = jrclust.u...
2040967464a128414d9869602b1df282ba73db22f1871f9072c91006f500c8d3
MATLAB
436
16
function [Xout, Yout, Zout] = meshrep(q,X) %meshrep - takes a single vector q and meshgrid vector as input, returns %a grid of just q repeated at every point in space. Ensure X,Y,Z is 3D and %has equal dimensions. siz = size(X); assert(length(siz) == 3,'Meshgrid dimensions != 3'); assert(siz(1) == siz(2)); assert(siz...
8a52b8b57c1fab8d8069d96012c32d82d80c4e9b14ecdc57d9bc018da5aa13bb
MATLAB
438
18
function fo = remove_first_points_fillup(fi,numberofpoints) if ~exist('numberofpoints') numberofpoints=1; end fo = fi; for nbs = 1:length(fi) fo(nbs).fid = fi(nbs).fid(numberofpoints+1:end,:); zz=zeros(numberofpoints,size(fo(nbs).fid,2)); fo(nbs).fid = [fo(nbs).fid; zz]; % fo(nbs).spectrum.np = fo(nbs).sp...
2ab6e30c0535ed17f36b9df36e70bc7b18b1e67befdf170ed287c34e28e28c1a
MATLAB
439
19
function id = get_id(session, channel, unit) % Get neuron's ID % % Parameters % ---------- % - session: scalar % Session number with format: yymmdd % - channel: scalar % Channel number % - unit: scalar % Unit number % % Returns % ------- % - id: char vector ...
6c1e8673129e7b20713779fe0b47e02ba7e5e30826ff8e58dc9674e7141ac8d6
MATLAB
439
26
function X = load_dream_network(file) % this function strips-off the "G" characters from the gene identifiers disp( ['Loading ' file] ) tic d = importdata(file,'\t'); confidence = d.data; A = d.textdata; %% G1 G2 N = size(A,1); %% strip off the first character (G), convert to double B = char(A); C = B'; D = C(2:en...
ecd3027587f54a2b147da94be1cb112196b2c4bcf589bf52f78dda3cca2fd012
MATLAB
439
22
%Function to evaluate multivariate normal liklihood function llike = mvnloglike(X, mu, omega, s_assign) %% Input %X nxp matrix of observations %mu 1xp vector of means %omega pxp precision (inverse covariance) matrix %% Output %llike scaler log likelihood %% Begin Code [n,p] = size(X); like = zeros(n,1); for i = 1:n ...
1325e679fd6082740fd9872d0400f60c13dc0047fb52a146ce0b26a344c2ccdd
MATLAB
440
18
function mm = uniq(mm, sc) shift = prod(sc); shiftmat = reshape(shift-1 : -1 : 0, [sc(2) sc(1)])' / shift; mmsize = [size(mm, 1) size(mm, 2) size(mm, 3) size(mm, 4)]; coefs = mmsize ./ sc; shiftmat = repmat(shiftmat, coefs); mm = mm + shiftmat; fi = ceil((sc+1)/2); b = strel('rectangle', [sc(1) sc(2)]); z = imdil...
7ad9494f53653ee9af04c549cf44ed13f5e6ab7f5f9e5df6b0ca7826002e6784
MATLAB
440
13
function out = full(ob, varargin) % function out = full(ob, varargin) %| full(ob) = ob(:,:) %| %| note: alternative is ob * eye(np) but this may yield the %| wrong precision because eye() is double but ob may be single. %| %| optional argument(s) passed to fatrix2_subsref_colon() %| to facilitate test_adjoint %| %| C...
b925187ef0fb21d3f0b5a395fa7650fce152b5f0c89f26dd79e62144d799b3ab
MATLAB
441
10
%////////////////////////////////////////////////////////////////////////// function C = Cost_gamma(x, b, s, sigma2, gamma) % Cost_gamma has been deprecated and integrated with OptimalSmoothnessFactor. % n = min([length(x), length(b), length(s)]); % x = x(1:n); % b = b(1:n); % s = s(1:n); % C = sum(((s.^2.*x + s.*b)./(...
404b77f7ebf64dface9895f49ae06c6e952c3ec315fee39cebc503a19782e94a
MATLAB
442
19
function [val, success] = tryGpuArray(val, useGPU) %TRYGPUARRAY Try to construct a gpuArray from val if nargin == 2 && ~useGPU return; end try val = gpuArray(val); success = 1; catch try % reset GPU memory and try again gpuDevice(1); val = gpu...
8c94733bb92496b112012a01a5e53700bceab6ea4e93c4b9d2149b5a79470e4c
MATLAB
442
21
function [ ] = plotCommunities(A, S, linewidth) % plot the communities, A is the adj-mat, S is the community labels [~,idx] = sort(S); %subplot(211) imagesc(A(idx, idx)); hold on; currIdx = 1; for i = 1:max(S) width = sum(S == i); if width > 1 rectangle('Position',[currIdx, currIdx, width-1, width-1], ...
a92508bd11bf774f62175f784f18ed57fc3480e399d1d22a65018b06579887f8
MATLAB
442
21
% Plot detrended signals function Plot_detrended(XD) [Ns,Frames]=size(XD); figure; hold on; offsetplot=0; for i=1:Ns xd=XD(i,:); if sum(xd)==0 xd(:)=0.5; disp('Empty Signal ... ') offsetplot=offsetplot+1; else C=max(xd)-min(xd); xd=(xd-min(xd))/C; ...
31ba9e5bfb6385a1939db88debb641637c7cc8f49741d271d2acc63f2ee81ddb
MATLAB
444
15
% generate random binary matrix % p row q col % plus and minus randomly selected from n entries function [PlusInd, MinusInd] = RandPermIndMat(p,q,n) a = zeros(p,q); perturbIndBoth = randperm(numel(a), n); PMInd = logical(randi(2,size(perturbIndBoth,1),size(perturbIndBoth,2))-1); PlusInd = a; MinusInd = a; PlusInd(pert...
84f31974c0bd8195b833fc1f3765b6ac3ed311f30b2a1d3621c50eaed244cbf2
MATLAB
444
17
N = 360; R = linspace(0,1000,N)./1000; % (distance in km) Az = linspace(0,360,N); % in degrees %[~,~,windSpeed] = peaks(N); % radial wind speefor i = 1:8 binSize = 360/8; windSpeed = zeros(360); windSpeed(:,360-22:360) = test(1); windSpeed(:,1:22) = test(1); for i=2:8 windSpeed(:,23:23+(i-1)*binSize) = test(i); end f...
e58fbd132f96158bb190e3e9848368ac755ad522326fefd243373d014b769875
MATLAB
444
16
function [Xout, Yout, Zout] = meshtrans(q,X,Y,Z) %meshtrans - takes a single vector q and meshgrid vectors as input, returns %input grid translated by q as output. Ensure X,Y,Z is 3D and has equal %dimensions. siz = size(X); assert(length(siz) == 3,'Meshgrid dimensions != 3'); assert(siz(1) == siz(2)); assert(siz(2) ...
42b5b84157cbe86684ff10f37560c954a9329f0bac0a9b477f050db536408eab
MATLAB
445
13
function formats = supported_wc_extensions() % Return a cell of arrays with the formats supported. Automatically updated formats ={}; raw_readers_folder = fileparts(mfilename('fullpath')); files = dir(raw_readers_folder); for i = 1: length(files) fname = files(i).name; fend = regexp(...
7352cf6e2f8a2e364cd302d69143133d6a5ff62cd9d8f4f631ed8420872dceb9
MATLAB
445
16
function [newVectors, meanValue] = remmean(vectors); %REMMEAN - remove the mean from vectors % % [newVectors, meanValue] = remmean(vectors); % % Removes the mean of row vectors. % Returns the new vectors and the mean. % % This function is needed by FASTICA and FASTICAG % 24.8.1998 % Hugo Gävert newVector...
b2b3cebdd2c9d325db337642e5d0af0969dbc94ce0c90a831896a3629e7a9a17
MATLAB
446
15
function fj = gg_Gnufft_forw(st,Fk) % first deconvolve Fmintau = pi/st.tau*st.E4.*Fk; % then take iDFT to get fmintau padval = (st.Mr-st.M)/2; fmintau = fftn_fast(fftshift(pad(reshape(Fmintau,st.M,st.M),padval, ... padval,padval,padval,0)))/st.Mr/st.Mr; % now do fast gridding fj = forw_...
b9834f3dec6059c6b7b4f2859ee9ca5909c8df97930aabcb081abfc5102dc3a0
MATLAB
446
18
function [A,LAGS,recs] = jstar(binaryVec,trace,maxLag) binaryVec = [NaN(maxLag,1);binaryVec(:);NaN(maxLag,1)]; trace = [NaN(maxLag,1);trace(:);NaN(maxLag,1)]; points = find(binaryVec>0); LAGS = -maxLag:maxLag; recs = NaN(length(points), length(LAGS)); for i=1:length(poi...
fd903b8d582b10db25059130ce2395c2c4e0e72fb044ee8233bb720b201126b6
MATLAB
446
18
function [ movieMat ] = loadMovie( moviePath,varargin ) %loadMovie loading movie from h5 files %optional argument: start and stop index as a vector if isempty(varargin) movieMat = h5read(moviePath,'/1'); else start = varargin{1}; stop = varargin{2}; info = h5info(moviePath); chunkSize = info.Datas...
aee8706106341360bd69a2550a1e0dc6eea30196227db84c8f4d5b4a4cca05db
MATLAB
447
14
function [xVals, yVals] = getDiagXY(lim) %GETDIAGXY Get x-y values for outlines of diagonal entries % lim: [start, end] or [start, end, offset] yVals_ = floor((lim(1)*2:lim(2)*2 + 1)/2); xVals_ = [yVals_(2:end), lim(2)]; xVals = [xVals_(1:end - 1), fliplr(yVals_)]; yVals = [yVals_(1:end - 1),...
e46ba0a8a86e90c50783ca27d5868f267282f8bf127239f22d4b83708fef1244
MATLAB
447
7
function [HR, peaks, HRPeriodSD] = HRCalculation1(x, f, fs, trim, averaging_method) % HRCalculation1 has been deprecated. Use hr_calculation instead. Check the options in hr_calculation warning('HRCalculation1 has been deprecated. Use hr_calculation instead. Check the options in hr_calculation'); peak_det_method = 'LO...
0f42af094893be84b273f99a7548294ee4a147541432a08a3c2563aa4c7d9c31
MATLAB
448
32
function fo = average_series_fid(fids) fo=fids(1); for nbser = 1:length(fids) fid = fids(nbser).fid; ns = size(fid,2)/2; fid1 = fid(:,1:ns); fid2 = fid(:,(ns+1):end); fid1m = mean(fid1,2); fid2m = mean(fid2,2); if ~exist('fm1') fm1 = fid1m; fm2 = fid2m; else fm1 = fm1 + fid1m; ...
62ee6a5313c4065050b2905f01b1a1ec5a96077b2e870b8e8ebae345c4c70f0d
MATLAB
449
1
779354.0 16795.0 67766.0 25598.0 298184.0 22412.0 65177.0 122943.0 467115.0 93813.0 140845.0 409911.0 3888.0 16412.0 42595.0 88809.0 71548.0 234433.0 346469.0 371988.0 240627.0 297425.0 153089.0 369200.0 511585.0 36871.0 116470.0 216357.0 37836.0 121125.0 215091.0 333727.0 344195.0 8512.0 32867.0 45267.0 55538.0 322669...
b66a2cc090f2357f70cd2a997f1c6f83b54b7e2a0d1aacc2bacac21835b01c32
MATLAB
449
22
function traces(obj) %TRACES Show traces if isempty(obj.hCfg) error('Please specify a config file'); end if isempty(obj.res) obj.loadFiles(); end hTraces = jrclust.views.TracesController(obj.hCfg); if numel(obj.args) > 1 recID = str2double(obj.args{2}); if i...
964a12abc922d9ca92f39df6caa39034a2b55de4acd0026aa5a726b2b07d51a4
MATLAB
450
22
function z = fatrix2_select(mask, dim, y) %|function z = fatrix2_select(mask, dim, y) %| %| version of masker that handles an empty mask %| %| in %| y [*dim L] %| dim [] size(mask) if mask is nonempty %| mask [(dim)] possibly empty %| %| out %| z [N L] N = sum(mask(:)) %| %| Copyright 2010-12-21, Jeff Fessler, Uni...
b62f343cf2b64f9059f074dc22448d24797b08f4f496cf4b27325245a06d450f
MATLAB
450
17
function ShowmeyourCoordinates(XY,r,isSIGNAL) %% Show Coordinates % ALL figure; scatter(XY(:,1),XY(:,2),r.*r*pi,'LineWidth',1.5) Ncells=numel(r); Indexes=1:Ncells; hold on scatter(XY(isSIGNAL,1),XY(isSIGNAL,2),r(isSIGNAL).*r(isSIGNAL)*pi,... repmat([0.2,0.3,0.5],numel(isSIGNAL),1),'filled','LineWidth',1.5) for n=1:...
495c728cb2e6371752e5e71e8a8383e09c2a2f0e56af634005a20a9de33b8c23
MATLAB
451
16
function shuf = shuffleCellArray(cellArray,nPerms) allCounts = vertcat(cellArray{:}); shuf(nPerms).array = []; for iperm = 1:nPerms shufCounts = allCounts(randperm(numel(allCounts))); idx = 1; for icond = 1:numel(cellArray) nEle = numel(cellArray{icond}); shuf(iperm).array{icond} = shufCou...
d3ab11d5a88e87101cb0b0aa030c257a90fc7d5950f4041417fbd0ba7f6345d2
MATLAB
451
23
function knots = make_knots(values, delta) % Make knots % % Parameters % ---------- % - values: vector % Value of data points % - delta: scalar % Distance between two data points % % Returns % ------- % - knots: vector % Knots half_delta = fix(delta / 2); ...
174e85a9cc862d444f1e61c654bcd9d36b34fccc6d5f38dac3bf88e39d5cf373
MATLAB
452
18
function filename = get_filename(session, channel, unit) % Get neuron's filename % % Parameters % ---------- % - session: scalar % Session number with format: yymmdd % - channel: scalar % Channel number % % Returns % ------- % - filename: char vector % Neuron's ...
2fb073ec72adbe23dfc782a1e7f2e4cf46079e95340ebdad847727c68acbdfc7
MATLAB
453
18
function [map,thr] = filtermap(map, X) %% Filter X% of weakest connections from a map. % % [map,thr] = filtermap(map, X) % % Input: % map: projections matrix (uni- or bilateral) % X: X% (i.e. 0%-100%) of weakest connections will be filtered % % Output: % map: filtered projections matrix % thr: numerical t...
3b80bbe07e940c8327f900dea82335ac0fe6b6b4b8e028da751c5c0e78912c61
MATLAB
453
20
function setConfigFile(obj, configFile, reloadParams) %SETCONFIGFILE Don't use this. Seriously. if nargin < 2 return; end if nargin < 3 reloadParams = 1; end configFile_ = jrclust.utils.absPath(configFile); if isempty(configFile_) error('Could not find %s', ...
f2715410d18f56e16b5f0c7aaecd42b3639b6a610f557245a4d21ca6fc95575f
MATLAB
454
22
function co=correct_result_ration(ci,field_change,field_ref,scale_fac) if ~exist('scale_fac') scale_fac=1; end if isempty(field_change) field_change = find_metab_list(ci); end for npool = 1:length(ci) cpool = ci(npool); cref = getfield(cpool,field_ref); for k=1:length(field_change) cc = getfield(...
aebce59e342b2f3e046d8cf5042e4751dbc1e824ac20f20bf540214d723a7441
MATLAB
455
22
function [p,H,p2] = schreirer_hare(data,grp) [R,tie] = tiedrank(data); % compute the anova SS's on the ranks: [p1,p2] = anovan(R,grp,'display','off','model','interaction'); nvar = size(p2,1)-2; for l=1:nvar df(l) = p2{l+1,3}; SS(l) = p2{l+1,2}; end % total MS MS = sum(SS)/sum(df); % compute ratios for l=1:nvar-1 H(l)...
0ff1976fdfc643c783314075511bc3cf48a7d69e296c106194ae8440169f647b
MATLAB
456
15
function strstruct = struct2str(S) %STRUCT2STR Convert a struct to a string strstruct = ''; if ~isstruct(S) return; end fieldNames = fieldnames(S); for iField = 1:numel(fieldNames) strstruct = sprintf('%s%s = %s;', strstruct, fieldNames{iField}, jrclust.utils.field2str(S.(fieldN...
2bc6d48f06864153a7138ecf59ec6b64a1fe4b9f78737381b9d79539d1f2abb0
MATLAB
456
12
% HBF_PHIINF_DIR computes potential due to a current dipole in infinite % homogeneous conductor that has unit conductivity % % phiinf=HBF_PHIINF_DIR(fp,spos,sdir) % fp = field points (where the field is computed), [N x 3] % spos = source positions, [M x 3] % spdir = dipole moments (or, if unit-norm, di...
79d624e98b977acc4705b867e19913389d2bb0cf3063758119c539c56bac766e
MATLAB
456
24
function [map] = load_map(session, channel, unit, prb) % Load map of bases for a given probe % % Parameters % ---------- % % - prb: scalar % Probe index % % Returns % ------- % - map: array(time, delay, iteration) % Map of bases in time/delay grid info = get_info(); fullfilename = fullfile(... info.folders.ba...
1ae46dd811faec820f38a3f6d08a2972d6301f60d634acf998cf1326391f1087
MATLAB
457
18
function [ isConnectedorNot ] = isConnected( A ) % for a given adjacent matrix A, determine whether the graph is connected % or not A(A ~=0) = 1; stack = []; stack(1) = 1; isVisited = zeros(size(A,1),1); isVisited(1) = 1; while ~isempty(stack) curr = stack(end); stack = stack(1:end-1); addIdx = find(A(:,cur...
2064888f69e41b8a130a3d00aef104ef1dc0ff35c2ff4258c9cd730ae4f32b9a
MATLAB
458
15
function [x fs sequence] = LoadSeizureEEG(path, subject, mode, number, ch, time) load([path subject '_' mode '_segment_' num2str(number,'%.4d') '.mat']); varname = [mode '_segment_' num2str(number,'%d')]; eval(['data = ' varname '; clear ' varname ';']); x = data.data; fs = data.sampling_frequency; sequence = data.se...
3c39cdea018307a5655e738c14ccfa45e42cac7459fd40bf7bb5c843f87c5d0e
MATLAB
459
18
function [singleresponse] = extSingleBOLDresponse(timeseries) % This program is intended to calculate the single bold response % % % % % % by Hiroaki Hamada, Araya inc. 2019/Sep/22th [nTime, nROI] = size(timeseries); singleresponse = zeros(35,6,nROI); BOLDStim = [20,50,80,110,140,170] for nstim = 1:6, temporalsigna...
89fd8f7a6ff1eec20f74c02e9d0326d3a3ef6486a8da51743e8b29da4f417d70
MATLAB
459
21
function [session, channel, unit] = get_id_parts(id) % Get neuron's IDs % % Parameters % ---------- % - id: char vector % Neuron's ID % % Returns % ---------- % - session: scalar % Session number with format: yymmdd % - channel: scalar % Channel number % - u...
f106d5c47ddd8bac1a2683d290f9b0abd386b8c43255fbe6cebe1719b9b904fe
MATLAB
459
4
function [ecg, teta]= SingleChannelECGGeneratorStochastic(N, fs, f, f_deviations, alphai, delta_alphai, bi, delta_bi, tetai, delta_tetai, teta0) % SingleChannelECGGeneratorStochastic has been deprecated. Use ecg_gen_stochastic instead. warning('SingleChannelECGGeneratorStochastic has been deprecated. Use ecg_gen_stoc...
3d4cf33b747f7d8ef4669f3bf19894895341deb1b3ee1ce93f30f1f6508dcc93
MATLAB
460
16
function closeFigures(obj) %CLOSEFIGURES Close all open figures if obj.hasFig('FigWav') && obj.hFigs('FigWav').isReady hFigWav = obj.hFigs('FigWav'); remove(obj.hFigs, 'FigWav'); % to prevent infinite recursion! hFigWav.close(); % calls killFigWav end try obj.figApply(@(...
914da8bdab51b315d2770bd652b8304581d62e006faccf326dab75102ca8f12a
MATLAB
460
20
figure('Position',[100 100 1000 380]) for sub = 1:p.nSubjects subplot(2,6,sub) imagesc(mses(:,:,sub),[0 0.0003]) title(['Sub. ' num2str(sub)]) set(gca,'XTick',[]) set(gca,'YTick',[]) if sub == 1 || sub == 7 ylabel('Day') set(gca,'YTick',[1 11]) end if sub > 6 ...