sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
cfc3fbfccf2b434ec3feba493031f5e37f5b69e9313ec56a547497ec862af463
MATLAB
337
18
% trkPath.m % % Helper function that returns path to folder with .trk files (APT output) % % INPUTS: % none % % OUTPUTS: % trkDir - full path to folder containing .trk files % % CREATED: 9/24/21 - HHY % % UPDATED: % 9/24/21 - HHY % function trkDir = trkPath() trkDir = '/Users/hyang/Dropbox (HMS)/APTlegTrackin...
28c8ccfab1e0af08386de33033954875f9e45449b1f6783f33e28271c526ac55
MATLAB
338
12
function union = BoxUnion(a, b) % union = BoxUnion(a, b) % % Creates the union box of two bounding boxes. % % a: Input bonding box "a" % b: Input bounding box "b" % % union: Intersection of box a and b union = [min(a(:,1),b(:,1)) min(a(:,2),b(:,2)) ... max(a(:,3),b(:,3)) max(...
534082e9be06bf0558135d42360ba4d17e07b4c980a99494e6d44043acefe5ac
MATLAB
338
13
function ret=SONUpdateStart(fh) % SONUPDATESTART flushes the SON file header to disc % % RET=SONUPDATESTART(FH) % where FH is the SON file handle % % Returns zero or a negative error % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 ret=calllib('son32', 'SONU...
13fee737ad6a516e58c9399179153c49e8de37ca7566901b78665cf6aedb91f8
MATLAB
339
12
% Tests a filter mask structure for active layers % % Implemented through SONFEqual.dll % % ANS=SONFEQUAL(FILTERMASK) % % Sets bits 1 to 4 in the output if layers 1 to 4 of the filter mask % do anything i.e. have cleared bits % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's Colleg...
2d65fd2cafbc5a385ddd2e69aba2c96b6bb5cbb4f45bf028800495800151acd4
MATLAB
339
7
function vidAmp = vidTimeFcn_APP(app, tvid,vidH,freq,tscale) varsTemp = [sin(2*pi*freq*tvid(:)/tscale) cos(2*pi*freq*tvid(:)/tscale) ones(size(tvid(:)))]; yTemp = [0; diff(vidH)]/mean(diff(tvid)); mask = abs(yTemp)<100; bVidTemp = regress(yTemp(mask), varsTemp(mask,:)); vidAmp = -sqrt(bVidTemp(1)^2+...
6067c62f3232ef059cdf5c5c719c7fd7fbad57057b8b2cae74da19523322bcbf
MATLAB
339
9
% mglMetalClose: Close mglMetal windows. Usually called from mglClose % % usage: mglMetalClose % by: justin gardner % date: 09/27/2021 % copyright: (c) 2021 Justin Gardner (GPL see mgl/COPYING) % purpose: Closes an mgl Metal window - typically called from mglClose % usage: mglMetalClose func...
7007dc55566243e3bce9f89dba70c039ae58fe99aab44c85d29c6344fc440b68
MATLAB
339
14
function b = loadobj(a) % loadobj for file_array class % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: loadobj.m 8776 2013-11-14 09:04:48Z roboos $ if isa(a,'file_array') b = a; else a = permission(a, 'rw'); b =...
95949d8277a22d35f24d8ee3080414870d666d1109e5041e2ab34160feed8eeb
MATLAB
340
8
function dspec = addCovariateRawMatrix(dspec, covLabel, desc, varargin) % Add the continuous covariate without basis function (instantaneous rel) if nargin < 3; desc = covLabel; end % assert(ischar(desc), 'Description must be a string'); dspec = buildGLM.addCovariate(dspec, covLabel, desc, basisFactory.rawStim(covLa...
a5bf4bd1ad2da2f0a8c36acef168af0a83cefafa24946675111e1f4042eb1fc5
MATLAB
341
13
function [meanAngle] = ml_alg_circ_mean(d) % Compute the mean angle (circularly) rx = 0; ry = 0; for i = 1:length(d) rx = rx + cosd(d(i)); ry = ry + sind(d(i)); end meanAngle = atan2d(ry, rx); % this will be -180 to 180 if meanAngle < 0 meanAngle = meanAngle + 360; ...
5e588cb1e50dff2027259d219b3da1670b8ea952b91eadf44a10c00011bf2e28
MATLAB
342
11
function vfTrace_dFF0 = calc_dF_F(vfTrace) % 'vfTrace' is a vector of raw fluorescence values for each frame. Compute % the 'F0' value, which is the median of the trace. Then compute (F-F0)/F0, % and return the result in a variable 'vfTrace_dFF0'. medianVal = median(vfTrace); vfTrace_dFF0 = (vfTrace - medianVal) / m...
8151f8bd46a4ab4c1f72a3901e25426616944f440a037955c5171e48fa7580a8
MATLAB
342
13
function[ds_events]= load_ds_events(type) if strcmp(type,'standard') if ismac ds_events=load('/Volumes/Runyan2/Christian/Processed Data/Event Analysis/standard_ds_onsets.mat'); else ds_events=load('Y:\Christian\Processed Data\Event Analysis\standard_ds_onsets.mat') end ds_events=ds_ev...
d5dbbffd58ff5d1f27d1c386b142728057b541680d82a578358ed19f3e9b8d1a
MATLAB
342
18
% testIInj.m function [iInjOut, iInjParams] = testIInjFn(settings, durScans) outDur = 20000; iInjParams = []; out = (linspace(-2,2,outDur))'; numRep = floor(durScans / outDur); remainder = mod(durScans, outDur); iInjOut = repmat(out,numRep,1); iInjOut = [iInjOut; out(1...
58c7a5e27f24f22130f569e64b63eed25af1aba389f95a391087af53a46e47ba
MATLAB
343
16
function [list_contents] = read_list(fname) % loads the contents of an old list to a cell array fid = fopen(fname,'r'); finished = false; list_contents = {}; while ~finished thisLine = fgetl(fid); if isnumeric(thisLine) && thisLine==(-1) finished = true; continue; end list_contents{end+...
67660fe40eee17dc79614fd3df4474bb309b8240d57c14587a2bcaa49e2ea549
MATLAB
344
16
no = 6; ss = 1; ns = 2; sc = sqrt(2); el = 2; fb = fbCreate(no,ss,ns,sc,el); for k = [32 64 128], tex = unitex(fb,k); tsim = textonsim(fb,tex); [tim,tperm] = visTextons(tex,fb); save(sprintf('unitex_%.2g_%.2g_%.2g_%.2g_%.2g_%d.mat',... no,ss,ns,sc,el,k),... 'fb','tex','tsim',...
1977f039d9398a9701deabf18a53a4a05d344c0be08b824995a77eb3e6b25aac
MATLAB
345
11
function paddedData = padBlockDataWithNaNs(dataIn, nrTRs) unevenTRs = cellfun(@(x) find(length(x)~=nrTRs), dataIn,'UniformOutput',false); paddedData = dataIn; for ii = 1:length(unevenTRs), if ~isempty(unevenTRs{ii}), diffTRs = nrTRs-length(paddedData{ii}); paddedData{ii} = cat(1,paddedData{ii},NaN...
4f64fe937bb956c290a6f653a4fcc3fcd7a82360700d330e1f234249d0756fae
MATLAB
345
18
function Rsq = linearityScatterPlot(vec1, vec2, keep, c) x = vec1(keep); y = vec2(keep); fit = polyfit(x,y,1); range = linspace(min(x),max(x),100); yfit = fit(1)*range + fit(2); R = corrcoef(x,y); Rsq = R(1,2).^2; scatter(vec2(keep), vec1(keep), 4, c(keep), '.'); hold on plot(yfit, range, 'k', 'lineWidth', 2); colo...
86e8a2f6c5b47f5a907488ea103be142b369f10b966ecaccb431fc047d838a32
MATLAB
345
11
% Author: Zachary Chiang, Buenrostro Lab, Harvard University % Uses BioFormats bfGetPlane to get an image given a reader, series, % z-slice, channel, and timepoint function[img] = readPlane(reader, series, z, c, t) reader.setSeries(series - 1); plane = reader.getIndex(z - 1, c -1, t - 1) + 1; img = bfGetP...
65d5b9284c1a75c9d09a9b3a79580faaa415c177ac6c30563ba4321e3940524d
MATLAB
346
17
function b = NormalizeArray(a) % Normalizes array a. This means that the minimum value will become 0 and % the maximum value 1. % % a: Input array. % % b: Normalized output array minVal = min(a(:)); maxVal = max(a(:)); diffVal = maxVal - minVal; b = a - minVal; if diffVal ~= 0 ...
d7290a556265c8c995ed0264eb97d426b115b30c9e12374f72ad0d3d275d7bb2
MATLAB
347
11
function handles = OpenFiles_cluster(fullFileName, handles) %% Authors: Jiri van Bergen and Xu Li % Affiliation: Radiology @ JHU - Kirby Center % Contact via xuli@mri.jhu.edu % cluster version if exist(fullFileName, 'file') handles.TableDatasets.Data = { fullFileName, handles.textReadyLoad }; handles...
4773f12d94aac9467e296bfdcfc2bedee78def18885b60f9b3cd240ceb565f6b
MATLAB
348
28
function file_exist=my_check_file(cache_file, be_quite) if nargin<2 be_quite=true; end if exist(cache_file, 'file') file_exist=true; if ~be_quite fprintf('file exist:%s\n',cache_file); end else file_exist=false; if ~be_quite fprintf('file not exist:%s\n',cache_...
e0d0b9a4c4383ac02cbcbbc6a1832f8351e4a9dccfdf2b3a2ec66a5c7b1d38ec
MATLAB
348
21
function y=file2str(x) %FILE2STR reads textfile intoa single long string % % Syntax: y=file2str(x) % % Description % x is a filename % y is the long string with all contents % % Jonas Almeida, almeidaj@musc.edu, 30 June 2003, MAT4NAT Tbox fid=fopen(x,'r'); i=1; while ~feof(fid) y{i}=fgetl(fid); i=i+1; end ...
51398da171f70de8a3b77b23d98f3b96b26de8fdc71c9dab7976148262880a90
MATLAB
349
16
function t = fieldnames(obj) % Fieldnames of a file-array object % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: fieldnames.m 8776 2013-11-14 09:04:48Z roboos $ t = {... 'fname' 'dim' 'dtype' 'offset' 's...
8b1416e9347ef985d06b9b46fbf20049f0aaa8f0b45e2ead4dbfcc58ae15da5a
MATLAB
349
12
function SONCommitFile(fh, bDelete) % SONCOMMITFILE flushes data to disc % FH is the SON file handle % BDELETE ,if non-zero, causes the data buffers to be deleted % % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 calllib('son32','SONCommitFil...
33dd2c3ccdba67198dc8c07e97acb3766aa401c59ab40c07eb18de8093ef9939
MATLAB
350
20
% % Computer the average distance in a network. % % PARAMETERS % $network % % INPUT FILES % dat/hopdistr.$network % % OUTPUT FILES % dat/statistic.meandist.$network % network = getenv('network'); data = load(sprintf('dat/hopdistr.%s', network)); x = konect_diammean(data); save(sprintf('dat/statistic.meandist.%...
500ac5f070471a326b8c31a8229d671a8cfbf65d72576845f5a65af39834e0ac
MATLAB
350
13
function ret=SONUpdateStart(fh) % SONUPDATESTART flushes the SON file header to disc % % RET=SONUPDATESTART(FH) % where FH is the SON file handle % % Returns zero or a negative error % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & King's College London 2005-2006 ret=calllib('s...
f5c04a50dcdf32e708f27dd5d7338a391ae746f50d2b4787f5ce09a8849b6ec1
MATLAB
350
12
% Tests a filter mask structure for active layers % % Implemented through SONFEqual.dll % % ANS=SONFEQUAL(FILTERMASK) % % Sets bits 1 to 4 in the output if layers 1 to 4 of the filter mask % do anything i.e. have cleared bits % % Author:Malcolm Lidierth % Matlab SON library: % Copyright © The Author & Ki...
3b919384028d61edf4f0887a169df257aefea8ea143048b76e194a8f24832cfd
MATLAB
351
11
function [subFolders] = mulana_util_get_subfolders(searchFolder) files = dir(fullfile(searchFolder)); subFolders = {}; for i = 1:length(files) if ~any([strcmp(files(i).name, '.'), strcmp(files(i).name, '..')]) if files(i).isdir subFolders{end+1} = files(i).name; ...
6f3e716374decbccd38835d45639be808270d604e14477bdc5c93b31192e17d5
MATLAB
351
13
function im = superpixel2im(segments, values) labelNum = length(unique(segments)); [height, width] = size(segments); sz = height * width; [~,dims] = size(values); im = zeros([height, width, dims]); for i = 1 : labelNum, idx = find(segments == i); for j = 0 : dims - 1, im(idx + j * sz) = values(...
d9704497300becfa785b2193fa6c3357e6e64a7d6029f898ac471e920b91b788
MATLAB
352
16
% % This is the additive normalization used. This function also knows % which type of networks need normalization or not. % function [U V] = means_best(T, m, n, weights) %%consts = konect_consts(); [negative interval_scale] = konect_data_weights(); if interval_scale(weights) [U V] = means_euv(T, m, n); els...
e04ef3b675c00a305d747cdc9b000d0889f936cb002af1134dfe10e41fde0019
MATLAB
352
13
function success = delete_tracks(folder_name) %delete the tracks given folders disp(folder_name) deletePath = [folder_name, filesep, 'analysis']; if exist(deletePath, 'dir') %delete the previous track variables by deleting the analysis %folder delete([deletePath, filesep, '*.*']); ...
160dc6bfea627114a9317a1e0fe9cb4c24723546307f841b177ec8f172478721
MATLAB
353
13
function rungibbscorrection(gibbsdir,root,DKIroot) addpath(genpath(DKIroot)); addpath(gibbsdir); nii = niftiread(fullfile(root,'dwidn.nii')); dwi = double(nii); params = [1 3 20]; dwigc = unring(dwi,params); info = niftiinfo(fullfile(root,'dwidn.nii')); info.DataType = 'double'; niftiwrite(dwigc, fullfile...
49cc4eea49669ab0ae3142224fb8dbe482a8773e48894b6d08475ddea53fc783
MATLAB
353
14
% mydisp.m % % usage: mydisp(str) % by: justin gardner % date: 06/03/08 % purpose: prints w/out newline and with a flush % function mydisp(str) % if this is being called it means the mex file doesn't exist, % so just print out (this won't flush though--preventing updating % text print outs like f...
8657f4c35fd9a393cf7debf95f2a19fa4da84c3e9f263ef04358cc9dfc7842f8
MATLAB
353
16
function [head,tail] = period(r,multiFreq) %PERIOD Get last period % Detailed explanation goes here head = zeros(5,1); tail = zeros(5,1); if multiFreq idx = 2; else idx = 1; end for i = 1:5 [pks,locs] = findpeaks(r(1,:,i)); head(i) = locs(end-idx)-(locs(end)-locs(end-1))/2; tail(i) = locs(end)-(lo...
19dcb26df47d6908dcaa5a99bf181424856632b4f3beadc265d59b7368fbe740
MATLAB
354
12
function parsave(filename, varargin) if strcmp(filename(end-3:end), '.mat') var_names = cell(1,length(varargin)); for i = 1:length(varargin) eval(sprintf('%s=varargin{%d};',inputname(i+1),i)); var_names{i} = inputname(i+1); end save(filename,var_names{:}, '-v7.3'); else error('filena...
660df36fd9d66d3453d796595a5b70da588ef90f24df03562ffded9e303e466b
MATLAB
354
9
function helper_bfo_save_total(outputFolder, total, rotDeg) if ~exist(outputFolder, 'dir') mkdir(outputFolder) end outputFilename = fullfile(outputFolder, sprintf('bfo_%d_total.mat', rotDeg)); fprintf('Saving best fit orientation data (total) to file: %s\n', outputFilename); save(output...
6a0e86fd86f5ba79a6ae6f96379110955483a2c41ea60db8cbd56ac86b15b45c
MATLAB
354
11
<<<<<<< HEAD function [FMR] = computeFMR_classic(imsVector, REJnira, threshold) FMR = length(find (sort(imsVector) >= threshold)) / (length(imsVector)); ======= function [FMR] = computeFMR_classic(imsVector, REJnira, threshold) FMR = length(find (sort(imsVector) >= threshold)) / (length(imsVector)); >>>>>>> 5aa7404...
6dcd236e7960c9d2ac9720fb10132dfb6f1a6e8da1a4acf767a283e946f8eb0d
MATLAB
354
21
clear; clc; % candidate = [0.25, 0.5, 1, 2, 4, 8]; % for i = 1:length(candidate) % ratio_sens_attn = candidate(i); % search_reduce_L46; % end % candidate = [6, 12, 32, 64, 128]; % for i = 1:length(candidate) % ratio_sens_attn = candidate(i); % search_reduce_L4; % end search_onlyA_blockL6E_L4E; clear...
a53ffd7ae6872f6b339870ff4ffd917067a99b197ab447eace93abb2d44def1c
MATLAB
354
14
function CE_int = xls_create(MNE_out) CE_int = readcell('16chs_rack_input.xls'); row_dis = ones(1,32); dI_dt_fin = MNE_out.dI_dt/1e6; int_MSO_tmp = 100*dI_dt_fin/140; int_MSO = upsample(int_MSO_tmp,2); CE_int(3,6:37) = mat2cell(floor(int_MSO),row_dis); CE_int(2,1:36) = mat2cell(zeros(36,1),ones(36,1)); writecell(CE...
669220d7b228ba96eaac61c1e8c1063d7d136e0842bac8e5447c62fd4b5c5e3b
MATLAB
355
15
function img_data=load_img_from_ds_info(img_data_info, img_idx) assert(~isempty(img_idx)); img_file=img_data_info.img_files{img_idx}; one_data_dir_idx=img_data_info.data_dir_idxes_img(img_idx); one_data_dir=img_data_info.data_dirs{one_data_dir_idx}; full_img_file=fullfile(one_data_dir, img_file); img_data=read_im...
98aea69f514a4897992406bf53ec49ecc21c32a68bd289e08f137e04a178dbca
MATLAB
355
13
function checkSet(pname, namedprops, constraints, val) if isempty(val) return; end assert(isa(val, 'types.untyped.Set'),... 'NWB:CheckSet:InvalidType',... 'Property `%s` must be a `types.untyped.Set`', pname); val.setValidationFcn(... @(nm, val)types.util.checkConstraint(pname, nm, namedprops, constra...
b71bf4f761ab79c314dab80498c798d1f2efe70ac4bf96e2755095a817e36fcd
MATLAB
356
23
function ynn_v = ValNLSNLD(Imat_v,dsr_init,nn_stat,nn_dyn,Xi,Ai,tv,no) u = Imat_v; y_s = sim(nn_stat,u); X = tonndata(y_s,true,false); yv = nn_dyn(X,Xi,Ai); yn = zeros(no,tv-1); for i = 1:tv-1 yn(1:no,i) = yv{i}; end ynn_v = zeros(tv,no); ynn_v(1,1:no) = dsr_init; for i = 1:no ynn_v(2:...
592969f1fbe2cc133a3ee45d7d7c580ba764baf0c97ee91620f18947fd11a1f2
MATLAB
357
13
function plot_wseries(wavelength_stack,info) clims = [0 250]; colormap gray imagesc(squeeze(wavelength_stack(length(info.pockels),length(info.wavelengths),:,:)),clims); set(gca, 'box', 'off','XTick',[],'YTick',[],'fontsize', 14) title(info.identities) %%title ([num2str(info.identities{length(info.pockels),length(inf...
9e0cc4679f91445a2a451188876c64908b4e8a9fa2275956ab15446c5bf1ed32
MATLAB
357
14
function v = ang2vec(theta, alpha) % v = ang2vec(theta, alpha) used to calculate the vectors from azimuth and elevation angles. % note that 'theta' is nagative actual azimuth angle. Theta and alpha are % in degrees. % % Author: Wei Zhao % %% a = (cosd(alpha).*cosd(theta))'; b = (cosd(alpha).*sind(theta))'; c...
269efddff7fb0ccd4beb2090333d887fe0e92888cf3a26131d2d7b8c3d07bfb3
MATLAB
358
15
function y = demean(x) % simple routine to removes the mean value from the vector X % or the mean value from each column, if X is a matrix. % % Cyril Pernet % --------------------------------- % Copyright (C) Corr_toolbox 2014 n = size(x,1); if n == 1 x = x(:); % If a single row, turn into column vector end N = si...
570e5d3905981281e6f5dbf84138bca40b8f31ed4267bc29755ebee47aac9693
MATLAB
358
17
function smoothed_dff_z = preprocess_pop_activity(dff,varargin) if isempty(varargin) dff_z = zscore(dff')'; summed_dff_z = sum(dff_z); smoothed_dff_z = smooth(summed_dff_z,30,'boxcar'); elseif strcmp('avg',varargin{1}) dff_z = zscore(dff')'; mean_dff_z = mean(dff_z,1); smoothed_dff_z = smooth(m...
8f93c58a91dbdfd465f92b4a44a34d71b0edab07ea107e3b59f86d3b47eb2564
MATLAB
358
15
function hdr = empty_hdr % Create an empty NIFTI-1 header % FORMAT hdr = empty_hdr % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: empty_hdr.m 8776 2013-11-14 09:04:48Z roboos $ org = niftistruc; for i=1:length(org), h...
d3854c6a4f00c2dd755da33a0214f9a2f604b46fb4f08159759ab1885c29ebcf
MATLAB
358
15
function [freqs, powers] = psdPeak(signal, maxFreq) % return two list: freqs and power. freqs contains the freqency of the % peak. power contains the psd value of the peak. % signal is time * conditions % return [f, P1] = getPSD(signal, maxFreq); for i = 1:size(signal,2) [pks,locs] = findpeaks(P1(:,i)); powers(i,:) =...
f704c8a4d363a45c0b0c42fee344f2bccacbe0dfa2155e55062716168a712d28
MATLAB
358
16
% Author: Zachary Chiang, Buenrostro Lab, Harvard University % Sets the maximum pixel value of an image based on either an absolute or % percentile based threshold function[O] = capImage(I,val,type) if type == "abs" cap = val; elseif type == "prc" cap = prctile(reshape(I,[],1),val); end ...
d324f3dd01ab2be2c272d6042535c4658bdbca274691e7a5defa5ef43f8d4de5
MATLAB
360
20
% % Compute Pearson correlation error measure. % % RESULT % value Correlation value % % PARAMETERS % p (e*1) Predictions % T (e*3) To be predicted % function [value] = measure_compute_corr(p, T) value = corr(p, T(:,3)); if ~isfinite(value) % An undefined Pearon correlation means constant predictions, so %...
b48b6000ed52e575e80fb945fd191d3fce9a8a48c036aab5da0525d30c0ee973
MATLAB
361
9
function helper_bfo_save_total(outputFolder, total, rotDeg) if ~exist(outputFolder, 'dir') mkdir(outputFolder) end outputFilename = fullfile(outputFolder, sprintf('bfo_%d_placey_total.mat', rotDeg)); fprintf('Saving best fit orientation data (total) to file: %s\n', outputFilename); save...
d52d78533fc1c560310b693c375a8d59b8b48fe618df2c2970054b67702b9ede
MATLAB
361
15
%% load analysis information try % don't load from a file if you don't have to mag1 = vars.mag1; mag2 = vars.mag2; vid = vars.vid; catch try pathname = cd; [~, filenameroot]= fileparts(pathname); load(fullfile(cd, [filenameroot '_analysis.mat'])) catch error('Unab...
e48783d297be6db18ee332e3b2de644ece29a195564d77947c1ddabae44be23b
MATLAB
361
16
% f_Secs2hms.m [As a part of HFO Detection Project] % Written by: % Miguel G. Navarrete Mejia % Electrical Engineering MS candidate % UNIVERSIDAD DE LOS ANDES % Colombia, 2012 % mnavarretem@gmail.com function v_secs = f_HMS2Secs(pv_HMS) if ~isvector(pv_HMS) && numel(pv_HMS)~=3 v_secs = 0; return...
9f77b0c33a754a0d2bface6bf72081191d0df54019209692a09aaeca65f7d870
MATLAB
362
8
function aAngle = ml_alg_center_out_angle(centerX, centerY, ax, ay) dy = ay - centerY; dx = ax - centerX; aAngle = atan2d(dy,dx); negind = find(aAngle < 0); aAngle(negind) = aAngle(negind) + 360; aAngle = 360 - aAngle; % This is so that in image coordinates, which is what we plot in, the angle i...
5f626e0fe519ccfaf9c7e1912f218f1d45c9748effcf197364757f4fc4b0c9b9
MATLAB
363
16
function [image_data] = load_data() filenames = dir(['.' filesep 'data' filesep '*.fig']); for x = 1:length(filenames) figure = hgload(['.' filesep 'data' filesep filenames(x).name]); children = get(figure,'Children'); l=get(children,'Children'); image_data{x} = l{2}.CDat...
7c344ccad674b5e353114f4905ddb41211eab7ac62ce275730380bcc7b6d08ce
MATLAB
363
20
function ml_cai_cnmfe_plot_cell_timeseries(cnmfe, nid) y1 = cnmfe.RawTraces(:,nid); y2 = cnmfe.FiltTraces(:,nid); y3 = cnmfe.neuron.S(nid,:); si = find(y3 ~= 0); x1 = 1:length(y1); x2 = x1; x3 = x1(si); y3 = y3(si); figure plot(x1,y1,'k-') hold on plot(x2,y2,'m-','linewidth',4) stem(x3,y3,'r') grid on grid minor titl...
895154327d850f30a956d97e6310fef9c80cab90714e856f70791352f951d4ef
MATLAB
363
20
% ftDataDir.m % % Quick function that returns the full path to the data directory on the % FicTrac computer % % INPUTS: % none % % OUTPUTS: % dataDir - full path to data directory on the FicTrac computer, as a % string % % CREATED: 1/8/21 - HHY % % UPDATED: % 1/8/21 - HHY % function dataDir = ftDataDir() ...
c8df10b1546035d3d7b2502cc759751c4d81a1a0a3034b7db4a1f80489bbd866
MATLAB
363
18
function array_str=my_gen_array_str(values, num_pattern) if nargin<2 num_pattern='%d'; end array_str='['; for f_idx=1:length(values) if f_idx>1 array_str=cat(2, array_str, ','); end array_str=cat(2, array_str, sprintf(num_pattern, values(f_idx))); end ...
1c07e5bf53f17b72d5095f83b7fba02a8b9de74824d4369f2fa7c43470d84728
MATLAB
364
23
function ynn_v = ValNLSNLD4SerECNN(Imat_v,dsr_init,nn_stat,nn_dyn,Xi,Ai,tv,no) u = Imat_v; y_s = sim(nn_stat,u); X = tonndata(y_s,true,false); yv = nn_dyn(X,Xi,Ai); yn = zeros(no,tv-1); for i = 1:tv-1 yn(1:no,i) = yv{i}; end ynn_v = zeros(tv,no); ynn_v(1,1:no) = dsr_init; for i = 1:no ...
1cf6ef3357d3b7550ee411e42b2446880916f0d5b844a60c6409f1ff303c0140
MATLAB
364
11
% Marc Normandin, Muzzio Lab, Psychological & Brain Sciences, University of Iowa, 2024 function [entropy] = ml_alg_entropy_image(I) % Ia and Ib must be discrete valued ind = double(I(:))+1; hist = accumarray(ind, 1); prob = hist ./ numel(ind); indNoZero = hist ~= 0; prob1DNoZero = prob(indNoZero); entropy = -sum( ...
2887a95e16493a92fdd4ec85028906b6319fac3a6a3cdfe7e751069e0ad079b1
MATLAB
364
6
function result = escape_string_for_bash(str) sq = '''' ; % a single quote sq_bs_sq_sq = '''\''''' ; % single quote, backslash, single quote, single quote str_escaped = strrep(str, sq, sq_bs_sq_sq) ; % replace ' with '\'' result = horzcat(sq, str_escaped, sq) ; % Surround with single quotes to handle...
75a7dbaf9de2280dbfcbaf86efe7e587fcabc2899e4e8ea7be04103795e07475
MATLAB
364
9
function [traceMap] = ml_cai_placefield_tracemap(sxi, syi, nonuniformTrace, nbinsx, nbinsy) % Perform the counts by hand because I don't trust MATLAB numi = length(sxi); traceMap = zeros(nbinsy, nbinsx); for i = 1:numi prevCount = traceMap( syi(i), sxi(i) ); traceMap( syi(i), sxi(i) ) = ...
a965208abc408e0065187f01a209d0bd28425573eb0397a47088f6c5bbd6b7a3
MATLAB
364
9
% Marc Normandin, Muzzio Lab, Psychological & Brain Sciences, University of Iowa, 2024 function [mutualInformation] = ml_alg_mutual_information_images(Ia, Ib) % Ia and Ib must be discrete valued Ea = ml_alg_entropy_image(Ia); Eb = ml_alg_entropy_image(Ib); Eab = ml_alg_joint_entropy_images(Ia, Ib); ...
3feb4a9114a9329720da806328dbb8b0a339b1d41b95d79ddf039b4ab54473b4
MATLAB
365
9
function helper_bfo_save_percell(outputFolder, perCell, rotDeg) if ~exist(outputFolder, 'dir') mkdir(outputFolder) end outputFilename = fullfile(outputFolder, sprintf('bfo_%d_percell.mat', rotDeg)); fprintf('Saving best fit orientation data (per cell) to file: %s\n', outputFilename); sa...
251bf2a756473d5c91bacbcd29a03f82c56a34e6bf90304672a6fa7f6bed1a98
MATLAB
366
16
function [xs] = runFiltFilt(x,smooth_info) %runFiltFilt.m % accepts either filter designer object % or structs w/ coefficients if isobject(smooth_info) % assumes FIR xs = filtfilt(smooth_info.numerator,1,x); elseif isstruct(smooth_info) xs = filtfilt(smooth_info.b,smooth_info.a,x); else error('expe...
37c19d3a1f3f47490df7e10304afaa65de7e28a4a298a78d7ad8865760119c80
MATLAB
366
24
function cnn_update_net_group(net_config, update_fn, update_opts) assert(~isempty(net_config)); group_num=length(net_config.ref.group_infos); for g_idx=1:group_num one_group_info=net_config.ref.group_infos{g_idx}; one_group_info=update_fn(one_group_info, update_opts); net_config.ref.gr...
d459e2793c0c009e3067060fd6b6d2cecaa6a43e947291fd1b1620518006305f
MATLAB
367
14
function [position] = ml_cai_behavtrackvid_h5_read( filename ) if ~isfile(filename) error("Cannot read from (%s) as it does not exist.", filename); end pi = h5read( filename, '/pos_vid_pixel_i'); pj = h5read( filename, '/pos_vid_pixel_j'); position.x = pi; position.y = pj; position.timestamps_ms = double(h5read(...
d812e7901753f9f9c700483a1f219150936414879437797f96c6765192471e65
MATLAB
367
16
function [groups] = helper_bfo_percell_get_groups(perCell) fn = fields(perCell); t = strfind(fn, 'prob_'); inds = []; for i = 1:length(t) if length(t{i}) > 0 inds(end+1) = i; end end groups = {}; for i = inds g = fn{i}; s = split(g, '_'); g...
0eb6e9d667c967f436ac17b591e0386f3350ee4228bb70a4653bab8709828a14
MATLAB
368
8
function [binSystem] = ml_egomaps_binsystem_create(RADIUS_CM, cm_per_bin) % This creates a bin system for the egocentric coordinates boundsx = [-RADIUS_CM, RADIUS_CM]; boundsy = [-RADIUS_CM, RADIUS_CM]; cm_per_bin_x = cm_per_bin; cm_per_bin_y = cm_per_bin; binSystem = ml_bs_create(boundsx, bound...
3f558cb97224af423e8522f1204ffe04f11b19711e25539edecdbd614ec14b83
MATLAB
368
14
function out = numeric(fa) % Convert to numeric form % FORMAT numeric(fa) % fa - a file_array % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: numeric.m 8776 2013-11-14 09:04:48Z roboos $ [vo{1:ndims(fa)}] = deal(':'); out ...
c99b518b1a87dfa84f577b561b04b7acaf798570d7bb4ae429be5eaeed2af254
MATLAB
368
14
function [ax] = plotRRM(matrix) ax = imagesc(matrix); line([.5 .5 6.5 6.5 .5],[.5 6.5 6.5 .5 .5], 'color', 'k', 'linewidth', 3); line([6.5 6.5 12.5 12.5 6.5],[6.5 12.5 12.5 6.5 6.5], 'color', 'k', 'linewidth', 3); %axis ij; daspect([1 1 1]); yticks(1:12); xticks(1:12); xlabel('trial b'); ylabel('trial a'); colormap je...
186965285b2c819c7a0bfecdb7176f0b1536f62aa3bc24f8763b741360ddfb52
MATLAB
369
19
function d = measureLinearity(vec1, vec2, keep) if ~exist('keep', 'var') keep = ones(length(vec1),1); end d.fit = polyfit(vec1,vec2,1); d.range = linspace(min(vec1),max(vec1),100); d.range_Norm = d.range - d.range(1); d.yfit = d.fit(1)*d.range + d.fit(2); d.yfit_Norm = d.yfit - d.yfit(1); d.R = corrcoef(vec1,v...
fcc94950d916b4592459516327270039c48713d61217db38dc431e6397f82ba6
MATLAB
369
13
function Tracks = FilterTracksBySize(Tracks, min_size, max_size) selected_indecies = []; for track_index = 1:length(Tracks) worm_size = mean(Tracks(track_index).Size); if worm_size > min_size && worm_size < max_size selected_indecies = [selected_indecies, track_index]; end ...
ab1776fe286defa6e07fec11f35bf9b43c6747b056d36a759700f95b3b31074b
MATLAB
371
16
% % Compute zero prediction, i.e. always predict zero. % % PARAMETERS % a Adjacency/biadjacency matrix % at (e*2) Vertex pairs for which to compute predictions % format % weights % % RESULT % predictions Struct by subname of (e*1) Predictions % function [predictions] = prediction_local_compute_zero(a, at, format, w...
0f92e7dd3444671f184bc14538fc7041663658a58025312e0a4e3c78d9e12629
MATLAB
372
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; return; end; bloc...
caeff917272596916b77a466b80b1b896e085515777744cd6ff8acd587f68f23
MATLAB
372
16
function [D,entropies] = findListKLDivergences(data,data2) %finds the KL-divergences (D) and entropies between all rows in 'data' and %all rows in 'data2' logData = log(data); entropies = -sum(data.*logData,2); clear logData; logData2 = log(data2); D = - data * logData2'; D = bsxfun...
d7e18638539bea46f045fcfdd63fc5fa2a473f0603a5c5ae8dc09388d9559d98
MATLAB
372
14
% % Return the types that can be passed to distrtest_plot(). % % RESULTS % types Cell array of all type names % function types = distrtest_types() types = {'normal', 'lognormal', 'logistic', 'loglogistic', 'cauchy', 'logcauchy', ... 'gumbel', 'weibull', 'hsd', 'loghsd', 'exp', 'pareto', ... 'gamm...
f307a49284e279dac6e1d81eabf4285150952e3591ccff962be7f935afbe1a45
MATLAB
372
23
classdef avalanche properties label startTime endTime size = 1; %event = []; %first row is the pixel second row is the time duration = 1; merged = false; roots = []; rootTime = []; %avtime = []; end methods ...
66e72634bc63e8a4ed6be57a2c5ae4b422ba4ceeafbfc363f35f5d3590d52cfb
MATLAB
374
7
function text=text_after_reading_path(handles) text=['There are '... num2str(handles.participants.N) ' individual studies listed in this file.',... ' Based on the naming using in the file, the data comes from ',... num2str(handles.participants.unique_ids) ' unique ids and has been processed using ',... num2str(han...
95380233aa767fe27d1ce7535c4d9d9d807e51aa88d90a4efb152d720a482926
MATLAB
374
8
% Marc Normandin, Muzzio Lab, Psychological & Brain Sciences, University of Iowa, 2024 function [SessionsToGroups] = load_sessions_to_groups_table(analysisSettings) if ~analysisSettings.IS_CALCIUM_DATA SessionsToGroups = load_tetrode_sessions_to_groups_table(); else SessionsToGroups = load_calci...
bb82c327378be0cd5de961f0c9fb26bfd621de7c0ac06eb0d2efcc8027341ee8
MATLAB
374
13
function [] = write_log(log_file, log_entry) % write to a specific log file if ~exist(log_file, 'file') fileID = fopen(log_file,'w'); fwrite(fileID,['Script_Name,Status,Time,Folder_Name,JobID,Computer_Name,Comment', char(10)]); else fileID = fopen(log_file,'a'); end fwrite(...
5575f461a0f8814c719d0e346ffa16880f2aca23699d7fe7ef10caa982c4e86b
MATLAB
375
16
function fh=OpenMATFile(filename) % Open MAT file for use by SON library % % This function is called when writing data to a standard MAT-file. % Called from the MATLAB SON library % % Malcolm Lidierth 07/06 % Copyright © The Author & King's College London 2006 file=dir(filename); if isempty(file) MakeMATFile(filen...
89b55704490f7e72276a0ac97a38e7b8a42e6f9d6c81d9a5f7af61f2a54b4e36
MATLAB
375
13
function CM = SymbDistCM(NoSD) % % Colormap used to represent differen Symbolic Distance in % (Di Antonio et al., bioRxiv 2023, DOI: 10.1101/2023.08.03.551859). % % Copyright Maurizio Mattia - Mar. 3, 2023 % PosSD = [255 80 155]/255; NegSD = [70 180 255]/255; % NoSD = 4; CM = flipud((PosSD' * lins...
2ab864e02be5d38d7e25a10c53df2a1ad1e57b4e467512f14ba683ae13613af8
MATLAB
376
24
% plotXYTraj.m % % Function to plot fly's trajectory in x-y space, where time is color coded % % INPUTS: % xPos - x position % yPos - y position % t - time % % OUTPUTS: % none, but generates plot % % CREATED: 12/12/18 HHY % UPDATED: 12/12/18 HHY % function plotXYTraj(xPos, yPos,t) figure; sca...
5d0bee4b14557c5f5182402df0c15f651bf9312d586086df828c150c5bfec410
MATLAB
376
12
% try reading excel file [num,txt,raw] = xlsread('opF rmap summary.xlsx'); Sesname = '20160730Thalamus43_opF_W'; CellGroupName = 'o-t nice graded'; titles = txt(1,:); iSesCol = find(strcmp(titles,'opF Session')) iSesname = find(strcmp(txt(:,iSesCol),Sesname)) iCellGroupCol = find(strcmp(titles,CellGroupName)...
3021468ce4f71f298d637bd16094bd420c90c800a6a465d6da7a215491525115
MATLAB
377
16
function SaveFigureSVG(figname,w,h) % figname: path/name.png for the Figure % w,h: width and height of the Figure (centimeters) if(nargin <2) w = 20; h = 10; end %%%%%%%%%%%%%%%%%%%% fig = gcf; fig.PaperPositionMode = 'auto'; %fig.PaperUnits = 'inches'; fig.PaperUnits = 'centimeters'; fig.PaperPosition = [0 0 w h]...
65afb1d56a97d05c968a5b9f5c90d4d0bdf71afdb298af948bfc18361b80822e
MATLAB
377
11
function [json] = mulana_json_read(filename) % Read in the json file if ~isfile( filename ) error('Cannot read the json file (%s), as it does not exist.', filename); end try json = jsondecode( fileread(filename) ); catch ME error('Error encountered while reading json from (%...
9b966db72f795b02d961a2851e165d1434856aeddc37c0d1f2fbc8f66f4a59a7
MATLAB
377
14
% Marc Normandin, Muzzio Lab, Psychological & Brain Sciences, University of Iowa, 2024 function [rateVector] = calculateMfrVector(s, label) nTrials = length(s.trial); rateVector = nan(1, nTrials); for tr = 1:nTrials idx = strcmp(s.trial(tr).label, label); if ~any(idx) rateVector(tr) = nan; else ...
a7f1916571490de008312908b8dc1260da1c67c0073911343194fd66815fa5fd
MATLAB
377
16
function SaveFigurePNG(figname,w,h) % figname: path/name.png for the Figure % w,h: width and height of the Figure (centimeters) if(nargin <2) w = 20; h = 10; end %%%%%%%%%%%%%%%%%%%% fig = gcf; fig.PaperPositionMode = 'auto'; %fig.PaperUnits = 'inches'; fig.PaperUnits = 'centimeters'; fig.PaperPosition = [0 0 w h]...
330489e7d2263e4a78a29007f0affd59829d2bb15d115ebcdd0c431b721ced4f
MATLAB
378
10
function activate_func_had_fin(SC,OPT_S) % activate final function on SLMs, depending on flags f_mat = rot90(OPT_S.f_fin,2); f_py = OPT_S.f_fin; if(OPT_S.las_SLM_flag == 1) las_SLM_func(f_mat,SC,SC.ramps.fx_laser,SC.ramps.fy_laser,OPT_S.SLM_flag_nearest); end if(OPT_S.cam_SLM_flag == 1) cam_SLM_func(f_py,SC,SC....
942ab82489522389d4ac9ca2cfe21b3d7177e63bb1437f979bc49b4fb8e3289f
MATLAB
378
15
% mglDisplayCursor.m % % $Id$ % usage: mglDisplayCursor() % by: Justin Gardner % date: 02/10/07 % copyright: (c) 2007 Justin Gardner, Jonas Larsson (GPL see mgl/COPYING) % purpose: display/hide cursor % usage: mglDisplayCursor(0) hide cursor % mglDisplayCursor(1) display c...
9651e63d50f7cb341f137b04141514e35f97851d6ec194b9896a3759429c69a2
MATLAB
378
16
N = 10000 ; dimension = 2 ; data = rand(dimension,N) ; numClusters = 20 ; cc=hsv(numClusters); [centers, assignments] = vl_kmeans(data, numClusters); figure hold on for i=1:numClusters plot(data(1,assignments == i),data(2,assignments == i),'.','color',cc(i,:)); end plot(centers(1,:),centers(2,:),'k.','Mar...
a70cb46020f1f728bfc9b50382c3d772f87e57b6e70f42f15230f195c7a8014c
MATLAB
378
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; retur...
aa1b92c2ad165d4986f7980545212333bf7cfe8a2f9ba3f9610a9fe64c17c33c
MATLAB
378
14
% SoftThresh Algorithm % last modified by Lijun Bao 06/23/2013 function [y,s] = SoftThresh(x,t) s = abs(x) - t; s = (s + abs(s))/2; y = sign(x).*s;% % Copyright (c) 2006. Iddo Drori % Part of SparseLab Version:100 % Created Tuesday March 28, 2006 % This is Copyrighted Material % For Copying permissions see...
e4024fdb894fc0af2af1048134cc1e8c7dda130d33553042c962f51ea603a49c
MATLAB
378
21
function im = im2col_general(varargin) % NumInput = length(varargin); InImg = varargin{1}; patchsize12 = varargin{2}; z = size(InImg,3); im = cell(z,1); if NumInput == 2 for i = 1:z im{i} = im2colstep(InImg(:,:,i),patchsize12)'; end else for i = 1:z im{i} = im2colstep(InImg(:,:,i),patchs...
098899348bda96e84826c256dda4ccd869ed47f919991fbcf1d4bdc38d483c46
MATLAB
379
9
function helper_bfo_save_percell_placey(outputFolder, perCell, rotDeg) if ~exist(outputFolder, 'dir') mkdir(outputFolder) end outputFilename = fullfile(outputFolder, sprintf('bfo_%d_placey_percell.mat', rotDeg)); fprintf('Saving best fit orientation data (per cell) to file: %s\n', outputFil...
22753cb3ed24ce381dca75c1924df768e7395e17633f55cffb8cc5e10019461f
MATLAB
379
12
function [timeScaleFactor] = ml_util_timeunit_to_s_scalefactor( timeUnits ) switch timeUnits case 'seconds' timeScaleFactor = 1; case 'milliseconds' timeScaleFactor = 10^3; case 'microseconds' timeScaleFactor = 10^(6); otherwise error('...
768dd5249a67b6d434c185b3896bf4fdae424f53bd01731db9d4c775d9665c3e
MATLAB
379
13
%% Place all *.fig files in a directory called "data" and CD in to the parent directory. image_data = load_data(); new_image = zeros(size(image_data{1})); %create blank array to sum data in to for x = 1:length(image_data) new_image = new_image + image_data{x}; % Sum images end imagesc(ne...
a7c3bd267b31b0b61eb829f72820e2d5b25dd656869e8f68a7eeec31285ac958
MATLAB
379
15
function h = reduce_plot(varargin) % h = reduce_plot(varargin) % % This is a light wrapper function for LinePlotReducer. It accepts exactly % the same arguments, but returns plot handles instead of a LinePlotReducer % object. See 'help LinePlotReducer'. % % Tucker McClure % Copyright 2013, The MathWorks, Inc. lp...
16823f9f134f9d3b22d672e885fc04be5ba9683afe5905a3fef13a64022e86d6
MATLAB
380
11
function remove_previous_result(path_of_script,inx_voxel,voxel_folder,index_snr,simulated_SNRs) directory = [path_of_script filesep 'simulation_data' filesep 'simulation_of_paper_data' filesep voxel_folder{inx_voxel} filesep 'simulated_SNR_' num2str(find(simulated_SNRs==index_snr)) filesep]; try rmd...
e203230eee93a5be76079dc4c297ec3489ab890f21a52ff64483f362a7b6aa99
MATLAB
380
14
function t = numel(obj) % Number of simple file arrays involved. % _______________________________________________________________________ % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging % % $Id: numel.m 8776 2013-11-14 09:04:48Z roboos $ % Should be this, but it causes problems when accessing % obj as a...