ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/tools ${PROJECT_BINARY_DIR}/tools)
ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/segmentation ${PROJECT_BINARY_DIR}/segmentation)
ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/registration ${PROJECT_BINARY_DIR}/registration)
+ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/scripts ${PROJECT_BINARY_DIR}/scripts)
ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/tests ${PROJECT_BINARY_DIR}/tests)
ENDIF(BUILD_TESTING)
-#=========================================================
-# Install scripts when running make install
-SET(SCRIPTS
- ${CLITK_SOURCE_DIR}/scripts/calculate_motion_amplitude.sh
- ${CLITK_SOURCE_DIR}/scripts/midp_common.sh
- ${CLITK_SOURCE_DIR}/scripts/registration.sh
- ${CLITK_SOURCE_DIR}/scripts/create_midP.sh
- ${CLITK_SOURCE_DIR}/scripts/create_midP-2.0.sh
- ${CLITK_SOURCE_DIR}/scripts/create_mhd_4D.sh
- ${CLITK_SOURCE_DIR}/scripts/create_mhd_4D_pattern.sh
- ${CLITK_SOURCE_DIR}/scripts/create_midP_masks.sh
- ${CLITK_SOURCE_DIR}/scripts/create_midP_masks-2.0.sh
- ${CLITK_SOURCE_DIR}/scripts/pts_to_landmarks.sh
- ${CLITK_SOURCE_DIR}/scripts/create_mhd_3D.sh
- ${CLITK_SOURCE_DIR}/scripts/dicom_info.sh
-)
-
-INSTALL (FILES ${SCRIPTS} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
FIND_PACKAGE(VTK REQUIRED)
IF(VTK_FOUND)
INCLUDE("${VTK_USE_FILE}")
- IF(VTK_VERSION VERSION_LESS 5.6.0)
+ IF(VTK_VERSION VERSION_LESS 5.8.0)
SET ( VTK_LIBRARIES
vtkCommon
vtkRendering
vtkWidgets
vtkImaging
vtkHybrid
- vtkQVTK
)
+ ENDIF(VTK_VERSION VERSION_LESS 5.8.0)
+ IF(VTK_VERSION VERSION_LESS 5.6.0)
+ SET ( VTK_LIBRARIES
+ ${VTK_LIBRARIES}
+ vtkQVTK
+ )
ENDIF(VTK_VERSION VERSION_LESS 5.6.0)
ELSE(VTK_FOUND)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
--- /dev/null
+#=========================================================
+# Install scripts when running make install
+SET(SCRIPTS
+ ${CLITK_SOURCE_DIR}/scripts/calculate_motion_amplitude.sh
+ ${CLITK_SOURCE_DIR}/scripts/calculate_contour_stats.sh
+ ${CLITK_SOURCE_DIR}/scripts/midp_common.sh
+ ${CLITK_SOURCE_DIR}/scripts/registration.sh
+ ${CLITK_SOURCE_DIR}/scripts/create_midP.sh
+ ${CLITK_SOURCE_DIR}/scripts/create_midP-2.0.sh
+ ${CLITK_SOURCE_DIR}/scripts/create_mhd_4D.sh
+ ${CLITK_SOURCE_DIR}/scripts/create_mhd_4D_pattern.sh
+ ${CLITK_SOURCE_DIR}/scripts/create_midP_masks.sh
+ ${CLITK_SOURCE_DIR}/scripts/create_midP_masks-2.0.sh
+ ${CLITK_SOURCE_DIR}/scripts/pts_to_landmarks.sh
+ ${CLITK_SOURCE_DIR}/scripts/create_mhd_3D.sh
+ ${CLITK_SOURCE_DIR}/scripts/dicom_info.sh
+)
+
+INSTALL (FILES ${SCRIPTS} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
--- /dev/null
+#! /bin/bash +x
+
+select_contour_gui()
+{
+ local roi_list=$@
+ roi=`zenity --list --title="Available Contours" --column="Please choose a contour:" $roi_list`
+ case $? in
+ 0)
+ if [ -z $roi ]
+ then
+ zenity --warning --text="You must choose one contour."
+ select_contour $roi_list
+ else
+ rtstruct_roi_name=$roi
+ fi;;
+ 1)
+ if zenity --question --text="Do you really wish to quit?"
+ then
+ exit
+ else
+ select_contour $roi_list
+ fi;;
+ -1)
+ zenity --error --text="Unexpected error. Please relaunch the application."
+ exit;;
+ esac
+}
+
+select_contour()
+{
+ local roi_list=$@
+ echo "Available Contours:"
+ for r in $roi_list; do
+ echo $r
+ done
+
+ echo "Please choose a contour number:"
+ read rtstruct_roi_number
+}
+
+select_roi()
+{
+ rtstruct_roi_name_list=( `clitkDicomInfo ${rtstruct_file} | grep "3006|0026" | cut -d '[' -f 4 | sed 's/| V 3006|0026[LO] [ROI Name] \|]//'` )
+ rtstruct_roi_number_list=( `clitkDicomInfo ${rtstruct_file} | grep "3006|0022" | cut -d '[' -f 4 | sed 's/| V 3006|0026[LO] [ROI Number] \|]//'` )
+ rtstruct_roi_list=( )
+ for i in $(seq 0 1 $(( ${#rtstruct_roi_name_list[@]} - 1 ))); do
+ rtstruct_roi_list[$i]=${rtstruct_roi_number_list[$i]}:${rtstruct_roi_name_list[$i]}
+ done
+
+ if [ $gui_mode = 1 ]; then
+ select_contour_gui ${rtstruct_roi_list[@]}
+ rtstruct_roi=`echo ${rtstruct_roi_name} | cut -d ':' -f 1`
+ rtstruct_roi_name=`echo ${rtstruct_roi_name} | cut -d ':' -f 2`
+ else
+ select_contour ${rtstruct_roi_list[@]}
+ rtstruct_roi=$rtstruct_roi_number
+ rtstruct_roi_name=${rtstruct_roi_name_list[$(( $rtstruct_roi_number - 1))]}
+ fi
+}
+
+############# main
+
+if echo $* | grep "\-h"; then
+ echo Usage: calculate_motion_amplitude.sh { RTSTRUCT_FILE REFERENCE_IMAGE | --gui }
+
+ exit 0
+fi
+
+
+rtstruct_roi=0
+
+if echo $* | grep "\-\-gui" > /dev/null 2>&1; then
+ if [ $# != 1 ]; then
+ echo Invalid arguments. Type \'`basename $0` -h\' for help
+ exit -1
+ fi
+
+ gui_mode=1
+ rtstruct_file=`zenity --file-selection --title="Select RT Struct file."`
+ select_roi
+ rtstruct_ref_image=`zenity --file-selection --title="Select Reference Image."`
+else
+ if [ $# != 2 ]; then
+ echo Invalid arguments. Type \'`basename $0` -h\' for help
+ exit -1
+ fi
+
+ gui_mode=0
+ rtstruct_file=$1
+ rtstruct_ref_image=$2
+ select_roi
+fi
+
+
+#echo "Processing \"${rtstruct_roi_list[$roi_struct]}\"..."
+# create ROI mask from rtstruct
+roi_mask=roi_${rtstruct_roi_name}.mhd
+clitkDicomRTStruct2Image -i ${rtstruct_file} -o ${roi_mask} -j ${rtstruct_ref_image} -r ${rtstruct_roi} 2> /tmp/err.txt
+if cat /tmp/err.txt | grep -q "No ROI"; then
+ echo Invalid contour number.
+ exit -3
+fi
+
+# guarantees the same sampling for roi mask and vector image
+roi_mask2=resampled_${roi_mask}
+clitkResampleImage -i ${roi_mask} -o ${roi_mask2} --like ${rtstruct_ref_image}
+
+# calculate stats
+clitkImageStatistics -i ${rtstruct_ref_image} -m ${roi_mask2} --verbose 2> /dev/null | tail -n 8 > /tmp/result.txt
+
+if [ $gui_mode = 1 ]; then
+ cat /tmp/result.txt | zenity --text-info --title "Restuls for \"${rtstruct_roi_name}\""
+else
+ echo "Restuls for \"${rtstruct_roi_name}\""
+ cat /tmp/result.txt
+fi
+
+rm `basename $roi_mask .mhd`.{mhd,raw}
+rm `basename $roi_mask2 .mhd`.{mhd,raw}
+rm /tmp/err.txt
+rm /tmp/result.txt
int orientation = ComputeCurrentOrientation();
position[orientation] = -mDepth;
- for(uint i=0; i<mSquaresActorList.size(); i++)
+ for(unsigned int i=0; i<mSquaresActorList.size(); i++)
mSquaresActorList[i]->SetPosition(position);
}
//------------------------------------------------------------------------------
w2i->Update();
vtkImageData *image = w2i->GetOutput();
- const char *ext = fileName.toStdString().c_str() + strlen(fileName.toStdString().c_str()) - 4;
+ std::string ext(itksys::SystemTools::GetFilenameLastExtension(fileName.toStdString()));
// Image
vtkImageWriter *imgwriter = NULL;
- if (!strcmp(ext, ".bmp"))
+ if (ext==".bmp")
imgwriter = vtkBMPWriter::New();
- else if (!strcmp(ext, ".tif"))
+ else if (ext==".tif")
imgwriter = vtkTIFFWriter::New();
- else if (!strcmp(ext, ".ppm"))
+ else if (ext==".ppm")
imgwriter = vtkPNMWriter::New();
- else if (!strcmp(ext, ".png"))
+ else if (ext==".png")
imgwriter = vtkPNGWriter::New();
- else if (!strcmp(ext, ".jpg"))
+ else if (ext==".jpg")
imgwriter = vtkJPEGWriter::New();
// Snapshot image if not null
// Video
vtkGenericMovieWriter *vidwriter = NULL;
#if CLITK_EXPERIMENTAL == 1
- if (!strcmp(ext, ".gif")) {
+ if (ext==".gif") {
vvAnimatedGIFWriter *gif = vvAnimatedGIFWriter::New();
vidwriter = gif;
}
#endif
#ifdef VTK_USE_VIDEO_FOR_WINDOWS
- if (!strcmp(ext, ".avi")) {
+ if (ext==".avi") {
vtkAVIWriter *mpg = vtkAVIWriter::New();
vidwriter = mpg;
mpg->SetQuality(2);
}
#endif
#ifdef VTK_USE_FFMPEG_ENCODER
- if (!strcmp(ext, ".avi")) {
+ if (ext==".avi") {
vtkFFMPEGWriter *mpg = vtkFFMPEGWriter::New();
vidwriter = mpg;
mpg->SetQuality(2);
}
#endif
#ifdef VTK_USE_MPEG2_ENCODER
- if (!strcmp(ext, ".mpg")) {
+ if (ext==".mpg") {
vtkMPEG2Writer *mpg = vtkMPEG2Writer::New();
vidwriter = mpg;
}
// Local copy of extent
int w_ext[6];
- copyExtent(GetExtent(), w_ext);
+ int* ext = GetExtent();
+ copyExtent(ext, w_ext);
// Set slice value
- w_ext[ this->SliceOrientation*2 ] = this->Slice;
- w_ext[ this->SliceOrientation*2+1 ] = this->Slice;
+ int s = this->Slice > ext[this->SliceOrientation*2+1] ? ext[this->SliceOrientation*2 + 1] : this->Slice;
+ w_ext[ this->SliceOrientation*2 ] = s;
+ w_ext[ this->SliceOrientation*2+1 ] = s;
// Image actor
this->ImageActor->SetDisplayExtent(w_ext);
dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
// Round to nearest
- targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
+ //targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
+ targetExtent[i] = itk::Math::Floor<double>(dExtents[i]);
}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void vvSlicer::Render()
{
- if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay && !this->mFusion) {
+ if (this->mFusion) {
+ legend->SetLookupTable(this->GetFusionMapper()->GetLookupTable());
+ legend->UseOpacityOn();
+ legend->SetVisibility(1);
+ }
+ else if (this->GetWindowLevel()->GetLookupTable()) {// && !this->mOverlay && !this->mFusion) {
legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
+ legend->UseOpacityOff();
legend->SetVisibility(1);
} else legend->SetVisibility(0);
double v[4];
// set color table transparency
+ double alpha_range=(double)mFusionThresOpacity/10;
double range_end = frange[0] + (double)mFusionThresOpacity*(frange[1] - frange[0])/100;
- double curr_value = frange[0];
+ double curr_value = fusRange[0];
int nvalues = fusLUT->GetNumberOfTableValues();
- //for (double i = frange[0]; i <= alpha_range_end; i++) {
for (double i = 0; curr_value < range_end; i++) {
fusLUT->GetTableValue(i, v);
v[3] = 0;
+ //if (curr_value >= -alpha_range && curr_value <= alpha_range) v[3] = pow(fabs(curr_value/alpha_range),2);
+ //else v[3] = 1;
fusLUT->SetTableValue(i, v);
- curr_value += (frange[1] - frange[0])/nvalues;
+ curr_value += (fusRange[1] - fusRange[0])/nvalues;
}
}
for ( unsigned int i = 0; i < mSlicers.size(); i++) {