sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
68ee9a0a5f00bce25743db8fd3e53cdb7444b9973e829f92ecc42a8086f3437c
MATLAB
780
28
function [Xcr, Ycr, Zcr] = meshcross(q,X,Y,Z) %meshcross - returns cross product of q with meshgrid input at each point %on the grid. siz = size(X); assert(length(siz) == 3,'Meshgrid dimensions != 3'); assert(siz(1) == siz(2)); assert(siz(2) == siz(3)); assert(siz(3) == siz(1)); %Iterate through all x, y, z values, ...
7f3d14ed9ff0a0496ca7d68e91352dd374bb08362f8b87d1d046657f925aeb02
MATLAB
780
21
%% Script to Load Deafult Directories % EDIT TO YOUR EXPERIMENTS DIRECTORY: DefaultPath='C:\Users\Vladimir\Documents\Doctorado\Experimentos\'; if exist(DefaultPath,'dir')==0 DefaultPath=pwd; end %% DO NOT EDIT (preferably): % Folder with all the files with data and processings: EXPID.mat FolderNamePD='Processed Dat...
de9c60658be70e7af577886e5bc9824e73b79dbc7fd5b5f7c443eaf094a8bc1f
MATLAB
785
15
function Vr = Reconstruct_XY_Projected_Vector(Vp,Ap,Ly,Rx) % Input: % Vp is the projected vector given as a 3D coordinate [x,y,z] (assuming origin at 0). % Ap is the rotation angle of the plane in *radians*. The direction (sign) of this angle is from XZ. % Rx is a function for the rotation matrix around the x-...
f4439153cf5c65bcb95481a06485854b78b6d5ab4198b85b3b535c76e1f7dc50
MATLAB
785
23
function showgrid(ux,uy,downsample,lim) if nargin<3; downsample = 1; end; sizex = size(ux,1); sizey = size(uy,2); ux = ux(1:downsample:end, 1:downsample:end); uy = uy(1:downsample:end, 1:downsample:end); if nargin<4; scale = 3; end; % Scale vector to show sm...
21495d57b10f5bdcc4772a62b761435c0bd1060ab4df1c2a2a78862dc03a8264
MATLAB
786
39
function dll = get_dll(session, channel, unit, fold, trials, times) % Get true delta log-likelihood of specific neuron % % Parameters % ---------- % % - fold: integer scalar % Fold number % - trials: vector % Trial indeces % - times: vector % Time of study % % Returns % ------- % - dll: scalar % Delta log-likel...
7c10e1e1dbe58e82d610691ebdbe800a6ace0ff9b0948377c648997741ec09ad
MATLAB
786
37
function y = ir_sinc_nopi(x) %function y = ir_sinc_nopi(x) %| %| no pi version of "sinc" function, because matlab's sinc() is in a toolbox %| %| Copyright 2001-12-8, Jeff Fessler, University of Michigan %| Modified by M Allison to not have a pi. if nargin < 1, help(mfilename), error(mfilename), end if streq(x, 'test'...
e73379b57d793827d2f2b4a1adf06a566d8a0ec26cfac8e238ebd716af03ed21
MATLAB
787
24
clear; close all; addpath('E:\Programs\Baseline Wander Comparison\ECG Normal Sinus\30SecSegmentsParams'); addpath('E:\Programs\Baseline Wander Comparison\ECG Normal Sinus\30SecSegments'); for k = 0:190, filename = ['seg_' , num2str(k,'%3.3d')]; load(filename,'data','chname'); filename = ['seg_'...
01514e27f098ecf2c0b45c6ca006f05b18164c362f0d6ad114b457d2887ca246
MATLAB
788
19
function plot_lines_area(AX, resection_time) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Dashed line %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear line % axes(AX); y_lim = get(AX(1), 'YLim'); hl = line([resection_time, resection_time], y_lim); set...
bcec53a509c95bf54389037f765a461cbc78f0ed2a50c207256d9dd779cd30c8
MATLAB
788
27
function pvals = roc_PSTH(hit_psth, fa_psth, win, testwin) % ROC_PSTH performs ROC analysis. % ROC_PSTH(HIT_PSTH, FA_PSTH, TAG, WIN, TESTWIN, STAGE) performs ROC % analysis of input data (HIT_PSTH and FA_PSTH) of length WIN in a test window % TESTWIN. % See also ROCAREA % Balazs Hangya, Panna Hegedüs % hangy...
e6fa05c77639193260b5e2b931cb57c8cb5bdf8c43a3f4fa978cbe5fb831b8b8
MATLAB
790
30
% % Test program for RelativeSpectralPower % % Dependencies: RelativeSpectralPower() from the Open Source ECG Toolbox % % % Reza Sameni, June 2022 % reza.sameni@gmail.com % Open-Source Electrophysiological Toolbox (OSET) % https://github.com/alphanumericslab/OSET.git clc clear close all; load('SampleEC...
c608add229d1e0b675001e612d6c0ed3f15b25d4ad0b6675d78b3edb7c6101df
MATLAB
791
29
function hMenu = menuCheckbox(menuTag, label, doUncheckOthers) %MENUCHECKBOX Check the label selected, optionally uncheck the rest if nargin < 3 doUncheckOthers = 1; end hMenu = []; try if ischar(menuTag) hMenu = findobj('Tag', menuTag, 'Type', 'uimenu'); else ...
a205457f7c7b2fb2ce1db35b28226c1f61cbf23ecde56aafeae904b2b690b215
MATLAB
792
34
%% %Name: char2rgb %Created by: Pratik %Created on: 27 July 2018 % %Description: Converts a character color value into its numerical RGB equivalent %Input: A lowercase character for any RGBCMYWK color %Ouput: A 1x3 vector with the equivalent numerical RGB values % %Usage: vector = char2rgb('color'); %% f...
424c97567d9a19d273e9e3b201ec5cc40250b46888db9529de7d49982eae0646
MATLAB
794
34
% test fetal ECG fractal dimension calculation % Reza Sameni, Copyright March 2006 % Modified June 2018 % clear; close all; clc; %load patient165_s0323lre; data = data(1:10000,4)'; load FOETAL_ECG.dat; data = FOETAL_ECG(:,4)';clear FOETAL_ECG; figure; plot(data');grid; %plot(data(6:8,:)');grid; N = length(data); for ...
66b7ed41b11e8157846fcadf0552dc32641f41eb58d3c52f65d7731b06131cd4
MATLAB
794
52
function get_lcmodel_correlation(d) for k=1:length(d) fps=get_subdir_regex_files(d{k},'.*PRINT$'); fps = cellstr(char(fps)); for kk=1:length(fps) fileid=fopen(fps{kk}); go_after('Correlation',fileid) go_after('Correlation',fileid) go_after('Glu',fileid) go_after('Glu',fileid) go...
a27fee623f04bc3e427a563da02c39f646f2fd3f4343ea2b3fb1aa39569cb4ba
MATLAB
795
41
function out = eigs(ob, varargin) % compute largest magnitude eigenvalue of object by calling eigs, % which in turn probably uses the power method. % this may be slow for big objects because it is iterative. warn 'todo: i could not get this to work' % A = Gdft('mask', true(8,6)); % eigs(A, 1) if numel(varargin) ~= 1...
be7436de89c5a5b6082cdb4b4563515efca3e7a24de2b1997469e6cfb0c82604
MATLAB
796
27
classdef SonoNERFfLossLayer < nnet.layer.RegressionLayer % This class implements the L1 loss layer for use in neural networks. methods function layer = SonoNERFfLossLayer(name) % Set layer name layer.Name = name; % Set layer description layer.Description...
c8ce28a5d05f5f30da96c7667ff3f7023a0be4ec9013c24cb7766b2f37e8f08f
MATLAB
796
29
clear shrink_ratio = 1; flat_map_data = load("flat_map_data_10um_v2.mat"); plotting_1 = flat_map_data.plotting_1; plotting_2 = flat_map_data.plotting_2; pre_flat_index = flat_map_data.pre_flat_index; pre_flat_dimention = flat_map_data.pre_flat_dimention; mask = zeros(pre_flat_dimention, "uint8"); mask(p...
d6f5e5599abe081d14fb4fb425904e6a012c76218694200fa43b7a85fc03ffbe
MATLAB
797
26
function peaks1 = LocalPeakDetection(x, half_win_len, number) N = length(x); peaks = zeros(N,1); peaks1 = zeros(N,1); half_win_len = round(half_win_len); x = abs(x); for j = 1:N index = max(j-half_win_len,1) : min(j+half_win_len,N); % if (x(j)>=0 && max(x(index))==x(j)) || (x(j)<0 && min(x(index))==...
4b4c2b853855a383d5fca0e2fd407712fccb4603ed7458199044a08b82a504ef
MATLAB
799
33
classdef h5_conversion_options < handle % % Class: % adi.h5_conversion_options % % See Also: % adi.channel.exportToHDF5File properties max_samples_per_read = 1e8 deflate_value = 3 %(0 - 9 for gzip %0 - no compression %9 - most compression ...
32cded00fb976088815b2d4c55f748a0a6413c29a184b934e66160b5c63db609
MATLAB
800
24
function [shiftsBack, shiftsForward] = shiftRange(nSamples, nShifts, shiftFactors) %SHIFTRANGE if ~isempty(nShifts) [shiftsBack, shiftsForward] = deal(cell(nShifts*2 + 1, 1)); shiftFactors = -nShifts:nShifts; else [shiftsBack, shiftsForward] = deal(cell(numel(shiftFactors), 1)); ...
2d547651ef2e2779f65ed1d969a2414192d5ef558054d2b3520b38e6cd3077e1
MATLAB
801
28
function openLog(obj, logFilename) %OPENLOG Open the log file if nargin < 2 || isempty(logFilename) logFilename = [datestr(now(), 30) '.log']; end % no directory specified in filename if isempty(fileparts(logFilename)) logDirname = fullfile(obj.outputDir, '.jrc'); if exist(l...
9523325a52ef1fc9d360fb93e29afc726f731024abdb9c0f1f93cf16f2151022
MATLAB
802
26
function chain = spa(X,k,M) % Projections routine for the Successive Projections Algorithm using the % built-in QR function of Matlab % % chain = projections(X,k,M) % % X --> Matrix of predictor variables (# objects N x # variables K) % k --> Index of the initial column for the projection operations % M --> N...
b6136423f64770524f9feb23a7b35f9e3c4e4a5971f9eae9023ffd0014394a89
MATLAB
802
24
%% compare diffrent sharp track iterations between people % load all cluster cordinates clc clear [file, path] = uigetfile('*.csv','MultiSelect','on');%When the user clicks the load psetion button, a window should open to enable the user to select a file. cd(path) %% for i = 1:length(file) cell_coordinates{i} = rea...
b726721342d1261dcdff340d5d3fe483eecae57a686af8722cf2b577adf17660
MATLAB
802
36
function lit = haslight(axish) %HASLIGHT Check if axis handle has a light attached % %Syntax % lit = haslight(axish); % %Description % LIT = HASLIGHT(AXISH) sets LIT to true if the axis specified by axis % handle AXISH has a child of type 'light', and sets LIT to false otherwise. % %Examples % > lit=haslight(gca) % lit...
1cd3cd4f4314be7aaf96d0f7403e2806d000fe266def0a36af7d113762abc2f3
MATLAB
803
30
function bases = make_bases() % Make basis functions % % Returns % ------- % - bases: struct % time/delay basis functions info = get_info(); % bases % - delay delay_values = 1:info.num_delays; delay_delta = 2 * info.probe_time_resolution; delay_knots...
14ad030068d014f08107e7ca63ceda4a559a892e830582f48a2bdefdbb8a49f2
MATLAB
804
36
function B = stretch(A, sc, st) asize = [size(A, 1) size(A, 2) size(A, 3) size(A, 4)]; dim = length(asize); s = ceil(asize ./ st); newsize = sc .* s; B = zeros(newsize); order = cell(dim, 1); ind = cell(dim, 1); oldind = cell(dim, 1); for d = 1 : dim ind{d} = []; for i = 1 : sc(d) - st(d) ind{d} = [ind{d}; sc...
fa4bd8f5d1322ffb20dbf51b3b8e9ab45463e1dc58063cccbedab58912b3bf1a
MATLAB
805
21
% Authors : Tatjana Schmitt & Simon Wadle 2019-2023 function dF_F_image_resized = dF_F_resized(resized_image) %function fits baseline pixelwise with chronux toolbox %and calculates dF/F for each pixel total_frames = size(resized_image,3); time_for_fit = [1:total_frames]'; [x_pixels, y_pixels, z_pixels]= size(r...
01eb510c063d84bc29d979494f2e77fc137b8c555cafa43728938674e6cca492
MATLAB
808
29
function Answers = cleanup_PVT(AllAnswers) % Take table from AllAnswers, save relevant information and make it in the % correct format type. Answers = AllAnswers(:, {'Participant', 'Session'}); Answers.Participant = string(Answers.Participant); Answers.Session = string(Answers.Session); Answers.Trial = cell2mat(AllAn...
f4c82c819610ca346797a7fb09ecfa8897bfaab6e5dcdf2320d9e4e65c923700
MATLAB
808
20
function [nLoads, nSamplesLoad, nSamplesFinal] = partitionLoad(nSamples, nSamplesMax) %PARTITIONLOAD Compute the number of samples to load from a file nLoads = min(max(ceil(nSamples / nSamplesMax), 1), inf); nSamplesLoad = min(nSamples, nSamplesMax); if nLoads == 1 % first load is last load, use nSamp...
8a168fe0309b2a30ccb3578d1c95f16f0ee6e260842993a2b9b573fb33b5ab2a
MATLAB
809
32
%% [cols,alpha] = chooseColors; lims = [-8 12]; tone_trace = tone_trace * lims(2); tone_trace(tone_trace == 0) = lims(1); figure('Position',[100 100 1200 300]) hold on plot(proj_trace,'k') area(tone_trace,'FaceColor',[.7 .7 .7],'FaceAlpha',alpha,'LineStyle','none','BaseValue',lims(1)) ylim(lims) set(gca,'XTick',[0:3...
8d2fa514473d482270ca3daffc703e670631f9b8304560f57a593bcf9ccab0a0
MATLAB
811
43
load('D:\Data\LSM\Preprocessed\Clean\Waves\LAT\P01_LAT_BaselineBeam_Clean.mat') freqs = 1:20; [Power, ~, TF.times] = wavetransform(EEG.data(68, :), EEG.srate, freqs, 3, 15); Power = squeeze(Power); EEGw = EEG; EEGw.data = Power; EEGwe = pop_epoch(EEGw, {'S 3'}, [-2 4]); t= linspace(-2, 4, 1500); %% close all Me...
2bf080fbd5450d8dd1db61ceae6b1578dffcb110a8c5480693a4565975cc4d9e
MATLAB
812
25
function p = fpval1(x,df1,df2) %FPVAL F distribution p-value function. % P = FPVAL(X,V1,V2) returns the upper tail of the F cumulative distribution % function with V1 and V2 degrees of freedom at the values in X. If X is % the observed value of an F test statistic, then P is its p-value. % % The size of P is t...
6f3cf523c9957be23639150447bf41c9b8830c706ce6517f4e0bdd0803005637
MATLAB
812
19
function [Clusters_Indices,Clusters_Centroids] = Cluster_Data(Data_Mat,Algorithm_Name,Clusters_Vector) switch Algorithm_Name case 'k-means' eva = evalclusters(Data_Mat,'kmeans','silhouette','KList',Clusters_Vector); [Clusters_Indices,Clusters_Centroids] = kmeans(Data_Mat,eva.OptimalK); case 'Gaussian Mixtu...
b7c48653c1e54c0c5f79b23d0ed8d737a91877051e1134c8403fdec785b438e2
MATLAB
812
18
function [templates, maxdist, pointdist] = build_templates(classes,features) % function [templates maxdist] = build_templates(classes,inspk,pointdist) max_class = max(classes); feature_dim = size(features,2); templates = zeros(max_class, feature_dim); maxdist = zeros(1,max_class); pointdist = zeros(max_class,feature_...
d3d1884aa9d83165a6ac7b7ff0dc8f18a14469b2549fde95c74168eb10f807e3
MATLAB
812
25
clear clc %% cluster cordinates load cd('E:\') [file, path] = uigetfile('clusters_coordinates.csv'); datafile = fullfile(path, file); X = readtable(datafile); %load all_cell_parameters cd('E:\2022\all_cell_parameters') [file, path] = uigetfile('cell_type_parameters.mat'); datafile = fullfile(path, file); loa...
24327b82d234034f809e8812893af697666a50dcd5aee789870543fd74434835
MATLAB
813
26
function terashita20191021 cd('C:\Users\C238\Desktop\CheetahData\2019-10-16_15-13-58 17301-04'); dpath=('C:\Users\C238\Desktop\CheetahData\2019-10-16_15-13-58 17301-04\'); dpath3=('C:\Users\C238\Desktop\CheetahData\2019-10-16_15-13-58 17301-04'); % data=load([dpath '15103_190313_98__'],'-ascii'); dpath3 load 17...
a6c7a4b9ac2334b5c407c8e5f0e065241c147158e9e4ff4f08a85a371e154c95
MATLAB
813
40
function [gl_node gl]=global_efficiency_wu(w) %calculate global efficiency %INPUT: w = inverse FCG (functional connectivity graph) %OUTPUT:gl_node = global efficiency per node % gl = total global efficiency of the network % distance = matrix which preserve the weighted shortest path length % binary = m...
f4e69e83e2d4883961fb5b4557e90f63f18e0ff8c51f3604dcdcbdf4d7742945
MATLAB
813
46
function PlotElectrode(x,y,r,Label,Gray,zl,fs) % Copyright 2009-2011 Thomas Koenig % distributed under the terms of the GNU AFFERO General Public License if (r == 1) xc = [x-1 x+1 x+1 x-1 x-1]; yc = [y-1 y-1 y+1 y+1 y-1]; patch(xc,yc,ones(size(xc))*zl,[0 0 0]); return end if numel(Gray) == 1 Gray...
0ce58027a83aed8af9d7970973b1fe114a4f6d8c57f80a861f2b1cf3ebbfbc2c
MATLAB
816
40
function [vtx, vty, vtz] = dipolefan(rx,ry,rz,theta_t) sizr = size(rx); % GRIDS % Get back R and unit vectors from passed grid R = sqrt(rx.^2 + ry.^2 + rz.^2); %calculate |r| at each point %getting normal vectors erx = rx./R; ery = ry./R; erz = rz./R; %Get theta and phi for each point in grid theta = acos(rz./R); ...
69444613bcb81932b0fff1fd7fa61dfa2eedf58912b213eb7503afdf745ea13e
MATLAB
816
31
function [mrprot] = parse_siemens_shadow_mrprot (dcm) % [ mrprot] = parse_siemens_shadow(dcm) % function to parse siemens numaris 4 shadow data % returns mrprot info % does not work with arrayed dcm() if (size(dcm,2) > 1) error('parse_siemens_shadow does not work on arrayed dicominfo data!') end % n...
264655ef1874f7a50600f825daf29795bc728543e9646e0bde54e85bb7b3dd84
MATLAB
818
22
function [c_partition,allegianceMatrix,modularity] = genRobustCommunityFromASeries(A, gplus, gminus) % for consensus_comm_wei % C is a pxn matrix of community assignments where p is the number of optimizations % that have been performed. n is the number of nodes in the system. C gives the real partitions. n = size...
c6808c508da678625f45d05cb2f22d920de4053bd46da79f17e506d0e78daaa2
MATLAB
818
24
function subsetFields(obj, keepMe) %SUBSETFIELDS Subset all data fields, taking only those indices we want % to keep, prior to rearranging or deleting vectorFields = obj.unitFields.vectorFields; hFun = @(vals, indices) vals(indices); for i = 1:numel(vectorFields) fn = vectorFields{i}; ...
f3af828cbb57ad2d24492fef2729431b934c0bf800999179ccda740b5d7ed70d
MATLAB
819
33
function MIClustering(x,kneig,algo) % hierarchical clustering using the grouping property of mutual information % output: dendrogram % x....input data mxn m...channelnummer n...sampling points m<<n % kneig... k nearest neigbor for MI algorithm % algo ... 1=cubic 2=rectangular %default-values if ~exist('kneig'),...
ca5241925286dde42cb647affc1f7a74977a27e7f180b93f78b0a37d744b746d
MATLAB
820
24
function Bursts = burst_averages(Bursts) % gets mean values of all the peaks in a burst, so long as the fieldname is % lowercase, and the number of items is equal to the number of peak ids. % Part of Matcycle 2022, by Sophia Snipes. Fields = char(fieldnames(Bursts)); uppercase = isstrprop(Fields,'upper'); Fields = str...
e6e6f3e8ca374a4eef7adb3a82d28e1e3d48f2ef8c36f6d0b41d8380580328c1
MATLAB
820
21
% A self contained function to present cell connectivity % ScatAdj between S and other celltype function [] = Paper2FigS1_ConnCell(NnS, PreSInd, SX, SY, ScatAdj,... N_HC, n_S_HC, CellType,Color) hold on S = scatter(NnS.X(PreSInd),NnS.Y(PreSInd), '.'); S.MarkerEdgeColor = Color; scatt...
81a67415e900f3fd79ef04d40eac6e57c6acda8dc393638326bc0514f651b52d
MATLAB
821
30
function [sortCH, sortSQI] = VotingSQIs(SQIInds) % % [sortCH, sortSQI] = VotingSQIs(SQIInds) % Voting between different SQIs % % Fahimeh Jamshidian Tehrani, % jamshidian.t@cse.shirazu.ac.ir, % fahimeh.jt@gmail.com % February 2020 % % input: % SQIInds: different input SQIs % output: % sortCH: ranked channel number a...
b2405e81efd59d5dad4ca51bc4ef7915d38abfdc110d03b47e4ff293636acfc6
MATLAB
822
30
function out = Intense2rgb(data,cmap,clims) % function out = Intense2rgb(data,cmap,clims) % take 2d data and return rgb image, based on given colormap (gray is % default) if nargin < 3 clims = [min(data(:)) max(data(:))]; end if ( nargin < 2 || isempty(cmap) ) cmap = repmat(linspace(0,1,64)',1,3); end cmapLe...
4f533ce853b778c6b16c0b1c1ab760bb32223428e5640615b9f2cddd85d029b9
MATLAB
823
28
function ob = gg_Gnufft(om,M,Msp,R) %function ob = gg_Gnufft(om, M, Msp, R) % % Object constructor for Leslie Greengard's 2-dimensional NUFFT using separable % gaussian interpolator. % % in % om [Min,2] "digital" frequencies in radians % M [1] image dimensions (N1,N2,...,Nd) % Msp [1] # of neighbors used % R [1] ove...
5b651040ba6ac8759b55d9390099bbfcb8aae9a8aa6d87e2ffe4299f177acc2e
MATLAB
825
20
function inconsistencies = inconsistentFields(obj) %INCONSISTENTFIELDS Check all fields have the correct sizes inconsistencies = inconsistentFields@jrclust.interfaces.Clustering(obj); % also check all clusterCenters are unique if ~ismember('clusterCenters', inconsistencies) % find all putative ...
66033f7d990b034994f3c74130b48963d2e3dcb46862de32ca3f02c1f2f9305d
MATLAB
826
29
% create the negative Gamma model % ------------------------------------------ % This file is part of the adaptative_threshold SPM plug-in % Copyright (C) Cyril Pernet and Chris Gorgolewski 2012 classdef NegativeGamma < Gamma methods function obj = NegativeGamma(shape, scale, mu) if nargin == ...
957afa3845e4b34c3059dd259dbdd8d8dbd117bba58dbbb0bdbff1c6c90f924a
MATLAB
826
21
function computeQualityScores(obj, updateMe) %COMPUTEQUALITYSCORES Get cluster quality scores computeQualityScores@jrclust.interfaces.Clustering(obj, updateMe); unitVmin = squeeze(min(obj.meanWfGlobal)); unitPeaks_ = jrclust.utils.rowColSelect(unitVmin, obj.clusterSites, 1:obj.nClusters); try ...
200d3e01dc287ea148d5e97b966361466ac683560e4aaefed2f6aaf5e9782b8d
MATLAB
827
34
function out = Ragu_CollapseMSFeatures(in,BetweenDesign,WithinDesign) [ngroups,nconds,~,~] = size(in); out = nan(size(in)); if isempty(BetweenDesign) BetweenDesign = ones(ngroups,1); end if isempty(WithinDesign) WithinDesign = ones(nconds,1); end if ngroups ~= numel(BetweenDesign) error('Group sizes mis...
8f1e787ce8adfea235cbc3697faae3644f1d77fe4cac138714bffd8c51a5efed
MATLAB
827
31
%% clear clear close all clc %% load ecg load ecgptb.mat %% prepare data ecg=ecg(10*fs+1:20*fs,:); % 10 sec multichannel ecg L=size(ecg,1); % ecg length tst=(1:L)/fs; % time stamp w1=.75; % window length of the first median filter used in base line removing w2=.9; % window length of the second median filter used in ...
be3e2718305747beb391515d3b3e46e1318beef548bd75b8a168c6788535fa63
MATLAB
827
27
function [skw, m, sd] = skew(data) % skew - Skewness of a matrix data (over the second dimension). % % Syntax: [skw, m, sd] = skew(data) % % Inputs: % data: N channels x T samples data matrix. % % Outputs: % skw: Skewness vector (N x 1). % m: Mean vector (N x 1). % sd: Standard deviation vector (N x 1). % % % ...
e5502cb17e74d1a65f7ba0d9ff7334e808feb39fb9d2e4e121ae42584c100369
MATLAB
828
30
% Only if flag_location_legend = 1 the function deals with the position of the % legend function set_fonts_lines(... ha, ... flag_location_legend) line = 1.5; marker = 8; font = 20; fontaxes = 18; set(0, 'ShowHiddenHandles', 'on') hl = findobj(ha, 'Type', 'line', '-not', 'LineStyle', 'none'); set(hl, ...
2c0a5cf7c577f86a92659ed2a9373a9939a17b67d4a75955a4cc9a88443abd37
MATLAB
829
24
function clusterMean = nanmeanInt16(spikeWindows, iSite, sites, hCfg) %NANMEANINT16 iSiteNeighbors = hCfg.siteNeighbors(:, iSite); trWav = nan([size(spikeWindows, 1), numel(iSiteNeighbors), numel(sites)], 'single'); uniqueSites = unique(sites); nUniqueSites = numel(uniqueSites); uniqueNeighbor...
b133ed573c8122dcb826e3c145b5a6ed226f623a2e3de96baa9fb4c5c8d437be
MATLAB
829
26
Experiment=Experiment(Experiment~='\'); % NAMES PATCH %% PLOTS [New_Index_Merged,~,RASTER_COND]=SortNeuronsCondition(R_merged); % Plot_Raster_V(RASTER_WHOLE(New_Index,:),fs); RASTER_COND=RASTER_COND(New_Index_Merged,:); Plot_Raster_Ensembles(RASTER_COND,fs) Label_Condition_Raster(Names_Conditions,R_Condition,fs); ...
d6f126a739784c8a71249d5787451d2ed36f16090d718ea2fa606e24ae19a514
MATLAB
829
34
% Author: Corentin Wicht, LCNS, 2018 % corentin.wicht@unifr.ch % This work is licensed under a Creative Commons Attribution-NonCommercial % 4.0 International License (CC BY-NC) function Fig=MessageBox(Text,Title,FontSize,Width,Height) % This function is an updated version of msgbox () enabling to resize the % message...
8776412fab993184efa2daa89790725d6373ab4a22df4e800a03cd10b3f5d936
MATLAB
830
23
clear [file, path] = uigetfile('*.mat');%When the user clicks the load data button, a window should open to enable the user to select a file. datafile = fullfile(path, file); %save path load(datafile) close all %% f4 = figure; set(f4,'color', [1 1 1]); set(f4,'position',[50 50 500 750]); cells_matrix = ~contains(clust...
067e80977c0600bbb0c9c331ce704b9e89946d701a8cb1e9a24696e3544c78b0
MATLAB
831
36
function D=hbf_BEMOperatorsPhi_LC(meshes) % HBF_BEMOPERATORS_PHI_LC makes the double-layer (D) matrices for LC BEM % % D=HBF_BEMOPERATORS_PHI_LC(meshes) % meshes: BEM geometry, [N x 1] cell array of hbf structs % % D: Double-layer matrices (D) in [N x N] cell array % % v160229 Matti Stenroos nsurf=length(meshes); ...
e237dfb81dfb367a4b68c4ee3459ff8b700cec98c7e6f2e6c7f8e320e0ef3463
MATLAB
831
17
function [signalPeaksArray] = getPeaks( p,signalMatrix ) % This might not be entirely accurate, since how many and which peaks % are found is dependent on the minTimeBtEvents paramter warning('off','signal:findpeaks:largeMinPeakHeight') for i=1:size(signalMatrix,1) inputSignal = signalMatrix(i,...
9cac2050cdbe936d588540524a899a8c2187bd6931d3ac4a7f4f3e087c69187e
MATLAB
833
30
% rawDataFile = ''; % <-- this must already be set before calling this script if ~exist(rawDataFile,'file') disp(['File ' rawDataFile ' not found, trying locally instead.']) rawDataFile = fullfile(script_pwd,rawDataFile); if ~exist(rawDataFile,'file') disp(['Error: file ' rawDataFile ' not found e...
82b21a9dc61f8053e92719f03be437ea9692f70dc51d05c489424d9c9a20bd86
MATLAB
834
30
function viewdicom(I, rot) % Function to view dicom file with a scrollbar if nargin < 1 handles.rot = 0; else handles.rot = rot; end handles.figImg = figure; handles.imgI = imagesc(imrotate(I(:,:,1), rot), [min(I(:)) max(I(:))]) colorbar %axis square colormap jet sizefig = get(handles.figImg, ...
60ab281b16a92ac06cc83570c8d7812b325a01f0bb7d449d368cc25c1d8a8238
MATLAB
835
32
function nrgSig = nrg_calc(data,dsmtx,nMSD,nTR) % Inputs % data = data organised at TIME x NODES % dsmtx = onsets for different events - list of TRs associated with each event type % nMSD = maximum MSD range % nTR = number of TRs to track % Outputs % nrg = MSD x TR x Energy nReg = siz...
a11577c374df45cdab5fd1c093ef4bdb8303a272515819d145cda8c81cecd22f
MATLAB
836
26
function data = decimateTLab(rawData,rawFs,dsRate) %decimate - Reduce sampling rate of data % % [data] = decimateTLab(rawData,rawFs,dsRate) % % Description: This function reduces the sampling rate of a data set by % applying a 10-th order butterworth filter at a cut-off frequency that % is 45% of the new...
7d7374b336717c58b0d49eda7e37195ada72aa72d7c63a88114d26325c94be2a
MATLAB
837
27
function FD = calc_framewiseDisplacements(Amats) % Calculation 'framewise displacement' motion scores, based on % Tisdall et al, MRM 2012 nT = size(Amats,3); FD = zeros(nT-1,1); for iT = 2:nT % get difference in affine matrices: thisDiff = Amats(:,:,iT) / Amats(:,:,iT-1); mpars = mats2pars(thisDiff...
3f0154703be674d6cb3107690f599b76e6c3d4b05a357c04a6da6a8d25b06062
MATLAB
839
29
function vel = getVel(distTravel,Fs,winSize) % Get Velocity % % vel = getVel(rawData,radius,Fs,winSize); % % Description: This function performs the simple manipulations to obtain % velocity information from raw rotary encoder data. % % Input: % - disTravel - Vector of distance traveled over time % ...
a75161048e4507824027a53c410de585663ede996d4edea8255269820f64b71c
MATLAB
841
43
function co = remove_big_lw(c1) field_list = fieldnames(c1); co=c1; for npool = 1:length(c1) nlw = c1(npool).linewidth; seuil = mean(nlw) + 2 * std(nlw); indrem1 = find(nlw>seuil); nlw = c1(npool).water_width; seuil2 = mean(nlw) + 2 * std(nlw); indrem2 = find(nlw>seuil2...
0085d225181462ccf4b0163fc666581c9d87443e6b7981ba783a40de07cf17df
MATLAB
842
26
function supp_fig3_gephi(folder) %% Code for supplemental Figure 3: Mouse brain export to gephi if nargin == 0 folder = 'All'; end load(fullfile(folder, 'data'), 'map', 'nodelist'); load('structures', 'structures'); map = map.density; map(map<0.005) = 0; [a, b] = ismember(nodelist, structures.name); nodelist = n...
26a53bbc67573de2e26f2d4fce3e8444f4f12577efe5507376db9edd442c720c
MATLAB
842
29
function [Power, Freqs] = compute_power(Data, SampleRate, WindowLength, Overlap) % Data is a channel x time marix matrix. SampleRate is a single value in % Hz, WindowLength is a single value in seconds, overlap is a ratio from 0 % to 1. % e.g.: [Power, Frequencies] = compute_power(Data, fs, 4, 0.5); % Power is a Chann...
ebc1ebec93f0bd9bf6be3367de936891efb2c1f0e067190611e2ed0432745ce3
MATLAB
842
30
function [beta,modelfunc]=mnl_FitExponentialDecay_v2(X,Y,beta0) %This is a much more streamlined version of mnl_FitExponentialDecay. Where %it doesn't work out the RMSE etc.. it simply provides the co-ordinates. %Also it doesn't faff around making a table. The addition is that I prevent %negative numbers % %Marcus Leiw...
057978dee4680817a2ed954515c179c531cb529adb79f48238ea7537274b0d4d
MATLAB
843
44
function co = remove_big_SD(c1,seuil) if iscell(c1) for k=1:length(c1) co{k} = remove_big_SD(c1{k},seuil) end return end field_list = fieldnames(c1); co=c1; for npool = 1:length(c1) for nf=1:length(field_list) ind = findstr(field_list{nf},'SD'); if ind cSD = getfield...
73297197480ddda92b67ab859c6f7d99dc30f90d2ec547c414f0ca3ae8353041
MATLAB
843
45
function concat_ps_file(d) cwd=pwd; for k=1:length(d) dd=d{k}; cd(dd); [p f] = fileparts(dd); [p f] = fileparts(p); [p pool] = fileparts(p); pool = [pool,'_',f]; fps=get_subdir_regex_files(d{k},{'.*PS$','.*ps$'}); fps=char(fps); cmdmerge = sprintf('LD_LIBRARY_PATH= ;psmerge -o%s.ps ',po...
cfd033783f3c8e8b4a86875a73f428d2b8b5d6f91697bf1006ca1e9b11664d01
MATLAB
844
26
% Copyright 2024 Eelke Spaak, Donders Institute. % See https://github.com/Spaak/rift-phase-and-visibility for readme/license. % Belongs with: % Spaak, E., Bouwkamp, F. G., & de Lange, F. P. (2024). Perceptual foundation and extension % to phase tagging for rapid invisible frequency tagging (RIFT). Imaging Neuroscience,...
ec8734df99038b4df4c5f65f4791a0b9c074a01a026050b96250591dca615be7
MATLAB
844
19
function [X,Y] = Rescale_Midline_Distance_And_Orientation(X0,Y0,R3,R4) % Rescale midline distance to PVD raddi: F3 = find(abs(X0) <= R3); % Find points that are between the midline and half-radius. F4 = find(abs(X0) > R3 & abs(X0) <= R4); % Find points that are between the half-radius and radius. X = abs(X0); ...
0e2e59db705d8147b4dae88747e7be4058936de1587cd64688961c841856a164
MATLAB
845
39
function [s,peaks] = PiCA5(dat,refslice,th,wlen,Itr) N = size(dat,2); w = floor(size(refslice,2)/2); ref = dat(1,:); % % % peaks = zeros(1,N); % % % peaks(160:round(1025/2.4):end) = 1; % % % % % % [s,W,A] = PiCA(dat,peaks); % % % ref = s(1,:); % % % refslice = W*refslice; for k = 1:Itr refframe = ...
ed84e0196a750de1a84e4acf4dc76f5da7a209ca4cc9fbe607c20e69793cb852
MATLAB
848
42
function [N, S, W, E] = getCropCoords( im ) % takes away edges containing ones until all edges are all zeros % set up initial parameters [rows,cols] = size(im); N = 1; S = rows; W = 1; E = cols; % shrink image until no more ones exist finished = 0; while ~finished % get ratio of ones rN = sum(im(N,W:E)...
a0ea9e0fda3e8b27e6218f799aad7259232a560cb13b0e1ca960a03ede173548
MATLAB
849
25
% Copyright 2024 Eelke Spaak, Donders Institute. % See https://github.com/Spaak/rift-phase-and-visibility for readme/license. % Belongs with: % Spaak, E., Bouwkamp, F. G., & de Lange, F. P. (2024). Perceptual foundation and extension % to phase tagging for rapid invisible frequency tagging (RIFT). Imaging Neuroscie...
e432e05adb82ed32d157ba533e789c5b60a6563f0eab652f16c8ef6ff204ac6c
MATLAB
850
30
function freqs = genFreqs(freqName) switch freqName case 'HFB' freqs = 2.^(6.15:0.05:7.4); case 'HFB_raw' freqs = 2.^(6.15:0.05:7.4); case 'HFB_db' freqs = 2.^(6.15:0.05:7.4); case 'Spec' freqs = 2.^([0:0.5:2,2.3:0.3:5,5.2:0.2:8]); case 'SpecDenseLF' freqs...
01b6e34e8600152eca2b57536f5129980a9e0beaaf81bb91f466ad3f2ef19ab4
MATLAB
851
32
%% load Data load('../../Additional_Data/ONimageS.mat') load('../../Additional_Data/OFFimageS.mat') %% Calculate refpic refpic = squeeze(mean(mean(ONimageS+OFFimageS,1),2)/2); imshow(refpic/1e3) save refpic refpic -v7.3 %% Using correlation to find trails with large artifact ref = imgaussfilt(refpic,1); CMat...
4d19f543d4ed769845d562426c1eebd1358ba1f542efa35748eddb5456d29462
MATLAB
851
44
function [params] = setparams(params) if (~isfield(params, 'batchsize')) params.batchsize = 128; end; if (~isfield(params, 'numepochs')) params.numepochs = 1; end; if (~isfield(params, 'balance')) params.balance = 0; end; if (~isfield(params, 'alpha')) params.alpha = 1; end; if (~isfield(params, 'beta'...
ed823d72ea6b5ec4d6ff9de2988d4b62110aca5d7a6f86b048b5d9da4fc0607e
MATLAB
854
29
function [test_indices train_indices ind]=cv_stratified_multilabel_DBP_speed(N,n_folds,bestmodel) % N is the label matrix %Stratifies by discretizing multiclass tracking data into one unique label %after bining individual classes. The final discretized label makes up an %combination of individual classes labels. ...
68474b39b4b9fc1066bfe1db50d0ba72b7614cd9b9c967851228bf9bf302256a
MATLAB
856
8
function [peaks, peak_indexes] = PeakDetection2(x, fs, varargin) % PeakDetection has been deprecated. Use % peak_det_modified_pan_tompkins instead (with the new ksigma % parameter), or replace PeakDetection2(data, fs, wlen, fp1, fp2, th, flag), with: % peak_det_modified_pan_tompkins(data, fs, wlen, fp1, fp2, th, ks...
c41adba68908689fc693237558fcf27cd95e150af3c2f57e5d4c9b4aed449ce6
MATLAB
857
27
function output = XxNorm(data, tmin, tmax) % ------------------------------------------------------------------------ % XxNorm: perform percentile normaliztion to data % % usage: output = XxNorm(data, tmin, tmax) % where, % output -- [0, 1] normalized data, data type is double % data -- data to be n...
cd620235f4c33037d08418ad5b9fa245f963f6df7ad1d9a170e376d1becbb0dc
MATLAB
859
43
function [vtx, vty, vtz] = tangdipoles(rx,ry,rz,theta_t) sizr = size(rx); sizt = size(theta_t); assert(sum(sizt) == 2); % GRIDS % Get back R and unit vectors from passed grid R = sqrt(rx.^2 + ry.^2 + rz.^2); %calculate |r| at each point %getting normal vectors erx = rx./R; ery = ry./R; erz = rz./R; %Get theta and...
97af8ed054cc0c933e8d65350cd50e1b9394bc7d9593f358aa886fe716d7dddf
MATLAB
860
21
%% add timing to [file, path] = uigetfile('*.mat','MultiSelect','on');%When the user clicks the load psetion button, a window should open to enable the user to select a file. datafile = fullfile(path, file); %save path cd('H:\mPFC\shiras_data\PFC') cd('E:\2023 - ledramp') %% for i = 1:length(file) all_dat...
cf3612f4ede88b0f2439d4d3e1652d3b05bf7b7c69083fbbec57a5aa3d799def
MATLAB
860
23
function startinfo(h,data) % autocorrelatemap() and crosscorrelatemaps() depend on this function. set(h,'Visible','off'); subplot(h); cla; inj = data.inj; if length(inj)==1 str = sprintf('Experiment:\n%s\n',data.exp_id); else str = sprintf('Experiments:\n%s\n%s\n',data.exp_id{:}); end str = [str ...
47f674d097a6b2c4922cebcb253464035d7783bc6c9032db0f067d5bceefb7b8
MATLAB
861
46
function s=get_spectrum(f) for k=1%1:length(f) s = fftshift(fft(f(k).fid),1); end if 0 aa=1:32:256; az=(32:32:256 ) fid= f.fid; for kk=1:length(aa) f(:,kk) = mean(fid(:,[aa(kk):az(kk)]),2); end spec = f(1).spectrum; resolution1 = spec.spectral_widht/(spec.n_data_points-1)/spec.synthesizer_frequency; ...
00859f7e1aa5a505066a94386a3e7077fa894878b539254eaa05e229e31150d6
MATLAB
864
39
function sample = time2sample(ts, varargin) % defaults FS = 195312.5; T1 = 0; T2 = 0; TO_TIME = 0; VALID_PARS = {'FS','T1','T2','TO_TIME'}; % parse varargin for ii = 1:2:length(varargin) if ~ismember(upper(varargin{ii}), VALID_PARS) error('%s is not a valid parameter. See help time2sample....
4d0cf3a2f6511dfdaeeb2f890caca40644159c4ae814515e109e0f99cf2d29ab
MATLAB
864
24
function scatterplot(h,data) %% Set dimensions of the graph % draw1experiment() and draw2experiments() depend on this function. load('structures','groups'); subplot(h); set(h,'DataAspectRatio',[1 1 1],'Color','None','Box','off','Fontsize',8); hold on; gr = length(groups.name); % Number of hyperstructures, 15 ...
5f1c32741d47a8e38f48c54cd58afb594b6de676550263867a0af0b42120e21a
MATLAB
864
29
% Find the taus of the biexponential funtion % that fit a linear predictor % computed from linear prediction % Input % tau_0 & tau_0: vector of starting taus % r_data: vector from the response function computed from lp % t_data: vector of time % Output % taus, paramteres that fit the biexponential the r_data % r ...
c184bf10018f30304108daf063f3ca0ad78abd9468e55d1db0a756c63136d06c
MATLAB
864
25
function [temp] = find_temp(tree, par) % Selects the temperature. num_temp = floor((par.maxtemp-par.mintemp)/par.tempstep); % total number of temperatures min_clus = par.min_clus; aux = diff(tree(:,5)); % Changes in the first cluster size aux1 = diff(tree(:,6)); % Changes in the second cluster size aux2 = di...
563255db2fc96b5f49237dc3ae1db1620659db8e5e35db9b50c2e31a39118665
MATLAB
865
31
%% unit testing for spmup_temporalSNR % % the model is simple with 4 'boxes': GM, WM, CSF, background % noise is white noise everywhere (std = 1), and the signal is a simple cos % added with amplitude 1 (background) 2 (GM) 3 (WM) and 4 (CSF) % ------------------------------ % Cyril Pernet 05 January 2016 %% get data ...
9ccc9e82dd0c83c8301802a20719d6fde9f5e6ec13f517f84f2554888a78b65a
MATLAB
865
29
function Extend_Margins_Multiple() R = 0.2; % Ratio of rows # and cols # for border extension. Path1 = uigetdir; % Let the user to manually choose a directory. Files_List = List_All_Files(Path1,'tif'); % List all .tif files in this directory (including sub-directories). for f=1:numel(Files_List) Im = i...
a849b810d70508a39e0ca6c96da7e1ddfaafe21553a0c2580fde1be724043a77
MATLAB
865
29
% function to plot Cummulative Distribution Function % of the data at input cell function plot_cdf_cell(RoA_All,Names_Conditions,ColMap) NC=size(ColMap,1); CDFfig=figure; CDFfig.Name='Cummulative Function Distribution'; ax1=subplot(1,1,1); hold(ax1,'on'); for c=1:NC % if ~isempty(RoA_All{c}) if c<=numel(RoA_Al...
33c688b18beadbf5d175fdf86eb05ae54d73b5b19ad35ce3220afb07d6d3d0fb
MATLAB
866
36
function DI=dunns(clusters_number,distM,ind) %%%Dunn's index for clustering compactness and separation measurement % dunns(clusters_number,distM,ind) % clusters_number = Number of clusters % distM = Dissimilarity matrix % ind = Indexes for each data point aka cluster to which each data point % belongs % Julian Ra...
3d2439db30873d464db5ccc44c72fdbf2b70bb07e7d8c2ffd9ac2ee98f7870c6
MATLAB
866
33
function ScorePAth = ScorePatho(subIDX) %fn = fullfile(Dpath,'Scores_Neuropsycho_Psychopatho_TOUT_Manon_cp'); %ALL_data = readtable(fn); ScorePAth = {}; RCMAS = [26;17;22;19;26;10;25;14;16;14;7;3;26;... 17;18;21;25]; ScorePAth.RCMAS = RCMAS(subIDX); CDI = [18;26;15;24;41;20;31;19;8;1...
9edfc776cb45aa0d643cea1e6d8d651295c094987d437c5de373e81bc4111d40
MATLAB
866
37
function y = reshaper(x, dim) %|function y = reshaper(x, dim) %| %| reshape function that is more flexible, allowing for "multiples". %| example: reshape(rand(2*3*5,7), [2 3 5]) will become [2 3 5 7] %| %| in %| x [*dim (Ld)] %| dim short row or column %| if dim is '2d' then y is 2d with first n-1 dims collapsed %| ...
c52ce6916fabb87adbd5a9a20fa3646439e0c774ad807a93d7c4cf630c55e8d9
MATLAB
867
20
function spikeWindows2 = samplesToWindows2(obj, samplesIn, spikeSites, spikeTimes) %SAMPLESTOWINDOWS2 Get spatiotemporal windows around SECONDARY peaking % events as 3D arrays (filtered samples assumed) nSpikes = numel(spikeSites); nSitesEvt = 1 + obj.hCfg.nSiteDir*2; % includes ref sites % nSample...
6a53660ebec77928691fa8a8b5a48cc679f82040b7e42d7084d95271baff677b
MATLAB
868
24
function Segment = Connect_Using_Skeleton(Segment,Im_Rows,Im_Cols,Scale_Factor) [Ys,Xs] = ind2sub([Im_Rows,Im_Cols],Segment.Skeleton_Linear_Coordinates); X1 = Segment.Rectangles1(end).X; Y1 = Segment.Rectangles1(end).Y; D1 = ( (Xs-X1).^2 + (Ys-Y1).^2 ) .^ 0.5; % The distances of all skeleton coordinates from the...