sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
17k
content
stringlengths
1
200k
7ce9119a4333c87173981758482121841752b34e9366f3afa3aa7b8a8755aec8
MATLAB
322
16
function O = sensor_average(input) 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 one) osl_startup D = spm_eeg_average(input); % perform analysis for subject n using data directory and subject n...
e8407feb6d8945a1cb9cf5935fc27da75d2e7e3174e3e3b093be65def4cf7431
MATLAB
324
11
function contrast = nst_make_basic_contrasts(events_order) contrast = struct(); for ievent=1:length(events_order) contrast(ievent).label = events_order{ievent}; con_vec = zeros(1, length(events_order)); con_vec(ievent) = 1; contrast(ievent).vector = sprintf('[%s]', strip(sprintf('%d ', con_vec))); end ...
14c6785d2833e9d0e047f84231f06ce9947e91d48a01fb96da60661b50ad26f3
MATLAB
329
18
function [freq]=time_frequency(ft_data1,freqrange,toy) % Compute spectrogram cfg = []; cfg.method = 'mtmconvol'; cfg.taper = 'dpss'; cfg.foi = freqrange; cfg.t_ftimwin = .1 * ones(size(cfg.foi)); cfg.tapsmofrq = 10; cfg.toi=toy; cfg.keeptrials = 'yes'; cfg.output = 'pow'; freq = ft_freqanalysis(cfg, ft_data1)...
4f5da556e325b6baa290d885dd68eb881e382eeebbcf7ab3f28b0a8edc8bb858
MATLAB
329
16
function spt_send_data_to_workspace(data_to_send) global data listbox if isempty(data)==1 data=data_to_send; else data= horzcat(data,data_to_send); end if isempty(data)==1 listbox.String = 'NaN'; else for i=1:length(data) names{i} = data{i}.name; end listbox.String = names; ...
68aaacba4103b9825ce7fb8fa04bd6221ca22a7e872e2e0d34e04889b7d82d06
MATLAB
331
14
function code=crc( msg ) % function for row by row encoding of msg % generator polynomial generator = [1 0 0 0 0 0 1 1 1]; % 8bit CRC c = [1 0 0 0 0 0 0 0 0]; % x^k for k=1:size(msg,1) multip=conv(c,msg(k,:)); [divid, remainder]=deconv(multip,generator); remainder=mod(remainder,2); code(k,:)=xor(multip,remai...
f074363276b3bd671c4d8041e2925f9b16634168259ef5fcc0f4ef08f64da340
MATLAB
331
13
function O = cluster_africa(S) 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 one) osl_startup D = S.D; D = osl_africa(D,'do_ica',true,'do_ident',false,'do_remove',false,'used_maxfilter',true); D.sav...
e63111a250ef9c17a59eef81b77abc9f8057c2816e3320f38e9ad6965d165048
MATLAB
332
14
function [q, P] = kalman_predict_gpu(q, P, A, V_q ) gputimes = @(A, B) pagefun(@mtimes, A, B); % A*B on GPU gputranspose = @(A) pagefun(@transpose, A); % A' q=gpuArray(q); P=gpuArray(P); A= gpuArray(A); V_q=gpuArray(V_q); q = gputimes(A,q); P = gputimes(gputimes(A,P),gputranspose(A)) + V_q; q=gather(q); P=ga...
48edb33df57c33adc63bd5bed0e30a5168334c49c4f1e1f3fa1c7dd56c660904
MATLAB
334
12
data_pi_sort(:,1)=data_pi(:,1); data_pi_sort(:,2)=data_pi(:,2); data_pi_sort(:,3)=data_pi(:,8); data_pi_sort(:,4)=data_pi(:,9); data_pi_sort(:,5)=data_pi(:,3); data_pi_sort(:,6)=data_pi(:,5); data_pi_sort(:,7)=data_pi(:,6); data_pi_sort(:,8)=data_pi(:,4); data_pi_sort(:,9)=data_pi(:,7); data_pi_sort(:,10)=...
c30eab8e058357a07e9eccde2ce5cab6b9985cb80e6cf19d9d56569bd5690209
MATLAB
334
14
function s = nst_protect_fn_str(s) s = strrep(s, '|', '_'); s = strrep(s, '"', ''); s = strrep(s, ':', '_'); s = strrep(s, '(', '_'); s = strrep(s, ')', '_'); s = strrep(s, '[', '_'); s = strrep(s, ']', '_'); s = strrep(s, '!', '_'); s = strrep(s, '__','_'); s = strrep(s, ' ', '...
e8628b64850edae0c8a8a8c5317a307a2de815100588c630f82b5d00f79ad999
MATLAB
334
11
function h = drawLine(ax, x, y, col) %DRAWLINE Draw line segment between two points % ax: axes to draw on % x: x-y position of beginning point % y: x-y position of ending point % col: optional color if ~exist('col', 'var'), col = 'k'; end hold(ax, 'on'); h = plot(ax, x, y, 'Color...
f8e85b8a2ea2cd9ef38d20ec7fd1b5d4c20df78e49c88f049b1c95c25f3df508
MATLAB
335
14
function classes_new = group_classes(idx,classes) idx_classes = classes(idx,:); temp = idx_classes(:,1); classes_new{1,1} = vertcat(temp{:}); temp = idx_classes(:,2); classes_new{1,2} = vertcat(temp{:}); classes_new{1,3} = mean(classes_new{1,2},1); temp = idx_classes(:,4); classes_new{1,4} = vertcat(tem...
6ab1f9e7959bcbbcbaf85a1c6b6bee12e284d6e4146a3b94613eb650505473c8
MATLAB
336
7
function [result, problem] = NOW_RUN(problem) % function [result, problem] = NOW_RUN(problem) % This function calls the private function "optimize". The repackaging is % done so that "NOW_RUN" can be acessed by calls from anywhere in the % matlab structure (unlike optimize, which is restricted). [result, problem] = op...
76146066ebf9a617c71a89a569b657eb6e55e1439b206e8931cf44101d5f6ac2
MATLAB
337
15
function O = combining_planar_cluster(input) 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 one) osl_startup D = spm_eeg_combineplanar(input); % perform analysis for subject n using data directory...
6df9131b42b9cc123602c6049d5cdbfaca9de8af65d4c5637b47609918440d13
MATLAB
343
16
%% read file filename='Ecoli.sff'; %M = 100; %sf = sffread(filename, 'block', [1 M], 'feature', 'f') %all = sffread(filename, 'block', [1 M], 'feature', 'sqc'); sf = sffread(filename, 'feature', 'hf'); %% extract flow x=rand(1,10) sf10=sf(1).FlowgramValue(:); sfh10=sfh(1).Header(:)' for i 1:10 blastval(i)=[sfh(i...
612466f0bb4ed120b18cb64fdb3883c5bf8555d4c7f66f7018a86b9c8a628a49
MATLAB
345
12
function [] = tc_move_spm_results(from, to, name) %% tc_move_spm_results(from, to, which) % % copies data with regexp file names in the row cell array "name" from "from" to "to" for this = name try movefile([from filesep this{1}], [to filesep]) catch warning(['file ' from filesep this{1} ' does...
b626a22c7eeb918a1ef828d8a628afa6caaf3fd873f2bf6467240b7f244aaa69
MATLAB
345
11
function [ind_, r_, G_] = set_part_traj_mcmv_prior(Y, noise_cov, G, pnts_e, included_sp, num_sources, T) [loc_est, id_est, G_mcmv, ~] = MCMV_beamformer_localizer(Y, noise_cov, G, pnts_e, included_sp, num_sources); for j=1:1:num_sources ind_(j,:) = repmat(id_est(j), [1 T]); end r_ = repmat(loc_est,[1 T]); G_ =repma...
bdea291891735cc3f5de35244ede6f9024385c0c52873d6a758a5752277e9cf0
MATLAB
346
10
function M_t = compute_Bt(P_ks, P_ks1, M, nq, ny, N) M_t = zeros(3*nq+ny, 3*nq+ny, N); M_t(1:nq,1:2*nq,:) = [P_ks, M]; M_t(1:nq,2*nq+ny+1:end,:) = P_ks; M_t(nq+1:2*nq,1:2*nq,:) = [M, P_ks1]; M_t(nq+1:2*nq,2*nq+ny+1:end,:) = M; M_t(2*nq+ny+1:end, 1:2*nq,:) = [P_ks, M]; M_t(2*nq+ny+1:end, 2*nq...
e6e8b10e89e3301c8e695552387dcd0fca8c7ea7f9174094c2bcc9acc69a5f3b
MATLAB
347
7
function [ll] = compute_complete_ll(T, stats, V_q, A, E, G_s) logdetV = 2*sum(log(diag(chol(V_q)))); logdetE = 2*sum(log(diag(chol(E)))); ll= -1/2*(T*logdetV + trace(V_q\(stats.Phi - stats.Psi*A' - A*stats.Psi' + A*stats.Sigma*A'))... + T*logdetE + trace(E\(stats.Omega - stats.Lambda*G_s' - G_s*stats.Lambda' + ...
b9ea9b4ee5a63c2af407450ef6b0a6ebcbf01da4cec267ac394c389acf0ba525
MATLAB
348
16
function Cell_slice = pl_cell_slice(Cell,ndx) % % Slices cell elements keeping the indices 'ndx' % This function is part of the permutationlab software: % Author: Dimitrios Pantazis % The code is currently under development, please do not share N = length(Cell); %compute mean for i = 1:N Cell_slice{i...
36ddb6ddd05ce2571b6bee436b3bbd694a76e2334aefe3ecc05405bbbbf9129d
MATLAB
349
15
function image_save_video(data) [file,path] = uiputfile('*.avi'); if path~=0 save_to = fullfile(path,file); video = VideoWriter(save_to); video.FrameRate = 10; open(video); for i = 1:length(data) images = data{i}.image{1}; writeVideo(video,images); clear I end...
88d61efb863cf8fefabbbd2aff71d146356203dcb04372465586233aa5e88a2f
MATLAB
350
16
function network_names = get_schaefer_networks(FC_project) old_path = pwd; cd(FC_project.CONN_results_dir) names = schaefer_roi_names(); network_names = cell(numel(names),1); for i=1:numel(names) split_name = split(names{i},'_'); network_names{i} = split_name{3}; end network_names = unique(networ...
c29a12e3d8a08334210cb2257f43f248e9ad82c3a42453146145b68ab3302973
MATLAB
356
16
function xy = mni2xy_v2(x, y, z, view) x_scale = 0.87; y_scale = 0.95; switch view case 'sagittal' xy(:,1) = x_scale*y+98; xy(:,2) = y_scale*z+110; case 'axial' xy(:,1) = x_scale*x + 8; xy(:,2) = y_scale*y + 2; case 'coronal' xy(:,1) = x_scale*x + 8; ...
5b0e0facb2a11b2ac9c7dccc77d73ee22f4072c9238ad368afdae28732aa194e
MATLAB
357
18
clear % S0 D Dr Vi Vir Va Var Ci Ca beta = [1 0.8 .5 .2 .1 .2 .1 .02 .01]; opt = resQ_opt(); load('resQ_xps_example.mat'); xps = resQ_check_xps(xps); s = resQ_1d_fit2data(beta, xps); e = resQ_1d_data2fit(s, xps, opt); difference = beta-resQ_unitSwap(e, 1)...
0eb0e754d55859ca4142057e9044013371f0565b7249549a00a2e0b36237a940
MATLAB
358
22
function flag = all_close(v1, v2, rtol, atol) if nargin < 3 rtol = 1e-5; %default relative tolerance end if nargin < 4 atol = 1e-5; %default absolute tolerance end % Convert to vectors if needed: if ndims(v1) == 2 v1 = v1(:)'; end if ndims(v2) == 2 v2 = v2(:)'; end flag = all(abs(v1 - v2) <= (atol ...
7816d0b64296e5f5a9d0cf8e55bed25376bf3e673e4ed9d71a8048d6c3f32010
MATLAB
358
15
function mfs_fn = resQ_4d_data2fit(s, mfs_fn, opt, ind) % function mfs_fn = resQ_4d_data2fit(s, mfs_fn, opt, ind) if (nargin < 3), opt = []; end % Verify the xps resQ_check_xps(s.xps); % Loop over the volume and fit the model xps = s.xps; f = @(signal) resQ_1d_data2fit(signal, xps, opt, ind); mfs_fn =...
5d81922a2d886222d9a8e7e242ec1a333eaa029eea0499944cd0bb501a8197b9
MATLAB
360
15
function PlotSpeedHisto(Histo,color) % Plots a histogram plot from a dFC speed structure Histo col1=[.4,0,.5]; col2=col1; c=Histo.BinCenters; lo=Histo.BinCounts_low; hi=Histo.Bincounts_high; h=fill([c fliplr(c)], [lo fliplr(hi)],col1); set(h,'facealpha',.2);hold on plot(c,Histo.BinCounts,'-o','Color',color,'linew...
fbaf5c2e905a7ad5dcd672a01230082a23356b171d8f2b851cf9d5291bcb7521
MATLAB
360
16
function network_names = get_schaefer_networks_200(FC_project) old_path = pwd; % cd(FC_project.CONN_results_dir) names = schaefer_roi_names_200(); network_names = cell(numel(names),1); for i=1:numel(names) split_name = split(names{i},'_'); network_names{i} = split_name{3}; end network_names = uni...
98273d7bcced68f9457c00277dbbce8a2bfe3297a6afe95989484a309db37af9
MATLAB
363
13
function str = humanReadableList(list) %HUMANREADABLELIST Print a cell-array of strings in a human-readable list format n = numel(list); if n == 1 str_cell = list(1); elseif n == 2 str_cell = join(list, ' and '); else str_cell = join([join(list(1:n - 1), ', '), list(n)], ', a...
71d6e22a7103d1e85a6defce76dc046b62287fd01ea281ebfea540074b815338
MATLAB
366
17
classdef ROI %ROI Region of interest in the brain % Right now this class isn't so useful but in the future there could % be more metadata associated with each region such as more detailed % bounds, etc. properties pos end methods function obj = ROI(pos) ...
b149028e675c4041befa1b357888fa004c079e1b9546cb8235ad2d3a7810b9ef
MATLAB
367
21
function str = cstring(x) % %CSTRING Print to a string like c % CSTRING(x) takes an array x, of type char, and prints it to % a string the way C would. % the first null, or non-ascii character is the terminator i=1; while (x(i)>0 & x(i)<128 & i<length(x)) i=i+1; end if i==1 str = char(0); else str = char(x(...
96cb61a0a58ea44f6194ac4d1c56f25a963f42bb0748898370e11bf7efade281
MATLAB
368
15
% perspect = [1 0.25 0.5]; % cmap1 = jet(64); % part1 = cmap1(1:31,:); % part2 = cmap1(34:end,:); % mid_tran = gray(64); % mid = mid_tran(57:58,:); % cmap = [part1;mid;part2]; perspect = [1 0.25 0.5]; cmap1 = jet(64); part1 = cmap1(1:31,:); part2 = cmap1(34:end,:); mid_tran = gray(64); mi...
c881e9a315e98c95f9f8eb84897b442838e117be7d7684853cf09f47ea53cdd1
MATLAB
369
18
function rad = angleFrom(a, b) %ANGLEFROM Angle from point a to point b, in radians x = b(1) - a(1); y = b(2) - a(2); rad = abs(atan(y / x)); if x < 0 && y >= 0 % Q2 rad = pi - rad; elseif x < 0 && y < 0 % Q3 rad = rad + pi; elseif x >= 0 && y < 0 ...
f1a12729961d368a14349cbd116a60cacac1e11a4ce39e219d28d806d8cdba8e
MATLAB
369
18
function O = cluster_rembadcomp(S) 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 one) osl_startup D = S.D; % S = rmfield(S,'D'); D = osl_africa(D,'do_ident',false,'do_remove',true); D.save(); % D =...
40bc119e798f02b3a1cd8441f73f19f68d27ccc66db2dd0e80a3ca4a324f370d
MATLAB
370
9
classdef BehaviorVec < nla.edge.permutationMethods.Base methods function permuted_input_struct = permute(obj, orig_input_struct) permuted_input_struct = orig_input_struct; permuted_behavior = nla.helpers.permuteVector(orig_input_struct.behavior); permuted_input_struct.beh...
b5658a8b7e2b84f625f7971a189a24a7a00eeebd0ef2d8aa776f568f168a0216
MATLAB
370
11
function [logp] = logpdf(x, mu, Sigma) %Author : Narayan Subramaniyam %Aalto/NBE m = size(x,1); CONST = -m * 0.5 * log(2*pi); logDetSigma = 2*sum(log(diag(chol(Sigma)))); %logp = CONST - 0.5*logDetSigma - 0.5*((x-mu)' * ... %choleskeyinverse(chol(Sigma)) * (x-mu)); logp = CONST - 0.5*logDetSigma - 0.5*((x-mu)'/Sigma *...
1a912b87256514a04114e47ac8668b2e0b3724810688082714c2a27b1e926ae8
MATLAB
371
9
function loc_list_clusters_count_clusters(data) for i = 1:length(data) number_of_clusters(i,1) = length(unique(data{i}.area)); names{i} = data{i}.name; end number_of_clusters(end+1,1) = sum(number_of_clusters); names{end+1} = 'Total Number of Clusters'; table_data_plot(number_of_clusters,names,{'Total Nu...
9a9df7a0927965298973391dc1ae35a9de17e738770ffc178ce1d68751a847fb
MATLAB
376
12
function O = cluster_oat_save_nii_stats(S2) 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 one) osl_startup % addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/scripts_osl_learningbach/Cluster') ...
f4b1474cbdd622289bfcfd71674ab1a7f4aeaf4fc36d00757075c82287e1b0e1
MATLAB
377
11
function trajectory = tracks_convert_space_time_units(trajectory,space_units,time_units,pixel_s,frame_interval) for i = 1:length(trajectory) if isequal(space_units,'pixels') trajectory{i}(:,2:3) = trajectory{i}(:,2:3)*pixel_s; end if isequal(time_units,'frames') trajectory{i}(:,1...
5b43a6626b2919e48a38804d6126f9e98a22baa31871d9295c18fbc4b2c0bf16
MATLAB
379
18
function [R, t] = rigid_transform_3D(A, B) % A and B are Nx3 matrices of corresponding points centroid_A = mean(A, 1); centroid_B = mean(B, 1); Am = A - centroid_A; Bm = B - centroid_B; H = Am' * Bm; [U,~,V] = svd(H); R = V * U'; if det(R) < 0 V(:,3) = -V(:,3); R = ...
a894ca34d0cce43896f2cd15b71b7e2a9a54368faeea33de6ffbc864fad674ef
MATLAB
380
13
function d = nst_pdist(x,y) % D = nst_pdist( X,Y) returns the distance between each pair of % observations in X and Y using the euclidean distance % Equivalent to pdist2(x,y); Might be slower % see also pdist2 d = zeros(size(x,1), size(y,1)); for i = 1:size(x,1) for j = 1:size(y,1) d(i,j) ...
c241ed70641e124cf03aac57d1289a58a49525bc2162417c0b15b32a020ddc8f
MATLAB
380
12
function [eta, data_cov_reg] = compute_LCMV_reg(h, noise_cov, data_cov) reg=0.05; alpha=reg*trace(data_cov)/length(data_cov); nchan = size(data_cov,2); data_cov_reg=data_cov+alpha*eye(nchan); alpha=reg*trace(noise_cov)/length(noise_cov); nchan = size(noise_cov,2); noise_cov_reg=noise_cov+alpha*eye(nchan); eta = (h' *...
1189faf831f7f6747e6de67d02327e99d798125d5fcda35b4e5b0cdb3117d224
MATLAB
382
13
function [M] = init_M_gpu(I, Kf, G, P_kf, A) 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' I=gpuArray(I); Kf = gpuArray(Kf); G=gpuArray(G); P_kf = gpuArray(P_kf); A=gpuArray(A); M = gputimes...
fcce4023a8a07b9491a034ee1eee7672ab86fc798d2298d51cec294d1cb0fcad
MATLAB
384
14
function image_motion_filter(data) InputValues = inputdlg({'length:','theta:'},'',1,{'2','10'}); if isempty(InputValues)==1 return else len = str2double(InputValues{1}); theta = str2double(InputValues{2}); h = fspecial('motion',len,theta); for k=1:length(data) data{k}.image = imf...
7ff16b5dabcdcc7409a62855ac6e187af15e0affccd0aa2c93ef3ce4592f9aaa
MATLAB
385
16
function O = red_dim(S) 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 one) osl_startup p = S.p; D = spm_eeg_load(S.filepath); D = D.montage('switch',S.montage); D = ROInets.get_node_t...
6e34d6de977c21497b3d1d9d89bb1c682aaa272f47eeb9cd904e97dd160a9565
MATLAB
390
18
function [str] = strengths_und(CIJ) %STRENGTHS_UND Strength % % str = strengths_und(CIJ); % % Node strength is the sum of weights of links connected to the node. % % Input: CIJ, undirected weighted connection matrix % % Output: str, node strength % % % Olaf Sporns, Indiana University, 20...
e6b31f05b6b5ce6ec84c1389cc408ffb38f7037a6da0b855d1ae560433466e59
MATLAB
391
14
function image_log_filter(data) InputValues = inputdlg({'filter size:','sigma value:'},'',1,{'2','1'}); if isempty(InputValues)==1 return else hsize = str2double(InputValues{1}); sigma = str2double(InputValues{2}); h = fspecial('log',hsize,sigma); for k=1:length(data) data{k}.imag...
db56b94d8c88ef3e52bb3da60d20aa7547c3f80cc93f88a5b318ce445daabdd3
MATLAB
392
8
function annotation50CHANGEDannolabelIDs = readXML_Lables(xml_file) %% Import the data [~, ~, annotation50CHANGEDannolabelIDs] = xlsread(xml_file); annotation50CHANGEDannolabelIDs = annotation50CHANGEDannolabelIDs(2:end,5); annotation50CHANGEDannolabelIDs = string(annotation50CHANGEDannolabelIDs); annotation50CH...
0f4f5c4e007174b86eff067892dd3ec1c1f331075c452c13e25b8146e796cf54
MATLAB
393
12
load('ERD_ERS_noise.mat') figure,imagesc(timeVec_zoom,freqVec_zoom,ERD_ERS_noise_zoom),title('ERD/ERSgram') set(gca,'YDir', 'normal') caxis([-70 70]); colormap('jet') colorbar smarterd = TFfindRespFreq2_scirep(ERD_ERS_noise_zoom,timeVec_zoom,freqVec_zoom,thr_max) hold on plot(timeVec_zoom(find(timeVec_z...
dd045cebbe548075d7f7494375f9633310277a75a02d19758357f5dac006c93c
MATLAB
394
30
%% demo gso hold on grid on axis equal x=-5:5; plot(2,3,'ro') plot(x,3*x/2,'k-') plot(x,3*x/2+65/26,'k-') plot(1,4,'go') plot(x,4*x,'c-') plot(-15/13,10/13,'bo') plot(x,-2*x/3,'y-') plot(x,-2*x/3+7,'m-') plot(x,-2*x/3+14/3,'k-') plot(14*2/13,14*3/13,'ko') hold off %% sphering - decorrelation and normalization wit...
903a7c5c167fe529e160381f137e5484cfd0d1fd08d1578873bc27e9c84b7be8
MATLAB
396
16
function [Y, sigma_b, sigma_m, est_snr] = gen_MEG_simu(q,G,source_ids, meas_snr, bio_snr, num_bio_ns) %GEN_MEG_SIMU Summary of this function goes here % Detailed explanation goes here Y_brain_sig = G(:, source_ids) * q; % add brain noise [Y, sigma_b] = add_brain_noise(Y_brain_sig, G, bio_snr, num_bio_ns); %add me...
73817aee705945d3ad46093477358adec9de60e61a975e49aa37ceee4fe7a1c0
MATLAB
401
19
classdef CortexAnatomy %CORTEXANATOMY Anatomical model of the cortex properties hemi_l hemi_r space end methods function obj = CortexAnatomy(fname) anat_struct = load(fname); obj.hemi_l = anat_struct.ctx_l; obj.hemi_r = anat_s...
92911729ffdd3ad552c464c657cfc2a5176aabb69d23fc110cb4d437458a272b
MATLAB
401
11
function voronoi_data = loc_list_voronoi_segmentation(data) for i=1:length(data) counter(1) = i; counter(2) = length(data); voronoi_data{i}.vor = loc_list_construct_voronoi_structure(data{i}.x_data,data{i}.y_data,counter); voronoi_data{i}.name = [data{i}.name,'_vor']; voronoi_data{i}.type = 'v...
3d8edaa41aca8f1b30beef497244baf98ee889a80de3e871f888e2d97d380735
MATLAB
402
12
function data_center = loc_list_center_data(data) data_center = cell(1,length(data)); for i = 1:length(data) data_center{i} = loc_list_center_data_inside(data{i}); end loc_list_plot(data_center) end function data = loc_list_center_data_inside(data) data.x_data = data.x_data - (max(data.x_data)+min(data.x_...
574d0c2640b4aa6c128cc4df07088eca6bc3b99620b1501f7919b71557879d0a
MATLAB
403
11
function clean_data = tc_regress_out_confounds(in_data, confound_regs) %% clean_data = tc_regress_out_confounds(in_data, confound_regs) % % confound_regs: shape: data_point x regressor % in_data: shape: feature x data_point % demeaning confound_regs = [confound_regs ones(size(confound_regs, 1), 1)]; betas_confound = ...
876058581a635d9d39003d6814e98481e61270eace14f9eea5cf048d148327b9
MATLAB
404
15
function T_tkr2scan = tc_tkr2scanner(V) M_vox2ras = V.mat; D = sqrt(sum(V.mat(1:3,1:3).^2)); N = V.dim; center = N / 2; T_tkr2vox = [ 1/D(1), 0, 0, center(1); 0, 1/D(2), 0, center(2); 0, 0, 1/D(3), center(3); 0, ...
80a78a3e93a97ab1897236405db2762eff2be374be270ea13f332f76b5fee53a
MATLAB
407
10
function [x_pdf,y_pdf,x_cdf,y_cdf] = calculate_pdf_cdf(data,percentile) I1 = prctile(data,percentile(1)); I2 = prctile(data,percentile(2)); wanted = data(data<I2 & data>I1); x_hist = linspace(min(wanted),max(wanted),1000); y_pdf = histcounts(wanted,x_hist,'normalization','probability'); y_cdf = histcounts(wanted,...
2f863c638f141324b01eccb96bbd756ea32cb712376434b6b9bd193c3741972f
MATLAB
410
15
classdef Precalculated < nla.edge.result.Base %SIMULATED The output result of a Simulated edge-level result methods function obj = Precalculated(size, prob_max) if nargin == 0 size = 2; prob_max = -1; end % Superclass ...
172fd11d465184d48eb202221dc9e2a167ddba3f63d503c3136cbadb36a487f5
MATLAB
412
12
function measure_types = nst_measure_types() % NST_MEASURE_TYPES return an enumeration of measure types (eg wavelength, Hb) % % MEASURE_TYPES = NST_MEASURE_TYPES() % MEASURE_TYPES: struct with numerical fields listing all available % channel types: % - MEASURE_TYPES.WAVELENGTH % ...
580efcbf6fdf56fef1ae457864beebb3c2f51c4a9757c3703887030f5ca6c216
MATLAB
412
14
function [D,R] = calc_correlationdist(zmat) % Jiaxin Cindy Tu 2022.11.22 % Calculates the correlation for NxN matrix but excludes the diagonal % check that the matrix is the right format assert(size(zmat,1)==size(zmat,2)); assert(length(size(zmat))==2); zmat(eye(size(zmat))==1) = NaN;% this calcul...
b8d6f55c0fa1c9f191e3c1ffe51f0c9fc9505f80eff7595dd53ba7386168be12
MATLAB
412
12
function M = one_lag_gpu(A, P_kf, J_tm1, M_tp1, J_t) gputimes = @(A, B) pagefun(@mtimes, A, B); % A*B on GPU gputranspose = @(A) pagefun(@transpose, A); % A' P_kf = gpuArray(P_kf); J_tm1=gpuArray(J_tm1); M_tp1=gpuArray(M_tp1); J_t=gpuArray(J_t); A=gpuArray(A); M = gputimes(P_kf, gputranspose(J_tm1)) + gputime...
d44637d9b51c921921c9b62c7ce18fe64c8b942214a89cdd5e57b863ef71afaa
MATLAB
412
13
function [A_reconst] = re_arrange_A(loc_true,loc_est, A_est, num_sources, P) %UNTITLED3 Summary of this function goes here % Detailed explanation goes here [comb_id, ~, ~] = check_loc_error(loc_true, loc_est, num_sources); A_reconst=zeros(size(A_est)); for p=1:P for i=1:num_sources for j=1:num_sources ...
6f3be80922acf23c810dee36cb1cbff2c94520f1193e1269c92d78bb77044d4e
MATLAB
413
16
function O = cluster_beamgrouplevel(oat) 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 one) osl_startup addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/osl/ohba-external/fmt') oat = osl_chec...
ec29aa378132f8f81190277455f7bafb48bed08d88d5c28805f75ef34cc3339a
MATLAB
416
14
function xps = resQ_check_xps(xps) % function resQ_check_xps(xps) f = {'n', 'b', 'b_shape', 'm', 'm_shape', 'bm_shape'}; for c = 1:numel(f) assert( isfield( xps, f{c} ), ['xps.' f{c} ' required']); end if ~isfield(xps, 'wf_ind') warning('Supplying a wf index assuming m/b*b_shape is unique!') [...
f36e9cc7e3de682fac66bd697acb277185016aa9fb82672687d4f7402ccefca5
MATLAB
418
16
function [pa_ind, wf_ind] = resQ_xps2paind(xps, tol) % function [pa_ind, wf_ind] = resQ_xps2paind(xps, tol) if nargin < 2 tol = 0.2; end data = [xps.b xps.b_shape xps.m]; data = data./max(data,[],1); % Get index for powder average (including b-val) [~, ~, pa_ind] = uniquetol(data, tol, 'ByRows', true); % Get in...
cc50725baee16289a46b9439e3c7b89eda299c0f960a668f3c46104aeaa09d2c
MATLAB
422
15
function data_flip = loc_list_flip_ud(data) data_flip = cell(1,length(data)); for i = 1:length(data) data_flip{i} = loc_list_flip_inside(data{i}); end end function data_flip = loc_list_flip_inside(data) max_y = max(data.y_data); data_flip.x_data = data.x_data; data_flip.y_data = max_y-data.y_data; data_...
cd38960395654139ad0020718b3c0f6c2d547e7bd151f0f4c68f611c4318eeb7
MATLAB
422
15
function data_flip = loc_list_flip_lr(data) data_flip = cell(1,length(data)); for i = 1:length(data) data_flip{i} = loc_list_flip_inside(data{i}); end end function data_flip = loc_list_flip_inside(data) max_x = max(data.x_data); data_flip.x_data = max_x-data.x_data; data_flip.y_data = data.y_data; data_...
eeb0f2639c18c644d9cbd9bbb9452b5623c55833d845aba31cdcac0b7d542d0d
MATLAB
424
18
function [path_table_1,path_table_2] = separate_table(path) table = load(path); table_1 = table(1:end/2,:); table_2 = table(end/2+1:end,:)-table(end/2+1,:); [dir_to_save,name,~] = fileparts(path); path_table_1 = [dir_to_save filesep name '_side1.txt']; writematrix(table_1,path_table_1,'Delimiter','tab') path_tab...
53a585390fcc61d330ffcc9e2ca5b7e290b3df616b58ef0ff2944cbe298d1ddd
MATLAB
425
15
function [outputArg1,outputArg2] = setTitle(ax, txt, is_subtitle) %SETTITLE Set the title of an axes % ax: Axes to set the title on % txt: Title/subtitle text % is_subtitle: boolean, whether to display as a subtitle if ~exist('is_subtitle', 'var'), is_subtitle = false; end if is_subti...
b209ff9e692445ad16ed67ca190fd92dbc9fe856d5e4cd888f2a3f64959a4d58
MATLAB
432
11
function [x_pdf,y_pdf,x_cdf,y_cdf] = calculate_pdf_cdf_reverse(data,percentile) data = 1./data; I1 = prctile(data,percentile(1)); I2 = prctile(data,percentile(2)); wanted = data(data<I2 & data>I1); x_hist = linspace(min(wanted),max(wanted),1000); y_pdf = histcounts(wanted,x_hist,'normalization','probability'); y...
7ddff1052137d0da9b3444260a1d4465f74b77402855eb4d245731a96e4c9f78
MATLAB
433
16
function results = nst_misc_unpack_glm_result(results, model,method_name,mask) results.B(:,mask)=model.B; if strcmp(method_name,'OLS_prewhitening') results.covB(:,:,mask)=model.covB; else results.covB(:,:,mask)=repmat(model.covB,1,1,length(mask)); end results.residuals(:,mask)=...
8989376c63e073ed03e1dc3c63067c5e296924a4eb95295694b8f8d9e8f4e126
MATLAB
433
15
rawdata=xlsread('96wellPLateData.xlsx'); step=10; fresult = fopen('combo.txt','w'); for i=1:size(rawdata,1) if rem(i,step)==1 ceil(i/step) fprintf(fresult,'Plate-%d\n',ceil(i/step)); elseif rem(i,step)<11 reshape(rawdata(i,:),size(rawdata,2),1) if ~isnan(rawdata(i,:)) ...
7757509eb3d049257159a33ef2afb9cb0a622a1695629db94a57e40be668dd41
MATLAB
435
9
function [status,cmdout] = tc_wrapper_fssurf2fsnifti(subjectsDir, o_file, s_file_l, s_file_r) command = sprintf('%s\n', ... ['subjectsDir=' subjectsDir], ... 'export SUBJECTS_DIR=$subjectsDir',... ['mri_surf2vol --o ' o_file ' --subject fsaverage \'], ... ['--so $subjectsDir/fsaverage/surf/lh.white ' s_...
c43b0aed271a26f574ea70a4d8bfd59e204e2ff34a8030966ac72ac4e433260b
MATLAB
435
22
function [deg] = degrees_und(CIJ) %DEGREES_UND Degree % % deg = degrees_und(CIJ); % % Node degree is the number of links connected to the node. % % Input: CIJ, undirected (binary/weighted) connection matrix % % Output: deg, node degree % % Note: Weight information is discarded. % % % O...
4f8ce8fb462d9e47f9a3d4b33f838045b7a9246052db07126e5bdf434a6096e3
MATLAB
440
26
%% data [prot gene ~]=xlsread('L:\Elite\Celine\final.xlsx'); a=[10 20 12 131 31]; b=[4 5 6 7 8]; c=[0.9 1 2 3 4]; d=[0.2 0.4 0.6 0.8 1]; t=[1 2 3 4] %b=rand()*a/2 %c=rand()*a/4 %d=rand()*a/8 %% trending plot(prot(end,:),prot(1:end-1,:)) plot(prot(end,:),prot(16,:),'r.') %% stabdardize a=zscore(a) b...
242d9cfd450b4231db93d37e0854a35aa9fd7e5d305bcb889f8eabcfab8cb204
MATLAB
443
13
function spt_combine_tracks(data) for i = 1:length(data) to_combine_tracks{i,1} = data{i}.tracks; to_combine_msd{i,1} = data{i}.msd; end to_combine_tracks = vertcat(to_combine_tracks{:}); to_combine_msd = vertcat(to_combine_msd{:}); data_combined{1}.tracks = to_combine_tracks; data_combined{1}.msd =...
266a8d117a5bd57c98ad03b59884f6aaf10d289facbcf458f1366e5db70f7ab7
MATLAB
444
21
function [TF,transition] = compute_TF(sub_clust,TR) nsub = size(sub_clust,2); nvol = size(sub_clust,1); duration = nvol*TR/60; TF = zeros(nsub,1); transition = zeros(nvol,nsub); for i=1:nsub transitions = zeros(nvol,1); for j=2:nvol if sub_clust(j,i) ~= sub_clust(j-1,i) trans...
c8bbe0725d30ed4066afe20ba9491faa73dbf3c54d9e7c109b4e981358481af8
MATLAB
448
20
function dFCstream_2D = Matrix2Vec(dFCstream_3D) % FUNCTION dFCstream_2D = Matrix2Vec(dFCstream_3D) % takes '3D' dFCstream as input and convert it to '2D' dFCstream % or % takes '2D' FC matrix as input and convert it to '1D' FC vector n = size(dFCstream_3D, 1); l = n*(n-1)/2; F = size(dFCstream_3D, 3); xo = find(tril...
497fddada2f87f174ca4cbfd222a5ad8f7276acd9d86ad0f81cd7aab4d7c08d7
MATLAB
449
14
function [comb_id, min_mean_err, err] = check_loc_error(loc_true, loc_est, nq) aa=perms(1:nq); for jj=1:1:length(aa) for i=1:1:nq dip_err(jj,i) = sqrt(sum((loc_est((3*i-3)+1:3*i,end) - loc_true((3*aa(jj,i)-3)+1:3*aa(jj,i),end)).^2)); end end mean_err = mean(dip_err,2); ...
e5258e43a0b64293274f4fc6093fb2facc6cd621c7a5e01247f652ca27e71380
MATLAB
450
19
function spt_tracks_filter_tracks_time_zero(data) for i = 1:length(data) for j=1:length(data{i}.tracks) if check_for_zero(data{i}.tracks{j}) data{i}.tracks{j} = []; end end data{i}.tracks = data{i}.tracks(~cellfun('isempty',data{i}.tracks)); end spt_plot(data); end f...
5435bb79aece1047a17d7100640e7425e25d212ede034d17ac0111cd2b16d808
MATLAB
453
12
function spectrum_1d_plot(data) figure() set(gcf,'name','Spectrum 1D','NumberTitle','off','color','w','units','normalized','position',[0.3 0.2 0.4 0.6],'menubar','none','toolbar','figure') hold on for i = 1:length(data) plot(data{i}.x_data,data{i}.y_data) names{i} = data{i}.name; end set(gca,'TickLength...
f987e9f5a81a8238fc7ae0774e342b7a27c08523567466e1eaf0fc7f8985ea38
MATLAB
454
13
function [Y, sigma_b] = add_brain_noise(Y, G, snr, n_noise_sources) %UNTITLED2 Summary of this function goes here T=size(Y,2); ind_noise_rand=randperm(size(G,2)); noise_ids=ind_noise_rand(1:n_noise_sources)'; pn = mkpinknoise(T, n_noise_sources)'; Y_brain_noise = G(:, noise_ids)*pn; bio_snr_=trace(Y*Y')./trace(Y_bra...
0a57f87081611675d63123050f90683f72cfff7dda891979496d51a3a81ffb86
MATLAB
457
14
function mycsvwrite(filename,var,header) % writes a CSV file with headers % mycsvwrite(filename,var,header) % header is a comma separeted list of names % for example, if you have a 25x4 matrix M you can do: % mycsvwrite('datafile.csv',M,'id,wage,age,educ') outid = fopen(filename, 'w+'); fprintf(outid, '%s\n', header...
66531b5328e5c49fbceeabc3083b1d3790e14a3a5edfb05c3870de4174e3a278
MATLAB
458
11
function shape_classification_clustergram(classes) if size(classes,1)<500 parameters = shape_classification_normalized_parameters(classes); disp('plotting clustergram') clustergram(parameters,'Standardize','row', 'RowPdist', 'correlation', 'ColumnPdist', 'correlation', 'ImputeFun', @knnimpute) ...
8c2792fca31342a96c10e1476ea335871edc20d1c747a9b8a64fff49ccbf083a
MATLAB
458
7
function [feature_template, feature_template_centered] = tc_make_feature_template(betas, compartments) %% [feature_template, feature_template_centered] = tc_make_feature_template(betas, compartments) beta_indices = reshape(ones(size(compartments, 1), 1) * (1:size(betas, 1)), [], 1); feature_template = compartments .* b...
73785d2f35c823cc28da02a4314927a9233fb3da2b7f7c97965c39d3ca3c9cd5
MATLAB
465
17
function display(model) display(model.mean); names=char(model.variance); v=double(model.variance); [n2,l]=size(v); n=sqrt(n2); for k=1:l disp(names{k}); % d=[repmat('| ',n,1) num2str(reshape(v(:,k),n,n)) repmat(' |',n,1)]; % disp(['+' repmat('-',1,size(d,2)-2) '+']); % disp(d); % disp(['+...
526b5c4831a0504c9ee0eae045033cc472da07a1c383a977909488213c8ba241
MATLAB
468
22
function O = cluster_epoch_osl(S2) 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 one) osl_startup D_continuous = S2.D_continuous; S2 = rmfield(S2,'D_continuous'); [epochinfo.trl, epochinfo.condition...
9ec2204a829c9cd50d16f4cf6ac3dd463af912dcc5e811e4bd72a7d5070b0665
MATLAB
470
20
function x = fac2var( f, v ) %Converts a cell array of strings or term of this to a numeric variable. % % Usage: x = fac2var( f [,v] ); % % f = n x 1 cell array of strings or term of this. % v = 1 x k numeric vector of values for the k unique strings in f, in % ascending order, =1:k if absent. % % x =...
563e12d93bcf2b5b4125563496c12842c0f566ee3753373392cc64cb3b672b91
MATLAB
473
21
function item = nst_parse_bst_item_name(item_name) %TODO: handle error scenarios item.comment = ''; item.subject_name = ''; item.condition = ''; split_re = '(?<root>.*/)?(?<item>[^/]+)'; toks = regexp(item_name, split_re, 'names'); if ~isempty(toks) item.comment = toks.item; if ~isempty(toks.root) t...
2cf9ab2b43b6eb3e2c5e04370354ef813f4a533f9d582626ccd9197fde1cb88e
MATLAB
474
16
function clusters = loc_list_find_clusters(data,idx) idx_unique = unique(idx); clusters = cell(length(idx_unique),1); %boundary = cell(length(idx_unique),1); for i = 1:length(idx_unique) I = idx == idx_unique(i); x = data(I,1); y = data(I,2); clusters{i}(:,1) = x; clusters{i}(:,2) = y; ...
52494aeb8060a330a7a4a0dc161b4134021543fd085fbd9413e791e476363066
MATLAB
476
22
function [granger,freq]=createauto_timefreq(data1,freqrange,toy) equis=0.5; cfg = []; cfg.method = 'mtmconvol'; cfg.taper = 'hanning'; cfg.pad=8; cfg.foi = freqrange; cfg.t_ftimwin = 0.5.*ones(size(4./cfg.foi')); cfg.tapsmofrq = equis*cfg.foi; cfg.toi=toy; cfg.output = 'fourier'; cfg.keep...
f722fb4f4912898df0ce0be827345c98c39a5d2bca1917c1be440f81e6b65897
MATLAB
476
13
function [x_pdf,y_pdf,x_cdf,y_cdf] = calculate_pdf_cdf_norm(data,percentile) temp = data; temp(isnan(temp)) = []; data = data/mean(temp); I1 = prctile(data,percentile(1)); I2 = prctile(data,percentile(2)); wanted = data(data<I2 & data>I1); x_hist = linspace(min(wanted),max(wanted),1000); y_pdf = histcounts(want...
4df9eed3ee43f7d07296c330298edcbb654079c92ad717768d2e4d5d53f7ffb6
MATLAB
478
20
function send_data_to_workspace(data_to_send) global data listbox if isempty(data)==1 data=data_to_send; else if size(data_to_send,1) > 1 data_to_send = data_to_send'; end data_to_send = data_to_send(~cellfun('isempty',data_to_send)); data= horzcat(data,data_to_send); end if i...
e9935b2399c8e38cf44d9038ef6440ebe78e93c8d272a5f855048f2a27b2e73e
MATLAB
483
29
clear % Fig 1 % mipp_fig_vol_vs_time % mipp_fig_morphologyVStime_v2 % Fig 2 is partially created outside of matlab % mipp_fig_histology (insets) % Fig 3 % mipp_fig_gwf_v2 % Fig 4 mouse 2 and 103 % mipp_fig_parammaps_treatevsuntreated % Fig 5 % mipp_fig_par_vs_time_inc_stats % Fig 6, case 1 and 4 % mipp_fig_signal...
93e75348158e8c046353c71ca15c37b619a2d9ab40386506ab66cbaf0554825f
MATLAB
485
23
function [data_cell] = pl_mat2cell(data) % % Converts an N dimensional array (n x m1 x m2 x ...) into a cell (n x 1) % of N-1 dimensional arrays (m1x m2 x ...) % Data in this form will be processed faster in permutationlab % % This function is part of the permutationlab software: % Author: Dimitrios Pantazis ...
ad25a04b668526b6a8e6f7d427b9be8b6c0f7974a94fd4306f1dab176270a8a3
MATLAB
488
19
function utest_reset_bst() % Remove unit test protocol from brainstorm DB % Reset stored messages. global GlobalData; % Delete unit test protocol ProtocolName = 'nst_utest'; gui_brainstorm('DeleteProtocol', ProtocolName); db_dir = bst_get('BrainstormDbDir'); nst_protocol_dir = fullfile(db_dir, ProtocolName); if exist...
49656f155c02ba10de0108ab35523e0f07e665844797418902a7685c55b581d3
MATLAB
489
17
function FC_project = get_conds(FC_project) condition_choices = split(num2str([1:FC_project.ncon]),' '); condition_prompt = 'Which conditions would you like to include?'; tf = 0; while tf==0 if ~isfield(FC_project,'include') [conds,tf] = listdlg('PromptString',condition_prompt,'ListString',conditio...
68089bf6f9a6f09a6e30ed11f1714a900eca6588102cdc2d5857c750fef9b721
MATLAB
489
16
function area = Area(TRI,Vertice_Location) Tri_Num = size(TRI,1); area = zeros(Tri_Num,1); %area2 = zeros(Tri_Num,1); for i=1:Tri_Num v1 = Vertice_Location(:,TRI(i,1)) - Vertice_Location(:,TRI(i,2)); v2 = Vertice_Location(:,TRI(i,1)) - Vertice_Location(:,TRI(i,3)); sinus = sqrt(...
28bbbb3a90bbfc14f06e864f82ac63272bcbbd345072c00cfac40f2b3002a7ac
MATLAB
491
15
classdef None < nla.net.mcc.Base properties (Constant) name = "None" end methods function [is_sig_vector, p_max] = correct(obj, net_atlas, input_struct, prob) p_max = input_struct.prob_max; is_sig_vector = prob.v < p_max; end function ...
d8e4efa188db8a584f083b7357c28808cbcafafafe5f4d81a8bb6ef0019212a0
MATLAB
492
18
% Load the session you want to analyze clc;close all;clear [file,path] = uigetfile('*.mat','Load the MATLAB file'); % Do the analysis if isequal(file,0) disp('User selected Cancel'); % Stop the script. else filename = fullfile(path,file); load(filename,'data'); textdata = cell(numel(data),1...
da98483dc1efe0a2fb41b4f84c0052de0bb0c4c6a7bbc89047e32db888173086
MATLAB
492
16
function data_scaled = loc_list_add_by_number(data) answer = inputdlg({'Number:'},'Input',[1 50],{'1000'}); if isempty(answer)~=1 number = str2double(answer{1}); data_scaled = cell(1,length(data)); for i = 1:length(data) data_scaled{i} = loc_list_scale_data_inside(data{i},number); end ...