sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
65322f25ac736a72a54460754bcb9bcce865ff02b01508adbecd34046253549e | MATLAB | 929 | 36 | fig = figure;
subplot(1,2,1);
hold;
h = 250;
n = 1;
for itrial = 1:53
i1 = find(dat_micro_chansel.time{itrial} >= -cfg.prestim,1,'first');
i2 = find(dat_micro_chansel.time{itrial} >= cfg.poststim,1,'first');
plot(dat_micro_chansel.time{itrial}(i1:i2),dat_micro_chansel.trial{itrial}(i1:i2) + n*h,'color','k... |
a8294f88fe251d2a2a4f5939492da7c6b445deee95e92c2cedee2666362a37ce | MATLAB | 930 | 29 | function CBIG_OutputMatlabVariables(matlab_data_file, eval_string, output_txt_file, prefix_string)
% Output a matlab variable to a text file.
%
% CBIG_OutputMatlabVariables(matlab_data_file, eval_string, output_txt_file, prefix_string)
% Input:
% matlab_data_file : a mat file
% eval_string ... |
e3790d91dc01b1751c4ce65ad1eb645e1daefa1b7924155769412ba0f8398e6b | MATLAB | 930 | 22 | % Returns a multi-line string with custom inter-line height.
% The first argument fontSize should be specified as a 2-element array [fontSize, interlineSize]. If
% less than this number of sizes are specified or are NaN, defaults of fontSize = 16.5 and
% interlineSize = 13 will be used. The remaining arguments shoul... |
550f5c9897a1c0b2ac6fbbdf060749289fcb909b951ae63dfba00b661c3bd8ba | MATLAB | 931 | 33 | function G = CBIG_SPGrad_create_graph(sbjMesh, grad_data)
% G = CBIG_SPGrad_create_graph(sbjMesh, grad_data)
%
% This script creates a graph structure based on the given data and surface mesh
%
% Input:
% - resolution: (scalar)
% the number of vertices of surface mesh, e.g. 40962.
%
% - output_dir:
% ... |
4beede1c4167135136c7f42f2590c9a384535f56cc81d864e1c2ac933878c3eb | MATLAB | 932 | 39 | %% XCORRS Computes the cross-correlation between input x and all columns of input y.
function [c, lags] = xcorrs(x, y, maxLag)
% Argument format
x = x(:);
M = numel(x);
if M ~= size(y,1)
error('xcorrs:dataSize', 'y must be a n-by-p matrix where n is the number of elements (%d) of x.', M);
... |
59e0c6166a0428a1a9f9fb02e97945b5a9fc46438e4ab9e3a8d0f5d0d178ab6c | MATLAB | 934 | 30 |
function surfdata2gord(subbasename, left_data, right_data, GOrdSurfIndFile, GOrdFile)
% Tells the compiler that parallel processing is required
GordSize=96854;
[pth, sub] = fileparts(subbasename);
sub_left = readdfs([subbasename,'.left.mid.cortex.svreg.dfs']);
sub_right = readdfs([subbasename,'.right.mid.cortex.svr... |
42a3515b4c459407133f87ef7c1553ab16f58b7971f4c9f345056fb4620ca5bc | MATLAB | 935 | 41 | %% This script converts the input txt files into mat files
%%
%% Author: Ana Luisa Pinho
%% e-mails: ana.pinho@inria.fr
%%
%% =======================================================
inputs_type = cellstr(["EP"; "PP"]);
%inputs_folder = "stimuli_french_ansi";
inputs_folder = "training_sess_french_ansi";
%inputs_prefi... |
8e49fd3872aa11c69d3990f63ac8e83b61b00027fccb0fa97121cb70522251c7 | MATLAB | 937 | 19 | function hspike_cluster_SpykingCircus(ipatient)
%find config script :
addpath(genpath('/network/lustre/iss01/charpier/analyses/stephen.whitmarsh/EpiCode'));
config = hspike_setparams;
%launch spykling circus :
for ipart = 1:size(config{ipatient}.directorylist,2)
subjdir = config{ipatient}.prefix(1:end-1... |
ae7fecfe7f29986226e8cae37d5fa9badfc1f3abe0b53f814d77bd4eb59201a5 | MATLAB | 937 | 30 | function [freq_cent, wt] = wavelet_transform(lfps, fs, freq)
% WAVELET TRANSFORM:
% Compute wavelet transform for many lfop trials.
%
% Input:
% lfps = the lfp snippets (trial x time)
% fs = sampling freq (kHz)
% freq = the frequencies to look at
%
% Output:
% freq_cent = the center freque... |
df78264383da1e9e518ed9e100546bfcf662c8de6897862c6b8139bd66d3f7b4 | MATLAB | 939 | 48 | function [y,abscissa]=nt_mmx(x,N)
%[y,abscissa]=nt_mmx(x, N) - calculate min-max pairs
%
% y: array or matrix of min-max pairs
%
% x: data
% N: target number of pairs (default: 1000 (or size(x,1) if smaller)
%
% To plot x cheaply: plot(mmx(x)).
% To get only maxima: y=mmx(x); y(2:2:end);
if nargin<2; N=1000; e... |
c9cf343944d6ed7630f3cecf6212f14b48a68468f7b496dd7b0a1e9997db80ea | MATLAB | 942 | 34 | %% This script resizes the input images of the stimuli
%%
%% Author: Ana Luísa Pinho
%% e-mails: ana.pinho@inria.fr
%%
%% =======================================================
%% Load image package
pkg load image
%% Number of inputs
total_items = 4;
inputs_folder = 'rewardim';
group_category = 'training_food';
cat... |
23040d77963964a1c66eaab79e757887bfd7bba898f79be306eaf9e89f152288 | MATLAB | 943 | 46 | figure
tiledlayout(3,2)
nexttile;
imagesc(RateMap{1}(:,:,3))
axis square
box off
nexttile;
imagesc(RateMap{2}(:,:,3))
axis square
box off
function SaveMaps(workdir)
file_name = strcat(workdir, "\PlaceMaps.pdf");
load(strcat(workdir, "\PCAnalysis.mat"))
cells = PC_tbl.IsPC(PC_tbl.IsDrifting ... |
bac99aa19d957ca772155c4fe16ec8858e3f187ba9461e7d76350340e4aad677 | MATLAB | 943 | 31 | %SPRING Magenta-yellow colormap
%
% Examples:
% map = spring;
% map = spring(len);
% B = spring(A);
% B = spring(A, lims);
%
% Similar to MATLAB's spring function, but also able to return a concise
% colormap table.
%
% The function can additionally be used to convert a real-valued array into
% a t... |
651aa53febe31959227f6b1f0d0557fbb312a19a03eff11835b4bc54406ad1f7 | MATLAB | 947 | 25 | classdef DistributionBinContents
properties
ContentsQuantity (1,1) {mustBeInteger}
BinDomain (1,2) double
DistanceList (:,1) double
SourceTargetIndexPairs (:,2) {mustBeInteger}
end
methods
function obj = DistributionBinContents(distanceMatrixNaNMasked,binLeft,binWidt... |
c0a72acecd46ed5ce133bc95896a3e44b8f119e2f6ef73452b7342fe468501c8 | MATLAB | 947 | 43 | function [X2,lags] = nanxcorr(data1,varargin)
scaled1 = (data1 - nanmean(data1)) / nanstd(data1);
scaled1(isnan(data1)) = 0;
if nargin > 1
if isscalar(varargin{1})
[X2,lags] = xcorr(scaled1,varargin{1});
else
data2 = varargin{1};
scaled2 = (data2 - nanmean(data2)) / nanstd(data2);
... |
8035c7e9145a5dede935656df6dc1040da7b617f7a0b6070333626dd717cd7d0 | MATLAB | 950 | 31 | %WINTER Blue-green colormap
%
% Examples:
% map = winter;
% map = winter(len);
% B = winter(A);
% B = winter(A, lims);
%
% Similar to MATLAB's winter function, but also able to return a concise
% colormap table.
%
% The function can additionally be used to convert a real-valued array into
% a truec... |
9b8ef14dcf3b9146c4a697562dbf0d95756e78da564da1781ea3d8709bd1272a | MATLAB | 951 | 39 | %
% [dataOut, stdVal] = unitVariance(dataIn, dim)
%
% Description:
% normalize data to unit variance on a particular dimension
%
% Input:
% dataIn - data input
% dim - on which dimension to unit variance
%
% Output:
% dataOut - data output
% stdVal - the standard deviation that divided by
%
% Co... |
54e8619c03c52fde37eaf9cdc9ee8e22e83f33ffae21316307782cc1aeb8b74d | MATLAB | 952 | 40 | function [A,y,AA]=nt_whiten(x,N)
%[A,y]=nt_whiten(x,N) - whiten spectrally using pca
%
% A: whitening matrix (to be applied to time-shifted x)
% y: whitened signal
%
% x: signal to whiten
% N: order (number of time shifts)
%
if nargin<2; error('!'); end
% calculate covariance across time shifts, looping over col... |
61355eafc2a7532d8151b6027fee229f8274fe123ebf704c38ef02fd91dcd3f5 | MATLAB | 952 | 35 | function [y, dydx] = rangeBarrier(yMin, yMax, x, speedMin, speedMax)
%% Constants
persistent HEIGHT LEEWAY
if isempty(HEIGHT)
HEIGHT = 1e305;
end
if isempty(LEEWAY)
LEEWAY = asinh(1. / HEIGHT);
end
%% Contributes barrier at lower bound
relXmin = (x - yMin) ./ spe... |
c6cabfccbebda9a4d8c98297c2155b8d6c53dd073d0b120cac26a21a302b72d8 | MATLAB | 953 | 30 | % Concatenates inputs along dimension dim, shifting the subsequent dimensions to the right
function Y = catshift(dim, varargin)
noData = cellfun(@isempty, varargin);
if ~all(noData)
varargin(noData)= [];
end
%% Special case with no inputs
if numel(varargin) < 1
nil = [ones... |
e41245f688b168cb0010779fa3d78e336bc6dfe33a2520b22267aa918340771e | MATLAB | 954 | 35 | function t = CBIG_ttest2_stat_only(x,y)
% Given two distributions, calculate 2 sample t test value.
%
% t = CBIG_ttest2_stat_only(x,y)
% Input:
% x: N1 x M matrix, N1 is number of samples, M is number of trails.
% y: N2 x M matrix, N2 is number of samples, M is number of trails.
% ... |
30f36d75906ef9efe13e83d2012a4b501b5403f13ed3f3b793ee47c779839a13 | MATLAB | 955 | 39 | disp('test example for nt_zapline()');
disp('MEG, 5 line noise components');
clear
fname='../data/example7/Bucket_EEG.bdf';
% 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... |
d9909d027a6b67fef13e428a9fe9816b047fddb94d3bbd163d6038653eb9e6b8 | MATLAB | 961 | 34 | function pos = PreProcessPathData(pos, fix, center, rot, convert)
if fix.run == 1
%set nans to zero
pos(isnan(pos(:,3)),2:3) = 0;
pos(isnan(pos(:,2)),2:3) = 0;
pos = fixZeroPosGT(pos);
elseif fix.run
[pos, ~] = fixPosDataGT(pos, fix.Threshold,fix.MaxDuration,fix... |
7cdd7be664b8c6c49adf7742a0e87aec175c39ea853b6c6f3b4e74493d2390dc | MATLAB | 962 | 44 | function addaxisreset(axishandle)
% addaxisreset(axishandle)
%
% axishandle is the handle to the parent axis (default = current axis)
% removes all added axes and deletes the addaxis_data appdata
%
% Example
% x = 0:10;
% plot(x,x)
% addaxis(x,x.^1.5,'-o');
% addaxis(x,x.^.5,'-s','linewidth',2);
% ... |
2016ad8aeda8924c4da32ad249e4ea8487ae57da39486f0ea3149c5960a6b3be | MATLAB | 963 | 38 | function y=nt_video_sns(x,nneighbors)
%y=nt_video_sns(x,nneighbors) - apply SNS locally
%
% y: processed data
%
% x: data to process (time * nrows * ncols)
% nneighbors: number of neighbors to incluce for each pixel
%
% Each channel is projected on its nneighbors closest neighbors,
% and the channel is replaced by ... |
58d45d29dc09235686c7caff263441971845f1e04e32abb904f05ddc63865e1e | MATLAB | 964 | 38 | % Save NIFTI header extension.
%
% Usage: save_nii_ext(ext, fid)
%
% ext - struct with NIFTI header extension fields.
%
% NIFTI data format can be found on: http://nifti.nimh.nih.gov
%
% - Jimmy Shen (jimmy@rotman-baycrest.on.ca)
%
function save_nii_ext(ext, fid)
if ~exist('ext','var') | ~exist('fid','var')
er... |
afe1b9d4ad85540410db84461d02dcf2047347cfc586970b1ad413571be05a84 | MATLAB | 964 | 37 | function L = fd_laplacian(side)
% FD_LAPLACIAN build a finite difference laplacian for a regular grid.
%
% L = fd_laplacian([h,w])
% L = fd_laplacian([h,w,t])
%
% Inputs:
% dims number of nodes along height (and width and depth)
% Outputs:
% L prod(side) by prod(side) Laplacian with negative ... |
fdc9eda813032d53a70083e88a44bcdaa88538437f5621add88565e8ade264f7 | MATLAB | 964 | 31 | %SUMMER Green-yellow colormap
%
% Examples:
% map = summer;
% map = summer(len);
% B = summer(A);
% B = summer(A, lims);
%
% Similar to MATLAB's summer function, but also able to return a concise
% colormap table.
%
% The function can additionally be used to convert a real-valued array into
% a tru... |
fdf96018c38ce8b0f908a816841d64fbb391e9c5b7a245eba28259ab977a28b6 | MATLAB | 964 | 34 | % Center and scale the columns of X such that they have zero mean and norm 1 (considering rows as samples)
function [Z, stdZ, muZ] = unitSpreadDirection(X, omitNaN, doCenter)
%% Default arguments
if nargin < 2 || isempty(omitNaN)
omitNaN = false;
end
if nargin < 3 || isempty(doCenter)
d... |
4eba7f8396a3290c4a5fd21ee8f72056bcf33f2fe539f946635b59713300cca0 | MATLAB | 965 | 41 | %% function to calculate spatial information in bit/min
function I_score = SpatialInfo(occupancy, ActivityRate)
%define t - linearized occupancy
t = occupancy(:);
%calculated summed occupany
t_sum = sum(t);
Ncells =length(ActivityRate);
I_score = zeros(Ncells,1);
for c=1:Ncells
%define lambda - linea... |
e8f376a0155e7ab84b86d16508a44cbb22fc80846d72138bd161315b2ad7eee7 | MATLAB | 965 | 42 | function H = ent_g(x, biascorrect)
% ENT_G Entropy of a Gaussian variable in bits
% H = ent_g(x) returns the entropy of a (possibly
% multidimensional) Gaussian variable x with bias correction.
% Rows of x correspond to samples, columns to dimensions/variables.
% (Samples first axis)
%
% biascorrect : true ... |
fc8478fc534eefb6c61ebb5d2dc9594ea01ba5619c0e6546ceab115cd70199fd | MATLAB | 966 | 35 | function [] = compute_biom_density(mask_1, biom_1,files,idx,results_folder);
close_figs = 0;
coloc_per_cell = 1;
%% Load image
fname = files(idx).name(36:end-4);
fpath = fullfile(files(idx).folder, files(idx).name);
biom_ch_1 = find_channel_img(biom_1);
[img_1] = load_channel_images(fpath, biom_ch_1);
%% Density (% ... |
a4d99e3c3edfc74b71b0496b6e610819a5058bc56b752352ed6b74ad673e3383 | MATLAB | 969 | 33 | function [C,A,score]=nt_cluster1D(x);
%[C,A,score]=nt_cluster1D_b(x) - cluster 1D data into 2 clusters
%
% x: column vector or matrix of data to cluster
%
% C: centroid pairs (one pair per column)
% A: ownership matrix (0, 1)
% score: energy/total energy, for each column
if nargin<1; error('!'); end
if size(x,1)<2... |
5b80429dade1d5bdfa549f03d3a8c21cdcde21b29a6f58f4595ea20d506d074d | MATLAB | 970 | 22 | function coef_vals = rwLCA_wrapper(dictionary_n, x_im, opts)
% coef_vals = rwLCA_wrapper(dictionary_n, x_im, opts)
%
% Wrapper for the l1ls minimization function
% Required parameters:
% opts.eta: 2-D vecotr of Delta/T for LCA (1 for coefficients, one
% for weights. Typically eta(2) < eta(1)/2
% ... |
27ce0067bf0e5be74c4471aae00ddae7885e13ce91b8f4933800e7612718529a | MATLAB | 971 | 27 | function out = mreshape(data)
% function out = mreshape(data)
%
% code accepts a one-dimensional cell array ('data') with each cell holding a vector of values
% and reshapes into a two-dimensional matrix with the first column holding all values from all vectors (across rows)
% and the second column holding a vector sp... |
aca9d7c6cf6e5692efa88389fcb5df49590f5e21bdc33b8e4d1330691da26d0a | MATLAB | 973 | 38 | disp('test example for nt_zapline()');
disp('EEG, resting state data from Trujillo et al doi: 10.3389/fnins.2017.00425');
clear
fname='../data/example2/EEG_Cat_Study4_Resting_S1.bdf';
% check for NoiseTools
try, nt_greetings; catch, disp('You must download NoiseNools from http://audition.ens.fr/adc/NoiseTools/'); ret... |
e9449eeaea86dc0b061a137091853dc1e443b0db5f1de53a4b83968fb6bab451 | MATLAB | 973 | 26 | function outpict = colorpict(imsize,cvec,outclass)
% COLORPICT(IMSIZE,CVEC,{OUTCLASS})
% returns an image of size IMSIZE with a solid color fill
%
% IMSIZE is the image size in pixels (2-D, HxW)
% CVEC is a tuple defining the color and alpha content of the image
% Basic sanity enforcement expects... |
922a47d0115a4e68ee04cba6d5851b445d24affc39419f18c5cfd54de60e073a | MATLAB | 974 | 34 | function CBIG_ExtendValuesInMaskToEntireVolume(input_file, mask_file, output_file, exit_flag)
% Extend the values within the mask to the entire volume.
%
% CBIG_ExtendValuesInMaskToEntireVolume(input_file, mask_file, output_file, exit_flag)
% Input:
% input_file : input nifti file
% mask_fil... |
a1a9538eb93c9d3c42f6581a85453f5ff43e36bf741ae17c4829a62cc90e3347 | MATLAB | 974 | 30 | function [probability, performance, length] = mostImprobableStreak(isCorrect, tailProbability, minLength, maxProb)
% Defaults
if nargin < 4
maxProb = 1;
end
probability = inf;
performance = nan;
length = 0;
% Initialize starting from first tria... |
1116f516e1f1d3b9685442dc993a151109fdaa8ca6ab3069f275e750746f7b9c | MATLAB | 977 | 40 | %function to plot and save figure in pdf of tuning curves (polar plot and histogram)
function SaveTuningExamples(All,file_name)
binCenter = deg2rad(-157.5:45:157.5)+pi/2;
N_cells = length(All.Length(:,1));
if exist(file_name,"file")
delete(file_name);
end
for i = 1:N_cells
figure("Visible", "off")
... |
05fbf87d5cef0238edce01cb5a61e99b7c0eb734f8cdf6d3caeffdac6a599c03 | MATLAB | 978 | 38 | %%
% Tacks on or replaces a trailing '(x)' where x is a unit.
%
function [formatted] = formatUnit(handle, unit)
persistent findUnit;
if isempty(findUnit)
findUnit = '(?<=\s)[(][a-zA-Z]+([^]{?[-+0-9]+}?)?[)]\s*$';
end
if ishandle(handle)
oldLabel = get(handle, 'String');
else
o... |
1b1800720c9ac2660b8409edfbbaea7e949741e899f7e96caca312e5045d4f0b | MATLAB | 978 | 26 | % Compute the polar decomposition A = U P where U is a unitary (or orthogonal, for real A) matrix
% and P a positive-semidefinite Hermetian (symmetric) matrix.
%
% Higham, N. J. MATRIX NEARNESS PROBLEMS AND APPLICATIONS. in (1989).
function [U, P] = polarDecomposition(A)
%% Preallocate output
assert(size(A... |
cd8c215bd470d1305374a470f55fb189b8695c31d020e7498f476606857759c1 | MATLAB | 978 | 34 | function minimametric = CBIG_SPGrad_find_minima(data,K_neighbors)
% minimametric = CBIG_gMSHBM_find_minima(data,K_neighbors)
%
% This script find the local minima of the smoothed gradient map
%
% Input:
% - data:
% the smoothed gradient map.
%
% - K_neighbors:
% the K nearest neighbors for a mesh.
... |
4d88904062ae35bae3d956a4627460287df64ec3f1469384084c18edde819e7c | MATLAB | 981 | 34 | function refineVNS(fname,M)
disp('loading data')
tic
%Img1 = imread(fname);
mask_name = [fname(1:end-4),'_mask.mat'];
load(mask_name)
toc
disp('refining segmentations')
tic
he = imread(fname);
lab_he = rgb2lab(he);
L_blue = lab_he(:,:,1) .* double(mask{M});
L_blue = rescale(L_blue);
idx_light_blue = imbinarize(nonzero... |
ec32e17d7b79fdc52fab8ec43a5f9b65de907e2decd5877d45a55da3323a7686 | MATLAB | 981 | 40 | function[As_restyled,As_restyled_index]=restyle_assembly_lags_time(A,A_index)
%% REORDER LAGS AND SHIFT ASSEMBLY'S OCCURRENCE
% lags and elements are reordered so that all lags are expressed with respect
% of the first firing unit. Assembly activation times is shifted
% accordingly to match the firing of the first ass... |
a8727640d2aedb14949692cf10e2d242bda66743874c6c4ecc9aed97b0271d8c | MATLAB | 982 | 39 | disp('test example for nt_zapline()');
disp('MEG, 5 line noise components');
clear
fname='../data/example8/data_plosone_EEG/data_EEG/sujet01/2008-10-27_LENA_0001.eeg';
% check for NoiseTools
try, nt_greetings; catch, disp('You must download NoiseNools from http://audition.ens.fr/adc/NoiseTools/'); return; end
% chec... |
d1f1ede02724cf734531f395095f3471c59c361eb63417a5f1bef4f292d8b40a | MATLAB | 982 | 37 | %% function to get reward tuning
function [IsRewardTuned, WhichReward, IsMatch] = GetRewardTuning(TunedBin,RewBin, LightBin)
IsRewardTuned = zeros(length(TunedBin(:,1)),2);
WhichReward = nan(length(TunedBin(:,1)),2);
IsMatch = nan(length(TunedBin(:,1)),2);
[~,ia,~] = intersect(RewBin,LightBin); % dont use re... |
ce068d59771c48cca1cb89877c54f004538f77cb0e3ba904e7e0f336ddffe888 | MATLAB | 983 | 47 | %
% map = mapType2Size(inByte)
%
% Description:
% generate a map from type of variable to Byte
%
% Input:
% inByte - flag indicating whether in Byte or Bit
%
% Output:
% map - the map
%
% Copyright:
% 2017-2018 (c) USC Biomedical Imaging Group (BigLab)
% Author:
% Jian (Andrew) Li
% Revision:
% ... |
f7c677cc1f0bf7fc2c667e133187b5455e4604deea4e56602058354ac3aa3643 | MATLAB | 984 | 36 | function [squares,quads,D]=nt_qpca(x,npcs,nsmooth,nquads)
%[squares,quads]=nt_qpca(x,npcs,nsmooth,nquads) - quadratic PCA
%
% squares: linear components closest to largest quadratic component
% quads: largest quadratic component(s)
% D: eigenvalues
%
% x: data (time*channel*trial)
% npcs: maximum number of data P... |
cf144988dcd8bad98fe623e3e20e4852d72efa82bc2ac9ca0a6cc5c99f17cdb1 | MATLAB | 985 | 24 | %% Demo 1 - Unpaired t-test equivalent (single two-level factor)
% The simplest equivalence: a linear model with one two-level factor reproduces
% the classical independent-samples t-test exactly. Shown on the sleep dataset
% (R base; Cushny & Peebles 1905 / Student 1908) - the extra hours of sleep
% gained by 10 patie... |
41ff914c7d853ce880f76af7b4c78d31ccab30de3ef8858c3718c5f2a5daa1d2 | MATLAB | 986 | 36 | function CBIG_CreateLooseGCAHeadMask(input_file, output_file, dist)
% Create loose GCA head mask. This function 1) set nonzero value to 1; 2)
% dilate the mask; 3) fill in the holes
%
% CBIG_CreateLooseGCAHeadMask(input_file, output_file, dist)
% Input:
% input_file : input mri nifti file
% output_fil... |
720bdf7a20a4395aefd7bb891403eed61fba81516c127917f4e0157b26a99a39 | MATLAB | 986 | 40 | %
% demo file on how to use Nlx2MatSpike_v3. for further details,see the original help in Nlx2MatSpike_v3.m
%
%
%Filename = '/Users/ueli/data/turtleD29_sept6/TT1.ntt';
%Filename = '/home/urut/MPI/data/testData/SE1_CSC34.nse';
Filename='/tmp/TT_test4.ntt';
% 1. Timestamps
% 2. Sc Numbers
% 3. Cell Numbe... |
f5c5f85af0bb8063a0724050f38be6699e86bfc555fe56c8fe37e30b3a38a851 | MATLAB | 986 | 36 | function y=nt_phase_scramble(x,allsameflag)
%y=nt_phase_scramble(x,allsameflag) - scramble time but preserve autocorrelation
%
% y: scrambled data
%
% x: data to scramble (time X channels, or time X channels X trials
% allsameflag: if true, same random phasor to all channels [default: true]
%
if nargin<1; error('!'... |
7588f9d484a1519b88fb898fb5251a5becaa7c0c92439325b63850fb457fd8c0 | MATLAB | 987 | 36 | function paramsOut = setParams(dParams, paramsIn)
% paramsOut = setParams(dParams, paramsIn)
%
% paramsOut = setParams(dParams, paramsIn)
%
% The output params struct will include the fields of dParams and paramsIn.
% If the same field exists in both of them, the value will be taken from 'paramsIn'
%
%
%%%%%%%%%%%... |
8a88bdce4d87c1379f9a018e7fb780a75be2537c7123e3a1403a683ecbb7c5bb | MATLAB | 987 | 34 | clear;clc
load('SubjectsBehaviorData.mat');load('GCM_Flight_airTraffic.mat');
%% PEB
%之前在spm batch中选择的界面,写成了代码进行批处理
% Design Matrix
N1 = 39;%被试个数,第一组的,注意修改,只能做两组的,两组以上的,拆成两组去做
N2 = 37;
C1 = ones(N1+N2,1);%x1对应的第一列
C2 = [ones(N1,1);-ones(N2,1)];
C2 = C2 - mean(C2);
%年龄变量
C3=age-mean(age);
C = [C1, C2, C3... |
cb32ed09960009f03a377b446a0530a1b63580438c8b721df4fcd66d161ce17a | MATLAB | 988 | 41 | % Solve an Input-Output Fitting problem with a Neural Network
% Script generated by NFTOOL
% Created Sun Mar 01 11:19:26 EAT 2026
%
% This script assumes these variables are defined:
%
% data - input data.
% data - target data.
inputs = data';
targets = data';
% Create a Fitting Network
hiddenLayerSi... |
e0ca3ee5bf666f6c3ba74602faafee72e3c4109c124ec553780a6ca159f69a08 | MATLAB | 988 | 41 | function m = CBIG_nanmean(x, dim)
% m = CBIG_nanmean(x, dim)
%
% Compute the mean values of a matrix/vector excluding NaN entries.
% It has the same functionality as nanmean.m, but avoid to use statistics
% toolbox.
%
% - Inputs
% x : the data matrix/vector you want to compute the mean.
% dim : takes the... |
06ebda8ac92861cd0542033e1255d90b042dfce6e801a78d43c504d22fbd89ff | MATLAB | 989 | 28 | function [BS,model_predictions] = main_lstm_MA(EEG, model_file_path, weights_file_path)
%% Generates model predictions
%
% **Usage:** [BS,model_predictions] = main_lstm_MA(EEG, model_file_path, weights_file_path)
%
% Input(s):
% - EEG = EEG struct m
% - model_file_path = keras model (h5 or JSON)
% - we... |
133260ece83dcbf094cca4fb9f01cb9398f7f9dd7fd273f3c02ca290a6711d76 | MATLAB | 989 | 30 | %THERMAL Black-purple-red-yellow-white colormap
%
% Examples:
% map = thermal;
% map = thermal(len);
% B = thermal(A);
% B = thermal(A, lims);
%
% A colormap designed to replicate the tones of thermal images.
%
% The function can additionally be used to convert a real-valued array into
% a truecolor... |
d0ac833b25c18e92c8c9e9c6c9fde7a45de0ff75a9ad7532cd495ce90da1752f | MATLAB | 989 | 25 | %% Construct negative-to-positive color map such that zero is at the joint
% colorFunction should be a cell array of color function handles, where the first element is to
% generate the negative color scale and the second to generate the positive color scale
function colors = twoSidedColormap(zMin, zMax, numColo... |
d5168a25442022e417d3c34022e79b367f222a700241153a9ef378703a57fece | MATLAB | 989 | 24 | %% Concatenate cells in the array data along dimension dim, creating an output of size 1 in dimension dim
function concatenated = catcell(catDim, data, dim, concatFcn, varargin)
%% Default arguments
if ~exist('concatFcn', 'var') || isempty(concatFcn)
concatFcn = @cat;
end
%% Reshape data so... |
787bd5408a40e083691514eb8deb1e4c5e0e1535e6720349889d774b2cb26daa | MATLAB | 991 | 38 | % Copyright (C) 2013 Quan Wang <wangq10@rpi.edu>,
% Signal Analysis and Machine Perception Laboratory,
% Department of Electrical, Computer, and Systems Engineering,
% Rensselaer Polytechnic Institute, Troy, NY 12180, USA
% dynamic time warping of two signals
function d=dtw(s,t,w)
% s: signal 1, size is ns*k, row for... |
6fe8946c9096600cf61964ffe4595b780508690cbf48bc57af44afc151adc8de | MATLAB | 994 | 32 | %%
% Bi-normal inverse cumulative distribution function.
function [x] = bigaussinv(cdf, mu, sigmaL, sigmaR)
if nargin < 3 && iscell(mu)
if numel(mu) < 3
x = norminv(cdf, mu{:});
else
x = bigaussinv(cdf, mu{:});
end
return;
end
% Assign points to either the ... |
d347c2ae2847f3e17f73cf2d910f23a65cc26cba59018f2908fbcf1195165e31 | MATLAB | 995 | 39 | function testfig(stat_x)
set(gcf,'Renderer','zbuffer')
f = figure;
set(f, 'units','normalized','position', [0 0 1 0.5]);
i = 1;
for ix = 1 : size(stat_x.xcorr,1)
for iy = 1 : size(stat_x.xcorr,2)
if ix > iy
c = [0 0.8 0];
end
if ix < iy
c = [0 0.8 0]... |
fd4e0f2885a376ebb00181979fa3e40b52b4d55aa616eb637014be3e69fe74ac | MATLAB | 995 | 32 | function result = montageToStack(montage, montageDims)
% MONTAGETOSTACK: Takes a montage and converts it back to a stack
%
% Usage:
% result = montageToStack(montage, montageDims)
%
% Inputs:
% montage: a montage generated by stackToMontage or a modification of such
% a montage
% montageDims: an output from stackToMo... |
15f57aed77e3b73a17f7f055f5d40a8e2cb16e00308855f42b2602c03e13bb63 | MATLAB | 999 | 17 | % SUBARRAY Returns a subset of the given array by specifying dimensions and ranges to restrict to.
%
% Usage syntax:
% subset = subarray(array, dim1, range1, dim2, range2, ...)
%
% This will select a (hyper-)rectangular subset of the given array by applying the specified range
% requirements to each of the... |
94b1eb0c311a632a1a8c56c4480b62cf7e132d14155b4a2e5a06e954d05753d8 | MATLAB | 1,002 | 27 | %% Computes principal coefficients such that X = P*C in a least-squares sense, given output from wpca().
% The main inputs to this function should be a matrix P whose columns are principal components.
% Additional arguments should be in pairs of X, W where X are data matrices and W corresponding
% weight matri... |
fe6c72e3ab22380814854f5efd290e135db4d8c84746c6ee2dcb572633dd6f8f | MATLAB | 1,004 | 30 | %THERMAL Black-purple-red-yellow-white colormap
%
% Examples:
% map = thermal;
% map = thermal(len);
% B = thermal(A);
% B = thermal(A, lims);
%
% A colormap designed to replicate the tones of thermal images.
%
% The function can additionally be used to convert a real-valued array into
% a truecolor... |
0ecfd8f4a308499884152db3efbb45a1b7013b3a1a0696bbc6f03de79f1baae0 | MATLAB | 1,005 | 34 | function [found_max, found_min] = find_nearest(x,find_value)
%% Find nearest predicted peak before and after one tap or prediction
%
% **Usage:** [found_max, found_max] = find_nearest(x,find_value)
%
% Input(s):
% - x = array with positions of events
% - find_value = the position of current tap or prediction
%
% Ou... |
c9cfff24465c4fcc8d6464b2af24e27c73669cad6b164fa61a789ceacdf2bab8 | MATLAB | 1,005 | 34 | %% Run all kbstat demo scripts and report pass/fail
% Executes every demo_*.m in this folder in turn, catching errors so one failure
% does not stop the rest. Each demo writes its output under demo/results/.
thisDir = fileparts(mfilename('fullpath'));
cd(thisDir);
demos = dir(fullfile(thisDir, 'demo_*.m'));
fprintf('... |
97d1e64c044674fbf0234e3035563dc6dae6e301923e5feb891d8d15548a11d7 | MATLAB | 1,006 | 27 | function next = create_slice_from_bucket(input, header)
matrix_size = header.encoding.encodedSpace.matrixSize;
function slice = slice_from_bucket(bucket)
disp("Assembling buffer from bucket containing " + num2str(bucket.data.count) + " acquisitions");
slice.reference = structfun(@(arr... |
f793c10cff4dce3fbedcb3d189ccfe3a7ac62a85fed0ddc1c3dbbad15be0037c | MATLAB | 1,007 | 45 | function CBIG_AvgFreeSurferVolumes(varargin_text, output_file)
% Average all freesurfer volumes.
%
% CBIG_AvgFreeSurferVolumes(varargin_text, output_file)
% Input:
% varargin_text: text file including all mat files
% output_file : output file name
%
% Written by CBIG under MIT license: https://github... |
fd05c90237ab416c88b68b8602a77f2ae9c9163fc2e1b1c1e7ce8d57132cea51 | MATLAB | 1,007 | 41 | classdef Segment < handle
properties (Constant)
size uint64 = 4096
end
properties (GetAccess = public, SetAccess = private)
bytes uint8
written uint64
end
properties (GetAccess = public, Dependent)
available uint64
end
methods
function self... |
9b46f9e6c960621bcb110d42792e40dc4b71f9b313c20de55a42f47a16212717 | MATLAB | 1,008 | 48 | %
% LBO = getLaplaceBeltramiOperator(sf, precision)
%
% Description:
% Get Laplace Beltrami operator
%
% Input:
% sf - the surface structure
% precision - precision of the operator
%
% Output:
% LBO - Laplace Beltrami operator structure
%
% Copyright:
% 2016-2017 (c) USC Biomedical Imaging Group... |
31f95eb05e8aa64c9287f1cd44cb049d4978a052006cd00ed051838e4b73a319 | MATLAB | 1,009 | 42 | %% function to get LED tuning
function [IsLightTuned, WhichLight, IsMatch] = GetLightTuning(TunedBin, LightBin, RewBin)
IsLightTuned = nan(length(TunedBin(:,1)),2);
WhichLight = nan(length(TunedBin(:,1)),2);
IsMatch = nan(length(TunedBin(:,1)),2);
%% remove light bin that overlaps with rewbin
[~, ia,~] = ... |
0d89cd8d19ee5979135af0a687f8f131a2b4956cbff76e70960015626653bd07 | MATLAB | 1,010 | 36 | function avg = CBIG_AverageStructures(output_file, var_name, varargin)
% Average each variable of a structure across all mat files.
%
% avg = CBIG_AverageStructures(output_file, var_name, varargin)
% Input:
% output_file : output file name
% var_name : structure name
% varargin : all the m... |
291d33edf45fea8e0ce588e769ddb1a38f2e80e57539820b255054c4fde176ca | MATLAB | 1,021 | 42 | function [B, R2, y_pred, y_fit, bint, R2_CI] = performRegression(X, y, n_boot)
% Add interaction term if exactly two predictors
if size(X, 2) == 2
X = [X, X(:,1) .* X(:,2)];
end
% Add intercept
X_aug = [ones(size(X,1),1), X];
% Perform OLS regression
[B, bint, ~, ~, stats] = regre... |
8875438bc5bcbec1227181e13841792fd8b77d986208f48041befdc8e6ec6976 | MATLAB | 1,021 | 17 | % === main_data_preparetion.m ===
%% === Prepare connectome data ===
connectomeMatrix = ConnectionMatrix(mouseBrainConnectomeMatrix); % <-- input matrix
brainInfo = BrainRegionInformation(brainRegionInformationTable);
brainSpace = BrainSpace3D(annotation3D_right_brainRegions);
brainSpace.setRegionCenterCoord(coordinat... |
8796f71899c2b196241b01d82daf8e154614356472c25d1ffea04ce23be899af | MATLAB | 1,022 | 28 | function writer = write_waveform()
writer.accepts = @(item) isa(item, 'gadgetron.types.Waveform');
writer.write = @write_waveform_header_and_data;
end
function write_waveform_header_and_data(socket, waveform)
write(socket, gadgetron.Constants.WAVEFORM);
write_header(socket, waveform.header);
write_... |
909ab7be9d17d4ccca02244e86b6e4e45424ca45e95923bc606e2d0626351696 | MATLAB | 1,022 | 28 | function hBar = barWithErrors(axs, value, interval, colors)
%% Default arguments
if nargin < 4
colors = [];
end
%% Draw bars
hold(axs, 'on');
hBar = bar(axs, 1:size(value,1), value);
drawnow;
%% Apply colors and draw errors
for iBar = 1:numel(hBar)
... |
55beccb179888dafcad5ea3613fdfdcc55d944ad871a512d19abd804f7aca1ba | MATLAB | 1,023 | 39 | function [varargout] = niceRange(range, numDivisions, integral, truncator)
% NICERANGE Returns an adjusted range for the requested number of
% divisions.
%% Parse input
if nargin < 3 || isempty(integral)
integral = false;
end
if nargin < 4 || isempty(truncator)
truncator = @ceil... |
e33ea09626f446dd3aa974290017e23093017af36c1bc293183cbd1de8ddfde4 | MATLAB | 1,023 | 43 | function outflag = isopaque(inpict,tol)
% OUTFLAG=ISOPAQUE(INPICT,{TOLERANCE})
% Determine whether an image is opaque. Return is true if
% INPICT has no alpha channels or if the alpha channels are
% all uniformly maximized within a given tolerance.
%
% INPICT is an I/IA/RGB/RGBA/RGBAAA image of any clas... |
b2a9ebcc769dd19fc6b463bdc690e84312a10d3c8e4cc6e1e0762c105429b1fb | MATLAB | 1,027 | 27 | function outgeometry = drysize(ingeometry,outscale)
% OUTGEOMETRY=DRYSIZE(INGEOMETRY,OUTSCALE)
% Calculate the output geometry resulting from the use of imresize().
% This may be convenient when needing to precalculate array sizes resulting
% from the subsequent use of imresize() with implicit resizing par... |
b6802fb18df34e3b83c429cf725718f53ce518461a8cc080b79814088b517f3f | MATLAB | 1,029 | 20 | %test force
addpath (genpath('\\lexport\iss01.charpier\analyses\lgi1\Git-Paul\EpiCode\development'));
addpath \\lexport\iss01.charpier\analyses\lgi1\Git-Paul\fieldtrip;
ft_defaults
addpath (genpath('\\lexport\iss01.charpier\analyses\lgi1\Git-Paul\EpiCode\projects\dtx'));
addpath (genpath('\\lexport\iss01.charpier\analy... |
079c5d7dfcc4fa4853e5efe7c8fba95dd528be6f2227a130758ff98b14b215e9 | MATLAB | 1,032 | 22 | clc;clear all;close all;restoredefaultpath;
%addpath(genpath('/big_disk/ajoshi/coding_ground/bfp/supp_data'))
addpath(genpath('/home/ajoshi/Projects/bfp/src'));
% 1050345 rest 2
% Set the input arguments
configfile='/home/ajoshi/Projects/bfp/supp_data/config_bfp_preproc_minimal.ini';
t1='/home/ajoshi/Downloads/vol... |
939310dc14028ca55e87e66f33b0610d2c2668f0cf57488186c35eef6ed8071a | MATLAB | 1,032 | 20 | %% Resamples f(t) by computing the average in bins of width deltaT aligned to t0 (t0 is constrained to be a bin center).
%
% Syntax:
% [binnedF, tCenters, t0Index] = binnedResample(t, f, t0, deltaT, [fLo = f(1)], [fHi = f(end)])
% t is assumed to be monotonic.
%
% The average f(t) is computed in each bin by li... |
aa84a168255614b0c2d8736b2eba0b067aec0c2d78dd209a7d0c7af69bff0ed7 | MATLAB | 1,034 | 27 | %% Gergely Tarcsay, 2024 Ewell lab. Function to calculate daily performance - total, ctxt A and ctxt B
function Performance = GetPerformance(TrialType, context, all_outcome)
%create table for each trial
Ctxt = context';
Outcome = all_outcome(:,1);
Outcome_tbl = table(TrialType, Ctxt, Outcome );
%get ctxt ... |
ea4005049d1c7e14d5ff212704cf67796b960af87e2167eb4274562d04f062b9 | MATLAB | 1,034 | 40 | function outpict = eoframe(inpict,N,offset)
% EOFRAME(INPICT, N, {OFFSET})
% extracts every Nth frame from INPICT
% alternatively, can be used for frame duplication
%
% INPICT is a 4-D image array
% N is an integer specifying the inverse of frame sampling density
% e.g. for N==2, every other fra... |
6bd25e5c272a5a269360f9efb39f267faa06300d4fa55422dee473fcd686abd4 | MATLAB | 1,036 | 29 | %% function to assign states to frames for the random foraging experiments
function [States, TrialFrames] = AssignFramesToStates_RF(event, v, v_thresh)
States.Run = v > v_thresh;
States.Context = zeros(length(v),1);
States.TrialPhase = zeros(length(v),1);
States.TrialType = nan(length(v),1);
... |
84ecd478dc1a125369bbeae114a6575fee69f160d4c75d2bc747afb08808e3fb | MATLAB | 1,036 | 33 | %%
function [handles] = circle(x, y, r, color, varargin)
if nargin < 4
color = [0 0 0];
end
customColors = ( size(color,1) == length(x) );
if ~customColors
clr = color;
end
phi = colvec( 2*pi:-0.1:0 );
handles = zeros(numel(x), 1);
for i = 1:numel(... |
e337d7a36e7ab7cc858190be9606015173fe7a4ac79f19df8c027f72823d8e2e | MATLAB | 1,036 | 45 | %%
% Extracts and concatenates element(s) at the given index of dimension
% dim, looping over a 1D cell array c.
%
function [collection] = cellCollect(c, dim, index)
% Get an example element so that we can preallocate the output array
example = [];
for iC = 1:numel(c)
if ~isempty(c{iC})
... |
395a5d5bb9d619ccfb8974809b98e31b4282e28b03605a6e73e7dde610c93a4c | MATLAB | 1,037 | 32 | % Directory path
path = '/scratch1/woojaeje/ImagePTE2/woojaeje/DARPA/Data/Processed data/';
items = dir(path);
folderNames = {items([items.isdir] & ~strcmp({items.name}, '.') & ~strcmp({items.name}, '..')).name};
for n = 1:size(folderNames,2)
n
fpath = [path, folderNames{n},'/'];
fileName = dir([fpa... |
73cc87719462a9b0ec29ddb5cc57a484187897509334fc62e1f47f80f3231cc5 | MATLAB | 1,042 | 39 | function VNS(fname,N)
%fname = '/dcl02/lieber/ajaffe/SpatialTranscriptomics/LIBD/spatialDLPFC/Images/Lieber_Institute_OTS-20-7748_rush_posterior_A1.tif
%N = 5;
tic
disp('Importing capture area')
Img1 = imread(fname); %import image
toc
tic
disp('Performing smoothing and contrast adjustment')
Img1_smooth = imgaussfilt(I... |
72b5de08e4e02e21886fd061f3d7aba1908a4ecc1aaf7d0d0bd1345715d3cf6e | MATLAB | 1,043 | 34 |
% Run SPM spatial smoothing for all Dartel images in folder
clear, clc, close all
%% Paths
path_Dartel_NAS = 'X:\ALFA_plus_v1_T1_Dartel_Unsmoothed\';
%% List subjects/files
list_subjects = dir(path_Dartel_NAS);
list_subjects = {list_subjects.name}.';
list_subjects(1:2) = []; % remove ... |
8fd84f17deb9927872738d8003e6e466e65397574cdc700488fb46cced229167 | MATLAB | 1,045 | 43 | %% RECTANGLECORNERS Returns patch x and y coordinates for a rectangle with corner at (x,y) and with the given width/height
function [cornerX, cornerY] = rectangleCorners(x, y, width, height, doClose)
if nargin < 5
doClose = false;
end
if isempty(width)
width = 0;
end
if isempty(height)
height... |
1f32fdd46f6625dd51e44ca401a0aca1490fb91db603d994b31e7330a6d94a03 | MATLAB | 1,049 | 40 | %% function to assign heading-direction tuned cells to reward/light or other category
function CategoricalTuning = GetTuningComposition(TunedBin, RewBin, LightBin)
% get "other" bins
OtherBin= 1:8;
[~, ia,~] = intersect(OtherBin,RewBin);
OtherBin(ia) = [];
[~, ia,~] = intersect(OtherBin,LightBin);
Other... |
7b94e92777286f007fce4c7e742b69de298eb78783dfc4c86278bdbbbf5fe571 | MATLAB | 1,049 | 33 | function [AMs_AT, NAMs_AT] = find_AM_NAM_AT(EEG, type, s_i,precision)
%% Calculates ERP per participant
%
% **Usage:** [AMs_AT, NAMs_AT] = find_AM_NAM_AT(EEG, type, s_i,precision)
%
% Input(s):
% - EEG = EEG struct with epoched integral data
% - type = name of event for artificial touch (e.g. type = '33')
% - s_i... |
ad42653c6ead1c1f3a80395124aa103e9ce42702daa527c55df009e8c2f7795c | MATLAB | 1,051 | 58 | function lim = stretchlimFB(inpict,tol)
% stretchlimFB(inpict,{tol})
% passthrough to stretchlim() with internal fallback
% for systems without IPT installed.
%
% Not all features are available in the fallback implementation
% IPT methods exploit precompiled private functions and are much faster
% ... |
c282d1ff75a877890b54a57400690e0e3c4ba712b71f889b0484ca62c2af06d8 | MATLAB | 1,051 | 43 | %--------------------------------------------------------------------------
%%
function [y] = fiteval(f, x, nonzeroOnly)
%----- Input parsing
if nargin < 3
nonzeroOnly = false;
end
%----- Assume all structures are C++ splines
if isstruct(f)
% Special case with an array of f correspo... |
b132ca76b9b1dbcd4659634279e5de514ab7cc922da377103f239e0a409f0fde | MATLAB | 1,054 | 39 | function c = redblue_cp(m)
%REDBLUE Shades of red and blue color map
% REDBLUE(M), is an M-by-3 matrix that defines a colormap.
% The colors begin with bright blue, range through shades of
% blue to white, and then through shades of red to bright red.
% REDBLUE, by itself, is the same length as the current f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.