sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
1f84efe84d91df7fd1a0764bf244438c348764e3e1cca86bc25dddc045fe5a5f
Julia
1,036
35
""" bin_clicks(clicks::Vector{T}) Wrapper to broadcast bin_clicks across a vector of clicks. """ bin_clicks(clicks::Vector{T}; dt::Float64=1e-2, centered::Bool=false) where T <: Any = bin_clicks.(clicks; dt=dt, centered=centered) """ bin_clicks(clicks) Bins clicks, based on dt (defaults to 1e-2). 'cente...
d6c1dadf4e04ed27a94884be08869f38b7c4b79cf924c893a1205c0d09c7ba6a
Julia
1,112
45
struct EdgeList{TData} edges::Vector{Pair{Int64, Int64}} data::Vector{TData} end EdgeList{T}() where {T} = EdgeList{T}([],Array{T}(undef,0)) function Base.empty!(el::EdgeList) empty!(el.edges) empty!(el.data) nothing end Base.length(el::EdgeList) = length(el.edges) @inline EdgeIter(g::EdgeList{T...
12238f21142e817990a491dc56f50a2983868f4ae3fb80e34b17bb24bf9f8164
Julia
1,276
41
module RNNhelpers include("types.jl") include("math.jl") include("IO.jl") include("plots.jl") include("force.jl") include("initialization.jl") using .Types using .Math using .IO using .Plots using .Force using .Initialization export init_rate_figure, update_rate_figure, init_plasticity_figure, update_plasticity_figu...
5cc2a16c30a2c7a95dc2cf724915fe82a2809abfaed0d0b00dd7cd815c9bbe9c
Julia
1,281
36
#= This file contains all DA model gating functions =# # Gating functions boltz(V, A, B) = 1 / (1 + exp(-(V-A)/B)) tauX(V, A, B, D, E) = A - B / (1 + exp((V+D)/E)) # Na-current (m = activation variable, h = inactivation variable) m_inf(V) = boltz(V, -30.0907, 9.7264) tau_m(V) = 0.01 + 1.0 / ((-(15.6504 + 0.4043*V)/(e...
a8704010c2ebd9262d53a04bb098c3defec121ee1b0ac1b239cc995e4d9bc7b4
Julia
1,585
49
@enum ReferenceTimePoint begin Cell_Birth Cell_G2_Start Cell_Mitosis_Start Cell_Division end Base.@kwdef mutable struct CellEvent <: AbstractCellEvent name::String = "R_hard" cell_ref_time::ReferenceTimePoint = Cell_Birth cell_time_start::Float64 = 0. sim_time_start::Float64 = 0. s...
db78ae2a51d3f617cc03b7c63081a93ed939d53129aaac4abe19667e0e248460
Julia
1,651
57
""" """ function CoM(x, t, thresh, margin) isevent = false go = true tprime = 5 y = [] while go if ((t - tprime) >= 1) & ((t + tprime) <= length(x)) y = x[t - tprime : t + tprime] if (x[t - 1] < thresh) & (x[t + 1] > thresh) ...
4c52fef6e2adf52e61df266a4dc66ba91e3b76052e3ade9a3da2c650cc331472
Julia
1,680
54
""" synthetic_data(; θ=θchoice(), ntrials=2000, rng=1) Returns default parameters and ntrials of synthetic data (clicks and choices) organized into a choicedata type. """ function synthetic_data(; θ::θchoice=θchoice(), ntrials::Int=2000, rng::Int=1, dt::Float64=1e-2, centered::Bool=false) clicks, choices = ra...
30a5514878c6d5bee2651adcd95fcded52ba070bb4771a993298f9307eec84d3
Julia
1,688
79
# # Plot node-level interevent time distributions. # # PARAMETERS # $network # # INPUT FILES # dat/out2.$network # dat/statistic.format.$network # # OUTPUT FILES # plot/inter2.{auv}{,l}.$network.png # using PyPlot; include("read_statistic.jl"); include("konect_consts.jl"); include("step_full.jl"); network = ENV["n...
c9657b54f9c3fbe965cdb5cf79b4a5856d5c8477d30c4e895ced0bc6166b6c98
Julia
1,743
54
function apply!(ce::CellEvent, s::State, p::StaticParameters, i::Int64) setproperty!(s[i], ce.symbol, ce.abs_value + ce.factor * getproperty(s[i], ce.symbol)) end function apply!(ce::SpecialCellEvent, s::State, p::StaticParameters, i::Int64) ce.julia_function(s, p, i) end funct...
756eebe95abd23b36dcfb6e1624b18393137ba982bb708b6b9f75de0e010ecc0
Julia
1,749
65
""" sep_neural_loglikelihood(x, model) A wrapper function that accepts a vector of mixed parameters, splits the vector into two vectors based on the parameter mapping function provided as an input. Used in optimization, Hessian and gradient computation. """ function sep_neural_loglikelihood(x::Vector{T}, model::ne...
0bee32579c95efbd352f55f947f360abc0edab0639ec2c16c8c47f80c3a5bf7c
Julia
1,857
71
#!julia using Base using Pkg # activate the environment defined by `Manifest.toml` and `Project.toml` # You should have already run `Pkg.instantiate()` and `Pkg.precompile()` Pkg.activate(joinpath(@__DIR__)) # Load the code necessary for simulation used below include("spiking_LIF_w_FORCE_STDP.jl") # Save directory (...
4a5eb3b916c6f75a4121dbac1fd4f47e50bfd5eb5328eed4c6b63dbc0c7c6c59
Julia
1,885
57
ncells, ntrials = [1,2], [3,4] f = [repeat(["Sigmoid"], N) for N in ncells] θ = θneural(θz = θz(σ2_i = 0.5, B = 15., λ = -0.5, σ2_a = 10., σ2_s = 1.2, ϕ = 0.6, τ_ϕ = 0.02), θy=[[Sigmoid() for n in 1:N] for N in ncells], f=f); fitbool,lb,ub = neural_options(f) data, = synthetic_data(θ, ntrials, ncells);...
8978dd11083156cbdf12fe93ec1a326c8a42a15daaf5328e700c32e52f703ebc
Julia
1,953
83
""" """ @with_kw struct choiceinputs{T1,T2} clicks::T1 binned_clicks::T2 dt::Float64 centered::Bool delay::Int=0 pad::Int=0 end """ θchoice(θz, bias, lapse) <: DDMθ Fields: - `θz`: is a module-defined type that contains the parameters related to the latent variable model. - `bias` is the...
17fd77f7e4a8a030ff08023c26641c8fb5497ded6ec0fe44309e46ca5d200b03
Julia
2,127
70
abstract type AbstractAlgorithm end abstract type AbstractCellEvent end @enum CellPhase G0=0 G1=1 G2=2 mitosis=3 @enum CellInitTypes random=0 clustered=1 HArray{T,Dim} = HybridArray{Tuple{Dim,StaticArrays.Dynamic()},T,2,2,Array{T,2}} where {T,Dim} hzeros(::Val{Dim}, n) where {Dim} = HArray{Float64,Dim}(zeros(Dim,n)) ...
e0a8099009b55f76b15695034af044cbb176bdf57d1aa5c59181090f55c6c18e
Julia
2,133
95
""" neuralchoiceDDM Fields: - θ - data - n - cross """ @with_kw mutable struct neural_choiceDDM{T} <: DDM θ::T n::Int=53 cross::Bool=false fit::Vector{Bool} ub::Vector{Float64} lb::Vector{Float64} end """ """ @with_kw mutable struct θneural_choice{T1, T2, T3} <: DDMθ θz::T1 bias:...
a0146a22d1cd3d52d1941df88b66642fdf64b34f87070ac4cdf7c915cce72e7d
Julia
2,162
80
module SEMTor using Printf using LinearAlgebra using Distributions using Random using StructArrays using StaticArrays, HybridArrays # config files using DataFrames # takes time using TOML using XLSX # takes time using CairoMakie import Base.show include("core/definitions.jl") include("cell_events/cell...
b56ddaa7739ed67e471ef0f9594b1ad2627613659b7712ccaef0fe4c454744f8
Julia
2,206
77
function write_sheet!(df, xf, prop, type; cols=:time, col_name=string(cols), prop_name=string(prop), df_mean=missing, max_reps=500) if isempty(df[!,prop]) return nothi...
e7760572f3f4d3f184b3a298657718c596e8621b257f9293bc17523f88ba8481
Julia
2,234
50
ncells, ntrials = [1,2], [3,4] f = [repeat(["Sigmoid"], N) for N in ncells] θ = θneural(θz = θz(σ2_i = 0.5, B = 15., λ = -0.5, σ2_a = 10., σ2_s = 1.2, ϕ = 0.6, τ_ϕ = 0.02), θy=[[Sigmoid() for n in 1:N] for N in ncells], f=f); data, = synthetic_data(θ, ntrials, ncells); spikes = map(x-> sum.(x), getfield.(vc...
43819b75caa988c108c0a5bc88c9566691e7e14fcaf8529bcf1ec7b1b7350443
Julia
2,298
35
#= This file contains all derivatives of DA model gating functions =# dboltz(V,A,B) = exp(-(V-A)/B) / (B * (exp(-(V-A)/B) + 1)^2) #boltz(V, A, B) = 1 / (1 + exp(-(V-A)/B)) # Na-current (m = activation variable, h = inactivation variable) dm(V) = dboltz(V, -30.0907, 9.7264) dh(V) = dboltz(V, -54.0289, -10.7665) # Kd-...
0431aff2d4e7d36136d4d677002c0e12c36ffcb508e05cec3bcd7368be25b8c8
Julia
2,449
78
""" Pulse Input DDM A julia module for fitting bounded accumlator models using behavioral and/or neural data from pulse-based evidence accumlation tasks. """ module PulseInputDDM using DocStringExtensions using StatsBase, Distributions, LineSearches using ForwardDiff, Distributed, LinearAlgebra using Optim, DSP,...
f8f98bc7cdaf59930604d487ec9a92636a84cbe384e726e68f02d2ea5bfcfd54
Julia
2,485
86
""" optimize(x, ll, lb, ub) Wrapper for executing an constrained optimization. Arguments: - `ll`: objective function. - `x`: an `array` of initial point - `lb`: lower bounds. `array` the same length as `x`. - `ub: upper bounds. `array` the same length as `x`. """ function optimize(x::Vector{TT}, ll, lb, ub; ...
8d0a73f1f08edf908b620e9e24fa3409da9f2e88c3aabb6d15d5a150a7c899a6
Julia
2,486
80
# a few helpers to deal with function list_params(d::Dict, table = DataFrame(key=[],value=[]), prefix="") for (k,v) in d if typeof(v) <: Dict || typeof(v) <: Array list_params(v, table, prefix * k * ".") else append!(table, DataFrame(key=prefix * k, value=v)) end end return table end function list_param...
6e26f7d488766c61250959ab3e3d62e0caa28207d0c35a3a72d6fdb7c3fe2ba8
Julia
2,493
78
function loss_apical_connection(state::State, p::StaticParameters, i::Int64) cell = state[i] # we could also deactive the cytoskeleton alltogether, but we # instead let it degenerate: #cell.has_apical_cytos = false cell.apical_cytos_strain = -1. cell.stiffness_nuclei_apical *= 0.1 adjs = f...
aea88d9b3ad7fabefae6201b616661e1149ed2d9f6f4e2574eecfc15909435d5
Julia
2,519
79
function pbd!(s::State, p::StaticParameters, basal_info, cache) (;no_curvature, Rb, y0, Rc) = basal_info (;vl) = cache c = s.cells # collision detection dtf = p.sim.dt / p.alg.n_substeps μi = 1. / p.epi.mu N = size(s.X,2)::Int64 for k = 1:p.alg.n_substeps # add forces ...
0727bd7b716e8771d3a760a908d65a8ca52fa2ac728ab1019ea8fa17f35e1ac2
Julia
2,605
76
function sub_time_steps!(s::State, alg::PGM) sc = s.cache # collision detection dt = s.params.sim.dt dtf = dt / alg.n_substeps μi = 1. / s.params.epi.mu for k = 1:alg.n_substeps # add forces compute_forces!(s) s.X .+= μi * dtf * sc.forceX s.A .+= μi * dtf * sc....
65c45616d70d47d0fe0c73a79e7d8d961d09ec1faaae2b0527cf998bbd27a3a3
Julia
2,629
97
function divide_cell(state::State{d}, p::StaticParameters, i::Int64) where {d} cell = state[i] # store value which we want to keep acrl = cell.apical_cytos_rest_length bcrl = cell.basal_cytos_rest_length hac = cell.has_apical_cytos hbc = cell.has_basal_cytos cell1 = new_cell_copy_startime...
0b797b2413330faf0adc0234da6696ffb6113392cc894e94fe9bdcef61bce86f
Julia
2,634
83
function read_cell_event(table, event_name="cell event") events = Dict{String,Any}() for row in 2:size(table,1) event = Dict{String,Any}() ct_name = table[row,1] if ismissing(ct_name) continue end for col in 2:size(table,2) key = table[1,col] ...
9a921f87d3a5cdb9641bd8ec07c90f267811e8bc508283009ff11d8845f7b765
Julia
2,644
97
function compute_forces!(s::State{Dim}, cache) where {Dim} (;forceX, forceA, forceB, da, dx, db, xixj, vl) = cache N = num_cells(s) c = s.cells # set zero forceX .= 0. forceA .= 0. forceB .= 0. @inbounds for i=1:N da .= 0 dx .= 0 db .= 0 a = s.A[:,i] ...
cc5a84faf86086b8e59aadd70c8764c74c8fc2ff5a294f1e73cdc7feaeda59c2
Julia
2,764
82
using DSP, Missings, Statistics, Distributions, Combinatorics """ """ pad_xcorr(r,nT,max,cells) = map((r,nT)-> vcat(missings(max - nT), xcorr(r[cells[1]], r[cells[2]]; padmode=:none) ./ (length(r[cells[1]]) .- vcat(length(r[cells[1]])-1:-1:0, 1:length(r[cells[1]])-1)), missings(max-nT)), r, ...
4f44c123b909ecedbc394dfba3070d804595d2811111b432afded0485a8c0b7e
Julia
2,773
83
""" """ function synthetic_data(θ::θneural_choice, ntrials::Vector{Int}, ncells::Vector{Int}; centered::Bool=true, dt::Float64=1e-2, rng::Int=1, dt_synthetic::Float64=1e-4, delay::Int=0, pad::Int=10, pos_ramp::Bool=false) nsess = length(ntrials) rng = sample(Random.seed!(rng), 1:nsess,...
ed7c63e2dda300a334d4a716f775b4cab8c650f44dbc50d398fa9fcb11587742
Julia
2,812
86
""" save_choice_data(file) Given a path, save data in to a `.MAT` file of an acceptable format, containing data, to use with `PulseInputDDM` to fit its choice model. """ function save_choice_data(file::String, data) rawdata = Dict("rawdata" => [(leftbups = x.click_data.clicks.L, rightbups = x.click_data.c...
7fa0888efebdb38ce4c46a9e3d14f39d78624e6ceb4ff11f4ebf6095a326aa85
Julia
2,920
88
module Initialization using LinearAlgebra using SparseArrays using Random using ..Types import StatsBase: mean export gen_recurrent_weights, gen_output_weights, gen_PW₀, shuffle_recurrent_weights! function check_for_at_least_one_input(W::SparseMatrixCSC) n_rows, _ = size(W) for i in range(1,length=n_rows) ...
d62c3943c96db30daaaeaa508e4c0692133064d67aa379bb6475dc6e1c43f7e5
Julia
3,090
115
""" choice_optimize(model, options) Optimize choice-related model parameters for a `neural_choiceDDM` using choice data. Arguments: - `model`: an instance of a `neural_choiceDDM`. Returns: - `model`: an instance of a `neural_choiceDDM`. - `output`: results from [`Optim.optimize`](@ref). """ function choice_o...
7e4e6df0aab5717538bb647253371367bc737104e1cef1ba12f64a5d7539224c
Julia
3,627
86
function getproperty_save(x, sym::Symbol) if hasproperty(x, sym) return getproperty(x, sym) else return missing end end function create_cell_dataframe(state::State2D) cs = state.cells DataFrame( label = state[:,:label], idx = collect(eachindex(cs)), ...
28137bc49ec4b35111762e90ca5e75fb345074e03d32a01271fb76f72a71cb2f
Julia
3,665
95
using Query function save_binned_data(fn, df; bin_pos_emt = false, Δt = 6.0, Δy = 0.333) # cleanup map!( s -> replace(s, "R" => ""), df.scenario, df.scenario) map!( s -> replace(s, "P" => "S"), df.scenario, df.scenario) map!( s -> replace(s, "∅" => "0"), df.scenario, df.scenario) scenarios = uniq...
31dafada825600a38b329656cf496bab4e0b855ad94e10ceabd58fc0ec250a50
Julia
3,943
173
""" synthetic_clicks(ntrials, rng) Computes randomly timed left and right clicks for ntrials. rng sets the random seed so that clicks can be consistently produced. Output is bundled into an array of 'click' types. """ function synthetic_clicks(ntrials::Int, rng::Int; tmin::Float64=0.2, tmax::Float64=1.0, click...
0d19e8213d460c8f78f740b73721a1707d2a727ffaa5ff7be1af1d8d8e3e038b
Julia
4,041
180
function load_parameters(fn) param = nothing sim_name_fn = "" if isfile(fn) if occursin('$', fn) return nothing end if lowercase(fn[end-4:end]) == ".toml" sim_name_fn = basename(fn)[1:end-5] file_str = read(fn,String) if file_str[1] == '\ufeff' file_str = file_str[4:end] end param = TOML....
3cc8d99bb4cc4b2b8630431e5704870ff6f14b71f284ea3ae877357ae4389456
Julia
4,102
146
Base.@kwdef mutable struct EpiCellType name::String = "control" color::String = "none" prototype_idx::Int64 = 1 cell_events::Vector{CellEvent} = [CellEvent(:R_hard, 0.7, 0.0; cell_ref_time = Cell_G2_Start)] special_cell_events::Vector{SpecialCellEvent} = [SpecialCellEvent(divide_cell; cell_ref_time...
8044f5b18ed8d608ea965f24518f6940a197db4a394cfeaf978fc9e02bd650d2
Julia
4,267
167
""" initalize(data, f) Returns: initializition of neural parameters. Module-defined class `θy`. """ function initalize(data, f::Vector{Vector{String}}) θy0 = θy.(data, f) x0 = vcat([0., 15., 0. - eps(), 0., 0., 1.0 - eps(), 0.008], vcat(vcat(θy0...)...)) θ = θneural(x0, f) fitbool, lb, ub =...
00ec2ef6caf2a48188e3bafddd1d103ae3f5d2514ffa9c941afa974f86404085
Julia
4,636
189
""" """ @with_kw struct neural_choice_GLM_DDM{T} <: DDM θ::T n::Int=53 cross::Bool=false end """ """ @with_kw struct θneural_choice_GLM{T1, T2, T3} <: DDMθ stim::T1 bias::T2 lapse::T2 θy::T3 f::Vector{Vector{String}} end """ """ @with_kw struct neural_choice_GLM_options fit::Vect...
b2b2d078bf5b06b69f1464adcee11610772206ab12353c8062f6cbd1f5bc5e21
Julia
4,782
171
EpiCellVector = typeof(StructVector(EpiCell[])) Base.@kwdef mutable struct State{Dim} X::HArray{Float64,Dim} = hzeros(Val(Dim),0) # nuclei positions A::HArray{Float64,Dim} = hzeros(Val(Dim),0) # apical positions B::HArray{Float64,Dim} = hzeros(Val(Dim),0) # basal positions apicalcons::EdgeList{Floa...
ef3041b911b5877ec3a7354548e9f1cfa9ee6396d07e34eee1a95e81691e985e
Julia
4,957
159
using SEMTor, DataFrames, ProgressMeter, CSV, Statistics, XLSX include("analyze_state.jl") #= Ensebmle simulation of the model for reproducing the data in S. Plunder, C. Danesin, B. Glise, M. A. Ferreira, S. Merino-Aceituno, E. Theveneau, Modelling variability and heterogeneity of EMT scenario...
501dc053a8a2d810e86044cd5611aa309ee09cb82d487030f10427d47971da2e
Julia
5,014
256
""" $(TYPEDEF) """ @with_kw struct neuralinputs{T1,T2} clicks::T1 binned_clicks::T2 λ0::Vector{Vector{Float64}} dt::Float64 centered::Bool delay::Int pad::Int end """ """ neuralinputs(clicks, binned_clicks, λ0::Vector{Vector{Vector{Float64}}}, dt::Float64, centered::Bool, delay::Int, pad::...
218caa903fccfcacde8c6a333eed6e8013a38b65ce7fed20aaf97e73658d702f
Julia
5,359
171
function categorise(t1,t2,t3, n1 = "A", n2 = "B", n3 = "S", n0="") tup(t,n) = (t, isinf(t) ? n0 : n) Ts = [tup(t1,n1), tup(t2,n2), tup(t3,n3)] sort!(Ts, by = tn -> tn[1]) res = prod(tn[2] for tn in Ts) return isempty(res) ? "∅" : res end function basal_extr_criterium(x, wnd) for i in eachindex(x)...
d82f5e2e9fda53e39773a8f7c3aaeae4a2f6977c2350ba912644fba7c2a0c8df
Julia
5,612
114
# module load tools # module load julia/1.9.0 # export JULIA_DEPOT_PATH=/home/projects/cpr_10006/people/svekut/julia_packages # julia --startup-file=no --project=@vambbench using DataFrames, CSV using VambBenchmarks function get_nbins(binning::Binning, recall::Real, precision::Real; tax_level::Integer=0, assembly::B...
62ced64e3f5e0eebf32cb32e672de55377e3b78441fd7bba87a2c5d3e6216b06
Julia
5,834
137
#= This file generates an initial set of DA neurons using the DA model as well as neuromodulating this set to tune its firing pattern =# # Include DICs computation include("FYON_2022_DA_DIC.jl") # Include the computation of DICs and compensation algorithms ## Functions to generate the initial set of DA neuron...
a844d4bc2b04b53a7bab7aa4deae0f8004fbd37db85f87ca881f6b0c7175c259
Julia
5,991
141
#= This file generates an initial set of STG neurons using the STG model as well as neuromodulating this set to tune its firing pattern =# # Include DICs computation include("FYON_2022_STG_DIC.jl") # Include the computation of DICs and compensation algorithms ## Functions to generate the initial set of STG ne...
48acd6c8b7a6678b4fcfe3115e897f778aa88c9b2c5166039fcb36add1f37931
Julia
6,016
198
mutable struct VerletList{Dim} box_list::Vector{Int64} # box_list[i] is either another index which is in the same box as 'i' or < 1 heads::Array{Int64,2} # containts the first index out of each box # domain bottomleft::SVector{Dim,Float64} topright::SVector{Dim,Float64} dx_inv::SVector...
3ca4ccad4f2d067f31f798a0f8405dc502f594965616f5c412b6c34a2598aac4
Julia
6,454
224
function simulate_expected_firing_rate(θ::Union{θneural, θneural_choice}, data, rng) @unpack θz,θy = θ μ_λ = rand.(Ref(θz), θy, data, Ref(rng)) return μ_λ end """ simulate_expected_firing_rate(model) Given a `model` generate samples of the firing rate `λ` of each neuron. Arguments: - `mo...
1f883be7e42d682638b219faa5d2e8f97a0cbb78ef4f47b21475e30ea4570aa8
Julia
6,628
193
Base.@kwdef struct EpitheliumParameters N_init::Int64 = 30 basal_curvature::Float64 = 0.0 basal_curvature_elliSEMTor_factor::Float64 = 4.0 init_curve_start::Float64 = 0.0 curve_growth::Float64 = 0.1 max_cytoskeleton_length::Float64 = Inf64 running_zone::SVector{2,Float64} = [-2.0, 0.0] ...
c860b18c845c9cf970e55f5f2b372d02d077ae836bccc9f0f3edf6c091175d55
Julia
6,842
225
""" all_Softplus(data) Returns: `array` of `array` of `string`, of all Softplus """ function all_Softplus(ncells) #ncells = getfield.(first.(data), :ncells) f = repeat(["Softplus"], sum(ncells)) borg = vcat(0,cumsum(ncells)) f = [f[i] for i in [borg[i-1]+1:borg[i] for i in 2:length(borg)]] ...
9752d234343582bdd1ccde0b97f27fa78661be967929d9928109717d31a57e47
Julia
6,917
253
""" sep_choice_neural_optimize(model, options) Optimize (potentially all) model parameters for a `neural_choiceDDM` using choice and neural data. Arguments: - `model`: an instance of a `neural_choiceDDM`. - `options`: some details related to the optimzation, such as which parameters were fit (`fit`), and the up...
41d221f90655ac98f8efef32ee06bc9559a311fe98feac47d0b8f536a3d36dce
Julia
7,124
259
function init_state(p::StaticParameters, rep = 1) Random.seed!(p.stat.random_seed + rep - 1) X, A, B = init_positions(p) init_cell_type_names = generate_init_cell_types(p) all_cell_types = [cts.prototype.name for cts in p.cell_types] N = p.epi.N_init types = EpiCellType[] cells = StructVec...
044ee5fe3d2307a833c79d81b8ee5e065369ff04a8fc499634dcc3f80deeabd8
Julia
7,535
222
module IO using DataFrames using Parameters using ..Types import JSON2 import HDF5 import JLD import CSV import Dates export load_weights, save_weights, load_params, save_params, save_experiment_params, load_metadata, save_metadata, save_experiment_metadata, modify_metadata, save_network, load_network, load_sets, rei...
b11858e8a5b66179e421b5910611994092cb41f71797e8e0f3b4221d2d5a16f1
Julia
7,611
154
@info "Loading CSV" using CSV @info "Loading DataFrames" using DataFrames @info "Loading Dates" using Dates @info "Loading Plots" using Plots @info "Loading Statistics" using Statistics @info "Loading NeuroAnalyzer" using NeuroAnalyzer df = CSV.read("rem_new.csv", DataFrame) eeg_powers = DataFrame(:id=>Int64[], :rem_...
c66ae06896d9c696f43f451fc1acbb65d3ed2e6b9a0732fd3cc6ec2d14b1f1de
Julia
8,309
304
""" choice_neural_optimize(model, options) Optimize (potentially all) model parameters for a `neural_choiceDDM` using choice and neural data. Arguments: - `model`: an instance of a `neural_choiceDDM`. Returns: - `model`: an instance of a `neural_choiceDDM`. - `output`: results from [`Optim.optimize`](@ref). ...
0effd0fb9450389e04d7fd33802d4970caab442bd0162f2d127ff38e4975a3ca
Julia
8,552
312
function project_onto_line(L, P) v_L = L[:,2] - L[:,1] v_P = P - L[:,1] d_L = dot(v_L, v_L) if d_L == 0. return L[:,1] end f = max(0., min(1., dot(v_L,v_P) / dot(v_L, v_L))) return L[:,1] + f * v_L end function project_onto_linestrip(L, P) dist = Inf64 Pr = [NaN, NaN] ...
2114b3a1c6e2108414862388c26a15ed4c830bf88eb0736cb1a1fa85d3ee0e80
Julia
8,637
276
struct RandomCellTypeParam des_param::Tuple{Symbol,Int64,Symbol} des_param_str::String src_val::Float64 src_param::Tuple{Symbol,Int64,Symbol} src_param_str::String src_rand::Tuple{Symbol,Float64,Float64,Float64,Float64} end function Base.show(io::IO, rct::RandomCellTypeParam) print(io, stri...
36194e6e62b90f0c99859742227d7d7e5ba3e0973409611fcb9469965f273563
Julia
8,667
357
#= """ """ function optimize(data, options::neural_poly_options; x_tol::Float64=1e-10, f_tol::Float64=1e-6, g_tol::Float64=1e-3, iterations::Int=Int(2e3), show_trace::Bool=true, outer_iterations::Int=Int(1e1), α1::Float64=0.) @unpack fit, lb, ub, x0, ncells, f, nparams, npolys = options ...
4068de1ed0937526e1c3fcb6ad588c0b59b68c115e8efd24bb100a00ec3fcf02
Julia
8,897
349
""" flatten(θ) Extract parameters `neuralDDM` and place in the correct order into a 1D `array` ``` """ function flatten(θ::θneural) @unpack θy, θz = θ @unpack σ2_i, B, λ, σ2_a, σ2_s, ϕ, τ_ϕ = θz vcat(σ2_i, B, λ, σ2_a, σ2_s, ϕ, τ_ϕ, vcat(collect.(Flatten.flatten.(vcat(θy...)))...)) end """ ...
576c9d46fa204b93a3caf36c55dbdff25768ca74c346b21b05e3853342a2b178
Julia
10,570
234
#= This file computes the dynamic input conductances of the DA model as well as applying the compensation algorithm for a set of maximal conductances (inputs of the algorithm) =# include("FYON_2022_DA_kinetics.jl") # Include model gating functions include("FYON_2022_DA_gs_derivatives.jl") # Include derivatives of mode...
136eb3baa9b9629fbc128ed6d981dbd9aa41ff352413fa7d923708315bf9c7f2
Julia
10,704
446
const dimz = 7 """ CIs(H) Given a Hessian matrix `H`, compute the 2 std confidence intervals based on the Laplace approximation. If `H` is not positive definite (which it should be, but might not be due numerical round off, etc.) compute a close approximation to it by adding a correction term. The magnitude of ...
49985582a43097884c347b17e5c005689c52fccf8ebbab2a8d6a6682d42fdabb
Julia
11,056
352
function minimal_plot_rect(states::Array{State{Dim}}, p::StaticParameters; margin = 0.2)::Rectangle{Dim} where {Dim} plot_rect=deepcopy(p.epi.init_zone) for state in states extend!(plot_rect, state.X) extend!(plot_rect, state.A) extend!(plot_rect, state.B) end plot_rect.size *= 1. + margin ...
9afc176131ae66210f030b807dfae339f081d1290242309bd6313370cef3300c
Julia
11,102
285
using FMM3D using Test using Random using LinearAlgebra @testset "testing Helmholtz utilities" begin n = 1000 nt = 1100 sources = randn(3,n) targets = randn(3,nt) charges = randn(n) + im*randn(n) dipvecs = randn(3,n) + im*randn(3,n) zk = 2.1 vals1c = h3ddir(zk,sources,targets,charges=...
304fbea31f49f051daa3573ac7eb9a136adf88ec150bd1f94692f2001df97670
Julia
11,137
431
""" fit(model, options) fit model parameters for a `choiceDDM`. Returns: - `model`: an instance of a `choiceDDM`. - `output`: results from [`Optim.optimize`](@ref). Arguments: - `model`: an instance of a `choiceDDM`. """ function fit(model::choiceDDM, data::Union{choicedata{choiceinputs{clicks, binned_clicks}...
267c6e462154b15ed54a15802b9239f2b2b1082e9dbccee9e3ba176968143023
Julia
12,466
357
using Plots using StatsBase using LaTeXStrings using DelimitedFiles function bfs(node, dict_nodes, dict_edges, counted, retained_link, clusterID, ID_list) # Breadth first search. Given the network structure, return the size of connected component that contains `node` # ID_list[i]: node i is in the component w...
341cfd8c2a2f70dc93f25cbc62f417c60e4128eb3ee3b847a6a96bb47782ec92
Julia
14,329
269
using NeuroAnalyzer using Plots using StatsKit cd(expanduser("~/Documents/Research/manuscripts/tdcs-avh/")) # load EEG data eeg1 = import_edf("79-v1.edf") eeg2 = import_edf("79-v2.edf") # load electrode locations, required for ICA load_locs!(eeg1, file_name=joinpath(NeuroAnalyzer.PATH, "locs", "standard-10-20-cap19-...
356b9c5bd4c45c494d12fb90c04fae16a0adbc3b8c22283528ef1229b4d97f87
Julia
14,339
327
#= This file contains differential equations describing the STG model =# include("FYON_2022_DA_kinetics.jl") # Include DA model gating functions ## DA model from Drion 2011 - current-clamp mode function DA_ODE(du, u, p, t) # Parameters Iapp = p[1] # Amplitude of constant applied current gNa = p[2] # So...
dee4610a9f459221d525e8a74ba4e412b99573e2486b59c0f2b1e844839afe89
Julia
14,792
323
#= This file contains differential equations describing the STG model =# include("FYON_2022_STG_kinetics.jl") # Include STG model gating functions ## STG model from Liu 1998 - current-clamp mode function STG_ODE(du, u, p, t) # Parameters Iapp = p[1] # Amplitude of constant applied current gNa = p[2] ...
be25f1f70d4850beb17eb5bffa3946819638d2c97b933ec2f37b632133b954f9
Julia
14,868
381
module Plots using CSV using DataFrames using PyPlot; const plt = PyPlot using ..Math using ..IO export init_rate_figure, update_rate_figure, init_plasticity_figure, update_plasticity_figure, init_current_figure, update_current_figure, init_IDom_figure, update_IDom_figure, init_raster_figure, update_raster_figure...
c18d0f4726e7007a4bb4999f70d97450dae815572af86699e3b2447fb16e0070
Julia
16,145
247
#= This file computes the dynamic input conductances of the STG model as well as applying the compensation algorithm for a set of maximal conductances (inputs of the algorithm) =# include("FYON_2022_STG_kinetics.jl") # Include model gating functions include("FYON_2022_STG_gs_derivatives.jl") # Include derivatives of m...
7d6c582a362229b3a760eca8761ff7d9673819dda9123822781d6943258bbd4c
Julia
18,323
522
function simulate(p::StaticParameters, rep::Int64 = 1; obs = missing, inplace=false, verbose=nothing, obs_callback=missing, pbd=true) s = init_state(p, rep) if !isnothing(verbose) println("Finished initialisation.") end return simulate(s, p, rep; obs, inplace, verbose, obs_callback, pbd) ...
74d9bb70e7491f70aeb5cfabff55cb9e8fe6dbe9da6f3c6da7df8c94c05f8142
Julia
20,958
424
#= This file contains functions to extract characteristics of the firing pattern as well as some functions to plot complicated graphs =# using Statistics, Plots, StatsPlots, LaTeXStrings, Printf ## Functions extracting characteristics of the firing pattern # This function extracts the spiking frequency of a...
7ad175986a46b648774aeda34a19f6dad02ccb6ba7f4fe60c0ccaa501edfc664
Julia
21,986
442
#= This file contains functions to extract characteristics of the firing pattern as well as some functions to plot complicated graphs =# using Statistics, Plots, StatsPlots, LaTeXStrings, Printf ## Functions extracting characteristics of the firing pattern # This function extracts the spiking frequency of a...
c03cff84e47860dacca5da1e5d5a6752a8f49440ee3a3c2d13b338c96f59d13c
Julia
36,717
967
function remean(data, μ_rnt; do_RBF=true, nRBFs=6) spikes = getfield.(data, :spikes) input_data = getfield.(data, :input_data) choice = getfield.(data, :choice) binned_clicks = getfield.(input_data, :binned_clicks) clicks = getfield.(input_data, :clicks) nT = getfield.(binned_clicks, ...
0fa92c6296f056ab55217f1c06472d22409b9492defe33fce03c5ae8b528e162
Julia
50,765
1,274
using LinearAlgebra using SparseArrays using ProgressBars # For progress indicator using Printf # For print formatting using Parameters # For default keywords using DataStructures # For Queue using Statistics using Distributions import Distributions: Normal import StatsBase: mean, sample, Weig...
d430efcebc5ff317ce9b453a7b129f16bdb52d97ab738f4f4d7d3ccba7f35c92
Julia
65,343
2,111
""" module FMM3D Wrappers for the Flatiron Institute's FMM3D library. # wrappers All N-body codes return output in an `FMMVals` structure. See documentation of N-body codes for details. N-body interactions with the Helmholtz kernel - [`hfmm3d`](@ref): ``O(N)`` fast mutlipole code - [`h3ddir`](@ref): ``O(N^2)`...
24312dc88be70203832772674bf19d82a8cba52c4792836052748d31e1c11b44
Jupyter
88
5
# %% from pybioportal import server_running_status as srs # %% srs.get_server_status()
baf7c525386fe5b20d5ec99705b8085272d6a803ed8608f5f4cda97c2707ed8c
Jupyter
148
10
# %% from pybioportal import cancer_types as ct # %% df1 = ct.get_all_cancer_types() df1 # %% df2 = ct.get_cancer_type(cancer_type_id="brca") df2
10c03bde726673e371a0efba3dc6f6eac58e310136a7eba2d38cbe58ee82ca9a
Jupyter
163
9
# %% from pybioportal.info import get_info get_info() # %% df = get_info() for column in df.columns: print(f'{column}: {df[column].to_string(index=False)}')
517c2414272086493ae5bc9a31a44e467ef53fe221869656f03fd1ac2a5176a8
Jupyter
225
24
# %% from language import figures as fig %reload_ext autoreload %autoreload 2 %matplotlib inline import warnings warnings.filterwarnings('ignore') # %% fig.fig1() # %% fig.fig2() # %% fig.fig3() # %% fig.figS1() # %%
7b6d37c42b04a4d44bb7b2d4ab3e4502cad5ed914c378840fd747e3fbd7976f5
Jupyter
310
27
# %% import cv2 import numpy as np # %% image_shape = (50,50) # %% data = (np.random.rand(50,50,3)) data2 = (np.random.rand(50,50,3)) # %% cv2.imshow("test",data) # %% cv2.imshow("2",data2); # %% cv2.waitKey(0) # %% cv2.destroyAllWindows() # %% data = (np.random.rand(50,50,3)) cv2.imshow("test",data)
397526370720098cf070d7e999b5fee132c26508be020919cfaa8f07225f9c06
Jupyter
328
15
# %% from pybioportal import gene_panels as gp # %% df1 = gp.get_all_gene_panels() df1.head(10) # %% df2 = gp.get_gene_panel("NSCLC_UNITO_2016_PANEL") df2.head(10) # %% df3 = gp.fetch_gene_panels(gene_panel_ids=["NSCLC_UNITO_2016_PANEL", "bcc_unige_2016_cancer_panel"], projection="DETAILE...
0c01743c1c03b74a1cdb4d43c4bff83aa542732a01263b7e13ff0c61f789020c
Jupyter
332
22
# %% from pybioportal import genes as gns # %% df1a = gns.get_all_genes(keyword = "BRCA1") df1a # %% df1b = gns.get_all_genes(alias = "FANCS") df1b # %% df2 = gns.get_gene("BRCA1") df2 # %% df3 = gns.get_aliases_of_gene("BRCA2") df3 # %% df4 = gns.fetch_genes(gene_ids=["BRCA1","BRCA2"], gene_id_type = "HUGO_GENE_S...
eaf6ecb67a4ac4d5da904b2489f6770df630b65905c67a6308f47703960e80cc
Jupyter
375
21
# %% import h5py as h5 from scipy import sparse import numpy as np #import seaborn as sns #sns.set(style = 'ticks') from lisa.core.data_interface import DataInterface from scipy.stats import gamma #import matplotlib.pyplot as plt # %% data = DataInterface('hg38', 100) # %% indices, metadata = data.get_binding_dataset...
3c7d479ca25b540b362beb750e704386ac7840d06c13727c0affec607b5acc6d
Jupyter
406
20
# %% from fimpy.core import H5SplitDataset from fimpy.pipeline.twop import align_2p_volume from pathlib import Path from skimage import io # %% path_list = [Path(r"J:\_Shared\experiments\E0022_multistim\v05_imaging_single_cell\181220_f2c2")] # %% for p in path_list: print(p) stack = H5SplitDataset(p / "aligne...
4b341a79d0f0dbe5afc32724f2aff2f1f6751639669cdc0c04447325029131c4
Jupyter
416
22
# %% from pybioportal import studies as std # %% df1 = std.get_all_studies(keyword="TCGA", projection="DETAILED") df1 # %% df2 = std.get_study(study_id="brca_tcga") df2 # %% df3 = std.get_tags_of_study(study_id="bowel_colitis_msk_2022") df3 # %% df4 = std.fetch_studies(study_ids=["brca_tcga","acc_tcga"], projection...
d891282c4a72d9da1b14fcd40f8cb8a50a09e47b1db8264fea21d3c92882f8b6
Jupyter
443
13
# %% [markdown] # Index # ============ # # This Github repository contains analysis and data relating to Winchester et al. (2024) Reproducible supervised learning-assisted classification of spontaneous synaptic waveforms with Eventer. Front Neuroinform. Submitted. # # There are 2 notebooks relating to figures in the ...
71db33785d1f9f8784f4d825baf903fa3f1e2f8d7b576d0a33c98310a13085be
Jupyter
457
28
# %% import matplotlib.pyplot as plt from utils import get_embs_labels, make_sim_matrix, make_result, make_tp_fp # %% embs, labels = get_embs_labels('data/embeddings_35.npy', 'data/labels_35.txt') sim_matrix = make_sim_matrix(embs) # %% pairs = make_result(sim_matrix, labels, th=4) # %% pairs[:10] # %% tps, fps = m...
7552cfb3913a31e48dd136ec16b14628c74002248ea98aaabe2dedef9bb2b452
Jupyter
470
22
# %% from pybioportal import sample_lists as sl # %% df1 = sl.get_all_sample_lists(projection="DETAILED") df1 # %% df2 = sl.get_sample_list(sample_list_id="brca_tcga_cna") df2 # %% df3 = sl.get_all_sample_ids_in_sample_list(sample_list_id="brca_tcga_cna") df3 # %% df4 = sl.fetch_sample_lists(sample_list_ids=["brca_...
6d45dfde71745fe0ac557934795b595ec45c798b1628d5bb63e23247ac4abb44
Jupyter
509
22
# %% from pybioportal import molecular_profiles as mf # %% df1 = mf.get_all_molecular_profiles() df1.head(5) # %% df2 = mf.get_molecular_profile("gbm_tcga_pan_can_atlas_2018_armlevel_cna") df2 # %% df3a = mf.fetch_molecular_profiles(molecular_profile_ids=["brca_tcga_mrna", "acc_tcga_rna_seq_v2_mrna"]) df3a # %% df3...
0cd8e1abb675fe2744d0495626d6ee13861bf82e7cee422b4e9f261c33159342
Jupyter
526
25
# %% [markdown] # # Store 10 digits for validation # %% import tonic import torch import numpy as np import tqdm # %% to_frame = tonic.transforms.ToFrame(sensor_size=tonic.datasets.NMNIST.sensor_size, time_window=1e3) test_ds = tonic.datasets.NMNIST("./nmnist", transform=to_frame, train=False) # %% numbers = [] for ...
f1d3a763152f548384ed8832b52d14eb14218b3954a52da524f9695e469898ac
Jupyter
555
19
# %% from pybioportal import generic_assays as ga # %% df1a = ga.fetch_generic_assay_meta(generic_assay_stable_ids=["TULP4_pS563", "TEP1_pS397", "ALAD_214_215_1_1_S215"]) df1a # %% df1b = ga.fetch_generic_assay_meta(molecular_profile_ids=["brca_tcga_phosphoprotein_quantification", ...
68cedeea2ce6b445286e07f81e203ba2a3622c0721e307eaa2c9c246b89767c8
Jupyter
572
18
# %% %load_ext autoreload %autoreload import UnitMatchPy.Save_utils as su import numpy as np import pandas as pd import matplotlib.pyplot as plt # %% SaveDir = r'c:\Users\Experiment\Documents\E-phys\UMPY savedata\test1' # %% # Load base output #UMScores, ClusInfo, param, MatchProb, WavefromInfo, MatchTable = su.load...
758eff200f0a8af26f2dc7bdbcb72aa8651f5168365b8bf6526919de18df6db5
Jupyter
589
25
# %% from pybioportal import clinical_attributes as ca # %% df1 = ca.get_all_clinical_attributes() df1 # %% df2 = ca.fetch_clinical_attributes(study_ids=["brca_tcga", "brca_bccrc"]) df2 # %% df3a = ca.get_all_clinical_attributes_in_study(study_id="brca_tcga", projection="DETAILED") df3a # %% [markdown] # In case of...
c3f3a0c06f4b0f562c66a9aac131e6addc8d3c926f7680bd916aad3af140cd51
Jupyter
624
20
# %% from pathlib import Path from scipy import io from skimage.external.tifffile import imsave import numpy as np # %% #path = Path(r"J:\_Shared\experiments\E0032_luminance\v01_flashes\GC") #GC Flashes path = Path(r"J:\_Shared\experiments\E0032_luminance\v02_steps\GC") #GC Steps path_list = list(path.glob("*_f[0-9]")...
d9d434adb398ad8c99534d6b4b35c6a6ee4a8b53b716479907d1ea0289546872
Jupyter
633
37
# %% from nmnist import NMNISTFrames, NMNISTRaster import torch # %% dataset = NMNISTFrames(save_to='data', batch_size=64, precision=32) dataset.prepare_data() dataset.setup() trainset = dataset.train_data trainloader = dataset.train_dataloader() # %% images, labels = next(iter(trainloader)) # %% image, label = tra...
643b055218ed0ccbe0ee3492a1c76af7f4b45b1f7ae802d4ff9e33622670def0
Jupyter
658
24
# %% import numpy as np import pandas as pd import scanpy as sc # Generate a virtual dataset num_cells = 1000000 # Number of cells num_genes = 3000 # Number of genes # Generate a random gene expression matrix gene_expression = np.random.rand(num_cells, num_genes) # Create metadata cell_metadata = pd.DataFrame({ ...
1bd74b95e9b01340dec6bbce453a620baf1d6c17593ee19ca5abf61104818c22
Jupyter
684
51
# %% %load_ext autoreload %autoreload 2 # %% import PySpin # %% from multicamera_acquisition.interfaces import get_camera # %% camera_list = [ {'name': 'top', 'serial': 22181547}, #{'name': 'side1', 'serial': 22181612}, ] # %% serial_number = 22181547 exposure_time = 2000 # %% cam = get_camera( brand="...
f61d9a17c2a9c4be3885541cb667a8d01b6921e83792a8ffe129fdbbb08772ea
Jupyter
700
31
# %% # The current millard_depo contains 11513 proteins. Let's cluster at 95% to reduce the dataset: import os path_work = "/media/concha-eloko/Linux/DepoPhagedetection_work" dataset = f"{path_work}/millard_depo.indexed.v3.fasta" cd-hit -i millard_depo.indexed.v3.fasta -o millard_depo.indexed.v3.reduced.fasta -c 0....