sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
17k
content
stringlengths
1
200k
d95b4dc17d941efc7be29b2f91660e36004eec049283467689cb686c668cee42
MATLAB
690
14
load empiricalAwake.mat load empiricalSleep.mat create_AALnifti(mean(Hierarchy),'aw_hierarchy.nii.gz',1); create_AALnifti(mean(Hierarchy2),'sl_hierarchy.nii.gz',1); create_AALnifti(mean(Hierarchyn2),'sln2_hierarchy.nii.gz',1); create_AALnifti(mean(SpatialTemporalBroadness_sink),'aw_sink.nii.gz',1); create_AALnifti(me...
3a4f535306d80499112a821f5f06850be80cc0198b8fc1a0b0aa3cf744d936f4
MATLAB
691
23
function transformations = tc_decomposeMatrix(M) transformations.translation = M(1:3, 4)'; L = M(1:3, 1:3); sx = norm(L(:, 1)); sy = norm(L(:, 2)); sz = norm(L(:, 3)); if det(L) < 0 sx = -sx; end transformations.scale = [sx, sy, sz]; L_norm = L ./ repmat(transforma...
2a70163ec9776fc53589ce71333f25a16b934c3475eb45aa1b64e5f313816980
MATLAB
692
28
function txt=SurfStatDataCursorP(empt,event_obj) pos=get(event_obj,'Position'); h=get(event_obj,'Target'); v=get(h,'Vertices'); x=get(h,'FaceVertexCData'); id1=min(find(v(:,1)==pos(1)&v(:,2)==pos(2)&v(:,3)==pos(3))); tag=get(get(h,'Parent'),'Tag'); [s,a,id0]=strread(tag,'%s %d %d'); id=id1+id0 c=get(get(h,'par...
2c73b1fdd740f92e0a5aae91a723f47f65aa8703bf13222ec9f78e0554d6fb4b
MATLAB
693
22
function clusters = loc_list_extract_clusters_from_data(data) area = data.area; count(1) = 1; counter = 1; for i = 2:length(area) if area(i)~=area(i-1) counter = counter+1; count(counter) = i; end end for i = 1:length(count) if i== length(count) clusters{i}(:,1) = data.x_...
8163ab9b072da16bc32e23a7ee4e37208113199aeb3822f08b9bb9eaa32e05c0
MATLAB
694
28
function s=minus(t1,t2) if (~isa(t1,'term') && numel(t1)>1) || (~isa(t2,'term') && numel(t2)>1) warning('If you don''t convert vectors to terms you can get unexpected results :-(') end t1=term(t1,inputname(1)); t2=term(t2,inputname(2)); if isempty(t1) || isempty(t2) s=t1; return end n1=size(t1.ma...
4c0bcb8f6e3f4f3ab9143f9697a491d490a3a6b2060db295abfae40f9755e9f7
MATLAB
698
27
function piled_data = loc_list_pile_data(data) f = waitbar(0,'Piling Data'); for i = 1:length(data) waitbar(i/length(data),f,'Piling Data'); x{i} = data{i}.x_data; y{i} = data{i}.y_data; area{i} = data{i}.area; end close(f) x = vertcat(x{:}); y = vertcat(y{:}); area = vertcat(area{:}); d...
a9841c0c050c062b0c0c059b224ebbd34bd08c4c8a6ab7327407fa0540a333d2
MATLAB
701
17
function O = StandardErrorGaussian(S) O = []; %0.1-1Hz indir = dir('/scratch7/MINDLAB2017_MEG-LearningBach/Leonardo/LearningBach/source/source_localsphere_01_1Hz_AllTrials_BC_2.oat/subj*dir'); DAT = zeros(23,27,23,400,length(indir)); %3D image, time-points and then subjects for ii = 1:length(indir) %over subjects ...
c7b00dfb0ca891cff069f6ae4392ee25813ec966246a73f9f80ae45984468769
MATLAB
702
14
function out = convert_2_AAL3_indices(in) AAL3_clusters = [1 2 3 4 5 6 7 8 9 10 11 12 13 14.... 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32.... 33 34 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52.... 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70.... 71 72 73 74 75 76 77 78 79 80 83 84 85...
e94dfbe85f2856a4e947ddd7e87ff909ddcfaf6eed229604a54e52e43edade11
MATLAB
703
35
function m = resQ_1d_data2fit(signal, xps, opt, ind) % function m = resQ_1d_data2fit(signal, xps, opt, ind) if nargin < 4 ind = ones(xps.n, 1, 'logical'); end if ~all(ind) signal = signal(ind); xps = mdm_xps_subsample(xps, ind); end s_nrm = median(signal(xps.b<0.5e9)); if isfield(xps, 'sig...
44008c1d72476b869d1615b551ef079ec4acb96c6555c1c050836d69cf4d2ec6
MATLAB
704
33
function [ind_, r_, G_] = set_part_traj(pnts, G, dist_thr, num_sources, T) n_pnts=size(pnts,1); ind_ = zeros(num_sources, T); distMat = inf*eye(num_sources,num_sources); dmin = 0; nr = 3*num_sources; % while dmin < dist_thr idx = randperm(n_pnts); id = idx(1:num_sources); for i=1:1:num_sources ...
e194eb220b7518cddc43e9618ffededc5a98eae9ca8ad185274e3a1294261ed5
MATLAB
706
25
% function adapted from the LiNGAM package % complete software may be downloaded from http://www.cs.helsinki.fi/group/neuroinf/lingam/ function [Wopt,rowp] = permnozerihungarian( W ) %-------------------------------------------------------------------------- % Find best row permutation by hungarian algorithm %...
651c3dc76334392623d3bc0e4893ba513bfa9f692ca157237533691cc8a8c4a9
MATLAB
707
28
function C=clustering_coef_bu(G) %CLUSTERING_COEF_BU Clustering coefficient % % C = clustering_coef_bu(A); % % The clustering coefficient is the fraction of triangles around a node % (equiv. the fraction of node's neighbors that are neighbors of each other). % % Input: A, binary undirected...
0be306523c1c6a33edf17421f9237c8db23dc692e5315de3fd28a32943829afe
MATLAB
711
15
function obj = drawCortexHemi(ax, anat_hemi, mesh, color, mesh_alpha) % DRAWCORTEXHEMI Draw one hemisphere of the cortex % ax: axes to display in % anat_hemi: anatomy mesh of one hemisphere of the brain % mesh: vertices of anatomy % color: 3x1 vector, cortex mesh color % mesh_alpha: tr...
cf6cb8078b3fbd005f94750e7bdf5446b85d0c372dd0e1551c7d6322194cca39
MATLAB
711
39
function [granger,granger2]=granger_automation(input1,input2,freqrange) label = [{'PFC'}; {'HPC'}]; %% input1 clear Data fn=1000; leng=length(input1); ro=3000; tm=create_timecell(ro,leng); Data.label=label; Data.time=tm; Data.trial=input1.'; % cfg.bsfilter = 'yes'; cfg.bsfreq = [49 51]; Data = ft_preprocessing(cfg,...
bceb11f37d844ed9b9047f9a9f735ae20771b3bb7aab98b6c0ef0e9f51c69b0e
MATLAB
715
41
function [data, A] = two_source_model(T) M = 2; %number of sources; P=2; %order of the model T0=1000; %length of ignored start %Generate stable AR matrix Rmax=50; %Generate stable AR matrix while Rmax>3 lambdamax=10; while lambdamax > 1 || lambdamax < 0.9 A=[]; for k=1:P aloc = zeros(M); alo...
7e6ea9af0cbba10f86b39d59e53ddd7abce1c1393ec89e274f9b8ecb124fd831
MATLAB
716
19
function shape_classification_kmeans(data) input_values = inputdlg({'k-means k value:'},'',1,{'10'}); if isempty(input_values)~=1 parameters = shape_classification_normalized_parameters(data.classes); kmeans_k = str2double(input_values{1}); idx = kmeans(parameters,kmeans_k); classes = cluster...
7e12c4eb1c9225c725ce3459b99ef5f52e8a7ee06961f44402dad31535e9f304
MATLAB
719
26
function loc_list_roi(data) try coordinates = getline(); data_roi = cell(1,length(data)); for i = 1:length(data) data_roi{i} = loc_list_roi_inside(data{i},coordinates); end data_roi = data_roi(~cellfun('isempty',data_roi)); catch data_roi = []; end loc_list_plot(data_roi) ...
abb46bd529ce9eb89c54c4910df4822f4cc463043237da982f00235ebbc0a508
MATLAB
720
34
function [h, yl] = mipp_plot_histogram(data, lims, do_filter) if do_filter data = mipp_parameterFilter(data); end mdat = median(data(:)); if strcmp(num2str(abs(mdat), '%0.2f'), '0.00') mdat = 0; end [~, sdat] = iqr(data(:)); hx = linspace(lims(1), lims(2), 51); h = histogram(data(:), hx, 'FaceColor', [.8 ...
bcf7a93734a3c05fbfc41d8fbaf4ebde8620bfab3f39653b72f2fd32c752eaf8
MATLAB
720
32
%% SPEARMAN or KENDALL test for independence % null hypothesis: uncorrelation % if p<alpha, reject -> presence of correlation % input: X row column % tipo: 'Spearman', 'Kendall' function [pM,rho,contarigett,stringout,stringflag]=test_independence(X,tipo,alpha); M=size(X,1); % n. of signals N=size(X,2); % l...
9264645f24d722966f0650abf4528e95ad12b7f34e896985cbf0b500587f60b6
MATLAB
721
25
function index = Which_StreamIndex_ThisLink(i,j, dFCstream) % FUNCTION index = Which_StreamIndex_ThisLink(i,j, dFCstream) % returns theordinal index of a link in the vector representation of a % symmetric FC matrix, where the maximum value for (i,j) is equal to the % number of regions. % NB: j must be strictly la...
bde49df2b9cb27b0f01d7e1e6c5700d29970f4db8e4a93e680bc9548cf2c4fd4
MATLAB
721
25
function dataERP = eegTimelockOnVC(parameterSettingsVCERP, dataVC) %% dataERP = eegTimelockOnVC(parameterSettingsVCERP, virtChannels, dataTL) tc_struct2ws('caller', parameterSettingsVCERP) newDataTL=[]; newDataTL.trial=dataVC.virtChannels; newDataTL.time= arrayfun(@(x) {dataVC.time},1:size(newDataTL.trial,2)); newDat...
b5eaaec9177fab93554aaa837a5c9444e3127f315616928b5246d4f420e53bb7
MATLAB
726
28
function [kden,N,K] = density_und(CIJ) % DENSITY_UND Density % % kden = density_und(CIJ); % [kden,N,K] = density_und(CIJ); % % Density is the fraction of present connections to possible connections. % % Input: CIJ, undirected (weighted/binary) connection matrix % % Output: kden, density %...
ef96df666214743ea58c5b554ff5f2cb39a33568a47f0daa0edd8fbff8f10397
MATLAB
727
17
% Taken from fileexchange and Matlab 2024a function hex = rgb2hex(rgb_color) assert(nargin==1,'This function requires an RGB input.') assert(isnumeric(rgb_color)==1,'Function input must be numeric.') sizergb = size(rgb_color); assert(sizergb(2)==3,'rgb value must have three components in the form [r ...
ec81b923f18f84d59ab948831e9b1f9c1b64d23dbfd97c3895d51d512cc655d6
MATLAB
728
21
function shape_classification_som(data) classes = data.classes; input_values = inputdlg({'number of nodes'},'',1,{'8'}); if isempty(input_values)~=1 parameters = shape_classification_normalized_parameters(classes); nn_dim = str2double(input_values{1,1}); disp('finding k clusters form som') di...
52e092e6139bd1e9a80dd8f1d0890a90c459bafa3f583487d6e7858209e831c1
MATLAB
730
37
function FC_project = get_ncon_nsub(FC_project) disp('Getting number of conditions...') cd(FC_project.CONN_preprocessing_dir) % Get number of conditions i = 1; j = 1; while i==1 if numel(dir(sprintf('*_Condition%03d.mat',j))) < 1 ncon = j-1; % number of conditions in CONN output folder ...
2bf786345e092d99cad9a4106df940e37c7972dcf2c20bfd5caffe9333c5cb74
MATLAB
731
15
function root_path = findRootPath() %FINDROOTPATH Find the root path of the NLA toolbox % path_split = split(string(which('nla.VERSION')), "/"); % path_joined = join(path_split(1:end-2), "/"); % root_path = char(path_joined + "/"); root_path_no_ending_slash = fileparts(which('nla.VERSION')); %r...
9f863a1f9b409d7780a933132667833eb5b69bf8c1045e2b51a8a0bc4eba859b
MATLAB
731
29
function [ind_new, Vr] = LW_model(loc, delta, p) n = size(loc,1); N = size(loc,2); nverts=size(p,1); a = (3*delta - 1)/(2*delta); h2 = 1 - a^2; mean_ = a.*loc + repmat((1-a)*mean(loc,2), [1 N]); Vt = (var(loc,0,2)'+ 1e-8).*eye(n); Vr=h2*Vt; loc = mean_ + chol(Vr)*randn(n,N); % h2 = 1-((3*c-1)/2*c)^2; % a = sqrt(1-h2);...
f41d0fa1ac1b7e24fe184279cb30db99a9c2c0ae054a315dd9d8170251032fae
MATLAB
734
21
%% data data=xlsread('X:\Elite\LARS\2013\oktober\bsa dmso test\BSAN2DMSO3med.xlsx'); %data=xlsread('X:\Elite\LARS\2013\oktober\bsa dmso test\BSAhigh.xlsx'); %% compare area plot(log(median(data(:,6:7)')),log(median(data(:,8:10)')),'r.') ylabel('DMSO') [h,p,ci] = ttest(median(data(:,6:7)'),median(data(:,8:10)'...
c67fce896c09412363ce88f30697daac8a46ca55cb93a7ac445a3db65e6ae7cf
MATLAB
736
31
function dFC = dFCstream2dFC(dFCstream) % FUNCTION dFC = dFCstream2dFC(dFCstream) % takes dFCstream as input ('2D' or '3D') and calculates dFC [FxF] matrix, % where F is the number of network frames in the input dFCstream. % % Example: dfc = dFCstream2dFC(dfcstream) if (ndims(dFCstream) == 3) dFC...
c468ca62e19929cf31eb2eef5ab6cdc90ab5bf61baee52c02b127268cb68eccb
MATLAB
738
32
classdef ContrastInput < handle & matlab.mixin.Copyable properties dataTable = []; name = ''; contrastVector = []; end methods function isValidFlag = isValid(obj) if any(~isspace(obj.name)) isValidFlag = true; else ...
e00d7815f7ac7db5bbab14fffb75e5326b4b33d7840853e0aba36fb9620c927b
MATLAB
740
22
classdef OrdinaryLeastSquares < nla.edge.test.SandwichEstimator methods %Hacky way to change name and coeff_name in superclass is to change %properties in constructor function obj = OrdinaryLeastSquares() obj = obj@nla.edge.test.SandwichEstimator(); ...
06485eae759fba1f0db9e65bbd72bbef0998081803e2df119c37b23ae531529c
MATLAB
742
15
function shape_classification_coeff_of_variation(data) classes = data.classes; N = cellfun(@(x) length(x), classes(:,1)); for i=1:size(classes,1) variation(i,:) = abs(std(classes{i,2},0,1)./mean(classes{i,2},1)); end similarity_measure = sum(N.*variation); variation = variation(:,[1:2,7:8]); similarity_meas...
c8a400fd7d58ac535e69af9def589fa300ea6b1c28adbeb4696fa15c8a466714
MATLAB
742
28
function [R] = dcor_dc(X,Y) % [R] = dcor_dc(X,Y) % Computes the double centered distance correlation between X and Y. % Rows represent the examples, and columns the variables. % Based on: http://www.mathworks.com/matlabcentral/fileexchange/49968-dcorr--x--y-- % and, the R package energy and papers by Szekely and Rizz...
2fd1ecd77fdd4e0230c3b71d5caf1267eb57b21e91925d28b5e7cbbd6cc4e950
MATLAB
745
30
function tc_compress_files(folder, name, zipname, deleteind) %% tc_compress_betas(folder, name, zipname, deleteind) % % zip files in folder and delete % % folder: folder containing the files % name: regexp of file names % zipname: archive name % deleteind: whether to delete disp('compressing files...') % get files in f...
db5f558426ec0ca3111213b14096cdedcf555c8810c3dc6f91bd5e8255920d55
MATLAB
745
21
function W = morlet_wavelet(t,fc,sigma_tc); % function W = morlet_wavelet(t,fc,sigma_tc) % % Returns the complex Morlet wavelet for a specified central frequency and standard deviation % % INPUTS: % t: timepoints where the wavelet will be calculated % fc: central frequency % sigma_tc: standard deviation o...
03c457945a07826f71cbe3c9df5b76f67d62aaa3266eed2a9629e33c3f5a7b49
MATLAB
748
24
function [v_id_mne, hemi, v_id] = map_locs_to_mne(avg_loc, mesh, incl_vert, src_l, src_r) num_sources = size(avg_loc,1)./3; v_id = zeros(num_sources,1); m=size(mesh.p(incl_vert,:),1); for i=1:1:num_sources d = sqrt(sum((mesh.p(incl_vert,:) - repmat(avg_loc((i-1)*3 + 1 : 3*i, 1)', m, 1)).^2, 2)); v_id(i,...
a257ec8c66017e79ae9b6276b9cdce8c5a7af5a7871226b43e889316bf78056b
MATLAB
750
36
function cb = SurfStatColLim( clim ); %Sets the colour limits for SurfStatView. % % Usage: cb = SurfStatColLim( clim ); % % clim = [min, max] values of data for colour limits. % % cb = handle to new colorbar. a=get(gcf,'Children'); k=0; for i=1:length(a) tag=get(a(i),'Tag'); if strcmp(tag,'Col...
5b975483c95a2e0afbee617a9fe39e817a72fb0df65bdc64158724e4bc9dae76
MATLAB
751
19
function interp_compartments = tc_interpolate_compartments(compartments, varargin) %% interp_compartments = tc_interpolate_compartments(compartments) % % Interpolates layers (cubic). % % Input: n x layer matrix where n is the number of voxel and each layer % column should hold a value representing the fraction of to wh...
797e17e52a20f506c9abd5917127acab6f22f8cef020cfa72bd0ecdbb4db0928
MATLAB
753
22
function fn = resQ_pipe(s, paths, opt, ind) % function fn = resQ_pipe(s, paths, opt, ind) if (nargin < 2) || isempty(paths), paths = [fileparts(s.nii_fn) filesep]; end if (nargin < 3), opt.present = 1; end if (nargin < 4), ind = ones(s.xps.n, 1, 'logical'); end opt = mdm_opt(opt); opt = resQ_opt(opt); paths ...
d8c69c35fe0a350398c22ac6c0fc76d51da301fb7d0d8208c146a0f2262b6919
MATLAB
753
16
function AS_WTA_SepRes_bat(indir,outdir,TARGETROIdir) % indir = uigetdir(pwd,'OrigData'); % outdir = uigetdir(pwd,'Outputdir'); % [TargetROI,FilPa,Filext] = uigetfile({'*.nii';'*.img'},'TargetROI'); % [vtar,dtar] = Dynamic_read_dir_NIFTI(fullfile(FilPa,TargetROI)); [vtar,dtar] = Dynamic_read_dir_NIFTI(TARGETROIdir...
bd5d71445d756bfe87d4ec17fdc9f738fbda1ed5b46a3052d96393affea21406
MATLAB
754
19
classdef HolmBonferroni < nla.net.mcc.Base properties (Constant) name = "Holm-Bonferroni" end methods function [is_sig_vector, p_max] = correct(obj, net_atlas, input_struct, prob) [is_sig_vector, adjusted_pvals, ~] = nla.lib.bonferroni_holm(prob.v, input_struct.prob_max); ...
af0d927fa8cb55b30b8125879f77cb2313278fc8e77086b91817d709d1486bf1
MATLAB
756
28
%% read data=mzxmlread('F:\promec\Davi\_QE\BSAs\20150512_BSA_The-PEG-envelope.mzXML'); pkl=csvread('F:\promec\Davi\_QE\BSAs\20150512_BSA_The-PEG-envelope.pkl') %% plot pkli=pkl(pkl(:,2)>100000,:) scatter(pkli(:,1),log(pkli(:,2))) hist(pkli(:,1)) hist(log(pkli(:,2))) pdpkl=pdist(pkl(:,1)); [nelements,centers]...
e82bb2fea406f1291b9de88a929127d6e140b32249d975df617972060cb3f55e
MATLAB
757
28
function shape_classification_merge_shape_classes(data) for i = 1:length(data) classes{i} = open_classes(data{i}.classes); end classes = vertcat(classes{:}); data_to_plot.classes = classes; data_to_plot.name = 'merged_classes'; data_to_plot.type = 'shape_class'; shape_classification_plot(data_to_plot); end...
1623e7981f91ced3652afd1ecc01014cf201d5ec21dca2c1b1a631f3c7fa9589
MATLAB
758
28
%% ESTIMATES STRICTLY CAUSAL MVAR MODEL GIVEN EXTENDED MVAR MODEL % output: Am=[A(1)...A(p)], M*pM matrix of strictly causal MVAR coeffs % output: Su, input covariance matrix of strictly causal MVAR model % input: Bm=[B(1)...B(p)], M*pM matrix of extended MVAR coeffs % input: B0, M*M matrix of instantaneous ef...
94636a797498153c3e465af23be40f21e7987ab0ce54d5f8621baced1e8054f9
MATLAB
759
34
function FC = TS2FC(TS, format) % FUNCTION FC = TS2FC(TS, format) % takes time-series (TS) as input and calculates static functional connectivity % (FC) as output. % % inputs: TS(t,n) --> rows are t different time-points; % columns are n different regions; % format --> '2D' (default) provi...
f3cbc8d9e0387aad6b0af392aeaf28daaada646a589c7f4efaa3b774f5d8b8de
MATLAB
759
18
function data = load_gradient(name,idx) % LOAD_GRADIENT loads template gradients. % % data = LOAD_GRADIENT(name,idx) loads template gradients. For functional % connectivity gradients set name to 'fc', for microstructural profile % covariance gradients set it to 'mpc'. idx can be set to 1 for the first % gradi...
4864c450687e46599eb7275a932d044e52a3d264baef26c337089911205b00cf
MATLAB
760
30
function [status]=emabv1(TOFfn, m1, s1, m2, s2) % Program for TOF-MRA segmentation to obtain air and bone mask. % USAGE: % [status]=emabv1(TOFfn, m1, s1, m2, s2); % Empirical values for inputs: % m1=6; s1=4; m2=100; s2=50; % % Algorithm adapted from Wilson & Noble, IEEE TMI 1999 18(10) 938-945. % Yi Su, 11/1...
00cd314196c167c755aa078924889f318fccde12d7cb2449868643aeb37a80e5
MATLAB
762
20
if ~exist('dFC_project','var') || ~isfield(dFC_project,'dFC') msgbox('You must load or create a dFC project before running connectivity states analyis') else maxk = inputdlg('What maximum value of k would you like to use? ', 'Choose max k value to try...', [1 45]); [condition,tf] = listdlg('SelectionMod...
4c0fb3c5f26141fe4dac69ac2a67db76e26307522f4c79e45512253089f1598b
MATLAB
762
26
clc; clear all; close all; G1 = 1; % row number of gene 1 in the data set G2 = 2; % row number of gene 2 in the data set % [filename, pathname] = uigetfile({'*.txt';'*.xls';'*.*'},'Select file'); % gene_raw=load(strcat(pathname,filename)); % gene_raw=xlsread('SigAll.xlsx'); c1 = 3; % number of samples in c...
d5da4bc33a7170bf6409d3bb08abb81197c82dcc558e71e5f1fab6cf07c0c84e
MATLAB
765
36
function out = slices2mosaic(mat,fillValue) if nargin < 2 fillValue = 0; % Default to filling with zeros end x=size(mat,1); y=size(mat,2); z=size(mat,3); if ndims(mat) == 4 t = size(mat,4); else t = 1; end % find the side length of the mosaic image ...
232af0a9d3da7250ad2e3300f80e43e811c6cb7135ac09a5c4ad043000321616
MATLAB
766
29
%% read lfq = tblread('L:\Elite\Aida\RawFiles\Samples\LFQcc.txt','\t'); ss = tblread('L:\Elite\Aida\RawFiles\Samples\SScc.txt','\t'); ssc=tblread('L:\Elite\Aida\RawFiles\CellLines RawFiles\hierarchical-data-1col.txt','\t'); %% linearize lfqr=lfq(:) ssr=ss(:) lfqr(isnan(lfqr))=1 ssr(isnan(ssr))=1 %% plot p...
fc90ec31513a08e725209374765ea8dae1b428df937664431c0f7f76e8492df5
MATLAB
766
27
function [PDC_sig, PDC_bin, f] = get_significant_pdc(x, Am, S, numsurr, nfft, fc, Ns, p) S1=S .* eye(Ns); for is=1:numsurr for ii=1:Ns for jj=1:Ns if ii~=jj xs=surrVCFTd(x,Am,S1,ii,jj); [Ams,Sus]=idMVAR(xs,p,2); Sus = Sus .* eye (Ns); ...
9b3ec7dbe96166b1cc2f528468b9f21761eceafe751349c613950b453d65a746
MATLAB
767
26
function parameters = loc_list_extract_parameters(data) area = unique(data(:,3)); [~,data] = pca(data(:,1:2)); major_axis_length = max(data(:,1))-min(data(:,1)); minor_axis_length = max(data(:,2))-min(data(:,2)); x_r = data(data(:,1)>=0,:); x_l = data(data(:,1)<=0,:); u_r = x_r(x_r(:,2)>=0,:); l_r = x_r(x_r(:...
7c9112d9325940f5de8a6e483e244bb2468236eba7ba35c8be8eb7284d4e7ffe
MATLAB
768
25
[project_file,project_path] = uigetfile(pwd,'Select dFC project file',which('findme.m')); app.DynamicFunctionalConnectivityToolboxUIFigure.Pointer = 'watch'; x = app.center_x; y = app.center_y; fig = uifigure('Position',[x-85 y-35 170 70]); uitextarea(fig,'Value','Loading Project...','Position',[10 10 150 50])...
c8e3721d55b17ac2f43f7ded852eb40248da89cd7be7d44329eb67d65fd64c2f
MATLAB
769
26
function [B,proj_X] = nst_glm_fit_B(model,y, method) % nst_glm_model_fit_B - fit the model to compute B using either SVD or the % pseudo-inverse if nargin < 3 method='SVD'; end X=model.X; switch method case 'SVD' [X_u, X_s, X_v] = svd(X,0); X_diag_s = diag(X_...
212b042031b49965408ee402b7c02ba99e3249609bd3a74e0f5fb2373cba8cd7
MATLAB
770
33
% Imbed a zoom menu to any figure. % % Usage: rri_zoom_menu(fig); % % - Jimmy Shen (jimmy@rotman-baycrest.on.ca) % %-------------------------------------------------------------------- function menu_hdl = rri_zoom_menu(fig) if isnumeric(fig) menu_hdl = uimenu('Parent',fig, ... 'Label','...
76952e4c0cc33f4ebc4940d146eca7c9ef49aaa8c140fb4a6456fc28ad90cb6d
MATLAB
771
25
function P = morlet_transform_singlesub(ts,fc, fwhm,srate,baseline) % INPUTS: % ts: time series for each trial (time x trial) % fc: central frequency of the wavelet % fwhm: full width half maximum of the wavelet % srate : sampling rate of the data % baseline: array that contains the time indices for normali...
94d946398436617a20a7be4a354c87be6c64f09712c229343de4d86bb8ef2536
MATLAB
771
18
function loc_list_add_scale_bar(data) subplot = @(m,n,p) subtightplot (m, n, p, [0 0], [0 0], [0 0]); answer = inputdlg({'Pixel Size (nm per pixel):','Scale Bar Size (x-axis um):','Scale Bar Size (y axis um):'},'Input',[1 50],{'116','2','0.5'}); if isempty(answer)~=1 pixel_size = str2double(answer{1}); s...
d379fbd11450302c1cd7e9bc196113b565dd5acea471ecccacae84963976157f
MATLAB
771
33
%% read el=xlsread('X:\Qexactive\130529_Incremental\Multiconsensus from 3 ReportsPepSNPG.xlsx') el=xlsread('X:\Qexactive\130529_Incremental\ELINP.xlsx') %% plot hist(el(:,18)) % charge hist(el(:,19),[100]) % detect hist(el(:,20)) % MZ hist(el(:,22),[100]) % RT hist(el(:,21),[1000]) % RT ...
b4830c2b1c0ae54e8fb4bc97378edcf11b41e4f0e198fd27a493aad288606fa9
MATLAB
773
29
function utest_bst_setup(gui, server_mode) % Run brainstorm with no user interface, if not already running. % Force brainstorm to run in server mode (no user interaction). % Activate exception bypassing. It requires to override bst_error, bst_call % and bst_process with the ones from nirstorm % -> use nst_install('lin...
772f3bfdba2c349a817b30bf3730d732056234e211d2d45f13e8ba25ed3b5b4f
MATLAB
775
22
function loc_list_voronoi_clusters_loc_list_plot(data) f=waitbar(0,'Please wait...'); for i=1:length(data) color = linspace(0,1,length(data{i}.clusters_points)); color = color(randperm(length(color))); for j = 1:length(data{i}.clusters_points) points{j} = data{i}.clusters_points{j}; c...
6a9549fb16da3100bb3f52221b62e5729c685dbfd7bd566555d9245765a34fe1
MATLAB
776
29
classdef Network < handle & nla.interfaces.IndexGroup %NETWORK Network meta-information and contained regions of interest properties name color indexes % indexes of ROIs(regions of interest) that make up the network end methods function obj = Network(name, color...
a5eda05f0c9ec4ebe64c5b8265f6c968c58d7dabe7fa2cea3527f3b18b5e2ffc
MATLAB
781
27
function v2 = smooth_vol_osl(vol_as_matrix, mask_fname, fwhm) %computing spatial smoothing % vol_as_matrix = data (voxels x time-points) % mask_fname = character with path to a standard brain mask % fwhm = paramter for spatial smoothing (e.g. 100) [mask,res,xform] = nii.load(mask_fname); mask(mask>0) = 1; % ...
10086bcc2dccada5c279b0d04ae5034303929c06e274fad2365386e1bc3fcefa
MATLAB
787
29
function [loc_est, id_est, G_mcmv, data_cov_inv] = MCMV_beamformer_localizer(Y, noise_cov, G, pnts, included_sp, num_sources) %addpath('/m/nbe/scratch/braintrack/pnas_mne_results') num_trials = size(Y,3); T = size(Y,2); data_cov = compute_cov(Y, num_trials, T); for i=1:1:size(G,2) eta_ai(i) = compute_ai(G(:,i), no...
1b6fb0965908f22f6850038ab8539990652f6e4fb4a1e863504bfb8f0c8cdcb1
MATLAB
787
20
function gains = nst_headmodel_get_gains(HeadModel, unused_iWL, sChannel, selected_channels) warning('This function is depracted. For more information, consult https://github.com/Nirstorm/nirstorm/pull/266') % Old head model if ndims(HeadModel.Gain) == 3 HeadModel = process_nst_import_head_mod...
5bb7801f54d7471252df6c92557d8439162506df7d1c135362c2bf75b1adb121
MATLAB
787
30
%% function O = coregfuncp(S) % apparently function need a 0 and no end to run in the cluster (!?), set the name of the function and the input variable O = []; addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/osl/osl-core'); %this add the path (not necessary being in the osl-core directory if you have this o...
abd3c13572206be142cf5a9fbded1cd489282a6ef45d4965c7e3b7ab7c5c5109
MATLAB
787
34
function [x]=varEM(fstr,varname,numswitch) % function for finding specified variable from EM config file (produced automatically using MATLAB) %% Find Variable ind=strfind(fstr,[varname,'=']); %% Loop incase of more than 1 start found (i.e. t=) if numel(ind) > 1 for j=1:numel(ind) k=strcmp(fstr...
9c5ff31edde2e98e94ced92ac38db3ee2605f5e51822ac1bda07e6fbcc984e65
MATLAB
790
20
protmut='GAMGQLKPMEINPEMLNKVLSRLGVAGQWRFVDVLGLEEESLGSVPAPACALLLLFPLTAQHENFRKKQIEELKGQEVSPKVYFMKQTIGNSCGTIGLIHAVANNQDKLGFEDGSVLKQFLSETEKMSPEDRAKCFEKNEAIQAAHDAVAQEGQCRVDDKVNFHFILFNNVDGHLYELDGQMPFPVNHGASSEDTLLKDAAKVCREFTEREQGEVRFSAVALCKAA' protwt='GAMGQLKPMEINPEMLNKVLSRLGVAGQWRFVDVLGLEEESLGSVPAPACALLLLFPLTAQHENFRKKQIEELK...
1747f63c027c32b4406ab5bbf99c55c86f45fbbe6560d1856a63307b0dc4920d
MATLAB
792
13
function num_volumes = tc_num_volumes(num_trials, num_volumes_per_trial, skip_first_N_volumes, TR, pseudo_TR, TEEG) %% num_volumes = tc_num_volumes(num_trials, num_volumes_per_trial, skip_first_N_volumes, TR, pseudo_TR, TEEG) % % computes the number of volumes given certain parameters: % % num_trials: number of trials ...
2bd8100ada67c1db5c5d7bd519a26f5bea6ad9d9f15471de249b2115022a9fc8
MATLAB
793
35
%% sqrt newton method x=1; for k=1:10 x=x-(x^2-2)/(2*x) end x=linspace(-10,0.1,10); plot(x,x.^2,2*x,(x.^2)/(2*x)) %% secant method clear x x(1)=1 x(2)=x(1)+rand(x(1)) for k=2:5 x(k+1)=x(k)-(x(k)^2-2)*(x(k)-x(k-1))/(x(k)^2-2-x(k-1)^2+2) end plot(x,x.^2-2,'r-') ...
42a50fa5bffd860d9a7c9b6c8e35985e2def90b5053f491126ac7e143fc33d42
MATLAB
801
47
%% prob 2 rng(0,'v5uniform'); n=100; m=300; A=rand(m,n); b=A*ones(n,1)/2; c=-rand(n,1); plot(c,A'*b,'r.') %% simple_portfolio_data from https://class.stanford.edu/courses/Engineering/CVX101/Winter2014/courseware/ n=20; rng(5,'v5uniform'); pbar = ones(n,1)*.03+[rand(n-1,1); 0]*.12; rng(5,'v5normal')...
8dda41552661f71463edee33829f11388451e68e4899c8bdde3ab584560d1326
MATLAB
801
21
function spt_filter_tracks(data) input_values = inputdlg({'minimum number of frames','maximum number of frames'},'',1,{'5','20'}); if isempty(input_values)==1 return else cutoff_min = str2double(input_values{1}); cutoff_max = str2double(input_values{2}); for i = 1:length(data) fo...
27af519975df259850199c3c0036aec1dee9656fecb4aceba23000edda544b7f
MATLAB
803
20
function y = cvx_check_dimension( x, zero_ok ) %CVX_CHECK_DIMENSION Verifies that the input is valid dimension. % CVX_CHECK_DIMENSION( DIM ) verifies that the quantity DIM is valid for use % in commands that call for a dimension; e.g., SUM( X, DIM ). In other words, % it verifies that DIM is a positive integer...
2ea3e68d99a6916423d459c9515d9adbbdcc6c4e3de26b87f1d64bb9cfaff87d
MATLAB
803
30
%TIMINGTEST Works out the average cputime required to run % nearestneighbour % This is a support function for nndemo.m % T = TIMINGTEST(P, X, MODE) % Runs NEARESTNEIGHBOUR(P, X, 'DelaunayMode', MODE) for at least one % second, and returns the average cputime for a single execution % % ...
736096b7ffef3cc80e7d20c46a8e6cac695f7afadc3612e0ca7fde3fd9f3d54f
MATLAB
808
27
clc;clear all;close all [file,path] = uigetfile('*.mat','Select the .mat file containing the tracks'); name = fullfile(path,file); % Make it a full name to save it as later. load(name); path = uigetdir('*.xlsx','Please specify the folder where you want to save the csv files'); for j = 1:size(data,2) cle...
dab1fbeb3230fc607199030e39393e1fbbf3071aea5951f826088bcaa38d1923
MATLAB
810
23
function [J, q_ks, P_ks] = kalman_smoother_gpu(P_kf_t, P_kp_t1, q_kf_t,q_kp_t1, q_ks_t1, P_ks_t1, A, N, Jt) gputimes = @(A, B) pagefun(@mtimes, A, B); % A*B on GPU gpurdivide = @(A, B) pagefun(@mrdivide, A, B); % A/B on GPU gputranspose = @(A) pagefun(@transpose, A); % A' P_kf_t=gpuArray(P_kf_t); P_kp_t1=gpuA...
f62e0c86270aeebb7cf96fce811807b95acf7c25bf9c785b18279468250ab4cd
MATLAB
810
24
function unpiled_data = unpile_data(data,name) f = waitbar(0,'Unpiling Data'); unpiled_data = []; for i = 1:length(data) waitbar(i/length(data),f,'Unpiling Data'); DataConcat = horzcat(data{i}.x_data,data{i}.y_data,data{i}.area); DataSplit = splitapply(@(x){(x)},DataConcat(:,1:3),data{i}.channel);...
fb3f4c1af86fff74b5ccc5daaeff41b001391cbcd527753b20888e6b8e9a4d38
MATLAB
814
30
function Reordered = HCPexOrdering(inputMat,direction) % ReorderMat = HCPexOrdering(inputMat,direction) % % Input: inputMat, Matrix (360x360 or 412x412) based on HCPMMP or HCPex % direction, old > new = 1; new > old = -1 % % Output: ReorderMat, Reordered Matrix (412x412 or 360x360) % % Note: HCPex_LabelID.ma...
05c9aa5adfda8529f82cea57de0f73d2ad836506ec61ed4b76678f520dbc08fd
MATLAB
815
21
function [q, P, Kf] = gpu_kalman_update(q, P, Y_, G, G_, XI, N, Jt) gputimes = @(A, B) pagefun(@mtimes, A, B); % A*B on GPU gpurdivide = @(A, B) pagefun(@mrdivide, A, B); % A/B on GPU gputranspose = @(A) pagefun(@transpose, A); % A' ny=size(Y_,1); nq=size(q,1); ns=size(G,2); Kf = gpurdivide(gputimes(P(:,1:ns,...
66235dddf3da72f586a23486eeca2bbf031715184f089a5ba09b67eb3c2bd0ad
MATLAB
815
30
function Reordered = HCPexOrdering(inputMat,direction) % ReorderMat = HCPexOrdering(inputMat,direction) % % Input: inputMat, Matrix (360x360 or 412x412) based on HCPMMP or HCPex % direction, old > new = 1; new > old = -1 % % Output: ReorderMat, Reordered Matrix (412x412 or 360x360) % % Note: HCPex_LabelID.ma...
bf9721d8cd73ba3909e5e0bb14d6c9137f1b883d8e9ce3ad3d9e8cdcf70b78a0
MATLAB
820
19
function [metric_lh,metric_rh] = load_marker(name) % LOAD_MARKER loads metric data. % % [metric_lh,metric_rh] = LOAD_MARKER(name) loads data on the cortical % surface. Set to 'thickness' for cortical thickness, 'curvature' for % curvature, or 't1wt2w' for t1w/t2w intensity. Left hemispheric data is % stored i...
84d4cf9f863fac29f8f1dd5ba4600958cdf340bdc0b292a43b5abd8eb8812a23
MATLAB
826
30
function [status]=emartv1(TOFfn, m1, s1, m2, s2, m0, s0) % Program for TOF-MRA segmentation to obtain arterial mask. % USAGE: % [status]=emartv1(TOFfn, m1, s1, m2, s2, m0, s0); % Empirical values for inputs: % m1=6; s1=4; m2=100; s2=50; m0=300; s0=100; % % Algorithm adapted from Wilson & Noble, IEEE TMI 1999 18...
119e8760f759ed7ee8587fa12cf9403d29bdd48df2a71a7244ecb6993362bfbe
MATLAB
828
33
function spt_log_log_plot(data) for i = 1:length(data) temp = data{i}.msd; for k=1:length(temp) temp_temp_x = real(log(temp{k}(:,1))); temp_temp_y = real(log(temp{k}(:,2))); I = temp_temp_x==Inf; temp_temp_x(I) = []; temp_temp_y(I) = []; ...
3b6ed24b2d579f922166c78d4ea714720e2eb75e86923b834709fdd658fe8b70
MATLAB
828
21
%% file prot=xlsread('L:\Tony\121005_CSR_SILAC_Velos_pro\combo.xlsx'); mrna=prot(:,9:14); %% extract plot and correlate mm=2 pm=5 sum(mrna(:,mm)>0&mrna(:,pm)>0|mrna(:,mm)<0&mrna(:,pm)<0) corr(mrna((mrna(:,mm)>0&mrna(:,pm)>0|mrna(:,mm)<0&mrna(:,pm)<0),mm),mrna((mrna(:,mm)>0&mrna(:,pm)>0|mrna(:,mm)<0&mrna(:,pm...
bb133143d55676692677d063e24b26ef66fd1f146f0f820c1a650507f5d86ce0
MATLAB
828
32
function s=plus(t1,t2) if (~isa(t1,'term') && numel(t1)>1) || (~isa(t2,'term') && numel(t2)>1) warning('If you don''t convert vectors to terms you can get unexpected results :-(') end t1=term(t1,inputname(1)); t2=term(t2,inputname(2)); if isempty(t1) s=t2; return end if isempty(t2) s=t1; ...
ce9bcb18f0d8781757520b676c6913c744d140ab22377c97f4c611f673ec31d5
MATLAB
829
16
classdef FCWildBootstrap < nla.edge.permutationMethods.Base methods function permuted_input_struct = permute(obj, orig_input_struct) permuted_input_struct = orig_input_struct; permuted_input_struct.func_conn = orig_input_struct.func_conn.copy(); fcData = permuted_input_st...
d005d1f2f2d53ce00282d65176e92d7d61c678285e201e0d91853ddc9a4b8ea4
MATLAB
836
33
function f = var2fac( x, str ); %Converts a numeric variable or term of this to a cell array of strings. % % Usage: f = var2fac( x [, str] ); % % x = n x 1 numeric vector or term of this. % str = either a single string, or a 1 x k cell array of strings of names % for the k unique values of x in ascend...
223952a31dcd814cd7ee696b7f6cdb31dc2ffe2f660c090ed895431070d7c497
MATLAB
837
37
function coordinate = mni2cor(mni, T) % function coordinate = mni2cor(mni, T) % convert mni coordinate to matrix coordinate % % mni: a Nx3 matrix of mni coordinate % T: (optional) transform matrix % coordinate is the returned coordinate in matrix % % caution: if T is not specified, we use: % T = ... % [-4...
34bd4d6b7382930f3d125defaf027a9909842818e1d0f6ae010158544bb5845a
MATLAB
837
31
function data = shape_classification_set_class_color(data) input_values = inputdlg({'Class Number:'},'',1,{'1'}); if isempty(input_values)~=1 class_number = str2double(input_values{1}); for i = 1:length(data) data{i}.classes = open_classes(data{i}.classes,class_number); end end end fu...
655ff55fcf9da2d254a34a6d6da9cc8247c99a99d547335669041a0e5a4e18a5
MATLAB
837
36
%% read data d=load('C:\Users\animeshs\SkyDrive\chum\Sample.mat') [r c]=size(d.d) plot(d.d(r,:)) %% check plot(d.d(1:50,:)) autocorr(d.d(r,:)') %% symbolic test % source http://blogs.mathworks.com/loren/2012/07/27/using-symbolic-equations-and-symbolic-functions-in-matlab/?s_eid=PSM_1986 besselODE = 't^2*D2y+t*Dy+(t...
d6cc2276c75f83402702b18038ab8e9a3ad94378efebb2bc5e0377c3bdcd47af
MATLAB
840
20
function [mask_lh, mask_rh] = load_mask(name) % LOAD_MASK loads cortical masks. % % [mask_lh,mask_rh] = LOAD_MASK(name) loads masks on the conte69-32k surfaces of % the left (mask_lh) and right (mask_rh) hemispheres. Name can be set to % 'midline' for a midline mask and 'temporal' for a temporal mask. % % For...
eee6c715f70be79d48eee0cda14f456015997662714353daaeb55c39eadb8ce3
MATLAB
841
27
function [is,os,str] = strengths_dir(CIJ) %STRENGTHS_DIR In-strength and out-strength % % [is,os,str] = strengths_dir(CIJ); % % Node strength is the sum of weights of links connected to the node. The % instrength is the sum of inward link weights and the outstrength is the % sum of outward link weights. % ...
ab7f302e1600739c178a3d215c77031229d2ff44f440a79d718088747dc4709e
MATLAB
844
25
function plotFSsurf(faces,vertices,data,custommap,mincol,maxcol,viewangle) %Plot data on surface rendering. % FORMAT plotFSsurf(faces,vertices,data,custommap,mincol,maxcol,viewangle) % faces - faces returned from freesurfer_read_surf % vertices - vertice corodinates returned from freesurfer_read_surf % data ...
332780e44a4fa894912a1f63dcc49226f154872be1b00ab7a3c3377f03255731
MATLAB
847
28
function fig = makefigure(width,height) %MAKEFIGURE Make a publication-ready figure % Width (in cm) can be 3.0, 9.0, 14.0, or 19.0 aka minimum size, single column, 1.5-column, or double column % Wiley: 8 cm (small) or 18 cm (large) % Height can be 24.0 cm max % Note that wide PowerPoint slides are 33.87 wide by 19.05 h...
8bd7ad0a9b15c74a47a436d9a835e15c15364acd11c72e0884aae0085d182ddb
MATLAB
851
29
function tc_make_reg_setups() %% tc_make_reg_setups() % % makes setup for loop over multiple conditions % current working directory needs to be /path/to/scripts mainpath = pwd; addpath([mainpath filesep 'fmriRegAnalysis']) best_percs = {'5'};%, '10', '15'}; data_types = {... %{'L', 'R', 'preference'};... {'L-...
b9307de3f2f723caeb4dd3ec3012c20128cf9c3f7e83447bea2855e849ff2231
MATLAB
853
32
classdef ScriptTest < matlab.unittest.TestCase properties tmp_dir end methods(TestMethodSetup) function create_tmp_dir(testCase) tmpd = tempname; mkdir(tmpd); testCase.tmp_dir = tmpd; end end methods(TestMethodTeardown) fun...
3dc0a2011b4b5e83963d91f021b33f3b189b07ee77f3d86e4a4c0ebeeb0ce06b
MATLAB
854
27
function [classes,classes_new] = check_classes_in_bubble(classes,classes_grouped) bubble_center = mean(classes_grouped{1,2},1); bubble_max = max(classes_grouped{1,2})-bubble_center; bubble_min = min(classes_grouped{1,2})-bubble_center; bubble_max = bubble_max(:,[1,7:8]); bubble_min = bubble_min(:,[1,7:8]); to_c...
7ab0320944d14efdcee65a523d109ef158005383be12f90adef1ee3ff92724d8
MATLAB
854
44
function m = fl_cell_mean(Cell,w) % Computes the mean of a cell % % The cell must be 1-dimensional % (The function does not make an internal copy of the cell variable, which % is critical for large data sets) % This function is part of the permutationlab software: % Author: Dimitrios Pantazis % The code is c...
598eba57d6d8d0c5315b805696157eb748ba7d51288beb35c1c9b449ed715400
MATLAB
857
29
für Native: subj = 'sub-20Slicer'; baseDir = '/mnt/data1/lmu_or_reconstructions/20/derivatives/leaddbs/'; recoFile = fullfile(baseDir, subj, 'reconstruction', [subj '_desc-reconstruction.mat']); load(recoFile); coords_native = reco.native.coords_mm; for i = 1:length(coords_native) fprintf('Elektrode%d (Native):\n', i...
8e4b297520ef3e59ef646f7c169d6847000355cf3d6373d434c245e21932e391
MATLAB
860
35
function [ Y, Ym ] = SurfStatStand( Y, mask, subtractordivide); %Standardizes by subtracting the global mean, or dividing by it. % % Usage: [ Y, Ym ] = SurfStatStand( Y [,mask [,subtractordivide] ] ); % % Y = n x v matrix of data, v=#vertices. % mask = 1 x v, 1=inside, 0=outside, v=#v...