Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI improvements #63

Merged
merged 9 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
style = "yas"
8 changes: 4 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@ concurrency:
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
name: Julia ${{ matrix.version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1'
- 'min'
os:
- ubuntu-latest
arch:
- x64
# - macos-latest # segfaults at the end of testing due to Python things
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v2
with:
cache-registries: "true"
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- name: Percy Upload
if: ${{ matrix.version }} == '1' && ${{ matrix.os }} == 'ubuntu-latest'
run: 'npx @percy/cli upload ./test/test_images'
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/formatcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
name: Style Guide
on:
push:
branches:
- master
- main
- /^release-.*$/
tags: ["*"]
paths:
- "**/*.jl"
- ".github/workflows/FormatCheck.yml"
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- "**/*.jl"
- ".github/workflows/FormatCheck.yml"
jobs:
format-check:
name: Julia
# These permissions are needed to:
# - Delete old caches: https://github.com/julia-actions/cache#usage
# - Post formatting suggestions: https://github.com/reviewdog/action-suggester#required-permissions
permissions:
actions: write
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: "1"
- uses: julia-actions/cache@v2
- name: Install JuliaFormatter
shell: julia --project=@format --color=yes {0}
run: |
using Pkg
Pkg.add(PackageSpec(; name="JuliaFormatter", version="1"))
- name: Check formatting
shell: julia --project=@format --color=yes {0}
run: |
using JuliaFormatter
format(".", YASStyle(); verbose=true) || exit(1)
# Add formatting suggestions to non-draft PRs even if when "Check formatting" fails
- uses: reviewdog/action-suggester@185c9c06d0a28fbe43b50aca4b32777b649e7cbd # v1.12.0
if: ${{ !cancelled() && github.event_name == 'pull_request' && github.event.pull_request.draft == false }}
with:
tool_name: JuliaFormatter
21 changes: 21 additions & 0 deletions .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# adapted from https://github.com/JuliaDocs/Documenter.jl/blob/master/.github/workflows/SpellCheck.yml
# see docs at https://github.com/crate-ci/typos
name: Spell Check
on: [pull_request]

jobs:
typos-check:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
- name: Check spelling
uses: crate-ci/typos@b74202f74b4346efdbce7801d187ec57b266bac8 # v1.27.3
with:
config: _typos.toml
write_changes: true
- uses: reviewdog/action-suggester@v1
with:
tool_name: Typos
fail_on_error: true
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ PrecompileTools = "1"
ScatteredInterpolation = "0.3.6"
Statistics = "1"
Test = "1"
julia = "1.6"
julia = "1.10"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

# See test/Project.toml!!
[targets]
test = ["Test"]
3 changes: 3 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[default.extend-words]
# don't current this name
Shepard = "Shepard"
11 changes: 6 additions & 5 deletions assets/write_template-positions-bin.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using PyMNE, PythonCall, TopoPlots
channels = ["fp1", "f3", "c3", "p3", "o1", "f7", "t3", "t5", "fz", "cz", "pz", "fp2", "f4", "c4", "p4", "o2", "f8", "t4", "t6"]
channels = ["fp1", "f3", "c3", "p3", "o1", "f7", "t3", "t5", "fz", "cz", "pz", "fp2", "f4",
"c4", "p4", "o2", "f8", "t4", "t6"]
info = pycall(PyMNE.mne.create_info, PyObject, channels, 120.0; ch_types="eeg")
info.set_montage("standard_1020"; match_case=false)
palday marked this conversation as resolved.
Show resolved Hide resolved
layout = PyMNE.mne.find_layout(info)
write(TopoPlots.assetpath("layout_10_20.bin"), hcat(layout.pos[:, 1], layout.pos[:, 2]))
write(TopoPlots.assetpath("layout_10_20.bin"), hcat(layout.pos[:, 1], layout.pos[:, 2]))

#---

using CSV,DataFrames
using CSV, DataFrames

loc2d = CSV.read(TopoPlots.assetpath("1005.tsv"),DataFrame) # taken from https://github.com/sappelhoff/eeg_positions/blob/main/data/Fpz-T8-Oz-T7/standard_1005_2D.tsv
write(TopoPlots.assetpath("layout_10_05.bin"),hcat(loc2d.x,loc2d.y))
loc2d = CSV.read(TopoPlots.assetpath("1005.tsv"), DataFrame) # taken from https://github.com/sappelhoff/eeg_positions/blob/main/data/Fpz-T8-Oz-T7/standard_1005_2D.tsv
write(TopoPlots.assetpath("layout_10_05.bin"), hcat(loc2d.x, loc2d.y))
35 changes: 15 additions & 20 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,20 @@ using TopoPlots: CHANNEL_TO_POSITION_10_05, CHANNEL_TO_POSITION_10_20
DocMeta.setdocmeta!(TopoPlots, :DocTestSetup, :(using TopoPlots); recursive=true)
palday marked this conversation as resolved.
Show resolved Hide resolved

makedocs(;
modules=[TopoPlots],
authors="Benedikt Ehinger, Simon Danisch, Beacon Biosignals",
sitename="TopoPlots.jl",
checkdocs=:exports,
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://MakieOrg.github.io/TopoPlots.jl",
assets=String[],
),
pages=[
"Home" => "index.md",
"General TopoPlots" => "general.md",
"EEG" => "eeg.md",
"Function reference" => "functions.md",
"Interpolator reference images" => "interpolator_reference.md"
],
)
modules=[TopoPlots],
authors="Benedikt Ehinger, Simon Danisch, Beacon Biosignals",
sitename="TopoPlots.jl",
checkdocs=:exports,
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://MakieOrg.github.io/TopoPlots.jl",
assets=String[],),
pages=["Home" => "index.md",
"General TopoPlots" => "general.md",
"EEG" => "eeg.md",
"Function reference" => "functions.md",
"Interpolator reference images" => "interpolator_reference.md"],)
palday marked this conversation as resolved.
Show resolved Hide resolved

