sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
6711fa1c8dd4586a537f97aa5659633f22b0deea8cdbdb891bb48193d6688a96
MATLAB
3,128
96
function logB = mkSoftEvidence(localCPD, X) %% Make a soft evidence matrix logB(j, t) = log p(X(:, t), S(t) = j) % (unnormalized), where S(t) denotes the state of node t. % %% Inputs: % % localCPD - a struct as created by e.g. gaussCpdCreate, representing a % local conditional probability distribution in a ...
43715a8429738e0e37bcaf90496368a1c14a67e0f8129d2451dffa6037e987ec
MATLAB
3,129
122
function save_data(data,fn) % save_data(data,fn) % % where data is the structured variable containing % amplitude and phase (*.paa) % Saves calculated boundary data. Automatically determines type of data % check if the user reversed the inputs if ischar(data) temp = data; data = fn; fn = temp; end % SPE...
fe8a44f92d907255396eb530cdebc524e0cd6c22595c5f0124d79b541fe37199
MATLAB
3,131
81
%% Converting a tensor to a matrix and vice versa % We show how to convert a tensor to a matrix stored with extra information % so that it can be converted back to a tensor. Converting to a matrix % requies an ordered mapping of the tensor indices to the rows and the % columns of the matrix. %% Creating a tenmat (tens...
1d878f8c3e907873d5528e0da8daac46281d8b0fa07cc835875979cd6cb6566e
MATLAB
3,132
97
function varargout = mat2xml(matfile, xmlfile) %MAT2XML Convert a MAT-file into an XML file % MAT2XML(MATFILE, XMLFILE) loads MAT-file MATFILE and converts it % into an XML file saved in XMLFILE. % T = MAT2XML(MATFILE) also converts the MAT-file MATFILE to XML % but returns it instead as an XMLTree object T. % % ...
4fd0a9326774e5281236562529b2d32b77d7c71109d208f11b0ac50768e21eef
MATLAB
3,132
72
[Patterns] = extract_variables ('ICA_results',[],resultsPath, 'Patterns',[],conditionType,conditionValue); [int_id,pyr_id] = extract_variables ('nCells',[],resultsPath, 'int','pyr',conditionType,conditionValue); int_weights = zeros(1,size(Patterns,2)); pyr_weights = zeros(1,size(Patterns,2)); int_weights_clust_rec =...
ed181a6c1d81ee2d07cabc6134b137dbf34934ce20e5f86d6b8881b6fb95ce67
MATLAB
3,132
103
function H=w_PlotEdge(Matrix, ElementLabel, ... HigherOrderNetworkIndex, HigherOrderNetworkLabel,... ColorMap) LineWidth=2; LineColor=[0, 0, 0]; NumNode=size(Matrix, 1); if ~isempty(HigherOrderNetworkIndex) && NumNode~=size(HigherOrderNetworkIndex, 1) errordlg('Invalid Length of HigherOrderNetworkIndex')...
96ef6af9ca1f5c6a3ba7770d8595172e946fd161dcfac6f7daee4254c8b5487b
MATLAB
3,133
110
function boundaries=compute_boundaries(faces) % compute boundaries of a mesh % % boundaries=compute_boundary(faces); % % faces: triangulation % boundaries: cell array containing ordered list of vertices for each % boundary % % based on function by Gabriel Peyre, modified to deal with mu...
a6d0aa92f0e2e69b514688271ee701672c8bce8f494d57dc2dde0b42cfcd5457
MATLAB
3,134
97
function error_DG = measure_round_alignment_mExR(params,fov) % Calculate's registration error (in nm, in post-expansion units) of % registered image volumes using the method for ExSeqProcessing by Dan Goodwin % from Alon et al., Science 2021 %extract parameters parentfolder = params.parentfolder; rounds = params.round...
06c2b93b8f20a7aec7bbea39bd1be83108aaa21078545ef0af38ae4412b6f714
MATLAB
3,136
100
%% Analysis of binomial differences on lefthand/righthand data % PMTKneedsStatsToolbox ksdensity %% % This file is from pmtk3.googlecode.com clear all requireStatsToolbox setSeed(0); y1 = 9; n1 = 52; y2 = 4; n2 = 48; %sf=1; %y1 = 1*sf; n1 = 50*sf; y2 = 25*sf; n2 = 50*sf; [deltas, post, thetas] = contingencyTableUnpair...
27a1024b277bfdf2f2036e8af4585ed8cbab69f040544e838b274b9dc63dfafe
MATLAB
3,136
115
function [source] = estimate_fwhm2(source, maxdist) % ESTIMATE_FWHM2(SOURCE, MAXDIST) % % This function computes the Gaussian fwhm of the spatial filters, according to % least-squares Gaussian fit including data points up until MAXDIST from the % locations of interest. % % This function can only deal with scalar filt...
9d01f4b95656da2b57396854a1063e7e29adb9f4c03b150f69e1c8fd998a963a
MATLAB
3,136
106
%% initialize % When in each video do you want to begin the mean velocity calculations? % (in seconds) start_delay = 0; yAxisLabel = 'Average velocity (mm/s) '; %% select files [inputFiles] = uipickfiles(); if (start_delay == 0) start_delay = start_delay + 1; end %% read each file and calculate mean veloc...
ab37a8841cc7d4073237fe4e867fd011bfdbbc4a10da7cd240b1ffc7cb9c3a74
MATLAB
3,136
98
%% Plot a Mixture of Gaussians % %% % This file is from pmtk3.googlecode.com function mixGaussPlotDemo() %{ mu = [0.22 0.45; 0.5 0.5; 0.77 0.55]'; Sigma1 = [0.018 0.01 ; 0.01 0.011]; Sigma2 = [0.011 -0.01 ; -0.01 0.018]; Sigma3 = Sigma1; Sigma = cat(3, Sigma1, Sigma2, Sigma3); mixmat = [0....
c8a72d82cf934499ca4cc902d8bae38b1ce6adc9638b3b42f3fb526d2f718517
MATLAB
3,136
84
% This is an example of how to load and display the functional (fMRI) and % structural (sMRI) ICA maps, provided for the 2014 MLSP Competition, using % MATLAB R2011a. % % It also includes an example of how to compute the correlation between the % fMRI and sMRI maps, like was done in reference [2] below. % % This script...
9d675d3af9e54bc1af471017a49281207fff3855a3df1f7a9d34244706e58beb
MATLAB
3,137
63
classdef CBIG_ASDf_unit_test < matlab.unittest.TestCase % Written by Nanbo Sun and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md methods (Test) function test_short(testCase) % create output folder CBIG_CODE_DIR = getenv('CBIG_CODE_DIR'); ...
b456e519d85be9bad6e79537449f3068729bc091ff31f0d3adb84a1b5abda73b
MATLAB
3,137
85
function [mappedX, mapping] = charting(X, no_dims, no_analyzers, max_iterations, eig_impl) %CHARTING Performs manifold charting on dataset X % % [mappedX, mapping] = charting(X, no_dims, no_analyzers, max_iterations, eig_impl) % % Performs manifold charting on dataset X to reduce its dimensionality to % no_dims dime...
becb3afebd0d09d13650d9392e511a0ffbacb4ded90903962e0f7f845c479406
MATLAB
3,137
101
function [tracedtensor] = diagsum(tensor1, d1, d2) % C = DIAGSUM(A, d1, d2) Performs the trace % C(i[1],...,i[d1-1],i[d1+1],...,i[d2-1],i[d2+1],...i[n]) = % A(i[1],...,i[d1-1],k,i[d1+1],...,i[d2-1],k,i[d2+1],...,i[n]) % (Sum on k). % % C = DIAGSUM(A, d1, d2) traces A along the diagonal formed by dime...
fcd18ca32e99ed2af5d5787f12e8fb960855743773c708e637750e1afbfbfce3
MATLAB
3,137
81
function [dfdx, fx] = VBA_numericDiff(fName, idxArg2Diff, varargin) % // VBA toolbox ////////////////////////////////////////////////////////// % % [dfdx, fx] = numericDiff(fname, idxArg2Diff, fArg1, fArg2, ...) % numerical evaluation of derivatives % % This function evaluates numerically the derivatives of the functio...
3a41abec0eb1b9dbc68bb89dfde5eaec9bb192633ae97da23f58be366dfd1053
MATLAB
3,138
106
function [cond_info] = get_conditionInfo_byname(cond_name, srmr_nr) %% return info of the different conditions if srmr_nr == 1 % conditions: % 1 = rest, % 2 = median stimulation, % 3 = tibial stimulation, % 4 = alternating median and tibial stimulation if strcmp('rest', cond_name) ...
ab612bdfe9f553411b6241ba245d6fd2d2aeeb945ec7f6996c9f1c0761d4ea22
MATLAB
3,138
93
function [varargout] = endsWith(varargin) % ENDSWITH True if text starts with pattern. % TF = endsWith(S,PATTERN) returns true if any element of string array S % starts with PATTERN. TF is the same size as S. % % This is a compatibility function that should only be added to the path on % MATLAB versions prior to R...
bca0f7cedcac597f0258788b3c0f301f445b3e7e0fd8d5139bb86b05269bc34b
MATLAB
3,139
133
function show_isa(vi,diags,locs_2D,para); [nchan,nf]=size(diags); kmax=12; kjump=0; reso=50; xf=0:nf-1; nplot=12; compjump=2; myaxis=[]; tf=[]; myxlabel=[]; myylabel=[]; if nargin>3 if isfield(para,'resolution'); reso=para.resolution; end if isfield(para,'kmax'); kmax=para.kmax; end i...
97d73c81134980abc6951726cb66645dc6f533c707d6f78219d5e5764d763b32
MATLAB
3,140
85
function Xr = pcaRandVec( U, mu, vars, k, n, hypershpere, show ) % Generate random vectors in PCA subspace. % % Used to generate random vectors from the subspace spanned by the first k % principal components. The points generated come from the gaussian % distribution from within the subspace. Can optionally generate p...
d45245a8e48c0ac149dc88eeb4f6e74fe18fd1388c50ecd339c141e28e3d08f4
MATLAB
3,141
122
function newmap = bluewhitered_drdt(m) %BLUEWHITERED Blue, white, and red color map. % BLUEWHITERED(M) returns an M-by-3 matrix containing a blue to white % to red colormap, with white corresponding to the CAXIS value closest % to 1. This colormap is most useful for images and surface plots % for computing d...
3447da0ca20557ff287bbf65ab66156175c5ab7625b22451dc9f417e45bcb5e0
MATLAB
3,142
104
function nsz = get_network_size(net_type,im_sz,batch_size,is_ma) % Estimates GPU memory requirement. % net_type is the network type. Eg: 'mdn', 'deeplabcut' etc. % imsz is the image size in pixels. eg [1024,1024]. % batch_size is the batch size. eg. 8 % return the memory size in MB. if is_ma dat_file = fullfile(APT.R...
ef75746c99e60fc7b5304651639c7bbdf3ebda7dd085580b8fee0950ade3860e
MATLAB
3,142
132
clear; clc; % close all; %% hist_data = []; n_subjects = 8; load ach_data_final.mat load x_ecog_rt_data.mat; srate = 400; %% all_rt_data = []; for isub = 1:n_subjects load(['s' num2str(isub) '_cho_method_allperiod_v1.mat']); rt_data = subj_rt_data{isub}; start...
a55e5cdaf0d5c1429779f00eb7d524d2409834cd082dd2ad7967d2a5e24c9bbd
MATLAB
3,143
107
addpath('../matlab_data/Simple-Brain-Plot-main/'); % %location to save the data. Note subject IDs will be appended to the end % saveLoc='../figures/'; % % %create folder if it doesn't exist % if ~isfolder(saveLoc) % % mkdir(saveLoc); % % end %load in the plot specifications load('../matlab_data/plotSpe...
b56ed873a1770e3d149f6d0af0c9dad226077c18ba4ee2a914e71bf294701e7f
MATLAB
3,145
102
function model = mlpFit(X, y, varargin) % Multi-layer perceptron for classification and regression %% INPUTS: (specified as name value pairs) % nHidden ... Number of hidden units. Can be a vector. % regType ... 'L1' or 'L2' or 'none' % nclasses ... the number of output classes % lambda ... regul...
b70922a323a3c4ae1b23ff441009236708c651b29707dcde32ac10b8ce04d4af
MATLAB
3,146
107
addpath('../matlab_data/Simple-Brain-Plot-main/'); % %location to save the data. Note subject IDs will be appended to the end % saveLoc='../figures/'; % % %create folder if it doesn't exist % if ~isfolder(saveLoc) % % mkdir(saveLoc); % % end %load in the plot specifications load('../matlab_data/plotSpe...
fa4930b03d151470f7283cf352f9ce0caa0276cad2dcbd8a8b9da7d36af5ff58
MATLAB
3,148
89
% Calculate cosine similarity between random projections in state space load(fullfile(saveLoc, 'mediation_randProj_gauss'), 'randProj') numPerm = size(randProj{1},1); cosine_sim_rand = nan(8,numPerm); for sess = 1 : 8 for n = 1 : numPerm - 1 w1 = randProj{sess}(n, :); w2 = randProj{sess}(...
4240be24ae14f5b43ed690ba04a64195f844ce14080756239ba2a512a432c827
MATLAB
3,150
91
% trim_dat_all allows the user to remove intervals from the binary files % (amplifier, auxiliary, digitalin, time) from Intan recordings. % Useful in case of unplugs, bad wires, or other mishaps that happen during % recordings. % Pipeline: 1) Copy origial files 2) Set intervals to remove 3) save new % files with int...
8844473fdac85c43f4c92e4eaced1f56e4d0dda700bb0068afc2e82205bd1167
MATLAB
3,150
96
% This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful,...
7715c8a0b1f4fc0f02754dbb669ca5b8d1086b0d4e96a1d5e97c8cdd9f150662
MATLAB
3,151
125
function out = NB_Run(S,vid) %% Unload variables [ t,t_lim,f,div,uprd,uprt,s, ... NEUR,N2M,K,PART,ALPHA,updm,RES,MOV ] = structvar(S); [X,Y] = meshgrid(1:div); N_neur = size(NEUR,1); % UPR tracking UPR = zeros(1,1+N_neur); WB = waitbar(0); clear S; %% Body while t<t_lim && sum(PART,'all') for n=...
e15cd41c97d26bc45f74f5a10911c332487154490d7e10480527fa747c5a5892
MATLAB
3,151
109
function hhh=hline(y,in1,in2) % HLINE add horizontal line on current axes % % function h=hline(y, linetype, label) % % Draws a horizontal line on the current axes at the location specified by 'y'. Optional arguments are % 'linetype' (default is 'r:') and 'label', which applies a text label to the graph near the l...
1fc298af3aca9be377cd4055ac0cb9eeac7a0769054c22bcc9605453791ed6ea
MATLAB
3,152
99
function [hdr, dat] = read_mpi_ds(dirname) % READ_MPI_DS reads all DAP files from a directory containing files or % alternatively a single DAP file and returns it in a simplified FieldTrip % format. The analog channels and spike channels are both returned in a % continuous format. % % Use as % [hdr, dat] = read_mpi_...
57a15e7c850f0e44379953112cc66a1a46f0b2c532fe06599e46609e22adddc0
MATLAB
3,152
104
%% pxTools_matrixRandomWalk() % % Simulate a specified number of transtions, given an input transition % matrix (e.g. Markov), under the assumption of a random-walk % % Generate N_STEPS transitions for N_SIM sets of data; % % NOTE: 'Steps' will be given at the resolution of the transition matrix % (e.g. a mark...
dd0b7c146de1653feae40d48e7d47760267b028a5e7b2c63550707290c141d29
MATLAB
3,152
86
function [e,out] = VBA_designEfficiency(f_fname,g_fname,dim,options,u,flag) % computes the design efficiency for param estimation or model comparison % function [e] = VBA_designEfficiency(f_fname,g_fname,dim,options,u,flag) % This function expects a state-space model of the form: % y_t = g(x_t,P,u_t) % x_t = f(x_t-...
31d409e876d705ad2780495567a513b4c0142cbb379ada31a223f773d9c66b0a
MATLAB
3,153
101
function [bels, logZ] = mrfInferQuery(mrf, queries, varargin) %% Compute sum_H p(Q, H | V) for each Q in queries % %% Inputs % % mrf - a struct as created by mrfCreate % queries - a query, (i.e. a list of variables) or a cell array of queries % %% Optional named inputs % % % sliceCliques [true] if true, factors...
91547acce5b803fd67fb2eff5949b834a2d7c0cc22185d7c666c5249e5c7b1e7
MATLAB
3,153
101
function [tfr,t,f] = tfrsp(x,t,N,h,trace); %TFRSP Spectrogram time-frequency distribution. % [TFR,T,F]=TFRSP(X,T,N,H,TRACE) computes the Spectrogram % distribution of a discrete-time signal X. % % X : signal. % T : time instant(s) (default : 1:length(X)). % N : number of frequency bins (default ...
140ff2fd3152addbbfe8d02ea7eb47c5a4432994d1cdec5b3f1df3cf93677e49
MATLAB
3,154
90
clear;clc;close all; %% 1D data X = -0.02*9.8+0.04*9.8*rand(100,1); y = [-0.00*X,0.016*X,0.004*X,0.016*X]; % add noise % y = y + 1e-4*randn(size(y)); split_ratio = 0.7; num_train_examples = round(size(X, 1)*split_ratio); rand_indices = randperm(size(X, 1)); X_train = X(rand_indices(1:num_train_examples), :); y_train =...
b6d17ff73f1bd7bcd3ddfdb270b8e725d86068d0bcd507f2097db6abe5339fca
MATLAB
3,154
103
function Perm_1tp_Figs2(dataOut,IM,B,params) %% Set parameters if ~exist('B','var'),B=1;end Pth=0.05./B; [NNidx,Tidx,TNidx]=IM2idx(IM); Nnets=max(IM.key(:,2)); NetKey=[[1:Nnets]',[1:Nnets]']; cMap=[1,1,1;0,0,0]; %% Enrichment a=reshape(dataOut.Chi_pval0,[],1);b=reshape(dataOut.Chi_EWpval,[],1); c=reshape(dataOut.H...
5ee000dff0682ead31b3dbd889d56851b6a2e06884716a25013c489b1f0ac2e1
MATLAB
3,155
108
% demo for mixed-effects analysis (2-levels hierachical model) % This script simulates and analyses data under two different hierarchical % models, namely (i) H0: group-mean=0, and (ii) H1: group-mean~=0. % The effect of H1 and H0 onto both the group-mean parameters estimates % (given H1) and the log-Bayes factors (com...
6969793ec390d551e5d9a56884cfbcaaf304c553fa4e93fc5a05d0cae65313e0
MATLAB
3,155
107
function plotsid(t,iflaws,k); %PLOTSID Schematic interference diagram of FM signals. % PLOTSID(T,IFLAWS,K) plots the schematic interference diagram of % (analytic) FM signals. % % T : time instants, % IFLAWS : matrix of instantaneous frequencies, % with as may columns as signal components. % K : dis...
b5c8c479d41ead65b974d52b12fa34fba19f57b6ac992fafaf5191d933dc3ec0
MATLAB
3,155
53
ind = 1; data = dir('/DATAPOOL/ERRORMONITORING/SEM_mri_data/P*'); %% for i = 1:size(data,1) data_func = dir([data(i).folder, '/', data(i).name, '/mri/SEM_', data(i).name, '/nifti/func/run*']); fprintf(data(i).name); for j = 1:size(data_func,1) dir_folder = [data_func(j).fol...
afb7260ee4b469130b567965e34065d0513d0474098a5efb9cb3cc4622af16bf
MATLAB
3,156
106
% MF_SPDIAG Extract diagonal using multifrontal factorization via sparse % apply/solves. % % This algorithm computes each diagonal entry by multiplying from the left % and right by unit coordinate vectors, taking advantage of the sparsity of % each such operation. % % Typical complexity for N = ...
038faec1f11e805b475e0a2de71d608a8d8f3f21f270eda63b5ab02a776fd917
MATLAB
3,157
86
function renumberfile(f,pat,newnum,nz,opt) %RENUMBERFILE Re-number the indices of a series of files. % RENUMBERFILE(NAME, P) renumbers the files matching NAME having an index % following the substring P, using consecutive indices starting from 1. % Wildcards (*) and brackets (see RDIR) may be used in NAME. If P ...
18ddb2c26ebfe8ea0f01f33656f3f518f968bd012cc61a0a8d5713f4fd129f72
MATLAB
3,157
97
function plotall_lan(data,chanlocs,ltime,y_lim) % v.0.0.1 % <*LAN)<] % % Pablo Billeke % LAN_DEF color =[{'blue'},{'red'},{'yellow'},{'green'},{'cyan'},... {'magenta'},{'yellow'},{'black'}];... nbchan = length(chanlocs); if isfield( chanlocs(1), 'electrodemat') electrodemat=chanlo...
e96d4d6f7d295d3a9f099cfed236717fd7b06716cebd7a95a3cea5d8666d6e22
MATLAB
3,158
117
if ~exist('n_ima'), fprintf(1,'No calibration data available.\n'); return; end; check_active_images; for kk = 1:n_ima, if ~exist(['dX_' num2str(kk)]), eval(['dX_' num2str(kk) '= dX;']); end; if ~exist(['dY_' num2str(kk)]), eval(['dY_' num2str(kk) '= dY;']); end; end; if ~exist('wintx'), wintx = []; ...
e5884ca30c3b922c19f600b5feac045ee3c451e9e0399bcf4e3fb0e68142be4e
MATLAB
3,159
119
%% plot_px % % A simple plotter for visually inpecting distributions. % Given an arbitrary number of px values, plot these as overlapping % distributions on the same figure % % INPUTS % - pxData: [N x K] doubles array, summing to ~1 across a dimension, % corresponding to a probability distribution. % - OPTI...
182c2922e2d168da8f87377cb4f91d293705e6589c5e76a6d46326af3e679a5d
MATLAB
3,161
96
function [tfr,t,f] = tfrmmce(x,h,t,N,trace); %TFRMMCE Minimum mean cross-entropy combination of spectrograms. % [TFR,T,F]=TFRMMCE(X,H,T,N,TRACE) computes the minimum mean % cross-entropy combination of spectrograms using as % windows the columns of the matrix H. % % X : signal. % H : frequency smoothing wind...
21cdbe1b724489cd79ab8e5a52baf2a770c559414209f356c83d436b1d650d9d
MATLAB
3,161
32
subjs={ '/m/cs/scratch/networks-pm/pm_denoise/sub-01/sub-01_task-movie_SGdetrend_24HMP-8Phys-4GSR-Spike_HPF.nii' '/m/cs/scratch/networks-pm/pm_denoise/sub-02/sub-02_task-movie_SGdetrend_24HMP-8Phys-4GSR-Spike_HPF.nii' '/m/cs/scratch/networks-pm/pm_denoise/sub-03/sub-03_task-movie_SGdetrend_24HMP-8Phys-4GSR-Spike_HPF.ni...
513e51e1b132f6a673affeb9154d9b3ab9e851077150ebe0e058c96088a43e05
MATLAB
3,161
82
%% sdoAnalysis_ppDataCell_new % Generates a data structure for point-process data ('ppDataCell'), % pre-populated with fields used in the SDO Analysis toolkit. % % PREREQUSITE: None % % INPUT PARAMETERS: % N_TRIALS : A postive integer, corresponding to the number of % independent recording trials/sessions use...
86e40d4ebfaa7f064c953ca6802afed8acaaea7d6dea56ef0baf63c2e1d71f4f
MATLAB
3,161
98
function [dat] = read_wdq_data(filename, hdr, begsample, endsample, chanindx) % READ_WDQ_DATA reads data from wdq files % % Use as % [dat] = read_wdq_data(filename, hdr, begsample, endsample, chanindx) % or % [dat] = read_wdq_data(filename, hdr, 'lowbits') % Copyright (C) 2011, Jan-Mathijs Schoffelen % % This file ...
92bb959db5a9f1c000baf629f47ea0a33f77f37ce7139a3de359c3172ed0a48e
MATLAB
3,161
82
function CBIG_KRDNN_KRR_UKBB(setup_file, num_val_tes, lambda_set) % CBIG_KRDNN_KRR_UKBB(setup_file, num_val_tes, lambda_set) % % This function runs the kernel ridge regression algorithm to predict % behavioral measures for UK Biobank dataset. % % Inputs: % - setup_file % Path of the setup file (.txt file). % ...
ee31aaa2578689f1653272318cae5404d28ae766ff9fda7775487d955662fe1a
MATLAB
3,162
117
function K = fixsigns(K,K0) %FIXSIGNS Fix sign ambiguity of a ktensor. % % K = FIXSIGNS(K) makes it so that the largest magnitude entries for % each vector in each factor of K are positive, provided that the % sign on *pairs* of vectors in a rank-1 component can be flipped. % % K = FIXSIGNS(K,K0) returns a vers...
f9945b1318891453cc097895312fa0068bc2629b68b71d1da0a4625188c69701
MATLAB
3,162
79
function mni2sub(out_path) %MNI to subject's space coregistraion using FSL FLIRT. it requires WSL to work in Windows Systems % %out_path: folder which contains the Pseudo_STATIC PET image. It will be used to store the coregistered images and the transformation matrix % %template_path: folder which contains the MNI temp...
fde3c7ac87b5bfd359265d8021c72042ae6e02c66adeee1c8c8ae2997dff9821
MATLAB
3,162
119
function datadisp(T, dimlabels, opts) %DATADISP Special display of a ktensor. % % DATADISP(T,LABELS) displays the largest positive entries of each rank-1 % factor of T using the corresponding labels. LABELS is a cell array of % size ndims(T) such that LABELS{n} is a string cell array of length % size(T,n). % %...
d0c207e37945f4efc5824de9970586bbb10d72aa74bd5f48893cc3156530fd93
MATLAB
3,163
102
function [muPost, SigmaPost, logZ, lambda] = varInferLogisticGaussCanonical(... y, W, b, muPrior, SigmaPriorInv, varargin) % Use a variational approximation to infer a Gaussian posterior % given a Gaussian prior and a logistic likelihood % % p(x(1:q) | y(1:p)) propto N(x(1:q)|muPrior, SigmaPrior) * p(y|x) % where p...
157d2160357821eb11469843d1c595be60d200a8d2d6ce19431f29fa476637af
MATLAB
3,164
117
function catFAdemo() % Factor analysis with categorical and continuous data % We reproduce the demo from % http://www.cs.ubc.ca/~emtiyaz/software/mixedDataFA.html % This just check the code runs, it is not intrinsically interesting. clear all setSeed(16) % generate data - data is stored along columns not rows! [trainD...
6c258c4f5a727db4a6a432217c357b16f0b8ec9a50fe924a48bd78cb1552f1c5
MATLAB
3,164
70
clear close all clc %% Load atlas % path to MRI template - must include hdr and img files atlas = niftiread('/Users/jstrohl/Documents/20230908 Pipelines for neural data analysis/Dependencies/ATLAS-MICE 2/2011-10-30_MRI-template3.hdr', ... '/Users/jstrohl/Documents/20230908 Pipelines for neural data analysis/D...
2d409b1aa25daafb9c54c45487bc518630aa18963d98179bc7678fd3783bbbd6
MATLAB
3,166
100
function [file] = read_ctf_ascii(filename) % READ_CTF_ASCII reads general data from an CTF configuration file % % The file should be formatted like % Group % { % item1 : value1a value1b value1c % item2 : value2a value2b value2c % item3 : value3a value3b value3c % item4 : value4a value4b va...
84833ce108c5a95c9b2f25a0507e6ad2cd33635194e66eb9d34daa0d5d7327d9
MATLAB
3,166
106
clear; basefolder = fileparts(fileparts(fileparts(mfilename('fullpath')))); codefolder = [basefolder,'/code/utils']; toolsfolder = [basefolder,'/tests/tools']; addpath(genpath(codefolder)); addpath(genpath(toolsfolder)); % [1] setup small test example plotall = false; dataset = [ 0.2, 0.6; 0.233, 0.581; ...
6a894d950363d636bbec37d934f312a0379432980989f4d23b9de52836ba484b
MATLAB
3,167
63
function [spmat] = helm_neu_near_corr(S,zpars,eps) npts = S.npts; npatches = S.npatches; ipatch_id = zeros(npts,1); uvs_targ = zeros(2,npts); norders = S.norders; ixyzs = S.ixyzs; iptype = S.iptype; srcvals = S.srcvals; srccoefs = S.srccoefs; npp1 = npatches+1; n3 = 3; n...
94b0522769b19a49423744d4fdf286e6bbbe792ccdeeb9bd095ff2ea676b9609
MATLAB
3,168
105
%% Generates the figure 6a %% Requires set: % - fn_timing % - res_path % - mapper_name % - CHANGE_POINTS workspace = getenv('WORKSPACE'); fn_timing = [workspace, '/data/cme/timing.csv']; res_path = [workspace, '/results/cme/ch10_mappers_cmev3_disp.json']; mapper_name='BDLMapper_12_30_60'; CHANGE_POINTS = 10; % Get th...
a40d52b03beffbd3140e3a3e9720b0bc5dd9febd36615f384353b967e626edee
MATLAB
3,172
102
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% wrapper_full_calibration.m -- A wrapper for the calibration runtime. %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function []=wrapper_full_calibration(pat_ix, model) pat_cell = {'110411','117122','120...
3cb83b641c4cdf1d72e8a3619ee3fc44b4ce86e1e4e153ca404da9c9ba64cad1
MATLAB
3,173
79
function reprocessRoundFromColorCorr(rounds) loadParameters; if params.DO_DOWNSAMPLE filename_root = sprintf('%s-downsample',params.FILE_BASENAME); else filename_root = sprintf('%s',params.FILE_BASENAME); end %Color Correct from File %fprintf('COLOR CORRECTION:\n'); for rnd = rounds colorcorrection_3D_from...
5ec2a91fd74f0668a43fb87b07c61d73e3d1db5b647a60112fe80e1a732b3cf9
MATLAB
3,173
101
function [EI,Pth,Qthth] = lme_EI(X,Zcols,W,CBhat,SIGMA,L,phi,ni) % [EI,Pth,Qthth] = lme_EI(X,Zcols,W,CBhat,SIGMA,L,phi,ni) % % Expected information matrix for the restricted log-likelihood. % % Input % X: Ordered design Matrix (according to time for each subject). % Zcols: Vector with the indices of the colums of X th...
0d091d8389be957de223d05086e8e942b6bf42e5f0369b77a29e456b61547b72
MATLAB
3,174
82
function N = tangentspherefactory(M, x) % Returns a manifold struct. for the sphere on the tangent space to M at x. % % N = tangentspherefactory(M, x) % % N defines a manifold that is the unit sphere on the tangent space to M % at x. Points are represented as tangent vectors of unit norm. Tangent % vectors are r...
ccf9c6c1757c5195c8ecd59279c7a82bd3bff22e99f027426dac9a0f5b76a6a8
MATLAB
3,175
86
function [Success,ExperimentID,SubID,Phase,Box,MatlabStartDate,... Duration,tsdata,Notes,Weight,Program,FileReportedUnits] = ... TSloadBalsamRaw(filename) % reads Balsam's raw data files, which have text headers followed by a % single column of raw data in which the last 4 digits are event codes, and % the time...
d39601ddbea9c99975eee8d54acf3d51c6223d8f480e7af1adb708f18bf40f86
MATLAB
3,175
163
%% Demonstrate cutset conditioning in cyclic undirected markov chain % Based on http://www.cs.ubc.ca/~schmidtm/Software/UGM/cutset.html % This file is from pmtk3.googlecode.com %% Setup model with a single loop nNodes = 13; nStates = 25; adj = zeros(nNodes); for i = 1:nNodes-1 adj(i,i+1) = 1; end adj(nNodes,1)...
778a3121b5747599ca2214dbb81f77849c3695134c98e9ade9bc3f68d0a323f0
MATLAB
3,176
81
function [actual_phase,fullCycle] = ETP_AutoCorrect_edge(data) % This function adjusts for the bias in the algorithm and returns the best % fullCycle. Bias is a constant variable that is added to the typical cycle % length. bias = 0; bestBias = 0; minError = 100; % A large number to begin with while 1 [actu...
7c6334c91f8041a281b0c260a180efb9eb0c67b294ad156bd21da612203493f8
MATLAB
3,176
78
function h_zoomInByClick3(handles, zoomFactor, syncFlag) global h_img3; if ~exist('syncFlag','var')||isempty(syncFlag) syncFlag = 1; end [currentInd, handles, currentStruct, currentStructName] = h_getCurrendInd3(handles); [x_lim,y_lim,z_lim] = h_getLimits3(handles); currentXLim = get(handles.imageAxe...
a232b0d0d603959ee612567c174748b8cc95f43e3c5ab790456cd71206d6bf01
MATLAB
3,176
94
%% RFR prepare pipeline %This main file will call all the neccessary routines to generate the RFR %results of the publication: "Stimulus-Induced Rotary Saturation imaging of %visually evoked neuroelectric response: preliminary results and data %analysis" (currently under review) % Author: Milena Capiglioni, University...
fc8249c44edb9300fc1420b9204c7bdb85923aaf151618fb34d749c897ec0f68
MATLAB
3,176
90
function data = edf2fieldtrip(filename) % EDF2FIELDTRIP reads data from a EDF file with channels that have a different % sampling rates. It upsamples all data to the highest sampling rate and % concatenates all channels into a raw data structure that is compatible with the % output of FT_PREPROCESSING. % % Use as % ...
7eadff0311877b62292ed293e54397094ce1824b741f830e343bc21764151130
MATLAB
3,177
155
% load movie information [File0, Path0] = uigetfile('*.tif'); info=imfinfo([Path0,File0]); Nz=length(info); Ny=info(1).Width; Nx=info(1).Height; %A=zeros(Nx,Ny,Nz*NTif); %% Load movie and first average movie = zeros (Nx, Ny, Nz); for i = 1: Nz movie (:, : , i) = imread (File0, 'TIFF', 'INDEX', i); end Ref= mean ...
e33bbff98cd425cf497a99bb3ad0ef3272e5f428647125eb562f9e5c887e2b40
MATLAB
3,178
112
function data = PlotIntanData(datDir, varargin) % hard-coded parameters vScale = 0.000195; bytesPerSample = 2; % default values of optional arguments trodeList = -1; chanList = []; timeRange = [0 20]; yRange = [-2 2]; returnData = false; makePlot = true; for i = 1 : 2 : length(varargin) switch lower(varargin{i}...
fbfe97527716b28cc5e3126ee75f27157dc1e0dc0c4f9b633b1e4d659c20ed09
MATLAB
3,178
105
% GetProbMap: create probability map from ImageArray_Max % By running over all pixels in AllBoutonsRegion. % and counting how many times responses occured in each pixel function OneImage_ProbMap = GetProbMapZN_parallel2(ImageArray_Max_Input, AllBoutonsRegion, NumOfIndices,se,StackLimits); ...
64c7aa37b837d86debf6fec202b4625ee242df6f6491ac39cfacba45dab35f55
MATLAB
3,179
84
function ft_preamble(cmd, varargin) % FT_PREAMBLE is a helper function that is included in many of the FieldTrip % functions and which takes care of some general settings and operations at the % begin of the function. % % This ft_preamble m-file is a function, but internally it executes a % number of private scripts i...
6e4ff8bc504fd7bd366c827b5020192494d69d9cdd05608a6d5a1dc38bcf113d
MATLAB
3,180
110
%% Look at relationship between euclidian distance and wire distance mkdir([DIRresults, '/wires/']); clear total_distance all_wires_dist counter = 1; big_counter = 1; every_wires = []; all_distances = []; for z=1:num_groups the_indexes = big_list_indexes{z}; for elect1 = 1:length(the_indexes) ...
94f4362272d7fdcaacc232d8c94391038da5b14aaa7c173f83fedd87a7d54343
MATLAB
3,180
78
%----------------------------------------------------------------------------------------- % Decoding perfromance as a function of decoding time window lenght % % Kehl et al. 2024 (DOI:XX) % Single-Neuron Representations of Odors in the Human Brain % Figure 2d % Author: Marcel Kehl % License: MIT License %----------...
319ebb976635a0b137ca71fd83822edd531c2ea0238417d6c4e218822aa28a3f
MATLAB
3,181
104
function [A,B,out,posterior] = VBA_LinDecomp(Y,k,options) % linear decomposition of a matrix Y % function [A,B,out] = VBA_LinDecomp(Y,k) % This function operates a probabilistic linear decomposition of matrix Y, % as follows: Y = A*B + cst + e, where A and B are unknow matrices, cst is % a constant term and e is assume...
68771d2e7c34444ad8c1c7843f12e7ae0d9bd63a76f7f7e0d723b2f0e44735a1
MATLAB
3,181
121
function [fdiff,fnot1,fnot2] = structdiff(s1,s2,varargin) % [fdiff,fnot1,fnot2] = structdiff(s1,s2,varargin) % % fdiff: cellstr, fields present in s1 and s2 that differ % fnot1: cellstr, fields not present in s1 but present in s2 % fnot2: etc % % Output args apply only to top-level fields. % % Optional PVs: ...
b7241f431a2b799cfcd846f6256795a8abf7b347fd6cddcdbc6df1ab26bdaf57
MATLAB
3,182
82
function [y,iflaw]=fmsin(N,fnormin,fnormax,period,t0,fnorm0,pm1); %FMSIN Signal with sinusoidal frequency modulation. % [Y,IFLAW]=FMSIN(N,FNORMIN,FNORMAX,PERIOD,T0,FNORM0,PM1) % generates a frequency modulation with a sinusoidal frequency. % This sinusoidal modulation is designed such that the instantaneous % frequency...
495d2a027d63de19c615ec8424fd0cf6782f5463b29a3b367440e0527a11a61c
MATLAB
3,183
71
% CREATE NEW CELL ID FOR REMAPPING STRUCTURE % Function to convert each session original cell IDs to a new ID in the % remapping structure.Created to avoid ID repetitions. % New ID structure: YXXX - Y = session ID (1 to 5), XXX - orginal cell ID (e.g. 004, 027, 112) % INPUT: % - method: 'wcorr' (default) or 'spea...
5a99d6ae178b09c0b649f5ed9f814dadb10e5cb8dd492593d8113ba25ba02272
MATLAB
3,183
83
function segmentation = fixsegmentation(segmentation, fn, style) % FIXSEGMENTATION is a helper function that ensures the segmentation to be internally % consistent. It is used by ft_datatype_segmentation and ft_datatype_parcellation. % % % See also CONVERT_SEGMENTATIONSTYLE, DETERMINE_SEGMENTATIONSTYLE switch style ...
c9a6cef643765005938a0ad647b37960bf366791b97d5e57a5d40c1eefc8fd8c
MATLAB
3,183
110
function [posterior,out] = VBA_PRESS(y,u,f_fname,g_fname,dim,options) % Train/test predictive power evaluation for VBA model inversion. % function [posterior,out] = VBA_PRESS(y,u,f_fname,g_fname,dim,options) % This function evaluates the predictive power of any nonlinear state-space % model of the form: % y_t = g( x...
4dccd772392c5e169b394c1868225fdfe086ced2b0c5ab24c3bfdc75d5ba2c43
MATLAB
3,184
99
%% (predictSDO_plot) px_v_x % % A method to visually compare predictions by looking at how the % distributions of the predicted post-spike state line up with the assigned % post-spike state. % Can reveal state-wise prediction behavior % % INPUTS: % 'pdPx1' - Predicted Probability Distribution (Organized as a Mx1 c...
9d7e23c97955c6613ffd5caf6b89b6ff9e9289cf1c6ac23b16044d9fe3f2a36c
MATLAB
3,184
93
%_______________________________________________________________________ % % newTargets sets up targets for erasing and displaying %_______________________________________________________________________ % function targets = newTargets(screenInfo,targets,targetIndex,x_position,y_position,diameter,tcolor) % % targets =...
4c9bef924690b4cb5e8319ea503edd25898f222e70019300ffb0995b169b5db8
MATLAB
3,185
107
%% Look at correlation as a function of distance (GAMMA) corr_data = Low60GammaData(good_chan,(task_data(1,3)-500):(task_data(end,3)+500)); close all clear eucl_distance_all; for z = 1:num_groups z actual_index = big_list_indexes{z}; geographic_mean = round(mean(actual_index)); for q=...
65dc2e381ba7ba471b80220400cab122ba7922e644869af4d75853ae3350398f
MATLAB
3,188
125
function out = AS_Run(S,vid) %% Unload variables [ t,t_lim,f,div,uprd,uprt,s, ... NEUR,N2M,K,PART,ALPHA,updm,RES,MOV ] = structvar(S); [X,Y] = meshgrid(1:div); N_neur = size(NEUR,1); % UPR tracking UPR = zeros(1,1+N_neur); WB = waitbar(0); clear S; %% Body while t<t_lim && sum(PART,'all')...
66ae5e7964ad2c21651819d28bb652897d35ea895b00ef84add0e69c09f26292
MATLAB
3,190
105
function [p,S,mu] = polyfit(x,y,n,w) %POLYFIT Fit polynomial to data. % P = POLYFIT(X,Y,N) finds the coefficients of a polynomial P(X) of % degree N that fits the data Y best in a least-squares sense. P is a % row vector of length N+1 containing the polynomial coefficients in % descending powers, P(1)*X^N + P(2...
9907f0c3cafac7689343ad39a76fc14ddc0f2d5db8115cbcf1e9aa696bcad08c
MATLAB
3,190
118
function indx = iimg_xyz2spheres(xyz, mask_xyzlist, r) % :Usage: % :: % % indx = iimg_xyz2spheres(xyz, mask_xyzlist, r) % % :Inputs: % % **mask_xyzlist:** % is a list of voxel coords of all in-mask voxels % % **xyz:** % is a list of voxels to be convolved with spheres % % **r:** % is sphe...
be8657e6352e2dd2822a44b863ac643d88deea77b450e00147b48d1f246898eb
MATLAB
3,191
168
function LAN = del_epo(LAN, epocas) % Only for simple LAN structur % Delete epoch number [epocas] % % v.0.2 % Pablo Billeke % 24.05.2021 fix compatibility % 23.01.2013 % 16.11.2010 % 16.6.2009 if iscell(LAN) error(' Only for simple LAN structur') end %%%%------- %%%% data epocas = sort(epocas); %,'descend'); ...
96b00f9c8c40f8db1101581f43be797a3da751ab80b42ea9d32802e05fa804af
MATLAB
3,192
132
function [ CONDXY ] = ConditionalHist( X,Y,varargin) %[CONDXY] = ConditionalHist(X,Y) Calculates the conditional probabilty %of Y given X % %INPUT % X % Y % (options) % 'numXbins' (default: 50) % 'numYbins' (default: 50) % 'Xbounds' % 'Ybounds' % 'Xbinoverlap' (default: 1) % 'minX' (default: 25)...
9ef3d8217fbda3b4dc17ecdb8e5e8cc0b481c602709133ea3d1287ffb64f018a
MATLAB
3,192
91
function ydata = tsne(X, labels, no_dims, initial_dims, perplexity) %TSNE Performs symmetric t-SNE on dataset X % % mappedX = tsne(X, labels, no_dims, initial_dims, perplexity) % mappedX = tsne(X, labels, initial_solution, perplexity) % % The function performs symmetric t-SNE on the NxD dataset X to reduce its % d...
525b4d34a2134b23c8625eaa21e0ee0b51f0701e6b26d90c35c4ade762ba2ff2
MATLAB
3,193
102
function M = skewsymmetricfactory(n, k) % Returns a manifold struct to optimize over k skew-symmetric matrices of size n % % function M = skewsymmetricfactory(n) % function M = skewsymmetricfactory(n, k) % % Returns M, a structure describing the Euclidean space of n-by-n % skew-symmetric matrices equipped with t...
8b704cb6c10500ea627245d38041e9e648d6a9d4b287932fa85edf75795d0d9c
MATLAB
3,193
127
function DCM = VBA_spm_dcm_test(DCM) % tests whether DCM parameters are zero using Savage-Dickey ratios % function DCM = spm_dcm_test(DCM) % IN: % - DCM: the DCM structure % OUT: % - DCM: the DCM structure, augmented with field .sdr, which contains the % Savage-Dickey ratios in the same format as DCM.Ep n = size...
0cf6674b61f28e8cc8d8f5c1974f8b3add8878fb6d5ba3f21a1797989ecf9dfe
MATLAB
3,194
130
function vc = get_vizConventions() % get_vizConventions() % this function give the parameters are needed only in visualization (visualization conventions) %% general settings vc.ecnSize_all = [50 76 100 126 150 176 200 300 400]; vc.f2.kecn_id = 3; % network of 100 % vc.f3.sel_ecn_ids = [1 2 3 5 6 7 8]; % this include ...
5e6fdc05367009fbf9a53876959371574222a5de71517159ecdee5a94848309a
MATLAB
3,194
88
function [timelock, cfg] = freq2timelock(cfg, freq) % FREQ2TIMELOCK transform the frequency data into something % on which the timelocked source reconstruction methods can % perform their trick. % % This function also performs frequency and channel selection, using % cfg.frequency % cfg.channel % % After source r...
6862d42474820a7d4efc79cd2c8774183b7b4dc9d9f1039f64c7e14dad9b7c6b
MATLAB
3,194
104
function filteredNoiseIm = makeFilteredNoise2(imSize, contrast, ... orientation, orientBandwidth, ... sfBandLow, sfBandHigh, ... pixelsPerDegree, maskWithAperture, filterSpecial) % function filteredNoiseIm = makeFilteredNoise(imSize, contrast, ... % orientation, orientBandwidth, ... % sfBandLow, sf...
973993786ad05ee057f42367854e88d220540711c2da1306c82266e63a88a368
MATLAB
3,194
102
clear srcinfo ns = 4000; srcinfo.sources = rand(3,ns); srcinfo.e_charge = rand(1,ns)+1i*rand(1,ns); srcinfo.e_current = rand(3,ns)+1i*rand(3,ns); srcinfo.h_current = rand(3,ns)+1i*rand(3,ns); nt = 3999; targ = rand(3,nt); eps = 1e-6; ntests = 6; ipass = zeros(ntests,1); errs = zeros(ntests,1); zk = complex(1.1); nte...
e612aaa128e18b4b009951805b524930b42b27518d10a4456ec0b4dd008c6472
MATLAB
3,194
81
% Evaluate estimated sources based on saved resource after performing otsu % threshold. clear dataset_name = '_sample_source2'; fname = '_sample_source2'; model_id = '75'; gt = load(['../source/Simulation/test' dataset_name '.mat']); % ground truth num_source = size(gt.selected_region, 2); load(['../model_r...