sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
c6e5a37c962b88b6d67cb60a2ad20d8c766f8e25512fcd3e4f45ac71c6950b68
MATLAB
719
18
function checked = check_software_spm5(software) if length(software)>=3 && strcmpi(software(1:3),'spm') try spm_ver = spm('ver'); catch %#ok<CTCH> error('SPM is not in your path!\nPlease add a version of SPM to your path or change cfg.software to another software') end if ~strcmpi(spm_v...
1d4ee6c8e46900370a7a08c0ac19afb7fcebb7f5fa48572679e608430cc6d457
MATLAB
720
19
function msBatchCalcSegRelations(dirName,calcCorr, calcDist, calcOverlap) %MSBATCHSEGRELATIONS Summary of this function goes here % Detailed explanation goes here dataFolders = msBatchFindDataFolders(dirName,[]); parfor folderNum = 1:length(dataFolders) currentFolder = dataFolders{folderNum}; ...
72736a260054630db8f2754b4ea7133e225adb91fcc532f9d3435bf1dbc720bc
MATLAB
720
22
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Authors : CHATENET Louis % Date : 24/05/2018 % Version : V1.0 % % Description : GABAa current calculation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [Isyn, r, T] = IsynGABAa(dt, Vpre, Vpost, rpre) ...
34a108172b9df137f3e5b3666225b6c542646fdbea179d7687dedf9d61a48882
MATLAB
721
24
function [newpat] = apply_detrend(pat, varargin) % Detrend a pattern. % % [NEWPAT] = APPLY_DETREND(PAT, ...) % % Detrends a pattern. Used in conjunction with apply_to_runs.m. % License: %===================================================================== % % This is part of the Princeton MVPA toolbox, released und...
5d9a18bbc0d0c51a7b59d78e7fd239a78503d9f13ab61e1b1442ac9ba2d22425
MATLAB
722
34
function [ phi ] = RF_phase_cycle( N, arg2 ) % RF_phase_cycle(N, args) Supplies phase cycling pattern to EPG code % % SPGR: phi = RF_phase_cycle(N,Phi0) % N = number of RF pulses % Phi0 = (quadratic) spoiling phase increment DEGREES % % balanced: phi = RF_phase_cycle(N,'balanced') ...
bcd1717f07ec93de6725fd3f43c7e3a7cd2e90c240b5ba7e3395a4d56bcf8ccb
MATLAB
722
21
function smart_save_figures(fig, params, title_suffix) % create desitnatoin folder where the figure will be saved if this % folder does not exists already if ~exist(params.folder) mkdir(params.folder) end % save the figure ion a png format p = [params.folder filesep [params.prefix '_' t...
0584b68132a2658548927bf832b3cbbd89fb2c08b06a7818602d7e78c12f6f7b
MATLAB
723
31
% @author Farad Khoyratee % @date 16 Apr 2019 % @copyright % SPDX-FileCopyrightText: © 2021 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later function LoadSim = LoadSim(i, Imax) LoadSim = (i*100)/(Imax-1); switch LoadSim case 10.0 disp('10%')...
5666ad7e6b8577599e72e7d4bb39816f4410aabef2bed1d6ef5b92893bd7ada1
MATLAB
723
36
function ft = FirstTime(O, TimeUnits) % First time of the intervalSet % % USAGE: % ft = FirstTime(is, TimeUnits) % % INPUTS: % O - an intervalSet object % TimeUnits (optionnal) - a units object or the abbreviation string % % OUTPUTS: % ft - the first time of the intervalSet % copyright (c) 2...
b91d7d3a84a9412f785989fa9070c25837e86623e8d1d553357699764190bbeb
MATLAB
723
29
function [b] = bivar(x, kappa, dim) %Compute biweight midvariance across dimension dim %Implementation according to Wilcox; Robust Estimation %and Hypothesis Testing (page 93-96) if nargin<3, dim = find(size(x)>1, 1, 'first'); end if nargin<2 || isempty(kappa), %this is supposed to be a good value for kappa ka...
c515c93140d29cb37d2417bc51f0efb32c90a31a2b4968f0a219f5664005a6d3
MATLAB
723
37
%% Log Likelihood Function function [logF, dlogF] = VMMix_logF(data, b) % parse parameters mu = b(1); k = b(2); p1 = b(3); p2 = b(4); p3 = b(5); % logF f = VMMix_f(data, mu, k, p1, p2, p3); % dlogF/dmu dfdmu = VMMix_df_dmu(data, mu, k, p1, p2, p3); dlogFdmu = sum(dfdmu./f); % dlogF/dk dfdk = VMMix_df_dk(data, mu, k,...
224a453ca6a6d84279f47ca355bfd1d42345902114352765f6352eaeda5903c3
MATLAB
724
34
function L = CrossValidationPeerCheck(S,Q,ep) nbEp = 10; epV = regIntervals(ep,nbEp); L = zeros(nbEp,1); weights = zeros(size(Data(Q),2),nbEp); for ii=1:nbEp ix = (1:nbEp); ix(ii)=[]; testEp = epV{ii}; trainingEp = epV{ix(1)}; for jj=1:nbEp-2 trainingEp = union(trainingEp,epV{ix(jj)}...
7ae229b8aca02cdb4230381c09b9637f3ba9cd2cda3e3b5256cff1fc28a737b2
MATLAB
724
26
function save_log(Experiment) % Save Log Files % Input: Struct 'Experiment' with fields 'Subject' % Output: (1) .mat file with table 'Log' (concatenated tables from % Subject.Log) and stuct 'Experiment' (Stimulus data is % removed before saving to reduce file size) % (2) .xls fi...
ef6161872f0fd3cb341e0e9ca728f36e969ca2dc7c16b0a33af93b7722c6fd70
MATLAB
724
26
function net = convertoldnet(net) %CONVERTOLDNET Convert pre-2.3 release MLP and MDN nets to new format % % Description % NET = CONVERTOLDNET(NET) takes a network NET and, if appropriate, % converts it from pre-2.3 to the current format. The difference is % simply that in MLPs and the MLP sub-net of MDNs the field AC...
13b7f189e986c6be9c866f78a664b3ed8f241dfcb5319763ed3090fc68193126
MATLAB
725
21
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Authors : CHATENET Louis % Date : 24/05/2018 % Version : V1.0 % % Description : NMDA current calculation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [Isyn, r] = IsynNMDA(dt,Vpre, Vpost, rpre) ...
e4038778244e78b7fb33d3b338551d0e1ff61b5dfb99839b0dbc3962b0d36a96
MATLAB
725
29
function [ gx,dgdx,dgdP ] = g_softmax(x,P,u,in ) % softmax decision rule for Q-learning (2-armed bandit task) % function [ gx,dgdx,dgdP ] = g_softmax(x,P,u,in ) % IN: % - x : Q-values % - P : inverse (log-) temperature and bias % - u : [useless] % - in : [useless] % OUT: % - gx : P(a=1|x) % inverse tempera...
8a8e264d7d41aebc34a12e2553824a38dca56cad3b117a1618b0043f45f4f72d
MATLAB
726
30
% Cost function % % Cost function present in the Matlab Help for fminunc function function [f,g] = costfunction(x) % BROWNFG Nonlinear minimization test problem % % Evaluate the function n = length(x); y = zeros(n,1); i = 1:(n-1); y(i)=(x(i).^2).^(x(i+1).^2+1) + (x(i+1).^2).^(x(i).^2+1); f=sum(y); % Evaluate the ...
a8225b1737a0094c88cd2a954f15624f8f82d2840d79b04551432b7de6face8e
MATLAB
726
27
function [xf] = generate_alpha_damped_sin( dt, T, frequency, tau, phase_angle ) % *WAVE* % % GENERATE ALPHA DAMPED SINE WAVE TEST DATA generates a simple test damped % sine wave for use with the % functions in WAVE...
bf7ef89601d4685c3cb03c4b071c886d336ea91e9c0380852fc232160617788a
MATLAB
726
22
function pSVR_save_temp(sub_id, p, predictions, results, suffix) % function pSVR_save_temp(sub_id, p, predictions, results, suffix) % % Save temporary result file during ongoing analysis. Variables include: % - sub_id: ID of the current subject. % - p: Structure with analysis parameters. % - predictions: Structu...
36f617b1fe5e47462eac9a72c9d12bff6a5258e8751bfd6e4a55cd436d47c8f0
MATLAB
728
28
% function out = cov2(x,y) % % Unlike cov(x,y) it assumes that x and y columns belong to pairs, i.e. we % calculate a quadrant of cov([x y]), equivalent to corr(x,y) for % correlations. cov(x,y) would calculate cov(x(:),y(:)). We always % calculate the sample covariance. % % 2015/04/15 Martin Hebart function...
a43cbd34a0aaf20e1cb2a10ebcfbc4794f81bf7cecc2502aa6e0569961d285b2
MATLAB
728
42
function R = Range(tsa, tsflag) % Returns TSD timestamps % % USAGE: % R = Range(tsa) % R = Range(tsa, tsflag) % % OPTIONS: % tsflag - if 'ts' returns time in timestamps (default), % if 'sec' returns time in sec % if 'ms' returns time in ms % ADR % version L4.1 % status: PROMOTED % v4.1 28 oct 1...
fd321d27f2c913b1b06f15ca4939113207bdef13a058d1aba82ea8a887051d9a
MATLAB
728
25
% function r = correl(x,y) % % Custom made correlation function, faster than Matlab versions, but less % general (e.g. only for 1D x and y). If you want another 2-6x or more % speed-up, download and compile fastcorr from file exchange and replace % the content of this function with a direct call to fastcorr(x,y)...
687ce5cbbe96eb64b4480344ed288b59043efe4d39be5d2e1c8d94c461a3cdef
MATLAB
729
30
getREM = 0; load(fullfile('Data','BehavEpochs')); load(fullfile('Data','SpikeData'),'S'); [~, foldername, ~] = fileparts(pwd); if getREM == 1 load(fullfile('Sleep',[foldername '.SleepState.states.mat'] )); % get REM episodes rem = SleepState.ints.REMstate; remDur = sum(rem(:,2) - rem...
ea4dbe7aa4352a2fd5b31e9e1d8d2e190d79f4238e4d4ad7af27e27c6115af89
MATLAB
730
32
function [S,ix] = Start(O,tsa) % Returns subsets of an intervalSet to which timestamps belong to % % USAGE: % S = Restrict(O, TimeUnits) % % INPUTS: % O - an intervalSet object % tsa - a tsd or ts object % TimeUnits - a units object or the abbreviation string % % OUTPUT: % S - an intervals...
686e15e7fc8cd5afb5a03caf7795c3bc11fba1dd07be395f8c1f74bd9eb74499
MATLAB
731
31
%% Gloor SSFP function 23-5-2017 % from Gloor, M., Scheffler, K. & Bieri, O. Quantitative magnetization transfer % imaging using balanced SSFP. Magn. Reson. Med. 60, 691–700 (2008). function Mss = ssSSFP_Gloor(alpha,b1sqrdtau, TR, T1x,T2,f,ka,G) M0a = (1-f); M0b = f; kb = ka * M0a/M0b; R1a = 1/T1x(1); R1b = ...
374ba91364642efa0bba2248dba477636d35bf1990867515904fae692fb02fcd
MATLAB
733
29
function [e, varargout] = neterr(w, net, x, t) %NETERR Evaluate network error function for generic optimizers % % Description % % E = NETERR(W, NET, X, T) takes a weight vector W and a network data % structure NET, together with the matrix X of input vectors and the % matrix T of target vectors, and returns the value o...
7ff5162e694ec638727afea841b2a9d02fd39333cd3ded2613e72da54ab33543
MATLAB
733
32
% trials is channels x time x trials % for continuous recording where data is time x (chn x cond x chromophore) % for new SD, should cut down from 324 to 270 channels function [data,varargout] = selectRS_cnt(data,isSDNew,mlList,mlActAuto) numConds = 3; if isSDNew % yes you can automate this list but too laz...
dba03ab83806b5ef07c89c6833fa73c72386e6af46ff7bc0b38d73ff2b1d2be0
MATLAB
733
26
function bfca = pSVR_load_bfca(p) bfca_temp = zeros(numel(p.subjects), p.psvr.n_tr, p.psvr.n_perm + 1); for i_sub = 1:numel(p.subjects) % Get subject ID sub_id = p.subjects(i_sub); % Get subject ID as string sub_str = num2str(sub_id,'%02i'); % Load reconstruction results bfca_file = dir(ful...
1d8d2b2282790bdae56dad8257f9fe157502c653fcab7529f188508cd37843bf
MATLAB
734
24
function mri_preprocessing(p) % Run a number of preprocessing steps on the fMRI data. The analysis is % based on realigned (but otherwise raw) data, so this is the only % essential preprocessing step for the analysis. We also run coregistration % and segmentation to estimate transformation-fields from MNI to subject %...
9ec529e4366bbdf9b6a5894cf4f5a3aa213226742de2b36d7937fa1e3e9206e6
MATLAB
735
32
function [xo] = bandpass_filter(x, f1, f2, filter_order, Fs) % *WAVE* % % BANDPASS FILTER filter a datacube between frequencies f1 and f2 % % INPUT: % x - datacube (r,c,t) % f1 - low-frequency cutoff % f2 - high-frequency cutoff % filter_order - filter order (N.B. doubled for forward-reverse filter) % Fs - sampling ...
ba06345844f6bd694c8869e25f616cb926294dd758406048dbff855a93403a49
MATLAB
735
17
function output = transres_RSA_dist_corr(decoding_out,chancelevel,cfg,data) % function output = transres_RSA_dist_corr(decoding_out,chancelevel,cfg,data) % % Calculates the correlation between all datapoints of the full datamatrix. % % 2013 Martin H. warningv('TRANSRES_RSA_DIST_CORR:DEPREC',... ['The ...
5b4bd22c311b74d14f052713670f46e3da438d17891e006cab8de65e3576306f
MATLAB
736
17
% This function call is deprecated. % % Because this function does not prepare a decoding, but describes the % data, it is now called decoding_describe_data.m. % Otherwise nothing changed. % % For convenience this function calls decoding_describe_data() for you. % % See also DECODING_DESCRIBE_DATA % functio...
cb09723caa4a32ec568b02b274c19d801d3ae51326b1895b13a8c2e465c9d5a2
MATLAB
736
28
% for continuous recording where data is time x (chn x cond x chromophore) % this is only for sbj 08 and 10. To convert old SD to new SD % should cut down from 378 chns to 324 chns function [data,varargout] = convert2SD2_cnt(data,mlList,mlActAuto) numConds = 3; % list of both LS and SS chns to remove, 42 to 36 chns ...
2c62af10eca142cd2c423c972fc6951837e3832e8c0af29f30f2ae313f68c273
MATLAB
737
20
function decoding_out = ensemble_balance_test(labels_test,data_test,cfg,model) switch lower(cfg.decoding.method) case 'classification' [predicted_labels, decision_values, opt] = ens_bal_te(labels_test,data_test,model,cfg); %#ok<*ASGLU> case 'classification_kernel' [predicted_l...
4ca904c3bff05251270d187e6d5f2f6ccfeb69cf06df2d7c7911df99a8fde667
MATLAB
737
31
function [xo] = analytic_signal_fir( x ) % *WAVE* % % ANALYTIC SIGNAL FIR returns the analytic signal representation % using FIR filter implementation % % INPUT: % x - datacube (r,c,t) % % OUTPUT: % xo - output datacube % assert(ndims(x) == 3,'datacube input required'); [dim1,dim2,dim3] = s...
70301db4217a091b64535b9a58ac81c37512f5bcaf25e162e84e5061341364cf
MATLAB
738
28
% run all level1 runwise all classes % add path to this script addpath('/home/kai/haxby01_scripts_etc/scripts'); % add path to spm addpath('/analysis/kai/spm/spm12b'); spm fmri %% runjob = 1 %% for sbj = 1:6 clear matlabbatch % get design matlabbatch = level1_ruwise_all_classes(sbj, 0); % est...
3bd89698eaeae577024eb6b196f4be1b4e1999aa2715e2aa670f797be594549d
MATLAB
739
23
function varargout = read_voxels_spm8(varargin) % read_voxels: % inputs: header, coordinates (n x 3 (XYZ)) % output: 1 x n vector of voxel values hdr = varargin{1}; x = varargin{2}(:,1); y = varargin{2}(:,2); z = varargin{2}(:,3); if nargin >= 3 % if subvolumes in 4D file should be selected...
4a0558da64828d53974bb4bf37c111463279887a5163cc504a6c2d0057a08592
MATLAB
739
22
clc clear resultPath1='/disk1/dan/di2/cascade_train_history/baseline_PMVS/collected_points_eval_0.75/TotalStat_binary.mat'; x1=load(resultPath1); resultPath2='/disk1/dan/di2/cascade_train_history/baseline_PMVS/collected_points_eval_0.5/TotalStat_binary.mat'; x2=load(resultPath2); resultPath3='/disk1/dan/di2/cascade_tr...
4bbd0d1b19b7e2257d1fac3c282274be75c66b41a4254d3d1d34fdd8086e8d35
MATLAB
739
18
function checked = check_software_spm8(software) if length(software)>=3 && strcmpi(software(1:3),'spm') try spm_ver = spm('ver'); catch %#ok<CTCH> error(['SPM is not in your path!' char(10) 'Please add a version of SPM to your path or change cfg.software to another software']) end if ~s...
5b0d96d172bdbecf9ab05d67aaa938486e9ac1f6e101c6591395f2d85632deda
MATLAB
739
26
function [PNN_matrix,res,loc] = dominateset(aff_matrix,NR_OF_KNN); %[res,loc] = maxk(aff_matrix, NR_OF_KNN, 2 ); %inds = repmat((1:size(loc,1))',[1 size(loc,2)]); [A,B] = sort(aff_matrix,2,'descend'); res = A(:,1:NR_OF_KNN); inds = repmat([1:length(aff_matrix)]',1,NR_OF_KNN); loc = B(:,1:NR_OF_KNN); PNN_matrix1 = z...
947970ad43162c1925891b244a295a1ab497b67941cec014b69bd0a512dd7d05
MATLAB
739
37
%% Super Lorentzian, interpolated as in Gloor et al, 2008 % return LUT interpolated from -1kHz to +1KHz % Units of G are us (microseconds) function [ff,G] = SuperLorentzian(T2b) %%% define frequency range n=512; ff = linspace(-30e3,30e3,n); %%% compute G for this range G = zeros([n 1]); for ii=1:n G(ii) = SL(ff...
a8594b252a8f372710566abc7a7481c43a8027feb7a30491752891910808bdf8
MATLAB
739
29
function [ A12,A22,P1toP2 ] = MouseBOT_LinkConfigurationValues(A1,A2,L0,L1,RobotPosition) P1 = zeros(2,1); P2 = zeros(2,1); P3 = zeros(2,1); P1(1,1) = L1 * cos(A1) - (L0/2.0); P1(2,1) = -L1 * sin(A1); P2(1,1) = L1 * cos(A2) + (L0/2.0); P2(2,1) = -L1 * sin(A2); P3(...
e24b58ef0dc33cae4c6fd7b8a28ba4a9b7bf569e484de0590b406a95fa19f72f
MATLAB
740
23
function varargout = read_voxels_spm12(varargin) % read_voxels: % inputs: header, coordinates (n x 3 (XYZ)) % output: 1 x n vector of voxel values hdr = varargin{1}; x = varargin{2}(:,1); y = varargin{2}(:,2); z = varargin{2}(:,3); if nargin >= 3 % if subvolumes in 4D file should be selecte...
1220d78be67790558044e6764beb87a8ea8f056e3324f215fc82beb94966d14b
MATLAB
741
21
function msBatchExtractBehavior( dirName, trackLength) %MSBATCHEXTRACTBEHAVIOR Summary of this function goes here % Detailed explanation goes here dataFolders = msBatchFindBehavFolders(dirName,[]); for folderNum = 1:length(dataFolders) currentFolder = dataFolders{folderNum}; dirData = dir(curre...
1721df370684515df862bafb6d6b0cc5c92bc3064f91623490e5d045fe2a70f6
MATLAB
741
28
function sliderMoving_spotsthresh global thresholds global sizes global sigmas global framenum global slice global text_threshold global text_size global text_sigma global text_timepoint global text_slice global text_spot_num global I global wholestack global ax set(text_threshold,'String',['threshold ...
258b4c33947e6a0cb5e0a1baeb26e5eae88dcbf1b391ba6e52fe5ed5e4825ca6
MATLAB
741
23
function varargout = read_voxels_spm12b(varargin) % read_voxels: % inputs: header, coordinates (n x 3 (XYZ)) % output: 1 x n vector of voxel values hdr = varargin{1}; x = varargin{2}(:,1); y = varargin{2}(:,2); z = varargin{2}(:,3); if nargin >= 3 % if subvolumes in 4D file should be select...
00be46c9a22195291673e21ced65396f459d8074ec937ef7b0de7e89915ebbc7
MATLAB
743
25
function s_model = init_model(analysis_folder) %% CREATION OF THE STRUCTURE WHO COLLECT EVERYTHING s_model = struct(); % ANALYSIS PARAMETERS ON THE OUTPUTS (main_structure : s) % step1 s_model.figure.savepng = 1; s_model.figure.savefig = 1; s_model.figure.closefig = 1; s_model.debug.mode = 0; s_model.debug.folder =...
63b3c63a52122f33cb3754bdcd23d24d57d6e0494818b88dba1653d5d078e1b7
MATLAB
743
26
% @title Ornstein-Uhlenbeck process to mimic synaptic noise % @file OUproc.m % @author Farad Khoyratee % @date 22 Feb 2018 % @copyright % SPDX-FileCopyrightText: © 2018 Farad Khoyratee <farad.khoyratee@gmail.com> % SPDX-License-Identifier: GPL-3.0-or-later % % @details % > **22 Feb 2018** : file c...
7a9b70b60dfa9c56648e36d0eea4fbc80aedb22b2d00de0def9cecce41e6f46a
MATLAB
743
41
function [Qns] = computeQnsFromGivenNetForNewData(Y, net) if isempty(net) error('net obejct is invalid') end Ycell = Y; Y = cell2mat(Y); psii = net.hparams.psii; Xm = net.hidden.Xm; Lm = net.params.Lm; Xcov = net.hidden.Xcov; Lcov = net.params.Lcov; n = size(Y,2); p = size(Y,1); s = size(Lm,2); stran = net.params....
98c46a935a442031a859bcd3f57e12c812a5ed70956b95ccb89b2473b4b004cc
MATLAB
744
23
function varargout = read_voxels_spm8b(varargin) % read_voxels: % inputs: header, coordinates (n x 3 (XYZ)) % output: 1 x n vector of voxel values hdr = varargin{1}; x = varargin{2}(:,1); y = varargin{2}(:,2); z = varargin{2}(:,3); if nargin >= 3 % if subvolumes in 4D file should be selecte...
05f935c603b4f42aad4f327d2c484e416fd767d31b1427afb869378919c37722
MATLAB
746
26
function [S1,S2,S3,M]=Demod(X0,X1,X2,phasex0,phasex1,phasex2) %This function solves the linear equation system for HELM % % Reto Fiolka, 17.07.2007 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% X=[X0; X1; X2]; i=sqrt(-1); m=2; M=[m exp(i*phasex0) exp(-i*phasex0); m exp(i*phasex1) exp...
3b0b57f0b68c128dd684f64a8a16b6f7eb556335fcd8a5c27f820ed8c627022d
MATLAB
747
20
function msBatchSelectPropsForTracking(dirName) %MSBATCHSELECTPROPSFORTRACKING Summary of this function goes here % Detailed explanation goes here dataFolders = msBatchFindBehavFolders(dirName,[]); for folderNum = 1:length(dataFolders) currentFolder = dataFolders{folderNum}; dirData = dir(curr...
82a7045a76a56a9f5c985d4fc30db772f77daf41c64e46c182fb2b442b2c53eb
MATLAB
747
24
function X = squeeze1(X) % Like squeeze but prevents unwanted transposes. This deals with % cases where e.g. size(X) = [1, 1, 20] and size(squeeze(X)) = [20, 1] % whereas size(squeeze(X)) = [1, 20] would be desirable. The latter case is % relevant e.g. in leaveout cross-validation where the first dimension is % the sam...
91c85f5c84d40bc93540fc300fc38c1708a7c7e8e55b4d21088db44aa128d8bb
MATLAB
747
20
function BN2brainmap(brainmeasure,mask_path,output_name) % V = spm_vol(fullfile(filesep,'Volumes','menon','projects','jinliu5','2021_Longt_math_gene','data','imaging','roi','Reslice_BN_Atlas_246_3mm.nii')); % V = spm_vol(fullfile(filesep,'oak','stanford','groups','menon','projects','jinliu5','2021_Longt_math_gene','da...
0de845866694e9934ed4fc4bd1be7907bd0ff36e6c6ad37d81737141cb246feb
MATLAB
748
40
function [dataout, B_PE] = filterExponential(tau, dt, datain, sines, delay) if ~exist('delay','var') delay = 0; end tt = (0:dt:(tau*5 + delay))'; if tau ==0 % Add a delay B_PE = zeros(size(tt)); B_PE(end) = 1; else % Filter and add a delay B_PE = exp(-(tt-delay)/tau); B_PE(...
00e8b5a0c235ac9c9db0503d1b401513e961152f1a514130881d4e1f24b1f090
MATLAB
749
30
% % report time in experiment % clear all; CMBHome_path = "/comp_neuro/Software/Github/CMBHOME_github/"; addpath(CMBHome_path); load filenames; load tetrodes; load cells; file_number=15; load(filenames(file_number)); root.cel = [tetrodes(file_number),cells(file_number)]; ts_per_sec=50; % timesteps per second ms_per_ts=...
21a99ebfdf07f7823346a5010bb409fd4966aa0974997d08721927de37cc45d7
MATLAB
749
18
function output = transres_RSA_dist_euclidean(decoding_out,chancelevel,cfg,data) % function output = transres_RSA_dist_euclidean(decoding_out,chancelevel,cfg,data) % % Calculates the euclidean distance between all datapoints of the full % datamatrix. % % 2013 Martin H. warningv('TRANSRES_RSA_DIST_CORR:DEPR...
5c9657d24c6b8b1082b45531b65189fbb419dd08d05d12b336da5a6ed9a33588
MATLAB
749
32
function ep = LoadDatEpoch(varargin) % % ep = LoadDatEpoch(epname) % or % ep = LoadDatEpoch(fbasename,epname) % if you need to specify the path to merged folder %Adrien Peyrache, 2012 if length(varargin)==1 epname = varargin{1}; fbasename = []; elseif length(varargin)==2 epname = varargin{2}; fbasename = [vararg...
33bf3347ba4231fc83bf0490651180d74292c55a296c8b8f130ec4c2474d5f0a
MATLAB
750
34
function UnitTestsAll() global cfg t1 = tic; setNamespace('Homer3') UnitTests_Init(true, true, 'UnitTestsAll'); cleanupObj = onCleanup(@()userInterrupt_Callback(true)); cfg.SetValue('Regression Test Active','true'); cfg.SetValue('Include Archived User Functions','Yes'); cfg.SetValue('Default Processing Stream Styl...
adedf24ebb9dd9cf1ed5954a080afd14ff64b2bc809398369251da4c688d8aff
MATLAB
752
25
% @title d state for Channel Rhodospin 2 (3 states model) % @file d_RhCh2_3states.m % @author Romain Beaubois % @date 09 Aug 2021 % @copyright % SPDX-FileCopyrightText: © 2021 Romain Beaubois <refbeaubois@yahoo.com> % SPDX-License-Identifier: GPL-3.0-or-later % % @details % > **09 Aug 2021** : fil...
bd08bdd3f29a2288e6146a460d7f6ba39fe7827e553b5dca1ba0d4cd71276a57
MATLAB
752
30
function R = Restrict_int(tsa, t0, t1) % tsd/Restrict % R = Restrict(tsa, t0, t1) % Returns a new tsa R so that tsa.data is between timestamps t0 and t1 % % ADR % version L4.1 % status: PROMOTED % v4.1 29 oct 1998 now can handle nargin=2 % v4.2 23 jan 1999 now can handle t0 and t1 as arrays switch nargin case 2 ...
fd0e3f3e8a253779c4e6ad679f5bf083aba45c21ee21697a8089797118b5999c
MATLAB
753
21
function tracklist=build_tracks(segment_links) origin_id=1; tracklist{origin_id}=[]; while ~isempty(segment_links) current_index=segment_links(1,1); target_index=segment_links(1,2); tracklist{origin_id}=[current_index, target_index]; segment_links(1,:)=[]; next_segment=find(segment_links...
01c49c1cdd658bf2bf6d73cff2bb1fcfe2e6d9820c25b165c240bab11f8fceb4
MATLAB
755
24
function vels = CalculateVelocities(tracks_in, pxPerMicron, timeBtwFrames) a = unique(tracks_in(:,4)); b = cell(size(a)); e1 = zeros(size(a)); e2 = zeros(size(a)); for i = 1:length(a) c = tracks_in(tracks_in(:,4) == a(i),[1,2]); d = nan; for j = 1:size(c,1)-1 p1...
481de976356632262f525ecda4097770fb86c982fc5544ae615c91637ac690ce
MATLAB
755
29
function res_table =get_PEATS_table(params) [~, c_info] = size(params.info_table); varTypes = [""]; varNames={}; for i=1:c_info varTypes(i)="string"; varNames{i}= params.info_table.Properties.VariableNames{i}; end varNum = c_info; varTypes(end+1)="string"; varNam...
e059b83e8cc430514aae049477918e95e8416e5babdbac8fd5f1331ccad71ea9
MATLAB
755
22
%This analysis code was used in: %Mares I, Ewing L, Papasavva E, Ducrocq E, Smith FW, Smith MLS (in press). %Face recognition ability is manifest in early dynamic decoding of face-orientation %selectivity – evidence from multi-variate pattern analysis of the neural %response. Cortex. %The code was originally cre...
f9440819519029cccdcf8785a71c2b6a14fc3f758c560f6586ae4fc5e4d61c94
MATLAB
758
38
function [x,yp,P,K,xm,Pm]=kalmanfilter(y,M); % Implentation of Kalman filter % y=oxT observables % M=structure: % M.A:transtion % M.C:Observation % M.Q:state Noise % M.R:Observation noise % M.x0: guess in beginning % M.P0: Uncertainty in beginning Pm=M.P0; xm=M.x0; for n=1:size(y,2) % Deal with time...
70f1b7b985d6c20dce99bd62a93b755adaaf04ab554d9cd37ef502e0563a3960
MATLAB
759
24
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Authors : CHATENET Louis % Date : 24/05/2018 % Updated : 30/05/2018 % Version : V2.0 % % Description : GABAb current calculation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [Isyn, r, s] = IsynGABAb2...
15ddd5216b7faf5831b2665a7d3c22aeae06d07c25c874f839ca18ff56626c76
MATLAB
761
25
function p = MD_vmpdf(x, mu, ka, Ik) % _ % Probability Density Function for a von Mises Distribution % FORMAT p = MD_vmpdf(x, mu, ka) % % x - an N x 1 vector of angles (domain: -pi <= x_i <= +pi) % mu - a scalar, the mean of the von Mises distribution % ka - a scalar, the precision of the von Mises distri...
6b08b9c1aa01924dfae873a8e00aa24ee4d1ab87701f1fd7eddcdd1ec5c4e1be
MATLAB
763
35
function ok = belong(is,t) % Tells whether timestamps belong to a intervalSet % % USAGE: % ok = belong(is,t) % % returns 1 if t belongs to the interval is, 0 otherwise % % INPUTS: % is - an interval set % t - a time expressed in the same Time_Unit, or a vector of times % % OUTPUTS: % ok ...
1e50c09beb745b0bec08e470e883500ae89b614afce004be2e6eba575ccc39a9
MATLAB
764
30
function req_params = reqParamsEffectSize(task,monkey) if nargin<2 || monkey=="both" if task=="floc" req_params.ID = 3000:4000; else req_params.ID = 4000:6000; end elseif monkey=="albert" req_params.ID = 4000:5000; elseif monkey=="golda" req_params.ID = 5001:6000; else return en...
b0d76d4e9fa619b0fa608077c98049078285ec5e445068cdda6b91b8438588dc
MATLAB
764
29
function [res, fmt] = detCosinor(actigraphy, epoch, varargin) %DETCOSINOR do cosinor analysis % % [RES, FMT] = DETCOSINOR(ACTIGRAPHY, EPOCH, STARTTIME, QUALITY, COSINORINFO) % performs ACTIGRAPHY of epoch length EPOCH and % return results to the caller. % FMT request the format to write RE...
901bfe0b12c6426f70428ffa30b67340abbfb2e41ff097c2f7bbbd60c71ce5fa
MATLAB
765
14
function model = RFEselect_train(labels_train,vectors_train,cfg) switch lower(cfg.decoding.method) case 'classification' model = svmtrain(labels_train,vectors_train,cfg.decoding.train.classification.model_parameters); if isempty(model), error('svmtrain returned an empty model - please check ...
4e9e8cf81700971e46d46bb2e729fa4681a1fdde3e7bd4165d96a9adacc46730
MATLAB
766
27
function msSaveVideo(ms,frameLimit, downSample, columnCorrect, align, dFF, outFile) %MSSAVEVIDEO Summary of this function goes here % Detailed explanation goes here mindFF = 0.1; maxdFF = 0.7; if isempty(frameLimit) frameLimit = [1 ms.numFrames]; end writerObj = VideoWriter([outFile ...
a241d05186a44e6034b69f2b120aff6d70c72cb9a3e3b17564a8b6f0abab6f4f
MATLAB
766
24
function disc = PT_disc(theta,type,varargin) % a function that converts Prospect Theory weighting function and amount function into discounting functions % varargin can provide alpha, gamma, delta, which would be instantiated as a, g, d respectively for i = 1:2:length(varargin) eval([varargin{i}(1),'=',num2str(var...
a7a6cbc8c61e3ffcac1a53c235943d30ff2ece08f8666152bb61178dba5532bc
MATLAB
767
33
fitFunc = @(b,x) b(1) * exp( b(2) * cosd( x - b(3) ) ); errorFunc = @(b,x,y) sum((fitFunc(b,x)-y).^2); opts = optimset('Display','off'); DIRECTIONS = 0:45:315; REPEATS = 1; BASELINES = 1:100; for i = BASELINES for r=1:REPEATS cosFun = i*cosd(DIRECTIONS-180); currErrorFunc = @(b) errorFunc(b,...
bcf585ed5ed6b5c337b79580629bb6991a5764110730a064b57603ac9f525ada
MATLAB
767
30
function [IQDataS] = LoadIQ(folder, filename) % Output: IQDataS - Inphase/quadrature ultrasound data f = fopen(fullfile(folder,filename),'r'); IQData = fread(f,'double'); fclose(f); if isfile(fullfile(folder,'IQSizeInfo.mat')) load(fullfile(folder,'IQSizeInfo.mat')); elseif isfile(fullfile(folder,'SizeI...
781311db3608e0216d0949d4c1c169cb1452b5ef13cd0eba0b964180bc9c67ec
MATLAB
768
36
function writeTsv(filename, tsv, options) global logger if ~exist('filename', 'var') filename = ''; end if ~exist('options', 'var') options = ''; end if optionExists(options, logger) logger = InitLogger(logger); logger.Write('Exporting stim to %s\n', filename); else fprintf('Exporting stim to ...
833218b9ef4b5fcb95d292f80269eb1455d51398607b60934423d0b44254c3c6
MATLAB
769
29
%This function feeds all your deltaF/F traces in dff variable through %T_star_loop, outputting a list of TStars T_star_temps = []; total_dff_amps = []; for i = 1:length(dff(1,:)) T_star_temp = []; Image_Time = 1:length(Temperature); raw_temperature = Temperature; steep_points = []; ...
c2d8ecb6bff1c35a3734735c3f1ef44d06beb13ae4048df6038e3340463fa832
MATLAB
770
37
function resultFlag = IsOSX(is64) % resultFlag = IsOSX([is64=0]) % % Returns true if the operating system is Mac OS X. % If the optional 'is64' flag is set to one, returns % true if the runtime is 64 bit and on OSX. % % See also: IsWin, IsLinux, OSName, computer % HISTORY % ??/??/?? awi Wrote it. % 6/30/06 awi Fixed...
18d492a304353cb1e114f8686bea6a08c16b7631320d607655dd8d298ebc113a
MATLAB
771
31
function [vox,n_idx,ep] = pk_follow_link(skel,node,k,j,idx,cans,c2n) vox = []; n_idx = []; ep = 0; % assign start node to first voxel vox(1) = node(k).idx(j); i=1; isdone = false; while(~isdone) % while no node reached i=i+1; % next voxel next_cand = c2n(idx); cand = cans(next_cand,2); ...
da054eee0e3967ec2a8b4bf5644a22fb453cc482f6d1ef2bf65d0b8c774b56be
MATLAB
771
32
% *WAVE* % % PHASE GRADIENT TEST SCRIPT takes the phase gradient of a test % test signal (here, a 2d target wave) % clear all; clc %#ok<CLSCR> % parameters T = 1; %s Fs = 1000; freq = 13.5; %Hz image_size = 8; %px pixel_spacing = 1; %a.u. direction = +1; % +1/-1 % generate data ...
12d0fb2a4f394e6d9c052f4021118f0d5d97c45064789b712bc4d27a9d8f210f
MATLAB
772
31
function val = HDF5_DatasetLoad(gid, name, val0, options) if ~exist('val0','var') val0 = []; end if ~exist('options','var') options = ''; end try dsetid = H5D.open(gid, name); % NOTE: HDF5 stores contiguous muti-dimensional arrays in row-major order. % Matlab stores them in row-major order. We wa...
e14ba76c7f99087797bbfa201aa640a0f2b88827bf0725d57692d58318564ebd
MATLAB
772
27
% function dist = cveuclidean2(X,Y) % % A function to calculate the cross-validated version of the squared % Euclidean distance between multiple matrices. This is equivalent to % d(i,j) = (X(:,i)-X(:,j))'*(Y(:,i)-Y(:,j)) for all pairs of i and j. % Negative squared distances are possible because of cross-validati...
43203f4bdb4577565405977be9ed0e5b6af8200e8be24e031183b534f5a4acb7
MATLAB
774
22
function val = HDF5_Transpose(val, options) if ~exist('options','var') options = ''; end % Matlab stores contiguous muti-dimensional arrays in column-major order. % HDF5 stores them in row-major order. We want to transpose the data to agree % with the file format's storage order. if (~isrow(val) && ~iscolumn(val)...
0c56ebef2c03407ec3dca15365651516a2b1b10ce065ffe41580143407634396
MATLAB
775
38
function S = Start(O, TimeUnits) % Starting times of for each interval in the set % % USAGE: % S = Start(O, TimeUnits) % % INPUTS: % O - an intervalSet object % TimeUnits (optionnal) - a units object or the abbreviation string % % OUTPUT: % S = an array of starting points for each interval in t...
223c6885a4cdc63016f8a31b3bedbf5d38a34fb750787d85959078fae173793e
MATLAB
775
36
function L = CrossValidationSpatialCheck_Cells(S,ang,ep) nbEp = 10; % dispBar = 1; epV = regIntervals(ep,nbEp); L = NaN(nbEp,length(S)); fprintf('Launching Cross-validated HD info\n') for ii=1:nbEp fprintf('.') ix = (1:nbEp); ix(ii)=[]; testEp = epV{ii}; trainingEp = epV{ix(1)}; for jj=2:nbE...
679e37d13867687c24591031b14053ffa0e42043f536015f69a69ef71726e92c
MATLAB
775
25
% @title o state for Channel Rhodospin 2 (3 states model) % @file o_RhCh2_3states.m % @author Romain Beaubois % @date 09 Aug 2021 % @copyright % SPDX-FileCopyrightText: © 2021 Romain Beaubois <refbeaubois@yahoo.com> % SPDX-License-Identifier: GPL-3.0-or-later % % @details % > **09 Aug 2021** : fil...
6c13c715ea761b0a0485d5758732ba0a205d80c207b94d7fae133db60d730b96
MATLAB
775
29
function [h, varargout] = nethess(w, net, x, t, varargin) %NETHESS Evaluate network Hessian % % Description % % H = NETHESS(W, NET, X, T) takes a weight vector W and a network data % structure NET, together with the matrix X of input vectors and the % matrix T of target vectors, and returns the value of the Hessian % e...
2f6314657d6650fdb2112756fd7a03d01428c46fdbb45f2ea8dd1f3c7f5245b7
MATLAB
777
33
function y = gauss(mu, covar, x) %GAUSS Evaluate a Gaussian distribution. % % Description % % Y = GAUSS(MU, COVAR, X) evaluates a multi-variate Gaussian density % in D-dimensions at a set of points given by the rows of the matrix X. % The Gaussian density has mean vector MU and covariance matrix COVAR. % % See also % ...
7c89afef9b48058e6d40efafe2d5adcbc8d1b37ca52125e137e85b7c0d6a0b64
MATLAB
777
23
function [histologyToOCTT, octPixelSize_um, topLeftCornerXmm, topLeftCornerZmm] = getHist2OCTTransformFromApp(app) % Get OCT Volume Pixel size x = app.jsons.sectionIterationConfig.data_um.x.values; z = app.jsons.sectionIterationConfig.data_um.z.values; dx = diff(x(1:2)); dz = diff(z(1:2)); if std(diff(x))>1...
2700fb17f50f81ebfb45f88a1be1142ec18b407e74c51614f6f94cb9dda833f2
MATLAB
779
32
function [newmap] = darkgray(m) % DARKGRAY- A darker gray colormap than GRAY. % % SEE ALSO % GRAY, COLORMAP % License: %===================================================================== % % This is part of the Princeton MVPA toolbox, released under % the GPL. See http://www.csbmb.princeton.edu/mvpa for more % in...
0469b69ee551b5aa50b242d6df74a79c862335da965d6ea8e601a013e6fe7ed6
MATLAB
781
34
function datatype = GetDatatype(handles) global maingui datatype=0; if nargin==0 return end if isempty(handles) return end plotRawVal = get(handles.radiobuttonPlotRaw, 'value'); plotODVal = get(handles.radiobuttonPlotOD, 'value'); plotConcVal = get(handles.radiobuttonPlotConc, 'value'); plotHRFVal = get(...
9fce20c4368f3955298ba20d14a14a1325cf8eea31bb9eb1da90367cc682fc03
MATLAB
781
32
function filename = get_filename(sub_id, p) % function filename = get_filename(sub_id, p) % % Create filename for final result file. % % Input: % - sub_id: ID of the current subject. % - p: Structure with analysis parameters. % % Output: % - filename: Filename (including file path, excluding timestamp) of % ...
b22e690963f54d8401305d9d8cb0ed87a9bd3a1ddb7eb67f44e17a8972f66cb7
MATLAB
781
35
function [errs, msgs] = exeShellCmds(cmds, preview, quiet) % Change #2 errs = zeros(length(cmds),1) - 1; msgs = cell(length(cmds),1); if nargin==0 return; end if ~exist('preview','var') preview = false; end if ~exist('quiet','var') quiet = false; end for ii = 1:length(cmds) if preview == false ...
f3517790f30a19f0a8d665722add6635b161a3638529a8d47fb08ed2870909f4
MATLAB
781
24
function PlotTwoVelocityDistributions(xVec, yVec1, yVec2, fileName, xTick, xTickLabel) h = figure; xData = xVec(2:(end - 1)); xData = [xData; xData]; xData = [0; xData(:); max(xVec)]; yData1 = [yVec1; yVec1]; yData2 = [yVec2; yVec2]; yData1 = yData1(:)/sum(yData1(:)/2); yData2 = yData2(:)/sum(yData2(:)/2); plot(xData, ...
7356fa32a71bc08e2baa23a13f81180c8297ef24106547de0d66fb574c31fb6c
MATLAB
782
18
function [diffIm, diffImBack] = CreateFinalImage(imageStack, corrPeaks) diffIm = zeros(size(imageStack, 1), size(imageStack, 2), size(imageStack, 3) - 1); factorArray = GetFactorArray(mean(corrPeaks), 1, std(corrPeaks)/mean(corrPeaks)); for i = 1:size(diffIm, 3) tempArray = factorArray(1:min(length(factorArray), si...
774264169beb372aea614f3718e769e5d91d6b5a769c317f933ee626da49cbe6
MATLAB
782
32
function y = bhvr_preproc(y) % function y = bhvr_preproc(y) % % Pre-processing of behavioral orientation labels for a von Mises mixture % model. Takes as input values in degrees between 0° and 180° and % returns as output the corresponding values in radians in the range -pi to % pi. % % Input: % - y: an N x 1 vecto...
af2dfa357b64291ee3e679f69967051c9f7083a19ac29a0542f9cf0dea26a366
MATLAB
782
38
smoothTC = 3; % smoothing of tuning curves (3 used in Duszkiewicz et al., 2024) %% load data load(fullfile('Analysis','MeanFR')); load(fullfile('Data','WaveformFeatures')); load(fullfile('Analysis','HdTuning_moveEp')); %load(fullfile('Analysis','CellDepth')); goodSpk = ~isnan(tr2pk); %frate = rateO; % for Opto d...
e8e086d6ffa2f4e160d1a4d8ee465f565550af2444f84622c1f54a884b8f0b7e
MATLAB
782
25
function [ROImatchBinA, ROImatchAinB] = ROIMapMatching(Amap, Bmap) % use anchor points to map ROI from 2 different map % For each ROI in Bmap is caclulate with the largest overlapping ROI in % Amap, overlappying is excluding nan area % [BId, AId, CoveredA(%), CoveredB(%)] assert(sum(size(Amap)-size...
c09dcf3093e7ff2d7f1ff826836ecdbd395eda08bb583b1d21ec7f6fe8fc7f74
MATLAB
783
27
function [approx detail] = dwt1(X, g, h) % Performs a single level discrete wavelet transform. % % [approx detail] = dwt1(X, g, h) % License: %===================================================================== % % This is part of the Princeton MVPA toolbox, released under % the GPL. See http://www.csbmb.princeton.e...
0c7529f8799a2bfa0d2df6049125d675377726e38de94807dddea47986f23f42
MATLAB
785
34
%% Plot V4 MI firing rates cued vs cue-opp (moving window plots locked to cue onset/offset) %% Code load('V4_FR.mat') monkey = ["G","B","Combined"]; metric = "MI_FR"; trial_type = "all"; yl = [-0.02,0.06]; close all cueMI = eval(sprintf("cue%s",metric)); oppMI = eval(sprintf("opp%s",metric)); sum_metric = "mean"; ...