deploydocs(;
repo="github.com/MakieOrg/TopoPlots.jl",
devbranch="master", push_preview=true
)
repo="github.com/MakieOrg/TopoPlots.jl",
devbranch="master", push_preview=true)
palday marked this conversation as resolved.
Show resolved Hide resolved
131 changes: 66 additions & 65 deletions docs/src/topo_series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,35 @@ using InteractiveUtils

# ╔═╡ 2fafb0da-f3a9-11ec-0ddf-6725344070fe
begin
using Pkg
Pkg.activate("../../devEnv") # docs
#Pkg.add("PyMNE")
#Pkg.add(path="../../../TopoPlotsjl/")
Pkg.develop(path="../../../TopoPlotsjl/")
#Pkg.add("DataFrames")
#Pkg.add("AlgebraOfGraphics")
#Pkg.add("StatsBase")
#Pkg.add("CategoricalArrays")

#Pkg.add("JLD2")
#Pkg.add("CairoMakie")
using Pkg
Pkg.activate("../../devEnv") # docs
#Pkg.add("PyMNE")
#Pkg.add(path="../../../TopoPlotsjl/")
Pkg.develop(; path="../../../TopoPlotsjl/")
palday marked this conversation as resolved.
Show resolved Hide resolved
#Pkg.add("DataFrames")
#Pkg.add("AlgebraOfGraphics")
#Pkg.add("StatsBase")
#Pkg.add("CategoricalArrays")

#Pkg.add("JLD2")

#Pkg.add("CairoMakie")
end

# ╔═╡ c4a25915-c7f5-453a-a4f0-4b40ebedea4c
using Revise

# ╔═╡ 59b87673-02d2-4deb-90be-74d923d170eb
using TopoPlots

using TopoPlots

# ╔═╡ 452a245c-773a-4303-a970-f2592c3e879f
begin
#using TopoPlots
#using ../../../Topoplotsjl
using CairoMakie
using DataFrames


