Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erp plot documentation #80

Merged
merged 16 commits into from
Sep 29, 2023
2 changes: 1 addition & 1 deletion docs/src/tutorials/butterfly.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Default is `(:labels, :label, :topoLabels, :sensor, :nothing)`

## Configurations for Butterfly Plots

Here we look into possible options for configuring the butterfly plot visualization using `(...;extra=(<name>=<value>,...)`.
Here we look into possible options for configuring the butterfly plot visualization using `(...; extra=(<name>=<value>, ...)`.
This is the list of unique configuration (extraData):

- topoLegend (boolean)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/tutorials/designmatrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The following code will result in the default configuration.
plot_designmatrix(designmatrix(uf))
```

# `plot_designmatrix(...;extra=(<name>=<value>,...)`.
# `plot_designmatrix(...; extra=(<name>=<value>, ...)`.

- sortData (boolean,false) - Indicating whether the data is sorted; using sortslices() of Base Julia.

Expand Down
4 changes: 2 additions & 2 deletions docs/src/tutorials/topoplot.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ cfgDefault.mapping.y
Indicates whether label should drawn next to their position.
Obviously the labels have to be provided: `plot_topoplot(...; labels=[...])`

`plot_topoplot(...;visual=(; label_text=true))`
`plot_topoplot(...; visual=(; label_text=true))`

### label_scatter (boolean)
Indicates whether the dots should be drawn at the given positions.

`plot_topoplot(...;visual=(; label_scatter=true))`
`plot_topoplot(...; visual=(; label_scatter=true))`


```@example main
Expand Down
11 changes: 9 additions & 2 deletions docs/src/tutorials/topoplotseries.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ nothing #hide
plot_topoplotseries(df, Δbin; positions = positions)
```

With colorbar:

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

### Positions
You can give either positions, or labels. If both are provided, positions have priority

### plot_toposeries(...;mapping=(;key=value))
`mapping=(:y=(:estimate, :yhat, :y))`

### plot_toposeries(...; mapping=(; key=value))
`mapping=(: y=(:estimate, :yhat, :y))`


### visual=(;)
`label_text` (boolean, false) Indicates whether label should drawn next to their position.
Expand Down
10 changes: 5 additions & 5 deletions src/plot_circulareegtopoplot.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""

plot_circulareegtopoplot(plotData::DataFrame;kwargs...)
plot_circulareegtopoplot!(figlike, plotData::DataFrame;kwargs...)
plot_circulareegtopoplot(plotData::DataFrame; kwargs...)
plot_circulareegtopoplot!(figlike, plotData::DataFrame; kwargs...)



Expand All @@ -13,15 +13,15 @@ Plot a circular EEG topoplot.
- `predictor` (optional; default :predictor) the circular predictor value, defines position of topoplot, is mapped around `predictorBounds`
- `kwargs...`: Additional styling behavior.

## Extra Data Behavior (...;extra=(;[key]=value)):
## Extra Data Behavior (...; extra=(; [key]=value)):

`predictorBounds`: Default: `[0,360]` - The bounds of the predictor. This is relevant for the axis labels.


## Axis Data Behavior (...;axis=(;[key]=value)):
## Axis Data Behavior (...; axis=(; [key]=value)):
`label`: default "", the text in the center of the cricle

## Mapping Data Behavior (...;mapping=(;[key]=value)):
## Mapping Data Behavior (...; mapping=(; [key]=value)):

## Return Value:
A figure containing the circular topoplot at given layout position
Expand Down
2 changes: 1 addition & 1 deletion src/plot_designmatrix.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
function plot_designmatrix(plotData::Unfold.DesignMatrix;kwargs...)
function plot_designmatrix(plotData::Unfold.DesignMatrix; kwargs...)


Plot a designmatrix.
Expand Down
2 changes: 1 addition & 1 deletion src/plot_parallelcoordinates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Plot a PCP (parallel coordinates plot).
- `config::PlotConfig`: Instance of PlotConfig being applied to the visualization.
- `channels::Vector{Int64}`: vector with all the channels representing an axis used in the PCP in given order.

## Extra Data Behavior (...;setExtraValues=(;[key]=value)):
## Extra Data Behavior (...; setExtraValues=(; [key]=value)):

PCP has problems with size changes of the view window.
By adapting the padding, aspect ratio and tick label size in px for a new use case, the PCP can even be added into a Coordinated Multiple Views System
Expand Down
6 changes: 3 additions & 3 deletions src/plot_topoplot.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
function plot_topoplot!(f::Union{GridPosition, Figure}, plotData, ; positions=nothing, labels=nothing,kwargs...)
function plot_topoplot(plotData,; positions=nothing, labels=nothing,kwargs...)
function plot_topoplot!(f::Union{GridPosition, Figure}, plotData, ; positions=nothing, labels=nothing, kwargs...)
function plot_topoplot(plotData,; positions=nothing, labels=nothing, kwargs...)

Plot a topo plot.
## Arguments:
Expand All @@ -9,7 +9,7 @@ Plot a topo plot.
- `positions::Vector{Point{2, Float32}}=nothing`: positions used if `plotData` is no DataFrame. If this is the case and `positions=nothing` then positions is generated from `labels`.
- `labels::Vector{String}=nothing`: labels used if `plotData` is no DataFrame.

## Extra Data Behavior (...;setExtraValues=(;[key]=value)):
## Extra Data Behavior (...; setExtraValues=(; [key]=value)):
None

## Return Value:
Expand Down
25 changes: 13 additions & 12 deletions src/plot_topoplotseries.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
"""
function plot_topoplotseries!(f::Union{GridPosition, Figure}, plotData::DataFrame,Δbin::Real;kwargs...)
function plot_topoplotseries!(plotData::DataFrame, Δbin::Real;kwargs...)
function plot_topoplotseries!(f::Union{GridPosition, Figure}, plotData::DataFrame, Δbin::Real; kwargs...)
function plot_topoplotseries!(plotData::DataFrame, Δbin::Real; kwargs...)


Plot a Topoplot Series.
## Arguments:
- `f::Union{GridPosition, Figure}`: Figure or GridPosition that the plot should be drawn into
- `plotData::DataFrame`: DataFrame with data, needs a `time` column
- `Δbin::Real`: A number for how large one bin should be. Δbin is in units of the `plotData.time` column
- `useColorbar`: (default `true`) - show colorbar.
- `kwargs...`: Additional styling behavior. Often used:
`plot_topoplotseries(df;mapping=(;col=:time,row=:conditionA))`
`plot_topoplotseries(df; mapping=(;col=:time, row=:conditionA))`

## Extra Data Behavior (...;extra=(;[key]=value)):
## Extra Data Behavior (...; extra=(; [key]=value)):
`combinefun` (default `mean`) can be used to specify how the samples within `Δbin` are combined.
`bin_labels` (default `true`) - plot the time-window bin size as xlabels at the last row of the plot
`rasterize_heatmaps` (deault `true`) - when saving a svg - enforce rasterization of the plot heatmap. This has the benefit that all lines/points are vectors, except the interpolated heatmap. This is typically what you want, because else you get ~500x500 vectors per topoplot, which makes everything super slow...
Expand All @@ -35,7 +36,7 @@ function plot_topoplotseries!(f::Union{GridPosition,Figure}, plotData::DataFrame

positions = getTopoPositions(; positions=positions, labels=labels)


if "label" ∉ names(plotData)
plotData.label = plotData.channel
end
Expand All @@ -45,19 +46,19 @@ function plot_topoplotseries!(f::Union{GridPosition,Figure}, plotData::DataFrame
label=:label,
col=config.mapping.col,
row=config.mapping.row,
col_labels = config.extra.col_labels,
row_labels = config.extra.row_labels,
rasterize_heatmaps = config.extra.rasterize_heatmaps,
col_labels=config.extra.col_labels,
row_labels=config.extra.row_labels,
rasterize_heatmaps=config.extra.rasterize_heatmaps,
combinefun=config.extra.combinefun,
positions=positions,
config.visual...
)

if config.layout.showLegend
@show "leegeeend"
if config.layout.useColorbar
@show "colorbar"
d = ftopo.content[1].scene.plots[1]
Colorbar(f[1,end+1],colormap=d.colormap,colorrange=d.colorrange,height=100)

Colorbar(f[1, end+1], colormap=d.colormap, colorrange=d.colorrange, height=100, flipaxis=false, label="Voltage [µV]")
end
return f

Expand Down
4 changes: 2 additions & 2 deletions src/plotconfig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ function PlotConfig(T::Val{:topoplotseries})
config_kwargs!(cfg, extra=(
combinefun=mean,
col_labels=true,
row_labels = true,
row_labels=true,
rasterize_heatmaps=true
), layout=(
showLegend=false, # what does it mean to have a topoplotseries legend?
useColorbar=true,
), visual=(; label_text=false # true doesnt work again
), mapping=(
col=(:time,),
Expand Down
9 changes: 5 additions & 4 deletions src/relative_axis.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@


"""
ax = RelativeAxis(figlike, p::NTuple{4,Float64}; kwargs...)
ax = RelativeAxis(figlike, p::NTuple{4, Float64}; kwargs...)

Returns an axis which's position is relative to a GridLayout Element (via BBox) and not
relative to the Scene (default Axis(...,bbox=BBox()) behavior)
relative to the Scene (default Axis(..., bbox=BBox()) behavior)

p::NTuple{4,Float64}: Give the relative position to the GridPosition, left:right; bottom:up,
typical numbers betwen 0 and 1. E.g. (0.25,0.75,0.25,0.75) would center an Axis inside that GridPosition
typical numbers betwen 0 and 1. E.g. (0.25, 0.75, 0.25, 0.75) would center an Axis inside that GridPosition

kwargs... are pasted into Axis

f = Figure()
ax = RelativeAxis(f[1,2],(0.25,0.75,0.25,0.75)) # returns Axis centered within f[1,2]
ax = RelativeAxis(f[1,2], (0.25, 0.75, 0.25, 0.75)) # returns Axis centered within f[1,2]

"""

struct RelativeAxis
layoutobservables::GridLayoutBase.LayoutObservables{GridLayout}
relative_bbox::NTuple
Expand Down
9 changes: 8 additions & 1 deletion test/test_toposeries.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@

@testset "testing calculateBBox" begin
@testset "testing standart" begin
data, positions = TopoPlots.example_data()
df = UnfoldMakie.eeg_matrix_to_dataframe(data[:, :, 1], string.(1:length(positions)));
Δbin=80
UnfoldMakie.plot_topoplotseries(df, Δbin; positions=positions)

end
@testset "testing with colorbar" begin
data, positions = TopoPlots.example_data()
df = UnfoldMakie.eeg_matrix_to_dataframe(data[:, :, 1], string.(1:length(positions)));
Δbin=80
UnfoldMakie.plot_topoplotseries(df, Δbin; positions=positions, layout = (; useColorbar=true))

end
Loading