60: m_qListBemSurface(p_MNEBem.m_qListBemSurface)
74 throw std::runtime_error(
"Could not read the bem surfaces\n");
92 m_qListBemSurface.clear();
102 bool open_here =
false;
105 if (!p_pStream->device()->isOpen())
107 QString t_sFileName = p_pStream->streamName();
109 t_file.setFileName(t_sFileName);
111 if(!p_pStream->open())
124 QList<FiffDirNode::SPtr> bem = p_pStream->dirtree()->dir_tree_find(
FIFFB_BEM);
127 qCritical() <<
"No BEM block found!";
135 QList<FiffDirNode::SPtr> bemsurf = p_pStream->dirtree()->dir_tree_find(
FIFFB_BEM_SURF);
136 if(bemsurf.isEmpty())
138 qCritical() <<
"No BEM surfaces found!";
146 for(
int k = 0; k < bemsurf.size(); ++k)
149 qInfo(
"\tReading a BEM surface...");
156 qInfo(
"\t[done]\n" );
158 p_Bem.m_qListBemSurface.append(p_BemSurface);
162 qInfo(
"\t%lld bem surfaces read\n", bemsurf.size());
175 p_BemSurface.
clear();
186 p_BemSurface.
id = *t_pTag->toInt();
194 p_BemSurface.
sigma = 1.0;
198 p_BemSurface.
sigma = *t_pTag->toFloat();
207 qWarning() <<
"np not found!";
212 p_BemSurface.
np = *t_pTag->toInt();
221 qWarning() <<
"ntri not found!";
226 p_BemSurface.
ntri = *t_pTag->toInt();
234 qWarning() <<
"FIFF_MNE_COORD_FRAME not found, trying FIFF_BEM_COORD_FRAME.";
238 throw std::runtime_error(
"Coordinate frame information not found.");
260 throw std::runtime_error(
"Vertex data not found.");
263 p_BemSurface.
rr = t_pTag->toFloatMatrix().transpose();
264 qint32 rows_rr = p_BemSurface.
rr.rows();
266 if (rows_rr != p_BemSurface.
np)
269 throw std::runtime_error(
"Vertex information is incorrect.");
280 throw std::runtime_error(
"Vertex normals not found.");
283 p_BemSurface.
nn = t_pTag->toFloatMatrix().transpose();
287 p_BemSurface.
nn = t_pTag->toFloatMatrix().transpose();
290 if (p_BemSurface.
nn.rows() != p_BemSurface.
np)
293 throw std::runtime_error(
"Vertex normal information is incorrect.");
299 if (p_BemSurface.
ntri > 0)
306 throw std::runtime_error(
"Triangulation not found.");
310 p_BemSurface.
itris = t_pTag->toIntMatrix().transpose();
311 p_BemSurface.
itris -= MatrixXi::Constant(p_BemSurface.
itris.rows(),3,1);
316 p_BemSurface.
itris = t_pTag->toIntMatrix().transpose();
317 p_BemSurface.
itris -= MatrixXi::Constant(p_BemSurface.
itris.rows(),3,1);
320 if (p_BemSurface.
itris.rows() != p_BemSurface.
ntri)
323 throw std::runtime_error(
"Triangulation information is incorrect.");
328 p_BemSurface.
itris.resize(0, 3);
344 qInfo(
"Write BEM surface in %s...\n", t_pStream->streamName().toUtf8().constData());
346 t_pStream->end_file();
354 for(qint32 h = 0; h < m_qListBemSurface.size(); ++h)
356 qInfo(
"\tWrite a bem surface... ");
358 m_qListBemSurface[h].writeToStream(p_pStream);
362 qInfo(
"\t%lld bem surfaces written\n", m_qListBemSurface.size());
370 if (idx>=m_qListBemSurface.length())
372 qWarning(
"Warning: Required surface doesn't exist! Returning surface '0'.");
375 return m_qListBemSurface[idx];
382 if (idx >= m_qListBemSurface.length())
384 qWarning(
"Warning: Required surface doesn't exist! Returning surface '0'.");
387 return m_qListBemSurface[idx];
394 this->m_qListBemSurface.append(surf);
402 this->m_qListBemSurface.append(*surf);
411 QList<MatrixXf> vertList;
412 for (
int i=0; i<this->m_qListBemSurface.size(); i++)
414 vertList.append(this->m_qListBemSurface[i].rr);
419 for (
int i=0; i<this->m_qListBemSurface.size(); i++)
421 this->m_qListBemSurface[i].rr = vertList.at(i);
431 for (
int i=0; i<this->m_qListBemSurface.size(); i++)
433 vert = this->m_qListBemSurface[i].rr;
435 this->m_qListBemSurface[i].rr = vert;
445 for (
int i=0; i<this->m_qListBemSurface.size(); i++)
447 vert = this->m_qListBemSurface[i].rr;
449 this->m_qListBemSurface[i].rr = vert;
Reader and in-memory representation of a FreeSurfer/MNE surface label (.label).
Boundary element model bundle (inner skull, outer skull, outer skin) loaded from -bem....
#define FIFF_MNE_COORD_FRAME
#define FIFF_MNE_SOURCE_SPACE_NORMALS
#define FIFF_MNE_SOURCE_SPACE_TRIANGLES
#define FIFFV_BEM_SURF_ID_UNKNOWN
#define FIFF_BEM_SURF_NNODE
#define FIFF_BEM_SURF_NODES
#define FIFF_BEM_SURF_TRIANGLES
#define FIFF_BEM_COORD_FRAME
#define FIFF_BEM_SURF_NTRI
#define FIFF_BEM_SURF_NORMALS
Thin-plate-spline 3-D warp from landmark correspondences.
Core MNE data structures (source spaces, source estimates, hemispheres).
FreeSurfer surface, annotation and parcellation I/O for mne-cpp.
FIFF file I/O, in-memory data structures and high-level readers/writers.
Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).
Labelled 4x4 FIFF affine: source frame, destination frame, rotation, translation and cached inverse.
Eigen::MatrixX3f apply_inverse_trans(const Eigen::MatrixX3f &rr, bool do_move=true) const
Eigen::MatrixX3f apply_trans(const Eigen::MatrixX3f &rr, bool do_move=true) const
QSharedPointer< FiffDirNode > SPtr
FIFF tag-stream reader/writer: wraps a QIODevice and exposes typed read_* / write_* methods for every...
fiff_long_t start_block(fiff_int_t kind)
QSharedPointer< FiffStream > SPtr
static FiffStream::SPtr start_file(QIODevice &p_IODevice)
fiff_long_t end_block(fiff_int_t kind, fiff_int_t next=FIFFV_NEXT_SEQ)
std::unique_ptr< FiffTag > UPtr
Thin-plate-spline 3-D warp fitted from landmark correspondences.
Eigen::MatrixXf calculate(const Eigen::MatrixXf &sLm, const Eigen::MatrixXf &dLm, const Eigen::MatrixXf &sVert)
void invtransform(const FIFFLIB::FiffCoordTrans &trans)
void transform(const FIFFLIB::FiffCoordTrans &trans)
static bool readBemSurface(FIFFLIB::FiffStream::SPtr &p_pStream, const FIFFLIB::FiffDirNode::SPtr &p_Tree, MNEBemSurface &p_BemSurface)
void writeToStream(FIFFLIB::FiffStream *p_pStream)
void warp(const Eigen::MatrixXf &sLm, const Eigen::MatrixXf &dLm)
void write(QIODevice &p_IODevice)
static bool readFromStream(FIFFLIB::FiffStream::SPtr &p_pStream, bool add_geom, MNEBem &p_Bem)
const MNEBemSurface & operator[](qint32 idx) const
MNEBem & operator<<(const MNEBemSurface &surf)
BEM surface provides geometry information.