|
| 1 | +""" |
| 2 | + gui(outbase, files) |
| 3 | + gui(outbase, glob::GlobMatch) |
| 4 | +
|
| 5 | +Run the graphical user interface (GUI) for CounterMarking. Supply the base name |
| 6 | +of the output files (e.g., "my_results") and a list of image files to process |
| 7 | +(alternatively, supply a `glob"pattern"` that matches just the files you want to |
| 8 | +process). |
| 9 | +
|
| 10 | +The GUI will display the images and their segmentation, and allow the user to |
| 11 | +select the segments corresponding to the stimulus (yellow) and marked spots. The |
| 12 | +results will be save to: |
1 | 13 |
|
| 14 | +- `outbase.xlsx`: an Excel file with one sheet per image, containing summary |
| 15 | + statistics on the stimulus spot and the selected spots. |
| 16 | +- `outbase.jld2`: a JLD2 file with one dataset per image, containing the |
| 17 | + segmented image, the selected spots, and the stimulus segment. |
| 18 | +
|
| 19 | +The JLD2 file can be used by [`density_map`](@ref). |
| 20 | +""" |
2 | 21 | function gui( |
3 | | - outbase, files; |
| 22 | + outbase::AbstractString, files; |
4 | 23 | colors=distinguishable_colors(15, [RGB(1, 1, 1)]; dropseed=true), |
5 | 24 | btnclick = Condition(), # used for testing |
6 | 25 | whichbutton = Ref{Symbol}(), # used for testing |
| 26 | + preclick::Union{Int,Nothing} = nothing, # used for testing |
7 | 27 | ) |
8 | 28 | channelpct(x) = string(round(Int, x * 100)) * '%' |
9 | 29 |
|
10 | 30 | outbase, _ = splitext(outbase) |
11 | 31 |
|
| 32 | + # Set up basic properties of the window |
12 | 33 | winsize = round.(Int, 0.8 .* screen_size()) |
13 | 34 | win = GtkWindow("CounterMarking", winsize...) |
14 | 35 | ag = Gtk4.GLib.GSimpleActionGroup() |
@@ -38,6 +59,7 @@ function gui( |
38 | 59 | cssprov = GtkCssProvider(css) |
39 | 60 | push!(Gtk4.display(win), cssprov) |
40 | 61 |
|
| 62 | + # Create the elements of the GUI |
41 | 63 | win[] = bx = GtkBox(:v) |
42 | 64 | ImageView.window_wrefs[win] = nothing |
43 | 65 | signal_connect(win, :destroy) do w |
@@ -87,7 +109,7 @@ function gui( |
87 | 109 | istim = stimulus_index(seg) |
88 | 110 | for (j, cb) in enumerate(cbs) |
89 | 111 | # set_gtk_property!(cb, "active", j <= nsegs) |
90 | | - cb[] = j == istim |
| 112 | + cb[] = (j == istim || j == preclick) |
91 | 113 | end |
92 | 114 | imshow(canvases[1, 1], img) |
93 | 115 | imshow(canvases[2, 1], map(i->colors[i], labels_map(seg))) |
@@ -135,7 +157,7 @@ function gui( |
135 | 157 | notify(btnclick) # used in testing |
136 | 158 | return |
137 | 159 | end |
138 | | -gui(outbase, glob::Glob.GlobMatch; kwargs...) = gui(outbase, Glob.glob(glob); kwargs...) |
| 160 | +gui(outbase::AbstractString, glob::Glob.GlobMatch; kwargs...) = gui(outbase, Glob.glob(glob); kwargs...) |
139 | 161 |
|
140 | 162 | function linkpair(img, imgc) |
141 | 163 | zr, slicedata = roi(img) |
|
0 commit comments