sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
cfeb516c72911e04037c802142f5f35fe2066baa1c0a2a598d89bb4f38fab141
MATLAB
702
29
%% % Returns the number of elements that are at least equal to or more than % the given target values. % function [counts] = countAbove(sortedData, targets) % Sanity check for inputs if sortedData(1) < sortedData(end) error('sortedData must be sorted in descending order'); end if targets(1) >...
c761b44db0e05f616c9b03cc37d9e5c0c579f89759d1a2d88be5dc5cb5ef68f2
MATLAB
703
19
%% http://www.holoborodko.com/pavel/numerical-methods/noise-robust-smoothing-filter/ function smoothed = robustSmoothing(data, dim, degree) % Smoothing kernel if degree < 5 || mod(degree,2) == 0 error('robustSmoothing:degree', 'Invalid degree of smoothing %d, must be an odd integer >= 5.', degree); e...
0d72a42f74c04dca745e44ba4fd7ba5177ff4a60bbe03978b26478ea30da7239
MATLAB
704
31
%% function to remove pixels that are not connected to the peak of the cluster function clusters = CheckConnectivity(I, clusters) [~,~,NClust] = size(clusters); for clust = 1:NClust % get peak of current field [~, peak_idx] =max(I.*clusters(:,:,clust),[],"all"); [r,c] = size(I); CC = bw...
7983ef44eb2f3d6d45f52b1f02e77abad9248f3cc065cfdf594821f51a773525
MATLAB
705
30
function [iMorton,toMorton]=nt_morton(nrows,ncols) %[iMorton,toMorton]=nt_morton(nrows,ncols) - indices for Morton scan of image % % iMorton: matrix of indices in Morton order % toMorton: indices to put pixels in Morton order % % nrows,ncols: dimensions of image % % NoiseTools nt_greetings; if nargin<2; error('!')...
6ca62b916b27e8102d41a27162016bd3f9b0fe084420fb2015e288863f2596e2
MATLAB
706
20
function firing_rate = getFiringRate(animal_name, spike_matrix, repeatCalc, save_data, output_folder) % by Mattia 08.20 % helper function to compute and save firing rate % spike matrix is assumed to be in ms if exist(strcat(output_folder, animal_name, '.mat'), 'file') && repeatCalc == 0 load(strcat(output_folder, ...
6178800ce83e6ee43709ade34cf879004cb7f62876ead51f76765fd1fbe716c6
MATLAB
708
24
function idx_shuffled = shuffledIndexByCategory(catArray) % shuffledIndexByCategory % X = categorical({'A','A','B','B','B','C','C'}); % idx = shuffledIndexByCategory(X); % X_shuffled = X(idx); arguments catArray (:,1) categorical %vertical end % 1. get unique category order [~, firstId...
1e01af4a67cd2c2ff3a442cf7fa35f1ed30a3653523fc7cb5ebafc7b89f0942b
MATLAB
709
29
%% function to save examples of drifting and non-drifting cells type = ["Non-drift", "Drift"]; for i = 0:1 file_name = strcat(out, type(i+1), ".pdf"); delete file_name idx = find(IsDrifting == i); if N_example < length(idx) y = datasample(idx, N_example); else y = idx...
8f41ad90bee9b75735b11d4ca89bc50e250fa572b5b9081a82f4885c221552c1
MATLAB
711
28
function [DSDeltaF, DTs, DFs] = DownSample(Signal,Fs,varargin) %Signal-- the Delta F/F or Raw signal to be processed %FS--The sampling frequency %Variable Input Arguments: %1-Size of Sample Group--median of n samples will be taken in order to % downsample the data. New sampling frequency = old Fs/n. Default is 1...
46a003958e25336c2f7938ae3e1bb1af56aa5a214ced47f3113f882da9faea39
MATLAB
713
26
function nt_colorlines(h,permutation) %nt_colorlines(h,permutation) - apply different colors to lines of plot % % h: handle to plot (default:gca) % permute: permutation to apply to colors % % Colors are applied to children of h in reverse order (ie in order of plot % commands). May produce unexpected results if ther...
e10dc49c65329018c27f5cd6fa8963cd8e60724510bac9467d519de0863b42cf
MATLAB
713
21
function [colorchans alphachans] = splitalpha(inpict) % [COLOR ALPHA] = SPLITALPHA(INPICT) % Split an image into its color and alpha channels. % % INPICT is an I/IA/RGB/RGBA/RGBAAA image of any standard image class. % Multiframe images are supported. % % Output class is inherited from the input. % % Example o...
f6789e68643a46d5c720f0c6e9c852dd3177ed49a881b64d24d08a33b6881491
MATLAB
713
33
function CBIG_znormalize(input_file, output_file, mask_file) % Znormalize the input nifti file along 1st dimension. % % CBIG_znormalize(input_file, output_file, mask_file) % Input: % input_file : input file % output_file : output file % mask_file : mask file % % Written by CBIG under MIT lice...
c26b5522d61337e6507e7f6f1d1a9265851d37c8b40d98a2a8cce37ab025b425
MATLAB
714
33
function varargout=nt_spect_plot(x,varargin) %nt_spect_plot - plot power spectrum % % The power spectral densities of all columns (pages, etc.) are calculated % and added. The result is divided by the number of columns and either % plotted or returned. % % See pwelch for syntax. if numel(x)==0; error('!'); end N...
f34ecb4e5e7e93abe893d93751b0d487725a493aba6eebfb7ebdd4e148f266d8
MATLAB
714
21
function out = mdSpatialScramble(md, area, vertord); % out = mdSpatialScramble(md,area); % Spatial scrambling of md data. Area is a vector with % three numbers that define the range within which the % random trajectory locations are chosen %vertord = 0 ->retain vert layout; vertord = 1 ->scramble vert layout...
20bb8628774cdb53bb122c98bed97cded93e9207a9e6ec635726e93a8659ea7d
MATLAB
717
21
% Compute the 1-sigma interval about the mean along a given dimension, using quantile-based % statistics for robustness. NaN entries are ignored. Specifying useQuantile = false will use std() % instead of quantile() for calculating the 1-sigma width of the distribution. function [stdDev, mu] = meanStdDev(X, dim, use...
0e00d95563b031f54d26910be76a2a4f454acacf7c4b8ebd6a5eb2a86e74eb57
MATLAB
718
26
function inpict = iminv(inpict) % OUT = IMINV(INPICT) % Return the inverse (complement) of an image. Make dark % things light; make light things dark. This is functionally % the same as IPT imcomplement(). I just hate long names. % % INPICT is an image of any size or numeric/logical class. % % See also: imc...
4f6c899d75497ccca2728c07c19eac4f34cbd01c05a3e9fd24a00d88dd775e49
MATLAB
720
28
%% PARSEPATH Consistent file path/name/extension parsing across operating systems. function [path, name, ext] = parsePath(path) tokens = regexp(path, '^(.*?)[/\\]*([^/\\]*?)([.][^/\\.]*)?$', 'tokens', 'once'); if ~iscell(path) if isempty(tokens) path = ''; name = ''; ext = '...
995e3c62bb3efe9d7724bada9a87a76c31e56b9649aa801cdf7f2c2ee7ad5633
MATLAB
720
29
% %reads the raw timestamps from a neuralynx CSC file. % %urut/april04 function [timestamps,nrBlocks,nrSamples,sampleFreq,isContinous,headerInfo] = getRawCSCTimestamps( filename ) disp(['reading ' filename]); isContinous=false; FieldSelection(1) = 1;%timestamps FieldSelection(2) = 0; FieldSelection(3) = 1;%sample fre...
1e9e368a60e7aea30bd1259adea4b41ea05b9a212a83be7e865345e055120a7f
MATLAB
722
30
function CBIG_WriteToReferenceVolume(input_file, ref_file, output_file, exit_flag) % Write input volume to reference nifti file. % % CBIG_WriteToReferenceVolume(input_file, ref_file, output_file, exit_flag) % Input: % input_file : input file % ref_file : reference file % output_file : output...
4490dccf14b8decda629a2e78d5f890cbbff923ca37553f0c400503c6b7a7a6c
MATLAB
723
18
function out = fft3(x, N1, N2, N3) % Function that computes the 3D Fourier transform of the input array x, % along the first three dimensions, with optional size specification. % % Input parameters: % --x: 4D array of size [N1, N2, N3, Nc], where N1, N2, N3 are spatial % dimensions and Nc is the number of ...
ed1fb9a264a29ae7455a89fde6de381fc8554f5392eaddf9ff3c5a0dcf26fb5d
MATLAB
723
24
% Like diag() when applied to convert diagonal elements to a square diagonal matrix. Slices (3rd and % higher dimensions) are supported in that the diagonal matrix is assembled independently per slice. function D = todiag3(A, k) if nargin < 2 || isempty(k) k = 0; end %% Deduce size of matrix ...
8a03e2fe6f94875fdcddbcd15db6e5dc5fa512c4cd06b1e69478f8ef60963733
MATLAB
725
27
function makeLegendsByDummyPlot(labelList,colorList,options) arguments labelList (:,1) string colorList (:,3) {mustBeNumeric} options.Marker = 'o'; options.MarkerEdgeColor = 'none'; options.MarkerSize = 12; options.LineStyle = 'none'; options.FontSize = 12; end NList = length(labelList); hol...
99d73e09774aed0635784049c3a80bfb7ead978c52ea685bb309bbf15cf498a4
MATLAB
726
32
function z = mutInfo(x, y) % Compute mutual information I(x,y) of two discrete variables x and y. % Input: % x, y: two integer vector of the same length % Output: % z: mutual information z=I(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...
be1a7c450f6af02de34025b1042a4720fd5a3a999d3032263be5cde5b1c4d4ee
MATLAB
726
36
function y=nt_squeeze_all(x) %y=nt_squeeze_all(x) - squeeze structs and cell arrays % % x: object to squeeze % % y: result of squeezing % % If x is a struct, all fields and subfields will be concatenated. If x is % a cell array, all elements will be concatenated. VERBOSE=1; x=squeeze(x); if isnumeric (x) y=...
9a73b07c73aecf21c0dece46ec7a92414a51f8ced1c1a5d2cf1a929cb7eb315a
MATLAB
727
20
clc;clear all;close all;restoredefaultpath; addpath(genpath('/home/rcf-40/ajoshi/aaj/git_sandbox/bfp')); % Configuration file configfile='/home/rcf-40/ajoshi/aaj/git_sandbox/bfp/supp_data/hpcconfig.ini'; %T1 and fMRI images in NIFTI-1 format (nii.gz) lst=dir('/home/rcf-40/ajoshi/aaj/Beijing_Zang/sub*'); for jj=1:leng...
031f47eec12b415852d558f3b29f537e60b15d5aa6d8f13defb7f76cc53e0190
MATLAB
730
26
function write_array(socket, array, type) dimensions = size(array); gadgetron.external.writers.write_vector(socket, dimensions); switch type case 'complex64' write_complex_array(socket, array, 'single'); case 'complex128' write_complex_array(socket, array, 'doubl...
0c7dcbcedd5d0c62fba647c4f4505c0790730a5541bbe7d0b8e891a2e32ec5ee
MATLAB
730
20
function [brain_index, non_brain_index] = CBIG_GetBrainIndices % Get Freesurfer brain indices. % Reference: $FREESURFER_HOME/FreeSurferColorLUT.txt % % [brain_index, non_brain_index] = CBIG_GetBrainIndices % Output: % brain_index : column vector, brain index % non_brain_index : column vector, non brain...
29d48641defc60289199e10ebdb19e06bcf675e512c5dd7f3dcba1e05f7ac178
MATLAB
730
23
%% % Convenience function to convert a variable number of inputs into cell % arrays. Note that the first argument is the dimension, unlike % num2cell(). It is possible to specify a dimension per array input by % making this first argument a cell array. % function [varargout] = num2cells(dimension, varargi...
49ada6c99ed1a402c0a8e0b0286d68d24b43a08e23f3dfa5b3e877d0df0ba2e0
MATLAB
730
23
function outpict = gray2rgb(inpict) % OUTPICT = GRAY2RGB(INPICT) % Convert an image with a single color channel to one with % three color channels by simple channel replication. % If given an RGB image, pass it without complaint or alteration. % % INPICT is an I/IA/RGB/RGBA/RGBAAA image of any standard image clas...
2f9acde54bbe6c145baa412f9a4f60427ae87f9e63bf29729a80ae0a69619b3b
MATLAB
731
26
function [y]=nt_xprod2(x1,x2,dsratio) %[y,ind]=nt_xprod(x1,x2,dsratio) - form all crossproducts % % y: crossproducts % % x1,x2: data (time*channels*trials) % dsratio: ratio by which to downsample cross-product. if nargin<3 || isempty(dsratio); dsratio=1; end if nargin<2 ; error('!'); end if ndims(x1) ~= ndims(x2...
08aa8a8cc64cd660004e71cc294363f9e82207a4aa60cf734c7e8473e2735cf6
MATLAB
733
29
function [yes] = approx(x, y, tolerance, epsilon) % APPROX Approximate equality of numeric objects; exact for other types. %----- Input parsing if any(ischar(x)) || any(ischar(y)) yes = strcmpi(x, y); return; elseif any(~isnumeric(x)) || any(~isnumeric(y)) yes = ( x == y )...
9686b774c077a847fa821d5c8ce8468c62b84eb1adc64fe951808c677528e541
MATLAB
734
29
% Apply a function (fnc) to the lowest level of a % nested cell array. % % input % dataset: nested cell arrays, where the bottom level is % a non-cell array (like the vector of a stroke). Any % nesting structure works. % fnc: function handle to apply % % output % ndataset: same nesting structure as th...
90c79c3d25bfcc030975879ff02789c4d218c18ef9dd55ab9f09a8ae65dbbefa
MATLAB
736
28
function [padded] = padto(input, targetSize, padwith, direction) % PADTO Pad the given input array so that it has the target size. excess = targetSize - size(input); if nargin < 3 padwith = 0; end if nargin > 3 if strcmpi(direction, 'pre') padLeft = excess;...
654e46cb331a343ba807913e0d3c0594a3e63232c4766049eeebf0dab42711fb
MATLAB
737
20
function [gray_index, non_gray_index] = CBIG_GetGrayIndices % Get Freesurfer gray matter indices. % Reference: $FREESURFER_HOME/FreeSurferColorLUT.txt % % [gray_index, non_gray_index] = CBIG_GetGrayIndices % Output: % gray_index : column vector, gray matter index % non_gray_index : column vector, non g...
8333246deb2d9e5ee65bbb793d1be83f75c891081b5cc465196360cf6556ce36
MATLAB
737
18
SpikeWaveforms{ipart}.(markername){icluster} itemp =1 ; cm = parula(100); figure; hold; y = cat(1, SpikeWaveforms{ipart}.window{itemp}.trial{:}); avg_waveshape = mean(y, 1); for itrial = 1 : size(SpikeWaveforms{ipart}.window{itemp}.trial, 2) lh = plot(SpikeWaveforms{ipart}.window{itemp}.time{itrial}*10...
3eca437cc79a5c70c7425eb29220cb90f68c9738a47b828c6cd31df9c937072d
MATLAB
742
31
%% function to measure whether a cell's calcium trace is drifting or not during recordings function [Mins, IsDrifting] = DetectDrift(c, segments, ms_framerate, DriftParams) [N_points, N_cells] = size(c); step = segments*ms_framerate*60; N_segments = floor(N_points/(step)); Mins = zeros(N_cells, N_segments); I...
7d3b20611d57dbdf713e340df7ef953e9356c05c6db853652e370432b5c6d85a
MATLAB
742
17
%% function to shuffle events and recalculate RVL function RVL_distribution = ShuffleCaEvents(CaMatrix,repeat, minShift, framesToUse, binned_HDir, HDirOccupancy, Nbins, binCenter, edges) [N_cell,Nframes] = size(CaMatrix); maxShift = Nframes-minShift; K = randi([minShift maxShift], repeat,1); RVL_distribution=zer...
d68f82412a24eacba67783b01bd7a73c91c5f913d230953d865c972d3d84f691
MATLAB
742
39
% % dataSm = laplaceBeltramiSmooth(LBO, data, sigma) % % Description: % Laplace Beltrami filtering % % Input: % LBO - Laplace Beltrami operator structure % data - data to be smoothed % sigma - Gaussian sigma % % Output: % dataSm - filtered data % % Copyright: % 2016-2017 (c) USC Biomedical I...
cf7805868929df8af6052fa83dc76d9d80434db1379bc21768c98a2c52b0724e
MATLAB
744
27
function [ output_args ] = ciftisavereset(cifti,filename,caret7command) %Save a CIFTI file as a GIFTI external binary and then convert it to CIFTI tic save(cifti,[filename '.gii'],'ExternalFileBinary') toc %unix(['/media/1TB/matlabsharedcode/ciftiunclean.sh ' filename '.gii ' filename '_.gii']); %unix(['mv ' filenam...
818663056803e9653c9c0a3a6094c681dafb68996a183928c62dac6e67a0fd00
MATLAB
746
23
function arr = read_array(socket, type) switch type case 'complex64' arr = read_complex_array(socket, 'single'); case 'complex128' arr = read_complex_array(socket, 'double'); otherwise arr = read_simple_array(socket, type); end end function arr = read...
c8458ada918b55868ade8586cdec24568cb392e045e1e546d59700b6e0d9df79
MATLAB
747
22
function cbresize(axisHandle, cbarHandle, widthScale, heightScale) axisPos = get(axisHandle, 'Position'); cbarPos = get(cbarHandle, 'Position'); newPos = cbarPos .* [1 1 widthScale heightScale]; deltaPos = newPos - cbarPos; switch get(cbarHandle, 'Location') case 'north...
ec4f1109efc11e63cdc805e8e48f34a28d7b4711d6a0c17fa1bc6717546ad4f4
MATLAB
747
24
function SN = rotateSpatialMaps(SN) % SN = rotateSpatialMaps(SN) % % Code to rotate spatial maps to beter align or visualize them. % % 2019 - Adam Charles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Rotate all the spatial maps if iscell(SN) for ll = 1:numel(SN) SN{ll} =...
8f79463ff1d0e810c2f5f3987efe955aa805f7ca2e3ae92e9b1fea07a2fd3e5d
MATLAB
748
29
% %reads the raw timestamps from a neuralynx CSC file. % %urut/april04 function [timestamps,nrBlocks,nrSamples,sampleFreq,isContinous,headerInfo] = getRawCSCTimestamps( filename ) disp(['reading ' filename]); isContinous=false; FieldSelection(1) = 1;%timestamps FieldSelection(2) = 0; FieldSelection(3) = 1;...
9a7ffbec51b628255d8df58d14a732e5e381ac17686ad153d147a4cbdbd4aae4
MATLAB
748
19
clear, clc, close all wlen = 32; % window length (recomended to be power of 2) h = wlen/4; % hop size (recomended to be power of 2) k = 5*wlen; % overlap-add span win = hamming(wlen, 'periodic'); % window s = zeros(k, 1); for k = 0:h:k-wl...
b0e53c33050e2e0f2485a0a03808e6825b3f5541d1c57e4d17152622268d0f31
MATLAB
751
31
%% function [p, s] = demo4plots() close all ; [p,s]=makePanels(4,'hi','hohohoho','LegendColumn',10,'TwoSided',true); selectPanel(p,1,s); draw([1:10; 2:11; 5:14]*10, 'ValueRange', [0,80]); xlabel('xxxxx_{xxx}'); ylabel('yyy_{yyyy}'); title('hello cruel world'); selectPanel(p,2,s); ...
dc18188b13c6725128e9180ba0809ba82ecac02e057f3ef25079dd7bb76e81f7
MATLAB
751
25
function subj_list = CBIG_SPGrad_read_sub_list(subject_text_list) % this function will output a 1xN cell where N is the number of % subjects in the text_list, each subject will be represented by one % line in the text file % NOTE: multiple runs of the same subject will still stay on the same % line % Each cell will co...
e3dd724d7e0d2096a08e0c21d67f06b88a7480a32b91f8aaa632284cd7acc7c1
MATLAB
751
21
function [MI, rows] = getMI(values1, values2) % by Mattia, 09/20 % simple helper function to compute modulation index (normalize "paired" values in the -1 to 1 range) % inputs: - values1 & 2 -> vector with values to use to compute MI % output: modulation index for the given values % important: - if the inputs take neg...
9f33831816b35488ea9d8cba205970b61d16c6fc40ad052fd333e8d54aff7c02
MATLAB
752
31
function isdir_or_mkdir(p) % ISDIR_OR_MKDIR Checks that a directory exists, or if not, creates the directory and % all its parent directories. % % See also FOPEN_OR_ERROR if~isfolder(p) ft_notice('creating directory %s', p); mkdir(p); end % add trailing file separator (slash or backslash) p = char(p); p_full...
65a35169cdee3f25bba4947d687279e327d236c274f64aa84352de66eaa14b1a
MATLAB
753
22
%% function to decide whether cell's HD and spatial tuning is at the same reward location function IsMisMatchTuning = GetHDSpatialRewardTuning(All_d) IsMisMatchTuning = nan(length(All_d.HasRewardField),2); for i = 1:length(All_d.HasRewardField) if ~isnan(All_d.HasRewardField(i)) HD_rew = All_d.Re...
f27e780a0770dd4fc38fe0557a9066f2d404bbe95cecb0420db7cce60e3f4780
MATLAB
755
24
function CBIG_shiftimdim(input_file, output_file, shiftdim1, shiftdim2, shiftdim3) % Circle shift a 3D nifti file. % % CBIG_shiftimdim(input_file, output_file, shiftdim1, shiftdim2, shiftdim3) % Input: % input_file : input file % output_file : output file % shiftdim1 : shift number in dimensi...
a95227d491e9bcb4837490cf60454dd748c76d1197a3af41474149e66a5d78bf
MATLAB
756
36
% % parProgressTracker(mode, num) % % Description: % Track progress for parallel loop % % Input: % mode - 's' - start, 'p' - progress or 'e' - end % num - total number of iterations, only needed for mode 's' % % Output: % % Copyright: % 2016-2018 (c) USC Biomedical Imaging Group (BigLab) % Author: %...
8965967a58cdc8bb9ce4c686ea2535eebbb5b1fb6ef4761606e57e2894d8fcc2
MATLAB
757
33
disp('test example for nt_zapline()'); disp('MEG, epoched data'); clear fname='../data/example4/data3.mat'; % check for NoiseTools try, nt_greetings; catch, disp('You must download NoiseNools from http://audition.ens.fr/adc/NoiseTools/'); return; end % check for data if ~exist(fname, 'file'); disp([fname, ' not ...
d89f1f8321dbe5ec3dbf4ad4f4a7d84dc6cad7e4e4beb7691eca330dd67b303c
MATLAB
759
28
% Like image(), except with nonuniform grid spacing function [handle, x, y] = imagexy(axs, x, y, C, varargin) %% Default arguments if isnumeric(axs) && ~ishghandle(axs) %% Allow for non-specification of the axis to draw in C = varargin{1}; varargin(1) = []; y = ...
2ba3fac1689406bd612e94e477b1e0015ff32d1e3d60b48fefa84df3e734b72f
MATLAB
760
24
path_in = 'D:\Datasets\Test\sample10_128\'; path_out = 'D:\Datasets\Test\sample10_128_scale_ver\'; fname = 'mnist_0_scale16_0001.aedat'; [allAddr,allTs,ISI,monTime] = loadaerdat(fname, path_in); for th = 50:5:100 for scale = 1:10 disp(['th = ' int2str(th) ', scale = ' int2str(scale)]); ...
1eb7c4cd426ef1185a827f322e195ad5d13df7d40980af74dbee9c69a7cab579
MATLAB
761
24
% Returns a list of linear indices for the k-th diagonal elements of A. Slices (3rd and higher % dimensions) are included by concatenating the indices for diagonal elements of each slice of A. function indices = diagIndex(A, k) if nargin < 2 || isempty(k) k = 0; end %% Ensure that we have a s...
70283f51d9d1d0923c593f6b0357e2e01f014b65fff120ae6720dc04c238e495
MATLAB
764
33
function z = nvi(x, y) % Compute normalized variation information z=(1-I(x,y)/H(x,y)) of two discrete variables x and y. % Input: % x, y: two integer vector of the same length % Output: % z: normalized variation information z=(1-I(x,y)/H(x,y)) % Written by Mo Chen (sth4nth@gmail.com). assert(numel(x) == numel(y));...
97111d1bd9659713d55cb52d96dc90baa2f3482fe4c0e53d62eee1e68b84c5d6
MATLAB
765
25
%% % Expands the given range by the requested left/right scale factor. % function [range] = expandrange(range, dim, leftScale, rightScale) %----- Parse input narginchk(3, 4); if nargin < 4 rightScale = leftScale / 2; leftScale = leftScale / 2; end if size(range, dim) ~= 2 er...
05cc6bac32cc4c04aa761938ee597d78b8a9963ecaca7c8b2df6495a469bf807
MATLAB
766
28
function [B_boot, r_boot] = performRegression_kfold(X, y, n_folds, random_seed) % ---- 10-fold cross-validation ---- %n_folds = 10; rng(random_seed); cvp = cvpartition(size(X,1), 'KFold', n_folds); y_pred = nan(size(y)); r_boot = zeros(n_folds, 1); for f = 1:n_folds train_idx = tr...
cd1e5df5bfaabbd66e524e3cdc697ba803d9f70d702fa534ca6388956e8d7bff
MATLAB
767
21
function corr_mat = CBIG_corr(s_series, t_series) % Calculate correlation matrix between each column of two matrix. % % corr_mat = CBIG_corr(s_series, t_series) % Input: % s_series: T x N1 matrix, T is number of frames, N1 number of voxels % t_series: T x N2 matrix, T is number of frames, N2 n...
8bde8c88c7d81aeed0e65ff556298801fcb72280a4d2837d12239e2931217660
MATLAB
768
34
% Toggles logarithmic scale on the given axes (y by default, otherwise specify xy = 'x' or xy = 'xy') function logscale(xy, axs, force) %% Default arguments if nargin < 1 || isempty(xy) xy = 'y'; end if nargin < 2 || isempty(axs) axs = curraxes; end if nargin < 3 force = []; ...
0ae1229575d3365931889590ed0c7ace28cf5055010c97d074301d88b9a14b7c
MATLAB
769
27
function generateVolGOrdfMRI(GOrdVolIndFile,subbasename,fmri,GOrdVolFile) load(GOrdVolIndFile); invmap=load_nii_BIG_Lab([subbasename,'.svreg.inv.map.nii.gz']); invmapx=invmap.img(:,:,:,1); invmapy=invmap.img(:,:,:,2); invmapz=invmap.img(:,:,:,3); ind=~isnan(bci_vol_ind); t1=load_nii_BIG_Lab([subbasename,'.bfc.nii.g...
3327db255e2c79550d0e294758dd4e221bba4f073872cfa8aff26e9d56da231d
MATLAB
770
42
function [res,resd] = bpassW(arr,lnoise,lobject) % % bandpass filter. % % Written by Pei-Hsun Wu, % Post-doc associate, @ JHU, IMBT. % % PW 211016,, imfilter --> use symmetric % PW 240101 , suposition at filter level., reduce the costly imfilter step arr=double(arr); % make sure this is double b = double(...
afa241619b4ab51c29143c2612eeaa8f13f5eb23e2f4cc5dd2261b559f90074a
MATLAB
770
31
function CBIG_DilateMask(input_file, output_file, dist, exit_flag) % Dilate a binary mask. % % CBIG_DilateMask(input_file, output_file, dist, exit_flag) % Input: % input_file : input binary mask % output_file : output file name % dist : threshold for Euclidean distance aft...
195971dc5f076374c224231f63dc02a83a76171969e60aa916334f8624356ee3
MATLAB
773
25
function RGB = gmcmyk2rgb(CMYK) % RGB = GMCMYK2RGB(CMYK) % Convert a CMYK image to RGB. % Note that this is in no way intended for print preparation. % No profiles are used. This is a direct replication of the % method used by GMIC cmyk2rgb -- specifically for the purpose % of replicating GMIC code that depende...
61b5ea1a63cc2ed7fc95148a7908a40db3d5b9f5b69482b1072d73a5a795562f
MATLAB
773
32
disp('test example for nt_zapline()'); disp('MEG data with large near-DC fluctuations'); clear fname='../data/example3/data1.mat'; % check for NoiseTools try, nt_greetings; catch, disp('You must download NoiseNools from http://audition.ens.fr/adc/NoiseTools/'); return; end % check for data if ~exist(fname, 'file'); ...
fd0425f998a5fd72e6c26a1274e20a950f98a1ab3c5e3f397c8401cae823898f
MATLAB
773
28
%% % Fast computation of atan(x) via look-up table. function [f] = fastatan(x) persistent FASTATAN_lookup_table; if isempty(FASTATAN_lookup_table) FASTATAN_lookup_table = arrayfun(@atan, 0:0.01:3); end if x < 0 f = fastatan(-x); elseif x > 9 f = pi/2 - 1/x; elseif x >...
060c257e9e92b2efc1d6f128a9157c3e4b07d1b6732cec7fc146287a12a65cc2
MATLAB
776
18
function simple_recon(connection) disp("Matlab reconstruction running.") next = gadgetron.examples.steps.noise_adjust(@connection.next, connection.header); next = gadgetron.examples.steps.remove_oversampling(next, connection.header); next = gadgetron.examples.steps.accumulate_slice(next, connect...
7803cfea443f4645099f6a184283234df71a696b02cbfeee6fa90937e35c63b8
MATLAB
778
27
function icc = CBIG_fisher_icc(data1, data2) % icc = CBIG_fisher_icc(data1, data2) % Compute fisher's intraclass correlation between two vectors.(This function will exclude NAN) % % cc = CBIG_fisher_icc(data1, data2) % Input: % data1: N x 1 vector % data2: N x 1 vector % Output: % icc : 1 x 1...
e8f469d990b33b7f15f3add8f7b70d16b156731fade9336904f552c6d8b04c3f
MATLAB
778
26
function [header, ext, filetype, machine] = load_untouch_header_only_gz( file ) % wrapper around load_untouch_header_only to work with .gz files. % % 1. Extracts GNU zip files, if file is zipped. % 2. Loads the data & returns it. % 3. Deletes the unzipped file, if file is zipped. % % file - is a string with rel...
0dc646d25bec6668911d042a21ae15e009065100d3f32933fad476246cd0d4ac
MATLAB
779
25
function main() % Workaround for occasional blank windows when Matlab run as root (as in container) % https://uk.mathworks.com/support/bugreports/details/2794932 % Fixed in Matlab R2023a setenv('MW_CEF_STARTUP_OPTIONS', '--in-process-gpu'); port = getenv('GADGETRON_EXTERNAL_PORT'); module...
a258abc47e51a75321914f5305583dc491eee303098bcd0a1f4da147d7754cb2
MATLAB
779
23
function CBIG_AnalyzeDirectAndIndirectCorrespondence % CBIG_AnalyzeDirectAndIndirectCorrespondence % % Written by CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md load lh.1000sub.FSL_MNI.ras.mat indirect_ras = ras; load lh.FSL_MNI.DIRECT.ras.mat direct_ras = ras; tmp = sqrt(sum((dir...
ce86c65128b284f5a01af77371bfcf9767fb5171298561bd3aa36f90609bdd9c
MATLAB
780
24
clear, clc, close all %% Using CEC2005 for testing Func_name = “F4”; % Test function name, can be modified to: F1-F23 [lb, ub, dim, fobj] = Get_CEC2005_details(Func_name); % Retrieve function variable upper/lower bounds, dimension, objective function handle pop = 50; % Population size maxIter = 600; % Maximum iterati...
3558720d076dbbe28c881c20aa4495dff678c75adc4f3a9fa865d1dee28cd194
MATLAB
783
34
function [cell_array, num_lines] = CBIG_text2cell(text_file) % [cell_array, num_lines] = CBIG_text2cell(text_file) % % This function reads from "text_file" and return the content of each line % to be an entry of "cell_array". % % Inputs: % - text_file % The input text file. % % Outputs: % - cell_array % ...
64b2adc8a7f9c5700c1136e6d08fe5bf8e0f6e9d2caf9914f56ae17d03e57bef
MATLAB
784
24
%% from: https://fr.mathworks.com/matlabcentral/answers/444501-how-to-use-intersect-command-with-a-tolerance-value function [AI, BI] = CommonElemTol(A, B, Tol) A = A(:); B = B(:); nA = numel(A); M = zeros(1, nA); % Collect the index of the first occurrence in B for every A: for iA = 1:nA ...
0e85fd0320e9b1fb37805fd3f14cb66fc9ba1c8b9c91e08cb8778713e7b2f2a6
MATLAB
785
24
function thisrange = imclassrange(classname) % RANGE = IMCLASSRANGE(CLASSNAME) % Get the nominal data range expected of a given image class % % CLASSNAME is a string/char specifying the class in question % Supports: 'single','double','logical','uint8','int8','uint16','int16' % 'uint32','int32','uint6...
e7bf5ddafe1d3623c0cc1ed77addfc47b392a9aa99cf28ae0252aee86c38e5a5
MATLAB
787
31
disp('test example for nt_zapline()'); disp('MEG, 5 line noise components'); clear fname='../data/example6/fig_9_data.mat'; % check for NoiseTools try, nt_greetings; catch, disp('You must download NoiseNools from http://audition.ens.fr/adc/NoiseTools/'); return; end % check for data if ~exist(fname, 'file'); dis...
37b2dacab3eb166f9761a87667f711ed05fe9bd1703ae6c25fdddf7490388924
MATLAB
789
30
disp('test example for nt_zapline()'); disp('FieldTrip example data: Monkey ECoG'); clear fname='../DATA/example1/data.mat'; % check for NoiseTools try, nt_greetings; catch, disp('You must download NoiseNools from http://audition.ens.fr/adc/NoiseTools/'); return; end % check for data if ~exist(fname, 'file'); di...
557060c5764e68d3203b5dc2a3c1028beaaff60b4a1c08b5dc8b403216332a6d
MATLAB
789
19
function [MuseStruct_updated] = updateMarkers(cfg, MuseStruct_updated, labels) % 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) for label = string(l...
85a2603da2342d3c22fe9d201c8f6f5ba89a6c9827d29321c1bef084a2b38905
MATLAB
789
34
function varargout = aa_splot(varargin) %AA_SPLOT replaces plot command and automatically changes color % % This function is a replacement for the plot command. % It automatically changes the color with subsequent % uses of aa_splot. % % Usage is exactly the same as for plot. np = get(gca,'nextplo...
6e3e1b6068b9813d36fa007f28306c539e6a3d7c6a87a837395bfb187eaf08b8
MATLAB
790
38
%% function to plot place map and clustered fields function PlotFieldClusters(I, clusters, cluster_Method, gm) figure tiledlayout("flow") nexttile; h= imagesc(I); axis square set(h, "AlphaData", ~isnan(I)) box off axis off if cluster_Method == "GMM" [r,c]...
f2a7e78c52d04206f89612894038f1943e1f2a53af829fffc50a1d093ab723ea
MATLAB
795
31
function [data, offset, scale] = normalizeToRange(data, range, minData, maxData, capToRange) %% Default arguments if nargin < 2 || isempty(range) range = [0 1]; end if nargin < 3 || isempty(minData) minData = min(data(:)); end if nargin < 4 || isempty(maxData) maxData ...
3ca49551cb3731f912dc7bd8c94a29b8c642136d8d9f689ac90e49dac9814c9b
MATLAB
802
34
function unitaxes(hax) % UNITAXES({AXESHANDLE}) % Simple convenience tool to set up an axes on the unit square. % if nargin<1 hax = gca; end hstate = get(hax,'nextplot'); hold(hax,'on') gc = [1 1 1]*0.8; hp(1) = plot(hax,[0 1],[0 1],'-','color',gc); hp(2) = plot(hax,[0 1],[1 0],'-','color',gc); hp(3) = pl...
a0710e7463a1c1259618a7b21a696d2295ab5ada8ac362ad1b875919ab188102
MATLAB
802
20
function disp_text(window, text, textcolour, backcolour, rect) %Setup boundary defaults if ~exist('rect', 'var') rect=Screen('Rect',0); % Window-coordinates, e.g. [0 0 1024 768] end %Get centre of writing area xcenter=round((rect(1)+rect(3))/2); ycenter=round((rect(2)+rect(4))/2); %Measur...
f93873cb9368264b3442923293ad746b717a9ab9872c75f3e00305e6631722d5
MATLAB
803
25
% Check correspondence between images in items_classification.mat % and data_evaluation.mat addpath(genpath('..')); fprintf(1,'Loading dataset...\n'); load('data_evaluation','drawings','images','names','timing'); load('items_classification','nrun','ntrain','ntest','cell_train','cell_test','cell_Y'); D = Dataset(draw...
bdd80eba7a69a3973173933cd34c8ce2418eef404aaa126e1297c0d5a1f34d78
MATLAB
805
56
clearvars;clc; % Define parameters for the coupled model % KNDy parameters par.d1=0.2; par.d2=1; par.d3=10; par.k1=4; par.k2=40; par.k01=0; par.k02=0; par.pr=0.008; par.v0=25000; par.KD=0.3; par.KN=4; par.Kr1=600; par.Kr2=200; par.theta=0.5; par.k=10; par.je=1; par.I0=0.19; % MePD parameters n=3; par.dl= n; par.di= n...
370ac662be2e1d8012b864e1e26f1539198728e1cf5de3cf6c3512da2ef45dcf
MATLAB
806
22
%% Creates a struct with fields corresponding to public properties of the given class object. function s = class2structure(c, varargin) s = struct(); members = metaclass(c); members = members.PropertyList; % Apply selection criteria if so provided isSelected = strc...
23f7a1c257e9ce75901e029f1f98161a607441abf379fbf72a8578e88b27d88e
MATLAB
808
29
function varargout=nt_whoss %size=nt_whoss - total Gbytes used by variables % % size: number of Gbytes % % If nargout==0, display Gbytes used s=evalin('caller', 'whos'); % lists variables in caller's workspace x=cell(1,numel(s)); [x{:}]=deal(s.bytes); % transfer to cell array size=sum(cat(1,x{:})); ...
be148519c3cec8fbb40d65d3f5bc50b0da6e4a5fb5d87a36017e61f46c7c243f
MATLAB
808
30
%% Colorbar title function [handle] = cbtitle(handle, label, varargin) %---- Get the colorbar narginchk(1, inf); if nargin < 2 label = handle; handle = cbhandle(); end %---- Set title hTitle = get(handle, 'Title'); origUnits = get(hTitle, 'Units'); set(hTitle, 'Units', '...
128393b5251b3d97314cfebe669190b799b2ea324490a3f5653df7884fc789ea
MATLAB
809
29
%% RENAMEFIELD Replace field name(s) old with the corresponding name in new. function s = renamefield(s, old, new, useRegexp) if nargin > 3 && useRegexp %% Regular expression replacement new = regexprep(fieldnames(s), old, new); old = fieldnames(s); end %% Multi- or s...
61427030b2640925a834de4a70da8abc5f633c6328bd00f412f151837ce28441
MATLAB
811
26
clear all;close all;clc; restoredefaultpath; addpath(genpath('/ImagePTE1/ajoshi/code_farm/svreg/src')); addpath(genpath('/ImagePTE1/ajoshi/code_farm/svreg/3rdParty')); load('../supp_data/USCBrain_grayordinate_labels.mat'); roilist=[1147,225, 373,247];%, 345,351]; s{1}=readdfs('../supp_data/bci32kleft.dfs'); %s{2}=re...
398f4636ac30a5e2618470e81fc13c4f05d0384c8243032a49387f1e68ad0de6
MATLAB
814
28
function PRB2folder(probetype, folder2save) % by Mattia. moves the PRB file in the same file in which the .DAT file % will be created % INPUT: % probetype - as a string. obviously need to add other probes here % folder2save - string, where you also save the .DAT file % the "PRBfolder" in which you have ...
c65113477164fd919794fb8cdc38e8da3c904cc4b3ebbd50f972885c9bde768d
MATLAB
814
32
% Faster version of histcounts(). function [N, edges, bin] = histcountsFast(X, edges, includeOverflow, normalize) if nargin < 3 || isempty(includeOverflow) includeOverflow = false; end if nargin < 4 || isempty(normalize) normalize = false; end %% Locate the bin in which t...
03d2b21bc0db75486df096b7adf30b5fd51396f08b76d6a14617802f13da1a52
MATLAB
815
28
classdef PairDataGenerationOptions properties NoiseLevel double {mustBeNonnegative} DataType string % "PC" or "gene" DataDimension double {mustBePositive} RngSeed {mustBeInteger} end methods function obj = PairDataGenerationOptions(noiseLevel,dataType,dataDimension,...
4fada4683f86713ae9f4306106c0f56d2c15c19c70c45968ad96465b1a84bada
MATLAB
815
24
function cmap = fscol(res) % % cmap = fscol([res=360]) % % Returns the FreeSurfer colour map (like MatLab colour maps) with the % resolution res, which must be a multiple of 4. By default res is 360. if nargin == 0 res = 360; % steps from one colour to the next end steps = res / 4; % Colour peaks R = [1 0 0]; ...
db7a8f537715736444455ffdb3b87bba14a7c9e00b4dadd261300b829be5af8f
MATLAB
815
28
function [divided_data] = seperate_sequences(sequence, sequence_length) %% Seperates input data into multiple sequences of a chosen length % % **Usage:** [divided_phone] = seperate_sequences(sequence, sequence_length) % % Input(s): % - sequence = data to be seperated into sequences (BS or Phone data) % - sequence_l...
a8a6fad311eb64e670b62af4e399a60acf6f9aecd19f4902fb2134b1474861a3
MATLAB
816
9
function [mask, cluster_p, one_sample] = run_clustering_linear(LIMO_paths, significance_threshold, channeighbstructmat) for current_beta = size(LIMO_paths, 2):-1:1 one_sample_tmp = load(fullfile(LIMO_paths{current_beta}, sprintf('one_sample_ttest_parameter_%d.mat', current_beta)), 'one_sample'); one...
ed57698ddf5da8f9adf8897a81357640542ee1b54cee9414db948a308a9177fc
MATLAB
818
23
function data = cifftn(data, dims) % The following code uses less peak memory and is much faster than % gadgetron.lib.fft.cifft % ifind "inverse find" - e.g. ifind([2:3 5], 6) -> [0 1 1 0 1 0] % Ref: https://uk.mathworks.com/matlabcentral/answers/385217-bed-of-nails-from-vectors-inverse-of-find ifind = @(indices, le...
f799992ec20b0c9143e0c3e3414599f318811e6533e49179ac64d7278cbbebd8
MATLAB
818
29
function sock = listen(port) server = java.net.ServerSocket(port); server.setReuseAddress(true); server.setSoTimeout(1000); cleanup = onCleanup(@() server.close()); % Accept would block forever in previous versions, leaving Matlab % unresponsive (process was blocked, so Ctrl+C was ignore...
a48506e9be47af1f17aef7ef201864a06e29b74da2fe342d3eb1d54110ade04c
MATLAB
822
28
function CMYK = gmrgb2cmyk(RGB) % CMYK = GMRGB2CMYK(RGB) % Convert an RGB image to CMYK. % Note that this is in no way intended for print preparation. % No profiles are used. This is a direct replication of the % method used by GMIC rgb2cmyk -- specifically for the purpose % of replicating GMIC code that depend...
00f51d0e39898eae389b6618b31c2c7c71fd2f921c430fa787c3cf126760e80c
MATLAB
823
38
function [biom_ch] = find_channel_img_SAP(biom, biom_set_folder) %% Find image based on biomarker % @author: speressotti %% if biom_set_folder == 'B1' channel_order = {'hoechst','sox2','btub','gfap'} if contains(fname,'hoechst') biom_ch = 1; elseif contains(fname, 'gf...
05f5202713dd645870ae065c1de503cf4fd66381604227b7b17c96491b12c6be
MATLAB
823
26
function rename_add_suffix(path, suffix) %% Rename LIMO saved files by adding suffix % % **Usage:** rename_add_suffix(path, action, suffix) % % Input(s): % - path = path to saved LIMO file % - suffix = suffix to add behind file name % % Author: R.M.D. Kock, Leiden University %% x = split(genpath(path),':'); for f...