Skip to main content

LayoutMaker

Namespace: UTILSLIB  ·  Library: Utilities Library

#include <utils/layoutmaker.h>

class UTILSLIB::LayoutMaker

Make layout files from given 3D points.

Make layout files from given 3D points.

src/examples/ex_utils/main.cpp
// Azimuthal equidistant projection around the fitted sphere: Cz lands near the centre, the nose points up
QList<QVector<float>> points3d;
QStringList names;
for (const ElectrodePosition& electrode : montage1020) {
points3d.append({static_cast<float>(electrode.pos.x()), static_cast<float>(electrode.pos.y()), static_cast<float>(electrode.pos.z())});
names.append(electrode.name);
}
QList<QVector<float>> layout2d;
QFile layoutFile(dir.filePath("1020.lout"));
LayoutMaker::makeLayout(points3d, layout2d, names, layoutFile, true, 20.0f, 5.0f, 4.0f, true);

Static Methods​

makeLayout(inputPoints, outputPoints, names, outFile, do_fit, prad, w, h, writeFile, mirrorXAxis, mirrorYAxis)​

Reads the specified ANT elc-layout file.

Parameters:

  • inputPoints : const QList< QVector< float > > & The input points in 3D space.

  • outputPoints : QList< QVector< float > > & The output layout points in 2D space.

  • names : const QStringList & The channel names.

  • outFile : QFile & The outout file.

  • do_fit : bool The flag whether to do a sphere fitting.

  • prad : float Radius of the projection disk in layout units.

  • w : float Width of each channel box in layout units.

  • h : float Height of each channel box in layout units.

  • writeFile : bool The flag whether to write to file.

  • mirrorXAxis : bool Mirror points at x axis.

  • mirrorYAxis : bool Mirror points at y axis.

Returns:

  • bool — true if making layout was successful, false otherwise.

makeLayout(inputPoints, outputPoints, names, outFilePath, do_fit, prad, w, h, writeFile, mirrorXAxis, mirrorYAxis)​

Reads the specified ANT elc-layout file.

Parameters:

  • inputPoints : const std::vector< std::vector< float > > & The input points in 3D space.

  • outputPoints : std::vector< std::vector< float > > & The output layout points in 2D space.

  • names : const std::vector< std::string > & The channel names.

  • outFilePath : const std::string & The outout file.

  • do_fit : bool The flag whether to do a sphere fitting.

  • prad : float Radius of the projection disk in layout units.

  • w : float Width of each channel box in layout units.

  • h : float Height of each channel box in layout units.

  • writeFile : bool The flag whether to write to file.

  • mirrorXAxis : bool Mirror points at x axis.

  • mirrorYAxis : bool Mirror points at y axis.

Returns:

  • bool — true if making layout was successful, false otherwise.

Example​

Used in examples​

ex_utils​

Utilities library: buffers, observers, logging, file formats, montages, layouts and reports.

src/examples/ex_utils/main.cpp, line 223
QList<QVector<float>> layout2d;
QFile layoutFile(dir.filePath("1020.lout"));
LayoutMaker::makeLayout(points3d, layout2d, names, layoutFile, true, 20.0f, 5.0f, 4.0f, true);
const int iCz = names.indexOf("Cz");
const int iFp1 = names.indexOf("Fp1");
const int iO1 = names.indexOf("O1");
const int iT8 = names.indexOf("T8");
// Box corners: the box of an electrode at (x, y) starts at (x - w/2, y - h/2)
const float czX = layout2d[iCz][0] + 2.5f;
const float czY = layout2d[iCz][1] + 2.0f;
ok &= expect(layout2d.size() == names.size() && std::hypot(czX, czY) < 1.0f && layout2d[iFp1][1] > layout2d[iCz][1] && layout2d[iO1][1] < layout2d[iCz][1] && layout2d[iFp1][0] < layout2d[iCz][0] && layout2d[iT8][0] > layout2d[iCz][0],
QString("LayoutMaker: Cz at (%1, %2), Fp1 front-left, O1 back, T8 right").arg(czX).arg(czY));

ex_make_layout​

Builds example for making a 2D layout from 3D points.

src/examples/ex_make_layout/main.cpp, line 142
if (!LayoutMaker::makeLayout(inputPoints,
outputPoints,
names,
out,
true,
prad,
width,
height,
true,
(bool)parser.value(mirrorxOption).toInt(),
(bool)parser.value(mirrorxOption).toInt())) {
numberTries++;
} else {
numberTries = 11;

Authors of this file​