X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMainWindow.cxx;h=409919f8019a8bca8105a8beac2ff7fce97fc859;hb=f203197b333c9d9ebe8ec479ce42979306c63b20;hp=5c7bbfd76f3ccb531c54b1ae01fe0b0d0358b33e;hpb=e2d2096e1a3a4afdad6446bf09d0e05f47d9b7eb;p=clitk.git diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 5c7bbfd..409919f 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -88,6 +88,7 @@ It is distributed under dual licence // Standard includes #include +#include #include #include @@ -101,7 +102,7 @@ It is distributed under dual licence #define COLUMN_IMAGE_NAME 7 #ifdef CLITK_PRIVATE_FEATURES -#define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz *.usf)" +#define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz *.usf *.svl)" #else #define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz)" #endif @@ -294,7 +295,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation())); connect(actionRegister_vv,SIGNAL(triggered()),this,SLOT(PopupRegisterForm())); - connect(overlayPanel, SIGNAL(FusionSequenceSignalButtonPressed()), this, SLOT(SelectFusionSequenceTemporalSignal())); + connect(overlayPanel, SIGNAL(FusionSequenceCorrespondancesButtonPressed()), this, SLOT(SelectFusionSequenceCorrespondances())); /////////////////////////////////////////////// @@ -738,7 +739,7 @@ void vvMainWindow::OpenDicom() { std::vector files; - std::cout << "dicomSeriesSelector " << std::endl; + //std::cout << "dicomSeriesSelector " << std::endl; if (dicomSeriesSelector->exec() == QDialog::Accepted) { files = *(dicomSeriesSelector->GetFilenames()); LoadImages(files, vvImageReader::DICOM); @@ -1133,6 +1134,9 @@ void vvMainWindow::ImageInfoChanged() dim += pixelType + ")"; infoPanel->setFileName(image); + std::string creationImageTimeValue("No creation time"); + itk::ExposeMetaData< std::string > (*imageSelected->GetFirstMetaDataDictionary(), "creationImageTime", creationImageTimeValue); + infoPanel->setImageCreationTime(QString(creationImageTimeValue.c_str())); infoPanel->setDimension(dim); infoPanel->setSizePixel(GetVectorIntAsString(inputSize)); infoPanel->setSizeMM(GetVectorDoubleAsString(sizeMM)); @@ -1638,6 +1642,24 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) } //if the slicer manager was involved in a fusion sequence visualization... if ( mSlicerManagers[index]->IsInvolvedInFusionSequence() ) { + //in both cases, close the overlay: find it... and close it + //ideally, I should duplicate the code, and avoid calling CloseImage, since this pops up another interactive box + QTreeWidgetItem* overlayItem; + if (mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) { + for (unsigned i=0 ; ichildCount() ; i++) { + overlayItem = item->child(i); + this->CloseImage( overlayItem, 0 ); + } + } + else { + QTreeWidgetItem* linkedItem = this->GetItemFromSlicerManager( mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()] ); + for (unsigned i=0 ; ichildCount() ; i++) { + overlayItem = linkedItem->child(i); + this->CloseImage( overlayItem, 0 ); + } + } + + /* -- this is normally already done when closing the overlay. //reset the transforms overlayPanel->getFusionSequenceProperty(-1, false, 0, false); @@ -1649,8 +1671,7 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) mSlicerManagers[index]->GetSlicer(i)->SetFusionSequenceCode(-1); mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->GetSlicer(i)->SetFusionSequenceCode(-1); } - - //TODO: also remove the image overlaid with the main sequence, as it is becoming invalid... + */ } linkPanel->removeImage(index); @@ -2443,7 +2464,7 @@ void vvMainWindow::SelectFusionSequence() //------------------------------------------------------------------------------ -void vvMainWindow::SelectFusionSequenceTemporalSignal() { +void vvMainWindow::SelectFusionSequenceCorrespondances() { //make sure the index is right? //in the end, I should attach the temporal data to the right sequence! @@ -2454,35 +2475,51 @@ void vvMainWindow::SelectFusionSequenceTemporalSignal() { } //open a dialog box to find a file - QString Extensions = EXTENSIONS; - Extensions += ";;All Files (*)"; + //QString Extensions = EXTENSIONS; + QString Extensions = ";;All Files (*)"; QString fileName = QFileDialog::getOpenFileName(this,tr("Load respiratory signal for fused sequence"),mInputPathName,Extensions); if (fileName.isNull()) return; //read it as a vector of values - std::vector signal; - //...TODO, look for itk functions that can do that... vnl in the worst case. - signal.push_back(1);signal.push_back(2); - - //TODO: instead: if the loaded signal is longer, just crop it... - //this allows loading only the first few frames when testing. - //->maybe raise a message that this behavior may be unsafe... - - //if compatible with the fused image sequence (number of images = number of entries), enable the temporalSync - if ( signal.size() >= mSlicerManagers[index]->GetFusionSequenceNbFrames()) { - //for convenience, associate this sequence to both the current slicer manager, and to the linked one - mSlicerManagers[index]->SetFusionSequenceTemporalSignal(signal); - mSlicerManagers[ mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager() ]->SetFusionSequenceTemporalSignal(signal); - overlayPanel->enableFusionSequenceTemporalSync(); - QMessageBox::information(this,tr("Adding signal"),"would add the signal from file: "+ fileName); + vnl_vector tmpVect; + + std::ifstream file; + file.open(fileName.toStdString().c_str()); + tmpVect.read_ascii(file); + file.close(); + + //if compatible with the fused image sequence (number of entries = nb of entries in main sequence + nb of entries in joint sequence), enable the temporalSync + bool signalOK = true; + unsigned nbFrameMain = mSlicerManagers[index]->GetImage()->GetTransform().size(); + unsigned nbFrameSecondary = mSlicerManagers[index]->GetFusionSequenceNbFrames(); +std::cout<<"nbFrameMain = "< temporalCorrespondances; + if ( tmpVect.size() == nbFrameMain + nbFrameSecondary ) { + for (unsigned i=0 ; i index in secondary seq. + if ( tmpVect(i) index in secondary seq. + if ( tmpVect(i)SetFusionSequenceCorrespondances(temporalCorrespondances); + mSlicerManagers[ mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager() ]->SetFusionSequenceCorrespondances(temporalCorrespondances); + overlayPanel->enableFusionSequenceTemporalSync(); + } } //------------------------------------------------------------------------------ @@ -2499,6 +2536,7 @@ void vvMainWindow::AddFusionSequence(int index, std::vector fileNam mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str(); itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO( file.toStdString().c_str(), itk::ImageIOFactory::ReadMode); + std::sort (fileNames.begin(), fileNames.end());//make sure the files are sorted. reader->SetFileName(fileNames[0].c_str()); reader->ReadImageInformation(); std::string component = reader->GetComponentTypeAsString(reader->GetComponentType()); @@ -2566,8 +2604,15 @@ void vvMainWindow::AddFusionSequence(int index, std::vector fileNam //This loads the secondary sequence (US) as an independent sequence LoadImages(fileNames, type); - //reset the transforms to identiy + //reset the transforms to identity + //FIX -- and set the thickness of the US slices to a large value (necessary for visualization purposes...) + double sp_x, sp_y, sp_z; + mSlicerManagers[indexParent]->GetImage()->GetVTKImages()[0]->GetSpacing(sp_x, sp_y, sp_z); + sp_z = std::max(sp_x, std::max(sp_y, sp_z)) + 0.5; // for (unsigned i=0 ; iGetImage()->GetTransform().size() ; i++) { + sp_x = mSlicerManagers.back()->GetImage()->GetVTKImages()[i]->GetSpacing()[0]; + sp_y = mSlicerManagers.back()->GetImage()->GetVTKImages()[i]->GetSpacing()[1]; + mSlicerManagers.back()->GetImage()->GetVTKImages()[i]->SetSpacing( sp_x, sp_y, sp_z); mSlicerManagers.back()->GetImage()->GetTransform()[i]->Identity(); mSlicerManagers.back()->GetImage()->GetTransform()[i]->Update(); } @@ -2590,7 +2635,7 @@ void vvMainWindow::AddFusionSequence(int index, std::vector fileNam error += mSlicerManagers[index]->GetLastError().c_str(); QMessageBox::information(this,tr("Problem reading image !"),error); } - //WindowLevelChanged(); + WindowLevelChanged(); ImageInfoChanged(); //this internally calls WindowLevelChanged... } else { @@ -2651,21 +2696,13 @@ void vvMainWindow::SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool if (spatialSyncFlag) { //reslice the CT if (temporalSyncFlag) { //do the temporal synchronisation - //TODO: add the temporal synchronisation stuff - //if the button is checked, get the phase of the requested US frame from the available signal - //and select the corresponding one in the CT. (check the one just before, and the one just after, and select the closest) - - //TODO: do it also the other way around, when modifying the time index related to CT, select a close frame - //this should not be done here directly, but the code should be inspired from the one here - //->find a good US frame such that when calling this function with this US frame, it produces the expected result - - - //TODO: select the right CT image to display int mainSequenceFrameIndex=0; //estimate the TSlice to set to the CT - + unsigned nbFramesMain = mSlicerManagers[index]->GetImage()->GetTransform().size(); + mainSequenceFrameIndex = mSlicerManagers[index]->GetFusionSequenceCorrespondances()[ nbFramesMain + fusionSequenceFrameIndex]; //and set it! mSlicerManagers[index]->SetTSlice(mainSequenceFrameIndex, false); + //warning, there is a loopback, and modification of the TSlice in main sequence forces an update of the TSlice in secondary, etc... } @@ -2921,12 +2958,13 @@ void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index) if (mSlicerManagers[i]->GetFusionSequenceTemporalSyncFlag()) { //WARNING: for some obscure reason, there are problems when accessing mSlicerManagers[mSlicerManagers[i]->GetFusionSequenceIndexOfLinkedManager()]->GetFusionSequenceFrameIndex(); - //int estimatedValue=mSlicerManagers[mSlicerManagers[i]->GetFusionSequenceIndexOfLinkedManager()]->GetFusionSequenceFrameIndex(); int estimatedValue=0; - //TODO: if temporal sync is active //estimate a corresponding time index for the secondary (US) sequence, and update it accordingly. - //estimatedValue = ... - overlayPanel->updateFusionSequenceSliderValueFromWindow(estimatedValue, true); + estimatedValue = mSlicerManagers[i]->GetFusionSequenceCorrespondances()[ value ]; + //TODO: at the moment, there is a loop in TSlice modifications + //modifying sequence 1 causes seq 2 to update, which in turns update seq1... + //I disable control on seq1 at the moment. + //overlayPanel->updateFusionSequenceSliderValueFromWindow(estimatedValue, true); } } }