Commit 7f3e2abb authored by David Wiesner's avatar David Wiesner
Browse files

ADD: Options MITOGEN_DEBUG_MULTITHREADING, GTGEN_WITH_LOCKVISUALIZATION.

ADD: New REPORT macro DEBUG_THR_REPORT.
ADD: Cell ID into filename of visualization.
ADD: i3d::Resample when saving visualization.
BUG_FIX: Visualization of sphere-locks wasn't correct.
parent 8f94e9e9
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ set(CMAKE_VERBOSE_MAKEFILE ON CACHE STRING
# set the debug/release version
#
option(DEBUG_VERSION "Shall I add debug information?" OFF)

if (DEBUG_VERSION)
	set(CMAKE_BUILD_TYPE "RELEASE" CACHE STATIC "" FORCE)
	add_definitions(-DMITOGEN_DEBUG -std=c++11 -Wall)
@@ -47,6 +46,11 @@ else (DEBUG_VERSION)
	add_definitions(-std=c++11 -Wall)
endif (DEBUG_VERSION)

option(DEBUG_MULTITHREADING "Shall I add multi-threading debug information?" OFF)
if (DEBUG_MULTITHREADING)
    add_definitions(-DMITOGEN_DEBUG_MULTITHREADING)
endif (DEBUG_MULTITHREADING)

#
# options
#
@@ -60,6 +64,7 @@ option (USE_REAL_PSF "Shall I use real PSF for final images (slower!!!)?" OFF)
option (HIGH_SNR "Shall I generate final images of higher SNR (not applied if real PSF is used)?" ON)
option (SAVE_TIFFS "Shall I save 3D TIFF images rather than ICS images?" OFF)
option (SAVE_FLOWFIELDS "Shall I also output flow field images?" OFF)
option (SAVE_LOCK_VISUALIZATION "Shall I save visualization of custom-shaped locks? (Only when DO_MULTITHREADING is turned ON.)" OFF)
option (DO_RIGID_MOTION "Shall I include rigid movement (translation plus rotation) of cells into the simulation?" ON)
option (DO_NONRIGID_MOTION "Shall I include non-rigid movement (smooth shape deformation) of cells into the simulation?" ON)
option (DO_FLAT_2DMOTION "Shall I prevent cells from movement along z-axis?" OFF)
@@ -96,6 +101,9 @@ endif (SAVE_TIFFS)
if (SAVE_FLOWFIELDS)
    add_definitions(-DGTGEN_WITH_FLOWFIELDS)
endif (SAVE_FLOWFIELDS)
if (SAVE_LOCK_VISUALIZATION)
    add_definitions(-DGTGEN_WITH_LOCKVISUALIZATION)
endif (SAVE_LOCK_VISUALIZATION)
if (DO_RIGID_MOTION)
    add_definitions(-DGTGEN_WITH_RIGIDMOTION)
endif (DO_RIGID_MOTION)
+1 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ template <class MV, class PV> class Cell
					isRunning_st(false),
#endif
					configIni(_configIni),
					// needed to be initialized here for the visualization
					ID(GetNewCellID<MV>()),
					parentID(parenttID),
					centrosomeA(NULL),
+6 −0
Original line number Diff line number Diff line
@@ -88,6 +88,12 @@
   #define DEBUG_REPORT(x)
#endif

#ifdef MITOGEN_DEBUG_MULTITHREADING
   #define DEBUG_THR_REPORT(x) REPORT(x)
#else
   #define DEBUG_THR_REPORT(x)
#endif

/// helper macro to unify error reports
#define ERROR_REPORT(x) std::string(_SHORT_FILE_)+"::"+__FUNCTION__+"(): "+x

+9 −5
Original line number Diff line number Diff line
@@ -257,9 +257,11 @@ Scheduler<MV, PV>::Scheduler(const IniHandler _configIni,
	 else
	   close(file);
	 
	 // set visualization parameters ///////////////////////////////////////////
#ifdef GTGEN_WITH_LOCKVISUALIZATION	   
	 // set visualization parameters
	 sceneLocks_st->setImgRes(this->GetSceneRes());
	 sceneLocks_st->setImgSize(this->GetSceneSizePX());
#endif
}

//-----------------------------------------------------------------------------
@@ -397,9 +399,11 @@ Scheduler<MV, PV>::Scheduler(const IniHandler _configIni) :
	 else
	   close(file);
	 
	 // set visualization parameters ///////////////////////////////////////////
#ifdef GTGEN_WITH_LOCKVISUALIZATION  
	 // set visualization parameters
	 sceneLocks_st->setImgRes(this->GetSceneRes());
	 sceneLocks_st->setImgSize(this->GetSceneSizePX());
#endif
}

