Skip to content

Commit

Permalink
refactoring ext and adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PavanChaggar committed Oct 28, 2023
1 parent 41923c8 commit f959098
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
13 changes: 2 additions & 11 deletions ext/ConnectomesMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,20 @@ module ConnectomesMakieExt

using Artifacts
using Connectomes
import Connectomes: RegionDict, View, meshpath
using Makie
using ColorSchemes
using Colors
using MeshIO, FileIO

const meshpath = artifact"DKTMeshes"
mni_cortex() = joinpath(meshpath, "meshes/cortex/connectome-cortex.obj")
fs_cortex() = joinpath(meshpath, "meshes/cortex/fs-cortex.obj")
rh_cortex() = joinpath(meshpath, "meshes/cortex/rh-cortex.obj")
lh_cortex() = joinpath(meshpath, "meshes/cortex/lh-cortex.obj")

function set_fig(;resolution::Tuple{Int64, Int64}=(1600,900), view=:front)
function Connectomes.set_fig(;resolution::Tuple{Int64, Int64}=(1600,900), view=:front)
f = Figure(resolution = resolution)
ax = Axis3(f[1,1], aspect = :data, azimuth = View[view]pi, elevation=0.0pi)
hidedecorations!(ax)
hidespines!(ax)
f
end

RegionDict = Dict(zip([:left, :right, :all, :connectome], [lh_cortex(), rh_cortex(), fs_cortex(), mni_cortex()]))

View = Dict(zip([:right, :front, :left, :back], [0.0, 0.5, 1.0, 1.5]))

function Connectomes.plot_cortex!(region::Symbol=:all; color=(:grey,0.05), transparency::Bool=true, kwargs...)
mesh!(load(RegionDict[region]), color=color, transparency=transparency, kwargs...)
end
Expand Down
1 change: 1 addition & 0 deletions src/Connectomes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ export plot_vertices
export plot_vertex!
export plot_connectome
export plot_connectome!
export set_fig

end
9 changes: 1 addition & 8 deletions src/plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,14 @@ function plot_vertices end
function plot_vertex! end
function plot_connectome end
function plot_connectome! end
function set_fig end

const meshpath = artifact"DKTMeshes"
mni_cortex() = joinpath(meshpath, "meshes/cortex/connectome-cortex.obj")
fs_cortex() = joinpath(meshpath, "meshes/cortex/fs-cortex.obj")
rh_cortex() = joinpath(meshpath, "meshes/cortex/rh-cortex.obj")
lh_cortex() = joinpath(meshpath, "meshes/cortex/lh-cortex.obj")

function set_fig(;resolution::Tuple{Int64, Int64}=(1600,900), view=:front)
f = Figure(resolution = resolution)
ax = Axis3(f[1,1], aspect = :data, azimuth = View[view]pi, elevation=0.0pi)
hidedecorations!(ax)
hidespines!(ax)
f
end

RegionDict = Dict(zip([:left, :right, :all, :connectome], [lh_cortex(), rh_cortex(), fs_cortex(), mni_cortex()]))

View = Dict(zip([:right, :front, :left, :back], [0.0, 0.5, 1.0, 1.5]))
3 changes: 2 additions & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
LightXML = "9c8b4983-aa76-5018-a973-4c85ecc9e179"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
7 changes: 7 additions & 0 deletions test/graphtest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@

@test diffusive_weights == weighted_connectome_A == reweighted_connectome_A
end

@testset "Makie" begin
using GLMakie

f = plot_cortex()
@test f isa Figure
end

0 comments on commit f959098

Please sign in to comment.