#using TopoPlots
#using ../../../Topoplotsjl
using CairoMakie
using DataFrames
end


# ╔═╡ 77dc1ba9-9484-485b-a49d-9aa231ef4983
using Statistics

Expand All @@ -56,54 +52,59 @@ revise(TopoPlots)

# ╔═╡ f4b81740-d907-42ae-a0df-f46fb2f2cb15
begin
data = Array{Float32}(undef, 64, 400, 3)
#read!(TopoPlots.assetpath("example-data.bin"), data)
read!(splitdir(pathof(TopoPlots))[1] * "/../assets/example-data.bin", data)

data = Array{Float32}(undef, 64, 400, 3)
#read!(TopoPlots.assetpath("example-data.bin"), data)
read!(splitdir(pathof(TopoPlots))[1]*"/../assets/example-data.bin",data)

positions = Vector{Point2f}(undef, 64)
read!(splitdir(pathof(TopoPlots))[1]*"/../assets/layout64.bin",positions)
#read!(TopoPlots.assetpath("layout64.bin"), positions)

end;
positions = Vector{Point2f}(undef, 64)
read!(splitdir(pathof(TopoPlots))[1] * "/../assets/layout64.bin", positions)
#read!(TopoPlots.assetpath("layout64.bin"), positions)

end;

# ╔═╡ 42f7755b-80f4-4185-8d21-42e11730e0fc
begin
using Random
pos = positions[1:10]
eeg_topoplot(rand(MersenneTwister(1),length(pos)), string.(1:length(pos));positions=pos,pad_value=0.)
using Random
pos = positions[1:10]
eeg_topoplot(rand(MersenneTwister(1), length(pos)), string.(1:length(pos));
positions=pos, pad_value=0.0)
palday marked this conversation as resolved.
Show resolved Hide resolved
end

# ╔═╡ aad784ee-6bb7-4f3c-8444-be050456ddea
eeg_topoplot(data[:, 340, 1], string.(1:length(positions));positions=positions)
eeg_topoplot(data[:, 340, 1], string.(1:length(positions)); positions=positions)
palday marked this conversation as resolved.
Show resolved Hide resolved

# ╔═╡ 237e4f4a-cdf2-4bac-8096-de8050251745
eeg_topoplot(data[:, 340, 1], string.(1:length(positions));positions=positions,pad_value=0.1)
eeg_topoplot(data[:, 340, 1], string.(1:length(positions)); positions=positions,
pad_value=0.1)
palday marked this conversation as resolved.
Show resolved Hide resolved

# ╔═╡ f522329b-3653-4059-9955-8cd05570e923
topoplot(rand(MersenneTwister(1),length(pos)),pos)
topoplot(rand(MersenneTwister(1), length(pos)), pos)

# ╔═╡ a9d2a2e2-6c8c-4cfc-9fed-b5e082cb44af
let
mon = PyMNE.channels.make_standard_montage("standard_1020")

