sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
2309106d9c57d6b5c2e830bdc899a06a9af073ac3afbc8085687e2a2ea91c9ab | MATLAB | 156 | 6 | function smd = f2smd(F,df1,df2)
%% Calculate Standardized Mean Difference (SMD) from F-value and degrees-of-freedom
smd = 2 * sqrt((F .* df1) ./ df2);
end |
caeb8176a355a7ba76bfb082916adf748360c35981afd7f1b99485200a1c49b5 | MATLAB | 156 | 7 | %% function to check whether HD is orthogonally tuned
function IsOrthogonal = CheckOrthogonality()
nnz(sum(HD_table.IsPC_HDC(:,2:3),2)==1);
end |
d9d89067a8990356d6cbf4b935f8bee6ac950e432d7934645df9e2361e25d7b0 | MATLAB | 159 | 8 | %%
% Rounds numbers away from zero, i.e. the opposite of fix().
%
function [rep] = defix(number)
rep = ceil(abs(number)) * sign(number);
end
|
ad3ed5b60899f238c0d2a58fe757011eb15538aa2a5b95940c029767c9fbfb16 | MATLAB | 160 | 11 | function set_figure_properties()
ax = gca;
ax.FontSize = 22;
lines = findobj(gcf,'Type','Line');
for i = 1:numel(lines)
lines(i).LineWidth = 2.0;
end
end
|
96e69b99163037f74adc34cf12428347f02cc6e98b044d0e736c749768df7d82 | MATLAB | 161 | 7 | function handle = findParent(handle, type)
while ~isempty(handle) && ~strcmp(get(handle,'Type'), type)
handle = get(handle, 'Parent');
end
end
|
08af8fb348a102979cc2605c01a468f852e1b22a57fc86557e1f7ce343dbf06f | MATLAB | 162 | 9 | function figsize(width, height)
if nargin < 2
height = 0.9 * width;
end
set(0, 'DefaultFigurePosition', [100 50 width height] );
end
|
34702acd8ed81a22023e9a6e9b1f6e9c28effa0ba082250ebc2671b8109f669b | MATLAB | 163 | 9 | function datout = shift(dat, steps)
datout = circshift(dat,steps);
if steps > 0
datout(1:steps) = nan;
elseif steps < 0
datout(end+steps:end) = nan;
end
|
3bb009003c5ee6f67a19b291a2ff1b5340930bdfdc0899967d4900a5893095fc | MATLAB | 163 | 8 | %%
function [rMin] = rangemin(range1, range2)
rMin = [ max([range1(1) range2(1)]) ...
, min([range1(2) range2(2)]) ...
];
end
|
80d4b87ad0687d9e7d6895aa6428d09d7a360894ab90aff1cf070da594b057d4 | MATLAB | 166 | 8 | %%
function [bin] = findBinBounded(x, xCenters)
bin = findBin(x, xCenters, false);
bin = max(bin, 1);
bin = min(bin, length(xCenters));
end
|
06abd50ce4c514de17cfb04695cf2d27b0d5951f9ae1f3fe76f5f6207b76e274 | MATLAB | 167 | 2 | function y=nt_version, y='12-May-2021';
if nargout==0; disp(['version ', y]); disp('check for latest version at http//audition.ens.fr/adc/NoiseTools/'); clear y; end;
|
4514cc527351c9bd94372701c15b367faf370f3d5a8777da139457fc334bf9ab | MATLAB | 167 | 9 | function range = ends2range(varargin)
if nargin == 1
range = varargin{1}(1):varargin{1}(2);
else
range = varargin{1}:varargin{2};
end
end
|
52ae6575f4229c4d8f5305c82837b5b7d494fa97c4fa89f66ae0c4fdbda76c22 | MATLAB | 169 | 5 | %PURPLE Gray-to-purple colormap
function map = graypurple(varargin)
map = [0.25 0.25 0.25 1; 0.5 0.3 0.5 1; 0.8 0.4 1 1];
map = colormap_helper(map, varargin{:});
|
c01ebf984cd30fa4dcec2b17aae8e60c4bde9c6c9d58e45818518de5a5f174b7 | MATLAB | 169 | 9 | function res = partialDCT(n,m,J)
res.adjoint = 0;
res.n = n;
res.m = m;
res.J = J(1:m);
% Register this variable as a partialDCT class
res = class(res,'partialDCT');
|
683257e4883a11db348945ebb29337f593bde5d8981063ebecc976c558eab951 | MATLAB | 170 | 9 | %%
%
function [x] = poly2inv(f, y)
p = coeffvalues(f);
det = sqrt( p(2)^2 + 4*p(1)*(y(:) - p(3)) );
x = [ -p(2) - det, -p(2) + det ] / 2 / p(1);
end
|
8285082f989451785c4921e6b80abef9c77480afd5a7be9ffe322555251b19dd | MATLAB | 171 | 12 | classdef ReconData
properties
bits
end
methods
function self = ReconData(bits)
self.bits = bits;
end
end
end
|
a99f0adfde1d554637ea0e6eb24abc01b51a00059f41f56d1713aa67c3c58c99 | MATLAB | 172 | 5 | %PURPLE Purple-white colormap
function map = purple(varargin)
map = [0 0 0 1; 0.25 0 0.25 5; 0.9 0.3 1 4; 0.95 0.85 0.95 0];
map = colormap_helper(map, varargin{:});
|
ff23b6aba6d164246ab1b313191ae6ee67f696a2cd5dc664a6970ac21a64614a | MATLAB | 172 | 7 | %%
% Recursively runs all() on an input tensor, returning the allimum over all
% element in all directions.
function [x] = rall(tensor)
x = all(tensor(:));
end
|
bbd40c1d759118a1efcbf776c8473ea28761b39b83798e021f38138f3b7bd8dd | MATLAB | 173 | 5 | % HYDRANGEA Purple-to-sky-blue
function map = hydrangea(varargin)
map = [100 20 50; 220 100 150; 0 50 200; 50 200 220]/255;
map = colormap_helper(map, varargin{:});
|
641d19c0a2cd2663e7cbc5670afbd045d55b174096aae17126f8ae6cedbfeed1 | MATLAB | 177 | 5 | function l = list(varargin)
if isempty(varargin), l = gadgetron.lib.Nil; return, end
args = varargin(2:end);
l = cons(gadgetron.lib.list(args{:}), varargin{1});
end
|
61ef479d12565d1a2ac6d50b3551e85310ba860fbd1e137503188258c82d8343 | MATLAB | 178 | 6 | %%
% Recursively runs min() on an input tensor, returning the minimum over all
% element in all directions.
function [x, i] = rmin(tensor)
[x, i] = min(tensor(:));
end
|
6f9d1ee1c381cad9c6a40cab820b0110dcc03ce407e2f1339f492bf034ecfc78 | MATLAB | 179 | 7 |
function h = subplottight(n,m,i)
[c,r] = ind2sub([m n], i);
ax = subplot('Position', [(c-1)/m + c*0.01 + 0.03, 1-(r)/n - r *0.01, 1/m*0.75, 1/n]);
if (nargout>0)
h = ax;
end
|
c46496fdd2c305f13299cbd41acf113cbfe701118c22dbd3dda42b8dc5c7abe9 | MATLAB | 179 | 4 | % SUBMULTIPLY Multiplies a matrix and an array, summing over the given
% dimension. Like M * a if the dimension is 2.
%
% submultiply(matrix, array, sumDim)
|
1fcbf6058af53279da3ad2ddd4cc6f96cece8f8e4f9ecc7169cffb83071b94d9 | MATLAB | 182 | 10 | %%
function [yes] = inrange(x, range)
if iscell(range)
yes = ( x > range{1} & x < range{end} );
else
yes = ( x > range(1) & x < range(end) );
end
end
|
2697a99dad9eddcd450dd3f788fd83de166dcb57358993614ef845b5c10a878e | MATLAB | 182 | 5 | %RED Black-red-orange colormap
function map = red(varargin)
map = [0 0 0 1; 0.25 0 0 4; 0.8 0 0 2; 1 0 0 4; 0.9 0.5 0 2; 0.9 0.7 0 5];
map = colormap_helper(map, varargin{:});
|
5a3dec89520020ae4d1a40e65727405a46820dfc6b3f0d6ddf1ded3ce607c6f4 | MATLAB | 185 | 10 | function consume(next)
try
while true
next();
end
catch ME
if ~strcmp(ME.identifier, 'Connection:noNextItem'), rethrow(ME); end
end
end
|
9973f39973f8033df72268f4c53e7927502c3bdcd0dd95075e4847ccad89bbd3 | MATLAB | 186 | 12 | %%
%
function [yes] = istiny(x, epsilon)
if nargin < 2
epsilon = 1e-10;
end
yes = false(size(x));
yes( abs(x) < epsilon ) = true;
end
|
dcb06acb851625fa89da23f7489994385b834b4d46d624149e1fab0039f5c891 | MATLAB | 187 | 8 | %% function to fix event file - remove too short event strings
function event = FixEventFile(event)
rmv = find(cellfun(@length,event{:,1}) < 6);
event(rmv,:) = [];
end
|
88545cb7937b551a1a597b6338a546dbd5f33bf624b96ec6895863f869a3d466 | MATLAB | 188 | 11 | function mask = multiMapMask()
params = activityMapParams;
params.preLimits = [10 15];
params.stimLimits = [20 25];
map = activityMap(params);
mask = logical(map.outlineObject(1));
end |
99d50270ebd7855c04f29ad5ee3a2e6b87dd01efd3de32bba42dbb813b65771c | MATLAB | 188 | 6 | %TEMP Blue-pale-dark red colormap
function map = alttemp(varargin)
map = [93 39 146; 166 107 223; 255 255 255; 250 166 0; 186 125 0]/255;
map = colormap_helper(map, varargin{:});
|
dee28d9ee249befa7555dd53e407269cee0fff8158badcb3b902c040ba8e98bb | MATLAB | 188 | 8 | %%
% Draws points from a random Gaussian.
function [points] = randgauss(mu, sigma, varargin)
points = bsxfun( @plus, mu, bsxfun( @times, sigma, randn(varargin{:}) ) );
end
|
688d8c543ef261cf7f7ce2b7bff0b3b014ee511fe0cdf1d9218451433c37b775 | MATLAB | 189 | 10 | function [num] = numcells(x)
%% NUMCELLS Like numel(), but treats all non-cell arrays as a singleton.
if iscell(x)
num = numel(x);
else
num = 1;
end
end
|
8aea3bdcdb594f469494b9e45464674c4810a266bd9378202e574ca5d0e0b84a | MATLAB | 189 | 3 | function map = fade(varargin)
map = [247 243 237 1; 235 204 171 1; 201 129 52 2; 158 166 20 1; 68 158 58 2; 194 227 191 1; 236 247 235 1] / 255;
map = colormap_helper(map, varargin{:});
|
2e2c2222b0658bc66dbc0cec206c172bd8b40b95d40ad5102c573682f0df1dd5 | MATLAB | 190 | 5 | % Like sum(), except that the output will be squished along the averaged dimensions
function M = sqsum(X, dim, varargin)
M = sum(X, dim, varargin{:});
M = squish(M, dim);
end
|
535d2bc60b9f0eb0e7cc5040828155b03c62adf09cff706d63d4f316e8fcc0ae | MATLAB | 190 | 8 | function [rad] = angle02Pi(rad)
rad = rad ...
- floor(rad / (2*pi)) ...
* 2*pi ...
;
end
|
0f83d1df6a829acaba6a7752a2d2d362e4bc6f72ba49eee4065d99e98bf3b4d1 | MATLAB | 191 | 10 | %% Computes the span of a given range [begin, end].
function [rSpan] = span(range)
if numel(range) < 2
rSpan = 0;
else
rSpan = range(end) - range(1);
end
end
|
cb791e2b6eba1709212f135e3dd7582b17f82ad01c958e7722f85a3e2e393d95 | MATLAB | 193 | 5 | % Like mean(), except that the output will be squished along the averaged dimensions
function M = sqmean(X, dim, varargin)
M = mean(X, dim, varargin{:});
M = squish(M, dim);
end
|
0284dc854d2da1d46a9cb24c7aa380543e0340d72d33cb12dd601bb44f1be021 | MATLAB | 194 | 8 | % function to calculate PVC of vector tuning
function PVC = GetPVC_HD(TuningCurves)
PVC = zeros(8,1);
for b = 1:8
PVC(b) = nancorr(TuningCurves(:,b,1), TuningCurves(:,b,2));
end
end |
cc8477c76e5c2f24826cbf4f4dc830a17286fcd5bdf86bbbfc04c8c1159e5177 | MATLAB | 194 | 6 | cla
xy = randn(100,2);
mmx = [min(xy(:,1)), max(xy(:,1))];
mmy = [min(xy(:,2)), max(xy(:,2))];
scatter(xy(:,1), xy(:,2));
tufteaxis(mmx, mmy);
|
a54ae70009e1953728c2ab1693c188e9dd524d5978db3b4631339b4fb41a54ae | MATLAB | 195 | 5 | %GREEN Green-white colormap
function map = green(varargin)
map = [0 0 0 1; 0 0.2 0 4; 0 0.7 0 1; 0 0.85 0 1; 0 0.9 0 2; 0.6 1 0.2 3; 0.9 1 0.5 0];
map = colormap_helper(map, varargin{:});
|
c5fbc853d12c4c1a8fcfcb233de57f1c70c85794c9543c3ad49648aa5417d011 | MATLAB | 195 | 11 | %%
% Creates a row vector with n elements initialized to x
function [vec] = rowvec(x, n)
if nargin > 1
vec = x .* ones(1, n);
else
vec = x(:)';
end
end
|
2917c323874f9c65a8e47cb8cfadcc0a94129821dfdb5396fea8af14eebd82b8 | MATLAB | 196 | 5 | %GREEN Green-white colormap
function map = green2(varargin)
map = [0 0 0 1; 0 0.3 0 4; 0 0.7 0 1; 0.25 0.82 0.25 1; 0.45 0.85 0.1 2; 0.7 0.85 0 0];
map = colormap_helper(map, varargin{:});
|
b7772494ddd05d5e73f3b5640272d6555c3d2e14b3349b0db4c91c2a5989f3f5 | MATLAB | 197 | 11 | %%
% Creates a column vector with n elements initialized to x
function [vec] = colvec(x, n)
if nargin > 1
vec = x .* ones(n, 1);
else
vec = x(:);
end
end
|
7f3227d759b5a44aba72d2c23f57f44fdf19ca7be4ea9803d33f77cbffb993a2 | MATLAB | 198 | 5 | % startup.m
projectRoot = fileparts(mfilename('fullpath'));
addpath(genpath(fullfile(projectRoot, 'src')));
addpath(genpath(fullfile(projectRoot, 'data')));
disp('Paths set. Ready to run SPERRFY.'); |
622cf209cafbd29160d130a593373975c0d59dbcec5afa66c5015f7074703d19 | MATLAB | 199 | 6 | function y = my_normpdf(x)
% this implements the standard normpdf without checks
% and without the possibility to set mu and sigma
% function y = my_normpdf(x)
y = exp(-0.5 * x.^2) ./ sqrt(2*pi);
|
baea7fece8d4765cc7ce91c96e992c494582930dcb5ce933e7c349165223439a | MATLAB | 199 | 5 | % Like median(), except that the output will be squished along the averaged dimensions
function M = sqmedian(X, dim, varargin)
M = median(X, dim, varargin{:});
M = squish(M, dim);
end
|
188a7ee4daaed7665282b209a6f73ab2f90dcd0efe64908340f34691cea09c2d | MATLAB | 200 | 12 | function out = loadload(fname)
count = 0;
err_count = 0;
while count == err_count
try
out = load(fname);
catch ME
err_count = err_count + 1;
end
count = count + 1;
end |
dcf0c94f968a3235fa7dee64296a5bde92d13d285e36842afe14a4c67a575215 | MATLAB | 201 | 9 | function gcmi_cpp_mex_clean(varargin)
cfg = gcmi_cpp_mex_config();
if exist(cfg.BuildDir, 'dir')
rmdir(cfg.BuildDir, 's');
end
if exist(cfg.OutputDir, 'dir')
rmdir(cfg.OutputDir, 's');
end
end
|
1dc779a36e2393412b1bccdda9d07540b0d080ad8b20798fa6d4a587f6e6c4d8 | MATLAB | 203 | 5 | function write_header_array(socket, headers)
gadgetron.external.writers.write_vector(socket, size(headers.version));
write(socket, gadgetron.external.writers.encode_image_headers(headers));
end
|
e915398b91024ce1b7d4542e3dd1e722ba18a37893c76c24fe5f180514d3cbfb | MATLAB | 204 | 12 | %%
%
function [centers] = toBinCenters(edges)
if numel(edges) < 2
error('At least two bin edges must be provided.');
end
centers = ( edges(1:end-1) + edges(2:end) ) / 2;
end
|
8630ed13e7fcfd18d406c640826a9331217ab7c43f49ddb0e8ec34bde4da8028 | MATLAB | 205 | 7 | function index = colorIndex(x, xRange, nColors)
scaled = ( x - xRange(1) ) / ( xRange(2) - xRange(1) );
scaled = min(max(scaled, 0), 1);
index = round( 1 + scaled * (nColors - 1) );
end
|
efb01a9b6700d29b6f2a69c14e7cd7e22a2274c8d3c0884099e1f4af9ff2147a | MATLAB | 206 | 8 | addpath {SPMPATH}
addpath {PREPROCPATH}/resources/leuven/prod/undist
addpath {PREPROCPATH}/resources/leuven/prod/mex/
currentDir = '{CWD}';
mc_undist_wouter_dante_tasserie(currentDir, '{BASENAME}')
exit;
|
18cf9760bd754289e22ada4142cbf00045c6a1eeb362b6f819183606e731787b | MATLAB | 210 | 9 | function next = basic_reconstruction(input)
function slice = reconstruct(slice)
slice.data = gadgetron.lib.fft.cifftn(slice.data, [2, 3, 4]);
end
next = @() reconstruct(input());
end
|
c0dd63bf9ea0cf71bf73b344f14300c38049fc220a5d365987aaa28c0a7b9565 | MATLAB | 211 | 9 | function next = send_image_to_client(input, connection)
function send_image(image)
disp("Sending image to client.");
connection.send(image);
end
next = @() send_image(input());
end
|
4bdbfaf8c6681f5a26fa5444efccdf3ac958ee7c6caea6994e45698c6b26cbfb | MATLAB | 212 | 9 | function [upstreamID] = extractUpstreamID(structureIdPath)
idListStr = strrep(structureIdPath,'/',',');
idListStr = strip(idListStr);
idList = str2num(idListStr).';
upstreamID = idList(length(idList) - 1);
end |
4f20453bbf6c55f2e841cd684a5419185af8c3e4430593e5561d5d7284dfbd25 | MATLAB | 212 | 13 | %%
%
function [handles] = colorize(handles, colors, colorWhat)
if nargin < 3
colorWhat = 'Color';
end
for iH = 1:length(handles)
set(handles(iH), colorWhat, colors(iH,:));
end
end
|
e69c494a03edc3f4cc97f7ec8fa00c00c9105955abe19ae3959352b15b3c5a78 | MATLAB | 212 | 9 | %% Set icon properties of a legend object
function hIcons = setLegend(hIcons, type, varargin)
hAssoc = findobj(hIcons, 'Type', type);
if ~isempty(hAssoc)
set(hAssoc, varargin{:});
end
end
|
e80da0d82a265246a6f2404024e2ea30208299d6d4df6edc8a6baf5305ccf767 | MATLAB | 214 | 11 | function Km = getUpsamplingKernel(nC, sig, upsamp)
xs = 1:nC;
xn = linspace(1, nC, nC * upsamp);
d0 = (xs' - xs).^2;
d1 = (xn' - xs).^2;
K0 = exp(-d0/sig);
K1 = exp(-d1/sig);
Km = K1 / (K0 + 0.001 * eye(nC));
end |
30696d90e397d4dc133e15bffd2e3a3fe9a87743ed9481ab5088c0e34a62e2d3 | MATLAB | 215 | 9 | function opt = read_optional(socket, handler, varargin)
is_present = read(socket, 1, 'uint8') ~= uint8(0);
if (is_present)
opt = handler(socket, varargin{:});
else
opt = [];
end
end
|
a0180232c5fdbddcfe978f68358be719695246f4c3a255a5abbf74c2c36fb41f | MATLAB | 215 | 10 | function write_string(socket, string, size)
length = cast(strlength(string), size);
write(socket, length);
if length == 0, return; end
write(socket, unicode2native(string, 'UTF-8'));
end
|
797b3747ec3b3b16330422e8b3b5c3a01c82543280de416b61200b64c5c154ac | MATLAB | 216 | 11 | function [Xb,Zb,maxkb] = generate_bootstrap_PF_set(X,Y,Z,maxk)
J=length(maxk);
for j=1:J
rnd=randi(J);
Xb(:,j)=X(:,rnd);
% Yb(:,j)=Y(:,rnd);
Zb(:,j)=Z(:,rnd);
maxkb(j)=maxk(rnd);
end
|
b4727dde4e318259addc33c02add41d7afef4fdf858f3fdbeff1f18236a89dea | MATLAB | 216 | 12 | function str = lowerFirstCase(str)
if iscell(str)
for iStr = 1:numel(str)
str{iStr}(1) = lower(str{iStr}(1));
end
elseif ~isempty(str)
str(1) = lower(str(1));
end
end
|
07d1ea0e79327ece70b1dbaed7a4c39bc5398fc9fb5990c0a1c9f1c3bfb6f68a | MATLAB | 219 | 8 | function writer = write_recon_data()
writer.accepts = @(item) isa(item, 'gadgetron.types.ReconData');
writer.write = @write_recondata_to_socket;
end
function write_recon_data_to_socket(socket, recon_data)
end
|
27906af5e4a66a9dde4ddb3a166c792d38a1eeb4a6cca70e10648ee574dafec6 | MATLAB | 219 | 11 | function Y = shuffle(X)
% Randomly redorders cell and numeric arrays.
% Written by KGS Lab
% Edited by AS 8/2014
dims = size(X);
[~, new_order] = sort(rand(1, prod(dims)));
Y = X(new_order);
Y = reshape(Y, dims);
end
|
3f8e35ef7d921e76f79bd8dfeaf998b6a17b2e2517c2c422b812f30d6e57fdae | MATLAB | 222 | 9 | function write_optional(socket, item, write_handler, varargin)
if isempty(item)
write(socket, uint8(0));
else
write(socket, uint8(1));
write_handler(socket, item, varargin{:});
end
end
|
1fbc676adc8ccbe47511fa63279d76e07e47929d9876f5af100407c71867ee6d | MATLAB | 223 | 8 | function [result] = nanzscore(x)
% Usage: [result] = nanzscore(x)
%
% Calculates the zscore ignoring NANs
%
% Author: Enea Ceolini
result = bsxfun(@rdivide, bsxfun(@minus, x, mean(x,'omitnan')), std(x, 'omitnan'));
end
|
fb2f5c37dcad20ba37a62823adf3659b4d49a1f363c029678d43778a70f264d3 | MATLAB | 223 | 15 | function msk=mskcircle(sz)
m = sz;
x = 0:(m-1) ;
cent = (m-1)/2;
x2 = (x-cent).^2;
dst=zeros(m,m);
for i=1:m
dst(i,:)=sqrt((i-1-cent)^2+x2);
end
ind=find(dst <= cent);
msk=zeros([m,m]);
msk(ind)=1.0;
end |
8d1f63fe60e0e1f523a7d20273bdf16ee230c8d2b974696b129d4ab788064961 | MATLAB | 226 | 11 | function [yes] = is2d(ax)
% IS2D Returns true if the given axes are 2D.
yes = false(size(ax));
for iX = 1:numel(ax)
[az, el] = view(ax(iX));
yes(iX) = ( az == 0 && el == 90 );
end
end
|
a577c9b920ea31d54f23b03b943cd106623a080fe8f50f6f9545e424c0fc1d6b | MATLAB | 227 | 13 | %%
function [x] = structSelect(x, varargin)
for field = fieldnames(x)'
name = field{:};
items = x.(name);
if ~isempty(x.(name))
x.(name) = items(varargin{:});
end
end
end
|
c1214d3ae8c029bb22c49b4d9c3998d47ae42c375815323f1624b8ad0a27a501 | MATLAB | 228 | 7 | function [outputArg1,outputArg2] = encode_waveform_headers(inputArg1,inputArg2)
%ENCODE_WAVEFORM_HEADERS Summary of this function goes here
% Detailed explanation goes here
outputArg1 = inputArg1;
outputArg2 = inputArg2;
end
|
cda3b645bffadc2f2f9f6b5d0bfa52e491c1085d230e29eb1a8d9a029be1f299 | MATLAB | 228 | 11 | function saveMarker(data, markername, fname_out)
LFP{size(data, 2)} = [];
for ipart = 1 : size(data, 2)
try
LFP{ipart}.(markername) = data{ipart}.(markername);
catch
end
end
save(fname_out, 'LFP', '-v7.3')
|
0ac7111a41c8e1315b17f8468a6fb01c7ae8279a2dcae3972dc3e8463eabffe2 | MATLAB | 229 | 10 | % Like ndims(), except that column vectors are considered to have dimension 1 (and not 2)
function [N, sz] = ndims1(A)
sz = size(A);
if sz(end) == 1
sz(end) = [];
end
N = numel(sz);
end
|
7615344871bf78e450c73a22316499665639e41e305593ba388f61eecb7ec71f | MATLAB | 231 | 12 | setenv('PATH', [getenv('PATH') ':/usr/local/bin']);
setenv('DYLD_LIBRARY_PATH', '/usr/local/bin/');
d=which('rann32c.c');
[d,~,~]=fileparts(d);
cur_dir = pwd;
cd(d);
mex rann32c.c myprin.c rann_core.c rann_utils.c
cd(cur_dir); |
029e38a7d6dbe02769be5e9b36a076d03a5c3c2be8907e245c545a69267ce228 | MATLAB | 232 | 11 | function saveMarker_TFR(data, markername, fname_out)
TFR{size(data, 2)} = [];
for ipart = 1 : size(data, 2)
try
TFR{ipart}.(markername) = data{ipart}.(markername);
catch
end
end
save(fname_out, 'TFR', '-v7.3')
|
1f3f29988c26472fbbcee6d6c50e18b414413d42488fe7841fb09bd18879de41 | MATLAB | 232 | 11 | function saveMarker_FFT(data, markername, fname_out)
FFT{size(data, 2)} = [];
for ipart = 1 : size(data, 2)
try
FFT{ipart}.(markername) = data{ipart}.(markername);
catch
end
end
save(fname_out, 'FFT', '-v7.3')
|
db674d727f57a82d513eeb1cbea8b6ca7382cb63bff29623b2e5ebe57c140cb8 | MATLAB | 232 | 11 | function saveMarker_LFP(data, markername, fname_out)
LFP{size(data, 2)} = [];
for ipart = 1 : size(data, 2)
try
LFP{ipart}.(markername) = data{ipart}.(markername);
catch
end
end
save(fname_out, 'LFP', '-v7.3')
|
df75a242bf4809aa234aba9f3aed0fb3d6fec2d7e7deb194057aecb3f46494b1 | MATLAB | 232 | 10 | %%
function [out] = bssfun(fun, subset, varargin)
arrays = cell(size(varargin));
for iA = 1:numel(arrays)
arrays{iA} = multiplex(subset, varargin{iA});
end
out = bsxfun(fun, arrays{:});
end
|
8521fa6ea9d8fcd73567dbbb5d3005e0ca7b930975202273787b450851497d44 | MATLAB | 233 | 13 | %%
function [output, status] = start(varargin)
args = [varargin{:}];
if ~exist(args, 'file')
try
args = eval(args);
end
end
[status, output] = system(sprintf('start %s', args));
end
|
5f767f76fa1a242c2b1609d5f9ca9d59194f3859bcb310e91d0991d6e0297103 | MATLAB | 234 | 15 | function [f,g] = objfun_l2l1(x0,A,I,lambda);
[L M]=size(A);
batch_size = size(I,2);
a = reshape(x0,M,batch_size);
Ihat = A*a;
e = I - Ihat;
f = 0.5*sum(e(:).^2) + lambda*sum(abs(a(:)));
df = -(A'*e) + lambda*sign(a);
g = df(:);
|
8585f8af8a2feddd620d48dc083ca0d771f687da3db26851a56de7021655a9fb | MATLAB | 236 | 10 | function x = replaceSelection(x, sel, value)
% if nargin > 3 && interiorOnly
% interior = diff(double(sel), 1, 1) == 0;
% sel(2:end,:) = sel(2:end,:) & interior;
% end
x(sel) = value;
end
|
efa97ecea4c8809e04baebcbdfe16d2e9f54132519a2bc7edab9146e6d5fb3cf | MATLAB | 237 | 12 | function [y] = atcell(x, i)
% ATCELL Cell-specific addressing.
if iscell(x)
y = x{i};
elseif i == 1
y = x;
else
error('atcell:input', 'Cannot access element %d of non-cell object.', i);
end
end
|
f26707657b1e5f29c1e19542fa54c3f080d6068a9006b120de21f67d58a8d475 | MATLAB | 238 | 5 | function usc_rigid_reg(moving_filename, static_filename, output_filename, similarity)
%A wrapper for USC's rigid registration.
opts.similarity = similarity;
register_files_affine(moving_filename, static_filename, output_filename, opts);
|
5882aaf1ee34271075639a7bfaf316d338b70e4ea3cd9ffdd843800b2535ddf0 | MATLAB | 241 | 11 | function x=my_t1icdf(p)
% inverse cumulative distribution function of a t-dist. with 1 degree of freedom
%function p=my_t1icdf(x)
%input
% x = point
%output
% p = cumulative probability
%
%see also: tinv
x = tan(pi * (p - 0.5)); |
663e0fc2c245a1067314fa77d16b533f7b82c63d274dba7c83fc9a06f47a2937 | MATLAB | 244 | 7 | % Smooth L1-norm approximation : http://pages.cs.wisc.edu/~gfung/GeneralL1/L1_approx_bounds.pdf
function xNorm = smoothL1(x, alpha)
alphaX = alpha .* x;
xNorm = ( log(1 + exp(-alphaX)) + log(1 + exp(alphaX)) ) ./ alpha;
end
|
28531c3536b1de905b6428e6b464184ca28fe49f3fb945e435e1cb941b953f85 | MATLAB | 245 | 5 | function headers = read_header_array(socket, size, parse_fn)
dimensions = gadgetron.external.readers.read_vector(socket, 'uint64');
nbytes = prod(dimensions) * size;
headers = parse_fn(read(socket, nbytes, 'uint8'), dimensions);
end
|
0c80d8b1adbd5f28bd93dbc1e9a57fce62181a4de4b521ea0a48142f629c2c67 | MATLAB | 246 | 10 | function next = combine_channels(input)
function x = square(x), x = x .^ 2; end
function image = combine_channels(image)
image.data = sqrt(sum(square(abs(image.data)), 1));
end
next = @() combine_channels(input());
end
|
de1acb958876f096bd0cb45b5865c8640c27a49d9f1418893f85963ca68468ca | MATLAB | 249 | 8 | function CBIG_SPGrad_save_dump(filename)
% This function save a dump file <filename>.dump
% Written by Ru(by) Kong and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md
fclose(fopen([filename '.dump'],'w'));
end
|
9696f6b18f6a9b451ca4af7e7ad2e5f1586e0a9297481e261ff85b1a426fe20e | MATLAB | 251 | 14 | %%
% Truncates to zero entries with very tiny amplitudes relative to the
% range of values.
%
function [x] = chop(x, epsilon)
if nargin < 2
epsilon = 1e-10;
end
teensy = ( abs(x) < epsilon );
x(teensy) = 0;
end
|
fbdf4d51a4dd19a7be8db75aa9da47cf1d82277b9c740f5035a352034f27eeea | MATLAB | 252 | 10 | function jEditor = meditor(varargin)
desktop = com.mathworks.mde.desk.MLDesktop.getInstance;
jEditor = desktop.getGroupContainer('Editor').getTopLevelAncestor;
for iArg = 1:numel(varargin)
jEditor.(varargin{iArg});
end
end
|
43302819ae63fec53a9317dda13b7f7d711f0ff842034d74ea3337475fb0d5b1 | MATLAB | 256 | 11 | %%
% Like ceil() most of the time, but rounds down instead i.e. floor() if x
% is close enough to it.
%
function [y] = ceil2(x, varargin)
y = floor(x);
doCeil = ~approx(x, y, varargin{:});
y(doCeil) = y(doCeil) + 1;
end
|
27e9b02e9fd58b7d7d51b0025d955fac6d7ecef625b3b3fc69409f01396a7635 | MATLAB | 257 | 9 | function [image_ch] = load_channels_images(file_path, biom_ch)
%% Load channels images
% @author: speressotti
%% save different channels to different images
image = read_file(file_path);
image_ch = image(:,:,biom_ch);
end
|
36f3c422c23af981cdd479bc1b3fab8224e4394a8a3c5971b679fbabb8c097a5 | MATLAB | 258 | 9 | %% Converts an unwrapped angle (in radians) to the range [-pi, pi]
function [rad] = angleMPiPi(rad)
rad = rad ...
- ceil((rad - pi) / (2*pi)) ...
* 2*pi ...
;
end
|
0413fe8fd94a93640e4ed000288463465171cfcb5549904db4355b0650517705 | MATLAB | 259 | 17 | function t = sigTimeGenerate(data)
data = sort(data);
t(1,1) = data(1);
tmp = 0;
for i = 1:size(data,2)-1
if data(i+1) - data(i) > 4
tmp = tmp+1;
t(tmp,2) = data(i);
t(tmp+1,1) = data(i+1);
end
end
t(tmp+1,2) = data(end);
|
e74ca61501e499555612b9ddaca3b33c53ecdb61f7d25a485b4f382913d9e960 | MATLAB | 260 | 16 | %%
% Computes the extent of a vector in the sense of the size of the first
% non-singleton dimension.
%
function [length] = extent(x)
for L = size(x)
if L > 1
length = L;
return;
end
end
length = 1;
end
|
f32e154b07529acd3d2996ddf7796ab494f0ddd8eacf03c0f0472d4d00cd069a | MATLAB | 261 | 11 | %%
% Like floor() most of the time, but rounds up instead i.e. ceil() if x
% is close enough to it.
%
function [y] = floor2(x, varargin)
y = ceil(x);
doFloor = ~approx(x, y, varargin{:});
y(doFloor) = y(doFloor) - 1;
end
|
df718d74b929c15e11a2a83dc7d1ed18908daf01ed302738937729d670c86a02 | MATLAB | 262 | 12 | %%
%
function [color] = lighten(color, intensity, saturation)
color = colorspace('rgb->hsl', color);
color(:,3) = intensity;
if nargin > 2
color(:,2) = saturation;
end
color = colorspace('hsl->rgb', color);
end
|
5dead3499e81ea4de8c712b76f0a6ac41ff9d9655e8f6109aa5fd9b9ba8a5545 | MATLAB | 264 | 9 | %% Converts an unwrapped angle (in radians) to the range [-2*pi, 2*pi]
function [rad] = angleM2Pi2Pi(rad)
rad = rad ...
- ceil((rad - 2*pi) / (4*pi)) ...
* 4*pi ...
;
end
|
f6eef0e7c307b8eafa3a259533868d1410b7381b9607e6b2c053219d8228f860 | MATLAB | 264 | 11 | function saveMarker_SpikeTrials(data, markername, fname_out)
SpikeTrials{size(data, 2)} = [];
for ipart = 1 : size(data, 2)
try
SpikeTrials{ipart}.(markername) = data{ipart}.(markername);
catch
end
end
save(fname_out, 'SpikeTrials', '-v7.3')
|
224ee6a4d07e1b58e9f576e0b933eecea193865f809aaa57a41ce00274e12903 | MATLAB | 267 | 15 | function FastPrint(filename)
mydir=cd;
if isdir([mydir '/Figure'])==0
mkdir('Figure')
else
end
%To DO: If current directory=figures; up one level
a= [cd,'\Figure'];
mydir=cd;
cd(a)
print(gcf,'-djpeg90','-r300',filename);
savefig(filename)
cd (mydir)
|
8cb16f82b1d163aa9b2b113a4ddb82352da2a2295985c886985694e97dd2453d | MATLAB | 268 | 10 | function [s] = truncateStruct(s, elements, varargin)
% TRUNCATESTRUCT Truncates all given fields in the structure s to the
% given elements.
for iArg = 1:numel(varargin)
s.(varargin{iArg}) = s.(varargin{iArg})(elements);
end
end
|
915306546b99f8b738e42a46e7e7b21d51a2684c7244fc8b0779b9f74030b03d | MATLAB | 271 | 12 | function [biom_name] = find_biom_name(biom)
if strcmp(biom,'hoechst')
biom_name = 'Hoechst';
elseif strcmp(biom,'sox2')
biom_name = 'Sox2';
elseif strcmp(biom,'btub')
biom_name = '\beta-tubulin III';
elseif strcmp(biom,'gfap')
biom_name = 'GFAP';
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.