Skip to content
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
8 changes: 6 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ jobs:
matrix:
version:
- '1.10'
- '1.6'
- 'pre'
- '1'
os:
- ubuntu-latest
arch:
- x64
include:
- os: ubuntu-latest
prefix: xvfb-run
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
Expand All @@ -39,6 +41,8 @@ jobs:
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
with:
prefix: ${{ matrix.prefix }}
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v5
with:
Expand Down
7 changes: 5 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name = "CounterMarking"
uuid = "454fbcff-fa78-4492-9c80-2cfc3f2a4b52"
authors = ["Tim Holy <[email protected]> and contributors"]
version = "1.0.0-DEV"
version = "1.0.0"

[deps]
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
ImageMorphology = "787d08f9-d448-5407-9aad-5290dd7ab264"
ImageSegmentation = "80713f31-8817-5129-9cf8-209ff8fb23e1"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -19,13 +20,15 @@ CounterMarkingImageViewExt = "ImageView"
[compat]
FileIO = "1"
ImageCore = "0.10"
ImageIO = "0.6"
ImageMorphology = "0.4"
ImageSegmentation = "1.9"
ImageView = "0.12"
julia = "1.10"

[extras]
ImageView = "86fae568-95e7-573e-a6b2-d8a6b900c9ef"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["ImageView", "Test"]
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CounterMarking

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://HolyLab.github.io/CounterMarking.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://HolyLab.github.io/CounterMarking.jl/dev/)
[![Build Status](https://github.com/HolyLab/CounterMarking.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/HolyLab/CounterMarking.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/HolyLab/CounterMarking.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/HolyLab/CounterMarking.jl)

Utilities for analyzing images from mouse territorial countermarking experiments.
33 changes: 18 additions & 15 deletions ext/CounterMarkingImageViewExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ using ImageSegmentation
using ImageView
using Random

function colorize(seg, segidxs::AbstractSet{Int}, color::Colorant)
label = seg.image_indexmap
img = similar(label, promote_type(typeof(color), valtype(seg.segment_means)))
fill!(img, zero(eltype(img)))
for idx in eachindex(label)
label[idx] ∈ segidxs || continue
img[idx] = color
end
return img
end
# function colorize(seg, segidxs::AbstractSet{Int}, color::Colorant)
# label = seg.image_indexmap
# img = similar(label, promote_type(typeof(color), valtype(seg.segment_means)))
# fill!(img, zero(eltype(img)))
# for idx in eachindex(label)
# label[idx] ∈ segidxs || continue
# img[idx] = color
# end
# return img
# end

function linkpair(img, imgc)
gd = imshow(img)
zr = gd["roi"]["zoomregion"]
slicedata = gd["roi"]["slicedata"]
gdc = imshow(imgc, nothing, zr, slicedata)
return (gd, gdc)
zr, slicedata = roi(img)
gd = imshow_gui((800, 800), (2,1); slicedata=slicedata)
imshow(gd["frame"][1,1], gd["canvas"][1,1], img, nothing, zr, slicedata)
imshow(gd["frame"][2,1], gd["canvas"][2,1], imgc, nothing, zr, slicedata)
return gd
end

# For visualization
Expand All @@ -34,4 +34,7 @@ end
CounterMarking.randshow(seg; kwargs...) = imshow(map(i->get_random_color(i), labels_map(seg)); kwargs...)
CounterMarking.meanshow(seg; kwargs...) = imshow(map(i->segment_mean(seg, i), labels_map(seg)); kwargs...)

CounterMarking.randshow(img, seg; kwargs...) = linkpair(img, map(i->get_random_color(i), labels_map(seg)); kwargs...)
CounterMarking.meanshow(img, seg; kwargs...) = linkpair(img, map(i->segment_mean(seg, i), labels_map(seg)); kwargs...)

end
32 changes: 31 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
using CounterMarking
using FileIO
using Test

@testset "CounterMarking.jl" begin
# Write your tests here.
testdir = "testimages"
img = load(joinpath(testdir, "Picture.png"))
seg = segment_image(img)
# Without ImageView loaded, we can't visualize it, but we get a helpful error
if !isdefined(@__MODULE__, :ImageView)
@test_throws "using ImageView" randshow(seg)
@test_throws "using ImageView" meanshow(seg)
end
@eval using ImageView
dct = meanshow(seg)
@test haskey(dct, "gui")
dct = randshow(seg)
@test haskey(dct, "gui")
dct = randshow(img, seg)
@test haskey(dct, "window")
dct = meanshow(img, seg)
@test haskey(dct, "window")
ImageView.closeall()

spotdict, stimulus = spots(seg)
_, stimspot = stimulus
@test stimspot.npixels > 1000
@test stimspot.centroid[1] < size(img, 1) ÷ 2
@test stimspot.centroid[2] > size(img, 2) ÷ 2

stdspotdict, stdstimulus = upperleft(spotdict, stimulus, size(img))
_, stimspot = stdstimulus
@test stimspot.npixels > 1000
@test stimspot.centroid[1] < size(img, 1) ÷ 2
@test stimspot.centroid[2] < size(img, 2) ÷ 2
end
Binary file added test/testimages/Picture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.