28#include <QRegularExpression>
51 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
55 const QString text = QTextStream(&file).readAll();
56 static const QRegularExpression linear(QStringLiteral(
"Transform_Type\\s*=\\s*Linear\\s*;\\s*Linear_Transform\\s*=([^;]*);"),
57 QRegularExpression::CaseInsensitiveOption);
58 const QRegularExpressionMatch match = linear.match(text);
59 const QStringList values = match.captured(1).split(QRegularExpression(QStringLiteral(
"\\s+")), Qt::SkipEmptyParts);
60 if (!match.hasMatch() || values.size() != 12) {
65 for (
int row = 0; row < 3; ++row) {
66 for (
int col = 0; col < 4; ++col) {
68 const float value = values[4 * row + col].toFloat(&ok);
73 rot(row, col) = value;
75 move[row] = value / 1000.0f;
92 above << 0.99f, 0.0f, 0.0f, 0.0f, 0.9688f, 0.046f, 0.0f, -0.0485f, 0.9189f;
94 below << 0.99f, 0.0f, 0.0f, 0.0f, 0.9688f, 0.042f, 0.0f, -0.0485f, 0.839f;
107 if (!stream->open()) {
124 for (
const auto& entry : stream->dir()) {
125 if (entry->kind !=
FIFF_COORD_TRANS || !stream->read_tag(tag, entry->pos)) {
129 for (
const auto& link : links) {
130 if (t.
from == link.from && t.
to == link.to) {
131 this->*link.member = t;
133 }
else if (t.
from == link.to && t.
to == link.from) {
173 MatrixX3f result(rr.rows(), 3);
174 for (Index k = 0; k < rr.rows(); ++k) {
175 result.row(k) = rr(k, 2) > 0.0f ? above.row(k) : below.row(k);
Symbolic FIFF tag, block, value, unit and channel-type constants shared across FIFFLIB.
#define FIFFV_MNE_COORD_MNI_TAL
#define FIFFV_MNE_COORD_FS_TAL_LTZ
#define FIFFV_MNE_COORD_FS_TAL_GTZ
#define FIFFV_MNE_COORD_RAS
FIFF tag: the 16-byte tag header (kind, type, size, next) plus its decoded payload.
The MNE-C transform chain from MEG head coordinates to MNI and FreeSurfer Talairach coordinates.
FIFF binary tag-stream layer: wraps a QIODevice to read and write FIFF tags, directories,...
return FiffCoordTrans(from_frame, to_frame, R, moveVec)
FIFF file I/O, in-memory data structures and high-level readers/writers.
Labelled 4x4 FIFF affine: source frame, destination frame, rotation, translation and cached inverse.
FiffCoordTrans inverted() const
The chain of transforms from MEG head coordinates to MNI and FreeSurfer Talairach coordinates.
FiffCoordTrans head_surf_RAS_t
Eigen::MatrixX3f mniToTalairach(const Eigen::MatrixX3f &rr) const
bool addTalairach(const QString &xfmPath)
int read(const QString &path)
FiffCoordTrans surf_RAS_RAS_t
void write(FiffStream &stream) const
FiffCoordTrans MNI_tal_tal_ltz_t
Eigen::MatrixX3f headToMni(const Eigen::MatrixX3f &rr) const
static FiffCoordTrans readMniTransform(const QString &path)
FiffCoordTrans MNI_tal_tal_gtz_t
FiffCoordTrans RAS_MNI_tal_t
FIFF tag-stream reader/writer: wraps a QIODevice and exposes typed read_* / write_* methods for every...
QSharedPointer< FiffStream > SPtr
fiff_long_t write_coord_trans(const FiffCoordTrans &trans)
std::unique_ptr< FiffTag > UPtr