sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
409b09c1d7255ffcdb5b6b93e46576b07601de8e711be78073985dee95baf626 | MATLAB | 320 | 24 | rng(1)
N = 100;
Ny = 15;
Nx = 12;
Nz = 10;
Nw = 10;
nP = 100;
nRlz = 500;
pAr = zeros(Ny,min(Ny,Nx),nRlz);
pBr = zeros(Nx,min(Ny,Nx),nRlz);
for rlz = 1:nRlz
Y = randn(N,Ny);
X = randn(N,Nx);
Z = randn(N,Nz);
[pfwer,r,A,B,U,V,pA,pB] = permloads(Y,X,nP,Z,[],[],true,false);
pAr(:,:,rlz) = pA;
pBr(:,:,rlz) = pB;
end
|
4d299b8a472116e08db5855383b9a906de1ccb3b3658eb9b4eca01b2f1990827 | MATLAB | 321 | 12 | %{
experiment.FluorophoreEmissionSpectrum (lookup) # calcium-sensitive indicators Spectrum
-> experiment.Fluorophore
loaded : tinyint #
---
wavelength : longblob #
fluorescence : longblob #
%}
classdef FluorophoreEmissionSpectrum < dj.Relvar
en... |
5482bbcbd7d528899ea8260f734d2a8fbaed08085a7a7cdab1b4ee9c50ad74db | MATLAB | 321 | 17 | function [data] = tapas_sem_hier_data(data, model, pars)
%% Get the date from the hgf.
%
% Input
% hgf -- Array of complete hgf models.
% pars -- Parameters structure
% Output
% data -- Structure with the data
% aponteeduardo@gmail.com
% copyright (C) 2016
%
data = data;
end
... |
67174f4c7bc6b872110f64115ccae00c68771dd23479483c7b9ca6d6390cf5b2 | MATLAB | 321 | 17 | function [gk] = tapas_trans_mv2igk(mu, sigma2)
%% Transforms the parameters to their native space
%
% Input
% mu -- Means
% sigma2 -- Variance
%
% Output
% gk -- K parameter of an inverse gamma distribution
% aponteeduardo@gmail.com
% copyright (C) 2015
%
gk = (mu.^2 ./ sigma2) + 2;
end... |
7e583b418857449e155a96a0c968010adc1d524d9bbc4518be8032537d89fb4b | MATLAB | 321 | 20 | function W = alignW(W, nt0min)
[nt0 , Nfilt] = size(W);
[~, imax] = min(W, [], 1);
dmax = -(imax - nt0min);
% dmax = min(1, abs(dmax)) .* sign(dmax);
for i = 1:Nfilt
if dmax(i)>0
W((dmax(i) + 1):nt0, i) = W(1:nt0-dmax(i), i);
else
W(1:nt0+dmax(i), i) = W((1-dmax(i)):nt0, i);
end
end
... |
8edc3ed18fca09ada47c8f4cc0df608b2f3040320827e6486db5edfdd0e0c881 | MATLAB | 321 | 20 | %{
# receptive field map
-> tune.STA
-> fuse.ActivityTrace
---
map : longblob # receptive field map
%}
classdef STAMap < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
self.insert(key)
end
end
en... |
ee0120d0c2f12516b11bc296b14c63da0b0b1bc7bba3d380c898dbee133d1dfd | MATLAB | 321 | 18 | function [states] = tapas_sem_hier_init_states(data, model, inference)
%% Generates the data structure to store the samples.
%
% Input
%
%
% Output
% data -- Cell array with nx1 cells, where n = niter
%
% aponteeduardo@gmail.com
% copyright (C) 2016
%
states = cell(inference.niter, 1);
end
... |
42d416bc5758f85ab6feac09013f22788a529497a40de5d606c265e65eb26281 | MATLAB | 322 | 18 | %{
# l6-norm of each pixel across time
-> reso.SummaryImages
---
average_image : longblob #
%}
classdef SummaryImagesAverage < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.insert(key)
end
end
e... |
665eee5d73121d23510cbe0fbeaaa9faf501cf2f838cab72a751834eb6824404 | MATLAB | 322 | 19 | %{
# scans that are fully processed (updated every time a field is added)
-> meso.ScanInfo
-> shared.SegmentationMethod
-> shared.SpikeMethod
%}
classdef ScanDone < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.insert(key)
end
end
e... |
ba4bee7b7d5f15ccb51c12b85e3012e51e403469784dd4408108b21827852241 | MATLAB | 322 | 17 | function s = ivim_modeling_noise(x,b,sigma)
%IVIM analysis
%s = s0*((1-f)exp(-b.D) + f.exp(- b(D + Dstar)))
%x = [f,D,Dstar];
f = x(1);
D = x(2);
Dstar = x(3);
s0 = x(4);
s = s0*((1-f)*exp(-b*D) + f*exp(-b*Dstar));
% n = 8;
% navg = 4;
% s = sqrt(s.^2 + 2*n*sigma.^2/navg);
s = sqrt(s.^2 + sigma.^2);... |
eb1ad491408071ca59473fc00d948cca4b9ae34d24b6932e0729800e9bceb8f5 | MATLAB | 322 | 19 | %{
# scans that are fully processed (updated every time a slice is added)
-> reso.ScanInfo
-> shared.SegmentationMethod
-> shared.SpikeMethod
%}
classdef ScanDone < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.insert(key)
end
end
e... |
ecde754479366ebee116454a99b264191983dd44f7cb8a5202bda32957fa004b | MATLAB | 322 | 13 | =============== MNIcheck
√ MNIcheck T1 to MNI alignment movie.. toggle through T1s
itksnap -g ~/nsd/nsddata/templates/MNI152_T1_1mm.nii.gz -o ~/nsd/nsddata/ppdata/subj??/anat/T1_to_MNI.nii.gz
auto contrast normalize.
use quicktime and select portion of screen
screen record -> handbrake (HQ 720)
-> MNIcheck.mp4
|
aba4c1c2e96ed1146d9e704eba7738bd9a1223576624543fab354306f70c4f08 | MATLAB | 323 | 20 | %{
#Brain Area
brain_area : varchar(12) # short brain area name
%}
classdef Area < dj.Lookup
properties
contents = {
'V1'
'P'
'POR'
'PM'
'AM'
'A'
'RL'
'AL'
'LI'
'LM'
}
end
... |
bf6ee8ddff3adafe489cc3ec8bb33c3b28715db3420c3ca044c3124c8d2af9f4 | MATLAB | 323 | 12 | classdef nndropout < nntest
methods (Test)
function basic(test)
x = test.randn(4,5,10,3) ;
[y,mask] = vl_nndropout(x) ;
dzdy = test.randn(size(y)) ;
dzdx = vl_nndropout(x,dzdy,'mask',mask) ;
test.der(@(x) vl_nndropout(x,'mask',mask), x, dzdy, dzdx, 1e-3*test.range) ;
end
end
en... |
ef53163f5e03f71ca679b649b5441d7727660d01beff260f742ae153653ef80a | MATLAB | 323 | 18 | function [states] = tapas_sem_multiv_init_states(data, model, inference)
%% Generates the data structure to store the samples.
%
% Input
%
%
% Output
% data -- Cell array with nx1 cells, where n = niter
%
% aponteeduardo@gmail.com
% copyright (C) 2016
%
states = cell(inference.niter, 1);
en... |
1b2d685de20e6a5334a549ca78fe92bac6ecfcaa3efbe88c13217c60dc744753 | MATLAB | 324 | 11 | function v = setLayerInputs(obj, layer, inputs)
%SETLAYERINPUTS Set or change the inputs to a layer
% Example: NET.SETLAYERINPUTS('layerName', {'input1', 'input2', ...})
v = [] ;
l = obj.getLayerIndex(layer) ;
for input = inputs
v(end+1) = obj.addVar(char(input)) ;
end
obj.layers(l).inputs = inputs ;
obj.rebuild(... |
2d78f0044e22d21355c98f6e2e3a5a29cb96dd72997b19ad8d269f3e31535e4b | MATLAB | 324 | 18 | function obj = apply_internal(obj)
% ----------
% Initialise
% ----------
obj.init_latent();
obj.init_elbo_parts();
obj.elbo_obs();
obj.elbo_latent();
% --------------
% Compute latent
% --------------
obj.update_latent();
obj.elbo_obs();
obj.elbo_latent();
... |
8c10480a5fcc416ff1c3787cdbd43baf3290287348abeb3c852d477dc2c69107 | MATLAB | 324 | 13 | %{
# projector set up
-> Projector
-> ProjectorConfig
-> Rig
---
display_width : float # projected display width in cm
display_height : float # projected display height in cm
target_distance : float # distance from mouse to the display in cm
%}
classdef ProjectorSetup < dj.Lookup... |
e05ec3c3e076b972afe0d5bee311b3d21deb274892b0be2e4b49d507a40d5184 | MATLAB | 324 | 10 | %{
# projector specifications
projector_id : tinyint # projector id
---
pixel_width : smallint # number of pixels in width
pixel_height : smallint # number of pixels in height
%}
classdef Projector < dj.Lookup... |
2c8d9938dfe014a7c926ae5f5f44c068c98dee1363696eaf57dc6ba29ced6fa7 | MATLAB | 325 | 12 | classdef Tanh < dagnn.ElementWise
methods
function outputs = forward(obj, inputs, params)
outputs{1} = tanh(inputs{1});
end
function [derInputs, derParams] = backward(obj, inputs, params, derOutputs)
derInputs{1} = derOutputs{1}.*(1 - tanh(inputs{1}).^2);
derParams = {} ;
end
en... |
c68b56dc0424d9a447460212a4d1ba07e9cde5a364dcc8cea547747f4468e5ae | MATLAB | 325 | 18 | function Pipeline_getROI(params)
% This function launches a GUI for selecting ROIs in imaging data
MovFn = getFileName(params, 'Mov');
analysisDir = getAnalysisDir(params);
mov = [];
if exist(fullfile(analysisDir, MovFn), 'File')
load(fullfile(analysisDir, MovFn));
end
vImageGUI(params, mov);
... |
9033e42cd898c987d1b748e186c137b1252cb099a34c7e4cbf0f0f8243c74c09 | MATLAB | 326 | 16 | function [Xsm] = causal_smooth_SS(X,win)
%simple code to do smoothing using data from future only
Xsm = zeros(size(X));
ns = numel(X);
for j = 1:ns
if isnan(X(j))
Xsm(j) = nan;
elseif j < win
Xsm(j) = 1/j*sum(X(1:j));
else
Xsm(j) = 1/win*sum(X(j-(win-1):j));
end
... |
0065ace5889133f7efbafce8b22ccd22838961543ca664016078d5e34a1c83da | MATLAB | 327 | 13 | function s = sanitize_label(label)
% SANITIZE_LABEL Make a label safe for folder/filenames.
%
% - Converts to char
% - Trims spaces
% - Replaces internal spaces with underscores
% - Replaces file separators with dashes (just in case)
s = char(label);
s = strtrim(s);
s = strrep(s, ' ', '_');
s = strrep(s, filesep, '-'... |
232de222999939ca48359cfc35b6333528892fa2dd10ff4e2578ce793ecc0b5e | MATLAB | 327 | 14 | function ind = sero_pulseq_getExcitationBlockInd(seq)
% function ind = sero_pulseq_getExcitationBlockInd(seq)
%
% Function returns a list of indices that correspond to excitation events.
nBlock = numel(seq.blockEvents);
ind = [];
for i = 1:nBlock
if all(seq.blockEvents{i}([2 5 7]))
ind(end+1) = i;
e... |
8546a9986c3da2508c26c0198bfa2f894ac870c992eb74ebdf03991488f8d3ed | MATLAB | 327 | 15 |
function [buni b] = discritizeBvals(ten)
%%
b = squeeze(ten(1,1,:)+ten(2,2,:)+ten(3,3,:))-eps;
v = -0.1:0.1:10;
h = imfilter(histc(b,v),fspecial('gaussian',[7 1])) - 0.00001*v';
buni = v(find(h>imdilate(h,[1 0 1]'))+1);
[~,idx] = min(abs(repmat(b,[1 length(buni)]) - repmat(buni,[length(b) 1])),[],2);
b = buni(idx);
... |
473883c0c810f48f1f59bdfeb84ec925f50d13517d9e9dbe7b897178368a58f4 | MATLAB | 328 | 16 | function pd = BullwinklePDatFAR(score,far)
% go through the scores backwards, find the first PD event at less than or equal far
pd = 0;
for i=size(score.Bullwinkle,1):-1:1
if strcmp(score.Bullwinkle{i,7},'tbfi') && score.Bullwinkle{i,3} <= far
pd = score.Bullwinkle{i,2};
break;
end
e... |
72a94ba5cc041fb3e4227705905f68b1f73a5cf8c80f08ec2a835d0e510e8228 | MATLAB | 328 | 8 | function ShowImage(I) % by Julia Becker, 01/04/2020, additions 27/04/2021 concerning maximising
imshow(I);
axis image
hold on;
set(gcf, 'WindowState','maximized'); % to display properly maximized
%set(gcf, 'Position', get(0, 'Screensize')); % old version, somewhat slightly bigger than maximized on some screen... |
a0291cb74a25131ad69fa157385cf11413e176104c7f52fb32ea88ce8cdd2fa5 | MATLAB | 328 | 12 | classdef Tanh < dagnn_bc.ElementWise
methods
function outputs = forward(obj, inputs, params)
outputs{1} = tanh(inputs{1});
end
function [derInputs, derParams] = backward(obj, inputs, params, derOutputs)
derInputs{1} = derOutputs{1}.*(1 - tanh(inputs{1}).^2);
derParams = {} ;
end
... |
f275130e299b5cf10362687f8b8a550fc2cf0834b94021887af1a476f6b7bf1f | MATLAB | 329 | 11 | function v = setLayerParams(obj, layer, params)
%SETLAYEPARAMS Set or change the parameters of a layer
% Example: NET.SETLAYERPARAMS('layerName', {'param1', 'param2', ...})
v = [] ;
l = obj.getLayerIndex(layer) ;
for param = params
v(end+1) = obj.addParam(char(param)) ;
end
obj.layers(l).params = params ;
obj.reb... |
1cc4c02b2ef95b44595bf9b9f7def1122feba71a32db4e02d58aff0b1b4013c3 | MATLAB | 330 | 11 | % Creates <alldata> in the workspace.
%
% This may be too expensive now that we are doing func1pt8mm... we load only 1:3
% load the data
tic;
alldata = {};
for hh=1:3 %length(datanames)
alldata{hh} = h5read(sprintf('~/ext/figurefiles/nsd/datab3nativesurface_subj%02d_%s_betas.hdf5',subjix,datanames{hh}),'/betas');... |
4728e8ea69c081649924fc4c3dbeecb6af26c70cdc6c74a03dccf4afee69aaeb | MATLAB | 330 | 6 | %%
load all_unitinfo % metainfo for each neuron
load rmANOVA % data of the partial eta squares and p-values obtained by the repeated-measures ANOVA for each neuron
%%
figure('Position',[281 304 735 317])
[ celldata ] = plot_2E(all_unitinfo,all_ps,all_etas,all_etas_imperm_boot,all_etas_qperm_boot,... |
877236e47eef6626ceb3973be460e44962f3a90ad16d5af7095d9bbd8a7ae4b5 | MATLAB | 331 | 8 | % (C) Copyright 2020 CPP visual motion localizer developpers
function [nbBlocks, nbRepet, nbEventsBlock, maxTargBlock] = getDesignInput(cfg)
nbRepet = cfg.design.nbRepetitions;
nbEventsBlock = cfg.design.nbEventsPerBlock;
maxTargBlock = cfg.target.maxNbPerBlock;
nbBlocks = length(cfg.design.names) * nb... |
91d8cd053bb92e732d800d8a3498457f8ccefc680f781d21e120220eac657f02 | MATLAB | 331 | 8 | function draw_slices(img,nm,zslice)
hf=figure; hf.Position=[100 100 1100 300]; hf.Color='w';
for i=1:length(zslice)
subplot(1,4,i);
imagesc(flipud(rot90(img(:,:,zslice(i))))); set(gca,'YDir','normal'); %axis off; axis equal;
xlabel('dim 1'); ylabel('dim 2'); title(sprintf('z=%d',zslice(i)));
end
s... |
e2290426246f9163cd695bc0d88a67a77fb62e809615fca1aeff80f367236ee0 | MATLAB | 331 | 11 | %{
preprocess.ClusterPeaks (lookup) # my newest table
# add primary key here
peakorder=1 : tinyint # 1=cluster around absolute maximum,
# 2=cluster around the next peak after removing the previous cluster elements
-----
# add additional attributes
%}
classdef ClusterPeaks < dj... |
82c1efa264d53b6f2876e08cd96e1afd7dd50c8fc8d2d3e2c2bce876a615fc6a | MATLAB | 332 | 7 | function time_index = getTimeInd(time_vector,limits)
%function time_index = getTimeInd(time_vector,limits)
%time_vector: 1xn vector of time points
%limits: 1x2 vector of time range limits
%time_index: 1xn logical vector with ones between limits(1) and limits(2)
time_index = time_vector>=limits(1) & time_vector<=lim... |
71543b71167717c09a8bfdc066bd1258981ed0ddf150571250827558b9e54568 | MATLAB | 333 | 12 | classdef nnoffset < nntest
methods (Test)
function basic(test)
param = [.34, .5] ;
x = test.randn(4,5,10,3) ;
y = vl_nnnoffset(x,param) ;
dzdy = test.randn(size(y)) ;
dzdx = vl_nnnoffset(x,param,dzdy) ;
test.der(@(x) vl_nnnoffset(x,param), x, dzdy, dzdx, 1e-3*test.range) ;
... |
e835d91b044e16bd760e1ca4c48d957bb27e14f7e9e653489b54115d3dd72324 | MATLAB | 333 | 19 | %{
# my newest table
-> preprocess.PrepareGalvoAverageFrame
---
frame_contrast : float # compute frame contrast
%}
classdef FrameContrast < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
%self.insert(key)
... |
42427572e90fc4cf81e46be632b5a21e870e494701472df7bd8957a7e34ac39a | MATLAB | 334 | 15 | function H = signal2hankel(x, embeddim)
%
import misc.ispset;
import misc.subset;
if nargin < 2 || isempty(embeddim), embeddim = 1; end
if ispset(x),
tmp = delay_embed(x, embeddim, 1);
else
tmp = misc.delay_embed(x, embeddim, 1);
end
%H = flipud(subset(tmp, [],1:(size(x,2)-embeddim+1)));
H = ... |
494f40410a288030363b4c34100e6e1eedeca35e044af5ec424a8d508e64dc6a | MATLAB | 334 | 19 | %{
# my newest table
-> preprocess.PrepareGalvoAverageFrame
---
frame_contrast : float # compute frame contrast
%}
classdef FrameConstrast < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
%self.insert(key)
... |
8676269ee29e6b714ead8f635c0791e1e23ddd1686a92b4f1375ae005ad337c8 | MATLAB | 334 | 7 | function ret = findOutliers(data)
% must be 1d array
% outlier detection: identify data that do not pass the MAD-based test, while ensuring that it never detects more than 5% of the highest or lowest values.
madOutliers=findScaledMADOutliers(data);
perOutliers=findFivePercentageOutliers(data);
ret=and(madOutliers, perO... |
d57fe6804d95f071d3fc3df6541c46cb7852d01e566618b22ea3ba60ce90cdef | MATLAB | 334 | 24 | function xps = sero_srr_xps_load(fn_xps)
% function xps = sero_srr_xps_load(fn_xps)
load(fn_xps)
if exist('xps', 'var')
%do nothing
else
xps.tr = tr;
xps.b = b;
try
xps.w = w;
catch
end
end
if ~isfield(xps, 'w')
xps.w = xps.tr>0;
warning('Filling in weight matrix f... |
4d84d02a5b4b0d1774af6018e5c9d9d8533853f74e34f18ff9f6c760c4cd4569 | MATLAB | 335 | 17 | function x = Renumber(x,mode)
% This function takes a vector and renumbers all the entries so there are
% no gaps between them and they start from one.
%
% EXAMPLE
% x = [30 4 4 5 30 6];
% x = Renumber(x);
%
% This returns [1 2 2 3 1 4].
if ~exist('mode','var')
mode = 'stable';
end
[~,~,x] = u... |
2811072629ab9034ee44f13fcc18d5f799052b15f4cc53fbf66c10c54f9405e0 | MATLAB | 336 | 13 | %{
preprocess.ExtractRawTrace (imported) # raw trace, common to Galvo
-> preprocess.ExtractRaw
-> preprocess.Channel
trace_id : smallint #
---
raw_trace : longblob # unprocessed calcium trace
%}
classdef ExtractRawTrace < dj.Relvar
% it's a part table o... |
403918a857c36af27a2d6a872e316de5370d8d08c9f04a9c70d58a2ef32562a0 | MATLAB | 336 | 11 | function v = setLayerOutputs(obj, layer, outputs)
%SETLAYEROUTPUTS Set or change the outputs of a layer
% Example: NET.SETLAYEROUTPUTS('layerName', {'output1', 'output2', ...})
v = [] ;
l = obj.getLayerIndex(layer) ;
for output = outputs
v(end+1) = obj.addVar(char(output)) ;
end
obj.layers(l).outputs = outputs ;
... |
8c0e619a1b1fdd70c5a90c9a481045743590a8ce46abb8b50deca995415fd117 | MATLAB | 336 | 12 | classdef Sigmoid < dagnn.ElementWise
methods
function outputs = forward(obj, inputs, params)
outputs{1} = vl_nnsigmoid(inputs{1}) ;
end
function [derInputs, derParams] = backward(obj, inputs, params, derOutputs)
derInputs{1} = vl_nnsigmoid(inputs{1}, derOutputs{1}) ;
derParams = {} ;
... |
1353768bc620f3e5c970b8dc08899feafda10e5b67f128e1069e559275d394ec | MATLAB | 337 | 6 | function stub = create_stub(address)
credentials = javaMethod("create", "io.grpc.InsecureChannelCredentials");
channel_builder = javaMethod("newChannelBuilder", "io.grpc.Grpc", address, credentials);
channel = channel_builder.build;
stub = javaMethod("newBlockingStub", "org.pesaranlab.thalamus_grpc.ThalamusGrpc... |
48fa6aac3078d809d03a4a7e662ac81eeafd7a3eddc4e69bd99f2c2c2f6cd553 | MATLAB | 337 | 11 | %{
# Trial times in 2pMaster clock
-> experiment.Scan
---
trial : double # Trial idx of stimulus
ts : timestamp # real time of frame
counter_ts : double # counter time
%}
classdef TrialTime... |
d81c7c9b605f6131a3b6ea5a526c8ac7c1529b3c0c31b84561c3544bfc14dd19 | MATLAB | 337 | 14 | function [posterior] = tapas_sem_multiv_prepare_posterior(data, model, ...
inference, states)
%% Prepate the output of the inference algorithm. Use the same method as
% the tapas_sem_hier.
%
% aponteeduardo@gmail.com
% copyright (C) 2016
%
posterior = tapas_sem_hier_prepare_posterior(data, model, inference, ...
... |
565d652db3f0cac23f4ef64fdcdf30f51d04cd1936b30f62a116a5f5ebfe55c5 | MATLAB | 339 | 12 | classdef Sigmoid < dagnn_bc.ElementWise
methods
function outputs = forward(obj, inputs, params)
outputs{1} = vl_nnsigmoid(inputs{1}) ;
end
function [derInputs, derParams] = backward(obj, inputs, params, derOutputs)
derInputs{1} = vl_nnsigmoid(inputs{1}, derOutputs{1}) ;
derParams = {} ;... |
b3682a38551bfdaf5b56a1ce984bbb6805e6d24cb0bf580e882f3d378c085f4c | MATLAB | 339 | 15 | clear all; close all; clc;
n = 5;
m = 15;
trnsp = true;
M = hyperbolicfactory(n, m, trnsp);
problem.M = M;
A = randn(size(problem.M.rand()));
problem.cost = @(X) .5*norm(X - A, 'fro')^2;
problem.egrad = @(X) X-A;
problem.ehess = @(X, Xdot) Xdot;
checkgradient(problem); pause;
checkhessian(problem); pause;
X = M.rand()... |
c6531007b2408b8d44ea4794ce05fa4e2ac66527c03f05817f8be61a9a74a483 | MATLAB | 339 | 14 | function [output] = getAttackSeconds(ParsedData)
%% getAttackSeconds
% Returns attack time for every trials. 3 or 6
numTrial = size(ParsedData,1);
output = zeros(numTrial,1);
for trial = 1 : numTrial
if ParsedData{trial,4}(1) - ParsedData{trial,3}(1) > 4.5
output(trial) = 6;
else
output(trial)... |
b6e460682352cd370c87d55b7c3d5ad26d2ec1fc011d4fa995ba8e6c4d180308 | MATLAB | 340 | 12 | r = rf.Session & 'session_date>"2016-02"';
while true
parpopulate(pre.ScanInfo, r)
parpopulate(rf.Sync)
parpopulate(pre.ScanCheck, r)
parpopulate(pre.AlignRaster, r)
parpopulate(pre.AlignMotion, r)
parpopulate(pre.AverageFrame, r)
parpopulate(pre.Segment)
parpopulate(pre.ExtractTraces)
... |
cb7bf0eaa02f287c97bfc0939ac44aee56304d9b56969f1c7db081e83a5be29a | MATLAB | 340 | 10 | function filename = getFilename( obj )
assert( length(obj)==1 );
[path,name] = fetch1( Experiments*obj, 'directory','file_name' );
if strcmp(fetch1(obj,'scan_prog'),'MPScan')
filename = getLocalPath([path '/' name 'p%u.h5']);
elseif strcmp(fetch1(obj,'scan_prog'),'ScanImage')
filename = getLocalPath([path '/' ... |
50105711e6ab88213b4949105152c89345b1c64c42db12e1b3aca0f6454b0ec1 | MATLAB | 341 | 12 | %{
#
-> eye.Eye
---
tracking_ts=CURRENT_TIMESTAMP: timestamp # automatic
min_lambda=null : float # minimum mixing weight for current frame in running average computation (1 means no running avg was used)
%}
classdef ManuallyTrackedContours < dj.Manual
% Impl... |
761fd3bb695eaedb2be288fb68dba55a76263f34e9dba0e5dadbf77e36b41682 | MATLAB | 341 | 14 | function [datafilt]=movieTimeFiltering(data, freqBand,fs)
% fast temporal filtering of movie (3D matrix). Time is assumed to be the
% last dimension.
d=size(data);
temp=reshape(data,d(1)*d(2),d(3));
[b,a]=butter(3,freqBand/(fs/2),'bandpass');
tic;
datafilt=filtfilt(b,a,double(temp'));
toc;
datafilt=reshape(datafilt'... |
ce1b637518c4dfcccbbc7edc2ff4c678396646ea602bbf3dc2ec7e8a9091020c | MATLAB | 341 | 13 | function [xtdvals, xtdlabels] = get_logsec_xticks
trial = 1;
minute = log(60);
hour = log(60*60);
day = log(24*60*60);
week = log(24*60*60*7);
month = log(24*60*60*30);
year = log(24*60*60*365);
xtdvals = [trial minute hour day week month year];
xtdlabels = {'1 Trial','1 Minute','1 Hour','1 Day','1 Week'... |
d72c9f41a993ddddf86ca63548024f555c46f557ab516f1eba6036aa18380deb | MATLAB | 341 | 11 | %{
# Frame times with 2pMaster clock
-> experiment.Scan
---
frame : double # Frame idx of Scan Image
ts : timestamp # real time of frame
counter_ts : double # counter time
%}
classdef Frame... |
066eb7d1e49332aa9fed00453a6609f2b45b1db076ac9f0d5ceb1bfbf0e4d92c | MATLAB | 342 | 20 | %{
# activity inferred from fluorescence traces
-> reso.ScanSet
-> shared.SpikeMethod
---
activity_time=CURRENT_TIMESTAMP: timestamp # automatic
%}
classdef Activity < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.inser... |
69be195f86433440c9e87991b7d721b96a3509a7407d2168abcc4669725e342c | MATLAB | 342 | 21 | function [trace, deltaF] = getTrace(movie, mask)
% return the trace within the mask
[m,n,p] = size(movie);
if nargin<2
mask = ones(m,n);
end
movie2 = bsxfun(@times, movie, mask);
trace = zeros(p,1);
parfor i=1:p
trace(i) = mean(nonzeros(movie2(:,:,i)));
end
parfor i=1:p
deltaF(i) = (trace(i)-trace(... |
7f2c9b2607154e2373841065c5e4cd564da29ba545aaca73c08302f8b69bfbda | MATLAB | 342 | 20 | %{
# activity inferred from fluorescence traces
-> meso.ScanSet
-> shared.SpikeMethod
---
activity_time=CURRENT_TIMESTAMP: timestamp # automatic
%}
classdef Activity < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.inser... |
9bb0991b940b9cb8054a11bc534660c68ffa91ebc29ee795c4957a9fbfe2e176 | MATLAB | 342 | 13 | function [zSampled, zMean, zLogvar] = sampling(encoderNet, x)
compressed = forward(encoderNet, x);
d = size(compressed,1)/2;
zMean = compressed(1:d,:);
zLogvar = compressed(1+d:end,:);
sz = size(zMean);
epsilon = randn(sz);
sigma = exp(.5 * zLogvar);
z = epsilon .* sigma + zMean;
z = reshape(z, [1,1,sz]);
zSampled = d... |
cd85df7185fc74584061e30d1af1f25d3b420d45859b9028a593f91c53997fe2 | MATLAB | 342 | 7 | function [episode_mean] = get_episode_mean(zscore_trace,this_eventonset_frames,this_eventoffset_frames)
this_episode_frames = arrayfun(@(x,y)[x:y],this_eventonset_frames,this_eventoffset_frames,'UniformOutput',false);
this_episode_frames = cell2mat(this_episode_frames');
episode_mean = nanmean(zscore_trace(this_ep... |
2a0c44573f530d25bba3dc5c698d05b150d0dbe68b6db423e11381ac6578726d | MATLAB | 343 | 10 | function tapas_BLT_runEnd_almost(params)
% tapas_BLT_runEnd_almost shows a screen once the task is finished but further
% measures are still needed
% Show Cue
Screen('DrawTexture', params.screen.window, params.text.endfieldmap, [], params.screen.fit, 0);
Screen('Flip', params.screen.window);
% Wait
params = wait2_es... |
84c7c6345206ea02ee4087f14d740d59ba95cf1c07d903beabac4646a71bc13b | MATLAB | 343 | 27 | function [pars] = tapas_linear_pars(pars)
%%
%
% aponteeduardo@gmail.com
% copyright (C) 2016
%
if ~isfield(pars, 'T')
pars.T = linspace(0.01, 1, 16) .^ 5;
end
if ~isfield(pars, 'ndiag')
pars.ndiag = 500;
end
if ~isfield(pars, 'seed')
pars.seed = 0;
end
if pars.seed > 0
rng(pars.seed);
else
rng... |
8bb98db670ad96d47ffd8254a5abd5f48557260c309107e5fd4e24ba8ba5b6a2 | MATLAB | 343 | 12 | %{
# Photodiode voltage for different pixel intensities
-> experiment.Session
---
luminance : mediumblob # luminance in cd/m^2
px_value : mediumblob # pixel intensity values
pd_voltage : mediumblob # photodiode voltage at specified pixel values
%}
classdef Displ... |
d60f5e2897cf11c9346a2b30ef81e7b409fb1e1751f82d23ffe89203fa49f874 | MATLAB | 343 | 15 | function obj = elbo_mean(obj)
if ~isfinite(obj.nm0) || obj.nm0 == 0
obj.lbm = 0;
else
D = prod(obj.lat);
obj.lbm = obj.nm0/D * obj.elbo_parts.trLM ...
+ obj.nm0/obj.nm ...
+ log(obj.nm/obj.nm0) ...
- 1;
obj.lbm = - 0.5 * D ... |
3fa02c415ef06a2b91e019bef9bccb2a8fc869104818dfb9647702865cad3e39 | MATLAB | 344 | 17 | function h = sero_pulseq_plotShots(seq, n)
% function h = sero_pulseq_plotShots(seq, n)
%
% seq is the pulseq sequence object
% n is the 1x2 shot interval vector [start end].
if nargin < 2
n = 1;
end
if numel(n) == 1 %#ok<ISCL>
n = [n n];
end
indBlock = sero_pulseq_shotToBlockInd(seq, n);
h = sero_pulseq_pl... |
92802275210270822d72fac5f7cb10d3dde66d679c4a8e946f1dadc077bc61ea | MATLAB | 344 | 19 | %{
#
-> preprocess.MatchedMasks
-> preprocess.ExtractRawGalvoROI
other_trace_id : smallint # index of the other scan
%}
classdef MatchedMasksMatchedID < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
%self.ins... |
3e13f8170d3a02ef0c76c55ea0b78d85e719e841b76ee90f591a4bd78ce58716 | MATLAB | 345 | 12 | %{
experiment.ScanLaser (manual) # Laser parameters for the scan
-> experiment.Scan
---
wavelength : float # (nm)
power : float # (mW) to brain
gdd : float # gdd setting
%}
classdef S... |
82eef8d7c0006b0e891772922c8764fd8f2bdac18b701cbd6ed148d923941631 | MATLAB | 345 | 20 | %{
# Different mask segmentations.
-> meso.MotionCorrection
-> meso.SegmentationTask
---
segmentation_time=CURRENT_TIMESTAMP: timestamp # automatic
%}
classdef Segmentation < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.in... |
855fb878bfad8b1db6829c516bc15cc94618fe5fc6743e4d46e663cc5993ab30 | MATLAB | 345 | 14 | % bidirectionally align 3D movie, manual shift
function movieL = bidi_align_manual(movie,shift)
movieL = zeros(size(movie));
for j = 1:size(movie,3)
for o = 1:size(movie,1)/2
movieL((o-1)*2+2,:,j) = circshift(movie((o-1)*2+2,:,j),[0 0]);
movieL((o-1)*2+1,:,j) = circshift(movie((o-1)*2+1,:,j),[0 -... |
dac4661fed3cb893d0e4539fc232e8eef2754f28014e74673718e2a1eeea3788 | MATLAB | 345 | 20 | %{
# Different mask segmentations.
-> reso.MotionCorrection
-> reso.SegmentationTask
---
segmentation_time=CURRENT_TIMESTAMP: timestamp # automatic
%}
classdef Segmentation < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.in... |
9b5780316c3b54007347461132e0397b408e1ea2aad1e9cab21ff4051f834404 | MATLAB | 346 | 21 | %{
# deconvolved calcium acitivity
-> meso.ScanSetUnit
-> shared.SpikeMethod
---
-> meso.Activity
trace : longblob #
%}
classdef ActivityTrace < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.i... |
f7ac201da4cb204292adcef1acee28e01d76882d4cec7e47ce4c49d00aa7b24f | MATLAB | 346 | 21 | %{
# deconvolved calcium acitivity
-> reso.ScanSetUnit
-> shared.SpikeMethod
---
-> reso.Activity
trace : longblob #
%}
classdef ActivityTrace < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self.i... |
98428242f5663caaeddd89442f21362ac42fabf1b144e1cf9a23cb303055d63f | MATLAB | 347 | 16 | % M = obliquecomplexfactory(5, 10, false);
% M = obliquefactory(5, 10, false);
% M = spherecomplexfactory(5, 10);
% M = spheresymmetricfactory(5);
% M = complexcirclefactory(5);
M = realphasefactory(5);
X = M.rand();
U = M.randvec(X);
U = U / M.norm(X, U);
t = 1e-9;
Y = M.exp(X, U, t);
abs(M.dist(X, Y) - t)/t
abs(M.... |
08393db16d7cb68bbfa695afe1252f72e012cdde0e0650d67874e9488b1ce93d | MATLAB | 348 | 13 | function allSpikeTimes = combineAllChannelSpikeTimes(spikeTimes, method)
%COMBINEALLCHANNELSPIKETIMES Summary of this function goes here
% Detailed explanation goes here
allSpikeTimes = [];
for channelIdx = 1:length(spikeTimes)
allSpikeTimes = [allSpikeTimes; spikeTimes{channelIdx}.(method)];
end
allSpikeTimes... |
599bee656d9cbc85d4f19fff01c1db9efeb9d1f52d934bad07be69c696839116 | MATLAB | 348 | 21 | %{
# mean intensity values across time
-> reso.Quality
-> shared.Field
-> shared.Channel
---
intensities : longblob #
%}
classdef QualityMeanIntensity < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self... |
97c963968d56c06a00b1d19b2cb2c9c00f5c6256dd67222c5ac5949e568fecfe | MATLAB | 348 | 21 | %{
# mean intensity values across time
-> meso.Quality
-> shared.Field
-> shared.Channel
---
intensities : longblob #
%}
classdef QualityMeanIntensity < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% self... |
3e738f1a21a900ea411025ef7d438fca74ac095788ccee756a2bb2c9f71666ca | MATLAB | 349 | 18 | %{
# union of ROIs from a stack (usually one volume per stack)
-> stack.Stitching
volume_id : tinyint # id of this volume
%}
classdef StitchingVolume < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
% sel... |
c9727be7b8c3840d7b1070c8b15e3aef4f1aac90a19bdb4dc8bd033d4de5703f | MATLAB | 350 | 16 | function display(this);
disp(inputname(1));
if length(this) == 1
struct(this.EEG)
else
TMP = struct(this);
TMP2 = TMP(1).EEG;
fieldorder = fieldnames(TMP2);
for index = 2:length(TMP)
TMP2(index) = orderfields(TMP(index).EEG, fieldorder);
... |
006d3e7df611bf0f995d394f0645026ea3e00c82161590d35da551572f7042a4 | MATLAB | 351 | 10 | function data = logfactorial(data)
% We compute log(n!) as the sum of logs, i.e. log(n!) = sum log(i) for i=1:n
% First determine the largest n in the array
m = max(data(:));
% Create a look-up vector of sum log(i) for each i up to the largest n
sums = [0 cumsum(log(1:m))];
% Look-up the value for each item in the arr... |
0928ed971cbf419eaf02fac98e6083c5a8ce592badbc41b2d08a36329a02a984 | MATLAB | 351 | 22 | %{
pre.Check (imported) # my newest table
# add primary key here
-----
# add additional attributes
%}
classdef Check < dj.Relvar & dj.AutoPopulate
properties
popRel % !!! update the populate relation
end
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
s... |
1abe60f8b9fb6e586bfd13beb62cd411ea96e6fb027766f8c0ac60c74cd5bbe7 | MATLAB | 352 | 14 | function audio = mergeAudio(data, window)
pad = [];
if window(1) <= 1
pad=zeros(abs(window(1)), 1);
window(1) = 1;
end
if isstring(data) |ischar(data)
audio = audioread(data, window);
else
audio = data;
end
audio = [mean(audio - mean(audio,1) ,2)]; % Take the mean of the audio channels
audio = int16(au... |
586bc53f84b453edcc808722ffc7a7b3b59ff2c2424287515f9e55b5dca1c168 | MATLAB | 352 | 10 | function [gwf, rf, dt, ti, rwf] = sero_pulseq_getShotWaveforms(seq, n)
% function [gwf, rf, dt, ti, rwf] = sero_pulseq_getShotWaveforms(seq, n)
if ~isscalar(n)
error('This function is intended for a single shot at a time!')
end
blockInd = sero_pulseq_shotToBlockInd(seq, n);
[gwf, rf, dt, ti, rwf] = sero_pulseq_g... |
829f216ecf2b4ca7823329e3dd2ada3e89405e5a193d58ac36fd853317091801 | MATLAB | 352 | 11 | function [rsq, SSres] = Rsquared(model, data)
%Rsquared - return the r^2 value of a fit between a linear model and data
% EXAMPLE
% rsq = Rsquared(polyfit(data(:,1), data(:,2),1), data(:,[1 2]);
yfit = polyval(model, data(:,1));
yresid = data(:,2) - yfit;
SSres = sum(yresid.^2);
SStotal = (length(data(:,2))-1)*var(da... |
fc8d57c18386deebf471b1c7def62edfb86eec3df72fb93e8e9ef6728666c2cc | MATLAB | 352 | 12 | %{
#
layer : char(12) # short name for cortical area
---
layer_description : varchar(255) #
z_start=null : float # starting depth
z_end=null : float # deepest point
%}
... |
6d03b989cf4ada8cddbbab9487c639733b9ad5f1e6c7c4990efe56d126925bfa | MATLAB | 353 | 22 | function [p] = normalpdf(x,mu,sigma,ispdf)
%normalpdf(x,mu,sigma,ispdf)
%sigma = variance
if nargin < 4
ispdf = true;
end
if nargin < 3
sigma = 1;
end
if nargin < 2
mu = 0;
end
if nargin < 1
error('Wrong input argument list.');
end
p = exp(-0.5*((x-mu)./sigma).^2);
if ispdf
p = p.... |
ceade1c63e988929850f9949caed5ed935d9dfe6cf890a2271191483b16697f3 | MATLAB | 353 | 13 | function [ttlE_temp,ttlO_temp,fps]=equalizeSamplingRate(ePhys,oPhys)
% Assume ePhys always the highest sampling rate
ttlO_temp=oPhys;
t_old=getTime(oPhys,oPhys.fps);
v_old=ttlO_temp;
t_new=linspace(0,t_old(end),t_old(end)*ePhys.fps);
v_new = interp1(t_old,v_old,t_new,'nearest')';
figure(1)
plot... |
f5cbae3e070d4fa85acbe4b53a5a191fd617d7b97e62ce4d7feb1ddc56ac6da7 | MATLAB | 354 | 18 | %{
preprocess.ExtractRawSpikeRate (imported) # spike trace extracted while segmentation
-> preprocess.ExtractRawTrace
---
spike_trace : longblob #
%}
classdef ExtractRawSpikeRate < dj.Relvar
methods
function makeTuples(self, key)
%!!! compute missing fields for key here
% ... |
10c66829d390c6f3e74018755a80a317753fdde6341cac195fbfd0c76efbcdc3 | MATLAB | 356 | 11 | %{
# an entry in this table indicates that two scans have been recorded at the same location
-> preprocess.ExtractRaw
other_scan_idx : smallint # second dependent scan idx
---
match_threshold=0.7 : float # minimal cosine between masks for match
%}
clas... |
11ef37de5b9da28b84c38b28706697d58d79c389ecf523e1ba7a0227554ce9ed | MATLAB | 356 | 13 | function output = sum_outlier(T)
%Afill = filloutliers(T,'spline');
%Afill = filloutliers(T,'next');
outliers=findOutliers(T);
Afill = filloutliers(T,'spline','OutlierLocations', outliers);
Afill(find(isnan(Afill)))=T(find(isnan(Afill)));
% original
output = sqrt(sum((T-Afill).^2));
% normalize version
%output = sqrt(... |
4aaea2f4e01ba9e6b9edd6d902093a6c48e3be00d94096549d7928972960174f | MATLAB | 356 | 20 | %{
# classification of segmented masks.
-> reso.Segmentation
-> shared.ClassificationMethod
---
classif_time=CURRENT_TIMESTAMP: timestamp # automatic
%}
classdef MaskClassification < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
... |
897387b5153b3085bcb1751711420c19f82a755e95ab3500bc572ed06f28dddc | MATLAB | 356 | 23 | %%
% Test function to compare nn_bnorm and its GPU/CPU implementation with
% using VLFEAT
%%
gpu = false;
gpu = true ;
T = 1 ;
x = randn(64,64,32,32,'single') ;
g = randn(32,1,'single') ;
b = randn(32,1,'single') ;
if gpu
x = gpuArray(x) ;
g = gpuArray(g) ;
b = gpuArray(b) ;
end
a=vl_nnbnorm(x,g,b);
a_=vl_nn... |
13179453e39771f33bf94516d469214bfe9077e28731ad58a72de2af8df07f66 | MATLAB | 357 | 12 | function fa = get_sess_fa(sessix,beh)
% fa = get_sess_fa(sessix,beh)
%
% calculates session-specific false alarm rate given session number and beh
% struct taken from e.g. get_adj_hr.m
%
% jbh 2/22/21
sessInds = beh.SESSION == sessix;
newInds = beh.ISOLD == 0;
errorVals = double(beh.ISCORRECT==0);
fa = mean... |
3d09131ac39f71370a08be647c18a87d037a4b6e53ce6173ce34518a89a94809 | MATLAB | 357 | 21 | %{
# calcium activity for the whole scan (multiple scan fields)
-> experiment.Scan
-> `pipeline_shared`.`#pipeline_version`
-> `pipeline_shared`.`#field`
---
-> fuse.Pipe
%}
classdef MotionCorrection < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here... |
4e64c5e838211e2789314e0b750ac6ed79d45e6d3db92821928526973cb5483e | MATLAB | 357 | 22 | function data=nDexample(cx,N,n,seedi)
rand('seed',seedi);
mu = rand(cx,n)*10;
x=[];
C=[];
for i=1:cx
r=[];
dum=rand(n,n)-0.5+diag(rand(n,1))+diag(ones(n,1))/3;
% R=dum*dum';
R=eye(n)/3;
for j=1:N
r(j,:) = randn(1,size(R,1)) * R + mu(i,:);
end
C=[C;ones(N,1)*i];
x=[x;r];
end
%pl... |
801518daff8953098cc36f84f1881d38d643271253cc9f66f9b3aec4da6f0def | MATLAB | 357 | 25 | function r = not(p)
%UMINUS: this function applies a unary minus to the x, y, and z values of the structures that I use in
% the FVtool.
%
% SYNOPSIS:
%
%
% PARAMETERS:
%
%
% RETURNS:
%
%
% EXAMPLE:
%
% SEE ALSO:
%
% Copyright (c) 2012-2016 Ali Akbar Eftekhari
% See the license file
r=p;
r.xvalue = ~p.xvalue;
r.yvalu... |
1d34d14b153573a3e368afba43c50b9c5d49adfe36f86a06799df73b264b311d | MATLAB | 358 | 20 | %{
# classification of segmented masks.
-> meso.Segmentation
-> shared.ClassificationMethod
---
classif_time=CURRENT_TIMESTAMP: timestamp # automatic
%}
classdef MaskClassification < dj.Computed
methods(Access=protected)
function makeTuples(self, key)
%!!! compute missing fields for key here
... |
faa27f21bca951fe442dc13bc3d845984193d8a8163146e5ae8ccb7a7e5dd305 | MATLAB | 358 | 17 | function [range_] = updateYlim(range, yl)
if range(1)==0 && range(2)==0
range_ = yl;
else
if yl(1) < range(1)
range_(1) = yl(1);
else
range_(1) = range(1);
end
if yl(2) > range(2)
range_(2) = yl(2);
else
range_(... |
12bc45a32fcfbe02a20073c259aedc97639491c3098bf773b10a77e60396e927 | MATLAB | 359 | 21 | function [ntheta] = tapas_ti_init_theta(ptheta, htheta, pars)
%% Initial values of theta with the prior expected value
%
% Input
% T - Temperatures
% ptheta - Priors
%
% Output
% ntheta -- Initialized structure array.
if isfield(ptheta, 'p0')
mu = ptheta.p0;
else
mu = ptheta.mu;
end
ntheta = cell(1, n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.