Skip to content

Commit

Permalink
8plots (#97)
Browse files Browse the repository at this point in the history
* Update plot_erp.jl

* new tests, combined plot in docs

* del

* additional docs problems

* little detail

* dead links

* docstring warnings

* cross-refs again

* test

* pp_plot fixed

* docs errors should be resolved

* Update hide_deco.md

* colorbar docs

* liting

* add Voltage label

* linting + name consistency

* formatter

* no extra for circular

* no extra toposeries

* test for design matrix and no extra

* test

* no extra for erp

* del extra in erpimage and parplot

* g

* citability

* failed, but I will save it

* fixed

* fixed colorbar in toposeries

* small test

* review of current test

* del chanNum argument

* adding Gridlayout option

* small fixes

* add new argument to erp plot

* colorbar section in configs for toposeries

* whatever

---------

Co-authored-by: behinger (s-ccs 001) <[email protected]>
  • Loading branch information
vladdez and behinger authored Nov 13, 2023
1 parent cc42f28 commit d9e56b5
Show file tree
Hide file tree
Showing 19 changed files with 322 additions and 257 deletions.
4 changes: 2 additions & 2 deletions docs/src/tutorials/topoplotseries.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ nothing #hide
plot_topoplotseries(df, Δbin; positions = positions)
```

With colorbar:
Without colorbar:

```@example main
plot_topoplotseries(df, Δbin; positions=positions, layout = (; useColorbar=true))
plot_topoplotseries(df, Δbin; positions=positions, layout = (; useColorbar=false))
```

### Positions
Expand Down
176 changes: 0 additions & 176 deletions src/eeg-series.jl

This file was deleted.

4 changes: 3 additions & 1 deletion src/eeg_series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ function eeg_topoplot_series!(
push!(axlist, ax)
end
end
colgap!(fig.layout, 0)
if typeof(fig) != GridLayout
colgap!(fig.layout, 0)
end

return fig, axlist
end
Expand Down
8 changes: 4 additions & 4 deletions src/plot_circulareegtopoplot.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""
plot_circulareegtopoplot(plotData::DataFrame;kwargs...)
plot_circulareegtopoplot!(figlike, plotData::DataFrame;kwargs...)
plot_circulareegtopoplot(plotData::DataFrame; kwargs...)
plot_circulareegtopoplot!(figlike, plotData::DataFrame; kwargs...)
Plot a circular EEG topoplot.
## Arguments:
- `figlike::Union{GridPosition, Figure}`: Figure or GridPosition that the plot should be drawn into
- `figlike::Union{GridPosition, GridLayout, Figure}`: Figure or GridPosition that the plot should be drawn into
- `plotData::DataFrame`: Dataframe with keys for data (looks for `:y,:yhat, :estimate`, and :position (looks for `:pos, :positions, :position`),
- `predictor` (optional; default :predictor) the circular predictor value, defines position of topoplot, is mapped around `predictorBounds`
- `predictorBounds`: Default: `[0,360]` - The bounds of the predictor. This is relevant for the axis labels.
Expand All @@ -29,7 +29,7 @@ plot_circulareegtopoplot(plotData::DataFrame; kwargs...) =
plot_circulareegtopoplot!(f, plotData::DataFrame; kwargs...) =
plot_circulareegtopoplot!(f, plotData; kwargs...)
function plot_circulareegtopoplot!(
f::Union{GridPosition,Figure},
f::Union{GridPosition,GridLayout,Figure},
plotData::DataFrame;
predictor = :predictor,
positions = nothing,
Expand Down
6 changes: 4 additions & 2 deletions src/plot_designmatrix.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""
plot_designmatrix(plotData::Unfold.DesignMatrix;kwargs...)
plot_designmatrix!(f::Union{GridPosition, GridLayout, Figure}, plotData::Unfold.DesignMatrix; kwargs...)
plot_designmatrix(plotData::Unfold.DesignMatrix; kwargs...)
Plot a designmatrix.
## Arguments:
- `f::Union{GridPosition, GridLayout, Figure}`: Figure or GridPosition (e.g. f[2, 3]) that the plot should be drawn into. New axis is created.
- `plotData::Unfold.DesignMatrix`: Data for the plot visualization.
## kwargs
Expand All @@ -27,7 +29,7 @@ A figure displaying the designmatrix.
plot_designmatrix(plotData::Unfold.DesignMatrix; kwargs...) =
plot_designmatrix!(Figure(), plotData; kwargs...)
function plot_designmatrix!(
f::Union{GridPosition,Figure},
f::Union{GridPosition,GridLayout,Figure},
plotData::Unfold.DesignMatrix;
xTicks = nothing,
sortData = false,
Expand Down
61 changes: 27 additions & 34 deletions src/plot_erp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ using DataFrames
using TopoPlots
using LinearAlgebra
"""
plot_erp!(f::Union{GridPosition, Figure}, plotData::DataFrame; kwargs...)
plot_erp!(f::Union{GridPosition, GridLayout, Figure}, plotData::DataFrame; kwargs...)
plot_erp(plotData::DataFrame; kwargs...)
Plot an ERP plot.
## Arguments:
- `f::Union{GridPosition, Figure}`: Figure or GridPosition that the plot should be drawn into
- `f::Union{GridPosition, GridLayout, Figure}`: Figure or GridPosition that the plot should be drawn into
- `plotData::DataFrame`: Data for the line plot visualization.
- `kwargs...`: Additional styling behavior. Often used: `plot_erp(df; mapping=(; color=:coefname, col=:conditionA))`
Expand Down Expand Up @@ -47,23 +47,26 @@ see also [`plot_erp`](@Ref)
plot_butterfly(plotData::DataFrame; kwargs...) =
plot_butterfly!(Figure(), plotData; kwargs...)

plot_butterfly!(f::Union{GridPosition,<:Figure}, plotData::DataFrame; kwargs...) =
plot_erp!(
f,
plotData;
butterfly = true,
topoLegend = true,
topomarkersize = 10,
topowidth = 0.25,
topoheigth = 0.25,
topoPositionToColorFunction = x -> posToColorRomaO(x),
kwargs...,
)
plot_butterfly!(
f::Union{GridPosition,GridLayout,<:Figure},
plotData::DataFrame;
kwargs...,
) = plot_erp!(
f,
plotData;
butterfly = true,
topoLegend = true,
topomarkersize = 10,
topowidth = 0.25,
topoheigth = 0.25,
topoPositionToColorFunction = x -> posToColorRomaO(x),
kwargs...,
)



function plot_erp!(
f::Union{GridPosition,Figure},
f::Union{GridPosition,GridLayout,Figure},
plotData::DataFrame;
positions = nothing,
labels = nothing,
Expand All @@ -86,7 +89,6 @@ function plot_erp!(
config_kwargs!(config; kwargs...)
end


plotData = deepcopy(plotData) # XXX why?

# resolve columns with data
Expand Down Expand Up @@ -184,7 +186,12 @@ function plot_erp!(
valign = 0.95,
aspect = 1,
)
topoplotLegend(topoAxis, topomarkersize, topoPositionToColorFunction, allPositions)
topoplotLegend(
topoAxis,
topomarkersize,
topoPositionToColorFunction,
allPositions,
)
end
# no extra legend
mainAxis = Axis(f_grid; config.axis...)
Expand All @@ -203,8 +210,6 @@ function plot_erp!(

end
applyLayoutSettings!(config; fig = f, ax = drawing, drawing = drawing)#, drawing = drawing)


return f

end
Expand All @@ -215,22 +220,10 @@ function eegHeadMatrix(positions, center, radius)
oldRadius, _ = findmax(x -> norm(x .- oldCenter), positions)
radF = radius / oldRadius
return Makie.Mat4f(
radF,
0,
0,
0,
0,
radF,
0,
0,
0,
0,
1,
0,
radF, 0, 0, 0, 0,
radF, 0, 0, 0, 0, 1, 0,
center[1] - oldCenter[1] * radF,
center[2] - oldCenter[2] * radF,
0,
1,
center[2] - oldCenter[2] * radF, 0, 1,
)
end

Expand Down
7 changes: 3 additions & 4 deletions src/plot_erpgrid.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
function plot_erpgrid!(f::Union{GridPosition, Figure}, data::Matrix{<:Real}, pos::Vector{Point{2,Float}}; kwargs...)
function plot_erpgrid!(f::Union{GridPosition, GridLayout, Figure}, data::Matrix{<:Real}, pos::Vector{Point{2,Float}}; kwargs...)
function plot_erpgrid(data::Matrix{<:Real}, pos::Vector{Point{2,Float}}; kwargs...)
Plot an ERP image.
## Arguments:
- `f::Union{GridPosition, Figure}`: Figure or GridPosition that the plot should be drawn into;
- `f::Union{GridPosition, GridLayout, Figure}`: Figure or GridPosition that the plot should be drawn into;
- `plotData::Matrix{<:Real}`: Data for the plot visualization;
- `pos::Vector{Point{2,Float}}`: electrode positions.
Expand All @@ -21,15 +21,14 @@ plot_erpgrid(plotData::Matrix{<:Real}, pos; kwargs...) =
plot_erpgrid!(Figure(), plotData, pos; kwargs...)

function plot_erpgrid!(
f::Union{GridPosition,Figure},
f::Union{GridPosition,GridLayout,Figure},
plotData::Matrix{<:Real},
pos;
drawLabels = false,
times = -1:size(plotData, 2)-2, #arbitrary strat just for fun
kwargs...,
)
chanNum = size(plotData, 1)
println(size(plotData, 1), " ", size(plotData, 2))
plotData = plotData[1:chanNum, :]
pos = hcat([[p[1], p[2]] for p in pos]...)

Expand Down
Loading

0 comments on commit d9e56b5

Please sign in to comment.