-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* revised topoplotseries and test all * erp image sorted in test_all * first draft * Update plot_channelimage.jl * first successfull test * upd to main * channelimage in complex plot * strange bug fix * small inconsistency in tests * reverse ERP image trials and sorted ERP image into combined plot * more example_data * del
- Loading branch information
Showing
17 changed files
with
171 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" | ||
plot_channelimage!(f::Union{GridPosition, GridLayout, Figure}, data::Matrix{<:Real}, position::Vector{Point{2,Float32}}, ch_names::Vector{String}; kwargs...) | ||
plot_channelimage(data::Matrix{<:Real}, position::Vector{Point{2,Float32}}, ch_names::Vector{String}; kwargs...) | ||
Channel image | ||
## Arguments: | ||
- `f::Union{GridPosition, GridLayout, Figure}`: Figure, GridLayout or GridPosition that the plot should be drawn into. | ||
- `data::DataFrame`: DataFrame with data. | ||
- `position` (Vector{Point{2,Float32}}): a vector with EEG layout coordinates. | ||
- `ch_names` (Vector{String}): vector with channel names. | ||
$(_docstring(:channelimage)) | ||
## Return Value: | ||
A figure displaying channel image | ||
""" | ||
|
||
plot_channelimage(data::Matrix{<:Real}, position::Vector{Point{2,Float32}}, ch_names::Vector{String}; kwargs...) = | ||
plot_channelimage!(Figure(), data, position, ch_names; kwargs...) | ||
|
||
function plot_channelimage!( | ||
f::Union{GridPosition,GridLayout,Figure}, | ||
data::Matrix{<:Real}, | ||
position::Vector{Point{2,Float32}}, | ||
ch_names::Vector{String}; | ||
kwargs..., | ||
) | ||
config = PlotConfig(:channelimage) | ||
config_kwargs!(config; kwargs...) | ||
|
||
|
||
x = [i[1] for i in position] | ||
y = [i[2] for i in position] | ||
|
||
x = round.(x; digits = 2) | ||
y = Integer.(round.((y .- mean(y)) * 20)) * -1 | ||
x = Integer.(round.((x .- mean(x)) * 20)) | ||
d = zip(x, y, ch_names, 1:20) | ||
a = sort!(DataFrame(d), [:2, :1], rev = [true, false]) | ||
b = a[!, :4] | ||
c = a[!, :3] | ||
c = [string(x) for x in c] | ||
|
||
ix = range(-0.3, 1.2, length = size(data, 2)) | ||
iy = 1:20 | ||
iz = mean(data, dims = 3)[b, :, 1]' | ||
|
||
gin = f[1, 1] = GridLayout() | ||
ax = Axis(gin[1, 1], xlabel = config.axis.xlabel, ylabel = config.axis.ylabel) | ||
hm = Makie.heatmap!(ix, iy, iz, colormap = config.visual.colormap) | ||
ax.yticks = iy | ||
ax.ytickformat = xc -> c | ||
ax.yticklabelsize = config.axis.yticklabelsize | ||
|
||
Makie.Colorbar(gin[1, 2], hm, label = config.colorbar.label, labelrotation = config.colorbar.labelrotation) | ||
return f | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
data, pos = TopoPlots.example_data() | ||
data = data[:, :, 1] | ||
pos = pos[1:30] | ||
raw_ch_names = ["FP1", "F3", "F7", "FC3", "C3", "C5", "P3", "P7", "P9", "PO7", | ||
"PO3", "O1", "Oz", "Pz", "CPz", "FP2", "Fz", "F4", "F8", "FC4", "FCz", "Cz", | ||
"C4", "C6", "P4", "P8", "P10", "PO8", "PO4", "O2"] | ||
|
||
@testset "channel image basic" begin | ||
plot_channelimage(data, pos, raw_ch_names; ) | ||
|
||
end | ||
|
||
@testset "channel image with Figure" begin | ||
f = Figure() | ||
plot_channelimage!(f, data, pos, raw_ch_names; ) | ||
|
||
end |
Oops, something went wrong.