sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
2c8986219b2829b3879dc663a83ee38bb11baf99f18afacbb642600cf967bcc6 | MATLAB | 852 | 37 | function resultFlag = IsWin(is64)
% resultFlag = IsWin([is64=0])
%
% Return true if the operating system is Windows.
% If optional 'is64' flag is set to one, returns
% true if the runtime is 64 bit and on Windows.
%
% See also: IsOSX, IsLinux, OSName, computer
% HISTORY
% ??/??/?? awi Wrote it.
% 6/30/06 awi Fixed ... |
a76780e1f2ce30de0945d3b6dc529a2a8397b09e63ed84e8d7f1be33f32d1042 | MATLAB | 852 | 40 | function T1 = StartTime(tsa, tsflag)
% Returns first timestamp
%
% USAGE:
% T1 = StartTime(tsa, tsflag)
%
% OPTIONS:
% tsflag - if 'ts' returns time in timestamps (default),
% if 'sec' returns time in sec
% if 'ms' returns time in ms
% the current version is an evolution of A. David Redish's cod... |
42616ea0c078fe0d9ccc033271c396470b083a19ff3f496855351287179a4142 | MATLAB | 853 | 30 | function iList = MapGroupTree2List(iGroup, iSubj, iSess, iRun)
global maingui
% Function to convert from processing element 3-tuple index to
% a linear index used to select a listbox entry
viewSetting = maingui.listboxGroupTreeParams.viewSetting;
idxs = maingui.listboxGroupTreeParams.listMaps(viewSetting).idxs;
% C... |
51b5ed7196cd787c3d04a39850adfc392454b70ca27d4c02d9e81e275ffdac5f | MATLAB | 853 | 28 | function [] = display_results_history(results)
% Display the results.history field
%
% [] = DISPLAY_RESULTS_HISTORY(RESULTS)
%
% Displays the freeform text history stored in the results'
% header.history field in a friendly way
% License:
%=====================================================================
%
% This... |
8bd05ab63201dc7dc66780ac3ef94d97f4d14f49f13c5d7f39f1b3a652da9a95 | MATLAB | 854 | 22 | function vidObj = msGoodFrames(vidObj, fluorescenceFrameThresh)
%MSGOODFRAMES Summary of this function goes here
% Detailed explanation goes here
vidObj.fluorescenceFrameThresh = fluorescenceFrameThresh;
vidObj.frameFluorescence = nan(1,vidObj.numFrames);
for frameNum=1:vidObj.numFrames
if mod(fra... |
f1af39bfe1e300e6cc50b84849748c0d70b0ae962db6f27731ea866f7b427fd5 | MATLAB | 854 | 28 | function [major,minor0,minor1,minor2,revision] = get_matlabVersion()
%
% This is a simple function to return the matlab version as an array of
% integer numbers so that it can be tested against required versions for
% conditional execution. It returns the full version split into an array.
%
% This function utilizes th... |
02bf71326829423aa238a4bfb96ef1660e63019c1b493d9df9625b1403cf559b | MATLAB | 855 | 34 | function data = Constant(transformer, data)
%
% Adds a new column with a constant value (numeric or char).
%
% Arguments:
%
% :param Output: **mandatory**. Name of the newly generated column.
% :type Output: char or array
%
% :param Value: Optional. The value of the constant, defaults to ``1``.
% :... |
18a32ea0007538eb764063c446d0b89a946167c43f5ff3e95ffc7c04fb0ded3e | MATLAB | 855 | 23 | function EEG_permuteGND(dir,model,outfix,regtype,EEGinfix,timewin,alpha,nPerm)
%% plotting and statistics
% model = 'hierarchicalRL-counterfact';
% regtype = 'resp-revision'
% outfix = 'stimLocked\regression';
targetdir = strcat(outfix, '-', model);
%load GND (will also be used for ERP plotting)
fin = fullfile(dir.di... |
c4982e7a5588702695bbd03b2e491765a2f79efb949d5973059ac101b822bfbf | MATLAB | 857 | 19 | %assigns color based on flicker modulation amplitude.
%2024/02/25
function colors=assign_zscore_color(zscores,threshold)
%create colors from yellow (low modulation) to red (high modulation):
plot_colormap=[flipud(autumn)];
%assign colors:
colors=[];
for i=1:length(zscores) %for each modulation... |
8a6549d437307684a09faa2aab8aabf9005d9f70579939792aaff74bbb97274c | MATLAB | 858 | 32 | clear
clc
close all
addpath('data')
addpath('src')
dataset = {'5_Zeisel'}
% perform the analysis
load(['Test_' dataset{1}]);
C = max(true_labs); %%% number of clusters
rng(75584,'twister'); %%% for reproducibility
in_X = log10(1 + in_X);%%% first of all, take log10 transformation for gene counts
tic
in_X = fast_pca(i... |
1a49daee1367f90af13be454396d91d6c0839dc9160fdd73e56e3f7656cfcc77 | MATLAB | 859 | 34 | function SaveEvents(filename,events)
%SaveEvents - Write events to file.
%
% USAGE
%
% SaveEvents(filename,events)
%
% filename event file name
% events event data
%
% SEE
%
% See also NewEvents, LoadEvents, SaveRippleEvents.
% Copyright (C) 2004-2011 by Michaël Zugaro
%
% This p... |
d475ae8eae2972ea05715aa77f26d382a1211576a3abafa72854718b5ae6269f | MATLAB | 859 | 46 | function iso = dropLongIntervals(is, thr, varargin)
% Drops the intervals in the set that are longer than a given threshold
%
% USAGE:
% iso = dropLongIntervals(is, thr, OptionName, OptionValue)
%
% INPUTS:
% is - an intervalSet
% thr - a duration threshold; all intervals longer than thr will be
% ... |
1fe59b6abcab660f549481a79ba62abaf8a51c30cb87be1f90ae44070687c78f | MATLAB | 860 | 24 | % function output = transres_accuracy_pairwise_minus_chance(decoding_out, chancelevel, varargin)
%
% For more than two classes, rather than getting the mean multiclass
% accuracy across all classes (i.e. chance = 1/n_label), report the mean
% accuracy of all pairwise comparisons (i.e. chance = 1/2).
%
% This code runs ... |
2340f43e6fb1ed4d2b8c9996737d1f17afee1ab35909b0654bf06302dce2fe03 | MATLAB | 860 | 31 | function pretty_print_matrix(M, indentrow, fmt)
if ~exist('indentrow','var')
indentrow = 0;
end
if ~exist('fmt','var')
fmt = sprintf('%%0.4f');
end
nr = size(M,1);
nc = size(M,2);
for ii=1:nr
fprintf(blanks(indentrow));
for jj=1:nc
if M(ii,jj)>=0 && M(ii,jj)<10
fprintf(['... |
d05ad9af8f5e5ba4d9aa43eac734c2cbef7fe22af930c56349e237449ea07e01 | MATLAB | 860 | 32 | function [M, uVar1, uVar2] = goodnessHeatmap(SimRes,IndepVar,DepVar,idx)
% SimRes table of simulation resultst
% MatchTable
% IndepVar cell array of 2 independet variable names
% DepVar string of depedent Variable name
% nSim = size(SimRes,1);
Var1 = IndepVar{1};
Var2 = IndepVar{2};
uVar1 = ... |
63980b5bc0722e2f09f9d479932d631e55b74512e523b866e382fdc27952d217 | MATLAB | 861 | 36 | function [phtgV1T,phthtpgV1T1]=VBHMMsmooth(logalpha,logbeta,logOutput,phghm,v)
T = size(v,2);
H = size(logOutput,1);
for t=1:T
logphtgV1T(:,t)=logalpha(:,t)+logbeta(:,t);
phtgV1T(:,t)=condexp(logphtgV1T(:,t));
end
for t=2:T
atmp=condexp(logalpha(:,t-1));
btmp=condexp(logbeta(:,t));
phatvgh1 = ... |
82063bd533a15dc0d7a278c8f6e6a869f0543560056f34efb2e0847e78853aea | MATLAB | 861 | 34 | function d = idummy(x, method)
%DUMMY Creates a matrix of dummy variables for a discrete variable
% D=IDUMMY(X,METHOD) creates an array D of dummy variables for the
% grouping variable I (integers 1,...,g), using the method specified:
%
% method = 1: 0/-1/1 coding, full rank
% method = 2: 0/1 coding, full ... |
adf81c2aca01ce39db8c36480dea1cbafd6ab38b1656b5dc35677fb4d8262018 | MATLAB | 861 | 38 | function M = triggeredDataMat(tsa, t, nbBins,varargin);
% Returns a event-by-events matrix of Data component triggered on a reference (TODO!)
%
% USAGE:
% M = triggeredDataMat(tsa,evt,nbB)
%
% INPUTS:
% tsa - a tsd
% evt - time of triggers
% nbB - nb of timestamps before and after (i.e. a total of... |
cbba61f1572e15f27f0c75483dd6b5d593eec3e88871ce31f83f2876182438ba | MATLAB | 861 | 35 | function is = boundaryIntervals(tsa, thrLow,thrHigh)
% Returns intervals in which a TSD is above (below) threshold
%
% USAGE:
% is = thresholdIntervals(tsa, thr, OptionName, OptionValue)
%
% INPUTS:
% tsa - a tsd object
% thr - a threshold value
%
% OUTPUTS:
% is - the intervalSet of the times... |
e874e50bad45989f18ecb64c01395693cc0cea368f34e4fdf08db1759a4ae150 | MATLAB | 861 | 25 | function msBatchExtractdFFTraces(dirName)
%MSBATCHEXTRACTDFFTRACES Summary of this function goes here
% Detailed explanation goes here
dataFolders = msBatchFindDataFolders(dirName,[]);
for folderNum = 1:length(dataFolders)
currentFolder = dataFolders{folderNum};
temp = load([currentFolder '\m... |
b3efcde10f3a6cadebafc56d8a291db395d76f38148fcd28eb7924aeb94578fb | MATLAB | 862 | 37 | function setSameAxisLim(axs, directions)
% sets the same axis limits on several plots
%
% INPUTS:
% axs: a cell array of axis handles
% directions: a string composed of 'x' and 'y', indicating which directions
% to act on
% axes will be set to the maximum interval including all axis current intervals
xa = zer... |
e9adf811c50f0c5a8f6f0b9912bd1bd25745b92493f297b03ab59c3ca2182d18 | MATLAB | 862 | 34 | % function [ranks,ind] = uget(labels_train,vectors_train)
%
% Feature selection subfunction using Mann-Whitney U-test (also called
% Wilcoxon Rank Sum Test)
%
% Replaced by more efficient function
% 14/01/29 Martin H.
function [ranks,ind] = uget(labels_train,vectors_train)
labels = uniqueq(labels_train);... |
363c3f0835a99aec033c2acda8a7c25a5a095d978122a0e1e6a2b29f8dcbc698 | MATLAB | 864 | 44 | function s = horzcat(a, b, varargin)
% Horizontal concatenation of TSDs (overload of the [a, b] operator)
%
% USAGE:
% tso = horzcat(tsa, tsb, ...)
%
% arguments must be all tsd, the cat function is used
% copyright (c) 2004 Francesco P. Battaglia
% This software is released under the GNU GPL
% www.gnu... |
579b161f177eb8cc0db49c2ee620ea6adb281a4cf556c37cf9db04ea0ec45f7b | MATLAB | 864 | 41 | function a = read_noran(filename,numz)
[nx,ny,nz,xdim,ydim,zdim] = parse_noran(filename);
if nz == 0
nz = 1;
end
size = nx * ny * nz;
fid = fopen(filename);
[filename,permission,machineformat] = fopen(fid);
fseek(fid,0,'eof');
f_size = ftell(fid);
sz = f_size-size;
frewind(fid);
... |
158fabada78e7193f8711ffc16e8c3e4f3c064e1d8a3dd2f51e46033b98f29f8 | MATLAB | 866 | 31 | function sleepSeries = doSleepDetActiware(data, epoch, T)
%DOSLEEPDETACTIWARE detect sleep episode in actigraphy DATAINMIN
%
% REF.: [1] Actiwatch Software Manual p. 76-77
%
% auto threshold is currently not available as the instruction in
% Actiwatch Software Manual is not clear enough
%
% $Auth... |
1b16d620064e9017d014fe8b43f6155323e0260929eab310cffbd2e1b63022da | MATLAB | 866 | 29 | function [N_low,N_high,mean_low,mean_high] = GSanalysis(zX_RS,Vhigh,Vlow,U)
% Graph signal analysis
data=zX_RS;
n_ROI = size(data,1);
nsubjs_RS = size(data,3);
%% compute filter low- and high-frequency components
for s=1:nsubjs_RS
% Calculate reconstruction beta coefficients
X_hat(:,:,... |
b5783f9fa2a10d3b88a251f111f595f44df60692df04a223afc9066f818a2247 | MATLAB | 867 | 24 | %LoadSpikeWaveforms - Read spike waveforms from file.
%
% USAGE
%
% waveforms = LoadSpikeWaveforms(filename,nChannels,nSamples)
%
% filename spike waveform file name
% nChannels number of channels in electrode group
% nSamples number of samples per waveform
% Copyright (C) ... |
22ecf5d21510e3df7035eebe484254e72fd8071257329d816b6a710481d77e3f | MATLAB | 868 | 36 | function [mx] = wpow(x, dim)
%Compute robust estimate of power based on a iterative weighted procedure,
%according to Chave et al. 1987
if nargin<2,
dim = find(size(x)>1, 1, 'first');
end
if ndims(x)>2, error('dimensionality > 2 is not supported'); end
pvec = [dim setdiff(1:ndims(x), dim)];
x = permute(x, pv... |
0e48d03ea6c4d33db5331256d8ac8ddfe84117a9e45367c25b457ad0d7aea093 | MATLAB | 869 | 29 | function [result1] = measuremnet_types(xr1, xr2, model)
%xr = zscore(xr);%z-score normalize each column of matrix xr
HT1 = hilbert(xr1);
HT2 = hilbert(xr2);
%ph = atan( imag(HT)./real(HT) );
ph2 = angle(HT2);
ph1 = angle(HT1);
if model=="mod(π)_PLV"
phi = mod(unwrap(ph1),pi) - mod(unwrap(ph2),pi);
E = exp(1i... |
3dd28e4266d669d8bb6aa59369d008eddd519dcd8f715e5bf12373a20ccb74c2 | MATLAB | 869 | 27 | function [nx,ny,nz,xdimension,ydimension,zdimension] = parse_noran(filename)
fid = fopen(filename);
head = char(fread(fid,3200))';
% protocol = get_item(head,'Protocol',/string)
objlensmag = get_item(head,'ObjLensMag',0);
objlensna = get_item(head,'ObjLensNA',0);
xlenscalibrt = get_item... |
fb651d580cc3a672efd9b5a58b88f910630c09580b6ae65b95d9f1f8cbcbdfd0 | MATLAB | 869 | 24 | function NodeTable = create_node_table_200820
% Creates node table for the graph object with attributes Name,No, X, Y
if exist('NodeTable.mat','file')
load('NodeTable')
return
else
wd = pwd;
cd("C:\Users\lasss\Documents\Research\Brewer Lab work\Code\AFR_p1s_connections\spikes-20220228T181146Z-0... |
1347af747be8da087790374aad36b4cb62d7d054ee6a70003907cfcb1296d1e9 | MATLAB | 870 | 28 | function data = define_behavioral_periods(data, r)
n = size(r,2);
for i=1:n
tmp = r{i};
if strcmp(tmp{1},'behavioral_periods_starts')
cmd = sprintf('starts=data.behavioral_events.%s.on_ts;',tmp{2});eval(cmd);
m = size(starts,1);
for j=1:m
... |
ac3bcb1ce852096c10ac3ebee07c9883c119887520566074ed65feb5386cb300 | MATLAB | 870 | 45 | function iso = dropShortIntervals(is, thr, varargin)
% Drops the intervals in the set that are shorter than a given threshold
%
% USAGE:
% iso = dropShortIntervals(is, thr, OptionName, OptionValue)
%
% INPUTS:
% is - an intervalSet
% thr - a duration threshold; all intervals shorter than thr will be
... |
25866ca3188acc04854e33bf43127d24575b6eb64f62e69d6dd5832df93fe1a9 | MATLAB | 871 | 28 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Authors : CHATENET Louis
% Date : 24/05/2018
% Version : V1.0
%
% Description : GABAb current calculation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Isyn, r, s] = IsynGABAb(dt, Vpre, Vpost, rpre, spre)... |
217ddc5a5084c702cfaaba057186ebd499f7503c0e6db36f900f66ef2f17c9c6 | MATLAB | 872 | 38 | % LOCAL_MAX detect all local extrema in a matrix
%
% [ idx, vals ] = local_max( x, mode )
%
% x data matrix
% mode (optional) string. 'ext', 'min'; default - maxima only
%
% idx indices of local maxima
% vals values
%
% note: if X is a matrix, this routine returns inds as a 2-colum... |
32236b0715d2a0ad10cc1d93326ba4b6582581237b7e631bac40757bdde4229f | MATLAB | 872 | 21 | %% Difference Image Control Script
% intPower = 0.9;
% clusterFilSig = 3;
% clusterFil = fspecial('gaussian', 6*clusterFilSig + 1, clusterFilSig);
% clusterFil(3*clusterFilSig + 1, 3*clusterFilSig + 1) = 0; clusterFil = clusterFil/sum(clusterFil(:));
% cVec = (0.55:0.15:1)';
% posThreshVec = [0, 0.0001, 0.001, 0.005]... |
2dadf67c0acdc0bac136d3d8fe47810b4eda043b9ba86d6b1a25c4eaa93244f0 | MATLAB | 873 | 22 | function [ ForceMean,ForceSD ] = MosbergerMotorCurrentMeanForce(MotorCurrent,J,CurrentTorqueGain,CurrentTorqueOffset,TorqueMax,TorqueSignList)
TorqueSignCount = length(TorqueSignList);
TorqueMax = TorqueMax * ones(size(MotorCurrent));
if( any(isnan(MotorCurrent)) )
MotorTorque = NaN(size... |
3023bc4c6f2df84077c142f67ac335c868af64f228fd1fd6d850f8e85faaeacd | MATLAB | 873 | 39 | % Compute quality control on all images of a subject
%% Inputs
subjectPath_ = s3SubjectPath('43','LG');
%% Jenkins & get section path
if exist('subjectPath__','var')
subjectPath_ = subjectPath__;
end
[~,sectionNames] = s3GetAllSlidesOfSubject(subjectPath_);
%% Run on all subjects in a loop
HRef = [... |
20ae18b49d99372a8b78b255d4445e7952ba1553fcaffad96c02084adb049140 | MATLAB | 875 | 24 | function features = extractFeaturesCSP3Classes(X1, X2, X3, regularizationParam)
% 为三个类别两两计算
Sigma1 = cov(X1) + regularizationParam * eye(size(X1, 2));
Sigma2 = cov(X2) + regularizationParam * eye(size(X2, 2));
Sigma3 = cov(X3) + regularizationParam * eye(size(X3, 2));
% 类别1和类别2
[V12, ~] ... |
80649e82ebf405648d5fba11097825ef0f70ba56aa2e144029a30b4ca638b32e | MATLAB | 875 | 45 | function Xsm = gausssmooth(X,N1,varargin)
% Xsm = gausssmooth(X,N1,N2)
%
% Input:
% X: vector (or matrix) to smooth
% N1: sd of gausswin for the first dimension. If N1==0, no smoothing
% N2: in case of X is a matrix, sd of smoothing on the 2nd dimension. If omitted, N2=N1
%
% Output:
% Xsm: smoot... |
e76e041d984e516d8fd0b41ddfc6ba0d0836b497677c97f777b653d8364d7fc6 | MATLAB | 878 | 36 |
% Potential Solution
% Isnan search on data_seg
% loop through each and every cell
% if find (1) = true
% store idx number in a variable
% Specifically for 31 & 17 as both stopped recording mid trial.
function [data_seg, trl_visual_feed, ECG_seg] = NaNremove(data_seg, trl_visual_feed, ECG_seg)
... |
39226e8dae0eac15be92aeb732d6a2bd39558bdad874efdeab72e48df9edda8f | MATLAB | 879 | 36 | function [issame] = compare_size(m1,m2)
% Returns true if two matrices are the same size
%
% [issame] = compare_size(m1,m2)
%
% Checks that M1 and M2 have the same number of dimensions and each
% dimension is the same size
% License:
%=====================================================================
%
% This is p... |
00053d1ca0be963052042fb158be9c90d10e318a0465d4ac3b439b736435dc47 | MATLAB | 880 | 23 | function [perfmet] = perfmet_corr(acts,targs,scratchpad,args)
% This is a deprecated function, since the name was
% confusing. See PERFMET_FOR_CLASS_CORR.M if you're using
% TRAIN/TEST_CORR.M or PERFMET_XCORR.M if you simply want to
% correlate your ACTS with your TARGS.
% License:
%==================================... |
597729e982cb83c8470889e919c9dbab9e0668f9207f72d81f8bdaa0ce02c09d | MATLAB | 880 | 25 | function w = netpak(net)
%NETPAK Combines weights and biases into one weights vector.
%
% Description
% W = NETPAK(NET) takes a network data structure NET and combines the
% component weight matrices into a single row vector W. The facility
% to switch between these two representations for the network
% parameters is ... |
e1e473ef8200ca34ae1224327eb28a3fe05383f6fdfbac2276d69ab0d227a14d | MATLAB | 880 | 37 | % loading stack
% load('wholestack.mat');
% loading tracking results
% load('neurons_reconstructed_max_2.mat');
% specifying output folder
% outputpath='.\output\';
% specifying voxel size
voxel_size=[0.267 0.267 2];
[folders, files] = getFileStructureMat('E:\PanNeuronale\Acquisizioni\20230912');
%%
... |
e8327e84684136a8b33735e4c82d029060c394836bdd60b1afed94c7ac95e9e7 | MATLAB | 880 | 38 | function proclevel = GetProclevel(handles)
global maingui
proclevel = 0;
if nargin==0
return
end
if isempty(handles)
return
end
bttnG = get(handles.radiobuttonProcTypeGroup, 'value');
bttnS = get(handles.radiobuttonProcTypeSubj, 'value');
bttnE = get(handles.radiobuttonProcTypeSess, 'value');
bttnR = get(han... |
87afca7376ecd51bf0d57bc983f9254e389c3a90dc09c8f07b044ff6d28cce82 | MATLAB | 881 | 17 | opIsLocal = 1;
sbjList = {'12','13','14','15','16','19','21','22','23','24'};
for i = 1:length(sbjList)
sbjNum = sbjList{i};
%rawDataDir = ['/projectnb2/binaural/mhn/RawDatafNIRS/Experiment' num2str(sbjNum)];
rawDataDir = ['C:\Users\mn0mn\Documents\ResearchProjects\spatailAttentionProject\RawDatafNIRS\Expe... |
75c80f13f4047e7fa5116a2d0103293b0dfade2f0985cb1c3c2622d37d89de7f | MATLAB | 882 | 38 | function varargout = read_voxels_afni(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);
hdrname = varargin{1}.RootName;
opt = struct;
opt.Form... |
de3b956b7aee3c88ba0aea9bad11c4c8d10af1c83c4aa961c3fc54d10627cd4e | MATLAB | 882 | 30 | function msPlayAlignment(vidObj, downSamp)
%MSPLAYALIGNMENT Summary of this function goes here
% Detailed explanation goes here
% count = 0;
cc = {'b' 'g' 'm' 'y'};
% h = vidObj.alignedHeight(1)/2;
% w=vidObj.alignedWidth(1)/2;
f = figure(1);
frame = msReadFrame(vidObj,1,true,false,false);
imshow(uint8(frame));... |
c5151520304e1e28e3cf7083eedcef1a8d7a607e08c25ea7d69b39450e7f1f12 | MATLAB | 883 | 36 | %
%copies a list of fields from a source to a target structure
%
%fields -> cell array of strings. entries in the cell array can also be an other cell array
%with two string entries: src and target. (to rename fields).
%
%i.e. fieldsSrc = {'a1',{'a2','a3'}, {'from','to'})
%
%will copy target.a1=src1 and target.a3=src2.... |
2c8c1f6076c1bf5a1e7205d11c0afdcc6de7bfda0bccbd95d79fe37c885295f4 | MATLAB | 884 | 40 | % lin_downsample downsample with a MA
%
% y = lin_downsample( x, dsf )
%
% x matrix (columns downsampled)
% dsf downsampling factor (integer); negative number indices number of
% samples in the output; vector indicates
function y = lin_downsample( x, dsf )
y = [];
if ~isnumeric( x )
retu... |
ab023a8b9935ae6886258486413b4f02532827e55b25815b4017824f9f76c713 | MATLAB | 884 | 29 | function varb1=pca_reconstruction(varb,rank)
if nargin<2
rank=4;
end
time1=max(varb(1).coords(:,4));
for i=2:numel(varb)
time1=min([time1 max(varb(i).coords(:,4))]);
end
raster=zeros(numel(varb),time1,3);
reraster=zeros(numel(varb),time1,3);
for i=1:numel(varb)
raster(i,:,1)=varb(i).coords(1:time... |
fdb052dfa3bc26630ad10034e1dede0d01d1ab401377261563556731460ebda1 | MATLAB | 884 | 37 |
%% parameters and data
binsize = 0.2;
nbins = 250;
load(fullfile('Data','SpikeData'),'S');
%% Compute CrossCorrs
fprintf('Computing spike train CCGs \n');
totC = length(S);
allCCG = nan(nbins+1,nchoosek(totC,2)*2);
allPairs = [];
noCCG = 1;
for nC1 = 1:totC
tempPairs = [];
for nC2 = 1:totC ... |
6bfc8c91eb2a6f33ae53ccc44b59e56b8b3da11fbb7b586d6d6d26207963e94f | MATLAB | 885 | 27 | function [CrossTime] = calcCrossing(PCs,tt,baseTime,modelTime,thrs)
nStm = size(PCs,1);
bIdx = tt > baseTime(1) & tt < baseTime(2); % time index for baseline
tIdx = tt > modelTime(1) & tt < modelTime(2); % time index for model
nThr = length(thrs);
CrossSamp = nan(nStm,nThr);
CrossTime = nan... |
845a3af53061dd13723f58709aeea78acc08eb2d98c17dfa6b270376bd074f23 | MATLAB | 885 | 59 | function [S, E] = VelFilter(V, threshold)
% [S, E] = VelFilter(V, threshold)
%
% Start and end times of hte epochs in which te speed il less than threshold
%
% INPUTS:
% V = tsd absolute velocity
% threshold = ...
%
% OUTPUTS:
% S = Column vector of start times
% E = Column vector of end times
% batta 2000
% status ... |
9498e59b68bc27433a37ac49e361bedf98198a03c53cdee7f822ccd9c06d7441 | MATLAB | 885 | 40 | function [d] = lbfgs(g,s,y,Hdiag)
% BFGS Search Direction
%
% This function returns the (L-BFGS) approximate inverse Hessian,
% multiplied by the gradient
%
% If you pass in all previous directions/sizes, it will be the same as full BFGS
% If you truncate to the k most recent directions/sizes, it will be L-BFGS
%
% s -... |
a8ccf549fcf1453b09d49f80b6fc5a16f6ed51360c3dfcd00d5d72d926b114f3 | MATLAB | 885 | 39 | function [h X Y] = hist2(Data, XBins, YBins)
% out = hist2(Data, XBins, YBins)
%
% Makess a 2d histogram of the data.
% XBins and YBins are optional arguments
% which give the number of grid segments.
% - default is 50.
if length(XBins) == 1
MinX = min(Data(:,1));
MaxX = max(Data(:,1));
else
MinX = XBins(1... |
06f231289f428d59165ac8b384f745540dcdea75a37454a295fa9b5964c1dcde | MATLAB | 886 | 30 | function varb1=pca_reconstruction(varb,rank)
if nargin<2
rank=4;
end
time1=max(varb(1).coords(:,4));
for i=2:numel(varb)
time1=min([time1 max(varb(i).coords(:,4))]);
end
raster=zeros(numel(varb),time1,3);
reraster=zeros(numel(varb),time1,3);
for i=1:numel(varb)
raster(i,:,1)=varb(i).coords(1:ti... |
16c0408f50f93ca1157655ba1e171ffd606602d9eab80c9396288456079efd6a | MATLAB | 886 | 23 | %counts peaks of dff traces. Run after exporttraces_TH and
%GCaMP_ampsdff_TH. Peaknum is peaks output
clear pktimes
clear pks
clear peaknum
clear peakfreq
Trace1=menu('Choose the first one to plot',sheetlist); %choose which spreadsheet to use
dff_A=readmatrix(filename + "_dff.xlsx",'Sheet',Trace1); %read selecte... |
6f9a1e97f293038040c2446f7feac51c6d0dafb1c1b4ca49b5b03fca079b5d88 | MATLAB | 886 | 28 | % function out = squareformq(in)
%
% Fast and general version of squareform that works also for matrices that
% are not distance matrices. Diagonal entries are ignored if they are
% present.
function out = squareformq(in)
inputdim = size(in);
% if we are dealing with a vector
if any(inputdim == 1)
n = max(inputd... |
32a3f961707a7c5b6b425a17fe1790c71cd1779da0c01596094c2441f8a9019f | MATLAB | 887 | 27 | function corrPeaks = GetCorrPeaks(image,thresh)
num_samples = 25;
if (thresh < 0)||(thresh > 1)
error('Inappropriate Threshold');
end
rand_array = randi([1, size(image, 3)], num_samples);
corrPeaks = zeros(length(rand_array),1);
for i = 1:length(rand_array)
im1_top = image(:,:,rand_array(i)) - nanmean(nanmean(i... |
d9592e58d0a3b1af4330afd6bf720fac6dad590c75ae14e388470fbc914c7583 | MATLAB | 887 | 45 | function O = intersect(varargin)
% Computes the intersection of intervalSet's
%
% USAGE:
% O = intersect(O1, O2, ..., On)
%
% INPUTS:
% O1, O2, ..., On - intervalSet objects
%
% OUTPUTS:
% O - intersection intervalSet object
% copyright (c) 2004 Francesco P. Battaglia, debugging by Adrien Peyrac... |
e957792b6a5405ce50a313718b2be17b949b67ceb1215136e6454e78f557727a | MATLAB | 887 | 30 | function [d2, win_nodes] = somfwd(net, x)
%SOMFWD Forward propagation through a Self-Organising Map.
%
% Description
% D2 = SOMFWD(NET, X) propagates the data matrix X through a SOM NET,
% returning the squared distance matrix D2 with dimension NIN by
% NUM_NODES. The $i$th row represents the squared Euclidean distan... |
719ca228607023d3b87dc61b70cfa2789edda398ad005bf3a56162030a33ee1c | MATLAB | 888 | 25 | function [z, mu, s] = zscore(x, varargin)
% [Z, MU, S] = ZSCORE(X, NORMALIZEFLAG, DIM, FLAG) computes the zscore, across all cells in x along
% the dimension dim, normalising by the total number of samples
%
% X should be an linear cell-array of matrices for which the size in at
% least one of the dimensions shoul... |
a296f9c476c0394eec46f74641999463a1bd3cd8df053cab4ba891227efd23e6 | MATLAB | 888 | 31 | #import <UnityAds/UANAApiAnalytics.h>
#import "UnityAdsUtilities.h"
typedef void (*UANAEngineTriggerAddExtras)(const char *payload);
static UANAEngineTriggerAddExtras triggerAddExtras = NULL;
void UANAEngineDelegateSetTriggerAddExtras(UANAEngineTriggerAddExtras trigger) {
triggerAddExtras = trigger;
}
@interfac... |
e225c21fae7e3eba17039d0ef1f9a99edd7a0f7c03c5bc3f7d6d0a2273cdb48a | MATLAB | 888 | 35 | function imf = li_upmemd(sig, fs, fd)
%LI_UPMEMD rewritten from the original upmemd
%
% $Author: Peng Li, Ph.D.
% $Date: Mar 24, 2023
%
nIMF = 2;
n = numel(sig);
rmf = [2.18*fd*2.^(floor(log2((0.5*fs) / (2.18*fd))):-1:0), fd];
maxn = numel(rmf);
maskAmp = std(sig, 'omitnan');
imf = nan(n, m... |
8a4e25d341878d4dedc9428bd0c79a4a5641dc469d6874c1533b4e1b1be578f2 | MATLAB | 890 | 25 | %% Create timeseries for turbulence
clear all
data_path='/Volumes/LASA/TBI_OpenNeuro/TBI_openneuro/timeseries/preprocessing/tbi_sch400/';
input_path='/Volumes/LASA/TBI_OpenNeuro/TBI_openneuro/timeseries/inputs_sch400/';
fnames=dir(data_path);
fnames=fnames(~ismember({fnames.name},{'.','..'}));
for s=1:12
load(ful... |
e136d9e2f39a368a51d09fd94220bb32afd5962a2a2a28ab98f48e7766d3b288 | MATLAB | 890 | 29 | function Experiment = set_up_keys(Experiment)
% Set Up Keys
% Input: Struct 'Experiment'
% Output: Struct 'Experiment' with field 'Keys'
% 'Keys' contains fields for each key that has a function during the
% experiment, the MRI trigger, as well as a list of the keys used to
% respond during the experimen... |
efce5cbc31067837d67855ae10619113a453483ef2fee341917d953630e27c7f | MATLAB | 890 | 45 | %% small program to simulate projections of a rotated and sheared image.
close all
theta = -45; %rotation and shearing angle
Im=double(imread('cameraman.tif'));
%rotate the image
Im2=imrotate(Im,theta);
[x,y]=size(Im2);
figure; imshow(Im2,[])
%project the rotated image
line=sum(Im2,1);
%compute matrix for af... |
5749127442a8d9ba0861baeaeea97056dbfdbe11233f2df26a8cdaded083e7f7 | MATLAB | 891 | 26 | % This file is part of the Matlab Toolbox for Dimensionality Reduction v0.7.2b.
% The toolbox can be obtained from http://homepage.tudelft.nl/19j49
% You are free to use, change, or redistribute this code in any way you
% want for non-commercial purposes. However, it is appreciated if you
% maintain the name of th... |
6347d7c7e66e73470216f83f5ea5b976e30a48ae2b405a8f239e0f57554f5011 | MATLAB | 892 | 28 | function [d] = det2x2(x)
% DET2X2 computes the determinant of a matrix X, using the explicit analytic
% definition if size(X,1) < 4, otherwise use the matlab det()-function. The
% input matrix X can be N-dimensional (up to 4 dimensions), provided the
% first 2 dimensions are equal. This function is also implemented as... |
aa6b11a78dbc072e7d3c6bcbf89746e0adfeac4883545f5e83892cbe72e3ab84 | MATLAB | 895 | 39 | function L = CrossValidationHDCheck(rip,dwEp,allEp)
nbEp = 10;
epV = regIntervals(allEp,nbEp);
L = zeros(nbEp,1);
Q = MakeQfromS(tsdArray({rip}),50);
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{... |
00a4cca1f7a901fbe681970738307f63d8d78d67876e28fe1c5e8c427d0276c5 | MATLAB | 896 | 23 | % This file is part of the Matlab Toolbox for Dimensionality Reduction v0.7.2b.
% The toolbox can be obtained from http://homepage.tudelft.nl/19j49
% You are free to use, change, or redistribute this code in any way you
% want for non-commercial purposes. However, it is appreciated if you
% maintain the name of th... |
09100466e3f78cbe184a7d3163bb94bb33a3291adc37ecb2d00e027f17fa19fb | MATLAB | 897 | 32 | function [x, y] = MakeHistogramData(xInt, yVec, int, distOption)
if distOption == 1
%% Plot histograms from 0 to 90
x = xInt:xInt:(90 - xInt);
x = [x', x']';
x = [0; x(:); 90];
angList = xInt/2:xInt:(360 - xInt/2);
angList = [angList; angList];
angList = angList(:)*pi/180;
angList = acos... |
dfafd61668681b18352967a06ab72ea79320947b2dfd4d3df5083d5336cba02e | MATLAB | 897 | 30 | function dataFolders = msBatchFindDataFolders(dirName, dataFolders)
%MSBATCHFINDDATAFOLDERS Summary of this function goes here
% Detailed explanation goes here
if isempty(dirName)
dirName = pwd;
end
if isempty(dataFolders)
dataFolders = cell(0);
end
dirData = dir(dirName);
dir... |
e72c53afadd7060e9879b0cb4fb126591d00e6132dd1181ea15ff9ea481f21a1 | MATLAB | 897 | 31 | function tf=awsExist(filePath,type)
%Equivalent to Matlab's exist function, but includes aws links.
%filepath - file path to check
%type - can be 'file', or 'dir' to say if file or directory is what you are
%looking for. Notice in AWS configuration, will not deffrinciate between
%both types so you can leave empty.... |
8e0e1ab912e09198fcd1d07dd09f27309be2438270456f7d5e2f3e23cc8aa558 | MATLAB | 898 | 25 | function h = plotInputsModel(fHandle, times, ipsiEye, ipsiPC,color, offsets, xlims, subplots, varargin)
% Just plot model fits
% NEW: single graph for all conditions
figure(fHandle);
if ~exist('subplots','var')
subplots(2) = subplot(1, 3, 2);
subplots(3) = subplot(1, 3, 3);
end
h = [];
for ii = 1:length(ipsi... |
61d216d8797fda83755c960117411a69b0765c0141ecc781ac9038467a3e398d | MATLAB | 900 | 29 | # module load matlab/R2018b
# matlab -nosplash -nodesktop
cd '/path/data/'
RSI = {'N0','NF','ND'};
for metricnum = 1:length(RSI)
metric = RSI{metricnum};
C = {'diffusion/ABCD_diffusion_PC_' metric '.mat'};
data = load(strjoin(C,''));
[uniqueA i j] = unique(data.subjid... |
e0e2592ccbef07581af8f3021fe071c9b1111f1e516ae937a7215ed4f1069d62 | MATLAB | 900 | 35 | function [ptsOut,indexSet] = reducePts_haa(pts, dst)
%Reduces a point set, pts, in a stochastic manner, such that the minimum sdistance
% between points is 'dst'. Writen by abd, edited by haa, then by raje
nPoints=size(pts,2);
indexSet=true(nPoints,1);
RandOrd=randperm(nPoints);
%tic
NS = KDTreeSearcher(pts');
%toc... |
319dd79ced37bf7cc4f0c041d9c8e2111a6365b59414c8edbb5749bf26fa3c66 | MATLAB | 903 | 31 | function dataFolders = msBatchFindBehavFolders(dirName, dataFolders)
%MSBATCHFINDBEHAVFOLDERS Summary of this function goes here
% Detailed explanation goes here
if isempty(dirName)
dirName = pwd;
end
if isempty(dataFolders)
dataFolders = cell(0);
end
dirData = dir(dirName);
d... |
d2db8c983e975d6eb7f5f7aa8935038d6b12d98fb51bc7aa0651e496cf6196a2 | MATLAB | 903 | 30 | function [nsizes avgsize] = calc_avg_adj_neighborhood_size(adj_list)
% This is just a v simple function that gives you a sense
% of how big the neighborhoods in your ADJ_LIST are.
% License:
%=====================================================================
%
% This is part of the Princeton MVPA toolbox, released... |
1cc2c9cdd890e9ae040a139753ede6b4ffd41967d0aa1c498d0e26f5d73527c0 | MATLAB | 904 | 33 | function plot_transients(transients_,t,sig,sig_str, plot_th)
locs_ = transients_.loc;
w_ = transients_.width;
p_ = transients_.prominence;
pks_ = transients_.peak;
th = transients_.filtered_sig_median + transients_.oneMAD;
th2 = transients_.filtered_sig_median + (transients_.oneMAD *2... |
5d8c6523fa5d71a0c772803e5d6f45d75f79c0642b851bc67e10a1f10e18128f | MATLAB | 904 | 33 | function [y] = cellcolremove(x, cols)
% [Y] = CELLCOLREMOVE(X, COLS) outputs cell-array Y with the same dimensionality as X
% Each cell in Y has the indexed columns COLS removed from the original corresponding cell in X
%
% X (and Y) should be linear cell-array(s) of matrices for which the number of rows
% should be... |
f911418b6e69e7ed7537feed410d9b28eefb3fdf1b60b5d584a8182704c401c1 | MATLAB | 904 | 25 | % function for providing starting points of optimization
function startpoints = UMStartingPoints(cellinput)
% process cellinput
np = length(cellinput);
assert(np==2 || np==3,'Unexpected number of parameters to create starting points.')
for i = 1:np
input = cellinput{i};
assert(length(in... |
dba7517d320de90f28bda7335050946cad41ee3754d57b509b480f64ab4a4d63 | MATLAB | 905 | 34 | function out = LK_RandomPointsInCircle(myR)
%
% LK_RandomPointsInCircle creates random points drawn from a circular area.
%
% Input: structure with fields
% maxR --> maximum radius
% minR --> minimum radius
% N --> number of points to create
% centerX --> x-center of circle
% centerY --> y-center ... |
f5460c8b7d20f4b2d8eef28af0526d8760a36e640286ebfa56a1b537329fa6f4 | MATLAB | 905 | 32 | function DatAnalysis(rootFolder,fction,fbasename,datIx,varargin)
% USAGE:
% DatOperations(fbasename,shankIx,chanIx)
% INPUTS:
% rootFolder: root folder of the data
% fction: name of function to be called
% fbasename: file base name
% shankIx: vector of shank indices to be treated
% chanIx (opti... |
228857279d6a42412c544991e2bd56ae6fa94b6905af444523dd597454caf387 | MATLAB | 906 | 39 | function Out = conjModelprediction(ChanType,Ori,Color,beta,bias,w)
%%%% this function computes trained RL model performance on a set of
%%%% stimuli
Out=[];
for o=1:length(Ori)
for c=1:length(Color)
OS=Ori(o); CS=Color(c);
DV_ot=OS.*w;
p_o1=1/(1 + exp(-1*beta*(DV_ot-bias)));
... |
c1e5e72decad10f27e8fe4f1ece6184abbcf94704e0bfd1a0d150260b4927d8d | MATLAB | 906 | 34 | function [class_args] = default_class_args(nHidden)
% [CLASS_ARGS] = DEFAULT_CLASS_ARGS([nHidden])
%
% nHidden (optional, default = 0)
% License:
%=====================================================================
%
% This is part of the Princeton MVPA toolbox, released under
% the GPL. See http://www.csbmb.prince... |
083d1578507835ffb74ff238e2c5b65f540665861c3327c696e2c0180275b638 | MATLAB | 907 | 36 | function fdln = fdlnSortLines (fdln)
%This function sorts Fiducial Line structure array such that they are orderd left to
%right, tissue interface at the begning of the array
%% In case class is empty
if isempty(fdln)
%No lines in the structure, so consider it sorted
return;
end
%% Sort from left ... |
c42ca59f798e4409f7fcbf54f85bf381a38f17a586bfba9dbfdd6016a60bc407 | MATLAB | 907 | 47 | function L = SpkTrainSpatialValuation(pf,S,x1,x2,X,Y,testEp,trainingEp)
X = Restrict(X,testEp);
xs = Data(X);
ys = Data(Restrict(Y,testEp));
t = Range(X);
f = zeros(length(t),1);
r = rate(S,trainingEp);
S = Restrict(S,testEp);
xx = floor((length(x1)-1)*contrast(xs))+1;
yy = floor((length(x2)-1)*contrast(ys))+1;
ix... |
5912830a06562fc6323d919aff1d9367a694bc443d7fd16f528ee461ea389999 | MATLAB | 908 | 34 | function CalibrateCamera()
Fs = 1250/32;
[dumy fbasename dumy] = fileparts(pwd);
[whl,t,GoodRanges] = LoadPosition(fbasename);
load('Analysis/BehavEpochs','wakeEp')
X = Restrict(tsd(t*10000,whl(:,1)),wakeEp);
Y = Restrict(tsd(t*10000,whl(:,2)),wakeEp);
figure(1),clf
plot(Data(X),Data(Y))
done=0;
while ~done
fp... |
8c7222088b0ee4e7665deb7409597536d7b15f1b7912f58f5969227009b1c84b | MATLAB | 908 | 30 | function [] = display_history(subj,objtype,objname)
% Display the object's history field in a friendly way
%
% [] = DISPLAY_HISTORY(SUBJ,OBJTYPE,OBJNAME)
%
% You can use this to display the SUBJ's own history if OBJTYPE ==
% 'subj' and OBJNAME == ''
% License:
%========================================================... |
adf772124bc38f75b40cf31423aaa2297b9f287808dc2814b29f73786bf9c909 | MATLAB | 909 | 39 | function ded(cc,hs,he)
% cc - edit number
% hs - handle to plot
% he - handle to edit
% This file is part of the Matlab Toolbox for Dimensionality Reduction v0.7.2b.
% The toolbox can be obtained from http://homepage.tudelft.nl/19j49
% You are free to use, change, or redistribute this code in any way you
% wan... |
c2eed876c8cf7f1343bdc684eae0df8ea39ef2a5ebff2d9eb4109584862b2971 | MATLAB | 909 | 48 | function iso = mergeCloseIntervals(is, thr, varargin)
% Merge together intervals that are closer than a given threshold
%
% USAGE:
% iso = mergeCloseIntervals(is, thr, OptionName, OptionValue)
%
% INPUTS:
% is - an intervalSet
% thr - a distance threshold; if two consecutive intervals are closer than... |
110a1921483e0cae2c127c307ea06a4a0670e076cbbea7a66b5a62d1a447146d | MATLAB | 912 | 25 | function [dFFTraces] = dFF_FixedBaseline_20211208(RawTraces, BaselinePeriod)
% Calculating dF/F using a fixed baseline window on the raw traces
% Michelle Cahill 20211208
% RawTraces: m x n matrix of raw fluorescence. m = number of frames; n =
% number of individual traces. Df/f will be calculated for each
% ... |
257c12b6234dc0337452afa466a5da7da885c947ece536fa5528fb7a8da33d53 | MATLAB | 912 | 28 | function [xph] = rectify_rotation( xph )
% *WAVE*
%
% RECTIFY ROTATION rectifies the sign of rotation in the complex plane,
% so that the resulting datacube has rotation in
% the positive-frequency direction
%
% INPUT:
% xph - analytic signal representation of ... |
9280a612ce80b7b4d3723e6d4c569bd29140c368e6f9fd9d9ed776b7bbe02654 | MATLAB | 912 | 34 | function changeDispersionParameterA2QuadraticTerm(subjectPath)
% This function recomputes stack alignment
% Written at Feb 27, 2020.
%%
volumesPath = [subjectPath '/OCTVolumes/'];
%% ScanConfig
pt = [volumesPath 'ScanConfig.json'];
j = awsReadJSON(pt);
j.volume.octProbe = changeField(j.volume.octProbe);
j... |
ab2b03d3a64a3918fe6376042b23ba370142815567c7547128e039bebab10054 | MATLAB | 913 | 37 | function [t_st t_en l singleIx doubleIx] = LoadOptoPulse(fbasename)
% USAGE
% [t_st t_en l singleIx doubleIx] = LoadOptoPulse(fbasename)
%
% read fbasename_optoStim.mat and retrive the pulse info (not oscillatory)
%
% OUTPUT:
% - t_st / t_en: ts of start/end illumination times
% - l: illumination du... |
d1c07a17053098d0a57a4a573ccfef7e0b4bcada06800d6014060b95b61a7911 | MATLAB | 913 | 26 | function [imOCTOut,imHistologyOut] = overlayOCTHistology(imOCT,imHistology,histologyToOCTT,...
isMoveHistologyToAlignWithOCT)
% imOCT - OCT slide
% imHistology - Histology slide
% histologyToOCTT - affine transform
% isMoveHistologyToAlignWithOCT - set to true of you would like to move
% histology to OCT fa... |
111c3d4e29d793cb939b45afe7a18d08b9d50c8d47ccbc9d1109ddcb0d0aefe7 | MATLAB | 914 | 41 | function a=cronbach(X)
%Syntax: a=cronbach(X)
%_____________________
%
% Calculates the Cronbach's alpha of a data set X.
%
% a is the Cronbach's alpha.
% X is the data set.
%
%
% Reference:
% Cronbach L J (1951): Coefficient alpha and the internal structure of
% tests. Psychometrika 16:297-333
%
%
% Alexandros Leontit... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.