Index: v3d_main/basic_c_fun/v3d_basicdatatype.h
===================================================================
--- v3d_main/basic_c_fun/v3d_basicdatatype.h	(revision 163)
+++ v3d_main/basic_c_fun/v3d_basicdatatype.h	(working copy)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c)2006-2010  Hanchuan Peng (Janelia Farm, Howard Hughes Medical Institute).  
+ * Copyright (c)2006-2010  Hanchuan Peng (Janelia Farm, Howard Hughes Medical Institute).
  * All rights reserved.
  */
 
@@ -7,7 +7,7 @@
 /************
                                             ********* LICENSE NOTICE ************
 
-This folder contains all source codes for the V3D project, which is subject to the following conditions if you want to use it. 
+This folder contains all source codes for the V3D project, which is subject to the following conditions if you want to use it.
 
 You will ***have to agree*** the following terms, *before* downloading/using/running/editing/changing any portion of codes in this package.
 
@@ -48,7 +48,7 @@
 typedef          float       float32;
 typedef          double      float64;
 
-//2010-05-19: by Hanchuan Peng. add the MSVC specific version # (vc 2008 has a _MSC_VER=1500) and win64 macro. 
+//2010-05-19: by Hanchuan Peng. add the MSVC specific version # (vc 2008 has a _MSC_VER=1500) and win64 macro.
 //Note that _WIN32 seems always defined for any windows application.
 //For more info see page for example: http://msdn.microsoft.com/en-us/library/b0084kay%28VS.80%29.aspx
 
@@ -68,8 +68,8 @@
 
 #endif
 
-enum ImagePixelType {V3D_UNKNOWN, V3D_UINT8, V3D_UINT16, V3D_FLOAT32};
-enum TimePackType {TIME_PACK_NONE,TIME_PACK_Z,TIME_PACK_C}; 
+enum ImagePixelType {V3D_UNKNOWN, V3D_UINT8, V3D_UINT16, V3D_UINT32, V3D_FLOAT32};
+enum TimePackType {TIME_PACK_NONE,TIME_PACK_Z,TIME_PACK_C};
 
 
 #endif
Index: v3d_main/basic_c_fun/mg_image_lib.h
===================================================================
--- v3d_main/basic_c_fun/mg_image_lib.h	(revision 163)
+++ v3d_main/basic_c_fun/mg_image_lib.h	(working copy)
@@ -51,6 +51,7 @@
 #define GREY   1   // 1-byte grey-level image or stack
 #define GREY16 2   // 2-byte grey-level image or stack
 #define COLOR  3   // 3-byte RGB image or stack
+#define GREY32 4   // 2-byte grey-level image or stack
 
 #define GREY_CHANNEL  0   // Images and stacks either have a single grey channel or 3 color channels
 #define RED_CHANNEL   0
@@ -68,7 +69,7 @@
 
 typedef struct
   { int      kind;
-    int      width; 
+    int      width;
     int      height;
     uint8   *array;   // Array of pixel values lexicographically ordered on (y,x,c).
   } Image;            //    Pixel (0,0) is the lower left-hand corner of an image.
@@ -83,18 +84,39 @@
 #define IMAGE_PIXEL_16(img,x,y,c) \
       ((uint16 *) ((img)->array + (((y)*(img)->width + (x))*(img)->kind + (c))))
 
+#define IMAGE_PIXEL_32(img,x,y,c) \
+      ((uint32 *) ((img)->array + (((y)*(img)->width + (x))*(img)->kind + (c))))
+
 static inline int Get_Image_Pixel(Image *image, int x, int y, int c)
-{ if (image->kind == GREY16)
-    return (*IMAGE_PIXEL_16(image,x,y,c));
-  else
-    return (*IMAGE_PIXEL_8(image,x,y,c));
+{
+  switch( image->kind )
+    {
+    case GREY:
+      return (*IMAGE_PIXEL_8(image,x,y,c));
+      break;
+    case GREY16:
+      return (*IMAGE_PIXEL_16(image,x,y,c));
+      break;
+    case GREY32:
+      return (*IMAGE_PIXEL_32(image,x,y,c));
+      break;
+    }
 }
 
 static inline void Set_Image_Pixel(Image *image, int x, int y, int c, int v)
-{ if (image->kind == GREY16)
-    *IMAGE_PIXEL_16(image,x,y,c) = v;
-  else
-    *IMAGE_PIXEL_8(image,x,y,c) = v;
+{
+  switch( image->kind )
+    {
+    case GREY:
+      *IMAGE_PIXEL_8(image,x,y,c) = v;
+      break;
+    case GREY16:
+      *IMAGE_PIXEL_16(image,x,y,c) = v;
+      break;
+    case GREY32:
+      *IMAGE_PIXEL_32(image,x,y,c) = v;
+      break;
+    }
 }
 
   /*  Basic I/O primitives:
@@ -173,18 +195,40 @@
       ((uint16 *) ((img)->array +   \
            ((((z)*(img)->height + (y))*(img)->width + (x))*(img)->kind + (c))))
 
+#define STACK_PIXEL_32(img,x,y,z,c) \
+      ((uint32 *) ((img)->array +   \
+           ((((z)*(img)->height + (y))*(img)->width + (x))*(img)->kind + (c))))
+
 static inline int Get_Stack_Pixel(Stack *stack, int x, int y, int z, int c)
-{ if (stack->kind == GREY16)
-    return (*STACK_PIXEL_16(stack,x,y,z,c));
-  else
-    return (*STACK_PIXEL_8(stack,x,y,z,c));
+{
+  switch( stack->kind )
+    {
+    case GREY:
+      return (*STACK_PIXEL_8(stack,x,y,z,c));
+      break;
+    case GREY16:
+      return (*STACK_PIXEL_16(stack,x,y,z,c));
+      break;
+    case GREY32:
+      return (*STACK_PIXEL_32(stack,x,y,z,c));
+      break;
+    }
 }
 
 static inline void Set_Stack_Pixel(Stack *stack, int x, int y, int z, int c, int v)
-{ if (stack->kind == GREY16)
-    *STACK_PIXEL_16(stack,x,y,z,c) = v;
-  else
-    *STACK_PIXEL_8(stack,x,y,z,c) = v;
+{
+  switch( stack->kind )
+    {
+    case GREY:
+      *STACK_PIXEL_8(stack,x,y,z,c) = v;
+      break;
+    case GREY16:
+      *STACK_PIXEL_16(stack,x,y,z,c) = v;
+      break;
+    case GREY32:
+      *STACK_PIXEL_32(stack,x,y,z,c) = v;
+      break;
+    }
 }
 
   /*   Stack Library:
Index: v3d_main/basic_c_fun/stackutil.cpp
===================================================================
--- v3d_main/basic_c_fun/stackutil.cpp	(revision 163)
+++ v3d_main/basic_c_fun/stackutil.cpp	(working copy)
@@ -1917,6 +1917,11 @@
 				datatype = 1;
 				break;
 
+			case GREY32:
+				sz[3] = 1;
+				datatype = 4;
+				break;
+
 			default:
 				printf("The type of tif file is not supported in this version.\n");
 				if (sz) {delete sz; sz=0;}
Index: v3d_main/basic_c_fun/basic_4dimage.cpp
===================================================================
--- v3d_main/basic_c_fun/basic_4dimage.cpp	(revision 163)
+++ v3d_main/basic_c_fun/basic_4dimage.cpp	(working copy)
@@ -41,10 +41,8 @@
 #include "stackutil.h"
 #include "basic_4dimage.h"
 
-typedef unsigned short int USHORTINT16;
 
 
-
 void Image4DSimple::loadImage(char filename[])
 {
 	cleanExistData(); /* note that this variable must be initialized as NULL. */
@@ -117,8 +115,10 @@
 			datatype = V3D_UINT8; //FLOAT32;
 			break;
 
+    // FIXME: Deal with V3D_UINT32 case too ...
+
 		default:
-			v3d_msg("The data type is not UINT8, UINT16 or FLOAT32. Something wrong with the program, -- should NOT display this message at all. Check your program. \n");
+			v3d_msg("The data type is not UINT8, UINT16, UINT32, or FLOAT32. Something wrong with the program, -- should NOT display this message at all. Check your program. \n");
 			if (tmp_sz) {delete []tmp_sz; tmp_sz=0;}
 			return;
 	}
@@ -165,7 +165,7 @@
 
 	if (datatype==2) //following is new method 090718, PHC
 	{
-		USHORTINT16 * tmpimg = (USHORTINT16 *)img;
+		uint16 * tmpimg = (uint16 *)img;
 		V3DLONG i; double maxvv=tmpimg[0];
 		for (i=0;i<totalunits;i++)
 		{
Index: v3d_main/basic_c_fun/basic_4dimage.h
===================================================================
--- v3d_main/basic_c_fun/basic_4dimage.h	(revision 163)
+++ v3d_main/basic_c_fun/basic_4dimage.h	(working copy)
@@ -93,17 +93,18 @@
 	V3DLONG getTotalUnitNumber() {return sz0*sz1*sz2*sz3;}
 	V3DLONG getTotalUnitNumberPerPlane() {return sz0*sz1;}
 	V3DLONG getTotalUnitNumberPerChannel() {return sz0*sz1*sz2;}
-	V3DLONG getUnitBytes()
+	V3DLONG getUnitBytes() const // pixel size in bytes
 	{
 		switch (datatype)
 		{
-			case V3D_UINT8: return 1;
-			case V3D_UINT16: return 2;
-			case V3D_FLOAT32: return 4;
+			case V3D_UINT8: return sizeof(uint8);
+			case V3D_UINT16: return sizeof(uint16);
+			case V3D_UINT32: return sizeof(uint32);
+			case V3D_FLOAT32: return sizeof(float);
 			default: return 1;
 		}
 	}
-	V3DLONG getTotalBytes() {return getUnitBytes()*sz0*sz1*sz2*sz3;}
+	V3DLONG getTotalBytes() const { return getUnitBytes()*sz0*sz1*sz2*sz3; }
 	unsigned char * getRawDataAtChannel(V3DLONG cid)
 	{
 		V3DLONG myid = cid; if (myid<0) myid=0; else if (myid>=sz3) myid = sz3-1;
@@ -113,14 +114,15 @@
 	virtual bool valid() {
     return (
       !data1d ||
-       sz0<=0 ||  
+       sz0<=0 ||
        sz1<=0 ||
        sz2<=0 ||
        sz3<=0 ||
        b_error ||
-     (datatype!=V3D_UINT8 && 
-      datatype!=V3D_UINT16 && 
-      datatype!=V3D_FLOAT32)) ?  false : true; 
+     (datatype!=V3D_UINT8 &&
+      datatype!=V3D_UINT16 &&
+      datatype!=V3D_UINT32 &&
+      datatype!=V3D_FLOAT32)) ?  false : true;
     }
 	double getRezX() {return rez_x;}
 	double getRezY() {return rez_y;}
@@ -149,7 +151,7 @@
   }
 	bool setData(unsigned char *p, V3DLONG s0, V3DLONG s1, V3DLONG s2, V3DLONG s3, ImagePixelType dt)
 	{
-		if (p && s0>0 && s1>0 && s2>0 && s3>0 && (dt==V3D_UINT8 || dt==V3D_UINT16 || dt==V3D_FLOAT32))
+		if (p && s0>0 && s1>0 && s2>0 && s3>0 && (dt==V3D_UINT8 || dt==V3D_UINT16 || dt==V3D_UINT32 ||dt==V3D_FLOAT32))
 			if (setNewRawDataPointer(p))
 			{
 				setXDim(s0);
Index: v3d_main/basic_c_fun/v3d_interface.h
===================================================================
--- v3d_main/basic_c_fun/v3d_interface.h	(revision 163)
+++ v3d_main/basic_c_fun/v3d_interface.h	(working copy)
@@ -62,6 +62,7 @@
 #include "v3d_global_preference.h"
 #include "v3d_message.h"
 
+
 struct V3DPluginArgItem
 {
 	QString type;	void * p;
@@ -194,7 +195,7 @@
 
 
 //a function for considering the global setting for data conversion
-template <class T> bool setPluginOutputAndDisplayUsingGlobalSetting(T * pluginoutputimg1d, V3DLONG sz0, V3DLONG sz1, V3DLONG sz2, V3DLONG sz3, V3DPluginCallback & callback)
+template <class T> bool setPluginOutputAndDisplayUsingGlobalSetting(T * pluginoutputimg1d, V3DLONG sz0, V3DLONG sz1, V3DLONG sz2, V3DLONG sz3, ImagePixelType datatype, V3DPluginCallback & callback)
 {
 	if (!pluginoutputimg1d || sz0<=0 || sz1<=0 || sz2<=0 || sz3<=0 )
 	{
@@ -256,13 +257,13 @@
 			for (i=0; i<totalunits; ++i)
 				output1d[i] = (unsigned char)(pluginoutputimg1d[i]);
 		}
-		else //not convert to unsigned char, but to float
+		else // just keep the same type, but copy the buffer
 		{
-			float * output1d_float = new float [totalunits];
+			T * output1d_float = new T [totalunits];
 			output1d = (unsigned char *)output1d_float;
 
 			for (i=0; i<totalunits; ++i)
-				output1d_float[i] = (float)(pluginoutputimg1d[i]);
+				output1d_float[i] = pluginoutputimg1d[i];
 		}
 	}
 
@@ -275,7 +276,7 @@
 	}
 	else
 	{
-		p4DImage.setData(output1d, sz0, sz1, sz2, sz3, V3D_FLOAT32);
+		p4DImage.setData(output1d, sz0, sz1, sz2, sz3, datatype );
 	}
 
 	v3dhandle mywin = ( gs.b_plugin_dispResInNewWindow ) ? callback.newImageWindow() : callback.currentImageWindow();
@@ -293,7 +294,11 @@
 	V3DLONG i;
 	for (i=0; i<pd.size(); i++)
 	{
-		if (!pd[i].data1d || pd[i].sz0<=0 || pd[i].sz1<=0 || pd[i].sz2<=0 || (pd[i].datatype!=V3D_UINT8 && pd[i].datatype!=V3D_UINT16 && pd[i].datatype!=V3D_FLOAT32) )
+		if (!pd[i].data1d || pd[i].sz0<=0 || pd[i].sz1<=0 || pd[i].sz2<=0 ||
+        (pd[i].datatype!=V3D_UINT8 &&
+         pd[i].datatype!=V3D_UINT16 &&
+         pd[i].datatype!=V3D_UINT32 &&
+         pd[i].datatype!=V3D_FLOAT32) )
 		{
 			v3d_msg(QString("The %1 channel of the input to assembleProcessedChannels2Image4DClass() is invalid. Don't output the plugin results.\n").arg(i));
 			return false;
@@ -307,10 +312,33 @@
 			}
 		}
 	}
+
 	V3DLONG mysz0 = pd[0].sz0, mysz1 = pd[0].sz1, mysz2 = pd[0].sz2, mysz3 = pd.size();
 	ImagePixelType curdatatype = pd[0].datatype;
-	V3DLONG nunitbytes = 1; if (curdatatype==V3D_UINT16) nunitbytes=2; else if (curdatatype==V3D_FLOAT32) nunitbytes=4;
+
+	V3DLONG nunitbytes = 1;
+
+  switch( curdatatype )
+    {
+    case V3D_UINT8:
+      nunitbytes = 1;
+      break;
+    case V3D_UINT16:
+      nunitbytes = 2;
+      break;
+    case V3D_UINT32:
+      nunitbytes = 4;
+      break;
+    case V3D_FLOAT32:
+      nunitbytes = 4;
+      break;
+    case V3D_UNKNOWN:
+      // What is the proper error management to do here ?
+      break;
+    }
+
 	V3DLONG nchanbytes = mysz0*mysz1*mysz2*nunitbytes;
+
 	unsigned char *pout = 0;
 
 	try {
@@ -331,16 +359,21 @@
 			pdst[j] = psrc[j];
 	}
 
+  bool result = false;
+
 	//now set V3D display
 	switch (curdatatype)
 	{
-		case V3D_UINT8:   return setPluginOutputAndDisplayUsingGlobalSetting(pout, mysz0, mysz1, mysz2, mysz3, cb); break;
-		case V3D_UINT16:  return setPluginOutputAndDisplayUsingGlobalSetting((unsigned short int *)pout, mysz0, mysz1, mysz2, mysz3, cb); break;
-		case V3D_FLOAT32: return setPluginOutputAndDisplayUsingGlobalSetting((float *)pout, mysz0, mysz1, mysz2, mysz3, cb); break;
-		default: return false;
+		case V3D_UINT8:   result = setPluginOutputAndDisplayUsingGlobalSetting((uint8  *)pout, mysz0, mysz1, mysz2, mysz3, curdatatype, cb); break;
+		case V3D_UINT16:  result = setPluginOutputAndDisplayUsingGlobalSetting((uint16 *)pout, mysz0, mysz1, mysz2, mysz3, curdatatype, cb); break;
+		case V3D_UINT32:  result = setPluginOutputAndDisplayUsingGlobalSetting((uint32 *)pout, mysz0, mysz1, mysz2, mysz3, curdatatype, cb); break;
+		case V3D_FLOAT32: result = setPluginOutputAndDisplayUsingGlobalSetting((float  *)pout, mysz0, mysz1, mysz2, mysz3, curdatatype, cb); break;
+		default: break;
 	}
 
-	return false;
+  delete [] pout;
+
+	return result;
 }
 
 
Index: v3d_main/v3d/dialog_keypoint_features.h
===================================================================
--- v3d_main/v3d/dialog_keypoint_features.h	(revision 163)
+++ v3d_main/v3d/dialog_keypoint_features.h	(working copy)
@@ -154,7 +154,8 @@
 		}
 
 		float **** data4d_float32 = 0;
-		USHORTINT16 **** data4d_uint16 = 0;
+		uint16 **** data4d_uint16 = 0;
+		uint32 **** data4d_uint32 = 0;
 		unsigned char **** data4d_uint8 = 0;
 
 		int b_win_shape=1; //0 for cube and 1 for sphere for pca computation
@@ -190,7 +191,7 @@
 
 			case V3D_UINT16:
 
-				data4d_uint16 = (USHORTINT16 ****)image4D->getData();
+				data4d_uint16 = (uint16 ****)image4D->getData();
 
 				for (int i=0;i<nscales;i++)
 				{
@@ -213,6 +214,33 @@
 
 				break;
 
+
+			case V3D_UINT32:
+
+				data4d_uint32 = (uint32 ****)image4D->getData();
+
+				for (int i=0;i<nscales;i++)
+				{
+					fpa[i].radius = basicscalesize*i;
+
+					compute_win3d_diff(data4d_uint32[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+									   x,y,z,
+									   fpa[i].radius,fpa[i].radius,fpa[i].radius);
+
+					compute_win3d_pca(data4d_uint32[channel_no], sz0, sz1, sz2,
+									  x, y, z,
+									  fpa[i].radius, fpa[i].radius, fpa[i].radius,
+									  fpa[i].imgpca.lambda1, fpa[i].imgpca.lambda2, fpa[i].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+					compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+									  x, y, z,
+									  fpa[i].radius, fpa[i].radius, fpa[i].radius,
+									  fpa[i].diffpca.lambda1, fpa[i].diffpca.lambda2, fpa[i].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+				}
+
+				break;
+
+
 			case V3D_FLOAT32:
 
 				data4d_float32 = (float ****)image4D->getData();
Index: v3d_main/v3d/v3d_core.cpp
===================================================================
--- v3d_main/v3d/v3d_core.cpp	(revision 163)
+++ v3d_main/v3d/v3d_core.cpp	(working copy)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c)2006-2010  Hanchuan Peng (Janelia Farm, Howard Hughes Medical Institute).  
+ * Copyright (c)2006-2010  Hanchuan Peng (Janelia Farm, Howard Hughes Medical Institute).
  * All rights reserved.
  */
 
@@ -7,7 +7,7 @@
 /************
                                             ********* LICENSE NOTICE ************
 
-This folder contains all source codes for the V3D project, which is subject to the following conditions if you want to use it. 
+This folder contains all source codes for the V3D project, which is subject to the following conditions if you want to use it.
 
 You will ***have to agree*** the following terms, *before* downloading/using/running/editing/changing any portion of codes in this package.
 
@@ -166,31 +166,31 @@
 /////// a global variable to limit the amount of memory use
 
 #if defined (Q_OS_LINUX)
-	#if defined (__x86_64__)
-		double th_use_memory=20.0; //for Hanchuan's linux box
-	#else
-		double th_use_memory=1.5; //for Hanchuan's linux box
-	#endif
+  #if defined (__x86_64__)
+    double th_use_memory=20.0; //for Hanchuan's linux box
+  #else
+    double th_use_memory=1.5; //for Hanchuan's linux box
+  #endif
 
 #else
 
-	#if defined (__APPLE__)
-		#if defined(__MAC_x86_64__)
-			double th_use_memory=20.0; //allow use 6G memory for 64bit v3d of mac
-		#else
-			double th_use_memory=1.5; //should be 1.1 for 32bit mac version of v3d
-		#endif
+  #if defined (__APPLE__)
+    #if defined(__MAC_x86_64__)
+      double th_use_memory=20.0; //allow use 6G memory for 64bit v3d of mac
+    #else
+      double th_use_memory=1.5; //should be 1.1 for 32bit mac version of v3d
+    #endif
 
-	#else
-		#if defined (WIN32) || defined (_WIN32)
-			#if defined (_WIN64) 
-				double th_use_memory=20.0; //allow use 8G window memory for 64bit windows
-			#else
-				double th_use_memory=1.5; //allow 1.5G memory for 32bit windows
-			#endif
-		#endif
+  #else
+    #if defined (WIN32) || defined (_WIN32)
+      #if defined (_WIN64)
+        double th_use_memory=20.0; //allow use 8G window memory for 64bit windows
+      #else
+        double th_use_memory=1.5; //allow 1.5G memory for 32bit windows
+      #endif
+    #endif
 
-	#endif
+  #endif
 
 #endif
 
@@ -199,50 +199,50 @@
 // 090622 RZC: load segment neuron, used by algorithm test
 void load_segment_neuron(My4DImage* curImg, Renderer_tex2* curRen)
 {
-	V_NeuronSWC null_neuron;
-	for (int i=0; i<curImg->tracedNeuron.last_seg_num; i++)	{
-		null_neuron.name = qPrintable(QString("%1").arg(i+1)); curRen->updateNeuronTree(null_neuron);}
-	for (int i=0; i<curImg->tracedNeuron.seg.size(); i++)
-		curRen->updateNeuronTree(curImg->tracedNeuron.seg[i]);
+  V_NeuronSWC null_neuron;
+  for (int i=0; i<curImg->tracedNeuron.last_seg_num; i++)  {
+    null_neuron.name = qPrintable(QString("%1").arg(i+1)); curRen->updateNeuronTree(null_neuron);}
+  for (int i=0; i<curImg->tracedNeuron.seg.size(); i++)
+    curRen->updateNeuronTree(curImg->tracedNeuron.seg[i]);
 }
 void load_merged_neuron(My4DImage* curImg, Renderer_tex2* curRen)
 {
-	V_NeuronSWC merged_neuron = merge_V_NeuronSWC_list(curImg->tracedNeuron);
-	merged_neuron.name = curImg->tracedNeuron.name;
-	merged_neuron.file = curImg->tracedNeuron.file;
-	curRen->updateNeuronTree(merged_neuron);
+  V_NeuronSWC merged_neuron = merge_V_NeuronSWC_list(curImg->tracedNeuron);
+  merged_neuron.name = curImg->tracedNeuron.name;
+  merged_neuron.file = curImg->tracedNeuron.file;
+  curRen->updateNeuronTree(merged_neuron);
 }
 #define LOAD_traced_neuron   load_merged_neuron
 
 void My4DImage::update_3drenderer_neuron_view(V3dR_GLWidget* glwidget, Renderer_tex2* renderer)
 {
-	LOAD_traced_neuron(this, renderer);
-	glwidget->updateTool();
+  LOAD_traced_neuron(this, renderer);
+  glwidget->updateTool();
 }
 
 void My4DImage::update_3drenderer_neuron_view()
 {
-	XFormWidget* xwidget = getXWidget();
-	if (! xwidget) return;
+  XFormWidget* xwidget = getXWidget();
+  if (! xwidget) return;
 
-	if (xwidget->mypara_3Dview.b_still_open && xwidget->mypara_3Dview.window3D)
-	{
-		Renderer_tex2 * cur_renderer = (Renderer_tex2 *)(xwidget->mypara_3Dview.window3D->getGLWidget()->getRenderer());
+  if (xwidget->mypara_3Dview.b_still_open && xwidget->mypara_3Dview.window3D)
+  {
+    Renderer_tex2 * cur_renderer = (Renderer_tex2 *)(xwidget->mypara_3Dview.window3D->getGLWidget()->getRenderer());
 
-		LOAD_traced_neuron(this, cur_renderer);
+    LOAD_traced_neuron(this, cur_renderer);
 
-		xwidget->mypara_3Dview.window3D->getGLWidget()->updateTool(); // 090622 RZC
-	}
+    xwidget->mypara_3Dview.window3D->getGLWidget()->updateTool(); // 090622 RZC
+  }
 
-	//also update local view
-	if (xwidget->mypara_3Dlocalview.b_still_open && xwidget->mypara_3Dlocalview.window3D)
-	{
-		Renderer_tex2 * cur_renderer = (Renderer_tex2 *)(xwidget->mypara_3Dlocalview.window3D->getGLWidget()->getRenderer());
+  //also update local view
+  if (xwidget->mypara_3Dlocalview.b_still_open && xwidget->mypara_3Dlocalview.window3D)
+  {
+    Renderer_tex2 * cur_renderer = (Renderer_tex2 *)(xwidget->mypara_3Dlocalview.window3D->getGLWidget()->getRenderer());
 
-		LOAD_traced_neuron(this, cur_renderer);
+    LOAD_traced_neuron(this, cur_renderer);
 
-		xwidget->mypara_3Dlocalview.window3D->getGLWidget()->updateTool();
-	}
+    xwidget->mypara_3Dlocalview.window3D->getGLWidget()->updateTool();
+  }
 }
 
 
@@ -254,11 +254,11 @@
   for (V3DLONG j=0;j<sz1;j++)
   {
     for (V3DLONG i=0;i<sz0;i++)
-	{
-	  tmpval = int(p2d[j][i]);
-	  tmpimg.setPixel(i, j, qRgb(tmpval, tmpval, tmpval));
-	}
+  {
+    tmpval = int(p2d[j][i]);
+    tmpimg.setPixel(i, j, qRgb(tmpval, tmpval, tmpval));
   }
+  }
   return QPixmap::fromImage(tmpimg);
 }
 
@@ -269,13 +269,13 @@
   for (V3DLONG j=0;j<sz1;j++)
   {
     for (V3DLONG i=0;i<sz0;i++)
-	{
-	  tr = int((p2dRed)?p2dRed[j][i]:0);
-	  tg = int((p2dGreen)?p2dGreen[j][i]:0);
-	  tb = int((p2dBlue)?p2dBlue[j][i]:0);
-	  tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	}
+  {
+    tr = int((p2dRed)?p2dRed[j][i]:0);
+    tg = int((p2dGreen)?p2dGreen[j][i]:0);
+    tb = int((p2dBlue)?p2dBlue[j][i]:0);
+    tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
   }
+  }
   return QPixmap::fromImage(tmpimg);
 }
 
@@ -294,202 +294,202 @@
   if (sz3>=3)
   {
     tmpb = p_vmax[2]-p_vmin[2]; tmpb = (tmpb==0)?1:tmpb;
-	tmpb_min = p_vmin[2];
+  tmpb_min = p_vmin[2];
   }
 
   if (sz3>=2)
   {
     tmpg = p_vmax[1]-p_vmin[1]; tmpg = (tmpg==0)?1:tmpg;
-	tmpg_min = p_vmin[1];
+  tmpg_min = p_vmin[1];
   }
 
   if (sz3>=1)
   {
-	tmpr = p_vmax[0]-p_vmin[0]; tmpr = (tmpr==0)?1:tmpr;
-	tmpr_min = p_vmin[0];
+  tmpr = p_vmax[0]-p_vmin[0]; tmpr = (tmpr==0)?1:tmpr;
+  tmpr_min = p_vmin[0];
   }
 
   //the wrong Ctype options should be disabled in the interface instead of a complicated logic management here
   switch (Ctype)
   {
-	case colorRedOnly:
-	  tb = tg = 0;
-	  if (bIntensityRescale==false)
-	  {
+  case colorRedOnly:
+    tb = tg = 0;
+    if (bIntensityRescale==false)
+    {
         for (j=0;j<sz1;j++)
         {
           for (i=0;i<sz2;i++)
           {
             tr = p4d[0][i][j][curpos];
- 	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+           tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  else
-	  {
+        }
+    }
+    else
+    {
         for (j=0;j<sz1;j++)
         {
           for (i=0;i<sz2;i++)
           {
             tr = floor((p4d[0][i][j][curpos]-tmpr_min)/tmpr*255.0);
- 	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+           tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  break;
+        }
+    }
+    break;
 
-	case colorGray: //070716
+  case colorGray: //070716
       for (j=0;j<sz1;j++)
       {
         for (i=0;i<sz2;i++)
         {
-		  double tmpval=0;
-		  for (int tmpcnt=0;tmpcnt<sz3;tmpcnt++)
-		  {
-		    if (tmpcnt==0)
-			    tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][i][j][curpos] : floor((p4d[tmpcnt][i][j][curpos]-tmpr_min)/tmpr*255.0));
-			else if (tmpcnt==1)
-			    tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][i][j][curpos] : floor((p4d[tmpcnt][i][j][curpos]-tmpg_min)/tmpg*255.0));
-			else if (tmpcnt==2)
-			    tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][i][j][curpos] : floor((p4d[tmpcnt][i][j][curpos]-tmpb_min)/tmpb*255.0));
-			else
-			    tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][i][j][curpos] : p4d[tmpcnt][i][j][curpos]); //in this case, don't about any channel more than 3
- 	      }
-		  tmpval /= sz3;
-		  tmpimg.setPixel(i, j, qRgb(int(tmpval), int(tmpval), int(tmpval)));
-	    }
+      double tmpval=0;
+      for (int tmpcnt=0;tmpcnt<sz3;tmpcnt++)
+      {
+        if (tmpcnt==0)
+          tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][i][j][curpos] : floor((p4d[tmpcnt][i][j][curpos]-tmpr_min)/tmpr*255.0));
+      else if (tmpcnt==1)
+          tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][i][j][curpos] : floor((p4d[tmpcnt][i][j][curpos]-tmpg_min)/tmpg*255.0));
+      else if (tmpcnt==2)
+          tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][i][j][curpos] : floor((p4d[tmpcnt][i][j][curpos]-tmpb_min)/tmpb*255.0));
+      else
+          tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][i][j][curpos] : p4d[tmpcnt][i][j][curpos]); //in this case, don't about any channel more than 3
+         }
+      tmpval /= sz3;
+      tmpimg.setPixel(i, j, qRgb(int(tmpval), int(tmpval), int(tmpval)));
       }
-	  break;
+      }
+    break;
 
-  	case colorRed2Gray:
-	  if (bIntensityRescale==false)
-	  {
+    case colorRed2Gray:
+    if (bIntensityRescale==false)
+    {
         for (j=0;j<sz1;j++)
         {
           for (i=0;i<sz2;i++)
           {
             tg = tb = tr = p4d[0][i][j][curpos];
-   	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+             tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  else
-	  {
+        }
+    }
+    else
+    {
         for (j=0;j<sz1;j++)
         {
           for (i=0;i<sz2;i++)
           {
             tg = tb = tr = floor((p4d[0][i][j][curpos]-tmpr_min)/tmpr*255.0);
-   	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+             tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  break;
+        }
+    }
+    break;
 
-	case colorGreenOnly:
-	  tb = tr = 0;
-	  if (bIntensityRescale==false)
-	  {
+  case colorGreenOnly:
+    tb = tr = 0;
+    if (bIntensityRescale==false)
+    {
         for (j=0;j<sz1;j++)
         {
           for (i=0;i<sz2;i++)
           {
             tg = p4d[1][i][j][curpos];
- 	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+           tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  else
-	  {
+        }
+    }
+    else
+    {
         for (j=0;j<sz1;j++)
         {
           for (i=0;i<sz2;i++)
           {
             tg = floor((p4d[1][i][j][curpos]-tmpg_min)/tmpg*255.0);
- 	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+           tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  break;
+        }
+    }
+    break;
 
-	case colorGreen2Gray:
-	  if (bIntensityRescale==false)
+  case colorGreen2Gray:
+    if (bIntensityRescale==false)
       {
-	    for (j=0;j<sz1;j++)
+      for (j=0;j<sz1;j++)
         {
           for (i=0;i<sz2;i++)
           {
             tb = tr = tg = p4d[1][i][j][curpos];
- 	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+           tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  else
-	  {
-	    for (j=0;j<sz1;j++)
+        }
+    }
+    else
+    {
+      for (j=0;j<sz1;j++)
         {
           for (i=0;i<sz2;i++)
           {
             tb = tr = tg = floor((p4d[1][i][j][curpos]-tmpg_min)/tmpg*255.0);
- 	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+           tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  break;
+        }
+    }
+    break;
 
-	case colorBlueOnly:
-	  tg = tr = 0;
-	  if (bIntensityRescale==false)
+  case colorBlueOnly:
+    tg = tr = 0;
+    if (bIntensityRescale==false)
       {
         for (j=0;j<sz1;j++)
         {
           for (i=0;i<sz2;i++)
           {
             tb = p4d[2][i][j][curpos];
- 	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+           tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  else
-	  {
-	    for (j=0;j<sz1;j++)
+        }
+    }
+    else
+    {
+      for (j=0;j<sz1;j++)
         {
           for (i=0;i<sz2;i++)
           {
             tb = floor((p4d[2][i][j][curpos]-tmpb_min)/tmpb*255.0);
- 	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+           tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  break;
+        }
+    }
+    break;
 
-	case colorBlue2Gray:
-	  if (bIntensityRescale==false)
+  case colorBlue2Gray:
+    if (bIntensityRescale==false)
       {
         for (j=0;j<sz1;j++)
         {
           for (i=0;i<sz2;i++)
           {
             tg = tr = tb = p4d[2][i][j][curpos];
- 	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+           tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  else
-	  {
+        }
+    }
+    else
+    {
         for (j=0;j<sz1;j++)
         {
           for (i=0;i<sz2;i++)
           {
             tg = tr = tb = floor((p4d[2][i][j][curpos]-tmpb_min)/tmpb*255.0);
- 	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+           tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  break;
+        }
+    }
+    break;
 
-	case colorRGB:
-	  if (bIntensityRescale==false)
+  case colorRGB:
+    if (bIntensityRescale==false)
       {
         for (j=0;j<sz1;j++)
         {
@@ -498,28 +498,28 @@
             tr = p4d[0][i][j][curpos];
             tg = p4d[1][i][j][curpos];
             tb = p4d[2][i][j][curpos];
- 	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+           tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
+        }
+    }
       else
-	  {
-	    for (j=0;j<sz1;j++)
+    {
+      for (j=0;j<sz1;j++)
         {
           for (i=0;i<sz2;i++)
           {
             tr = floor((p4d[0][i][j][curpos]-tmpr_min)/tmpr*255.0);
             tg = floor((p4d[1][i][j][curpos]-tmpg_min)/tmpg*255.0);
             tb = floor((p4d[2][i][j][curpos]-tmpb_min)/tmpb*255.0);
- 	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+           tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  break;
+        }
+    }
+    break;
 
-	case colorRG:
-  	  tb = 0;
-	  if (bIntensityRescale==false)
+  case colorRG:
+      tb = 0;
+    if (bIntensityRescale==false)
       {
         for (j=0;j<sz1;j++)
         {
@@ -527,28 +527,28 @@
           {
             tr = p4d[0][i][j][curpos];
             tg = p4d[1][i][j][curpos];
-  	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+            tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  else
-	  {
+        }
+    }
+    else
+    {
         for (j=0;j<sz1;j++)
         {
           for (i=0;i<sz2;i++)
           {
             tr = floor((p4d[0][i][j][curpos]-tmpr_min)/tmpr*255.0);
             tg = floor((p4d[1][i][j][curpos]-tmpg_min)/tmpg*255.0);
-  	        tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	      }
+            tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
         }
-	  }
-	  break;
+        }
+    }
+    break;
 
     case colorUnknown:
     default:
 
-	  break;
+    break;
   }
 
   return QPixmap::fromImage(tmpimg);
@@ -570,146 +570,146 @@
   if (sz3>=3)
   {
     tmpb = p_vmax[2]-p_vmin[2]; tmpb = (tmpb==0)?1:tmpb;
-	tmpb_min = p_vmin[2];
+  tmpb_min = p_vmin[2];
   }
 
   if (sz3>=2)
   {
     tmpg = p_vmax[1]-p_vmin[1]; tmpg = (tmpg==0)?1:tmpg;
-	tmpg_min = p_vmin[1];
+  tmpg_min = p_vmin[1];
   }
 
   if (sz3>=1)
   {
-	tmpr = p_vmax[0]-p_vmin[0]; tmpr = (tmpr==0)?1:tmpr;
-	tmpr_min = p_vmin[0];
+  tmpr = p_vmax[0]-p_vmin[0]; tmpr = (tmpr==0)?1:tmpr;
+  tmpr_min = p_vmin[0];
   }
 
   //the wrong Ctype options should be disabled in the interface instead of a complicated logic management here
 
   switch (Ctype)
   {
-	case colorRedOnly:
-	  tb = tg = 0;
+  case colorRedOnly:
+    tb = tg = 0;
       for (j=0;j<sz2;j++)
       {
         for (i=0;i<sz0;i++)
         {
           tr = (bIntensityRescale==false) ? p4d[0][j][curpos][i] : floor((p4d[0][j][curpos][i]-tmpr_min)/tmpr*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
-	case colorGray: //070716
+  case colorGray: //070716
       for (j=0;j<sz2;j++)
       {
         for (i=0;i<sz0;i++)
         {
-		  double tmpval=0;
-		  for (int tmpcnt=0;tmpcnt<sz3;tmpcnt++)
-		  {
-		    if (tmpcnt==0)
-			    tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][j][curpos][i] : floor((p4d[tmpcnt][j][curpos][i]-tmpr_min)/tmpr*255.0));
-			else if (tmpcnt==1)
-			    tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][j][curpos][i] : floor((p4d[tmpcnt][j][curpos][i]-tmpg_min)/tmpg*255.0));
-			else if (tmpcnt==2)
-			    tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][j][curpos][i] : floor((p4d[tmpcnt][j][curpos][i]-tmpb_min)/tmpb*255.0));
-			else
-			    tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][j][curpos][i] : p4d[tmpcnt][j][curpos][i]); //in this case, don't about any channel more than 3
- 	      }
-		  tmpval /= sz3;
-		  tmpimg.setPixel(i, j, qRgb(int(tmpval), int(tmpval), int(tmpval)));
-	    }
+      double tmpval=0;
+      for (int tmpcnt=0;tmpcnt<sz3;tmpcnt++)
+      {
+        if (tmpcnt==0)
+          tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][j][curpos][i] : floor((p4d[tmpcnt][j][curpos][i]-tmpr_min)/tmpr*255.0));
+      else if (tmpcnt==1)
+          tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][j][curpos][i] : floor((p4d[tmpcnt][j][curpos][i]-tmpg_min)/tmpg*255.0));
+      else if (tmpcnt==2)
+          tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][j][curpos][i] : floor((p4d[tmpcnt][j][curpos][i]-tmpb_min)/tmpb*255.0));
+      else
+          tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][j][curpos][i] : p4d[tmpcnt][j][curpos][i]); //in this case, don't about any channel more than 3
+         }
+      tmpval /= sz3;
+      tmpimg.setPixel(i, j, qRgb(int(tmpval), int(tmpval), int(tmpval)));
       }
-	  break;
+      }
+    break;
 
-  	case colorRed2Gray:
+    case colorRed2Gray:
       for (j=0;j<sz2;j++)
       {
         for (i=0;i<sz0;i++)
         {
           tg = tb = tr = (bIntensityRescale==false) ? p4d[0][j][curpos][i] : floor((p4d[0][j][curpos][i]-tmpr_min)/tmpr*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
-	case colorGreenOnly:
-	  tb = tr = 0;
+  case colorGreenOnly:
+    tb = tr = 0;
       for (j=0;j<sz2;j++)
       {
         for (i=0;i<sz0;i++)
         {
           tg = (bIntensityRescale==false) ? p4d[1][j][curpos][i] : floor((p4d[1][j][curpos][i]-tmpg_min)/tmpg*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
-	case colorGreen2Gray:
+  case colorGreen2Gray:
       for (j=0;j<sz2;j++)
       {
         for (i=0;i<sz0;i++)
         {
           tb = tr = tg = (bIntensityRescale==false) ? p4d[1][j][curpos][i] : floor((p4d[1][j][curpos][i]-tmpg_min)/tmpg*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
-	case colorBlueOnly:
-	  tg = tr = 0;
+  case colorBlueOnly:
+    tg = tr = 0;
       for (j=0;j<sz2;j++)
       {
         for (i=0;i<sz0;i++)
         {
           tb = (bIntensityRescale==false) ? p4d[2][j][curpos][i] : floor((p4d[2][j][curpos][i]-tmpb_min)/tmpb*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
-	case colorBlue2Gray:
+  case colorBlue2Gray:
       for (j=0;j<sz2;j++)
       {
         for (i=0;i<sz0;i++)
         {
           tg = tr = tb = (bIntensityRescale==false) ? p4d[2][j][curpos][i] : floor((p4d[2][j][curpos][i]-tmpb_min)/tmpb*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
-	case colorRGB:
+  case colorRGB:
       for (j=0;j<sz2;j++)
       {
         for (i=0;i<sz0;i++)
         {
-		  tr = (bIntensityRescale==false) ? p4d[0][j][curpos][i] : floor((p4d[0][j][curpos][i]-tmpr_min)/tmpr*255.0);
-		  tg = (bIntensityRescale==false) ? p4d[1][j][curpos][i] : floor((p4d[1][j][curpos][i]-tmpg_min)/tmpg*255.0);
-		  tb = (bIntensityRescale==false) ? p4d[2][j][curpos][i] : floor((p4d[2][j][curpos][i]-tmpb_min)/tmpb*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+      tr = (bIntensityRescale==false) ? p4d[0][j][curpos][i] : floor((p4d[0][j][curpos][i]-tmpr_min)/tmpr*255.0);
+      tg = (bIntensityRescale==false) ? p4d[1][j][curpos][i] : floor((p4d[1][j][curpos][i]-tmpg_min)/tmpg*255.0);
+      tb = (bIntensityRescale==false) ? p4d[2][j][curpos][i] : floor((p4d[2][j][curpos][i]-tmpb_min)/tmpb*255.0);
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
-	case colorRG:
-	  tb = 0;
+  case colorRG:
+    tb = 0;
       for (j=0;j<sz2;j++)
       {
         for (i=0;i<sz0;i++)
         {
-		  tr = (bIntensityRescale==false) ? p4d[0][j][curpos][i] : floor((p4d[0][j][curpos][i]-tmpr_min)/tmpr*255.0);
-		  tg = (bIntensityRescale==false) ? p4d[1][j][curpos][i] : floor((p4d[1][j][curpos][i]-tmpg_min)/tmpg*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+      tr = (bIntensityRescale==false) ? p4d[0][j][curpos][i] : floor((p4d[0][j][curpos][i]-tmpr_min)/tmpr*255.0);
+      tg = (bIntensityRescale==false) ? p4d[1][j][curpos][i] : floor((p4d[1][j][curpos][i]-tmpg_min)/tmpg*255.0);
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
     case colorUnknown:
     default:
-	  break;
+    break;
   }
 
   return QPixmap::fromImage(tmpimg);
@@ -737,146 +737,146 @@
   if (sz3>=3)
   {
     tmpb = p_vmax[2]-p_vmin[2]; tmpb = (tmpb==0)?1:tmpb;
-	tmpb_min = p_vmin[2];
+  tmpb_min = p_vmin[2];
   }
 
   if (sz3>=2)
   {
     tmpg = p_vmax[1]-p_vmin[1]; tmpg = (tmpg==0)?1:tmpg;
-	tmpg_min = p_vmin[1];
+  tmpg_min = p_vmin[1];
   }
 
   if (sz3>=1)
   {
-	tmpr = p_vmax[0]-p_vmin[0]; tmpr = (tmpr==0)?1:tmpr;
-	tmpr_min = p_vmin[0];
+  tmpr = p_vmax[0]-p_vmin[0]; tmpr = (tmpr==0)?1:tmpr;
+  tmpr_min = p_vmin[0];
   }
 
   //the wrong Ctype options should be disabled in the interface instead of a complicated logic management here
 
   switch (Ctype)
   {
-	case colorRedOnly:
-	  tg = tb = 0;
+  case colorRedOnly:
+    tg = tb = 0;
       for (j=0;j<sz1;j++)
       {
         for (i=0;i<sz0;i++)
         {
-		  tr = (bIntensityRescale==false) ? p4d[0][curpos][j][i] : floor((p4d[0][curpos][j][i]-tmpr_min)/tmpr*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+      tr = (bIntensityRescale==false) ? p4d[0][curpos][j][i] : floor((p4d[0][curpos][j][i]-tmpr_min)/tmpr*255.0);
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
-	case colorGray: //070716
+  case colorGray: //070716
       for (j=0;j<sz1;j++)
       {
         for (i=0;i<sz0;i++)
         {
-		  double tmpval=0;
-		  for (int tmpcnt=0;tmpcnt<sz3;tmpcnt++)
-		  {
-		    if (tmpcnt==0)
-			    tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][curpos][j][i] : floor((p4d[tmpcnt][curpos][j][i]-tmpr_min)/tmpr*255.0));
-			else if (tmpcnt==1)
-			    tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][curpos][j][i] : floor((p4d[tmpcnt][curpos][j][i]-tmpg_min)/tmpg*255.0));
-			else if (tmpcnt==2)
-			    tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][curpos][j][i] : floor((p4d[tmpcnt][curpos][j][i]-tmpb_min)/tmpb*255.0));
-			else
-			    tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][curpos][j][i] : p4d[tmpcnt][curpos][j][i]); //in this case, don't about any channel more than 3
- 	      }
-		  tmpval /= sz3;
-		  tmpimg.setPixel(i, j, qRgb(int(tmpval), int(tmpval), int(tmpval)));
-	    }
+      double tmpval=0;
+      for (int tmpcnt=0;tmpcnt<sz3;tmpcnt++)
+      {
+        if (tmpcnt==0)
+          tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][curpos][j][i] : floor((p4d[tmpcnt][curpos][j][i]-tmpr_min)/tmpr*255.0));
+      else if (tmpcnt==1)
+          tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][curpos][j][i] : floor((p4d[tmpcnt][curpos][j][i]-tmpg_min)/tmpg*255.0));
+      else if (tmpcnt==2)
+          tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][curpos][j][i] : floor((p4d[tmpcnt][curpos][j][i]-tmpb_min)/tmpb*255.0));
+      else
+          tmpval += ((bIntensityRescale==false) ? p4d[tmpcnt][curpos][j][i] : p4d[tmpcnt][curpos][j][i]); //in this case, don't about any channel more than 3
+         }
+      tmpval /= sz3;
+      tmpimg.setPixel(i, j, qRgb(int(tmpval), int(tmpval), int(tmpval)));
       }
-	  break;
+      }
+    break;
 
-	case colorRed2Gray:
+  case colorRed2Gray:
       for (j=0;j<sz1;j++)
       {
         for (i=0;i<sz0;i++)
         {
-		  tg = tb = tr = (bIntensityRescale==false) ? p4d[0][curpos][j][i] : floor((p4d[0][curpos][j][i]-tmpr_min)/tmpr*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+      tg = tb = tr = (bIntensityRescale==false) ? p4d[0][curpos][j][i] : floor((p4d[0][curpos][j][i]-tmpr_min)/tmpr*255.0);
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
-	case colorGreenOnly:
-	  tr = tb = 0;
+  case colorGreenOnly:
+    tr = tb = 0;
       for (j=0;j<sz1;j++)
       {
         for (i=0;i<sz0;i++)
         {
-		  tg = (bIntensityRescale==false) ? p4d[1][curpos][j][i] : floor((p4d[1][curpos][j][i]-tmpg_min)/tmpg*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+      tg = (bIntensityRescale==false) ? p4d[1][curpos][j][i] : floor((p4d[1][curpos][j][i]-tmpg_min)/tmpg*255.0);
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
-	case colorGreen2Gray:
+  case colorGreen2Gray:
       for (j=0;j<sz1;j++)
       {
         for (i=0;i<sz0;i++)
         {
-		  tr = tb = tg = (bIntensityRescale==false) ? p4d[1][curpos][j][i] : floor((p4d[1][curpos][j][i]-tmpg_min)/tmpg*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+      tr = tb = tg = (bIntensityRescale==false) ? p4d[1][curpos][j][i] : floor((p4d[1][curpos][j][i]-tmpg_min)/tmpg*255.0);
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
-	case colorBlueOnly:
-	  tr = tg = 0;
+  case colorBlueOnly:
+    tr = tg = 0;
       for (j=0;j<sz1;j++)
       {
         for (i=0;i<sz0;i++)
         {
-		  tb = (bIntensityRescale==false) ? p4d[2][curpos][j][i] : floor((p4d[2][curpos][j][i]-tmpb_min)/tmpb*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+      tb = (bIntensityRescale==false) ? p4d[2][curpos][j][i] : floor((p4d[2][curpos][j][i]-tmpb_min)/tmpb*255.0);
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
-	case colorBlue2Gray:
+  case colorBlue2Gray:
       for (j=0;j<sz1;j++)
       {
         for (i=0;i<sz0;i++)
         {
-		  tr = tg = tb = (bIntensityRescale==false) ? p4d[2][curpos][j][i] : floor((p4d[2][curpos][j][i]-tmpb_min)/tmpb*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+      tr = tg = tb = (bIntensityRescale==false) ? p4d[2][curpos][j][i] : floor((p4d[2][curpos][j][i]-tmpb_min)/tmpb*255.0);
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
-	case colorRGB:
+  case colorRGB:
       for (j=0;j<sz1;j++)
       {
         for (i=0;i<sz0;i++)
         {
-		  tr = (bIntensityRescale==false) ? p4d[0][curpos][j][i] : floor((p4d[0][curpos][j][i]-tmpr_min)/tmpr*255.0);
-		  tg = (bIntensityRescale==false) ? p4d[1][curpos][j][i] : floor((p4d[1][curpos][j][i]-tmpg_min)/tmpg*255.0);
-		  tb = (bIntensityRescale==false) ? p4d[2][curpos][j][i] : floor((p4d[2][curpos][j][i]-tmpb_min)/tmpb*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+      tr = (bIntensityRescale==false) ? p4d[0][curpos][j][i] : floor((p4d[0][curpos][j][i]-tmpr_min)/tmpr*255.0);
+      tg = (bIntensityRescale==false) ? p4d[1][curpos][j][i] : floor((p4d[1][curpos][j][i]-tmpg_min)/tmpg*255.0);
+      tb = (bIntensityRescale==false) ? p4d[2][curpos][j][i] : floor((p4d[2][curpos][j][i]-tmpb_min)/tmpb*255.0);
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
-	case colorRG:
-	  tb = 0;
+  case colorRG:
+    tb = 0;
       for (j=0;j<sz1;j++)
       {
         for (i=0;i<sz0;i++)
         {
-		  tr = (bIntensityRescale==false) ? p4d[0][curpos][j][i] : floor((p4d[0][curpos][j][i]-tmpr_min)/tmpr*255.0);
-		  tg = (bIntensityRescale==false) ? p4d[1][curpos][j][i] : floor((p4d[1][curpos][j][i]-tmpg_min)/tmpg*255.0);
- 	      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	    }
+      tr = (bIntensityRescale==false) ? p4d[0][curpos][j][i] : floor((p4d[0][curpos][j][i]-tmpr_min)/tmpr*255.0);
+      tg = (bIntensityRescale==false) ? p4d[1][curpos][j][i] : floor((p4d[1][curpos][j][i]-tmpg_min)/tmpg*255.0);
+         tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
       }
-	  break;
+      }
+    break;
 
     case colorUnknown:
     default:
-	  break;
+    break;
   }
 /*
   for (j=0;j<sz1;j++)
@@ -884,11 +884,11 @@
     for (i=0;i<sz0;i++)
     {
       tr = (p2dRed) ? ((bIntensityRescale==false) ? p2dRed[j][i] : floor((p2dRed[j][i]-tmpr_min)/tmpr*255.0)) : 0;
-	  tg = (p2dGreen) ? ((bIntensityRescale==false) ? p2dGreen[j][i] : floor((p2dGreen[j][i]-tmpg_min)/tmpg*255.0)) : 0;
-	  tb = (p2dBlue) ? ((bIntensityRescale==false) ? p2dBlue[j][i] : floor((p2dBlue[j][i]-tmpb_min)/tmpb*255.0)) : 0;
-  	  tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-	}
+    tg = (p2dGreen) ? ((bIntensityRescale==false) ? p2dGreen[j][i] : floor((p2dGreen[j][i]-tmpg_min)/tmpg*255.0)) : 0;
+    tb = (p2dBlue) ? ((bIntensityRescale==false) ? p2dBlue[j][i] : floor((p2dBlue[j][i]-tmpb_min)/tmpb*255.0)) : 0;
+      tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
   }
+  }
 */
   return QPixmap::fromImage(tmpimg);
 }
@@ -900,325 +900,325 @@
   {
     case imgPlaneX:
       return copyRaw2QPixmap_xPlanes(p4d, sz0, sz1, sz2, sz3, Ctype, cpos, bIntensityRescale, p_vmax, p_vmin);
-	  break;
+    break;
 
     case imgPlaneY:
       return copyRaw2QPixmap_yPlanes(p4d, sz0, sz1, sz2, sz3, Ctype, cpos, bIntensityRescale, p_vmax, p_vmin);
-	  break;
+    break;
 
     case imgPlaneZ:
       return copyRaw2QPixmap_zPlanes(p4d, sz0, sz1, sz2, sz3, Ctype, cpos, bIntensityRescale, p_vmax, p_vmin);
-	  break;
+    break;
 
     default:
-	  printf("Undefined ImagePlaneDisplayType. Check your code.\n");
-	  return QPixmap(0,0); //return an empty image for this prohibited case
-	  break;
+    printf("Undefined ImagePlaneDisplayType. Check your code.\n");
+    return QPixmap(0,0); //return an empty image for this prohibited case
+    break;
   }
 }
 
 QPixmap copyRaw2QPixmap_colormap(const void **** p4d, ImagePixelType dtype, V3DLONG sz0, V3DLONG sz1, V3DLONG sz2, V3DLONG sz3, V3DLONG cpos, const ColorMap *pc, ImagePlaneDisplayType disType)
 {
-	/*  if (Ctype!=colorPseudoMaskColor)
-	 {
-	 printf("This function is designed for colorPseudoMaskColor only. Check your code.\n");
-	 return QPixmap(0,0); //return an empty image for this prohibited case
-	 }
-	 */
-	switch (disType)
-	{
-		case imgPlaneX:
-			return copyRaw2QPixmap_xPlanes_colormap(p4d, dtype, sz0, sz1, sz2, sz3, cpos, pc);
-			break;
+  /*  if (Ctype!=colorPseudoMaskColor)
+   {
+   printf("This function is designed for colorPseudoMaskColor only. Check your code.\n");
+   return QPixmap(0,0); //return an empty image for this prohibited case
+   }
+   */
+  switch (disType)
+  {
+    case imgPlaneX:
+      return copyRaw2QPixmap_xPlanes_colormap(p4d, dtype, sz0, sz1, sz2, sz3, cpos, pc);
+      break;
 
-		case imgPlaneY:
-			return copyRaw2QPixmap_yPlanes_colormap(p4d, dtype, sz0, sz1, sz2, sz3, cpos, pc);
-			break;
+    case imgPlaneY:
+      return copyRaw2QPixmap_yPlanes_colormap(p4d, dtype, sz0, sz1, sz2, sz3, cpos, pc);
+      break;
 
-		case imgPlaneZ:
-			return copyRaw2QPixmap_zPlanes_colormap(p4d, dtype, sz0, sz1, sz2, sz3, cpos, pc);
-			break;
+    case imgPlaneZ:
+      return copyRaw2QPixmap_zPlanes_colormap(p4d, dtype, sz0, sz1, sz2, sz3, cpos, pc);
+      break;
 
-		default:
-			printf("Undefined ImagePlaneDisplayType. Check your code.\n");
-			return QPixmap(0,0); //return an empty image for this prohibited case
-			break;
-	}
+    default:
+      printf("Undefined ImagePlaneDisplayType. Check your code.\n");
+      return QPixmap(0,0); //return an empty image for this prohibited case
+      break;
+  }
 }
 
 QPixmap copyRaw2QPixmap_xPlanes_colormap(const void **** p4d, ImagePixelType dtype, V3DLONG sz0, V3DLONG sz1, V3DLONG sz2, V3DLONG sz3, V3DLONG cpos, const ColorMap *pc)
 {
     if (!p4d || !pc)
-	{
-		printf("The input parameters are invalid in copyRaw2QPixmap_xPlanes_colormap()!\n");
-		return QPixmap(sz2, sz1);
-	}
+  {
+    printf("The input parameters are invalid in copyRaw2QPixmap_xPlanes_colormap()!\n");
+    return QPixmap(sz2, sz1);
+  }
 
-	if (sz3<1)
-	{
-		printf("The number of color channels cannot be smalled than 1. Note that as an indexed color, only the first (0-th) dim is used. \n");
-		return QPixmap(sz2, sz1);;
-	}
+  if (sz3<1)
+  {
+    printf("The number of color channels cannot be smalled than 1. Note that as an indexed color, only the first (0-th) dim is used. \n");
+    return QPixmap(sz2, sz1);;
+  }
 
-	QImage tmpimg = QImage(sz2, sz1, QImage::Format_RGB32);
-	int tr,tg,tb;
-	int clen = pc->len;
-	V3DLONG ind;
+  QImage tmpimg = QImage(sz2, sz1, QImage::Format_RGB32);
+  int tr,tg,tb;
+  int clen = pc->len;
+  V3DLONG ind;
 
-	V3DLONG curpos = (cpos>sz0) ? sz0-1 : cpos-1;
-	curpos = (curpos<0)?0:curpos;
+  V3DLONG curpos = (cpos>sz0) ? sz0-1 : cpos-1;
+  curpos = (curpos<0)?0:curpos;
 
-	V3DLONG i,j;
+  V3DLONG i,j;
 
-	float ***p3d_float32=0;
-	USHORTINT16 ***p3d_uint16=0;
-	unsigned char ***p3d_uint8=0;
+  float ***p3d_float32=0;
+  uint16 ***p3d_uint16=0;
+  unsigned char ***p3d_uint8=0;
 
-	switch(dtype)
-	{
-		case V3D_UINT8:
-			p3d_uint8 = (unsigned char ***)(p4d[0]);
+  switch(dtype)
+  {
+    case V3D_UINT8:
+      p3d_uint8 = (unsigned char ***)(p4d[0]);
 
-			for (j=0;j<sz1;j++)
-			{
-				for (i=0;i<sz2;i++)
-				{
-					ind = V3DLONG(p3d_uint8[i][j][curpos]);
-					if (ind>=clen) ind = ind % clen;
-					tr = pc->map2d[ind][0];
-					tg = pc->map2d[ind][1];
-					tb = pc->map2d[ind][2];
-					tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-				}
-			}
+      for (j=0;j<sz1;j++)
+      {
+        for (i=0;i<sz2;i++)
+        {
+          ind = V3DLONG(p3d_uint8[i][j][curpos]);
+          if (ind>=clen) ind = ind % clen;
+          tr = pc->map2d[ind][0];
+          tg = pc->map2d[ind][1];
+          tb = pc->map2d[ind][2];
+          tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
+        }
+      }
 
-			break;
+      break;
 
-		case V3D_UINT16:
-			p3d_uint16 = ((USHORTINT16 ****)p4d)[0];
-			//printf("p3d=[%ld] sz1=%d sz2=%d\n", V3DLONG(p3d_uint16), sz1, sz2);
+    case V3D_UINT16:
+      p3d_uint16 = ((uint16 ****)p4d)[0];
+      //printf("p3d=[%ld] sz1=%d sz2=%d\n", V3DLONG(p3d_uint16), sz1, sz2);
 
-			for (j=0;j<sz1;j++)
-			{
-				for (i=0;i<sz2;i++)
-				{
-				    //printf("(i=%d,j=%d,curpos=%d) \n", i,j,curpos);
-					ind = V3DLONG(p3d_uint16[i][j][curpos]);
-					if (ind>=clen) ind = ind % clen;
-					tr = pc->map2d[ind][0];
-					tg = pc->map2d[ind][1];
-					tb = pc->map2d[ind][2];
-					tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-				}
-			}
+      for (j=0;j<sz1;j++)
+      {
+        for (i=0;i<sz2;i++)
+        {
+            //printf("(i=%d,j=%d,curpos=%d) \n", i,j,curpos);
+          ind = V3DLONG(p3d_uint16[i][j][curpos]);
+          if (ind>=clen) ind = ind % clen;
+          tr = pc->map2d[ind][0];
+          tg = pc->map2d[ind][1];
+          tb = pc->map2d[ind][2];
+          tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
+        }
+      }
 
-			break;
+      break;
 
-		case V3D_FLOAT32:
-			p3d_float32 = ((float ****)p4d)[0]; //(float ***)(p4d[0]);
+    case V3D_FLOAT32:
+      p3d_float32 = ((float ****)p4d)[0]; //(float ***)(p4d[0]);
 
-			for (j=0;j<sz1;j++)
-			{
-				for (i=0;i<sz2;i++)
-				{
-					ind = V3DLONG(p3d_float32[i][j][curpos]);
-					if (ind>=clen) ind = ind % clen;
-					tr = pc->map2d[ind][0];
-					tg = pc->map2d[ind][1];
-					tb = pc->map2d[ind][2];
-					tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-				}
-			}
+      for (j=0;j<sz1;j++)
+      {
+        for (i=0;i<sz2;i++)
+        {
+          ind = V3DLONG(p3d_float32[i][j][curpos]);
+          if (ind>=clen) ind = ind % clen;
+          tr = pc->map2d[ind][0];
+          tg = pc->map2d[ind][1];
+          tb = pc->map2d[ind][2];
+          tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
+        }
+      }
 
-			break;
+      break;
 
-		default:
-			break;
-	}
+    default:
+      break;
+  }
 
-	return QPixmap::fromImage(tmpimg);
+  return QPixmap::fromImage(tmpimg);
 }
 
 QPixmap copyRaw2QPixmap_yPlanes_colormap(const void **** p4d, ImagePixelType dtype, V3DLONG sz0, V3DLONG sz1, V3DLONG sz2, V3DLONG sz3, V3DLONG cpos, const ColorMap *pc)
 {
     if (!p4d || !pc)
-	{
-		printf("The input parameters are invalid in copyRaw2QPixmap_yPlanes_colormap()!\n");
-		return QPixmap(sz0, sz2);
-	}
+  {
+    printf("The input parameters are invalid in copyRaw2QPixmap_yPlanes_colormap()!\n");
+    return QPixmap(sz0, sz2);
+  }
 
-	if (sz3<1)
-	{
-		printf("The number of color channels cannot be smalled than 1. Note that as an indexed color, only the first (0-th) dim is used. \n");
-		return QPixmap(sz0, sz2);
-	}
+  if (sz3<1)
+  {
+    printf("The number of color channels cannot be smalled than 1. Note that as an indexed color, only the first (0-th) dim is used. \n");
+    return QPixmap(sz0, sz2);
+  }
 
-	QImage tmpimg = QImage(sz0, sz2, QImage::Format_RGB32);
-	int tr,tg,tb;
-	int clen = pc->len;
-	V3DLONG ind;
+  QImage tmpimg = QImage(sz0, sz2, QImage::Format_RGB32);
+  int tr,tg,tb;
+  int clen = pc->len;
+  V3DLONG ind;
 
-	V3DLONG curpos = (cpos>sz1) ? sz1-1 : cpos-1;
-	curpos = (curpos<0)?0:curpos;
+  V3DLONG curpos = (cpos>sz1) ? sz1-1 : cpos-1;
+  curpos = (curpos<0)?0:curpos;
 
-	V3DLONG i,j;
+  V3DLONG i,j;
 
-	float ***p3d_float32;
-	USHORTINT16 ***p3d_uint16;
-	unsigned char ***p3d_uint8;
+  float ***p3d_float32;
+  uint16 ***p3d_uint16;
+  unsigned char ***p3d_uint8;
 
-	switch (dtype)
-	{
-		case V3D_UINT8:
-			p3d_uint8 = (unsigned char ***)(p4d[0]);
+  switch (dtype)
+  {
+    case V3D_UINT8:
+      p3d_uint8 = (unsigned char ***)(p4d[0]);
 
-			for (j=0;j<sz2;j++)
-			{
-				for (i=0;i<sz0;i++)
-				{
-					ind = V3DLONG(p3d_uint8[j][curpos][i]);
+      for (j=0;j<sz2;j++)
+      {
+        for (i=0;i<sz0;i++)
+        {
+          ind = V3DLONG(p3d_uint8[j][curpos][i]);
 
-					if (ind>=clen) ind = ind % clen;
-					tr = pc->map2d[ind][0];
-					tg = pc->map2d[ind][1];
-					tb = pc->map2d[ind][2];
-					tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-				}
-			}
-			break;
+          if (ind>=clen) ind = ind % clen;
+          tr = pc->map2d[ind][0];
+          tg = pc->map2d[ind][1];
+          tb = pc->map2d[ind][2];
+          tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
+        }
+      }
+      break;
 
-		case V3D_UINT16:
-			p3d_uint16 = (USHORTINT16 ***)(p4d[0]);
+    case V3D_UINT16:
+      p3d_uint16 = (uint16 ***)(p4d[0]);
 
-			for (j=0;j<sz2;j++)
-			{
-				for (i=0;i<sz0;i++)
-				{
-					ind = V3DLONG(p3d_uint16[j][curpos][i]);
+      for (j=0;j<sz2;j++)
+      {
+        for (i=0;i<sz0;i++)
+        {
+          ind = V3DLONG(p3d_uint16[j][curpos][i]);
 
-					if (ind>=clen) ind = ind % clen;
-					tr = pc->map2d[ind][0];
-					tg = pc->map2d[ind][1];
-					tb = pc->map2d[ind][2];
-					tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-				}
-			}
-			break;
+          if (ind>=clen) ind = ind % clen;
+          tr = pc->map2d[ind][0];
+          tg = pc->map2d[ind][1];
+          tb = pc->map2d[ind][2];
+          tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
+        }
+      }
+      break;
 
-		case V3D_FLOAT32:
-			p3d_float32 = (float ***)(p4d[0]);
+    case V3D_FLOAT32:
+      p3d_float32 = (float ***)(p4d[0]);
 
-			for (j=0;j<sz2;j++)
-			{
-				for (i=0;i<sz0;i++)
-				{
-					ind = V3DLONG(p3d_float32[j][curpos][i]);
+      for (j=0;j<sz2;j++)
+      {
+        for (i=0;i<sz0;i++)
+        {
+          ind = V3DLONG(p3d_float32[j][curpos][i]);
 
-					if (ind>=clen) ind = ind % clen;
-					tr = pc->map2d[ind][0];
-					tg = pc->map2d[ind][1];
-					tb = pc->map2d[ind][2];
-					tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
-				}
-			}
-			break;
+          if (ind>=clen) ind = ind % clen;
+          tr = pc->map2d[ind][0];
+          tg = pc->map2d[ind][1];
+          tb = pc->map2d[ind][2];
+          tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
+        }
+      }
+      break;
 
-		default:
-			break;
-	}
+    default:
+      break;
+  }
 
-	return QPixmap::fromImage(tmpimg);
+  return QPixmap::fromImage(tmpimg);
 }
 
 QPixmap copyRaw2QPixmap_zPlanes_colormap(const void **** p4d, ImagePixelType dtype, V3DLONG sz0, V3DLONG sz1, V3DLONG sz2, V3DLONG sz3, V3DLONG cpos, const ColorMap *pc)
 {
     if (!p4d || !pc)
-	{
-		printf("The input parameters are invalid in copyRaw2QPixmap_zPlanes_colormap()!\n");
-		return QPixmap(sz0, sz1);
-	}
+  {
+    printf("The input parameters are invalid in copyRaw2QPixmap_zPlanes_colormap()!\n");
+    return QPixmap(sz0, sz1);
+  }
 
-	if (sz3<1)
-	{
-		printf("The number of color channels cannot be smalled than 1. Note that as an indexed color, only the first (0-th) dim is used. \n");
-		return QPixmap(sz0, sz1);
-	}
+  if (sz3<1)
+  {
+    printf("The number of color channels cannot be smalled than 1. Note that as an indexed color, only the first (0-th) dim is used. \n");
+    return QPixmap(sz0, sz1);
+  }
 
-	QImage tmpimg = QImage(sz0, sz1, QImage::Format_RGB32);
-	int tr,tg,tb;
-	int clen = pc->len;
-	V3DLONG ind;
+  QImage tmpimg = QImage(sz0, sz1, QImage::Format_RGB32);
+  int tr,tg,tb;
+  int clen = pc->len;
+  V3DLONG ind;
 
-	V3DLONG curpos = (cpos>sz2)?sz2-1:cpos-1;
-	curpos = (curpos<0)?0:curpos;
+  V3DLONG curpos = (cpos>sz2)?sz2-1:cpos-1;
+  curpos = (curpos<0)?0:curpos;
 
-	V3DLONG i,j;
+  V3DLONG i,j;
 
-	float ***p3d_float32;
-	USHORTINT16 ***p3d_uint16;
-	unsigned char ***p3d_uint8;
+  float ***p3d_float32;
+  uint16 ***p3d_uint16;
+  unsigned char ***p3d_uint8;
 
-	switch (dtype)
-	{
-		case V3D_UINT8:
-			p3d_uint8 = (unsigned char ***)(p4d[0]);
+  switch (dtype)
+  {
+    case V3D_UINT8:
+      p3d_uint8 = (unsigned char ***)(p4d[0]);
 
-			for (j=0;j<sz1;j++)
-			{
-				for (i=0;i<sz0;i++)
-				{
-					ind = V3DLONG(p3d_uint8[curpos][j][i]);
-					if (ind>=clen) ind = ind % clen;
-					tr = pc->map2d[ind][0];
-					tg = pc->map2d[ind][1];
-					tb = pc->map2d[ind][2];
-					tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
+      for (j=0;j<sz1;j++)
+      {
+        for (i=0;i<sz0;i++)
+        {
+          ind = V3DLONG(p3d_uint8[curpos][j][i]);
+          if (ind>=clen) ind = ind % clen;
+          tr = pc->map2d[ind][0];
+          tg = pc->map2d[ind][1];
+          tb = pc->map2d[ind][2];
+          tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
 
-				}
-			}
-			break;
+        }
+      }
+      break;
 
-		case V3D_UINT16:
-			p3d_uint16 = (USHORTINT16 ***)(p4d[0]);
+    case V3D_UINT16:
+      p3d_uint16 = (uint16 ***)(p4d[0]);
 
-			for (j=0;j<sz1;j++)
-			{
-				for (i=0;i<sz0;i++)
-				{
-					ind = V3DLONG(p3d_uint16[curpos][j][i]);
-					if (ind>=clen) ind = ind % clen;
-					tr = pc->map2d[ind][0];
-					tg = pc->map2d[ind][1];
-					tb = pc->map2d[ind][2];
-					tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
+      for (j=0;j<sz1;j++)
+      {
+        for (i=0;i<sz0;i++)
+        {
+          ind = V3DLONG(p3d_uint16[curpos][j][i]);
+          if (ind>=clen) ind = ind % clen;
+          tr = pc->map2d[ind][0];
+          tg = pc->map2d[ind][1];
+          tb = pc->map2d[ind][2];
+          tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
 
-				}
-			}
-			break;
+        }
+      }
+      break;
 
-		case V3D_FLOAT32:
-			p3d_float32 = (float ***)(p4d[0]);
+    case V3D_FLOAT32:
+      p3d_float32 = (float ***)(p4d[0]);
 
-			for (j=0;j<sz1;j++)
-			{
-				for (i=0;i<sz0;i++)
-				{
-					ind = V3DLONG(p3d_float32[curpos][j][i]);
-					if (ind>=clen) ind = ind % clen;
-					tr = pc->map2d[ind][0];
-					tg = pc->map2d[ind][1];
-					tb = pc->map2d[ind][2];
-					tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
+      for (j=0;j<sz1;j++)
+      {
+        for (i=0;i<sz0;i++)
+        {
+          ind = V3DLONG(p3d_float32[curpos][j][i]);
+          if (ind>=clen) ind = ind % clen;
+          tr = pc->map2d[ind][0];
+          tg = pc->map2d[ind][1];
+          tb = pc->map2d[ind][2];
+          tmpimg.setPixel(i, j, qRgb(tr, tg, tb));
 
-				}
-			}
-			break;
+        }
+      }
+      break;
 
-		default:
-			break;
-	}
+    default:
+      break;
+  }
 
-	return QPixmap::fromImage(tmpimg);
+  return QPixmap::fromImage(tmpimg);
 }
 
 
@@ -1233,22 +1233,22 @@
   switch (Ptype)
   {
     case imgPlaneX:
-	  focusPosInWidth = imgData->curFocusZ;
-	  focusPosInHeight = imgData->curFocusY;
-	  break;
+    focusPosInWidth = imgData->curFocusZ;
+    focusPosInHeight = imgData->curFocusY;
+    break;
 
-	case imgPlaneY:
-	  focusPosInWidth = imgData->curFocusX;
-	  focusPosInHeight = imgData->curFocusZ;
-	  break;
+  case imgPlaneY:
+    focusPosInWidth = imgData->curFocusX;
+    focusPosInHeight = imgData->curFocusZ;
+    break;
 
-	case imgPlaneZ:
-	  focusPosInWidth = imgData->curFocusX;
-	  focusPosInHeight = imgData->curFocusY;
-	  break;
+  case imgPlaneZ:
+    focusPosInWidth = imgData->curFocusX;
+    focusPosInHeight = imgData->curFocusY;
+    break;
 
-	default:
-	  return false;
+  default:
+    return false;
   }
 
   return (focusPosInWidth==-1 || focusPosInHeight==-1) ? false : true;
@@ -1274,146 +1274,146 @@
 //    m_rotation = 0.0;
     m_scale = 1.0;
 //    m_shear = 0.0;
-	myCursor = QCursor(Qt::OpenHandCursor);
+  myCursor = QCursor(Qt::OpenHandCursor);
 
     b_displayFocusCrossLine = true;
 
     Ptype = imgPlaneUndefined; //set -1 as a invalid type
     cur_focus_pos = 1;
-	imgData = 0; //make a reference to the actual data
-	Ctype = colorRGB; //set how to display RGB color. This setting can be changed later by the setCType() function
+  imgData = 0; //make a reference to the actual data
+  Ctype = colorRGB; //set how to display RGB color. This setting can be changed later by the setCType() function
 
     // set a default map
 
-	pixmap = QPixmap(256, 256);
-	pixmap.fill(Qt::red);
+  pixmap = QPixmap(256, 256);
+  pixmap.fill(Qt::red);
 
     focusPosInWidth = pixmap.width()/2.0;
     focusPosInHeight = pixmap.height()/2.0;
 
-	bMouseCurorIn = false;
+  bMouseCurorIn = false;
 
     //setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 
-	curDisplayCenter = QPoint(pixmap.width()/2.0, pixmap.height()/2.0);
+  curDisplayCenter = QPoint(pixmap.width()/2.0, pixmap.height()/2.0);
 
-	//080106
-	ind_landmarkToBeChanged=-1; //reset it initially
-	b_moveCurrentLandmark = false; //reset it initially
+  //080106
+  ind_landmarkToBeChanged=-1; //reset it initially
+  b_moveCurrentLandmark = false; //reset it initially
 
-	//081114
-//	int max_width_height=256;
-//	double r1 = qMin(pixmap.width(), max_width_height) / double(pixmap.width());
-//	double r2 = qMin(pixmap.height(), max_width_height) / double(pixmap.height());
-//	disp_scale = qMin(r1, r2);
-//	disp_width = qMax(1, int(disp_scale * pixmap.width()));
-//	disp_height = qMax(1, int(disp_scale * pixmap.height()));
-//	b_lock_wh_ratio = true;
+  //081114
+//  int max_width_height=256;
+//  double r1 = qMin(pixmap.width(), max_width_height) / double(pixmap.width());
+//  double r2 = qMin(pixmap.height(), max_width_height) / double(pixmap.height());
+//  disp_scale = qMin(r1, r2);
+//  disp_width = qMax(1, int(disp_scale * pixmap.width()));
+//  disp_height = qMax(1, int(disp_scale * pixmap.height()));
+//  b_lock_wh_ratio = true;
 
-	disp_scale = 1;
-	disp_width = disp_scale * pixmap.width();
-	disp_height = disp_scale * pixmap.height();
+  disp_scale = 1;
+  disp_width = disp_scale * pixmap.width();
+  disp_height = disp_scale * pixmap.height();
 }
 
 void XFormView::setImgData(ImagePlaneDisplayType ptype, My4DImage * pdata, ImageDisplayColorType ctype)
 {
-	Ptype = ptype; //which type of the display cutting plane the pixmap is going to get from pdata image
+  Ptype = ptype; //which type of the display cutting plane the pixmap is going to get from pdata image
     cur_focus_pos = 1;
-	imgData = pdata; //make a reference to the actual data
-	Ctype = ctype; //set how to display RGB color. This setting can be changed later by the setCType() function
+  imgData = pdata; //make a reference to the actual data
+  Ctype = ctype; //set how to display RGB color. This setting can be changed later by the setCType() function
 
     if (!imgData) //this is used to set the default pictures
-	{
-	  switch (Ptype)
-	  {
-	    case imgPlaneX:
-		  pixmap = QPixmap(":/pic/default_yz_pic.jpg");
-		  break;
-	    case imgPlaneY:
-		  pixmap = QPixmap(":/pic/default_zx_pic.jpg");
-		  break;
-	    case imgPlaneZ:
-		  pixmap = QPixmap(":/pic/default_xy_pic.jpg");
-		  break;
-	    default:
-		  pixmap = QPixmap(":/pic/bg1.jpg");
-		  break;
-	  }
-   	  printf("The pixel map size is %d %d (for invalid imagedata)\n", pixmap.width(), pixmap.height());
+  {
+    switch (Ptype)
+    {
+      case imgPlaneX:
+      pixmap = QPixmap(":/pic/default_yz_pic.jpg");
+      break;
+      case imgPlaneY:
+      pixmap = QPixmap(":/pic/default_zx_pic.jpg");
+      break;
+      case imgPlaneZ:
+      pixmap = QPixmap(":/pic/default_xy_pic.jpg");
+      break;
+      default:
+      pixmap = QPixmap(":/pic/bg1.jpg");
+      break;
+    }
+       printf("The pixel map size is %d %d (for invalid imagedata)\n", pixmap.width(), pixmap.height());
 
-	  return;
-	}
+    return;
+  }
 
     ImagePixelType dtype;
-  	unsigned char **** p4d = (unsigned char ****)imgData->getData(dtype);
-  	if (!p4d)
-  	{
-	    printf("invalid pointer address in XFormView::setImgData()\n");
-	    switch (Ptype)
-	    {
-	      case imgPlaneX:
-		    pixmap = QPixmap(":/pic/default_yz_pic.jpg");
-		    break;
-	      case imgPlaneY:
-		    pixmap = QPixmap(":/pic/default_zx_pic.jpg");
-		    break;
-	      case imgPlaneZ:
-		    pixmap = QPixmap(":/pic/default_xy_pic.jpg");
-		    break;
-	      default:
-		    pixmap = QPixmap(":/pic/bg1.jpg");
-		    break;
-	    }
+    unsigned char **** p4d = (unsigned char ****)imgData->getData(dtype);
+    if (!p4d)
+    {
+      printf("invalid pointer address in XFormView::setImgData()\n");
+      switch (Ptype)
+      {
+        case imgPlaneX:
+        pixmap = QPixmap(":/pic/default_yz_pic.jpg");
+        break;
+        case imgPlaneY:
+        pixmap = QPixmap(":/pic/default_zx_pic.jpg");
+        break;
+        case imgPlaneZ:
+        pixmap = QPixmap(":/pic/default_xy_pic.jpg");
+        break;
+        default:
+        pixmap = QPixmap(":/pic/bg1.jpg");
+        break;
+      }
 
-   	    //printf("The pixel map size is %d %d\n", pixmap.width(), pixmap.height());
-	}
-	else
-	{   //the ->sz0 operation should be replaced by a safer fucntion calling later
+         //printf("The pixel map size is %d %d\n", pixmap.width(), pixmap.height());
+  }
+  else
+  {   //the ->sz0 operation should be replaced by a safer fucntion calling later
 
-		//080824: copied from wano
+    //080824: copied from wano
 
-		if (dtype==V3D_UINT8)
-		{
-			if (imgData->getCDim()==1 && (Ctype==colorPseudoMaskColor || Ctype==colorArnimFlyBrainColor || Ctype==colorHanchuanFlyBrainColor))
-			{
-				if (imgData->colorMap)
+    if (dtype==V3D_UINT8)
+    {
+      if (imgData->getCDim()==1 && (Ctype==colorPseudoMaskColor || Ctype==colorArnimFlyBrainColor || Ctype==colorHanchuanFlyBrainColor))
+      {
+        if (imgData->colorMap)
           {
-					pixmap = copyRaw2QPixmap_colormap( 
-            (const void ****) p4d, dtype, 
-            imgData->getXDim(), 
-            imgData->getYDim(), 
-            imgData->getZDim(), 
-            imgData->getCDim(), 
-            cur_focus_pos, 
+          pixmap = copyRaw2QPixmap_colormap(
+            (const void ****) p4d, dtype,
+            imgData->getXDim(),
+            imgData->getYDim(),
+            imgData->getZDim(),
+            imgData->getCDim(),
+            cur_focus_pos,
             imgData->colorMap, Ptype);
           }
-				else
-				{
-					v3d_msg("The image colormap has not been set yet (XFormView::setImgData()) for UINT8!\n");
-					return;
-				}
-			}
-			else
-			{
-				pixmap = copyRaw2QPixmap(  // FIXME: implement a variant of copyRaw2QPixmap that takes an imgData as parameter
+        else
+        {
+          v3d_msg("The image colormap has not been set yet (XFormView::setImgData()) for UINT8!\n");
+          return;
+        }
+      }
+      else
+      {
+        pixmap = copyRaw2QPixmap(  // FIXME: implement a variant of copyRaw2QPixmap that takes an imgData as parameter
           (const unsigned char ****) p4d,
           imgData->getXDim(),
           imgData->getYDim(),
           imgData->getZDim(),
           imgData->getCDim(),
           Ctype, cur_focus_pos, Ptype,
-			  	imgData->getFlagImgValScaleDisplay(),
-			    imgData->p_vmax,
-			    imgData->p_vmin);
-			}
-		}
-		else if (dtype==V3D_UINT16)  // this part need to change in the future when I want to scale the UINT16 and display it as grayscale-256
-		{
-			if (imgData->getCDim()==1)
-			{
-				if (imgData->colorMap && (Ctype==colorPseudoMaskColor || Ctype==colorArnimFlyBrainColor || Ctype==colorHanchuanFlyBrainColor))
+          imgData->getFlagImgValScaleDisplay(),
+          imgData->p_vmax,
+          imgData->p_vmin);
+      }
+    }
+    else if (dtype==V3D_UINT16)  // this part need to change in the future when I want to scale the UINT16 and display it as grayscale-256
+    {
+      if (imgData->getCDim()==1)
+      {
+        if (imgData->colorMap && (Ctype==colorPseudoMaskColor || Ctype==colorArnimFlyBrainColor || Ctype==colorHanchuanFlyBrainColor))
           {
-					pixmap = copyRaw2QPixmap_colormap(
+          pixmap = copyRaw2QPixmap_colormap(
             (const void ****) p4d,
             dtype,
             imgData->getXDim(),
@@ -1423,33 +1423,33 @@
             cur_focus_pos,
             imgData->colorMap, Ptype);
           }
-				else
-				{
-					v3d_msg(QString("The image colormap has not been set yet (XFormView::setImgData()) for UINT16. imgData->colorMap=%1, Ctype=%2!\n").arg((V3DLONG)imgData->colorMap).arg((int)Ctype));
-					return;
-				}
-			}
-			else
-			{
-				pixmap = copyRaw2QPixmap(
-          (const unsigned short int ****) p4d, 
+        else
+        {
+          v3d_msg(QString("The image colormap has not been set yet (XFormView::setImgData()) for UINT16. imgData->colorMap=%1, Ctype=%2!\n").arg((V3DLONG)imgData->colorMap).arg((int)Ctype));
+          return;
+        }
+      }
+      else
+      {
+        pixmap = copyRaw2QPixmap(
+          (const unsigned short int ****) p4d,
           imgData->getXDim(),
           imgData->getYDim(),
           imgData->getZDim(),
           imgData->getCDim(),
           Ctype, cur_focus_pos, Ptype,
-					imgData->getFlagImgValScaleDisplay(),
-					imgData->p_vmax,
-					imgData->p_vmin);
-			}
-		}
-		else if (dtype==V3D_FLOAT32)
-		{
-			if (imgData->getCDim()==1)
-			{
-				if (imgData->colorMap && (Ctype==colorPseudoMaskColor || Ctype==colorArnimFlyBrainColor || Ctype==colorHanchuanFlyBrainColor))
+          imgData->getFlagImgValScaleDisplay(),
+          imgData->p_vmax,
+          imgData->p_vmin);
+      }
+    }
+    else if (dtype==V3D_FLOAT32)
+    {
+      if (imgData->getCDim()==1)
+      {
+        if (imgData->colorMap && (Ctype==colorPseudoMaskColor || Ctype==colorArnimFlyBrainColor || Ctype==colorHanchuanFlyBrainColor))
           {
-					pixmap = copyRaw2QPixmap_colormap(
+          pixmap = copyRaw2QPixmap_colormap(
             (const void ****) p4d,
             dtype,
             imgData->getXDim(),
@@ -1459,33 +1459,33 @@
             cur_focus_pos,
             imgData->colorMap, Ptype);
           }
-				else
-				{
-					v3d_msg(QString("The image colormap has not been set yet (XFormView::setImgData()) for UINT16. imgData->colorMap=%1, Ctype=%2!\n").arg((V3DLONG)imgData->colorMap).arg((int)Ctype));
-					return;
-				}
-			}
-			else
-			{
-				pixmap = copyRaw2QPixmap(
+        else
+        {
+          v3d_msg(QString("The image colormap has not been set yet (XFormView::setImgData()) for UINT16. imgData->colorMap=%1, Ctype=%2!\n").arg((V3DLONG)imgData->colorMap).arg((int)Ctype));
+          return;
+        }
+      }
+      else
+      {
+        pixmap = copyRaw2QPixmap(
           (const float ****) p4d,
           imgData->getXDim(),
           imgData->getYDim(),
           imgData->getZDim(),
           imgData->getCDim(),
           Ctype, cur_focus_pos, Ptype,
-					imgData->getFlagImgValScaleDisplay(),
-					imgData->p_vmax,
-					imgData->p_vmin);
-			}
-		}
-		else
-		{
-			printf("Right now only support UINT8 (grayscale) and UINT16 (colormap).\n");
-			return; //do nothing
-		}
+          imgData->getFlagImgValScaleDisplay(),
+          imgData->p_vmax,
+          imgData->p_vmin);
+      }
+    }
+    else
+    {
+      printf("Right now only support UINT8 (grayscale) and UINT16 (colormap).\n");
+      return; //do nothing
+    }
 
-	}
+  }
 }
 
 
@@ -1493,8 +1493,8 @@
 {
    if (roiPolygon.count()<2) //in case the roiPolygon is not really specified
    {
-	 //return QRect(0,0, width(), height());
-	   return QRect(0,0, pixmap.width(), pixmap.height()); //081114
+   //return QRect(0,0, width(), height());
+     return QRect(0,0, pixmap.width(), pixmap.height()); //081114
    }
    else
      return roiPolygon.boundingRect();
@@ -1503,84 +1503,84 @@
 void XFormView::mouseDoubleClickEvent(QMouseEvent * e)
 {
     if (!imgData)
-	  return;
+    return;
 
     QPoint cp = e->pos()/disp_scale;
-	int sx,sy,sz; //current selection location's x,y,z
+  int sx,sy,sz; //current selection location's x,y,z
 
-	switch(Ptype)
-	{
-		case imgPlaneZ:
-		    sx = cp.x(); sy = cp.y(); sz = imgData->curFocusZ;
-		    break;
+  switch(Ptype)
+  {
+    case imgPlaneZ:
+        sx = cp.x(); sy = cp.y(); sz = imgData->curFocusZ;
+        break;
 
-		case imgPlaneX:
-		    sz = cp.x(); sy = cp.y(); sx = imgData->curFocusX;
-		    break;
+    case imgPlaneX:
+        sz = cp.x(); sy = cp.y(); sx = imgData->curFocusX;
+        break;
 
-		case imgPlaneY:
-		    sx = cp.x(); sz = cp.y(); sy = imgData->curFocusY;
-		    break;
+    case imgPlaneY:
+        sx = cp.x(); sz = cp.y(); sy = imgData->curFocusY;
+        break;
 
-		default:
-		    return;
-			break;
-	}
+    default:
+        return;
+      break;
+  }
 
-	int rr = 10;
+  int rr = 10;
 
-	double dmin;
-	V3DLONG ind_min;
+  double dmin;
+  V3DLONG ind_min;
 
-	int tmpx,tmpy,tmpz;
-	LocationSimple tmpLocation(0,0,0);
-	double dx,dy,dz, dd;
-	int b_find = 0;
-	for (V3DLONG i=0; i<imgData->listLandmarks.count();i++)
-	{
-		tmpLocation = imgData->listLandmarks.at(i);
-		tmpLocation.getCoord(tmpx,tmpy,tmpz);
-		if (fabs(dx=tmpx-sx)>rr || fabs(dy=tmpy-sy)>rr || fabs(dz=tmpz-sz)>rr) //use a simple criterion to filter point first
-		  continue;
-		if ((dd=dx*dx+dy*dy+dz*dz)>rr*rr)
-		  continue;
+  int tmpx,tmpy,tmpz;
+  LocationSimple tmpLocation(0,0,0);
+  double dx,dy,dz, dd;
+  int b_find = 0;
+  for (V3DLONG i=0; i<imgData->listLandmarks.count();i++)
+  {
+    tmpLocation = imgData->listLandmarks.at(i);
+    tmpLocation.getCoord(tmpx,tmpy,tmpz);
+    if (fabs(dx=tmpx-sx)>rr || fabs(dy=tmpy-sy)>rr || fabs(dz=tmpz-sz)>rr) //use a simple criterion to filter point first
+      continue;
+    if ((dd=dx*dx+dy*dy+dz*dz)>rr*rr)
+      continue;
 
-		if (b_find==0)
-		{
-		  b_find=1;
-		  dmin = dd;
-		  ind_min = i;
-		}
-		else
-		{
-  		  if (dd<dmin)
-		  {
-		    dmin = dd;
-			ind_min = i;
-		  }
-		}
-	}
+    if (b_find==0)
+    {
+      b_find=1;
+      dmin = dd;
+      ind_min = i;
+    }
+    else
+    {
+        if (dd<dmin)
+      {
+        dmin = dd;
+      ind_min = i;
+      }
+    }
+  }
 
-	if (b_find==1)
-	{
-		QString tmps("Change Landmark [");
-		QString v1,v2,v3;
-		tmpLocation = imgData->listLandmarks.at(ind_min);
-		tmpLocation.getCoord(tmpx,tmpy,tmpz);
-		v1.setNum(tmpx+1); v1.append(",");
-		v2.setNum(tmpy+1); v2.append(",");
-		v3.setNum(tmpz+1); v3.append("]");
-		tmps.append(v1);
-		tmps.append(v2);
-		tmps.append(v3);
+  if (b_find==1)
+  {
+    QString tmps("Change Landmark [");
+    QString v1,v2,v3;
+    tmpLocation = imgData->listLandmarks.at(ind_min);
+    tmpLocation.getCoord(tmpx,tmpy,tmpz);
+    v1.setNum(tmpx+1); v1.append(",");
+    v2.setNum(tmpy+1); v2.append(",");
+    v3.setNum(tmpz+1); v3.append("]");
+    tmps.append(v1);
+    tmps.append(v2);
+    tmps.append(v3);
 
         QMessageBox mb(tmps, //tr("Landmark change: []"),
-					   "Change (delete) the selected marker?",
-					   QMessageBox::Question,
-					   QMessageBox::Yes | QMessageBox::Default,
-					   QMessageBox::No,
-					   QMessageBox::Cancel | QMessageBox::Escape);
-		mb.addButton(QMessageBox::Open);
+             "Change (delete) the selected marker?",
+             QMessageBox::Question,
+             QMessageBox::Yes | QMessageBox::Default,
+             QMessageBox::No,
+             QMessageBox::Cancel | QMessageBox::Escape);
+    mb.addButton(QMessageBox::Open);
 
         mb.setButtonText(QMessageBox::Yes, "Move");
         mb.setButtonText(QMessageBox::No, "Delete");
@@ -1589,53 +1589,53 @@
 
         switch(mb.exec()) {
             case QMessageBox::Yes:
-				//move the location: 080101
-				setMouseTracking(false); //"false" should be the default, but I set it again here to assure the mouseMove event is captured only when one mouse button is pressed
-				b_moveCurrentLandmark=true;
-				ind_landmarkToBeChanged=ind_min;
-				printf("landmark to change=[%ld] start\n", ind_landmarkToBeChanged);
+        //move the location: 080101
+        setMouseTracking(false); //"false" should be the default, but I set it again here to assure the mouseMove event is captured only when one mouse button is pressed
+        b_moveCurrentLandmark=true;
+        ind_landmarkToBeChanged=ind_min;
+        printf("landmark to change=[%ld] start\n", ind_landmarkToBeChanged);
 
-				//imgData->listLandmarks.removeAt(ind_min);
-				//imgData->setFocusFeatureViewText();
-				break;
+        //imgData->listLandmarks.removeAt(ind_min);
+        //imgData->setFocusFeatureViewText();
+        break;
 
-			case QMessageBox::No:
-				//delete the current landmark
-				imgData->listLandmarks.removeAt(ind_min);
-				imgData->setFocusFeatureViewText();
-				break;
+      case QMessageBox::No:
+        //delete the current landmark
+        imgData->listLandmarks.removeAt(ind_min);
+        imgData->setFocusFeatureViewText();
+        break;
 
-			case QMessageBox::Open:
-				{
-					LandmarkPropertyDialog *landmarkView = NULL;
-					landmarkView = new LandmarkPropertyDialog(&(imgData->listLandmarks), ind_min, imgData);
-					if (landmarkView->exec()!=QDialog::Accepted)
-					{
-						if (landmarkView) {delete landmarkView; landmarkView = NULL;}
-						break; //only return true when the results are accepted, which will lead to an update operation below
-					}
-					landmarkView->fetchData(&(imgData->listLandmarks), ind_min);
-					qDebug("edit landmark [%ld]. data fetched [%s][%s][%d]", ind_min,
-						   imgData->listLandmarks.at(ind_min).name.c_str(), imgData->listLandmarks.at(ind_min).comments.c_str(),  int(imgData->listLandmarks.at(ind_min).shape));
+      case QMessageBox::Open:
+        {
+          LandmarkPropertyDialog *landmarkView = NULL;
+          landmarkView = new LandmarkPropertyDialog(&(imgData->listLandmarks), ind_min, imgData);
+          if (landmarkView->exec()!=QDialog::Accepted)
+          {
+            if (landmarkView) {delete landmarkView; landmarkView = NULL;}
+            break; //only return true when the results are accepted, which will lead to an update operation below
+          }
+          landmarkView->fetchData(&(imgData->listLandmarks), ind_min);
+          qDebug("edit landmark [%ld]. data fetched [%s][%s][%d]", ind_min,
+               imgData->listLandmarks.at(ind_min).name.c_str(), imgData->listLandmarks.at(ind_min).comments.c_str(),  int(imgData->listLandmarks.at(ind_min).shape));
 
-					//inportant: set the shape of the landmark
-					LocationSimple * p_tmp_location = (LocationSimple *) & (imgData->listLandmarks.at(ind_min));
-					switch (p_tmp_location->shape)
-					{
-						case pxSphere:	p_tmp_location->inputProperty = pxLocaUseful; break;
-						case pxCube: p_tmp_location->inputProperty = pxLocaNotUseful; break;
-						default: p_tmp_location->inputProperty = pxLocaUnsure; break;
-					}
+          //inportant: set the shape of the landmark
+          LocationSimple * p_tmp_location = (LocationSimple *) & (imgData->listLandmarks.at(ind_min));
+          switch (p_tmp_location->shape)
+          {
+            case pxSphere:  p_tmp_location->inputProperty = pxLocaUseful; break;
+            case pxCube: p_tmp_location->inputProperty = pxLocaNotUseful; break;
+            default: p_tmp_location->inputProperty = pxLocaUnsure; break;
+          }
 
-					if (landmarkView) {delete landmarkView; landmarkView = NULL;}
-				}
-				break;
+          if (landmarkView) {delete landmarkView; landmarkView = NULL;}
+        }
+        break;
 
-			case QMessageBox::Cancel:
-				//do nothing
-				break;
-		}
-	}
+      case QMessageBox::Cancel:
+        //do nothing
+        break;
+    }
+  }
 }
 
 void XFormView::mousePressEvent(QMouseEvent *e)
@@ -1644,14 +1644,14 @@
   {
     case Qt::LeftButton:
       mouseLeftButtonPressEvent(e);
-	  break;
+    break;
 
-	case Qt::RightButton:
+  case Qt::RightButton:
       mouseRightButtonPressEvent(e);
-	  break;
+    break;
 
-	default:
-	  break;
+  default:
+    break;
   }
 }
 
@@ -1660,95 +1660,95 @@
 {
 //#define USE_POPUP_MENU_RIGHT
 #ifdef USE_POPUP_MENU_RIGHT
-	//printf("  ... [x=%d y=%d]\n", e->x(), e->y());
-	if (QApplication::keyboardModifiers()==Qt::ShiftModifier) //080314 to pop up the menu
-	{
-		popupImageProcessingDialog();
-	}
-	else
-	{
+  //printf("  ... [x=%d y=%d]\n", e->x(), e->y());
+  if (QApplication::keyboardModifiers()==Qt::ShiftModifier) //080314 to pop up the menu
+  {
+    popupImageProcessingDialog();
+  }
+  else
+  {
 #endif
-		switch (Ptype)
-		{
-			case imgPlaneX:
-					emit focusZChanged(double((e->x()-curDisplayCenter.x()))/(disp_scale*m_scale)+pixmap.width()/2.0+0.5);
-					emit focusYChanged(double((e->y()-curDisplayCenter.y()))/(disp_scale*m_scale)+pixmap.height()/2.0+0.5);
-				break;
+    switch (Ptype)
+    {
+      case imgPlaneX:
+          emit focusZChanged(double((e->x()-curDisplayCenter.x()))/(disp_scale*m_scale)+pixmap.width()/2.0+0.5);
+          emit focusYChanged(double((e->y()-curDisplayCenter.y()))/(disp_scale*m_scale)+pixmap.height()/2.0+0.5);
+        break;
 
-			case imgPlaneY:
-					emit focusXChanged(double((e->x()-curDisplayCenter.x()))/(disp_scale*m_scale)+pixmap.width()/2.0+0.5);
-					emit focusZChanged(double((e->y()-curDisplayCenter.y()))/(disp_scale*m_scale)+pixmap.height()/2.0+0.5);
-				break;
+      case imgPlaneY:
+          emit focusXChanged(double((e->x()-curDisplayCenter.x()))/(disp_scale*m_scale)+pixmap.width()/2.0+0.5);
+          emit focusZChanged(double((e->y()-curDisplayCenter.y()))/(disp_scale*m_scale)+pixmap.height()/2.0+0.5);
+        break;
 
-			case imgPlaneZ:
-					emit focusXChanged(double((e->x()-curDisplayCenter.x()))/(disp_scale*m_scale)+pixmap.width()/2.0+0.5);
-					emit focusYChanged(double((e->y()-curDisplayCenter.y()))/(disp_scale*m_scale)+pixmap.height()/2.0+0.5);
-				//qDebug()<<"x="<<e->x()<<"y="<<e->y()<<"disp_scale="<<disp_scale<<"m_scale="<<m_scale<<"curdispcenter.x="<<curDisplayCenter.x()<<"curdispcenter.y="<<curDisplayCenter.y();
+      case imgPlaneZ:
+          emit focusXChanged(double((e->x()-curDisplayCenter.x()))/(disp_scale*m_scale)+pixmap.width()/2.0+0.5);
+          emit focusYChanged(double((e->y()-curDisplayCenter.y()))/(disp_scale*m_scale)+pixmap.height()/2.0+0.5);
+        //qDebug()<<"x="<<e->x()<<"y="<<e->y()<<"disp_scale="<<disp_scale<<"m_scale="<<m_scale<<"curdispcenter.x="<<curDisplayCenter.x()<<"curdispcenter.y="<<curDisplayCenter.y();
 
-				break;
+        break;
 
-			default: //do nothing
-				break;
-		}
+      default: //do nothing
+        break;
+    }
 #ifdef USE_POPUP_MENU_RIGHT
-	}
+  }
 #endif
 }
 
 void XFormView::mouseLeftButtonPressEvent(QMouseEvent *e) //080101
 {
-	//reserved for future editing of the the pop-up menu
-	if (QApplication::keyboardModifiers()==Qt::ControlModifier)
-	{
-		roiPolygon << e->pos()/disp_scale;
-		update();
-	}
-	else if (b_moveCurrentLandmark==true && ind_landmarkToBeChanged>=0 && QApplication::keyboardModifiers()==Qt::ShiftModifier)
-	{
-		QPoint cp = e->pos()/disp_scale;
+  //reserved for future editing of the the pop-up menu
+  if (QApplication::keyboardModifiers()==Qt::ControlModifier)
+  {
+    roiPolygon << e->pos()/disp_scale;
+    update();
+  }
+  else if (b_moveCurrentLandmark==true && ind_landmarkToBeChanged>=0 && QApplication::keyboardModifiers()==Qt::ShiftModifier)
+  {
+    QPoint cp = e->pos()/disp_scale;
 
-		int sx,sy,sz; //current selection location's x,y,z
+    int sx,sy,sz; //current selection location's x,y,z
 
-		switch(Ptype)
-		{
-			case imgPlaneZ:
-				sx = cp.x(); sy = cp.y(); sz = imgData->curFocusZ;
-				break;
+    switch(Ptype)
+    {
+      case imgPlaneZ:
+        sx = cp.x(); sy = cp.y(); sz = imgData->curFocusZ;
+        break;
 
-			case imgPlaneX:
-				sz = cp.x(); sy = cp.y(); sx = imgData->curFocusX;
-				break;
+      case imgPlaneX:
+        sz = cp.x(); sy = cp.y(); sx = imgData->curFocusX;
+        break;
 
-			case imgPlaneY:
-				sx = cp.x(); sz = cp.y(); sy = imgData->curFocusY;
-				break;
+      case imgPlaneY:
+        sx = cp.x(); sz = cp.y(); sy = imgData->curFocusY;
+        break;
 
-			default:
-				return;
-				break;
-		}
+      default:
+        return;
+        break;
+    }
 
-		LocationSimple tmpLocation(sx,sy,sz);
-		tmpLocation.inputProperty = imgData->listLandmarks.at(ind_landmarkToBeChanged).inputProperty;
-		tmpLocation.radius = imgData->listLandmarks.at(ind_landmarkToBeChanged).radius;
-		imgData->listLandmarks.replace(ind_landmarkToBeChanged, tmpLocation);
-		imgData->setFocusFeatureViewText();
+    LocationSimple tmpLocation(sx,sy,sz);
+    tmpLocation.inputProperty = imgData->listLandmarks.at(ind_landmarkToBeChanged).inputProperty;
+    tmpLocation.radius = imgData->listLandmarks.at(ind_landmarkToBeChanged).radius;
+    imgData->listLandmarks.replace(ind_landmarkToBeChanged, tmpLocation);
+    imgData->setFocusFeatureViewText();
 
-		imgData->b_proj_worm_mst_diameter_set = false; //080318: whenever a landmark's location has been changed, reset the flag of MST diameter existency
+    imgData->b_proj_worm_mst_diameter_set = false; //080318: whenever a landmark's location has been changed, reset the flag of MST diameter existency
 
-		printf("end moving point [%ld].\n", ind_landmarkToBeChanged);
-		ind_landmarkToBeChanged=-1; //reset it after the updating
-		b_moveCurrentLandmark = false; //reset it after the updating
+    printf("end moving point [%ld].\n", ind_landmarkToBeChanged);
+    ind_landmarkToBeChanged=-1; //reset it after the updating
+    b_moveCurrentLandmark = false; //reset it after the updating
 
-		//update();
-	    imgData->updateViews();
-	}
-	else if (m_scale>1) //then interpret the press as a drag operation
-	{
-		dragStartPosition = e->pos();
-		curDisplayCenter0 = curDisplayCenter;
-	    setCursor(myCursor);
-	}
+    //update();
+      imgData->updateViews();
+  }
+  else if (m_scale>1) //then interpret the press as a drag operation
+  {
+    dragStartPosition = e->pos();
+    curDisplayCenter0 = curDisplayCenter;
+      setCursor(myCursor);
+  }
 }
 
 void XFormView::mouseMoveEvent (QMouseEvent * e)
@@ -1757,29 +1757,29 @@
   curMousePos = e->pos()/disp_scale;
 
     //090212. for panning
-	if (m_scale>1)
-	{
-		if ((e->buttons() & Qt::LeftButton))
-		{
-			{
-				setCursor(myCursor); //maybe repeated set? is this necessary?
+  if (m_scale>1)
+  {
+    if ((e->buttons() & Qt::LeftButton))
+    {
+      {
+        setCursor(myCursor); //maybe repeated set? is this necessary?
 
-				curDisplayCenter = curDisplayCenter0 + QPointF(curMousePos.x()*disp_scale-dragStartPosition.x(), curMousePos.y()*disp_scale-dragStartPosition.y());
-				//qDebug()<<curDisplayCenter.x()<<" "<<curDisplayCenter.y();
+        curDisplayCenter = curDisplayCenter0 + QPointF(curMousePos.x()*disp_scale-dragStartPosition.x(), curMousePos.y()*disp_scale-dragStartPosition.y());
+        //qDebug()<<curDisplayCenter.x()<<" "<<curDisplayCenter.y();
 
-				if (curDisplayCenter.x() < (2-m_scale)*disp_width/2.0-1)
-					curDisplayCenter.setX((2-m_scale)*disp_width/2.0-1);
-				else if (curDisplayCenter.x() > m_scale*disp_width/2.0)
-					curDisplayCenter.setX(m_scale*disp_width/2.0);
+        if (curDisplayCenter.x() < (2-m_scale)*disp_width/2.0-1)
+          curDisplayCenter.setX((2-m_scale)*disp_width/2.0-1);
+        else if (curDisplayCenter.x() > m_scale*disp_width/2.0)
+          curDisplayCenter.setX(m_scale*disp_width/2.0);
 
-				if (curDisplayCenter.y() < (2-m_scale)*disp_height/2.0-1)
-					curDisplayCenter.setY((2-m_scale)*disp_height/2.0-1);
-				else if (curDisplayCenter.y() > m_scale*disp_height/2.0)
-					curDisplayCenter.setY(m_scale*disp_height/2.0);
-			}
-		}
-	}
-	update();
+        if (curDisplayCenter.y() < (2-m_scale)*disp_height/2.0-1)
+          curDisplayCenter.setY((2-m_scale)*disp_height/2.0-1);
+        else if (curDisplayCenter.y() > m_scale*disp_height/2.0)
+          curDisplayCenter.setY(m_scale*disp_height/2.0);
+      }
+    }
+  }
+  update();
 }
 
 void XFormView::enterEvent (QEvent * e)
@@ -1836,34 +1836,34 @@
 void XFormView::changeScale(int s)
 {
     m_scale = double(s/4.0);
-	if (m_scale<=1)
-		curDisplayCenter = QPointF(disp_width/2.0, disp_height/2.0); //reset the center
+  if (m_scale<=1)
+    curDisplayCenter = QPointF(disp_width/2.0, disp_height/2.0); //reset the center
     update();
 }
 
 void XFormView::changeFocusPlane(int c)
 {
     if (!imgData)
-	  return;
+    return;
 
     ImagePixelType dtype;
     unsigned char ****p4d = (unsigned char ****)imgData->getData(dtype);
-	if (!p4d)
-	  return;
+  if (!p4d)
+    return;
 
     cur_focus_pos = c;
-//	pixmap = copyRaw2QPixmap((const unsigned char ****) p4d, imgData->sz0, imgData->sz1, imgData->sz2, imgData->sz3, Ctype, cur_focus_pos, Ptype,
-//							 imgData->getFlagImgValScaleDisplay(),
-//							 imgData->p_vmax,
-//							 imgData->p_vmin);
+//  pixmap = copyRaw2QPixmap((const unsigned char ****) p4d, imgData->sz0, imgData->sz1, imgData->sz2, imgData->sz3, Ctype, cur_focus_pos, Ptype,
+//               imgData->getFlagImgValScaleDisplay(),
+//               imgData->p_vmax,
+//               imgData->p_vmin);
 //
-	if (dtype==V3D_UINT8)
-	{
-		if (imgData->getCDim()==1 && (Ctype==colorPseudoMaskColor || Ctype==colorArnimFlyBrainColor || Ctype==colorHanchuanFlyBrainColor))
-		{
-			if (imgData->colorMap)
+  if (dtype==V3D_UINT8)
+  {
+    if (imgData->getCDim()==1 && (Ctype==colorPseudoMaskColor || Ctype==colorArnimFlyBrainColor || Ctype==colorHanchuanFlyBrainColor))
+    {
+      if (imgData->colorMap)
         {
-				pixmap = copyRaw2QPixmap_colormap(
+        pixmap = copyRaw2QPixmap_colormap(
           (const void ****) p4d,
           dtype,
           imgData->getXDim(),
@@ -1874,16 +1874,16 @@
           imgData->colorMap,
           Ptype);
         }
-			else
-			{
-				printf("The image colormap has not been set yet (changeFocusPlane())!\n");
-				return;
-			}
-		}
-		else
-		{
-			//qDebug("focus=%d [ptype=%d]", cur_focus_pos, int(Ptype));
-			pixmap = copyRaw2QPixmap(
+      else
+      {
+        printf("The image colormap has not been set yet (changeFocusPlane())!\n");
+        return;
+      }
+    }
+    else
+    {
+      //qDebug("focus=%d [ptype=%d]", cur_focus_pos, int(Ptype));
+      pixmap = copyRaw2QPixmap(
        (const unsigned char ****) p4d,
        imgData->getXDim(),
        imgData->getYDim(),
@@ -1892,18 +1892,18 @@
        Ctype,
        cur_focus_pos,
        Ptype,
-			 imgData->getFlagImgValScaleDisplay(),
-			 imgData->p_vmax,
-			 imgData->p_vmin);
-		}
-	}
-	else if (dtype==V3D_UINT16)  // this part need to change in the future when I want to scale the UINT16 and display it as grayscale-256
-	{
-		if (imgData->getCDim()==1 && (Ctype==colorPseudoMaskColor || Ctype==colorArnimFlyBrainColor || Ctype==colorHanchuanFlyBrainColor))
-		{
-			if (imgData->colorMap)
+       imgData->getFlagImgValScaleDisplay(),
+       imgData->p_vmax,
+       imgData->p_vmin);
+    }
+  }
+  else if (dtype==V3D_UINT16)  // this part need to change in the future when I want to scale the UINT16 and display it as grayscale-256
+  {
+    if (imgData->getCDim()==1 && (Ctype==colorPseudoMaskColor || Ctype==colorArnimFlyBrainColor || Ctype==colorHanchuanFlyBrainColor))
+    {
+      if (imgData->colorMap)
         {
-				pixmap = copyRaw2QPixmap_colormap(
+        pixmap = copyRaw2QPixmap_colormap(
           (const void ****) p4d,
           dtype,
           imgData->getXDim(),
@@ -1914,15 +1914,15 @@
           imgData->colorMap,
           Ptype);
         }
-			else
-			{
-				printf("The image colormap has not been set yet (changeFocusPlane())!\n");
-				return;
-			}
-		}
-		else
-		{
-			pixmap = copyRaw2QPixmap(
+      else
+      {
+        printf("The image colormap has not been set yet (changeFocusPlane())!\n");
+        return;
+      }
+    }
+    else
+    {
+      pixmap = copyRaw2QPixmap(
         (const unsigned short int ****) p4d,
         imgData->getXDim(),
         imgData->getYDim(),
@@ -1931,39 +1931,39 @@
         Ctype,
         cur_focus_pos,
         Ptype,
-				imgData->getFlagImgValScaleDisplay(),
-				imgData->p_vmax,
-				imgData->p_vmin);
-		}
-	}
-	else
-	{
-		printf("Right now only support UINT8 (grayscale) and UINT16 (colormap).\n");
-		return; //do nothing
-	}
+        imgData->getFlagImgValScaleDisplay(),
+        imgData->p_vmax,
+        imgData->p_vmin);
+    }
+  }
+  else
+  {
+    printf("Right now only support UINT8 (grayscale) and UINT16 (colormap).\n");
+    return; //do nothing
+  }
 
-	switch (Ptype)
-	{
-	  case imgPlaneX: imgData->setFocusX(cur_focus_pos); break;
-	  case imgPlaneY: imgData->setFocusY(cur_focus_pos); break;
-	  case imgPlaneZ: imgData->setFocusZ(cur_focus_pos); break;
-	  default: break; //do nothing
-	}
+  switch (Ptype)
+  {
+    case imgPlaneX: imgData->setFocusX(cur_focus_pos); break;
+    case imgPlaneY: imgData->setFocusY(cur_focus_pos); break;
+    case imgPlaneZ: imgData->setFocusZ(cur_focus_pos); break;
+    default: break; //do nothing
+  }
 
-	//update the focus cross lines in other two views
+  //update the focus cross lines in other two views
 
-	if (imgData->getFlagLinkFocusViews()==true) //otherwise do not update the two other views
-	{
-	  if (imgData->get_xy_view()!=this)
-	    imgData->get_xy_view()->update();
-	  if (imgData->get_yz_view()!=this)
-	    imgData->get_yz_view()->update();
-	  if (imgData->get_zx_view()!=this)
-	    imgData->get_zx_view()->update();
-	}
+  if (imgData->getFlagLinkFocusViews()==true) //otherwise do not update the two other views
+  {
+    if (imgData->get_xy_view()!=this)
+      imgData->get_xy_view()->update();
+    if (imgData->get_yz_view()!=this)
+      imgData->get_yz_view()->update();
+    if (imgData->get_zx_view()!=this)
+      imgData->get_zx_view()->update();
+  }
 
 
-	imgData->setFocusFeatureViewText();
+  imgData->setFocusFeatureViewText();
 
     //update the current view
     update();
@@ -1974,29 +1974,29 @@
     Ctype = c;
 
     if (!imgData)
-	  return;
+    return;
 
     /* the following three sentences are used to assue the display is updated */
     ImagePixelType dtype;
     unsigned char ****p4d = (unsigned char ****)imgData->getData(dtype);
 
-	if (!p4d)
-	  return;
+  if (!p4d)
+    return;
 
 //    pixmap = copyRaw2QPixmap((const unsigned char ****) p4d, imgData->sz0, imgData->sz1, imgData->sz2, imgData->sz3, Ctype, cur_focus_pos, Ptype,
-//							 imgData->getFlagImgValScaleDisplay(),
-//							 imgData->p_vmax,
-//							 imgData->p_vmin);
+//               imgData->getFlagImgValScaleDisplay(),
+//               imgData->p_vmax,
+//               imgData->p_vmin);
 //
 
-	//
-	if (dtype==V3D_UINT8)
-	{
-		if (imgData->getCDim()==1 && (Ctype==colorPseudoMaskColor || Ctype==colorArnimFlyBrainColor || Ctype==colorHanchuanFlyBrainColor))
-		{
-			if (imgData->colorMap)
+  //
+  if (dtype==V3D_UINT8)
+  {
+    if (imgData->getCDim()==1 && (Ctype==colorPseudoMaskColor || Ctype==colorArnimFlyBrainColor || Ctype==colorHanchuanFlyBrainColor))
+    {
+      if (imgData->colorMap)
         {
-				pixmap = copyRaw2QPixmap_colormap(
+        pixmap = copyRaw2QPixmap_colormap(
           (const void ****) p4d,
           dtype,
           imgData->getXDim(),
@@ -2007,15 +2007,15 @@
           imgData->colorMap,
           Ptype);
         }
-			else
-			{
-				printf("The image colormap has not been set yet (changeColorType()) for UINT8!\n");
-				return;
-			}
-		}
-		else
-		{
-			pixmap = copyRaw2QPixmap(
+      else
+      {
+        printf("The image colormap has not been set yet (changeColorType()) for UINT8!\n");
+        return;
+      }
+    }
+    else
+    {
+      pixmap = copyRaw2QPixmap(
         (const unsigned char ****) p4d,
         imgData->getXDim(),
         imgData->getYDim(),
@@ -2024,18 +2024,18 @@
         Ctype,
         cur_focus_pos,
         Ptype,
-				imgData->getFlagImgValScaleDisplay(),
-				imgData->p_vmax,
-				imgData->p_vmin);
-		}
-	}
-	else if (dtype==V3D_UINT16)  // this part need to change in the future when I want to scale the UINT16 and display it as grayscale-256
-	{
-		if (imgData->getCDim()==1 && (Ctype==colorPseudoMaskColor || Ctype==colorArnimFlyBrainColor || Ctype==colorHanchuanFlyBrainColor))
-		{
-			if (imgData->colorMap)
+        imgData->getFlagImgValScaleDisplay(),
+        imgData->p_vmax,
+        imgData->p_vmin);
+    }
+  }
+  else if (dtype==V3D_UINT16)  // this part need to change in the future when I want to scale the UINT16 and display it as grayscale-256
+  {
+    if (imgData->getCDim()==1 && (Ctype==colorPseudoMaskColor || Ctype==colorArnimFlyBrainColor || Ctype==colorHanchuanFlyBrainColor))
+    {
+      if (imgData->colorMap)
         {
-				pixmap = copyRaw2QPixmap_colormap(
+        pixmap = copyRaw2QPixmap_colormap(
           (const void ****) p4d,
            dtype,
            imgData->getXDim(),
@@ -2046,15 +2046,15 @@
            imgData->colorMap,
            Ptype);
         }
-			else
-			{
-				printf("The image colormap has not been set yet (changeColorType()) for UINT16!\n");
-				return;
-			}
-		}
-		else
-		{
-			pixmap = copyRaw2QPixmap(
+      else
+      {
+        printf("The image colormap has not been set yet (changeColorType()) for UINT16!\n");
+        return;
+      }
+    }
+    else
+    {
+      pixmap = copyRaw2QPixmap(
         (const unsigned short int ****) p4d,
         imgData->getXDim(),
         imgData->getYDim(),
@@ -2063,26 +2063,26 @@
         Ctype,
         cur_focus_pos,
         Ptype,
-				imgData->getFlagImgValScaleDisplay(),
-				imgData->p_vmax,
-				imgData->p_vmin);
-		}
-	}
-	else
-	{
-		printf("Right now only support UINT8 (grayscale) and UINT16 (colormap).\n");
-		return; //do nothing
-	}
+        imgData->getFlagImgValScaleDisplay(),
+        imgData->p_vmax,
+        imgData->p_vmin);
+    }
+  }
+  else
+  {
+    printf("Right now only support UINT8 (grayscale) and UINT16 (colormap).\n");
+    return; //do nothing
+  }
 
-	//
-	update();
+  //
+  update();
 }
 
 
 void XFormView::reset()
 {
     emit scaleChanged(4);
-//	emit focusPlaneChanged(1);
+//  emit focusPlaneChanged(1);
 }
 
 void XFormView::wheelEvent(QWheelEvent * e) //add this on 2008-01-10
@@ -2090,25 +2090,25 @@
     int numDegrees = -e->delta() / 8; //change to -e on 080121
     int numSteps = numDegrees / 15;
 
-	if (!imgData) return;
-	if (imgData->isEmpty()) return;
+  if (!imgData) return;
+  if (imgData->isEmpty()) return;
 
-	switch (Ptype)
-	{
-		case imgPlaneX:
-			emit focusXChanged(imgData->curFocusX+1+numSteps); //the first +1 to convert to the range [1, max]. The below is the same.
-			break;
-		case imgPlaneY:
-			emit focusYChanged(imgData->curFocusY+1+numSteps);
-			break;
-		case imgPlaneZ:
-			emit focusZChanged(imgData->curFocusZ+1+numSteps);
-			break;
-		default: //do nothing
-			break;
-	}
+  switch (Ptype)
+  {
+    case imgPlaneX:
+      emit focusXChanged(imgData->curFocusX+1+numSteps); //the first +1 to convert to the range [1, max]. The below is the same.
+      break;
+    case imgPlaneY:
+      emit focusYChanged(imgData->curFocusY+1+numSteps);
+      break;
+    case imgPlaneZ:
+      emit focusZChanged(imgData->curFocusZ+1+numSteps);
+      break;
+    default: //do nothing
+      break;
+  }
 
-	return;
+  return;
 }
 
 //void XFormView::dragMoveEvent(QDragMoveEvent * e)
@@ -2118,760 +2118,760 @@
 void XFormView::keyPressEvent(QKeyEvent * e)
 {
     //two temp variables for pop-up dialog
-   	QStringList items;
+     QStringList items;
     QString item;
 
 
     double stepx = 1, stepy = 1; //default size is 1 pixel by pixel
-	//qDebug()<<"init: "<<stepx<<" "<<stepy;
+  //qDebug()<<"init: "<<stepx<<" "<<stepy;
 
-	//printf("[%d]\n",e->modifiers()); //don't know why this cause a crash!!
+  //printf("[%d]\n",e->modifiers()); //don't know why this cause a crash!!
 
     //if (e->modifiers()==Qt::ShiftModifier) //note that e->modifiers() does not work!!!
 
 
-	if (!imgData) return;
-	if (imgData->isEmpty()) return;
+  if (!imgData) return;
+  if (imgData->isEmpty()) return;
 
-	switch (e->key())
-	{
-		case Qt::Key_S:
-		    if (QApplication::keyboardModifiers()==Qt::ControlModifier)
-		    {
-				imgData->getXWidget()->saveData();
-			}
-			break;
+  switch (e->key())
+  {
+    case Qt::Key_S:
+        if (QApplication::keyboardModifiers()==Qt::ControlModifier)
+        {
+        imgData->getXWidget()->saveData();
+      }
+      break;
 
-		case Qt::Key_Left: //for unknown reason, QT just do not recognize the combination of keymodifier and arrow!. by PHC, 090211.
-			if (QApplication::keyboardModifiers()==Qt::ControlModifier) //then scroll page by page
-			{
-				stepx = pixmap.width()/2.0, stepy = pixmap.height()/2.0;
-				qDebug()<<"ctrl pressed: "<<stepx<<" "<<stepy;
-			}
-			if (m_scale>1)
-		   {
+    case Qt::Key_Left: //for unknown reason, QT just do not recognize the combination of keymodifier and arrow!. by PHC, 090211.
+      if (QApplication::keyboardModifiers()==Qt::ControlModifier) //then scroll page by page
+      {
+        stepx = pixmap.width()/2.0, stepy = pixmap.height()/2.0;
+        qDebug()<<"ctrl pressed: "<<stepx<<" "<<stepy;
+      }
+      if (m_scale>1)
+       {
               curDisplayCenter -= QPointF(stepx, 0);
-			  if (curDisplayCenter.x() < (2-m_scale)*pixmap.width()/2.0-1)
-			    curDisplayCenter.setX((2-m_scale)*pixmap.width()/2.0-1);
+        if (curDisplayCenter.x() < (2-m_scale)*pixmap.width()/2.0-1)
+          curDisplayCenter.setX((2-m_scale)*pixmap.width()/2.0-1);
 
-			  update();
-		    }
-	  		break;
+        update();
+        }
+        break;
 
-		case Qt::Key_Right:
-			if (QApplication::keyboardModifiers()==Qt::ControlModifier) //then scroll page by page
-			{
-				stepx = pixmap.width()/2.0, stepy = pixmap.height()/2.0;
-				qDebug()<<"ctrl pressed: "<<stepx<<" "<<stepy;
-			}
-			if (m_scale>1)
-		   {
+    case Qt::Key_Right:
+      if (QApplication::keyboardModifiers()==Qt::ControlModifier) //then scroll page by page
+      {
+        stepx = pixmap.width()/2.0, stepy = pixmap.height()/2.0;
+        qDebug()<<"ctrl pressed: "<<stepx<<" "<<stepy;
+      }
+      if (m_scale>1)
+       {
               curDisplayCenter += QPointF(stepx, 0);
-			  if (curDisplayCenter.x() > m_scale*pixmap.width()/2.0)
-			    curDisplayCenter.setX(m_scale*pixmap.width()/2.0);
+        if (curDisplayCenter.x() > m_scale*pixmap.width()/2.0)
+          curDisplayCenter.setX(m_scale*pixmap.width()/2.0);
 
-			  update();
-		    }
-			break;
+        update();
+        }
+      break;
 
-		case Qt::Key_Up:
-			if (QApplication::keyboardModifiers()==Qt::ControlModifier) //then scroll page by page
-			{
-				stepx = pixmap.width()/2.0, stepy = pixmap.height()/2.0;
-				qDebug()<<"ctrl pressed: "<<stepx<<" "<<stepy;
-			}
-			if (m_scale>1)
-		   {
+    case Qt::Key_Up:
+      if (QApplication::keyboardModifiers()==Qt::ControlModifier) //then scroll page by page
+      {
+        stepx = pixmap.width()/2.0, stepy = pixmap.height()/2.0;
+        qDebug()<<"ctrl pressed: "<<stepx<<" "<<stepy;
+      }
+      if (m_scale>1)
+       {
               curDisplayCenter -= QPointF(0, stepy);
-			  if (curDisplayCenter.y() < (2-m_scale)*pixmap.height()/2.0-1)
-			    curDisplayCenter.setY((2-m_scale)*pixmap.height()/2.0-1);
+        if (curDisplayCenter.y() < (2-m_scale)*pixmap.height()/2.0-1)
+          curDisplayCenter.setY((2-m_scale)*pixmap.height()/2.0-1);
 
-			  update();
-		    }
-			break;
+        update();
+        }
+      break;
 
-		case Qt::Key_Down:
-		//case Qt::Key_8: //a test to show normal key modifier works!
-			if (QApplication::keyboardModifiers()==Qt::ControlModifier) //then scroll page by page
-			{
-				stepx = pixmap.width()/2.0, stepy = pixmap.height()/2.0;
-				qDebug()<<"ctrl pressed: "<<stepx<<" "<<stepy;
-			}
-			if (m_scale>1)
-		   {
-			   //qDebug()<<"real stepx="<<stepx<<" stepy="<<stepy;
+    case Qt::Key_Down:
+    //case Qt::Key_8: //a test to show normal key modifier works!
+      if (QApplication::keyboardModifiers()==Qt::ControlModifier) //then scroll page by page
+      {
+        stepx = pixmap.width()/2.0, stepy = pixmap.height()/2.0;
+        qDebug()<<"ctrl pressed: "<<stepx<<" "<<stepy;
+      }
+      if (m_scale>1)
+       {
+         //qDebug()<<"real stepx="<<stepx<<" stepy="<<stepy;
               curDisplayCenter += QPointF(0, stepy);
-			  if (curDisplayCenter.y() > m_scale*pixmap.height()/2.0)
-			    curDisplayCenter.setY(m_scale*pixmap.height()/2.0);
+        if (curDisplayCenter.y() > m_scale*pixmap.height()/2.0)
+          curDisplayCenter.setY(m_scale*pixmap.height()/2.0);
 
-			  update();
-		    }
-			break;
+        update();
+        }
+      break;
 
-		case Qt::Key_N:
-		case Qt::Key_Period: //080403
-			switch (Ptype)
-			{
-				case imgPlaneX:
-					emit focusXChanged(imgData->curFocusX+1+1); //the first +1 to convert to the range [1, max]. The below is the same.
-					break;
-				case imgPlaneY:
-					emit focusYChanged(imgData->curFocusY+1+1);
-					break;
-				case imgPlaneZ:
-					emit focusZChanged(imgData->curFocusZ+1+1);
-					break;
-				default: //do nothing
-					break;
-			}
-			break;
+    case Qt::Key_N:
+    case Qt::Key_Period: //080403
+      switch (Ptype)
+      {
+        case imgPlaneX:
+          emit focusXChanged(imgData->curFocusX+1+1); //the first +1 to convert to the range [1, max]. The below is the same.
+          break;
+        case imgPlaneY:
+          emit focusYChanged(imgData->curFocusY+1+1);
+          break;
+        case imgPlaneZ:
+          emit focusZChanged(imgData->curFocusZ+1+1);
+          break;
+        default: //do nothing
+          break;
+      }
+      break;
 
-		case Qt::Key_B: //add 'b' on 080109
-		case Qt::Key_Comma: //080403
-			switch (Ptype)
-			{
-				case imgPlaneX:
-					emit focusXChanged(imgData->curFocusX+1-1);
-					break;
-				case imgPlaneY:
-					emit focusYChanged(imgData->curFocusY+1-1);
-					break;
-				case imgPlaneZ:
-					emit focusZChanged(imgData->curFocusZ+1-1);
-					break;
-				default: //do nothing
-					break;
-			}
-			break;
+    case Qt::Key_B: //add 'b' on 080109
+    case Qt::Key_Comma: //080403
+      switch (Ptype)
+      {
+        case imgPlaneX:
+          emit focusXChanged(imgData->curFocusX+1-1);
+          break;
+        case imgPlaneY:
+          emit focusYChanged(imgData->curFocusY+1-1);
+          break;
+        case imgPlaneZ:
+          emit focusZChanged(imgData->curFocusZ+1-1);
+          break;
+        default: //do nothing
+          break;
+      }
+      break;
 
-		case Qt::Key_I:
-			imgData->getXWidget()->triview_zoomin();
-			break;
+    case Qt::Key_I:
+      imgData->getXWidget()->triview_zoomin();
+      break;
 
-		case Qt::Key_O:
+    case Qt::Key_O:
       {
-			bool result = (
+      bool result = (
         imgData->getXWidget()->disp_zoom * imgData->getXDim() <= 1 ||
         imgData->getXWidget()->disp_zoom * imgData->getYDim() <= 1 ||
         imgData->getXWidget()->disp_zoom * imgData->getZDim() <= 1 );
 
-			if ( result )
-			{
-				v3d_msg("Cannot zoom-out more, - one of the first 3 dims of the images has been displayed to <=1 pixel on the monitor.");
-				break;
-			}
-			imgData->getXWidget()->triview_zoomout();
-			break;
+      if ( result )
+      {
+        v3d_msg("Cannot zoom-out more, - one of the first 3 dims of the images has been displayed to <=1 pixel on the monitor.");
+        break;
       }
+      imgData->getXWidget()->triview_zoomout();
+      break;
+      }
 
-		case Qt::Key_1:
-			imgData->getXWidget()->triview_zoom1();
-			break;
+    case Qt::Key_1:
+      imgData->getXWidget()->triview_zoom1();
+      break;
 
-		case Qt::Key_2:
-			imgData->getXWidget()->triview_zoom2();
-			break;
+    case Qt::Key_2:
+      imgData->getXWidget()->triview_zoom2();
+      break;
 
-			//the following is another way to activate the pop-up menu or point-definition dialog at the pixel location. by PHC, 060312
+      //the following is another way to activate the pop-up menu or point-definition dialog at the pixel location. by PHC, 060312
 
 #if COMPILE_TARGET_LEVEL != 0
-		case Qt::Key_M:
-			{
-				//first search if a landmark has been defined at the same location. If yes, modify that one. Otherwise add a new one.
+    case Qt::Key_M:
+      {
+        //first search if a landmark has been defined at the same location. If yes, modify that one. Otherwise add a new one.
 
-				QList <LocationSimple> * tmplist = (QList <LocationSimple> *) &(imgData->listLandmarks);
-				int tmprownum; bool b_landmark_exist=false;
-				int cx = imgData->curFocusX+1, cy = imgData->curFocusY+1, cz = imgData->curFocusZ+1;
-				for (tmprownum=0;tmprownum<tmplist->count();tmprownum++)
-				{
-					if (int(tmplist->at(tmprownum).x)==cx && int(tmplist->at(tmprownum).y)==cy && int(tmplist->at(tmprownum).z)==cz)
-					{
-						b_landmark_exist=true;
-						printf("detected existing landmark no=[%d]\n", tmprownum);
-						break;
-					}
-				}
+        QList <LocationSimple> * tmplist = (QList <LocationSimple> *) &(imgData->listLandmarks);
+        int tmprownum; bool b_landmark_exist=false;
+        int cx = imgData->curFocusX+1, cy = imgData->curFocusY+1, cz = imgData->curFocusZ+1;
+        for (tmprownum=0;tmprownum<tmplist->count();tmprownum++)
+        {
+          if (int(tmplist->at(tmprownum).x)==cx && int(tmplist->at(tmprownum).y)==cy && int(tmplist->at(tmprownum).z)==cz)
+          {
+            b_landmark_exist=true;
+            printf("detected existing landmark no=[%d]\n", tmprownum);
+            break;
+          }
+        }
 
-				LandmarkPropertyDialog *landmarkView = NULL;
-				if (!landmarkView)
-				{
-					if (b_landmark_exist)
-						landmarkView = new LandmarkPropertyDialog(tmplist, tmprownum, imgData);
-					else
-					{
-						LocationSimple tmp_location(cx, cy, cz);
-						//tmp_location.order = imgData->listLandmarks.count()+1;
-						QString tmp_label = "";
-						tmp_location.name = qPrintable(tmp_label.setNum(imgData->listLandmarks.count()+1).prepend("landmark "));
-						tmp_location.radius = imgData->getXWidget()->getMainControlWindow()->global_setting.default_marker_radius; //add a default landmark size
-						QList <LocationSimple> tmplist_1;
-						tmplist_1.append(tmp_location);
-						landmarkView = new LandmarkPropertyDialog(&tmplist_1, 0, imgData);
-					}
-				}
+        LandmarkPropertyDialog *landmarkView = NULL;
+        if (!landmarkView)
+        {
+          if (b_landmark_exist)
+            landmarkView = new LandmarkPropertyDialog(tmplist, tmprownum, imgData);
+          else
+          {
+            LocationSimple tmp_location(cx, cy, cz);
+            //tmp_location.order = imgData->listLandmarks.count()+1;
+            QString tmp_label = "";
+            tmp_location.name = qPrintable(tmp_label.setNum(imgData->listLandmarks.count()+1).prepend("landmark "));
+            tmp_location.radius = imgData->getXWidget()->getMainControlWindow()->global_setting.default_marker_radius; //add a default landmark size
+            QList <LocationSimple> tmplist_1;
+            tmplist_1.append(tmp_location);
+            landmarkView = new LandmarkPropertyDialog(&tmplist_1, 0, imgData);
+          }
+        }
 
-				int res = landmarkView->exec(); //note that as I request the user must either accept or change the cell property, I set it as a Modal dialog by calling exec() instead of show.
-				if (res!=QDialog::Accepted)
-				{
-					if (landmarkView) {delete landmarkView; landmarkView = NULL;}
-					break; //only return true when the results are accepted, which will lead to an update operation below
-				}
+        int res = landmarkView->exec(); //note that as I request the user must either accept or change the cell property, I set it as a Modal dialog by calling exec() instead of show.
+        if (res!=QDialog::Accepted)
+        {
+          if (landmarkView) {delete landmarkView; landmarkView = NULL;}
+          break; //only return true when the results are accepted, which will lead to an update operation below
+        }
 
-				//update the current item
-				if (!b_landmark_exist)
-				{
-					LocationSimple tmp_location(cx, cy, cz);
-					//QString tmp_label = ""; tmp_location.name = qPrintable(tmp_label.setNum(imgData->listLandmarks.count()+1).prepend("landmark ")); //no need to do again, as the content will be overwritten anyway
-					imgData->listLandmarks.append(tmp_location);
-					tmprownum = imgData->listLandmarks.count()-1;
-				}
-				landmarkView->fetchData(&(imgData->listLandmarks), tmprownum);
-				qDebug("data fetched [%s][%s] shape=[%d] radius=[%5.3f]",
-					   imgData->listLandmarks.at(tmprownum).name.c_str(), imgData->listLandmarks.at(tmprownum).comments.c_str(),  int(imgData->listLandmarks.at(tmprownum).shape),  float(imgData->listLandmarks.at(tmprownum).radius));
+        //update the current item
+        if (!b_landmark_exist)
+        {
+          LocationSimple tmp_location(cx, cy, cz);
+          //QString tmp_label = ""; tmp_location.name = qPrintable(tmp_label.setNum(imgData->listLandmarks.count()+1).prepend("landmark ")); //no need to do again, as the content will be overwritten anyway
+          imgData->listLandmarks.append(tmp_location);
+          tmprownum = imgData->listLandmarks.count()-1;
+        }
+        landmarkView->fetchData(&(imgData->listLandmarks), tmprownum);
+        qDebug("data fetched [%s][%s] shape=[%d] radius=[%5.3f]",
+             imgData->listLandmarks.at(tmprownum).name.c_str(), imgData->listLandmarks.at(tmprownum).comments.c_str(),  int(imgData->listLandmarks.at(tmprownum).shape),  float(imgData->listLandmarks.at(tmprownum).radius));
 
-				//important: set the shape of the landmark
-				LocationSimple * p_tmp_location = (LocationSimple *) & (imgData->listLandmarks.at(tmprownum));
-				switch (p_tmp_location->shape)
-				{
-					case pxSphere:	p_tmp_location->inputProperty = pxLocaUseful; //qDebug("pxsphere");
-						break;
-					case pxCube: p_tmp_location->inputProperty = pxLocaNotUseful; //qDebug("pxcube");
-						break;
-					default: p_tmp_location->inputProperty = pxLocaUnsure; //qDebug("%d pxunsure", int(p_tmp_location->shape));
-						break;
-				}
+        //important: set the shape of the landmark
+        LocationSimple * p_tmp_location = (LocationSimple *) & (imgData->listLandmarks.at(tmprownum));
+        switch (p_tmp_location->shape)
+        {
+          case pxSphere:  p_tmp_location->inputProperty = pxLocaUseful; //qDebug("pxsphere");
+            break;
+          case pxCube: p_tmp_location->inputProperty = pxLocaNotUseful; //qDebug("pxcube");
+            break;
+          default: p_tmp_location->inputProperty = pxLocaUnsure; //qDebug("%d pxunsure", int(p_tmp_location->shape));
+            break;
+        }
 
-				if (landmarkView) {delete landmarkView; landmarkView = NULL;}
-			}
-			break;
+        if (landmarkView) {delete landmarkView; landmarkView = NULL;}
+      }
+      break;
 
-		case Qt::Key_H:
-		    dispHistogram();//in the future I can add a parameter to indicate the current view-id, so that I can only display the histogram of the current view (slice) instead of the whole stack
-			break;
+    case Qt::Key_H:
+        dispHistogram();//in the future I can add a parameter to indicate the current view-id, so that I can only display the histogram of the current view (slice) instead of the whole stack
+      break;
 
-		case Qt::Key_C:
-		    if (QApplication::keyboardModifiers()==Qt::ControlModifier)
-		    {
-		      popupImageProcessingDialog(tr(" -- crop image using minMax bounding box in 3D (derived from ROIs)"));
+    case Qt::Key_C:
+        if (QApplication::keyboardModifiers()==Qt::ControlModifier)
+        {
+          popupImageProcessingDialog(tr(" -- crop image using minMax bounding box in 3D (derived from ROIs)"));
             }
-			else if (QApplication::keyboardModifiers()==Qt::ShiftModifier)
-			{
-				if (imgData->getCDim()!=1) break;
-				if(imgData->getDatatype()!=V3D_UINT16 && imgData->getDatatype()!=V3D_UINT8) //only work for UINT16/UINT8 1 channel data
-					break;
-				imgData->getXWidget()->switchMaskColormap();
-			}
-			break;
+      else if (QApplication::keyboardModifiers()==Qt::ShiftModifier)
+      {
+        if (imgData->getCDim()!=1) break;
+        if(imgData->getDatatype()!=V3D_UINT16 && imgData->getDatatype()!=V3D_UINT8) //only work for UINT16/UINT8 1 channel data
+          break;
+        imgData->getXWidget()->switchMaskColormap();
+      }
+      break;
 
-		case Qt::Key_R:
-		    if (QApplication::keyboardModifiers()==Qt::ControlModifier)
-		    {
-				Options_Rotate tmpopt;
-				tmpopt.degree=0.0;
-				tmpopt.b_keepSameSize=true;
-				tmpopt.fillcolor=0;
-				tmpopt.center_x = (imgData->getXDim()-1.0)/2;
-				tmpopt.center_y = (imgData->getYDim()-1.0)/2;
-				tmpopt.center_z = (imgData->getZDim()-1.0)/2;
+    case Qt::Key_R:
+        if (QApplication::keyboardModifiers()==Qt::ControlModifier)
+        {
+        Options_Rotate tmpopt;
+        tmpopt.degree=0.0;
+        tmpopt.b_keepSameSize=true;
+        tmpopt.fillcolor=0;
+        tmpopt.center_x = (imgData->getXDim()-1.0)/2;
+        tmpopt.center_y = (imgData->getYDim()-1.0)/2;
+        tmpopt.center_z = (imgData->getZDim()-1.0)/2;
 
-				Dialog_Rotate tmpdlg;
-				tmpdlg.setContents(tmpopt);
+        Dialog_Rotate tmpdlg;
+        tmpdlg.setContents(tmpopt);
 
-				int dlg_res = tmpdlg.exec();
-				if (dlg_res)
-				{
-					tmpdlg.getContents(tmpopt);
-					imgData->rotate(Ptype, tmpopt);
-				}
-			}
-			break;
+        int dlg_res = tmpdlg.exec();
+        if (dlg_res)
+        {
+          tmpdlg.getContents(tmpopt);
+          imgData->rotate(Ptype, tmpopt);
+        }
+      }
+      break;
 
-		case Qt::Key_D: //remove the last pos from roiVertexList
-		    if (QApplication::keyboardModifiers()==Qt::ControlModifier)
-		    {
-				//roiPolygon.erase(roiPolygon.end()-1);
-				if (roiPolygon.count()>0)
-				{
-				  roiPolygon.pop_back();
-				  update();
-				}
-			}
-			break;
+    case Qt::Key_D: //remove the last pos from roiVertexList
+        if (QApplication::keyboardModifiers()==Qt::ControlModifier)
+        {
+        //roiPolygon.erase(roiPolygon.end()-1);
+        if (roiPolygon.count()>0)
+        {
+          roiPolygon.pop_back();
+          update();
+        }
+      }
+      break;
 #endif
 
 
 #if COMPILE_TARGET_LEVEL == 2
-		case Qt::Key_P:
-		    if (QApplication::keyboardModifiers()==Qt::ControlModifier)
-		    {
-				popupImageProcessingDialog();
-			}
-			break;
+    case Qt::Key_P:
+        if (QApplication::keyboardModifiers()==Qt::ControlModifier)
+        {
+        popupImageProcessingDialog();
+      }
+      break;
 #endif
 
 #if COMPILE_TARGET_LEVEL != 0
-		case Qt::Key_V:
-			if(imgData->getDatatype()!=V3D_UINT8) //only work for UINT8 data
-				break;
+    case Qt::Key_V:
+      if(imgData->getDatatype()!=V3D_UINT8) //only work for UINT8 data
+        break;
 
-		    if (QApplication::keyboardModifiers()==Qt::ControlModifier) //launch the full-image 3d view
-		    {
-				imgData->getXWidget()->doImage3DView(true); //use the maximum display 512x512x256
-			}
-			else if (QApplication::keyboardModifiers()==Qt::ShiftModifier) //launch the local zoom-in view
-			{
-				imgData->getXWidget()->doImage3DLocalRoiView();
-			}
-			else if (QApplication::keyboardModifiers()==(Qt::ShiftModifier | Qt::ControlModifier)) //display the real size of an image. This may crash if not enough memory is available
-			{
-				if(QMessageBox::question (0, "",
-							   "You have just requested displaying 3D view for an image using the full resolution. if your machine does not have enough video memory, you may have a crash in the video memory which is hard to catch. "
-							   "Are you sure you want to continue?",
-							   QMessageBox::Yes, QMessageBox::No)
-					== QMessageBox::Yes)
-				{
-					imgData->getXWidget()->doImage3DView(false);
-				}
-			}
-			break;
+        if (QApplication::keyboardModifiers()==Qt::ControlModifier) //launch the full-image 3d view
+        {
+        imgData->getXWidget()->doImage3DView(true); //use the maximum display 512x512x256
+      }
+      else if (QApplication::keyboardModifiers()==Qt::ShiftModifier) //launch the local zoom-in view
+      {
+        imgData->getXWidget()->doImage3DLocalRoiView();
+      }
+      else if (QApplication::keyboardModifiers()==(Qt::ShiftModifier | Qt::ControlModifier)) //display the real size of an image. This may crash if not enough memory is available
+      {
+        if(QMessageBox::question (0, "",
+                 "You have just requested displaying 3D view for an image using the full resolution. if your machine does not have enough video memory, you may have a crash in the video memory which is hard to catch. "
+                 "Are you sure you want to continue?",
+                 QMessageBox::Yes, QMessageBox::No)
+          == QMessageBox::Yes)
+        {
+          imgData->getXWidget()->doImage3DView(false);
+        }
+      }
+      break;
 #endif
 
 #if COMPILE_TARGET_LEVEL == 2
 
-	#ifdef _ALLOW_ATLAS_IMAGE_MENU_
-		case Qt::Key_A: //activate the atlas viewer
-		case Qt::Key_F: //activate the find/search function
-		    if (QApplication::keyboardModifiers()==Qt::ControlModifier)
-		    {
+  #ifdef _ALLOW_ATLAS_IMAGE_MENU_
+    case Qt::Key_A: //activate the atlas viewer
+    case Qt::Key_F: //activate the find/search function
+        if (QApplication::keyboardModifiers()==Qt::ControlModifier)
+        {
 
-				imgData->getXWidget()->launchAtlasViewer();
-			}
-			break;
-	#endif
+        imgData->getXWidget()->launchAtlasViewer();
+      }
+      break;
+  #endif
 
-	#ifdef _ALLOW_NEURONSEG_MENU_
-		case Qt::Key_T:
-			popupImageProcessingDialog(tr(" -- trace between two locations"));
- 			break;
+  #ifdef _ALLOW_NEURONSEG_MENU_
+    case Qt::Key_T:
+      popupImageProcessingDialog(tr(" -- trace between two locations"));
+       break;
 
-		case Qt::Key_Z: //undo the last tracing step if possible. by PHC, 090120
-		    if (QApplication::keyboardModifiers()==Qt::ControlModifier)
-		    {
-		    	if (imgData)
-					imgData->getXWidget()->popupImageProcessingDialog(tr(" -- undo last tracing step"));
-			}
-			break;
-	#endif
+    case Qt::Key_Z: //undo the last tracing step if possible. by PHC, 090120
+        if (QApplication::keyboardModifiers()==Qt::ControlModifier)
+        {
+          if (imgData)
+          imgData->getXWidget()->popupImageProcessingDialog(tr(" -- undo last tracing step"));
+      }
+      break;
+  #endif
 
-	#ifdef _ALLOW_IMGREG_MENU_
-		case Qt::Key_W:
-			popupImageProcessingDialog(tr(" -- Match one single landmark in another image"));
- 			break;
+  #ifdef _ALLOW_IMGREG_MENU_
+    case Qt::Key_W:
+      popupImageProcessingDialog(tr(" -- Match one single landmark in another image"));
+       break;
 
-		case Qt::Key_E:
-		    if (QApplication::keyboardModifiers()==Qt::ControlModifier)
-		    {
-				bool ok;
-				if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod==(int)MATCH_INTENSITY)
-					item = tr("MATCH_INTENSITY");
-				else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod==(int)MATCH_CORRCOEF)
-					item = tr("MATCH_CORRCOEF");
-				else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod==(int)MATCH_MI)
-					item = tr("MATCH_MI");
-				else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod==(int)MATCH_IMOMENT)
-					item = tr("MATCH_IMOMENT");
-				else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod==(int)MATCH_MEANOFCIRCLES)
-					item = tr("MATCH_MEANOFCIRCLES");
-				else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod==(int)MATCH_MULTIPLE_MI_INT_CORR)
-					item = tr("MATCH_MULTIPLE_MI_INT_CORR");
-				else
-					item = tr("Undefined");
+    case Qt::Key_E:
+        if (QApplication::keyboardModifiers()==Qt::ControlModifier)
+        {
+        bool ok;
+        if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod==(int)MATCH_INTENSITY)
+          item = tr("MATCH_INTENSITY");
+        else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod==(int)MATCH_CORRCOEF)
+          item = tr("MATCH_CORRCOEF");
+        else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod==(int)MATCH_MI)
+          item = tr("MATCH_MI");
+        else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod==(int)MATCH_IMOMENT)
+          item = tr("MATCH_IMOMENT");
+        else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod==(int)MATCH_MEANOFCIRCLES)
+          item = tr("MATCH_MEANOFCIRCLES");
+        else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod==(int)MATCH_MULTIPLE_MI_INT_CORR)
+          item = tr("MATCH_MULTIPLE_MI_INT_CORR");
+        else
+          item = tr("Undefined");
 
-				if(QMessageBox::Yes == QMessageBox::question (0, "", tr("Your current landmark matching method is [ ") + item + tr("]<br> Do you change?"), QMessageBox::Yes, QMessageBox::No))
-				{
-					items << tr("MATCH_MI") << tr("MATCH_MULTIPLE_MI_INT_CORR") << tr("MATCH_INTENSITY") << tr("MATCH_CORRCOEF") << tr("MATCH_IMOMENT") << tr("MATCH_MEANOFCIRCLES");
-					item = QInputDialog::getItem(this, tr(""), tr("Please select a landmark matching method"), items, 0, false, &ok);
-					if (ok && !item.isEmpty())
-					{
-						if (item==tr("MATCH_INTENSITY"))
-							imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod = (int)MATCH_INTENSITY;
-						else if (item==tr("MATCH_CORRCOEF"))
-							imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod = (int)MATCH_CORRCOEF;
-						else if (item==tr("MATCH_MI"))
-							imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod = (int)MATCH_MI;
-						else if (item==tr("MATCH_IMOMENT"))
-							imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod = (int)MATCH_IMOMENT;
-						else if (item==tr("MATCH_MEANOFCIRCLES"))
-							imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod = (int)MATCH_MEANOFCIRCLES;
-						else if (item==tr("MATCH_MULTIPLE_MI_INT_CORR"))
-							imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod = (int)MATCH_MULTIPLE_MI_INT_CORR;
-						else
-							imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod = (int)MATCH_MI;
-					}
-				}
-			}
-			else if (QApplication::keyboardModifiers()==Qt::ShiftModifier)
-			{
-				bool ok;
-				if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method==(int)DF_GEN_TPS)
-					item = tr("TPS");
-				else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method==(int)DF_GEN_HIER_B_SPLINE)
-					item = tr("Hier-B-Spline");
-				else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method==(int)DF_GEN_TPS_B_SPLINE)
-					item = tr("TPS-B-Spline-interpolation");
-				else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method==(int)DF_GEN_TPS_LINEAR_INTERP)
-					item = tr("TPS-linear-interpolation");
-				else
-					item = tr("Undefined");
+        if(QMessageBox::Yes == QMessageBox::question (0, "", tr("Your current landmark matching method is [ ") + item + tr("]<br> Do you change?"), QMessageBox::Yes, QMessageBox::No))
+        {
+          items << tr("MATCH_MI") << tr("MATCH_MULTIPLE_MI_INT_CORR") << tr("MATCH_INTENSITY") << tr("MATCH_CORRCOEF") << tr("MATCH_IMOMENT") << tr("MATCH_MEANOFCIRCLES");
+          item = QInputDialog::getItem(this, tr(""), tr("Please select a landmark matching method"), items, 0, false, &ok);
+          if (ok && !item.isEmpty())
+          {
+            if (item==tr("MATCH_INTENSITY"))
+              imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod = (int)MATCH_INTENSITY;
+            else if (item==tr("MATCH_CORRCOEF"))
+              imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod = (int)MATCH_CORRCOEF;
+            else if (item==tr("MATCH_MI"))
+              imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod = (int)MATCH_MI;
+            else if (item==tr("MATCH_IMOMENT"))
+              imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod = (int)MATCH_IMOMENT;
+            else if (item==tr("MATCH_MEANOFCIRCLES"))
+              imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod = (int)MATCH_MEANOFCIRCLES;
+            else if (item==tr("MATCH_MULTIPLE_MI_INT_CORR"))
+              imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod = (int)MATCH_MULTIPLE_MI_INT_CORR;
+            else
+              imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_landmarkMatchingMethod = (int)MATCH_MI;
+          }
+        }
+      }
+      else if (QApplication::keyboardModifiers()==Qt::ShiftModifier)
+      {
+        bool ok;
+        if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method==(int)DF_GEN_TPS)
+          item = tr("TPS");
+        else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method==(int)DF_GEN_HIER_B_SPLINE)
+          item = tr("Hier-B-Spline");
+        else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method==(int)DF_GEN_TPS_B_SPLINE)
+          item = tr("TPS-B-Spline-interpolation");
+        else if (imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method==(int)DF_GEN_TPS_LINEAR_INTERP)
+          item = tr("TPS-linear-interpolation");
+        else
+          item = tr("Undefined");
 
-				if(QMessageBox::Yes == QMessageBox::question (0, "", tr("Your current displacement field computing method is [ ") + item + tr("]<br> Do you change?"), QMessageBox::Yes, QMessageBox::No))
-				{
-					items << tr("TPS-linear-interpolation") <<  tr("TPS-B-Spline-interpolation") << tr("TPS") << tr("Hier-B-Spline");
-					item = QInputDialog::getItem(this, tr(""), tr("Please select a displacement filed (DF) computing method"), items, 0, false, &ok);
-					if (ok && !item.isEmpty())
-					{
-						if (item==tr("TPS-linear-interpolation"))
-							imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method = (int)DF_GEN_TPS_LINEAR_INTERP;
-						else if (item==tr("TPS-B-Spline-interpolation"))
-							imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method = (int)DF_GEN_TPS_B_SPLINE;
-						else if (item==tr("TPS"))
-							imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method = (int)DF_GEN_TPS;
-						else if (item==tr("Hier-B-Spline"))
-							imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method = (int)DF_GEN_HIER_B_SPLINE;
-						else
-							imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method = (int)DF_GEN_TPS;
-					}
-				}
-			}
-			break;
-	#endif
+        if(QMessageBox::Yes == QMessageBox::question (0, "", tr("Your current displacement field computing method is [ ") + item + tr("]<br> Do you change?"), QMessageBox::Yes, QMessageBox::No))
+        {
+          items << tr("TPS-linear-interpolation") <<  tr("TPS-B-Spline-interpolation") << tr("TPS") << tr("Hier-B-Spline");
+          item = QInputDialog::getItem(this, tr(""), tr("Please select a displacement filed (DF) computing method"), items, 0, false, &ok);
+          if (ok && !item.isEmpty())
+          {
+            if (item==tr("TPS-linear-interpolation"))
+              imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method = (int)DF_GEN_TPS_LINEAR_INTERP;
+            else if (item==tr("TPS-B-Spline-interpolation"))
+              imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method = (int)DF_GEN_TPS_B_SPLINE;
+            else if (item==tr("TPS"))
+              imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method = (int)DF_GEN_TPS;
+            else if (item==tr("Hier-B-Spline"))
+              imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method = (int)DF_GEN_HIER_B_SPLINE;
+            else
+              imgData->getXWidget()->getMainControlWindow()->global_setting.GPara_df_compute_method = (int)DF_GEN_TPS;
+          }
+        }
+      }
+      break;
+  #endif
 
 #endif
 
-		default:
-			break;
-	}
+    default:
+      break;
+  }
 
-	return;
+  return;
 }
 
 
 void XFormView::drawPixmapType(QPainter *painter)
 {
     int pwid = disp_width; //changed to disp_height/disp_width on 090212
-	int phei = disp_height;
+  int phei = disp_height;
     QPointF center(pwid/2.0, phei/2.0);
 
-	if (m_scale>1)
-		painter->translate(curDisplayCenter - center);
-	else
-		curDisplayCenter = center;
+  if (m_scale>1)
+    painter->translate(curDisplayCenter - center);
+  else
+    curDisplayCenter = center;
 
-	//for the un-zommed coordinate
+  //for the un-zommed coordinate
     painter->translate(center);
     //    painter->rotate(m_rotation);
     painter->scale(m_scale, m_scale);
     //    painter->shear(m_shear, m_shear);
     painter->translate(-center);
 
-	//now zoom. 081114
+  //now zoom. 081114
     painter->scale(disp_scale, disp_scale);
 
-	//
+  //
     painter->drawPixmap(QPointF(0, 0), pixmap);
 
     painter->setPen(QPen(QColor(255, 255, 255, alpha), 1, Qt::DotLine, Qt::FlatCap, Qt::BevelJoin));
     painter->setBrush(Qt::NoBrush);
     //painter->drawRect(QRectF(0, 0, pixmap.width(), pixmap.height()).adjusted(-2, -2, 2, 2));
 
-	if(imgData!=NULL && imgData->isEmpty()==false)
-		b_displayFocusCrossLine = imgData->getFlagDisplayFocusCross();
+  if(imgData!=NULL && imgData->isEmpty()==false)
+    b_displayFocusCrossLine = imgData->getFlagDisplayFocusCross();
 
-	if (b_displayFocusCrossLine)
-	{
-		int focusPosInWidth, focusPosInHeight;
-		if (!getFocusCrossLinePos(focusPosInWidth, focusPosInHeight, imgData, Ptype)) //should be safe to call even imgData is NULL or contains no data
-		{
-			focusPosInWidth = pwid/2.0;
-			focusPosInHeight = phei/2.0;
-		}
+  if (b_displayFocusCrossLine)
+  {
+    int focusPosInWidth, focusPosInHeight;
+    if (!getFocusCrossLinePos(focusPosInWidth, focusPosInHeight, imgData, Ptype)) //should be safe to call even imgData is NULL or contains no data
+    {
+      focusPosInWidth = pwid/2.0;
+      focusPosInHeight = phei/2.0;
+    }
 
-		painter->drawLine(0, focusPosInHeight, pixmap.width()-1, focusPosInHeight);
-		painter->drawLine(focusPosInWidth, 0, focusPosInWidth, pixmap.height()-1);
-	}
+    painter->drawLine(0, focusPosInHeight, pixmap.width()-1, focusPosInHeight);
+    painter->drawLine(focusPosInWidth, 0, focusPosInWidth, pixmap.height()-1);
+  }
 
-	if (imgData && !(imgData->isEmpty()))
-	{
-		if (imgData->getFlagLookingGlass())
-		{
-			setCursor(Qt::CrossCursor);
+  if (imgData && !(imgData->isEmpty()))
+  {
+    if (imgData->getFlagLookingGlass())
+    {
+      setCursor(Qt::CrossCursor);
 
 
-			// draw the Looking glass if necessary and possible. Note that when Looking glass is enabled, the m_scale is assumed to be 1
-			drawLookingGlassMap(painter, 0); //draw the anchored zoom-in map
-			if (bMouseCurorIn)
-				drawLookingGlassMap(painter, &curMousePos); //draw the moving-point zoom-in map
-		}
-		else
-		{
-			setCursor(Qt::ArrowCursor);
-		}
-	}
+      // draw the Looking glass if necessary and possible. Note that when Looking glass is enabled, the m_scale is assumed to be 1
+      drawLookingGlassMap(painter, 0); //draw the anchored zoom-in map
+      if (bMouseCurorIn)
+        drawLookingGlassMap(painter, &curMousePos); //draw the moving-point zoom-in map
+    }
+    else
+    {
+      setCursor(Qt::ArrowCursor);
+    }
+  }
 
-	// draw the defined interesting & non-interesting points
-	bool b_displaySelectedLocation=true;
-	if (imgData && b_displaySelectedLocation==true)
-	{
-		drawSelectedLocations(painter, &(imgData->listLandmarks), &(imgData->listLocationRelationship));
-	}
+  // draw the defined interesting & non-interesting points
+  bool b_displaySelectedLocation=true;
+  if (imgData && b_displaySelectedLocation==true)
+  {
+    drawSelectedLocations(painter, &(imgData->listLandmarks), &(imgData->listLocationRelationship));
+  }
 
-	// draw ROI
-	drawROI(painter);
+  // draw ROI
+  drawROI(painter);
 }
 
 
 void XFormView::drawSelectedLocations(QPainter *painter, QList <LocationSimple> *curList, QList <PtIndexAndParents> * curRelation)
 {
-	if (!curList) return;
-	V3DLONG NLandmarks = curList->count();
-	if (NLandmarks<=0)
-	{
-		//qDebug("No landmark.");
-		return;
-	}
+  if (!curList) return;
+  V3DLONG NLandmarks = curList->count();
+  if (NLandmarks<=0)
+  {
+    //qDebug("No landmark.");
+    return;
+  }
 
-	int b_color = 1;
-	bool b_disp_polylines = true;
-	//bool b_disp_textlabel = true;
+  int b_color = 1;
+  bool b_disp_polylines = true;
+  //bool b_disp_textlabel = true;
 
-	QColor curColor;
-	PxLocationMarkerShape curShape;
-	QString curStrLabel;
+  QColor curColor;
+  PxLocationMarkerShape curShape;
+  QString curStrLabel;
 
-	if (Ctype==colorGray || Ctype==colorRed2Gray || Ctype==colorGreen2Gray || Ctype==colorBlue2Gray)
-	{
-		b_color=1;
-	}
-	else
-	{
-		b_color = 0;
-	}
+  if (Ctype==colorGray || Ctype==colorRed2Gray || Ctype==colorGreen2Gray || Ctype==colorBlue2Gray)
+  {
+    b_color=1;
+  }
+  else
+  {
+    b_color = 0;
+  }
 
     int cx = imgData->curFocusX,cy = imgData->curFocusY, cz = imgData->curFocusZ;
-	int rr = 5; //, rr_real;
+  int rr = 5; //, rr_real;
 
-	//int tmpx,tmpy,tmpz;
-	float tmpx,tmpy,tmpz;
-	float twidpos,theipos; //int
-	int b_draw = 0;
+  //int tmpx,tmpy,tmpz;
+  float tmpx,tmpy,tmpz;
+  float twidpos,theipos; //int
+  int b_draw = 0;
 
-	LocationSimple tmpLocation(0,0,0);
+  LocationSimple tmpLocation(0,0,0);
     QPolygonF polygon;
 
-	for (V3DLONG i=0;i<NLandmarks;i++)
-	{
-		tmpLocation = curList->at(i);
-		tmpLocation.getCoord(tmpx,tmpy,tmpz);
-		rr = ceil(tmpLocation.radius); //090109
+  for (V3DLONG i=0;i<NLandmarks;i++)
+  {
+    tmpLocation = curList->at(i);
+    tmpLocation.getCoord(tmpx,tmpy,tmpz);
+    rr = ceil(tmpLocation.radius); //090109
 
-		b_draw = 0;
-		if (tmpLocation.on==false) continue; //do not draw those have been disabled in the landmark manager. 081210
-		switch(Ptype)
-		{
-			case imgPlaneZ:
-				if (tmpz<=cz+rr && tmpz>=cz-rr) {twidpos = tmpx; theipos = tmpy; b_draw=1;}
-				break;
+    b_draw = 0;
+    if (tmpLocation.on==false) continue; //do not draw those have been disabled in the landmark manager. 081210
+    switch(Ptype)
+    {
+      case imgPlaneZ:
+        if (tmpz<=cz+rr && tmpz>=cz-rr) {twidpos = tmpx; theipos = tmpy; b_draw=1;}
+        break;
 
-			case imgPlaneX:
-				if (tmpx<=cx+rr && tmpx>=cx-rr) {twidpos = tmpz; theipos = tmpy; b_draw=1;}
-				break;
+      case imgPlaneX:
+        if (tmpx<=cx+rr && tmpx>=cx-rr) {twidpos = tmpz; theipos = tmpy; b_draw=1;}
+        break;
 
-			case imgPlaneY:
-				if (tmpy<=cy+rr && tmpy>=cy-rr) {twidpos = tmpx; theipos = tmpz; b_draw=1;}
-				break;
+      case imgPlaneY:
+        if (tmpy<=cy+rr && tmpy>=cy-rr) {twidpos = tmpx; theipos = tmpz; b_draw=1;}
+        break;
 
-			default:
-				b_draw=0;
-				break;
-		}
+      default:
+        b_draw=0;
+        break;
+    }
 
-		if (b_draw==0)
-		{
-			//qDebug("[%d] out of range not show", i);
-			continue;
-		}
+    if (b_draw==0)
+    {
+      //qDebug("[%d] out of range not show", i);
+      continue;
+    }
 
-		switch(tmpLocation.howUseful())
-		{
-			case pxLocaUseful:
-				curColor = (b_color==1) ? QColor(255, 0, 0, alpha) : QColor(255, 255, 255, alpha);
-				curShape = pxSphere; //pxCircle;
-				b_draw=1;
-				break;
+    switch(tmpLocation.howUseful())
+    {
+      case pxLocaUseful:
+        curColor = (b_color==1) ? QColor(255, 0, 0, alpha) : QColor(255, 255, 255, alpha);
+        curShape = pxSphere; //pxCircle;
+        b_draw=1;
+        break;
 
-			case pxLocaNotUseful:
-				curColor = (b_color==1) ? QColor(0, 255, 0, alpha) : QColor(255, 255, 255, alpha);
-				curShape = pxCube; //pxRect;
-				b_draw=1;
-				break;
+      case pxLocaNotUseful:
+        curColor = (b_color==1) ? QColor(0, 255, 0, alpha) : QColor(255, 255, 255, alpha);
+        curShape = pxCube; //pxRect;
+        b_draw=1;
+        break;
 
-			case pxLocaUnsure:
-				curColor = (b_color==1) ? QColor(0, 0, 255, alpha) : QColor(255, 255, 255, alpha);
-				curShape = pxTriangle;
-				b_draw=1;
-				break;
+      case pxLocaUnsure:
+        curColor = (b_color==1) ? QColor(0, 0, 255, alpha) : QColor(255, 255, 255, alpha);
+        curShape = pxTriangle;
+        b_draw=1;
+        break;
 
-			case pxTemp: //080405
-				curColor = (b_color==1) ? QColor(155, 155, 0, alpha) : QColor(255, 255, 255, alpha);
-				curShape = pxDot;
-				b_draw=1;
-				break;
+      case pxTemp: //080405
+        curColor = (b_color==1) ? QColor(155, 155, 0, alpha) : QColor(255, 255, 255, alpha);
+        curShape = pxDot;
+        b_draw=1;
+        break;
 
-			default:
-				b_draw=0;
-				break;
-		}
+      default:
+        b_draw=0;
+        break;
+    }
 
-		if (b_draw==0)
-		{
-			//qDebug("[%d] unknown pxtype not show", i);
-			continue;
-		}
+    if (b_draw==0)
+    {
+      //qDebug("[%d] unknown pxtype not show", i);
+      continue;
+    }
 
         painter->setPen(QPen(curColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
 
-		//qDebug("rr_real=%d ",rr_real);
-		switch(curShape)
-		{
-			case pxSphere:
-				//painter->drawEllipse(twidpos-rr,theipos-rr, rr+rr+1, rr+rr+1);
-				painter->drawEllipse(twidpos-rr-1,theipos-rr-1, rr+rr+1, rr+rr+1); //081210. correct a skewed draw bug
-				//painter->drawEllipse(twidpos-rr_real-1,theipos-rr_real-1, rr_real+rr_real+1, rr_real+rr_real+1); //090109. now use the real radius
-				break;
+    //qDebug("rr_real=%d ",rr_real);
+    switch(curShape)
+    {
+      case pxSphere:
+        //painter->drawEllipse(twidpos-rr,theipos-rr, rr+rr+1, rr+rr+1);
+        painter->drawEllipse(twidpos-rr-1,theipos-rr-1, rr+rr+1, rr+rr+1); //081210. correct a skewed draw bug
+        //painter->drawEllipse(twidpos-rr_real-1,theipos-rr_real-1, rr_real+rr_real+1, rr_real+rr_real+1); //090109. now use the real radius
+        break;
 
-			case pxCube:
-				//painter->drawRect(twidpos-rr,theipos-rr, rr+rr+1, rr+rr+1);
-				painter->drawRect(twidpos-rr-1,theipos-rr-1, rr+rr+1, rr+rr+1); //081210.
-				break;
+      case pxCube:
+        //painter->drawRect(twidpos-rr,theipos-rr, rr+rr+1, rr+rr+1);
+        painter->drawRect(twidpos-rr-1,theipos-rr-1, rr+rr+1, rr+rr+1); //081210.
+        break;
 
-			case pxTriangle:
-				polygon.clear();
-				//polygon << QPointF(twidpos, theipos-rr) << QPointF(twidpos-rr, theipos+rr) << QPointF(twidpos+rr, theipos+rr);
-				polygon << QPointF(twidpos, theipos-rr-1) << QPointF(twidpos-rr-1, theipos+rr) << QPointF(twidpos+rr, theipos+rr); //081210
-				painter->drawPolygon(polygon);
-				break;
+      case pxTriangle:
+        polygon.clear();
+        //polygon << QPointF(twidpos, theipos-rr) << QPointF(twidpos-rr, theipos+rr) << QPointF(twidpos+rr, theipos+rr);
+        polygon << QPointF(twidpos, theipos-rr-1) << QPointF(twidpos-rr-1, theipos+rr) << QPointF(twidpos+rr, theipos+rr); //081210
+        painter->drawPolygon(polygon);
+        break;
 
-			case pxDot:	//080405
-				//painter->drawPoint(twidpos, theipos); //strange- why not work
-				//painter->drawLine(twidpos, theipos, twidpos, theipos); //strange- why not work
-				painter->drawEllipse(twidpos,theipos, 1, 1);
-				break;
+      case pxDot:  //080405
+        //painter->drawPoint(twidpos, theipos); //strange- why not work
+        //painter->drawLine(twidpos, theipos, twidpos, theipos); //strange- why not work
+        painter->drawEllipse(twidpos,theipos, 1, 1);
+        break;
 
-			default:
-				break;
-		}
+      default:
+        break;
+    }
 
-		if (curShape!=pxDot && imgData->getXWidget()->bDispMarkerLabel ) //update 080405: do not display text for the pxDot shaped locations
-		{
-			painter->drawText(twidpos+rr/2, theipos-rr/2, curStrLabel.setNum(i+1));
-		}
-	}
+    if (curShape!=pxDot && imgData->getXWidget()->bDispMarkerLabel ) //update 080405: do not display text for the pxDot shaped locations
+    {
+      painter->drawText(twidpos+rr/2, theipos-rr/2, curStrLabel.setNum(i+1));
+    }
+  }
 
-	// draw the polylines and also labels
+  // draw the polylines and also labels
 
-	if (b_disp_polylines && Ptype==imgPlaneZ && curRelation && curRelation->count()>0)
-	{
+  if (b_disp_polylines && Ptype==imgPlaneZ && curRelation && curRelation->count()>0)
+  {
         painter->setPen(QPen(QColor(255, 255, 0, alpha), 1, Qt::DotLine, Qt::FlatCap, Qt::RoundJoin));
 
-		float tmpx1,tmpy1,tmpz1;
-		float tmpx2,tmpy2,tmpz2;
-		V3DLONG curNode, curNodeParent;
-		for (V3DLONG jr=0; jr<curRelation->count(); jr++)
-		{
-			curNode = curRelation->at(jr).nodeInd;
-			curNodeParent = curRelation->at(jr).nodeParent;
+    float tmpx1,tmpy1,tmpz1;
+    float tmpx2,tmpy2,tmpz2;
+    V3DLONG curNode, curNodeParent;
+    for (V3DLONG jr=0; jr<curRelation->count(); jr++)
+    {
+      curNode = curRelation->at(jr).nodeInd;
+      curNodeParent = curRelation->at(jr).nodeParent;
 
-			if (curNode>=NLandmarks || curNode<0 || curNodeParent>=NLandmarks || curNodeParent<0)
-			{
-				continue; //do not print this line
-			}
+      if (curNode>=NLandmarks || curNode<0 || curNodeParent>=NLandmarks || curNodeParent<0)
+      {
+        continue; //do not print this line
+      }
 
-			tmpLocation = curList->at(curNode);
-			tmpLocation.getCoord(tmpx1,tmpy1,tmpz1);
+      tmpLocation = curList->at(curNode);
+      tmpLocation.getCoord(tmpx1,tmpy1,tmpz1);
 
-			tmpLocation = curList->at(curNodeParent);
-			tmpLocation.getCoord(tmpx2,tmpy2,tmpz2);
+      tmpLocation = curList->at(curNodeParent);
+      tmpLocation.getCoord(tmpx2,tmpy2,tmpz2);
 
-			painter->drawLine(QPointF(tmpx1, tmpy1), QPointF(tmpx2, tmpy2));
-		}
-	}
+      painter->drawLine(QPointF(tmpx1, tmpy1), QPointF(tmpx2, tmpy2));
+    }
+  }
 
-	//	printf("done \n");
+  //  printf("done \n");
 }
 
 
 void XFormView::drawROI(QPainter *painter)
 {
-	int b_color = 1;
-	QColor curColor;
+  int b_color = 1;
+  QColor curColor;
 
-	if (Ctype==colorGray || Ctype==colorRed2Gray || Ctype==colorGreen2Gray || Ctype==colorBlue2Gray)
-	{
-	  b_color=1;
-	}
-	else
-	{
-	  b_color = 0;
-	}
+  if (Ctype==colorGray || Ctype==colorRed2Gray || Ctype==colorGreen2Gray || Ctype==colorBlue2Gray)
+  {
+    b_color=1;
+  }
+  else
+  {
+    b_color = 0;
+  }
 
     curColor = (b_color==1) ? QColor(255, 0, 0, alpha) : QColor(255, 255, 255, alpha);
     painter->setPen(QPen(curColor, 1, Qt::DashDotLine, Qt::FlatCap, Qt::BevelJoin));
-	painter->drawPolygon(roiPolygon);
+  painter->drawPolygon(roiPolygon);
 }
 
 void XFormView::drawLookingGlassMap(QPainter *painter, QPoint *curPt)
 {
-	// draw the Looking glass. Note that when Looking glass is enabled, the m_scale is assumed to be 1
-	int glassRadius = imgData->getXWidget()->getMainControlWindow()->global_setting.default_lookglass_size; //5
+  // draw the Looking glass. Note that when Looking glass is enabled, the m_scale is assumed to be 1
+  int glassRadius = imgData->getXWidget()->getMainControlWindow()->global_setting.default_lookglass_size; //5
     int glassZoom = 4; //4, 5,6,8
 
-	if (m_scale!=1)
-		return;
+  if (m_scale!=1)
+    return;
 
-	int focusPosInWidth, focusPosInHeight;
-	if (!curPt)
-	{
-		if (!getFocusCrossLinePos(focusPosInWidth, focusPosInHeight, imgData, Ptype))
-			return;
-	}
-	else
-	{
-		focusPosInWidth = curPt->x();
-		focusPosInHeight = curPt->y();
-	}
+  int focusPosInWidth, focusPosInHeight;
+  if (!curPt)
+  {
+    if (!getFocusCrossLinePos(focusPosInWidth, focusPosInHeight, imgData, Ptype))
+      return;
+  }
+  else
+  {
+    focusPosInWidth = curPt->x();
+    focusPosInHeight = curPt->y();
+  }
 
-	QPixmap myrgn = pixmap.copy(QRect(QPoint(qMin(qMax(focusPosInWidth-glassRadius,0), pixmap.width()-1),
-	                                         qMin(qMax(0,focusPosInHeight-glassRadius), pixmap.height()-1)),
-									  QPoint(qMax(qMin(focusPosInWidth+glassRadius,pixmap.width()-1), 0),
-									         qMax(qMin(focusPosInHeight+glassRadius, pixmap.height()-1), 0))
-											 )
-											 );
+  QPixmap myrgn = pixmap.copy(QRect(QPoint(qMin(qMax(focusPosInWidth-glassRadius,0), pixmap.width()-1),
+                                           qMin(qMax(0,focusPosInHeight-glassRadius), pixmap.height()-1)),
+                    QPoint(qMax(qMin(focusPosInWidth+glassRadius,pixmap.width()-1), 0),
+                           qMax(qMin(focusPosInHeight+glassRadius, pixmap.height()-1), 0))
+                       )
+                       );
 
-	QPointF tmpcenter(focusPosInWidth, focusPosInHeight);
-	painter->translate(tmpcenter);
-	painter->scale(glassZoom, glassZoom); //looking glass zoom-in 4 times
-	painter->translate(-tmpcenter);
-	painter->drawPixmap(QPointF(qMax(focusPosInWidth-glassRadius-0.5, 0.0),
-	                            qMax(focusPosInHeight-glassRadius-0.5, 0.0)),
-								myrgn);
+  QPointF tmpcenter(focusPosInWidth, focusPosInHeight);
+  painter->translate(tmpcenter);
+  painter->scale(glassZoom, glassZoom); //looking glass zoom-in 4 times
+  painter->translate(-tmpcenter);
+  painter->drawPixmap(QPointF(qMax(focusPosInWidth-glassRadius-0.5, 0.0),
+                              qMax(focusPosInHeight-glassRadius-0.5, 0.0)),
+                myrgn);
 
-	painter->translate(tmpcenter);
-	painter->scale(1.0/glassZoom, 1.0/glassZoom); //looking glass zoom-in 4 times
-	painter->translate(-tmpcenter);
+  painter->translate(tmpcenter);
+  painter->scale(1.0/glassZoom, 1.0/glassZoom); //looking glass zoom-in 4 times
+  painter->translate(-tmpcenter);
 
     if (!curPt)
       painter->setPen(QPen(QColor(255, 0, 255, alpha), 1, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin));
-	else
+  else
       painter->setPen(QPen(QColor(255, 255, 0, alpha), 1, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin));
 
     painter->setBrush(Qt::NoBrush);
@@ -2907,137 +2907,137 @@
     imgData = 0;
     openFileNameLabel = QString(""); //"/Users/hanchuanpeng/work/v3d/test1.raw"
 
-	mypara_3Dview.b_use_512x512x256 = true;
-	mypara_3Dview.b_still_open = false;
-	mypara_3Dview.image4d = 0;
+  mypara_3Dview.b_use_512x512x256 = true;
+  mypara_3Dview.b_still_open = false;
+  mypara_3Dview.image4d = 0;
 
   Ctype = colorUnknown;
 
-	atlasViewerDlg = 0; //081123
+  atlasViewerDlg = 0; //081123
 
   /* GUI related pointers*/
     bExistGUI = false;
-	bLinkFocusViews = false;
-	bDisplayFocusCross = false;
-	bDispMarkerLabel = true;
+  bLinkFocusViews = false;
+  bDisplayFocusCross = false;
+  bDispMarkerLabel = true;
 
     xy_view = NULL;
     yz_view = NULL;
     zx_view = NULL;
 
-	disp_zoom=1; //081114
-	b_use_dispzoom=false;
+  disp_zoom=1; //081114
+  b_use_dispzoom=false;
 
-	focusPointFeatureWidget = NULL;
+  focusPointFeatureWidget = NULL;
 
     dataGroup = NULL;
-  	viewGroup = NULL;
-	infoGroup = NULL;
-	mainGroup = NULL;
-	coordGroup = NULL;
-	scaleGroup = NULL;
-	typeGroup = NULL;
+    viewGroup = NULL;
+  infoGroup = NULL;
+  mainGroup = NULL;
+  coordGroup = NULL;
+  scaleGroup = NULL;
+  typeGroup = NULL;
 
-	xSlider = NULL;
-	ySlider = NULL;
-	zSlider = NULL;
-	xValueSpinBox = NULL;
-	yValueSpinBox = NULL;
-	zValueSpinBox = NULL;
-	xSliderLabel = NULL;
-	ySliderLabel = NULL;
-	zSliderLabel = NULL;
+  xSlider = NULL;
+  ySlider = NULL;
+  zSlider = NULL;
+  xValueSpinBox = NULL;
+  yValueSpinBox = NULL;
+  zValueSpinBox = NULL;
+  xSliderLabel = NULL;
+  ySliderLabel = NULL;
+  zSliderLabel = NULL;
 
-	linkFocusCheckBox = NULL;
-	displayFocusCrossCheckBox = NULL;
+  linkFocusCheckBox = NULL;
+  displayFocusCrossCheckBox = NULL;
 
     xScaleSlider = NULL;
-	yScaleSlider = NULL;
-	zScaleSlider = NULL;
-	xScaleSliderLabel = NULL;
-	yScaleSliderLabel = NULL;
-	zScaleSliderLabel = NULL;
-	zoomWholeViewButton = NULL; 
+  yScaleSlider = NULL;
+  zScaleSlider = NULL;
+  xScaleSliderLabel = NULL;
+  yScaleSliderLabel = NULL;
+  zScaleSliderLabel = NULL;
+  zoomWholeViewButton = NULL;
 
     lookingGlassCheckBox = NULL;
 
     colorRedType = NULL;
-	colorGreenType = NULL;
-	colorBlueType = NULL;
-	colorAllType = NULL;
+  colorGreenType = NULL;
+  colorBlueType = NULL;
+  colorAllType = NULL;
     colorRed2GrayType = NULL;
-	colorGreen2GrayType = NULL;
-	colorBlue2GrayType = NULL;
-	colorAll2GrayType = NULL;
+  colorGreen2GrayType = NULL;
+  colorBlue2GrayType = NULL;
+  colorAll2GrayType = NULL;
 
     imgValScaleDisplayCheckBox = NULL;
 
-	cBox_bSendSignalToExternal = NULL;
-	cBox_bAcceptSignalFromExternal = NULL;
+  cBox_bSendSignalToExternal = NULL;
+  cBox_bAcceptSignalFromExternal = NULL;
 
     landmarkCopyButton = NULL;
-	landmarkPasteButton = NULL;
-	landmarkSaveButton = NULL;
-	landmarkLoadButton = NULL;
-	landmarkManagerButton = NULL;
+  landmarkPasteButton = NULL;
+  landmarkSaveButton = NULL;
+  landmarkLoadButton = NULL;
+  landmarkManagerButton = NULL;
 
-	//landmarkLabelDispCheckBox = NULL;
+  //landmarkLabelDispCheckBox = NULL;
 
     resetButton = NULL;
-	openFileNameButton = NULL;
-	imgProcessButton = NULL;
-	imgV3DButton = NULL;
-	//imgV3DROIButton = NULL;
-	whatsThisButton = NULL;
+  openFileNameButton = NULL;
+  imgProcessButton = NULL;
+  imgV3DButton = NULL;
+  //imgV3DROIButton = NULL;
+  whatsThisButton = NULL;
 
-	allLayout = NULL;
-	dataGroupLayout = NULL;
-	xyzViewLayout = NULL;
-	infoGroupLayout = NULL;
-	coordGroupLayout = NULL;
-	scaleGroupLayout = NULL;
-	typeGroupLayout = NULL;
-	LandmarkGroupLayout = NULL; //080107
-	mainGroupLayout = NULL;
+  allLayout = NULL;
+  dataGroupLayout = NULL;
+  xyzViewLayout = NULL;
+  infoGroupLayout = NULL;
+  coordGroupLayout = NULL;
+  scaleGroupLayout = NULL;
+  typeGroupLayout = NULL;
+  LandmarkGroupLayout = NULL; //080107
+  mainGroupLayout = NULL;
 
-	// communication to other windows
+  // communication to other windows
 
-	p_mainWindow = NULL;
-	bSendSignalToExternal = false;
-	bAcceptSignalFromExternal = false;
+  p_mainWindow = NULL;
+  bSendSignalToExternal = false;
+  bAcceptSignalFromExternal = false;
 }
 
 XFormWidget::~XFormWidget()
 {
-	qDebug("***v3d: ~XFormWidget");
-	cleanData();
+  qDebug("***v3d: ~XFormWidget");
+  cleanData();
 }
 
 void XFormWidget::closeEvent(QCloseEvent *event) //080814: this function is specially added to assure the image data will be cleaned; so that have more memory for other stacks.
-												//note the reason to overload this closeEvent function but not use the QWidget destructor is because seems Qt has a build-in bug in freeing ArthurFrame object in QString freeing
+                        //note the reason to overload this closeEvent function but not use the QWidget destructor is because seems Qt has a build-in bug in freeing ArthurFrame object in QString freeing
 {
-	qDebug("***v3d: XFormWidget::closeEvent");
+  qDebug("***v3d: XFormWidget::closeEvent");
 
-	printf("Now going to free memory for this image or data of this window. .... ");
-	cleanData();
-	printf("Succeeded in freeing memory.\n");
+  printf("Now going to free memory for this image or data of this window. .... ");
+  cleanData();
+  printf("Succeeded in freeing memory.\n");
 
-	//if(!testAttribute(Qt::WA_DeleteOnClose)) deleteLater(); //090812 RZC
+  //if(!testAttribute(Qt::WA_DeleteOnClose)) deleteLater(); //090812 RZC
 }
 
 //void XFormWidget::focusInEvent ( QFocusEvent * event )
 //{
-//	if (p_mainWindow)
-//	{
-//		p_mainWindow->updateMenus();
-//		printf("Updated mainwindow menu.\n");
-//	}
+//  if (p_mainWindow)
+//  {
+//    p_mainWindow->updateMenus();
+//    printf("Updated mainwindow menu.\n");
+//  }
 //}
 
 
 void XFormWidget::updateViews()
 {
-	if (imgData) imgData->updateViews();
+  if (imgData) imgData->updateViews();
 }
 
 void XFormWidget::cleanData()
@@ -3048,11 +3048,11 @@
 
 void XFormWidget::createGUI()
 {
-	if (bExistGUI)
-	  return;
+  if (bExistGUI)
+    return;
 
-	bLinkFocusViews = true;
-	bDisplayFocusCross = true;
+  bLinkFocusViews = true;
+  bDisplayFocusCross = true;
 
     /* Set up the data related GUI */
     dataGroup = new QGroupBox(this);
@@ -3063,7 +3063,7 @@
     //viewGroup->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
 
     xy_view = new XFormView(viewGroup);
-	xy_view->setImgData(imgPlaneZ, 0, colorRGB); //because the second parameter is 0 (NULL pointer), then just load the default maps for this view
+  xy_view->setImgData(imgPlaneZ, 0, colorRGB); //because the second parameter is 0 (NULL pointer), then just load the default maps for this view
 //    xy_view->setFixedWidth(xy_view->width());
 //    xy_view->setFixedHeight(xy_view->height());
     xy_view->setFixedWidth(xy_view->get_disp_width());
@@ -3071,7 +3071,7 @@
     xy_view->setFocusPolicy(Qt::ClickFocus);
 
     yz_view = new XFormView(viewGroup);
-	yz_view->setImgData(imgPlaneX, 0, colorRGB); //because the second parameter is 0 (NULL pointer), then just load the default maps for this view
+  yz_view->setImgData(imgPlaneX, 0, colorRGB); //because the second parameter is 0 (NULL pointer), then just load the default maps for this view
 //    yz_view->setFixedWidth(yz_view->width());
 //    yz_view->setFixedHeight(yz_view->height());
     yz_view->setFixedWidth(yz_view->get_disp_width());
@@ -3079,7 +3079,7 @@
     yz_view->setFocusPolicy(Qt::ClickFocus);
 
     zx_view = new XFormView(viewGroup);
-	zx_view->setImgData(imgPlaneY, 0, colorRGB); //because the second parameter is 0 (NULL pointer), then just load the default maps for this view
+  zx_view->setImgData(imgPlaneY, 0, colorRGB); //because the second parameter is 0 (NULL pointer), then just load the default maps for this view
 //    zx_view->setFixedWidth(zx_view->width());
 //    zx_view->setFixedHeight(zx_view->height());
     zx_view->setFixedWidth(zx_view->get_disp_width());
@@ -3094,10 +3094,10 @@
     infoGroup->setTitle("Information of your selections");
 
     focusPointFeatureWidget = new QTextBrowser(infoGroup);
-//	focusPointFeatureWidget->setFixedWidth(qMax(200, xy_view->width()+yz_view->width()));
-	focusPointFeatureWidget->setFixedWidth(qMax(200, xy_view->get_disp_width()+yz_view->get_disp_width()));
-	//focusPointFeatureWidget->setFixedHeight(50);
-	//focusPointFeatureWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
+//  focusPointFeatureWidget->setFixedWidth(qMax(200, xy_view->width()+yz_view->width()));
+  focusPointFeatureWidget->setFixedWidth(qMax(200, xy_view->get_disp_width()+yz_view->get_disp_width()));
+  //focusPointFeatureWidget->setFixedHeight(50);
+  //focusPointFeatureWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
 
     //viewGroup->setFixedWidth(xy_view->width()+yz_view->width()+10);
 //    viewGroup->setMinimumSize(xy_view->width()+yz_view->width(), xy_view->height()+zx_view->height()+50);
@@ -3121,9 +3121,9 @@
     //xSlider->setRange(1, imgData->getXDim()); //need redefine range
     xSlider->setRange(1, 1); //need redefine range
     xSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
-	xSliderLabel = new QLabel("X", coordGroup);
+  xSliderLabel = new QLabel("X", coordGroup);
 
-	xValueSpinBox = new QSpinBox;
+  xValueSpinBox = new QSpinBox;
     //xValueSpinBox->setRange(1, imgData->getXDim());
     xValueSpinBox->setRange(1, 1);
     xValueSpinBox->setSingleStep(1);
@@ -3133,9 +3133,9 @@
     //ySlider->setRange(1, imgData->getYDim()); //need redefine range
     ySlider->setRange(1, 1); //need redefine range
     ySlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
-	ySliderLabel = new QLabel("Y", coordGroup);
+  ySliderLabel = new QLabel("Y", coordGroup);
 
-	yValueSpinBox = new QSpinBox;
+  yValueSpinBox = new QSpinBox;
     //yValueSpinBox->setRange(1, imgData->getYDim());
     yValueSpinBox->setRange(1, 1);
     yValueSpinBox->setSingleStep(1);
@@ -3145,19 +3145,19 @@
     //zSlider->setRange(1, imgData->getZDim()); //need redefine range
     zSlider->setRange(1, 1); //need redefine range
     zSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
-	zSliderLabel = new QLabel("Z", coordGroup);
+  zSliderLabel = new QLabel("Z", coordGroup);
 
-	zValueSpinBox = new QSpinBox;
+  zValueSpinBox = new QSpinBox;
     //zValueSpinBox->setRange(1, imgData->getZDim());
     zValueSpinBox->setRange(1, 1);
     zValueSpinBox->setSingleStep(1);
     zValueSpinBox->setValue(xy_view->focusPlaneCoord());
 
-	linkFocusCheckBox = new QCheckBox("Anchor 3 Focal Views");
-	linkFocusCheckBox->setCheckState((bLinkFocusViews) ? Qt::Checked : Qt::Unchecked);
+  linkFocusCheckBox = new QCheckBox("Anchor 3 Focal Views");
+  linkFocusCheckBox->setCheckState((bLinkFocusViews) ? Qt::Checked : Qt::Unchecked);
 
-	displayFocusCrossCheckBox = new QCheckBox("Display Focus Cross Lines");
-	displayFocusCrossCheckBox->setCheckState((bDisplayFocusCross) ? Qt::Checked : Qt::Unchecked);
+  displayFocusCrossCheckBox = new QCheckBox("Display Focus Cross Lines");
+  displayFocusCrossCheckBox->setCheckState((bDisplayFocusCross) ? Qt::Checked : Qt::Unchecked);
 
     /* scale factor group */
 
@@ -3170,33 +3170,33 @@
     xScaleSlider->setSingleStep(1);
     xScaleSlider->setValue(4);
     xScaleSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
-	xScaleSliderLabel = new QLabel("ZY-plane", scaleGroup);
+  xScaleSliderLabel = new QLabel("ZY-plane", scaleGroup);
 
     yScaleSlider = new QScrollBar(Qt::Horizontal, scaleGroup);
     yScaleSlider->setRange(1, 32);
     yScaleSlider->setSingleStep(1);
     yScaleSlider->setValue(4);
     yScaleSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
-	yScaleSliderLabel = new QLabel("XZ-plane", scaleGroup);
+  yScaleSliderLabel = new QLabel("XZ-plane", scaleGroup);
 
     zScaleSlider = new QScrollBar(Qt::Horizontal, scaleGroup);
     zScaleSlider->setRange(1, 32);
     zScaleSlider->setSingleStep(1);
     zScaleSlider->setValue(4);
     zScaleSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
-	zScaleSliderLabel = new QLabel("XY-plane", scaleGroup);
+  zScaleSliderLabel = new QLabel("XY-plane", scaleGroup);
 
-	lookingGlassCheckBox = new QCheckBox("Use looking glass");
-	lookingGlassCheckBox->setCheckState(Qt::Unchecked);
+  lookingGlassCheckBox = new QCheckBox("Use looking glass");
+  lookingGlassCheckBox->setCheckState(Qt::Unchecked);
 
-	resetButton = new QPushButton(scaleGroup);
+  resetButton = new QPushButton(scaleGroup);
     resetButton->setText("Reset");
 
-	zoomWholeViewButton = new QPushButton(); 
-	zoomWholeViewButton->setText("TriView zoom=1. Click to set."); 
-	
-	createMenuOfTriviewZoom();
-	
+  zoomWholeViewButton = new QPushButton();
+  zoomWholeViewButton->setText("TriView zoom=1. Click to set.");
+
+  createMenuOfTriviewZoom();
+
     /* color display group */
 
     QGroupBox *typeGroup = new QGroupBox(mainGroup);
@@ -3211,7 +3211,7 @@
     colorGreen2GrayType = new QRadioButton(typeGroup);
     colorBlue2GrayType = new QRadioButton(typeGroup);
     colorAll2GrayType = new QRadioButton(typeGroup);
-	colorMapDispType = new QRadioButton(typeGroup);
+  colorMapDispType = new QRadioButton(typeGroup);
 
     colorRedType->setText("Red (Chan 1)");
     colorGreenType->setText("Green (Chan 2)");
@@ -3221,44 +3221,44 @@
     colorGreen2GrayType->setText("Green (gray)");
     colorBlue2GrayType->setText("Blue (gray)");
     colorAll2GrayType->setText("RGB (gray)");
-	colorMapDispType->setText("Colormap (for indexed image)");
+  colorMapDispType->setText("Colormap (for indexed image)");
 
-	imgValScaleDisplayCheckBox = new QCheckBox("I(Voxel) rescale: m->0, M->255");
-	imgValScaleDisplayCheckBox->setCheckState(Qt::Unchecked);
+  imgValScaleDisplayCheckBox = new QCheckBox("I(Voxel) rescale: m->0, M->255");
+  imgValScaleDisplayCheckBox->setCheckState(Qt::Unchecked);
 
     //other control button
-	cBox_bSendSignalToExternal = new QCheckBox("Link out");
-	cBox_bSendSignalToExternal->setCheckState(Qt::Unchecked);
+  cBox_bSendSignalToExternal = new QCheckBox("Link out");
+  cBox_bSendSignalToExternal->setCheckState(Qt::Unchecked);
 
-	cBox_bAcceptSignalFromExternal = new QCheckBox("Linked");
-	cBox_bAcceptSignalFromExternal->setCheckState(Qt::Unchecked);
+  cBox_bAcceptSignalFromExternal = new QCheckBox("Linked");
+  cBox_bAcceptSignalFromExternal->setCheckState(Qt::Unchecked);
 
-	//the landmark ctrl box
+  //the landmark ctrl box
 
-	QGroupBox *landmarkGroup  = new QGroupBox(mainGroup);
-	landmarkGroup->setTitle("Landmark controls");
+  QGroupBox *landmarkGroup  = new QGroupBox(mainGroup);
+  landmarkGroup->setTitle("Landmark controls");
 
-	landmarkCopyButton = new QPushButton(landmarkGroup);
-	landmarkCopyButton->setText("Copy");
+  landmarkCopyButton = new QPushButton(landmarkGroup);
+  landmarkCopyButton->setText("Copy");
 
-	landmarkPasteButton = new QPushButton(landmarkGroup);
-	landmarkPasteButton->setText("Paste");
+  landmarkPasteButton = new QPushButton(landmarkGroup);
+  landmarkPasteButton->setText("Paste");
 
-	landmarkSaveButton = new QPushButton(landmarkGroup);
-	landmarkSaveButton->setText("Save");
+  landmarkSaveButton = new QPushButton(landmarkGroup);
+  landmarkSaveButton->setText("Save");
 
-	landmarkLoadButton = new QPushButton(landmarkGroup);
-	landmarkLoadButton->setText("Load");
+  landmarkLoadButton = new QPushButton(landmarkGroup);
+  landmarkLoadButton->setText("Load");
 
-	landmarkManagerButton = new QPushButton(landmarkGroup);
-	landmarkManagerButton->setText("Landmark/Image-atlas Manager");
-	
-	//landmarkLabelDispCheckBox = new QCheckBox("show label");
-	//landmarkLabelDispCheckBox->setCheckState(Qt::Unchecked);
+  landmarkManagerButton = new QPushButton(landmarkGroup);
+  landmarkManagerButton->setText("Landmark/Image-atlas Manager");
 
-	//other buttons
+  //landmarkLabelDispCheckBox = new QCheckBox("show label");
+  //landmarkLabelDispCheckBox->setCheckState(Qt::Unchecked);
 
-	//remove this button on 080402
+  //other buttons
+
+  //remove this button on 080402
     //openFileNameButton = new QPushButton(tr("Open Another Image Stack"));
 
     //imgProcessButton = new QPushButton(mainGroup);
@@ -3271,7 +3271,7 @@
     //imgV3DROIButton = new QPushButton(mainGroup);
     //imgV3DROIButton->setText("See in 3D (Region of Interest)");
 
-	createMenuOf3DViewer();
+  createMenuOf3DViewer();
 
     whatsThisButton = new QPushButton(mainGroup);
     whatsThisButton->setText("Help ... ");
@@ -3287,11 +3287,11 @@
     xyzViewLayout->addWidget(xy_view, 0, 0, 1, 1, Qt::AlignRight | Qt::AlignBottom);
     xyzViewLayout->addWidget(yz_view, 0, 1, 1, 1, Qt::AlignLeft | Qt::AlignBottom);
     xyzViewLayout->addWidget(zx_view, 1, 0, 1, 1, Qt::AlignRight | Qt::AlignTop);
-	xyzViewLayout->update();//061014
-	//xyzViewLayout->addWidget(focusPointFeatureWidget, 2, 0, 1, 2, Qt::AlignLeft | Qt::AlignBottom);
+  xyzViewLayout->update();//061014
+  //xyzViewLayout->addWidget(focusPointFeatureWidget, 2, 0, 1, 2, Qt::AlignLeft | Qt::AlignBottom);
 
     infoGroupLayout = new QVBoxLayout(infoGroup);
-	infoGroupLayout->addWidget(focusPointFeatureWidget);
+  infoGroupLayout->addWidget(focusPointFeatureWidget);
 
     dataGroupLayout = new QVBoxLayout(dataGroup);
     dataGroupLayout->addWidget(viewGroup);
@@ -3300,24 +3300,24 @@
 
     /* layout for focus planes */
 
-	coordGroupLayout = new QGridLayout(coordGroup);
+  coordGroupLayout = new QGridLayout(coordGroup);
     coordGroupLayout->addWidget(zSliderLabel, 0, 0, 1, 1);
-	coordGroupLayout->addWidget(zSlider, 0, 1, 1, 12);
+  coordGroupLayout->addWidget(zSlider, 0, 1, 1, 12);
     coordGroupLayout->addWidget(zValueSpinBox, 0, 13, 1, 4);
 
     coordGroupLayout->addWidget(xSliderLabel, 1, 0, 1, 1);
-	coordGroupLayout->addWidget(xSlider, 1, 1, 1, 12);
+  coordGroupLayout->addWidget(xSlider, 1, 1, 1, 12);
     coordGroupLayout->addWidget(xValueSpinBox, 1, 13, 1, 4);
 
     coordGroupLayout->addWidget(ySliderLabel, 2, 0, 1, 1);
-	coordGroupLayout->addWidget(ySlider, 2, 1, 1, 12);
+  coordGroupLayout->addWidget(ySlider, 2, 1, 1, 12);
     coordGroupLayout->addWidget(yValueSpinBox, 2, 13, 1, 4);
 
     coordGroupLayout->addWidget(linkFocusCheckBox, 3, 0, 1, 14);
-	coordGroupLayout->addWidget(displayFocusCrossCheckBox, 4, 0, 1, 14);
+  coordGroupLayout->addWidget(displayFocusCrossCheckBox, 4, 0, 1, 14);
 
-	coordGroupLayout->addWidget(cBox_bSendSignalToExternal, 5, 0, 1, 6);
-	coordGroupLayout->addWidget(cBox_bAcceptSignalFromExternal, 5, 7, 1, 7);
+  coordGroupLayout->addWidget(cBox_bSendSignalToExternal, 5, 0, 1, 6);
+  coordGroupLayout->addWidget(cBox_bAcceptSignalFromExternal, 5, 7, 1, 7);
 
     /* layout for scaling factors */
 
@@ -3334,7 +3334,7 @@
     scaleGroupLayout->addWidget(lookingGlassCheckBox, 3, 0, 1, 9);
     scaleGroupLayout->addWidget(resetButton, 3, 10, 1, 4);
 
-	//scaleGroupLayout->addWidget(zoomWholeViewLabel, 4, 0, 1, 9);
+  //scaleGroupLayout->addWidget(zoomWholeViewLabel, 4, 0, 1, 9);
     scaleGroupLayout->addWidget(zoomWholeViewButton, 4, 0, 1, 14);
 
     /* color display layout */
@@ -3352,15 +3352,15 @@
 
     typeGroupLayout->addWidget(imgValScaleDisplayCheckBox, 5, 0, 1, 2);
 
-	//landmark group
+  //landmark group
 
-	LandmarkGroupLayout = new QGridLayout(landmarkGroup);
-	LandmarkGroupLayout->addWidget(landmarkCopyButton, 0, 0, 1, 4);
-	LandmarkGroupLayout->addWidget(landmarkPasteButton, 0, 5, 1, 4);
-	LandmarkGroupLayout->addWidget(landmarkLoadButton, 0, 10, 1, 4);
-	LandmarkGroupLayout->addWidget(landmarkSaveButton, 0, 15, 1, 4);
+  LandmarkGroupLayout = new QGridLayout(landmarkGroup);
+  LandmarkGroupLayout->addWidget(landmarkCopyButton, 0, 0, 1, 4);
+  LandmarkGroupLayout->addWidget(landmarkPasteButton, 0, 5, 1, 4);
+  LandmarkGroupLayout->addWidget(landmarkLoadButton, 0, 10, 1, 4);
+  LandmarkGroupLayout->addWidget(landmarkSaveButton, 0, 15, 1, 4);
 
-	//LandmarkGroupLayout->addWidget(landmarkLabelDispCheckBox, 1, 0, 1, 11);
+  //LandmarkGroupLayout->addWidget(landmarkLabelDispCheckBox, 1, 0, 1, 11);
 
     /* main control panel layout */
 
@@ -3370,296 +3370,296 @@
     mainGroupLayout->addWidget(typeGroup);
     mainGroupLayout->addWidget(landmarkGroup); //080107
     //mainGroupLayout->addWidget(resetButton);
-    //mainGroupLayout->addWidget(openFileNameButton); 	//remove this button on 080402
-	mainGroupLayout->addWidget(landmarkManagerButton);
+    //mainGroupLayout->addWidget(openFileNameButton);   //remove this button on 080402
+  mainGroupLayout->addWidget(landmarkManagerButton);
     mainGroupLayout->addWidget(imgV3DButton);
     //mainGroupLayout->addWidget(imgV3DROIButton);
     mainGroupLayout->addStretch(0);
     //mainGroupLayout->addWidget(imgProcessButton);
     mainGroupLayout->addWidget(whatsThisButton);
 
-	// force layout set
-	//setSizePolicy(QSizePolicy::Minimum);
-	QLayout *cur_layout=layout();
-	printf("cur layout=%ld\n", V3DLONG(cur_layout));
-	//if (cur_layout){delete cur_layout;cur_layout=0;}
+  // force layout set
+  //setSizePolicy(QSizePolicy::Minimum);
+  QLayout *cur_layout=layout();
+  printf("cur layout=%ld\n", V3DLONG(cur_layout));
+  //if (cur_layout){delete cur_layout;cur_layout=0;}
 
-	setLayout(allLayout);
-//	resize(xy_view->width()+yz_view->width()+300+50, size().height());
+  setLayout(allLayout);
+//  resize(xy_view->width()+yz_view->width()+300+50, size().height());
 
-	// set the flag
-	bExistGUI = true;
+  // set the flag
+  bExistGUI = true;
 }
 
 void XFormWidget::setWindowTitle_Prefix(char *prefix)
 {
-	if (!openFileNameLabel.startsWith(prefix)) //only prepend the prefix if it has not been prepended before
-	{
-		setWindowTitle(openFileNameLabel.prepend(prefix));
-		getImageData()->setFileName((char *)(openFileNameLabel.constData())); //also update the file name
-	}
+  if (!openFileNameLabel.startsWith(prefix)) //only prepend the prefix if it has not been prepended before
+  {
+    setWindowTitle(openFileNameLabel.prepend(prefix));
+    getImageData()->setFileName((char *)(openFileNameLabel.constData())); //also update the file name
+  }
 }
 
 void XFormWidget::setWindowTitle_Suffix(char *sfix)
 {
-	if (!openFileNameLabel.endsWith(sfix)) //only append suffix if it has not been appended before
-	{
-		setWindowTitle(openFileNameLabel.append(sfix));
-		//printf("file name in win: [%s]\n", (char *)qPrintable(openFileNameLabel));
-		//printf("file name: before [%s]", getImageData()->getFileName());
-		getImageData()->setFileName((char *)qPrintable(openFileNameLabel)); //also update the file name
-		//printf("after [%s]\n", getImageData()->getFileName());
-	}
+  if (!openFileNameLabel.endsWith(sfix)) //only append suffix if it has not been appended before
+  {
+    setWindowTitle(openFileNameLabel.append(sfix));
+    //printf("file name in win: [%s]\n", (char *)qPrintable(openFileNameLabel));
+    //printf("file name: before [%s]", getImageData()->getFileName());
+    getImageData()->setFileName((char *)qPrintable(openFileNameLabel)); //also update the file name
+    //printf("after [%s]\n", getImageData()->getFileName());
+  }
 }
 
 void XFormWidget::updateDataRelatedGUI()
 {
-	if (imgData)
-	{
-		// the data of tri-view planes
+  if (imgData)
+  {
+    // the data of tri-view planes
 
-		xy_view->setImgData(imgPlaneZ, imgData, Ctype);
-		if (b_use_dispzoom)
-		{
-			xy_view->set_disp_width(imgData->getXDim()*disp_zoom);
-			xy_view->set_disp_height(imgData->getYDim()*disp_zoom);
-			xy_view->set_disp_scale(disp_zoom);
-		}
-		else
-		{
-			xy_view->set_disp_width(imgData->getXDim());
-			xy_view->set_disp_height(imgData->getYDim());
-			xy_view->set_disp_scale(1);
-		}
-		xy_view->setFixedWidth(xy_view->get_disp_width());
-		xy_view->setFixedHeight(xy_view->get_disp_height());
-		imgData->set_xy_view(xy_view);
+    xy_view->setImgData(imgPlaneZ, imgData, Ctype);
+    if (b_use_dispzoom)
+    {
+      xy_view->set_disp_width(imgData->getXDim()*disp_zoom);
+      xy_view->set_disp_height(imgData->getYDim()*disp_zoom);
+      xy_view->set_disp_scale(disp_zoom);
+    }
+    else
+    {
+      xy_view->set_disp_width(imgData->getXDim());
+      xy_view->set_disp_height(imgData->getYDim());
+      xy_view->set_disp_scale(1);
+    }
+    xy_view->setFixedWidth(xy_view->get_disp_width());
+    xy_view->setFixedHeight(xy_view->get_disp_height());
+    imgData->set_xy_view(xy_view);
 
-		//
-		yz_view->setImgData(imgPlaneX, imgData, Ctype);
-		if (b_use_dispzoom)
-		{
-			yz_view->set_disp_width(imgData->getZDim()*disp_zoom);
-			yz_view->set_disp_height(imgData->getYDim()*disp_zoom);
-			yz_view->set_disp_scale(disp_zoom);
-		}
-		else
-		{
-			yz_view->set_disp_width(imgData->getZDim());
-			yz_view->set_disp_height(imgData->getYDim());
-			yz_view->set_disp_scale(1);
-		}
-		yz_view->setFixedWidth(yz_view->get_disp_width());
-		yz_view->setFixedHeight(yz_view->get_disp_height());
-		imgData->set_yz_view(yz_view);
+    //
+    yz_view->setImgData(imgPlaneX, imgData, Ctype);
+    if (b_use_dispzoom)
+    {
+      yz_view->set_disp_width(imgData->getZDim()*disp_zoom);
+      yz_view->set_disp_height(imgData->getYDim()*disp_zoom);
+      yz_view->set_disp_scale(disp_zoom);
+    }
+    else
+    {
+      yz_view->set_disp_width(imgData->getZDim());
+      yz_view->set_disp_height(imgData->getYDim());
+      yz_view->set_disp_scale(1);
+    }
+    yz_view->setFixedWidth(yz_view->get_disp_width());
+    yz_view->setFixedHeight(yz_view->get_disp_height());
+    imgData->set_yz_view(yz_view);
 
-		//
-		zx_view->setImgData(imgPlaneY, imgData, Ctype);
-		if (b_use_dispzoom)
-		{
-			zx_view->set_disp_width(imgData->getXDim()*disp_zoom);
-			zx_view->set_disp_height(imgData->getZDim()*disp_zoom);
-			zx_view->set_disp_scale(disp_zoom);
-		}
-		else
-		{
-			zx_view->set_disp_width(imgData->getXDim());
-			zx_view->set_disp_height(imgData->getZDim());
-			zx_view->set_disp_scale(1);
-		}
-		zx_view->setFixedWidth(zx_view->get_disp_width());
-		zx_view->setFixedHeight(zx_view->get_disp_height());
-		imgData->set_zx_view(zx_view);
+    //
+    zx_view->setImgData(imgPlaneY, imgData, Ctype);
+    if (b_use_dispzoom)
+    {
+      zx_view->set_disp_width(imgData->getXDim()*disp_zoom);
+      zx_view->set_disp_height(imgData->getZDim()*disp_zoom);
+      zx_view->set_disp_scale(disp_zoom);
+    }
+    else
+    {
+      zx_view->set_disp_width(imgData->getXDim());
+      zx_view->set_disp_height(imgData->getZDim());
+      zx_view->set_disp_scale(1);
+    }
+    zx_view->setFixedWidth(zx_view->get_disp_width());
+    zx_view->setFixedHeight(zx_view->get_disp_height());
+    imgData->set_zx_view(zx_view);
 
-		if (b_use_dispzoom)
-		{
-			focusPointFeatureWidget->setFixedWidth(qMax(200, int(imgData->getXDim()*disp_zoom+imgData->getZDim()*disp_zoom)));
-		}
-		else
-		{
-			focusPointFeatureWidget->setFixedWidth(qMax(200, int(imgData->getXDim()+imgData->getZDim())));
-		}
-		focusPointFeatureWidget->setMinimumHeight(100);
-		imgData->setFocusFeatureView(focusPointFeatureWidget);
+    if (b_use_dispzoom)
+    {
+      focusPointFeatureWidget->setFixedWidth(qMax(200, int(imgData->getXDim()*disp_zoom+imgData->getZDim()*disp_zoom)));
+    }
+    else
+    {
+      focusPointFeatureWidget->setFixedWidth(qMax(200, int(imgData->getXDim()+imgData->getZDim())));
+    }
+    focusPointFeatureWidget->setMinimumHeight(100);
+    imgData->setFocusFeatureView(focusPointFeatureWidget);
 
-		imgData->setMainWidget((XFormWidget *)this);
+    imgData->setMainWidget((XFormWidget *)this);
 
-		//viewGroup->setFixedWidth(imgData->getXDim() + imgData->getZDim() + 20);
+    //viewGroup->setFixedWidth(imgData->getXDim() + imgData->getZDim() + 20);
 
-		// range of scroll bars of focus planes
+    // range of scroll bars of focus planes
 
-		xSlider->setRange(1, imgData->getXDim()); //need redefine range
-		xValueSpinBox->setRange(1, imgData->getXDim());
-		xSlider->setValue(1);
-		imgData->setFocusX(xSlider->value());
+    xSlider->setRange(1, imgData->getXDim()); //need redefine range
+    xValueSpinBox->setRange(1, imgData->getXDim());
+    xSlider->setValue(1);
+    imgData->setFocusX(xSlider->value());
 
-		ySlider->setRange(1, imgData->getYDim()); //need redefine range
-		yValueSpinBox->setRange(1, imgData->getYDim());
-		ySlider->setValue(1);
-		imgData->setFocusY(ySlider->value());
+    ySlider->setRange(1, imgData->getYDim()); //need redefine range
+    yValueSpinBox->setRange(1, imgData->getYDim());
+    ySlider->setValue(1);
+    imgData->setFocusY(ySlider->value());
 
-		zSlider->setRange(1, imgData->getZDim()); //need redefine range
-		zValueSpinBox->setRange(1, imgData->getZDim());
-		zSlider->setValue(1);
-		imgData->setFocusZ(zSlider->value());
+    zSlider->setRange(1, imgData->getZDim()); //need redefine range
+    zValueSpinBox->setRange(1, imgData->getZDim());
+    zSlider->setValue(1);
+    imgData->setFocusZ(zSlider->value());
 
-		linkFocusCheckBox->setEnabled(true);
-		displayFocusCrossCheckBox->setEnabled(true);
+    linkFocusCheckBox->setEnabled(true);
+    displayFocusCrossCheckBox->setEnabled(true);
 
-		// external communication
+    // external communication
 
-		cBox_bSendSignalToExternal->setEnabled(true);
-		cBox_bAcceptSignalFromExternal->setEnabled(true);
+    cBox_bSendSignalToExternal->setEnabled(true);
+    cBox_bAcceptSignalFromExternal->setEnabled(true);
 
-		// position of scales
+    // position of scales
 
-		xScaleSlider->setValue(4);
-		yScaleSlider->setValue(4);
-		zScaleSlider->setValue(4);
+    xScaleSlider->setValue(4);
+    yScaleSlider->setValue(4);
+    zScaleSlider->setValue(4);
 
-		lookingGlassCheckBox->setEnabled(true);
-		lookingGlassCheckBox->setChecked(false);
-		toggleLookingGlassCheckBox(); //this is used to set the correct enable for the zoom-in sliders
-		
-		zoomWholeViewButton->setText(QString("Tri-view zoom=%1. Click to set.").arg(disp_zoom));
-		
-		// color channel options
+    lookingGlassCheckBox->setEnabled(true);
+    lookingGlassCheckBox->setChecked(false);
+    toggleLookingGlassCheckBox(); //this is used to set the correct enable for the zoom-in sliders
 
-		colorRedType->setEnabled(true);
-		colorBlueType->setEnabled(true);
-		colorGreenType->setEnabled(true);
-		colorAllType->setEnabled(true);
-		colorRed2GrayType->setEnabled(true);
-		colorGreen2GrayType->setEnabled(true);
-		colorBlue2GrayType->setEnabled(true);
-		colorAll2GrayType->setEnabled(true);
-		colorMapDispType->setEnabled(true);
+    zoomWholeViewButton->setText(QString("Tri-view zoom=%1. Click to set.").arg(disp_zoom));
 
-		imgValScaleDisplayCheckBox->setEnabled(true);
+    // color channel options
 
-		if (imgData->getCDim()>=3) //081124
-		{
-			setColorAllType();
-		}
+    colorRedType->setEnabled(true);
+    colorBlueType->setEnabled(true);
+    colorGreenType->setEnabled(true);
+    colorAllType->setEnabled(true);
+    colorRed2GrayType->setEnabled(true);
+    colorGreen2GrayType->setEnabled(true);
+    colorBlue2GrayType->setEnabled(true);
+    colorAll2GrayType->setEnabled(true);
+    colorMapDispType->setEnabled(true);
 
-		if (imgData->getCDim()<3)
-		{
-			colorBlueType->setEnabled(false);
-			colorBlue2GrayType->setEnabled(false);
-		}
+    imgValScaleDisplayCheckBox->setEnabled(true);
 
-		if (imgData->getCDim()<2)
-		{
-			colorGreenType->setEnabled(false);
-			colorGreen2GrayType->setEnabled(false);
-		}
+    if (imgData->getCDim()>=3) //081124
+    {
+      setColorAllType();
+    }
 
-		colorMapDispType->setEnabled(imgData->getCDim()==1);
+    if (imgData->getCDim()<3)
+    {
+      colorBlueType->setEnabled(false);
+      colorBlue2GrayType->setEnabled(false);
+    }
 
-		if (imgData->getDatatype()==V3D_UINT16 && imgData->getCDim()==1)
-			colorMapDispType->setChecked(true);
-		else
-			colorAllType->setChecked(true);
+    if (imgData->getCDim()<2)
+    {
+      colorGreenType->setEnabled(false);
+      colorGreen2GrayType->setEnabled(false);
+    }
 
-		//landmarkLabelDispCheckBox->setEnabled(true);
+    colorMapDispType->setEnabled(imgData->getCDim()==1);
 
-		//imgProcessButton->setCheckable(true); //080402
-		if (imgData->getDatatype()==V3D_UINT8)
-		{
-			imgV3DButton->setEnabled(true);
-			//imgV3DROIButton->setEnabled(true);
-		}
-		else
-		{
-			imgV3DButton->setEnabled(false);
-			//imgV3DROIButton->setEnabled(false);
-		}
-		//setLayout(viewLayout);
+    if (imgData->getDatatype()==V3D_UINT16 && imgData->getCDim()==1)
+      colorMapDispType->setChecked(true);
+    else
+      colorAllType->setChecked(true);
 
-		//resize(minimumSize());
+    //landmarkLabelDispCheckBox->setEnabled(true);
 
-		// main window title
-		//setWindowTitle(openFileNameLabel.prepend("v3d: "));
-		setWindowTitle(openFileNameLabel); //061011
+    //imgProcessButton->setCheckable(true); //080402
+    if (imgData->getDatatype()==V3D_UINT8)
+    {
+      imgV3DButton->setEnabled(true);
+      //imgV3DROIButton->setEnabled(true);
+    }
+    else
+    {
+      imgV3DButton->setEnabled(false);
+      //imgV3DROIButton->setEnabled(false);
+    }
+    //setLayout(viewLayout);
 
-		//added 081124
-		imgData->updateViews();
-	}
-	else
-	{
-		// range of scroll bars of focus planes
+    //resize(minimumSize());
 
-		xSlider->setRange(1, 1); //need redefine range
-		xValueSpinBox->setRange(1, 1);
+    // main window title
+    //setWindowTitle(openFileNameLabel.prepend("v3d: "));
+    setWindowTitle(openFileNameLabel); //061011
 
-		ySlider->setRange(1, 1); //need redefine range
-		yValueSpinBox->setRange(1, 1);
+    //added 081124
+    imgData->updateViews();
+  }
+  else
+  {
+    // range of scroll bars of focus planes
 
-		zSlider->setRange(1, 1); //need redefine range
-		zValueSpinBox->setRange(1, 1);
+    xSlider->setRange(1, 1); //need redefine range
+    xValueSpinBox->setRange(1, 1);
 
-		linkFocusCheckBox->setEnabled(false);
-		displayFocusCrossCheckBox->setEnabled(false);
+    ySlider->setRange(1, 1); //need redefine range
+    yValueSpinBox->setRange(1, 1);
 
-		// external communication
+    zSlider->setRange(1, 1); //need redefine range
+    zValueSpinBox->setRange(1, 1);
 
-		cBox_bSendSignalToExternal->setEnabled(false);
-		cBox_bAcceptSignalFromExternal->setEnabled(false);
+    linkFocusCheckBox->setEnabled(false);
+    displayFocusCrossCheckBox->setEnabled(false);
 
-		lookingGlassCheckBox->setEnabled(false);
-		
-		zoomWholeViewButton->setText("Set tri-view zoom");
+    // external communication
 
-		// color channel options
+    cBox_bSendSignalToExternal->setEnabled(false);
+    cBox_bAcceptSignalFromExternal->setEnabled(false);
 
-		colorRedType->setEnabled(false);
-		colorBlueType->setEnabled(false);
-		colorGreenType->setEnabled(false);
-		colorAllType->setEnabled(false);
-		colorRed2GrayType->setEnabled(false);
-		colorGreen2GrayType->setEnabled(false);
-		colorBlue2GrayType->setEnabled(false);
-		colorAll2GrayType->setEnabled(false);
-		colorMapDispType->setEnabled(false);
+    lookingGlassCheckBox->setEnabled(false);
 
-		imgValScaleDisplayCheckBox->setEnabled(false);
+    zoomWholeViewButton->setText("Set tri-view zoom");
 
-		colorAllType->setChecked(true);
-		//landmarkLabelDispCheckBox->setEnabled(true);
+    // color channel options
 
-		//imgProcessButton->setCheckable(false); //080402
-		imgV3DButton->setEnabled(false);
-		//imgV3DROIButton->setEnabled(false);
-		
-		//setLayout(viewLayout);
+    colorRedType->setEnabled(false);
+    colorBlueType->setEnabled(false);
+    colorGreenType->setEnabled(false);
+    colorAllType->setEnabled(false);
+    colorRed2GrayType->setEnabled(false);
+    colorGreen2GrayType->setEnabled(false);
+    colorBlue2GrayType->setEnabled(false);
+    colorAll2GrayType->setEnabled(false);
+    colorMapDispType->setEnabled(false);
 
-		// set main window title
-		setWindowTitle("v3d: no data loaded yet - click the Load Stack Image button to load data.");
-	}
+    imgValScaleDisplayCheckBox->setEnabled(false);
 
+    colorAllType->setChecked(true);
+    //landmarkLabelDispCheckBox->setEnabled(true);
+
+    //imgProcessButton->setCheckable(false); //080402
+    imgV3DButton->setEnabled(false);
+    //imgV3DROIButton->setEnabled(false);
+
+    //setLayout(viewLayout);
+
+    // set main window title
+    setWindowTitle("v3d: no data loaded yet - click the Load Stack Image button to load data.");
+  }
+
 #if COMPILE_TARGET_LEVEL == 0 //disable the landmark control box if use the V3D lite
-	if (landmarkCopyButton) landmarkCopyButton->setEnabled(false);
-	if (landmarkPasteButton) landmarkPasteButton->setEnabled(false);
-	if (landmarkLoadButton) landmarkLoadButton->setEnabled(false);
-	if (landmarkSaveButton) landmarkSaveButton->setEnabled(false);
-	if (landmarkManagerButton) landmarkManagerButton->setEnabled(false);
+  if (landmarkCopyButton) landmarkCopyButton->setEnabled(false);
+  if (landmarkPasteButton) landmarkPasteButton->setEnabled(false);
+  if (landmarkLoadButton) landmarkLoadButton->setEnabled(false);
+  if (landmarkSaveButton) landmarkSaveButton->setEnabled(false);
+  if (landmarkManagerButton) landmarkManagerButton->setEnabled(false);
 #endif
 
-	allLayout->update();
+  allLayout->update();
 
-	//set the default focus location
-	if (imgData)
-	{
-		emit external_focusXChanged(imgData->getXDim()>>1);
-		emit external_focusYChanged(imgData->getYDim()>>1);
-		emit external_focusZChanged(imgData->getZDim()>>1);
-	}
+  //set the default focus location
+  if (imgData)
+  {
+    emit external_focusXChanged(imgData->getXDim()>>1);
+    emit external_focusYChanged(imgData->getYDim()>>1);
+    emit external_focusZChanged(imgData->getZDim()>>1);
+  }
 
-	updateGeometry();
-	adjustSize();
-	allLayout->update();
+  updateGeometry();
+  adjustSize();
+  allLayout->update();
 
-	update();
+  update();
 }
 
 void XFormWidget::setOpenFileName()
@@ -3668,11 +3668,11 @@
                                 tr("Select a stack image file to open ... "),
                                 openFileNameLabel,
                                 tr("Hanchuan's Raw image stack (*.raw);TIFF stacks (*.tif; *.tiff);All Files (*)"));
-	if (!tmp.isEmpty()) //note that I used isEmpty() instead of isNull, although seems the Cancel operation will return a null string. phc 060422
-	{
-  	  openFileNameLabel = tmp;
-	  loadData();
-	}
+  if (!tmp.isEmpty()) //note that I used isEmpty() instead of isNull, although seems the Cancel operation will return a null string. phc 060422
+  {
+      openFileNameLabel = tmp;
+    loadData();
+  }
 }
 
 bool XFormWidget::loadFile(QString filename)
@@ -3690,40 +3690,40 @@
 
 bool XFormWidget::loadData()
 {
-	//try to get a rough estimation of available amount of memory
-	V3DLONG nbytes = estimateRoughAmountUsedMemory();
-	if (nbytes>(unsigned V3DLONG)((double(1024)*1024*1024*th_use_memory)))
-	{
-		printf("machine info: double upper limit =%5.4f V3DLONG upper limit=%ld\n long_n_bytes=%d",(double(1024)*1024*1024*th_use_memory), (V3DLONG)(double(1024)*1024*1024*th_use_memory), sizeof(V3DLONG));
-		v3d_msg(QString("You already used about %1 bytes of memory, which is more than %2 G bytes for your images. Please close some stacks to assure you have enough memory.\n").arg(nbytes).arg(th_use_memory));
-		return false;
-	}
+  //try to get a rough estimation of available amount of memory
+  V3DLONG nbytes = estimateRoughAmountUsedMemory();
+  if (nbytes>(unsigned V3DLONG)((double(1024)*1024*1024*th_use_memory)))
+  {
+    printf("machine info: double upper limit =%5.4f V3DLONG upper limit=%ld\n long_n_bytes=%d",(double(1024)*1024*1024*th_use_memory), (V3DLONG)(double(1024)*1024*1024*th_use_memory), sizeof(V3DLONG));
+    v3d_msg(QString("You already used about %1 bytes of memory, which is more than %2 G bytes for your images. Please close some stacks to assure you have enough memory.\n").arg(nbytes).arg(th_use_memory));
+    return false;
+  }
 
-	//the following are the original codes
+  //the following are the original codes
 
     if (imgData)
-	{
-	  cleanData();
-	}
+  {
+    cleanData();
+  }
 
-  	imgData = new My4DImage;
-	if (!imgData)
-	  return false;
+    imgData = new My4DImage;
+  if (!imgData)
+    return false;
 
     printf("%s\n", openFileNameLabel.toAscii().data());
-	imgData->loadImage(openFileNameLabel.toAscii().data());  // imgData->loadImage("/Users/hanchuanpeng/work/v3d/test1.raw");
-	if (imgData->isEmpty())
-	{
-	  delete imgData; imgData = 0;
-	  printf("File open error : Fail to open the image file you specified. This could be due to \n(1) The file does not exist. \n(2) The file format is not supported (V3D only supports TIFF stacks, most Zeiss LSM files, and Hanchuan Peng's RAW files. TIFF stacks are widely used and can be easily generated using other tools such as ImageJ or Hanchuan Peng's Matlab image fileio toolbox). \n(3) Your image file is too big. Since on 32-bit machines, an image is at most 2G bytes, and opening tiff files need extra-space for temporary buffer, thus currently V3D has a limitaton on the size of images: TIFF and LSM files < 900M Bytes, and V3D's RAW file < 1.5G bytes. You can contact Hanchuan Peng to get a special version of V3D to handle very big image files.\n");
-	  QMessageBox::information(0, QString("File open error"), QString("Fail to open the image file you specified. This could be due to <br><br>"
-																	  "(1) The file does not exist. <br>"
-																	  "(2) The file format is not supported (V3D only supports TIFF stacks, most Zeiss LSM files, and Hanchuan Peng's RAW files. TIFF stacks are widely used and can be easily generated using other tools such as ImageJ or Hanchuan Peng's Matlab image fileio toolbox). <br>"
-																	  "(3) Your image file is too big. Since on 32-bit machines, an image is at most 2G bytes, and opening tiff files need extra-space for temporary buffer, thus currently V3D has a limitaton on the size of images: TIFF and LSM files less than 900M Bytes, and Hanchuan's RAW file less than 1.5G bytes. You can contact Hanchuan Peng to get a special version of V3D to handle very big image files.<br>"));
-	  return false;
-	}
+  imgData->loadImage(openFileNameLabel.toAscii().data());  // imgData->loadImage("/Users/hanchuanpeng/work/v3d/test1.raw");
+  if (imgData->isEmpty())
+  {
+    delete imgData; imgData = 0;
+    printf("File open error : Fail to open the image file you specified. This could be due to \n(1) The file does not exist. \n(2) The file format is not supported (V3D only supports TIFF stacks, most Zeiss LSM files, and Hanchuan Peng's RAW files. TIFF stacks are widely used and can be easily generated using other tools such as ImageJ or Hanchuan Peng's Matlab image fileio toolbox). \n(3) Your image file is too big. Since on 32-bit machines, an image is at most 2G bytes, and opening tiff files need extra-space for temporary buffer, thus currently V3D has a limitaton on the size of images: TIFF and LSM files < 900M Bytes, and V3D's RAW file < 1.5G bytes. You can contact Hanchuan Peng to get a special version of V3D to handle very big image files.\n");
+    QMessageBox::information(0, QString("File open error"), QString("Fail to open the image file you specified. This could be due to <br><br>"
+                                    "(1) The file does not exist. <br>"
+                                    "(2) The file format is not supported (V3D only supports TIFF stacks, most Zeiss LSM files, and Hanchuan Peng's RAW files. TIFF stacks are widely used and can be easily generated using other tools such as ImageJ or Hanchuan Peng's Matlab image fileio toolbox). <br>"
+                                    "(3) Your image file is too big. Since on 32-bit machines, an image is at most 2G bytes, and opening tiff files need extra-space for temporary buffer, thus currently V3D has a limitaton on the size of images: TIFF and LSM files less than 900M Bytes, and Hanchuan's RAW file less than 1.5G bytes. You can contact Hanchuan Peng to get a special version of V3D to handle very big image files.<br>"));
+    return false;
+  }
 
-	printf("img data size %ld %ld %ld %ld\n", imgData->getXDim(), imgData->getYDim(), imgData->getZDim(), imgData->getCDim());
+  printf("img data size %ld %ld %ld %ld\n", imgData->getXDim(), imgData->getYDim(), imgData->getZDim(), imgData->getCDim());
 
     setCTypeBasedOnImageData();
 
@@ -3732,145 +3732,145 @@
 
     imgData->setFlagImgValScaleDisplay((imgValScaleDisplayCheckBox->checkState()==Qt::Checked) ? true : false);
 
-	//now set the disp_zoom. 081114
+  //now set the disp_zoom. 081114
 
-	if (imgData->getXDim()>512 || imgData->getYDim()>512 || imgData->getZDim()>512)
-	{
-		disp_zoom= double(512) / qMax(imgData->getXDim(), qMax(imgData->getYDim(), imgData->getZDim()));
-		b_use_dispzoom=true;
-	}
+  if (imgData->getXDim()>512 || imgData->getYDim()>512 || imgData->getZDim()>512)
+  {
+    disp_zoom= double(512) / qMax(imgData->getXDim(), qMax(imgData->getYDim(), imgData->getZDim()));
+    b_use_dispzoom=true;
+  }
 
     // update the interface
 
     updateDataRelatedGUI();
 
-	reset(); //090718. PHC. force to update once, since sometimes the 16bit image does not diapl correctly (why all black but once click reset button everything correct?)
-	return true;
+  reset(); //090718. PHC. force to update once, since sometimes the 16bit image does not diapl correctly (why all black but once click reset button everything correct?)
+  return true;
 }
 
 bool XFormWidget::setCTypeBasedOnImageData() //separate this out on 2010-08-01. by PHC
 {
     if (!imgData || !imgData->valid())
-	{
-		v3d_msg("Invalid data in setCTypeBasedOnImageData()");
-		return false;
-	}
-	
+  {
+    v3d_msg("Invalid data in setCTypeBasedOnImageData()");
+    return false;
+  }
+
     if (imgData->getCDim()<1)
-	{
-	  printf("Error in data reading. The number of color channels cannot be smaller than 1!!\n");
-	  if (imgData) {delete imgData; imgData = 0;}
-	  return false;
-	}
+  {
+    printf("Error in data reading. The number of color channels cannot be smaller than 1!!\n");
+    if (imgData) {delete imgData; imgData = 0;}
+    return false;
+  }
 
-	if (imgData->getDatatype()==V3D_UINT8)
-	{
-		if (imgData->getCDim()>=3)
-			Ctype = colorRGB;
-		else if (imgData->getCDim()==2)
-			Ctype = colorRG;
-		else //==1
-			Ctype = colorRed2Gray;
-	}
-	else if (imgData->getDatatype()==V3D_UINT16) //080824
-	{
-		Ctype = colorPseudoMaskColor;
-	}
-	else
-	{
-		printf("Seems you load a float32 bit data which is not supported for display at this moment.\n");
-		Ctype = colorRed2Gray;
-	}
+  if (imgData->getDatatype()==V3D_UINT8)
+  {
+    if (imgData->getCDim()>=3)
+      Ctype = colorRGB;
+    else if (imgData->getCDim()==2)
+      Ctype = colorRG;
+    else //==1
+      Ctype = colorRed2Gray;
+  }
+  else if (imgData->getDatatype()==V3D_UINT16) //080824
+  {
+    Ctype = colorPseudoMaskColor;
+  }
+  else
+  {
+    printf("Seems you load a float32 bit data which is not supported for display at this moment.\n");
+    Ctype = colorRed2Gray;
+  }
 
    return true;
 }
 
 bool XFormWidget::setCurrentFileName(QString cfilename)
 {
-	qDebug()<<"XFormWidget::setCurrentFileName: " <<cfilename;
-	if (cfilename.isEmpty()) return false;
-	openFileNameLabel = cfilename;
-	setWindowTitle(openFileNameLabel);
-	if (getImageData())
-		getImageData()->setFileName((char *)qPrintable(openFileNameLabel));
-	update();
-	return true;
+  qDebug()<<"XFormWidget::setCurrentFileName: " <<cfilename;
+  if (cfilename.isEmpty()) return false;
+  openFileNameLabel = cfilename;
+  setWindowTitle(openFileNameLabel);
+  if (getImageData())
+    getImageData()->setFileName((char *)qPrintable(openFileNameLabel));
+  update();
+  return true;
 }
 
 bool XFormWidget::saveData()
 {
-	if (!imgData) {printf("Image data is empty!\n"); return false;}
+  if (!imgData) {printf("Image data is empty!\n"); return false;}
 
-	QString outputFile = QFileDialog::getSaveFileName(0,
-													  "Choose a filename to save under",
-													  //"./",
-													  QString(openFileNameLabel)+".tif",
-													  "Save file format (*.tif *.raw)");
+  QString outputFile = QFileDialog::getSaveFileName(0,
+                            "Choose a filename to save under",
+                            //"./",
+                            QString(openFileNameLabel)+".tif",
+                            "Save file format (*.tif *.raw)");
 
-	while (outputFile.isEmpty()) //note that I used isEmpty() instead of isNull, although seems the Cancel operation will return a null string. phc 060422
-	{
-    	if(QMessageBox::Yes == QMessageBox::question (0, "", "Are you sure you do NOT want to save?", QMessageBox::Yes, QMessageBox::No))
-	    {
-		    return false;
-		}
-		outputFile = QFileDialog::getSaveFileName(0,
-												  "Choose a filename to save under",
-												  "./",
-												  "Save file format (*.tif *.raw)");
-	}
+  while (outputFile.isEmpty()) //note that I used isEmpty() instead of isNull, although seems the Cancel operation will return a null string. phc 060422
+  {
+      if(QMessageBox::Yes == QMessageBox::question (0, "", "Are you sure you do NOT want to save?", QMessageBox::Yes, QMessageBox::No))
+      {
+        return false;
+    }
+    outputFile = QFileDialog::getSaveFileName(0,
+                          "Choose a filename to save under",
+                          "./",
+                          "Save file format (*.tif *.raw)");
+  }
 
-	saveFile(outputFile);
+  saveFile(outputFile);
 
-	return true;
+  return true;
 }
 bool XFormWidget::saveFile(QString filename)
 {
-	if (!imgData) {printf("Image data is empty!\n"); return false;}
-	if (filename.isEmpty()) {printf("The file name to save image is empty!\n"); return false;}
+  if (!imgData) {printf("Image data is empty!\n"); return false;}
+  if (filename.isEmpty()) {printf("The file name to save image is empty!\n"); return false;}
 
-	imgData->saveImage(qPrintable(filename));
+  imgData->saveImage(qPrintable(filename));
 
-	printf("Current image is saved to the file %s\n", qPrintable(filename));
-	setCurrentFileName(filename);
-	return true;
+  printf("Current image is saved to the file %s\n", qPrintable(filename));
+  setCurrentFileName(filename);
+  return true;
 }
 
 
 
 bool XFormWidget::newProcessedImage(QString filename, unsigned char *ndata1d, V3DLONG nsz0, V3DLONG nsz1, V3DLONG nsz2, V3DLONG nsz3, ImagePixelType ndatatype) //080408
 {
-	if (filename.isEmpty()) return false;
-	openFileNameLabel = filename;
+  if (filename.isEmpty()) return false;
+  openFileNameLabel = filename;
 
-	return setImageData(ndata1d, nsz0, nsz1, nsz2, nsz3, ndatatype)
-			&& setCurrentFileName(filename);
+  return setImageData(ndata1d, nsz0, nsz1, nsz2, nsz3, ndatatype)
+      && setCurrentFileName(filename);
 }
 
 bool XFormWidget::setImageData(unsigned char *ndata1d, V3DLONG nsz0, V3DLONG nsz1, V3DLONG nsz2, V3DLONG nsz3, ImagePixelType ndatatype) //090818 RZC
 {
 
-//	printf("he %p\n", ndata1d);
-	if (imgData) { cleanData();	}
-	imgData = new My4DImage;
-	if (!imgData)  return false;
+//  printf("he %p\n", ndata1d);
+  if (imgData) { cleanData();  }
+  imgData = new My4DImage;
+  if (!imgData)  return false;
 
-	updateDataRelatedGUI(); //this should be important to set up all pointers
+  updateDataRelatedGUI(); //this should be important to set up all pointers
 
-	printf("now in the function setImageData() line=%d.\n", __LINE__);
-	if (!imgData->setNewImageData(ndata1d, nsz0, nsz1, nsz2, nsz3, ndatatype))
-	{
-		printf("Sth wrong in the function setImageData() line=%d.\n", __LINE__);
-		return false;
-	}
+  printf("now in the function setImageData() line=%d.\n", __LINE__);
+  if (!imgData->setNewImageData(ndata1d, nsz0, nsz1, nsz2, nsz3, ndatatype))
+  {
+    printf("Sth wrong in the function setImageData() line=%d.\n", __LINE__);
+    return false;
+  }
 
-	imgData->setFileName((char *)qPrintable(openFileNameLabel));
+  imgData->setFileName((char *)qPrintable(openFileNameLabel));
 
     if (imgData->getCDim()>=3)
-	    Ctype = colorRGB;
+      Ctype = colorRGB;
     else if (imgData->getCDim()==2)
-	    Ctype = colorRG;
-	else //==1
-	    Ctype = colorRed2Gray;
+      Ctype = colorRG;
+  else //==1
+      Ctype = colorRed2Gray;
 
     imgData->setFlagLinkFocusViews(bLinkFocusViews);
     imgData->setFlagDisplayFocusCross(bDisplayFocusCross);
@@ -3878,225 +3878,225 @@
     imgData->setFlagImgValScaleDisplay((imgValScaleDisplayCheckBox->checkState()==Qt::Checked) ? true : false);
 
 
-	//now set the disp_zoom. 081114
+  //now set the disp_zoom. 081114
 
-	if (imgData->getXDim()>512 || imgData->getYDim()>512 || imgData->getZDim()>512)
-	{
-		disp_zoom= double(512) / qMax(imgData->getXDim(), qMax(imgData->getYDim(), imgData->getZDim()));
-		b_use_dispzoom=true;
-	}
+  if (imgData->getXDim()>512 || imgData->getYDim()>512 || imgData->getZDim()>512)
+  {
+    disp_zoom= double(512) / qMax(imgData->getXDim(), qMax(imgData->getYDim(), imgData->getZDim()));
+    b_use_dispzoom=true;
+  }
 
     updateDataRelatedGUI();
 
-	v3d_msg("success in set up image data", 0);
-	return true;
+  v3d_msg("success in set up image data", 0);
+  return true;
 }
 
 void XFormWidget::doImage3DView()
 {
-	doImage3DView(true, 0); //0 for entire image
+  doImage3DView(true, 0); //0 for entire image
 }
 
 void XFormWidget::doImage3DLocalMarkerView()
 {
-	if (!imgData)  return;
-	doImage3DView(true, 1); //1 for marker
+  if (!imgData)  return;
+  doImage3DView(true, 1); //1 for marker
 }
 
 void XFormWidget::doImage3DLocalRoiView()
 {
-	if (!imgData)  return;
-	doImage3DView(true, 2); //2 for roi
+  if (!imgData)  return;
+  doImage3DView(true, 2); //2 for roi
 }
 
 
 void XFormWidget::doImage3DView(bool tmp_b_use_512x512x256, int b_local) //b_local==1, use marker; b_local==2, use roi; b_local==0, use entire image
 {
-	if (!b_local && mypara_3Dview.b_still_open)
-	{
-		mypara_3Dview.window3D->raise_and_activate(); // activateWindow();
-		//printf("The 3D view window is still open. Please close it or re-use it.\n");
-		//QMessageBox::warning(0, "3D view window is still open", "Your 3D view window is still open. Please re-use it or close it before re-open.");
-		return;
-	}
-	if (b_local && mypara_3Dlocalview.b_still_open)
-	{
-		//mypara_3Dlocalview.window->raise_and_activate();
+  if (!b_local && mypara_3Dview.b_still_open)
+  {
+    mypara_3Dview.window3D->raise_and_activate(); // activateWindow();
+    //printf("The 3D view window is still open. Please close it or re-use it.\n");
+    //QMessageBox::warning(0, "3D view window is still open", "Your 3D view window is still open. Please re-use it or close it before re-open.");
+    return;
+  }
+  if (b_local && mypara_3Dlocalview.b_still_open)
+  {
+    //mypara_3Dlocalview.window->raise_and_activate();
 
-		//090723 RZC: continue create a new view, wait 1 second for the last local 3D view closed
-		mypara_3Dlocalview.window3D->postClose();
-		if (b_local==1)
-			QTimer::singleShot(1000, this, SLOT(doImage3DLocalMarkerView()));
-		else if (b_local==2)
-			QTimer::singleShot(1000, this, SLOT(doImage3DLocalRoiView()));
-		else
-			v3d_msg("Invalid b_local parameter in doImage3DView();");
+    //090723 RZC: continue create a new view, wait 1 second for the last local 3D view closed
+    mypara_3Dlocalview.window3D->postClose();
+    if (b_local==1)
+      QTimer::singleShot(1000, this, SLOT(doImage3DLocalMarkerView()));
+    else if (b_local==2)
+      QTimer::singleShot(1000, this, SLOT(doImage3DLocalRoiView()));
+    else
+      v3d_msg("Invalid b_local parameter in doImage3DView();");
 
-		return;
-	}
+    return;
+  }
 
-	if (imgData)
-	{
-		//	QString	tmpfile = QFileDialog::getOpenFileName(
-		//                    this,
-		//                    "Choose an atlas/annotation file to open",
-		//                    "./",
-		//                    "File (*.txt *.ano)");
-		//
-		//    if (tmpfile.isEmpty()) // do nothing if nothing is chosen
-		//	{
-		//	    return;
-		//	}
+  if (imgData)
+  {
+    //  QString  tmpfile = QFileDialog::getOpenFileName(
+    //                    this,
+    //                    "Choose an atlas/annotation file to open",
+    //                    "./",
+    //                    "File (*.txt *.ano)");
+    //
+    //    if (tmpfile.isEmpty()) // do nothing if nothing is chosen
+    //  {
+    //      return;
+    //  }
 
 
-		V3DLONG nbytes = estimateRoughAmountUsedMemory();
-		if (nbytes>(V3DLONG)((double(1024)*1024*1024*th_use_memory)))
-		{
-			printf("You already used more than %5.2fG bytes for your images. Please close some stacks to assure you have enough memory.", th_use_memory);
-			QMessageBox::warning(0, "Memory warning", "You already used >1.1G bytes and may not be able to allocate enough memory for 3D volume rendering. Please close some stacks first.");
-			return;
-		}
+    V3DLONG nbytes = estimateRoughAmountUsedMemory();
+    if (nbytes>(V3DLONG)((double(1024)*1024*1024*th_use_memory)))
+    {
+      printf("You already used more than %5.2fG bytes for your images. Please close some stacks to assure you have enough memory.", th_use_memory);
+      QMessageBox::warning(0, "Memory warning", "You already used >1.1G bytes and may not be able to allocate enough memory for 3D volume rendering. Please close some stacks first.");
+      return;
+    }
 
-		if (! b_local) //0 for entire image
-		{
-			//iDrawExternalParameter mypara;
-			mypara_3Dview.image4d = imgData;
-			mypara_3Dview.b_use_512x512x256 = tmp_b_use_512x512x256;
-			mypara_3Dview.xwidget = this; //imgData->listLandmarks;
-			mypara_3Dview.V3Dmainwindow = p_mainWindow; //added on 090503
-			mypara_3Dview.p_list_3Dview_win = &(p_mainWindow->list_3Dview_win); //081003: always keep an record in the central controller
+    if (! b_local) //0 for entire image
+    {
+      //iDrawExternalParameter mypara;
+      mypara_3Dview.image4d = imgData;
+      mypara_3Dview.b_use_512x512x256 = tmp_b_use_512x512x256;
+      mypara_3Dview.xwidget = this; //imgData->listLandmarks;
+      mypara_3Dview.V3Dmainwindow = p_mainWindow; //added on 090503
+      mypara_3Dview.p_list_3Dview_win = &(p_mainWindow->list_3Dview_win); //081003: always keep an record in the central controller
 
-			mypara_3Dlocalview.b_local = b_local;
-		}
-		if (b_local==1 || b_local==2)
-		{
-			V3DLONG x0, y0, z0, x1, y1, z1;
+      mypara_3Dlocalview.b_local = b_local;
+    }
+    if (b_local==1 || b_local==2)
+    {
+      V3DLONG x0, y0, z0, x1, y1, z1;
 
-			if (b_local==1) //1 for marker
-			{
-				if (imgData->listLandmarks.size()>0)
-				{
-					//get the current marker
-					LocationSimple *pt = 0;
-					LocationSimple mypt;
-					mypt = imgData->listLandmarks.at(imgData->cur_hit_landmark);
-					mypt.x-=1; mypt.y-=1; mypt.z-=1;
-					pt = &mypt;
+      if (b_local==1) //1 for marker
+      {
+        if (imgData->listLandmarks.size()>0)
+        {
+          //get the current marker
+          LocationSimple *pt = 0;
+          LocationSimple mypt;
+          mypt = imgData->listLandmarks.at(imgData->cur_hit_landmark);
+          mypt.x-=1; mypt.y-=1; mypt.z-=1;
+          pt = &mypt;
 
-					x0 = qBound((V3DLONG)0L, (V3DLONG)((*pt).x-64) , (imgData->getXDim()-1));
-					y0 = qBound((V3DLONG)0L, (V3DLONG)((*pt).y-64) , (imgData->getYDim()-1));
-					z0 = qBound((V3DLONG)0L, (V3DLONG)((*pt).z-64) , imgData->getZDim()-1);
-					x1 = qBound((V3DLONG)0L, (V3DLONG)((*pt).x+63) , imgData->getXDim()-1);
-					y1 = qBound((V3DLONG)0L, (V3DLONG)((*pt).y+63) , imgData->getYDim()-1);
-					z1 = qBound((V3DLONG)0L, (V3DLONG)((*pt).z+63) , imgData->getZDim()-1);
-//					c0 = 0;
-//					c1 = sz3-1;
-				}
-			}
-			else //b_local==2 //2 for roi
-			{
-				QRect b_xy = imgData->p_xy_view->getRoiBoundingRect();
-				QRect b_yz = imgData->p_yz_view->getRoiBoundingRect();
-				QRect b_zx = imgData->p_zx_view->getRoiBoundingRect();
+          x0 = qBound((V3DLONG)0L, (V3DLONG)((*pt).x-64) , (imgData->getXDim()-1));
+          y0 = qBound((V3DLONG)0L, (V3DLONG)((*pt).y-64) , (imgData->getYDim()-1));
+          z0 = qBound((V3DLONG)0L, (V3DLONG)((*pt).z-64) , imgData->getZDim()-1);
+          x1 = qBound((V3DLONG)0L, (V3DLONG)((*pt).x+63) , imgData->getXDim()-1);
+          y1 = qBound((V3DLONG)0L, (V3DLONG)((*pt).y+63) , imgData->getYDim()-1);
+          z1 = qBound((V3DLONG)0L, (V3DLONG)((*pt).z+63) , imgData->getZDim()-1);
+//          c0 = 0;
+//          c1 = sz3-1;
+        }
+      }
+      else //b_local==2 //2 for roi
+      {
+        QRect b_xy = imgData->p_xy_view->getRoiBoundingRect();
+        QRect b_yz = imgData->p_yz_view->getRoiBoundingRect();
+        QRect b_zx = imgData->p_zx_view->getRoiBoundingRect();
 
-				V3DLONG bpos_x = qBound((V3DLONG)(0), V3DLONG(qMax(b_xy.left(), b_zx.left())), imgData->getXDim()-1),
-					 bpos_y = qBound((V3DLONG)(0), V3DLONG(qMax(b_xy.top(),  b_yz.top())), imgData->getYDim()-1),
-					 bpos_z = qBound((V3DLONG)(0), V3DLONG(qMax(b_yz.left(), b_zx.top())), imgData->getZDim()-1),
-					 bpos_c = 0;
-				V3DLONG epos_x = qBound((V3DLONG)(0), V3DLONG(qMin(b_xy.right(), b_zx.right())), imgData->getXDim()-1),
-				 	 epos_y = qBound((V3DLONG)(0), V3DLONG(qMin(b_xy.bottom(), b_yz.bottom())), imgData->getYDim()-1),
-					 epos_z = qBound((V3DLONG)(0), V3DLONG(qMin(b_yz.right(), b_zx.bottom())), imgData->getZDim()-1),
-					 epos_c = imgData->getCDim()-1;
+        V3DLONG bpos_x = qBound((V3DLONG)(0), V3DLONG(qMax(b_xy.left(), b_zx.left())), imgData->getXDim()-1),
+           bpos_y = qBound((V3DLONG)(0), V3DLONG(qMax(b_xy.top(),  b_yz.top())), imgData->getYDim()-1),
+           bpos_z = qBound((V3DLONG)(0), V3DLONG(qMax(b_yz.left(), b_zx.top())), imgData->getZDim()-1),
+           bpos_c = 0;
+        V3DLONG epos_x = qBound((V3DLONG)(0), V3DLONG(qMin(b_xy.right(), b_zx.right())), imgData->getXDim()-1),
+            epos_y = qBound((V3DLONG)(0), V3DLONG(qMin(b_xy.bottom(), b_yz.bottom())), imgData->getYDim()-1),
+           epos_z = qBound((V3DLONG)(0), V3DLONG(qMin(b_yz.right(), b_zx.bottom())), imgData->getZDim()-1),
+           epos_c = imgData->getCDim()-1;
 
-				if (bpos_x>epos_x || bpos_y>epos_y || bpos_z>epos_z)
-				{
-					v3d_msg("The roi polygons in three views are not intersecting! No crop is done!\n");
-					return;
-				}
+        if (bpos_x>epos_x || bpos_y>epos_y || bpos_z>epos_z)
+        {
+          v3d_msg("The roi polygons in three views are not intersecting! No crop is done!\n");
+          return;
+        }
 
-				x0 = bpos_x;
-				y0 = bpos_y;
-				z0 = bpos_z;
-				x1 = epos_x;
-				y1 = epos_y;
-				z1 = epos_z;
-			}
+        x0 = bpos_x;
+        y0 = bpos_y;
+        z0 = bpos_z;
+        x1 = epos_x;
+        y1 = epos_y;
+        z1 = epos_z;
+      }
 
-			mypara_3Dlocalview.image4d = imgData;
-			mypara_3Dlocalview.b_use_512x512x256 = tmp_b_use_512x512x256;
-			mypara_3Dlocalview.xwidget = this; //imgData->listLandmarks;
-			mypara_3Dlocalview.V3Dmainwindow = p_mainWindow; //added on 090503
-			mypara_3Dlocalview.p_list_3Dview_win = &(p_mainWindow->list_3Dview_win); //081003: always keep an record in the central controller
+      mypara_3Dlocalview.image4d = imgData;
+      mypara_3Dlocalview.b_use_512x512x256 = tmp_b_use_512x512x256;
+      mypara_3Dlocalview.xwidget = this; //imgData->listLandmarks;
+      mypara_3Dlocalview.V3Dmainwindow = p_mainWindow; //added on 090503
+      mypara_3Dlocalview.p_list_3Dview_win = &(p_mainWindow->list_3Dview_win); //081003: always keep an record in the central controller
 
-			mypara_3Dlocalview.b_local = b_local;
-			mypara_3Dlocalview.local_size = LocationSimple(x1-x0+1, y1-y0+1, z1-z0+1);
-			mypara_3Dlocalview.local_start = LocationSimple(x0, y0, z0);
+      mypara_3Dlocalview.b_local = b_local;
+      mypara_3Dlocalview.local_size = LocationSimple(x1-x0+1, y1-y0+1, z1-z0+1);
+      mypara_3Dlocalview.local_start = LocationSimple(x0, y0, z0);
 
-//			if (mypara_3Dlocalview.localimage4d)
-//				delete mypara_3Dlocalview.localimage4d;
-//			mypara_3Dlocalview.localimage4d = 0;
-//			mypara_3Dlocalview.localimage4d = new My4DImage();
-//			if (mypara_3Dlocalview.localimage4d)
-//				mypara_3Dlocalview.localimage4d->setNewImageData(imgData->getRawData(),
-//						mypara_3Dlocalview.local_size.x,
-//						mypara_3Dlocalview.local_size.y,
-//						mypara_3Dlocalview.local_size.z,
-//						imgData->getCDim(), imgData->getDatatype());
-		}
+//      if (mypara_3Dlocalview.localimage4d)
+//        delete mypara_3Dlocalview.localimage4d;
+//      mypara_3Dlocalview.localimage4d = 0;
+//      mypara_3Dlocalview.localimage4d = new My4DImage();
+//      if (mypara_3Dlocalview.localimage4d)
+//        mypara_3Dlocalview.localimage4d->setNewImageData(imgData->getRawData(),
+//            mypara_3Dlocalview.local_size.x,
+//            mypara_3Dlocalview.local_size.y,
+//            mypara_3Dlocalview.local_size.z,
+//            imgData->getCDim(), imgData->getDatatype());
+    }
 
-		V3dR_MainWindow *my3dwin = 0;
-		try
-		{
-			if (b_local)
-			{
-				my3dwin = new V3dR_MainWindow(&mypara_3Dlocalview); //090628 RZC
-				mypara_3Dlocalview.window3D = my3dwin;
-			}
-			else
-			{
-				my3dwin = new V3dR_MainWindow(&mypara_3Dview); //iDrawMainWindow-->V3dR_MainWindow, by RZC 20080921
-				mypara_3Dview.window3D = my3dwin;
-			}
-			my3dwin->setParent(0);
-			my3dwin->show();
-		}
-		catch (...)
-		{
-			QMessageBox::warning(0, "Memory warning", "You fail to open a 3D view window. You may have opened too many stacks (if so please close some first) or try to render a too-big 3D view (if so please contact Hanchuan Peng for a 64-bit version of V3D).");
-			printf("You fail to open a 3D view window. You may have opened too many stacks (if so please close some first) or try to render a too-big 3D view (if so please contact Hanchuan Peng for a 64-bit version of V3D).");
-			return;
-		}
-	}
-	else
-	{
-		printf("The image data is invalid() in doImage3DView().\n");
-		return;
-	}
+    V3dR_MainWindow *my3dwin = 0;
+    try
+    {
+      if (b_local)
+      {
+        my3dwin = new V3dR_MainWindow(&mypara_3Dlocalview); //090628 RZC
+        mypara_3Dlocalview.window3D = my3dwin;
+      }
+      else
+      {
+        my3dwin = new V3dR_MainWindow(&mypara_3Dview); //iDrawMainWindow-->V3dR_MainWindow, by RZC 20080921
+        mypara_3Dview.window3D = my3dwin;
+      }
+      my3dwin->setParent(0);
+      my3dwin->show();
+    }
+    catch (...)
+    {
+      QMessageBox::warning(0, "Memory warning", "You fail to open a 3D view window. You may have opened too many stacks (if so please close some first) or try to render a too-big 3D view (if so please contact Hanchuan Peng for a 64-bit version of V3D).");
+      printf("You fail to open a 3D view window. You may have opened too many stacks (if so please close some first) or try to render a too-big 3D view (if so please contact Hanchuan Peng for a 64-bit version of V3D).");
+      return;
+    }
+  }
+  else
+  {
+    printf("The image data is invalid() in doImage3DView().\n");
+    return;
+  }
 }
 
 void XFormWidget::popupImageProcessingDialog()
 {
-	popupImageProcessingDialog(QString(""));
+  popupImageProcessingDialog(QString(""));
 }
 void XFormWidget::popupImageProcessingDialog(QString item)
 {
-	if (imgData && xy_view)
-	{
-		xy_view->popupImageProcessingDialog(item);
-	}
+  if (imgData && xy_view)
+  {
+    xy_view->popupImageProcessingDialog(item);
+  }
 }
 
 void XFormWidget::aboutInfo()
 {
-	v3d_aboutinfo();
+  v3d_aboutinfo();
 }
 
 void XFormWidget::connectEventSignals()
 {
-	connect(xSlider, SIGNAL(valueChanged(int)), yz_view, SLOT(changeFocusPlane(int)));
+  connect(xSlider, SIGNAL(valueChanged(int)), yz_view, SLOT(changeFocusPlane(int)));
     connect(ySlider, SIGNAL(valueChanged(int)), zx_view, SLOT(changeFocusPlane(int)));
     connect(zSlider, SIGNAL(valueChanged(int)), xy_view, SLOT(changeFocusPlane(int)));
-	//printf("connect status[%d]\n",a);
+  //printf("connect status[%d]\n",a);
 
     connect(xValueSpinBox, SIGNAL(valueChanged(int)), xSlider, SLOT(setValue(int)));
     connect(xSlider, SIGNAL(valueChanged(int)), xValueSpinBox, SLOT(setValue(int)));
@@ -4107,7 +4107,7 @@
     connect(zValueSpinBox, SIGNAL(valueChanged(int)), zSlider, SLOT(setValue(int)));
     connect(zSlider, SIGNAL(valueChanged(int)), zValueSpinBox, SLOT(setValue(int)));
 
-	//set the navigation event connection
+  //set the navigation event connection
     connect(xy_view, SIGNAL(focusXChanged(int)), xSlider, SLOT(setValue(int)));
     connect(xy_view, SIGNAL(focusYChanged(int)), ySlider, SLOT(setValue(int)));
     connect(xy_view, SIGNAL(focusZChanged(int)), zSlider, SLOT(setValue(int)));
@@ -4126,21 +4126,21 @@
     connect(this, SIGNAL(external_focusYChanged(int)), yValueSpinBox, SLOT(setValue(int)));
     connect(this, SIGNAL(external_focusZChanged(int)), zValueSpinBox, SLOT(setValue(int)));
 
-	//set up slot to accept signals passed to external
+  //set up slot to accept signals passed to external
     connect(xValueSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeFocusXToExternal(int)));
     connect(yValueSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeFocusYToExternal(int)));
     connect(zValueSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeFocusZToExternal(int)));
-	//printf("out connect status[%d]\n",a);
+  //printf("out connect status[%d]\n",a);
 
 
     // set up focus link events
     connect(linkFocusCheckBox, SIGNAL(clicked()), this, SLOT(toggleLinkFocusCheckBox()));
     connect(displayFocusCrossCheckBox, SIGNAL(clicked()), this, SLOT(toggleDisplayFocusCrossCheckBox()));
 
-	// external communication
+  // external communication
 
-	connect(cBox_bSendSignalToExternal, SIGNAL(clicked()), this, SLOT(toggleCheckBox_bSendSignalToExternal()));
-	connect(cBox_bAcceptSignalFromExternal, SIGNAL(clicked()), this, SLOT(toggleCheckBox_bAcceptSignalFromExternal()));
+  connect(cBox_bSendSignalToExternal, SIGNAL(clicked()), this, SLOT(toggleCheckBox_bSendSignalToExternal()));
+  connect(cBox_bAcceptSignalFromExternal, SIGNAL(clicked()), this, SLOT(toggleCheckBox_bAcceptSignalFromExternal()));
 
     // set up zoom events
 
@@ -4154,9 +4154,9 @@
 
     connect(lookingGlassCheckBox, SIGNAL(clicked()), this, SLOT(toggleLookingGlassCheckBox()));
 
-	connect(zoomWholeViewButton, SIGNAL(clicked()), this, SLOT(doMenuOfTriviewZoom()));
+  connect(zoomWholeViewButton, SIGNAL(clicked()), this, SLOT(doMenuOfTriviewZoom()));
 
-	
+
     // set up color mapping events
 
     connect(colorRedType, SIGNAL(clicked()), this, SLOT(setColorRedType()));
@@ -4169,7 +4169,7 @@
     connect(colorBlue2GrayType, SIGNAL(clicked()), this, SLOT(setColorBlue2GrayType()));
     connect(colorAll2GrayType, SIGNAL(clicked()), this, SLOT(setColorAll2GrayType()));
 
-	connect(colorMapDispType, SIGNAL(clicked()), this, SLOT(setColorMapDispType()));
+  connect(colorMapDispType, SIGNAL(clicked()), this, SLOT(setColorMapDispType()));
 
     connect(imgValScaleDisplayCheckBox, SIGNAL(clicked()), this, SLOT(toggleImgValScaleDisplay()));
 
@@ -4180,7 +4180,7 @@
     connect(landmarkManagerButton, SIGNAL(clicked()), this, SLOT(openLandmarkManager()));
 
     connect(resetButton, SIGNAL(clicked()), this, SLOT(reset()));
-	//connect(openFileNameButton, SIGNAL(clicked()), this, SLOT(setOpenFileName())); //	remove this button on 080402
+  //connect(openFileNameButton, SIGNAL(clicked()), this, SLOT(setOpenFileName())); //  remove this button on 080402
 
     //connect(landmarkLabelDispCheckBox, SIGNAL(clicked()), this, SLOT(toggleLandmarkLabelDisp()));
 
@@ -4196,7 +4196,7 @@
 
 void XFormWidget::disconnectEventSignals()
 {
-	disconnect(xSlider, 0, yz_view, 0);
+  disconnect(xSlider, 0, yz_view, 0);
     disconnect(ySlider, 0, zx_view, 0);
     disconnect(zSlider, 0, xy_view, 0);
 
@@ -4240,16 +4240,16 @@
 
     disconnect(imgValScaleDisplayCheckBox, 0, this, 0);
 
-	disconnect(landmarkCopyButton, 0, this, 0);
-	disconnect(landmarkPasteButton, 0, this, 0);
-	disconnect(landmarkLoadButton, 0, this, 0);
-	disconnect(landmarkSaveButton, 0, this, 0);
-	disconnect(landmarkManagerButton, 0, this, 0);
+  disconnect(landmarkCopyButton, 0, this, 0);
+  disconnect(landmarkPasteButton, 0, this, 0);
+  disconnect(landmarkLoadButton, 0, this, 0);
+  disconnect(landmarkSaveButton, 0, this, 0);
+  disconnect(landmarkManagerButton, 0, this, 0);
 
     //disconnect(landmarkLabelDispCheckBox, 0, this, 0);
 
     disconnect(resetButton, 0, this, 0);
-	//disconnect(openFileNameButton, 0, this, 0);
+  //disconnect(openFileNameButton, 0, this, 0);
 
     //disconnect(imgProcessButton, 0, this, 0);
     disconnect(imgV3DButton, 0, this, 0);
@@ -4264,83 +4264,83 @@
 void XFormWidget::toggleLinkFocusCheckBox()
 {
     bLinkFocusViews = (linkFocusCheckBox->checkState()==Qt::Checked) ? true : false;
-	if (imgData!=NULL)
-	{
-	  if (imgData->isEmpty()==false)
-	  {
-	    imgData->setFlagLinkFocusViews(bLinkFocusViews);
-		//printf("display cross %d\n", int(imgData->getFlagLinkFocusViews()));
-	  }
-	}
+  if (imgData!=NULL)
+  {
+    if (imgData->isEmpty()==false)
+    {
+      imgData->setFlagLinkFocusViews(bLinkFocusViews);
+    //printf("display cross %d\n", int(imgData->getFlagLinkFocusViews()));
+    }
+  }
     update();
 }
 
 void XFormWidget::toggleDisplayFocusCrossCheckBox()
 {
     bDisplayFocusCross = (displayFocusCrossCheckBox->checkState()==Qt::Checked) ? true : false;
-	if (imgData!=NULL)
-	{
-	  if (imgData->isEmpty()==false)
-	  {
-	    imgData->setFlagDisplayFocusCross(bDisplayFocusCross);
-		//printf("display cross %d\n", int(imgData->getFlagDisplayFocusCross()));
-	  }
-	}
+  if (imgData!=NULL)
+  {
+    if (imgData->isEmpty()==false)
+    {
+      imgData->setFlagDisplayFocusCross(bDisplayFocusCross);
+    //printf("display cross %d\n", int(imgData->getFlagDisplayFocusCross()));
+    }
+  }
     update();
 }
 
 void XFormWidget::toggleImgValScaleDisplay()
 {
-	if (imgData!=NULL)
-	{
-	  if (imgData->isEmpty()==false)
-	  {
-	    imgData->setFlagImgValScaleDisplay((imgValScaleDisplayCheckBox->checkState()==Qt::Checked) ? true : false);
-		//printf("display cross %d\n", int(imgData->getFlagDisplayFocusCross()));
-	  }
-	}
+  if (imgData!=NULL)
+  {
+    if (imgData->isEmpty()==false)
+    {
+      imgData->setFlagImgValScaleDisplay((imgValScaleDisplayCheckBox->checkState()==Qt::Checked) ? true : false);
+    //printf("display cross %d\n", int(imgData->getFlagDisplayFocusCross()));
+    }
+  }
 
     //use color change to force the update of 3 views
 
-	xy_view->changeColorType(Ctype);
-	yz_view->changeColorType(Ctype);
-	zx_view->changeColorType(Ctype);
+  xy_view->changeColorType(Ctype);
+  yz_view->changeColorType(Ctype);
+  zx_view->changeColorType(Ctype);
     update();
 }
 
 
 void XFormWidget::toggleLookingGlassCheckBox()
 {
-	if (imgData!=NULL)
-	{
-	  if (imgData->isEmpty()==false)
-	  {
-	    if (lookingGlassCheckBox->checkState()==Qt::Checked)
-		{
+  if (imgData!=NULL)
+  {
+    if (imgData->isEmpty()==false)
+    {
+      if (lookingGlassCheckBox->checkState()==Qt::Checked)
+    {
           xScaleSlider->setValue(4);
-		  xScaleSlider->setEnabled(false);
+      xScaleSlider->setEnabled(false);
 
           yScaleSlider->setValue(4);
-		  yScaleSlider->setEnabled(false);
+      yScaleSlider->setEnabled(false);
 
           zScaleSlider->setValue(4);
-		  zScaleSlider->setEnabled(false);
-		}
-		else
-		{
-		  xScaleSlider->setEnabled(true);
-		  yScaleSlider->setEnabled(true);
-		  zScaleSlider->setEnabled(true);
-		}
+      zScaleSlider->setEnabled(false);
+    }
+    else
+    {
+      xScaleSlider->setEnabled(true);
+      yScaleSlider->setEnabled(true);
+      zScaleSlider->setEnabled(true);
+    }
 
-	    imgData->setFlagLookingGlass((lookingGlassCheckBox->checkState()==Qt::Checked) ? true : false);
+      imgData->setFlagLookingGlass((lookingGlassCheckBox->checkState()==Qt::Checked) ? true : false);
 
-//		xy_view->changeScale(4);
-//		yz_view->changeScale(4);
-//		zx_view->changeScale(4);
-		//printf("display cross %d\n", int(imgData->getFlagDisplayFocusCross()));
-	  }
-	}
+//    xy_view->changeScale(4);
+//    yz_view->changeScale(4);
+//    zx_view->changeScale(4);
+    //printf("display cross %d\n", int(imgData->getFlagDisplayFocusCross()));
+    }
+  }
     update();
 }
 
@@ -4355,7 +4355,7 @@
   if (bSendSignalToExternal==true)
   {
     bAcceptSignalFromExternal = false;
-	cBox_bAcceptSignalFromExternal->setChecked(bAcceptSignalFromExternal);
+  cBox_bAcceptSignalFromExternal->setChecked(bAcceptSignalFromExternal);
   }
 }
 
@@ -4370,152 +4370,152 @@
   if (bAcceptSignalFromExternal==true)
   {
     bSendSignalToExternal = false;
-	cBox_bSendSignalToExternal->setChecked(bSendSignalToExternal);
+  cBox_bSendSignalToExternal->setChecked(bSendSignalToExternal);
   }
 }
 
 void XFormWidget::setColorRedType()
 {
     Ctype = colorRedOnly;
-	xy_view->changeColorType(Ctype);
-	yz_view->changeColorType(Ctype);
-	zx_view->changeColorType(Ctype);
+  xy_view->changeColorType(Ctype);
+  yz_view->changeColorType(Ctype);
+  zx_view->changeColorType(Ctype);
     update();
 }
 
 void XFormWidget::setColorRed2GrayType()
 {
     Ctype = colorRed2Gray;
-	xy_view->changeColorType(Ctype);
-	yz_view->changeColorType(Ctype);
-	zx_view->changeColorType(Ctype);
+  xy_view->changeColorType(Ctype);
+  yz_view->changeColorType(Ctype);
+  zx_view->changeColorType(Ctype);
     update();
 }
 
 void XFormWidget::setColorGreenType()
 {
     if (!imgData)
-	  return;
+    return;
 
     if (imgData->getCDim()<2)
-	  return;
+    return;
 
     Ctype = colorGreenOnly;
-  	xy_view->changeColorType(Ctype);
-	yz_view->changeColorType(Ctype);
-	zx_view->changeColorType(Ctype);
-	update();
+    xy_view->changeColorType(Ctype);
+  yz_view->changeColorType(Ctype);
+  zx_view->changeColorType(Ctype);
+  update();
 }
 
 void XFormWidget::setColorGreen2GrayType()
 {
     if (!imgData)
-	  return;
+    return;
 
     if (imgData->getCDim()<2)
-	  return;
+    return;
 
     Ctype = colorGreen2Gray;
-	xy_view->changeColorType(Ctype);
-	yz_view->changeColorType(Ctype);
-	zx_view->changeColorType(Ctype);
+  xy_view->changeColorType(Ctype);
+  yz_view->changeColorType(Ctype);
+  zx_view->changeColorType(Ctype);
     update();
 }
 
 void XFormWidget::setColorBlueType()
 {
     if (!imgData)
-	  return;
+    return;
 
     if (imgData->getCDim()<3)
-	  return;
+    return;
 
     Ctype = colorBlueOnly;
-	xy_view->changeColorType(Ctype);
-	yz_view->changeColorType(Ctype);
-	zx_view->changeColorType(Ctype);
+  xy_view->changeColorType(Ctype);
+  yz_view->changeColorType(Ctype);
+  zx_view->changeColorType(Ctype);
     update();
 }
 
 void XFormWidget::setColorBlue2GrayType()
 {
     if (!imgData)
-	  return;
+    return;
 
     if (imgData->getCDim()<3)
-	  return;
+    return;
 
     Ctype = colorBlue2Gray;
-	xy_view->changeColorType(Ctype);
-	yz_view->changeColorType(Ctype);
-	zx_view->changeColorType(Ctype);
+  xy_view->changeColorType(Ctype);
+  yz_view->changeColorType(Ctype);
+  zx_view->changeColorType(Ctype);
     update();
 }
 
 void XFormWidget::setColorAllType()
 {
     if (!imgData)
-	  return;
+    return;
 
     int cdim = imgData->getCDim();
     if (cdim>=3)
       Ctype = colorRGB;
-	else if (cdim==2)
-	  Ctype = colorRG;
-	else
-	  Ctype = colorGray;
+  else if (cdim==2)
+    Ctype = colorRG;
+  else
+    Ctype = colorGray;
 
-	xy_view->changeColorType(Ctype);
-	yz_view->changeColorType(Ctype);
-	zx_view->changeColorType(Ctype);
+  xy_view->changeColorType(Ctype);
+  yz_view->changeColorType(Ctype);
+  zx_view->changeColorType(Ctype);
     update();
 }
 
 void XFormWidget::setColorAll2GrayType()
 {
     Ctype = colorGray;
-	xy_view->changeColorType(Ctype);
-	yz_view->changeColorType(Ctype);
-	zx_view->changeColorType(Ctype);
+  xy_view->changeColorType(Ctype);
+  yz_view->changeColorType(Ctype);
+  zx_view->changeColorType(Ctype);
     update();
 }
 
 void XFormWidget::setColorMapDispType()
 {
     Ctype = colorPseudoMaskColor;
-	xy_view->changeColorType(Ctype);
-	yz_view->changeColorType(Ctype);
-	zx_view->changeColorType(Ctype);
+  xy_view->changeColorType(Ctype);
+  yz_view->changeColorType(Ctype);
+  zx_view->changeColorType(Ctype);
     update();
 }
 
 void XFormWidget::switchMaskColormap() //080824
 {
-	if (!imgData)
-		return;
+  if (!imgData)
+    return;
 
-	if (!colorMapDispType->isChecked()) //switch color will only be valid is the colorMapDispType is on
-		return;
+  if (!colorMapDispType->isChecked()) //switch color will only be valid is the colorMapDispType is on
+    return;
 
-	int clen;  ImageDisplayColorType cc;
+  int clen;  ImageDisplayColorType cc;
 
-	imgData->getColorMapInfo(clen, cc);
+  imgData->getColorMapInfo(clen, cc);
 
-	if (cc==colorPseudoMaskColor) cc=colorHanchuanFlyBrainColor;
-	else if (cc==colorHanchuanFlyBrainColor) cc=colorArnimFlyBrainColor;
-	else if (cc==colorArnimFlyBrainColor) cc=colorPseudoMaskColor;
-	else cc=colorPseudoMaskColor;
+  if (cc==colorPseudoMaskColor) cc=colorHanchuanFlyBrainColor;
+  else if (cc==colorHanchuanFlyBrainColor) cc=colorArnimFlyBrainColor;
+  else if (cc==colorArnimFlyBrainColor) cc=colorPseudoMaskColor;
+  else cc=colorPseudoMaskColor;
 
-	imgData->switchColorMap(clen, cc);
+  imgData->switchColorMap(clen, cc);
 
-	//update
-	xy_view->changeColorType(cc);
-	yz_view->changeColorType(cc);
-	zx_view->changeColorType(cc);
+  //update
+  xy_view->changeColorType(cc);
+  yz_view->changeColorType(cc);
+  zx_view->changeColorType(cc);
 
     update();
-	//updateDataRelatedGUI(); //just make sure the image will be displayed
-	return;
+  //updateDataRelatedGUI(); //just make sure the image will be displayed
+  return;
 }
 
 
@@ -4523,22 +4523,22 @@
 void XFormWidget::reset()
 {
     if (imgData)
-	{
+  {
       if (imgData->getCDim()>=2)
-	  {
-	    Ctype = colorRGB;
+    {
+      Ctype = colorRGB;
         setColorAllType();
       }
-	  else //==1
-	  {
-	    Ctype = colorRed2Gray;
-		setColorAll2GrayType();
+    else //==1
+    {
+      Ctype = colorRed2Gray;
+    setColorAll2GrayType();
       }
-	}
+  }
 
-	if (xy_view) xy_view->reset();
-	if (yz_view) yz_view->reset();
-	if (zx_view) zx_view->reset();
+  if (xy_view) xy_view->reset();
+  if (yz_view) yz_view->reset();
+  if (zx_view) zx_view->reset();
 }
 
 
@@ -4570,27 +4570,27 @@
   if (listlen>1 && list) //otherwise the only possible window is itself
   {
     //if there is invalid flag like -1, then replace it using valid focus info
-	if (newx<=0) newx = imgData->curFocusX+1; //correction on 03/31/2006 so that the focus planes of master/slave images are the same
-	if (newy<=0) newy = imgData->curFocusY+1;
-	if (newz<=0) newz = imgData->curFocusZ+1;
+  if (newx<=0) newx = imgData->curFocusX+1; //correction on 03/31/2006 so that the focus planes of master/slave images are the same
+  if (newy<=0) newy = imgData->curFocusY+1;
+  if (newz<=0) newz = imgData->curFocusZ+1;
 
-	//broadcast signal
+  //broadcast signal
 
     for (int i=0;i<listlen;i++)
-	{
-	  if (list[i]==this) //of course no need to affect this view itself
-	    continue;
-	  else
-	  {
-	    list[i]->changeFocusFromExternal(newx, newy, newz);
-		//printf("\t%d window set new xyz %d %d %d\n", V3DLONG(list[i]), newx, newy, newz);
-	  }
-	}
+  {
+    if (list[i]==this) //of course no need to affect this view itself
+      continue;
+    else
+    {
+      list[i]->changeFocusFromExternal(newx, newy, newz);
+    //printf("\t%d window set new xyz %d %d %d\n", V3DLONG(list[i]), newx, newy, newz);
+    }
   }
+  }
 
   if (list) {delete []list; list=0;} //because list is a newly created pointer, should delete after used it
                                      //probably a better logic is to store this list somewhere temporarily, -- but need to manage the case that
-									 // some windows may be closed.
+                   // some windows may be closed.
   return;
 }
 
@@ -4601,10 +4601,10 @@
     if (x>0) //as I used -1 as invalid signal, then here I only allow valid signal to be passed
       emit external_focusXChanged(x);
 
-	if (y>0)
+  if (y>0)
       emit external_focusYChanged(y);
 
-	if (z>0)
+  if (z>0)
       emit external_focusZChanged(z);
   }
   //update();
@@ -4612,376 +4612,376 @@
 
 void XFormWidget::forceToChangeFocus(int x, int y, int z) //this is called by other controller
 {
-	{
-		if (x>0) //as I used -1 as invalid signal, then here I only allow valid signal to be passed
-			emit external_focusXChanged(x);
+  {
+    if (x>0) //as I used -1 as invalid signal, then here I only allow valid signal to be passed
+      emit external_focusXChanged(x);
 
-		if (y>0)
-			emit external_focusYChanged(y);
+    if (y>0)
+      emit external_focusYChanged(y);
 
-		if (z>0)
-			emit external_focusZChanged(z);
-	}
-	//update();
+    if (z>0)
+      emit external_focusZChanged(z);
+  }
+  //update();
 }
 
 
 My4DImage * XFormWidget::selectSubjectImage()
 {
-	if (!p_mainWindow)
-		return 0;
+  if (!p_mainWindow)
+    return 0;
 
-	int listlen;
-	XFormWidget **list = p_mainWindow->retrieveAllMdiChild(listlen);
-	if (listlen<=1)
-		return 0;
+  int listlen;
+  XFormWidget **list = p_mainWindow->retrieveAllMdiChild(listlen);
+  if (listlen<=1)
+    return 0;
 
-	int i,k; int * indTable = new int [listlen];
-	if (!indTable)
-	{
-		printf("Fail to allocate memory for index table in selectSubjectImage();\n");
-		return 0;
-	}
+  int i,k; int * indTable = new int [listlen];
+  if (!indTable)
+  {
+    printf("Fail to allocate memory for index table in selectSubjectImage();\n");
+    return 0;
+  }
 
-	QStringList items;
-	if (listlen>=2 && list) //otherwise the only possible window is itself
-	{
-		for (i=0, k=0;i<listlen;i++)
-		{
-			if (list[i]==this)
-			{
-				continue;
-			}
-			else
-			{
-				items << tr(list[i]->getImageData()->getFileName());
-				indTable[k++] = i;
-			}
-		}
-	}
+  QStringList items;
+  if (listlen>=2 && list) //otherwise the only possible window is itself
+  {
+    for (i=0, k=0;i<listlen;i++)
+    {
+      if (list[i]==this)
+      {
+        continue;
+      }
+      else
+      {
+        items << tr(list[i]->getImageData()->getFileName());
+        indTable[k++] = i;
+      }
+    }
+  }
 
-	QString item;
-	bool ok;
-	item = QInputDialog::getItem(this, tr("Subject image list"),
-								 tr("Please select one image as the *subject* image"), items, 0, false, &ok);
+  QString item;
+  bool ok;
+  item = QInputDialog::getItem(this, tr("Subject image list"),
+                 tr("Please select one image as the *subject* image"), items, 0, false, &ok);
 
-	int iSelected=-1;
-	for (k=0;k<listlen;k++)
-	{
-		if (item==items.at(k))
-		{
-			iSelected=indTable[k];
-			break;
-		}
-	}
+  int iSelected=-1;
+  for (k=0;k<listlen;k++)
+  {
+    if (item==items.at(k))
+    {
+      iSelected=indTable[k];
+      break;
+    }
+  }
 
-	if (iSelected<0) return 0;
+  if (iSelected<0) return 0;
 
-	My4DImage * pSelected = list[iSelected]->getImageData();
-	if (indTable) {delete []indTable; indTable=0;}
-	if (list) {delete []list; list=0;}
-	return pSelected;
+  My4DImage * pSelected = list[iSelected]->getImageData();
+  if (indTable) {delete []indTable; indTable=0;}
+  if (list) {delete []list; list=0;}
+  return pSelected;
 }
 
 My4DImage * XFormWidget::selectImage()
 {
-	if (!p_mainWindow)
-		return 0;
+  if (!p_mainWindow)
+    return 0;
 
-	int listlen;
-	XFormWidget **list = p_mainWindow->retrieveAllMdiChild(listlen);
-	if (listlen<=1)
-		return 0;
+  int listlen;
+  XFormWidget **list = p_mainWindow->retrieveAllMdiChild(listlen);
+  if (listlen<=1)
+    return 0;
 
-	int i,k; int * indTable = new int [listlen];
-	if (!indTable)
-	{
-		printf("Fail to allocate memory for index table in selectSubjectImage();\n");
-		return 0;
-	}
+  int i,k; int * indTable = new int [listlen];
+  if (!indTable)
+  {
+    printf("Fail to allocate memory for index table in selectSubjectImage();\n");
+    return 0;
+  }
 
-	QStringList items;
-	if (listlen>=1 && list) //otherwise the only possible window is itself
-	{
-		for (i=0, k=0;i<listlen;i++)
-		{
-			items << tr(list[i]->getImageData()->getFileName());
-			indTable[k++] = i;
-		}
-	}
+  QStringList items;
+  if (listlen>=1 && list) //otherwise the only possible window is itself
+  {
+    for (i=0, k=0;i<listlen;i++)
+    {
+      items << tr(list[i]->getImageData()->getFileName());
+      indTable[k++] = i;
+    }
+  }
 
-	QString item;
-	bool ok;
-	item = QInputDialog::getItem(this, tr("image list"),
-								 tr("Please select one image for processing"), items, 0, false, &ok);
+  QString item;
+  bool ok;
+  item = QInputDialog::getItem(this, tr("image list"),
+                 tr("Please select one image for processing"), items, 0, false, &ok);
 
-	int iSelected=-1;
-	for (k=0;k<listlen;k++)
-	{
-		if (item==items.at(k))
-		{
-			iSelected=indTable[k];
-			break;
-		}
-	}
+  int iSelected=-1;
+  for (k=0;k<listlen;k++)
+  {
+    if (item==items.at(k))
+    {
+      iSelected=indTable[k];
+      break;
+    }
+  }
 
-	if (iSelected<0) return 0;
+  if (iSelected<0) return 0;
 
-	My4DImage * pSelected = list[iSelected]->getImageData();
-	if (indTable) {delete []indTable; indTable=0;}
-	if (list) {delete []list; list=0;}
-	return pSelected;
+  My4DImage * pSelected = list[iSelected]->getImageData();
+  if (indTable) {delete []indTable; indTable=0;}
+  if (list) {delete []list; list=0;}
+  return pSelected;
 }
 
 V3DLONG XFormWidget::estimateRoughAmountUsedMemory()
 {
-	if (!p_mainWindow)
-		return 0;
+  if (!p_mainWindow)
+    return 0;
 
-	int listlen;
-	XFormWidget **list = p_mainWindow->retrieveAllMdiChild(listlen);
-	if (listlen<=1)
-		return 0;
+  int listlen;
+  XFormWidget **list = p_mainWindow->retrieveAllMdiChild(listlen);
+  if (listlen<=1)
+    return 0;
 
-	int i;
+  int i;
 
-	V3DLONG nbytes=0;
-	if (listlen>=1 && list) //otherwise the only possible window is itself
-	{
-		for (i=0;i<listlen;i++)
-		{
-			nbytes += list[i]->getImageData()->getTotalBytes();
-		}
-	}
+  V3DLONG nbytes=0;
+  if (listlen>=1 && list) //otherwise the only possible window is itself
+  {
+    for (i=0;i<listlen;i++)
+    {
+      nbytes += list[i]->getImageData()->getTotalBytes();
+    }
+  }
 
-	printf("=== You have used [%ld] bytes. If you are using 32-bit system, you may only use maximum 2G bytes. === \n", nbytes);
+  printf("=== You have used [%ld] bytes. If you are using 32-bit system, you may only use maximum 2G bytes. === \n", nbytes);
 
-	if (list) {delete []list; list=0;}
-	return nbytes;
+  if (list) {delete []list; list=0;}
+  return nbytes;
 }
 
 
 QList <BlendingImageInfo> XFormWidget::selectBlendingImages()
 {
-	QList <BlendingImageInfo> bList;
-	BlendingImageInfo curInfo;
-	My4DImage * tmp_pimg;
+  QList <BlendingImageInfo> bList;
+  BlendingImageInfo curInfo;
+  My4DImage * tmp_pimg;
 
-	if (!p_mainWindow)
-		return bList;
+  if (!p_mainWindow)
+    return bList;
 
-	//get the image list
-	int listlen;
-	XFormWidget **list = p_mainWindow->retrieveAllMdiChild(listlen);
-	if (listlen<=0) return bList; //allow blending even there is only one image, because this blending func can be used to change its coloring scheme
+  //get the image list
+  int listlen;
+  XFormWidget **list = p_mainWindow->retrieveAllMdiChild(listlen);
+  if (listlen<=0) return bList; //allow blending even there is only one image, because this blending func can be used to change its coloring scheme
 
-	int i,k; int * indTable = new int [listlen];
-	if (!indTable)
-	{
-		printf("Fail to allocate memory for index table in selectBlendingImages();\n");
-		return bList;
-	}
+  int i,k; int * indTable = new int [listlen];
+  if (!indTable)
+  {
+    printf("Fail to allocate memory for index table in selectBlendingImages();\n");
+    return bList;
+  }
 
-	QStringList items;
-	for (i=0, k=0;i<listlen;i++)
-	{
-		items << tr(list[i]->getImageData()->getFileName());
-		indTable[k++] = i;
-	}
+  QStringList items;
+  for (i=0, k=0;i<listlen;i++)
+  {
+    items << tr(list[i]->getImageData()->getFileName());
+    indTable[k++] = i;
+  }
 
-	int BLEND_MAXVAL=511;
-	int nBlend=0; V3DLONG sz0_first, sz1_first, sz2_first;
-	do
-	{
-		//first select an image
-		QString item;
-		bool ok;
-		item = QInputDialog::getItem(this, tr("image list"), tr("Please select one image to blend"), items, 0, false, &ok);
+  int BLEND_MAXVAL=511;
+  int nBlend=0; V3DLONG sz0_first, sz1_first, sz2_first;
+  do
+  {
+    //first select an image
+    QString item;
+    bool ok;
+    item = QInputDialog::getItem(this, tr("image list"), tr("Please select one image to blend"), items, 0, false, &ok);
 
-		int iSelected=-1;
-		for (k=0;k<listlen;k++)
-		{
-			if (item==items.at(k))
-			{
-				iSelected=indTable[k];
-				break;
-			}
-		}
-		if (iSelected<0)
-		{
-			printf("Should never see this in selectBlendingImages(). Check codes.\n");
-			break;
-		}
+    int iSelected=-1;
+    for (k=0;k<listlen;k++)
+    {
+      if (item==items.at(k))
+      {
+        iSelected=indTable[k];
+        break;
+      }
+    }
+    if (iSelected<0)
+    {
+      printf("Should never see this in selectBlendingImages(). Check codes.\n");
+      break;
+    }
 
-		tmp_pimg = list[iSelected]->getImageData();
-		if (nBlend==0)
-		{
-			sz0_first = tmp_pimg->getXDim(); sz1_first = tmp_pimg->getYDim(); sz2_first = tmp_pimg->getZDim();
-			curInfo.pimg = tmp_pimg;
+    tmp_pimg = list[iSelected]->getImageData();
+    if (nBlend==0)
+    {
+      sz0_first = tmp_pimg->getXDim(); sz1_first = tmp_pimg->getYDim(); sz2_first = tmp_pimg->getZDim();
+      curInfo.pimg = tmp_pimg;
 
-			//then select the channel of this image
-			curInfo.channo = QInputDialog::getInteger(this, tr("channel"), tr("Please select one channel of the last image to blend"), 2, 1, curInfo.pimg->getCDim(), 1, &ok) - 1;
+      //then select the channel of this image
+      curInfo.channo = QInputDialog::getInteger(this, tr("channel"), tr("Please select one channel of the last image to blend"), 2, 1, curInfo.pimg->getCDim(), 1, &ok) - 1;
 
-			//then select RGB info
-			int rgbVal;
-			rgbVal = QInputDialog::getInteger(this, tr("Red component"), tr("Red component"), 0, 0, BLEND_MAXVAL, 50, &ok); //set to 511 instead of 255 so that intensity can be increased as well
-			curInfo.rr = rgbVal/255.0;
-			rgbVal = QInputDialog::getInteger(this, tr("Green component"), tr("Green component"), 0, 0, BLEND_MAXVAL, 50, &ok);
-			curInfo.gg = rgbVal/255.0;
-			rgbVal = QInputDialog::getInteger(this, tr("Blue component"), tr("Blue component"), 0, 0, BLEND_MAXVAL, 50, &ok);
-			curInfo.bb = rgbVal/255.0;
+      //then select RGB info
+      int rgbVal;
+      rgbVal = QInputDialog::getInteger(this, tr("Red component"), tr("Red component"), 0, 0, BLEND_MAXVAL, 50, &ok); //set to 511 instead of 255 so that intensity can be increased as well
+      curInfo.rr = rgbVal/255.0;
+      rgbVal = QInputDialog::getInteger(this, tr("Green component"), tr("Green component"), 0, 0, BLEND_MAXVAL, 50, &ok);
+      curInfo.gg = rgbVal/255.0;
+      rgbVal = QInputDialog::getInteger(this, tr("Blue component"), tr("Blue component"), 0, 0, BLEND_MAXVAL, 50, &ok);
+      curInfo.bb = rgbVal/255.0;
 
-			//add the selected info to the bList
-			bList.append(curInfo);
+      //add the selected info to the bList
+      bList.append(curInfo);
 
-			//check if want to select more images
-			if(QMessageBox::No == QMessageBox::question (0, "Continue?", "Continue select another image/channel for blending?", QMessageBox::Yes, QMessageBox::No))
-				break;
-		}
-		else
-		{
-			if (sz0_first == tmp_pimg->getXDim() && sz1_first == tmp_pimg->getYDim() && sz2_first == tmp_pimg->getZDim())
-			{
-				curInfo.pimg = tmp_pimg;
+      //check if want to select more images
+      if(QMessageBox::No == QMessageBox::question (0, "Continue?", "Continue select another image/channel for blending?", QMessageBox::Yes, QMessageBox::No))
+        break;
+    }
+    else
+    {
+      if (sz0_first == tmp_pimg->getXDim() && sz1_first == tmp_pimg->getYDim() && sz2_first == tmp_pimg->getZDim())
+      {
+        curInfo.pimg = tmp_pimg;
 
-				//then select the channel of this image
-				curInfo.channo = QInputDialog::getInteger(this, tr("channel"), tr("Please select one channel of the last image to blend"), 2, 1, curInfo.pimg->getCDim(), 1, &ok) - 1;
+        //then select the channel of this image
+        curInfo.channo = QInputDialog::getInteger(this, tr("channel"), tr("Please select one channel of the last image to blend"), 2, 1, curInfo.pimg->getCDim(), 1, &ok) - 1;
 
-				//then select RGB info
-				int rgbVal;
-				rgbVal = QInputDialog::getInteger(this, tr("Red component"), tr("Red component"), 0, 0, BLEND_MAXVAL, 50, &ok);
-				curInfo.rr = rgbVal/255.0;
-				rgbVal = QInputDialog::getInteger(this, tr("Green component"), tr("Green component"), 0, 0, BLEND_MAXVAL, 50, &ok);
-				curInfo.gg = rgbVal/255.0;
-				rgbVal = QInputDialog::getInteger(this, tr("Blue component"), tr("Blue component"), 0, 0, BLEND_MAXVAL, 50, &ok);
-				curInfo.bb = rgbVal/255.0;
+        //then select RGB info
+        int rgbVal;
+        rgbVal = QInputDialog::getInteger(this, tr("Red component"), tr("Red component"), 0, 0, BLEND_MAXVAL, 50, &ok);
+        curInfo.rr = rgbVal/255.0;
+        rgbVal = QInputDialog::getInteger(this, tr("Green component"), tr("Green component"), 0, 0, BLEND_MAXVAL, 50, &ok);
+        curInfo.gg = rgbVal/255.0;
+        rgbVal = QInputDialog::getInteger(this, tr("Blue component"), tr("Blue component"), 0, 0, BLEND_MAXVAL, 50, &ok);
+        curInfo.bb = rgbVal/255.0;
 
-				//add the selected info to the bList
-				bList.append(curInfo);
+        //add the selected info to the bList
+        bList.append(curInfo);
 
-				//check if want to select more images
-				if(QMessageBox::No == QMessageBox::question (0, "Continue?", "Continue select another image/channel for blending?", QMessageBox::Yes, QMessageBox::No))
-					break;
-			}
-			else
-			{
-				if(QMessageBox::No == QMessageBox::question (0, "Continue?", "You just select an image with different dimensions (x,y,z sizes) with the first one. This one will NOT be used. Continue to select another image?", QMessageBox::Yes, QMessageBox::No))
-					break;
-			}
-		}
+        //check if want to select more images
+        if(QMessageBox::No == QMessageBox::question (0, "Continue?", "Continue select another image/channel for blending?", QMessageBox::Yes, QMessageBox::No))
+          break;
+      }
+      else
+      {
+        if(QMessageBox::No == QMessageBox::question (0, "Continue?", "You just select an image with different dimensions (x,y,z sizes) with the first one. This one will NOT be used. Continue to select another image?", QMessageBox::Yes, QMessageBox::No))
+          break;
+      }
+    }
 
-		nBlend++;
-	} while (1);
+    nBlend++;
+  } while (1);
 
-	if (indTable) {delete []indTable; indTable=0;}
-	if (list) {delete []list; list=0;}
+  if (indTable) {delete []indTable; indTable=0;}
+  if (list) {delete []list; list=0;}
 
-	return bList;
+  return bList;
 }
 
 void XFormWidget::copyLandmarkToPublicBuffer() //080107
 {
-	if (imgData && imgData->listLandmarks.count()>0)
-	{
-		p_mainWindow->buffer_landmark_pts.erase(p_mainWindow->buffer_landmark_pts.begin(), p_mainWindow->buffer_landmark_pts.end());
-		for (int i=0;i<imgData->listLandmarks.count(); i++)
-		{
-			p_mainWindow->buffer_landmark_pts.append(imgData->listLandmarks.at(i));
-		}
-	}
+  if (imgData && imgData->listLandmarks.count()>0)
+  {
+    p_mainWindow->buffer_landmark_pts.erase(p_mainWindow->buffer_landmark_pts.begin(), p_mainWindow->buffer_landmark_pts.end());
+    for (int i=0;i<imgData->listLandmarks.count(); i++)
+    {
+      p_mainWindow->buffer_landmark_pts.append(imgData->listLandmarks.at(i));
+    }
+  }
 }
 
 void XFormWidget::pasteLandmarkFromPublicBuffer() //080107
 {
-	if (imgData && p_mainWindow->buffer_landmark_pts.count()>0)
-	{
-		//imgData->listLandmarks.erase(imgData->listLandmarks.begin(), imgData->listLandmarks.end());
-		imgData->listLandmarks.clear();
-		for (int i=0;i<p_mainWindow->buffer_landmark_pts.count(); i++)
-		{
-			imgData->listLandmarks.append(p_mainWindow->buffer_landmark_pts.at(i));
-		}
+  if (imgData && p_mainWindow->buffer_landmark_pts.count()>0)
+  {
+    //imgData->listLandmarks.erase(imgData->listLandmarks.begin(), imgData->listLandmarks.end());
+    imgData->listLandmarks.clear();
+    for (int i=0;i<p_mainWindow->buffer_landmark_pts.count(); i++)
+    {
+      imgData->listLandmarks.append(p_mainWindow->buffer_landmark_pts.at(i));
+    }
 
-		//update the related views
-		imgData->updateViews();
-	}
+    //update the related views
+    imgData->updateViews();
+  }
 }
 
 void XFormWidget::saveLandmarkToFile() //080107, 080111
 {
-	if (!imgData || imgData->listLandmarks.count()<=0)
-	{
-		v3d_msg("You don't have any landmark defined yet. Do nothing.");
-		return;
-	}
+  if (!imgData || imgData->listLandmarks.count()<=0)
+  {
+    v3d_msg("You don't have any landmark defined yet. Do nothing.");
+    return;
+  }
 
-	imgData->saveLandmarkToFile();
+  imgData->saveLandmarkToFile();
 }
 
 void XFormWidget::loadLandmarkFromFile() //080107
 {
-	if (!imgData)
-	{
-		v3d_msg("You don't have the image data ready, - thus unable to import landmark. Do nothing.");
-		return;
-	}
+  if (!imgData)
+  {
+    v3d_msg("You don't have the image data ready, - thus unable to import landmark. Do nothing.");
+    return;
+  }
 
-	imgData->loadLandmarkFromFile();
+  imgData->loadLandmarkFromFile();
 
-	//update the related views
-	imgData->updateViews();
+  //update the related views
+  imgData->updateViews();
 }
 
-void XFormWidget::openLandmarkManager() 
+void XFormWidget::openLandmarkManager()
 {
-	if (!imgData)
-	{
-		v3d_msg("You don't have the image data yet. Do nothing.");
-		return;
-	}
-	
-	launchAtlasViewer(1);
-	
-	//update the related views
-	imgData->updateViews();
+  if (!imgData)
+  {
+    v3d_msg("You don't have the image data yet. Do nothing.");
+    return;
+  }
+
+  launchAtlasViewer(1);
+
+  //update the related views
+  imgData->updateViews();
 }
 
 
 void XFormWidget::launchAtlasViewer(int curTab)
 {
-	if (atlasViewerDlg)
-	{
-		atlasViewerDlg->reCreateTables(this);
-		atlasViewerDlg->show();
-	}
-	else
-	{
-		atlasViewerDlg = new V3D_atlas_viewerDialog(this);
-		atlasViewerDlg->show();
-	}
-	atlasViewerDlg->setCurTab(curTab); // 090504 RZC
+  if (atlasViewerDlg)
+  {
+    atlasViewerDlg->reCreateTables(this);
+    atlasViewerDlg->show();
+  }
+  else
+  {
+    atlasViewerDlg = new V3D_atlas_viewerDialog(this);
+    atlasViewerDlg->show();
+  }
+  atlasViewerDlg->setCurTab(curTab); // 090504 RZC
 }
 
 void XFormWidget::createMenuOfTriviewZoom()
 {
     QAction* Act;
-	
+
     Act = new QAction(tr("Zoom &In"), this);
     connect(Act, SIGNAL(triggered()), this, SLOT(triview_zoomin()));
     menuTriviewZoom.addAction(Act);
-	
+
     Act = new QAction(tr("Zoom &Out"), this);
     connect(Act, SIGNAL(triggered()), this, SLOT(triview_zoomout()));
     menuTriviewZoom.addAction(Act);
-	
+
     Act = new QAction(tr("x&1"), this);
     connect(Act, SIGNAL(triggered()), this, SLOT(triview_zoom1()));
     menuTriviewZoom.addAction(Act);
-	
+
     Act = new QAction(tr("x&2"), this);
     connect(Act, SIGNAL(triggered()), this, SLOT(triview_zoom2()));
     menuTriviewZoom.addAction(Act);
-	
+
     Act = new QAction(tr("x&0.5"), this);
     connect(Act, SIGNAL(triggered()), this, SLOT(triview_zoomhalf()));
     menuTriviewZoom.addAction(Act);
@@ -4989,62 +4989,62 @@
 
 void XFormWidget::doMenuOfTriviewZoom()
 {
-	try 
-	{
-		menuTriviewZoom.exec(QCursor::pos());
-	}
-	catch (...)
-	{
-		v3d_msg("Fail to run the XFormWidget::doMenuOfTriviewZoom() function.\n", 0);
-	}
+  try
+  {
+    menuTriviewZoom.exec(QCursor::pos());
+  }
+  catch (...)
+  {
+    v3d_msg("Fail to run the XFormWidget::doMenuOfTriviewZoom() function.\n", 0);
+  }
 }
 
 void XFormWidget::triview_zoomin()
 {
-	triview_setzoom(2, true);
+  triview_setzoom(2, true);
 }
 void XFormWidget::triview_zoomout()
 {
-	triview_setzoom(0.5, true);
+  triview_setzoom(0.5, true);
 }
 void XFormWidget::triview_zoom1()
 {
-	triview_setzoom(1, false);
+  triview_setzoom(1, false);
 }
 void XFormWidget::triview_zoom2()
 {
-	triview_setzoom(2, false);
+  triview_setzoom(2, false);
 }
 void XFormWidget::triview_zoomhalf()
 {
-	triview_setzoom(0.5, false);
+  triview_setzoom(0.5, false);
 }
 
 void XFormWidget::triview_setzoom(double z, bool b_multiply) //b_multiply determine is z is the target zoom, or the target zoom should be product of the current zoom multply z
 {
-	if (b_multiply)
-		disp_zoom *= z;
-	else 
-		disp_zoom = z;
-	
-	b_use_dispzoom = (fabs(disp_zoom-1)>0.01) ? true : false;
-	updateDataRelatedGUI();
-	QTimer::singleShot(200, this, SLOT(cascadeWindows())); //this is very important to ensure the events propogate through. 2010-01-29
+  if (b_multiply)
+    disp_zoom *= z;
+  else
+    disp_zoom = z;
+
+  b_use_dispzoom = (fabs(disp_zoom-1)>0.01) ? true : false;
+  updateDataRelatedGUI();
+  QTimer::singleShot(200, this, SLOT(cascadeWindows())); //this is very important to ensure the events propogate through. 2010-01-29
 }
 
 void XFormWidget::cascadeWindows()
 {
-	getMainControlWindow()->cascadeWindows(); 
+  getMainControlWindow()->cascadeWindows();
 }
 
 void XFormWidget::createMenuOf3DViewer()
 {
     QAction* Act;
-	
+
     Act = new QAction(tr("Entire image"), this);
     connect(Act, SIGNAL(triggered()), this, SLOT(doImage3DView()));
     menu3DViewer.addAction(Act);
-	
+
     Act = new QAction(tr("Region of Interest"), this);
     connect(Act, SIGNAL(triggered()), this, SLOT(doImage3DLocalRoiView()));
     menu3DViewer.addAction(Act);
@@ -5052,146 +5052,146 @@
 
 void XFormWidget::doMenuOf3DViewer()
 {
-	try 
-	{
-		menu3DViewer.exec(QCursor::pos());
-	}
-	catch (...)
-	{
-		v3d_msg("Fail to run the XFormWidget::doMenuOf3DViewer() function.\n", 0);
-	}
+  try
+  {
+    menu3DViewer.exec(QCursor::pos());
+  }
+  catch (...)
+  {
+    v3d_msg("Fail to run the XFormWidget::doMenuOf3DViewer() function.\n", 0);
+  }
 }
 
 QList <LocationSimple> My4DImage::autoMarkerFromImg(V3DLONG chno, BoundingBox bbox, float zthickness)
 {
-	QList <LocationSimple> ql;
-	if (!valid() || this->getDatatype() != V3D_UINT8 || chno < 0 || chno >= getCDim() )
-	{
-		v3d_msg("Now only support UINT8 type of data. Your data is not this type, or your channel info is not correct. Do nothing.\n");
-		return ql;
-	}
-	
-	//prepare input and output data
-	
-	Vol3DSimple <unsigned char> * tmp_inimg = 0;
-	Vol3DSimple <USHORTINT16> * tmp_outimg = 0;
-	
-	V3DLONG xb,yb,zb,xe,ye,ze;
-	if (bbox.x0<bbox.x1) {xb=bbox.x0; xe=bbox.x1;} else {xb=bbox.x1; xe=bbox.x0;}
-	if (bbox.y0<bbox.y1) {yb=bbox.y0; ye=bbox.y1;} else {yb=bbox.y1; ye=bbox.y0;}
-	if (bbox.z0<bbox.z1) {zb=bbox.z0; ze=bbox.z1;} else {zb=bbox.z1; ze=bbox.z0;}
-	xb = qMin(qMax(xb,V3DLONG(0)), getXDim()-1);
-	xe = qMin(qMax(xe,V3DLONG(0)), getXDim()-1);
-	yb = qMin(qMax(yb,V3DLONG(0)), getYDim()-1);
-	ye = qMin(qMax(ye,V3DLONG(0)), getYDim()-1);
-	zb = qMin(qMax(zb,V3DLONG(0)), getZDim()-1);
-	ze = qMin(qMax(ze,V3DLONG(0)), getZDim()-1);
-	V3DLONG vsz0=xe-xb+1, vsz1=ye-yb+1, vsz2=ze-zb+1;
-	
-	try
-	{
-		tmp_inimg = new Vol3DSimple <unsigned char> (vsz0, vsz1, vsz2);
-		tmp_outimg = new Vol3DSimple <USHORTINT16> (vsz0, vsz1, vsz2);
-	}
-	catch (...)
-	{
-		v3d_msg("Unable to allocate memory for processing. Do nothing.\n");
-		if (tmp_inimg) {delete tmp_inimg; tmp_inimg=0;}
-		if (tmp_outimg) {delete tmp_outimg; tmp_outimg=0;}
-		return ql;
-	}
-	
-	//copy data
-	unsigned char *** tmp_inimg3d = tmp_inimg->getData3dHandle();
-	unsigned char *** pCur3d = ((unsigned char ****)getData())[chno /*segpara.channo*/]; //does not allow changing the channo #
-	{
-		for (V3DLONG k=zb;k<=ze;k++)
-			for (V3DLONG j=yb;j<=ye;j++)
-				for (V3DLONG i=xb;i<=xe;i++)
-					tmp_inimg3d[k-zb][j-yb][i-xb] = pCur3d[k][j][i];
-	}
-	
-	//define the template matching parameters
-	para_template_matching_cellseg segpara;
-	segpara.channo = chno;
-	segpara.szx=13;
-	segpara.szy=13;
-	segpara.szz=5; //dim
-	segpara.stdx=4.0;
-	segpara.stdy=4.0;
-	segpara.stdz=3.0; //std
-	segpara.t_pixval=150;
-	segpara.t_rgnval=20;
-	segpara.t_corrcoef=0.30; //thresholds
-	segpara.merge_radius = 20;
-	
-	//now set the two thresholds adaptively
-	double mean_val=0, std_val=0;
-	data_array_mean_and_std(tmp_inimg->getData1dHandle(), tmp_inimg->getTotalElementNumber(), mean_val, std_val);
-	segpara.t_pixval=qMax(double(150.0), mean_val+3.0*std_val);
-	segpara.t_rgnval=qMax(double(20.0), mean_val+1.0*std_val);
-	
-	//use dialog to select seg parameters
-	para_template_matching_cellseg_dialog *p_mydlg=0;
-	if (!p_mydlg) p_mydlg = new para_template_matching_cellseg_dialog(getCDim(), &segpara);
-	p_mydlg->setEnabledChannelField(false); //does not allow to change the channel no any more
-	
-	int res = p_mydlg->exec();
-	if (res!=QDialog::Accepted)
-	{
-		if (tmp_inimg) {delete tmp_inimg; tmp_inimg=0;}
-		if (tmp_outimg) {delete tmp_outimg; tmp_outimg=0;}
-		return ql;
-	}
-	else
-		p_mydlg->fetchData(&segpara);
-	if (p_mydlg) {delete p_mydlg; p_mydlg=0;}
-	
-	//do computation
-	bool b_res = template_matching_seg(tmp_inimg, tmp_outimg, segpara);
-	if (!b_res)
-	{
-		v3d_msg("Fail to do the cell segmentation().\n");
-	}
-	else
-	{
-		USHORTINT16 * tmpImg_d1d = (USHORTINT16 *)(tmp_outimg->getData1dHandle());
-		
-		//display new images
-		LocationSimple * p_ano = 0;
-		V3DLONG n_objects = 0;
-		if (!compute_statistics_objects(tmp_inimg, tmp_outimg, p_ano, n_objects))
-		{
-			v3d_msg("Some errors happen during the computation of image objects' statistics. The annotation is not generated.");
-			return ql;
-		}
-		
-		for (V3DLONG i=1;i<n_objects;i++) //do not process 0 values, as it is background. Thus starts from 1
-		{
-			p_ano[i].x += xb;
-			p_ano[i].y += yb;
-			p_ano[i].z += zb;
-			ql << p_ano[i];
-			//			fprintf(f_ano, "%ld,%ld,%s,%s,%d,%d,%d,%5.3f,%5.3f,%5.3f,%5.3f,%5.3f,,,\n",
-			//					i,i,"","", int(p_ano[i].z+0.5), int(p_ano[i].x+0.5), int(p_ano[i].y+0.5),
-			//					p_ano[i].pixmax, p_ano[i].ave, p_ano[i].sdev, p_ano[i].size, p_ano[i].mass);
-		}
-		//finally save to image and mask and linker file
-		if (p_ano) {delete []p_ano; p_ano=0;}
-	}
-	
-	//free unneeded variables
-	if (tmp_inimg) {delete tmp_inimg; tmp_inimg=0;}
-	if (tmp_outimg) {delete tmp_outimg; tmp_outimg=0;}
-	
-	return ql;
+  QList <LocationSimple> ql;
+  if (!valid() || this->getDatatype() != V3D_UINT8 || chno < 0 || chno >= getCDim() )
+  {
+    v3d_msg("Now only support UINT8 type of data. Your data is not this type, or your channel info is not correct. Do nothing.\n");
+    return ql;
+  }
+
+  //prepare input and output data
+
+  Vol3DSimple <unsigned char> * tmp_inimg = 0;
+  Vol3DSimple <uint16> * tmp_outimg = 0;
+
+  V3DLONG xb,yb,zb,xe,ye,ze;
+  if (bbox.x0<bbox.x1) {xb=bbox.x0; xe=bbox.x1;} else {xb=bbox.x1; xe=bbox.x0;}
+  if (bbox.y0<bbox.y1) {yb=bbox.y0; ye=bbox.y1;} else {yb=bbox.y1; ye=bbox.y0;}
+  if (bbox.z0<bbox.z1) {zb=bbox.z0; ze=bbox.z1;} else {zb=bbox.z1; ze=bbox.z0;}
+  xb = qMin(qMax(xb,V3DLONG(0)), getXDim()-1);
+  xe = qMin(qMax(xe,V3DLONG(0)), getXDim()-1);
+  yb = qMin(qMax(yb,V3DLONG(0)), getYDim()-1);
+  ye = qMin(qMax(ye,V3DLONG(0)), getYDim()-1);
+  zb = qMin(qMax(zb,V3DLONG(0)), getZDim()-1);
+  ze = qMin(qMax(ze,V3DLONG(0)), getZDim()-1);
+  V3DLONG vsz0=xe-xb+1, vsz1=ye-yb+1, vsz2=ze-zb+1;
+
+  try
+  {
+    tmp_inimg = new Vol3DSimple <unsigned char> (vsz0, vsz1, vsz2);
+    tmp_outimg = new Vol3DSimple <uint16> (vsz0, vsz1, vsz2);
+  }
+  catch (...)
+  {
+    v3d_msg("Unable to allocate memory for processing. Do nothing.\n");
+    if (tmp_inimg) {delete tmp_inimg; tmp_inimg=0;}
+    if (tmp_outimg) {delete tmp_outimg; tmp_outimg=0;}
+    return ql;
+  }
+
+  //copy data
+  unsigned char *** tmp_inimg3d = tmp_inimg->getData3dHandle();
+  unsigned char *** pCur3d = ((unsigned char ****)getData())[chno /*segpara.channo*/]; //does not allow changing the channo #
+  {
+    for (V3DLONG k=zb;k<=ze;k++)
+      for (V3DLONG j=yb;j<=ye;j++)
+        for (V3DLONG i=xb;i<=xe;i++)
+          tmp_inimg3d[k-zb][j-yb][i-xb] = pCur3d[k][j][i];
+  }
+
+  //define the template matching parameters
+  para_template_matching_cellseg segpara;
+  segpara.channo = chno;
+  segpara.szx=13;
+  segpara.szy=13;
+  segpara.szz=5; //dim
+  segpara.stdx=4.0;
+  segpara.stdy=4.0;
+  segpara.stdz=3.0; //std
+  segpara.t_pixval=150;
+  segpara.t_rgnval=20;
+  segpara.t_corrcoef=0.30; //thresholds
+  segpara.merge_radius = 20;
+
+  //now set the two thresholds adaptively
+  double mean_val=0, std_val=0;
+  data_array_mean_and_std(tmp_inimg->getData1dHandle(), tmp_inimg->getTotalElementNumber(), mean_val, std_val);
+  segpara.t_pixval=qMax(double(150.0), mean_val+3.0*std_val);
+  segpara.t_rgnval=qMax(double(20.0), mean_val+1.0*std_val);
+
+  //use dialog to select seg parameters
+  para_template_matching_cellseg_dialog *p_mydlg=0;
+  if (!p_mydlg) p_mydlg = new para_template_matching_cellseg_dialog(getCDim(), &segpara);
+  p_mydlg->setEnabledChannelField(false); //does not allow to change the channel no any more
+
+  int res = p_mydlg->exec();
+  if (res!=QDialog::Accepted)
+  {
+    if (tmp_inimg) {delete tmp_inimg; tmp_inimg=0;}
+    if (tmp_outimg) {delete tmp_outimg; tmp_outimg=0;}
+    return ql;
+  }
+  else
+    p_mydlg->fetchData(&segpara);
+  if (p_mydlg) {delete p_mydlg; p_mydlg=0;}
+
+  //do computation
+  bool b_res = template_matching_seg(tmp_inimg, tmp_outimg, segpara);
+  if (!b_res)
+  {
+    v3d_msg("Fail to do the cell segmentation().\n");
+  }
+  else
+  {
+    uint16 * tmpImg_d1d = (uint16 *)(tmp_outimg->getData1dHandle());
+
+    //display new images
+    LocationSimple * p_ano = 0;
+    V3DLONG n_objects = 0;
+    if (!compute_statistics_objects(tmp_inimg, tmp_outimg, p_ano, n_objects))
+    {
+      v3d_msg("Some errors happen during the computation of image objects' statistics. The annotation is not generated.");
+      return ql;
+    }
+
+    for (V3DLONG i=1;i<n_objects;i++) //do not process 0 values, as it is background. Thus starts from 1
+    {
+      p_ano[i].x += xb;
+      p_ano[i].y += yb;
+      p_ano[i].z += zb;
+      ql << p_ano[i];
+      //      fprintf(f_ano, "%ld,%ld,%s,%s,%d,%d,%d,%5.3f,%5.3f,%5.3f,%5.3f,%5.3f,,,\n",
+      //          i,i,"","", int(p_ano[i].z+0.5), int(p_ano[i].x+0.5), int(p_ano[i].y+0.5),
+      //          p_ano[i].pixmax, p_ano[i].ave, p_ano[i].sdev, p_ano[i].size, p_ano[i].mass);
+    }
+    //finally save to image and mask and linker file
+    if (p_ano) {delete []p_ano; p_ano=0;}
+  }
+
+  //free unneeded variables
+  if (tmp_inimg) {delete tmp_inimg; tmp_inimg=0;}
+  if (tmp_outimg) {delete tmp_outimg; tmp_outimg=0;}
+
+  return ql;
 }
 
 QList <LocationSimple> My4DImage::autoMarkerFromImg(V3DLONG chno)
 {
-	BoundingBox bbox(0, 0, 0, getXDim()-1, getYDim()-1, getZDim()-1);
-	float zthickness = 1.0;
-	return 	autoMarkerFromImg(chno, bbox, zthickness);
+  BoundingBox bbox(0, 0, 0, getXDim()-1, getYDim()-1, getZDim()-1);
+  float zthickness = 1.0;
+  return   autoMarkerFromImg(chno, bbox, zthickness);
 }
 
 
@@ -5202,225 +5202,225 @@
 
 LandmarkPropertyDialog::LandmarkPropertyDialog(const QList <LocationSimple> *p_anoTable, int curRowNum, My4DImage *p_imgdata=0)
 {
-	if (!p_anoTable)
-		return;
-	else
-		updateContent(p_anoTable, curRowNum, p_imgdata);
+  if (!p_anoTable)
+    return;
+  else
+    updateContent(p_anoTable, curRowNum, p_imgdata);
 }
 
 void LandmarkPropertyDialog::updateContent(const QList <LocationSimple> *p_anoTable, int curRowNum, My4DImage *p_imgdata=0)
 {
-	if (!p_anoTable)
-	{
-		printf("anoTable is not valid in LandmarkPropertyDialog::fetchData().\n");
-		return;
-	}
-	
-	if (curRowNum>=p_anoTable->count())
-	{
-		printf("The index [=%d] is bigger than the size of the list [=%d].\n", curRow, anoTable->count());
-		return;
-	}
+  if (!p_anoTable)
+  {
+    printf("anoTable is not valid in LandmarkPropertyDialog::fetchData().\n");
+    return;
+  }
 
+  if (curRowNum>=p_anoTable->count())
+  {
+    printf("The index [=%d] is bigger than the size of the list [=%d].\n", curRow, anoTable->count());
+    return;
+  }
 
-	imgdata = p_imgdata;
-	anoTable = (QList <LocationSimple> *)p_anoTable;
-	curRow = curRowNum;
-	create();
-	
-	QString tmp;
-	
-	const LocationSimple *p_landmark = &(anoTable->at(curRow));
-	
-	//landmark name/comments/annoattions
-	
-	if (curRow==0 && anoTable->size()==1)
-		order->setText(tmp.setNum(curRow+1).prepend("No.") + " or new landmark"); //curRow
-	else
-		order->setText(tmp.setNum(curRow+1)); //curRow
-		
-	name->setText(p_landmark->name.c_str());
-	comment->setText(p_landmark->comments.c_str());
-	
-	//landmark geometry
-	
-	coord_z->setText(tmp.setNum(int(p_landmark->z)));
-	coord_x->setText(tmp.setNum(int(p_landmark->x)));
-	coord_y->setText(tmp.setNum(int(p_landmark->y)));
-	radius->setText(tmp.setNum(int(p_landmark->radius)));
-	
-	if (int(p_landmark->shape)>=landmark_shape->count())
-	{
-		qDebug("Warning: your landmark shape type is not compatible with the combobox list. Unset it.\n");
-		landmark_shape->setCurrentIndex(0); //the first one is call "unset" 
-	}
-	else
-		landmark_shape->setCurrentIndex(int(p_landmark->shape)); 
-	
-	
-	//pixel intensity
-	
-	if (imgdata)
-	{	
-		int nc = imgdata->getCDim();
-		pix_val_red->setText(tmp.setNum(int(imgdata->at(int(p_landmark->x-1), int(p_landmark->y-1), int(p_landmark->z-1), 0))));
-		if (nc>=2) 
-			pix_val_green->setText(tmp.setNum(int(imgdata->at(int(p_landmark->x-1), int(p_landmark->y-1), int(p_landmark->z-1), 1))));
-		else
-			pix_val_green->setText(tmp.setNum(0));
-		if (nc>=3) 
-			pix_val_blue->setText(tmp.setNum(int(imgdata->at(int(p_landmark->x-1), int(p_landmark->y-1), int(p_landmark->z-1), 2))));
-		else
-			pix_val_blue->setText(tmp.setNum(0));
-		if (nc>=4) 
-			pix_val_ch4->setText(tmp.setNum(int(imgdata->at(int(p_landmark->x-1), int(p_landmark->y-1), int(p_landmark->z-1), 3))));
-		else
-			pix_val_ch4->setText(tmp.setNum(0));
-		if (nc>=5) 
-			pix_val_ch5->setText(tmp.setNum(int(imgdata->at(int(p_landmark->x-1), int(p_landmark->y-1), int(p_landmark->z-1), 4))));
-		else
-			pix_val_ch5->setText(tmp.setNum(0));
-		
-		//landmark surrounding area statistics
 
-		statistics_channel->setRange(1, nc);
-		//compute the stat of surrounding rgn
-		
-		int tmp_vv =int(imgdata->at(int(p_landmark->x-1), int(p_landmark->y-1), int(p_landmark->z-1), 0));
-		
-		val_peak->setText(tmp.setNum(tmp_vv));
-		val_mean->setText(tmp.setNum(tmp_vv));
-		val_stddev->setText(tmp.setNum(0));
-		val_size->setText(tmp.setNum(1));
-		val_mass->setText(tmp.setNum(tmp_vv));
-		
-		//now do computation
-		compute_rgn_stat();
-	}
-	else
-	{
-		pix_val_red->setText("Unset");
-		pix_val_green->setText("Unset");
-		pix_val_blue->setText("Unset");
-		pix_val_ch4->setText("Unset");
-		pix_val_ch5->setText("Unset");
-		
-		//landmark surrounding area statistics
-		
-		statistics_channel->setRange(0, 0);
-		//compute the stat of surrounding rgn
-		val_peak->setText("Unset");
-		val_mean->setText("Unset");
-		val_stddev->setText("Unset");
-		val_size->setText("Unset");
-		val_mass->setText("Unset");
-	}
+  imgdata = p_imgdata;
+  anoTable = (QList <LocationSimple> *)p_anoTable;
+  curRow = curRowNum;
+  create();
 
-	//set read/write property
-	
-	order->setReadOnly(true);
-	coord_z->setReadOnly(true);
-	coord_x->setReadOnly(true);
-	coord_y->setReadOnly(true);
-	pix_val_red->setReadOnly(true);
-	pix_val_green->setReadOnly(true);
-	pix_val_blue->setReadOnly(true);
-	pix_val_ch4->setReadOnly(true);
-	pix_val_ch5->setReadOnly(true);
-	val_peak->setReadOnly(true);
-	val_mean->setReadOnly(true);
-	val_stddev->setReadOnly(true);
-	val_size->setReadOnly(true);
-	val_mass->setReadOnly(true);
+  QString tmp;
+
+  const LocationSimple *p_landmark = &(anoTable->at(curRow));
+
+  //landmark name/comments/annoattions
+
+  if (curRow==0 && anoTable->size()==1)
+    order->setText(tmp.setNum(curRow+1).prepend("No.") + " or new landmark"); //curRow
+  else
+    order->setText(tmp.setNum(curRow+1)); //curRow
+
+  name->setText(p_landmark->name.c_str());
+  comment->setText(p_landmark->comments.c_str());
+
+  //landmark geometry
+
+  coord_z->setText(tmp.setNum(int(p_landmark->z)));
+  coord_x->setText(tmp.setNum(int(p_landmark->x)));
+  coord_y->setText(tmp.setNum(int(p_landmark->y)));
+  radius->setText(tmp.setNum(int(p_landmark->radius)));
+
+  if (int(p_landmark->shape)>=landmark_shape->count())
+  {
+    qDebug("Warning: your landmark shape type is not compatible with the combobox list. Unset it.\n");
+    landmark_shape->setCurrentIndex(0); //the first one is call "unset"
+  }
+  else
+    landmark_shape->setCurrentIndex(int(p_landmark->shape));
+
+
+  //pixel intensity
+
+  if (imgdata)
+  {
+    int nc = imgdata->getCDim();
+    pix_val_red->setText(tmp.setNum(int(imgdata->at(int(p_landmark->x-1), int(p_landmark->y-1), int(p_landmark->z-1), 0))));
+    if (nc>=2)
+      pix_val_green->setText(tmp.setNum(int(imgdata->at(int(p_landmark->x-1), int(p_landmark->y-1), int(p_landmark->z-1), 1))));
+    else
+      pix_val_green->setText(tmp.setNum(0));
+    if (nc>=3)
+      pix_val_blue->setText(tmp.setNum(int(imgdata->at(int(p_landmark->x-1), int(p_landmark->y-1), int(p_landmark->z-1), 2))));
+    else
+      pix_val_blue->setText(tmp.setNum(0));
+    if (nc>=4)
+      pix_val_ch4->setText(tmp.setNum(int(imgdata->at(int(p_landmark->x-1), int(p_landmark->y-1), int(p_landmark->z-1), 3))));
+    else
+      pix_val_ch4->setText(tmp.setNum(0));
+    if (nc>=5)
+      pix_val_ch5->setText(tmp.setNum(int(imgdata->at(int(p_landmark->x-1), int(p_landmark->y-1), int(p_landmark->z-1), 4))));
+    else
+      pix_val_ch5->setText(tmp.setNum(0));
+
+    //landmark surrounding area statistics
+
+    statistics_channel->setRange(1, nc);
+    //compute the stat of surrounding rgn
+
+    int tmp_vv =int(imgdata->at(int(p_landmark->x-1), int(p_landmark->y-1), int(p_landmark->z-1), 0));
+
+    val_peak->setText(tmp.setNum(tmp_vv));
+    val_mean->setText(tmp.setNum(tmp_vv));
+    val_stddev->setText(tmp.setNum(0));
+    val_size->setText(tmp.setNum(1));
+    val_mass->setText(tmp.setNum(tmp_vv));
+
+    //now do computation
+    compute_rgn_stat();
+  }
+  else
+  {
+    pix_val_red->setText("Unset");
+    pix_val_green->setText("Unset");
+    pix_val_blue->setText("Unset");
+    pix_val_ch4->setText("Unset");
+    pix_val_ch5->setText("Unset");
+
+    //landmark surrounding area statistics
+
+    statistics_channel->setRange(0, 0);
+    //compute the stat of surrounding rgn
+    val_peak->setText("Unset");
+    val_mean->setText("Unset");
+    val_stddev->setText("Unset");
+    val_size->setText("Unset");
+    val_mass->setText("Unset");
+  }
+
+  //set read/write property
+
+  order->setReadOnly(true);
+  coord_z->setReadOnly(true);
+  coord_x->setReadOnly(true);
+  coord_y->setReadOnly(true);
+  pix_val_red->setReadOnly(true);
+  pix_val_green->setReadOnly(true);
+  pix_val_blue->setReadOnly(true);
+  pix_val_ch4->setReadOnly(true);
+  pix_val_ch5->setReadOnly(true);
+  val_peak->setReadOnly(true);
+  val_mean->setReadOnly(true);
+  val_stddev->setReadOnly(true);
+  val_size->setReadOnly(true);
+  val_mass->setReadOnly(true);
 }
 
 void LandmarkPropertyDialog::fetchData(QList <LocationSimple>  *anoTable, int curRow)
 {
-	if (!anoTable)
-	{
-		printf("anoTable is not valid in LandmarkPropertyDialog::fetchData().\n");
-		return;
-	}
+  if (!anoTable)
+  {
+    printf("anoTable is not valid in LandmarkPropertyDialog::fetchData().\n");
+    return;
+  }
 
-	if (curRow>=anoTable->count())
-	{
-		printf("The index [=%d] is bigger than the size of the list [=%d].\n", curRow, anoTable->count());
-		return;
-	}
-	
-	LocationSimple *p_landmark = (LocationSimple *) &(anoTable->at(curRow));
-	
-	//landmark name/comments/annoattions
-	
-	//order->setText(tmp.setNum(curRow));
-	p_landmark->name = qPrintable(name->text());
-	p_landmark->comments = qPrintable(comment->text());
-	
-	//landmark geometry
-	
-	p_landmark->x = coord_x->text().toDouble();
-	p_landmark->y = coord_y->text().toDouble();
-	p_landmark->z = coord_z->text().toDouble();
-	p_landmark->radius = (radius->text().toDouble()>=0)?radius->text().toDouble():0;
-	p_landmark->shape = PxLocationMarkerShape(landmark_shape->currentIndex());
+  if (curRow>=anoTable->count())
+  {
+    printf("The index [=%d] is bigger than the size of the list [=%d].\n", curRow, anoTable->count());
+    return;
+  }
+
+  LocationSimple *p_landmark = (LocationSimple *) &(anoTable->at(curRow));
+
+  //landmark name/comments/annoattions
+
+  //order->setText(tmp.setNum(curRow));
+  p_landmark->name = qPrintable(name->text());
+  p_landmark->comments = qPrintable(comment->text());
+
+  //landmark geometry
+
+  p_landmark->x = coord_x->text().toDouble();
+  p_landmark->y = coord_y->text().toDouble();
+  p_landmark->z = coord_z->text().toDouble();
+  p_landmark->radius = (radius->text().toDouble()>=0)?radius->text().toDouble():0;
+  p_landmark->shape = PxLocationMarkerShape(landmark_shape->currentIndex());
 }
 
 void LandmarkPropertyDialog::create()
 {
-	setupUi(this);
-	
-	connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
-	connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
-	
-//	radius->setInputMask(tr("999")); //only allow three degits, each is 0~9
-	connect(radius, SIGNAL(editingFinished()), this, SLOT(compute_rgn_stat()));
-	connect(landmark_shape, SIGNAL(currentIndexChanged(int)), this, SLOT(compute_rgn_stat(int)));
-	
-	connect(statistics_channel, SIGNAL(valueChanged(int)), this, SLOT(compute_rgn_stat(int)));
+  setupUi(this);
+
+  connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
+  connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+
+//  radius->setInputMask(tr("999")); //only allow three degits, each is 0~9
+  connect(radius, SIGNAL(editingFinished()), this, SLOT(compute_rgn_stat()));
+  connect(landmark_shape, SIGNAL(currentIndexChanged(int)), this, SLOT(compute_rgn_stat(int)));
+
+  connect(statistics_channel, SIGNAL(valueChanged(int)), this, SLOT(compute_rgn_stat(int)));
 }
 
 void LandmarkPropertyDialog::compute_rgn_stat(int c) //overload for convenience
 {
-	compute_rgn_stat(); 
+  compute_rgn_stat();
 }
 
 void LandmarkPropertyDialog::compute_rgn_stat()
 {
-	if (!imgdata || !imgdata->valid()) return;
-	
-	LocationSimple pt;
+  if (!imgdata || !imgdata->valid()) return;
 
-	pt.x = coord_x->text().toInt()-1;
-	pt.y = coord_y->text().toInt()-1;
-	pt.z = coord_z->text().toInt()-1;
-	V3DLONG cc = statistics_channel->value()-1; if (cc<0) cc=0; if (cc>=imgdata->getCDim()) cc=imgdata->getCDim()-1;
-	pt.radius = (radius->text().toDouble()>=0)?radius->text().toDouble():0;
-	pt.shape = PxLocationMarkerShape(landmark_shape->currentIndex());
-	
-	//now do the computation
-	if (imgdata->compute_rgn_stat(pt, cc)==true)
-	{
-		//now update the value of the respective 
-		QString tmp;
-		val_peak->setText(tmp.setNum(pt.pixmax));
-		val_mean->setText(tmp.setNum(pt.ave));
-		val_stddev->setText(tmp.setNum(pt.sdev));
-		val_size->setText(tmp.setNum(pt.size));
-		val_mass->setText(tmp.setNum(pt.mass));	
-		
-		if (pt.ev_pc1==VAL_INVALID && pt.ev_pc2==VAL_INVALID && pt.ev_pc3==VAL_INVALID)
-		{
-			val_pc1_d->setText("uncomputed");
-			val_pc2_d->setText("uncomputed");
-			val_pc3_d->setText("uncomputed");
-		}
-		else
-		{	
-			val_pc1_d->setText(tmp.setNum(sqrt(pt.ev_pc1)));
-			val_pc2_d->setText(tmp.setNum(sqrt(pt.ev_pc2)));
-			val_pc3_d->setText(tmp.setNum(sqrt(pt.ev_pc3)));
-		}
-	}
+  LocationSimple pt;
+
+  pt.x = coord_x->text().toInt()-1;
+  pt.y = coord_y->text().toInt()-1;
+  pt.z = coord_z->text().toInt()-1;
+  V3DLONG cc = statistics_channel->value()-1; if (cc<0) cc=0; if (cc>=imgdata->getCDim()) cc=imgdata->getCDim()-1;
+  pt.radius = (radius->text().toDouble()>=0)?radius->text().toDouble():0;
+  pt.shape = PxLocationMarkerShape(landmark_shape->currentIndex());
+
+  //now do the computation
+  if (imgdata->compute_rgn_stat(pt, cc)==true)
+  {
+    //now update the value of the respective
+    QString tmp;
+    val_peak->setText(tmp.setNum(pt.pixmax));
+    val_mean->setText(tmp.setNum(pt.ave));
+    val_stddev->setText(tmp.setNum(pt.sdev));
+    val_size->setText(tmp.setNum(pt.size));
+    val_mass->setText(tmp.setNum(pt.mass));
+
+    if (pt.ev_pc1==VAL_INVALID && pt.ev_pc2==VAL_INVALID && pt.ev_pc3==VAL_INVALID)
+    {
+      val_pc1_d->setText("uncomputed");
+      val_pc2_d->setText("uncomputed");
+      val_pc3_d->setText("uncomputed");
+    }
+    else
+    {
+      val_pc1_d->setText(tmp.setNum(sqrt(pt.ev_pc1)));
+      val_pc2_d->setText(tmp.setNum(sqrt(pt.ev_pc2)));
+      val_pc3_d->setText(tmp.setNum(sqrt(pt.ev_pc3)));
+    }
+  }
 }
 
 
Index: v3d_main/v3d/dialog_keypoint_features.cpp
===================================================================
--- v3d_main/v3d/dialog_keypoint_features.cpp	(revision 163)
+++ v3d_main/v3d/dialog_keypoint_features.cpp	(working copy)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c)2006-2010  Hanchuan Peng (Janelia Farm, Howard Hughes Medical Institute).  
+ * Copyright (c)2006-2010  Hanchuan Peng (Janelia Farm, Howard Hughes Medical Institute).
  * All rights reserved.
  */
 
@@ -7,7 +7,7 @@
 /************
                                             ********* LICENSE NOTICE ************
 
-This folder contains all source codes for the V3D project, which is subject to the following conditions if you want to use it. 
+This folder contains all source codes for the V3D project, which is subject to the following conditions if you want to use it.
 
 You will ***have to agree*** the following terms, *before* downloading/using/running/editing/changing any portion of codes in this package.
 
@@ -49,1068 +49,1224 @@
 
 KeypointFeaturesDialog::KeypointFeaturesDialog(const QList <ImgPixelFea> *p_anoTable, int curRowNum, My4DImage *p_imgdata=0)
 {
-	if (!p_anoTable)
-		return;
-	else
-		updateContent(p_anoTable, curRowNum, p_imgdata);
+  if (!p_anoTable)
+    return;
+  else
+    updateContent(p_anoTable, curRowNum, p_imgdata);
 }
 
 void KeypointFeaturesDialog::updateContent(const QList <ImgPixelFea> *p_anoTable, int curRowNum, My4DImage *p_imgdata=0)
 {
-	if (!p_anoTable)
-	{
-		printf("anoTable is not valid in KeypointFeaturesDialog::fetchData().\n");
-		return;
-	}
-	
-	if (curRowNum>=p_anoTable->count())
-	{
-		printf("The index [=%d] is bigger than the size of the list [=%d].\n", curRow, anoTable->count());
-		return;
-	}
+  if (!p_anoTable)
+  {
+    printf("anoTable is not valid in KeypointFeaturesDialog::fetchData().\n");
+    return;
+  }
 
+  if (curRowNum>=p_anoTable->count())
+  {
+    printf("The index [=%d] is bigger than the size of the list [=%d].\n", curRow, anoTable->count());
+    return;
+  }
 
-	imgdata = p_imgdata;
-	anoTable = (QList <ImgPixelFea> *)p_anoTable;
-	curRow = curRowNum;
-	create();
-	
-	QString tmp;
-	
-	const ImgPixelFea *p_keypoint = &(anoTable->at(curRow));
-	
-	//landmark name/comments/annoattions
-	if (curRow==0 && anoTable->size()==1)
-		order->setText(tmp.setNum(curRow+1).prepend("No.") + " or new keypoint"); //curRow
-	else
-		order->setText(tmp.setNum(curRow+1)); //curRow
-		
-	name->setText(p_keypoint->name.c_str());
-	comment->setText(p_keypoint->comments.c_str());
-	
-	//landmark geometry
-	coord_z->setText(tmp.setNum(int(p_keypoint->z)));
-	coord_x->setText(tmp.setNum(int(p_keypoint->x)));
-	coord_y->setText(tmp.setNum(int(p_keypoint->y)));
-	radius->setText(tmp.setNum(int(p_keypoint->radius)));
 
-	//pixel intensity
-	if (imgdata)
-	{	
-		//which channel is interest
-		int nc = imgdata->getCDim();
-		statistics_channel->setRange(1, nc);
-		
-		//normalized when value=1
-		normalized->setRange(0, 1);
-		normalized->setValue(1);
-		
-		//thresholding get the foreground region
-		V3DLONG cc = statistics_channel->value()-1; if (cc<0) cc=0; if (cc>=imgdata->getCDim()) cc=imgdata->getCDim()-1;
-		float meanVal=0, stdVal=0;
-		V3DLONG channel_bytes = imgdata->getZDim() * imgdata->getYDim() *imgdata->getZDim();
-		
-		switch ( imgdata->getDatatype() )
-		{
-			case V3D_UINT8:
+  imgdata = p_imgdata;
+  anoTable = (QList <ImgPixelFea> *)p_anoTable;
+  curRow = curRowNum;
+  create();
 
-				mean_and_std(imgdata->getRawData() + cc*channel_bytes, channel_bytes, meanVal, stdVal);
-				threshold->setText(tmp.setNum( meanVal + 1*stdVal ));
+  QString tmp;
 
-				break;
-				
-			case V3D_UINT16:
+  const ImgPixelFea *p_keypoint = &(anoTable->at(curRow));
 
-				mean_and_std(imgdata->getRawData() + cc*channel_bytes, channel_bytes, meanVal, stdVal);
-				threshold->setText(tmp.setNum( meanVal + 1*stdVal ));
-				
-				break;
-				
-			case V3D_FLOAT32:
+  //landmark name/comments/annoattions
+  if (curRow==0 && anoTable->size()==1)
+    order->setText(tmp.setNum(curRow+1).prepend("No.") + " or new keypoint"); //curRow
+  else
+    order->setText(tmp.setNum(curRow+1)); //curRow
 
-				mean_and_std(imgdata->getRawData() + cc*channel_bytes, channel_bytes, meanVal, stdVal);
-				threshold->setText(tmp.setNum( meanVal + 1*stdVal ));
-				
-				break;
-		}
-		
-		//set initial multiple resolution checkstates Qt::Checked 2
-		checkBox_ori_scale1->setCheckState(Qt::Checked);
-		checkBox_ori_scale2->setCheckState(Qt::Checked);
-		checkBox_ori_scale3->setCheckState(Qt::Checked);
-		checkBox_ori_scale4->setCheckState(Qt::Checked);
-		
-		checkBox_diff_scale1->setCheckState(Qt::Checked);
-		checkBox_diff_scale2->setCheckState(Qt::Checked);
-		checkBox_diff_scale3->setCheckState(Qt::Checked);
-		checkBox_diff_scale4->setCheckState(Qt::Checked);
-	}
-	else
-	{
-		lambda1_ori_r1->setText("Unset");
-		lambda2_ori_r1->setText("Unset");
-		lambda3_ori_r1->setText("Unset");
-		lambda1_diff_r1->setText("Unset");
-		lambda2_diff_r1->setText("Unset");
-		lambda3_diff_r1->setText("Unset");
-		
-		lambda1_ori_r2->setText("Unset");
-		lambda2_ori_r2->setText("Unset");
-		lambda3_ori_r2->setText("Unset");
-		lambda1_diff_r2->setText("Unset");
-		lambda2_diff_r2->setText("Unset");
-		lambda3_diff_r2->setText("Unset");
-		
-		lambda1_ori_r3->setText("Unset");
-		lambda2_ori_r3->setText("Unset");
-		lambda3_ori_r3->setText("Unset");
-		lambda1_diff_r3->setText("Unset");
-		lambda2_diff_r3->setText("Unset");
-		lambda3_diff_r3->setText("Unset");
-		
-		lambda1_ori_r4->setText("Unset");
-		lambda2_ori_r4->setText("Unset");
-		lambda3_ori_r4->setText("Unset");
-		lambda1_diff_r4->setText("Unset");
-		lambda2_diff_r4->setText("Unset");
-		lambda3_diff_r4->setText("Unset");
-		
-	}
+  name->setText(p_keypoint->name.c_str());
+  comment->setText(p_keypoint->comments.c_str());
 
-	//set read/write property
-	
-	order->setReadOnly(true);
-	coord_z->setReadOnly(true);
-	coord_x->setReadOnly(true);
-	coord_y->setReadOnly(true);
+  //landmark geometry
+  coord_z->setText(tmp.setNum(int(p_keypoint->z)));
+  coord_x->setText(tmp.setNum(int(p_keypoint->x)));
+  coord_y->setText(tmp.setNum(int(p_keypoint->y)));
+  radius->setText(tmp.setNum(int(p_keypoint->radius)));
 
+  //pixel intensity
+  if (imgdata)
+  {
+    //which channel is interest
+    int nc = imgdata->getCDim();
+    statistics_channel->setRange(1, nc);
+
+    //normalized when value=1
+    normalized->setRange(0, 1);
+    normalized->setValue(1);
+
+    //thresholding get the foreground region
+    V3DLONG cc = statistics_channel->value()-1; if (cc<0) cc=0; if (cc>=imgdata->getCDim()) cc=imgdata->getCDim()-1;
+    float meanVal=0, stdVal=0;
+    V3DLONG channel_bytes = imgdata->getZDim() * imgdata->getYDim() *imgdata->getZDim();
+
+    switch ( imgdata->getDatatype() )
+    {
+      case V3D_UINT8:
+
+        mean_and_std(imgdata->getRawData() + cc*channel_bytes, channel_bytes, meanVal, stdVal);
+        threshold->setText(tmp.setNum( meanVal + 1*stdVal ));
+
+        break;
+
+      case V3D_UINT16:
+
+        mean_and_std(imgdata->getRawData() + cc*channel_bytes, channel_bytes, meanVal, stdVal);
+        threshold->setText(tmp.setNum( meanVal + 1*stdVal ));
+
+        break;
+
+      case V3D_UINT32:
+
+        mean_and_std(imgdata->getRawData() + cc*channel_bytes, channel_bytes, meanVal, stdVal);
+        threshold->setText(tmp.setNum( meanVal + 1*stdVal ));
+
+        break;
+
+      case V3D_FLOAT32:
+
+        mean_and_std(imgdata->getRawData() + cc*channel_bytes, channel_bytes, meanVal, stdVal);
+        threshold->setText(tmp.setNum( meanVal + 1*stdVal ));
+
+        break;
+    }
+
+    //set initial multiple resolution checkstates Qt::Checked 2
+    checkBox_ori_scale1->setCheckState(Qt::Checked);
+    checkBox_ori_scale2->setCheckState(Qt::Checked);
+    checkBox_ori_scale3->setCheckState(Qt::Checked);
+    checkBox_ori_scale4->setCheckState(Qt::Checked);
+
+    checkBox_diff_scale1->setCheckState(Qt::Checked);
+    checkBox_diff_scale2->setCheckState(Qt::Checked);
+    checkBox_diff_scale3->setCheckState(Qt::Checked);
+    checkBox_diff_scale4->setCheckState(Qt::Checked);
+  }
+  else
+  {
+    lambda1_ori_r1->setText("Unset");
+    lambda2_ori_r1->setText("Unset");
+    lambda3_ori_r1->setText("Unset");
+    lambda1_diff_r1->setText("Unset");
+    lambda2_diff_r1->setText("Unset");
+    lambda3_diff_r1->setText("Unset");
+
+    lambda1_ori_r2->setText("Unset");
+    lambda2_ori_r2->setText("Unset");
+    lambda3_ori_r2->setText("Unset");
+    lambda1_diff_r2->setText("Unset");
+    lambda2_diff_r2->setText("Unset");
+    lambda3_diff_r2->setText("Unset");
+
+    lambda1_ori_r3->setText("Unset");
+    lambda2_ori_r3->setText("Unset");
+    lambda3_ori_r3->setText("Unset");
+    lambda1_diff_r3->setText("Unset");
+    lambda2_diff_r3->setText("Unset");
+    lambda3_diff_r3->setText("Unset");
+
+    lambda1_ori_r4->setText("Unset");
+    lambda2_ori_r4->setText("Unset");
+    lambda3_ori_r4->setText("Unset");
+    lambda1_diff_r4->setText("Unset");
+    lambda2_diff_r4->setText("Unset");
+    lambda3_diff_r4->setText("Unset");
+
+  }
+
+  //set read/write property
+
+  order->setReadOnly(true);
+  coord_z->setReadOnly(true);
+  coord_x->setReadOnly(true);
+  coord_y->setReadOnly(true);
+
 }
 
 void KeypointFeaturesDialog::fetchData(QList <ImgPixelFea>  *anoTable, int curRow)
 {
-	if (!anoTable)
-	{
-		printf("anoTable is not valid in KeypointFeaturesDialog::fetchData().\n");
-		return;
-	}
+  if (!anoTable)
+  {
+    printf("anoTable is not valid in KeypointFeaturesDialog::fetchData().\n");
+    return;
+  }
 
-	if (curRow>=anoTable->count())
-	{
-		printf("The index [=%d] is bigger than the size of the list [=%d].\n", curRow, anoTable->count());
-		return;
-	}
-	
-	ImgPixelFea *p_keypoint = (ImgPixelFea *) &(anoTable->at(curRow));
-	
-	//keypoint name/comments/annoattions
-	
-	p_keypoint->name = qPrintable(name->text());
-	p_keypoint->comments = qPrintable(comment->text());
-	
-	//keypoint geometry
-	
-	p_keypoint->x = coord_x->text().toDouble();
-	p_keypoint->y = coord_y->text().toDouble();
-	p_keypoint->z = coord_z->text().toDouble();
-	p_keypoint->radius = (radius->text().toDouble()>=0)?radius->text().toDouble():0;
+  if (curRow>=anoTable->count())
+  {
+    printf("The index [=%d] is bigger than the size of the list [=%d].\n", curRow, anoTable->count());
+    return;
+  }
 
+  ImgPixelFea *p_keypoint = (ImgPixelFea *) &(anoTable->at(curRow));
+
+  //keypoint name/comments/annoattions
+
+  p_keypoint->name = qPrintable(name->text());
+  p_keypoint->comments = qPrintable(comment->text());
+
+  //keypoint geometry
+
+  p_keypoint->x = coord_x->text().toDouble();
+  p_keypoint->y = coord_y->text().toDouble();
+  p_keypoint->z = coord_z->text().toDouble();
+  p_keypoint->radius = (radius->text().toDouble()>=0)?radius->text().toDouble():0;
+
 }
 
 void KeypointFeaturesDialog::create()
 {
-	setupUi(this);
-	
-	connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
-	connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
-	
-	connect(radius, SIGNAL(editingFinished()), this, SLOT(compute_pointfea()));
-	connect(statistics_channel, SIGNAL(valueChanged(int)), this, SLOT(compute_pointfea()));
-	connect(normalized, SIGNAL(valueChanged(int)), this, SLOT(compute_pointfea()));
+  setupUi(this);
 
-	connect(GenSimMap, SIGNAL(clicked()), this, SLOT(compute_similarmap()));
+  connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
+  connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
 
+  connect(radius, SIGNAL(editingFinished()), this, SLOT(compute_pointfea()));
+  connect(statistics_channel, SIGNAL(valueChanged(int)), this, SLOT(compute_pointfea()));
+  connect(normalized, SIGNAL(valueChanged(int)), this, SLOT(compute_pointfea()));
+
+  connect(GenSimMap, SIGNAL(clicked()), this, SLOT(compute_similarmap()));
+
 }
 
 void KeypointFeaturesDialog::compute_pointfea()
 {
-	if (!imgdata || !imgdata->valid()) return;
-	
-	QTime t;
-	t.start();
+  if (!imgdata || !imgdata->valid()) return;
 
-	pt.x = coord_x->text().toInt()-1;
-	pt.y = coord_y->text().toInt()-1;
-	pt.z = coord_z->text().toInt()-1;
-	V3DLONG cc = statistics_channel->value()-1; if (cc<0) cc=0; if (cc>=imgdata->getCDim()) cc=imgdata->getCDim()-1;
-	V3DLONG normalized_flag = normalized->value(); 
-	pt.radius = (radius->text().toDouble()>=0)?radius->text().toDouble():0;
+  QTime t;
+  t.start();
 
-	//now do the computation
+  pt.x = coord_x->text().toInt()-1;
+  pt.y = coord_y->text().toInt()-1;
+  pt.z = coord_z->text().toInt()-1;
+  V3DLONG cc = statistics_channel->value()-1; if (cc<0) cc=0; if (cc>=imgdata->getCDim()) cc=imgdata->getCDim()-1;
+  V3DLONG normalized_flag = normalized->value();
+  pt.radius = (radius->text().toDouble()>=0)?radius->text().toDouble():0;
 
-	V3DLONG xx = V3DLONG(pt.x+0.5);
-	V3DLONG yy = V3DLONG(pt.y+0.5);
-	V3DLONG zz = V3DLONG(pt.z+0.5);
-	V3DLONG rr = pt.radius; if (rr<0) rr=0;
-	
-	V3DLONG sz0 = imgdata->getXDim();
+  //now do the computation
+
+  V3DLONG xx = V3DLONG(pt.x+0.5);
+  V3DLONG yy = V3DLONG(pt.y+0.5);
+  V3DLONG zz = V3DLONG(pt.z+0.5);
+  V3DLONG rr = pt.radius; if (rr<0) rr=0;
+
+  V3DLONG sz0 = imgdata->getXDim();
   V3DLONG sz1 = imgdata->getYDim();
   V3DLONG sz2 = imgdata->getZDim();
   V3DLONG sz3 = imgdata->getCDim();
 
-	
-	pt.n = 4;
 
-	//computing	
-	pt.setPCAscore(imgdata, pt.n, rr, cc, normalized_flag);
-	
-	//display
-	QString tmp;
+  pt.n = 4;
 
-	if(pt.fpa[0].imgpca.lambda1==VAL_INVALID && pt.fpa[0].imgpca.lambda2==VAL_INVALID && pt.fpa[0].imgpca.lambda3==VAL_INVALID &&
-	   pt.fpa[1].imgpca.lambda1==VAL_INVALID && pt.fpa[1].imgpca.lambda2==VAL_INVALID && pt.fpa[1].imgpca.lambda3==VAL_INVALID &&
-	   pt.fpa[2].imgpca.lambda1==VAL_INVALID && pt.fpa[2].imgpca.lambda2==VAL_INVALID && pt.fpa[2].imgpca.lambda3==VAL_INVALID &&
-	   pt.fpa[3].imgpca.lambda1==VAL_INVALID && pt.fpa[3].imgpca.lambda2==VAL_INVALID && pt.fpa[3].imgpca.lambda3==VAL_INVALID &&
-		pt.fpa[0].diffpca.lambda1==VAL_INVALID && pt.fpa[0].diffpca.lambda2==VAL_INVALID && pt.fpa[0].diffpca.lambda3==VAL_INVALID &&
-		pt.fpa[1].diffpca.lambda1==VAL_INVALID && pt.fpa[1].diffpca.lambda2==VAL_INVALID && pt.fpa[1].diffpca.lambda3==VAL_INVALID &&
-		pt.fpa[2].diffpca.lambda1==VAL_INVALID && pt.fpa[2].diffpca.lambda2==VAL_INVALID && pt.fpa[2].diffpca.lambda3==VAL_INVALID &&
-		pt.fpa[3].diffpca.lambda1==VAL_INVALID && pt.fpa[3].diffpca.lambda2==VAL_INVALID && pt.fpa[3].diffpca.lambda3==VAL_INVALID)
-	{
-		lambda1_ori_r1->setText("uncomputed");
-		lambda2_ori_r1->setText("uncomputed");
-		lambda3_ori_r1->setText("uncomputed");
-		lambda1_diff_r1->setText("uncomputed");
-		lambda2_diff_r1->setText("uncomputed");
-		lambda3_diff_r1->setText("uncomputed");
-		
-		lambda1_ori_r2->setText("uncomputed");
-		lambda2_ori_r2->setText("uncomputed");
-		lambda3_ori_r2->setText("uncomputed");
-		lambda1_diff_r2->setText("uncomputed");
-		lambda2_diff_r2->setText("uncomputed");
-		lambda3_diff_r2->setText("uncomputed");
-		
-		lambda1_ori_r3->setText("uncomputed");
-		lambda2_ori_r3->setText("uncomputed");
-		lambda3_ori_r3->setText("uncomputed");
-		lambda1_diff_r3->setText("uncomputed");
-		lambda2_diff_r3->setText("uncomputed");
-		lambda3_diff_r3->setText("uncomputed");
-		
-		lambda1_ori_r4->setText("uncomputed");
-		lambda2_ori_r4->setText("uncomputed");
-		lambda3_ori_r4->setText("uncomputed");
-		lambda1_diff_r4->setText("uncomputed");
-		lambda2_diff_r4->setText("uncomputed");
-		lambda3_diff_r4->setText("uncomputed");
+  //computing
+  pt.setPCAscore(imgdata, pt.n, rr, cc, normalized_flag);
 
-	}
-	else
-	{	
-		lambda1_ori_r1->setText(tmp.setNum(pt.fpa[0].imgpca.lambda1));
-		lambda2_ori_r1->setText(tmp.setNum(pt.fpa[0].imgpca.lambda2));
-		lambda3_ori_r1->setText(tmp.setNum(pt.fpa[0].imgpca.lambda3));
-		lambda1_diff_r1->setText(tmp.setNum(pt.fpa[0].diffpca.lambda1));
-		lambda2_diff_r1->setText(tmp.setNum(pt.fpa[0].diffpca.lambda2));
-		lambda3_diff_r1->setText(tmp.setNum(pt.fpa[0].diffpca.lambda3));
-		
-		lambda1_ori_r2->setText(tmp.setNum(pt.fpa[1].imgpca.lambda1));
-		lambda2_ori_r2->setText(tmp.setNum(pt.fpa[1].imgpca.lambda2));
-		lambda3_ori_r2->setText(tmp.setNum(pt.fpa[1].imgpca.lambda3));
-		lambda1_diff_r2->setText(tmp.setNum(pt.fpa[1].diffpca.lambda1));
-		lambda2_diff_r2->setText(tmp.setNum(pt.fpa[1].diffpca.lambda2));
-		lambda3_diff_r2->setText(tmp.setNum(pt.fpa[1].diffpca.lambda3));
-		
-		lambda1_ori_r3->setText(tmp.setNum(pt.fpa[2].imgpca.lambda1));
-		lambda2_ori_r3->setText(tmp.setNum(pt.fpa[2].imgpca.lambda2));
-		lambda3_ori_r3->setText(tmp.setNum(pt.fpa[2].imgpca.lambda3));
-		lambda1_diff_r3->setText(tmp.setNum(pt.fpa[2].diffpca.lambda1));
-		lambda2_diff_r3->setText(tmp.setNum(pt.fpa[2].diffpca.lambda2));
-		lambda3_diff_r3->setText(tmp.setNum(pt.fpa[2].diffpca.lambda3));
-		
-		lambda1_ori_r4->setText(tmp.setNum(pt.fpa[3].imgpca.lambda1));
-		lambda2_ori_r4->setText(tmp.setNum(pt.fpa[3].imgpca.lambda2));
-		lambda3_ori_r4->setText(tmp.setNum(pt.fpa[3].imgpca.lambda3));
-		lambda1_diff_r4->setText(tmp.setNum(pt.fpa[3].diffpca.lambda1));
-		lambda2_diff_r4->setText(tmp.setNum(pt.fpa[3].diffpca.lambda2));
-		lambda3_diff_r4->setText(tmp.setNum(pt.fpa[3].diffpca.lambda3));
-		
-	}//end of display
+  //display
+  QString tmp;
 
+  if(pt.fpa[0].imgpca.lambda1==VAL_INVALID && pt.fpa[0].imgpca.lambda2==VAL_INVALID && pt.fpa[0].imgpca.lambda3==VAL_INVALID &&
+     pt.fpa[1].imgpca.lambda1==VAL_INVALID && pt.fpa[1].imgpca.lambda2==VAL_INVALID && pt.fpa[1].imgpca.lambda3==VAL_INVALID &&
+     pt.fpa[2].imgpca.lambda1==VAL_INVALID && pt.fpa[2].imgpca.lambda2==VAL_INVALID && pt.fpa[2].imgpca.lambda3==VAL_INVALID &&
+     pt.fpa[3].imgpca.lambda1==VAL_INVALID && pt.fpa[3].imgpca.lambda2==VAL_INVALID && pt.fpa[3].imgpca.lambda3==VAL_INVALID &&
+    pt.fpa[0].diffpca.lambda1==VAL_INVALID && pt.fpa[0].diffpca.lambda2==VAL_INVALID && pt.fpa[0].diffpca.lambda3==VAL_INVALID &&
+    pt.fpa[1].diffpca.lambda1==VAL_INVALID && pt.fpa[1].diffpca.lambda2==VAL_INVALID && pt.fpa[1].diffpca.lambda3==VAL_INVALID &&
+    pt.fpa[2].diffpca.lambda1==VAL_INVALID && pt.fpa[2].diffpca.lambda2==VAL_INVALID && pt.fpa[2].diffpca.lambda3==VAL_INVALID &&
+    pt.fpa[3].diffpca.lambda1==VAL_INVALID && pt.fpa[3].diffpca.lambda2==VAL_INVALID && pt.fpa[3].diffpca.lambda3==VAL_INVALID)
+  {
+    lambda1_ori_r1->setText("uncomputed");
+    lambda2_ori_r1->setText("uncomputed");
+    lambda3_ori_r1->setText("uncomputed");
+    lambda1_diff_r1->setText("uncomputed");
+    lambda2_diff_r1->setText("uncomputed");
+    lambda3_diff_r1->setText("uncomputed");
 
-	
-	//display to the screen
-	qDebug(" current marker: [%d] \nscale (in row), img_pca, imgdiff_pca (in columns):\n %lf %lf %lf %lf %lf %lf \n %lf %lf %lf %lf %lf %lf \n %lf %lf %lf %lf %lf %lf \n %lf %lf %lf %lf %lf %lf \n ",
-		   curRow,
-		    pt.fpa[0].imgpca.lambda1, pt.fpa[0].imgpca.lambda2, pt.fpa[0].imgpca.lambda3,
-		    pt.fpa[0].diffpca.lambda1, pt.fpa[0].diffpca.lambda2, pt.fpa[0].diffpca.lambda3,
-		    
-		    pt.fpa[1].imgpca.lambda1, pt.fpa[1].imgpca.lambda2, pt.fpa[1].imgpca.lambda3,
-		    pt.fpa[1].diffpca.lambda1, pt.fpa[1].diffpca.lambda2, pt.fpa[1].diffpca.lambda3,
+    lambda1_ori_r2->setText("uncomputed");
+    lambda2_ori_r2->setText("uncomputed");
+    lambda3_ori_r2->setText("uncomputed");
+    lambda1_diff_r2->setText("uncomputed");
+    lambda2_diff_r2->setText("uncomputed");
+    lambda3_diff_r2->setText("uncomputed");
 
-		    pt.fpa[2].imgpca.lambda1, pt.fpa[2].imgpca.lambda2, pt.fpa[2].imgpca.lambda3,
-		    pt.fpa[2].diffpca.lambda1, pt.fpa[2].diffpca.lambda2, pt.fpa[2].diffpca.lambda3,
+    lambda1_ori_r3->setText("uncomputed");
+    lambda2_ori_r3->setText("uncomputed");
+    lambda3_ori_r3->setText("uncomputed");
+    lambda1_diff_r3->setText("uncomputed");
+    lambda2_diff_r3->setText("uncomputed");
+    lambda3_diff_r3->setText("uncomputed");
 
-		    pt.fpa[3].imgpca.lambda1, pt.fpa[3].imgpca.lambda2, pt.fpa[3].imgpca.lambda3,
-		    pt.fpa[3].diffpca.lambda1, pt.fpa[3].diffpca.lambda2, pt.fpa[3].diffpca.lambda3);
+    lambda1_ori_r4->setText("uncomputed");
+    lambda2_ori_r4->setText("uncomputed");
+    lambda3_ori_r4->setText("uncomputed");
+    lambda1_diff_r4->setText("uncomputed");
+    lambda2_diff_r4->setText("uncomputed");
+    lambda3_diff_r4->setText("uncomputed");
 
-	//testing cost time
-	qDebug("Time elapsed: %d ms \n", t.elapsed());
+  }
+  else
+  {
+    lambda1_ori_r1->setText(tmp.setNum(pt.fpa[0].imgpca.lambda1));
+    lambda2_ori_r1->setText(tmp.setNum(pt.fpa[0].imgpca.lambda2));
+    lambda3_ori_r1->setText(tmp.setNum(pt.fpa[0].imgpca.lambda3));
+    lambda1_diff_r1->setText(tmp.setNum(pt.fpa[0].diffpca.lambda1));
+    lambda2_diff_r1->setText(tmp.setNum(pt.fpa[0].diffpca.lambda2));
+    lambda3_diff_r1->setText(tmp.setNum(pt.fpa[0].diffpca.lambda3));
+
+    lambda1_ori_r2->setText(tmp.setNum(pt.fpa[1].imgpca.lambda1));
+    lambda2_ori_r2->setText(tmp.setNum(pt.fpa[1].imgpca.lambda2));
+    lambda3_ori_r2->setText(tmp.setNum(pt.fpa[1].imgpca.lambda3));
+    lambda1_diff_r2->setText(tmp.setNum(pt.fpa[1].diffpca.lambda1));
+    lambda2_diff_r2->setText(tmp.setNum(pt.fpa[1].diffpca.lambda2));
+    lambda3_diff_r2->setText(tmp.setNum(pt.fpa[1].diffpca.lambda3));
+
+    lambda1_ori_r3->setText(tmp.setNum(pt.fpa[2].imgpca.lambda1));
+    lambda2_ori_r3->setText(tmp.setNum(pt.fpa[2].imgpca.lambda2));
+    lambda3_ori_r3->setText(tmp.setNum(pt.fpa[2].imgpca.lambda3));
+    lambda1_diff_r3->setText(tmp.setNum(pt.fpa[2].diffpca.lambda1));
+    lambda2_diff_r3->setText(tmp.setNum(pt.fpa[2].diffpca.lambda2));
+    lambda3_diff_r3->setText(tmp.setNum(pt.fpa[2].diffpca.lambda3));
+
+    lambda1_ori_r4->setText(tmp.setNum(pt.fpa[3].imgpca.lambda1));
+    lambda2_ori_r4->setText(tmp.setNum(pt.fpa[3].imgpca.lambda2));
+    lambda3_ori_r4->setText(tmp.setNum(pt.fpa[3].imgpca.lambda3));
+    lambda1_diff_r4->setText(tmp.setNum(pt.fpa[3].diffpca.lambda1));
+    lambda2_diff_r4->setText(tmp.setNum(pt.fpa[3].diffpca.lambda2));
+    lambda3_diff_r4->setText(tmp.setNum(pt.fpa[3].diffpca.lambda3));
+
+  }//end of display
+
+
+
+  //display to the screen
+  qDebug(" current marker: [%d] \nscale (in row), img_pca, imgdiff_pca (in columns):\n %lf %lf %lf %lf %lf %lf \n %lf %lf %lf %lf %lf %lf \n %lf %lf %lf %lf %lf %lf \n %lf %lf %lf %lf %lf %lf \n ",
+       curRow,
+        pt.fpa[0].imgpca.lambda1, pt.fpa[0].imgpca.lambda2, pt.fpa[0].imgpca.lambda3,
+        pt.fpa[0].diffpca.lambda1, pt.fpa[0].diffpca.lambda2, pt.fpa[0].diffpca.lambda3,
+
+        pt.fpa[1].imgpca.lambda1, pt.fpa[1].imgpca.lambda2, pt.fpa[1].imgpca.lambda3,
+        pt.fpa[1].diffpca.lambda1, pt.fpa[1].diffpca.lambda2, pt.fpa[1].diffpca.lambda3,
+
+        pt.fpa[2].imgpca.lambda1, pt.fpa[2].imgpca.lambda2, pt.fpa[2].imgpca.lambda3,
+        pt.fpa[2].diffpca.lambda1, pt.fpa[2].diffpca.lambda2, pt.fpa[2].diffpca.lambda3,
+
+        pt.fpa[3].imgpca.lambda1, pt.fpa[3].imgpca.lambda2, pt.fpa[3].imgpca.lambda3,
+        pt.fpa[3].diffpca.lambda1, pt.fpa[3].diffpca.lambda2, pt.fpa[3].diffpca.lambda3);
+
+  //testing cost time
+  qDebug("Time elapsed: %d ms \n", t.elapsed());
 }
 
 
 bool KeypointFeaturesDialog::compute_similarmap()
 {
-	if (!imgdata || !imgdata->valid()) return false;
-	
-	QTime t;
-	t.start();
-	
-	pt.x = coord_x->text().toInt()-1;
-	pt.y = coord_y->text().toInt()-1;
-	pt.z = coord_z->text().toInt()-1;
-	V3DLONG channel_no = statistics_channel->value()-1; if (channel_no<0) channel_no=0; if (channel_no>=imgdata->getCDim()) channel_no=imgdata->getCDim()-1;
-	V3DLONG normalized_flag = normalized->value(); 
-	pt.radius = (radius->text().toDouble()>=0)?radius->text().toDouble():0;
-	
-	//now do the computation
-	
-	V3DLONG xx = V3DLONG(pt.x+0.5);
-	V3DLONG yy = V3DLONG(pt.y+0.5);
-	V3DLONG zz = V3DLONG(pt.z+0.5);
-	V3DLONG rr = pt.radius; if (rr<0) rr=0;
-	
-	//reading updated current inputs
-	if(checkBox_ori_scale1->isChecked())
-	{
-		pt.fpa[0].imgpca.lambda1 = lambda1_ori_r1->text().toDouble();
-		pt.fpa[0].imgpca.lambda2 = lambda2_ori_r1->text().toDouble();
-		pt.fpa[0].imgpca.lambda3 = lambda3_ori_r1->text().toDouble();		
-	}
-	else
-	{
-		pt.fpa[0].imgpca.lambda1 = 0;
-		pt.fpa[0].imgpca.lambda2 = 0;
-		pt.fpa[0].imgpca.lambda3 = 0;		
-	}
-	
-	if(checkBox_ori_scale2->isChecked())
-	{
-		pt.fpa[1].imgpca.lambda1 = lambda1_ori_r2->text().toDouble();
-		pt.fpa[1].imgpca.lambda2 = lambda2_ori_r2->text().toDouble();
-		pt.fpa[1].imgpca.lambda3 = lambda3_ori_r2->text().toDouble();
-	}
-	else
-	{
-		pt.fpa[1].imgpca.lambda1 = 0;
-		pt.fpa[1].imgpca.lambda2 = 0;
-		pt.fpa[1].imgpca.lambda3 = 0;
-	}
-	
-	if(checkBox_ori_scale3->isChecked())
-	{
-		pt.fpa[2].imgpca.lambda1 = lambda1_ori_r3->text().toDouble();
-		pt.fpa[2].imgpca.lambda2 = lambda2_ori_r3->text().toDouble();
-		pt.fpa[2].imgpca.lambda3 = lambda3_ori_r3->text().toDouble();
-	}
-	else
-	{
-		pt.fpa[2].imgpca.lambda1 = 0;
-		pt.fpa[2].imgpca.lambda2 = 0;
-		pt.fpa[2].imgpca.lambda3 = 0;
-	}
-	
-	if(checkBox_ori_scale4->isChecked())
-	{
-		pt.fpa[3].imgpca.lambda1 = lambda1_ori_r4->text().toDouble();
-		pt.fpa[3].imgpca.lambda2 = lambda2_ori_r4->text().toDouble();
-		pt.fpa[3].imgpca.lambda3 = lambda3_ori_r4->text().toDouble();
-	}
-	else
-	{
-		pt.fpa[3].imgpca.lambda1 = 0;
-		pt.fpa[3].imgpca.lambda2 = 0;
-		pt.fpa[3].imgpca.lambda3 = 0;
-	}
-	
-	if(checkBox_diff_scale1->isChecked())
-	{
-		pt.fpa[0].diffpca.lambda1 = lambda1_diff_r1->text().toDouble();
-		pt.fpa[0].diffpca.lambda2 = lambda2_diff_r1->text().toDouble();
-		pt.fpa[0].diffpca.lambda3 = lambda3_diff_r1->text().toDouble();
-	}
-	else
-	{
-		pt.fpa[0].diffpca.lambda1 = 0;
-		pt.fpa[0].diffpca.lambda2 = 0;
-		pt.fpa[0].diffpca.lambda3 = 0;
-	}
-	
-	if(checkBox_diff_scale2->isChecked())
-	{
-		pt.fpa[1].diffpca.lambda1 = lambda1_diff_r2->text().toDouble();
-		pt.fpa[1].diffpca.lambda2 = lambda2_diff_r2->text().toDouble();
-		pt.fpa[1].diffpca.lambda3 = lambda3_diff_r2->text().toDouble();
-	}
-	else
-	{
-		pt.fpa[1].diffpca.lambda1 = 0;
-		pt.fpa[1].diffpca.lambda2 = 0;
-		pt.fpa[1].diffpca.lambda3 = 0;
-	}
-		
-	if(checkBox_diff_scale3->isChecked())
-	{
-		pt.fpa[2].diffpca.lambda1 = lambda1_diff_r3->text().toDouble();
-		pt.fpa[2].diffpca.lambda2 = lambda2_diff_r3->text().toDouble();
-		pt.fpa[2].diffpca.lambda3 = lambda3_diff_r3->text().toDouble();
-	}
-	else
-	{
-		pt.fpa[2].diffpca.lambda1 = 0;
-		pt.fpa[2].diffpca.lambda2 = 0;
-		pt.fpa[2].diffpca.lambda3 = 0;
-	}
-	
-	if(checkBox_diff_scale4->isChecked())
-	{
-		pt.fpa[3].diffpca.lambda1 = lambda1_diff_r4->text().toDouble();
-		pt.fpa[3].diffpca.lambda2 = lambda2_diff_r4->text().toDouble();
-		pt.fpa[3].diffpca.lambda3 = lambda3_diff_r4->text().toDouble();
-	}
-	else
-	{
-		pt.fpa[3].diffpca.lambda1 = 0;
-		pt.fpa[3].diffpca.lambda2 = 0;
-		pt.fpa[3].diffpca.lambda3 = 0;
-	}
+  if (!imgdata || !imgdata->valid()) return false;
 
-	//do computation of similarity map
-	V3DLONG sz0 = imgdata->getXDim();
+  QTime t;
+  t.start();
+
+  pt.x = coord_x->text().toInt()-1;
+  pt.y = coord_y->text().toInt()-1;
+  pt.z = coord_z->text().toInt()-1;
+  V3DLONG channel_no = statistics_channel->value()-1; if (channel_no<0) channel_no=0; if (channel_no>=imgdata->getCDim()) channel_no=imgdata->getCDim()-1;
+  V3DLONG normalized_flag = normalized->value();
+  pt.radius = (radius->text().toDouble()>=0)?radius->text().toDouble():0;
+
+  //now do the computation
+
+  V3DLONG xx = V3DLONG(pt.x+0.5);
+  V3DLONG yy = V3DLONG(pt.y+0.5);
+  V3DLONG zz = V3DLONG(pt.z+0.5);
+  V3DLONG rr = pt.radius; if (rr<0) rr=0;
+
+  //reading updated current inputs
+  if(checkBox_ori_scale1->isChecked())
+  {
+    pt.fpa[0].imgpca.lambda1 = lambda1_ori_r1->text().toDouble();
+    pt.fpa[0].imgpca.lambda2 = lambda2_ori_r1->text().toDouble();
+    pt.fpa[0].imgpca.lambda3 = lambda3_ori_r1->text().toDouble();
+  }
+  else
+  {
+    pt.fpa[0].imgpca.lambda1 = 0;
+    pt.fpa[0].imgpca.lambda2 = 0;
+    pt.fpa[0].imgpca.lambda3 = 0;
+  }
+
+  if(checkBox_ori_scale2->isChecked())
+  {
+    pt.fpa[1].imgpca.lambda1 = lambda1_ori_r2->text().toDouble();
+    pt.fpa[1].imgpca.lambda2 = lambda2_ori_r2->text().toDouble();
+    pt.fpa[1].imgpca.lambda3 = lambda3_ori_r2->text().toDouble();
+  }
+  else
+  {
+    pt.fpa[1].imgpca.lambda1 = 0;
+    pt.fpa[1].imgpca.lambda2 = 0;
+    pt.fpa[1].imgpca.lambda3 = 0;
+  }
+
+  if(checkBox_ori_scale3->isChecked())
+  {
+    pt.fpa[2].imgpca.lambda1 = lambda1_ori_r3->text().toDouble();
+    pt.fpa[2].imgpca.lambda2 = lambda2_ori_r3->text().toDouble();
+    pt.fpa[2].imgpca.lambda3 = lambda3_ori_r3->text().toDouble();
+  }
+  else
+  {
+    pt.fpa[2].imgpca.lambda1 = 0;
+    pt.fpa[2].imgpca.lambda2 = 0;
+    pt.fpa[2].imgpca.lambda3 = 0;
+  }
+
+  if(checkBox_ori_scale4->isChecked())
+  {
+    pt.fpa[3].imgpca.lambda1 = lambda1_ori_r4->text().toDouble();
+    pt.fpa[3].imgpca.lambda2 = lambda2_ori_r4->text().toDouble();
+    pt.fpa[3].imgpca.lambda3 = lambda3_ori_r4->text().toDouble();
+  }
+  else
+  {
+    pt.fpa[3].imgpca.lambda1 = 0;
+    pt.fpa[3].imgpca.lambda2 = 0;
+    pt.fpa[3].imgpca.lambda3 = 0;
+  }
+
+  if(checkBox_diff_scale1->isChecked())
+  {
+    pt.fpa[0].diffpca.lambda1 = lambda1_diff_r1->text().toDouble();
+    pt.fpa[0].diffpca.lambda2 = lambda2_diff_r1->text().toDouble();
+    pt.fpa[0].diffpca.lambda3 = lambda3_diff_r1->text().toDouble();
+  }
+  else
+  {
+    pt.fpa[0].diffpca.lambda1 = 0;
+    pt.fpa[0].diffpca.lambda2 = 0;
+    pt.fpa[0].diffpca.lambda3 = 0;
+  }
+
+  if(checkBox_diff_scale2->isChecked())
+  {
+    pt.fpa[1].diffpca.lambda1 = lambda1_diff_r2->text().toDouble();
+    pt.fpa[1].diffpca.lambda2 = lambda2_diff_r2->text().toDouble();
+    pt.fpa[1].diffpca.lambda3 = lambda3_diff_r2->text().toDouble();
+  }
+  else
+  {
+    pt.fpa[1].diffpca.lambda1 = 0;
+    pt.fpa[1].diffpca.lambda2 = 0;
+    pt.fpa[1].diffpca.lambda3 = 0;
+  }
+
+  if(checkBox_diff_scale3->isChecked())
+  {
+    pt.fpa[2].diffpca.lambda1 = lambda1_diff_r3->text().toDouble();
+    pt.fpa[2].diffpca.lambda2 = lambda2_diff_r3->text().toDouble();
+    pt.fpa[2].diffpca.lambda3 = lambda3_diff_r3->text().toDouble();
+  }
+  else
+  {
+    pt.fpa[2].diffpca.lambda1 = 0;
+    pt.fpa[2].diffpca.lambda2 = 0;
+    pt.fpa[2].diffpca.lambda3 = 0;
+  }
+
+  if(checkBox_diff_scale4->isChecked())
+  {
+    pt.fpa[3].diffpca.lambda1 = lambda1_diff_r4->text().toDouble();
+    pt.fpa[3].diffpca.lambda2 = lambda2_diff_r4->text().toDouble();
+    pt.fpa[3].diffpca.lambda3 = lambda3_diff_r4->text().toDouble();
+  }
+  else
+  {
+    pt.fpa[3].diffpca.lambda1 = 0;
+    pt.fpa[3].diffpca.lambda2 = 0;
+    pt.fpa[3].diffpca.lambda3 = 0;
+  }
+
+  //do computation of similarity map
+  V3DLONG sz0 = imgdata->getXDim();
   V3DLONG sz1 = imgdata->getYDim();
   V3DLONG sz2 = imgdata->getZDim();
   V3DLONG sz3 = imgdata->getCDim();
 
-	//initial a float type pointer for computing difference
-	float **** pDiff = new float *** [sz3];
-	if (!pDiff)
-	{
-		printf("Memory allocate error for pDiff! \n");
-		return false;
-	}
+  //initial a float type pointer for computing difference
+  float **** pDiff = new float *** [sz3];
+  if (!pDiff)
+  {
+    printf("Memory allocate error for pDiff! \n");
+    return false;
+  }
 
-	for (V3DLONG c=0;c<sz3; c++)
-	{
-		pDiff[c] = new float ** [sz2];
-		if (!pDiff[c])
-		{
-			for (V3DLONG i=0;i<c;i++) {delete [] (pDiff[c]);}
-			delete []pDiff; 
-			pDiff=NULL;
-			return false;
-		}
-		else
-		{
-			for (V3DLONG i=0;i<sz2; i++)
-			{
-				pDiff[c][i] = new float * [sz1];
-				if (!pDiff[c][i])
-				{
-					for (V3DLONG j=0;j<i;j++) {delete [] (pDiff[c][i]);}
-					delete [](pDiff[c]); 
-					pDiff[c]=NULL;
-					return false;
-				}
-				else
-				{
-					for (V3DLONG j=0;j<sz1; j++)
-					{
-						pDiff[c][i][j] = new float [sz0]; 
-						if (!pDiff[c][i][j])
-						{
-							for (V3DLONG k=0;k<j;k++) {delete [] (pDiff[c][i][j]);}
-							delete [](pDiff[c][i]); 
-							pDiff[c][i]=NULL;
-							return false;
-						}
-						else
-						{
-							for(V3DLONG k=0; k<sz0; k++)
-							{
-								pDiff[c][i][j][k]=0; //initialization
-							}
-						}
-					}
-				}
-			}
-		}
-	}
-	
-	int b_win_shape=1; //0 for cube and 1 for sphere for pca computation
-	bool b_disp_CoM_etc=false; //if display center of mass and covariance info
-	
-	double max_val = -INF, min_val = INF; //for rescaling
-	
-	V3DLONG channel_bytes = sz2*sz1*sz0;
-	
-	float **** data4d_float32 = (float ****)imgdata->getData();;
-	USHORTINT16 **** data4d_uint16 = (USHORTINT16 ****)imgdata->getData();
-	unsigned char **** data4d_uint8 = (unsigned char ****)imgdata->getData();;
-	
-	float * pSMap = new float [channel_bytes];
-	if (!pSMap)
-	{
-		printf("Fail to allocate memory for pSMap!\n");
-		return false;
-	}
-	for (V3DLONG k=0;k<channel_bytes;k++)
-	{
-		pSMap[k] = 0;
-	}
+  for (V3DLONG c=0;c<sz3; c++)
+  {
+    pDiff[c] = new float ** [sz2];
+    if (!pDiff[c])
+    {
+      for (V3DLONG i=0;i<c;i++) {delete [] (pDiff[c]);}
+      delete []pDiff;
+      pDiff=NULL;
+      return false;
+    }
+    else
+    {
+      for (V3DLONG i=0;i<sz2; i++)
+      {
+        pDiff[c][i] = new float * [sz1];
+        if (!pDiff[c][i])
+        {
+          for (V3DLONG j=0;j<i;j++) {delete [] (pDiff[c][i]);}
+          delete [](pDiff[c]);
+          pDiff[c]=NULL;
+          return false;
+        }
+        else
+        {
+          for (V3DLONG j=0;j<sz1; j++)
+          {
+            pDiff[c][i][j] = new float [sz0];
+            if (!pDiff[c][i][j])
+            {
+              for (V3DLONG k=0;k<j;k++) {delete [] (pDiff[c][i][j]);}
+              delete [](pDiff[c][i]);
+              pDiff[c][i]=NULL;
+              return false;
+            }
+            else
+            {
+              for(V3DLONG k=0; k<sz0; k++)
+              {
+                pDiff[c][i][j][k]=0; //initialization
+              }
+            }
+          }
+        }
+      }
+    }
+  }
 
-	//computing similarity map according to point (xx, yy, zz)	
-	double thresh = threshold->text().toDouble();
-	int m = 0;
-	
-	switch ( imgdata->getDatatype() )
-	{
-		case V3D_UINT8:
-			//compute distance instead of correlation
-			for (int k=0;k<sz2;k++)
-			{
-				qDebug("k %d ", k);
-				for (int j=0;j<sz1;j++)
-				{
-					for (int i=0;i<sz0;i++)
-					{
-						if(data4d_uint8[channel_no][k][j][i] > thresh)
-						{
-							V3DLONG indLoop = k*sz0*sz1 + j*sz0 + i;
-							
-							//computing	
-							ImgPixelFea pt_cmp(i,j,k);
-							
-							double sum = 0;
-							if(checkBox_ori_scale1->isChecked())
-							{
-								m = 0;
+  int b_win_shape=1; //0 for cube and 1 for sphere for pca computation
+  bool b_disp_CoM_etc=false; //if display center of mass and covariance info
 
-								compute_win3d_pca(data4d_uint8[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  rr, rr, rr,
-												  pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
-								
-							}
-							
-							if(checkBox_ori_scale2->isChecked())
-							{
-								m = 1;
-								
-								compute_win3d_pca(data4d_uint8[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
-							}
-							
-							if(checkBox_ori_scale3->isChecked())
-							{
-								m = 2;
+  double max_val = -INF, min_val = INF; //for rescaling
 
-								compute_win3d_pca(data4d_uint8[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
-							}
-							
-							if(checkBox_ori_scale4->isChecked())
-							{
-								m = 3;
+  V3DLONG channel_bytes = sz2*sz1*sz0;
 
-								compute_win3d_pca(data4d_uint8[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);	
-								
-								sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
-							}
-							
-							if(checkBox_diff_scale1->isChecked())
-							{
-								m = 1;
-								
-								compute_win3d_diff(data4d_uint8[channel_no], pDiff[channel_no], sz0, sz1, sz2,
-												   i,j,k,
-												   rr,rr,rr);
-								
-								compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  rr, rr, rr,
-												  pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
-							}
-							
-							if(checkBox_diff_scale2->isChecked())
-							{
-								m = 1;
-								
-								compute_win3d_diff(data4d_uint8[channel_no], pDiff[channel_no], sz0, sz1, sz2,
-												   i,j,k,
-												   i*rr, i*rr, i*rr);
-								
-								compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
-							}
-							
-							if(checkBox_diff_scale3->isChecked())
-							{
-								m = 2;
-								
-								compute_win3d_diff(data4d_uint8[channel_no], pDiff[channel_no], sz0, sz1, sz2,
-												   i,j,k,
-												   i*rr, i*rr, i*rr);
-								
-								compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
-								
-							}
-							
-							if(checkBox_diff_scale4->isChecked())
-							{
-								m = 3;
-								
-								compute_win3d_diff(data4d_uint8[channel_no], pDiff[channel_no], sz0, sz1, sz2,
-												   i,j,k,
-												   i*rr, i*rr, i*rr);
-								
-								compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
-							}
+  float **** data4d_float32 = (float ****)imgdata->getData();;
+  uint16 **** data4d_uint16 = (uint16 ****)imgdata->getData();
+  uint32 **** data4d_uint32 = (uint32 ****)imgdata->getData();
+  unsigned char **** data4d_uint8 = (unsigned char ****)imgdata->getData();;
 
-							//compute distance
-							pSMap[indLoop] = exp(-sum);
-							
-							max_val = (max_val<pSMap[indLoop])? pSMap[indLoop] : max_val;
-							min_val = (min_val>pSMap[indLoop])? pSMap[indLoop] : min_val;
-							
-						}
+  float * pSMap = new float [channel_bytes];
+  if (!pSMap)
+  {
+    printf("Fail to allocate memory for pSMap!\n");
+    return false;
+  }
+  for (V3DLONG k=0;k<channel_bytes;k++)
+  {
+    pSMap[k] = 0;
+  }
 
-					}
-				}
-			}
-			
-			break;
-			
-		case V3D_UINT16:
-			//compute distance instead of correlation
-			for (int k=0;k<sz2;k++)
-			{
-				for (int j=0;j<sz1;j++)
-				{
-					for (int i=0;i<sz0;i++)
-					{
-						if(data4d_uint16[channel_no][k][j][i] > thresh)
-						{
-							V3DLONG indLoop = k*sz0*sz1 + j*sz0 + i;
-							
-							//computing	
-							ImgPixelFea pt_cmp(i,j,k);
-							
-							double sum = 0;
-							if(checkBox_ori_scale1->isChecked())
-							{
-								m = 0;
+  //computing similarity map according to point (xx, yy, zz)
+  double thresh = threshold->text().toDouble();
+  int m = 0;
 
-								compute_win3d_pca(data4d_uint16[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  rr, rr, rr,
-												  pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
-								
-							}
-							
-							if(checkBox_ori_scale2->isChecked())
-							{
-								m = 1;
-								
-								compute_win3d_pca(data4d_uint16[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
-							}
-							
-							if(checkBox_ori_scale3->isChecked())
-							{
-								m = 2;
-								
-								compute_win3d_pca(data4d_uint16[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
-							}
-							
-							if(checkBox_ori_scale4->isChecked())
-							{
-								m = 3;
-								
-								compute_win3d_pca(data4d_uint16[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);	
-								
-								sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
-							}
-							
-							if(checkBox_diff_scale1->isChecked())
-							{
-								m = 0;
-								
-								compute_win3d_diff(data4d_uint16[channel_no], pDiff[channel_no], sz0, sz1, sz2,
-												   i,j,k,
-												   rr,rr,rr);	
-								
-								compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  rr, rr, rr,
-												  pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
-							}
-							
-							if(checkBox_diff_scale2->isChecked())
-							{
-								m = 1;
-								
-								compute_win3d_diff(data4d_uint16[channel_no], pDiff[channel_no], sz0, sz1, sz2,
-												   i,j,k,
-												   i*rr, i*rr, i*rr);	
-								
-								compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
-							}
-							
-							if(checkBox_diff_scale3->isChecked())
-							{
-								m = 2;
-								
-								compute_win3d_diff(data4d_uint16[channel_no], pDiff[channel_no], sz0, sz1, sz2,
-												   i,j,k,
-												   i*rr, i*rr, i*rr);	
-								
-								compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
-								
-							}
-							
-							if(checkBox_diff_scale4->isChecked())
-							{
-								m = 3;
-								
-								compute_win3d_diff(data4d_uint16[channel_no], pDiff[channel_no], sz0, sz1, sz2,
-												   i,j,k,
-												   i*rr, i*rr, i*rr);	
-								
-								compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
-							}
-							
-							
-							
-							//compute distance
-							
-							pSMap[indLoop] = exp(-sum);
-							
-							max_val = (max_val<pSMap[indLoop])? pSMap[indLoop] : max_val;
-							min_val = (min_val>pSMap[indLoop])? pSMap[indLoop] : min_val;
-							
-						}
-						
-					}
-				}
-			}
-			
-			break;
-			
-		case V3D_FLOAT32:
-			//compute distance instead of correlation
-			for (int k=0;k<sz2;k++)
-			{
-				for (int j=0;j<sz1;j++)
-				{
-					for (int i=0;i<sz0;i++)
-					{
-						if(data4d_float32[channel_no][k][j][i] > thresh)
-						{
-							V3DLONG indLoop = k*sz0*sz1 + j*sz0 + i;
-							
-							//computing	
-							ImgPixelFea pt_cmp(i,j,k);
-							
-							double sum = 0;
-							if(checkBox_ori_scale1->isChecked())
-							{
-								m = 0;
-								
-								compute_win3d_pca(data4d_float32[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  rr, rr, rr,
-												  pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
-								
-							}
-							
-							if(checkBox_ori_scale2->isChecked())
-							{
-								m = 1;
-								
-								compute_win3d_pca(data4d_float32[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
-							}
-							
-							if(checkBox_ori_scale3->isChecked())
-							{
-								m = 2;
-								
-								compute_win3d_pca(data4d_float32[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
-							}
-							
-							if(checkBox_ori_scale4->isChecked())
-							{
-								m = 3;
-								
-								compute_win3d_pca(data4d_float32[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);	
-								
-								sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
-							}
-							
-							if(checkBox_diff_scale1->isChecked())
-							{
-								m = 0;
-								
-								compute_win3d_diff(data4d_float32[channel_no], pDiff[channel_no], sz0, sz1, sz2,
-												   i,j,k,
-												   rr,rr,rr);
-								
-								compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  rr, rr, rr,
-												  pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
-							}
-							
-							if(checkBox_diff_scale2->isChecked())
-							{
-								m = 1;
-								
-								compute_win3d_diff(data4d_float32[channel_no], pDiff[channel_no], sz0, sz1, sz2,
-												   i,j,k,
-												   i*rr, i*rr, i*rr);
-								
-								compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
-							}
-							
-							if(checkBox_diff_scale3->isChecked())
-							{
-								m = 2;
-								
-								compute_win3d_diff(data4d_float32[channel_no], pDiff[channel_no], sz0, sz1, sz2,
-												   i,j,k,
-												   i*rr, i*rr, i*rr);
-								
-								compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
-								
-							}
-							
-							if(checkBox_diff_scale4->isChecked())
-							{
-								m = 3;
-								
-								compute_win3d_diff(data4d_float32[channel_no], pDiff[channel_no], sz0, sz1, sz2,
-												   i,j,k,
-												   i*rr, i*rr, i*rr);
-								
-								compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
-												  i, j, k,
-												  i*rr, i*rr, i*rr,
-												  pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
-								
-								sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
-							}
-							
-							
-							
-							//compute distance
-							
-							pSMap[indLoop] = exp(-sum);
-							
-							max_val = (max_val<pSMap[indLoop])? pSMap[indLoop] : max_val;
-							min_val = (min_val>pSMap[indLoop])? pSMap[indLoop] : min_val;							
-							
-						}
-						
-					}
-				}
-			}
-			
-			break;
-	}
-	qDebug("max value and min value of the point similarity map is %lf and %lf .\n", max_val, min_val);
+  switch ( imgdata->getDatatype() )
+  {
+    case V3D_UINT8:
+      //compute distance instead of correlation
+      for (int k=0;k<sz2;k++)
+      {
+        qDebug("k %d ", k);
+        for (int j=0;j<sz1;j++)
+        {
+          for (int i=0;i<sz0;i++)
+          {
+            if(data4d_uint8[channel_no][k][j][i] > thresh)
+            {
+              V3DLONG indLoop = k*sz0*sz1 + j*sz0 + i;
 
-	//RGB with similarity=1 Blue (255) & similarity=0 Red (0)
-	unsigned char * outvol1d = new unsigned char [3*channel_bytes];
-	if (!outvol1d)
-	{
-		printf("Fail to allocate memory for outvol1d!\n");
-		return false;
-	}
-	else
-	{
-		for (V3DLONG k=0;k<channel_bytes;k++)
-		{
-			outvol1d[k] = 0;
-			outvol1d[k+channel_bytes] = 0;
-			outvol1d[k+channel_bytes+channel_bytes] = 0;
-		}
-	}
-	
-	XFormWidget * newwin = imgdata->getXWidget()->getMainControlWindow()->createMdiChild();
-	newwin->newProcessedImage("Similarity Map ", outvol1d, sz0, sz1, sz2, 3, V3D_UINT8); 
-	
-	V3DLONG sxy = sz0*sz1;
-	V3DLONG offset2 = 2*channel_bytes;
-	
-	for (V3DLONG k=0;k<sz2;k++)
-	{
-		V3DLONG indz = k*sxy;
-		for (V3DLONG j=0;j<sz1;j++)
-		{
-			V3DLONG indy = indz+j*sz0;
-			for (V3DLONG i=0;i<sz0;i++)
-			{
-				V3DLONG indLoop = indy + i;
-				
-				if(pSMap[indLoop])
-				{
-					float tmp = 255*(pSMap[indLoop]-min_val)/(max_val-min_val);
+              //computing
+              ImgPixelFea pt_cmp(i,j,k);
 
-					outvol1d[indLoop] = 255-tmp;
-					outvol1d[indLoop + channel_bytes] = 0;
-					outvol1d[indLoop + offset2] = tmp;
-				}
-				else
-				{
-					outvol1d[indLoop] = 0;
-					outvol1d[indLoop + channel_bytes] = 0;
-					outvol1d[indLoop + offset2] = 0;
-				}
-			}
-		}
-	}
-	
-	newwin->show();
-	newwin->getImageData()->updateViews();
-	
+              double sum = 0;
+              if(checkBox_ori_scale1->isChecked())
+              {
+                m = 0;
 
-	//de-alloc
-	if(pSMap) {delete [] pSMap; pSMap=0;}
-	
-	if(pDiff) 
-	{
-		for (V3DLONG i=0;i<sz3; i++)
-		{
-			if(pDiff[i])
-			{
-				for (V3DLONG j=0;j<sz2; j++)
-				{
-					if (pDiff[i][j])
-					{
-						for(V3DLONG k=0; k<sz1; k++)
-						{
-							if(pDiff[i][j][k])
-							{
-								delete [] (pDiff[i][j][k]);
-								pDiff[i][j][k]=NULL;
-							}
-						}
-						
-						delete [] (pDiff[i][j]);
-						pDiff[i][j] = NULL;
-					}
-				}
-			}
-			
-			delete [] pDiff[i];
-			pDiff[i] = NULL;
-		}
-		
-		delete [] pDiff;
-		pDiff = NULL;
-	}
-	
-	//testing cost time
-	qDebug("Time elapsed: %d ms \n", t.elapsed());
-	
-	//Exit Normal
-	return true;
-	
+                compute_win3d_pca(data4d_uint8[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          rr, rr, rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+
+              }
+
+              if(checkBox_ori_scale2->isChecked())
+              {
+                m = 1;
+
+                compute_win3d_pca(data4d_uint8[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+              }
+
+              if(checkBox_ori_scale3->isChecked())
+              {
+                m = 2;
+
+                compute_win3d_pca(data4d_uint8[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+              }
+
+              if(checkBox_ori_scale4->isChecked())
+              {
+                m = 3;
+
+                compute_win3d_pca(data4d_uint8[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+              }
+
+              if(checkBox_diff_scale1->isChecked())
+              {
+                m = 1;
+
+                compute_win3d_diff(data4d_uint8[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           rr,rr,rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          rr, rr, rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+              }
+
+              if(checkBox_diff_scale2->isChecked())
+              {
+                m = 1;
+
+                compute_win3d_diff(data4d_uint8[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           i*rr, i*rr, i*rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+              }
+
+              if(checkBox_diff_scale3->isChecked())
+              {
+                m = 2;
+
+                compute_win3d_diff(data4d_uint8[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           i*rr, i*rr, i*rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+
+              }
+
+              if(checkBox_diff_scale4->isChecked())
+              {
+                m = 3;
+
+                compute_win3d_diff(data4d_uint8[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           i*rr, i*rr, i*rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+              }
+
+              //compute distance
+              pSMap[indLoop] = exp(-sum);
+
+              max_val = (max_val<pSMap[indLoop])? pSMap[indLoop] : max_val;
+              min_val = (min_val>pSMap[indLoop])? pSMap[indLoop] : min_val;
+
+            }
+
+          }
+        }
+      }
+
+      break;
+
+    case V3D_UINT16:
+      //compute distance instead of correlation
+      for (int k=0;k<sz2;k++)
+      {
+        for (int j=0;j<sz1;j++)
+        {
+          for (int i=0;i<sz0;i++)
+          {
+            if(data4d_uint16[channel_no][k][j][i] > thresh)
+            {
+              V3DLONG indLoop = k*sz0*sz1 + j*sz0 + i;
+
+              //computing
+              ImgPixelFea pt_cmp(i,j,k);
+
+              double sum = 0;
+              if(checkBox_ori_scale1->isChecked())
+              {
+                m = 0;
+
+                compute_win3d_pca(data4d_uint16[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          rr, rr, rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+
+              }
+
+              if(checkBox_ori_scale2->isChecked())
+              {
+                m = 1;
+
+                compute_win3d_pca(data4d_uint16[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+              }
+
+              if(checkBox_ori_scale3->isChecked())
+              {
+                m = 2;
+
+                compute_win3d_pca(data4d_uint16[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+              }
+
+              if(checkBox_ori_scale4->isChecked())
+              {
+                m = 3;
+
+                compute_win3d_pca(data4d_uint16[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+              }
+
+              if(checkBox_diff_scale1->isChecked())
+              {
+                m = 0;
+
+                compute_win3d_diff(data4d_uint16[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           rr,rr,rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          rr, rr, rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+              }
+
+              if(checkBox_diff_scale2->isChecked())
+              {
+                m = 1;
+
+                compute_win3d_diff(data4d_uint16[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           i*rr, i*rr, i*rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+              }
+
+              if(checkBox_diff_scale3->isChecked())
+              {
+                m = 2;
+
+                compute_win3d_diff(data4d_uint16[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           i*rr, i*rr, i*rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+
+              }
+
+              if(checkBox_diff_scale4->isChecked())
+              {
+                m = 3;
+
+                compute_win3d_diff(data4d_uint16[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           i*rr, i*rr, i*rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+              }
+
+
+
+              //compute distance
+
+              pSMap[indLoop] = exp(-sum);
+
+              max_val = (max_val<pSMap[indLoop])? pSMap[indLoop] : max_val;
+              min_val = (min_val>pSMap[indLoop])? pSMap[indLoop] : min_val;
+
+            }
+
+          }
+        }
+      }
+
+      break;
+
+    case V3D_UINT32:
+      //compute distance instead of correlation
+      for (int k=0;k<sz2;k++)
+      {
+        for (int j=0;j<sz1;j++)
+        {
+          for (int i=0;i<sz0;i++)
+          {
+            if(data4d_uint32[channel_no][k][j][i] > thresh)
+            {
+              V3DLONG indLoop = k*sz0*sz1 + j*sz0 + i;
+
+              //computing
+              ImgPixelFea pt_cmp(i,j,k);
+
+              double sum = 0;
+              if(checkBox_ori_scale1->isChecked())
+              {
+                m = 0;
+
+                compute_win3d_pca(data4d_uint32[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          rr, rr, rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+
+              }
+
+              if(checkBox_ori_scale2->isChecked())
+              {
+                m = 1;
+
+                compute_win3d_pca(data4d_uint32[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+              }
+
+              if(checkBox_ori_scale3->isChecked())
+              {
+                m = 2;
+
+                compute_win3d_pca(data4d_uint32[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+              }
+
+              if(checkBox_ori_scale4->isChecked())
+              {
+                m = 3;
+
+                compute_win3d_pca(data4d_uint32[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+              }
+
+              if(checkBox_diff_scale1->isChecked())
+              {
+                m = 0;
+
+                compute_win3d_diff(data4d_uint32[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           rr,rr,rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          rr, rr, rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+              }
+
+              if(checkBox_diff_scale2->isChecked())
+              {
+                m = 1;
+
+                compute_win3d_diff(data4d_uint32[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           i*rr, i*rr, i*rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+              }
+
+              if(checkBox_diff_scale3->isChecked())
+              {
+                m = 2;
+
+                compute_win3d_diff(data4d_uint32[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           i*rr, i*rr, i*rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+
+              }
+
+              if(checkBox_diff_scale4->isChecked())
+              {
+                m = 3;
+
+                compute_win3d_diff(data4d_uint32[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           i*rr, i*rr, i*rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+              }
+
+
+
+              //compute distance
+
+              pSMap[indLoop] = exp(-sum);
+
+              max_val = (max_val<pSMap[indLoop])? pSMap[indLoop] : max_val;
+              min_val = (min_val>pSMap[indLoop])? pSMap[indLoop] : min_val;
+
+            }
+
+          }
+        }
+      }
+
+      break;
+
+
+    case V3D_FLOAT32:
+      //compute distance instead of correlation
+      for (int k=0;k<sz2;k++)
+      {
+        for (int j=0;j<sz1;j++)
+        {
+          for (int i=0;i<sz0;i++)
+          {
+            if(data4d_float32[channel_no][k][j][i] > thresh)
+            {
+              V3DLONG indLoop = k*sz0*sz1 + j*sz0 + i;
+
+              //computing
+              ImgPixelFea pt_cmp(i,j,k);
+
+              double sum = 0;
+              if(checkBox_ori_scale1->isChecked())
+              {
+                m = 0;
+
+                compute_win3d_pca(data4d_float32[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          rr, rr, rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+
+              }
+
+              if(checkBox_ori_scale2->isChecked())
+              {
+                m = 1;
+
+                compute_win3d_pca(data4d_float32[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+              }
+
+              if(checkBox_ori_scale3->isChecked())
+              {
+                m = 2;
+
+                compute_win3d_pca(data4d_float32[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+              }
+
+              if(checkBox_ori_scale4->isChecked())
+              {
+                m = 3;
+
+                compute_win3d_pca(data4d_float32[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].imgpca.lambda1, pt_cmp.fpa[m].imgpca.lambda2, pt_cmp.fpa[m].imgpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].imgpca.lambda1 - pt_cmp.fpa[m].imgpca.lambda1) + abs(pt.fpa[m].imgpca.lambda2 - pt_cmp.fpa[m].imgpca.lambda2) + abs(pt.fpa[m].imgpca.lambda3 - pt_cmp.fpa[m].imgpca.lambda3);
+              }
+
+              if(checkBox_diff_scale1->isChecked())
+              {
+                m = 0;
+
+                compute_win3d_diff(data4d_float32[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           rr,rr,rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          rr, rr, rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+              }
+
+              if(checkBox_diff_scale2->isChecked())
+              {
+                m = 1;
+
+                compute_win3d_diff(data4d_float32[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           i*rr, i*rr, i*rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+              }
+
+              if(checkBox_diff_scale3->isChecked())
+              {
+                m = 2;
+
+                compute_win3d_diff(data4d_float32[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           i*rr, i*rr, i*rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+
+              }
+
+              if(checkBox_diff_scale4->isChecked())
+              {
+                m = 3;
+
+                compute_win3d_diff(data4d_float32[channel_no], pDiff[channel_no], sz0, sz1, sz2,
+                           i,j,k,
+                           i*rr, i*rr, i*rr);
+
+                compute_win3d_pca(pDiff[channel_no], sz0, sz1, sz2,
+                          i, j, k,
+                          i*rr, i*rr, i*rr,
+                          pt_cmp.fpa[m].diffpca.lambda1, pt_cmp.fpa[m].diffpca.lambda2, pt_cmp.fpa[m].diffpca.lambda3, b_win_shape, b_disp_CoM_etc, normalized_flag);
+
+                sum += abs(pt.fpa[m].diffpca.lambda1 - pt_cmp.fpa[m].diffpca.lambda1) + abs(pt.fpa[m].diffpca.lambda2 - pt_cmp.fpa[m].diffpca.lambda2) + abs(pt.fpa[m].diffpca.lambda3 - pt_cmp.fpa[m].diffpca.lambda3);
+              }
+
+
+
+              //compute distance
+
+              pSMap[indLoop] = exp(-sum);
+
+              max_val = (max_val<pSMap[indLoop])? pSMap[indLoop] : max_val;
+              min_val = (min_val>pSMap[indLoop])? pSMap[indLoop] : min_val;
+
+            }
+
+          }
+        }
+      }
+
+      break;
+  }
+  qDebug("max value and min value of the point similarity map is %lf and %lf .\n", max_val, min_val);
+
+  //RGB with similarity=1 Blue (255) & similarity=0 Red (0)
+  unsigned char * outvol1d = new unsigned char [3*channel_bytes];
+  if (!outvol1d)
+  {
+    printf("Fail to allocate memory for outvol1d!\n");
+    return false;
+  }
+  else
+  {
+    for (V3DLONG k=0;k<channel_bytes;k++)
+    {
+      outvol1d[k] = 0;
+      outvol1d[k+channel_bytes] = 0;
+      outvol1d[k+channel_bytes+channel_bytes] = 0;
+    }
+  }
+
+  XFormWidget * newwin = imgdata->getXWidget()->getMainControlWindow()->createMdiChild();
+  newwin->newProcessedImage("Similarity Map ", outvol1d, sz0, sz1, sz2, 3, V3D_UINT8);
+
+  V3DLONG sxy = sz0*sz1;
+  V3DLONG offset2 = 2*channel_bytes;
+
+  for (V3DLONG k=0;k<sz2;k++)
+  {
+    V3DLONG indz = k*sxy;
+    for (V3DLONG j=0;j<sz1;j++)
+    {
+      V3DLONG indy = indz+j*sz0;
+      for (V3DLONG i=0;i<sz0;i++)
+      {
+        V3DLONG indLoop = indy + i;
+
+        if(pSMap[indLoop])
+        {
+          float tmp = 255*(pSMap[indLoop]-min_val)/(max_val-min_val);
+
+          outvol1d[indLoop] = 255-tmp;
+          outvol1d[indLoop + channel_bytes] = 0;
+          outvol1d[indLoop + offset2] = tmp;
+        }
+        else
+        {
+          outvol1d[indLoop] = 0;
+          outvol1d[indLoop + channel_bytes] = 0;
+          outvol1d[indLoop + offset2] = 0;
+        }
+      }
+    }
+  }
+
+  newwin->show();
+  newwin->getImageData()->updateViews();
+
+
+  //de-alloc
+  if(pSMap) {delete [] pSMap; pSMap=0;}
+
+  if(pDiff)
+  {
+    for (V3DLONG i=0;i<sz3; i++)
+    {
+      if(pDiff[i])
+      {
+        for (V3DLONG j=0;j<sz2; j++)
+        {
+          if (pDiff[i][j])
+          {
+            for(V3DLONG k=0; k<sz1; k++)
+            {
+              if(pDiff[i][j][k])
+              {
+                delete [] (pDiff[i][j][k]);
+                pDiff[i][j][k]=NULL;
+              }
+            }
+
+            delete [] (pDiff[i][j]);
+            pDiff[i][j] = NULL;
+          }
+        }
+      }
+
+      delete [] pDiff[i];
+      pDiff[i] = NULL;
+    }
+
+    delete [] pDiff;
+    pDiff = NULL;
+  }
+
+  //testing cost time
+  qDebug("Time elapsed: %d ms \n", t.elapsed());
+
+  //Exit Normal
+  return true;
+
 }
 
 
Index: v3d_main/v3d/v3d_core.h
===================================================================
--- v3d_main/v3d/v3d_core.h	(revision 163)
+++ v3d_main/v3d/v3d_core.h	(working copy)
@@ -118,7 +118,6 @@
 
 //#include "thread_regist.h"
 
-typedef unsigned short int USHORTINT16;
 
 //class RegistrationThread;
 /**********************************************************/
@@ -214,7 +213,8 @@
 
 	//private:   // FIXME: It should be private 
 	float **** data4d_float32;
-	USHORTINT16 **** data4d_uint16;
+	uint16 **** data4d_uint16;
+	uint32 **** data4d_uint32;
 	unsigned char **** data4d_uint8;
 	void **** data4d_virtual;
 
Index: v3d_main/v3d/my4dimage.cpp
===================================================================
--- v3d_main/v3d/my4dimage.cpp	(revision 163)
+++ v3d_main/v3d/my4dimage.cpp	(working copy)
@@ -190,20 +190,100 @@
 	return true;
 }
 
-bool compute_statistics_objects(My4DImage *grayimg, V3DLONG c, My4DImage * maskimg, LocationSimple * & p_ano, V3DLONG & n_objects)
+bool compute_statistics_objects_mask_16(My4DImage *grayimg, V3DLONG c, My4DImage * maskimg, LocationSimple * & p_ano, V3DLONG & n_objects)
 {
-	if (!grayimg || !grayimg->valid() || !maskimg || !maskimg->valid() || p_ano) //p_ano MUST be 0 as this function need to alocate memory for it
+	if (grayimg->getDatatype()!=V3D_UINT8 || (maskimg->getDatatype()!=V3D_UINT16))
 	{
-		v3d_msg("The inputs of compute_statistics_objects() are invalid.\n");
+		v3d_msg("The input datatypes are invalid. The grayimg must be UINT8 and the maskimg must be UINT16.\n");
 		return false;
 	}
 
-	if (grayimg->getDatatype()!=V3D_UINT8 || (maskimg->getDatatype()!=V3D_UINT16))
+	if (grayimg->getXDim()!=maskimg->getXDim() || grayimg->getYDim()!=maskimg->getYDim() || grayimg->getZDim()!=maskimg->getZDim())
 	{
-		v3d_msg("The input datatypes are invalid. The grayimg must be UINT8 and the maskimg must be UINT16.\n");
+		v3d_msg("The sizes of the grayimg and maskimg do not match in compute_statistics_objects().\n");
 		return false;
 	}
 
+	if (c<0 || c>=grayimg->getCDim() || maskimg->getCDim()!=1)
+	{
+		v3d_msg("The input channel of grayimg is invalid or the maskimg has more than 1 channel.\n");
+		return false;
+	}
+
+	//first find the largest index
+	V3DLONG i,j,k;
+
+	uint16 *p_maskimg_1d = (uint16 *)(maskimg->getRawData());
+	uint16 ***p_maskimg_3d = (uint16 ***)(((uint16 ****)maskimg->getData())[0]);
+	unsigned char *p_grayimg_1d = (unsigned char *)(grayimg->getRawData()) + grayimg->getTotalUnitNumberPerChannel()*c;
+	unsigned char ***p_grayimg_3d = (unsigned char ***)(((unsigned char ****)grayimg->getData())[c]);
+
+	n_objects = 0;
+	for (i=0;i<maskimg->getTotalUnitNumberPerChannel();i++)
+		n_objects = (p_maskimg_1d[i]>n_objects)?p_maskimg_1d[i]:n_objects;
+
+	n_objects += 1; //always allocate one more, as the object index starts from 1. This will provide some convenience for later indexing (i.e. no need to minus 1)
+	if (n_objects==1)
+	{
+		v3d_msg("The maskimg is all 0s. Nothing to generate!.\n");
+		return false;
+	}
+
+	//then allocate memory and collect statistics
+
+	try
+	{
+		p_ano = new LocationSimple [n_objects];
+	}
+	catch(...)
+	{
+		v3d_msg("Fail to allocate memory in compute_statistics_objects().\n");
+		return false;
+	}
+
+	for (k=0;k<maskimg->getZDim();k++)
+		for (j=0;j<maskimg->getYDim();j++)
+			for (i=0;i<maskimg->getXDim();i++)
+			{
+				V3DLONG cur_ind = p_maskimg_3d[k][j][i];
+				if (p_grayimg_3d[k][j][i]==0) continue; //do not process 0 values, as it is background
+
+				double cur_pix = double(p_grayimg_3d[k][j][i]);
+
+
+				p_ano[cur_ind].size += 1;
+				p_ano[cur_ind].mass += cur_pix;
+				p_ano[cur_ind].sdev += cur_pix*cur_pix; //use the incremental formula
+				if (cur_pix > p_ano[cur_ind].pixmax) p_ano[cur_ind].pixmax =  cur_pix;
+
+				p_ano[cur_ind].x += i*cur_pix;
+				p_ano[cur_ind].y += j*cur_pix;
+				p_ano[cur_ind].z += k*cur_pix;
+			}
+
+	for (k=0;k<n_objects;k++)
+	{
+		if (p_ano[k].size>0)
+		{
+			p_ano[k].ave = p_ano[k].mass / p_ano[k].size;
+			p_ano[k].sdev = sqrt(p_ano[k].sdev/p_ano[k].size - p_ano[k].ave*p_ano[k].ave); //use the incremental formula
+
+			p_ano[k].x /= p_ano[k].mass;
+			p_ano[k].y /= p_ano[k].mass;
+			p_ano[k].z /= p_ano[k].mass;
+		}
+	}
+	return true;
+}
+
+bool compute_statistics_objects_mask_32(My4DImage *grayimg, V3DLONG c, My4DImage * maskimg, LocationSimple * & p_ano, V3DLONG & n_objects)
+{
+	if (grayimg->getDatatype()!=V3D_UINT8 || (maskimg->getDatatype()!=V3D_UINT32))
+	{
+		v3d_msg("The input datatypes are invalid. The grayimg must be UINT8 and the maskimg must be UINT32.\n");
+		return false;
+	}
+
 	if (grayimg->getXDim()!=maskimg->getXDim() || grayimg->getYDim()!=maskimg->getYDim() || grayimg->getZDim()!=maskimg->getZDim())
 	{
 		v3d_msg("The sizes of the grayimg and maskimg do not match in compute_statistics_objects().\n");
@@ -219,8 +299,8 @@
 	//first find the largest index
 	V3DLONG i,j,k;
 
-	unsigned short int *p_maskimg_1d = (unsigned short int *)(maskimg->getRawData());
-	unsigned short int ***p_maskimg_3d = (unsigned short int ***)(((unsigned short int ****)maskimg->getData())[0]);
+	uint32 *p_maskimg_1d = (uint32 *)(maskimg->getRawData());
+	uint32 ***p_maskimg_3d = (uint32 ***)(((uint32 ****)maskimg->getData())[0]);
 	unsigned char *p_grayimg_1d = (unsigned char *)(grayimg->getRawData()) + grayimg->getTotalUnitNumberPerChannel()*c;
 	unsigned char ***p_grayimg_3d = (unsigned char ***)(((unsigned char ****)grayimg->getData())[c]);
 
@@ -283,6 +363,27 @@
 }
 
 
+bool compute_statistics_objects(My4DImage *grayimg, V3DLONG c, My4DImage * maskimg, LocationSimple * & p_ano, V3DLONG & n_objects)
+{
+	if (!grayimg || !grayimg->valid() || !maskimg || !maskimg->valid() || p_ano) //p_ano MUST be 0 as this function need to alocate memory for it
+	{
+		v3d_msg("The inputs of compute_statistics_objects() are invalid.\n");
+		return false;
+	}
+
+	if ( maskimg->getDatatype()==V3D_UINT16)
+    {
+    return compute_statistics_objects_mask_16( grayimg, c, maskimg, p_ano, n_objects );
+    }
+
+	if ( maskimg->getDatatype()==V3D_UINT32)
+    {
+    return compute_statistics_objects_mask_32( grayimg, c, maskimg, p_ano, n_objects );
+    }
+
+  return false;
+}
+
 template <class T> int new3dpointer_v3d(T *** & p, V3DLONG sz0, V3DLONG sz1, V3DLONG sz2, unsigned char * p1d)
 {
 	if (p!=0) {return 0;} //if the "p" is not empty initially, then do nothing and return un-successful
@@ -386,6 +487,7 @@
 My4DImage::My4DImage()
 {
 	data4d_float32 = 0;
+	data4d_uint32 = 0;
 	data4d_uint16 = 0;
 	data4d_uint8 = 0;
 	data4d_virtual = 0; //a pointer used to link the external src data
@@ -468,7 +570,7 @@
 void **** My4DImage::getData(ImagePixelType & dtype)
 {
 	dtype = this->getDatatype();
-	if (dtype==V3D_UINT8 || dtype==V3D_UINT16)
+	if (dtype==V3D_UINT8 || dtype==V3D_UINT16 || dtype==V3D_UINT32 )
 		return data4d_virtual;
 	else
 		return NULL; //temnporarily allow only UINT8 and UINT16 data
@@ -493,6 +595,9 @@
 		case V3D_UINT16:
 			return double(data4d_uint16[c][z][y][x]);
 			break;
+		case V3D_UINT32:
+			return double(data4d_uint32[c][z][y][x]);
+			break;
 		case V3D_FLOAT32:
 			return double(data4d_float32[c][z][y][x]);
 			break;
@@ -623,7 +728,8 @@
 	}
 
 	float **** tmp_data4d_float32 = 0;
-	USHORTINT16 **** tmp_data4d_uint16 = 0;
+	uint16 **** tmp_data4d_uint16 = 0;
+	uint32 **** tmp_data4d_uint32 = 0;
 	unsigned char **** tmp_data4d_uint8 = 0;
 
 	V3DLONG ind_array[4];
@@ -649,8 +755,9 @@
 				}
 			}
 			break;
+
 		case V3D_UINT16:
-			tmp_data4d_uint16 = (USHORTINT16 ****)tmp_img->getData();
+			tmp_data4d_uint16 = (uint16 ****)tmp_img->getData();
 			for (c=0;c<this->getCDim();c++)
 			{
 				ind_array[3] = c;
@@ -670,6 +777,28 @@
 			}
 			break;
 
+		case V3D_UINT32:
+			tmp_data4d_uint32 = (uint32 ****)tmp_img->getData();
+			for (c=0;c<this->getCDim();c++)
+			{
+				ind_array[3] = c;
+				for (k=0;k<this->getZDim();k++)
+				{
+					ind_array[2] = k;
+					for (j=0;j<this->getYDim();j++)
+					{
+						ind_array[1] = j;
+						for (i=0;i<this->getXDim();i++)
+						{
+							ind_array[0] = i;
+							tmp_data4d_uint32[ind_array[dimorder[3]]][ind_array[dimorder[2]]][ind_array[dimorder[1]]][ind_array[dimorder[0]]] = data4d_uint32[c][k][j][i];
+						}
+					}
+				}
+			}
+			break;
+
+
 		case V3D_FLOAT32:
 			tmp_data4d_float32 = (float ****)tmp_img->getData();
 			for (c=0;c<this->getCDim();c++)
@@ -805,6 +934,19 @@
 
 			break;
 
+		case V3D_UINT32:
+			if (!new4dpointer_v3d(data4d_uint32, this->getXDim(), this->getYDim(), this->getZDim(), this->getCDim(), this->getRawData() ))
+			{
+				this->setError( 1 );
+				return;
+			}
+			data4d_virtual = (void ****)data4d_uint32;
+
+			v3d_msg("Warning: this data type UINT32 has not been supported in display yet.\n");
+
+			break;
+
+
 		case V3D_FLOAT32:
 			if (!new4dpointer_v3d(data4d_float32, this->getXDim(), this->getYDim(), this->getZDim(), this->getCDim(), this->getRawData() ))
 			{
@@ -875,14 +1017,26 @@
 		case V3D_UINT16:
 			for(i=0;i<this->getCDim();i++)
 			{
-				USHORTINT16 minvv,maxvv;
+				uint16 minvv,maxvv;
 				V3DLONG tmppos_min, tmppos_max;
-				minMaxInVector((USHORTINT16 *)(this->getRawData() +(V3DLONG)i*channelPageSize*sizeof(USHORTINT16)), channelPageSize, tmppos_min, minvv, tmppos_max, maxvv);
+				minMaxInVector((uint16 *)(this->getRawData() +(V3DLONG)i*channelPageSize*sizeof(uint16)), channelPageSize, tmppos_min, minvv, tmppos_max, maxvv);
 				p_vmax[i] = maxvv; p_vmin[i] = minvv;
 				printf("channel [%ld] max=[%5.3f] min=[%5.3f]\n", i, p_vmax[i], p_vmin[i]);
 			}
 			break;
 
+		case V3D_UINT32:
+			for(i=0;i<this->getCDim();i++)
+			{
+				uint32 minvv,maxvv;
+				V3DLONG tmppos_min, tmppos_max;
+				minMaxInVector((uint32 *)(this->getRawData() +(V3DLONG)i*channelPageSize*sizeof(uint32)), channelPageSize, tmppos_min, minvv, tmppos_max, maxvv);
+				p_vmax[i] = maxvv; p_vmin[i] = minvv;
+				printf("channel [%ld] max=[%5.3f] min=[%5.3f]\n", i, p_vmax[i], p_vmin[i]);
+			}
+			break;
+
+
 		case V3D_FLOAT32:
 			for(i=0;i<this->getCDim();i++)
 			{
@@ -950,7 +1104,7 @@
 			break;
 
 		case V3D_UINT16:
-			if (!new4dpointer(data4d_uint16, this->getXDim(), this->getYDim(), this->getZDim(), this->getCDim(), (USHORTINT16 *)this->getRawData() ))
+			if (!new4dpointer(data4d_uint16, this->getXDim(), this->getYDim(), this->getZDim(), this->getCDim(), (uint16 *)this->getRawData() ))
 			{
 				this->setError(1);
 				return;
@@ -970,6 +1124,25 @@
 
 			break;
 
+		case V3D_UINT32:
+			if (!new4dpointer(data4d_uint32, this->getXDim(), this->getYDim(), this->getZDim(), this->getCDim(), (uint32 *)this->getRawData() ))
+			{
+				this->setError(1);
+				return;
+			}
+			data4d_virtual = (void ****)data4d_uint32;
+
+			for(i=0;i<this->getCDim();i++)
+			{
+				p_vmax[i] = 0;
+				p_vmin[i] = 0;
+			}
+
+			v3d_msg("Warning: this data type UINT32 has not been supported in display yet.\n");
+
+			break;
+
+
 		case V3D_FLOAT32:
 			if (!new4dpointer(data4d_float32, this->getXDim(), this->getYDim(), this->getZDim(), this->getCDim(), (float *)this->getRawData() ))
 			{
@@ -1254,7 +1427,8 @@
 	nsz3 = epos_c-bpos_c+1;
 
     float **** ndata4d_float32 = 0;
-    USHORTINT16 **** ndata4d_uint16 = 0;
+    uint16 **** ndata4d_uint16 = 0;
+    uint32 **** ndata4d_uint32 = 0;
     unsigned char **** ndata4d_uint8 = 0;
 
 	unsigned char * ndata1d = 0;
@@ -1297,7 +1471,7 @@
 				break;
 
 			case V3D_UINT16:
-				ndata1d = new unsigned char [nsz0 * nsz1 * nsz2 * nsz3 * sizeof(unsigned short int)];
+				ndata1d = new unsigned char [nsz0 * nsz1 * nsz2 * nsz3 * sizeof(uint16)];
 				if (!ndata1d)
 				{
 					v3d_msg("Cannot allocate memory for the cropped image. You may want to free memory by closing unnecessary programs.\n");
@@ -1326,6 +1500,37 @@
 
 				break;
 
+			case V3D_UINT32:
+				ndata1d = new unsigned char [nsz0 * nsz1 * nsz2 * nsz3 * sizeof(uint32)];
+				if (!ndata1d)
+				{
+					v3d_msg("Cannot allocate memory for the cropped image. You may want to free memory by closing unnecessary programs.\n");
+					return;
+				}
+
+				if (!new4dpointer_v3d(ndata4d_uint32, nsz0, nsz1, nsz2, nsz3, ndata1d))
+				{
+					this->setError(1);
+					if (ndata1d) {delete ndata1d; ndata1d=0;}
+					return;
+				}
+				for (c=bpos_c, c0=0;c<=epos_c;c++, c0++)
+				{
+					for (k=bpos_z, k0=0;k<=epos_z;k++, k0++)
+					{
+						for (j=bpos_y, j0=0;j<=epos_y;j++, j0++)
+						{
+							for (i=bpos_x, i0=0;i<=epos_x;i++, i0++)
+							{
+								ndata4d_uint32[c0][k0][j0][i0] = data4d_uint32[c][k][j][i];
+							}
+						}
+					}
+				}
+
+				break;
+
+
 			case V3D_FLOAT32:
 				ndata1d = new unsigned char [nsz0 * nsz1 * nsz2 * nsz3 * sizeof(float)];
 				if (!ndata1d)
@@ -1374,6 +1579,7 @@
 	this->setRawDataPointer( ndata1d );
 
 	data4d_float32 = ndata4d_float32;
+	data4d_uint32 = ndata4d_uint32;
 	data4d_uint16 = ndata4d_uint16;
 	data4d_uint8 = ndata4d_uint8;
 
@@ -1418,12 +1624,24 @@
 
 			for(i=0;i<this->getCDim();i++)
 			{
-				p_vmax[i] = (double)maxInVector((USHORTINT16 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(USHORTINT16), channelPageSize, tmppos);
-				p_vmin[i] = (double)minInVector((USHORTINT16 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(USHORTINT16), channelPageSize, tmppos);
+				p_vmax[i] = (double)maxInVector((uint16 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(uint16), channelPageSize, tmppos);
+				p_vmin[i] = (double)minInVector((uint16 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(uint16), channelPageSize, tmppos);
 			}
 
-			//v3d_msg("Warning: this data type UINT16 has not been supported in display yet.\n");
+			break;
 
+		case V3D_UINT32:
+			data4d_virtual = (void ****)data4d_uint32;
+
+			for(i=0;i<this->getCDim();i++)
+			{
+				p_vmax[i] = (double)maxInVector((uint32 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(uint32), channelPageSize, tmppos);
+				p_vmin[i] = (double)minInVector((uint32 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(uint32), channelPageSize, tmppos);
+			}
+
+
+			v3d_msg("Warning: this data type UINT32 has not been supported in display yet.\n");
+
 			break;
 
 		case V3D_FLOAT32:
@@ -1854,7 +2072,7 @@
 
 	V3DLONG sz_time_old = this->getTDim();
 	TimePackType timepacktype_old = this->getTimePackType();
-	
+
 	cleanExistData_butKeepFileName();
 
 	this->setRawDataPointer( ndata1d );
@@ -1905,7 +2123,7 @@
 			for(i=0;i<this->getCDim();i++)
 			{
 				printf("my4dimage setimage %d [%d %d %d %d] %ld %p %p\n", i, this->getXDim(), this->getYDim(), this->getZDim(), this->getCDim(), channelPageSize, this->getRawData(), data4d_virtual);
- 
+
 				p_vmax[i] = (double)maxInVector((unsigned char *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(unsigned char), channelPageSize, tmppos);
 				p_vmin[i] = (double)minInVector((unsigned char *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(unsigned char), channelPageSize, tmppos);
 			}
@@ -1922,8 +2140,8 @@
 
 			for(i=0;i<this->getCDim();i++)
 			{
-				p_vmax[i] = (double)maxInVector((USHORTINT16 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(USHORTINT16), channelPageSize, tmppos);
-				p_vmin[i] = (double)minInVector((USHORTINT16 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(USHORTINT16), channelPageSize, tmppos);
+				p_vmax[i] = (double)maxInVector((uint16 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(uint16), channelPageSize, tmppos);
+				p_vmin[i] = (double)minInVector((uint16 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(uint16), channelPageSize, tmppos);
 			}
 
 			//printf("Warning: this data type UINT16 has not been supported in display yet.\n");
@@ -1932,6 +2150,27 @@
 
 			break;
 
+
+		case V3D_UINT32:
+			if (!new4dpointer_v3d(data4d_uint32, this->getXDim(), this->getYDim(), this->getZDim(), this->getCDim(), this->getRawData() ))
+			{
+				this->setError(1);
+        this->deleteRawDataAndSetPointerToNull();
+				return false;
+			}
+			data4d_virtual = (void ****)data4d_uint32;
+
+			for(i=0;i<this->getCDim();i++)
+			{
+				p_vmax[i] = (double)maxInVector((uint32 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(uint32), channelPageSize, tmppos);
+				p_vmin[i] = (double)minInVector((uint32 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(uint32), channelPageSize, tmppos);
+			}
+
+			v3d_msg("Warning: this data type UINT32 has not been supported in display yet.\n");
+
+			break;
+
+
 		case V3D_FLOAT32:
 			if (!new4dpointer_v3d(data4d_float32, this->getXDim(), this->getYDim(), this->getZDim(), this->getCDim(), this->getRawData() ))
 			{
@@ -1947,7 +2186,7 @@
 				p_vmin[i] = (double)minInVector((float *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(float), channelPageSize, tmppos);
 			}
 
-			v3d_msg("Warning: this data type FLOAT32 has not been supported in display yet.\n");
+			v3d_msg("Warning: this data type I'M THE SUSPECT FLOAT32 has not been supported in display yet.\n");
 
 			break;
 
@@ -2178,6 +2417,77 @@
 			break;
 
 
+		case V3D_UINT32:
+			switch (my_axiscode)
+		{
+			case axis_x:
+			{
+				V3DLONG hsz0=floor((double)(this->getXDim()-1)/2.0); if (hsz0*2<this->getXDim()-1) hsz0+=1;
+				for (c=0;c<this->getCDim();c++)
+					for (k=0;k<this->getZDim();k++)
+						for (j=0;j<this->getYDim();j++)
+							for (i=0;i<hsz0;i++)
+							{
+								unsigned short int tmpv = data4d_uint32[c][k][j][this->getXDim()-i-1];
+								data4d_uint32[c][k][j][this->getXDim()-1-i] = data4d_uint32[c][k][j][i];
+								data4d_uint32[c][k][j][i] = tmpv;
+							}
+			}
+				break;
+			case axis_y:
+			{
+				V3DLONG hsz1=floor((double)(this->getYDim()-1)/2.0); if (hsz1*2<this->getYDim()-1) hsz1+=1;
+				for (c=0;c<this->getCDim();c++)
+					for (k=0;k<this->getZDim();k++)
+						for (j=0;j<hsz1;j++)
+							for (i=0;i<this->getXDim();i++)
+							{
+								unsigned short int tmpv = data4d_uint32[c][k][this->getYDim()-j-1][i];
+								data4d_uint32[c][k][this->getYDim()-1-j][i] = data4d_uint32[c][k][j][i];
+								data4d_uint32[c][k][j][i] = tmpv;
+							}
+			}
+				break;
+			case axis_z:
+			{
+				V3DLONG hsz2=floor((double)(this->getZDim()-1)/2.0); if (hsz2*2<this->getZDim()-1) hsz2+=1;
+				for (c=0;c<this->getCDim();c++)
+					for (k=0;k<hsz2;k++)
+						for (j=0;j<this->getYDim();j++)
+							for (i=0;i<this->getXDim();i++)
+							{
+								unsigned short int tmpv = data4d_uint32[c][this->getZDim()-k-1][j][i];
+								data4d_uint32[c][this->getZDim()-1-k][j][i] = data4d_uint32[c][k][j][i];
+								data4d_uint32[c][k][j][i] = tmpv;
+							}
+			}
+				break;
+			case axis_c:
+			{
+				V3DLONG hsz3=floor((double)(this->getCDim()-1)/2.0); if (hsz3*2<this->getCDim()-1) hsz3+=1;
+				for (c=0;c<hsz3;c++)
+				{
+					for (k=0;k<this->getZDim();k++)
+						for (j=0;j<this->getYDim();j++)
+							for (i=0;i<this->getXDim();i++)
+							{
+								unsigned short int tmpv = data4d_uint32[this->getCDim()-c-1][k][j][i];
+								data4d_uint32[this->getCDim()-c-1][k][j][i] = data4d_uint32[c][k][j][i];
+								data4d_uint8[c][k][j][i] = tmpv;
+							}
+
+					double tmpc;
+					tmpc = p_vmax[this->getCDim()-c-1]; p_vmax[this->getCDim()-c-1] = p_vmax[c]; p_vmax[c] = tmpc;
+					tmpc = p_vmin[this->getCDim()-c-1]; p_vmin[this->getCDim()-c-1] = p_vmin[c]; p_vmin[c] = tmpc;
+				}
+			}
+				break;
+			default:
+				break;
+		}
+			break;
+
+
 		case V3D_FLOAT32:
 			switch (my_axiscode)
 		{
@@ -2344,17 +2654,42 @@
 							t = data4d_uint16[c][k][j][i];
 							if (t>higher_th) t=higher_th;
 							else if (t<lower_th) t=lower_th;
-							data4d_uint16[c][k][j][i] = (USHORTINT16)((t - lower_th)*rate + target_min);
+							data4d_uint16[c][k][j][i] = (uint16)((t - lower_th)*rate + target_min);
 						}
 
 				//update the min and max
 				V3DLONG tmppos;
-				p_vmax[c] = (double)maxInVector((USHORTINT16 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
-				p_vmin[c] = (double)minInVector((USHORTINT16 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
+				p_vmax[c] = (double)maxInVector((uint16 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
+				p_vmin[c] = (double)minInVector((uint16 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
 				printf("updated channel [%ld] max=[%ld] min=[%d]\n", c, V3DLONG(p_vmax[c]), V3DLONG(p_vmin[c]));
 			}
 			break;
 
+
+		case V3D_UINT32:
+			for (c=0;c<this->getCDim();c++)
+			{
+				if (channo>=0 && c!=channo)
+					continue;
+				for (k=0;k<this->getZDim();k++)
+					for (j=0;j<this->getYDim();j++)
+						for (i=0;i<this->getXDim();i++)
+						{
+							t = data4d_uint32[c][k][j][i];
+							if (t>higher_th) t=higher_th;
+							else if (t<lower_th) t=lower_th;
+							data4d_uint32[c][k][j][i] = (uint32)((t - lower_th)*rate + target_min);
+						}
+
+				//update the min and max
+				V3DLONG tmppos;
+				p_vmax[c] = (double)maxInVector((uint32 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
+				p_vmin[c] = (double)minInVector((uint32 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
+				printf("updated channel [%ld] max=[%ld] min=[%d]\n", c, V3DLONG(p_vmax[c]), V3DLONG(p_vmin[c]));
+			}
+			break;
+
+
 		case V3D_FLOAT32:
 			for (c=0;c<this->getCDim();c++)
 			{
@@ -2434,12 +2769,33 @@
 
 				//update the min and max
 				V3DLONG tmppos;
-				p_vmax[c] = (double)maxInVector((USHORTINT16 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
-				p_vmin[c] = (double)minInVector((USHORTINT16 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
+				p_vmax[c] = (double)maxInVector((uint16 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
+				p_vmin[c] = (double)minInVector((uint16 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
 				printf("updated channel [%ld] max=[%ld] min=[%d]\n", c, V3DLONG(p_vmax[c]), V3DLONG(p_vmin[c]));
 			}
 			break;
 
+		case V3D_UINT32:
+			for (c=0;c<this->getCDim();c++)
+			{
+				if (channo>=0 && c!=channo)
+					continue;
+				for (k=0;k<this->getZDim();k++)
+					for (j=0;j<this->getYDim();j++)
+						for (i=0;i<this->getXDim();i++)
+						{
+							if (data4d_uint32[c][k][j][i]<th) data4d_uint32[c][k][j][i]=0;
+						}
+
+				//update the min and max
+				V3DLONG tmppos;
+				p_vmax[c] = (double)maxInVector((uint32 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
+				p_vmin[c] = (double)minInVector((uint32 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
+				printf("updated channel [%ld] max=[%ld] min=[%d]\n", c, V3DLONG(p_vmax[c]), V3DLONG(p_vmin[c]));
+			}
+			break;
+
+
 		case V3D_FLOAT32:
 			for (c=0;c<this->getCDim();c++)
 			{
@@ -2516,12 +2872,33 @@
 
 				//update the min and max
 				V3DLONG tmppos;
-				p_vmax[c] = (double)maxInVector((USHORTINT16 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
-				p_vmin[c] = (double)minInVector((USHORTINT16 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
+				p_vmax[c] = (double)maxInVector((uint16 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
+				p_vmin[c] = (double)minInVector((uint16 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
 				printf("updated channel [%ld] max=[%ld] min=[%d]\n", c, V3DLONG(p_vmax[c]), V3DLONG(p_vmin[c]));
 			}
 			break;
 
+		case V3D_UINT32:
+			for (c=0;c<this->getCDim();c++)
+			{
+				if (channo>=0 && c!=channo)
+					continue;
+				for (k=0;k<this->getZDim();k++)
+					for (j=0;j<this->getYDim();j++)
+						for (i=0;i<this->getXDim();i++)
+						{
+							data4d_uint32[c][k][j][i] = (data4d_uint32[c][k][j][i]<th)?0:1;
+						}
+
+				//update the min and max
+				V3DLONG tmppos;
+				p_vmax[c] = (double)maxInVector((uint32 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
+				p_vmin[c] = (double)minInVector((uint32 *)(this->getRawData())+c*channelPageSize, channelPageSize, tmppos);
+				printf("updated channel [%ld] max=[%ld] min=[%d]\n", c, V3DLONG(p_vmax[c]), V3DLONG(p_vmin[c]));
+			}
+			break;
+
+
 		case V3D_FLOAT32:
 			for (c=0;c<this->getCDim();c++)
 			{
@@ -2600,7 +2977,7 @@
 			{
 				int tmpr=0, tmpg=0, tmpb=0;
 
-				USHORTINT16 ****ptmp = (USHORTINT16 ****)data4d_virtual;
+				uint16 ****ptmp = (uint16 ****)data4d_virtual;
 				if (getCDim()>=3)
 					tmpb = int(ptmp[2][curFocusZ][curFocusY][curFocusX]);
 				if (getCDim()>=2)
@@ -2614,6 +2991,24 @@
 			}
 				break;
 
+			case V3D_UINT32:
+			{
+				int tmpr=0, tmpg=0, tmpb=0;
+
+				uint32 ****ptmp = (uint32 ****)data4d_virtual;
+				if (getCDim()>=3)
+					tmpb = int(ptmp[2][curFocusZ][curFocusY][curFocusX]);
+				if (getCDim()>=2)
+					tmpg = int(ptmp[1][curFocusZ][curFocusY][curFocusX]);
+				if (getCDim()>=1)
+					tmpr = int(ptmp[0][curFocusZ][curFocusY][curFocusX]);
+
+				v1.setNum(tmpr); v1.append(",");
+				v2.setNum(tmpg); v2.append(",");
+				v3.setNum(tmpb); v3.append(")");
+			}
+				break;
+
 			case V3D_FLOAT32:
 			{
 				float tmpr=0, tmpg=0, tmpb=0;
@@ -2729,7 +3124,7 @@
 
 void My4DImage::cleanExistData_only4Dpointers()
 {
-	if (data4d_uint8 || data4d_uint16 || data4d_float32 || data4d_virtual) //080416. Only try to free space and set up b_error flag if applicable
+	if (data4d_uint8 || data4d_uint16 || data4d_uint32 || data4d_float32 || data4d_virtual) //080416. Only try to free space and set up b_error flag if applicable
 	{
 		switch ( this->getDatatype() )
 		{
@@ -2743,6 +3138,11 @@
 				data4d_virtual = 0;
 				break;
 
+			case V3D_UINT32:
+				delete4dpointer_v3d(data4d_uint32, this->getXDim(), this->getYDim(), this->getZDim(), this->getCDim());
+				data4d_virtual = 0;
+				break;
+
 			case V3D_FLOAT32:
 				delete4dpointer_v3d(data4d_float32, this->getXDim(), this->getYDim(), this->getZDim(), this->getCDim());
 				data4d_virtual = 0;
@@ -2816,7 +3216,7 @@
 	V3DLONG i,j,k, nn;
 
 	//  unsigned char *p1dtmp_uint8 = 0;
-	//  USHORTINT16 *p1dtmp_uint16 = 0;
+	//  uint16 *p1dtmp_uint16 = 0;
 	float *p1dtmp_float32 = 0;
 
 	switch( this->getDatatype() )
@@ -2847,7 +3247,7 @@
 			break;
 
 		case V3D_UINT16:
-			//	  p1dtmp_uint16 = new USHORTINT16 [(x1-x0+1)*(y1-y0+1)*(z1-z0+1)];
+			//	  p1dtmp_uint16 = new uint16 [(x1-x0+1)*(y1-y0+1)*(z1-z0+1)];
 			p1dtmp_float32 = new float [(x1-x0+1)*(y1-y0+1)*(z1-z0+1)];
 			nn=0;
 			for (k=z0;k<=z1;k++)
@@ -2864,6 +3264,20 @@
 			curptval = data4d_uint16[c][z][y][x];
 			break;
 
+		case V3D_UINT32:
+			p1dtmp_float32 = new float [(x1-x0+1)*(y1-y0+1)*(z1-z0+1)];
+			nn=0;
+			for (k=z0;k<=z1;k++)
+			{
+				for (j=y0;j<=y1;j++)
+					for (i=x0;i<=x1;i++)
+						p1dtmp_float32[nn++] = float(data4d_uint32[c][k][j][i]);
+			}
+			moment(p1dtmp_float32, nn, ave, adev, sdev, var, skew, curt);
+			delete []p1dtmp_float32; p1dtmp_float32=0;
+			curptval = data4d_uint32[c][z][y][x];
+			break;
+
 		case V3D_FLOAT32:
 			p1dtmp_float32 = new float [(x1-x0+1)*(y1-y0+1)*(z1-z0+1)];
 			nn=0;
@@ -3549,6 +3963,13 @@
 							  pt.ev_pc1, pt.ev_pc2, pt.ev_pc3, b_win_shape, b_disp_CoM_etc);
 			break;
 
+		case V3D_UINT32:
+			compute_win3d_pca(data4d_uint32[cc], this->getXDim(), this->getYDim(), this->getZDim(),
+							  xx, yy, zz,
+							  rr, rr, rr,
+							  pt.ev_pc1, pt.ev_pc2, pt.ev_pc3, b_win_shape, b_disp_CoM_etc);
+			break;
+
 		case V3D_FLOAT32:
 			compute_win3d_pca(data4d_float32[cc], this->getXDim(), this->getYDim(), this->getZDim(),
 							  xx, yy, zz,
@@ -3948,6 +4369,11 @@
 			data4d_virtual = 0;
 			break;
 
+		case V3D_UINT32:
+			delete4dpointer_v3d(data4d_uint32, this->getXDim(), this->getYDim(), this->getZDim(), this->getCDim());
+			data4d_virtual = 0;
+			break;
+
 		case V3D_FLOAT32:
 			delete4dpointer_v3d(data4d_float32, this->getXDim(), this->getYDim(), this->getZDim(), this->getCDim());
 			data4d_virtual = 0;
@@ -3997,12 +4423,28 @@
 			data4d_virtual = (void ****)data4d_uint16;
 			for(i=0;i<this->getCDim();i++)
 			{
-				p_vmax[i] = (double)maxInVector((USHORTINT16 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(USHORTINT16), channelPageSize, tmppos);
-				p_vmin[i] = (double)minInVector((USHORTINT16 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(USHORTINT16), channelPageSize, tmppos);
+				p_vmax[i] = (double)maxInVector((uint16 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(uint16), channelPageSize, tmppos);
+				p_vmin[i] = (double)minInVector((uint16 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(uint16), channelPageSize, tmppos);
 			}
 
-			//v3d_msg("Warning: this data type UINT16 has not been supported in display yet.\n");
+			break;
 
+		case V3D_UINT32:
+			if (!new4dpointer_v3d(data4d_uint32, this->getXDim(), this->getYDim(), this->getZDim(), this->getCDim(), (this->getRawData())))
+			{
+				this->setError(1);
+        this->deleteRawDataAndSetPointerToNull();
+				return false;
+			}
+			data4d_virtual = (void ****)data4d_uint32;
+			for(i=0;i<this->getCDim();i++)
+			{
+				p_vmax[i] = (double)maxInVector((uint32 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(uint32), channelPageSize, tmppos);
+				p_vmin[i] = (double)minInVector((uint32 *)(this->getRawData())+(V3DLONG)i*channelPageSize*sizeof(uint32), channelPageSize, tmppos);
+			}
+
+			v3d_msg("Warning: this data type UINT32 has not been supported in display yet.\n");
+
 			break;
 
 		case V3D_FLOAT32:
@@ -4852,7 +5294,7 @@
 			QVector<int> vec;
 
 			V3DLONG maxori = 0, minori = 0;
-			USHORTINT16 *curp = (USHORTINT16 *)this->getRawData();
+			uint16 *curp = (uint16 *)this->getRawData();
 			V3DLONG icurp = c*pagesz;
 			curp += icurp;
 
@@ -5034,7 +5476,7 @@
 
 	if ( this->getDatatype() ==V3D_UINT16)
 	{
-		USHORTINT16 *** p3d = data4d_uint16[0];
+		uint16 *** p3d = data4d_uint16[0];
 
 		V3DLONG i,j,k;
 		for (k=0;k<tsz2;k++)
@@ -5125,9 +5567,9 @@
 		if (outvol1d) {delete []outvol1d;outvol1d=0;}
 		return false;
 	}
-	
+
 	setNewImageData(outvol1d, tsz0, tsz1, tsz2, tsz3, V3D_UINT8);
-	
+
 	getXWidget()->reset(); //to force reset the color etc
 	return true;
 }
