sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
edbad8b997150a2916e312e16327d41a356cf375629a1dd72779aa3e1da8393b
MATLAB
380
10
function plotfeatures(featurestable, pred1, pred2, response) figure; hold on tab = featurestable; scatter(tab.(pred1)(tab.(response)==1), tab.(pred2)(tab.(response)==1)) scatter(tab.(pred1)(tab.(response)==0), tab.(pred2)(tab.(response)==0),'x') legend({'Response=True','Response=False'}) xlabel(...
1d8e5ada1109fd01c8ca05c140140955f79b4e08f28144d211560cf11f82c9c8
MATLAB
381
12
function [timeScaleFactor] = ml_util_timeunit_to_ms_scalefactor( timeUnits ) switch timeUnits case 'seconds' timeScaleFactor = 10^3; case 'milliseconds' timeScaleFactor = 1; case 'microseconds' timeScaleFactor = 10^(-3); otherwise error...
61602350dde4e16bc8ea124eb490988eeae6e82c5579c461f2667d9c7c1563f5
MATLAB
381
4
function [sum_result, agg_restul] = zasoFarray(zaso, fct_sum, fct_agg) % This may look stupid, but it is to reduce a very likely and hard to debug problem where one calls z1.fxsum(z2, fct) which is nonsensical. This function makes the interface more Python-like and requires only one reference to the object. [sum_re...
b5b59b8ff7a03c6af6b969079c22a70f65e7f8095cbf47758e399153e8009882
MATLAB
381
11
setenv( 'FSLDIR', '/usr/local/fsl'); fsldir = getenv('FSLDIR'); fsldirmpath = sprintf('%s/etc/matlab',fsldir); path(path, fsldirmpath); clear fsldir fsldirmpath; % set FSL environment setenv('FSLOUTPUTTYPE','NIFTI_GZ'); % this to tell what the output type would be % That?s it and you can launch any FSL command as foll...
1bf5f8fe355b9d586c9b0887cd179ab4f5a74b20e9105302d0de31607ea3a7b0
MATLAB
382
10
function [similarity indSim] = SSSimColourTextureFlowSizeFillOrig(a, b, blobStruct) % Colour + Texture + Flow + Size + Fill indSim(:,1) = SSSimColour(a, b, blobStruct); indSim(:,2) = SSSimTexture(a, b, blobStruct); indSIm(:,3) = SSSimFlow(a, b, blobStruct); indSim(:,4) = SSSimSize(a, b, blobStruct); indSim(:,5) = SSSi...
315ee51f03c4ac930f894486b8ad17bdb041d11f912a2e0dadc3db5033fbeb86
MATLAB
382
10
function discritized_v = discretize_given_edges(v, edges) %similar to the matlab discritize function in later versions discritized_v = zeros(size(v)); discritized_v(v < edges(1)) = 1; for edge_index = 1:numel(edges)-1 discritized_v(v >= edges(edge_index) & v < edges(edge_index+1)) = edge_index; ...
b24aaefee73e9dcc7d8bc0f8658ba9121aede307707f4f44f50ba2a75643b8b7
MATLAB
382
11
function group_info=get_current_work_group_idx(work_info_batch) group_idx=work_info_batch.ref.net_run_current_group_idx; net_run_current_group_idx_linked=work_info_batch.ref.net_run_current_group_idx_linked; if ~isempty(net_run_current_group_idx_linked) group_idx=net_run_current_group_idx_linked; end group_info=w...
fc9b82301c0f1e8b1a8fb4e49cccc8540ef31d22043d6375314406e80dd5d94d
MATLAB
382
18
function [ rmse ] = rmse( in, true, use_abs ) %RMSE Summary of this function goes here % Detailed explanation goes here % output percentage % updated by X.L. 202003 if nargin < 3 use_abs = 0; end if (nargin == 3) && (use_abs == 1) rmse = 100 * norm(abs(in(:)) - abs(true(:))) / norm(abs(true(:))); else ...
5135a150570b8767fec7200b133474d8da52979a59bd427ca1604f0eb42c0c88
MATLAB
383
17
function [img] = readImg_APP(imAdjust, cam, frame, roi) %% Load sample images img = imread(fullfile(cd, ['img' num2str(cam), '.tiff']),'Index',frame); % Upsample image for better detection of CR img = imresize(img,2); % Enhance contrast if imAdjust img = imadjust(img); end ...
6e9d0bfe69697edace1c953d0f8a985c95d0fbd57316ef1970097d100341bf28
MATLAB
383
9
function min_displacement = min_circshifted_displacement(K, Old_K) %finds the minimum circshifted displacement to look for flips in the %centerline displacements = zeros(1,size(K,1)); for shift = 1:size(K,1) displacements(shift) = find_displacement_between_two_centerlines(K, circshift(Old_K,shif...
c722d7dde05c8fa65ba0078ae2fa99f4dda8fb8608c1baf5bce5e85f27dbd0a0
MATLAB
383
17
Adapts code from: https://github.com/trendscenter/gift function [SSE, R] = cluster_goodness(D, IDX) % Get SSE and dispersion ratio [nobs, k] = size(D); Din = zeros(1, k); Dout = zeros(1, k); for ii = 1:k Din(ii) = sum(D(IDX == ii,ii).^2); % dispersion in cluster Dout(ii) = sum(D(IDX ~= ii,ii).^2); % sum of ...
424a7e234ee9e05da1ac7ddb0da8f091465ca8755ef0803c37e074d38fe91659
MATLAB
384
14
function [D,entropies] = findKLDivergences(data) %finds the KL-divergences (D) and entropies between all rows in 'data' N = length(data(:,1)); logData = log(data); logData(isinf(logData) | isnan(logData)) = 0; entropies = -sum(data.*logData,2); D = - data * logData'; D = bsxfun(@minus...
b3f386391162bf069c64f8959591b0717ff6166752050b415c74021013ecbb90
MATLAB
384
15
function fix_ActionCancelled( hObject, handles, panel_to_deselect ) % cancel a fix-action and return GUI to neutral state % JAB 6/23/12 for fly = handles.selected, if fly > 0, fix_SetFlySelected(handles,fly,false); end end handles.nselect = 0; handles.selected = []; set(panel_to_deselect,'visible','off'); fix_...
feafa53c7ae8ce2f3690ba1ea553698abc41f7d9817eb2eec994bff01008d6cf
MATLAB
384
16
function activateCEDS64 % This script actiates the CEDS64 library aka Spike2 MATLAB SON Interface % % see http://ced.co.uk/upgrades/spike2matson for more information % Each computer MUST install this! % % Maxwell Gagnon if isempty(getenv('CEDS64ML')) setenv('CEDS64ML', 'C:\CEDMATLAB\CEDS64ML'); end cedpath = ge...
10923a7396b8941ba5d686e73f3fec10a2e33af0f90ebfca737843b9bd6d3ebf
MATLAB
386
9
function [spikeCountMap] = ml_placefield_spikecountmap(sxi, syi, nbinsx, nbinsy) % Perform the counts by hand because I don't trust MATLAB numSpikes = length(sxi); spikeCountMap = zeros(nbinsy, nbinsx); for iSpike = 1:numSpikes prevCount = spikeCountMap( syi(iSpike), sxi(iSpike) ); spike...
1d6f4f585f9976486aedb22d39067dd5abd262076b309b4b7de6ac383bf0f548
MATLAB
386
12
function no_weight_tuples = get_behavior_tuples(number_of_behaviors, degree) %this generates all possible transition tuples iteration = 1; no_weight_tuples = 1:number_of_behaviors; while iteration < degree no_weight_tuples = combvec(no_weight_tuples, 1:number_of_behaviors); iteration = iter...
ea9fe98396683d3bebcebc788c9daba5ae6a843f1d249545967df1859446b808
MATLAB
386
14
num_meta_tr = 10; value_list = [.25 .5 .75 1 1.25 1.5]; ff_values = zeros(length(value_list),num_meta_tr); for valuei = 1:length(value_list) value = value_list(valuei); for tempi = 1:num_meta_tr run('Main_vectorized_simple_dopa.m') ff_values(valuei,tempi) = ff_vect(num_trials); end ...
bb980c0c62d23085fbd678646664bfd7c89248fcfd616f37aa9e5b1b2bbed8cf
MATLAB
387
18
function rootPath = simseqRootPath() % % Return the path to root simSeq project folder % % This function must reside in the directory base of this code repository. % It is used to determine the location of various subdirectories % % Example: % fullfile(simseqRootPath, 'stimulus') % % By Eline Kupers 2020 rootPath =...
0a20043799ea0bab22810690abb0f5d677b75cb1a96268e36d3882c2780478d4
MATLAB
388
22
function [x,y] = pairwise_cleanup(X,Y) % This function receives two column vectors and removes the missing values % pairwise % % M C Valdes Hernandez <mvhernan@staffmail.ed.ac.uk> % 29.10.2013 LX = length(X); LY = length(Y); if ~isequal(LX,LY) errdlg('Both vectors need to have the same length'); exit; end p...
56e5a72716591145427254b17f6ad1a4d5b2c0eb73488a113907b7901a7c113f
MATLAB
388
19
function lab= convertLab(lab,nlab) lab=char(lab) for i=1:nlab ilab=lab(i,:); ilab(ilab=='_')=[]; ind= strfind(ilab,'_1'); ilab(ind:ind+1)=[]; ind= strfind(ilab,'2'); ilab(ind)=[]; ind= strfind(ilab,'1'); ilab(ind)=[]; ind= strfind(ilab,'0'); ilab(ind)=[]; ind= strfind(ila...
c13d208371b82035896db5e5536990402ab397d207acdc2a63bf5823664a43aa
MATLAB
389
17
function [ret]=SONCanWrite(fh) % SONCANWRITE test whether a file can be written to % BOOLEAN=SONCANWRITE(FH) % FH SON32.DLL file handle % Returns 0 if FALSE, 1 if TRUE % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 if nargin ~= 1 ret=-10...
4a2020a51a09384a4170ece60ff99f76c9dd98c9bf23713a33706c382533dfaa
MATLAB
390
18
function Q = qNormalize( Q1 ) % qNormalize: quaternion normalization, i.e. ||Q||=1 % Q = qNormalize( Q1 ) % IN: % Q1 - input quaternion % % OUT: % Q - normalized (unity) quaternion, i.e. Q1 = Q / ||Q|| % % VERSION: 03.03.2012 Q1 = reshape( Q1, 4, 1 ); if( Q1 ~= 0 ) Q = Q1 ./ qLength( Q1...
6b600ebc818084167cb0607d7f2f3b438e03fe540d35803fdd560695fd39ba30
MATLAB
390
9
function mlgp_plot_bfo_90_sessions(obj) mlgp_plot_bfo_general_sessions(obj, 90, 'same'); mlgp_plot_bfo_general_sessions(obj, 90, 'different'); mlgp_plot_bfo_general_sessions(obj, 90, 'all'); numContexts = obj.Experiment.getNumContexts(); for iContext = 1:numContexts mlgp_plot_bfo_general_ses...
8d7ccc037beda100eac2701467cccb4202e361fff2149130d525b8fe9d8f57ed
MATLAB
390
9
function mltp_plot_bfo_90_sessions(obj) mltp_plot_bfo_general_sessions(obj, 90, 'same'); mltp_plot_bfo_general_sessions(obj, 90, 'different'); mltp_plot_bfo_general_sessions(obj, 90, 'all'); numContexts = obj.Experiment.getNumContexts(); for iContext = 1:numContexts mltp_plot_bfo_general_ses...
a99b52ad0a2f3f9b8116323a8359e97d7f07d6ac6a300c1fc6b58222e399c622
MATLAB
390
19
function blocks=SONDelBlocks(fh, chan) % SONDELBLOCKS returns the number of deleted blocks in file FH on channel CHAN % % BLOCKS=SONDELBLOCKS(FH, CHAN) % % % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 if nargin<2 blocks=-1000; retur...
c6516efe3a7d6d9c6eff43dc75730adbc8c358d70a29d2f251f1ff300da10f74
MATLAB
390
16
% This script does pcode conversion. % Copyright SNM 2017-2019 clear all; %#ok<CLALL> FileName = uigetfile('*.m','Select the tissue mesh file to open', 'MultiSelect', 'on'); if iscell(FileName) for m = 1:length(FileName) display(FileName{m}); pcode(FileName{m}); end e...
003bf279835cb7dd177bb10dac8c831f65aaf880f6d93b479ec044911aab3b9a
MATLAB
391
15
function gdir = dirgen(ndir) filePath = matlab.desktop.editor.getActiveFilename; root = fileparts(filePath); system(sprintf('dirgen %u %s -cartesian -force',... ndir,... fullfile(root,'dirgen_temp.txt') )); fid = fopen(fullfile(root,'dirgen_temp.txt'),'r'); fgetl(fid); gdir = zeros(ndir,3); for i = 1:ndir t...
fb3744abd03e900588fa92ab0f30032fcb86928bfccf769e5983fa85c75e2bcd
MATLAB
391
13
function overlay_heatmap_gradcam(image, heatmap, base_axis, alpha) set(base_axis, 'color', 'none', 'visible', 'off') img = axes; imagesc(squeeze(image)); colormap(img, 'gray'); set(img, 'color', 'none', 'visible', 'off') hm = axes; imagesc(heatmap, 'AlphaData', alpha); colormap(hm, 'jet'); %colorbar set(hm, 'color', ...
71c4279eb79d45fa09796d439a17128dfc889fba8b78c2877757fd283c56da76
MATLAB
392
12
function dframe = extractForeground(frame,arenaModel,Thresh) gFrame = im2gray(frame); dframe = imabsdiff(arenaModel,gFrame); dframe(dframe>Thresh) = 255; dframe(dframe<Thresh) = 0; dframe = imerode(dframe,strel('rectangle',[2 2])); %dframe = imdilate(dframe,strel('rectangle',[4 4])); %dframe = imdilate(dframe,strel('d...
b8b4861b991f5e93c2d0269fc7292fe55558d986b73d14e9096c1d9e679ac72a
MATLAB
392
15
function check_failed(text) FILE = fopen(sprintf('dat/check_error.%s', getenv('network')), 'w'); if FILE < 0, error('fopen'); end fprintf(FILE, '%s\n', text); if fclose(FILE) < 0, error('fclose'); end data = 0; OUT = fopen(sprintf('dat/check.%s', getenv('network')), 'w'); if OUT < 0, error('fopen'); end fprin...
6945d8517fe9004233525ea42dece8f7064b085f6250cbedb8d3c1477d41e62a
MATLAB
394
16
function[parameters]=fit_silhouettes(all_silhouettes) % function to get parameters from distribution of silhoeuttes % parameters is a [alpha beta negloglikelihood mean variance] vector parameters=nan(4,1); pd = fitdist(all_silhouettes,'Beta'); parameters(1)=pd.a; parameters(2)=pd.b; parameters(3)=negloglik(pd); p...
a75e0f618787073a4c588cb2e5e783b739186b2afa96065a60640f580bdb7e08
MATLAB
394
13
function SONSetChanTitle(fh, chan, str) % SONSETCHANTITLE sets the channel title % FH = SON file handle % CHAN = channel number (0 to Max-1) % str = string with new title % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 global SON_TITLESZ; str=str(1:min(SON_...
c7800da847e4c2654cd9200efbcd093aff70c319a7fb81c271e2b227acbd1bfe
MATLAB
394
13
%% save num_saves = length(save_params); text = ['''' save_params{1} ''',']; for i = 1:num_saves-1 if(exist(save_params{i+1},'var')) text = [text '''' save_params{i+1} ''',']; end end text = text(1:end-1); save_time = datestr(datevec(now),'yyyy_mm_dd_HH_MM_SS'); save_command = ['save(''' save_folder '...
2280a470a940ae2a55ff90553f23c6bffb70d6fc52adfa84bdd79b7d03e04126
MATLAB
395
17
function [err]=SONCloseFile(fh) % SONCLOSEFILE closes an opened SON file % ERR=SONCLOSEFILE(FH) where FH is the SON32.DLL handle for the file % Returns zero if all OK. % % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 if nargin ~= 1 err=-1000...
68b1bb1f7fdbcbacacad04c0c3c3e88a64513bf46ed3e6ca05ea34bff7c32d3f
MATLAB
395
9
function mltp_plot_bfo_180_sessions(obj) mltp_plot_bfo_general_sessions(obj, 180, 'same'); mltp_plot_bfo_general_sessions(obj, 180, 'different'); mltp_plot_bfo_general_sessions(obj, 180, 'all'); numContexts = obj.Experiment.getNumContexts(); for iContext = 1:numContexts mltp_plot_bfo_general...
2bc80d2c828679a64626f568d73bd2bad8308b67ff785fb0a9d92e8ee9075000
MATLAB
396
13
function parentcluster = getActiveParentCluster(cluster, active, network) %this gets the active parents of a cluster parentcluster = []; for i = 1:length(cluster) %parentcluster = [parentcluster getActiveNeighbours(cluster(i), active, [network{cluster(i)}])']; parentcluster = [parentcluste...
8df5eb1bc71e6a71ef612ca66fb796ffa4c58bf47b90ef85998563807d9c0932
MATLAB
396
12
function bytes=SONItemSize(fh, chan) % SONITEMSIZE returns the size of a data item on the specified channel (bytes) % % BYTES=SONITEMSIZE(FH, CHAN) % where FH is the SON file handle and CHAN is the channel number % (0 - SONMaxChan()-1) % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King'...
70ca9ad42a761ccfab017c70a7aed99b695641fec5b417065da56bd035a36791
MATLAB
397
23
function [ax] = acorrFig(xcData,figopt) % acorrFig.m 9/28/22 xc = xcData.xcn2; be = xcData.be; clr = 'k'; inputax = optCheck(figopt,'ax',[],[]); tistr = optCheck(figopt,'tistr','ACF',''); if isempty(inputax) plot(be,xc,'Color',clr) else plot(inputax,be,xc,'Color',clr) end ax = gca; ax.TickDir = 'out'; ax.Box = 'o...
b872dd554da8790ebbb94e9099f8851f6b31bd16fffe74ccb64472c616862591
MATLAB
397
18
function [imageStack, n_images] = getImageStack(file) info = imfinfo(file); nImage = info(1).Height; mImage = info(1).Width; n_images = length(info); imageStack = zeros(nImage,mImage,n_images,'uint8'); TifLink = Tiff(file, 'r'); for i=1:n_images TifLink.setDirectory(i); im...
f045d24f29982d41e40d1e125f5cae5bf307a6101704b2f85df8f73bf6532d1a
MATLAB
397
12
function [abslocalskew] = abslocalskew(eeg, Fs) %ABSLOCALSKEW Calculates the local skewness of every 15ms of signal, and %returns the mean of these. interval = round(15 * Fs * 0.001); localskew = []; for i=1:interval:length(eeg)/interval-interval % skew in 15ms segment localskew = [localskew, abs(skewness(eeg(...
3b84d516cbd6bf1da8b5f0c92d8ab523a909ee69afebfaa4cecf7b9ebb3730ad
MATLAB
399
15
function dispsig(signalMatrix, range, titlestr); %DISPSIG - deprecated! % % Please use icaplot instead. % % See also ICAPLOT % @(#)$Id: dispsig.m 8776 2013-11-14 09:04:48Z roboos $ fprintf('\nNote: DISPSIG is now deprecated! Please use ICAPLOT.\n'); if nargin < 3, titlestr = ''; end if nargin < 2, range = 1:size(s...
3f468fc24aa472a766ae69259288598c354021609559c338c07b7ff7efe5505c
MATLAB
399
11
clear; tPET = zeros(100,16,16,50000,5); for i = 51:100 load_data = load(append("../../data/tPET_0.22_0.42_0.034_0.034_Iattn_0.02/",num2str(i),".mat"),"tPET"); tPET(i-50,:,:,:,:) = load_data.tPET; clearvars load_data; disp(append(num2str(i), " done")); end disp("Saving...") save('..\..\data\tPET_0.22_0.4...
545457a8d5f54fe38bd17e7a2dabcb130e4ab665de408303d264c01709f07e74
MATLAB
399
24
function ynn_v = ValNLDNLS(Imat_v,dsr_init,nn_stat,nn_dyn,Xi,Ai,tv,no,nh) X = tonndata(Imat_v,true,false); yv = nn_dyn(X,Xi,Ai); yn = zeros(nh,tv-1); for i = 1:tv-1 yn(1:nh,i) = yv{i}; end ynn_d = zeros(tv,nh); ynn_d(1,1:nh) = 0; for i = 1:nh ynn_d(2:tv,i) = abs((yn(i,:))'); end ynn_v(...
6f845a74942caae6b7295d01f95dfee5499cef8c32e99eb729597d608ac16746
MATLAB
399
12
function mltp_compute_bfo_90_average(obj) mltp_compute_bfo_general_average(obj, 90, 'same'); mltp_compute_bfo_general_average(obj, 90, 'different'); mltp_compute_bfo_general_average(obj, 90, 'all'); numContexts = obj.Experiment.getNumContexts(); for iContext = 1:numContexts mltp_compute_bfo_g...
b72024c21f92114a2bcf7a0537fda30638e5421e48a8850fae84a9464e610017
MATLAB
399
16
relevant_track_fields = {'Size','Frames'}; %select folders folders = getfoldersGUI(); [allTracks, folder_indecies, track_indecies] = loadtracks(folders,relevant_track_fields ); worm_sizes = zeros(1,length(allTracks)); for track_index = 1:length(allTracks) worm_sizes(track_index) = mean(allTracks(track_index).Siz...
c4b32b017f56cbf314436ba229c06814a1cef3921b00bba1fae25f25c2ea222b
MATLAB
399
11
function clr; % Clear workspace, close all windows, clears command window %---------------------------------------------------------------| % Sergei Koptenko, Medipattern Corp., Toronto | % phone (416)744-0009 fax (416)744--6899 | % skoptenko@medipattern.com | %---------------Ma...
e08f300ea61b9f514ccbeb4cc20798e3b2776dda0fbd50b0529bbb4fe906e709
MATLAB
399
12
function mlgp_compute_bfo_90_average(obj) mlgp_compute_bfo_general_average(obj, 90, 'same'); mlgp_compute_bfo_general_average(obj, 90, 'different'); mlgp_compute_bfo_general_average(obj, 90, 'all'); numContexts = obj.Experiment.getNumContexts(); for iContext = 1:numContexts mlgp_compute_bfo_g...
602ff64ad5f0e77f168b1de22f83a0e4d9bd0a25fcbd35d66de0454aabf747b6
MATLAB
400
8
function alternative_path_variances=ask_for_alternative_path_variance(has_variance_flag) alternative_path_variances=pwd; if sum(has_variance_flag)<numel(has_variance_flag) title='Some variance files might not exist in the derivatives folder. If existing, provide an alternative path to look for variance files';...
edc3112a3d1f40f74f1d6ede1e24ce1b598b630943f529e260d46cb69c3e52c9
MATLAB
400
11
<<<<<<< HEAD function [FNMR] = computeFNMR_classic(gmsVector, REJngra, threshold) FNMR = (length(find(sort(gmsVector) < threshold)) + REJngra) / (length(gmsVector) + REJngra); ======= function [FNMR] = computeFNMR_classic(gmsVector, REJngra, threshold) FNMR = (length(find(sort(gmsVector) < threshold)) + REJngra) / (...
46651da4ea6f4d1aadd289fbd0d709196a7a1c6dd29178e13d76c9f3fe31d05e
MATLAB
401
16
function t = mystruct(obj) % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: mystruct.m 8776 2013-11-14 09:04:48Z roboos $ if numel(obj)~=1, error('Too many elements to convert'); end; fn = fieldnames(obj); for i=1:lengt...
9665e054e2bd075a4173936e40b8194d756741feedf5fa839a555497659e5be9
MATLAB
401
12
function mltp_compute_bfo_180_average(obj) mltp_compute_bfo_general_average(obj, 180, 'same'); mltp_compute_bfo_general_average(obj, 180, 'different'); mltp_compute_bfo_general_average(obj, 180, 'all'); numContexts = obj.Experiment.getNumContexts(); for iContext = 1:numContexts mltp_compute_bfo_...
b5946d2ef3ccf36fb8dec9c1b9dcea49ec431bb3a718d987b448f104bbd8618a
MATLAB
401
18
function [avgpower] = alphaPower(eeg,Fs) %ALPHAPOWER Calculates log band power in the alpha (8-13Hz) band of an % EEG signal. x = eeg; N = length(x); xdft = fft(x); xdft = xdft(1:N/2+1); psdx = (1/(Fs*N)) * abs(xdft).^2; psdx(2:end-1) = 2*psdx(2:end-1); freq = 0:Fs/length(x):Fs/2; assert(length(psdx)==length(freq)) ...
eaa04d6dc4333c5c9c01c0165f2ce15fc41a50dd77d0d84115bbfdd852bd6566
MATLAB
401
14
function [meanTracks] = getMean(sTracks,LookBack) if length(sTracks)>5 for i = 1:length(sTracks) TOI = sTracks(i).data; Range = round(size(TOI,1)/2):size(TOI,1); if length(Range)>LookBack Range = Range(end-LookBack):Range(end); end meanData = mean(TOI(Range,:),1,'omit...
0682a8d2f4d9e2a2f46beb04640b3e1e84ffd60fb6a4c7c2e0029a1606101709
MATLAB
404
16
function spikeDensityFunction = calc_spikeDensityFunction(spikeTimes, kernel_sd, samplerate) % Get Data spikeTimes = round(spikeTimes * samplerate); binned = zeros(spikeTimes(end),1); for i = 1:length(spikeTimes) binned(spikeTimes(i)) = 1; end % Kernel edges = -5 * kernel_sd : 1/samplerate : 5 * kernel_sd; kerne...
2ad2ea5c46031670b9b6ed5399be75c249a60c6ec54501469a32d57e44729fb4
MATLAB
404
12
function [visitedCountMap] = ml_placefield_visitedcountmap(xi, yi, nbinsx, nbinsy) % Perform the counts by hand because I don't trust MATLAB numSamples = length(xi); visitedCountMap = zeros(nbinsy, nbinsx); for iVisited = 1:numSamples prevCount = visitedCountMap( yi(iVisited), xi(iVisited) ); ...
640eddf612828ad1808b7270ba0e85376d908e89c91a34c4d57574af52b3ac6c
MATLAB
404
24
function res = D(image) % % res = D(image) % % image = a 3D image % % This function computes the finite difference transform of the image % % Related functions: % adjD , invD % % [sx,sy,sz] = size(image); Dx = image([2:end,end],:,:) - image; Dy = image(:,[2:end,end],:) - image; Dz = image(:,:,[2:end,end]) - i...
87f22b742e230047d2217d443a7bf0bbb0cb2bc6810f17c1740f2c345cd318f7
MATLAB
404
21
function node_scores=my_softmax(node_scores) if size(node_scores, 1)>1 node_scores=bsxfun(@minus, node_scores, max(node_scores, [], 2)); node_scores=exp(node_scores); node_scores=bsxfun(@rdivide, node_scores,... sum(node_scores, 2)); else node_scores=node_scores-max(node_scores); no...
5d69af40a72b074d43dfc16ea4b349e7f72af76bbf617a0c387fb0946b11855a
MATLAB
405
14
function runsmoothing(root,width,DKIroot) addpath(genpath(DKIroot)); nii = niftiread(fullfile(root,'CSFmask.nii')); csf = logical(nii); info = niftiinfo(fullfile(root,'dwibc.nii')); dwi = double(niftiread(info)); kernelsize = [5 5]; width = str2double(width); dwism = smoothing(dwi,kernelsize,width,csf); i...
ac0fa22d4ff7664ce6727877d127737a58a9de76d84f22a58c3d2072674e72cc
MATLAB
405
17
function [ret]=SONCanWrite(fh) % SONCANWRITE test whether a file can be written to % BOOLEAN=SONCANWRITE(FH) % FH SON32.DLL file handle % Returns 0 if FALSE, 1 if TRUE % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 if nargin ~= 1 ...
b607362e5fdbb9bc769fefb969775950715b4bbbcf666835cacb459e6a628fd8
MATLAB
405
19
%% compare the heritability between DBM and VBM path = pwd; roi_num = 48; her_mask = logical(tril(ones(roi_num),-1)); dbm_her_file = 'heritability_matrix_p_DBM.mat'; vbm_her_file = 'heritability_matrix_p_VBM.mat'; load(dbm_her_file) dbm_her = her(her_mask); dbm_p = her_p(her_mask); load(vbm_her_file) vbm_her = her(...
655f2393d08542a4170e4499e12a457d994dfb8503671ff1cac2d33aeb9d4479
MATLAB
406
21
function ButttonDownFcn(~,~) clc global passdata; switch(get(gcf,'SelectionType')) case 'normal' passdata.mouseSign = 0; passdata.singalclick=1; str = 'µ¥»ú×ó¼ü'; case 'alt' str = 'µ¥»úÓÒ¼ü/ctrl+×ó'; case 'open' passdata.doubleclick=1; str = 'Ë«»÷ÈÎÒâ¼ü'; ...
81eef57d558c1dbd1d13ee40c687f8186fb8203c883cc36bbe185da14a41fd4b
MATLAB
406
17
function en = end(a,k,n) % Overloaded end function for file_array objects. % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: end.m 8776 2013-11-14 09:04:48Z roboos $ dim = size(a); if k>length(dim) en = 1; else if n<l...
93e6e91437b68fb08f8c7343481be91fb89afe81553ac7dd20e3cc8cdcb11ded
MATLAB
406
13
function SONSetChanTitle(fh, chan, str) % SONSETCHANTITLE sets the channel title % FH = SON file handle % CHAN = channel number (0 to Max-1) % str = string with new title % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 global SON_TITLESZ; str=str...
d2ecc2e74755dff3ba987dbb3744e688822d68914eccd97393488c965db25173
MATLAB
406
22
% % The exp-entropy, i.e. the entropy of a vector given by considering the % exponential of its entries as probabilities. Used with eigenvalues in % [671]. % % RESULT % entropy Entropy % % PARAMETERS % values Vector of values % function entropy = exp_entropy(values) values = values - max(values); lnsum = log(s...
0249ed40e996e5038d968b40b048cb40a22ee690290e4f9c2c8c2e100f5ba105
MATLAB
407
12
function bytes=SONItemSize(fh, chan) % SONITEMSIZE returns the size of a data item on the specified channel (bytes) % % BYTES=SONITEMSIZE(FH, CHAN) % where FH is the SON file handle and CHAN is the channel number % (0 - SONMaxChan()-1) % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Autho...
7f199d52d7a281648d8c071354ccff526d646419a6c794f0483ed67c48934a89
MATLAB
408
18
% testradiipupil % Test pupil radius parameters for initial search function [pupilStart] = testradiipupilmanual_APP(app, img) % Camera 1 figure('units','normalized','outerposition',[0 0 1 1]); clf imagesc(img); colormap(gray); axis image;box off %% Get pupil center manually disp('Click on pupil center') [x, y] = ...
877a70c315ce2cd6bbd57e2cf36c352cef283c7ac0553cdf13d0362964dff486
MATLAB
408
18
function n=num_edges(A) % NUM_EDGES The number of edges in a graph. % % n = num_edges(A) returns the number of edges in graph A. % % For symmetric/undirected graphs, the number of edges returned is twice % the number of undirected edges. % % Example: % load graphs/dfs_example.mat % n = num_edges(A) % % See als...
8c025189bfa3f24723d4bd386db538bef7a1059877c45d941b87e7345dadca7c
MATLAB
408
17
function g = fmri_doublegamma(t, d1, d2, c) % Calculates the double-gamma HRF at point T using parameters D1, D2 and C % defaults: D1 = 6 sec; D2 = 12 sec; C = 0.35. % % g = fmri_doublegamma(t, d1, d2, c); % % example: % g = doublegamma(0:.125:25); if nargin<4 c=.35; end if nargin<3 d2=12; end if nargin<2 d1=6; end ...
a7f99f9add2a473fd3f4d88972704dfc76f4edff86abdecd7f9f89b93968508e
MATLAB
408
20
function [ff, row, col, lastRow] = getff(ff, uu, Nrows, Ncols) %returns the row and col for multiple figures plots % uuRow = floor(uu/(Ncols+0.1))+1; row = mod(uuRow,Nrows); if row==0, row=Nrows; end; col = mod(uu,Ncols); if col==0, col=Ncols; end; if mod(row,Nrows)==1 && col==1, ff=ff+1; % pause(0.2...
5039eaf1a238db616d03f66c2cc6f585e1560881e59b31ddd733830307b094a0
MATLAB
409
13
function SONSetChanComment(fh, chan, str) % SONSETCHANCOMMENT sets the channel comment % FH = SON file handle % CHAN = channel number (0 to Max-1) % str = string with new comment % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 global SON_CHANCOMSZ; str=str(...
afe8bc4f7e7973dc57c80103447c095d1a7e87f67947ac3e1231aae11527fd94
MATLAB
409
12
%%%associate string with a number function StrOut = create_string_from_num(vec_in,num_range,string_range) % num_range = [ 1,2,3,4,5] ; % string_range = {'AA','B','CCC','D','EEE'} ; % vec_in = [3 6 4 6 3 1 9 9 0 4 4 1 3]; % note the 0! % engine to convert ValuesIn to StrOut StrOut = repmat({'Unknown'},size(...
b4fe12b1e810e5757a244fb0162117c00fb3a2b87ad425ef60487ddec323bd1e
MATLAB
410
10
function [balancedAccuracy] = balacc(y,ypred) %BALACC Summary of this function goes here % Detailed explanation goes here cm = confusionchart(y, ypred); TP = cm.NormalizedValues(2,2); TN = cm.NormalizedValues(1,1); FP = cm.NormalizedValues(1,2); FN = cm.NormalizedValues(2,1); sensitivity = TP/(TP+FN...
4b68fcd82d4f4a5544458f5642961536da28f432d9f0d3394c28f528cecc0450
MATLAB
412
9
function edges = meshconnee(t) % This function establishes all edges of a triangular mesh given its % t-array. The result will be sorted. % % Copyright (C) 2004-2012 Per-Olof Persson. (See DISTMESH) edges = [t(:,[1, 2]); t(:,[1, 3]); t(:,[2, 3])]; % All edges duplicated edges ...
4b16bed5093c9a8e941e777673afa8eacd77284c2906f4d2c4e3f21329027b88
MATLAB
413
18
function test_results=display_significance_results(p_value) %%%% displays the results of z-test if isnan(p_value) test_results=''; end if p_value<0.05 && p_value>=0.01 test_results='*'; elseif p_value<0.01 && p_value>=0.001 test_results='**'; elseif p_value<0.001 ...
4e97b5c039a3b4bbeb097914c9fdd0c96d27d4214c9a78782b8880344b5b30f2
MATLAB
413
14
function blobIm = Blob2Image(blob, im) % function blobIm = Blob2Image(blob, im) % % converts a blob to an image which can be displayed. % Crop region blobIm = im(blob.rect(1):blob.rect(3), blob.rect(2):blob.rect(4),:); % Multiply with mask if isa(im, 'uint8') blobIm = blobIm .* repmat(uint8(blob.mask),...
9a98f1eac60c9b90d43c587e39c1e48e0e1b10ece1b4b85abf876871582aae75
MATLAB
413
17
% Generate fake data using FA model % Data dimensionality: 20 % Latent dimensionality: 5 params.L = randn(20, 5); params.Ph = 0.1 * (1:20)'; params.mu = ones(20, 1); X = simdata_fa(params, 100); % Cross-validation dim = crossvalidate_fa(X); % Identify optimal latent dimensionality istar = ([dim.sumLL] == max([dim.s...
cc69ac5254a51ffb61e85955e4ecb4d6382e5448c85bc499dda801249516c1f1
MATLAB
413
16
function spikeDensityFunction = calc_spikeDensityFunction_sawtooth(spikeTimes, kernel_sd, samplerate) % Get Data spikeTimes = round(spikeTimes * samplerate); binned = zeros(spikeTimes(end),1); for i = 1:length(spikeTimes) binned(spikeTimes(i)) = 1; end % Kernel edges = -5 * kernel_sd : 1/samplerate : 5 * kernel_...
446dd0727cb32aec446de6bb3252b4fa880a7265b8638cf75af04897d41cbfa6
MATLAB
414
7
function result = folder_names_matching_template(parent_folder_name, template) % Return folder names matching the template within parent_folder_name s_from_file_index = dir(fullfile(parent_folder_name, template)) ; name_from_file_index = { s_from_file_index.name } ; is_folder_from_file_index = [ s_fr...
eccc9a6c77b886a49f0e360a3f8970919afb20a731441541459c331a42ca3d5d
MATLAB
414
24
function results = vl_test_plotbox(varargin) % VL_TEST_PLOTBOX vl_test_init ; function test_basic(s) figure(1) ; clf ; vl_plotbox([-1 -1 1 1]') ; xlim([-2 2]) ; ylim([-2 2]) ; close(1) ; function test_multiple(s) figure(1) ; clf ; randn('state', 0) ; vl_plotbox(randn(4,10)) ; close(1) ; function test_style(s) figure...
723caf847d2cde7169bf9844c2f6b516c3e0879feab9d1062d9c765f04857bd6
MATLAB
415
9
function [indexesFold, allIndexes, indImagesTrain, indImagesTest, numImagesTrain, numImagesTest] = computeIndexesPersonFold(numImagesAll, labels, param) indexesFold = personFold(numImagesAll, labels, param.kfold); indImagesTrain = (indexesFold ~= 1); %1 or 2 indImagesTest = ~indImagesTrain; allIndexes = 1 : numImagesA...
99bbfcb9c242cb0db4731bdaf3f28d39410a768c6d62c4cabbf8fb91890a7876
MATLAB
415
20
function plot_ephysFrCsOverview(recData, z, segment_ssfr) figure('Position', [2 557 958 439]) FREphys = tight_subplot(2,1,[.05 .01],[.03 .03],[.01 .01]); axes(FREphys(1)); plot(z.segTime_ssfr, segment_ssfr) if ~isempty(recData(9).data) vline(recData(9).data); end axes(FREphys(2)); plot(z.segTime_e, recData(10).d...
c18fc6544d550fd70bf98999b6915959fdd48445bd00255002b17e2f7b47c0cd
MATLAB
415
17
function spikeTimes = ml_nlx_mclust_load_spikes_64bit(filename) % Load t-files as 32 bits fid = fopen(filename, 'rb','b'); if (fid == -1) error('Could not open t-file %s.', filename); end ml_mclust_readheader(fid); spikeTimes = fread(fid,inf,'uint64'); fclose(fid);...
d025256a505377e26039ffe4290f27eab38d7ac85337895b70047478cd48140e
MATLAB
415
19
function [X] = ml_alg_possible_patterns(symbols, numDraws) X = []; for i = 1:numDraws x = possible_patterns_helper(X, symbols); X = x; end X = unique(X,'rows'); end % function function [X] = possible_patterns_helper(T, symbols) X = []; for i = 1:length(symbols) s = symb...
d7a3099778083504d7a017286b2613ebab88216b80649b5df2633ad5aa181c23
MATLAB
415
13
function ab = termcross(a,b) %TERMCROSS Multiply dummy variables for two terms to get interaction % Copyright 1993-2002 The MathWorks, Inc. % $Revision: 8776 $ $Date: 2009/01/23 15:13:50 $ if (isempty(a)), ab = b; return, end if (isempty(b)), ab = a; return, end na = size(a,2); nb = size(b,2); acols = repmat((1...
a95ceafd03cbd81c8d116c215a4014e1c94b9fac11c58ac016754b6183ecd089
MATLAB
416
10
function [report_data] = report_w(report_data, state) % Reporting function to record w for each iteration % % Copyright (C) 2004, 2005 DSS MATLAB package team (dss@cis.hut.fi). % Distributed by Laboratory of Computer and Information Science, % Helsinki University of Technology. http://www.cis.hut.fi/projects/dss/. % $...
dee72a3237dd5910b3b73e1a8128a5d6a92a8a9bdd09efc6efa43f61f4a28a53
MATLAB
416
12
function p = ml_util_bivariatepdf(s1, s2, m1, m2, rho, xx1, xx2) p = zeros(size(xx1)); for i = 1:size(xx1,1) for j = 1:size(xx2,2) x1 = xx1(i,j); x2 = xx2(i,j); z = (x1-m1).^2 ./ s1^2 - 2*rho*(x1-m1).*(x2-m2)./ (s1*s2) + (x2-m2).^2 ./s2^2; n = 2*pi*s1*s2*s...
03e1edeab3b54e87516ceedfeb8616518b4086c5c2bb15ebc95cce2e5284539c
MATLAB
417
19
function slmetric_pw_compile() %SLMETRIC_PW_COMPILE Compiles the CPP mex files for slmetric_pw % % [ History ] % - Created by Dahua Lin, on Aug 16, 2007 % mdir = fileparts(mfilename('fullpath')); if ~strcmp(pwd(), mdir) cd(mdir); end disp('compile pwhamming_cimp.cpp'); mex -O pwhamming_cimp.cpp ...
1884fa078d23330ee69141dd2721a7d9cca69d927b003013b21c7771bed46b4d
MATLAB
417
12
function [edgesX, edgesY] = ml_it_edges_xy_uniformly_spaced(x,y) x = reshape(x, 1, numel(x)); y = reshape(y, 1, numel(y)); pearsonCorr = corrcoef(x', y'); pearsonCorr = pearsonCorr(1,2); N = length(x); nBinXY = round( 1 / sqrt(2) * (1 + sqrt(1 + (24*N/(1-pearsonCorr^2))))^(1/2) ); ...
259edb740377b9feb9da803dbcd014fee436fe7f46095b4b8f631464eb857a42
MATLAB
417
18
function sdf = plotSpikeDensityfunction(spikeTimes, kernel_sd)%% Spike Density Function %% Get Data ephysSampleRate = 50000; spikeTimes = round(spikeTimes * ephysSampleRate); binned = zeros(spikeTimes(end),1); for i = 1:length(spikeTimes) binned(spikeTimes(i)) = 1; end %% Kernel edges = -5 * kernel_sd : 1/ephys...
2afa6600f7c7863c9725ce85fbffa47d52bdd9898bb991d0d311dde853e17371
MATLAB
417
14
function [behavDataset ] = ml_cai_behav_h5_read(fn) % Reads a 'behav.hdf5' file specified by the filename given in fn behavDataset = ml_cai_core_h5_read_header( fn ); behavArrays = ml_cai_behav_h5_read_timeseries( fn ); arrayNames = fields(behavArrays); numArrays = length(arrayNames); for iF = 1:numArrays arrayNa...
d72ea91d8fed085997cd8af05a03da075e30d0e047bd0e945adb937f47deacd1
MATLAB
417
14
function [scopeDataset ] = ml_cai_scope_h5_read(fn) % Reads a 'scope.hdf5' file specified by the filename given in fn scopeDataset = ml_cai_core_h5_read_header( fn ); scopeArrays = ml_cai_scope_h5_read_timeseries( fn ); arrayNames = fields(scopeArrays); numArrays = length(arrayNames); for iF = 1:numArrays arrayNa...
1db34a9491ee429850f9dc6894a834bdeb47801477d849eebcbb2d82ff133a5c
MATLAB
418
12
function [probe] = getTotalModuleCount(probe) %GETTOTALMODULECOUNT Gets the total active modules in a probe % Derives an integer value representing the total number of active % modules in the particular probe. activemoduleidx = probe.modules(:,4) == 1; % indeces of active modules activemodules = probe.modules(act...
dd6cfe17661ed24bbaff2e02ec242efcbf89ad7c7392821938d72ac7c982a298
MATLAB
418
11
function [dwellTimeMap] = ml_placefield_dwelltimemap_v2(xi, yi, median_dt, nbinsx, nbinsy) numSamples = length(xi); % Perform the dwell time by hand because I don't trust MATLAB dwellTimeMap = zeros(nbinsy, nbinsx); for iVisited = 1:numSamples prevCount = dwellTimeMap( yi(iVisited), xi(iVis...
e96c8f63ca024db5d000c3724fb8d49fa3edce94e75ba42ffd15eba797fb1cd3
MATLAB
418
18
function rootPath = stPRFsRootPath() % % Return the path to root VPNL/spatiotemporalPRFs project folder % % This function must reside in the directory base of this code repository. % It is used to determine the location of various subdirectories % % Example: % fullfile(stPRFsRootPath, 'functions') % % By Eline Kupers...
53577c255d9b6038ec20eb499d1bac0ed5819aceff047aa51efbaa7b6bacd96f
MATLAB
420
10
function dspec = addCovariateBoxcar(dspec, covLabel, startLabel, endLabel, desc, varargin) if nargin < 5; desc = covLabel; end assert(ischar(desc), 'Description must be a string'); binfun = dspec.expt.binfun; stimHandle = @(trial, nT) basisFactory.boxcarStim(binfun(trial.(startLabel)), binfun(trial.(endLabel)), binf...
be2c42bdb9f692cfb62b90fb85b96964376d477e6d73dd5a5b7f8079e88736fa
MATLAB
420
6
function [climerICS] = ml_cai_climer_information_rate(bs, probXYS, smoothingKernelXY, trace_x_valid, trace_y_valid, trace_value_valid) traceXY = ml_bs_accumulate_xy(bs, trace_x_valid, trace_y_valid, trace_value_valid); traceXYS = imfilter(traceXY, smoothingKernelXY); meanTraceS = nansum(probXYS .* traceXYS,...
fd5f61f4580ae67f59ae52db8e33216180fd2424a7c1cf1d3584a534205e1c9f
MATLAB
420
19
function [nose, irmv] = useFrames(nose, condtxt); globals; irmv = find(~(eval(condtxt))); % find frames to remove nose.t(irmv)=nan; nose.x(irmv)=nan; nose.y(irmv)=nan; nose.o(irmv)=nan; nose.v(irmv)=nan; nose.s(irmv)=nan; nose.a(irmv)=nan; nose.do(irmv)=nan; nose.do2(irmv)=nan; nose.ddo2(irmv)=nan; nose.o...
1ab0c1fec2137e4558d2ddfb2406d24f2baa32057cd62e55c21740497b69b999
MATLAB
421
14
function ordered_textons = select_diverse_textons(tsim, nt) next_t = zeros(nt, 1); vals = zeros(nt, 1); indices = (1:size(tsim, 1)); for t = 1:nt total_dsim = mean(tsim, 1); [vals(t), index] = max(total_dsim); next_t(t) = indices(index); tsim = tsim([(1:index-1) (index+1:end)], [(1:index-1) (i...
cac2111214d78f1f751bce63ce3ec1ec341e247167da774c5ca3a99179520c99
MATLAB
421
7
% Marc Normandin, Muzzio Lab, Psychological & Brain Sciences, University of Iowa, 2024 function [hFig] = plot_per_day_cell_averaged_rate_difference_matrix(DaysToSessions, RateMatrices, perCellNormalizationMethod) T = compute_per_day_cell_averaged_rate_difference_matrix(DaysToSessions, RateMatrices, perCellNormaliz...
ff05d2554a4666975cb68ca0078adceeca51f5154a71e38d53ac83b4cfa1046c
MATLAB
421
12
function UpdateInterpolateFly(handles) % update a fly's position during interpolation % splintered from fixerrorsgui 6/23/12 JAB fly = handles.interpolatefly; i = handles.trx(fly).off+(handles.interpolatefirstframe); x = handles.trx(fly).x(i); y = handles.trx(fly).y(i); a = 2*handles.trx(fly).a(i); b = 2*handles.trx(f...