bool BrainRTConnectivityDataTreeItem::init(const MNEForwardSolution& tForwardSolution, int iHemi)
{   
    //Set hemisphere information as item's data
    this->setData(iHemi, BrainRTConnectivityDataTreeItemRoles::RTHemi);

    //Set data based on clusterd or full source space
    bool isClustered = tForwardSolution.src[iHemi].isClustered();

    QVariant data;

    //Add meta information as item children
    QString sIsClustered = isClustered ? "Clustered" : "Full";
    BrainTreeMetaItem* pItemSourceSpaceType = new BrainTreeMetaItem(BrainTreeMetaItemTypes::RTDataSourceSpaceType, sIsClustered);
    pItemSourceSpaceType->setEditable(false);
    *this<<pItemSourceSpaceType;
    data.setValue(sIsClustered);
    pItemSourceSpaceType->setData(data, BrainTreeMetaItemRoles::RTDataSourceSpaceType);

    m_bIsInit = true;

    return true;
}
bool BrainAnnotationTreeItem::addData(const Surface& tSurface, const Annotation& tAnnotation)
{
    //Create color from annotation data if annotation is not empty
    if(!tAnnotation.isEmpty()) {
        QByteArray arrayColorsAnnot;
        arrayColorsAnnot.resize(tAnnotation.getVertices().rows() * 3 * (int)sizeof(float));
        float *rawArrayColors = reinterpret_cast<float *>(arrayColorsAnnot.data());

        QList<FSLIB::Label> qListLabels;
        QList<RowVector4i> qListLabelRGBAs;

        tAnnotation.toLabels(tSurface, qListLabels, qListLabelRGBAs);

        for(int i = 0; i<qListLabels.size(); i++) {
            FSLIB::Label label = qListLabels.at(i);
            for(int j = 0; j<label.vertices.rows(); j++) {
                rawArrayColors[label.vertices(j)*3+0] = qListLabelRGBAs.at(i)(0)/255.0;
                rawArrayColors[label.vertices(j)*3+1] = qListLabelRGBAs.at(i)(1)/255.0;
                rawArrayColors[label.vertices(j)*3+2] = qListLabelRGBAs.at(i)(2)/255.0;
            }
        }

        //Add data which is held by this BrainAnnotationTreeItem
        QVariant data;
        data.setValue(arrayColorsAnnot);
        this->setData(data, BrainAnnotationTreeItemRoles::AnnotColors);

        data.setValue(qListLabels);
        this->setData(data, BrainAnnotationTreeItemRoles::LabeList);

        data.setValue(tAnnotation.getLabelIds());
        this->setData(data, BrainAnnotationTreeItemRoles::LabeIds);

        //Add annotation meta information as item children
        BrainTreeMetaItem *itemAnnotFileName = new BrainTreeMetaItem(BrainTreeMetaItemTypes::AnnotFileName, tAnnotation.fileName());
        itemAnnotFileName->setEditable(false);
        *this<<itemAnnotFileName;
        data.setValue(tAnnotation.fileName());
        itemAnnotFileName->setData(data, BrainAnnotationTreeItemRoles::AnnotFileName);

        BrainTreeMetaItem *itemAnnotPath = new BrainTreeMetaItem(BrainTreeMetaItemTypes::AnnotFilePath, tAnnotation.filePath());
        itemAnnotPath->setEditable(false);
        *this<<itemAnnotPath;
        data.setValue(tAnnotation.filePath());
        itemAnnotFileName->setData(data, BrainAnnotationTreeItemRoles::AnnotFilePath);
    }

    return true;
}
Example #3
0
bool BrainSurfaceTreeItem::addData(const Surface& tSurface, Qt3DCore::QEntity* parent)
{
    //Create renderable 3D entity
    m_pParentEntity = parent;
    m_pRenderable3DEntity = new Renderable3DEntity(parent);
    m_pRenderable3DEntityActivationOverlay = new Renderable3DEntity(parent);

    QMatrix4x4 m;
    Qt3DCore::QTransform* transform =  new Qt3DCore::QTransform();
    m.rotate(180, QVector3D(0.0f, 1.0f, 0.0f));
    m.rotate(-90, QVector3D(1.0f, 0.0f, 0.0f));
    transform->setMatrix(m);
    m_pRenderable3DEntity->addComponent(transform);
    m_pRenderable3DEntityActivationOverlay->addComponent(transform);

    //Create color from curvature information with default gyri and sulcus colors
    QByteArray arrayCurvatureColor = createCurvatureVertColor(tSurface.curv());

    //Set renderable 3D entity mesh and color data
    m_pRenderable3DEntity->setMeshData(tSurface.rr(), tSurface.nn(), tSurface.tris(), -tSurface.offset(), arrayCurvatureColor);

    //Generate activation overlay surface
//    MatrixX3f overlayAdds = tSurface.rr();
//    for(int i = 0; i<tSurface.nn().rows(); i++) {
//        RowVector3f direction = tSurface.nn().row(i);
//        direction.normalize();

//        overlayAdds.row(i) = direction*0.0001;
//    }

//    m_pRenderable3DEntityActivationOverlay->setMeshData(tSurface.rr()+overlayAdds, tSurface.nn(), tSurface.tris(), -tSurface.offset(), matCurvatureColor);

    //Add data which is held by this BrainSurfaceTreeItem
    QVariant data;

    data.setValue(arrayCurvatureColor);
    this->setData(data, BrainSurfaceTreeItemRoles::SurfaceCurrentColorVert);
    this->setData(data, BrainSurfaceTreeItemRoles::SurfaceCurvatureColorVert);

    data.setValue(tSurface.rr());
    this->setData(data, BrainSurfaceTreeItemRoles::SurfaceVert);

    data.setValue(tSurface.tris());
    this->setData(data, BrainSurfaceTreeItemRoles::SurfaceTris);

    data.setValue(tSurface.nn());
    this->setData(data, BrainSurfaceTreeItemRoles::SurfaceNorm);

    data.setValue(tSurface.curv());
    this->setData(data, BrainSurfaceTreeItemRoles::SurfaceCurv);

    data.setValue(tSurface.offset());
    this->setData(data, BrainSurfaceTreeItemRoles::SurfaceOffset);

    data.setValue(m_pRenderable3DEntity);
    this->setData(data, BrainSurfaceTreeItemRoles::SurfaceRenderable3DEntity);

    data.setValue(m_pRenderable3DEntityActivationOverlay);
    this->setData(data, BrainSurfaceTreeItemRoles::SurfaceRenderable3DEntityAcivationOverlay);

    //Add surface meta information as item children
    m_pItemSurfColorInfoOrigin = new BrainTreeMetaItem(BrainTreeMetaItemTypes::SurfaceColorInfoOrigin, "Color from curvature");
    connect(m_pItemSurfColorInfoOrigin, &BrainTreeMetaItem::colorInfoOriginChanged,
            this, &BrainSurfaceTreeItem::onColorInfoOriginOrCurvColorChanged);
    *this<<m_pItemSurfColorInfoOrigin;
    data.setValue(QString("Color from curvature"));
    m_pItemSurfColorInfoOrigin->setData(data, BrainTreeMetaItemRoles::SurfaceColorInfoOrigin);

    m_pItemSurfColSulci = new BrainTreeMetaItem(BrainTreeMetaItemTypes::SurfaceColorSulci, "Sulci color");
    connect(m_pItemSurfColSulci, &BrainTreeMetaItem::curvColorsChanged,
            this, &BrainSurfaceTreeItem::onColorInfoOriginOrCurvColorChanged);
    *this<<m_pItemSurfColSulci;
    data.setValue(QColor(50,50,50));
    m_pItemSurfColSulci->setData(data, BrainTreeMetaItemRoles::SurfaceColorSulci);
    m_pItemSurfColSulci->setData(data, Qt::DecorationRole);

    m_pItemSurfColGyri = new BrainTreeMetaItem(BrainTreeMetaItemTypes::SurfaceColorGyri, "Gyri color");
    connect(m_pItemSurfColGyri, &BrainTreeMetaItem::curvColorsChanged,
            this, &BrainSurfaceTreeItem::onColorInfoOriginOrCurvColorChanged);
    *this<<m_pItemSurfColGyri;
    data.setValue(QColor(125,125,125));
    m_pItemSurfColGyri->setData(data, BrainTreeMetaItemRoles::SurfaceColorGyri);
    m_pItemSurfColGyri->setData(data, Qt::DecorationRole);

    BrainTreeMetaItem *itemSurfFileName = new BrainTreeMetaItem(BrainTreeMetaItemTypes::SurfaceFileName, tSurface.fileName());
    itemSurfFileName->setEditable(false);
    *this<<itemSurfFileName;
    data.setValue(tSurface.fileName());
    itemSurfFileName->setData(data, BrainTreeMetaItemRoles::SurfaceFileName);

    BrainTreeMetaItem *itemSurfType = new BrainTreeMetaItem(BrainTreeMetaItemTypes::SurfaceType, tSurface.surf());
    itemSurfType->setEditable(false);
    *this<<itemSurfType;
    data.setValue(tSurface.surf());
    itemSurfType->setData(data, BrainTreeMetaItemRoles::SurfaceType);

    BrainTreeMetaItem *itemSurfPath = new BrainTreeMetaItem(BrainTreeMetaItemTypes::SurfaceFilePath, tSurface.filePath());
    itemSurfPath->setEditable(false);
    *this<<itemSurfPath;
    data.setValue(tSurface.filePath());
    itemSurfPath->setData(data, BrainTreeMetaItemRoles::SurfaceFilePath);

    return true;
}