Skip to contents

Returns the integer permutation that reorders the columns of a raw device export into the column-major grid order every other pressR function assumes. A reader applies it once: pressure <- raw[, pr_channel_order(layout), drop = FALSE].

Usage

pr_channel_order(layout_or_map)

Arguments

layout_or_map

A pr_layout built by pr_layout_from_index_map() (or pr_layout_saddle_novel()), a channel index matrix as accepted by pr_layout_from_index_map(), or an integer vector that already is such a permutation.

Value

An integer vector of length layout$n_sensors.

Details

Element k of the result is the device channel that belongs in pressure column k, where column k corresponds to which(layout$active)[k] — the same column-major ordering used by pr_mask() and .layout_build_coords().

See also

Examples

pr_channel_order(rbind(c(2L, 1L), c(4L, 3L)))
#> [1] 2 4 1 3

ord <- pr_channel_order(pr_layout_saddle_novel())
length(ord)
#> [1] 256
ord[1:8]
#> [1]  16  32  48  64  80  96 112 128