Skip to content

Instantly share code, notes, and snippets.

Created November 24, 2011 23:54
Show Gist options
  • Save anonymous/1392533 to your computer and use it in GitHub Desktop.
Save anonymous/1392533 to your computer and use it in GitHub Desktop.
Geradus patch for Clarity v1.0.0 which, amongst other things, allows it to compile under Ubuntu 11.10
Index: apps/DeconvolveRawImages/DeconvolveRawImages.cxx
===================================================================
--- apps/DeconvolveRawImages/DeconvolveRawImages.cxx (.../cquammen-Clarity-v1.0.0-5-c9d0889) (revision 643)
+++ apps/DeconvolveRawImages/DeconvolveRawImages.cxx (.../cquammen-Clarity) (revision 658)
@@ -21,6 +21,13 @@
* Author: Cory Quammen <cquammen@cs.unc.edu>
*/
+/*
+ * This is a derivative work of Clarity provided as a third-party
+ * library in Gerardus
+ *
+ * Minor fixes by Ramon Casero <rcasero@gmail.com>
+ */
+
/* This example shows how to read unsigned short images, run a deconvolution
* routine on them, and write the result. */
@@ -61,7 +68,7 @@
if (!psfFp)
printf("ERROR: Could not open PSF file '%s'\n'", psfFileName);
if (!outputFp)
- printf("ERROR: Could not open file '%' for writing\n", outputFileName);
+ printf("ERROR: Could not open file '%s' for writing\n", outputFileName);
if (inputFp) fclose(inputFp);
if (psfFp) fclose(psfFp);
@@ -75,9 +82,17 @@
unsigned short *inputImage = new unsigned short[inputImageSize];
unsigned short *psfImage = new unsigned short[psfImageSize];
- fread(inputImage, sizeof(unsigned short), inputImageSize, inputFp);
+ if ((size_t)inputImageSize
+ != fread(inputImage, sizeof(unsigned short), inputImageSize, inputFp)) {
+ printf("Error reading input image file\n");
+ return 1;
+ }
fclose(inputFp);
- fread(psfImage, sizeof(unsigned short), psfImageSize, psfFp);
+ if ((size_t)psfImageSize
+ != fread(psfImage, sizeof(unsigned short), psfImageSize, psfFp)) {
+ printf("Error reading PSF file\n");
+ return 1;
+ }
fclose(psfFp);
// Cast to floats
Index: include/internal/Stopwatch.h
===================================================================
--- include/internal/Stopwatch.h (.../cquammen-Clarity-v1.0.0-5-c9d0889) (revision 643)
+++ include/internal/Stopwatch.h (.../cquammen-Clarity) (revision 658)
@@ -20,6 +20,13 @@
// $Id: Stopwatch.h,v 1.1 2008/09/11 14:56:35 cquammen Exp $
//------------------------------------------------------------------------------
+/*
+ * This is a derivative work of Clarity provided as a third-party
+ * library in Gerardus
+ *
+ * Minor fixes by Ramon Casero <rcasero@gmail.com>
+ */
+
//------------------------------------------------------------------------------
// The interface is as follows:
// The first call to Start() begins the timer counting.
@@ -118,8 +125,8 @@
float elapsedTime; // the accumulated elapsed time
int numStarts; // number of calls to Start since last Reset
char sw_name[STOPWATCH_MAX_NAME]; // a name for the stopwatch
+ bool running;
const char *sw_type;
- bool running;
// THESE ARE THE METHODS SUBCLASSES NEED TO IMPLEMENT
virtual void markTime()=0; // jot down the current timestamp
Index: src/WienerDeconvolve.cxx
===================================================================
--- src/WienerDeconvolve.cxx (.../cquammen-Clarity-v1.0.0-5-c9d0889) (revision 643)
+++ src/WienerDeconvolve.cxx (.../cquammen-Clarity) (revision 658)
@@ -21,9 +21,17 @@
* Author: Cory Quammen <cquammen@cs.unc.edu>
*/
+/*
+ * This is a derivative work of Clarity provided as a third-party
+ * library in Gerardus
+ *
+ * Minor fixes by Ramon Casero <rcasero@gmail.com>
+ */
#include "Clarity.h"
+#include <cstdlib>
+
#include <iostream>
#include <fftw3.h>
#include <math.h>
Index: src/FFT.cxx
===================================================================
--- src/FFT.cxx (.../cquammen-Clarity-v1.0.0-5-c9d0889) (revision 643)
+++ src/FFT.cxx (.../cquammen-Clarity) (revision 658)
@@ -21,6 +21,12 @@
* Author: Cory Quammen <cquammen@cs.unc.edu>
*/
+/*
+ * This is a derivative work of Clarity provided as a third-party
+ * library in Gerardus
+ *
+ * Minor fixes by Ramon Casero <rcasero@gmail.com>
+ */
#include "Clarity.h"
@@ -105,7 +111,7 @@
fftTimer.Start();
#endif // TIME_FFT
- int numVoxels = nx*ny*nz;
+ // int numVoxels = nx*ny*nz;
#ifdef BUILD_WITH_CUDA
if (g_CUDACapable) {
Index: src/MaximumLikelihoodDeconvolve.cxx
===================================================================
--- src/MaximumLikelihoodDeconvolve.cxx (.../cquammen-Clarity-v1.0.0-5-c9d0889) (revision 643)
+++ src/MaximumLikelihoodDeconvolve.cxx (.../cquammen-Clarity) (revision 658)
@@ -21,6 +21,12 @@
* Author: Cory Quammen <cquammen@cs.unc.edu>
*/
+/*
+ * This is a derivative work of Clarity provided as a third-party
+ * library in Gerardus
+ *
+ * Minor fixes by Ramon Casero <rcasero@gmail.com>
+ */
#include "Clarity.h"
@@ -133,7 +139,7 @@
Clarity_ReduceSum(&energy, inImage, nx*ny*nz);
// Iterate
- int numVoxels = nx*ny*nz;
+ // int numVoxels = nx*ny*nz;
for (unsigned k = 0; k < iterations; k++) {
float* currentGuess = (k == 0 ? inImage : iPtr);
float* newGuess = (k == iterations-1 ? outImage : iPtr);
Index: src/Clarity.cxx
===================================================================
--- src/Clarity.cxx (.../cquammen-Clarity-v1.0.0-5-c9d0889) (revision 643)
+++ src/Clarity.cxx (.../cquammen-Clarity) (revision 658)
@@ -22,8 +22,17 @@
*/
+/*
+ * This is a derivative work of Clarity provided as a third-party
+ * library in Gerardus
+ *
+ * Minor fixes by Ramon Casero <rcasero@gmail.com>
+ */
+
#include "Clarity.h"
+#include <cstdlib>
+
#include <fftw3.h>
#include <iostream>
Index: src/Memory.cxx
===================================================================
--- src/Memory.cxx (.../cquammen-Clarity-v1.0.0-5-c9d0889) (revision 643)
+++ src/Memory.cxx (.../cquammen-Clarity) (revision 658)
@@ -21,6 +21,12 @@
* Author: Cory Quammen <cquammen@cs.unc.edu>
*/
+/*
+ * This is a derivative work of Clarity provided as a third-party
+ * library in Gerardus
+ *
+ * Minor fixes by Ramon Casero <rcasero@gmail.com>
+ */
#include "Clarity.h"
#include "Memory.h"
@@ -46,9 +52,9 @@
ClarityResult_t result = CLARITY_SUCCESS;
- size_t totalSize = size*2*nz*ny*(nx/2 + 1);
#ifdef BUILD_WITH_CUDA
if (g_CUDACapable) {
+ size_t totalSize = size*2*nz*ny*(nx/2 + 1);
cudaError_t cudaResult = cudaMalloc(buffer, totalSize);
if (cudaResult != cudaSuccess) {
return CLARITY_DEVICE_OUT_OF_MEMORY;
@@ -56,6 +62,7 @@
} else
#endif // BUILD_WITH_CUDA
{
+ size_t totalSize = size*2*nz*ny*(nx/2 + 1);
*buffer = fftwf_malloc(totalSize);
if (*buffer == NULL) {
result = CLARITY_OUT_OF_MEMORY;
@@ -72,9 +79,9 @@
ClarityResult_t result = CLARITY_SUCCESS;
- size_t totalSize = size*nz*ny*nx;
#ifdef BUILD_WITH_CUDA
if (g_CUDACapable) {
+ size_t totalSize = size*nz*ny*nx;
cudaError_t cudaResult = cudaMalloc(buffer, totalSize);
if (cudaResult != cudaSuccess) {
return CLARITY_DEVICE_OUT_OF_MEMORY;
Index: src/IDivergenceDeconvolve.cxx
===================================================================
--- src/IDivergenceDeconvolve.cxx (.../cquammen-Clarity-v1.0.0-5-c9d0889) (revision 643)
+++ src/IDivergenceDeconvolve.cxx (.../cquammen-Clarity) (revision 658)
@@ -21,6 +21,12 @@
* Author: Cory Quammen <cquammen@cs.unc.edu>
*/
+/*
+ * This is a derivative work of Clarity provided as a third-party
+ * library in Gerardus
+ *
+ * Minor fixes by Ramon Casero <rcasero@gmail.com>
+ */
#include "Clarity.h"
@@ -30,29 +36,30 @@
#include <omp.h>
#endif // BUILD_WITH_OPENMP
-static float IDIVFunctional(
- float* g, float* gHat, float* sHat, float alpha,
- int nx, int ny, int nz) {
+// comment out these undefined functions, to avoid compilation warnings
+// static float IDIVFunctional(
+// float* g, float* gHat, float* sHat, float alpha,
+// int nx, int ny, int nz) {
- float sum = 0.0f;
- int numVoxels = nx*ny*nz;
+// float sum = 0.0f;
+// int numVoxels = nx*ny*nz;
-#ifdef BUILD_WITH_OPENMP
-#pragma omp parallel for reduction(+:sum)
-#endif // BUILD_WITH_OPENMP
- for (int i = 0; i < numVoxels; i++) {
- sum += (g[i]*log(g[i]/gHat[i])) + gHat[i] - g[i] + (alpha*sHat[i]*sHat[i]);
- }
- return sum;
-}
+// #ifdef BUILD_WITH_OPENMP
+// #pragma omp parallel for reduction(+:sum)
+// #endif // BUILD_WITH_OPENMP
+// for (int i = 0; i < numVoxels; i++) {
+// sum += (g[i]*log(g[i]/gHat[i])) + gHat[i] - g[i] + (alpha*sHat[i]*sHat[i]);
+// }
+// return sum;
+// }
-static void IDIVGradient(
- float* g, float* gHat, float* sHat, float* flippedPSFtf,
- float alpha, float* gradient) {
+// static void IDIVGradient(
+// float* g, float* gHat, float* sHat, float* flippedPSFtf,
+// float alpha, float* gradient) {
-}
+// }
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (.../cquammen-Clarity-v1.0.0-5-c9d0889) (revision 643)
+++ CMakeLists.txt (.../cquammen-Clarity) (revision 658)
@@ -1,10 +1,12 @@
PROJECT(Clarity)
-CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
-IF(COMMAND cmake_policy)
- CMAKE_POLICY(SET CMP0003 OLD)
-ENDIF(COMMAND cmake_policy)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+#IF(COMMAND cmake_policy)
+# CMAKE_POLICY(SET CMP0003 OLD)
+#ENDIF(COMMAND cmake_policy)
+# options can we set from the command line as
+# $ cmake -DBUILD_WITH_CUDA:BOOL=ON ..
OPTION(BUILD_SHARED_LIBS "Build Clarity with shared libraries." ON)
OPTION(BUILD_WITH_OPENMP "Build with OpenMP." ON)
OPTION(BUILD_WITH_CUDA "Build with CUDA FFT acceleration." OFF)
@@ -15,7 +17,7 @@
OPTION(TIME_DECONVOLVE "Time deconvolution operation only." OFF)
OPTION(TIME_TOTAL "Time total deconvolution operation (includes image padding and clipping." OFF)
-SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/")
+SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake/")
IF(BUILD_WITH_CUDA)
# Load CUDA macros
@@ -75,7 +77,8 @@
ADD_LIBRARY( Clarity ${Clarity_SRCS})
ENDIF(BUILD_WITH_CUDA)
-TARGET_LINK_LIBRARIES(Clarity ${FFTW_LIBRARIES} ${FFTW_EXECUTABLE_LIBRARIES})
+TARGET_LINK_LIBRARIES(Clarity ${FFTW_LIBRARIES}
+ ${FFTW_EXECUTABLE_LIBRARIES})
# Enable linking with OpenMP when compiling with gcc
SET (USE_GOMP ${CMAKE_COMPILER_IS_GNUCXX}
@@ -91,5 +94,22 @@
SOVERSION ${Clarity_MAJOR_VERSION}.${Clarity_MINOR_VERSION}
)
-ADD_SUBDIRECTORY(apps)
-ADD_SUBDIRECTORY(tests)
+# Gerardus doesn't need to build the apps and tests of Clarity
+#ADD_SUBDIRECTORY(apps)
+#ADD_SUBDIRECTORY(tests)
+
+################################################################
+## installation of library
+################################################################
+
+IF(WIN32)
+ INSTALL(TARGETS
+ Clarity
+ RUNTIME
+ DESTINATION ${CMAKE_INSTALL_PREFIX})
+ELSE(WIN32)
+ INSTALL(TARGETS
+ Clarity
+ LIBRARY
+ DESTINATION ${CMAKE_INSTALL_PREFIX})
+ENDIF(WIN32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment