sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
6cc1ac36a2ec789e4aa05ca01c43c0fd19b1ee8be21ab8c9c48b296f14d48a9f
MATLAB
282
10
function zef_add_dof_space %This function plots the degrees of freedom h_axes = evalin('base','zef.h_axes1'); %axes(h_axes); hold on source_positions = evalin('base','zef.source_positions'); scatter3(source_positions(:,1),source_positions(:,2),source_positions(:,3),'filled') end
2a4afb97f803bb8b6073976591d9fb6df50ecf18f5bf9c18d2b8bd26c3ca64e7
MATLAB
283
8
function vecY = logfitfun(vecParams,vecX) %logfitfun Logarithmic function with scaling factors for fitting % Syntax: vecY = logfitfun(vecParams,vecX) %params; x-offset, x-scaling, y-offset, y-scaling vecY = vecParams(3)+vecParams(4)*log(vecX*vecParams(2)+vecParams(1)); end
7bfffa6d2d89cb7bec8c93f00d87c5215dcb43e27c6fdb211cebc5dd1e881ef9
MATLAB
284
10
% THIS FUNCTION IS PRIVATE AND SHOULD NOT BE CALLED BY OUTSIDE CODE! % function [] = ReceiveOK( sm, cmd ) line = CalinsNetMex( 'readline', sm.handle ); if( ~contains( line, 'OK' ) ) error( 'After cmd [%s] got [%s] but expected ''OK''.\n', cmd, line ); end end
1aa8c63a141d31731bf95f69f6beac5a7ccb77ae073a176b78e8440171604fef
MATLAB
285
12
function x_transform = transform_clusterstat(x,modality) switch modality case 'eeg' x = x-mean(x,2) ; % re-reference to average case 'meg' % do nothing case 'source' x = abs(x) ; % .^2 ; % set to magnitude case 'ampenv' % do nothing end
9f81911967e6c492bdd742eda9b148a237eb61323ae3cd4fea592972d05d84ee
MATLAB
285
12
function x_stdft = stdft(x, N, K, N_fft) frames = 1:K:(length(x)-N); x_stdft = zeros(length(frames), N_fft); w = hanning(N); x = x(:); for i = 1:length(frames) ii = frames(i):(frames(i)+N-1); x_stdft(i, :) = fft(x(ii).*w, N_fft); end
f2b58b8f48d744f37b690ad7e1f06f5e5d6c5b8d54ea51555666ba163664ac7e
MATLAB
286
14
function zef = zef_strip_tool_open(zef) if not(isfield(zef,'strip_tool')) zef.strip_tool = struct; zef.strip_tool.strip_current_id = 1; end zef.strip_tool.current_strip = 1; zef = zef_strip_tool_window(zef); zef = zef_strip_tool_init(zef); zef = zef_strip_tool_update(zef); end
081d0d0df0878dbea40e7d08ab98f01b8b68454b65798aa9f2c6d7bea1d77138
MATLAB
287
9
function vecY = gnmgauss(vecX,vecParams) %gnmgauss Wrapper with scale-parameter for normal distribution % vecY = gnmgauss(vecX,vecParams) % %Function: %vecY = vecParams(1)*normpdf(vecX,vecParams(2),vecParams(3)); vecY = vecParams(1)*normpdf(vecX,vecParams(2),vecParams(3)); end
4fbb47a550c353f878686b54a6d82f74d3a7e41f8c57fb8f6e73b5f6d3235d74
MATLAB
287
14
function GammaInit = initGamma_seq(T,K) GammaInit = zeros(sum(T),K); for j = 1:length(T) ind = (1:T(j)) + sum(T(1:j-1)); assig = ceil(K*(1:T(j))./T(j)); Gammaj = zeros(T(j), K); for k = 1:K Gammaj(assig==k,k) = 1; end GammaInit(ind,:) = Gammaj; end end
6f66cd0e8317097264058a6c06513ed6ddffafb2cc247a60601a6d88035b6d6a
MATLAB
287
10
%trim frames function [ trimmed, tTarray ] = trimArray( array, tarray, startindex, endindex ) tic trimmed = array; tTarray = tarray; trimmed(:,:, startindex : endindex )=[]; tTarray(:,startindex : endindex )=[]; str = append('trimming took ', num2str(toc), ' seconds' ); disp(str); end
0f04438c149d52b604214720bc71d2b86bd1a3bb5211cc97b679aa25e45d5dbf
MATLAB
288
15
function retrieve_gui_colors(app) newcolors = [ 0.47 0.25 0.80 0.25 0.80 0.54 1.0000 0.3098 0.2941 0.0745 0.6235 1.00 1.00 0.54 0.00 0.6510 0.6510 0.6510 1.00 0.0745 0.6510 0 0.2980 0.6000 ]; app.newcolors = newcolors; end
c427eed0dc052be616b55ea93065970855f18e6e3d3c4b1defa6eea7f8e208a6
MATLAB
288
12
function x_stdft = stdft(x, N, K, N_fft) frames = 1:K:(length(x)-N); x_stdft = zeros(length(frames), N_fft); w = ml_hanning(N); x = x(:); for i = 1:length(frames) ii = frames(i):(frames(i)+N-1); x_stdft(i, :) = fft(x(ii).*w, N_fft); end
e5f3bfc3bedd72b3d49f43ea4734c5a0ecf9ad1909f881132f3b108cbcc821d6
MATLAB
288
9
% List of open inputs nrun = X; % enter the number of runs here jobfile = {'/home/mfromano/Research/mri-pet/image_processing/mask_mni_brain_job.m'}; jobs = repmat(jobfile, 1, nrun); inputs = cell(0, nrun); for crun = 1:nrun end spm('defaults', 'PET'); spm_jobman('run', jobs, inputs{:});
877afbdd9b06c4bc450c7194c2e8c38b78e34fbed4b939dc8af6f3c1a8b53974
MATLAB
289
11
function []=zef_callbackstop(src,~) if ~src.Value evalin('base',[ num2str(src.Value),';']) set(src,'foregroundcolor',[0 0 0]); set(src,'string','Stop'); else evalin('base','zef.stop_movie=1;') ; set(src,'foregroundcolor',[1 0 0]); set(src,'string','Stopped'); end
653f912633a2c6dcf77506bb7ba9612dcf00a7d623342a7a6c775b21fdca0762
MATLAB
290
11
function th = threeshold_estimation(distance,method) if nargin < 2 method = 'mean'; end switch method case 'mean' th = mean(distance)+2.5*std(distance); case 'median' th = median(distance)+2.5*1.4826*mad(distance,1); end
b33c2b70b6b1cca55357132aed3ad4539536c90919cf1bf4d05bd8ff57753777
MATLAB
290
13
function [Y] = vl_nnunpool(X, Ind, sizeY, varargin) % forward mode if(isempty(varargin)) Y = gpuArray.zeros(sizeY(1), sizeY(2), size(X, 3), size(X, 4), 'single'); Y(real(Ind+1)) = X; % backward mode else DZDX = (varargin{1}); Y = reshape(DZDX(Ind+1), sizeY); end end
b3c99bd2ddab0f2023f7b21d8b873244804d07bc76b5b91bd2e575e19284be6e
MATLAB
290
11
function strDate = datemod(strFile) %datemod Returns last modified date for file % strDate = datemod(strFile) try sDate = System.IO.File.GetLastWriteTime(strFile); strDate = sprintf('%04d-%02d-%02d',sDate.Year,sDate.Month,sDate.Day); catch strDate = 'Unable-to-read'; end end
bc5759824601bf4d4f7e2b89d46c2935103fcd32f67a63afb017feed001e69cc
MATLAB
290
16
function [zef] = zef_turn_compartment_onoff(zef,compartment_onoff_vec) c_t = zef.compartment_tags; n_c_t = length(c_t); % if isempty(compartment_onoff_vec) compartment_onoff_vec = ones(1,n_c_t); % end for i = 1 : n_c_t zef.([c_t{i} '_on']) = compartment_onoff_vec(i); end end
16f8ccedd251c10b3cb27f95159de0b2f8627b1713327a5cde380a11e6c7bb28
MATLAB
291
10
function vecMahal=getMahalCell(cellXY,matThisCovInv) %UNTITLED8 Summary of this function goes here % Detailed explanation goes here %get number of trials vecMahal = cellfun(@calcMahal,cellXY); function dblMahal=calcMahal(vecXY) dblMahal = vecXY * matThisCovInv * vecXY'; end end
f7fd761bc2d3e56166999dbc6bec36ced677f6b7a4b95e398a74d0854b960983
MATLAB
291
5
%Copyright © 2018- Sampsa Pursiainen & ZI Development Team %See: https://github.com/sampsapursiainen/zeffiro_interface zef.filter_pipeline = zef.filter_pipeline([zef.filter_pipeline_selected setdiff([1:length(zef.filter_pipeline)],zef.filter_pipeline_selected)]); zef_update_filter_tool;
6149a8c7df494c45dfad47fc92ad63ff7f16c2c2bbdbb556dc161ac84075a7da
MATLAB
292
14
function [udf] = secondary_validation_udf(udf) u = unique(udf); for uu = 1:length(u) assert(round(u(uu)) == u(uu), 'UDF must contain only integers'); end % make sure it's binary, if it's a vector of states then one-hot encode if length(u)~= 2 udf = quick_expand_udf(udf); end end
86fc9cccbd0da60e54cc8ed4bf93e2f2b92f3db025763918f12732f977819c92
MATLAB
292
10
function y=minf(pab,papb) % Used by the mutual information function (you can compile this to your % machine using the Matlab coder if you want to speed up the algorithm even % further). I=find(papb(:)>1e-12 & pab(:)>1e-12); % function support y=pab(I).*log2(pab(I)./papb(I)); end
8d3ee88ec22a9691fe9ddf5c314a96de9fbd9f71d517982e89313789e91dc169
MATLAB
292
6
%Copyright © 2018- Sampsa Pursiainen & ZI Development Team %See: https://github.com/sampsapursiainen/zeffiro_interface zef.filter_pipeline = zef.filter_pipeline([setdiff([1:length(zef.filter_pipeline)],zef.filter_pipeline_selected) zef.filter_pipeline_selected]); zef_update_filter_tool;
da9d419ecb8bf52b439338c4308cc7fef21b2d111208ebf5ab8f5e013d00d4e6
MATLAB
294
10
% boolval = IsUserOrder( myobj, streamID ) % % Returns 1 if graphs currently sorted in user order. % % This query is sent only to the main Graphs window. % function [ret] = IsUserOrder( s, streamID ) ret = sscanf( DoQueryCmd( s, sprintf( 'ISUSRORDER %d', streamID ) ), '%d' ); end
e440674d42c12aed7f8ece763e35ff298448d392410e7f2bea69364547b94b5f
MATLAB
294
4
writecell(zef.h_system_settings_table.Data,[zef.program_path '/profile/zeffiro_interface.ini'],'FileType','text'); for zef_i = 1 : size(zef.h_system_settings_table.Data,1) evalin('base',['zef.' zef.h_system_settings_table.Data{zef_i,3} '= zef.h_system_settings_table.Data{zef_i,2};']); end
fd80991820111616d6925a726a4d96e5405f9d948a1482ba27c69360f74b4f05
MATLAB
295
12
function [app, status] = variable_loader(app, filename, key) try v = load(filename, key); app.(key) = v.(key); msg = strcat(['Located ', key]); update_log(app, msg); status = 0; catch msg = strcat(['Unable to Retrieve ', key]); update_log(app, msg); status = 1; end
31ceb3ee5897d86f3645f6f9a1f2b648d146aabc383bf9ea01a44d6d49a2161d
MATLAB
297
13
function norm = zef_L2_norm(arr, dim) % Calculates the L2-norm of a given array arr along a given dimension dim. % If the dimension is not given, calculates the norm assuming arr is a % vector. if nargin == 2 norm = sqrt(sum(arr.^2, dim)); else norm = sqrt(sum(arr.^2, 'all')); end end
60e06bc3807ee4076113dbeb3c261c6759f2b01269085946ca912c4f0fd97896
MATLAB
297
15
%Copyright © 2021- Sampsa Pursiainen & GPU-ToRRe-3D Development Team %See: https://github.com/sampsapursiainen/GPU-Torre-3D function [y] = mat_vec(R,x,gpu_extended_memory) R = gpuArray(R); x = gpuArray(double(x)); y = R*x; if (ismember(gpu_extended_memory,[0 2])) y = gather(y); end end
d71245b3965474326b14aedb74679e9b2790d5aae566ad82e53e0d6dc71c3333
MATLAB
298
10
function s = softmax(x, dim) % Softmax function % By default dim = 1 (columns). % Written by Mo Chen (sth4nth@gmail.com). if nargin == 1, % Determine which dimension sum will use dim = find(size(x)~=1,1); if isempty(dim), dim = 1; end end s = exp(bsxfun(@minus,x,logsumexp(x,dim)));
866a79d331616b6e8455cf9784f693d639ebe08223ea0815b00c47fc9a5d294d
MATLAB
300
10
% boolval = IsConsoleHidden( myobj ) % % Returns 1 if console window is hidden, false otherwise. % The console window may be hidden/shown using ConsoleHide() % and ConsoleUnhide(). % function [ret] = IsConsoleHidden( s ) ret = sscanf( DoQueryCmd( s, 'ISCONSOLEHIDDEN' ), '%d' ); end
ea2b548d03ca1e6f5653949217cf8f3333a5a2a629dfea7ef2ed51fc89e03a61
MATLAB
301
15
function [dfof] = quick_extract_dfof(traces) num_samples = size(traces, 1); num_neurons = size(traces, 2); dfof = zeros(num_samples, num_neurons); for neuron = 1:num_neurons baseline = median(traces(:, neuron)); dfof(:, neuron) = (traces(:, neuron) - baseline)./baseline; end end
0cb34131870c9b39c449dae4804925fd494b2f44e432ae783261cad6f414a140
MATLAB
303
11
warning('off'); zef.lead_field_type = 1; zef.source_interpolation_on = 1; set(zef.h_source_interpolation_on,'value',1); zef_create_finite_element_mesh; zef_postprocess_finite_element_mesh; zef.n_sources_mod = 1; zef.source_ind = []; zef_update_fig_details; zef_eeg_lead_field; zef_source_interpolation;
4b53012439a0f9dd5c5fc31781bf51b7590035f88c3ad60551b261a03d0ec8fb
MATLAB
303
16
function zef_ES_optimization(zef) if nargin == 0 zef = evalin('base','zef'); end org_val = zef.font_size; zef.font_size = 14; zef = zef_tool_start(zef, 'zef_ES_optimization_window', 1/5, 1); zef.font_size = org_val; if nargout == 0 assignin('base','zef',zef); end end
4e3344711dc58b9f6a90832380c9f34efa5987b76c2d5c05919b7a8696872634
MATLAB
303
11
warning('off'); zef.lead_field_type = 5; zef.source_interpolation_on = 1; set(zef.h_source_interpolation_on,'value',1); zef_create_finite_element_mesh; zef_postprocess_finite_element_mesh; zef.n_sources_mod = 1; zef.source_ind = []; zef_update_fig_details; zef_tes_lead_field; zef_source_interpolation;
5a6b07909a04db53cccf53be53f6e3b956bd7d6fdc9d6c99c186add153a55a19
MATLAB
303
11
warning('off'); zef.lead_field_type = 4; zef.source_interpolation_on = 1; set(zef.h_source_interpolation_on,'value',1); zef_create_finite_element_mesh; zef_postprocess_finite_element_mesh; zef.n_sources_mod = 1; zef.source_ind = []; zef_update_fig_details; zef_eit_lead_field; zef_source_interpolation;
c7580b95ed215b2ea791b0a26ccf1606b375d9f890a6e5dfdfea639ba8611ddc
MATLAB
304
10
function [ModProbMap] = ReMapSagProbMap(ProbMap) ReMapInd = [1, 2, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16 ]; sz = size(ProbMap); ModProbMap = zeros(sz(1),sz(2),28,sz(4), 'single'); for i = 1:28 ModProbMap(:,:,i,:) = ProbMap(:,:,ReMapInd(i),:); end
2b70418bb84fbae56ad1488086b2f27ce9111ee166130941879ca1823a3f0e24
MATLAB
305
8
%Copyright © 2018- Sampsa Pursiainen & ZI Development Team %See: https://github.com/sampsapursiainen/zeffiro_interface zef.parcellation_colortable = cell(0); zef.parcellation_points = cell(0); zef.parcellation_merge = 1; zef.use_parcellation = 0; zef.parcellation_selected = []; zef_update_parcellation;
775369e8276a54231b2a64f41c207ffe19eda4f701069ac2994454367fbb8cf9
MATLAB
305
14
function fdn = zef_tetra_fdn % The face defining neighbours on nodes in a tetrahedron. The sets of vectors % fdn[:,2] - fdn[:,1] and fdn[:,3] - fdn[:,1] define a basis which spans the % plane that defines the faces of a tetrahedron. fdn = [ 2 3 4 ; 3 4 1 ; 4 1 2 ; 1 2 3 ]; end
3b5e787558682053be250aa5954aa57bda02887aefa0f9795467b32cc059b4d6
MATLAB
306
9
function Gamma = vpath_to_stc(vpath,K) % changes a viterbi path (T x 1) to a state time course (T x K) format if size(vpath,2)>1, error('Viterbi paths have one single column'); end if nargin<2, K = max(vpath); end Gamma = zeros(numel(vpath),K,'double'); for k=1:K, Gamma(vpath==k,k) = 1; end end
4070d86105f47b2e1f084ab8c93b88e48c6aa65b306562c4a9970ce3791f6a19
MATLAB
307
12
function plot_roi_2D_dots %grab and format rois = app.rois; numROIs = size(rois,1); C = jet(numROIs); S = ones(1,numROIs)*10; %plots scatter(app.roi_preview, rois(:,1),rois(:,2),S,C, 'MarkerFaceColor','flat','MarkerFaceAlpha',0.5,'MarkerEdgeAlpha', 0.75, 'Marker','o'); axis(app.roi_preview,'tight'); end
782cc82108661fbadfb64a4833a6d0ad3831ffab22576e9914f54ca5e9d5a442
MATLAB
308
11
if ~isempty(strfind(fsub,'.mat')) if exist(fsub,'file') save(fsub,'X','-append') else save(fsub,'X') end elseif ~isempty(strfind(fsub,'.txt')) dlmwrite(fsub,X); else % no extension - assumed to be an SPM file error('For now, we can only deal with .mat and .txt files') end
80546d7928324e3e6f6e003f9d19cb437b53d01bab6c7bc1f18d6b92683f4360
MATLAB
308
11
function [m, P] = kf_predict(m,P,A,Q) % kf_predict is the prediction step of kalman filter % Skip multiplications if A is Indentity if (isdiag(A) && all(diag(A) - 1) < eps) P = P + Q; else % Basic kalman prediction steps m = A * m; P = A * P * A' + Q; end end
706853c7ebfa9bb6dccb2057660ef5977e759c96b27883e7346b0472bf000130
MATLAB
309
8
function N=bsliang_nonemptycol(data) % ͳ¼Æ¶þά¾ØÕóµÄµÚһά¶ÈÿһÐзǿյ¥Ôª¸ñÊýÁ¿£¨ÓÃÓÚ¼ÆËãstandard error£© N=nan(size(data,1),1); for row=1:size(data,1) datacol=data(row,:); datacol=datacol(~isnan(datacol)); N(row)=length(datacol); end
e5e763715492a2642c26e543fb94b73cdedc11807c8f319d0666e70cc7589bc7
MATLAB
309
11
function [m, P, K] = kf_update(m,P,y,H,R) % kf_update is the update step of kalman filter v = y-H*m; % downsample? H, P, R before S S = H*P*H'+R; K = (P*H')/S; % /S is same as *inv(S) but faster and more accurate % upsample? K, P m = m+K*v; P = P-K*S*K'; % upsample P end
ee06a8d3f823b9bca16b37b480c0438f97bb39c07f5816673b36347b79b49fea
MATLAB
309
17
function [info, columnNames] = zef_dataBank_WorkingSpaceInfo(tree, hash) columnNames={'hash', 'node type', 'name'}; if ~iscell(hash) hash={hash}; end info=cell(length(hash), 3); for i=1:length(hash) info{i,1}=hash{i}; info{i,2}=tree.(hash{i}).type; info{i,3}=tree.(hash{i}).name; end end
4cdc0c11e63e43501f65e898a43ec6bfdc193708ff68769cfcc0b6a6c3302d7a
MATLAB
310
8
function [colormap_vec] = zef_blue_brain_3_colormap(colortune_param, colormap_size) colormap_vec = [[1:colormap_size] ; 0.5*[1:colormap_size] ; 0.5*[colormap_size:-1:1] ]; colormap_vec = colormap_vec + 1; colormap_vec = colormap_vec'/max(colormap_vec(:)); colormap_vec = colormap_vec.^(colortune_param); end
933b9470124fa8e939749d438039704ab8369c780b011c25cf372b94a100f844
MATLAB
310
11
function sesNew = doSelectNeurons(ses,vecNeurons) %UNTITLED4 Summary of this function goes here % Detailed explanation goes here sesNew = rmfield(ses, 'neuron'); intNewCounter=0; for intNeuron=vecNeurons intNewCounter=intNewCounter+1; sesNew.neuron(intNewCounter) = ses.neuron(intNeuron); end end
dee6adb18cca689669154b2de9898527d2508c8a5e720a98393b759018186480
MATLAB
310
56
clear all close all clc time_today = datestr(now, 'mmddyyyy'); % traj_type = 'lorenz'; % uncertain_test_saferegion % traj_type = 'circle'; % uncertain_test_saferegion % traj_type = 'mg17'; % uncertain_test_saferegion traj_type = 'infty'; uncertain_test_saferegion
3fe316e83ee67434de95c43d81a638e440de095b9fd6c75a0af62c25bf574543
MATLAB
311
14
function compartment_tag = zef_compartment_tag(zef) ismember_tag = 1; compartment_counter = 0; while ismember_tag compartment_counter = compartment_counter + 1; compartment_tag = ['c' num2str(compartment_counter)]; ismember_tag = ismember(compartment_tag,eval('zef.compartment_tags')); end end
8256a63c1c3174b3c5a599bb275a99051d6da464a3a8f89875ccaf5905376eac
MATLAB
311
16
ns = 2; ny = 2; nz = 2; N = ns*ny*nz; P = zeros(N); P = sort([0, rand(1,N-1), 1]); P = P(end:-1:2)-P(end-1:-1:1); P = P/sum(P); Pzys = reshape(P,nz,ny,ns); Psy = squeeze(sum(Pzys,1))'; Psz = squeeze(sum(Pzys,2))'; [UI,~] = admUI(Psy, Psz) %% test the generated MEX %[UI,~]=admUI_mex(Psy, Psz, accu, g)
fd9041fdb155483d219200f506ec92b2fc962eef97c068a43f73ee90c86533f0
MATLAB
312
8
function dblDateDiff = datediff(strDate1,strDate2) %datediff Calculates difference in days between two dates. Syntax: %dblDateDiff = datediff(strDate1,strDate2) % %dblDateDiff = etime(datevec(strDate1),datevec(strDate2))/(60*60*24); dblDateDiff = etime(datevec(strDate1),datevec(strDate2))/(60*60*24); end
371fd2ff7c5d5400860a63f0da451e62cc969b1081be30e575b0c367735c4c70
MATLAB
313
7
function zef_init_profile_table_selection(hObject,eventdata,handles) init_profile_selected = eventdata.Indices(:,1); init_profile_selected = unique(init_profile_selected); init_profile_selected = init_profile_selected(:)'; evalin('base',['zef.init_profile_selected =[' num2str(init_profile_selected) '];']); end
3b01caf353bf113a6778e1671973516bcdde23e790fa6d47eeb372fcbdd8d863
MATLAB
313
16
function weights = RidgeRRR(X,Y,lambda,rank) % Y = X*weights subject to Ridge regularisation Sig = (X'*X + lambda*eye(size(X,2))); MAT = X'*Y*Y'*X/Sig; [U, D] = eig(MAT); [sortedD,permutation]=sort(diag(D)); U = U(:,permutation); U = U(:,1:rank); P = orth(U); P = P'; W = P*X'*Y/(P*Sig*P'); weights = P'*W; end
4d4e3d5acb061d98a7b5b302a12e781d7ffe80a3efd635221857ddefc86fc1af
MATLAB
313
12
% [Vmin,Vmax] = GetImVoltageRange( myobj, streamID ) % % Returns votlage range of selected IMEC probe. % function [Vmin,Vmax] = GetImVoltageRange( s, streamID ) ret = DoQueryCmd( s, sprintf( 'GETIMVOLTAGERANGE %d', streamID ) ); C = textscan( ret, '%f %f' ); Vmin = C{1}; Vmax = C{2}; end
31d0f945bba335b9b13ad2d05cf041273d03b09fffe63da80dc95da98a9f9e5b
MATLAB
314
19
function [useBIG, chunks] = check_memory_requirements(elements, RAM) if nargin<2 RAM=115; end memoryRequirementInBytes = (elements*8)/(1024^3); if memoryRequirementInBytes>=RAM useBIG = logical(1); chunks = ceil(memoryRequirementInBytes/RAM); else useBIG = logical(0); chunks = 1; end end
8ccacab46464c32595fb59eaa39b6628d41f691027d53d770955e0f3a26ef31c
MATLAB
314
9
function [d] = zef_distance_to_resection(points, mesh_points, mesh_edges) d=nan(size(points,1),1); inside_index=zef_tetra_in_compartment(mesh_points, mesh_edges, points); not_inside=setdiff(1:size(points, 1), inside_index); d(inside_index)=0; [~, d(not_inside)]=knnsearch(mesh_points, points(not_inside,:)); end
2b304fd8dbdda0090cd9c206881fa0dc4bcf490262a380dc4e7bda3e860806e7
MATLAB
315
11
function [nearest_points] = find_closest_points_brute(Set1, Set2) distances = pdist2(Set1, Set2); minDistance = min(distances(:)); [rowOfA, rowOfB] = find(distances == minDistance); nearest_points = [Set1(rowOfA, :), Set2(rowOfB, :)]; if size(nearest_points,1) > 1 nearest_points = nearest_points(1, :); end
2939b9926ec2209e701a08a24db89345733680781aa507ae1ddab323a6aec24e
MATLAB
316
11
warning('off'); zef.lead_field_type = 3; zef.source_interpolation_on = 1; set(zef.h_source_interpolation_on,'value',1); zef_create_finite_element_mesh; zef_postprocess_finite_element_mesh; zef.n_sources_mod = 1; zef.source_ind = []; zef_update_fig_details; zef_meg_gradiometers_lead_field; zef_source_interpolation;
c1d938868fc0028351e390b10b9ead7feebeb172cc87f7de4982479c5f2723cd
MATLAB
316
8
function ETO_SliderCallback(hObject,eventdata,ptrSubPanel) vecSize = ptrSubPanel.Position; val = get(hObject,'Value'); dblRealMax = vecSize(end) - 1; dblStartY = val*dblRealMax; vecSetPanelPos = [0 -dblStartY 1 vecSize(end)]; set(ptrSubPanel,'Position',vecSetPanelPos);%[from-left from-bottom width height] end
fc2c62799aa038a184e43aab09dc269dd8d57ff61459554f6a9f4400baf8c93c
MATLAB
317
11
function update_unlearned_models(app) totalModelsPlanned = numel(app.params.s_lambda_sequence) * numel(app.params.p_lambda_sequence); currentModelsLearned = length(app.model_collection.models); val = totalModelsPlanned-currentModelsLearned; if val <= 0 val = 0; end app.ModelsUnlearnedEditField.Value = val; end
fc7be4aaccbb4e3221fd435d22f785cf479f806be3222fc699bbb8b8fba3dfa0
MATLAB
317
11
warning('off'); zef.lead_field_type = 2; zef.source_interpolation_on = 1; set(zef.h_source_interpolation_on,'value',1); zef_create_finite_element_mesh; zef_postprocess_finite_element_mesh; zef.n_sources_mod = 1; zef.source_ind = []; zef_update_fig_details; zef_meg_magnetometers_lead_field; zef_source_interpolation;
160268a1f9a42d0fc0d6a57817d0b1b4819f9cfac80be8dc399d24d27353eb2d
MATLAB
318
14
function plot_pattern_completion_coordinates(app) if app.roi_style == 0 plot_pcn_coordinates_style_0(app); elseif app.roi_style == 1 plot_pcn_coordinates_style_1(app); elseif app.roi_style == 2 plot_pcn_coordinates_style_2(app); elseif app.roi_style == 3 plot_pcn_coordinates_style_3(app); end end
64b25e6e03e3627f57d78c8874ff5b4bc5d2e3459f89cd4a94102d638aa65911
MATLAB
318
16
function fdn = zef_prism_fdn % The face defining neighbours on nodes in a prism. The sets of vectors % fdn[:,2] - fdn[:,1] and fdn[:,3] - fdn[:,1] define a basis which spans the % plane that defines the faces of a tetrahedron. fdn = [ 2 3 5; 3 1 6; 1 2 4; 5 6 2; 6 4 3; 4 5 1 ]; end
f6bf36140ee1085e4869248e506c8d924f75d8eaa77ac39bd59cddc082adce56
MATLAB
318
14
function load_params(app) % Function to load params try params = load(app.file_params,'params'); params = params.params; app.params = convert_paths_to_absolute(params); update_log(app,'Retrieved Parameters'); update_params(app); catch update_log(app, 'Could Not Retrieve Parameters'); end end
396031a10582e3e0e111dd78addf8fe3507db6759213c0bb4160a841556a3986
MATLAB
319
10
function update_s_lambda_text(app) completeString = []; for i = 1:length(app.params.s_lambda_sequence) completeString = [completeString regexprep(char(vpa(app.params.s_lambda_sequence(i))),'([0-9]+\.[0-9]+)','${num2str(str2num($1),''%e'')}') newline]; end app.SelectedLambdasTextArea.Value = completeString; end
74a0b60c13a7d9fe116d1c40432577b3c77ab0a4a12ba8c121ffce03debb8d53
MATLAB
319
9
function vecSD = xstd2(matInput) %xstd2 Fast standard deviation calculation over second dimension of 2D %matrix. Calculation time is approximately 75% of original std(). % vecSD = xstd2(matInput) intP = size(matInput,2); vecSD = sqrt(sum(bsxfun(@minus,matInput,sum(matInput,2)./intP).^2,2)*(1/(intP-1))); end
0f20918c96cd4523ae2eb4be6c24d90d44582aabb1d5e306cc292efc825a2ec6
MATLAB
320
15
function score = matching_score(data, Model) N = numel(data.y); tmodel = 0:0.001:data.t(end); ymodel = dbl_exp_func(tmodel, Model); t = 0:data.dt:tmodel(end); [~,idx] = findClosest(t, tmodel); temperate = ymodel(idx); dy = diff( [data.y data.y(end)] ); dt = diff( temperate ); coin = conv(dy, dt); score = coin(1:N);
7ce473df142af39f0591048be2611f5c415b417c203221a455a5dbe49d2761e2
MATLAB
320
10
function [x] = loadPic(picNum) % Load picture picSearchString = sprintf('p%04d*.m', picNum); picMFile = dir(picSearchString); if (~isempty(picMFile)) eval( strcat('x = ',picMFile.name(1:length(picMFile.name)-2),';') ); else error = sprintf('Picture file p%04d*.m not found.', picNum) x = []; return; end
ab07481f4b469960f78f99857a65b402c7156e312de3dae7618515f446db024d
MATLAB
320
11
function zef_plot_graph zef = evalin('base','zef'); g_list = eval('zef.mesh_visualization_graph_list'); g_ind = eval('zef.mesh_visualization_graph_selected'); p_ind = eval('zef.mesh_visualization_parameter_selected'); [~,v_name] = zef_get_profile_parameters(zef,p_ind); eval([g_list{2}{g_ind} '(' v_name ');']); end
53e8ec857a1f3f3e731f0d513d35e86e97193685c8196ffbe419a89adab4bcae
MATLAB
321
10
function update_p_lambda_text(app) completeString = []; for i = 1:length(app.params.p_lambda_sequence) completeString = [completeString regexprep(char(vpa(app.params.p_lambda_sequence(i))),'([0-9]+\.[0-9]+)','${num2str(str2num($1),''%e'')}') newline]; end app.SelectedLambdasTextArea_PE.Value = completeString; en...
34beed7d35132e0e7e68f9b12b174b761dbcbdbd47c5f691854e33a77b5362c6
MATLAB
322
17
function [params] = convert_paths_to_relative(params) root_dir = params.source_directory; params.experiment_directory = erase(params.experiment_directory, root_dir); [filepath, name, ~] = fileparts(params.filename); params.data_directory = erase(filepath, root_dir); params.filename = name; end ...
8799961842868047983b6812631b0f809a63292a695c9fffce927a567a232e25
MATLAB
323
9
%Copyright © 2018- Sampsa Pursiainen & ZI Development Team %See: https://github.com/sampsapursiainen/zeffiro_interface if zef.use_display zef = zeffiro_interface('zeffiro_restart', true); else zef = zeffiro_interface('zeffiro_restart', true, 'start_mode','nodisplay'); end zef = zef_delete_all_compartments(zef)...
7cf5f1abe960b71cd4fa531ed6a454026c32b40c96298ae32822f61c7014762e
MATLAB
324
14
% how to normalize each frame function [nst, Smax] = normStack( st ) % assumes 3rd %Smean = squeeze(mean(st, [1 2])); sz = size( st ); for i=1:sz(3) Smax(i) = single(1.1*max( st(:,:,i),[], "all")); % 1.1 to avoid saturation nst(:,:,i) = single(st(:,:,i) / Smax(i)); end %mn2 = mean(nst, [1 2]); ...
1d85952314357a64a26206a6298db6504b6451145664a35a643d481fb329dae6
MATLAB
325
10
function zef_set_linear_colorbar_ticks(zef,n_ticks,n_digits,max_val) h_c = findobj(zef.h_zeffiro.Children,'Tag','rightColorbar'); h_c.Ticks = linspace(h_c.Limits(1),h_c.Limits(2),n_ticks); TicksLabels = round(max_val.*10.^((h_c.Ticks - h_c.Limits(2))./20),n_digits); h_c.TickLabels = cellstr(num2str(TicksLabels(:))); ...
699ef37bc7521215e84517934e5957fd5f76151488d238488e9b3db892af119f
MATLAB
326
7
function [tuda,Gamma,GammaInit,vpath,stats] = tucatrain(X,Y,T,options) % Wrapper function to perform temporally unconstrained classification % Analysis (TUCA). This function is now merely a wrapper function with core % functionality maintained in tudatrain. [tuda,Gamma,GammaInit,vpath,stats] = tudatrain(X,Y,T,options)...
3c95a0b5bf31f0dc40b1a376943b44e9d394840fa88a1e9017bb092f502212be
MATLAB
327
16
%Copyright © 2018- Sampsa Pursiainen & ZI Development Team %See: https://github.com/sampsapursiainen/zeffiro_interface for zef_i = 1:length(zef.lf_bank_storage) if ismember(zef_i,zef.lf_item_selected) zef.lf_bank_storage{zef_i}.noise_data = zef.noise_data; end end clear zef_i; zef_update_lf_bank_...
b2905a2255d86be8e8a18f73ce7325769ef462358c1bd9ba1123adfd94d36906
MATLAB
327
10
% filtfilt filter ROIs function fdata = filterData( data, Fsampling, Niir, Fstop ) % data = nsamples x ncells % Fs = 10; % sampling rate % Niir = 7; % order % Fst = 1; % stop frequency iir = designfilt('lowpassiir','FilterOrder',Niir,... 'HalfPowerFrequency',Fstop,'SampleRate',Fsampling); fdata = filtfilt(iir, dat...
60f61f2e0c1a7f3264f82e6f0a7bceb0d00dcd37d8df12994e4a988ab4cb6ccc
MATLAB
328
11
function zef_set_timepointline(h_axes) h_line = findobj(h_axes.Children,'Tag','timepointline'); delete(h_line); h_line = line(h_axes.CurrentPoint([1 1]),[h_axes.YLim]); h_line.Color = 0.5*[1 1 1]; h_line.Tag = 'timepointline'; h_axes.Title.String = ['Time value = ' num2str(h_axes.CurrentPoint(1))]; h_line.LineWidth = ...
a63e784a05c6fd131a546e8d6584eacf0d459484f44c24867703e287acae73d9
MATLAB
329
14
function plot_ensemble_coordinates(app) if app.roi_style == 0 plot_ensemble_coordinates_style_0(app); elseif app.roi_style == 1 plot_ensemble_coordinates_style_1(app); elseif app.roi_style == 2 plot_ensemble_coordinates_style_2(app); elseif app.roi_style == 3 plot_ensemble_coordinates_style_3(app); e...
6cca04227a0ddb33810fe915c902de4ff9dc5d126f525a48fdd88b9a8fe82ad3
MATLAB
330
15
function [nodes, triangles] = zef_triangulate_surface(X, Y, Z, varargin) max_faces = 0; if not(isempty(varargin)) max_faces = varargin{1}; end patch_data = surf2patch(X,Y,Z,'triangles'); if max_faces > 0 patch_data = reducepatch(patch_data,max_faces); end nodes = patch_data.vertices; triangles = patch_data.fa...
ebdca5cf8a1bb8186c5cffaffa05b7663738d5c3afbfd61e23990b4bed4afb81
MATLAB
330
10
function vecMean = xmean(matInput,intDim) %xstd Fast mean calculation. Speed-up is approximately 95% of original %time. Syntax: % vecMean = xmean(matInput,intDim) % % By Dr. Jorrit S. Montijn, 29-11-16 (dd-mm-yy; Universite de Geneve) vecMean = sum(matInput,intDim,'default','includenan')./size(matInput,intD...
4798071270268e0157ab682792c97e11139226e7087a60aba299b3ace958ea03
MATLAB
332
13
% [SN,type] = GetImProbeSN( myobj, streamID ) % % Returns serial number string (SN) and integer type % of selected IMEC probe. % function [SN,type] = GetImProbeSN( s, streamID ) ret = DoQueryCmd( s, sprintf( 'GETIMPROBESN %d', streamID ) ); C = textscan( ret, '%[^ ] %d' ); SN = C{1}; type ...
7035abf6a2b20ea98c7a78378cf0778ca6a7ce1ce34e2121f878691094c3c3d6
MATLAB
333
11
set(zef.h_zeffiro_window_main,'DeleteFcn',''); close(zef.h_zeffiro_window_main); zef_segmentation_tool; zef_update; set(findobj(zef.h_zeffiro_window_main.Children,'-property','FontUnits'),'FontUnits','pixels') set(findobj(zef.h_zeffiro_window_main.Children,'-property','FontSize'),'FontSize',zef.font_size); zef.clear_...
f51c7c3a705ee8b96cae9cd65fb8e1e1c797e63ba32ba62c2d824f4d9220e797
MATLAB
333
11
function dPrime = getdprime2(vecIn1,vecIn2,intDim) if ~exist('intDim','var') || isempty(intDim) intDim=1; end if isvector(vecIn1) && isvector(vecIn2) vecIn1 = vecIn1(:); vecIn2 = vecIn2(:); intDim = 1; end dPrime = (mean(vecIn1,intDim) - mean(vecIn2,intDim))./sqrt(0.5*(var(vecIn1,[],intDim)+var(vecIn2,[],i...
64f6102010c618391ba8cde144d0226a731c81d443e8e790a83258fae23aae2a
MATLAB
334
18
function sc = sw_load_scoring_h (sc_fn, opt) % funtion to import scorign for human EEG/PSG directly into sleepwalker opt = opt; %%formats: % luna txt files: % read table sc0 = readtable (sc_fn); sc=struct; sc.id = sc0.ID{1}; sc.clocktime = sc0.CLOCK_TIME; sc.mins = sc0.MINS; sc.stage= sc0.STAGE; sc.stage_no= ...
1f617af628e24356e1bbd6b00cef53693079d4246c8c3fefd424de3ff26a3d31
MATLAB
336
12
function cellOut = strparse(strInput,strDelimiter) %strparse Splits input string by delimiter % cellOut = strparse(strInput,strDelimiter) intParts = sum(ismember(strInput, '_')); cellOut = cell(1,intParts); for intPart=1:(intParts+1) [strTok, strInput] = strtok(strInput,strDelimiter); cellOut{intPart} = st...
689a933e7f01e0d3482ace1654cc05bad3e165c7e2e2afe62360caca9bd1bec3
MATLAB
336
19
%Copyright © 2018- Sampsa Pursiainen & ZI Development Team %See: https://github.com/sampsapursiainen/zeffiro_interface function zef = zef_minimum_norm_estimation(zef) if nargin == 0 zef = evalin('base','zef'); end zef = zef_tool_start(zef,'zef_mne_tool_start',1/4,0); if nargout == 0 assignin('base','zef',...
ab942954c66a36512a2def1fbef5d7579c391e31384b0918939378ba945ddf66
MATLAB
336
13
zef.aux_data_1 = cell(0); zef.aux_data_2 = eval(['zef.' zef.current_tag '_transform_name']); for zef_i = 1 : length(zef.aux_data_2) zef.aux_data_1{zef_i,1} = zef_i; zef.aux_data_1{zef_i,2} = zef.aux_data_2{zef_i}; end zef.h_transform_table.Data = zef.aux_data_1; zef = rmfield(zef,{'aux_data_1','aux_data_2'}...
9532fbb470fb8fd4ddb9d7d8d874a14a9972d2ea45d1a1c859e8d71e73fd1653
MATLAB
337
4
set(gcf,'AutoResizeChildren','off'); zef.zeffiro_current_size{zef_fig_num} = get(gcf,'Position'); set(gcf,'Tag',num2str(zef_fig_num)); set(gcf,'SizeChangedFcn','zef.zeffiro_current_size{str2num(get(gcf,''Tag''))} = zef_change_size_function(gcf,zef.zeffiro_current_size{str2num(get(gcf,''Tag''))},[],{''Colorbar'',''image...
e80f46f751f4bda1ed2f56d030e39ac42babae632c24a1ae55284ebd3f31ea0c
MATLAB
337
9
%Copyright © 2021- Sampsa Pursiainen & GPU-ToRRe-3D Development Team %See: https://github.com/sampsapursiainen/GPU-Torre-3D function save_jacobian_data_complex(aux_mat_cos, aux_mat_sin, ind_vec, torre_dir) save([torre_dir '/system_data/aux_mat_' int2str(ind_vec(1)) '_' int2str(ind_vec(2)) '.mat'],'aux_mat_cos', 'aux...
2646ddfb66f545d44fa26f1e25b67e0d6b5a622ddf17e0afdddd1ac0e0dd97f4
MATLAB
338
8
function zef_system_settings_table_selection(hObject,eventdata,handles) system_settings_selected = eventdata.Indices(:,1); system_settings_selected = unique(system_settings_selected); system_settings_selected = system_settings_selected(:)'; evalin('base',['zef.system_settings_selected =[' num2str(system_settings_selec...
6fdd8aff3050ef8e0ca56ad852250149632e737e7c0895390fd4716c04b993ce
MATLAB
338
6
[zef.file zef.file_path] = uigetfile({'*.mat'},'Import interpolation',zef.save_file_path); if not(isequal(zef.file,0)); [zef.eit_sensitivity_tool_data] = load([zef.file_path zef.file]); zef.eit_sensitivity_tool_file = [zef.file_path zef.file]; set(zef.h_eit_sensitivity_tool_file, 'Value', zef.eit_sensitivit...
8990c08fc064488e809f0d1e41f38903a89b9d7191bbb2d415cf47caae00cc90
MATLAB
338
8
function zef_plugin_settings_table_selection(hObject,eventdata,handles) plugin_settings_selected = eventdata.Indices(:,1); plugin_settings_selected = unique(plugin_settings_selected); plugin_settings_selected = plugin_settings_selected(:)'; evalin('base',['zef.plugin_settings_selected =[' num2str(plugin_settings_selec...
dc986c7f05653507d12d3adc6818d9567ef6adceeb1c544afbb4444d89234da0
MATLAB
338
19
function zef_wireframe_plot(w_t,w_n) h_a = evalin('base','zef.h_axes1'); axes(h_a); h_t = trimesh(w_t,w_n(:,1),w_n(:,2),w_n(:,3)); h_t.EdgeColor = 'none'; h_t.FaceColor = 0.5*[1 1 1]; h_l = light; h_l.Position = [1 0 0]; h_l = light; h_l.Position = [-1 0 0]; lighting phong; axis equal; h_t.Tag = 'surface'; h_a.Visi...
7ce67f62ff5d006e36ac34da5d38be5ed486a88eb8510d4390363beaf0c37957
MATLAB
339
14
function [nodes, tetra] = zef_optimize_mesh(nodes,tetra) nodes_old = nodes; tetra_old = tetra; [tetra, optimizer_flag] = zef_tetra_turn(zef, nodes, tetra, evalin('base','zef.mesh_optimization_parameter')); if optimizer_flag == -1 nodes = nodes_old; tetra = tetra_old; errordlg('Mesh optimization failed.')...
481472ba4132814342ab1b4589f2340d0745ec867bb7710de6a42b7395172743
MATLAB
340
10
%Copyright © 2021- Sampsa Pursiainen & GPU-ToRRe-3D Development Team %See: https://github.com/sampsapursiainen/GPU-Torre-3D function [min_ind] = array_min(i, xq, yq, zq, nodes_aux) aux_pos = [xq(i),yq(i),zq(i)]; [min_val,min_ind] = min(sqrt(sum((nodes_aux - aux_pos(ones(size(nodes_aux,1),1),:)).^2,2))); min_ind = gath...
a6968fcd1b2ffd2dfe1b26f9285ece3dde5be548622a62e9f332bc41f5783e91
MATLAB
342
11
function zef = zef_parcellation_roi_pick_color(zef) color_vec = uisetcolor; if not(isequal(color_vec,0)) color_str = num2str(color_vec); zef.h_parcellation_roi_color.String = color_str; zef.h_parcellation_roi_color.BackgroundColor = color_vec; zef.parcellation_roi_color(zef.parcellation_roi_selected,:)...
e6c262a7e88c47c7b412f3d8cdac1397ca1dd8584121f56e6c4851b01ec7ca4b
MATLAB
342
15
function sEpochs = ETC_GenEmptyEpochs sEpochs = struct; sEpochs.BeginFrame = nan; sEpochs.BeginLabels = []; sEpochs.EndFrame = nan; sEpochs.EndLabels = []; sEpochs.CenterX = []; sEpochs.CenterY = []; sEpochs.Radius = []; sEpochs.Radius2 = []; sEpochs.Angle = []; sEpochs.Blinks = []; sEpochs.IsDetected = [];...
e7a8eb00d5722c85dc39ca53a360dba4cc4955b50bca7c2ffb3eaa9c60026a51
MATLAB
342
9
function im8bit = dbl2uint8( stack ) tic im8bit = uint8(255 * mat2gray(stack)); [premin, premax] = minmax(stack); [postmin, postmax] = minmax(im8bit); disp(append('pre min max: ', num2str(premin), ' , ', num2str(premax))) disp(append('post min max: ', num2str(postmin), ' , ',num2str(postmax))) disp(append('dbl2uint8: '...
c81ea97f9ac1fc1b8df6391ee4e6a045ad0c8ae6fb9f081c957610a265b4908c
MATLAB
343
15
function post_info = estimate_spike_num_weight(post_info,Model) % --- % post_info = estimate_spike_num_weight(post_info,Model) % --- % post_info.Pspike(ns,n) = P(ns | yk) of n-th overlap window X = post_info.Pspike; X = [X; ones(1,size(X,2))]; Y = Model.W * X; [ytmp, Yid] = max(Y,[],1); post_info.s...
6ca130eac8641ce33c5fe8b5bc9bcd8957c1d7668d634825c0c7355e209ad460
MATLAB
344
18
function plot_rois_preview(app) % Pull Out rois = app.rois; %now parse whether 3D Single-Point Coordinates OR 2D Polygons if size(rois,2)==3 app.roi_style = 0; plot_roi_dots(app); elseif size(rois,2)==2 app.roi_style = 1; plot_roi_2D_dots(app); elseif isstruct(rois) app.roi_style = 2; plot_roi...