75: m_qListBemSurface(p_MNEBem.m_qListBemSurface)
89 throw std::runtime_error(
"Could not read the bem surfaces\n");
107 m_qListBemSurface.clear();
117 bool open_here =
false;
120 if (!p_pStream->device()->isOpen())
122 QString t_sFileName = p_pStream->streamName();
124 t_file.setFileName(t_sFileName);
126 if(!p_pStream->open())
139 QList<FiffDirNode::SPtr> bem = p_pStream->dirtree()->dir_tree_find(
FIFFB_BEM);
142 qCritical() <<
"No BEM block found!";
150 QList<FiffDirNode::SPtr> bemsurf = p_pStream->dirtree()->dir_tree_find(
FIFFB_BEM_SURF);
151 if(bemsurf.isEmpty())
153 qCritical() <<
"No BEM surfaces found!";
161 for(
int k = 0; k < bemsurf.size(); ++k)
164 qInfo(
"\tReading a BEM surface...");
171 qInfo(
"\t[done]\n" );
173 p_Bem.m_qListBemSurface.append(p_BemSurface);
177 qInfo(
"\t%lld bem surfaces read\n", bemsurf.size());
190 p_BemSurface.
clear();
201 p_BemSurface.
id = *t_pTag->toInt();
209 p_BemSurface.
sigma = 1.0;
213 p_BemSurface.
sigma = *t_pTag->toFloat();
222 qWarning() <<
"np not found!";
227 p_BemSurface.
np = *t_pTag->toInt();
236 qWarning() <<
"ntri not found!";
241 p_BemSurface.
ntri = *t_pTag->toInt();
249 qWarning() <<
"FIFF_MNE_COORD_FRAME not found, trying FIFF_BEM_COORD_FRAME.";
253 throw std::runtime_error(
"Coordinate frame information not found.");
275 throw std::runtime_error(
"Vertex data not found.");
278 p_BemSurface.
rr = t_pTag->toFloatMatrix().transpose();
279 qint32 rows_rr = p_BemSurface.
rr.rows();
281 if (rows_rr != p_BemSurface.
np)
284 throw std::runtime_error(
"Vertex information is incorrect.");
295 throw std::runtime_error(
"Vertex normals not found.");
298 p_BemSurface.
nn = t_pTag->toFloatMatrix().transpose();
302 p_BemSurface.
nn = t_pTag->toFloatMatrix().transpose();
305 if (p_BemSurface.
nn.rows() != p_BemSurface.
np)
308 throw std::runtime_error(
"Vertex normal information is incorrect.");
314 if (p_BemSurface.
ntri > 0)
321 throw std::runtime_error(
"Triangulation not found.");
325 p_BemSurface.
itris = t_pTag->toIntMatrix().transpose();
326 p_BemSurface.
itris -= MatrixXi::Constant(p_BemSurface.
itris.rows(),3,1);
331 p_BemSurface.
itris = t_pTag->toIntMatrix().transpose();
332 p_BemSurface.
itris -= MatrixXi::Constant(p_BemSurface.
itris.rows(),3,1);
335 if (p_BemSurface.
itris.rows() != p_BemSurface.
ntri)
338 throw std::runtime_error(
"Triangulation information is incorrect.");
343 p_BemSurface.
itris.resize(0, 3);
359 qInfo(
"Write BEM surface in %s...\n", t_pStream->streamName().toUtf8().constData());
361 t_pStream->end_file();
369 for(qint32 h = 0; h < m_qListBemSurface.size(); ++h)
371 qInfo(
"\tWrite a bem surface... ");
373 m_qListBemSurface[h].writeToStream(p_pStream);
377 qInfo(
"\t%lld bem surfaces written\n", m_qListBemSurface.size());
385 if (idx>=m_qListBemSurface.length())
387 qWarning(
"Warning: Required surface doesn't exist! Returning surface '0'.");
390 return m_qListBemSurface[idx];
397 if (idx >= m_qListBemSurface.length())
399 qWarning(
"Warning: Required surface doesn't exist! Returning surface '0'.");
402 return m_qListBemSurface[idx];
409 this->m_qListBemSurface.append(surf);
417 this->m_qListBemSurface.append(*surf);
426 QList<MatrixXf> vertList;
427 for (
int i=0; i<this->m_qListBemSurface.size(); i++)
429 vertList.append(this->m_qListBemSurface[i].rr);
434 for (
int i=0; i<this->m_qListBemSurface.size(); i++)
436 this->m_qListBemSurface[i].rr = vertList.at(i);
446 for (
int i=0; i<this->m_qListBemSurface.size(); i++)
448 vert = this->m_qListBemSurface[i].rr;
450 this->m_qListBemSurface[i].rr = vert;
460 for (
int i=0; i<this->m_qListBemSurface.size(); i++)
462 vert = this->m_qListBemSurface[i].rr;
464 this->m_qListBemSurface[i].rr = vert;
#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
#define FIFF_MNE_COORD_FRAME
#define FIFF_MNE_SOURCE_SPACE_NORMALS
#define FIFF_MNE_SOURCE_SPACE_TRIANGLES
FsLabel class declaration.
MNEBem class declaration.
Core MNE data structures (source spaces, source estimates, hemispheres).
FreeSurfer surface and annotation I/O.
FIFF file I/O and data structures (raw, epochs, evoked, covariance, forward).
Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).
Coordinate transformation description.
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_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
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.