//-----------------------------------------------------------------------------
@@ -847,7 +851,7 @@ void Scheduler<MV, PV>::Run_st(const size_t noFrames)
	// detect available hardware threads
	// (equals to 0 if function can't determine the number of available threads)
	const size_t hwThreads_st = std::thread::hardware_concurrency();
	DEBUG_REPORT("Available hardware threads: " << hwThreads_st);
	DEBUG_THR_REPORT("Detected available hardware threads: " << hwThreads_st);
	
	// in current implementation, using more than 8 threads doesn't offer
	// any performance improvements (only increases scheduling overhead)
+76 −63
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@
*
***********************************************************************/

#ifdef GTGEN_WITH_LOCKVISUALIZATION
	#include <i3d/transform.h> // i3d::Resample
#endif

#include "regionlock.h"

@@ -122,17 +125,13 @@ lock_handle SceneLocks::checkAndLock(CustomLock* newLock)
			// *** Lock acquired ***
			listOfCustomLocks.push_back(newLock);
			lockAcquired = true;
#ifdef MITOGEN_DEBUG
#ifdef MITOGEN_DEBUG_MULTITHREADING
			newLock->printLockInfo();
#endif
		
			// save visualization //////////////////////////////////////////////
			if (newLock->getLockType() == sphere_lock)
#ifdef GTGEN_WITH_LOCKVISUALIZATION
			// save visualization
			saveVisualization(newLock, true);
			
			/*DEBUG_REPORT("*** Lock acquired - timePoint: "
				<< newLockHandle->getFromTimePoint() << " to "
				<< newLockHandle->getToTimePoint());*/
#endif
		}
		else
		{
@@ -200,13 +199,16 @@ bool SceneLocks::ableToLockSphere(CustomLock* curLock, CustomLock* newLock)
	return true;
}


// visualization ///////////////////////////////////////////////////////////////
// (currently only for sphere-locks on sceneMasks)
#ifdef GTGEN_WITH_LOCKVISUALIZATION
void SceneLocks::saveVisualization(CustomLock* newLock, bool addedLock)
{
	using namespace std;
	
	// TODO: currently implemented only for sphere-locks on sceneMasks
	if (newLock->getLockType() != sphere_lock
		|| newLock->getSceneType() != masks)
		return;
	
	// draw only timePoints influenced by the current lock
	const size_t drawFromTimePoint = newLock->getFromTimePoint();
	const size_t drawToTimePoint = newLock->getToTimePoint();
@@ -265,6 +267,7 @@ void SceneLocks::saveVisualization(CustomLock* newLock, bool addedLock)
					int z = lockImg->GetZ(i);
		
					// write cellID if voxel is in the sphere
					// (cell IDs start from 1)
					if (pow((x-x0), 2) + pow((y-y0), 2) + pow((z-z0), 2) <= pow(r, 2))
						*m=cellID;
				}
@@ -273,8 +276,6 @@ void SceneLocks::saveVisualization(CustomLock* newLock, bool addedLock)
			++iter;
		}
		
		if (sphereCount > 0)
		{
		// get time stamp
		const report_clock::time_point currentTime_st = report_clock::now();
		const report_clock::duration runTime_st = currentTime_st - this->startTime;
@@ -290,7 +291,7 @@ void SceneLocks::saveVisualization(CustomLock* newLock, bool addedLock)
		const chrono::milliseconds msec =
			chrono::duration_cast<chrono::milliseconds> (runTime_msec_st % chrono::seconds(1));
			
			// get date
		// get date & time
		time_t rawtime;
		struct tm* timeinfo;
		time (&rawtime);
@@ -310,6 +311,7 @@ void SceneLocks::saveVisualization(CustomLock* newLock, bool addedLock)
			addedOrRemoved = "afterLockRemoved";				
			
		// generate file name
		SphereLock* _newLock = dynamic_cast<SphereLock*>(newLock);
		stringstream fileName;
		fileName << "lockImg_masks_tp" << setfill('0')
			<< setw(4) << tP << "_"
@@ -321,15 +323,26 @@ void SceneLocks::saveVisualization(CustomLock* newLock, bool addedLock)
   			<< "time" << hour << "h" << min << "m" << sec << "s_" 
   			<< "date" << year << "-" << month << "-" << day << "_"
   			<< sphereCount << "locks_"
   			<< "cellId" << _newLock->getCellID() << "_"
   			<< addedOrRemoved << "." << SUFFIX;
   		
   		// resample image to custom resolution
   		i3d::Image3d<i3d::GRAY8>* resampledLockImg = new i3d::Image3d<i3d::GRAY8>();
   		i3d::Resample(*lockImg, *resampledLockImg,
   			this->imgSize.x/4,
   			this->imgSize.y/4,
   			this->imgSize.z/4);

   		// save image to HDD
	   		lockImg->SaveImage(fileName.str().c_str());   		
		}
   		resampledLockImg->SaveImage(fileName.str().c_str());
   		
   		// free memory
   		delete resampledLockImg;   		
	}

	// free memory
	delete lockImg;
}
#endif

Loading