sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
839ff40fae77249a018dd34a2b697493ddd1609bc209f555d96a8b82423fd5c7 | MATLAB | 825 | 23 | % DESCRIPTION
% Set different 3D axes to the same limits and view angle as you zoom and pan
% INPUT
% axList - List of handles to axes to connct
%
% Source: https://www.mathworks.com/matlabcentral/answers/351573-how-to-link-2-3d-subplots-to-sync-zoom-and-pan
function axList = connectaxes(axList)
%% Us... |
0eec473f60b173245e0d2eb6d53885f70d4ef52758e7a8b52957af14b94a0cd7 | MATLAB | 827 | 27 | function smoothedV = ...
CBIG_AuthorTopic_FFTSmooth3DVolumeWithPredefinedKernel( ...
V, fftK)
% smoothedV = ...
% CBIG_AuthorTopic_FFTSmooth3DVolumeWithPredefinedKernel( ...
% V, fftK)
%
% Smooth a 3D volume using Fast Fourier Transform (FFT) with a predefined
% smoothing kernel
%
% Input:
% - V: the origi... |
4f38fb1b02dc7efb879c7c72c5efbda41420fb49efb9fa207b6d568aab1acd0d | MATLAB | 827 | 38 | %%
% Returns a representation of the given number that has the requested
% number of significant digits.
function [rep] = significantDigits(number, numDigits, truncator)
if ~isfinite(numDigits)
rep = number;
return;
end
if nargin < 3
truncator = @round;
end
upper ... |
7762b4020a7302edaaae004f2a907ac33c4de028107e1d4e3bc3b48cd0db5294 | MATLAB | 828 | 21 | function [subcort_index, non_subcort_index] = CBIG_GetSubcortIndices
% Get Freesurfer subcortical indices.
% Reference: $FREESURFER_HOME/FreeSurferColorLUT.txt
%
% [subcort_index, non_subcort_index] = CBIG_GetSubcortIndices
% Output:
% subcort_index : column vector, subcortical index
% non_subcor... |
05c0887cd4afacfe6942d66c5fe583cb69dafbf9120b6248ec9ed65ef7bed5da | MATLAB | 829 | 17 | function [p,logPmax] = likelihood(data, options, alpha, beta, lambda, gamma, varscale)
% calculates the (normalized) likelihood for the data from given parameters
%function [p,logPmax] = likelihood(typeHandle,data,alpha,beta,lambda,gamma)
% This function computes the likelihood for specific parameter values from
% the ... |
5fdd8c7cfbcf9eb3d58447e459f00971ef67d2eae0d8cc714e79137789157d12 | MATLAB | 830 | 21 | function next = remove_oversampling(input, header)
encoding_space = header.encoding.encodedSpace.matrixSize;
recon_space = header.encoding.reconSpace.matrixSize;
if encoding_space.x == recon_space.x, next = input; return, end
x0 = (encoding_space.x - recon_space.x) / 2 + 1;
x1 = (encoding_space.x... |
2078315d8b9f7891b0864cdf49bd61a94bc5d22ea22cafbcf402b2c41e52c57f | MATLAB | 831 | 37 | % Demonstrate how negative values arise from sampling variability when
% there is no effect
% trials per class
Ntrl_class = 100;
% sampling repetitions
Nrep = 1000;
Inobc = zeros(1,Nrep);
Ibc = zeros(1,Nrep);
for ri=1:Nrep
% generate data
% the class has no effect on the distribution the data is drawn from
... |
0de4048161790c714f4b7ca15c15d8137788b4534a90e2223cb476bb25099eab | MATLAB | 832 | 29 | function rep = formatSIPrefix(x, unit, digits)
if nargin < 2
unit = '';
end
if nargin < 3
digits = 4;
end
magnitude = log10(x);
if magnitude > 0
magnitude = floor(magnitude);
rounding = -1;
else
magnitude = ceil(magnitude);
rounding = 1;
end
... |
137dc30f019b335ec98d3303ee6b0a0ee05d53fc7b1eac64bd05f414ac546a75 | MATLAB | 832 | 23 | % Replace with colored text() labels for those matching a given regular expression pattern
function labels = highlightMatching(labels, pattern, color)
if ischar(labels)
labels = {labels};
singleton = true;
else
singleton = false;
end
%% Support regular expression... |
1a3c5419d60ed148d3d8aaed58be48c8f50477c11e550ed3cf0dea9bd2bbc481 | MATLAB | 833 | 21 | function tempForDisplay = mdisp(x)
% Function used to visualize multichannel images.
% If the input corresponds to a 3D array of dimensions N1 x N2 x Nc, the
% output corresponds to a 2D array that displays Nc images of dimension
% N1 x N2.
%
% Input parameters:
% --x: 3D array of size N1 x N2 x Nc, wher... |
26eaae092914a37e4e325394e652e1b60bbd09d91860210854ecb36a68025c5a | MATLAB | 834 | 22 | function [sz12] = mergesize(sz1, sz2)
% MERGESIZE Merges two size arrays if possible, i.e. replacing singleton
% dimensions in one with dimensions of the other. An error is
% raised if non-singleton dimensions have incompatible sizes.
sz12 = zeros(1, max(numel(sz1), numel(sz... |
8a7576c7b4bce564c04b3dd101300f5bae4fb8fb4b780be82161ea648d994657 | MATLAB | 834 | 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=[147,225, 373,247,186,187,188,189,227,145];%, 345,351];
s{1}=readdfs('../supp_data/bci... |
36865563153140fae44866bf98af8bd8f2850812ad2494553332445baa6e6b48 | MATLAB | 835 | 26 | %% Envelope entropy–based fitness function
function [ff] = EnvelopeEntropyCost(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, ... |
86b722dba93c272b9e7b6d687a560dfc42f29d60e12fa56553d25b4cef88cae1 | MATLAB | 835 | 16 | %% function to shuffle heading-direction and calculate RVL distribution
function RVL_distribution = ShuffleHD(HDir, minShift, repeat, edges, framesToUse, Nbins, framerate, EventTime, binCenter)
N_cell = length(EventTime(:,1));
Nframes = length(HDir);
maxShift = Nframes-minShift;
K = randi([minS... |
9e47a54cb9d8cbbfc3e609202cbb8c7514d76a931e12236c75a9d263e07c70c2 | MATLAB | 835 | 30 | function displayException(err, blurb, focus)
if nargin > 1
cprintf('Comments', blurb);
end
cprintf ( 'Errors', '\n[[%s]] %s\n' ...
, err.identifier, err.message ...
);
width = max(cellfun(@length, {err.stack.name}));
for iStack = numel(err.stack):-1:1
fprintf... |
922baca1f50d03f4ad9353f9670485b4113481d0b4a1b54bdad9ca5d3b675940 | MATLAB | 836 | 29 | %%
% Sorts the other matrices in the same order as reference.
function [varargout] = sortTogether(reference, varargin)
if numel(varargin) > 1 && isempty(varargin{1}) && numel(varargin{2}) == 1 && isintegral(varargin{2})
arrays = varargin{3:end};
sortOptions = varargin(1:2);
... |
961564605a1956fbe8e7885db795a9df87c3a5199fedfc9b30b1dfd4da3da53a | MATLAB | 836 | 31 | function [ncchans nachans] = chancount(inpict)
% COUNTVECTOR = CHANCOUNT(INPICT)
% [NUM_COLOR_CHANS NUM_ALPHA_CHANS] = CHANCOUNT(INPICT)
% simple convenience tool for fetching info about an image
% assumes I/IA/RGB/RGBA/RGBAAA channel arrangements
% assumes image dimensioning is [height width channels f... |
b8de20d545ac27147901c75d48b8f2b36720dc95987cc5bbe54d8b87a94939b6 | MATLAB | 836 | 32 | %% Return a list of struct field names where the value of the field passes the provided test function
% If test is not a function, then equality is tested for using isequaln().
function names = fieldswithvalue(S, test, invert, pattern)
if nargin < 4
pattern= [];
end
if numel(S) ~= 1 || ~isstruct(S... |
e6ab6f41e7411ad7ea8b365d73ad2a618cea300aa73453748af45e0070adefd1 | MATLAB | 840 | 23 | %% function to count match/mismatch/neutral fields
function [N_mm, dist_mm] = CountMM(Mismatch, cut_off)
dist_mm = cell(4,1);
i=1;
dist_mm{1} = [dist_mm{1}; Mismatch{i}(find(Mismatch{i}(:,1) >= cut_off),1)];
dist_mm{2} = [dist_mm{2}; Mismatch{i}(find(Mismatch{i}(:,1) < cut_off & Mismatch{i}(:,2) < cut_off),1... |
b1c4d1acdf0685021ae5b53053d354df41b7285b90750ec78892d55d4bb4e6a7 | MATLAB | 841 | 19 | function res = psignifitFast(data,options)
% this uses changed settings for the fit to obtain a fast point estimate to
% your data.
% The mean estimate with these settings is very crude, the MAP estimate is
% better, but takes a bit of time for the optimization (~100 ms)
warning('You use the speed optimized version o... |
f977c44c075fd1e5aecc00c20e541843787413c1ba246f071f8a2ef5c5f9ceea | MATLAB | 842 | 29 | function inpict = straightshifter(inpict,amt)
% STRAIGHTSHIFTER(INPICT, SHIFTAMOUNT)
% shifts all rows and columns by the amount specified in AMOUNT
% all shifts are circular
%
% INPICT is an I/RGB image of any standard image class
% SHIFTAMOUNT specifies the shift amounts (in pixels)
% for RGB... |
0601ffb26e0e3c390e08da83a92d71f9c98a8e2dcb7bfa16b81623218cbd4ed9 | MATLAB | 843 | 27 | function [window, colour]=create_windows
%[window, colour]=create_windows
%
%Open display window and also set colour shortcuts
%
%OUTPUTS
%window pointer to display window
%colour colour shortcuts which are [R G B] CLUT indeces: colour.red, .white, .darkblue, .lightblue, .green, .black
%Create colou... |
77513c2a0c4f70504f00f013a82969ff2de712eec78e1454a5b549f594ef334b | MATLAB | 844 | 24 | clc;clear all;close all;restoredefaultpath;
addpath(genpath('/home/ajoshi/coding_ground/bfp/src'));
% Configuration file
configfile='/home/ajoshi/coding_ground/bfp/supp_data/config.ini';
%T1 and fMRI images in NIFTI-1 format (nii.gz)
for jj=1:21
subid=sprintf('sub-%02d',jj);
t1=sprintf('/deneb_disk/studyforres... |
4312a9144b23284b31a87e00a927dd77fe81893186ce7eb2fb355a4a6f32b8dc | MATLAB | 847 | 44 | function y = my_betapdf(x,a,b)
% this implements the betapdf with less input checks and to work with GPU
% and non GPU inputs correctly
% function y = my_betapdf(x,a,b)
% Initialize y to zero.
y = zeros(size(x));
if numel(a) == 1
a = repmat(a,size(x));
end
if numel(b) == 1
b = repmat(b,size(x));
end
% Spec... |
9d2fe4fcd2f736be59decd5a91a3f144cf799e7e53b820ec9a25aa1120a0941d | MATLAB | 848 | 23 | function preictal_launch_SpykingCircus_extracting(slurm_task_id)
addpath (genpath('/network/lustre/iss01/charpier/analyses/louis.cousyn/Scripts/EpiCode/projects/preictal'))
config = preictal_setparams;
for ipatient = slurm_task_id
for ipart = 1:size(config{ipatient}.directorylist,2)
subjdir = config{... |
2a491b1d14cd31b2982c33ecb16c9f439d41e4c702a515117a810092a5c16ca1 | MATLAB | 859 | 46 | close all; clear all; clc
addpath(genpath('~chuck/code/matlab/'));
addpath('matlab');
%%%%%%%%%%%%%%%%%
% SCRIPT PARAMS %
%%%%%%%%%%%%%%%%%
% Site data
Analysis.database{1} = '/data/coord/tyr/tyrunits';
Analysis.database{2} = '/data/coord/zen/zenunits';
% Data
Analysis.dataDirectory = 'data/LIP';
Analysis.class{1} ... |
8e6521c39bdb6c9db1319a573e85827a89dceb4d9fe7004f00cbdaa885e5720a | MATLAB | 859 | 31 | % loop trough files in folder to make undistortion for all .nii files in
% folder
% Attention: the mask needs to be made first! (see
% Use_mc_undist_wouter_dante.m)
% This is STEP 2.
clear
% addpaths
addpath('/fmri/apps/spm5')
addpath('/fmri/spm5_scripts/')
addpath('/fmri/spm5_templates/')
addpath('/fmri/spm5_utils/'... |
f52f6c17172b2b8212bfa605e16c5b15f574d7771e82af6ffd0d9e677ec3fee2 | MATLAB | 859 | 22 | function [eeg_name] = calculate_date_differences(eeg_name)
%% Calculates the difference between all dates and smallest date
% This function is used to ignore the second file of curfew
% participants(ignore the data after curfew)
%
% **Usage:** [eeg_name] = calculate_date_differences(eeg_name)
%
% Input(s):
% - eeg_na... |
b2e65d47a87f49a6a78d0de86930b772f1ab66443581cc2a1cfd69a287edb5b9 | MATLAB | 862 | 26 | function varargout = splitchans(inpict)
% [CH1 CH2 CH3 ...] = SPLITCHANS(INPICT)
% Split a multichannel image into its color channels.
% This tool is effectively a direct replacement for IPT imsplit(),
% though splitchans() also allows underspecified and multiframe inputs.
%
% INPICT is an image of any stan... |
f52e3b7deb3956062feaf93e0a2c09c8b784af9f85586ceaf0b259b8397df390 | MATLAB | 862 | 32 | % Example of line noise removal using ZapLine toolbox.
%
% de Cheveigné, A. (2020). ZapLine: A simple and effective method to remove
% power line artifacts. NeuroImage, 207, 116356.
%
% IMPORTANT NOTE: LFP must contain more than 1 channel.
clear
clc
% load data
% zapline wants 2d array m_timepoints x n_channels
fn... |
0e7d8e1ea918374eeac18c3d14bb436fd2cd7705a8a7a162e069b881710d7858 | MATLAB | 864 | 28 | function BoundaryVec = CBIG_ComputeSurfaceBoundaries(mesh, labels)
% BoundaryVec = CBIG_ComputeSurfaceBoundaries(mesh, labels)
% This function is used to generate a two-vertex thick boundary defined by
% labels.
% Example:
% lh_avg_mesh= CBIG_ReadNCAvgMesh('lh', 'fsaverage5', 'inflated', 'cortex');
% BoundaryVec = CBI... |
3ee3e0374894805747abcb8b0cbed37902591de83b9d432fe818785ee8291fc3 | MATLAB | 864 | 23 | function [x,y,z] = montageXYToStackXYZ(x_in, y_in, targetXYSize, montageDims)
% montageXYToStackXYZ: turn xy coordinates in a montage into xyz coordinates of the corresponding stack
% usage:
% [x,y,z] = montageXYToStackXYZ(x_in, y_in, targetXYSize, montageDims)
% turn a series of x and y points in a montage into a seri... |
115975adde3dc6b6b8ab7e5858b6da6f703db561634baa263a8d34f7f3e9d612 | MATLAB | 866 | 29 | function outpict = imclamp(inpict,varargin)
% OUTPICT = IMCLAMP(INPICT,{LIMIT})
% Clamp data values to stay within a closed interval. This is
% more readable than min(max(myvariable,lim1),lim2), especially
% in cases where the limits are already in vector form.
%
% INPICT is any numeric array
% LIMITS optio... |
db637b2ebb42d81375c7703f3e9e27c35d294731fe165489504a4cdf24087ecc | MATLAB | 867 | 33 | function SI = parseFijiScanImageMetadata(filename)
% Written by Andrew Lin, andrew.lin@sheffield.ac.uk
metadataText = fileread(filename);
% in Fiji metadata, the ScanImage metadata appears after the string
% 'Software = '
startKey = 'Software = ';
% in some Fiji files, there is a line ----------------- after the Sc... |
fa4d69af8db4d78ce73ce9f753120934bc5563c0e6e3914d17bcca85e74d0eee | MATLAB | 869 | 36 | function saveTable(myTable, fname, fext, fdir)
if nargin < 4
fdir = '.';
end
if nargin < 3
fext = '.xlsx';
end
% make file extension lowercase
fext = lower(fext);
% ensure that file extension is cell array
fext = cellstr(fext);
for iFext = 1:length(fext)
myFext = fext{iFext};
if ~startsWith(fext, '... |
ae713d30636b0b3e1850116ae16dabcbf75e3e129eeb23b51e13e9c2d275c230 | MATLAB | 871 | 23 | function sds = estimate_sd_for_snr(VOI, SNRdb)
% estimate_sd_for_snr Estimates the SD for white noise, that added to the
% pure signal in VOI should create the desired SNR in DB
% INPUTS:
% -VOI: a SPM VOI structure
% -SNRdb: a vector that defines for which SNRs (in DB) the standard
... |
763ba1b26a5e18c2ee67de7016a9869231ead045afc2f65fdc004e2f539e11b5 | MATLAB | 873 | 36 | %%
function [] = disc(x, y, r1, r2, faceColor, edgeColor, varargin)
if nargin < 5 || isempty(faceColor)
faceColor = [1 1 1];
edgeColor = [0 0 0];
end
if nargin < 6 || isempty(edgeColor)
edgeColor = faceColor;
end
customFace = ( ~ischar(faceColor) && size(faceColor,1) == lengt... |
a1539fb0bff82c1bc5651ea3373d23c2c3a4016339a3459a70f15cc303a44830 | MATLAB | 873 | 20 | % Compute concentration measures of angular differences between direction vectors specified as the
% columns of X. Each slice (3rd and higher dimensions) of X is treated independently.
%
% N.B. We have to use circular statistics here, see
% https://en.wikipedia.org/wiki/Directional_statistics
function [stdAng, v... |
e77254478ba2ed07efce75d80ec4884da9b6a0df099c9bff3e1b315eb29c249a | MATLAB | 874 | 25 | % Compute the standard error on 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 [sem, mu] = meanError(X, dim, useQuantile)... |
30282b19636554a543d96fa286adf83d3da4281e0a09fbfd97bca5c5b5c5277a | MATLAB | 875 | 26 | function priors=normalizePriors(options)
% normalization of given priors
%function Priors=normalizePriors(options)
% This function normalizes the priors from the given options struct, to
% obtain normalized priors.
% This normalization makes later computations for the Bayesfactor and
% plotting of the prior easier.
%
%... |
bb171a22a800c2d6e60b25f4abfc2cbabaab7b022ab4aed5f3b69794b1665783 | MATLAB | 875 | 30 | function retdata = getaddaxisdata(axishandle,flag)
% retdata = getaddaxisdata(axishandle,flag)
%
% internal function for addaxis
% axishandle is handle to the parent axis onto which other axes were added
% flag is either 'axisdata', or 'resetinfo' to return the added axis
% handles and plot handles, or the p... |
0e57305100c38a0a3b19292a260d854081b0b8f3ccc82658cd2b29d02fa34655 | MATLAB | 878 | 31 | % loop trough files in folder to make undistortion for all .nii files in
% folder
% Attention: the mask needs to be made first! (see
% Use_mc_undist_wouter_dante.m)
% This is STEP 2.
clear
% addpaths
addpath('/fmri/apps/spm5')
addpath('/fmri/spm5_scripts/')
addpath('/fmri/spm5_templates/')
addpath('/fmri/spm5_utils/'... |
87d1d6f7186bb91337192356aceca8feb6174a367ab683ace842df7f9593d854 | MATLAB | 878 | 29 | % UNITVECTORS Normalizes all vectors in the matrix M.
%
% Inputs
% ========
% M : A matrix of vectors to normalize
% dim : Direction that specifies the vectors, e.g. dim = 1 assumes that each column of M
% corresponds to a vector to be normalized
% varargin : Can be 'omitnan' to ... |
93f694f5898f59992289d77ec6739f2896da8c0d8c94b3fe314ca1db877482ec | MATLAB | 878 | 32 | function data = Read_FreeSurfer(fname)
%data = Read_FreeSurfer(fname)
%
% Reads the contents of FreeSurfer ASCII files.
% The matrix is organized into five colums:
% 1: vertex vertex index number
% 2-4: x,y,z coordinates of vertices in world space
% 5: values contains overlay values etc
... |
61e0957ed41849027815fc0fbe889c94819b22e4dcbdab53e33989f6fbdc134f | MATLAB | 879 | 23 | function bias_bits = bias_ent_g_bits(Nvar, Ntrl)
%BIAS_ENT_G_BITS Analytic Gaussian entropy bias in bits.
% bias_bits = bias_ent_g_bits(Nvar, Ntrl) returns the
% finite-sample bias term for the log-determinant part of the entropy of an
% Nvar-dimensional Gaussian estimated from Ntrl samples.
if ~isscalar(Nvar) |... |
87937555b55908f3a99c3e1b3338966ea4a427550488190ba0e9975a4944afda | MATLAB | 879 | 42 | % Demonstration of hierarchical model fits
%
% SF 2014
clear all
Ntrials = 200;
Nsubj = 30;
c = -0.3;
c1 = [-1.5 -1 -0.5];
c2 = [0.5 1 1.5];
group_d = 2;
group_mratio = 0.8;
sigma = 0.5;
mcmc_params = fit_meta_d_params;
mcmc_params.estimate_dprime = 0;
for i = 1:Nsubj
% Generate dprime
d(i... |
034983f9839314d4e661a8449681cc8eaf49f9439edd0a0cabfec16a820c2bcf | MATLAB | 880 | 30 | % loop trough files in folder to make undistortion for all .nii files in
% folder
% Attention: the mask needs to be made first! (see
% Use_mc_undist_wouter_dante.m)
% This is STEP 2.
clear
% addpaths
addpath('/fmri/apps/spm5')
addpath('/fmri/spm5_scripts/')
addpath('/fmri/spm5_templates/')
addpath('/fmri/spm5_utils/'... |
da388aee66b3b6b679aa39be907cc0f9c183be533f383a616fb0fca646765044 | MATLAB | 880 | 28 | function [ ] = display_Rating( WindowPtr,x,y,yscale,rating)
%DISPLAY_RATING shows the effort rating scale
% "rating" indicates the position of the cursor, between 0 and 100.
% Define graduations
ngrad=100;
segment=800/(ngrad-1);
% define y coordinates for the scale
%yscale=400;
% Draw the line and the cursor
xarr... |
eea52b47a3bf3af212631e7c4f3b6b4bea3b9f27b4d0e3a8d78f07101c654355 | MATLAB | 883 | 26 | function [decreased_precision_phone] = change_sequence_precision(Phone, pad_length)
%% The tap measurement may be off by about +/- 10 taps, this function pads
% the data with this difference
%
% **Usage:** [decreased_precision_phone] = change_sequence_precision(Phone, pad_length)
%
%
% Input(s):
% - Phone = Phone tap... |
a97d5f4acd816d146d14a604e2220331e886597bec4824ef55ddb586b0103935 | MATLAB | 884 | 30 | % loop trough files in folder to make undistortion for all .nii files in
% folder
% Attention: the mask needs to be made first! (see
% Use_mc_undist_wouter_dante.m)
% This is STEP 2.
clear
% addpaths
addpath('/fmri/apps/spm5')
addpath('/fmri/spm5_scripts/')
addpath('/fmri/spm5_templates/')
addpath('/fmri/spm5_utils/'... |
d73f64078d4bdaf953e97e286c70ab8f89eb6f4dc5c4ff14b93bb451df1bb889 | MATLAB | 884 | 39 | function z = nmi(x, y)
% Compute normalized mutual information I(x,y)/sqrt(H(x)*H(y)) of two discrete variables x and y.
% Input:
% x, y: two integer vector of the same length
% Ouput:
% z: normalized mutual information z=I(x,y)/sqrt(H(x)*H(y))
% Written by Mo Chen (sth4nth@gmail.com).
assert(numel(x) == numel(y))... |
3f15e52aaa11982b807ef27969f84ee951591496c2f718dff484b6485c2f8e7f | MATLAB | 885 | 37 | function xsum = CBIG_nansum(x, dim)
% m = CBIG_nansum(x, dim)
%
% Compute the sum of a matrix/vector excluding NaN entries.
% It has the same functionality as nansum.m, but avoid to use statistics
% toolbox.
%
% - Inputs
% x : the data matrix/vector you want to compute the sum.
% dim : takes the sum alon... |
0e2a248c8931791b3bda9a0689df1089de80e5f1aef0695a6dc1b5a88df7cb4b | MATLAB | 886 | 23 | function [bb_1, bb_2, bb_3] = find_bounding_box(mask, pad_vox)
% Returns the indices representing bounding box of input 3D-mask.
% pad_vox is the number of voxels to be padded around the actual bounding box.
msk_stat = regionprops(mask>0 , 'BoundingBox'); % returns center of border voxels (outside the box)
tmp_stat... |
135d8051dc18fa8d07643e13db6487946fb5f17c779abc9b61455362989ee09b | MATLAB | 886 | 36 | function [childrenIdListTxt] = extractChildrenIdListTxtFromPath(structureIdPath)
load("MBStructureTreeData_raw.mat");
idListStr = strrep(structureIdPath,'/',',');
idListStr = strip(idListStr);
idList = str2num(idListStr).';
% i = 1
childrenCell = struct2cell(MBStructureTreeData_raw.children);
childrenIdList = cell2... |
aeaea886ea15d0226e4a59eeb7334f38dcd22b37296876753bdf4e05f0e75aa0 | MATLAB | 886 | 32 | function [acorr, nFFT] = fastAutocorr(X, nLags, nFFT, normalize)
%% Default arguments
if nargin < 4 || isempty(normalize)
normalize = true;
end
%% Default arguments
if nargin < 2 || isempty(nLags)
nLags = size(X,1) - 1;
else
nLags = min(size(X,1) - 1, nLags);
end
if nargin < 3... |
4ef52effeeeff35a22ddb9979c7f85a66741dfe7dd7d01f11b297d829cfb3392 | MATLAB | 887 | 36 | disp('test example for nt_zapline()');
disp('MEG, 5 line noise components');
clear
fname='../data/example5/example_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');
d... |
bf80c4811c86bf44317db2d6a2639d746678c0650ae1a5ec300f5ccb84890d98 | MATLAB | 888 | 36 | function S04_residuals_3D_to_4D(subject, game)
root_path = 'YOUR_DATA_PATH';
main_dir = strcat(subject, '/', game) ;
GLM_name = 'GLM_empty';
clear matlabbatch
res_dir = remove_dots_from_dir(dir(strcat(root_path, main_dir, '/GLMs/', GLM_name, '/Res_*.nii')));
for i = 1:size(res_dir,1)
if str2d... |
60478d4af5daf2589debb4925d91f47ed3fd3440a64c2127f4e2970731634297 | MATLAB | 890 | 31 | %% BOXCORNERS Returns patch x and y coordinates for a box centered at (centerX,centerY) and with the given width/height
function [cornerX, cornerY] = boxCorners(centerX, centerY, width, height)
if nargin < 5
doClose = false;
end
% Canonical format of arguments
centerX = rowvec(centerX);
cen... |
707ed20b4f4a046446e2aa2961773af54a9fa60b44d81f4d49c33f1059b2c28c | MATLAB | 891 | 30 | % loop trough files in folder to make undistortion for all .nii files in
% folder
% Attention: the mask needs to be made first! (see
% Use_mc_undist_wouter_dante.m)
% This is STEP 2.
clear
% addpaths
addpath('/fmri/apps/spm5')
addpath('/fmri/spm5_scripts/')
addpath('/fmri/spm5_templates/')
addpath('/fmri/spm5_utils/'... |
a2088b05811fba4a5847a28bba45158e2cb73e1385415bcd53f864701dee7691 | MATLAB | 892 | 34 | function angles = angleBetween(X, Y, dim, varargin)
%% Default arguments
if ~exist('dim', 'var') || isempty(dim)
dim = 1;
elseif ischar(dim)
varargin = [{dim}, varargin];
dim = 1;
end
% assert(isequal( size(X), size(Y) ));
%% Convert to unit vectors
X ... |
b5521fe49365602554f6130f23883e7c1baf42453bf3e97a349a2c34571f84a6 | MATLAB | 892 | 21 | function [subcort_index, non_subcort_index] = CBIG_GetSubcortAndCerebellumWhiteIndices
% Get Freesurfer subcortical and cerebellum white matter indices.
% Reference: $FREESURFER_HOME/FreeSurferColorLUT.txt
%
% [subcort_index, non_subcort_index] = CBIG_GetSubcortAndCerebellumWhiteIndices
% Output:
% subcort_i... |
e6a5bf563b9c77d23eb4734e5b242f48195a0e72046f15f345025ae42c031e92 | MATLAB | 892 | 24 | function D = sparseDeconvDictEst(D, Y, A, h, opts)
% This function should return the solution to the optimiation
%
% S = argmin[||Y - (h*S)A||_F^2 + ]
%
% D_i = h*S_i
Dfun = @(Z) bilin_fun(Z, Y, A, h, D, opts);
Hfun = @(x, lambda, Z) bilin_Hessfun(x, lambda, Z, Y, A, h, opts);
% minopts = optimset();
minopts = opti... |
39836bc0fa2a0f8efea208a1826b799e7e95108eee3065409afa588d7b359bc0 | MATLAB | 900 | 41 | function outpict = paritysweep(bg,modsize,width)
% PARITYSWEEP(INPICT, MODSIZE, WIDTH)
% returns an imageset of length MODSIZE wherein each frame is a map
% of all pixels where mod(pixel,modsize) matches a group of values
% of count WIDTH. This sampling window is swept from 0 to MODSIZE
% c... |
abdeda9b246353a57431d4f9154d9ddbde8dbca8fa41cda4f264b8c614387bd8 | MATLAB | 904 | 28 | function outpict = flattenbg(inpict,sg)
% OUTPICT = FLATTENBG(INPICT,SIGMA)
% Flatten low-frequency nonuniformities of an image using a
% traditional blur and divide technique, similar to that used
% by IPT imflatfield().
%
% INPICT is an image of any standard image class
% SIGMA describes the blur filt... |
f11f3cdd6755af61297620db942f630ced3be5fc3f65ac1bb3eba417bec26df5 | MATLAB | 904 | 29 | function [epochedvals] = getepocheddata(Data, triggersample, SampleRange)
% Usage: [epochedvals] = getepocheddata(Data, triggersample, Sample Range)
%
% Input(s)
% - Data --> Samples as in timeseries
% - triggersample ---> The samples containing trigger as in cell number of T.
% - Sample range ----> [-100 ... |
2bc47e81b266d96554e41ba9bced4930014130f8652349600c0bbee52cfd0f89 | MATLAB | 905 | 32 | function neigbor_mat = CBIG_SPGrad_create_neighbor_mat(sbjMesh, grad_data)
% neigbor_mat = CBIG_SPGrad_create_neighbor_mat(sbjMesh, grad_data)
%
% This script creates a gradient neighborhood matrix for a given surface mesh
%
% Input:
% - sbjMesh:
% the surface mesh structure.
%
% - grad_data:
% the... |
1b740535f524d775c4e1f8b3536fdfb5c82e85eebc9ae0cae31616ed3a1d16ae | MATLAB | 906 | 30 | % loop trough files in folder to make undistortion for all .nii files in
% folder
% Attention: the mask needs to be made first! (see
% Use_mc_undist_wouter_dante.m)
% This is STEP 2.
clear
% addpaths
addpath('/fmri/apps/spm5')
addpath('/fmri/spm5_scripts/')
addpath('/fmri/spm5_templates/')
addpath('/fmri/spm5_utils/'... |
ccfdb552c2a8b902070e98ab1686614c5ff85846b031d58246fdc08287e8fc3a | MATLAB | 906 | 1 | function y=nt_wmean(x,w,dim)
%y=nt_wmean(x,w,dim) - weighted average
%
% y: vector of weighed means
%
% x: column vector or matrix of values to average columnwise
% w: column vector or matrix of weights (default: all ones)
% dim: dimension over which to average (default: 1)
%
% if x contains nans the corresponding we... |
ddbdc2715eda063087c89a119d876615872c6ae56149b73618f9048cf37ca1fc | MATLAB | 906 | 30 | % loop trough files in folder to make undistortion for all .nii files in
% folder
% Attention: the mask needs to be made first! (see
% Use_mc_undist_wouter_dante.m)
% This is STEP 2.
clear
% addpaths
addpath('/fmri/apps/spm5')
addpath('/fmri/spm5_scripts/')
addpath('/fmri/spm5_templates/')
addpath('/fmri/spm5_utils/'... |
e35be3322453a3ab0a910f8a319bbaa93fbece39e962d5f84d1a965551f8301d | MATLAB | 906 | 32 | %%
% Returns the number of elements that need to be summed in order to yield
% at least equal to the given percentiles of the cumulative.
%
function [counts] = countPercentile(sortedData, percentiles, cumulative)
% Sanity check for inputs
if sortedData(1) < sortedData(end)
error('sortedData must be... |
89a18eda4d5c60938c06a89de92763415427e0969622d18df42261784a8fd4be | MATLAB | 910 | 37 | %% http://people.eecs.berkeley.edu/~wkahan/Mindless.pdf
function ang = angleBetween(x, y)
if nargin < 2
y = x;
symmetric = true;
else
symmetric = false;
end
ang = zeros(size(x,2), size(y,2));
nx = normd(x, 1);
ny = normd(y... |
36e785e4b0ea8799b5f77902ff071fa7f9a474a5feed25e945f38969aa6cdbbf | MATLAB | 911 | 29 | %% function to get field center - reward site distance
function [RewDistance, RewLoc] = GetRewDistance(event, Field_tbl, BinnedXY)
[TrialStart, TrialStop, ZoneTriggered, context] = ParseTrials(event);
[Correct, ~, ~, ~, ~, ~, ~] = GetTrialOutcome(event,TrialStart,TrialStop,ZoneTriggered);
if sum(ismember(contex... |
0bcc033951cb2a2ef44d5aa41340098fb20e13586ce3931427e4aa9908e5dc9c | MATLAB | 913 | 30 | % loop trough files in folder to make undistortion for all .nii files in
% folder
% Attention: the mask needs to be made first! (see
% Use_mc_undist_wouter_dante.m)
% This is STEP 2.
clear
% addpaths
addpath('/fmri/apps/spm5')
addpath('/fmri/spm5_scripts/')
addpath('/fmri/spm5_templates/')
addpath('/fmri/spm5_utils/'... |
2d83517aeb808ae47a93ca85104d5506797ec0615e703213fc6ead05aca3e3d7 | MATLAB | 913 | 30 | % loop trough files in folder to make undistortion for all .nii files in
% folder
% Attention: the mask needs to be made first! (see
% Use_mc_undist_wouter_dante.m)
% This is STEP 2.
clear
% addpaths
addpath('/fmri/apps/spm5')
addpath('/fmri/spm5_scripts/')
addpath('/fmri/spm5_templates/')
addpath('/fmri/spm5_utils/'... |
c697d52debd945415f3c6a7f8f76743613f0b9fa64154fcc0be0e55d03ad0db7 | MATLAB | 914 | 35 | en_h2co = [1.936 0.6736, 0.5640, 0.5201
2.054, 0.8724, 0.7852, 0.7157
1.126, 0.9571, 0.9184, 0.8833
2.518, 0.8791, 0.6765, 0.0752
3.766, 0.2837, 0.2757, 0.1486
]';
colors = [1,0,0
0.8,0,0
0.7,0,0
0.6,0,0
0.4,0,0
];
set(groot,'defaultAxesTickLabelInterpre... |
fde08bb07cf5330c5d4fa9f7608b5e9730df44e0227a070e8f5efa4a38973460 | MATLAB | 914 | 29 | addpath(genpath('~chuck/code/matlab'));
DIST = 0.5;
DataList = selectDataFromDatabase('/data/coord/zen/zenunits','LFP','coord');
SiteParams = listSiteParams(DataList,'/data/coord/zen/zenunits','coord');
coordinates(1,:) = [SiteParams.xCoord];
coordinates(2,:) = [SiteParams.yCoord];
coordinates(3,:) = [SiteParams.z... |
30079ede6a7d172680ee64c95593bac0bfd24aa86a048c52a3ce245486069f36 | MATLAB | 916 | 30 | % loop trough files in folder to make undistortion for all .nii files in
% folder
% Attention: the mask needs to be made first! (see
% Use_mc_undist_wouter_dante.m)
% This is STEP 2.
clear
% addpaths
addpath('/fmri/apps/spm5')
addpath('/fmri/spm5_scripts/')
addpath('/fmri/spm5_templates/')
addpath('/fmri/spm5_utils/'... |
467a650e3a9b8d2adb461288f68e7bfe8acb44d60f00232640d44b7cc27b57de | MATLAB | 916 | 41 | function outpict = hsl2rgb(inpict)
% HSL2RGB(INPICT)
% undoes an HSL conversion from (RGB2HSL)
%
% INPICT is an image of class double wherein
% H: [0 360)
% S: [0 1]
% L: [0 1]
%
% Return type is double, scaled [0 1]
%
% See also: rgb2hsv, rgb2hsl, rgb2hsi, rgb2hwb
% This is basically ... |
8bdc1b3c29112c22a45c66578c9778431c27c8f373561b849b207752a0744f18 | MATLAB | 916 | 30 | % loop trough files in folder to make undistortion for all .nii files in
% folder
% Attention: the mask needs to be made first! (see
% Use_mc_undist_wouter_dante.m)
% This is STEP 2.
clear
% addpaths
addpath('/fmri/apps/spm5')
addpath('/fmri/spm5_scripts/')
addpath('/fmri/spm5_templates/')
addpath('/fmri/spm5_utils/'... |
9fac5c3cf9411e53e286d8051d20e8e692566271457afed058db4b94acd1b3b9 | MATLAB | 917 | 30 | % loop trough files in folder to make undistortion for all .nii files in
% folder
% Attention: the mask needs to be made first! (see
% Use_mc_undist_wouter_dante.m)
% This is STEP 2.
clear
% addpaths
addpath('/fmri/apps/spm5')
addpath('/fmri/spm5_scripts/')
addpath('/fmri/spm5_templates/')
addpath('/fmri/spm5_utils/'... |
3ea52c529a6ecddae46f4dcd5ea8c13863dec04e5ab03b9c6bf5c2709c8c21fd | MATLAB | 918 | 35 |
size(dat.trial{1}(1,:))
deadtimes
maxsamples = dat.fsample*26;
% maxsamples = size(dat.trial{1},2);
figure; hold;
plot(dat.time{1}(1:maxsamples),dat.trial{1}(1,1:maxsamples))
mindat = min(dat.trial{1}(1,1:maxsamples));
maxdat = max(dat.trial{1}(1,1:maxsamples));
idead = 1;
while deadtimes(idead,1) <= maxsamples ... |
8965620482dc5a54218bdf8645ec20e739bfa449385c2a9eee69bddfac06efac | MATLAB | 918 | 30 | % loop trough files in folder to make undistortion for all .nii files in
% folder
% Attention: the mask needs to be made first! (see
% Use_mc_undist_wouter_dante.m)
% This is STEP 2.
clear
% addpaths
addpath('/fmri/apps/spm5')
addpath('/fmri/spm5_scripts/')
addpath('/fmri/spm5_templates/')
addpath('/fmri/spm5_utils/'... |
89b4ab217e0961be3c5721877d1e21b1397c18b8426259ce202877cec9652da2 | MATLAB | 919 | 40 | function varargout = addaxislabel(varargin)
%ADDAXISLABEL adds axis labels to axes made with ADDAXIS.m
%
% handle_to_text = addaxislabel(axis_number, label);
%
% See also
% ADDAXISPLOT, ADDAXIS, SPLOT
if isstr(varargin{1}),
axnum = varargin{2};
label = varargin{1};
else
label = v... |
bcff4bc9e2e5ba1910e8d59b0ac3781e7f3d8b4eadd00f686ee743635ae72e93 | MATLAB | 919 | 30 | % loop trough files in folder to make undistortion for all .nii files in
% folder
% Attention: the mask needs to be made first! (see
% Use_mc_undist_wouter_dante.m)
% This is STEP 2.
clear
% addpaths
addpath('/fmri/apps/spm5')
addpath('/fmri/spm5_scripts/')
addpath('/fmri/spm5_templates/')
addpath('/fmri/spm5_utils/'... |
d07f765721eece69f57c47581325d41534e8af6826b72beac206c4d0756f48a3 | MATLAB | 919 | 26 | %% BrainSync: Syncronize the subject fMRI data to the reference fMRI data
% Authors: Anand A Joshi, Minqi Chong, Jian Li, Richard M. Leahy
% Input:
% X - Time series of the reference data (Time x Vertex)
% Y - Time series of the subject data (Time x Vertex)
%
% Output:
% Y2 - Syncronized... |
d815e5f7f59e76e6911ec42221bf9e4bd75673289ecbf6f6bec6241ba01a8ef7 | MATLAB | 920 | 46 |
tam = 10000;
allAddr = 1320*ones(tam,1);
ISI = ones(tam,1);
isi_out = ones(tam,1);
n_out = ones(tam,1);
flag = true;
test = 10000;
iter_ints = cell(test,1);
ini = 2100; % [20, 250, 2100]
bin = 100; % [10, 50, 100]
freq_in = ini:bin:test;
freq_out = zeros(1,(test-ini)/bin);
for i =... |
0b99b0fcbd0853474e7bf13b1c68780c494ccaebe85901e7f30e1d862635deb7 | MATLAB | 921 | 31 | function [answer, anstime]=get_key(keys, wait);
%[answer, anstime]=get_key(keys, wait);
%
%Get keyboard-input from user - waits for a key press as defined in input variable 'keys' OR just checks once
%
%INPUTS
%keys key numbers we are looking for. scalar for one key, or row vector of key numbers
% ... |
90815114fcd497f2488cdd5d72de303f92efffa5afb9917d63a769391d74fc91 | MATLAB | 921 | 39 | %
% [dataOut, meanVal] = zeroMean(dataIn, dim)
%
% Description:
% remove mean from data on a particular dimension
%
% Input:
% dataIn - data input
% dim - on which dimension to remove mean
%
% Output:
% dataOut - data output
% meanVal - mean value that subtracted
%
% Copyright:
% 2013-2018 (... |
e0b5ac14bdb2e26e267df08273ae1dc5bd28e1b101e46a31e3059ba595fe4009 | MATLAB | 921 | 33 | function pdf = binnedKDE(x, w, xBins, bandwidth, numSigmas)
%%
if nargin < 5
numSigmas = 5;
end
%%
dx = xBins(2) - xBins(1);
bin = 1 + round(( x - xBins(1) ) / dx);
xTemp = 0:dx:numSigmas * bandwidth;
xTemp = [-fli... |
e736ddb3f18e9e29f43048539abf9fffbe0f38582903bcaf8bebde5482ff4fcc | MATLAB | 921 | 26 | 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'));
BSTDir = '/home/ajoshi/BrainSuite19b';
usclobes_file = '/ImagePTE1/ajoshi/code_farm... |
217b36a5f0f8aded5abc6cc230e919cb1533dcf26303c1db62374938b5906174 | MATLAB | 923 | 40 | function outsize = imsize(inpict,varargin)
% SIZE = IMSIZE(INPICT,{LENGTH})
% This is just a simple wrapper for size(). This ensures
% that the size vector is always a fixed length, allowing
% simpler and safer comparison of image dimensionality.
% It also allows the equivalent of size(mypict... |
fe810e315429bafc0d7ed37b9ee78bf2209fde92af1d2e88235f29560c182d74 | MATLAB | 923 | 21 | % [normed_signal, mean_vector, norm_vector] = normalizeData(pre_signal)
% This function normalizes the input signal to have 0 mean and unit
% variance in time.
% pre_signal: Time x Original Vertices data
% normed_signal: Normalized (Time x Vertices) signal
% mean_vector: 1 x Vertices mean for each time series
% std_vec... |
feccdf70c11405802625d8c67d01840f803b027e68b81ccd82f6934d28f24625 | MATLAB | 923 | 32 | function [hasDuplicates, duplicatePairs] = checkDuplicatesTol(arr, tol)
%CHECKDUPLICATESTOL Checks for approximate duplicates within a tolerance
%
% [hasDuplicates, duplicatePairs] = checkDuplicatesTol(arr, tol)
%
% Inputs:
% arr - A numerical array (vector or matrix)
% tol - Tolerance for comparing flo... |
897bf6e5a3d3ff7bbc16b3fe94692ab296877bba20b766a92d25d1d84e263451 | MATLAB | 924 | 1 | % CreateDataFile.m
function err = CreateDataFile(Data)
%Check acceleration sign
if Data.RunType == 1
Gradient = 'DIS';
else %Data.RunType == 2
Gradient = 'LOC';
end
%Get Date
Data.Date = fix(clock);
Data.Folder = [ 'Data' filesep ];
Data.Filename = sprintf('%s-%04d-%02d-%02d-%02d-%02d-%s-%04d-%04d.mat', ..... |
aa948d1c1d5b7960c29236c3807f81a1db673693d9a04436400a78f0a17a1e12 | MATLAB | 924 | 26 | function S = diagScaledMatrix(A, tol)
if nargin < 2 || isempty(tol)
tol = eps(max(abs(A(:))));
end
%% Preallocate output
assert(size(A,1) == size(A,2));
S = nan(size(A));
nSlice = size(S,1) * size(S,2);
iDiag = 1:size(S,1)+1:nSlice;
%% ... |
dc817c3b013f6eca6a605f5e43e15bc7fa770715de6b97219a9616e36316a97c | MATLAB | 925 | 39 | % Author: Woojae Jeong
%% Preprocessing
eeglab; % Call EEGLab
% Start BrainStorm
if ~brainstorm('status')
brainstorm nogui % Start BrainStorm without GUI
%brainstorm % Start BrainStorm with GUI
end
% EEG file directory path
path = '/scratch1/woojaeje/ImagePTE2/woojaeje/DARPA/Data/Emotional Stroop/'; % Em... |
dd1cf64ac487ac76f22316385dbbc7fb55d604e1f2520f9a3c1fd03c6d13520c | MATLAB | 926 | 25 | %%
function [handle] = rectanglePatch(center, extent, color, rangeInput)
% Draws a rectangular patch. Different from rectangle() because this
% makes a patch() object. If rangeInput is true (default false), the
% input arguments are instead the minimum and maximum coordinates
% spanning the rectangle.
%
... |
28ce0514752fd47b0e3c7f6dda51d1f4ea9501e6328b05191abb156f0b83ae10 | MATLAB | 927 | 31 | %%
function [handle] = cbscale(handle, label, varargin)
%---- Get the colorbar
narginchk(1, inf);
if nargin < 2
label = handle;
handle = cbhandle();
end
%---- Set title
hTitle = get(handle, 'Title');
handles = [handle, hTitle];
units = rset(handles, 'Units', 'norma... |
704a250c38b1bd6d5ab2d63e92080b971636e8635c2b6e29124cfe38bf9fe531 | MATLAB | 927 | 25 | function acquisition = read_acquisition(socket)
header = gadgetron.external.readers.decode_acquisition_headers(read(socket, 340, 'uint8'), 1);
trajectory = read_trajectory(socket, header);
data = read_data(socket, header);
acquisition = gadgetron.types.Acquisition(header, data, trajectory);
end
functi... |
eb5d2cb831d3019be14521e6a9c01f310147d7695cde479d671cd07b636a1d0e | MATLAB | 927 | 38 | function plotxcorr(cfg,stat)
fig = figure;
set(fig, 'units','normalized','position', [0 0 1 0.5]);
i = 1;
for ix = 1 : size(stat.xcorr,1)
for iy = 1 : size(stat.xcorr,2)
if ix > iy
c = [0 0 0];
end
if ix < iy
c = [0 0 0];
end
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.