sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
17k
content
stringlengths
1
200k
e7748f10ec8be3d3fae6af1db8c1850971cbd66fd651f60805cace6235ac12c8
MATLAB
861
36
% function adapted from the LiNGAM package % complete software may be downloaded from http://www.cs.helsinki.fi/group/neuroinf/lingam/ function [Wopt,rowp] = permnozeribrutal ( W ) %-------------------------------------------------------------------------- % Try all row permutations, find best solution %------...
b39ae471d007ee54159392f8721c29ff8c9ebd53cdf329ae673fdd4712c24c81
MATLAB
866
44
%% CHOLESKY DECOMPOSITION WITH DIAGONAL MATRIX % given A positive definite symmetric matrix, returns a lower triangular % matrix L and a diagonal matrix D such that A=LDL' function [L,D]=choldiag(A); error(nargchk(1,1,nargin));%min e max di input arguments n=size(A,1); if sum(sum(A'~=A)), error('A non è si...
7c00158031d588ae6208efff1e9260edf6ac41104e4f99038b60493bce1c039e
MATLAB
868
27
function plot_classes_to_group(f,classes) clf(f); if length(classes{1,1})<=10 for i = 1:length(classes{1,1}) subplot(1,10,i) scatter(classes{1,1}{i}(:,1),classes{1,1}{i}(:,2),1,'b','filled') if i ==1 title(['Number of clusters in the class :',num2str(length(classes...
cecaca49d32c9d823a91aee238b6a14c1b82af8d0c55e9b78c0d5471ac52a86c
MATLAB
869
36
function [sigma_b] = grad_descent_sigmab(S_R, G, T, sigma_b, sigma_m) diff_obj = inf; obj = 1e10; old_obj = 0; step_init=1.0; tau=0.8; iter_count=1; max_count = 1000; while abs(diff_obj/obj)>=1e-10 if iter_count > max_count break; end R = sigma_m^2*eye(size(G,1)) + sigma_b^2*(G*G'); grad_R = T*...
da5c9088bb60e620cbf0f4da88640aea52559275c239942df7de848fada19937
MATLAB
871
41
function [Fluidity, Dimension] = MA_EEG_Man_Dim_Flui(TS) % This function compute Manifold Fluidity and local dimension of time serie % INPUT: TS, your time serie in observation x variables format quanti=0.98; STEP = 1; L = length(TS); %u = 0; Dimension = zeros(L,1); Fluidity = zeros(L,1); for j = 1:STEP:L %u=...
3410b4d63ccad6447d7436d07219b3f7c2407c089ab65d828dd5cb937f91c99f
MATLAB
876
17
function table_data_plot(data,row_names,column_names,title) figure('name',title,'NumberTitle','off','units','normalized','position',[0 0.1 1 0.4],'ToolBar','none','MenuBar', 'none'); column_width = {200}; uitable('Data',data,'units','normalized','position',[0 0 1 1],'FontSize',12,'RowName',row_names,'ColumnName',col...
132bfdcbf1202d7fd9e99f778793d9776ee2e61451611b9edde8396c73cd297d
MATLAB
878
35
function sel_trls=artRej(fl, bpfilt,chnls) % sj='P3_grating'; % stem='/project/3016045.05/Experiment3.2_ERC/Data/EEG/'; % bpfilt=[0 0]; data1=do_read_trials(1, bpfilt,fl{1},chnls); data2=do_read_trials(2, bpfilt,fl{2},chnls); data3=do_read_trials(3, bpfilt,fl{3},chnls); data4=do_read_trials(4, bpfilt,fl{4},chnls); ...
f8ca0950d0eaf165b1a7337160fdcbde6606ec2d0fe32dab184f4872f7b49f6d
MATLAB
879
36
function [sigma_m] = grad_descent_sigmam(S_R, G, T, sigma_b, sigma_m) diff_obj = inf; obj = 1e10; old_obj = 0; step_init=1.0; tau=0.8; iter_count=1; max_count = 1000; while abs(diff_obj/obj)>=1e-10 if iter_count > max_count break; end R = sigma_m^2*eye(size(G,1)) + sigma_b^2*(G*G'); grad_R = T*...
764e46e249fd985a26054b4abfd21fd6c77a794c7194256718978b3b7666407b
MATLAB
883
38
function s = classToStructRecursive(c) %CLASSTOSTRUCTRECURSIVE Convert classes to structs recursively if isa(c, 'cell') s = cell(size(c)); for i = 1:numel(c) s{i} = nla.helpers.classToStructRecursive(c{i}); end return end if ~isobject(c) || isa(c, 's...
ab097528481c4d652927ad70cfaf3597268ae072a9e1d6bec5545422671e1f36
MATLAB
883
41
function writetoPAJ(CIJ, fname, arcs) %WRITETOPAJ Write to Pajek % % writetoPAJ(CIJ, fname, arcs); % % This function writes a Pajek .net file from a MATLAB matrix % % Inputs: CIJ, adjacency matrix % fname, filename minus .net extension % arcs, 1 f...
ed435b733b1fe0156f5b759303ece5e3bf4567a35f459519413d0e6ff3d6e886
MATLAB
886
27
%path('/home/fimm/ii/ash022/tom/spm2/',path); path('/home/fimm/ii/ash022/tom/spm2/',path); beh=load('/home/fimm/ii/ash022/tom/beh/MMBT.mat'); behmat = zeros(1,2612); behmat(beh.onset)=1; cd /home/fimm/ii/ash022/tom/Session_1; files = dir('*.img'); %for i=1:length(files) for i=1:2 v = spm_vol(files(i).name); [vo...
37c7aebc135953ca64a59a9e12f78ee5c83738c5c9a25a52b28c9b9777871c8a
MATLAB
890
21
%% This function transform a 2D mosaic matrix into a 3D one with im_size,im_size,slices function out_sl = mosaic2slices(mat,im_size, slices) if ndims(mat) == 2 num = (size(mat,2)/im_size); aux = mat(:,:); out = permute(reshape(aux',[size(mat,2),size(mat,2)/num,num]),[2,1,3]); %change the n...
d8e1bebfef44fd0ea03513ec55f12dabc1697b8f790f56e77af39806354940cd
MATLAB
890
28
function moveFigToParentUILocation(fig_h, parent_h) %Intended to fix issue in Windows where plots generated from NLA_GUI %and NLA_Result get drawn way off top of screen. %Inputs are: % fig_h - figure handle % parent_h - UIFigure handle to move to (matlab.ui.Figure) figPos = ...
d8f173b67f2c2b0a140835872319160c6130ae924e460342a5ea466ef5c93951
MATLAB
892
31
function [id,od,deg] = degrees_dir(CIJ) %DEGREES_DIR Indegree and outdegree % % [id,od,deg] = degrees_dir(CIJ); % % Node degree is the number of links connected to the node. The indegree % is the number of inward links and the outdegree is the number of % outward links. % % Input: CIJ, direct...
b0e00b098480eb252cfe88753fca8044980f422820a1791baf6affbcc24037aa
MATLAB
893
30
function [] = image_mat(subj,objtype,objname) % [] = IMAGE_MAT(SUBJ,OBJTYPE,OBJNAME) % % Visualize the contents of an object or group with % IMAGESC. Automatically shifts to black&white colormap for binary % matrices. if exist_object(subj,objtype,objname) mat = get_mat(subj,objtype,objname); elseif exist_group(subj...
94dc797d92d29a5c5f6aff0ddfb55282bd72a71ffe4002b636821e2629cf081d
MATLAB
894
30
function O = averaging_TRF(S) O = []; S = []; %OLD PP = zeros(306,74,700,70); for ii = 1:71 if ii ~= 39 load(['/scratch5/MINDLAB2017_MEG-LearningBach/Leonardo/LearningBach/Time_frequency_MEGsensors/Subject_' num2str(ii) '_Old_Correct.mat']); PP(:,:,:,ii) = P; end disp(ii) end P = mean(PP,4...
22994c56f5f7b4914fe4a7c0afe388e6102df9ea19ac37996b33bfd81063e2c8
MATLAB
897
21
function data_simulated = loc_list_gaussian_point_pattern_simulation() input_values = inputdlg({'Sigma Range:','Number of Gaussian Clusters:','Number of Points in Clusters:','Image Size:'},'',1,{'0 5','10','200','50'}); if isempty(input_values)==1 data_simulated = []; else sigma_input = str2num(input_value...
bc45b8dc7638b87654aadd2ce5a354699589840817cbb771c5e0d1ef7146f6fe
MATLAB
897
23
function plot_model(ax, x, mu, se, fillCol, lwModel, hasBL) if hasBL [hl, hp] = boundedline(ax, x, mu, se, 'alpha', 'cmap', [0 0 0]); try, set(hp, 'FaceColor', fillCol, 'FaceAlpha', 0.35, 'EdgeColor', 'none'); end if isgraphics(hl) set(hl, 'Color', 'k', 'LineWidth',...
36b72b6891060f9938bbceef972ce56dc0a92aa2bff74741d6908a58eaebeb11
MATLAB
899
38
function [id, r_, G_] = set_all_part_traj(pnts, G, dist_thr, num_sources, N) %source_ids = 1:length(pnts); M=length(pnts); dist_sources=zeros(1,N); r_=zeros(3*num_sources,N); G_=zeros(size(G,1),num_sources,N); min_dist = 0; while min_dist < dist_thr % unique_flag=0; % while unique_flag==0 for nn=1:N ...
d26e5ed1f2840dfb0ad148a612c388441064ccb65882076222c0810c622b08c2
MATLAB
903
38
SimFile=spm_load('spike_detector-21-0.gdf') Neurons=zeros(20,2000); %Neurons_conv = Neurons; for i=1:length(SimFile) Neurons(round(SimFile(i,1)),round(SimFile(i,2)/0.01))=1; end hrf01=spm_hrf(0.1); for i=1:size(Neurons,1) Neurons_conv(i,:)=conv(Neurons(i,:),hrf01); end nrows = size(Neurons_conv,2); ...
2c93b4cdb730f27a14073214457c9fe8faaf5fd8e5bb34a6294a59972a15cd20
MATLAB
906
27
function [ax,srf,cam] = make_surface_plot(~,data,surf,pos,view,clim) % Constructs a single axis with a hemisphere in it. Called exclusively by % plotter. % % For more information, please consult our <a % href="https://brainspace.readthedocs.io/en/latest/pages/matlab_doc/visualization/plot_hemispheres.html">ReadThe...
789f808da55d68a1c14eeaafaf38e44dd0422c679a64875e3e7e03380b079eb4
MATLAB
908
29
load('svm_mat555'); [s v t]=size(svm_mat); sn=Design_Para(:,6)'; mn=Design_Para(:,4)'; corrcoef(mn,sn) for i = 1:size(svm_mat,1) for j = 1:size(svm_mat,3) %svm_mat_norm(i,:,j)=mat2gray(svm_mat(i,:,j)); svm_mat_std(i,:,j)=(svm_mat(i,:,j)-mean(svm_mat(i,:,j)))/std(svm_mat(i,:,j)); end end voxmean_std=resh...
bfb9366f8f1ea79738dcb9bbbda150d354b44ee2cc8dbf7340303a1ca1d46a38
MATLAB
908
27
function loc_list_clusters_area_histogram(data) input_values = inputdlg({'Percentile:'},'',1,{'0 95'}); if isempty(input_values)==1 return else percentile =str2num(input_values{1}); counter = 0; for i = 1:length(data) data_to = unique(data{i}.area); if length(data_to)>1 ...
8934faf2c1c688ee64abfb7f15ef3d30dfc386f8f43e4cdf6ceed7100a2633cd
MATLAB
910
28
function [LocsTable,AllClusters] = calcLocs(data) LocsTable = cell(1,length(data)); AllClusters = cell(1,length(data)); for i = 1:length(data) if ~isempty(data{i}) Clusters = extract_clusters(data{i}); LocsTable{i} = NaN(length(Clusters),8); for j = 1:length(Clusters) ...
9bb44bdd60b636686649d0faa6518bc90ea9872477f97a9406156aa70c490219
MATLAB
910
29
function is_connected = graph_is_connected(G) % GRAPH_IS_CONNECTED Assesses whether a graph is fully connected. % % is_connected = GRAPH_IS_CONNECTED(graph) tests whether the graph is % fully connected. Graph must be a graph, a 2D logical matrix, or a data type that % may be converted to a 2D logical matrix; i...
52dfa993c1d001698d543be63db5b443707ca6be7a0815ea08b5bea61f7104a6
MATLAB
916
24
function y = cvx_default_dimension( sx ) %CVX_DEFAULT_DIMENSION Default dimension for SUM, MAX, etc. % DIM = CVX_DEFAULT_DIMENSION( SX ), where SX is a size vector, returns the % first index DIM such that SX(DIM)>1, if one exists; otherwise, DIM=1. This % matches the behavior by functions like SUM, MAX, ANY, ...
5537e58e70fcb28a36cdd1ee2dfd5ed9d1f0404defa9e09029dba54b05290a3f
MATLAB
916
30
clear all; close all; dataFolder = 'C:\Users\frada\Desktop\WORK in PROGRESS\LAB\TouchScreen_project\Data\Datasets\'; filenameSpikes = [dataFolder 'ID2055_chs0_128_ave_bpass300_6.0k_Int16_r_4_unsorted.mat']; filenameEvents = [dataFolder 'ID2055_data.csv']; filenameCSMS = [dataFolder 'ID2055_CSMS_chs0_128_ave_bpas...
6d6d9df62f990d23a84c3523037a3ced0e93be71ab029cbca72f691d37aad227
MATLAB
917
27
function [coreness,kn] = kcoreness_centrality_bd(CIJ) %KCORENESS_CENTRALITY_BD K-coreness centrality % % [coreness,kn] = kcoreness_centrality_bd(CIJ) % % The k-core is the largest subgraph comprising nodes of degree at least % k. The coreness of a node is k if the node belongs to the k-core but % ...
cfa4159c787ef6cc7c4e0db1e227fdd6f5a5107747cd258e85731d178cc066c3
MATLAB
920
21
function [aN] = compute_aN_fast(r_pf_t, r_pf, q_kf, P_kf, V_r, ... omega_t, lambda_t, num_sources, w, N, CONST, log_det) lam = zeros(num_sources,num_sources,N); eta = zeros(N,1); logw_rb = zeros(N,1); for i=1:1:N gamma = chol(P_kf(1:num_sources,1:num_sources,i)); lam(:,:,i) = gam...
653104a5d596967f6e7b967e638ea2d2bc52de373cc6e3e3323506ba93aa6e6c
MATLAB
922
29
function [CIJ] = maketoeplitzCIJ(N,K,s) %MAKETOEPLITZCIJ A synthetic directed network with Gaussian drop-off of % connectivity with distance % % CIJ = maketoeprandCIJ(N,K,s) % % This function generates a directed network with a Gaussian drop-off in % edge density with increasing distance fro...
321e85096eb1473a9ace9247d3d3d21e77a1d67f21ddaf01e54f54f883045846
MATLAB
924
32
function output = tc_make_sliding_windows(start, stop, steps, sizes) %% output = tc_make_sliding_windows(start, stop, steps, sizes) % % Computes different variations of sliding windows for respective analyses. % % Input: % start: start time point % stop: end time point % steps: 1 x n containing in which steps t...
7f56e5b1f493d1026db4ef005029c2431c1e54327c981879e159f158c487596b
MATLAB
929
24
function O = time_frequency_MEGsensors_dim(S) O = []; %starting up some of the functions that I wrote for the following analysis addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/MITDecodingToServer/BrainstormDemo_CodesTimeFrequencyDecomposition/functions') %to Dimitrios Morlet transform function %preparing da...
9db716ab5149bd1c2c2ea3dbaed0d86525a37665e84cf7487068d7e66a7aba71
MATLAB
929
24
function spt_tracks_convert_tracks_to_image(data) input_values = inputdlg({'pixel size:','image width:','image height:'},'',1,{'0.117','419','680'}); if isempty(input_values)==1 return else pixel_size = str2double(input_values{1}); width = str2double(input_values{2}); heigts = str2double(input_va...
0c1a1655e0345726ce3ee3348b50a70eb255ca182c5fbf9fbed6f88dd0a4741e
MATLAB
935
32
function image_crop(data) rec_coordinates=getrect; if isempty(rec_coordinates) return else x1 = round(rec_coordinates(1)); x2 = round(x1+rec_coordinates(3)); y1 = round(rec_coordinates(2)); y2 = round(y1+rec_coordinates(4)); for k=1:length(data) x_data = 1:size(data{k}....
679116afc8bc40fcc2dfda042f2721c4dd5d465d5842a2d0cfacbf52f8d3bfe4
MATLAB
937
25
function data_load = spt_simulate_random_brownian_motion() input_values = inputdlg({'number of particles:','time step:','number of time steps:','diffusion coefficient: (um^2/s)','size:'},'',1,{'10','0.05','100','0.001','2'}); if isempty(input_values)==1 data_load = []; else num_of_particles = str2double(in...
059225f36a146f6ec44f61ba73289a144c3fc04498f918ecd2b33f4fb22f2fe8
MATLAB
940
29
function T=transitivity_wu(W) %TRANSITIVITY_WU Transitivity % % T = transitivity_wu(W); % % Transitivity is the ratio of 'triangles to triplets' in the network. % (A classical version of the clustering coefficient). % % Input: W weighted undirected connection matrix % % Output: T ...
42ea85dc7fd380d86ff02ae13e3c3cc515b3d1df4e9b0e46f9246ff961adec70
MATLAB
942
35
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% cor2mni %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function mni = cor2mni(cor, T) % function mni = cor2mni(cor, T) % convert matrix coordinate to mni coordinate % % cor: an Nx3...
d11d46f54ac1e40db71f1e7286eba46eacb51a1d0498cdd8ed6e7d23a0e34600
MATLAB
942
29
function SC = combine_surfaces(S1,S2,format) % COMBINE_SURFACES combines two surfaces into a single structure. % % SC = COMBINE_SURFACES(S1,S2) takes two surfaces in a format readable % by convert_surface and combines them into a single one. % % SC = COMBINE_SURFACES(S1,S2,format) outputs surface in the d...
544d481738333c283d7126eb35c10039391e2db58e779dbe33304849b95424e5
MATLAB
945
30
function colormaps(obj,maps) % Sets colormaps for plot_hemispheres. Maps must either be a n-by-3 color % map, or a cell array with the same number of elements as columns in % obj.data, each containing n-by-3 colormaps. % % For more information, please consult our <a % href="https://brainspace.readthedocs.io/en/latest/p...
aa45a5edf4a12af7dd485110717d5a3ad8efb41b13b703dc20b95b4d5483fcbc
MATLAB
945
34
cd('/home/adrian/Documents/GitHub/RGS14/spiking_activity') % RGS14 %load('Name_Confirming_Data.mat'); load('New_Wake_Data_Extra_Units_clean.mat'); x=New_Wake_Data_Extra_Units; %% v=[]; v_name={}; for i=1:length(x) % 107 pyr units v(i,:)=[x(i).Presleep x(i).Trial_1 x(i).Post_Trial_1 x(i).Trial_2 x(i).Post_Tr...
56003bba4a477b2a115c0538d6e84fd03ff2a29c5f00ba6a79abe5768f4d2992
MATLAB
946
37
function filenames = SurfStatListDir( d, exclude ); %Lists all the file names in a directory. % % Usage: filenames = SurfStatListDir( dir [, exclude] ); % % d = directory, including wildcards such as '*'. % exclude = matrix with rows as strings; any file name containing % any of these str...
c24053c761c842ff5c4e4626b11f871af50c2888b987c2aa75761d7d01c0be9f
MATLAB
946
48
function [t] = pl_cell_tstat2_unequalvar(Cell1,Cell2) % Computes a 2-sample t-statistic (does not assume equal variance). % % The variables are expressed in cells for speed % This function is part of the permutationlab software: % Author: Dimitrios Pantazis % The code is currently under development, please do...
0a02cb0644adcc1746f46f3eb90433cf5872aa561310bd5128230da5a59fb1cf
MATLAB
947
26
function matchingFiles = getFileContainingString(folderPath, searchStr, extension) % Check if an extension is provided if nargin < 3 extension = ''; % Default to empty string if not provided end % List all files in the folder files = dir(folderPath); % Initialize a cell array to store ...
d37b58f3dcde73d3708e5c6f555bccd60d9410e67e6d6b00f0d3e66753c731b7
MATLAB
947
30
function [Spos,Sneg,vpos,vneg] = strengths_und_sign(W) %STRENGTHS_UND_SIGN Strength and weight % % [Spos Sneg] = strengths_und_sign(W); % [Spos Sneg vpos vneg] = strengths_und_sign(W); % % Node strength is the sum of weights of links connected to the node. % % Inputs: W, undirect...
a92f5ddb8176b056f89e990f1e4c88ca6825d6566ce46c4d53a570f02f7b60ee
MATLAB
950
27
function loc_list_clusters_no_of_locs_histogram(data) input_values = inputdlg({'Ppercentile:'},'',1,{'0 95'}); if isempty(input_values)==1 return else percentile =str2num(input_values{1}); counter = 0; for i = 1:length(data) data_to = unique(data{i}.area); if length(data_to)>1 ...
59308a10b95a9e4a0387e842df9e18bdadcd0dffb5a164b812eef51b56e8323b
MATLAB
953
40
function y = diff(x) % DIFF Difference and approximate derivative. % DIFF(X), for a vector X, is [X(2)-X(1) X(3)-X(2) ... X(n)-X(n-1)]. % DIFF(X), for a matrix X, is the matrix of row differences, % [X(2:n,:) - X(1:n-1,:)]. % DIFF(X), for an N-D array X, is the difference along the first % non-si...
5edf9b4454511775b1ab61c62dc52f89456cd2dc5b7bf8abeaa5e47967964bec
MATLAB
954
15
function image_plot_right_click(data,name) ax = gca; cla(ax); mouse_location = get(gca,'CurrentPoint'); imagesc(data) colormap(gray) title({'',regexprep(name,'_',' ')},'Interpreter','latex','fontsize',14) line([mouse_location(1,1) mouse_location(1,1)],[1 size(image,1)],'Color','r','LineStyle','--') line([1 size(...
d5d4ac47d50ef455434a2bbcb3907b72d9ae744351e098140557a3600f8f4ba7
MATLAB
954
46
function mipp_plotParVsTime(T, xnam, ynam, fnam, flev) % function mipp_plotParVsTime(T, xnam, ynam, fnam, flev) uID = unique(T.ID); for i = 1:numel(uID) ind = T.ID == uID(i); % f = T.(fnam)(ind); x = T.(xnam)(ind); tmp = T.(ynam)(ind); clear y for j = 1:numel(tmp) tmp2 = tmp{j};...
b537e552ddd84e23f052d18c42db1078223c78f09e857bf70025ff44907048f7
MATLAB
955
23
function data_down_sample = loc_list_down_sample_data(data) answer = inputdlg({'Number of Localizations:'},'Input',[1 50],{'50000'}); if isempty(answer)~=1 scatter_num = str2double(answer{1}); data_down_sample = cell(1,length(data)); for i = 1:length(data) if length(data{i}.x_data)>scatter_num...
f2de91d15095e0bdbaa697340ca3366d79e825fafde5e30af4c6b66470671ad3
MATLAB
955
39
function M0 = matching_ind_und(CIJ) %MATCHING_IND_UND matching index % % M0 = MATCHING_IND_UND(CIJ) computes matching index for undirected % graph specified by adjacency matrix CIJ. Matching index is a measure of % similarity between two nodes' connectivity profiles (excluding their % mutual connect...
6667685d96bfd003eeb7dcd215442df87eae3f5107a35f382b06c613b3a8b95c
MATLAB
956
31
function [subject_name, sSubject, iSubject] = bst_create_test_subject(template_name, use_default_anatomy) if nargin < 1 template_name = 'Colin27_4NIRS_lowres'; end if nargin < 2 use_default_anatomy = 0; end bst_create_test_protocol(use_default_anatomy); % Add test subject subject_name = 'test_subject'; [sSu...
7b0956154cfe5e9353fa3963b194dd15b446be76766f39c5877a7fe6df3448b0
MATLAB
959
27
clear; addpath('/home/common/matlab/fieldtrip') sj='S52'; %task=['B' num2str(blknr)]; stem='/project/3018037.01/Experiment3.2_ERC/AnalysisFolder/'; %S8/rawData/eegfiles' %/project/3018037.01/Experiment3.2_ERC/AnalysisFolder/subjectData/S30/6_EEG/ica bpfilt=[0 0]; chnls ={'all','-ECG'};%,'-F3',...
0818ba67c1967fd72dd15310c096050e7b273463674dd008b9abb276b3e5f587
MATLAB
960
63
%% motivated by http://grasshoppernetwork.com/showthread.php?tid=629 %% create signal a=5; c=1; m=2; f=50; n=10;%no of sample per second? fs=100*f;% @least twice by nequist ts=1/fs; t=0:ts:n/f; x = c+a*sin(2*pi*f*t)+a*sin(2*pi*m*f*t)+a*sin(2*pi*2*m*f*t); plot(x); fx=fft(x); plot(real(fx)) [idx val]=max(real(fx)) %% o...
3b6a66466d36dc4f25cf749012036c09467e05aa9016a553c5f056bfff0d6270
MATLAB
961
37
%READ_WRITE_ENTIRE_TEXTFILE Read or write a whole text file to/from memory % % Read or write an entire text file to/from memory, without leaving the % file open if an error occurs. % % Reading: % fstrm = read_write_entire_textfile(fname) % Writing: % read_write_entire_textfile(fname, fstrm) % %IN: % fn...
68232a43bcd28b4e83b78097ba2ba812e5cd7bccbc2a2dcd6ae6051e0ce190d6
MATLAB
962
41
function [freq,power] = ft_power(mat,TR) Fs = 1/TR; % Sampling frequency if ndims(mat) == 4 L = size(mat,4); % Length of signal elseif ndims(mat) == 2 L = length(mat); end freq = Fs*(0:(L/2))/L; if ndims(mat) == 4 power = zeros([size(m...
e2b8790b806568ad462c16db19f1480dccaa3f879e5ed34776eb9ca6967dd896
MATLAB
962
55
%% kernel projection demo datac0=[rand(10,1);-rand(10,1)]; plot(datac0,0,'r.') datac1=[randi(10,10,1)',-randi(10,10,1)']'; hold plot(datac1,0,'b.') hold off train=[datac0;datac1] figure class=[zeros(20,1);zeros(20,1)+1]; train2d=[train,train.*train] svmStruct = svmtrain(train2d,class,'showplot',true); %% svm circl...
5699d2f1749a4ef967986052392888d81ac9e6be56d0c702a244ea320ba4f934
MATLAB
968
35
function create_AALnifti(aalvector,name,symm) % script to create AAL nifti file for rendering % aalvector is a 1x90 vector with a value for each AAL region % name is the name of the output file % symm is a flag that if >0 means that ordering is symmetrical aalnii=load_nii('aal_2mm.nii.gz') % create new image newni...
8cd21725c0c8da727097b5a07f08b022383ac04dd93926966027e679c9c4ec55
MATLAB
972
29
function [S] = suff_stats_gpu(q_ks, q_ks1, Y_, N, nq, ny, w_1, J, T) gputimes = @(A, B) pagefun(@mtimes, A, B); % A*B on GPU gputranspose = @(A) pagefun(@transpose, A); % A' gputimes_e = @(A, B) pagefun(@times, A, B); % A*B on GPU q_ks = permute(q_ks, [1 3 4 2]); q_ks1 = permute(q_ks1, [1 3 4 2]); Y...
ad1a1562b46bece62f9027443c67325a3bb1fcf5164850294bdab96315b4df90
MATLAB
973
55
function [comm_diff, perm_needed, V1, V2] = find_comm_diff(V1, V2) comm_diff1 = sum(V1~=V2)/length(V1); count = 0; for i=1:max(V1) if sum(V1==i)<2 V1(V1==i) = 0; count = count + 1; else V1(V1==i) = i-count; end end count = 0; for i=1:max(V2) if sum(V2==i)<2 ...
0cf41347fb1a433877ea9fe5c61c65f19f0f42daf25cb56ef42b8df0e535fb7b
MATLAB
974
53
%% load data %load('svm_mat555'); %% extract zone data_STS=svm_mat(:,ind_STS,:); %% plot zone temp=data_STS(7,round(33.0078),:); temp=Design_Para(:,1); plot(squeeze(temp)); axis equal;axis off; plot(Design_Para(:,4)) hold plot(Design_Para(:,6),'r') hold off %% Extract musicness [s v t]=size(svm_mat); temp=reshape(sv...
6762ed65569ca504370349887268afc2f9f45c3be4dd8f816b9fcccac73df091
MATLAB
976
26
function events_mat = nst_make_event_regressors(events, filter, time) % NST_MAKE_EVENT_REGRESSORS build event design matrix from given events and filter % % EVENTS_MAT = NST_MAKE_EVENT_REGRESSORS(EVENTS, FILTER, TIME % % EVENTS (struct array): % events as brainstorm structure (see DB_TEMPLATE('event')...
967e6d65aafbea3f2ead8b63b8449b1d81501f20348e5b6e505f04d5a52f1cbf
MATLAB
977
29
function results = runTests() import matlab.unittest.TestSuite matlab.unittest.TestRunner import matlab.unittest.plugins.CodeCoveragePlugin import matlab.unittest.plugins.codecoverage.CoverageReport root_path = nla.findRootPath(); % get all unittests folders filelist = dir(fullfile(root_path,...
c7bc7de31bc08da747ba6bc4af4e86d4041452a029b8d620caf20fbbaeb2bc06
MATLAB
977
38
% Save NIFTI header extension. % % Usage: save_nii_ext(ext, fid) % % ext - struct with NIFTI header extension fields. % % NIFTI data format can be found on: http://nifti.nimh.nih.gov % % - Jimmy Shen (jimmy@rotman-baycrest.on.ca) % function save_nii_ext(ext, fid) if ~exist('ext','var') | ~exist('fid','var') ...
4bc05413c23c27de7620545c4c24759bface705fe654e900bf9c4d311416ef8d
MATLAB
978
24
function plot_histogram(x_pdf,y_pdf,x_cdf,y_cdf,names,x_label,percentile) figure() set(gcf,'name','histogram','NumberTitle','off','color','w','units','normalized','position',[0.15 0.2 0.7 0.5],'menubar','none','toolbar','figure') subplot(1,2,1) hold on for i = 1:length(x_pdf) plot(x_pdf{i},y_pdf{i}) en...
23f5852a9309eda9d7383705b3bac6cfced8a37980ae10d0c01e8604a16d5bbe
MATLAB
983
47
function [t] = pl_cell_tstat_2sample(Cell1,Cell2) % Computes a 2-sample t-statistic assuming equal variance. % % The variables are expressed in cells for speed % This function is part of the permutationlab software: % Author: Dimitrios Pantazis % The code is currently under development, please do not share ...
8078ed1595da20d9f79840fa550eb72bfc7730e1d4838240fa6dce5372c47e1e
MATLAB
994
23
function [origin, rad_origin, radius] = findCircleFromTwoTangents(a, b, rad_a, rad_b) %FINDCIRCLEWITHTWOTANGENTS Find the origin and radius of a circle, % given two tangent points and slopes % Points and slopes MUST be ordered clockwise from the perspective of % the circle you are trying to locate (cann...
3ca3c9612bc631228829131f5a3322eaf225640e11f21d204f8d4e6f02a86e66
MATLAB
996
41
function map = spectral( m ); %Black-purple-blue-green-yellow-red-white color map. % % Usage: map = spectral( m ); % % m = number of colours; default is the length of the current colormap. % % map = m x 3 matrix containing a "spectral" colormap. % % E.g. colormap(spectral) resets the colormap of the current...
24df3683b62691e98a9d0ade6df4fb4c8ab6d55967d61e87d398081c4fcd1b42
MATLAB
1,002
20
function shape_classification_iterative_linkage_coeff_var_clustering(data) input_values = inputdlg({'Length and Width Coeff. of Variation Threshold Variation:'},'',1,{'0.05:0.01:0.17'}); if isempty(input_values)~=1 coeff_var = eval(input_values{1}); size_c_o_v = size(data.classes{1,3},2); coefficient_o...
8178e1ab6ae5cd0d426069d47abd8f694338cf9a3a4fb6b78a2277a30721509f
MATLAB
1,002
34
function formatNBP(h,plotColours, plotAlpha) %FORMATNBP Formats a notBoxPlot % Formats colours, alpha values, line widths, and point size of the notBoxPlot. % % h: handle to notBoxPlot % plotColours (optional): desired colours (you need to provide at least as many as % your conditions) as a numberOfColours X 3 ...
8e039a5922979c130a4ed878f4415bb65499a0dc342b6bfbaa595a27671b3164
MATLAB
1,003
26
function [omega_t, lambda_t] = compute_omega_lambda_fast(A, V_q, G_pf, Y, XI, num_sources, p, N, T) nq = num_sources*p; F_ = chol(V_q(1:num_sources, 1:num_sources)); % F_ = zeros(nq,nq); % F_(1:num_sources, 1:num_sources) = F; % F_(num_sources+1:num_sources*p, 1:num_sources)=0; % F_(1:num_sources*p, num_sources+1:end)=...
2117b6fe356b69818016d9da338ec45326cb6748857eee7b2537179ddf23d841
MATLAB
1,004
20
function shape_classification_iterative_distance_coeff_var_clustering(data) input_values = inputdlg({'Length and Width Coeff. of Variation Threshold Variation:'},'',1,{'0.05:0.01:0.17'}); if isempty(input_values)~=1 coeff_var = eval(input_values{1}); size_c_o_v = size(data.classes{1,3},2); coefficient_...
7dd5548b162fc267a081977d2b021b2d32618fb29c61c5407d3ab6ffd8d6efcf
MATLAB
1,004
51
%% load file load('svm_mat_UMS_svm_20110520.mat') whos %% write csv a=csvread('voxel_index.csv'); csvwrite(svm_mat,'dysl,csv'); %% extract voxel coordinates v=size(ind,1); P_in='svm_mat_UMS_svm_20110520.mat'; for i=1:v i [voxcoords] = svm2mni(P_in, i); vxcrds(i,1)=voxcoords.XYZmm(1); vxcrds(i,2)=voxcoor...
3bccb1eb056f89b7b83d4c19f996333b5674d0e5ab6bc6b2c0e50682d6b6a6c3
MATLAB
1,006
23
function [data_clustered,data_not_clustered] = voronoi_data_get_voronoi_cluster(data,type) if type ==1 answer = inputdlg({'Area Threshold:','Minimum Number of Localizations per Cluster:'},'Input',[1 50],{'0.013','5'}); else answer = inputdlg({'Area Threshold:','Minimum Number of Localizations per Cluster:'},...
c5c4706b5bd06f8f537094d799de81a6347f07c7ac86ab8e371e51466c75aba8
MATLAB
1,009
43
function t=emart(I,NI, m1, s1, m2, s2) %dm1=1; %dm2=1; %ds1=1; %ds2=1; w0=0.001; w1=0.6; w2=0.399; N=sum(NI); %disp([m1, s1, m2, s2, w0, w1, w2]); %while (dm1>.1 || dm2>.1 || ds1>.1 || ds2>.1) iter=0; while iter<80, p0=1/I(end); p1=exp(-1/2*((I-m1)/s1).^2)/sqrt(2*pi*s1^2); p2=exp(-1/2*((I-m2)/s2).^2)/sqrt...
c5a1d3500065b6791a153c817c23020f71efcb56f78e183b35df3c012075c255
MATLAB
1,010
43
function [p_vec, t_vec, dof_vec] = welchT(x1, x2) %WELCHT 2-sample Welch T-test %% Prepare data x1_size = size(x1); if x1_size(end) == 1 x1_size(end) = []; end x2_size = size(x2); if x2_size(end) == 1 x2_size(end) = []; end ndim = length(x1_size); %...
bbf3bf924caec5943700e1f21918d17c62f44f8404a9b5fc44147cc6e64ad179
MATLAB
1,015
38
% Save NIFTI header extension. % % Usage: save_nii_ext(ext, fid) % % ext - struct with NIFTI header extension fields. % % NIFTI data format can be found on: http://nifti.nimh.nih.gov % % - Jimmy Shen (jimmy@rotman-baycrest.on.ca) % function save_nii_ext(ext, fid) if ~exist('ext','var') | ~exist('fi...
dcd665edbcff7419d79e3d27b00e7addb189eebe355067dd41c1f2fb06269625
MATLAB
1,015
30
function C=clustering_coef_wu(W) %CLUSTERING_COEF_WU Clustering coefficient % % C = clustering_coef_wu(W); % % The weighted clustering coefficient is the average "intensity" % (geometric mean) of all triangles associated with each node. % % Input: W, weighted undirected connection matrix ...
301299b7a0f9238652e364dc9833bd15d5cf6358ab76008f804ade9d15610b04
MATLAB
1,019
28
function loc_list_clusters_norm_density_histogram(data) input_values = inputdlg({'Percentile:'},'',1,{'0 95'}); if isempty(input_values)==1 return else percentile =str2num(input_values{1}); counter = 0; for i = 1:length(data) data_to = unique(data{i}.area); if length(data_to)>1 ...
65a8d402707f1918c5208eaf13e88d37678f1b2d24020ce74ef570129eafa3e7
MATLAB
1,020
28
function D = agreement_weighted(CI,Wts) % AGREEMENT_WEIGHTED Weights agreement matrix % % D = AGREEMENT_WEIGHTED(CI,WTS) is identical to AGREEMENT, with the % exception that each partitions contribution is weighted according to % the corresponding scalar value stored in the vector WTS. As an example, ...
9a0b47f98202ed9dd0398f4630c6567a06f84a37232475f81bdc2e99874d317f
MATLAB
1,020
26
function shape_classification_extract_classes(data) number_of_classes = size(data.classes,1); if number_of_classes == 1 input_values = inputdlg({'Classes to Exctract:'},'',1,{'1'}); else input_values = inputdlg({'Classes to Exctract:'},'',1,{['1:',num2str(number_of_classes)]}); end if isempty(input_val...
af6fc083878d0c94b58a32099cad63679578ec2849f63eb90d4dd67f61b020c8
MATLAB
1,023
32
function loc_list_clusters_total_clusters_area(data) counter = 0; for i = 1:length(data) data_to = unique(data{i}.area); if length(data_to)>1 counter = counter+1; data_to_send{counter} = data{i}; end end if exist('data_to_send','var') f = waitbar(0,'Finding Total Cluster Area')...
23c1e85db45a23243de921374ca157e13136ca19613729d334e1dc04b5589a64
MATLAB
1,028
31
function spt_compute_mean_velocity_correlation(data) f = waitbar(0,'calculating mean msd'); for i=1:length(data) mean_velocity_correlation{1} = calculate_mean_velocity_correlation(data{i}.velocity_correlation); data_to_send{i}.velocity_correlation = mean_velocity_correlation; data_to_send{i}.name = [da...
23537e53285b550689cdc2ed9619cd67a28b7ca7830c1d3cdcc2b2d4b96044a0
MATLAB
1,032
42
function create_HCP_MMP1_nifti_LBPD(vector,name) % script to create HCP-MMP1 nifti file for rendering % INPUTS: vector: a 1x90 vector with a value for each AAL region % name: the name of the output file if length(vector) == 180 MMP1 = load_nii('HCP-MMP1_on_MNI152_ICBM2009a_nlin....
713f74b0033bd8a33128ea1f778a421840022e79947b2a4aa07f05738e541929
MATLAB
1,036
66
function [data, A] = three_source_model(T, type) %if type = 0, one non-interacting source else source 1 -> source 2 -> %source 3 M = 3; %number of sources; P=2; %order of the model T0=1000; %length of ignored start Rmax=50; %Generate stable AR matrix while Rmax>3 lambdamax=10; while lambdamax > 1 || lambda...
4d8785b28abdecd677118a8f1258befb489b9e996e4f504c79b485f80152c81c
MATLAB
1,039
29
function loc_list_clusters_density_histogram(data) input_values = inputdlg({'Percentile:'},'',1,{'0 95'}); if isempty(input_values)==1 return else percentile =str2num(input_values{1}); counter = 0; for i = 1:length(data) data_to = unique(data{i}.area); if length(data_to)>1 ...
0dd4cb687a9dda6c69f9a2cfd002062032aab805fe498d2c8f1f78e8d5d10bfe
MATLAB
1,040
36
function dataTFR = eegFreqAnalysis(parameterSettingsTF, dataVC) %% dataTFR = eegFreqAnalysis(parameterSettingsTF, dataVC, dataTL) tc_struct2ws('caller', parameterSettingsTF) % prepare data struct for fieldtrip dataTFR=[]; dataTFR.trial=dataVC.virtChannels; % set virtual channels to be the data dataTFR.time= arrayfun(...
c0bde50575c1e66da3c656ef20776ae8261d56d72bbd794a9bf8742612d111f0
MATLAB
1,041
35
function data_load = load_image() [file_name,path] = uigetfile({'*.jpg;*.png;*.jpg;*.tif;*.tiff;*.jpeg'},'Select Image File(s)','MultiSelect','on'); if isequal(file_name,0) data_load=[]; else file_name = cellstr(file_name); f=waitbar(0,'Loading Image(s)...'); for i = 1:length(file_name) ...
4d4bd4aecc6b425af3352fc68b3f0add3c47929631b38ad5eb24e93465ae34bb
MATLAB
1,052
33
function [Rate_on_mean]=data_reduction(Rate_on,StringFunc) if strcmp(StringFunc,'mean') Rate_on_mean=[mean(getfield(Rate_on,'Presleep'))... mean(getfield(Rate_on,'Post_Trial_1'))... mean(getfield(Rate_on,'Post_Trial_2'))... mean(getfield(Rate_on,'Post_Trial_3'))... mean(getfield(Rate_on,'Post_Trial...
bd4dc94aa1fe9303982dae56dee3874c9df668cbc3b4370b7291a7c66a1b49d5
MATLAB
1,052
39
function [R,D] = breadthdist(CIJ) %BREADTHDIST Reachability and distance matrices % % [R,D] = breadthdist(CIJ); % % The binary reachability matrix describes reachability between all pairs % of nodes. An entry (u,v)=1 means that there exists a path from node u % to node v; alternatively (u,v)=0. % % The ...
f076755daffec6ee7c73ae80947e617404b7086a4d4082faa1c2b44552f9460d
MATLAB
1,052
28
function D = remove_bad_components_l(D,S) % Take in a D object with D.ica.bad_components % Make a new montage where all the channels stay the same but % they have had the bad ICA components subtracted from them D = D.montage('switch',0); if strcmp(S.modality,'EEG') chantype = 'EEG'; ...
17317645539ff970f9a9de5636663a0150c35936b24bb10da1ec83de3995554e
MATLAB
1,054
35
classdef EdgeResultsTest < matlab.unittest.TestCase properties variables end methods (TestClassSetup) end methods (TestClassTeardown) function clearTestData(testCase) clear end end methods (Test) function precalculatedInitTest(testCase) ...
773a0149227ffc0149c265c0c4973edf2456599a453ed6e814c58b1cebc36608
MATLAB
1,056
24
function Cs = subgraph_centrality(CIJ) % SUBGRAPH_CENTRALITY Subgraph centrality of a network % % Cs = subgraph_centrality(CIJ) % % The subgraph centrality of a node is a weighted sum of closed walks of % different lengths in the network starting and ending at the node. This % function returns a vector of s...
e1ae5e9fe6d358401248ce035bcd3fe91e2af584ff21055852e58100e1247e89
MATLAB
1,056
34
classdef utils_tests < matlab.unittest.TestCase methods(Test) function test_graph_is_connected(testCase) % Tests the graph_is_connected function against MathWorks' % conncomp. one_disconnected = ones(5); one_disconnected(:,5) = 0; one...
00e88343c8454d9237eda1f9bd6f554e4f17d78cd821c3a4b372c51f017d4d5a
MATLAB
1,058
59
function V3 = harmonize_comm(V1, V2) comm_diff1 = sum(V1~=V2)/length(V1); count = 0; for i=1:max(V1) if sum(V1==i)<2 V1(V1==i) = 0; count = count + 1; else V1(V1==i) = i-count; end end count = 0; for i=1:max(V2) if sum(V2==i)<2 V2(V2==i) = 0; ...
9e5078a1edb336ee5ef59bd5572af8f8694c322fc77c4d2736a374e099252de1
MATLAB
1,060
25
function [valid_nodes,dis2cortex] = nst_headmodel_get_FOV(ChannelMat, cortex, thresh_dis2cortex, ChannelFlag) %% define the reconstruction FOV if nargin < 4 ChannelFlag = ones(1, length(ChannelMat.Channel)); end montage_info = nst_montage_info_from_bst_channels(ChannelMat.Channel, Chan...
b89647fb25d1a08136a7aaaad389ad53d7135e0dae586ea15ac5d2649e5b731e
MATLAB
1,063
28
function fig2svg(name, w, h, folder) if nargin < 4 % Determine figure folder from name (e.g., "Fig2C" -> output/fig2/) repoRoot = fileparts(fileparts(mfilename('fullpath'))); tokens = regexp(name, '(?i)(S?Fig)[_]?(\d+)', 'tokens', 'once'); if ~isempty(tokens) prefix = low...
3c8a56f3ad7616f4f2447a4f7ffabb3863df7981104a36946bb486d23b4bb27a
MATLAB
1,064
41
function loc_list_crop(data) try coordinates = getrect(); data_crop = cell(1,length(data)); for i = 1:length(data) data_crop{i} = loc_list_crop_inside(data{i},coordinates); end data_crop = data_crop(~cellfun('isempty',data_crop)); catch data_crop = []; end loc_list_p...
62936f10fe16013033917a9c833ff768a4e309a3bd7b07c0e543969503352922
MATLAB
1,064
24
function opt = resQ_opt(opt) % function opt = resQ_opt(opt) opt.resQ.present = 1; opt.resQ = msf_ensure_field(opt.resQ, 'fig_maps', ... {'s0', ... 'D', 'R', 'Vi','Va','Vt', ... 'VRi', 'VRa', 'XDRi', 'XDRa', ... 'D_lo', 'D_hi', 'Vi_hi','Va_hi','Vt_hi', ... 'Xi_hi', 'Xa_hi', 'Xt_hi', ... ...
cdfcbd55fa9975f865339f30e5b23138d5bd5c7aab1d612e02109d1618ca1aaa
MATLAB
1,065
32
classdef Homoskedastic < nla.helpers.stdError.AbstractSwEStdErrStrategy properties (SetAccess = protected) REQUIRES_GROUP = false; end methods function contrastStdErr = calculate(obj, sweStdErrInput) %Calculation of standard error assuming homoskedasti...
55c170bad58f3e0bcdde63da164fe07c74ad77e2c133cf60b0cd62bff1c86469
MATLAB
1,067
58
%% microglia image tiffread for i=1:size(ans,2) microglia(:,:,i)=ans(i).data; end % figure;imshow(reference_image) figure;imagesc(microglia(:,:,1)) reference=[350,350] reference=round(reference); mask=zeros(size(microglia(:,:,1))); mask(reference(2),reference(1))=1; % figure;imagesc(mask) % pixel ...