void WindowTimeCourse::UpdateData() { LayerMRI* layer = qobject_cast<LayerMRI*>(MainWindow::GetMainWindow()->GetActiveLayer("MRI")); if (layer && layer->GetNumberOfFrames() > 1) { double ras[3]; int n[3]; MainWindow::GetMainWindow()->GetLayerCollection("MRI")->GetSlicePosition(ras); layer->RemapPositionToRealRAS(ras, ras); layer->RASToOriginalIndex(ras, n); QList<double> data; for (int i = 0; i < layer->GetNumberOfFrames(); i++) data << layer->GetVoxelValueByOriginalIndex(n[0], n[1], n[2], i); FSVolume* vol = layer->GetSourceVolume(); ui->widgetPlot->SetTimeCourseData(data, vol->GetMinValue(), vol->GetMaxValue(), layer->GetTR()); ui->widgetPlot->SetCurrentFrame(layer->GetActiveFrame()); } }
void DialogRepositionSurface::UpdateIntensity() { LayerMRI* mri = (LayerMRI*)MainWindow::GetMainWindow()->GetTopVisibleLayer("MRI"); LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindow()->GetActiveLayer( "Surface" ); if (mri && surf) { double ras[3], surf_ras[3]; mri->GetSlicePosition(ras); surf->GetSurfaceRASAtTarget(ras, surf_ras); mri->RemapPositionToRealRAS(ras, ras); double val = mri->GetSampledVoxelValueByRAS(ras); if (val >= 0) { ui->lineEditTarget->setText(QString::number(val, 'f', 2)); OnCoordinateTypeChanged(); } ui->lineEditTargetX->setText(QString::number(surf_ras[0], 'f', 2)); ui->lineEditTargetY->setText(QString::number(surf_ras[1], 'f', 2)); ui->lineEditTargetZ->setText(QString::number(surf_ras[2], 'f', 2)); } }
void PixelInfoListCtrl::DoUpdateList() { Reset(); LayerCollection* lc_mri = MainWindow::GetMainWindowPointer()->GetLayerCollection( "MRI" ); LayerCollection* lc_surf = MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" ); if ( !lc_mri || !lc_surf ) { // collection does not exist. program must be in exiting process. return; } if ( lc_mri->IsEmpty() && lc_surf->IsEmpty() ) { SetItemCount( 0 ); return; } else AddItem( _("RAS"), _(""), 1, false ); if ( !lc_mri->IsEmpty() ) { LayerMRI* mri = ( LayerMRI* )lc_mri->GetLayer( 0 ); double ras[3]; mri->RemapPositionToRealRAS( m_dRASPosition, ras ); m_listValue[0].Printf( _("%.2f, %.2f, %.2f"), ras[0], ras[1], ras[2] ); int nIndex[3]; std::vector<Layer*> layers = lc_mri->GetLayers(); for ( size_t i = 0; i < layers.size(); i++ ) { if ( layers[i]->GetProperties()->GetShowInfo() ) { ((LayerMRI*)layers[i])->RASToOriginalIndex( ras, nIndex ); // double dvalue = ( (LayerMRI*)layers[i] )->GetVoxelValueByOriginalIndex( nIndex[0], nIndex[1], nIndex[2] ); double dvalue = ( (LayerMRI*)layers[i] )->GetVoxelValue( m_dRASPosition ); wxString coordStrg; if ( m_bShowVoxelCoordinates ) coordStrg.Printf( _("[%d, %d, %d] "), nIndex[0], nIndex[1], nIndex[2] ); wxString labelStrg; if (layers[i]->IsTypeOf("PLabel")) { labelStrg = wxString::FromAscii( ( (LayerPLabel*)layers[i] )->GetLabelName( m_dRASPosition ).c_str() ); } else { labelStrg = wxString::FromAscii( ( (LayerMRI*)layers[i] )->GetLabelName( dvalue ).c_str() ); if ( m_bShowShortName ) labelStrg = GetShortName( labelStrg ); } AddItem( wxString::FromAscii( layers[i]->GetName() ), AppendSpaceString( ( wxString() << dvalue ) ) + coordStrg + _(" ") + labelStrg, (long)layers[i], false ); } } } if ( !lc_surf->IsEmpty() ) { if ( lc_mri->IsEmpty() ) { double ras[3] = { m_dRASPosition[0], m_dRASPosition[1], m_dRASPosition[2] }; // mri->RemapPositionToRealRAS( m_dRASPosition, ras ); m_listValue[0].Printf( _("%.2f, %.2f, %.2f"), ras[0], ras[1], ras[2] ); } std::vector<Layer*> layers = lc_surf->GetLayers(); for ( size_t i = 0; i < layers.size(); i++ ) { if ( layers[i]->GetProperties()->GetShowInfo() ) { LayerSurface* surf = ( LayerSurface* )layers[i]; AddSurfaceItem( surf, m_dRASPosition, false ); } } } SetItemCount( m_listName.Count() ); }
void DialogTransformVolume::DoRotate() { LayerMRI* layer = ( LayerMRI* )MainWindow::GetMainWindow()->GetActiveLayer( "MRI" ); if ( layer ) { std::vector<RotationElement> rotations; RotationElement re; re.SampleMethod = SAMPLE_TRILINEAR; if ( ui->radioButtonNearestNeighbor->isChecked() ) { re.SampleMethod = SAMPLE_NEAREST; } else if (ui->radioButtonCubic->isChecked()) { re.SampleMethod = SAMPLE_CUBIC_BSPLINE; } if (ui->radioButtonRotateManual->isChecked()) { if ( ui->radioButtonAroundCursor->isChecked() ) { MainWindow::GetMainWindow()->GetLayerCollection( "MRI" )-> GetSlicePosition( re.Point ); layer->RemapPositionToRealRAS( re.Point, re.Point ); } else { // use center of the volume to rotate layer->GetRASCenter( re.Point ); } // else if ( m_radioSinc->GetValue() ) // re.SampleMethod = SAMPLE_SINC; for ( int i = 0; i < 3; i++ ) { if ( GetRotation( i, re.Plane, re.Angle ) ) { rotations.push_back( re ); } } MainWindow::GetMainWindow()->RotateVolume( rotations, false ); } else { layer->GetRASCenter( re.Point ); LayerLandmarks* landmarks = (LayerLandmarks*)MainWindow::GetMainWindow()->GetSupplementLayer("Landmarks"); double* p[4]; for (int i = 0; i < 4; i++) p[i] = landmarks->GetLandmark(i).pos; // first figure out landmark vectors double v[3][3], ax[3][3]; int n0 = ui->comboBoxAxis11->currentIndex(); int n1 = ui->comboBoxAxis12->currentIndex(); for (int i = 0; i < 3; i++) v[0][i] = p[n1][i] - p[n0][i]; vtkMath::Normalize(v[0]); n0 = ui->comboBoxAxis21->currentIndex(); n1 = ui->comboBoxAxis22->currentIndex(); for (int i = 0; i < 3; i++) v[1][i] = p[n1][i] - p[n0][i]; vtkMath::Normalize(v[1]); vtkMath::Cross(v[0], v[1], v[2]); vtkMath::Normalize(v[2]); vtkMath::Cross(v[2], v[0], v[1]); int n[3]; n[0] = ui->comboBoxAxisTarget1->currentIndex(); n[1] = ui->comboBoxAxisTarget2->currentIndex(); if (n[0] == 0) n[2] = (n[1] == 1 ? 2 : 1); else if (n[0] == 1) n[2] = (n[1] == 0 ? 2 : 0); else n[2] = (n[1] == 0 ? 1 : 0); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) ax[n[i]][j] = v[i][j]; } double m[16]; memset(m, 0, sizeof(double)*16); for (int i = 0; i < 16; i++) { if (i/4 < 3 && i%4 < 3) m[i] = ax[i/4][i%4]; } m[15] = 1; vtkSmartPointer<vtkTransform> tf = vtkSmartPointer<vtkTransform>::New(); tf->Identity(); double pt[3]; layer->RASToTarget( re.Point, pt ); tf->Translate(pt[0], pt[1], pt[2]); tf->Concatenate(m); tf->Translate(-pt[0], -pt[1], -pt[2]); vtkMatrix4x4::DeepCopy(m, tf->GetMatrix()); MainWindow::GetMainWindow()->TransformVolume(m, re.SampleMethod); } } }