keyword stringclasses 7
values | repo_name stringlengths 8 98 | file_path stringlengths 4 244 | file_extension stringclasses 29
values | file_size int64 0 84.1M | line_count int64 0 1.6M | content stringlengths 1 84.1M ⌀ | language stringclasses 14
values |
|---|---|---|---|---|---|---|---|
2D | pillowlab/GLMspiketools | glmtools_spline/neglogli_tspline_poiss.m | .m | 1,247 | 49 | function [L,dL,ddL] = neglogli_tspline_poiss(prs,X,Y,g,dtbin)
% [L,dL,ddL] = neglogli_tspline_poiss(prs,X,Y,g,dtbin)
%
% Compute negative log-likelihood of data Y given rate g(X*prs).
%
% INPUT:
% prs [M x 1] - parameters
% X [N x M] - design matrix
% Y [N x 1] - observed Poisson random variables... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_spline/MLfit_splineNlin.m | .m | 985 | 30 | function [gg,negloglival,pp] = MLfit_splineNlin(gg,Stim)
% [gg,neglogli,pp] = MLfit_splineNlin(gg,Stim,optimargs)
%
% Fit a nonlinear function in an GLM neuron with a (positive) spline defined using a set of knots
% (discontinuities of a piecewise-polynomial function), using maximum likelihood
% loss
%
% Inputs:
% ... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_spline/fminNewton.m | .m | 5,145 | 181 | function [prs,fval,H] = fminNewton(fptr,prs,opts)
% [prs,fval,H] = fminNewton(fptr,prs,opts)
%
% Simple mplementation of Newton's method for minimizing a function
%
% Inputs:
% fptr - function handle for loss function
% prs - initial value of parameters
% opts - struct with fields: 'tolX', 'tolFun', 'maxIter', '... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_spline/tsplinefun.m | .m | 483 | 24 | function [f,df,ddf] = tsplinefun(x,splfun,tfun)
% [f,df,ddf] = tsplinefun(x,splfun,tfun)
%
% Computes the function:
% f(x) = tfun(splfun(x)) and its first and second derivatives
% where tfun is a function handle
switch nargout
case 0,
f = tfun(splfun(x));
case 1,
f = tfun(splfun(x));
case 2,
[g... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_spline/initializeGLMsplineNlin.m | .m | 1,847 | 45 | function [ggnew,negloglival] = initializeGLMsplineNlin(gg,Stim,prs)
% [ggnew,negloglival] = initializeGLMsplineNlin(gg,Stim,prs)
%
% Initializes parameters for a spline nonlinearity using GLM log-likelihood
%
% Inputs:
% gg = param struct
% Stim = stimulus
% spline_prs = structure parameters for spline nonl... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_spline/fit_tspline_poisson.m | .m | 2,410 | 66 | function [fun,pp,neglogli,splPrs,Mspline] = fit_tspline_poisson(x,y,ss,dtbin,prs0)
% [fun,pp,neglogli,splPrs,Mspline] = fit_tspline_poisson(x,y,ss,dtbin,prs0)
%
% Fit a function y = f(x) with a cubic spline, defined using a set of
% breaks, smoothness and extrapolation criteria, by maximizing Poisson
% likelihood: ... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_spline/mksplinefun.m | .m | 544 | 19 | function [fun,pp] = mksplinefun(breaks,x)
% [fun,pp] = mksplinefun(breaks,x)
%
% Make spline function handle out of breaks (knots) and coefficients in vector x.
%
% Inputs:
% breaks - points of discontinuity
% x - vector that can be reshaped into N x 4 matrix of spline coefficients
% for each segment
%
% Ou... | MATLAB |
2D | pillowlab/GLMspiketools | nlfuns/logexp4.m | .m | 559 | 24 | function [f,df,ddf] = logexp4(x);
% [f,df,ddf] = logexp4(x);
%
% Implements the nonlinearity:
% f(x) = log(1+exp(x)).^4;
% plus first and second derivatives
%
% General formulas:
% f(x) = log(1+exp(x))^k
% f'(x) = k log(1+e^x)^(k-1) * e^x/(1+e^x);
% f"(x) = k(k-1) log(1+e^x)^(k-2) * (e^x/(1+e^x))^2
% ... | MATLAB |
2D | pillowlab/GLMspiketools | nlfuns/logexp_pow.m | .m | 508 | 23 | function [f,df,ddf] = logexp_pow(x,pow);
% [f,df,ddf] = logexp_pow(x);
%
% Implements the nonlinearity:
% f(x) = log(1+exp(x)).^pow;
% plus first and second derivatives
f0 = log(1+exp(x));
f = f0.^pow;
if nargout > 1
df = pow*f0.^(pow-1).*exp(x)./(1+exp(x));
end
if nargout > 2
if pow == 1
dd... | MATLAB |
2D | pillowlab/GLMspiketools | nlfuns/logexp1.m | .m | 368 | 22 | function [f,df,ddf] = logexp1(x);
% [f,df,ddf] = logexp1(x);
%
% Implements the nonlinearity:
% f(x) = log(1+exp(x)).^pow;
% Where pow = 1;
% plus first and second derivatives
%
pow = 1;
f0 = log(1+exp(x));
f = f0.^pow;
if nargout > 1
df = pow*f0.^(pow-1).*exp(x)./(1+exp(x));
end
if nargout > 2
dd... | MATLAB |
2D | pillowlab/GLMspiketools | nlfuns/logexp2.m | .m | 430 | 20 | function [f,df,ddf] = logexp2(x);
% [f,df,ddf] = logexp_pow(x);
%
% Implements the nonlinearity:
% f(x) = log(1+exp(x)).^pow;
% where pow=2,
% plus first and second derivatives
pow = 2;
f0 = log(1+exp(x));
f = f0.^pow;
if nargout > 1
df = pow*f0.^(pow-1).*exp(x)./(1+exp(x));
end
if nargout > 2
ddf =... | MATLAB |
2D | pillowlab/GLMspiketools | nlfuns/logexp3.m | .m | 358 | 19 | function [f,df,ddf] = logexp3(x);
% [f,df,ddf] = logexp3(x);
%
% Implements the nonlinearity:
% f(x) = log(1+exp(x)).^3;
% plus first and second derivatives
f0 = log(1+exp(x));
f = f0.^3;
if nargout > 1
df = 3*f0.^2.*exp(x)./(1+exp(x));
end
if nargout > 2
ddf = 6*f0.*(exp(x)./(1+exp(x))).^2 + ...
... | MATLAB |
2D | pillowlab/GLMspiketools | nlfuns/expfun.m | .m | 166 | 9 | function [f,df,ddf] = expfun(x)
% [f,df,ddf] = expfun(x)
%
% replacement for 'exp' that returns 3 arguments (value, 1st & 2nd deriv)
f = exp(x);
df = f;
ddf = df;
| MATLAB |
2D | pillowlab/GLMspiketools | nlfuns/logexp5.m | .m | 559 | 24 | function [f,df,ddf] = logexp5(x);
% [f,df,ddf] = logexp4(x);
%
% Implements the nonlinearity:
% f(x) = log(1+exp(x)).^4;
% plus first and second derivatives
%
% General formulas:
% f(x) = log(1+exp(x))^k
% f'(x) = k log(1+e^x)^(k-1) * e^x/(1+e^x);
% f"(x) = k(k-1) log(1+e^x)^(k-2) * (e^x/(1+e^x))^2
% ... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_misc/normalizecols.m | .m | 171 | 7 | function B = normalizecols(A);
%
% B = normalizecols(A);
%
% Normalizes the columns of a matrix, so each is a unit vector.
B = A./repmat(sqrt(sum(A.^2)), size(A,1), 1); | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_misc/spikefilt.m | .m | 697 | 24 | function Y = spikefilt(sps, H)
% Y = spikefilt(sps, H, twin)
%
% Causally filters spike train with spike indices spikeInds with filter matrix H.
%
% Inputs:
% sps [tlen x 1] - spike train vector
% H [n x m] - spike-history matrix (each column is a filter)
%
% Output:
% Y [tlen x m] - each column is the spi... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_misc/makeStimRows.m | .m | 2,036 | 67 | function S = makeStimRows(Stim, nkt, flag)
% S = makeStimRows(Stim, nkt, flag);
%
% Converts spatio-temporal stimulus to a design matrix, where each row of
% the design matrix contains all space-time stimulus elements within a time
% window of "nkt" time bins.
%
% INPUT:
% Stim [N x M] - stimulus, first dimension is... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_misc/getFminOptsForVersion.m | .m | 736 | 18 | function opts = getFminOptsForVersion(v)
% opts = getFminOptsForVersion(v)
%
% Gets the options for fminunc needed for user's version of MATLAB
%
% Note of complaint: it's stupid that I had to write this function, but
% matlab has incompatible syntax for fminunc options for different versions
% (earlier versions of mat... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_misc/in.m | .m | 461 | 22 | function [ii, nds] = in(v, rnge)
% [ii,nds] = in(v, rnge)
%
% returns indices of vector v within range rnge, inclusive of endpoints
if (nargout == 1)
if length(rnge) == 1;
ii = v(v<=vrnge);
else
ii = v((v>=rnge(1)) & (v<=rnge(2)));
end
else
if length(rnge) == 1;
nds = find(v<=... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_misc/simGLM.m | .m | 7,517 | 185 | function [tsp,sps,Itot,Istm] = simGLM(glmprs,Stim)
% [tsp,sps,Itot,Ispk] = simGLM(glmprs,Stim)
%
% Compute response of glm to stimulus Stim.
%
% Uses time rescaling instead of Bernouli approximation to conditionally
% Poisson process
%
% Dynamics: Filters the Stimulus with glmprs.k, passes this through a
% nonlineari... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_misc/makeBasis_PostSpike.m | .m | 3,133 | 90 | function [iht, ihbas, ihbasis] = makeBasis_PostSpike(ihprs,dt)
% [iht, ihbas, ihbasis] = makeBasis_PostSpike(ihprs,dt)
%
% Make nonlinearly stretched basis consisting of raised cosines
% -------
% Inputs:
% prs = param structure with fields:
% ncols = # of basis vectors
% hpeaks = 2-vector co... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_misc/makeBasis_StimKernel.m | .m | 2,344 | 61 | function [kbasorth,kbasis] = makeBasis_StimKernel(kbasprs, nkt);
% [kbasorth, kbasis] = makeBasis_StimKernel(kbasprs, nkt);
%
% Generates a basis consisting of raised cosines and several columns of
% identity matrix vectors for temporal structure of stimulus kernel
%
% Args: kbasprs = struct with fields:
% ... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_misc/simpleSTC.m | .m | 6,243 | 171 | function [STA,STC,RawMu,RawCov] = simpleSTC(Stim,sp,nkt,maxsize)
% [STA,STC,RawMu,RawCov] = simpleSTC(Stim,sp,nkt,maxsize)
%
% Computes mean and covariance of spike-triggered (or response weighted)
% stimuli and raw stimuli
%
% INPUT:
% Stim [N x M] - stimulus matrix; 1st dimension = time, 2nd dimension = space
% ... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_misc/makeSimStruct_GLM.m | .m | 3,025 | 70 | function S = makeSimStruct_GLM(nkt,dtStim,dtSp)
% S = makeSimStruct_GLM(nkt,dtStim,dtSp);
%
% Creates a structure with default parameters for a GLM model
%
% Input: nkt = number of time bins for stimulus filter
% dtStim = bin size for sampling of stimulus kernel ('ih'), in s
% dtSp = bin size for sam... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_misc/sameconv.m | .m | 1,679 | 58 | function Y = sameconv(X, F)
% SAMECONV - causally filters X with F and returns output of same height
%
% Y = sameconv(X, F)
%
% F is not "flipped", so first element of Y is last row of F dot product with
% first row of X.
%
% Inputs:
% X [NxM] - tall matrix
% F [RxM] - short matrix (same width as X)
%
... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_misc/makeSimStruct_GLMcpl.m | .m | 2,094 | 89 | function S = makeSimStruct_GLMcpl(varargin);
% S = makeSimStruct_GLMcpl(gg1, gg2, gg3, ...);
%
% Creates a structure for simulating coupled GLM from multiple
% single-neuron GLMs.
%
% Input: structures params of glms to combine
ncells = nargin;
gg = varargin{1};
[klen,kwid] = size(gg.k);
kk = zeros(klen,kwid,ncel... | MATLAB |
2D | pillowlab/GLMspiketools | demos/demo5_GLM_10CoupledNeurons.m | .m | 8,057 | 205 | % testscript3_GLM_coupled.m
%
% Demo script for simulating and fitting a coupled GLM (2 neurons).
%
% Notes:
% - Fitting code uses same functions as for single-cell responses.
% - Simulation code requires new structures / functions
% (due to the need to pass activity between neurons)
% Make sure paths are set (... | MATLAB |
2D | pillowlab/GLMspiketools | demos/demo2_GLM_spatialStim.m | .m | 6,074 | 157 | % demo2_GLM_spatialStim.m
%
% Test code for simulating and fitting the GLM with a 2D stimulus filter
% (time x 1D space), with both traditional and bilinear parametrization
% of the stimulus kernel.
% Make sure paths are set (assumes this script called from 'demos' directory)
cd ..; setpaths_GLMspiketools; cd demos/
... | MATLAB |
2D | pillowlab/GLMspiketools | demos/demo1_GLM_temporalStim.m | .m | 4,719 | 116 | % demo1_GLM_temporalStim.m
%
% Demo script for simulating and fitting a single-neuron GLM with 1D
% (temporal) filter with exponential nonlinearity
% Make sure paths are set (assumes this script called from 'demos' directory)
cd ..; setpaths_GLMspiketools; cd demos/
%% 1. Set parameters and display for GLM % =====... | MATLAB |
2D | pillowlab/GLMspiketools | demos/demo3_GLM_coupled.m | .m | 7,432 | 174 | % testscript3_GLM_coupled.m
%
% Demo script for simulating and fitting a coupled GLM (2 neurons).
%
% Notes:
% - Fitting code uses same functions as for single-cell responses.
% - Simulation code requires new structures / functions
% (due to the need to pass activity between neurons)
% Make sure paths are set (... | MATLAB |
2D | pillowlab/GLMspiketools | demos/demo2b_GLM_spatialStim_Regularized.m | .m | 8,074 | 224 | % demo2b_GLM_spatialStim_Regularized.m
%
% Test code for simulating and fitting the GLM with a 2D stimulus filter
% (time x 1D space), regularized with a Gaussian prior.
% Make sure paths are set (assumes this script called from 'demos' directory)
cd ..; setpaths_GLMspiketools; cd demos/
%% 1. Set parameters and di... | MATLAB |
2D | pillowlab/GLMspiketools | demos/demo4_GLM_3CoupledNeurons.m | .m | 9,026 | 220 | % testscript3_GLM_coupled.m
%
% Demo script for simulating and fitting a coupled GLM (2 neurons).
%
% Notes:
% - Fitting code uses same functions as for single-cell responses.
% - Simulation code requires new structures / functions
% (due to the need to pass activity between neurons)
% Make sure paths are set (... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/MLfit_GLMbi.m | .m | 1,644 | 49 | function [gg,fval,H,Xstruct] = MLfit_GLMbi(gg,Stim,optimArgs)
% [gg,fval,H,Xstruct] = MLfit_GLMbi(gg,Stim,optimArgs);
%
% Computes the ML estimate for GLM params, using grad and hessians.
% Assumes bilinear parametrization of space-time filter.
%
% Inputs:
% gg = param struct
% Stim = stimulus
% optim... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/MAPfit_GLMbi_coordascent.m | .m | 4,334 | 133 | function [gg,neglogli,H,neglogp] = MAPfit_GLMbi_coordascent(gg,Stim,Cxinv,Ctinv,maxiter,ftol,optimArgs)
% [gg,neglogli,H,neglogp] = MAPfit_GLMbi_coordascent(gg,Stim,Cxinv,Ctinv,maxiter,ftol,optimArgs)
%
% Computes the MAP estimate for GLM params, with gradient and hessians, via
% coordinate ascent, for bilinear (lo... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/reinsertFitPrs_GLMbi.m | .m | 759 | 30 | function gg = reinsertFitPrs_GLMbi(gg,prs,Xstruct)
% gg = reinsertFitPrs_GLMbi(gg,prs);
%
% After fitting, reinsert params into param structure
% Put returned vals back into param structure ------
krank = Xstruct.krank;
nktprs = Xstruct.nkt*krank;
nkxprs = Xstruct.nkx*krank;
nktot = nktprs+nkxprs;
nh = Xstruct.nh;
nh... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/reinsertFitPrs_GLM.m | .m | 705 | 28 | function gg = reinsertFitPrs_GLM(gg,prs,Xstruct)
% gg = reinsertFitPrs_GLM(gg,prs,Xstruct)
%
% After fitting, reinsert params into GLM param structure
% Extract relevant size information
nkt = Xstruct.nkt;
nkx = Xstruct.nkx;
nktot = nkt*nkx;
nh = Xstruct.nh;
nh2 = Xstruct.nh2;
% Insert params
gg.kt = reshape(p... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/initfit_stimDesignMat_bi.m | .m | 1,968 | 48 | function Xstruct = initfit_stimDesignMat_bi(gg,Stim)
% Xstruct = initfit_stimDesignMat_bi(gg,Stim)
%
% Initialize parameters relating to stimulus design matrix for bilinearly
% parametrized GLM
% ---- Set up filter and stim processing params -------------------
nkx = size(gg.kxbas,2); % # params per spatial vecto... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/neglogli_GLM.m | .m | 3,083 | 93 | function [neglogli,rr,tt,Itot,Istm,Ih,Icpl] = neglogli_GLM(gg,Stim)
% [neglogli,rr,tt,Itot,Istm,Ih,Icpl] = neglogli_GLM(gg,Stim)
%
% Compute glm model negative log-likelihood given the parameters in gg,
%
% Inputs: gg = param object
% fields: k - stimulus kernel
% ih - post-spike current
% ... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/Loss_GLMbi_logli.m | .m | 6,263 | 190 | function [logli, dL, H] = Loss_GLMbi_logli(prs,Xstruct)
% [logli, dL, H] = Loss_GLMbi_logli(prs,Xstruct)
%
% Compute negative log-likelXXspood of data undr the GLM model, with bilinear
% parametrization of the input current
%
% Uses arbitrary nonlinearity 'nlfun' instead of exponential
%
% Inputs:
% prs = [ktprs - we... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/MAPfit_GLM.m | .m | 3,158 | 97 | function [gg,neglogli,H,Xstruct,neglogp] = MAPfit_GLM(gg,Stim,Cinv,optimArgs)
% [gg,neglogli,H,Xstruct,neglogp] = MAPfit_GLM(gg,C,Stim,optimArgs)
%
% Computes the MAP estimate for GLM params, using grad and hessians under
% a zero-mean Gaussian prior with inverse covariance Cinv.
%
% Minimizes negative log-likelih... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/MLfit_GLMbi_coordascent.m | .m | 3,484 | 113 | function [gg,fval,H] = MLfit_GLMbi_coordascent(gg,Stim,maxiter,ftol,optimArgs)
% [gg,fval,H] = MLfit_GLMbi_coordascent(gg,Stim,maxiter,ftol,optimArgs);
%
% Computes the ML estimate for GLM params, with gradient and hessians, via
% coordinate ascent, for bilinear (low rank) parametrization of space-time filter.
%
% ... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/initfit_mask.m | .m | 1,147 | 38 | function bmask = initfit_mask(mask,dtSp,rlen)
% bmask = initfit_mask(mask,dtSp,rlen)
%
% Compute binary mask for computing log-likelihood
%
% Input:
% ------
% mask [n x 2]: list of intervals to use for computing log-likelihood
% (ignore time bins outside these intervals)
% dtSp [1 x 1]: bin size ... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/makeFittingStruct_GLM.m | .m | 3,351 | 78 | function gg = makeFittingStruct_GLM(dtStim,dtSp,klength,nkbasis,k0,nhbasis,lasthpeak)
% gg = makeFittingStruct_GLM(dtStim,dtSp,klength,nkbasis,k0,nhbasis,lasthpeak)
%
% Initialize parameter structure for fitting GLM,
% with normal parametrization of stim kernel
%
% Inputs:
% dtStim = bin size of stimulus (in s)
% ... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/initfit_sphistDesignMat.m | .m | 1,390 | 48 | function Xstruct = initfit_sphistDesignMat(gg,Xstruct)
% Xstruct = initfit_sphistDesignMat(gg,Xstruct)
%
% Sets parameters relating to optimization of
% spike-filter terms in the point process GLM and inserts them into design
% matrix structure 'Xstruct'
% Determine # of parameters for self-coupling filter
if ~is... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/setupfitting_GLM.m | .m | 1,529 | 45 | function [prs0,Xstruct] = setupfitting_GLM(gg, Stim)
% [prs0,Xstruct] = setupfitting_GLM(gg, Stim)
%
% Set initial parameters and build design matrix structure for GLM fitting
%
% Inputs:
% gg = glm param structure
% Stim = stimulus (time along columns, other dims along rows)
% maxsize = maximum # float... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/Loss_GLM_logli.m | .m | 4,129 | 122 | function [logli, dL, H] = Loss_GLM_logli(prs,Xstruct)
% [logli, dL, H] = Loss_GLM_logli(prs,Xstruct)
%
% Compute negative log-likelihood of data undr the GLM model
% (with standard linear parametrization of stimulus kernel);
%
% Uses arbitrary nonlinearity 'nlfun' instead of exponential
%
% Inputs:
% prs = [kprs - we... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/initfit_stimDesignMat.m | .m | 1,536 | 36 | function Xstruct = initfit_stimDesignMat(gg,Stim)
% Xstruct = initfit_stimDesignMat(gg,Stim)
%
% Initialize parameters relating to stimulus design matrix
% ---- Set up filter and stim processing params -------------------
nkx = size(gg.k,2); % number stim pixels (# x params)
nkt = size(gg.ktbas,2); % # time param... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/makeFittingStruct_GLMbi.m | .m | 1,806 | 53 | function gg = makeFittingStruct_GLMbi(krank,varargin)
% gg = makeFittingStruct_GLM(krank,dtStim,dtSp,klength,nkbasis,k0,nhbasis,lasthpeak)
%
% Initialize parameter struct for fitting generalized linear model (GLM),
% with bilinear (i.e., low-rank) parametrization stimulus filter
%
% Inputs:
% krank = rank of stim... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/MLfit_GLM.m | .m | 1,912 | 53 | function [gg,neglogli,H,Xstruct] = MLfit_GLM(gg,Stim,optimArgs)
% [gg,neglogli,H,Xstruct] = MLfit_GLM(gg,Stim,optimArgs)
%
% Computes the ML estimate for GLM params, using grad and hessians.
% Assumes basis for temporal dimensions of stim filter
%
% Inputs:
% gg = param struct
% Stim = stimulus
% opti... | MATLAB |
2D | pillowlab/GLMspiketools | glmtools_fitting/Loss_GLM_logli_exp.m | .m | 3,269 | 100 | function [logli, dL, H] = Loss_GLM_logli_exp(prs,Xstruct)
% [neglogli, dL, H] = Loss_GLM_logli_exp(prs)
%
% Compute negative log-likelihood of data undr the GLM model with
% exponential nonlinearity (with standard linear parametrization of stim filter)
%
% Inputs:
% prs = [kprs - weights for stimulus kernel
% ... | MATLAB |
2D | pillowlab/GLMspiketools | unittests/unit_condIntensityConsistency_cpl.m | .m | 3,361 | 85 | % Unit test to check the consistency of conditional intensity computed
% during simulation and during fitting, using spikes from generated from a
% simulation of coupled neurons in demo3
% 1. First, run relevant section of demo3
dtStim = .01; % Bin size for simulating model & computing likelihood (in units of stim... | MATLAB |
2D | pillowlab/GLMspiketools | unittests/unit_condIntensityConsistency.m | .m | 1,954 | 51 | % Unit testing code to ensure that conditional intensity is computed the
% same way during simulation as during fitting
%% 1. Set parameters and display for a GLM % ==============================
dtStim = .01; % Bin size for stimulus (in seconds). (Equiv to 100Hz frame rate)
dtSp = .001; % Bin size for simulating m... | MATLAB |
2D | MRSRL/mridata-recon | recon_2d_fse.py | .py | 10,357 | 268 | """Basic recon for 2D FSE datasets on mridata.org."""
import numpy as np
import os
import ismrmrd
import argparse
import imageio
from tqdm import tqdm
from fileio import cfl
from mrirecon import fse
from mrirecon import fftc
def isrmrmd_user_param_to_dict(header):
"""
Store ISMRMRD header user parameters in a ... | Python |
2D | MRSRL/mridata-recon | fileio/__init__.py | .py | 0 | 0 | null | Python |
2D | MRSRL/mridata-recon | fileio/cfl.py | .py | 1,764 | 72 | """Read/write files for BART"""
# This file is slightly modified from the file:
# https://github.com/mrirecon/bart/blob/master/python/cfl.py
# Copyright 2013-2015. The Regents of the University of California.
# All rights reserved. Use of this source code is governed by
# a BSD-style license which can be found in t... | Python |
2D | MRSRL/mridata-recon | mrirecon/fse.py | .py | 2,670 | 73 | """General recon functions for FSE datasets."""
import numpy as np
from mrirecon import fftc
def _compute_coefficients_ahncho(kscalib):
"""Compute correction coefficients for FSE using Ahn-Cho method.
kscalib: [..., channels, segments, kx]
"""
# offset start and end to avoid effects from fft wrap
... | Python |
2D | MRSRL/mridata-recon | mrirecon/__init__.py | .py | 0 | 0 | null | Python |
2D | MRSRL/mridata-recon | mrirecon/fftc.py | .py | 1,755 | 77 | try:
import pyfftw.interfaces.numpy_fft as fft
except:
from numpy import fft
import numpy as np
def ifftnc(x, axes):
tmp = fft.fftshift(x, axes=axes)
tmp = fft.ifftn(tmp, axes=axes)
return fft.ifftshift(tmp, axes=axes)
def fftnc(x, axes):
tmp = fft.fftshift(x, axes=axes)
tmp = fft.fftn(tm... | Python |
2D | LaurentNevou/Q_SchrodingerPoisson1D_CB | Library.m | .m | 21,731 | 709 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Library load %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DB = importdata('materialDB_ZB.csv',',');
%DB = importdata('materialDB_WZ.cs... | MATLAB |
2D | LaurentNevou/Q_SchrodingerPoisson1D_CB | computesISBdipoles.m | .m | 1,345 | 30 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Computes ISB dipoles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Take care! Some people use meff inside the oscillator strenght f
% Actuall... | MATLAB |
2D | LaurentNevou/Q_SchrodingerPoisson1D_CB | SchrodingerPoisson1D_CB_Kane_Main.m | .m | 18,760 | 492 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%% last update 20December2021, lne %%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This program solves the Schrodinger-Poisson equation in the conduction band... | MATLAB |
2D | LaurentNevou/Q_SchrodingerPoisson1D_CB | scale_PSI.m | .m | 815 | 17 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%% Scaling and shifting the wavefunctions %%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:length(Ec)
PSIc(:,i)=abs(psic(:,i)).^2/max(abs(psic(:,i)).^2)*ScF ... | MATLAB |
2D | LaurentNevou/Q_SchrodingerPoisson1D_CB | SchrodingerPoisson1D_CB_Main.m | .m | 17,453 | 457 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%% last update 25December2021, lne %%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This program solves the Schrodinger-Poisson equation in the conduction band... | MATLAB |
2D | LaurentNevou/Q_SchrodingerPoisson1D_CB | TernaryAlloy.m | .m | 5,184 | 123 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%% III-V Ternary alloys on InP %%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=0.53;
InGaAs = x*InAs + (1-x)*GaAs - x*(1-x)*InGaAs_bowing; % In0.53Ga0.... | MATLAB |
2D | LaurentNevou/Q_SchrodingerPoisson1D_CB | input_file.m | .m | 1,620 | 46 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Layers Structure %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% first column is the material used from the "library"
% second column is the... | MATLAB |
2D | LaurentNevou/Q_SchrodingerPoisson1D_CB | find_Ef_f.m | .m | 1,701 | 54 | function[Ef,NN,roEf]=find_Ef_f(z,Ec,psic,E,ro,Ntot,T)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Constants %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e = 1.602176487E-19;... | MATLAB |
2D | LaurentNevou/Q_SchrodingerPoisson1D_CB | Schrod_Nbands_shoot_f.m | .m | 3,601 | 116 | function[E,psi]=Schrod_Nbands_shoot_f(z,V0,me,n,Evec,dE,precision)
method=2; % method "2" is much more acurate than "1" but take also more time...
e=min(V0);
Emax=max(V0)+0.1;
C=0; N=0; E=[];
psi=z*0+1; psi_old=psi;
while e<Emax && length(E)<n
C = C+1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%... | MATLAB |
2D | LaurentNevou/Q_SchrodingerPoisson1D_CB | PrintResults.m | .m | 1,065 | 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Print Results %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%display('')
display('===================================================')
... | MATLAB |
2D | LaurentNevou/Q_SchrodingerPoisson1D_CB | ExtractParameters.m | .m | 8,801 | 271 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%% Extract general parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% lattice parameter
for i=1:length(DB.textdata(:,1))
idx=strcmp(DB.textdat... | MATLAB |
2D | LaurentNevou/Q_SchrodingerPoisson1D_CB | Schrod_2bands_Kane_f.m | .m | 4,189 | 121 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%% Schrodinger solver on uniform grid with m(z,E)!!! %%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% With the non-parabolic band 2x2k.p Kane model %%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%... | MATLAB |
2D | obaica/vasp_wavecar_parity | main.f90 | .f90 | 587 | 19 | program main
implicit none
integer :: ierr
ierr=0
open(unit=19, file='GCOEFF.txt', status='old', action='read', iostat=ierr)
close(unit=19)
if ( ierr.eq.0 ) then
write(*,*) "'GCOEFF.txt' file exits, now calc parity."
call parity
write(*,*) "**************End of parity ca... | Fortran |
2D | obaica/vasp_wavecar_parity | wavetrans.f90 | .f90 | 10,118 | 310 | !!$************************* WaveTrans
!************************************
!!$*
!!$* input the WAVECAR file in binary format from VASP, and output
!!$* in text format a file GCOEFF of G values and corresponding plane
!!$* wave coefficients, together with energy eigenvalues and
!occupations
!!$*
!!$* Compile ... | Fortran |
2D | obaica/vasp_wavecar_parity | parity.f90 | .f90 | 5,331 | 172 | subroutine parity
implicit none
complex, parameter :: zi=(0.000, 0.000)
integer :: i, j, l, n, m
real:: V
complex, allocatable :: coeff(:, :)
integer :: nspin, nkpt, nband, npmax
integer, allocatable :: Gvector(:, :, :)
real :: a1(3),a2(3),a3(3), b1(3),b2(3),b3(3)
real :: kcurrent(3... | Fortran |
2D | poreathon/poreathon | getdata.sh | .sh | 327 | 10 | #!/bin/bash
cd input/nanopore
wget http://pathogenomics.bham.ac.uk/filedist/nanopore/Ecoli_R7_2D.fastq
wget http://pathogenomics.bham.ac.uk/filedist/nanopore/Ecoli_R7_2D.fasta
wget http://pathogenomics.bham.ac.uk/filedist/nanopore/Ecoli_R73_2D.fasta
wget http://pathogenomics.bham.ac.uk/filedist/nanopore/Ecoli_R73_2D.f... | Shell |
2D | poreathon/poreathon | makemakefile.py | .py | 794 | 23 | import glob
import yaml
pipelines = yaml.load(file('pipelines.yaml'))
recipes = glob.glob('recipes/*.yaml')
recipes = dict([(r[8:-5], yaml.load(file(r))) for r in recipes])
for pipeline, inputs in pipelines.iteritems():
for input_file in inputs:
for recipe_name, recipe_info in recipes.iteritems():
if recipe_inf... | Python |
2D | poreathon/poreathon | PIPELINES.md | .md | 1,322 | 67 | # Proposed Pipelines
## Alignment
The alignment pipeline aligns FASTA or FASTQ or FAST5 files to a reference.
Input: FASTA/FASTQ/FAST5 file & reference
Output: Sorted BAM file
Tests:
- # mapped/ # unmapped
- median/mean coverage
- time to run
- histogram of alignment lengths
- coverage plots
## Alignment corr... | Markdown |
2D | poreathon/poreathon | analysis/count-errors.py | .py | 2,263 | 83 | import sys
import pysam
from collections import Counter
# http://pysam.readthedocs.org/en/latest/api.html#pysam.AlignedRead.cigar
MATCH = 0 # M
INS = 1 # I
DEL = 2 # D
SKIP = 3 # N
SOFT = 4 # S
HARD = 5 # H
PAD = 6 # P
EQUAL = 7 # =
DIFF = 9 # X
def cigar_profile(cigar_tuples):
"""
Ret... | Python |
2D | poreathon/poreathon | analysis/cov_histogram.R | .R | 287 | 7 | #!/usr/bin/Rscript
library(ggplot2)
args=commandArgs(TRUE)
cov=read.table(args[1], sep="\t", header=F)
p=ggplot(cov, aes(x=V2, y=V3)) + geom_bar(stat="identity") + scale_x_continuous("Coverage depth") + scale_y_continuous("Number of bases") + theme_bw()
ggsave(filename=args[2], plot=p)
| R |
2D | poreathon/poreathon | analysis/aln_histogram.R | .R | 342 | 9 | #!/usr/bin/Rscript
library(ggplot2)
args=commandArgs(TRUE)
cov=read.table(args[1], sep="\t", header=T, stringsAsFactors=T)
cov=subset(cov, align_len != 'None')
cov=cbind(cov,"frac" = as.numeric(cov$align_len) / as.numeric(cov$read_len))
p=ggplot(cov, aes(x=frac)) + geom_histogram() + xlim(0, 2) + theme_bw()
ggsave(file... | R |
2D | poreathon/poreathon | analysis/expand-cigar.py | .py | 3,347 | 114 | import sys
import pysam
import argparse
"""Author: Aaron R. Quinlan, December 2014"""
# http://pysam.readthedocs.org/en/latest/api.html#pysam.AlignedRead.cigar
MATCH = 0 # M
INS = 1 # I
DEL = 2 # D
SKIP = 3 # N
SOFT = 4 # S
HARD = 5 # H
PAD = 6 # P
EQUAL = 7 # =
DIFF = 8 # X
def get_chrom(fasta_f... | Python |
2D | poreathon/poreathon | analysis/basic-stats.py | .py | 500 | 26 | import sys
import pysam
from collections import Counter
import numpy
def stats(fn):
unaligned = 0
best_align = {}
bam = pysam.Samfile(fn)
for read in bam:
if read.is_unmapped:
unaligned += 1
continue
if read.qname not in best_align:
best_align[read.qname] = read.alen
print """- Filename: %s
Mean_... | Python |
2D | poreathon/poreathon | analysis/collate_alignment_stats.py | .py | 1,845 | 51 | import glob
import os
import yaml
import sys
import pysam
from collections import Counter
from Bio import SeqIO
import numpy
def count_sequences(input_file, typ):
return len([s for s in SeqIO.parse(open(input_file), typ)])
def dump_pipeline(input_file, recipe_name, recipe_info):
input_lines = count_sequences("input... | Python |
2D | lhalloran/ERTplot | ERTplot.py | .py | 2,432 | 66 | """
ERTplot.py
Landon Halloran 29-Nov-2016
Script to read in 2D electrical resistivity tomography (ERT) data
(i.e., inversion output from RES2DINV) and topography data and plot
it with much more user control than RES2DINV allows. Data must first be
exported to .xls/.xlsx format (see example file).
"""
import matp... | Python |
2D | pl992/VirusPropagator | VirusPropagator.py | .py | 3,859 | 134 | import numpy as np
import os
import matplotlib.pyplot as plt
import matplotlib.animation as animation
#2D World -> People fluctuating around central points
#Person with infection leaves infected area for dt
#People on those areas get infected with probability p
#People after t1 die
dt = 3
space = 100
npeople = 1000
n... | Python |
2D | NSDRLIISc/e2e | e2e.py | .py | 52,301 | 1,535 | '''#!/home/magtest/test_env/bin/python'''
from pymatgen.io.vasp.sets import MPRelaxSet, MPStaticSet, MPSOCSet
from pymatgen import Structure
from pymatgen.core.periodic_table import Element
from pymatgen.analysis.magnetism.analyzer import MagneticStructureEnumerator, CollinearMagneticStructureAnalyzer
from pymatgen.io... | Python |
2D | rpestourie/fdfd_local_field | src/simulation_unit_cell.jl | .jl | 4,271 | 110 | # TODO: modularize code, write simulate_unit_cell independent of the geometry, all geometry related code should be in geometry_code
"""
```x, y, Ez, dpml, dsource, resolution = simulate_unit_cell(ps; refractive_indexes=zeros(3), frequency=1, interstice = 0.5, hole = 0.75, Ly = 17)```
This function simulates Helmholtz ... | Julia |
2D | rpestourie/fdfd_local_field | src/misc.jl | .jl | 1,929 | 50 | function rescaling(x, lb, ub)
@assert all([x <= 1, x >= 0])
lb + x * (ub-lb)
end
function create_parameters(number_holes, number_training_data, δ, lb, ub)
ps_vec = zeros(number_holes)
for it_training = 1:number_training_data
cur_ps = rescaling.(rand(number_holes), lb, ub)
ps_vec = vcat(... | Julia |
2D | rpestourie/fdfd_local_field | src/fdfd_maxwell_solver.jl | .jl | 2,488 | 81 | """
```Maxwell_2d(Lx, Ly, ϵ, ω, dpml, resolution; Rpml=1e-20, show_geometry=false)```
This function compute the finite difference operator for a Maxwell Finite Difference Frequency Domain solver.
The solver is in 2D and handles the out-of-plane polarization.
Boundary conditions:
- periodic in x
- pml at y = Ly and y... | Julia |
2D | rpestourie/fdfd_local_field | src/fdfd_local_field.jl | .jl | 201 | 9 | using Statistics
using LinearAlgebra
using SparseArrays
include("../src/fdfd_maxwell_solver.jl")
include("../src/geometry_code.jl")
include("../src/simulation_unit_cell.jl")
include("../src/misc.jl")
| Julia |
2D | rpestourie/fdfd_local_field | src/geometry_code.jl | .jl | 6,132 | 174 | """
```ϵ_hole_layers(x, y, ps, interstice = 0.5, hole = 0.75)```
return the permittivity of a unit-cell which consists of air holes in silica
Arguments:
- ps : widths of the air holes (need to be unit-less)
- refractive_indexes : optional argument with refractive indexes of background, hole and substrate. For referen... | Julia |
2D | rpestourie/fdfd_local_field | test/test_get_gradient.jl | .jl | 1,023 | 20 | data_array = [0.405503 0.707334 0.211959 0.2539 0.479168 0.161135 -0.0888367
0.415503 0.707334 0.211959 0.2539 0.479168 0.153381 -0.102154
0.405503 0.717334 0.211959 0.2539 0.479168 0.14144 -0.106894
0.405503 0.707334 0.221959 0.2539 0.479168 0.150405 -0.0882103
0.405503 0.707334 0.211959 0.... | Julia |
2D | rpestourie/fdfd_local_field | test/test_fdfd_maxwell_solver.jl | .jl | 577 | 11 | # checks Fresnel's transmission coefficient numerically
n_incident = 1.
n_transmit = 1.45
ref_local_field = get_local_field(Float64[0.5], refractive_indexes=ones(3) * n_incident)[3]
interface_localfield = get_local_field(Float64[0.5], refractive_indexes=Float64[n_transmit, n_incident, n_incident])[3]
transmission_num... | Julia |
2D | rpestourie/fdfd_local_field | test/runtests.jl | .jl | 409 | 10 | using Test
include("../src/fdfd_local_field.jl")
@testset "fdfd_local_field" begin
@testset "maxwell_fdfd_solver" begin include("test_fdfd_maxwell_solver.jl") end
@testset "pixel averaging" begin include("test_geometry_code.jl") end
@testset "finite difference gradient" begin include("test_get_gradient.jl"... | Julia |
2D | rpestourie/fdfd_local_field | test/test_parallel_vs_serial.jl | .jl | 970 | 27 | number_training_data = 6
r = rand()
δ = 1e-2
number_holes = 5
lb = 0.1 # for a blue wavelength this corresponds to a minimum feature of ≈40 nm
ub = 0.95 - lb # this assumes a period of 0.95 λ
# create parameters
ps_array = create_parameters(number_holes, number_training_data, δ, lb, ub)
# reference simulation
refrac... | Julia |
2D | rpestourie/fdfd_local_field | test/test_geometry_code.jl | .jl | 490 | 15 |
ps = [37/40]
refractive_indexes = Float64[1., 1., sqrt(3)]
x, y, Ez, dpml, dsource, resolution = simulation_hole_layers_unit_cell(ps, refractive_indexes=refractive_indexes)
δ = x[2] - x[1]
Ly_pml = y[end] - y[1] + δ
# test that the unit-cell is correct
@test resolution == 40
@test Ly_pml == 16
# test that some permi... | Julia |
2D | rpestourie/fdfd_local_field | examples/example_Ez_geometry_plots.jl | .jl | 805 | 25 | include("../src/fdfd_local_field.jl")
using Plots
pyplot()
### reference simulation
refractive_indexes = ones(3) * 1.45
ps = [0.75, 0.5, 0.66, 0.33, 0.66, 0.5, 0.75, 0.5, 0.66, 0.33]
x, y, Ez, dpml, dsource, resolution = simulation_hole_layers_unit_cell(ps, refractive_indexes=refractive_indexes, frequency=0.25)
heatm... | Julia |
2D | rpestourie/fdfd_local_field | examples/serial_simulations.jl | .jl | 1,219 | 35 | include("../src/fdfd_local_field.jl")
cd("examples/")
using BenchmarkTools
using DelimitedFiles
println("$(Threads.nthreads()) threads!")
number_training_data = 150000 # ideally 1e5 here
r = rand()
δ = 1e-2
fname = "test_data_$(round(Int, r*1e5))_$δ.csv"
number_holes = 10
lb = 0.1 # for a blue wavelength this corres... | Julia |
2D | rpestourie/fdfd_local_field | examples/Simulate_RGB_data.ipynb | .ipynb | 63,282 | 113 | {
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"┌ Warning: PyPlot is using tkagg backend, which is known to cause crashes on MacOS (#410); use the MPLBACKEND environment variable to req... | Unknown |
2D | rpestourie/fdfd_local_field | examples/example_parameter_sweep_single_hole.jl | .jl | 271 | 16 | include("../src/fdfd_local_field.jl")
using Plots
pyplot()
ps = transpose(0.1:0.01:0.9)
E_local_field = [get_local_field(ps[:,i])[3] for i=1:length(ps)]
Plots.plot(real.(E_local_field))
Plots.plot!(imag.(E_local_field))
gui()
Plots.plot(angle.(E_local_field))
gui()
| Julia |
2D | rpestourie/fdfd_local_field | examples/get_val_gradients.jl | .jl | 454 | 14 | include("../src/fdfd_local_field.jl")
using DelimitedFiles
fname="examples/data/test_data__0.01.csv"
data_array = readdlm(fname, ',')
start_index = findnext('.', fname, 1) - 1
end_index = findnext('.', fname, start_index+2) - 1
δ = parse(Float64, fname[start_index:end_index])
real_gd, imag_gd = get_val_gradient_from... | Julia |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.