60 using namespace UTILSLIB;
61 using namespace FSLIB;
62 using namespace MNELIB;
63 using namespace FIFFLIB;
64 using namespace Eigen;
76 MNEBem::MNEBem(
const MNEBem &p_MNEBem)
77 : m_qListBemSurface(p_MNEBem.m_qListBemSurface)
91 std::cout <<
"Could not read the bem surfaces\n";
109 m_qListBemSurface.clear();
119 bool open_here =
false;
122 if (!p_pStream->device()->isOpen())
124 QString t_sFileName = p_pStream->streamName();
126 t_file.setFileName(t_sFileName);
128 if(!p_pStream->open())
141 QList<FiffDirNode::SPtr> bem = p_pStream->dirtree()->dir_tree_find(
FIFFB_BEM);
144 qCritical() <<
"No BEM block found!";
152 QList<FiffDirNode::SPtr> bemsurf = p_pStream->dirtree()->dir_tree_find(
FIFFB_BEM_SURF);
153 if(bemsurf.isEmpty())
155 qCritical() <<
"No BEM surfaces found!";
163 for(
int k = 0;
k < bemsurf.size(); ++
k)
166 printf(
"\tReading a BEM surface...");
173 printf(
"\t[done]\n" );
175 p_Bem.m_qListBemSurface.append(p_BemSurface);
179 printf(
"\t%lld bem surfaces read\n", bemsurf.size());
192 p_BemSurface.
clear();
199 p_BemSurface.
id = FIFFV_BEM_SURF_ID_UNKNOWN;
203 p_BemSurface.
id = *t_pTag->toInt();
211 p_BemSurface.
sigma = 1.0;
215 p_BemSurface.
sigma = *t_pTag->toFloat();
224 std::cout <<
"np not found!";
229 p_BemSurface.
np = *t_pTag->toInt();
238 std::cout <<
"ntri not found!";
243 p_BemSurface.
ntri = *t_pTag->toInt();
251 qWarning() <<
"FIFF_MNE_COORD_FRAME not found, trying FIFF_BEM_COORD_FRAME.";
255 std::cout <<
"Coordinate frame information not found.";
278 std::cout <<
"Vertex data not found.";
282 p_BemSurface.
rr = t_pTag->toFloatMatrix().transpose();
283 qint32 rows_rr = p_BemSurface.
rr.rows();
285 if (rows_rr != p_BemSurface.
np)
288 std::cout <<
"Vertex information is incorrect.";
300 std::cout <<
"Vertex normals not found.";
304 p_BemSurface.
nn = t_pTag->toFloatMatrix().transpose();
308 p_BemSurface.
nn = t_pTag->toFloatMatrix().transpose();
311 if (p_BemSurface.
nn.rows() != p_BemSurface.
np)
314 std::cout <<
"Vertex normal information is incorrect.";
321 if (p_BemSurface.
ntri > 0)
328 std::cout <<
"Triangulation not found.";
333 p_BemSurface.
tris = t_pTag->toIntMatrix().transpose();
334 p_BemSurface.
tris -= MatrixXi::Constant(p_BemSurface.
tris.rows(),3,1);
339 p_BemSurface.
tris = t_pTag->toIntMatrix().transpose();
340 p_BemSurface.
tris -= MatrixXi::Constant(p_BemSurface.
tris.rows(),3,1);
343 if (p_BemSurface.
tris.rows() != p_BemSurface.
ntri)
346 std::cout <<
"Triangulation information is incorrect.";
352 MatrixXi p_defaultMatrix(0, 0);
353 p_BemSurface.
tris = p_defaultMatrix;
369 printf(
"Write BEM surface in %s...\n", t_pStream->streamName().toUtf8().constData());
371 t_pStream->end_file();
379 for(qint32 h = 0; h < m_qListBemSurface.size(); ++h)
381 printf(
"\tWrite a bem surface... ");
383 m_qListBemSurface[h].writeToStream(p_pStream);
387 printf(
"\t%lld bem surfaces written\n", m_qListBemSurface.size());
395 if (idx>=m_qListBemSurface.length())
397 qWarning(
"Warning: Required surface doesn't exist! Returning surface '0'.");
400 return m_qListBemSurface[idx];
407 if (idx >= m_qListBemSurface.length())
409 qWarning(
"Warning: Required surface doesn't exist! Returning surface '0'.");
412 return m_qListBemSurface[idx];
419 this->m_qListBemSurface.append(surf);
427 this->m_qListBemSurface.append(*surf);
436 QList<MatrixXf> vertList;
437 for (
int i=0; i<this->m_qListBemSurface.size(); i++)
439 vertList.append(this->m_qListBemSurface[i].rr);
444 for (
int i=0; i<this->m_qListBemSurface.size(); i++)
446 this->m_qListBemSurface[i].rr = vertList.at(i);
456 for (
int i=0; i<this->m_qListBemSurface.size(); i++)
458 vert = this->m_qListBemSurface[i].rr;
460 this->m_qListBemSurface[i].rr = vert;
470 for (
int i=0; i<this->m_qListBemSurface.size(); i++)
472 vert = this->m_qListBemSurface[i].rr;
474 this->m_qListBemSurface[i].rr = vert;