void BabyMEGHPIDgl::setDigitizerDataToView3D(const FiffDigPointSet& digPointSet, const QVector<double>& vGof, bool bSortOutAdditionalDigitizer)
{
    if(bSortOutAdditionalDigitizer) {
        FiffDigPointSet t_digSetWithoutAdditional;

        for(int i = 0; i < digPointSet.size(); ++i) {
            switch(digPointSet[i].kind)
            {
                case FIFFV_POINT_HPI:
                    t_digSetWithoutAdditional << digPointSet[i];
                    break;

                case FIFFV_POINT_CARDINAL:
                    t_digSetWithoutAdditional << digPointSet[i];
                    break;

                case FIFFV_POINT_EEG:
                    t_digSetWithoutAdditional << digPointSet[i];
                    break;
            }
        }

        m_pData3DModel->addDigitizerData("Head", "Digitizer", t_digSetWithoutAdditional);

        //Update gof labels and transform from m to mm
        QString sGof("0mm");
        if(vGof.size() > 0) {
            sGof = QString("%1mm").arg(1000*vGof[0]);
            ui->m_label_gofCoil1->setText(sGof);
        }

        if(vGof.size() > 1) {
            sGof = QString("%1mm").arg(1000*vGof[1]);
            ui->m_label_gofCoil2->setText(sGof);
        }

        if(vGof.size() > 2) {
            sGof = QString("%1mm").arg(1000*vGof[2]);
            ui->m_label_gofCoil3->setText(sGof);
        }

        if(vGof.size() > 3) {
            sGof = QString("%1mm").arg(1000*vGof[3]);
            ui->m_label_gofCoil4->setText(sGof);
        }
    } else {
        m_pData3DModel->addDigitizerData("Head", "Digitizer", digPointSet);
    }
}
bool FiffDigPointSet::readFromStream(FiffStream::SPtr &p_pStream, FiffDigPointSet &p_Dig)
{
    //
    //   Open the file, create directory
    //
    bool open_here = false;

    if (!p_pStream->device()->isOpen()) {
        QString t_sFileName = p_pStream->streamName();

        if(!p_pStream->open())
            return false;

        printf("Opening header data %s...\n",t_sFileName.toUtf8().constData());

        open_here = true;
    }

    //
    //   Read the measurement info
    //
    //read_hpi_info(p_pStream,p_Tree, info);
    fiff_int_t kind = -1;
    fiff_int_t pos = -1;
    FiffTag::SPtr t_pTag;

    //
    //   Locate the Electrodes
    //
    QList<FiffDirNode::SPtr> isotrak = p_pStream->dirtree()->dir_tree_find(FIFFB_ISOTRAK);

    fiff_int_t coord_frame = FIFFV_COORD_HEAD;
    FiffCoordTrans dig_trans;
    qint32 k = 0;

    if (isotrak.size() == 1)
    {
        for (k = 0; k < isotrak[0]->nent(); ++k)
        {
            kind = isotrak[0]->dir[k]->kind;
            pos  = isotrak[0]->dir[k]->pos;
            if (kind == FIFF_DIG_POINT)
            {
                p_pStream->read_tag(t_pTag, pos);
                p_Dig.m_qListDigPoint.append(t_pTag->toDigPoint());
            }
            else
            {
                if (kind == FIFF_MNE_COORD_FRAME)
                {
                    p_pStream->read_tag(t_pTag, pos);
                    qDebug() << "NEEDS To BE DEBBUGED: FIFF_MNE_COORD_FRAME" << t_pTag->getType();
                    coord_frame = *t_pTag->toInt();
                }
                else if (kind == FIFF_COORD_TRANS)
                {
                    p_pStream->read_tag(t_pTag, pos);
                    qDebug() << "NEEDS To BE DEBBUGED: FIFF_COORD_TRANS" << t_pTag->getType();
                    dig_trans = t_pTag->toCoordTrans();
                }
            }
        }
    }
    for(k = 0; k < p_Dig.size(); ++k)
    {
        p_Dig[k].coord_frame = coord_frame;
    }

    //
    //   All kinds of auxliary stuff
    //
    if(open_here)
    {
        p_pStream->close();
    }
    return true;
}