sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
f525b4c1478656e79be301bab79869d66d1dccbfb5cb707ce1ad841e85bc324f
MATLAB
486
21
function t = CBIG_ttest_paired_stat_only(x) % Calculate one sample t test value. % % t = CBIG_ttest_paired_stat_only(x) % Input: % x: N x M matrix, N is number of samples, M is number of trails. % Output: % t: 1 x M vector, M is number of trails % % Written by CBIG under MIT license: https:...
3f4c14bc8b5ef8f84d6d2ee79fc301a66ed0e91ed25425a3399b0b36ccea892c
MATLAB
487
21
%% % Draws numSamples random directions on a spherical shell. % function [theta, phi] = randOnSphere(numSamples) if ndims(numSamples) == 1 theta = rand(1, numSamples); phi = rand(1, numSamples); elseif size(numSamples,1) == 2 theta = numSamples(1, :); phi = numSample...
53cd3b7bd19d1cfd6ece10f7c41ae7118044bd9094c1a0b14b7672870d2bc71a
MATLAB
491
17
%% function to get # of events and ROS relationship function [MedianROS, counts,edges] = GetROS_NEvent(Nevent,RateOverlapScore, step) edges = 0:step:ceil(max(Nevent)+4); Nbins = length(edges); BinnedN = discretize(Nevent, edges); MedianROS = zeros(Nbins,1); counts = zeros(Nbins,1...
fef0a8d36d539a85dc3e8abe29ab3eaf2e7dde7ff675129c4edba5ab042c0cc1
MATLAB
492
13
function [h_colormap,dab_colormap] = create_hdab_colormaps() %% Create H DAB colormaps for easier visualisation % @author: pdzialecka %% dab_col = (1-[0.26814753,0.57031375,0.77642715]); h_col = (1-[0.6500286,0.704031,0.2860126]); dab_colormap = [(linspace(dab_col(1),1,256)'),(linspace...
0080c9a893a2e126e35ada140c7ed25f7ae28160a86e7caab179a1c63644a0dd
MATLAB
495
13
%clear all;close all;clc; addpath(genpath('/home/ajoshi/projects/bfp/src')) fmribase = '/home/ajoshi/tmp_study_dir/sub08001/func/sub08001_rest_bold'; anatbase = '/home/ajoshi/tmp_study_dir/sub08001/anat/sub08001_T1w'; config.FSLPATH = '/home/ajoshi/webware/fsl' config.FSLOUTPUTTYPE='NIFTI_GZ'; config.AFNIPATH = '/home/...
a47fbcc40729f4a462a637cc8af5e1d851134440e7fd0d41632633bbc35a620c
MATLAB
495
20
function [gmm_idx] = gmm_eval(x, idx, sigma) % Evaluate gaussian mixture model on points X. % idx contains the previous clustering results % sigma is a fixed covariance for the gaussian mixture. dim = size(x,2); % calculate mean of each cluster mu = zeros(max(idx), size(x,2)); for i=1:max(idx) clc mu(i,...
71ee32231836ba44fea26edd4333a9dc1596e3c07e056d50d7a400c575bfbd39
MATLAB
497
20
function [target] = setstruct(target, value, fieldPattern) % SETSTRUCT Sets specified fields in the target struct to the given % value. if nargin < 3 fieldPattern = '.*'; end for field = rowvec(fieldnames(target)) for iPattern = 1:numobj(fieldPattern) matches = reg...
909e14a677c59a51fb60561abb57a465dd93ac55499502baa9030ef91ac79f94
MATLAB
497
8
function [dapi_colormap,BrdU_colormap,DCX_colormap,NeuN_colormap] = create_IF_colormaps() %% Create IF colormaps for easier visualisation % BrdU_colormap = [(linspace(0, 255, 256))'/256, linspace(0, 255, 256)'/256, zeros(256, 1)]; dapi_colormap = [zeros(256, 1), zeros(256, 1), (linspace(0, 255, 256...
e39edf1dab4a7073a6d4996b795e47ee36705fe0b91f0e11919f24fe164448a8
MATLAB
497
28
function plotSpectrogram(spec,freqAxis,timeAxis,smoothSpan,interpFactor,cLabel) % % Smooth C = smoothSignal(spec,smoothSpan); % Interpolate C = interp2(C,interpFactor); % Plot imagesc(timeAxis,freqAxis,C); axis('xy'); %% Formatting cbar = colorbar; colormap(jet(512)); %caxis(specLimits); xlim(timeAxis([1,end])); yl...
2841de8d11d6dc0f9970072c9e4c17edcede9ae8833c41305a474e6c9b7c671e
MATLAB
498
22
% %extracts events from a neuralynx events file. % %urut/may04 function events = getRawTTLs(filename) FieldSelection(1) = 1;%timestamps FieldSelection(2) = 0; FieldSelection(3) = 1;%ttls FieldSelection(4) = 0; FieldSelection(5) = 0; ExtractHeader = 1; ExtractMode = 1; %ModeArray(1)=fromInd; %ModeArray(2)=toInd; [time...
37f04c1a9192ec32c48a784d5eea3bb69a2f64733427fec42bb5f5d111435079
MATLAB
501
14
function out = ifft3(x) % Function that computes the inverse 3D Fourier transform of the input array x, % along the first three dimensions. % % Input parameters: % --x: 4D array of size [N1, N2, N3, Nc], where N1, N2, N3 are spatial % dimensions and Nc is the number of channels. % % Output parameters: % ...
3d682aaf19bcc543cf107be34617455f8c321f4ca6220c5ad07d045c2ab6626f
MATLAB
501
23
function [y]=nt_mat2trial(x,w) %[y]=nt_trial2mat(x) - convert 3D matrix to trial cell array % % y: trial array (each trial is channels * samples) % % x: matrix (samples * channels * trials) % w: weights (samples * 1 * trials) % % Weights, if provided, control the size of each trial. if nargin<2; w=[]; end [nsampl...
e17c2b2ec94326ab98113b0012433c0b54ee3517a512bc65ddfbca71ca7b7516
MATLAB
504
17
% Like diag(), except that slices (3rd and higher dimensions) are supported in that the diagonal % elements are extracted independently per slice. function D = diag3(A, k) if nargin < 2 || isempty(k) k = 0; end %% Get indices of diagonal elements szA = size(A); iDiag = diagIndex(A, k...
27cd772b51502521bccbd40ae5874e7259459c7d8fcf8d44fc6b6e102949e5d7
MATLAB
505
22
format longG q = [ 9000000.0000 9100000.0000 15200000.0000 16200000.0000 17900000.0000 18400000.0000 22400000.0000 23800000.0000 59000000.0000 59500000.0000 22400000.0000 23800000.0000 62900000.0000 64600000.0000 71500000.0000 71700000.0000 67000000.0...
aeb76ba8850e7089ba734c1181ec2bd1a7c56b4aa8c46dc594cb9b2c9b65cc50
MATLAB
505
13
%% function to calculate vector remapping (Pearson's between tuning curves in A and B) function VectorRemap = GetVectorRemap(HDir_Rate) [Ncell,~,~] = size(HDir_Rate); VectorRemap = zeros(Ncell,1); for c = 1:Ncell Curve1 = HDir_Rate(c,:,1); Curve1(Curve1 == 0) = randn(length(find(Curve1 == 0)),1)./1e9; %...
d830708f4818f04cade769616318cb6801dcbd325123c6a8ee91b2e166cd0a47
MATLAB
505
17
%% AUM %% %Shree Ganeshaya Namaha %function gen_brainordinates(subname,studydir) clear all;close all;clc; restoredefaultpath; addpath(genpath('/ImagePTE1/ajoshi/code_farm/bfp/dev/gifti-1.6')); addpath(genpath('/ImagePTE1/ajoshi/code_farm/svreg/src')); addpath(genpath('/ImagePTE1/ajoshi/code_farm/svreg/3rdParty')); BS...
2337d6934a50630dce47880c24f2cf0fbbe8a855eb0b942d54efd6e3af20d9a4
MATLAB
507
26
function txt = coloredText(txt, color) %% if ischar(txt) txt = coloredText({txt}, color); txt = txt{1}; return end %% if isinteger(color) color = double(color) / 255; end if size(color,1) == 1 rgb = color; end %% for iTxt = 1:numel...
ae96e27df7553cb4235a22186bd6c3d60400259d4654181dd762ff0bda702608
MATLAB
510
21
% Compute the geometric average of X along dimension dim (default 1) function gm = geometricMean(X, dim, omitNaN) %% Default arguments if nargin < 2 || isempty(dim) dim = 1; end if nargin < 3 || isempty(omitNaN) omitNaN = false; end %% Use log transform to avoid numerical under/ov...
0a15cb5d5750ae797d384b1b843bd49588405d4f834ee70b7a7c55cfd9d888b0
MATLAB
512
13
%% function to get angular difference between two contexts for a subset of cells function [AngDiff,IsOrthogonal] = GetAngularDifference(HD_list, HD_table) AngDiff = zeros(length(HD_list),1); IsOrthogonal = zeros(length(HD_list),1); for i = 1:length(HD_list) idx = find(HD_table.cellID == HD_li...
ef83860177e930c5eb1a87aa20face305ab4894123d82af8bcd0e9e18fc4d2e6
MATLAB
512
15
% Pregenerate filter weights function kernel = gaussianKernel2D(kernelWidth, nSigmas) if nargin < 2 nSigmas = 4; end filterSize = 2 * ceil(nSigmas * kernelWidth) + 1; x = linspace(-nSigmas * kernelWidth, nSigmas * kernelWidth, filterSize); [x1,x2] = meshgrid...
0cb68b8af84a85de3c761f91f76b03814c19934c71c5cf65ed7737fd96b6ac92
MATLAB
513
18
%% % Bin centers for a uniform division of the range xMin to xMax into nBins function centers = uniformBinsAround(xMin, xMax, xMiddle, dx) if nargin < 4 dx = xMiddle; xMiddle = xMax; nBins = xMin; half = floor( nBins/2 ); centers = linspace(xMiddle - half*dx, xMiddl...
c70cf0bfbb0fd03993ef35ea3fe8cb9cf33d2ddcec26f9913b37729a080cc85c
MATLAB
515
21
function [deltas] = delta_mod(data) %% Calculates the difference (delta) between two points % % **Usage:** [deltas] = delta_mod(data) % % Input(s): % - data : Input data vector (BS data) % Output(s): % - deltas : Differences between samples from input data % % Author: R.M.D. Kock, Leiden University %% ...
00e3b49a2b2372010430d2338dff43788c348cb3cb4f3ad460f5fed8a87bf7b2
MATLAB
516
25
%#function gcp function tNLMPDFGOrdfMRI(GOrdInFile,GOrdOutFile,fpr,memory,MultiThreading, scbPath) load(GOrdInFile); option = tNLMGPDF(); option.FPR = str2double(fpr); if ~strcmpi(memory,'auto') memory=str2double(memory); end if ischar(MultiThreading) MultiThreading = str2double(MultiThreading); end if Mul...
66298e713149a05de483ab80f7434547702f1aefd4ce892b393c479567f3c8f6
MATLAB
517
15
function coef_vals = SolveMP_wrapper(dictionary_n, x_im, opts) % coef_vals = l1ls_wrapper(dictionary_n, x_im, opts) % % Wrapper for Matching Pursuit % % Last Modified 6/10/2010 - Adam Charles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Run l1ls on the desired parameters coef_vals...
e444323595c93c1d7ffc4ea5465d5bb6471576f86ed6215cb37deec538349e35
MATLAB
518
18
% Returns the 2D rotation matrix to rotate points counterclockwise by an angle theta (in radians) function M = rotationMatrix2D(theta) if isrow(theta) theta = theta(:); end cosTheta = cos(theta); sinTheta = sin(theta); M = nan([2,2,size(theta)]); for iSl...
f7e10985142388b9e71bcc689f337f23d9fd14818170b9b416b4fc903f970352
MATLAB
519
18
function MAP = getColormap() % returns our standard Tuebingen Colormap %function getColormap() %midBlue = [0 105 170]./255; midBlue = [165 30 55]./255; %lightBlue = [80 170 200]./255; %lightBlue = [125 165 75]./255; lightBlue = [210 150 0]./255; steps = linspace(0,1,100)'; %MAP = bsxfun(@times,s...
71850b39dbd0fceafd78cb5e4fe83fb4fdc2d35ee0f8023cf6b0c24ba255e956
MATLAB
520
20
%% wrap mismatch function [FiringPref, RZ_ID, MeanRate] = WrapMisMatch(workdir) FiringPref = []; RZ_ID = []; MeanRate = []; for f = 1:length(workdir) load(strcat(workdir(f),"\processedData\MisMatchTbl.mat")); rfield_idx = find(Mismatch_tbl.IsActive == 1 & Mismatch_tbl.RewZone > 0); RZ_ID = [R...
bc2d43ec58378089a31bcacc59a37d25d02e01261025f896399c0df8ae5adec0
MATLAB
520
18
%% function to bin distance from reward and calculate mean and std of ros in each bin function [ROS_dist, counts, edges] = GetROS_Dist(RewDist, RateOverlapScore) edges = 0:2.50000001:ceil(max(RewDist))+2.50000001; Nbins = length(edges); BinnedDist = discretize(RewDist, edges); ROS_dist = zeros(Nbins,3); count...
de094e6ccd6efe5f960a4f4cd517ad3177a87fd939e4a05e74293f72fd09d5f5
MATLAB
520
22
% %extracts events from a neuralynx events file. % %urut/may04 function events = getRawTTLs(filename) FieldSelection(1) = 1;%timestamps FieldSelection(2) = 0; FieldSelection(3) = 1;%ttls FieldSelection(4) = 0; FieldSelection(5) = 0; ExtractHeader = 1; ExtractMode = 1; %ModeArray(1)=fromInd; %ModeArray(2)...
f496b638f7ca629014e414bb5c753d459e2e898bc417833d0c14918db9fada48
MATLAB
522
23
function [y] = at(x, i, noCellStr) % AT Smart(er) array addressing. % % Strings are treated as singletones unless the provided index i is a % non-singleton vector, or not 1. % % Otherwise returns x{i} for cell arrays and x(i) for other types of arrays. if nargin < 3 noCellStr = false; end ...
69dfb96cb143e016fd0bc9ccbd3f5001d10581da6a1db9c42a18b741c94745f1
MATLAB
523
26
function frequencyValue = Frequency(OriginalSignal,EventMatrix) % USAGE % % frequencyValue = Frequency(denoisedMatrix,event) % % Calculate the frequency of the events in a signal. % % % OriginalSignal Original signal (matrix) % EventMatrix Contains all the detected events (matrix) % ...
b70b7360e4064d6c2e94f0a97fded706455e513d03160b8a71d56027e5206753
MATLAB
524
23
function nt_plot_mmx(a,b,c) %nt_plot_mmx - plot data using min-max pairs % % nt_plot_mmx(x): plot x % nt_plot_mmx(abscissa,x): plot x using abscissa % nt_plot_mmx(abscissa,x,N): plot x using abscissa, with specified target number of min-max pairs [default: 1000] error('not yet implemented'); if nargin < 3 || i...
109b722160ca60ac73f92596037b2d471e3fa8bd70ee52511f3d694f9c4b467a
MATLAB
525
26
function C = nancorr( X,Y ) % NANCORR calculates the sample correlation coefficient % for the series with NaNs expected. % X is the one series, Y is another. X=X(:); Y=Y(:); L1=length(X); L2=length(Y); if L1 ~= L2 error('The samples must be of the same length') end for i=1:L1, if isnan(X(i...
35bef08d72d6aeed79505bf74c77628382a9d26c6c9e0839fc4900bb7fd954c7
MATLAB
526
20
classdef HoldoutParameters properties TrainRatio double % 0.0 ~ 1.0 NumSplits {mustBeInteger} RngSeed = []; end methods function obj = HoldoutParameters(trainRatio,numSplits,options) arguments trainRatio double numSplits {mustBeInt...
46e4d30aca60ff652948be77773ba55064a49f6d3ed328bd7deff16cbf466a94
MATLAB
526
20
function outpict = rgb2hwb(inpict) % RGB2HWB(INPICT) % Convert an RGB image to HWB (Hue, Whiteness, Blackness) % This is a variant of HSV proposed by Alvy Ray Smith (1996) % http://alvyray.com/Papers/CG/HWB_JGTv208.pdf % % INPICT is an RGB image of any standard image class % % Return type is double...
6a863978710d888f84e50baf3fafaa2226c7e326720e94a862c3774acce847b8
MATLAB
526
19
function b = get_box_num % Checks connected USB devices and returns the device number corresponding % to the scanner button box (box_id should be set the the productID of % the button box used locally). % Written by KGS Lab % Edited by AS 8/2014 % change to productID number of local button box box_id = 8; b = 0; d = P...
40e96a7fc190de0b5e406209d8462ecf73c17e71c331ade8f0edb464fd84f10d
MATLAB
527
17
%% % Extrapolates the given array by the requested left/right number of % items. % function [extended] = extend(array, left, right) delta = array(2) - array(1); moreLeft = uniformBinEdges(left -1, array(1)-left *delta, array(1) - delta); moreRight = uniformBinEdges(right-1, array(end) +...
e36eeb2fe59bb8575765c8c1979cdad2405e01ae526bc3ce144e3adef61ee7b5
MATLAB
527
21
%% % Bin centers for a uniform division of the range xMin to xMax into nBins function [centers] = uniformBinCenters(nBins, xMin, xMax, logarithmic) if nargin > 3 && logarithmic xMin = log(xMin); xMax = log(xMax); dx = (xMax - xMin) / nBins; centers = exp( (xMin + dx/2):dx:(xMax -...
409ef033a22b8a6cb2265413a8119c6e26e063f6fff9651fe9d0360243ce4d21
MATLAB
528
18
%% Concatenate results of arrayfun() along the specified dimension. function varargout = accumfun(dim, func, varargin) if ~isnumeric(dim) error('accmufun:input', 'dim must be a number.'); end if iscell(varargin{1}) fcn = @cellfun; else fcn = @arrayfun; end ...
5f59f0e9a33db813c60dcf4659f4ac37e99c449ddf984a1d888f7a8c64ef64bc
MATLAB
528
19
%% function to get mismatch matrices function rate_ordered = GetMisMatchMatrix(rate,id,pref) % split fields into ctx A and B RZ fields idx = cell(2,1); pref_split = cell(2,1); rate_split = cell(2,1); rate_ordered = cell(2,1); for i = 1:2 idx{i} =find(id == i); pref_split{i} = pref(idx{i}); rate_...
b5d6fd4c8c76342b89d2d02065c3b0d235b33f194e8eb136809f01e42c07996e
MATLAB
528
18
function permut = CBIG_permutation_given_inversion(inv_vec) % Given the inversion of a permutation (4 3 2 1 5), get the permutation. % % permut = CBIG_permutation_given_inversion(inv_vec) % Input: % inv_vec : inversion vector e.g. 4 3 2 1 5 % Output: % permut : permutation e.g. 5 4 3 2 1 % % Written...
e0a4c294f5079cfbfe24b0c35cfded22d8adffa375785e3c0141165aa5d65e47
MATLAB
528
19
%% Returns a vector of length n with all zero entries except at position k, which has value 1 % one = 1 by default, and can be used to override the value of the hot bit. % dim = 1 by default, and specifies the dimension along which the vector has length n. function v = onehot(k, n, one, dim) v = zeros(n...
e6f2fc5041bf854aaa40a946f72eff32bfe0e4f1aeaad88d1da270146c4309a7
MATLAB
528
20
function next = set_image_index(input) indices = containers.Map('KeyType', 'uint32', 'ValueType', 'uint32'); function index = produce_index(series) if indices.isKey(series) index = indices(series) + 1; else index = 1; end indices(ser...
fb7a85c5da867a1ec8e0868dd232ee36f3512132e2bb83a141939b534367e654
MATLAB
528
16
function [spikePhase] = getPhaseLocking(signalFilt, spikeIndx) %% By Joachim % Calculates spike-LFP phaselocking % dependencies % HilbertTransf (Located in Preproccessing) % Inputs: % signalFilt: Filtered signal % spike_indx: spikeTimes as index for when they occurred during % signal % Output: % ...
990568b37e0731cf945492ceaafdc69f70a2c19abea4ec98440ebf4dfc7c9e75
MATLAB
529
15
function coef_vals = perform_omp_wrapper(dictionary_n, x_im, opts) % coef_vals = l1ls_wrapper(dictionary_n, x_im, opts) % % Wrapper for Orthogonal Matching Pursuit % % Last Modified 6/10/2010 - Adam Charles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Run l1ls on the desired parame...
fd81ac3aa34b9ae517141a6f9f4ce0320eac412fe483d95b59d01529ef979034
MATLAB
530
17
%% % Creates an array of bin centers, uniformly spread and covering [xMin, % xMax) with the given pitch dx. Note that xMax is the upper bound and % therefore not included in the range. function [centers] = bestBinEdges(xMin, xMax, dx) % First determine the segmentation xRange = xMax - xMin; numB...
b8bc8c1c4902d3a278469ab18d0203a90f225945299b2ec3e8bc8a322133a391
MATLAB
535
14
function next = create_ismrmrd_image(input, header) function image = create_image(image) image = gadgetron.types.Image.from_data(image.data, image.reference); image.header.image_type = gadgetron.types.Image.MAGNITUDE; image.header.field_of_view = [ ... header.encoding.re...
cc3fc16039a6fdcf256ba37c6a9f5befa8a6aef393f6a2f952acc6b9c63ed558
MATLAB
536
22
function cov_xy = CBIG_cov_matrix(x,y) % function cov_xy = CBIG_cov_matrix(x,y) % % Calculates the covariance matrix given two matrices x and y. % % Inputs: % - x % N*K1 matrix, N is # observation, K1 is # variables % % - y % N*K2 matrix, N is # observation, K2 is # variables % % Outputs: % - cov_xy: % K1*K2 ...
e7093f88439220975cd444d58d84dcbbd27665d0e7f5054542ad1aaaac2a6aaf
MATLAB
537
36
function y = filter_iir(x,a,b,N) size_x = size(x,1); y = x; w_a = 0; w_b = 0; N = N; for i = 1:N for j = 1: i w_a = b(j) * x(i-(j-1)) + w_a; end if(i == 1) w_b = 0; else for j = 2: i w_b = a(j) * y(i-(j-1)) + w_b; end end y(i) = w_a - w_b; w_b = 0; w_a = 0; en...
26ffa92cefefd452721f52716a02cbc236bc1e1c7fbc7484df0d4066737694cf
MATLAB
538
23
function x=nt_fixsign(x) %y=nt_fixsign(x) - flip signs to maximize inter-component correlation if ndims(x)<3; y=nt_pca(x); y=y(:,1)'*x; % correlation with PC x=x*sign(diag(y)); else [m,n,o]=size(x); if 0 % can't remember the logic of this... for k=1:n x(:,k,:)=reshape(nt...
5e9b267b1c2bdcec42843f55c940c1f41b2bc3dce7869509a9727caa0ed7ce1d
MATLAB
538
15
function coef_vals = l1ls_wrapper(dictionary_n, x_im, opts) % coef_vals = l1ls_wrapper(dictionary_n, x_im, opts) % % Wrapper for the l1ls minimization function % % Last Modified 6/10/2010 - Adam Charles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Run l1ls on the desired parameters...
632117998b39241fa9f1f4d94e1cf5926cf0d52ef90b38dbdc1fbb7650707b71
MATLAB
538
22
function result = correlateImages(images) % input: images should be a cell array, each cell contains an N-dimensional % image numImages = length(images); for i=1:numImages % if there are more than 2 dimensions for this image, average along the % other dimensions until you get a 2d image while (length(size(...
7a62b360626ecf37035c4b93194a6522d71be785a07f5b0a26815f99c281a538
MATLAB
538
22
function z = jointEntropy(x, y) % Compute joint entropy z=H(x,y) of two discrete variables x and y. % Input: % x, y: two integer vector of the same length % Output: % z: joint entroy z=H(x,y) % Written by Mo Chen (sth4nth@gmail.com). assert(numel(x) == numel(y)); n = numel(x); x = reshape(x,1,n); y = reshape(y...
4f18a2b4102879efba4cb392fda0a5ce181f5892cdac9bf06dd48d3e212d512c
MATLAB
539
21
%% function subsample population and recalculate 1) difference between median and 25th pctile of two pops 2) ranksum function [DistDifference, p_val] = SubSamplePopulation(popToSubSamp, popToMatch, repeat) DistDifference = zeros(repeat,2); p_val = zeros(repeat,1); NsubSize = length(popToMatch); for r = 1:rep...
773940375f10bf3692e83ca8f4cb6b1b573529f626b98ed8015ccb3eca5c389f
MATLAB
539
12
%Run the Spike batch and save the result. %clear %Select the analysis main function mfile='W:\Analysis\MEA\MEA_Toolbox\Batch_SpikeDetection.m'; %Select the batch file bfile='W:\Analysis\MEA\2022-11-22\IIA_spikes_detection\Slice2\IIABatch16h59.bat'; %Run the analysis for all the lines in the batch file batch = StartBat...
b3f1187ba20010c4488b94c7c457c710a36a3c7d8979d3aaed88c0d95f3c553d
MATLAB
539
21
function cell_nums = nums_from_ids(datarun, cell_ids) % convert cell ids to row vector of cell numbers % % 2010-01 phli % cell_nums = zeros(1,length(cell_ids)); for cc = 1:length(cell_ids) % look for the specified cell id in the list of cell ids temp = find(datarun.cell_ids == cell_ids(cc)); if ~isempty...
8532d74b1acb5cd9306e5cc0cd0ed03356726937f37622bf4cc754530e9a0b4f
MATLAB
540
17
%% % Creates an array of bin centers, uniformly spread and covering [xMin, % xMax) with the given pitch dx. Note that xMax is the upper bound and % therefore not included in the range. function [centers] = bestBins(xMin, xMax, dx) % First determine the segmentation xRange = xMax - xMin; numBins ...
ad54e89b3caa2e0afe87d717cc14d4b56c8f6f68e835135132e9ed7244cfa419
MATLAB
540
16
function [peaks, isPeak] = localPeaks(data, minHeight) dRight = [data(2:end,:) - data(1:end-1,:); zeros(1,size(data,2))]; dLeft = [zeros(1,size(data,2)); -dRight(1:end-1,:)]; isPeak = ( data >= minHeight ) & ( min(dRight,dLeft) < 0 ) & ( max(dRight,dLeft) <= 0 ); % ...
ae8d59b0eb38948cc1d1dab8b575f409d19e626cfef6fb295d26e2fe609f37b6
MATLAB
543
21
function setaddaxisdata(axishandle,data,flag); % setaddaxisdata(axishandle,data,flag) % % internal function for addaxis to update the added axes handles and plot % handles, or to save the original figure position. if nargin<3, flag = 'axisdata'; end; aad = getappdata(axishandle,'addaxis_data'); ...
ddd2c1ccfb68ff8d3b371668b14d5ebabde34b84810c9767db6bd3016b5e57cc
MATLAB
543
25
classdef Waveform properties header data end methods function self = Waveform(header, data) self.header = header; self.data = data; end function tf = isequal(self, other) tf = ... isequal(self.head...
23cfff6b4edf3c13335fb7e4a6124b435b543223f2c5b12a19de12f135e36b38
MATLAB
547
23
%% % Bin edges for a uniform division of the range xMin to xMax into nBins function [edges] = uniformBinEdges(nBins, xMin, xMax, integral, logarithmic) if nBins < 1 edges = []; elseif nargin > 4 && logarithmic xMin = log(xMin); xMax = log(xMax); dx = (xMax - xMin) / nB...
65bf6b44afcd4d17af673f4af89e9010089f572378bfa9074b5e9454ed443835
MATLAB
547
24
function CBIG_cell2text(cell_var, filename) % CBIG_cell2text(cell_var, filename) % % This function writes a cell array (cell_var) into a text file "filename". % % Inputs: % - cell_var % The cell array that the user wants to write out. % % - filename % Full path of the output text file. % % Written by C...
9e250da71b22d2d40d19c3b7fd8e1e429bd68615e853f5eb6a905a1c377be456
MATLAB
547
13
function sens = ESPIRiT_calc_sens(dat, dimRef) % FORMAT sens = ESPIRiT_calc_sens(dat, dimref) % dat - k-space [ro p1 p2 cl] % dimRef - either a vector with reference vol dimentions (epi) or a structure of PPIparams (MPM) - parameters describing the acceleration global N_order if isstruct(dimRef) % PPIparams ...
6b172e966429fea28a48302efd272005d13a016778ff382e2dce43cd2d855656
MATLAB
548
23
classdef ReconstructionParameters properties DimPI (1,1) {mustBeInteger} ThreshWidth (1,1) double end methods function obj = ReconstructionParameters(dimPI,threshWidth) obj.DimPI = dimPI; if mod(1/threshWidth,1) == 0 obj.ThreshWidth = threshWi...
4d6f9d318f05b3cdce4f9eee84cff745290a6db90e0913dbe7bfe1c8b5e77931
MATLAB
549
16
%% save() functionality for parallel computing. N.B. All arguments must be Matlab variables, e.g. an array element x(i) will break this code! function parsave(filename, varargin) options = {}; what = struct(); for iArg = 1:numel(varargin) if ischar(varargin{iArg}) && ~isempty...
e16700594f0bed33fc02d9eeb6eb04475138915ce38d30e2e2e153a1fb8dabea
MATLAB
551
24
function h=nt_banner(text) %h=nt_banner(text) - annotate with text at head of figure % % h: handle to annotation % % text: string to print % % default horizontal position is 'center' % % NoiseTools c=get(gcf,'children'); % find the top of uppermost subplot y=0; for k=1:numel(c) pos=get(c(k),'position'); ...
e77d25ab639fe81f9e0c729f11705a9b2572521d24425546a711cfe0632d6f80
MATLAB
551
15
clear all;close all;clc; restoredefaultpath; addpath(genpath('/home/ajoshi/Projects/bfp/src')); bfpdir='/home/ajoshi/Projects/bfp'; %fmridatfile='/home/ajoshi/coding_ground/fMRIReg/src/task_diff_dyn.mat'; fmridatfile='/home/ajoshi/Downloads/for_parsa/bfpoutput/sub1/func/sub1_task-restingstate_bold.32k.GOrd.mat'; %'/d...
ffab9a54807fd2322984dd05db2ca0907c960f8ca8e4a43c906169f40880fd2e
MATLAB
551
16
% addpath /Users/stephen.whitmarsh/WhitmarshEpilepsy/ addpath /Users/stephen.whitmarsh/fieldtrip/ ft_defaults patient_directory = '/Users/stephen.whitmarsh'; patient_directory = '/Volumes/epimicro/Donnees-analyses/Stephen/pat_02230_0674/eeg'; directory_searchstring = '02230_2015-02-25_*'; directory_sear...
b1293f5490e87bb9694c85d47f2723c13e0686e9857c6c69719ccf65ddfd4ff7
MATLAB
553
20
function lab = lch2lab(lch) % LAB = LCH2LAB(LCH) % Perform a simple polar-rectangular conversion on color data. % % LCH is a 3-channel image formatted with its lightness component first % and with its hue channel in degrees. % % Output LAB is of the same scale as LCH. The output does not have to % be CIELAB...
062136ad5dbb2eb011877c45f15af4d8fd78631c14132a14dc22143fe00808d6
MATLAB
554
21
%% Output the arithmetic mean of all arguments: (x_1 + x_2 + ... + x_n ) / n % Test: % data = {randn(5,3), randn(5,3), randn(5,3)}; % accummean(data{:}) - mean(cat(3,data{:}),3) function mu = accummean(varargin) %% Special case for no inputs if isempty(varargin) mu = 0; return end ...
803d566fb02d35b52183b9ef0383f4c06f2e0f4906e44d3a337bf5b9a05486b7
MATLAB
554
15
function coef_vals = SolveOOMP_wrapper(dictionary_n, x_im, opts) % coef_vals = l1ls_wrapper(dictionary_n, x_im, opts) % % Wrapper for Optimized Orthogonal Matching Pursuit % % Last Modified 6/10/2010 - Adam Charles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Run l1ls on the desire...
ca54d35ec0f267bb0ee59c5b8f4b0fc183acfe53e6fa98845183284e4df96780
MATLAB
558
21
function x = CBIG_StableAtanh(x) % Stable version of atanh. It constrains the input within [-1 1] and output within [atanh(-1+eps) atanh(1-eps)]. % % x = CBIG_StableAtanh(x) % Input: % x: a matrix % Output: % x: a matrix % % Written by CBIG under MIT license: https://github.com/ThomasYeoLab...
237bbb006ac4e79cdfe064535cfbdce25ce3b0f085366a07f72e8976f97e471d
MATLAB
559
20
% PAIRWISECORR Fast calculation of Pearson's correlation coefficient for each pair of columns in X and Y function [corrCoeff, stdX, stdY] = pairwiseCorr(X, Y, omitNaN) if nargin < 3 || isempty(omitNaN) omitNaN = false; end %% Convert to unit vectors in data space [X, stdX] = unitSpreadDirec...
31fc05412387cdb2cc53497c6166a48f0be2775f6130c4d87147dca836c587d7
MATLAB
559
17
function corr_mat = CBIG_self_corr(s_series) % Calculate self correlation within a matrix. % % corr_mat = CBIG_self_corr(s_series) % Inputs: % s_series: T x N matrix, T is number of frames, N is number of voxels % Outputs: % corr_mat: N x N matrix, N is number of voxels % % Written by CBIG...
5f76dcec2c5e68fa74daa0e85bb28715b3e349e523fc093cc272d834859330d5
MATLAB
559
15
function ticks = niceTicks(range, numDivisions) %% stdRes = [0.01 0.1 0.5 1 2 5 10 50 100 500 1e4 1e5 1e6 1e8 1e10]; range = extrema(range(:)); resolution = abs(range(2) - range(1)); resolution = stdRes( binarySearch(stdRes, resolution/numDivisions, 0, 2) ); %% range = [flo...
3ac462c82b43f295fcf0b50163e9ab7974fd1bc8db9a69095cea6805cd3df2be
MATLAB
560
15
function coef_vals = cg_l2l1_wrapper(dictionary_n, x_im, opts) % coef_vals = l1ls_wrapper(dictionary_n, x_im, opts) % % Wrapper for the l2l1 conjugate gradient minimization function % % Last Modified 6/10/2010 - Adam Charles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Run l1ls on ...
e1935a1e10226d6a3a4bf75b28551f5e1ffee383d32d1d83ae94abe755b29b8f
MATLAB
561
15
function coef_vals = groupLCA_wrapper(dictionary_n, x_im, opts) % coef_vals = l1ls_wrapper(dictionary_n, x_im, opts) % % Wrapper for the block l1 minimization function % % Last Modified 1/28/2015 - Adam Charles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Run l1ls on the desired pa...
c380be0287f536d8ff514b87a93f0ce4f8fe328d470200dcefa2749261c034cb
MATLAB
562
20
function result = erws2(ampa_current, gaba_current, params, v_0, rec_step) if nargin < 4 v_0 = 0; end if nargin < 5 rec_step = 2.0; end tau_AMPA = params(1) * power(v_0, -params(2)) + params(3); tau_GABA = params(4) * power(v_0, -params(5)) + params(6); alpha = params(7) * p...
c4ffae8a0f5a1fe8300052fb70bc78b9e1d1d98a4085b4da84941f4437197cd4
MATLAB
562
12
function buffer_recon(connection) % 'Buffer' is a colloquial name for Recon Data. next = gadgetron.examples.steps.create_slice_from_recon_data(@connection.next); next = gadgetron.examples.steps.basic_reconstruction(next); next = gadgetron.examples.steps.combine_channels(next); next = gadgetron...
8d112d758929edf1eabd89a252314a675f8c24049851d54015a8565843927534
MATLAB
563
15
function coef_vals = l1ls_nneg_wrapper(dictionary_n, x_im, opts) % coef_vals = l1ls_wrapper(dictionary_n, x_im, opts) % % Wrapper for the l1ls non negative minimization function % % Last Modified 6/10/2010 - Adam Charles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Run l1ls on the ...
6d5c9c89af4bbd08266f5cbbad318e951bceb4152080772efd298612fbe94747
MATLAB
567
17
%% % Draws nPoints random points in a spherical shell with radius % [rMin,rMax]. The return value is a 3 x nPoints matrix where the rows % are x,y,z coordinates of the points respectively. % % Reference: % http://www.mathworks.com/matlabcentral/answers/353-uniform-distribution-of-n-points-within-a-sph...
08b18fb4c9aa5c73e86049ec166a644777e454d1891637bc1fcf627908ad2ce9
MATLAB
568
21
function varargout = findOrZero(varargin) varargout = cell(nargout, 1); if nargout <= 1 varargout{1} = find(varargin{:}); elseif nargout == 2 [varargout{1}, varargout{2}] = find(varargin{:}); elseif nargout == 3 [varargout{1}, varargout{2}, varargout{3}] = find(varargin{:})...
6075a6575bc755f1d9ebc120588330ed17f92eb235d0ff37c8a35e111f08cb25
MATLAB
568
30
function v_ref = fMRI_findRefv(v,k,verbose) % v = nifti file % k = searches only multiple of k timepoints % verbose: 1 or 0 % author: soyoung choi USC if isstruct(v) vls = v; else isa(v,'char'); if exist(v,'file') vls = load_untouch_nii_gz(v); end end n= floor(size(vls.img,4)/k); smeasure = zeros...
c502f6a23b63997d7761db8819826d27d4d2cc488e266174db17cefad2e603bd
MATLAB
568
15
function out = ft3(x) % Function that computes the 3D Fourier transform of the input array x, % applying fftshift and ifftshift for proper centering. % % Input parameters: % --x: 4D array of size [N1, N2, N3, Nc], where N1, N2, N3 are spatial % dimensions and Nc is the number of channels. % % Output parame...
c78bdcb60e2d1450b823d4c92c9d3c08a505ee2c9b696ec0393361ce4633ecd4
MATLAB
568
26
%% % function [edges] = toBinEdges(centers) if numel(centers) < 1 error('At least one bin center must be provided.'); end % Guesstimate in case of triviality if numel(centers) < 2 edges = centers + [-0.5 0.5]; return; end dx1 = centers(2) - centers(1); dx2...
d070b4dc7da209bc6f7180fe44ffeaee219c39d3b46efc0eac132be998ee7b0c
MATLAB
571
15
function coef_vals = greed_omp_qr_wrapper(dictionary_n, x_im, opts) % coef_vals = l1ls_wrapper(dictionary_n, x_im, opts) % % Wrapper for the QR implementation of Orthogonal Matching Pursuit % % Last Modified 6/10/2010 - Adam Charles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Run ...
1d6aa8effca591521dff9f547adc84bc9477c74befe2918334b29d17270e66aa
MATLAB
573
17
%% Information entropy–based fitness function function [ff] = infoEntropyCost(c, data) X = data; alpha = fix(c(1)); % Penalty factor (moderate bandwidth constraint) K = fix(c(2)); % Number of modes (IMFs) for decomposition %--------------- Perform VMD decomposition on the input signal -------------- [u, u...
3e23b1d0f63659a93d8c823852ed4dbe092a347f9b8154fa271500ec7777d712
MATLAB
573
21
function [S,C] = conncomp(G) % CONNCOMP Drop in replacement for graphconncomp.m from the bioinformatics % toobox. G is an n by n adjacency matrix, then this identifies the S % connected components C. This is also an order of magnitude faster. % % [S,C] = conncomp(G) % % Inputs: % G n by n adjacency m...
88eaa3fde412f398c1f9e088e993dcc2f281bb218a79267b59aa8f5d474f1c94
MATLAB
574
13
function yeahitis = isimageclass(inpict) % ISIMAGECLASS(INPICT) % Check if an array is of a standard image class. % Returns true for the following datatypes: % 'double','single','uint8','uint16','int16','logical' % % See also: ismono, issolidcolor, isopaque % yes, ~isempty(find(strcmp())) is faster tha...
7dddded1802b209c28a57043c0b6dbb120fcad1029c15b431c2144594cf88c97
MATLAB
575
15
function [MuseStruct_updated] = updateBadMuseMarkers(cfg, MuseStruct_updated) % don't write original muse markers to file cfg.muse.write = false; MuseStruct_new = readMuseMarkers(cfg, true); for ipart = 1 : size(MuseStruct_new, 2) for idir = 1 : size(MuseStruct_new{ipart}, 2) try Muse...
56688452aa4cef0506e467298dd0f08cbbf00417445dc1d774d4c0e9ec3363ee
MATLAB
576
18
function PPC = computePPC(phases) % by Mattia: computes PPC given a vector of phases. It is in vectorized % form and therefore not easy to read. For an explanation of % the computation steps, see Vinck et al (2010) % INPUT % phases : - vector of phases (in radians) % OUTPUT % PPC : -...
00fffdd0d44c10d8993998aa9674746d4fc2ed9d330ebde56706af4910deec06
MATLAB
578
13
%Run the IIA batch and save the result. %clear %Select the analysis main function mfile='W:\Analysis\MEA\MEA_Toolbox\Batch_InterictalDetection.m'; %Select the batch file bfile='W:\Analysis\MEA\2022-11-22\IIA_spikes_detection\Slice2\IIABatch16h59.bat'; %Run the analysis for all the lines in the batch file batch = Star...
63b1edd503f4c773b32cb3bf560869ca8b44f092d0f57ce33b70ed2bc66362f0
MATLAB
578
13
%----------------------------------------------------------------------- % Job saved on 16-Sep-2024 09:48:40 by cfg_util (rev $Rev: 7345 $) % spm SPM - SPM12 (7771) % cfg_basicio BasicIO - Unknown %----------------------------------------------------------------------- load('tmp_jobs/workspace_spatial_smoothing....
293f098d074cb5eecb36d157a2d8f7b6051cbb73f3ecfc83f697f7de8d3fc37f
MATLAB
579
29
function [B,A] = nt_filter_peak(Wo,Q) %[B,A] = nt_filter_peak(Wo,Q) - second order resonator filter % % Wo: peak frequency (1 == nyquist) % Q: quality factor % % NoiseTools if nargin<2; error('!'); end if Wo>1; error('normalized centre frequency should be < 1'); end BW=Wo/Q; % frequencies are normalized by pi. BW = ...
f7dfe30a940bda76d879ec21f817400b091948526514567b7007171355de1ba2
MATLAB
579
27
function amplitude = MeanAmplitude(DetectedEventsMatrix) % USAGE % % amplitude = MeanAmplitude(DetectedEventsMatrix) % % Calculate the mean amplitude of all the events which are in the input % matrix % % % DetectedEventsMatrix Matrix which contains all the detected % ...
781370114b8fd5b1b6ea1c5f679a35bf017612692e611bb834d366dae63c4e4f
MATLAB
580
20
function lch = lab2lch(lab) % LCH = LAB2LCH(LAB) % Perform a simple rectangular-polar conversion on color data. % % LAB is a 3-channel image formatted with its lightness component first % and with its chrominance information centered around zero. % This does not have to be CIELAB. It can be LUV or YPbPr, etc....
8df48501234c28f44310cbd4cf04b9f72f71ac327dbae484ef1e94e6afbad7e5
MATLAB
580
19
classdef Nil methods (Access=public) function list = cons(nil, element) list = gadgetron.lib.LinkedList(nil, element); end function nil = head(nil), end function nil = nth(nil, ~), end function nil = tail(nil), end function nil = take(nil, ~), end...
dd6d1ded5484e7b37550992bb9df34bd36534022c44f089410a2fdba44463c47
MATLAB
580
18
function hAx = getOrCreateAxes(parentArg) % getOrCreateAxes: Return axes handle based on provided Parent argument. % % Usage: % hAx = getOrCreateAxes(opts.Parent); % % If parentArg is provided (non-empty), it is returned as hAx. % If parentArg is empty, a new axes is created in the current figure. % (Figure is NOT cr...
6107f03a20c47ced9fe203f33afeaba17627b7ae39b02ab50b4089abcd93b702
MATLAB
582
23
function div = CBIG_KLdiv_sym_pairwise(prob_mat) % Calculate pairwise symmetric KL divergence for each row of input matrix. % % div = CBIG_KLdiv_sym_pairwise(prob_mat) % Input: % prob_mat: N x T matrix, N is # of variables, T is # of outcomes % Output: % div : N x N matrix, N is # of va...
b10e465280c74ba4da10eea03ae76f1731f437ad44aca9b6de4fbe49d232949a
MATLAB
582
20
function k = get_keyboard_num % Checks to make sure that the laptop keyboard is used in case another % device connected at the scanner also has the usageName Keyboard % (keyboardID should be set to the productID of the native keyboard). % Written by KGS Lab % Edited by AS 8/2014 % change to productID number of native ...