posMat = (Matrix(hcat(pos...)).-0.5).*0.5
#pos = PyMNE.channels.make_eeg_layout(mon).pos
PyMNE.viz.plot_topomap(rand(MersenneTwister(1),length(pos)),posMat',cmap="RdBu_r",extrapolate="box",border=-1)
mon = PyMNE.channels.make_standard_montage("standard_1020")

posMat = (Matrix(hcat(pos...)) .- 0.5) .* 0.5
#pos = PyMNE.channels.make_eeg_layout(mon).pos
PyMNE.viz.plot_topomap(rand(MersenneTwister(1), length(pos)), posMat'; cmap="RdBu_r",
extrapolate="box", border=-1)
palday marked this conversation as resolved.
Show resolved Hide resolved
end

# ╔═╡ c358633f-8d18-4c5e-80f7-ab972e8860be
Pkg.status("TopoPlots")

# ╔═╡ c0a2ad2e-ccce-4e80-b52c-75f1428ed182
e1eg_topoplot(data[:, 340, 1], string.(1:length(positions));positions=positions,interpolation = TopoPlots.NormalMixtureInterpolator() )
e1eg_topoplot(data[:, 340, 1], string.(1:length(positions)); positions=positions,
interpolation=TopoPlots.NormalMixtureInterpolator())
palday marked this conversation as resolved.
Show resolved Hide resolved

# ╔═╡ d7620a42-d54c-4244-a820-d15aecdae626
@time TopoPlots.eeg_topoplot_series(data[:,:,1],40;topoplotCfg=(positions=positions,label_scatter=false))
@time TopoPlots.eeg_topoplot_series(data[:, :, 1], 40;
topoplotCfg=(positions=positions, label_scatter=false))
palday marked this conversation as resolved.
Show resolved Hide resolved

# ╔═╡ ec59c704-ae33-4a62-82ce-63acc6b17793
f, ax, pl = TopoPlots.eeg_topoplot(1:length(TopoPlots.CHANNELS_10_20),TopoPlots.CHANNELS_10_20; interpolation=TopoPlots.NullInterpolator(),)
f, ax, pl = TopoPlots.eeg_topoplot(1:length(TopoPlots.CHANNELS_10_20),
TopoPlots.CHANNELS_10_20;
interpolation=TopoPlots.NullInterpolator(),)
palday marked this conversation as resolved.
Show resolved Hide resolved

# ╔═╡ f3d1f3cc-f7c9-4ef4-ba4f-3d32f2509cad
let
Expand All @@ -124,36 +125,36 @@ let
minx, miny = minimum(rect)
maxx, maxy = maximum(rect)
# recreate the coordinates of the data
x = range(minx, maxx, length=size(m, 1))
y = range(miny, maxy, length=size(m, 2))
x = range(minx, maxx; length=size(m, 1))
y = range(miny, maxy; length=size(m, 2))
palday marked this conversation as resolved.
Show resolved Hide resolved
xys = Point2f.(x, y')

# find the highest point
_, i = findmax(x -> isnan(x) ? -Inf : x, m)
xy = xys[i]
@show peak_xy
@show xy
@show peak_xy
@show xy
#@test isapprox(xy, peak_xy; atol=0.02)
@show isapprox(xy, peak_xy; atol=0.02)
fig
@show isapprox(xy, peak_xy; atol=0.02)
palday marked this conversation as resolved.
Show resolved Hide resolved
fig
end

# ╔═╡ 872ac6a4-ddaa-4dfb-a40d-9d5ea55bdb3d
let
f = Figure()
axis = Axis(f[1, 1], aspect = 1)
xlims!(low = -2, high = 2)
ylims!(low = -2, high = 2)
data = [0, 0, 0]
pos1 = [Point2f(-1, -1), Point2f(-1.0, 0.0), Point2f(0, -1)]
pos2 = [Point2f(1, 1), Point2f(1.0, 0.0), Point2f(0, 1)]

pos1 = pos1 .- mean(pos1)
pos2 = pos2 .- mean(pos2)
eeg_topoplot!(axis, data, positions=pos1)
eeg_topoplot!(axis, data, positions=pos2)
f
f = Figure()
axis = Axis(f[1, 1]; aspect=1)
xlims!(; low=-2, high=2)
ylims!(; low=-2, high=2)
palday marked this conversation as resolved.
Show resolved Hide resolved

data = [0, 0, 0]
pos1 = [Point2f(-1, -1), Point2f(-1.0, 0.0), Point2f(0, -1)]
pos2 = [Point2f(1, 1), Point2f(1.0, 0.0), Point2f(0, 1)]

pos1 = pos1 .- mean(pos1)
pos2 = pos2 .- mean(pos2)
eeg_topoplot!(axis, data; positions=pos1)
eeg_topoplot!(axis, data; positions=pos2)
palday marked this conversation as resolved.
Show resolved Hide resolved
f
end

# ╔═╡ Cell order:
Expand Down
Loading
Loading