2/ 1st prototype version of the sequence fusion visualization mode (not so clean, but it works)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+IF(MSVC)
+ SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj" )
+ SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /bigobj" )
+ENDIF(MSVC)
+
#=========================================================
INCLUDE(${CLITK_SOURCE_DIR}/cmake/common.cmake)
INCLUDE(${CLITK_SOURCE_DIR}/cmake/dependencies.cmake)
# include <sys/resource.h>
#elif defined(_WIN32)
# include <windows.h>
+# include <stdint.h>
#endif
//--------------------------------------------------------------------
size_t nelements = 0;
nelements += fread ( (void *) hnd.sFileType, sizeof(char), 32, fp);
- nelements += fread ( (void *) &hnd.FileLength, sizeof(uint32_t), 1, fp);
+ nelements += fread ( (void *) &hnd.FileLength, sizeof(itk::uint32_t), 1, fp);
nelements += fread ( (void *) hnd.sChecksumSpec, sizeof(char), 4, fp);
- nelements += fread ( (void *) &hnd.nCheckSum, sizeof(uint32_t), 1, fp);
+ nelements += fread ( (void *) &hnd.nCheckSum, sizeof(itk::uint32_t), 1, fp);
nelements += fread ( (void *) hnd.sCreationDate, sizeof(char), 8, fp);
nelements += fread ( (void *) hnd.sCreationTime, sizeof(char), 8, fp);
nelements += fread ( (void *) hnd.sPatientID, sizeof(char), 16, fp);
- nelements += fread ( (void *) &hnd.nPatientSer, sizeof(uint32_t), 1, fp);
+ nelements += fread ( (void *) &hnd.nPatientSer, sizeof(itk::uint32_t), 1, fp);
nelements += fread ( (void *) hnd.sSeriesID, sizeof(char), 16, fp);
- nelements += fread ( (void *) &hnd.nSeriesSer, sizeof(uint32_t), 1, fp);
+ nelements += fread ( (void *) &hnd.nSeriesSer, sizeof(itk::uint32_t), 1, fp);
nelements += fread ( (void *) hnd.sSliceID, sizeof(char), 16, fp);
- nelements += fread ( (void *) &hnd.nSliceSer, sizeof(uint32_t), 1, fp);
- nelements += fread ( (void *) &hnd.SizeX, sizeof(uint32_t), 1, fp);
- nelements += fread ( (void *) &hnd.SizeY, sizeof(uint32_t), 1, fp);
+ nelements += fread ( (void *) &hnd.nSliceSer, sizeof(itk::uint32_t), 1, fp);
+ nelements += fread ( (void *) &hnd.SizeX, sizeof(itk::uint32_t), 1, fp);
+ nelements += fread ( (void *) &hnd.SizeY, sizeof(itk::uint32_t), 1, fp);
nelements += fread ( (void *) &hnd.dSliceZPos, sizeof(double), 1, fp);
nelements += fread ( (void *) hnd.sModality, sizeof(char), 16, fp);
- nelements += fread ( (void *) &hnd.nWindow, sizeof(uint32_t), 1, fp);
- nelements += fread ( (void *) &hnd.nLevel, sizeof(uint32_t), 1, fp);
- nelements += fread ( (void *) &hnd.nPixelOffset, sizeof(uint32_t), 1, fp);
+ nelements += fread ( (void *) &hnd.nWindow, sizeof(itk::uint32_t), 1, fp);
+ nelements += fread ( (void *) &hnd.nLevel, sizeof(itk::uint32_t), 1, fp);
+ nelements += fread ( (void *) &hnd.nPixelOffset, sizeof(itk::uint32_t), 1, fp);
nelements += fread ( (void *) hnd.sImageType, sizeof(char), 4, fp);
nelements += fread ( (void *) &hnd.dGantryRtn, sizeof(double), 1, fp);
nelements += fread ( (void *) &hnd.dSAD, sizeof(double), 1, fp);
nelements += fread ( (void *) &hnd.dGating4DInfoZ, sizeof(double), 1, fp);
nelements += fread ( (void *) &hnd.dGating4DInfoTime, sizeof(double), 1, fp);
- if(nelements != /*char*/120 + /*uint32_t*/10 + /*double*/41)
+ if(nelements != /*char*/120 + /*itk::uint32_t*/10 + /*double*/41)
itkGenericExceptionMacro(<< "Could not read header data in " << m_FileName);
if(fclose (fp) != 0)
{
FILE *fp;
- uint32_t* buf = (uint32_t*)buffer;
+ itk::uint32_t* buf = (itk::uint32_t*)buffer;
unsigned char *pt_lut;
- uint32_t a;
+ itk::uint32_t a;
unsigned char v;
int lut_idx, lut_off;
size_t num_read;
char dc;
short ds;
long dl, diff=0;
- uint32_t i;
+ itk::uint32_t i;
fp = fopen (m_FileName.c_str(), "rb");
if (fp == NULL)
/* Read first row */
for (i = 0; i < GetDimensions(0); i++) {
- if(1 != fread (&a, sizeof(uint32_t), 1, fp))
+ if(1 != fread (&a, sizeof(itk::uint32_t), 1, fp))
itkGenericExceptionMacro(<< "Could not read first row in: " << m_FileName);
buf[i] = a;
}
/* Read first pixel of second row */
- if(1 != fread (&a, sizeof(uint32_t), 1, fp))
+ if(1 != fread (&a, sizeof(itk::uint32_t), 1, fp))
itkGenericExceptionMacro(<< "Could not read first pixel of second row");
buf[i++] = a;
lut_idx = 0;
lut_off = 0;
while (i < GetDimensions(0) * GetDimensions(1) ) {
- uint32_t r11, r12, r21;
+ itk::uint32_t r11, r12, r21;
r11 = buf[i-GetDimensions(0)-1];
r12 = buf[i-GetDimensions(0)];
diff = ds;
break;
case 2:
- num_read = fread (&dl, sizeof(uint32_t), 1, fp);
+ num_read = fread (&dl, sizeof(itk::uint32_t), 1, fp);
if (num_read != 1) goto read_error;
diff = dl;
break;
switch(mDim) {
case 2:
UpdateWithDim<2>(mInputPixelType);
- break;;
+ break;
case 3:
UpdateWithDim<3>(mInputPixelType);
- break;;
+ break;
case 4:
UpdateWithDim<4>(mInputPixelType);
- break;;
+ break;
default:
std::cerr << "dimension unknown in Update ! " << std::endl;
}
}
// TODO SR and BP: check on the list of transforms and not the first only
- mImage->GetTransform()[0]->PostMultiply();
+ mImage->GetTransform()[0]->PreMultiply();
mImage->GetTransform()[0]->Concatenate(matrix);
mImage->GetTransform()[0]->Update();
+
+ //for image sequences, apply the transform to each images of the sequence
+ if (mImage->IsTimeSequence())
+ {
+ for (unsigned i = 1 ; i<mImage->GetTransform().size() ; i++)
+ {
+ mImage->GetTransform()[i]->PreMultiply();
+ mImage->GetTransform()[i]->Concatenate(matrix);
+ mImage->GetTransform()[i]->Update();
+ }
+ }
+
}
}
//------------------------------------------------------------------------------
IF(CLITK_EXPERIMENTAL)
WRAP_GGO(clitkBinaryImageToMesh_GGO_C clitkBinaryImageToMesh.ggo)
ADD_EXECUTABLE(clitkBinaryImageToMesh clitkBinaryImageToMesh.cxx ${clitkBinaryImageToMesh_GGO_C})
- TARGET_LINK_LIBRARIES(clitkBinaryImageToMesh itksys ${VTK_LIBRARIES})
+ TARGET_LINK_LIBRARIES(clitkBinaryImageToMesh itksys ${ITK_LIBRARIES} ${VTK_LIBRARIES})
SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkBinaryImageToMesh)
WRAP_GGO(clitkMeshToBinaryImage_GGO_C clitkMeshToBinaryImage.ggo)
WRAP_GGO(clitkMeshViewer_GGO_C clitkMeshViewer.ggo)
ADD_EXECUTABLE(clitkMeshViewer clitkMeshViewer.cxx ${clitkMeshViewer_GGO_C})
- TARGET_LINK_LIBRARIES(clitkMeshViewer ${VTK_LIBRARIES})
+ TARGET_LINK_LIBRARIES(clitkMeshViewer ${ITK_LIBRARIES} ${VTK_LIBRARIES})
SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMeshViewer)
ENDIF(CLITK_EXPERIMENTAL)
IF(WIN32)
#INCLUDE(InstallRequiredSystemLibraries)
- INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/vv.exe DESTINATION .)
+ INSTALL(TARGETS vv DESTINATION bin)
#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/icons/ducky.png DESTINATION .)
ENDIF(WIN32)
#=========================================================
</sizepolicy>
</property>
<property name="currentIndex">
- <number>0</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="DataTab">
<attribute name="title">
<x>0</x>
<y>0</y>
<width>1008</width>
- <height>25</height>
+ <height>29</height>
</rect>
</property>
<property name="defaultUp">
<addaction name="actionAdd_VF_to_current_Image"/>
<addaction name="actionAdd_overlay_image_to_current_image"/>
<addaction name="actionAdd_fusion_image"/>
+ <addaction name="actionAdd_USSequence_toCT"/>
</widget>
<widget class="QMenu" name="menuScreenshots">
<property name="title">
<bool>true</bool>
</property>
</action>
+ <action name="actionAdd_USSequence_toCT">
+ <property name="icon">
+ <iconset resource="../vvIcons.qrc">
+ <normaloff>:/common/icons/rotateright.png</normaloff>:/common/icons/rotateright.png</iconset>
+ </property>
+ <property name="text">
+ <string>Test / Fusion of US & CT sequences</string>
+ </property>
+ <property name="iconVisibleInMenu">
+ <bool>true</bool>
+ </property>
+ </action>
</widget>
<customwidgets>
<customwidget>
<rect>
<x>0</x>
<y>0</y>
- <width>344</width>
- <height>480</height>
+ <width>444</width>
+ <height>815</height>
</rect>
</property>
<property name="sizePolicy">
</property>
</widget>
</item>
+ <item>
+ <widget class="QFrame" name="fCTUSFrame">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>70</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QCheckBox" name="fCTUSActivateTimeSyncCheckBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>10</y>
+ <width>80</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Temporal</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="fCTUSActivateSpaceSyncCheckBox">
+ <property name="geometry">
+ <rect>
+ <x>210</x>
+ <y>10</y>
+ <width>61</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Spatial</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_13">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>31</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="pixmap">
+ <pixmap resource="../vvIcons.qrc">:/common/icons/rotateright.png</pixmap>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_14">
+ <property name="geometry">
+ <rect>
+ <x>30</x>
+ <y>0</y>
+ <width>171</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Synchronized fusion of sequences</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_15">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>30</y>
+ <width>121</width>
+ <height>29</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string> Browse fused sequence </string>
+ </property>
+ </widget>
+ <widget class="QSlider" name="fCTUSSlider">
+ <property name="geometry">
+ <rect>
+ <x>130</x>
+ <y>36</y>
+ <width>181</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </widget>
+ </item>
<item>
<widget class="QFrame" name="vFFrame">
<property name="enabled">
std::vector<std::string> &sequence_filenames,
int n_image_loaded)
{
- const std::string open_mode_names[] = {"base", "overlay", "fusion", "vf", "contour"};
+ const std::string open_mode_names[] = {"base", "overlay", "fusion", "vf", "contour", "fusionSequence"};
if(open_mode==O_BASE)
window.LoadImages(sequence_filenames, vvImageReader::MERGEDWITHTIME);
else if (open_mode==O_OVERLAY)
class vtkImageAppend;
-class VTK_IO_EXPORT vvAnimatedGIFWriter : public vtkGenericMovieWriter
+class vvAnimatedGIFWriter : public vtkGenericMovieWriter //test this if link error...
{
public:
static vvAnimatedGIFWriter *New();
contextMenu.addAction(actionAdd_fusion_image);
contextActions.push_back(actionAdd_fusion_image);
+ contextMenu.addAction(actionAdd_USSequence_toCT);
+ contextActions.push_back(actionAdd_USSequence_toCT);
+
+
contextMenu.addSeparator();
QAction* actionResetMatrix = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/identity.png")),
tr("Reset transformation to identity"));
actionSave_As->setEnabled(0);
actionAdd_VF_to_current_Image->setEnabled(0);
actionAdd_fusion_image->setEnabled(0);
+ actionAdd_USSequence_toCT->setEnabled(0);
//init the sliders
verticalSliders.push_back(NOVerticalSlider);
connect(actionExit,SIGNAL(triggered()),this,SLOT(close()));
connect(actionAdd_VF_to_current_Image,SIGNAL(triggered()),this,SLOT(OpenField()));
connect(actionAdd_fusion_image,SIGNAL(triggered()),this,SLOT(SelectFusionImage()));
- connect(actionAdd_overlay_image_to_current_image,SIGNAL(triggered()), this,SLOT(SelectOverlayImage())); connect(actionNavigation_Help,SIGNAL(triggered()),this,SLOT(ShowHelpDialog()));
+ connect(actionAdd_overlay_image_to_current_image,SIGNAL(triggered()), this,SLOT(SelectOverlayImage()));
+ connect(actionAdd_USSequence_toCT,SIGNAL(triggered()), this,SLOT(SelectFusionSequence()));
+ connect(actionNavigation_Help,SIGNAL(triggered()),this,SLOT(ShowHelpDialog()));
connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation()));
connect(actionRegister_vv,SIGNAL(triggered()),this,SLOT(PopupRegisterForm()));
+
///////////////////////////////////////////////
connect(actionSegmentation,SIGNAL(triggered()),this,SLOT(SegmentationOnCurrentImage()));
connect(actionSurface_Viewer,SIGNAL(triggered()),this,SLOT(SurfaceViewerLaunch()));
this,SLOT(SetFusionProperty(int,int,int,double,double, bool)));
connect(landmarksPanel,SIGNAL(UpdateRenderWindows()),this,SLOT(UpdateRenderWindows()));
+ connect(overlayPanel,SIGNAL(FusionSequencePropertyUpdated(int, bool, unsigned int)),
+ this,SLOT(SetFusionSequenceProperty(int, bool,unsigned int)));
+
+
playMode = 0;//pause
mFrameRate = 10;
playButton->setEnabled(0);
//timerMemory->setInterval(5);
connect(timerMemory, SIGNAL(timeout()), this, SLOT(UpdateMemoryUsage()));
timerMemory->start(2000);
+
}
//------------------------------------------------------------------------------
void vvMainWindow::show()
this, SLOT(OverlayChanged(int,double,double)));
connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)),
this, SLOT(FusionChanged(int,double)));
+ //connect(mSlicerManagers.back(), SIGNAL(UpdateFusionSequence(int, bool, unsigned int)),
+ // this, SLOT(FusionSequenceChanged(int, bool, unsigned int)));
connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged()),
this,SLOT(WindowLevelChanged()));
connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)),
actionAdd_VF_to_current_Image->setEnabled(1);
actionAdd_fusion_image->setEnabled(1);
actionAdd_overlay_image_to_current_image->setEnabled(1);
+ actionAdd_USSequence_toCT->setEnabled(1);
actionNorth_East_Window->setEnabled(1);
actionNorth_West_Window->setEnabled(1);
actionSouth_East_Window->setEnabled(1);
colorMapComboBox->setEnabled(1);
for (int i = 0; i < DataTree->topLevelItem(index)->childCount(); i++) {
if (DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "overlay" ||
- DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "fusion") {
+ DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "fusion" ||
+ DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "fusionSequence") {
colorMapComboBox->setEnabled(0);
break;
}
}
- std::vector<double> origin;
+ std::vector<double> origin;
std::vector<double> inputSpacing;
std::vector<int> inputSize;
std::vector<double> sizeMM;
QString inputSizeInBytes;
QString image = DataTree->selectedItems()[0]->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
- int nframes = mSlicerManagers[index]->GetSlicer(0)->GetTMax();
+ int nframes = mSlicerManagers[index]->GetSlicer(0)->GetTMax();
if (nframes > 1 || playMode == 1) {
playButton->setEnabled(1);
frameRateLabel->setEnabled(1);
//read image header
int NPixel = 1;
- int tSlice = 0;
+ int tSlice = 0;
vvImage::Pointer imageSelected;
if (DataTree->topLevelItem(index) == DataTree->selectedItems()[0]) {
imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage();
imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetOverlay();
tSlice = mSlicerManagers[index]->GetSlicer(0)->GetOverlayTSlice();
} else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "fusion") {
- imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetFusion();
- tSlice = mSlicerManagers[index]->GetSlicer(0)->GetFusionTSlice();
+ imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetFusion();
+ tSlice = mSlicerManagers[index]->GetSlicer(0)->GetFusionTSlice();
}
+ else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "fusionSequence") {
+ imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetFusion();
+ tSlice = mSlicerManagers[index]->GetSlicer(0)->GetFusionTSlice();
+ }
else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "contour") {
- imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage();
- tSlice = mSlicerManagers[index]->GetSlicer(0)->GetTSlice();
+ imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage();
+ tSlice = mSlicerManagers[index]->GetSlicer(0)->GetTSlice();
}
else {
- imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage();
- tSlice = mSlicerManagers[index]->GetSlicer(0)->GetTSlice();
+ imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage();
+ tSlice = mSlicerManagers[index]->GetSlicer(0)->GetTSlice();
}
- dimension = imageSelected->GetNumberOfDimensions();
+ dimension = imageSelected->GetNumberOfDimensions();
origin.resize(dimension);
inputSpacing.resize(dimension);
inputSize.resize(dimension);
NPixel *= inputSize[i];
}
inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
-
+
QString dim = QString::number(dimension) + " (";
dim += pixelType + ")";
infoPanel->setOrigin(GetVectorDoubleAsString(origin));
infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
- transformation = imageSelected->GetTransform()[tSlice]->GetMatrix();
+
+ transformation = imageSelected->GetTransform()[tSlice]->GetMatrix();
infoPanel->setTransformation(Get4x4MatrixDoubleAsString(transformation));
- landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
+ landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size());
landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str());
}
}
- infoPanel->setFileName(image);
+ infoPanel->setFileName(image);
infoPanel->setDimension(dim);
infoPanel->setSizePixel(GetVectorIntAsString(inputSize));
infoPanel->setSizeMM(GetVectorDoubleAsString(sizeMM));
break;
}
}
- WindowLevelChanged();
+
+ WindowLevelChanged();
slicingPresetComboBox->setCurrentIndex(mSlicerManagers[index]->GetSlicingPreset());
- if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) {
+ if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) {
overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str());
overlayPanel->getVFProperty(mSlicerManagers[index]->GetSlicer(0)->GetVFSubSampling(),
mSlicerManagers[index]->GetSlicer(0)->GetVFScale(),
} else {
overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str());
}
-
- if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
+
+ if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
} else {
overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
else if (role == "fusion"){
mSlicerManagers[index]->ReloadFusion();
}
+ else if (role == "fusionSequence"){
+ mSlicerManagers[index]->ReloadFusionSequence(); //same as for standard fusion
+ }
else{
mSlicerManagers[index]->Reload();
}
else
overlayPanel->getOverlayProperty(-1,0,0.,0.);
- // Fusion image
- if (mSlicerManagers[index]->GetSlicer(0)->GetFusion())
- overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(),
- mSlicerManagers[index]->GetFusionThresholdOpacity(),
- mSlicerManagers[index]->GetFusionColorMap(),
- mSlicerManagers[index]->GetFusionWindow(),
- mSlicerManagers[index]->GetFusionLevel());
+ // Fusion & SequenceFusion image
+ if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
+ overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(),
+ mSlicerManagers[index]->GetFusionThresholdOpacity(),
+ mSlicerManagers[index]->GetFusionColorMap(),
+ mSlicerManagers[index]->GetFusionWindow(),
+ mSlicerManagers[index]->GetFusionLevel());
+ overlayPanel->getFusionSequenceProperty(mSlicerManagers[index]->GetFusionSequenceFrameIndex(),
+ mSlicerManagers[index]->GetFusionSequenceSpatialSyncFlag(),
+ mSlicerManagers[index]->GetFusionSequenceNbFrames());
+ }
else
- overlayPanel->getFusionProperty(-1, -1, -1, -1, -1);
+ {
+ overlayPanel->getFusionProperty(-1, -1, -1, -1, -1);
+ overlayPanel->getFusionSequenceProperty(-1, false, 0);
+ }
}
//------------------------------------------------------------------------------
//check if one fusion image is added
for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
- if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusion") {
+ if ( (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusion") ||
+ (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusionSequence") ) {
QString error = "Cannot add more than one fusion image\n";
error += "Please remove first ";
error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
mSlicerManagers[index]->SetFusionLevel(level);
mSlicerManagers[index]->SetFusionShowLegend(showLegend);
mSlicerManagers[index]->SetColorMap(0);
- mSlicerManagers[index]->Render();
+ mSlicerManagers[index]->Render();
}
}
//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvMainWindow::SelectFusionSequence()
+{
+ int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+ //check if one overlay image is added
+ for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
+ if ( (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusion") ||
+ (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusionSequence") ) {
+ QString error = "Cannot add more than one compared image\n";
+ error += "Please remove first ";
+ error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
+ QMessageBox::information(this,tr("Problem adding compared image !"),error);
+ return;
+ }
+
+ QString Extensions = EXTENSIONS;
+ Extensions += ";;All Files (*)";
+ QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Overlay image sequence"),mInputPathName,Extensions);
+ if (files.isEmpty())
+ return;
+
+ std::vector<std::string> vecFileNames;
+ for (int i = 0; i < files.size(); i++) {
+ vecFileNames.push_back(files[i].toStdString());
+ }
+
+ AddFusionSequence(index,vecFileNames,vvImageReader::MERGEDWITHTIME);
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvMainWindow::AddFusionSequence(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type)
+{
+ QString file(fileNames[0].c_str());
+ if (QFile::exists(file))
+ {
+ mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
+ itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
+ file.toStdString().c_str(), itk::ImageIOFactory::ReadMode);
+ reader->SetFileName(fileNames[0].c_str());
+ reader->ReadImageInformation();
+ std::string component = reader->GetComponentTypeAsString(reader->GetComponentType());
+ int dimension = reader->GetNumberOfDimensions();
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+ vvProgressDialog progress("Opening " + file.toStdString());
+ qApp->processEvents();
+
+ std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str();
+
+ if (mSlicerManagers[index]->SetFusionSequence(fileNames,dimension, component,type)) {
+ //create an item in the tree with good settings
+ QTreeWidgetItem *item = new QTreeWidgetItem();
+ item->setData(0,Qt::UserRole,file.toStdString().c_str());
+ item->setData(1,Qt::UserRole,tr("fusionSequence"));
+
+ QFileInfo fileinfo(file); //Do not show the path
+ item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
+ item->setToolTip(COLUMN_IMAGE_NAME, mSlicerManagers[index]->GetListOfAbsoluteFilePathInOneString("fusionSequence").c_str());
+ qApp->processEvents();
+ for (int j = 1; j <= 4; j++) {
+ item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
+ }
+
+ //Create the buttons for reload and close
+ qApp->processEvents();
+ QTreePushButton* cButton = new QTreePushButton;
+ cButton->setItem(item);
+ cButton->setColumn(COLUMN_CLOSE_IMAGE);
+ cButton->setToolTip(tr("close image"));
+ cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png")));
+ connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+ this,SLOT(CloseImage(QTreeWidgetItem*, int)));
+
+ QTreePushButton* rButton = new QTreePushButton;
+ rButton->setItem(item);
+ rButton->setColumn(COLUMN_RELOAD_IMAGE);
+ rButton->setToolTip(tr("reload image"));
+ rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png")));
+ connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+ this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
+
+ DataTree->topLevelItem(index)->setExpanded(1);
+ DataTree->topLevelItem(index)->addChild(item);
+ DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
+ DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
+
+ //store the original transform matrix
+ int indexParent = GetSlicerIndexFromItem( DataTree->topLevelItem(index) );
+ mSlicerManagers[indexParent]->SetFusionSequenceMainTransformMatrix( mSlicerManagers[indexParent]->GetSlicer(0)->GetImage()->GetTransform()[0]->GetMatrix() );
+
+ //set the id of the image
+ QString id = DataTree->topLevelItem(index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
+ item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
+ UpdateTree();
+ qApp->processEvents();
+ ImageInfoChanged();
+
+ QApplication::restoreOverrideCursor();
+ // Update the display to update, e.g., the sliders
+ for(int i=0; i<4; i++)
+ DisplaySliders(index, i);
+
+ } else {
+ QApplication::restoreOverrideCursor();
+ QString error = "Cannot import the new image.\n";
+ error += mSlicerManagers[index]->GetLastError().c_str();
+ QMessageBox::information(this,tr("Problem reading image !"),error);
+ }
+ WindowLevelChanged();
+ }
+ else
+ QMessageBox::information(this,tr("Problem reading fusion sequence !"),"File doesn't exist!");
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvMainWindow::SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool spatialSyncFlag, unsigned int fusionSequenceNbFrames)
+{
+ int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+ if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
+ int indexParent = GetSlicerIndexFromItem( DataTree->topLevelItem(index) );
+
+ mSlicerManagers[index]->SetFusionSequenceLength(fusionSequenceNbFrames);
+ mSlicerManagers[index]->SetFusionSequenceSpatialSyncFlag(spatialSyncFlag);
+ mSlicerManagers[index]->SetFusionSequenceFrameIndex(fusionSequenceFrameIndex);
+
+ if (spatialSyncFlag) { //reslice the CT
+ //show the right frame of the US sequence
+ mSlicerManagers[index]->SetFusionSequenceTSlice(fusionSequenceFrameIndex);
+
+ //Set the transform matrix of the parent sequence (typically CT / 4DCT)
+ vtkSmartPointer<vtkMatrix4x4> tmpMat = vtkSmartPointer<vtkMatrix4x4>::New();
+ vtkMatrix4x4::Invert( mSlicerManagers[index]->GetFusionSequenceInitialTransformMatrixAtFrame(fusionSequenceFrameIndex), tmpMat );
+ for ( unsigned i=0 ; i<mSlicerManagers[indexParent]->GetSlicer(0)->GetImage()->GetTransform().size() ; i++ ) {
+ mSlicerManagers[indexParent]->GetSlicer(0)->GetImage()->GetTransform()[i]->SetMatrix( mSlicerManagers[index]->GetFusionSequenceMainTransformMatrix() );
+ mSlicerManagers[indexParent]->GetSlicer(0)->GetImage()->GetTransform()[i]->PreMultiply();
+ mSlicerManagers[indexParent]->GetSlicer(0)->GetImage()->GetTransform()[i]->Concatenate( tmpMat );
+ mSlicerManagers[indexParent]->GetSlicer(0)->GetImage()->GetTransform()[i]->Update();
+ }
+
+ for (int i=0; i<mSlicerManagers[indexParent]->GetNumberOfSlicers(); i++) {
+ mSlicerManagers[indexParent]->GetSlicer(i)->ForceUpdateDisplayExtent();
+ mSlicerManagers[indexParent]->GetSlicer(i)->Render();
+ }
+ }
+ else { //flag is off.
+ //rather use a different method for switching on/off... or check whether the matrix is the same...
+ //TODO: reset the CT to its original state, as well as the US
+ }
+
+ //TODO: recenter the view so that the US frame is visible?
+ //or when adding the sequence, also add the sequence as an independent image that is automatically linked, to guide the views...
+ }
+}
+//------------------------------------------------------------------------------
+
+
//------------------------------------------------------------------------------
void vvMainWindow::SaveAs()
{
connect(mSlicerManagers.back(), SIGNAL(UpdateOverlay(int, double, double)),
this, SLOT(OverlayChanged(int,double,double)));
connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)),
- this, SLOT(FusionChanged(int,double)));
+ this, SLOT(FusionChanged(int,double)));
+ //connect(mSlicerManagers.back(), SIGNAL(UpdateFusionSequence(int, bool, unsigned int)),
+ // this, SLOT(FusionSequenceChanged(int, bool, unsigned int)));
connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged()),
this,SLOT(WindowLevelChanged()));
connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)),
void AddOverlayImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
void AddFusionImage(int index, QString filename);
void AddROI(int index, QString filename);
+ //Process the sequence for fusion:
+ void AddFusionSequence(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
+
///Adds a mesh to a SlicerManager, with optional warping by vector field
void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
///This is used to show an image when opened or computed
void VectorChanged(int visibility, double x, double y, double z, double value);
void OverlayChanged(int visibility, double valueOver, double valueRef);
void FusionChanged(int visibility, double value);
+ //void FusionSequenceChanged(int visibility, double value);
void SegmentationOnCurrentImage();
void SurfaceViewerLaunch();
void OpenField();
void SelectOverlayImage();
void SelectFusionImage();
+ //select the file(s) from the disk containing the image sequence to fuse
+ void SelectFusionSequence();
+
void ResetTransformationToIdentity();
void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
void SetOverlayProperty(int color, int linked, double window, double level);
void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level, bool showLegend);
+ void SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool spatialSyncFlag, unsigned int fusionSequenceNbFrames);
void GoToCursor();
void PlayPause();
vFFrame->hide();
compareFrame->hide();
fusionFrame->hide();
+ fCTUSFrame->hide();
subSamplingSpinBox->setEnabled(0);
scaleSpinBox->setEnabled(0);
lutCheckBox->hide();
lutCheckBox->setEnabled(0);
fusionShowLegendCheckBox->setChecked(false);
-
+ fCTUSActivateSpaceSyncCheckBox->setChecked(true);
+
connect(subSamplingSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
connect(scaleSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty()));
connect(lutCheckBox,SIGNAL(clicked()),this,SLOT(setVFProperty()));
connect(overlayLevelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setOverlayProperty()));
connect(overlayLinkCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setOverlayProperty()));
+ connect(fCTUSSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionSequenceProperty()));
+ connect(fCTUSActivateSpaceSyncCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setFusionSequenceProperty()));
+
disableFusionSignals = false;
+ disableFusionSequenceSignals = false;
}
void vvOverlayPanel::getCurrentImageName(QString name)
{
if (disableFusionSignals)
return;
-
+
fusionOpacitySpin->setValue(opacityHorizontalSlider->value());
fusionThresSpin->setValue(thresOpacityHorizontalSlider->value());
valueFusionnedLabel->setText(fusionValue);
}
+
+void vvOverlayPanel::getFusionSequenceProperty(int sequenceFrameIndex, bool spatialSync, unsigned int sequenceLenth)
+{
+ if (sequenceFrameIndex > -1) {
+ disableFusionSequenceSignals = true;
+ fCTUSFrame->show();
+ fCTUSFrame->setEnabled(1);
+ fCTUSSlider->setEnabled(1);
+ fCTUSSlider->setValue(sequenceFrameIndex);
+ fCTUSSlider->setMaximum(sequenceLenth);
+ if (spatialSync) fCTUSActivateSpaceSyncCheckBox->setCheckState(Qt::Checked);
+ else fCTUSActivateSpaceSyncCheckBox->setCheckState(Qt::Unchecked);
+ disableFusionSequenceSignals = false;
+ setFusionSequenceProperty();
+ } else {
+ fCTUSFrame->hide();
+ fCTUSFrame->setEnabled(0);
+ fCTUSSlider->setEnabled(0);
+ fCTUSSlider->setValue(0);
+ fCTUSSlider->setMaximum(0);
+ fCTUSActivateSpaceSyncCheckBox->setCheckState(Qt::Unchecked);
+ }
+}
+
+
+void vvOverlayPanel::setFusionSequenceProperty()
+{
+ if (disableFusionSequenceSignals)
+ return;
+
+ emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum());
+}
+
+
+
void vvOverlayPanel::VFColorChangeRequest()
{
QColor color(vfColorButton->palette().color(QPalette::Background));
void getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level);
void getFusionName(QString name);
- void getCurrentVectorInfo(int visibility, double x, double y, double z, double value);
+ void getFusionSequenceProperty(int sequenceFrameIndex, bool spatialSync, unsigned int sequenceLength);
+
+ void getCurrentVectorInfo(int visibility, double x, double y, double z, double value);
void getCurrentOverlayInfo(int visibility,double valueOver, double valueRef);
void getCurrentFusionInfo(int visibility,double value);
+ //void getCurrentFusionSequenceInfo(int visibility,double value);
bool getShowLegend();
void setFusionProperty();
void setFusionSpinProperty();
void VFColorChangeRequest();
+ void setFusionSequenceProperty();
signals:
void VFPropertyUpdated(int subsampling, int scale, int log, int width, double r, double g, double b);
void OverlayPropertyUpdated(int color, int linked, double window, double level);
void FusionPropertyUpdated(int opacity, int thresOpacity, int colormap, double window, double level, bool showLegend);
+ void FusionSequencePropertyUpdated(int sequenceFrameIndex, bool spatialSync, unsigned int sequenceLength);
private:
bool disableFusionSignals;
+ bool disableFusionSequenceSignals;
}; // end class vvOverlayPanel
//====================================================================
else if (actor_type == "overlay") {
vis = this->mOverlayActor->GetVisibility();
}
- else if (actor_type == "fusion") {
+ else if ( (actor_type == "fusion") || (actor_type == "fusionSequence") ){
vis = this->mFusionActor->GetVisibility();
}
else if (actor_type == "contour")
else if (actor_type == "overlay") {
this->mOverlayActor->SetVisibility(vis);
}
- else if (actor_type == "fusion") {
+ else if ( (actor_type == "fusion") || (actor_type == "fusionSequence") ){
this->mFusionActor->SetVisibility(vis);
}
else if (actor_type == "contour")
mOverlayActor = NULL;
mOverlayMapper = NULL;
}
- if (actor_type == "fusion") {
+ if ( (actor_type == "fusion") || (actor_type == "fusionSequence") ) {
Renderer->RemoveActor(mFusionActor);
mFusion = NULL;
mFusionActor = NULL;
if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
}
+//also temporarilly disabled...
if (mOverlay && mOverlayActor->GetVisibility()) {
if (mOverlay->GetVTKImages().size() > (unsigned int)t) {
mCurrentOverlayTSlice = t;
mConcatenatedOverlayTransform->Concatenate(mSlicingTransform);
}
}
+//temporarilly disabled for testing fusionSequence
+ //if (mFusion && mFusionActor->GetVisibility()) {
+ // if (mFusion->GetVTKImages().size() > (unsigned int)t) {
+ // mCurrentFusionTSlice = t;
+ // mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice]);
+
+ // // Update fusion transform
+ // mConcatenatedFusionTransform->Identity();
+ // mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[mCurrentFusionTSlice]);
+ // mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
+ // }
+ //}
+ if (mSurfaceCutActors.size() > 0)
+ for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
+ i!=mSurfaceCutActors.end(); i++)
+ (*i)->SetTimeSlice(mCurrentTSlice);
+ UpdateDisplayExtent();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvSlicer::SetFusionSequenceTSlice(int t)
+{
+//QMessageBox::information(NULL, "vvSlicer::SetFusionSequenceTSlice", "ENTER, t = " + QString::number(t) + ", currentFusionTSlice = " + QString::number(mCurrentFusionTSlice));
+ //fusionSequence data is stored behind standard fusion data...
if (mFusion && mFusionActor->GetVisibility()) {
if (mFusion->GetVTKImages().size() > (unsigned int)t) {
mCurrentFusionTSlice = t;
mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
}
}
- if (mSurfaceCutActors.size() > 0)
- for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
- i!=mSurfaceCutActors.end(); i++)
- (*i)->SetTimeSlice(mCurrentTSlice);
+
UpdateDisplayExtent();
}
//------------------------------------------------------------------------------
int t = mCurrentTSlice;
if(mOverlay)
t = std::max(t, mCurrentOverlayTSlice);
- if(mFusion)
- t = std::max(t, mCurrentFusionTSlice);
+ //TODO temporarily desactivated...
+ //if(mFusion)
+ // t = std::max(t, mCurrentFusionTSlice);
return t;
}
//------------------------------------------------------------------------------
}
}
}
-
}
//----------------------------------------------------------------------------
#include <iostream>
#include <vector>
+#include <QString> //TODO delete
+#include <QMessageBox>
+
#include "vvLandmarks.h"
#include "vvImage.h"
#include "vvMesh.h"
void SetLandmarks(vvLandmarks* landmarks);
void SetTSlice(int t);
+
+ void SetFusionSequenceTSlice(int t);
+
void SetSliceOrientation(int orientation);
void AdjustResliceToSliceOrientation(vtkImageReslice *reslice);
int GetTSlice();
#include <vtkCamera.h>
#include <qfileinfo.h>
-
//----------------------------------------------------------------------------
vvSlicerManager::vvSlicerManager(int numberOfSlicers)
{
mFusionLevel = 1000;
mFusionShowLegend = true;
+ mFusionSequenceFrameIndex = -1;
+ mFusionSequenceSpatialSyncFlag = false;
+ mFusionSequenceNbFrames = 0;
+
mLandmarks = NULL;
mLinkedId.resize(0);
mPreviousSlice.resize(numberOfSlicers);
mPreviousTSlice.resize(numberOfSlicers);
mSlicingPreset = WORLD_SLICING;
+
+
}
//----------------------------------------------------------------------------
reader = mFusionReader;
else if(actorType=="vector")
reader = mVectorReader;
+ else if(actorType=="fusionSequence")
+ reader = mFusionSequenceReader;
if(!reader)
return "";
}
//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+bool vvSlicerManager::SetFusionSequence(std::vector<std::string> filenames,int dim, std::string component, vvImageReader::LoadedImageType type)
+{
+ mFusionName = filenames[0];
+ mFusionComponent = component;
+
+ if (dim > mImage->GetNumberOfDimensions()) {
+ mLastError = " Fusion Sequence dimension cannot be greater than reference image!";
+ return false;
+ }
+
+ if (mFusionSequenceReader.IsNull())
+ mFusionSequenceReader = vvImageReader::New();
+
+ mFusionSequenceReader->SetInputFilenames(filenames);
+ mFusionSequenceReader->Update(type);
+
+ //store the initial transform matrices of each frame, and reset them to identity
+ mFusionSequenceListInitialTransformMatrices.clear();
+ for (unsigned i=0 ; i<mFusionSequenceReader->GetOutput()->GetTransform().size() ; i++) {
+ AddFusionSequenceInitialTransformMatrices( mFusionSequenceReader->GetOutput()->GetTransform()[i]->GetMatrix() );
+ mFusionSequenceReader->GetOutput()->GetTransform()[i]->Identity();
+ mFusionSequenceReader->GetOutput()->GetTransform()[i]->Update();
+ }
+
+ //adjust the time slider in the overlay panel
+ mFusionSequenceNbFrames = mFusionSequenceReader->GetOutput()->GetTransform().size()-1; //actually, this is the maximum index...
+ if (mFusionSequenceFrameIndex>=mFusionSequenceNbFrames) {
+ mFusionSequenceFrameIndex=0;
+ }
+
+
+ if (mFusionSequenceReader->GetLastError().size() == 0) {
+ for ( unsigned int i = 0; i < mSlicers.size(); i++) {
+ mSlicers[i]->SetFusion(mFusionSequenceReader->GetOutput());
+ }
+ } else {
+ mLastError = mFusionSequenceReader->GetLastError();
+ return false;
+ }
+ double *fusRange = mFusionSequenceReader->GetOutput()->GetVTKImages()[0]->GetScalarRange();
+ mFusionLevel = (fusRange[0]+fusRange[1])/2;
+ mFusionWindow = fusRange[1]-fusRange[0];
+
+ return true;
+}
+//----------------------------------------------------------------------------
+
//----------------------------------------------------------------------------
bool vvSlicerManager::SetVF(std::string filename)
//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+void vvSlicerManager::SetFusionSequenceTSlice(int slice)
+{
+ for ( unsigned int i = 0; i < mSlicers.size(); i++) {
+ mSlicers[i]->SetFusionSequenceTSlice(slice);
+ UpdateTSlice(i);
+ }
+}
+//----------------------------------------------------------------------------
+
+
//----------------------------------------------------------------------------
void vvSlicerManager::SetNextTSlice(int originating_slicer)
{
else if(actorType == "fusion")
for(unsigned int i=0; i<this->GetImage()->GetTransform().size(); i++)
this->GetSlicer(0)->GetFusion()->GetTransform()[i]->Identity();
+ else if(actorType == "fusionSequence") //TODO: Check what should really be done here
+ for(unsigned int i=0; i<this->GetImage()->GetTransform().size(); i++)
+ this->GetSlicer(0)->GetFusion()->GetTransform()[i]->Identity();
else if(actorType == "vf")
for(unsigned int i=0; i<this->GetImage()->GetTransform().size(); i++)
this->GetVF()->GetTransform()[i]->Identity();
for ( unsigned int i = 0; i < mSlicers.size(); i++) {
mSlicers[i]->SetImage(mImage);
}
+ //TODO: check if this image is involved in a fusion sequence, then the main transform matrix should be updated.
}
//----------------------------------------------------------------------------
}
//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+void vvSlicerManager::ReloadFusionSequence()
+{
+ mFusionSequenceReader->Update(mImage->GetNumberOfDimensions(),mFusionComponent.c_str(),vvImageReader::MERGEDWITHTIME);
+
+ for ( unsigned int i = 0; i < mSlicers.size(); i++) {
+ mSlicers[i]->SetFusion(mFusionSequenceReader->GetOutput());
+ mSlicers[i]->Render();
+ }
+
+ //Update the slider
+ mFusionSequenceNbFrames = mFusionSequenceReader->GetOutput()->GetTransform().size();
+ if (mFusionSequenceFrameIndex>=mFusionSequenceNbFrames) {
+ mFusionSequenceFrameIndex=0;
+ }
+
+ //Update the list of initial transforms
+ //Warning, the main transform will not be updated on reload.........
+ mFusionSequenceListInitialTransformMatrices.clear();
+ for (unsigned i=0 ; i<mFusionSequenceNbFrames ; i++) {
+ this->AddFusionSequenceInitialTransformMatrices( mFusionSequenceReader->GetOutput()->GetTransform()[i]->GetMatrix() );
+ }
+
+ //emit UpdateFusionSequence(mFusionSequenceFrameIndex, mFusionSequenceSpatialSyncFlag, mFusionSequenceNbFrames);
+}
+//----------------------------------------------------------------------------
+
//----------------------------------------------------------------------------
void vvSlicerManager::ReloadOverlay()
if (actor_type =="fusion")
mFusionReader = NULL;
+ if (actor_type =="fusionSequence") {
+ mFusionSequenceReader = NULL;
+ }
+
for (unsigned int i = 0; i < mSlicers.size(); i++)
mSlicers[i]->RemoveActor(actor_type,overlay_index);
double Zover = (z - overlay->GetOrigin()[2]) / overlay->GetSpacing()[2];
valueOver = this->GetScalarComponentAsDouble(overlay, Xover, Yover, Zover);
}
- if (mSlicers[slicer]->GetFusionActor() ) {
- displayFus = 1;
- vtkImageData *fusion = dynamic_cast<vtkImageData*>(mSlicers[slicer]->GetFusionMapper()->GetInput());
- double Xover = (x - fusion->GetOrigin()[0]) / fusion->GetSpacing()[0];
- double Yover = (y - fusion->GetOrigin()[1]) / fusion->GetSpacing()[1];
- double Zover = (z - fusion->GetOrigin()[2]) / fusion->GetSpacing()[2];
- valueFus = this->GetScalarComponentAsDouble(fusion, Xover, Yover, Zover);
- }
+\r
+ if (mSlicers[slicer]->GetFusionActor() ) {\r
+ displayFus = 1;\r
+ vtkImageData *fusion = dynamic_cast<vtkImageData*>(mSlicers[slicer]->GetFusionMapper()->GetInput());\r
+ double Xover = (x - fusion->GetOrigin()[0]) / fusion->GetSpacing()[0];\r
+ double Yover = (y - fusion->GetOrigin()[1]) / fusion->GetSpacing()[1];\r
+ double Zover = (z - fusion->GetOrigin()[2]) / fusion->GetSpacing()[2];\r
+ valueFus = this->GetScalarComponentAsDouble(fusion, Xover, Yover, Zover);\r
+ }\r
+
+
emit UpdatePosition(mSlicers[slicer]->GetCursorVisibility(),
x,y,z,X,Y,Z,value);
emit UpdateVector(displayVec,xVec, yVec, zVec, valueVec);
void vvSlicerManager::SetColorMap(int colormap)
{
double range[2];
+
range[0] = mSlicers[0]->GetInput()->GetScalarRange()[0];
range[1] = mSlicers[0]->GetInput()->GetScalarRange()[1];
}
vtkWindowLevelLookupTable* fusLUT = NULL;
if (mSlicers[0]->GetFusion()) { // && mFusionColorMap >= 0) {
- fusLUT = vtkWindowLevelLookupTable::New();
+ fusLUT = vtkWindowLevelLookupTable::New();
double fusRange [2];
fusRange[0] = mFusionLevel - mFusionWindow/2;
fusRange[1] = mFusionLevel + mFusionWindow/2;
- double* frange = mFusionReader->GetOutput()->GetVTKImages()[0]->GetScalarRange();
- fusLUT->SetTableRange(frange);
+
+ //check whether it is actually a fusionSequence or a fusion, before invoking mFusionReader...
+ double* frange;
+ if (mFusionReader.IsNull()) frange = mFusionSequenceReader->GetOutput()->GetVTKImages()[0]->GetScalarRange();
+ else frange = mFusionReader->GetOutput()->GetVTKImages()[0]->GetScalarRange();
+
+ fusLUT->SetTableRange(frange);
fusLUT->SetValueRange(1,1);
fusLUT->SetSaturationRange(1,1);
fusLUT->SetAlphaRange(1, 1);
bool SetOverlay(std::vector<std::string> filenames, int dim, std::string component, vvImageReader::LoadedImageType type);
bool SetFusion(std::string filename, int dim, std::string component);
+ bool SetFusionSequence(std::vector<std::string> filenames, int dim, std::string component, vvImageReader::LoadedImageType type);
///Set a VF by loading it from the disk
bool SetVF(std::string filename);
///Set a VF from memory
void SetPreviousTSlice(int originating_slicer);
void SetTSliceInSlicer(int tslice, int slicer);
+ void SetFusionSequenceTSlice(int slice);
+
void GenerateDefaultLookupTable();
void SetColorWindow(double s);
void SetColorLevel(double s);
mFusionShowLegend = show;
}
+
+ //set/get fusionSequence related data
+ void SetFusionSequenceFrameIndex(int sequenceFrameIndex) { mFusionSequenceFrameIndex = sequenceFrameIndex; }
+ void SetFusionSequenceSpatialSyncFlag(bool spatialSync) { mFusionSequenceSpatialSyncFlag = spatialSync; }
+ void SetFusionSequenceLength(unsigned int fusionSequenceNbFrames) { mFusionSequenceNbFrames = fusionSequenceNbFrames; }
+ void SetFusionSequenceMainTransformMatrix(vtkSmartPointer<vtkMatrix4x4> mat) {
+ mFusionSequenceMainTransform = vtkSmartPointer<vtkMatrix4x4>::New();
+ mFusionSequenceMainTransform->DeepCopy(mat);
+ }
+ void AddFusionSequenceInitialTransformMatrices(vtkSmartPointer<vtkMatrix4x4> mat) {
+ vtkSmartPointer<vtkMatrix4x4> tmpMat = vtkSmartPointer<vtkMatrix4x4>::New();
+ tmpMat->DeepCopy(mat);
+ mFusionSequenceListInitialTransformMatrices.push_back( tmpMat );
+ }
+
+ int GetFusionSequenceFrameIndex() { return mFusionSequenceFrameIndex; }
+ bool GetFusionSequenceSpatialSyncFlag() { return mFusionSequenceSpatialSyncFlag; }
+ unsigned int GetFusionSequenceNbFrames() { return mFusionSequenceNbFrames; }
+ const vtkSmartPointer<vtkMatrix4x4>& GetFusionSequenceMainTransformMatrix() {return mFusionSequenceMainTransform;}
+ const std::vector< vtkSmartPointer<vtkMatrix4x4> >& GetFusionSequenceInitialTransformMatrices() {return mFusionSequenceListInitialTransformMatrices;}
+ const vtkSmartPointer<vtkMatrix4x4>& GetFusionSequenceInitialTransformMatrixAtFrame(unsigned i) {
+ return mFusionSequenceListInitialTransformMatrices[i];
+ }
+
double GetColorWindow() const;
double GetColorLevel() const;
double GetOverlayColorWindow() const;
return mFusionLevel;
}
+
void SetCursorAndCornerAnnotationVisibility(int s);
void UpdateViews(int current, int slicer);
void UpdateLinked(int slicer);
void Reload();
void ReloadOverlay();
void ReloadFusion();
+ void ReloadFusionSequence();
void ReloadVF();
void Activated();
void UpdateVector(int display, double x, double y, double z, double value);
void UpdateOverlay(int display, double valueOver, double valueRef);
void UpdateFusion(int display, double valueFus);
+ void UpdateFusionSequence(int fusionSequenceFrameIndex, bool fusionSequenceSpatialSyncFlag, unsigned int fusionSequenceNbFrames);
void MousePositionUpdatedSignal(int slicer);
void KeyPressedSignal(std::string KeyPressed);
void UpdateOrientation(int slicer, int orientation);
vvImageReader::Pointer mReader;
vvImageReader::Pointer mOverlayReader;
vvImageReader::Pointer mFusionReader;
+ vvImageReader::Pointer mFusionSequenceReader;
vvImageReader::Pointer mVectorReader;
vvImage::Pointer mImage;
vvImage::Pointer mVF;
double mFusionLevel;
bool mFusionShowLegend;
+ //fusionSequence related data
+ int mFusionSequenceFrameIndex;
+ bool mFusionSequenceSpatialSyncFlag;
+ unsigned int mFusionSequenceNbFrames;
+ vtkSmartPointer<vtkMatrix4x4> mFusionSequenceMainTransform;
+ std::vector< vtkSmartPointer<vtkMatrix4x4> > mFusionSequenceListInitialTransformMatrices;
+
int mPreset;
SlicingPresetType mSlicingPreset;
vvImageReader::LoadedImageType mType;
#ifndef VVTOOLBASEBASE_H
#define VVTOOLBASEBASE_H
+#include <algorithm>
#include "vvMainWindowBase.h"
#include "vvToolCreatorBase.h"
class QXmlStreamWriter;