sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
001b90da41644be910dc34d9aeeb5461154e84b2be23e940e50be89740928a6e
MATLAB
1,554
60
function att = CBIG_ConvertStrCell2Attributes(str_cell, type, sequence) % att = CBIG_ConvertStrCell2Attributes(str_cell, type, sequence) % type can be "unique" or "single" % if "single", then must specify "sequence_cell", e.g. {'LFT', 'AMB', % 'RHT'}, and the corresponding att will be a N x 1 vector where LFT is set %...
554e5b9ec82fac1a71c86c49271bb83933c81b83b81d33f2993ba3d825dfaa53
MATLAB
1,554
47
function [pixel_thresh,min_size,max_size,do_watershed,normalise_img, kernel, colormap] = get_biomarker_info(biomarker) %% Define detection threshold and analysis strategyfor each antibody % @author: speressotti % Threshold can be between 0 and 1, with smaller values corresponding % to higher i...
8f51a8aea5ad88240b5dcde1dee9117154dc6ff3ebcf39a2bc415eaec5183c35
MATLAB
1,554
54
function outpict = gcolorize(inpict,hslvec) % OUTPICT = GCOLORIZE(INPICT,HSLVEC) % Colorize an image in a manner replicating GIMP's 'Colorize' tool. % I'm only including this for sake of compatibility with some GIMP scripts. % % INPICT is an I/IA/RGB/RGBA image of any standard image class. % HSLVEC is a three-term...
5a0ed3fa3202bc3144d822ba90c61178001ce22a208481a1bb360b797f2e5bc4
MATLAB
1,555
49
function [S,Dx,Dy]=get_stiffness_matrix_tri_wt(surf1,W) %This finds stiffness matrix for triangular elements using techniques from %book by Sadiku: Numerical Techniques Formulas 6.17,6.18 % A=tri_area(surf1.faces,surf1.vertices); % % % f=surf1.faces;v=surf1.vertices; % % C11e=(1./(4.*A)).*(v(f(:,2),2)- v(f(:,3),2)...
a740a3a71c3d0637532813cf5c96e8048485276159e3786fd4abfbb33f9869f9
MATLAB
1,555
48
function ct = makect(colorA,colorB,varargin) % COLORTABLE = MAKECT(COLORA,COLORB,{NUMCOLORS},{IDX}) % Create a simple linear color table from two RGB tuples % % COLORA, COLORB are 3-element vectors in any orientation % Values are expected to be scaled according to the numeric class. % NUMCOLORS specifies the l...
7d33030e7f596ad660faef68cd8d7699b8bcda31551d37718b8242d1770e1abd
MATLAB
1,557
50
function[root, resultdir, subdir, behaviordir, fMRIScansDir] = setDir(subid, IRM) % setDir % function which creates different results folders. % INPUTS: % subid: string indicating subject number % IRM: indicate whether fMRI run (1) or not (0) % If yes, also creates a folder to store fMRI data % % OUPUT % root: folder f...
9bcf45117c39ddea3e39b9944d1dd00a347615bcf9bea51c5d88e00b9a3b69f8
MATLAB
1,558
70
function [h,readwith]=nt_read_header(fname) %[h,readwith]=nt_read_header(fname,flag) - read data from file % % h: header % readwith: fieldtrip or biosemi % % fname: file to read % % if nargin < 1 ; error('!'); end if ~isa(fname, 'char'); error('filename is not char string'); end [PATHSTR,NAME,EXT] = filepa...
1963f9bba1203d217c596a58a92163ee9b9e585b09c9794fef38a483e0a88444
MATLAB
1,562
56
% compare run/rest between discrimination and grouping mouseID= [ "M119" "M120" "M292" "M319" "M231" "M314" "M316" "M318"]; RestRatio = zeros(length(mouseID),2); medianSpeed = zeros(length(mouseID),2); for i =1:length(mouseID) load(strcat("G:\Decoder input\",mouseID(i),"\trained\CaActivity.mat"), "States...
e9c665530dacb1b10df4b727607db5c20e1e0c69a76cec6ee4a5d36dc5de8429
MATLAB
1,562
63
clear all;close all;clc; restoredefaultpath; addpath('/ImagePTE1/ajoshi/code_farm/svreg/src'); addpath('/ImagePTE1/ajoshi/code_farm/svreg/3rdParty/') figure; mysphere([0,0,0],100,[.5,.5,.5],100); hold on;axis equal;material dull;camlight; cml=jet(125); r =100; phi=.3*rand(125,1); theta=2*pi*rand(125,1); %[phi,theta...
dd556f8bd9e030b5f8b953c16c509c4469fe73b6f430cb2cb5b956b26ca7e909
MATLAB
1,563
54
function s = motionEval(v, ref) % calculates structural similarity measure between reference volume and % all volumes in 4D time series data. % required input: v = fname or nifti file structure % ref = reference volume, volume# or 'mid' % author: soyoung choi USC if isstruct(v) vls = v; el...
11a396327ec27b2e5302fef77bf24b20b9ee3244f2e1ecc2cd2eaeaf7c7c3569
MATLAB
1,567
28
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%% Install GraFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%...
9c21ada6a067c21daad793c164fcdd38945fe2d91d6e68ca036a18340dae03f1
MATLAB
1,569
51
function CBIG_UpsampleVolume(input, output, scales, interp_type) % Upsample a volume. % % CBIG_UpsampleVolume(input, output, scales, interp_type) % Input: % input : input nifti file % output : output nifti file % scales : scales = FS_vox (order as seen on freeview) % interp...
c1b489f47273b4ae539dd0203ed59ae4865e73364a43e4b447b3cce094d04fc9
MATLAB
1,569
48
function S = reCalcCoefWithLS(data, D, S, nonneg) % S = recalcCoefWithLS(data, D, S) % % % % 202 - Adam Charles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% S_on = abs(S)>10*eps; % Compute the support of all pixels classS = class(S); if ndims(S)==3 nPix = size(S,1)*size(S,2); % g...
998429452728b7d540e6faca77c0394e0bc2a0be995b2d0e183e2cd81ffed525
MATLAB
1,572
45
%% function to analyze whether reward tuned HDC/PCs have place field nearby reward function [HasRewardField, RewDist] = AnalyzeFieldHDCPC(IsRewardTuned, cellID, Field_tbl, LightBin, RewBin) [~,ia,~] = intersect(RewBin,LightBin); HasRewardField = nan(length(cellID),1); RewDist = nan(length(cellID),1); for i = 1...
d825a28c8fa1c29b99a11caa494bddd3c121355d40350491dfa5ccc5c1a52545
MATLAB
1,582
38
function [cfg,data] = dtx_correctDTX2name(cfg,data) % Error during acquisition for rat DTX2 : need to rename channels ECoGS1 to % ECoGM1G and ECoGM1 to ECoGM1D. if strcmp(cfg.prefix,'DTX2-') fprintf('Rat DTX2, correct cfg and LFP channel names\n'); for ipart = 1:length(data) for markername = string(fie...
a63c17364e199f4a0d968fa916a34b3ceafa98aa2f1483dc0de3e93ddf39bcd5
MATLAB
1,583
56
load("error_stat_Nmax_Nconfigs_Strength.mat"); error_stat = log10(error_stat); % axis Nmax alpha phi3 phi4 type(mean,std) ncolor = 10000; color1 = [255, 150, 150]/255; color2 = [150, 150, 255]/255; anticolor1 = [1,1,1]-color1; anticolor2 = [1,1,1]-color2; colors1 = ones(ncolor,1)*color1 + linspace(1,0,ncolor)'*anticolo...
67a3bcb1a0916ce73d49d26775f5864ae5f45cc4c24973c073f854d516dc699c
MATLAB
1,584
50
% The purpose of this file is to generate a file that gives a vector of % grayordinate labels, its id lookup tables clc;clear all;close all;restoredefaultpath; addpath(genpath('/ImagePTE1/ajoshi/code_farm/bfp/dev/gifti-1.6')); addpath(genpath('/ImagePTE1/ajoshi/code_farm/bfp/src')); %addpath(genpath('/ImagePTE1/ajoshi...
a93524e866b24c14f9f7d49ebf4a64febc6eafa7dc779bdf5b25625101ac14a7
MATLAB
1,584
42
function cpm_savefig(fig, fname) % % cpm_savefig, wrapper for better saving of functions. Using different % setting for pdf and png. % % fig - figure handle % fname - output name % % --------------------------------------------------------------------- % Copyright (C) 2023 Simon R. Stein...
9b7fb4ac7e97ac9164a56a2752ea537c6f997e6859872dcac3f0b9d360efb93e
MATLAB
1,586
62
function hArrow = carrow3(axs, p1, p2, color, lineWidth, shrinkage, varargin) %% Default arguments if isempty(axs) axs = gca; end if ~exist('color', 'var') color = []; end if ~exist('lineWidth', 'var') lineWidth = []; end if ~exist('shrinkage', 'var') shri...
a1a209768bb67dfc85c29bf4255661a2e6fcc26d182a8237d89f15e8fa75bee4
MATLAB
1,586
39
function [config] = wod_setparams_lfp disp('setting parameters'); if ismac error('Platform not supported') elseif isunix %CED library does not work on unix % rootpath_analysis = '/network/lustre/iss01/charpier/analyses/wod'; % rootpath_data = '/network/lustre/iss01/charpier/raw/rat-iso/DATA_Antoin...
477e8939e6f48db656db754e5e1842512a4c0759456e741b9edac70cce527535
MATLAB
1,587
60
function val = CBIG_ComputeMultipeTestingPermutationStudentTPval(vec1, vec2, one_sample, N, alpha) % One or two sample t-test via permutation. % % val = CBIG_ComputeMultipeTestingPermutationStudentTPval(vec1, vec2, one_sample, N, alpha) % Input: % vec1 : M1 x T where M is number of subjects and T i...
f4c42657306a27d1b33006a8807c2c73cdce04e218ac764ef4db4c45fe05b057
MATLAB
1,587
36
function S = singlePoiNeuroInfer(tau_vec, mov_vec, D, maxiter, tolerance, verbose) % S = singlePoiNeuroInfer(tau_vec, mov_vec, D, maxiter, tolerance, verbose) % % Use SpiralTAP for a single vector % % 2018 - Adam Charles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Set up problem ...
6d8f9eb1be26cec98e2ab0d825bc2a2aaca50e5c009a34524c46442ad262dc63
MATLAB
1,588
41
function [y, x] = cpm_predict(prf, idx, from_posterior) % % cpm_predict, helper function, predicts signal from prf for given voxel. % % prf - a prf structure % idx - [optional, default=1] voxel index from which parameters should be % predicted % from_posterior [optional, default=true] wh...
be66c61197a0c6ca67b8d0ad2021e1b27f4d5e1f493eb56e18e2281c338ce9f8
MATLAB
1,593
56
function out = flipd(varargin) % OUT=FLIPD(A,{DIM}) % Flip an array. This is a wrapper for flip() and flipdim() to provide a consistent % syntax across versions with the speed benefit of flip() where it's available. % % flip() is ~2-3x as fast as flipdim() for large arrays, but it's only available % post-R...
440061db79eb9a9d8f7d2b479e5730c0d742ddc44f7444df3945eb7aeb58f4d5
MATLAB
1,595
57
function y=nt_deboing(x,events) %y=nt_deboing(x,events) - fit, remove ringing associated with events % % y: clean data % % x: data to clean % events: list of event samples % % NoiseTools. nt_greetings; if nargin<2; error('!'); end if size(x,2)>1; error('x should be column vector'); end ORDER=10; % order of ...
a1f9aef8fc6dd06ea97030730bf9715849efb3ae4d743c14a13cedd92683e284
MATLAB
1,596
57
% Sets axis tick labels function varargout = ticklabels(axs, labels, xOrYticks, indices, varargin) %% Default arguments if isempty(axs) axs = gca; elseif nargin < 4 && iscellstr(axs) %% Alternate input format: ticklabels(labels, xOrYticks, [indices]) if nargin > 2 indice...
54ea8d7d1f1954c49be249760e979ad5081c59f3ae0e95b31404ad7a3595e8cb
MATLAB
1,597
47
% Matlab codes for computing link predictability of complex networks. % Journal reference:"Toward link predictability of complex networks", % Proceedings of the National Academy of Sciences, 201424644 (2015). % by Linyuan L¨¹, Liming Pan, Tao Zhou, Yi-Cheng Zhang and H. Eugene Stanley. % http://www.pnas.org/content/ea...
7e5fb66e66a3daf09c4f3b94937daab87bb2b1f5180cea4a9a0ef328c0a55324
MATLAB
1,598
48
% % BDP BrainSuite Diffusion Pipeline % % Copyright (C) 2019 The Regents of the University of California and % the University of Southern California % % Created by Chitresh Bhushan, Divya Varadarajan, Justin P. Haldar, Anand A. Joshi, % David W. Shattuck, and Richard M. Leahy % % This program is free sof...
64e52ae3ed84c5eab0b24f2a81b940b99ea9ef94be695c0e16a2dad1508917c8
MATLAB
1,600
42
%% Convert digits to ordinal format: '1st', '2nd', ... etc. Non-numeric inputs will be included as prefix/postfix. function name = num2ordinal(varargin) %% Locate the numbers to convert iNumber = find(cellfun(@isnumeric, varargin), 1); if isempty(iNumber) error('At least one of the inputs must be a...
c1df2f0a2c87023f376451c040e4d263bb522aabf40ac9c98852e08ce32ac4e1
MATLAB
1,602
44
%% function to detect peaks on deconvolved calcium traces % simple findpeaks for non-drifting cells % thresholded detection for threshold needed cells % 0s for drifting cells %% Gergely Tarcsay, 2024. Function to detect Ca events using the deconvolved calcium signal. % 1. Drifting cells are kept 0 % 2. For ...
6416b9390341e82d2eaf6867053d219e0fe5fc0cd4649dd00d1e9d3a9bfba923
MATLAB
1,605
42
function bias_bits = bias_mi_gd_bits(Xdim, Ntrl, bincount) %BIAS_MI_GD_BITS Analytic bias correction for Gaussian/discrete MI. % bias_bits = bias_mi_gd_bits(Xdim, Ntrl, bincount) returns the % scalar bias correction in bits for the model-based MI estimator between an % Xdim-dimensional Gaussian variable and a dis...
228c4072ac19ba681a2906318734a51972d06acea16b36435fbfec876182ff27
MATLAB
1,609
35
function checkVars = isInMatFile(fileName, varName) % isInMatFile(fileName, varName) % % Chech if a variable called "varName", or list of variables as a cell % array of variable names in 'varName' exist in the file "fileName" % % 2018 - Adam Charles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
0088e2a0f0379364d287c7aa6380df1b025b07140e9ade1d68fa32a330c8ae19
MATLAB
1,610
75
% % Copyright (c) 2015, Yarpiz (www.yarpiz.com) % All rights reserved. Please read the "license.txt" for license terms. % % Project Code: YPML110 % Project Title: Implementation of DBSCAN Clustering in MATLAB % Publisher: Yarpiz (www.yarpiz.com) % % Developer: S. Mostapha Kalami Heris (Member of Yarpiz Team) % % Cont...
636a938e7e5997b124389e0d44a32b9260ba0c7667ff7dc31965a660cb9c20cf
MATLAB
1,610
50
% The purpose of this file is to generate a file that gives a vector of % grayordinate labels, its id lookup tables clc;clear all;close all;restoredefaultpath; addpath(genpath('/ImagePTE1/ajoshi/code_farm/bfp/dev/gifti-1.6')); addpath(genpath('/ImagePTE1/ajoshi/code_farm/bfp/src')); %addpath(genpath('/ImagePTE1/ajoshi...
05574a0859692184c230ab8f8806b5965a7fb7336a6f6f4bc5a4f9293975473c
MATLAB
1,613
62
function [tosquares,D]=nt_quad2square(toquad,order) %[tosquare,D]=nt_quad2square(toquad,order) - quadratic to squared linear component % % tosquares: matrix to linear components with closest square % D: scores % % toquad: matrix that defines quadratic component from cross products % order: order of cross produ...
166eea9b79dde08a253d4147cecba88f93b34659416a90b13f31f801690ceec3
MATLAB
1,614
59
function a = groupLCA(y, A, lambda, group_cell, varargin) % a = solve_grouplasso_lca(y, A, lambda, group_cell, tol) % % Block l1 minimization (group lasso) function. Uses LCA to optimize. % % y - vector to infer decomposition % A - sparsity matrix (generative mode: y = A*a) % lambda - regulariz...
665430a8837742d641e09ec28f27e8eaab3ad4fc147496ec9ff8bcbd4f25a3b7
MATLAB
1,616
62
function [labels labelcount] = bwlabelFB(varargin) % LABELS=BWLABELFB(INPICT,{CONN}) % [LABELS LABELCOUNT]=BWLABELFB(INPICT,{CONN}) % Connected group labeling for binary images. Labels a binary image based on % user-specified connectivity. % % This is a passthrough to the IPT function bwlabel(), with an ex...
36afc789718cea3f58d1e9a39786d1c701c44ad7a6021e38b15cccfdafe66273
MATLAB
1,619
32
% OME Bio-Formats package for reading and converting biological file formats. % % Copyright (C) 2014 - 2021 Open Microscopy Environment: % - Board of Regents of the University of Wisconsin-Madison % - Glencoe Software, Inc. % - University of Dundee % % Redistribution and use in source and binary forms, with or wi...
85227d038d8e5d750429ea4ef58b80f61512cca919203da1a17e65711e27ef81
MATLAB
1,629
47
% % BDP BrainSuite Diffusion Pipeline % % Copyright (C) 2019 The Regents of the University of California and % the University of Southern California % % Created by Chitresh Bhushan, Divya Varadarajan, Justin P. Haldar, Anand A. Joshi, % David W. Shattuck, and Richard M. Leahy % % This program is free sof...
7010431133d3c9feb08e57b497dc44adb37d92fdda5caa1a5e1c4c98bbaa4a42
MATLAB
1,632
37
function LFP = dtx_readLFP(cfg, MuseStruct, force) %read LFP data, remove artefacted trials, flip if required, correct %baseline, and align interictal data to the following TDW %used in dtx_spikes_project LFP = readLFP(cfg, MuseStruct, force); LFP = removeArtefactedTrials(cfg, LFP); if ~isempty(LFP) for ipart = ...
ac719bb98e6cec92557adadd6cc5054a1140dd38ed59e07d21086174fd820bce
MATLAB
1,634
39
% SVReg: Surface-Constrained Volumetric Registration % Copyright (C) 2017 The Regents of the University of California and the University of Southern California % Created by Anand A. Joshi, Chitresh Bhushan, David W. Shattuck, Richard M. Leahy % % This program is free software; you can redistribute it and/or % modify ...
d4cc1099f83c7daacd5367c4deeded83647debff4b8500492aef56149c9c04e5
MATLAB
1,634
37
%% Gergely Tarcsay, 2024. Function to split session into 1st and 2nd half trials, even and odd trials for each context function [frames, labels] = SplitSession(TrialFrames, States) % get trial # for each context CtxtOfTrial = States.Context(TrialFrames(:,2)); % get context for each trial; trial 1 is not assigned ...
353bd302ee749c1c52963797cce724c12dd48de415b2ef52ca4e51356f858d09
MATLAB
1,635
42
function katia_prepare_spykingcircus restoredefaultpath if ispc addpath (genpath('\\l2export\iss02.charpier\analyses\vn_pet\EpiCode\shared')) addpath (genpath('\\l2export\iss02.charpier\analyses\vn_pet\EpiCode\external')) addpath (genpath('\\l2export\iss02.charpier\analyses\vn_pet\EpiCode\templates')) ...
744fcd0ef45580d66c180a209dc3f96993abc8670199bdbee0205f03359d5c94
MATLAB
1,635
59
% SVReg: Surface-Constrained Volumetric Registration % Copyright (C) 2016 The Regents of the University of California and the University of Southern California % Created by Anand A. Joshi, Chitresh Bhushan, David W. Shattuck, Richard M. Leahy % % This program is free software; you can redistribute it and/or % modify ...
0c98b0de55673ee95c911dd1e540775d33f4cbf8cb0b18929540e0a4c2174661
MATLAB
1,638
66
function Q = randomPowerFindRange(A, r, q, epsilon, randMatrix) %% Default arguments if nargin < 2 || isempty(r) r = 10; end if nargin < 3 || isempty(q) q = 1; end if nargin < 4 || isempty(epsilon) epsilon = 1e-5; end if nargin < 5 randMatrix = []...
6b280a5bfa9c5c3d182fa3d50a235c49c20fd47075c219e0542e39be73d729ba
MATLAB
1,640
45
% Verify NIFTI header extension to make sure that each extension section % must be an integer multiple of 16 byte long that includes the first 8 % bytes of esize and ecode. If the length of extension section is not the % above mentioned case, edata should be padded with all 0. % % Usage: [ext, esize_total] = verif...
7287d0e17bd1a4f7787ec984fab6541c41386a88c3e88a70a2e238cb6fd5201e
MATLAB
1,641
61
function [iBad,toGood]=nt_find_bad_channels(x,proportion,thresh1,thresh2,thresh3) %[iBad,toGood]=nt_find_bad_channels(x,proportion,thresh1,thresh2,thresh3) - find bad channels % % iBad: indices of bad channels % toGood: matrix to good channels % % x: data % proportion: proportion of time above threshold(s) [def...
84aebdcf98bd477a17a5a149cc57966fe44a2999d56e58a590f0cc33dff8c765
MATLAB
1,643
34
%% Create slurm job list config = pnh_setparams; fname_slurm_joblist = fullfile(config{1}.datasavedir, 'slurm_job_list.txt'); delete(fname_slurm_joblist); for ipatient = 1:4 for ipart = 1 : size(config{ipatient}.directorylist, 2) subjdir = config{ipatient}.prefix(1:end-1); partdir = ['p', ...
296e4e91374a6c4d3ea57e50cef56ffadc391c77c724209edc8e89f611b434ce
MATLAB
1,644
57
function Xcorr = fastXcorr(spike_matrix, maxLag, autocorr) %% by Mattia %% compute cross correlation for sparse binary matrices (orders of magnitude faster than matlab xcorr) % inputs: % spike_matrix: units * time % maxLag: the maximum lag for which xcorr will be computed. in the same % units as the spike_matrix % au...
a23dc3a7f5b7feb205ce323efa8ee20b61ab25644e0f52b68117e45383e0c600
MATLAB
1,645
52
classdef PCAResults properties coeff score latent tsquared explained mu end methods function obj = PCAResults(XMatrix) [coeff,score,latent,tsquared,explained,mu] = pca(XMatrix); obj.coeff = coeff; obj.score = sc...
902af71f1b420cd15c45a6a46383395b6723d1efe50f4eb0e7cba41b6038d90e
MATLAB
1,646
60
%% Compute the variance of a weighted sample. % Input: % unbiasing : 'none', 'frequency' (default), or 'reliability' function [variance, mean] = varw(data, weight, unbiasing, dim, nanflag) %% Default arguments if ~ischar(unbiasing) if exist('dim','var') nanflag = dim; end dim ...
e15074a9fc3756b517cf785e246ad5625cc1c0933760a5536419166d120d0d42
MATLAB
1,648
52
classdef ConnectionMatrix < handle % ConnectionMatrix % Handles pure connection matrix (source x target) without any metadata. properties Matrix double % [N_source x N_target] connection matrix (binary or weighted) IndexPairList double % [#connections x 2] (optional) source-t...
17eca62ae7ae73dc0ec5487dd8f11e6368a82a0b1eab8a0737df422b3678de51
MATLAB
1,649
40
function [] = arrowProjection(tail, direction, dimensions, scale, color, varargin) % ARROWPROJECTION Draws a 3D arrow projected to 2D, with special % notation for into plane and out of plane. i = dimensions(1); j = dimensions(2); xRange = span(xlim()); yRange ...
541029ca2d492c91b5ad586b02f980b3b3798d28d4080c3e2f01a512c77c7885
MATLAB
1,649
48
classdef Socket < handle properties (Access = private) sock end properties (Access = private, Constant) sizes = containers.Map( ... {'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', ... 'int64', 'uint64', 'single', 'double'}, ... [1, 1, 2, 2, ...
9c8dea31513baef4ad08b4ceb9a4678d40de722d1911e7b4bec70af8bb4a39eb
MATLAB
1,651
47
%% Generate a random permutation of indices [1,2,...,n] where the indices are first partitioned into segments and then segments are permuted function r = randpermSegments(n, nSegments, minSegment, nSamples) %% Default arguments if nargin < 3 || isempty(minSegment) minSegment = 1; end if nargin < 4 ...
b105d008417a697885dc8c39fd90f3db7b6c61a16687a8d54877349d50a0bfe2
MATLAB
1,651
44
function [true_P] = cpm_get_true_parameters(varargin) % % cpm_get_true_parameters, transform parameters in PRF.Ep or arbitrary parameters % from latent into real parameter space. % % true_P = cpm_get_true_parameters(PRF, idx) transforms posterior parameter % estimates for vox...
ef64172f84842973f14e0eb39c63e7eec106886d976cc4ab30a7f5b09088f489
MATLAB
1,652
48
function avg_mesh = CBIG_ReadNCAvgMesh(hemi, mesh_name, surf_type, label) % Read the average mesh (from FREESURFER) of normal control people. % % avg_mesh = CBIG_ReadNCAvgMesh(hemi, mesh_name, surf_type, label) % Input: % hemi : 'lh' or 'rh' % mesh_name : 'fsaverage6', 'fsaverage5', 'fsaverag...
b9bf18479e954278e9a27db0cc5584b4df84b899e53d92ed5fb2286f47b0109d
MATLAB
1,656
40
%% function to create event map for every cell function [RateMap, EventXY, EventTime, OccupancyMap] = MakeRateMap(BinnedXY, CaMatrix, XYedges, frames, framerate, filterSize) [N_cell,~] = size(CaMatrix); BinEdges = length(XYedges(:,1)); %% make occupancy map [OccupancyMap, ~,~] = histcounts2(BinnedXY(frames,2),...
d86dc7108f3a4e2328a89756fab8a5eb03c8ca7de6b272bbb19180fddd2bfe43
MATLAB
1,658
34
%% Demo 8 - Generalized linear mixed model with gamma distribution % Strictly positive, right-skewed outcomes can be modelled directly with a % distribution that fits, instead of being forced into a normal model. Shown on % the Oats dataset (nlme; Yates 1935), a split-plot field trial: oat yield for % three varieties u...
8b6acccb0a36a20c39226cd30ceec8837e5cb8cb523f206c61651f3854100c5d
MATLAB
1,659
53
function [outflag color] = issolidcolor(inpict,tol) % OUTFLAG=ISSOLIDCOLOR(INPICT,{TOLERANCE}) % [OUTFLAG COLOR]=ISSOLIDCOLOR(INPICT,{TOLERANCE}) % Determine whether an image consists of a uniform color with % uniform alpha (when present). If the image is uniform, % optionally return its color tuple. % % ...
5366f976ed7b7004329182eedc9d6af0c54bcb55164e117153ad91fdd515bd3c
MATLAB
1,660
53
function ftdata = jw_import_neuralynx(sessionDir, varargin) % JW_IMPORT_NEURALYNX imports a set of Neuralynx continuous channel files % (ncs) and imports them into a fieldtrip structure after preprocessing. % % Author: Jeffrey B. Wang <Jeffrey.Bond.Wang@gmail.com> % % Inputs: % sessionDir: Directory for w...
a924de1741d4b638b04f17ed4f41ce1fbe8fdfe60f5096b8347dacc8780448c4
MATLAB
1,662
47
function [mean_angle,std_angle, Dist_along_PF, term_ang]=find_angle_vs_position(dA2,dL0,dL,maxk2,Lstep, term_bin) J=length(maxk2); for j=1:J Lfromwall(1,j)=dL0(j); Lfromtip(1,j)=dL0(j); for k=2:maxk2(j) Lfromwall(k,j)=Lfromwall(k-1,j)+dL(k-1,j); Lfromtip(k,j)=Lfromtip(k-1,j)+dL(ma...
7e1bf4e55c85a2753837105608f100e76b7dd0f4b77459ba63136861f8d6fab4
MATLAB
1,663
79
function [topcs,pwr,y]=nt_pca0(x,shifts,nkeep,threshold,w) %[topcs,pwr,y]=nt_pca0(x,shifts,nkeep,threshold,w) - time-shift pca % % topcs: matrix to convert data to PCs % pwr: power per PC % y: PCs % % x: data matrix % shifts: array of shifts to apply % nkeep: number of PCs to keep % w: weight (see nt_cov) % thr...
c326d431ccab4a40a131e5607c0b03dedf19b185b642ffe46bd51692c101f23f
MATLAB
1,664
47
% Load figures invisibly fig1 = openfig('./../figures/ast1.fig', 'invisible'); fig2 = openfig('./../figures/ast2.fig', 'invisible'); fig3 = openfig('./../figures/ast3.fig', 'invisible'); % Create new figure for merging mergedFig = figure; hold on axis([0 1 0 1]); % Set both x and y axes to [0,1] % Find axes in each ...
2daefe1838687d20d95fa93ecb697eb2ea44db972c37623b9d9afbde8e257a14
MATLAB
1,667
61
function writer = write_image_array() writer.accepts = @(item) isa(item, 'gadgetron.types.ImageArray'); writer.write = @write_image_array_to_socket; end function write_image_array_to_socket(socket, image_array) write(socket, gadgetron.Constants.IMAGE_ARRAY); write_data(socket, image_array.data); ...
4b3d281d069591731eb0557c22a950c792dc262bd7eb3d9bcb1ebc4d171c54be
MATLAB
1,667
65
function BMtraining(subjectname, runnum) %e.g., BMtraining('TEST', 1, 1) % 12 mini blocks per run, (see below) each consisting of four main block % types repeated 3 times. Must run both run types to acquire complete set. %runtypes: 1 IdealCutting/BMLscramble x Upright/Inverted % 2 BMLscramble/Modified...
6ceff1a9027c5940b41a57798b5c990d00512b22ec1c812bd4b8bc2ecd8aad45
MATLAB
1,671
50
function [ savedFileName] = save_nii_gz( niiData, fileName, datatype ) % Wrapper around save_nii to create compressed GNU zip files. Only works % with nii structures. % % niiData: nii structure or .nii filename with full path. % % fileName: Destination filename, with/without '.nii' or '.nii.gz'. % Use [...
45334627121fd5c09423cbdcb17d9565041ec083169c66322bcc964e1315b9cd
MATLAB
1,672
57
close all; clear all; clc addpath(genpath('/data/code/matlab')); prepOutput; %%%% PARAMS %%%% dataDir = '/data/coord/tyr/15-07-13'; % Go to directory initPath = path; initDir = pwd; cd(dataDir); % Clear temp files and run grab to generate them (run d-files) delete('*.temp'); grabCall = 'grab -od -at2 -Xs62:66 -mc ...
48d42cb10740a1d1243585e0df28c98c3e1518b3febd874ae4545b72430adb04
MATLAB
1,673
50
% Finding Indices % Always Sel_ind = find(HC_ind | OCD_ind) % Late onset OCD HC_ind = (demographics.Diag == 2) & (demographics.Age >= 18) & (isnan(demographics.Onset)); OCD_ind = (demographics.Diag == 1) & (demographics.Onset == 2) & (demographics.Age >= 18); % Number of HC: 663; Number of OCD: 388 % p=0.0005 % Earl...
3edcd35a2f4283e27c7a2e3fc586453b8484a6a9d1dc294c713de3e2dda65d48
MATLAB
1,675
59
function [C,tw,m]=nt_cov_lags(x,y,shifts,demeanflag) %[C,tw,m]=nt_cov_lags(x,y,shifts,nodemeanflag) - covariance of [x,y] with lags % % C: covariance matrix (3D if length(lags)>1) % tw: total weight % m: number of columns in x % % x,y: data matrices % shifts: positive shift means y is delayed relative to x % de...
53126eae4da4010a942d7f0fce20ec5e2db43796694d0d3356984180ceafbd60
MATLAB
1,676
53
function CBIG_DownsampleDataFSaverage(hemi, input_file, input_mesh_file, output_mesh_file, output_file, var_name, exit_flag) % CBIG_DownsampleDataFSaverage(hemi, input_file, input_mesh_file, output_mesh_file, output_file, var_name, exit_flag) % CBIG_DownsampleDataFSaverage('lh', './lh.090722_ZC47CH.014.resid.mgz', 'fs...
ca68b15b75fcf0a23bd3281c3a245bcd7a99e11331ba2262a0b5aee5a44abb47
MATLAB
1,680
61
function [squares,quads,D]=nt_qca(x,npcs,nsmooth,nquads) %[squares,quads,D]=nt_qca(x,npcs,nsmooth,nquads) - maximize induced power using quadratic component analysis % % squares: linear components closest to most repeatable quadratic component % quads: most reproducible quadratic component(s) % D: eigenvalues % % ...
e248a64fdc5d7d371b265e39a28ffdfbf1905239051c9e474b562b759a717225
MATLAB
1,680
51
% position = [left bottom width height] function [figHandle, position] = makePositionedFigure(position, monitor, positionMode, doCreate, varargin) % Default arguments if nargin < 2 || isempty(monitor) monitor = getMonitorBySize(true); end if nargin < 3 || isempty(positionMode) positio...
624e6964544a8ecefb051a617fe0896f2360678d197dd101cf3872e7a452bf10
MATLAB
1,683
44
%% function to get reference point, Gergely Tarcsay, 2025. % First the position is rotated based on difference of the expected and % observed position of the mouse when at getting the reward (head position) % Next the reference point is taken as [0 20] - northern corner function [RefPoint,XY, theta, Rew] =GetRefere...
15e47cedd848fb16b948adf29993fcad855196fbc3c560b38de5d7d3c7abf0f9
MATLAB
1,689
42
% This is a sample main file that reads two grayordinate fmri files generated by bfp and outputs the synced files. clc;clear all;close all; addpath(genpath('/home/ajoshi/coding_ground/svreg')); addpath(genpath('../')); sl=readdfs('/home/ajoshi/coding_ground/bfp/supp_data/bci32kleft.dfs'); sr=readdfs('/home/ajoshi/co...
20fec097d3b1bd009167e5e8dab61bf29c0a1d15894eeb2b49db1f510e575868
MATLAB
1,692
42
function PET_prepare_spykingcircus restoredefaultpath if ispc addpath (genpath('\\l2export\iss02.charpier\analyses\vn_pet\EpiCode\shared')) addpath (genpath('\\l2export\iss02.charpier\analyses\vn_pet\EpiCode\external')) addpath (genpath('\\l2export\iss02.charpier\analyses\vn_pet\EpiCode\templates')) ad...
9df58336d74db19e5faa804afa2d164134a68f3d7cdbf83e546afb6872aad02b
MATLAB
1,694
47
function CBIG_SPGrad_example_wrapper(output_dir) % CBIG_SPGrad_example_wrapper(output_dir) % % This function will run examples sequentially % % Written by Ru(by) Kong and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md if(~exist(output_dir)) mkdir(output_dir); else rmdir...
4e2224f7287ecbacb208b4ead5fc24135d8d60a393b1b927e80bef49037505a8
MATLAB
1,696
65
function [B, lims] = rescale(A, lims, out_lims) %RESCALE Linearly rescale values in an array % % Examples: % B = rescale(A) % B = rescale(A, lims) % B = rescale(A, lims, out_lims) % [B lims] = rescale(A) % % Linearly rescales values in an array, saturating values outside limits. % % IN: % A - Inp...
fb94b2b05b5d84f8b37262988a5ff146639da79ed6095f02bc45cbc94863de8b
MATLAB
1,696
37
function sbjMesh = CBIG_SPGrad_read_surf_mesh(surf_path) % This function reads a surface mesh from a surface file % Written by Ru(by) Kong and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md radius = 100; total_surface_area = 4*pi*(radius^2); [vertices, faces] = read_surf(surf_pat...
7d08f9f28684123d986785f9ecbaf0e6bef8d66df290293acdabc34e6e2ab555
MATLAB
1,700
53
% putRawCSC.m % demo on how to use Mat2NlxCSC % % % example: % putRawCSC( filenameOut, timestamps, dataSamples, ['Test header info'] ); % where timestamps and dataSamples are as returned by: % [timestamps,dataSamples] = getRawCSCData( filename, fromInd, toInd, mode ); % %urut/MPI/dec11 %urut/feb13 added exporting Fs/va...
ae6431cfcae44840140bbf2f6ffd4dcaedac0d3ab507b61aef71ba9507dc4303
MATLAB
1,702
52
% % BDP BrainSuite Diffusion Pipeline % % Copyright (C) 2019 The Regents of the University of California and % the University of Southern California % % Created by Chitresh Bhushan, Divya Varadarajan, Justin P. Haldar, Anand A. Joshi, % David W. Shattuck, and Richard M. Leahy % % This program is free sof...
d59be8a48010b7bc5530fb78b1b7d04a30373ea889a128df5a46f38e96fbca74
MATLAB
1,702
50
function smoothedV = CBIG_Smooth3DVolumeWithMasks(V, mask, outside_mask_type, method, filter_size, arg) % smoothedV = CBIG_Smooth3DVolumeWithMasks(V, mask, outside_mask_type, method, filter_size, arg) % outside_mask_type = SMOOTH => Everything outside the mask is smoothed ignoring the mask. % outside_mask_type = SAME ...
1000e1142ef7a33fa093b1809b3e1d9a49686b89fc498b09740de9619ab1c5b0
MATLAB
1,703
53
function [spectrum, freq] = medianSpectrum(signal, windowSize, overlap, nfft, fs, maxFreq) %% Calculate median power spectrum using matlab pwelch on single windows % By Mattia % This function replaces the last step of welch's method (mean) with % a median. If you are unsure why this is preferrable t...
18007ba6cfcca6014e39cff975bf1cc9913a5c151e0f4aa24cf82331d9daf41d
MATLAB
1,704
54
classdef BH32 < handle %BH32 TDT BH32 class. % obj = BH32(varargin) controls a BH32 through SynapseAPI % optional argument is the Synapse computer IP address, otherwise % defaults to 'localhost' % % obj reference to BH32 object % obj.read get d...
c7e1ba12e684d484afe0658a9bf8fc03f894b4e6e733116a6eae9c98c1b3bc47
MATLAB
1,705
60
function Seed = getSeed(data,options) % calculation of a first guess for the parameters %function Seed=getSeed(data,options) % This function finds a seed for initial optimization by logistic % regression of the data % Additional parameter is the options.widthalpha which specifies the % scaling of the width by % width= ...
e674d723e5192ddd0a620ffa56c93c20e44f5eed8d3bcd21cdaa4057153e1ab0
MATLAB
1,705
74
function res = grs2rgb(img, map) %%Convert grayscale images to RGB using specified colormap. % IMG is the grayscale image. Must be specified as a name of the image % including the directory, or the matrix. % MAP is the M-by-3 matrix of colors. % % RES = GRS2RGB(IMG) produces the RGB image RES from the grayscale image...
128c163cdcf82533ff9a7c9b3734fe47b2f8a2bf91b141a40045eb8d30d855a5
MATLAB
1,707
63
function A=nt_narrowband_scan(x,freqs,sr,Q,plotflag) %A=nt_narrowband_scan(x,freqs,sr,Q,plotflag) - scan for narrowband components using DSS % % A: cell array of DSS matrices % % x: data (time*channels or time*channels*trials) % freqs: Hz, array of bias frequencies % sr: Hz, sampling rate % Q: quality factors of s...
f489188c25e7e1a93a88b705522334b9cd062bb7e9ed1933d1ffd6458f3618d6
MATLAB
1,707
61
%% load relevant code base paths addpath(genpath('.../phototagging_functions/')); %path to matlab/code/lab folder %% load data load('.../testdatarun.mat') %% Import epi image epi_image = '...test_array_image.jpg'; im2 = imread(epi_image); %% Get a matrix (tform) for electrode locations on the epi image % Two...
e7268f86446c9b7f19b741719f6dd6c4092b83ca1359931c92e21dd2897064e0
MATLAB
1,709
63
%% % function [f] = bigaussfit(x, y, yError2, zeroError2, mu, sigma, isOrdered) % fitFunction object (static) % Note that just for fun, MatLab reorders the parameters such that what % it calls coefficients is alphabetically (?) sorted persistent fitFunction; if isempty(fitFunction) fitFunctio...
7d58dbfd9c9a80ae27c0e0194c4db8d9a190807fcbfd990d632be64f93349f16
MATLAB
1,710
42
% Toolbox for batch processing ASL perfusion based fMRI data. % All rights reserved. % Ze Wang @ TRC, CFN, Upenn 2004 par; % get the subdirectories in the main directory for sb = 1:length(PAR.subjects) % for each subject sprintf('uBEN calc. subject %u .........',sb) %go get the sessions for ses=1:P...
bc0af9916fa5cac08a75b9f70b28e728b89db81492e8fb18f4d6aa4c48a45ed5
MATLAB
1,711
82
%%% clo2_Nmax_9_alpha_2_Nsamples_64_lr_0.002 %%% set(groot,'defaultAxesTickLabelInterpreter','latex'); set(groot,'defaulttextinterpreter','latex'); set(groot,'defaultLegendInterpreter','latex'); E = readmatrix("Eigenenergy_Error_clo2_wVSCF.txt"); Ewo = readmatrix("Eigenenergy_Error_clo2_woVSCF.txt"); Emean = mean(...
ba9e1589b4394b4d93a3e04e673269eed0ecf48252fe3df983b39d9c16b7f5a2
MATLAB
1,712
42
function plotSpikesV2(Number,IIA_batchResults) % length = size(IIA_batchResults{Number, 1}.OriginalSignal); threshold = zeros(length(:,1),1); for point = 1:length(:,1) threshold(point,1)=IIA_batchResults{Number, 1}.threshold; end thresholdMatrix = [IIA_batchResults{Number, 1}.OriginalSignal(:,1) threshold]; figur...
e24a99f8d362015471a03e6177cd712641d0dc1ef8f59c2eb19fb5d3180823a7
MATLAB
1,714
57
function [answer, anstime]=get_key(keys, wait, response_end); %[answer, anstime]=get_key(keys, wait); % %Get keyboard-input from user - waits for a key press as defined in input variable 'keys' OR just checks once % %INPUTS %keys key numbers we are looking for. scalar for one key, or row vector of key num...
5c656907493958bccedbebeb02ba1fc343314fc384218633863952351a524c3b
MATLAB
1,715
69
function outpict = interleave(dim,A,B,varargin) % OUTPICT=INTERLEAVE(DIM,A,B,{C},{D},...,{WIDTH}) % Combine multiple images by interleaving them along a given dimension, % alternating in the given order. The resulting image dimension is multiplied % by the number of images being combined. % % A, B, C, etc are...
84c3757f88e4d475739105cf2c00c8ce8cddc6b0c0253b4f9c2ef489a6ae9d93
MATLAB
1,715
51
% The purpose of this file is to generate a file that gives a vector of % grayordinate labels, its id lookup tables clc;clear all;close all;restoredefaultpath; addpath(genpath('/ImagePTE1/ajoshi/code_farm/bfp/dev/gifti-1.6')); addpath(genpath('/ImagePTE1/ajoshi/code_farm/bfp/src')); %addpath(genpath('/ImagePTE1/ajoshi...
9d38ab0dac88dd6b6477423bab737d38bcbd0c1b52538bb18200bd20f7ffc8a2
MATLAB
1,717
46
function datatypes=getdatatypes(data) %datatypes=getdatatypes(data) % %Determines the type of each walker data set in 'data' %Each type may be: %'mm' mm walker, either alone or in an mmw matrix %'md' md walker (alone) %'cellmm' mm walker in a cell array %'cellmd' md walker in a...
88b16a8ffef549fa3fa94be3a2a6109134cfde67ae2e6ed1813a929677f24875
MATLAB
1,721
47
% Like pinv() or inv(), except that slices (3rd and higher dimensions) are supported and each slice % is treated independently for computing the inverse. If tol = 0, then the exact inverse is computed % via inv(). Otherwise, a truncated SVD is used to compute the inverse, where singular values less % than the specif...
3fc116e58ccc5f060e73c9295ac00436e369ccf5afb7ed7e4a9ce0ccc7b6b98d
MATLAB
1,722
59
% % BDP BrainSuite Diffusion Pipeline % % Copyright (C) 2019 The Regents of the University of California and % the University of Southern California % % Created by Chitresh Bhushan, Divya Varadarajan, Justin P. Haldar, Anand A. Joshi, % David W. Shattuck, and Richard M. Leahy % % This program is free sof...
4742f7b083298ebbed088de2aa942e2d8e9e831ff149ccaea836dadcb3f46c2a
MATLAB
1,725
69
function varargout = fourdee(fhandle,varargin) % FOURDEE(FHANDLE, ARG1, ARG2...) % Generic tool for using single-frame image processing functions % on multiframe (4-D) image sets. Only works if first argument % for said function is a 4D array. % % As outputs are arranged along dim4, things...
a6a7c3d6a1640603dc40af7b0028a7168e16852a76c2591727b8f7283936caaf
MATLAB
1,727
62
function splitSlide(fname,A1,B1,C1,D1) %fname = '/dcl02/lieber/ajaffe/SpatialTranscriptomics/LIBD/spatialDLPFC/Images/Lieber_Institute_OTS-20-7748_rush_posterior.tif'; numimgs = size(imfinfo(fname),1); %numimgs is the number of images in the multiplane tif file N = 4; %number of capture areas disp(['The multiplane tif ...