169 QSharedPointer<QDataStream> t_pStream(
new QDataStream(&p_IODevice));
171 t_pStream->setFloatingPointPrecision(QDataStream::SinglePrecision);
172 t_pStream->setByteOrder(QDataStream::BigEndian);
173 t_pStream->setVersion(QDataStream::Qt_5_0);
175 if(!t_pStream->device()->open(QIODevice::ReadOnly))
178 QFile* t_pFile = qobject_cast<QFile*>(&p_IODevice);
180 qInfo(
"Reading source estimate from %s...", t_pFile->fileName().toUtf8().constData());
182 qInfo(
"Reading source estimate...");
185 *t_pStream >> p_stc.
tmin;
188 *t_pStream >> p_stc.
tstep;
192 *t_pStream >> t_nVertices;
193 p_stc.
vertices = VectorXi(t_nVertices);
195 for(quint32 i = 0; i < t_nVertices; ++i)
199 *t_pStream >> t_nTimePts;
203 p_stc.
data = MatrixXd(t_nVertices, t_nTimePts);
204 for(qint32 i = 0; i < p_stc.
data.array().size(); ++i)
208 p_stc.
data.array()(i) = value;
212 p_stc.update_times();
215 t_pStream->device()->close();
227 QSharedPointer<QDataStream> t_pStream(
new QDataStream(&p_IODevice));
229 t_pStream->setFloatingPointPrecision(QDataStream::SinglePrecision);
230 t_pStream->setByteOrder(QDataStream::BigEndian);
231 t_pStream->setVersion(QDataStream::Qt_5_0);
233 if(!t_pStream->device()->open(QIODevice::WriteOnly))
235 qWarning(
"Failed to write source estimate!");
239 QFile* t_pFile = qobject_cast<QFile*>(&p_IODevice);
241 qInfo(
"Write source estimate to %s...", t_pFile->fileName().toUtf8().constData());
243 qInfo(
"Write source estimate...");
246 *t_pStream << static_cast<float>(1000*this->
tmin);
248 *t_pStream << static_cast<float>(1000*this->
tstep);
250 *t_pStream << static_cast<quint32>(this->
vertices.size());
252 for(qint32 i = 0; i < this->
vertices.size(); ++i)
253 *t_pStream <<
static_cast<quint32
>(this->
vertices[i]);
255 *t_pStream << static_cast<quint32>(this->
data.cols());
259 for(qint32 i = 0; i < this->
data.array().size(); ++i)
260 *t_pStream <<
static_cast<float>(this->
data.array()(i));
263 t_pStream->device()->close();
318 VectorXi vIndexSourceLabels;
320 if(lPickedLabels.isEmpty()) {
321 qWarning() <<
"InvSourceEstimate::getIndicesByLabel - picked label list is empty. Returning.";
322 return vIndexSourceLabels;
326 for(
int i = 0; i < this->
vertices.rows(); i++) {
327 for(
int k = 0; k < lPickedLabels.size(); k++) {
328 if(this->
vertices(i) == lPickedLabels.at(k).label_id) {
329 vIndexSourceLabels.conservativeResize(vIndexSourceLabels.rows()+1,1);
330 vIndexSourceLabels(vIndexSourceLabels.rows()-1) = i;
338 for(
int i = 0; i < this->
vertices.rows(); i++) {
346 for(
int k = 0; k < lPickedLabels.size(); k++) {
347 for(
int l = 0; l < lPickedLabels.at(k).
vertices.rows(); l++) {
348 if(this->
vertices(i) == lPickedLabels.at(k).vertices(l) && lPickedLabels.at(k).hemi == hemi) {
349 vIndexSourceLabels.conservativeResize(vIndexSourceLabels.rows()+1,1);
350 vIndexSourceLabels(vIndexSourceLabels.rows()-1) = i;
358 return vIndexSourceLabels;