sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
076f1f11155e400e64364114787d5458d1d23f9691e0acf6f05472bd5860fba5
Julia
3,790
65
@testset "Orbital configuration" begin # Test 1: Test conjugates sym = Hamster.SymOrb() def = Hamster.DefOrb() mirr = Hamster.MirrOrb() @test typeof(Hamster.conjugate(sym)) <: Hamster.SymOrb @test typeof(Hamster.conjugate(def)) <: Hamster.MirrOrb @test typeof(Hamster.conjugate(mirr)) <: Ha...
2c933883716058b552c78fe588c19ea47dae5792b4f1a7a09908de7956467b2a
Julia
3,922
109
# uses Gaussian emission dist for mL - mR struct HMM_ARTR_m_diff <: HiddenMarkovModels.AbstractHMM transition_matrix::Matrix{Float64} # T[y,z] = P(y -> z) μ::Vector{Float64} σ::Vector{Float64} pinit::Vector{Float64} # initial state probabilities λreg::Vector{Float64} # regularization for μ func...
501a22b999bbc607c54f2ab5b889da606e24b8e5475400bf41b67626863aa701
Julia
3,923
109
### A Pluto.jl notebook ### # v0.19.41 using Markdown using InteractiveUtils # ╔═╡ 1dc64219-66c6-44e8-8cba-bda286833f94 import Pkg, Revise; Pkg.activate(Base.current_project()) # ╔═╡ 6ae0e2b3-16af-41c5-99d7-7bb4d5a5d7bb using Statistics: mean, std, cov, cor # ╔═╡ 5c8c9272-34dd-4aa0-a5e0-7df9eff2ba96 using DataFrame...
28e45f5916a7795379a8e06c4c9bd264958b1ba2c1930883b7e8c95972b9d550
Julia
3,968
118
### A Pluto.jl notebook ### # v0.19.41 using Markdown using InteractiveUtils # ╔═╡ d9d420e7-9df0-4aa5-8b18-b9ec77a9021e import Pkg, Revise; Pkg.activate(Base.current_project()) # ╔═╡ be486509-c91a-49e9-b8ec-65fde601dab5 using Statistics: mean # ╔═╡ a22b7e35-84ca-424a-b888-b933d5637436 using Distributions: Normal #...
57a4a1e5aefa7df99bc4c9af9bd5d910cfb0e40b64c3ab99d34bf9d1440845e7
Julia
4,015
114
function brute_force_periodic_coulomb( pos, q, box; nimg::Int=3 ) N = length(pos) phi = zeros(Float64, N) E = 0.0 @views for i in 1:N ri = pos[i] for j in 1:N rj = pos[j] qj = q[j] for nx in -nimg:nimg, ny in -nimg:nimg, nz in -nimg:...
9624aa563798b40e24373933bde4360f64ec2a3424ce6d7bb769a924700f91b4
Julia
4,021
97
using Colors using DelimitedFiles # RelaxationColorMap: acts in two ways: # 1. generate a colormap to be used on display, given image type # (which must be one of # "T1","R1","T2","T2*","R2","R2*","T1rho","T1ρ","R1rho","R1ρ","t1","r1","t2","t2*","r2","r2*","t1rho","t1ρ","r1rho","r1ρ") # and given t...
edcaeb9bee2a6d5da075fdab6f51ff48d306484227f57e28de1d8ff450029f8c
Julia
4,023
112
mutable struct ZebrafishHMM_TN03 <: HiddenMarkovModels.AbstractHMM #= Truncated normal (TN) turning angle emissions (zero mean). States are stored in this order: 1. Forward (forward bouts) 2. Left (left turning bouts) 3. Right (right turning bouts) =# const initial_probs::Vec...
8c5d9371f0ab05c170184f2503cdb8f74f19f60fb9d4edfbb6fbe6f9fd59f3ca
Julia
4,036
164
# Kai Sandbrink, building off script by Johanni Brea # 2023-01-31 # This script solves the Infobandit POMDP - OvB for the Pure Explore v. Pure Exploit Task ## LIBRARY IMPORT using Pkg; Pkg.activate("."); Pkg.instantiate() Pkg.add(["POMDPTools", "CSV"]) using POMDPs, POMDPTools, QuickPOMDPs, SARSOP, Statistics using ...
fd006f8bd187d5d453397d914c83307e27baa353cbd58353f62df63e24a87f4e
Julia
4,050
101
struct Gaze_ARTR_Emit gaze::Normal{Float64} # Normal gaze distribution logbias::Vector{Float64} # Fields for the ARTR neural activity pseudocount::Float64 # regularize inference of fields function Gaze_ARTR_Emit(gaze::Normal, logbias::AbstractVector{<:Real}, pseudocount::Real = 0.0) @assert all(...
7d0d0cbb4965c2b793af17986a720fdf429e094cf9a40e8aaac79202e8358480
Julia
4,115
89
@testset "Optimization workflow for TB" begin path = joinpath(@__DIR__, "test_files") conf = get_config(filename = joinpath(path, "hconf")) set_value!(conf, "poscar", joinpath(path, "POSCAR_gaas")) set_value!(conf, "rllm_file", joinpath(path, "rllm.dat")) set_value!(conf, "train_data", "Optimizer", ...
6697c33864b502f1e92a4bb9f6d1c93f5c37e42b04e335baa8e562a08421556f
Julia
4,197
85
""" get_nearest_neighbors(r0, rs, Ts, point_grid::PointGrid; kNN=1, sorted=false) Find the nearest neighbors (NN) of a given point `r0` within a set of points `rs` and translation vectors `Ts`. # Arguments - `r0::AbstractVector{T}`: The reference point in 3D space for which the nearest neighbors are to be found. ...
ce8f38caac285979666824b59e7ff376b3fd8a2baad27e0055d80dae5ae10d81
Julia
4,204
85
""" get_nearest_neighbors(r0, rs, Ts, point_grid::PointGrid; kNN=1, sorted=false) Find the nearest neighbors (NN) of a given point `r0` within a set of points `rs` and translation vectors `Ts`. # Arguments - `r0::AbstractVector{T}`: The reference point in 3D space for which the nearest neighbors are to be found. ...
1a72f8c67f6ad58bdcd0cffb7bf254274ee63846f007d424a0dc4cd10f52a21c
Julia
4,211
82
@testset "Fit model to GaAs eigenvalues" begin path = joinpath(@__DIR__, "test_files") conf = get_config(filename = joinpath(path, "hconf")) set_value!(conf, "poscar", joinpath(path, "POSCAR_gaas")) set_value!(conf, "rllm_file", joinpath(path, "rllm.dat")) set_value!(conf, "train_data", "Optimizer",...
93df88757c12aab06d1da629c9daae5d052e98697b0d20c38216c98eb004c2a6
Julia
4,232
92
@testset "Optimization workflow for TB" begin path = joinpath(@__DIR__, "test_files") conf = get_config(filename = joinpath(path, "hconf")) set_value!(conf, "poscar", joinpath(path, "POSCAR_gaas")) set_value!(conf, "rllm_file", joinpath(path, "rllm.dat")) set_value!(conf, "train_data", "Optimizer", ...
d6733c03194ffce6830f235d2381599f20e5138bd06187958ff60472fd53602f
Julia
4,241
78
""" Structure A data structure representing a crystal structure, including its lattice vectors, atomic positions, and a point grid for efficient neighbor searching. # Fields - `lattice::Matrix{Float64}`: A 3x3 matrix representing the lattice vectors of the crystal. Each column corresponds to a lattice vector. - `...
93e5305983172e1b065e1985ad612d702a7f4e24357cd4864f78dcd71c4914c1
Julia
4,254
130
using Plots using HDF5 using NaNStatistics using Statistics # MAIN PATH DANDIPATH = "/Volumes/labs/dmclab/Pierre/NPX_Database/mPFC/Passive/" #"Your/Path/To/DandiSet/" # FIGURE PATH FIGPATH = "Your/path/to/figures" # UTILS FUNCTIONS REQUIRED include("Utils/simple_raster_units.jl") include("Utils/simple_PSTH.jl") # P...
740e057df8430d3535b07bd7a9cc790aeca28dc87dc4f28b8b69b6410b5d08a0
Julia
4,259
101
""" Ion A mutable structure representing an ion in a crystal lattice. # Fields - `type::UInt8`: The type or species of the ion, denoted by its proton number. - `pos::StaticArray{3, Float64}`: A 3D static array representing the position of the ion in Cartesian coordinates. - `dist::StaticArray{3, Float64}`: A 3D s...
31bcc309e495d0bc30101d77dd034165574a99ab7c1604d60998848c84c3cf0c
Julia
4,279
140
println(""" Welcome to =========================================================================== || _ _ _ _ _ || || | | | | __ _ _ __ ___ ___ | |_ ___ _ __ (_) | | || || | |_| | / _` | | '_ ` _ \\ / __| | __| / _ \\ | '__| | ...
4c8b48321b71fac688edd52b4646c92a3d2d6406e8d0f30fd31270671ff47182
Julia
4,295
146
using Plots using ProgressMeter using Glob using HDF5 using Statistics using Random Random.seed!(42) # MAIN PATH ZENODOPATH = "Your/Path/To/Zenodo/Data" DANDIPATH = "Your/Path/To/DandiSet/" DANDIPATH2 = "Your/Path/To/DandiSet2/" # FIGURE PATH FIGPATH = "Your/path/to/figures" # Hard-coded values used for the Nw Ww s...
53897c50cb9a286a562eb5c51a974933f0ad45cc3963727fde3b0d1b1bb258dc
Julia
4,333
117
mutable struct ZebrafishHMM_TN04 <: HiddenMarkovModels.AbstractHMM #= Truncated normal (TN) turning angle emissions (zero mean). States are stored in this order: 1. Forward-Left (forward bouts, but last turn was left) 2. Forward-Right (forward bouts, but last turn was right) 3. Left (lef...
25892bad05a12d4e0ae1c810ef4ce2d89aaa0d5ec5654fb34a4aec6d38867783
Julia
4,364
159
module HHChannels export Stim, run_hh using Sundials using Unitful using Unitful.DefaultSymbols struct HHParam c_m # membrane spacific capacitance gnabar # Na channel cross-membrane conductivity gkbar # K channel cross-membrane conductivity gl # Leak conductivity ena # N...
516827916eebd093838d770f325352f587bcd593e184bdd2338e4cff4d914481
Julia
4,374
97
#––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––# # MACAQUE VS MARMOSET - DISTRIBUTED WORKING MEMORY # #––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––# #––––––––––––––––––––––––––––––––––––––––––––––––––––# # ...
0f2778f4978777dd37bc5b7116cf2799863950eb34b7247f9edb442b871f1037
Julia
4,385
92
""" get_translation_vectors(rs_ion, lattice, conf=get_empty_config(); Rmax=get_Rmax(lattice, conf), rcut=get_rcut(conf)) Generate a set of translation vectors based on ion positions `rs_ion`, the lattice vectors `lattice`, and optional configuration settings. The function returns the translation vectors that satis...
731cef16b9fb7db2e7621222044da7838e496c9dc17143439d8e08433f95a56b
Julia
4,385
92
""" get_translation_vectors(rs_ion, lattice, conf=get_empty_config(); Rmax=get_Rmax(lattice, conf), rcut=get_rcut(conf)) Generate a set of translation vectors based on ion positions `rs_ion`, the lattice vectors `lattice`, and optional configuration settings. The function returns the translation vectors that satis...
e97cc4d06c35e2e9aa6d29c5a2509572b13315578199fd0888cf0e7a449cce40
Julia
4,475
127
## using Pkg script_dir = @__DIR__ # Get the directory of the current script project_root = joinpath(script_dir, "..", "..", "..") # Get the path to the parent directory (the project root) Pkg.activate(project_root) # Activate the project #Pkg.instantiate() # download all the required packages using DelimitedFiles usi...
93883979075987aa6df1d65a76dbff38de0d3b30d5bf199412a312205846a5b3
Julia
4,489
131
### A Pluto.jl notebook ### # v0.19.41 using Markdown using InteractiveUtils # ╔═╡ 32deac33-32dd-454f-96fd-1276e03d1a68 import Pkg, Revise; Pkg.activate(Base.current_project()) # ╔═╡ eca1a5cb-7862-4afe-b5ba-efeb864da254 using Statistics: mean # ╔═╡ 54f44afc-9a47-4f55-a4fe-0e09769e86ac using Distributions: Normal #...
684c974ce756d44d82ad8b78ea18d1c38f07fda9c149927d3b72eb7d2e6ebc57
Julia
4,495
119
""" clear_hamster_output(; output_files=["hamster_out.h5", "hamster.out", "Es.dat", "vs.dat"]) Delete output files generated by Hamster. # Keyword Arguments - `output_files::Vector{String}`: List of filenames to remove. Defaults to `["hamster_out.h5", "hamster.out", "Es.dat", "vs.dat"]`. """ function clear_hams...
8c7c06cc92d47e612a67687c854540e66f0ed3ef7046e9c7bb9cdfa3b9406689
Julia
4,505
122
#= Freeze some parameters of the model =# struct HMM_ARTR_Log_Freeze <: HiddenMarkovModels.AbstractHMM transition_matrix::Matrix{LogFloat64} # T[y,z] = P(y -> z) h::Matrix{Float64} # h[:,z] = fields in hidden state 'z' pinit::Vector{LogFloat64} # initial state probabilities pseudocount::Float64 # pseudo...
83c45fb0f377c6ee88763a8d2c4647122a2e8e0b923332cdeba6e24c99904e45
Julia
4,524
102
const ê_z = Float64[0, 0, 1] """ get_sk_transform_matrix(r⃗₁, r⃗₂, axis, tmethod) Returns a transformation matrix that aligns the z-axis along the vector connecting `r⃗₁` and `r⃗₂`. The method of transformation depends on `tmethod`. # Arguments - `r⃗₁::AbstractVector`: The first position vector. - `r⃗₂::Abstra...
37fe11d8674ffe736879875274132f56d4294d7a48e3ae91abc2d846ebd08b90
Julia
4,585
124
mutable struct ZebrafishHMM_G4 <: HiddenMarkovModels.AbstractHMM #= If allow_flipe == false, states are stored in this order: 1. Forward-Left (forward bouts, but last turn was left) 2. Forward-Right (forward bouts, but last turn was right) 3. Left (left turning bouts) 4. Right (r...
0a0a4c10f15a9c6ca963c8fc278f7f0d96c8e9e792609a43620737e5071bc82e
Julia
4,615
95
""" run_calculation(::Val{:optimization}, comm, conf::Config; rank=0, nranks=1) Runs the optimization process for an effective Hamiltonian model using the specified configuration. # Arguments - `conf::Config`: A configuration instance. # Workflow 1. **Configuration Sampling**: - Splits the configuration indice...
06f884ff12a9de1924ebc41a29f8e506d6420ddeacd227eb03d42f78de101451
Julia
4,624
144
""" **verbosity**=1 The `verbosity` parameter controls the amount of output printed to the console or written to output files. A value of `0` disables most print statements. Possible options: - `0`: minimal output; most print statements are suppressed. - `1`: normal output volume (default). - `2`: increased output;...
664780d592a021294e761f978e5da7992aaffd6a7aefbcd4e0bf3a821190df28
Julia
4,644
167
module LVAChannels export Stim, run_lva, LVAParam using Sundials using Unitful using Unitful.DefaultSymbols struct LVAParam c_m # membrane spacific capacitance gbar # Ca channel cross-membrane conductivity eca # Ca channel reversal potential gl # leak conductivity el ...
f201b9bff556c86b5a71f83b90260ee3b58efc2b8699aaba3a7d3d3528e21265
Julia
4,686
132
mutable struct ZebrafishHMM_G3 <: HiddenMarkovModels.AbstractHMM #= States are stored in this order: 1. Forward (forward bouts) 2. Left (left turning bouts) 3. Right (right turning bouts) In contrast to ZebrafishHMM_G4, Forward bouts have no memory of the last turning direction. ...
f41be0f607c04962dcaeeaa71bcd6d4fa211da5e4b8d7de71a38b491af908394
Julia
4,747
98
function wolf_eyes_data() mat = matread(joinpath(wolf_eyes_data_dir(), "analysis.mat")) return mat["D"] end #= Neural recordings corresponding to the eye gaze data =# function wolf_eyes_artr_data_dir() return artifact"Wolf_Eyes_ARTR_Data_20240313" end function wolf_eyes_artr_data() left = matread(join...
6a2252f3e367d50311168633d686495f747c7eac91bb873c95aece5081b0aad4
Julia
4,791
127
""" Ion A mutable structure representing an ion in a crystal lattice. # Fields - `type::UInt8`: The type or species of the ion, denoted by its proton number. - `pos::StaticArray{3, Float64}`: A 3D static array representing the position of the ion in Cartesian coordinates. - `dist::StaticArray{3, Float64}`: A 3D s...
82c21bddf2201ac7511c30d48c08d2ec895d9a81992752ce948b368653fbd637
Julia
4,797
144
using Pkg script_dir = @__DIR__ # Get the directory of the current script project_root = joinpath(script_dir, "..", "..") # Get the path to the parent directory (the project root) Pkg.activate(project_root) # Activate the project Pkg.instantiate() # download all the required packages using FFTW using LinearAlgebra usi...
26174a0d1d08c41798210effc23ddfd7d860e64f3be3c52d96d0e2d2e0866324
Julia
4,824
127
mutable struct ZebrafishHMM_G3_Sym <: HiddenMarkovModels.AbstractHMM pinit_turn::Float64 const transition_matrix::Matrix{Float64} # T[i,j] = probability of transitions i -> j σforw::Float64 turn::Gamma{Float64} min_turn_alpha::Float64 function ZebrafishHMM_G3_Sym( pinit_turn::Real, ...
30f0355a5516a56ec7de1632245c712b7966d8e7a2fcbb7b329ff58947bab796
Julia
4,909
156
# Constants used in modelling # # SI units are used in computations but we need to pay attention to some conventions between text files and computation # Units used: s (second), m (meter), T (tesla), s/m^2, m^2/s, T/m # # In text files, e.g. bval, techo, tdelta and tsmalldel, units are s/mm^2 for b-values and ms for ti...
6331ef8da9e4170d868e8020f7faaf2fc0142e065ff2116f1b2c527ecbacaf0d
Julia
4,939
117
@testset "DataLoader PC Eigs" begin path = joinpath(@__DIR__, "test_files") conf = get_empty_config() kp, Es = Hamster.read_eigenval(joinpath(path, "EIGENVAL_gaas"), 8) set_value!(conf, "train_data", "Optimizer", joinpath(path, "EIGENVAL_gaas")) # Test 1: test PC training data with no validati...
966f2bd01204323c7f000f0831cd438585f23316402858d3a1b71d99f2c01211
Julia
4,946
90
#––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––# # MACAQUE VS MARMOSET - DISTRIBUTED WORKING MEMORY # #––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––# #––––––––––––––––––––––––––––––––––––––––––––––––––––# # ...
972eaddc19f824d6b0defccd180edee869284506abbf0c742b432f7f650d896b
Julia
4,946
114
@testset "Profiler validation prints" begin prof = HamsterProfiler(3) # Test 1: verbosity > 0 val_print = @capture_out Hamster.print_val_start(prof, 1, verbosity=1) @test val_print == " Validating model...\n" #Test 2: verbosity = 0 val_print = @capture_out Hamster.print_val_start(prof, 1,...
74e3d7763d19d12a380aa7da42c824387962c5b96ed3fe2199355d27354dc9cc
Julia
4,960
119
using Test: @test, @testset using ZebrafishHMM2023: ZebrafishHMM_G3, ZebrafishHMM_G4, ZebrafishHMM_TN03, ZebrafishHMM_TN04, ZebrafishHMM_TN3, ZebrafishHMM_TN4, ZebrafishHMM_G3_Sym, ZebrafishHMM_G4_Sym, save_hmm, load_hmm, HMM_ARTR_Log, normalize_transition_matrix using Distributions: Normal, Gamma using Statist...
68930e125f58b6e34218b805ecef2a42d10df1c9c6d96e15b7c36d66e5da1521
Julia
4,964
128
#= Like the Elife2020 model, but with Gamma turn emissions. =# mutable struct ZebrafishHMM_Elife2020_Gamma <: HiddenMarkovModels.AbstractHMM pinit_turn::Float64 pturn::Float64 pflip::Float64 σforw::Float64 turn::Gamma{Float64} function ZebrafishHMM_Elife2020_Gamma( ; pinit_turn::Real,...
2b54a205ffafbb6454c78496d9151a26e4694698845f34b449420ce008c5180b
Julia
4,976
135
# Here we try to enforce that the 3rd state has the same mean field in the left and right sides. # Thus resembling a "forward" state. struct HMM_ARTR_3_SYM <: HiddenMarkovModels.AbstractHMM transition_matrix::Matrix{Float64} # T[i,j] = P(i -> j) h::Matrix{Float64} # h[:,i] = fields in hidden state 'i' pinit...
a3e063328c3ab4f38eef62e5e9df35d0ad9498f21801052b1477add4a3d512de
Julia
5,050
131
struct HMM_ARTR_Log <: HiddenMarkovModels.AbstractHMM transition_matrix::Matrix{LogFloat64} # T[y,z] = P(y -> z) h::Matrix{Float64} # h[:,z] = fields in hidden state 'z' pinit::Vector{LogFloat64} # initial state probabilities pseudocount::Float64 # pseudocount for the inference of 'h' function HMM_...
5bae5f8cd18ded148ca0b57fef8d908cb12f1d8eae16db16270419fe1fd7c4b2
Julia
5,051
132
struct HMM_ARTR <: HiddenMarkovModels.AbstractHMM transition_matrix::Matrix{Float64} # T[i,j] = P(i -> j) h::Matrix{Float64} # h[:,i] = fields in hidden state 'i' pinit::Vector{Float64} # initial state probabilities pseudocount::Float64 # pseudocount for the inference of 'h' function HMM_ARTR(transi...
f9d735fef7812dd3b329f3373b99e2761588f924f970b7a04434009a33e9ccc9
Julia
5,082
134
mutable struct ZebrafishHMM_TN3 <: HiddenMarkovModels.AbstractHMM #= Truncated normal (TN) turning angle emissions, with fitted mean. States are stored in this order: 1. Forward (forward bouts) 2. Left (left turning bouts) 3. Right (right turning bouts) =# const initial_probs...
2d289191535b33c6a4cbce7645c949c0bd6c01e16ef4990dcccc8995be8799e1
Julia
5,097
193
### A Pluto.jl notebook ### # v0.20.6 using Markdown using InteractiveUtils # ╔═╡ cf46e4a6-0fb2-11f0-3416-d5d2b4b5f546 begin using Pkg Pkg.activate(Base.current_project()) Pkg.instantiate() # loading usefules using PlutoLinks using PlutoUI end # ╔═╡ e7f1ae5a-e0f1-4052-8b33-99e8ceab7ae9 begin # loading module...
3fe0e28c58c636209cdf49eaf7c2b84db26c8225272bfca5a99f8373db554486
Julia
5,201
151
@testset "Option defaults" begin # Test 1: test verbosity conf = get_empty_config() @test Hamster.get_verbosity(conf) == 1 set_value!(conf, "verbosity", 0) @test Hamster.get_verbosity(conf) == 0 set_value!(conf, "verbosity", "none") @test_throws MethodError Hamster.get_verbosity(conf) #...
733a18031b63b59c604397fbff93b5bd3765c46683bee16f3c92609fba8d5ac8
Julia
5,215
125
mutable struct ZebrafishHMM_TN04_Sym <: HiddenMarkovModels.AbstractHMM pinit_turn::Float64 const transition_matrix::Matrix{Float64} σforw::Float64 σturn::Float64 function ZebrafishHMM_TN04_Sym( pinit_turn::Real, transition_matrix::AbstractMatrix{<:Real}, σforw::Real, σturn::...
f2d79463b14f71c6f17c07cbd1942efc5ad915ac6c8029ba40f7e37b61b3f436
Julia
5,241
130
#= This model should be the Hidden Markov model equivalent of the Markov chain model of Karpenko et al Elife 2020 The hidden states represent two independent Markov chains, one for Forward/Turn states, and one for Left/Right states. Left/right orientations are symmetric. Turning angle emissions are truncated normal wi...
b120fc5c0a0b8085a456dc01d702f40e17a44914a73f05c793dbc284948088b3
Julia
5,298
144
## using Pkg script_dir = @__DIR__ # Get the directory of the current script project_root = joinpath(script_dir, "..", "..") # Get the path to the parent directory (the project root) Pkg.activate(project_root) # Activate the project #Pkg.instantiate() # download all the required packages using DelimitedFiles using Sta...
8b55ad9f6a25e174c858398392000162d94f9d484a8294cc027b9488f3ee8d13
Julia
5,371
136
mutable struct ZebrafishHMM_TN4 <: HiddenMarkovModels.AbstractHMM #= Truncated normal (TN) turning angle emissions. States are stored in this order: 1. Forward-Left (forward bouts, but last turn was left) 2. Forward-Right (forward bouts, but last turn was right) 3. Left (left turning bou...
369a279bf68657f3e445fa2e420de6c8309b03d45308dec64607dceb81f5c8dc
Julia
5,374
137
""" AdaptiveInterpolator(xmin::Float64, xmax::Float64, Ninit::Int64, Nmax::Int64, tol::Float64) A struct that defines the settings for adaptive interpolation. # Fields - `xmin::Float64`: The minimum value of `x` in the interpolation range. - `xmax::Float64`: The maximum value of `x` in the interpolation range. - ...
3289def14a140acce787de163f1cb2be62a7d3b2e66abca77d20af937ddd454c
Julia
5,381
143
""" OrbitalConfiguration Abstract type for defining the configuration of orbitals w.r.t. to the overlap label for a specific TB overlap. Subtypes: - `SymOrb`: Symmetry in orbitals allows for interchangeable orbital types in labels. - `DefOrb`: No symmetry; the order of orbital types in labels must be preserved ex...
7efce820dd96f17151031d96e42b69eb62adbc8a0ee8a4b7512e5c7cc25327b8
Julia
5,505
107
import CairoMakie import Makie import MAT using HiddenMarkovModels: logdensityof, baum_welch, transition_matrix, initial_distribution, viterbi using Statistics: mean using Test: @test, @testset using ZebrafishHMM2023: artr_wolf_2023_distances using ZebrafishHMM2023: artr_wolf_2023_distances_file using ZebrafishHMM2023:...
aa3d069ee1a08cc429ac218a95591a9b760b4503c9d86a148550ad484dca8b21
Julia
5,547
178
# test if frac_to_cart is inverse of cart_to_frac function test_inverse(ε) Ê = rand(Float64, (3, 3)) r⃗ = rand(Float64, 3) t1 = norm(r⃗ .- Hamster.frac_to_cart(Hamster.cart_to_frac(r⃗, Ê), Ê)) < ε t2 = norm(r⃗ .- Hamster.cart_to_frac(Hamster.frac_to_cart(r⃗, Ê), Ê)) < ε return t1 && t2 end # t...
ac8e87db714e5920f64065395e85edbd58fc607dbf738194617f1e629b6fbe51
Julia
5,548
178
# test if frac_to_cart is inverse of cart_to_frac function test_inverse(ε) Ê = rand(Float64, (3, 3)) r⃗ = rand(Float64, 3) t1 = norm(r⃗ .- Hamster.frac_to_cart(Hamster.cart_to_frac(r⃗, Ê), Ê)) < ε t2 = norm(r⃗ .- Hamster.cart_to_frac(Hamster.frac_to_cart(r⃗, Ê), Ê)) < ε return t1 && t2 end # t...
9f88f1464222b548db2ecb525087118bd77898b4fe8cede8f46bf4b0949c426d
Julia
5,615
201
### A Pluto.jl notebook ### # v0.20.6 using Markdown using InteractiveUtils # This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). macro bind(def, element) #! format: off ...
5cc026a4dae3889c29cb294cb160ddbeac9bfdd2917b7e2f49f65b0e14b85e0e
Julia
5,625
201
### A Pluto.jl notebook ### # v0.20.6 using Markdown using InteractiveUtils # ╔═╡ ae499992-896f-11f0-2889-d3a6f356213c begin using Pkg Pkg.activate(Base.current_project()) Pkg.instantiate() # loading usefules using PlutoLinks using PlutoUI end # ╔═╡ b2c5986b-9944-4430-a1be-c32ec9aedce8 LOAD = @ingredients(joi...
450c2e2be246b8dc43f7b977e47a2d1b24dc57b786b9f4921d4554c8f7914ca5
Julia
5,628
164
@testset "Normal loss" begin # Test 1: MSE y = rand(2, 4) ŷ = rand(2, 4) mse(y, ŷ) = mean(@. (y - ŷ)^2) mae(y, ŷ) = mean(@. abs(y - ŷ)) loss_1 = Loss(2) @test loss_1(y, ŷ) ≈ mse(y, ŷ) @test Hamster.backward(loss_1, y, ŷ) ≈ FiniteDiff.finite_difference_gradient(y->loss_1(y, ŷ),...
0a5a7e24ab21b99a157246372f51fa677a3d0c0bf369d7766d0234c17ed3a424
Julia
5,634
220
### A Pluto.jl notebook ### # v0.20.6 using Markdown using InteractiveUtils # This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). macro bind(def, element) #! format: off ...
5f68643ed517a9fe0d989893b906e9216fe3d02e7bff6c72af3ef3e65ea990d1
Julia
5,672
160
using Glob using HDF5 using ProgressMeter using DataFrames using MixedModels, StatsModels, Statistics using StatsPlots using RCall, JellyMe4 #Get R packages to interpret the LME R"library(lme4)" R"library(emmeans)" R"library(pbkrtest)" R"library(MuMIn)" # MAIN PATH ZENODOPATH = "Your/Path/To/Zenodo/Data" # FIGURE PA...
a7a7610267e87e240535cd8760f1da6de6da9065e70705bd2743a7a2fdd2ab89
Julia
5,674
123
""" run_calculation(::Val{:optimization}, comm, conf::Config; rank=0, nranks=1) Performs the optimization using gradient descent of an effective Hamiltonian model using the specified configuration. The routine iteratively adjusts model parameters to minimize the loss over a training set, while optionally validat...
f34ab2af62a6348a14a38a5063ebd9dec4d2bfbca7a08f1f7a4043ee9b87d76b
Julia
5,763
224
### A Pluto.jl notebook ### # v0.20.6 using Markdown using InteractiveUtils # ╔═╡ 8696354c-300d-11f0-2524-8dc8a1538c50 begin using Pkg Pkg.activate(Base.current_project()) Pkg.instantiate() # loading usefules using PlutoLinks using PlutoUI end # ╔═╡ 44d4f416-abec-4694-93bd-9621a65759ba begin # loading module...
01f20406536028bc1e503094b94ec0df482ecc1cae359750099cafbc9be74f51
Julia
5,817
226
### A Pluto.jl notebook ### # v0.20.6 using Markdown using InteractiveUtils # This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). macro bind(def, element) #! format: off ...
361067a7942d7219b8b4424bce9a51276598eca0dcaae02031824d48e21ad3dc
Julia
5,823
144
@testset "Band index selection" begin @test Hamster.get_band_indices(17, 5, Int[], 1) == [17, 18, 19, 20, 21] @test Hamster.get_band_indices(17, 5, Int[], 4) == [17, 18, 19, 20, 21] @test Hamster.get_band_indices(17, 5, [13], 1) == [13, 17, 18, 19, 20] @test H...
f803bef4ed64c400aa2122d09afc89f842d0c3864979a2bd9cfee26293448cad
Julia
5,823
117
gaas_poscar = string(@__DIR__) * "/../parse/test_files/POSCAR_gaas" cspbbr_poscar = string(@__DIR__) * "/../strc/test_files/POSCAR_CsPbBr3" @testset "Parameter label" begin param_label1 = Hamster.ParameterLabel(1, Hamster.IonLabel("Ga", "As"), SVector{3}([0, 0, 0])) @test param_label1 == Hamster.string_to_para...
47cec71402269ec8ab3dbc7af2d857c4851b541156507cfa43f8555942745e2b
Julia
5,907
133
@testset "greedy farthest-point sampling" begin ds = rand(3, 100) cluster_indices = 1:5:100 num_to_take = 5 selected = Hamster.farthest_point_sampling(ds, cluster_indices, num_to_take) @test length(unique(selected)) == num_to_take @test all([i ∈ cluster_indices for i in selected]) end @testset...
678ea9a3563f1e989a90fcde62ba647bb21242cb9da5dbe311ab9fcb397e41e1
Julia
5,937
134
# Unit tests split_line = Hamster.split_line @testset "split_line" begin # Basic tests @test split_line("This is a test") == ["This", "is", "a", "test"] @test split_line("Hello World") == ["Hello", "World"] # Tests with multiple spaces @test split_line("This is a test") == ["This", "is", "a...
2233e2f1858836b8c983b8be1b03dc9c157fd71ad3e35d8343af3981b9bb3228
Julia
6,084
149
## using Pkg script_dir = @__DIR__ # Get the directory of the current script project_root = joinpath(script_dir, "..", "..") # Get the path to the parent directory (the project root) Pkg.activate(project_root) # Activate the project #Pkg.instantiate() # download all the required packages using LinearRNNforFMRIdigitalt...
32887806b7907041f469519dc02c2bb34a6c74714f1dd772b3ab05252f00eaa9
Julia
6,130
154
mutable struct ZebrafishHMM_G4_Sym <: HiddenMarkovModels.AbstractHMM #= Imposes Left/Right symmetry =# pinit_turn::Float64 const transition_matrix::Matrix{Float64} # T[i,j] = probability of transitions i -> j σforw::Float64 turn::Gamma{Float64} min_turn_alpha::Float64 function Zebra...
e17b2d85f411231d4167b5d914386b59191e20f2903e3b536c704c9655f968d4
Julia
6,138
122
""" get_eigenvalue_gradient(vs, Rs, ks, sp_mode, sp_iterator; nthreads_bands, nthreads_kpoints) Compute the gradient `dE_dHr` of each energy eigenvalue at each k-point w.r.t. the real-space Hamiltonian matrix elements. # Arguments -`vs`: Matrix that contains the (sparse) eigenvectors of each eigenvalue `(m, k)`. ...
4f7cc25e13448dfed9b1a45177107f1ddadf141dbabeb80f03b802e375664344
Julia
6,215
183
""" print_hamster(io_stream=stdout) Prints an ASCII art Hamster logo and description. # Arguments - `io_stream::IO`: The output stream to which the text should be printed. Defaults to `stdout`. """ function print_hamster(io_stream=stdout) println(io_stream, """ Welcome to ============================...
8565d3cfc2f5fe1b1019bbaca0e55a652455df44b30a70a2c5c4500da2062177
Julia
6,265
135
""" hyper_optimize(param_values, params, comm, conf; rank=0, nranks=1, verbosity=get_verbosity(conf)) -> Float64 Evaluate a given set of hyperparameters by updating a configuration and running an optimization calculation. # Arguments - `param_values::Vector{Float64}`: Numerical values for each parameter to be opt...
78b831fcd56bfd2064af046e0b02229a8db3c4205783da3b937ed1ce56710056
Julia
6,275
178
import CairoMakie import Dates import Makie import MAT import ZebrafishHMM2023 using HiddenMarkovModels: baum_welch using HiddenMarkovModels: viterbi using HiddenMarkovModels: logdensityof using Statistics: mean using Distributions: Normal using ZebrafishHMM2023: ATol using ZebrafishHMM2023: normalize_transition_matrix...
401183a5247d46c7044fab3fbdd855f0f7de6e6861f53e49219b86a3e13e2382
Julia
6,324
163
const COMMENT_SYMBOLS = ['!', '#', '%'] """ get_config(; filename="hconf") Retrieves the configuration from a file if it exists, or returns an empty configuration if the file does not exist. # Arguments - `filename` (optional): The name of the configuration file to check for existence. Defaults to `"hconf"`. # ...
c96bacd164062e0dbeb8efe2c843239a4015ca062118c1552a0cf51c9376c97e
Julia
6,364
198
module KernelInterpolation using NearestNeighbors using Distances using LinearAlgebra # dot, mul! using Statistics # cor using Random export gaussian_kernel_interpolate, filtered_correlation # --------------------------------------------------------------------- # Internal helpers # ------------------...
e6b92ba9845da1c932411ceb938f2304be96497cf9f8a721908ac258bf6cf6eb
Julia
6,370
171
### A Pluto.jl notebook ### # v0.20.13 using Markdown using InteractiveUtils # ╔═╡ 7f95a967-426a-465f-bad4-671372ea1092 import Pkg, Revise; Pkg.activate(Base.current_project()) # ╔═╡ 7d355591-dddd-4463-97b1-d53e223bd6b3 using Statistics: mean # ╔═╡ 8398c332-235b-4f6c-ab1e-8b5fd62d2d5a using Distributions: Gamma # ...
848c700e87c8a6998df8f915f05d5bcbad9204ff9809908330ce3ce0bc349e3d
Julia
6,407
127
""" Orbital{O<:Angular}(ion_type::Int64, type::O, axis::SVector{3, Float64}) Defines an orbital associated with an ion, characterized by its type, angular momentum properties, and orientation. # Type Parameters - `O<:Angular`: Specifies the angular momentum type, such as s, p, or d orbitals. # Fields - `ion_type...
355b0a2bbec82541e07fcde4b9d525ca8fdd4099cc0083d101e487ec198817da
Julia
6,507
183
### A Pluto.jl notebook ### # v0.19.42 using Markdown using InteractiveUtils # ╔═╡ 34fc02ca-be22-4200-8dc4-6a0c9d7806bb import Pkg, Revise; Pkg.activate(Base.current_project()) # ╔═╡ ec9792cc-1651-46f2-9eb4-216321dde7a7 using Statistics: mean # ╔═╡ 4f5f45fe-d114-44ca-acad-455afba4c3e3 using Distributions: Normal #...
f4653ceaa6df7863b3a5fc86f3655d3b2bcc78bfac92f8ed89e41609352ba6c8
Julia
6,521
183
### A Pluto.jl notebook ### # v0.19.42 using Markdown using InteractiveUtils # ╔═╡ b5731209-833e-400a-bd91-0ca87807f3df import Pkg, Revise; Pkg.activate(Base.current_project()) # ╔═╡ 5c003b8f-2e2b-498f-af41-033c6b7c691c using Statistics: mean # ╔═╡ cf43f299-64fe-4aeb-9a3c-4f963fa72525 using Distributions: Normal #...
d851aa8d05f9689fa77be875fb8c01e7d80296ae0d282bb0d73b94be506c47c3
Julia
6,524
188
## using Pkg script_dir = @__DIR__ # Get the directory of the current script project_root = joinpath(script_dir, "..", "..") # Get the path to the parent directory (the project root) Pkg.activate(project_root) # Activate the project Pkg.instantiate() # download all the required packages using LinearRNNforFMRIdigitaltw...
028e2b01b9af893d08fbaa8efb385bbbb561a5d54e2c1e097eb86131320f9464
Julia
6,557
193
file_path = string(@__DIR__) * "/test_files/" @testset "Phase factor" begin # Test arrays R⃗ = rand(3) k⃗ = rand(3) result = Hamster.exp_2πi(R⃗, k⃗) expected = exp(2π * im * dot(k⃗, R⃗)) @test isapprox(result, expected, rtol=1e-10) @test result isa ComplexF64 # Test matrices Rs = r...
21d1e91a613a773eeb31979e42dd0b446791d4f77d18266310319a828a0dbed0
Julia
6,618
188
""" EigData A struct for storing eigenvalue data associated with k-points. # Fields - `kp::Matrix{Float64}`: A matrix where each column represents a k-point. - `Es::Matrix{Float64}`: A matrix where each column represents the eigenvalues corresponding to the respective k-point. """ struct EigData kp :: Matrix...
6e8a458ba3a7c4e9e53413a74c9f23bfefb91f52f240ef310e18e8eec66234be
Julia
6,722
171
### A Pluto.jl notebook ### # v0.19.42 using Markdown using InteractiveUtils # ╔═╡ 167996be-274e-44b7-8cb0-2dc6bebaa57c import Pkg, Revise; Pkg.activate(Base.current_project()) # ╔═╡ a36894e5-b139-4d75-8856-f868be1b329a using Statistics: mean # ╔═╡ 8e80e780-817d-4486-b74d-f00b7dec33be using Statistics: cov # ╔═╡ 8...
674c0b82235b3e6428642abd4dd90f91fbad3ba7007cf078f9a5a1376451ed59
Julia
6,755
209
## using Pkg script_dir = @__DIR__ # Get the directory of the current script project_root = joinpath(script_dir, "..", "..") # Get the path to the parent directory (the project root) Pkg.activate(project_root) # Activate the project Pkg.instantiate() # download all the required packages using LinearRNNforFMRIdigitaltw...
4142794bdaaa061eda824d0053581ca9cf6d599732f445efeeb19719c023b8cb
Julia
6,760
181
using Pkg script_dir = @__DIR__ # Get the directory of the current script project_root = joinpath(script_dir, "..", "..", "..") # Get the path to the parent directory (the project root) Pkg.activate(project_root) # Activate the project #Pkg.instantiate() # download all the required packages ## using MultivariateStats,...
d4bd725110dc2c3e38625c52ff9c18256b1a36ee39684b9db305a4e704b864fe
Julia
6,773
261
### A Pluto.jl notebook ### # v0.20.6 using Markdown using InteractiveUtils # This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). macro bind(def, element) #! format: off ...
81af80bd9c7957e4c1ef74f32bf4872b924accc64da814f9557d884c8df2d8ec
Julia
6,842
175
""" transform_basis(r⃗::AbstractVector, Ê::AbstractMatrix) -> AbstractVector Transforms a vector to a new basis using a given transformation matrix. This function takes a vector `r⃗` and transforms it into a new basis by applying the transformation matrix `Ê`. The transformation is performed by multiplying the ...
c9280de966ee35a2d38843d671f9d1cfb1550c382607df10cd51ccd2578a946d
Julia
6,918
203
using MCMCDiagnosticTools, Statistics using DataFrames, Gadfly export Sampler, run_diagnostics, plot_diagnostics """ Change the number of samples in a sampler """ function Sampler(sampler::Sampler, nsamples::Int64) return Sampler(; params=sampler.params, prior_range=sampler.prior_range, ...
795f4fcc2713ec3170997373fd44da5d5c89e33c1bd0e94ede08997b38b03f59
Julia
6,994
200
""" num_mdict::Dict{String, Array{Int}} A dictionary mapping the orbital type to an array of `m` quantum numbers. The keys are orbital types as strings ("s", "p", "d") and the values are arrays containing the possible `m` values for each orbital type. """ #TODO: Check whether this is already implemented elsewhere ...
a0882429ce87899ba732714574411b5e1273f11736c015a0477ce5e5f52ba652
Julia
7,145
189
""" transform_basis(r⃗::AbstractVector, Ê::AbstractMatrix) -> AbstractVector Transforms a vector to a new basis using a given transformation matrix. This function takes a vector `r⃗` and transforms it into a new basis by applying the transformation matrix `Ê`. The transformation is performed by multiplying the ...
1f21a33d811f49c787a1fbab17291ed168744caadaeaf104b38f2376c5d28422
Julia
7,158
156
@testset "greedy farthest-point sampling" begin ds = rand(3, 100) cluster_indices = 1:5:100 num_to_take = 5 selected = Hamster.farthest_point_sampling(ds, cluster_indices, num_to_take) @test length(unique(selected)) == num_to_take @test all([i ∈ cluster_indices for i in selected]) end @testset...
8ff0d630b9c0485d30fd87ee7310fb2986630731266428380056b59829d894af
Julia
7,252
164
""" update_tb=haskey(conf, "Optimizer") The `update_tb` tag determines whether/which parameters of the TB model are updated during the optimization. Defaults to `true` if an `Optimizer` block is provided. """ function get_update_tb(conf::Config, NV)::Vector{Bool} update_tb = Vector{Bool}(undef, NV) if conf...
dfa1851fe48cd11487e35c253d3dbbc529c01dbfd27e30a761cd88f090330625
Julia
7,318
198
""" clear_hamster_output(; output_files=["hamster_out.h5", "hamster.out", "Es.dat", "vs.dat"]) Delete output files generated by Hamster. # Keyword Arguments - `output_files::Vector{String}`: List of filenames to remove. Defaults to `["hamster_out.h5", "hamster.out", "Es.dat", "vs.dat"]`. """ function clear_hams...
4a26904f40ec824ee38ad0c8601422abd75ce8272c55deb71fc95b33a486bb79
Julia
7,452
219
""" update_tb=haskey(conf, "Optimizer") The `update_tb` tag determines whether/which parameters of the TB model are updated during the optimization. Defaults to `true` if an `Optimizer` block is provided. """ function get_update_tb(conf::Config, NV)::Vector{Bool} update_tb = Vector{Bool}(undef, NV) if conf...
25e4d1670928d9b3af4131941c3493338deabf64bb864a26e920aa56fe7a22c9
Julia
7,556
213
@testset "Option defaults" begin # Test 1: test verbosity conf = get_empty_config() @test Hamster.get_verbosity(conf) == 1 set_value!(conf, "verbosity", 0) @test Hamster.get_verbosity(conf) == 0 set_value!(conf, "verbosity", "none") @test_throws MethodError Hamster.get_verbosity(conf) #...
7f8d52a1a3376bf38ed38f3a4c76a2070a92477839d63b645963ebb0235ab1d0
Julia
7,589
288
### A Pluto.jl notebook ### # v0.20.6 using Markdown using InteractiveUtils # This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). macro bind(def, element) #! format: off ...