Beispiel #1
0
void LayerFCD::MakeAllLayers()
{
  if (true)
  {
    LayerMRI* mri = m_mri_norm;
    if (m_layerSource)
    {
      mri->SetRefVolume(m_layerSource->GetSourceVolume());
    }
    mri->SetName(GetName() + "_norm");
    mri->SetFileName(m_fcd->mri_norm->fname);
    if ( mri->CreateFromMRIData((void*)m_fcd->mri_norm) )
    {
      if (!m_layerSource)
      {
        m_layerSource = mri;
        InitializeData();
      }
    }
    else
    {
      cerr << "Failed to create norm layer" << endl;
      delete mri;
      m_mri_norm = NULL;
    }
  }

  if (m_fcd->mri_flair)
  {
    LayerMRI* mri = m_mri_flair;
    if (m_layerSource)
    {
      mri->SetRefVolume(m_layerSource->GetSourceVolume());
    }
    mri->SetName(GetName() + "_flair");
    mri->SetFileName(m_fcd->mri_flair->fname);
    if ( !mri->CreateFromMRIData((void*)m_fcd->mri_flair) )
    {
      delete m_mri_flair;
      m_mri_flair = NULL;
    }
  }
  else
  {
    delete m_mri_flair;
    m_mri_flair = NULL;
  }

  if (m_fcd->mri_t2)
  {
    LayerMRI* mri = m_mri_t2;
    if (m_layerSource)
    {
      mri->SetRefVolume(m_layerSource->GetSourceVolume());
    }
    mri->SetName(GetName() + "_t2");
    mri->SetFileName(m_fcd->mri_t2->fname);
    if ( !mri->CreateFromMRIData((void*)m_fcd->mri_t2) )
    {
      delete m_mri_t2;
      m_mri_t2 = NULL;
    }
  }
  else
  {
    delete m_mri_t2;
    m_mri_t2 = NULL;
  }

  if (m_fcd->mri_aseg)
  {
    LayerMRI* mri = m_mri_aseg;
    if (m_layerSource)
    {
      mri->SetRefVolume(m_layerSource->GetSourceVolume());
    }
    mri->SetName(GetName() + "_aseg");
    mri->SetFileName(m_fcd->mri_aseg->fname);
    if ( mri->CreateFromMRIData((void*)m_fcd->mri_aseg) )
    {
      mri->GetProperty()->SetColorMap(LayerPropertyMRI::LUT);
      mri->SetVisible(false);
    }
    else
    {
      delete m_mri_aseg;
      m_mri_aseg = NULL;
    }
  }
  else
  {
    delete m_mri_aseg;
    m_mri_aseg = NULL;
  }

  if (m_fcd->mri_thickness_difference)
  {
    LayerMRI* mri = m_mri_difference;
    if (m_layerSource)
    {
      mri->SetRefVolume(m_layerSource->GetSourceVolume());
    }
    mri->SetName(GetName() + "_thickness_difference");
//    mri->SetFileName(m_fcd->mri_thickness_increase->fname);
    if ( mri->CreateFromMRIData((void*)m_fcd->mri_thickness_difference) )
    {
      mri->GetProperty()->SetColorMap(LayerPropertyMRI::Heat);
    }
    else
    {
      delete m_mri_difference;
      m_mri_difference = NULL;
    }
  }
  else
  {
    delete m_mri_difference;
    m_mri_difference = NULL;
  }

  if (m_fcd->mris_lh)
  {
    LayerSurface* surf = m_surf_lh;
    if (m_layerSource)
    {
      surf->SetRefVolume(m_layerSource);
    }
    surf->SetName(GetName() + "_lh");
    if (!surf->CreateFromMRIS((void*)m_fcd->mris_lh))
    {
      delete m_surf_lh;
      m_surf_lh = NULL;
    }
  }
  else
  {
    delete m_surf_lh;
    m_surf_lh = NULL;
  }

  if (m_fcd->mris_lh_pial)
  {
    LayerSurface* surf = m_surf_lh_pial;
    if (m_layerSource)
    {
      surf->SetRefVolume(m_layerSource);
    }
    surf->SetName(GetName() + "_lh.pial");
    if (!surf->CreateFromMRIS((void*)m_fcd->mris_lh_pial))
    {
      delete m_surf_lh_pial;
      m_surf_lh_pial = NULL;
    }
    else
    {
      surf->GetProperty()->SetEdgeColor(Qt::green);
    }
  }
  else
  {
    delete m_surf_lh_pial;
    m_surf_lh_pial = NULL;
  }

  if (m_fcd->mris_lh_sphere_d1)
  {
    LayerSurface* surf = m_surf_lh_sphere_d1;
    if (m_layerSource)
    {
      surf->SetRefVolume(m_layerSource);
    }
    surf->SetName(GetName() + "_lh.sphere.d1");
    if (!surf->CreateFromMRIS((void*)m_fcd->mris_lh_sphere_d1))
    {
      delete m_surf_lh_sphere_d1;
      m_surf_lh_sphere_d1 = NULL;
    }
    else
    {
      surf->GetProperty()->SetEdgeColor(Qt::red);
      surf->SetVisible(false);
    }
  }
  else
  {
    delete m_surf_lh_sphere_d1;
    m_surf_lh_sphere_d1 = NULL;
  }

  if (m_fcd->mris_rh)
  {
    LayerSurface* surf = m_surf_rh;
    if (m_layerSource)
    {
      surf->SetRefVolume(m_layerSource);
    }
    surf->SetName(GetName() + "_rh");
    if (!surf->CreateFromMRIS((void*)m_fcd->mris_rh))
    {
      delete m_surf_rh;
      m_surf_rh = NULL;
    }
  }
  else
  {
    delete m_surf_rh;
    m_surf_rh = NULL;
  }

  if (m_fcd->mris_rh_pial)
  {
    LayerSurface* surf = m_surf_rh_pial;
    if (m_layerSource)
    {
      surf->SetRefVolume(m_layerSource);
    }
    surf->SetName(GetName() + "_rh.pial");
    if (!surf->CreateFromMRIS((void*)m_fcd->mris_rh_pial))
    {
      delete m_surf_rh_pial;
      m_surf_rh_pial = NULL;
    }
    else
    {
      surf->GetProperty()->SetEdgeColor(Qt::green);
    }
  }
  else
  {
    delete m_surf_rh_pial;
    m_surf_rh_pial = NULL;
  }

  if (m_fcd->mris_rh_sphere_d1)
  {
    LayerSurface* surf = m_surf_rh_sphere_d1;
    if (m_layerSource)
    {
      surf->SetRefVolume(m_layerSource);
    }
    surf->SetName(GetName() + "_rh.sphere.d1");
    if (!surf->CreateFromMRIS((void*)m_fcd->mris_rh_sphere_d1))
    {
      delete m_surf_rh_sphere_d1;
      m_surf_rh_sphere_d1 = NULL;
    }
    else
    {
      surf->GetProperty()->SetEdgeColor(Qt::red);
      surf->SetVisible(false);
    }
  }
  else
  {
    delete m_surf_rh_sphere_d1;
    m_surf_rh_sphere_d1 = NULL;
  }
}
Beispiel #2
0
void InfoTreeWidget::UpdateAll()
{
  this->clear();
  m_editor->hide();
  LayerCollection* lc_mri = MainWindow::GetMainWindow()->GetLayerCollection( "MRI" );
  LayerCollection* lc_surf = MainWindow::GetMainWindow()->GetLayerCollection( "Surface" );

  if ( lc_mri->IsEmpty() && lc_surf->IsEmpty())
  {
    return;
  }

  QTreeWidgetItem* item = new QTreeWidgetItem(this);
  item->setText(0, "RAS");

  double ras[3] = {m_dRAS[0], m_dRAS[1], m_dRAS[2]};
  if (!lc_mri->IsEmpty())
  {
    qobject_cast<LayerMRI*>(lc_mri->GetLayer(0))->RemapPositionToRealRAS(m_dRAS, ras);
  }
  QVariantMap map;
  item->setText(1, QString("%1, %2, %3")
                .arg(ras[0], 0, 'f', 2)
                .arg(ras[1], 0, 'f', 2)
                .arg(ras[2], 0, 'f', 2));
  map["Type"] = "RAS";
  map["EditableText"] = item->text(1);
  item->setData(1, Qt::UserRole, map);

  for (int i = 0; i < lc_mri->GetNumberOfLayers(); i++)
  {
    LayerMRI* layer = (LayerMRI*)lc_mri->GetLayer(i);
    int nIndex[3];
    if ( layer->GetProperty()->GetShowInfo() )
    {
      QTreeWidgetItem* item = new QTreeWidgetItem(this);
      item->setText(0, layer->GetName());
      layer->RASToOriginalIndex( ras, nIndex );
      double dvalue = layer->GetVoxelValue( m_dRAS );
      QString editable = QString("%1, %2, %3").arg(nIndex[0]).arg(nIndex[1]).arg(nIndex[2]);
      QString strg = QString("%1 \t[%2]").arg(dvalue).arg(editable);
      QString labelStrg;
      if (layer->IsTypeOf("PLabel"))
      {
        labelStrg = ((LayerPLabel*)layer)->GetLabelName(m_dRAS);
      }
      else
      {
        labelStrg = layer->GetLabelName( dvalue );
      }
      if (!labelStrg.isEmpty())
      {
        strg += "  " + labelStrg;
      }
      item->setText(1, strg);
      map.clear();
      map["Type"] = "MRI";
      map["EditableText"] = editable;
      map["Object"] = QVariant::fromValue((QObject*)layer);
      item->setData(1, Qt::UserRole, map);
    }
  }

  for (int i = 0; i < lc_surf->GetNumberOfLayers(); i++)
  {
    LayerSurface* surf = (LayerSurface*)lc_surf->GetLayer(i);
    if ( surf->GetProperty()->GetShowInfo() )
    {
      QTreeWidgetItem* item = new QTreeWidgetItem(this);
      item->setText(0, surf->GetName());
      double sf_pos[3];
      surf->GetSurfaceRASAtTarget( m_dRAS, sf_pos );
      QString editable = QString("%1, %2, %3")
                         .arg(sf_pos[0], 0, 'f', 2)
                         .arg(sf_pos[1], 0, 'f', 2)
                         .arg(sf_pos[2], 0, 'f', 2);
      item->setText(1, QString("SurfaceRAS\t[%1]").arg(editable));
      map.clear();
      map["Type"] = "SurfaceRAS";
      map["EditableText"] = editable;
      map["Object"] = QVariant::fromValue((QObject*)surf);
      item->setData(1, Qt::UserRole, map);

      int nVertex = surf->GetVertexIndexAtTarget( m_dRAS, NULL );
      if ( nVertex >= 0 )
      {
        surf->GetSurfaceRASAtVertex( nVertex, sf_pos );
        QTreeWidgetItem* item = new QTreeWidgetItem(this);
        item->setText(1, QString("Vertex \t%1  [%2, %3, %4]")
                      .arg(nVertex)
                      .arg(sf_pos[0], 0, 'f', 2)
                      .arg(sf_pos[1], 0, 'f', 2)
                      .arg(sf_pos[2], 0, 'f', 2));
        map.clear();
        map["Type"] = "SurfaceVertex";
        map["EditableText"] = QString::number(nVertex);
        map["Object"] = QVariant::fromValue((QObject*)surf);
        item->setData(1, Qt::UserRole, map);

        double vec[3];
        surf->GetNormalAtVertex( nVertex, vec );
        item = new QTreeWidgetItem(this);
        item->setText(1, QString("Normal \t[%1, %2, %3]")
                      .arg(vec[0], 0, 'f', 2)
                      .arg(vec[1], 0, 'f', 2)
                      .arg(vec[2], 0, 'f', 2));

        if ( surf->GetActiveVector() >= 0 )
        {
          surf->GetVectorAtVertex( nVertex, vec );
          item = new QTreeWidgetItem(this);
          item->setText(1, QString("Vector \t[%1, %2, %3]")
                        .arg(vec[0], 0, 'f', 2)
                        .arg(vec[1], 0, 'f', 2)
                        .arg(vec[2], 0, 'f', 2));
        }

        if ( surf->HasCurvature() )
        {
          item = new QTreeWidgetItem(this);
          item->setText(1, QString("Curvature \t%1").arg(surf->GetCurvatureValue(nVertex)));
        }


        int nOverlays = surf->GetNumberOfOverlays();
        for ( int i = 0; i < nOverlays; i++ )
        {
          SurfaceOverlay* overlay = surf->GetOverlay( i );
          item = new QTreeWidgetItem(this);
          item->setText(1, QString("%1 \t%2").arg(overlay->GetName()).arg(overlay->GetDataAtVertex( nVertex )));
        }

        int nAnnotations = surf->GetNumberOfAnnotations();
        for ( int i = 0; i < nAnnotations; i++ )
        {
          SurfaceAnnotation* annot = surf->GetAnnotation( i );
          item = new QTreeWidgetItem(this);
          item->setText(1, QString("%1 \t%2").arg(annot->GetName()).arg(annot->GetAnnotationNameAtVertex( nVertex )));
        }
      }
    }
  }
}