Skip to content

Commit

Permalink
Add filter for converting Rice-corrupted images into Gaussian-corrupt…
Browse files Browse the repository at this point in the history
…ed images
  • Loading branch information
astamm authored and ocommowi committed Jul 4, 2018
1 parent 66088d4 commit 23d9103
Show file tree
Hide file tree
Showing 33 changed files with 1,388 additions and 15 deletions.
20 changes: 20 additions & 0 deletions Anima/cmake/ANIMAConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ set(NLOPT_INCLUDE_DIR "@NLOPT_INCLUDE_DIR@")
set(NLOPT_LIBRARY_DIR "@NLOPT_LIBRARY_DIR@")
set(NLOPT_LIBRARY "@NLOPT_LIBRARY@")

set(USE_GMP "@USE_GMP@")
set(GMP_INCLUDE_DIR "@GMP_INCLUDE_DIR@")
set(GMP_LIBRARY_DIR "@GMP_LIBRARY_DIR@")
set(GMP_LIBRARY "@GMP_LIBRARY@")

set(USE_MPFR "@USE_MPFR@")
set(MPFR_INCLUDE_DIR "@MPFR_INCLUDE_DIR@")
set(MPFR_LIBRARY_DIR "@MPFR_LIBRARY_DIR@")
set(MPFR_LIBRARY "@MPFR_LIBRARY@")

set(USE_FLINT "@USE_FLINT@")
set(FLINT_INCLUDE_DIR "@FLINT_INCLUDE_DIR@")
set(FLINT_LIBRARY_DIR "@FLINT_LIBRARY_DIR@")
set(FLINT_LIBRARY "@FLINT_LIBRARY@")

set(USE_ARB "@USE_ARB@")
set(ARB_INCLUDE_DIR "@ARB_INCLUDE_DIR@")
set(ARB_LIBRARY_DIR "@ARB_LIBRARY_DIR@")
set(ARB_LIBRARY "@ARB_LIBRARY@")

set(TinyXML2_INCLUDE_DIR "@TinyXML2_INCLUDE_DIR@")
set(TinyXML2_LIBRARY_DIR "@TinyXML2_LIBRARY_DIR@")
set(TinyXML2_LIBRARY "@TinyXML2_LIBRARY@")
Expand Down
1 change: 1 addition & 0 deletions Anima/cmake/ANIMAExports.cmake.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include_directories(@ANIMA_BINARY_DIR@)
include_directories(@ANIMA_BINARY_DIR@/math-tools/arb_special_functions)
include_directories(@ANIMA_BINARY_DIR@/math-tools/data_io)
include_directories(@ANIMA_BINARY_DIR@/math-tools/optimizers)
include_directories(@ANIMA_BINARY_DIR@/math-tools/multi_compartment_base)
Expand Down
36 changes: 36 additions & 0 deletions Anima/cmake/ANIMAUse.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,42 @@ if(NOT ANIMA_USE_FILE_INCLUDED)
set(NLOPT_FOUND 1)
endif(USE_NLOPT)

set(USE_GMP ${USE_GMP})
if (USE_GMP)
set(GMP_INCLUDE_DIR ${GMP_INCLUDE_DIR})
include_directories(${GMP_INCLUDE_DIR})
set(GMP_LIBRARY_DIR ${GMP_LIBRARY_DIR})
set(GMP_LIBRARY ${GMP_LIBRARY})
set(GMP_FOUND 1)
endif(USE_GMP)

set(USE_MPFR ${USE_MPFR})
if (USE_MPFR)
set(MPFR_INCLUDE_DIR ${MPFR_INCLUDE_DIR})
include_directories(${MPFR_INCLUDE_DIR})
set(MPFR_LIBRARY_DIR ${MPFR_LIBRARY_DIR})
set(MPFR_LIBRARY ${MPFR_LIBRARY})
set(MPFR_FOUND 1)
endif(USE_MPFR)

set(USE_FLINT ${USE_FLINT})
if (USE_FLINT)
set(FLINT_INCLUDE_DIR ${FLINT_INCLUDE_DIR})
include_directories(${FLINT_INCLUDE_DIR})
set(FLINT_LIBRARY_DIR ${FLINT_LIBRARY_DIR})
set(FLINT_LIBRARY ${FLINT_LIBRARY})
set(FLINT_FOUND 1)
endif(USE_FLINT)

set(USE_ARB ${USE_ARB})
if (USE_ARB)
set(ARB_INCLUDE_DIR ${ARB_INCLUDE_DIR})
include_directories(${ARB_INCLUDE_DIR})
set(ARB_LIBRARY_DIR ${ARB_LIBRARY_DIR})
set(ARB_LIBRARY ${ARB_LIBRARY})
set(ARB_FOUND 1)
endif(USE_ARB)

set(TinyXML2_INCLUDE_DIR ${TinyXML2_INCLUDE_DIR})
include_directories(${TinyXML2_INCLUDE_DIR})
set(TinyXML2_LIBRARY_DIR ${TinyXML2_LIBRARY_DIR})
Expand Down
40 changes: 40 additions & 0 deletions Anima/cmake/AnimaDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,46 @@ if(USE_NLOPT)
find_package(NLOPT REQUIRED)
endif()

# GMP
option(USE_GMP
"Use GMP external library (necessary for some special functions)"
OFF
)

if(USE_GMP)
find_package(GMP REQUIRED)
endif()

# MPFR
option(USE_MPFR
"Use MPFR external library (necessary for some special functions)"
OFF
)

if(USE_MPFR)
find_package(MPFR REQUIRED)
endif()

# FLINT
option(USE_FLINT
"Use FLINT external library (necessary for some special functions)"
OFF
)

if(USE_FLINT)
find_package(FLINT REQUIRED)
endif()

# ARB
option(USE_ARB
"Use ARB external library (necessary for some special functions)"
OFF
)

if(USE_ARB)
find_package(ARB REQUIRED)
endif()

# TinyXML2
if (BUILD_MODULE_REGISTRATION OR BUILD_MODULE_DIFFUSION)
find_package(TinyXML2 REQUIRED)
Expand Down
4 changes: 4 additions & 0 deletions Anima/cmake/AnimaModulesSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ set(${PROJECT_NAME}_INCLUDE_DIRS
"${Boost_INCLUDE_DIR}"
"${TCLAP_INCLUDE_DIR}"
"${NLOPT_INCLUDE_DIR}"
"${GMP_INCLUDE_DIR}"
"${MPFR_INCLUDE_DIR}"
"${FLINT_INCLUDE_DIR}"
"${ARB_INCLUDE_DIR}"
"${TinyXML2_INCLUDE_DIR}"
)

Expand Down
29 changes: 29 additions & 0 deletions Anima/cmake/FindARB.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Try to find the arb library
# Once done this will define
#
# ARB_FOUND - system has arb and it can be used
# ARB_INCLUDE_DIR - directory where the header file can be found
# ARB_LIBRARY - Path where arb library file can be found
#

SET (ARB_FOUND FALSE)

FIND_PATH(ARB_INCLUDE_DIR arb.h
/usr/include
/usr/local/include
)

set(ARB_LIBRARY_DIR "" CACHE PATH "ARB library folder")

FIND_LIBRARY(ARB_LIBRARY NAMES arb libarb
HINTS "${ARB_LIBRARY_DIR}"
)

mark_as_advanced(ARB_LIBRARY)

IF( EXISTS "${ARB_INCLUDE_DIR}" AND EXISTS "${ARB_LIBRARY}" )
set(ARB_FOUND TRUE)
else()
message(FATAL_ERROR "ARB not found")
endif()

29 changes: 29 additions & 0 deletions Anima/cmake/FindFLINT.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Try to find the flint library
# Once done this will define
#
# FLINT_FOUND - system has flint and it can be used
# FLINT_INCLUDE_DIR - directory where the header file can be found
# FLINT_LIBRARY - Path where flint library file can be found
#

SET (FLINT_FOUND FALSE)

FIND_PATH(FLINT_INCLUDE_DIR flint/flint.h
/usr/include
/usr/local/include
)

set(FLINT_LIBRARY_DIR "" CACHE PATH "FLINT library folder")

FIND_LIBRARY(FLINT_LIBRARY NAMES flint libflint
HINTS "${FLINT_LIBRARY_DIR}"
)

mark_as_advanced(FLINT_LIBRARY)

IF( EXISTS "${FLINT_INCLUDE_DIR}" AND EXISTS "${FLINT_LIBRARY}" )
set(FLINT_FOUND TRUE)
else()
message(FATAL_ERROR "FLINT not found")
endif()

29 changes: 29 additions & 0 deletions Anima/cmake/FindGMP.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Try to find the gmp library
# Once done this will define
#
# GMP_FOUND - system has gmp and it can be used
# GMP_INCLUDE_DIR - directory where the header file can be found
# GMP_LIBRARY - Path where gmp library file can be found
#

SET (GMP_FOUND FALSE)

FIND_PATH(GMP_INCLUDE_DIR gmp.h
/usr/include
/usr/local/include
)

set(GMP_LIBRARY_DIR "" CACHE PATH "GMP library folder")

FIND_LIBRARY(GMP_LIBRARY NAMES gmp libgmp
HINTS "${GMP_LIBRARY_DIR}"
)

mark_as_advanced(GMP_LIBRARY)

IF( EXISTS "${GMP_INCLUDE_DIR}" AND EXISTS "${GMP_LIBRARY}" )
set(GMP_FOUND TRUE)
else()
message(FATAL_ERROR "GMP not found")
endif()

29 changes: 29 additions & 0 deletions Anima/cmake/FindMPFR.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Try to find the mpfr library
# Once done this will define
#
# MPFR_FOUND - system has mpfr and it can be used
# MPFR_INCLUDE_DIR - directory where the header file can be found
# MPFR_LIBRARY - Path where mpfr library file can be found
#

SET (MPFR_FOUND FALSE)

FIND_PATH(MPFR_INCLUDE_DIR mpfr.h
/usr/include
/usr/local/include
)

set(MPFR_LIBRARY_DIR "" CACHE PATH "MPFR library folder")

FIND_LIBRARY(MPFR_LIBRARY NAMES mpfr libmpfr
HINTS "${MPFR_LIBRARY_DIR}"
)

mark_as_advanced(MPFR_LIBRARY)

IF( EXISTS "${MPFR_INCLUDE_DIR}" AND EXISTS "${MPFR_LIBRARY}" )
set(MPFR_FOUND TRUE)
else()
message(FATAL_ERROR "MPFR not found")
endif()

Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,12 @@ DTIEstimationImageFilter<InputPixelScalarType, OutputPixelScalarType>
for (unsigned int i = 0;i < numInputs;++i)
{
dwi[i] = inIterators[i].Get();
lnDwi[i] = std::log(std::max(1.0e-6,dwi[i]));
lnDwi[i] = (dwi[i] <= 0) ? 0 : std::log(dwi[i]);
}

for (unsigned int i = 0;i < m_NumberOfComponents;++i)
{
for (unsigned int j = 0;j < numInputs;++j)
resVec[i] += m_InitialMatrixSolver(i+1,j) * lnDwi[j];
}

anima::GetTensorFromVectorRepresentation(resVec,data.workTensor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ MCMEstimatorImageFilter<InputPixelType, OutputPixelType>
// Load DWI
for (unsigned int i = 0;i < m_NumberOfImages;++i)
observedSignals[i] = inIterators[i].Get();

int moseValue = -1;
bool estimateNonIsoCompartments = false;
if (m_ExternalMoseVolume)
Expand Down Expand Up @@ -818,7 +818,7 @@ MCMEstimatorImageFilter<InputPixelType, OutputPixelType>
workVec = mcmUpdateValue->GetParametersAsVector();
for (unsigned int i = 0;i < dimension;++i)
p[i] = workVec[i];

double costValue = this->PerformSingleOptimization(p,cost,lowerBounds,upperBounds);
this->GetProfiledInformation(cost,mcmUpdateValue,b0Value,sigmaSqValue);

Expand All @@ -832,7 +832,7 @@ MCMEstimatorImageFilter<InputPixelType, OutputPixelType>

if (m_CompartmentType == Stick)
return;

// We're done with ball and stick, next up is ball and zeppelin
// - First create model
mcmCreator->SetCompartmentType(Zeppelin);
Expand Down
5 changes: 5 additions & 0 deletions Anima/filtering/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ project(ANIMA-FILTERING)
add_subdirectory(bias_correction)
add_subdirectory(denoising)
add_subdirectory(dti_tools)

if (USE_GMP AND GMP_FOUND AND USE_MPFR AND MPFR_FOUND AND USE_FLINT AND FLINT_FOUND AND USE_ARB AND ARB_FOUND)
add_subdirectory(gaussianizer)
endif()

add_subdirectory(noise_generator)
add_subdirectory(nyul_standardization)
add_subdirectory(regularization)
37 changes: 37 additions & 0 deletions Anima/filtering/gaussianizer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
if(BUILD_TOOLS)

project(animaGaussianizer)

## #############################################################################
## List Sources
## #############################################################################

list_source_files(${PROJECT_NAME}
${CMAKE_CURRENT_SOURCE_DIR}
)

## #############################################################################
## add executable
## #############################################################################

add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_CFILES}
)


## #############################################################################
## Link
## #############################################################################

target_link_libraries(${PROJECT_NAME}
${ITKIO_LIBRARIES}
AnimaArbSpecialFunctions
)

## #############################################################################
## install
## #############################################################################

set_exe_install_rules(${PROJECT_NAME})

endif()
Loading

0 comments on commit 23d9103

Please sign in to comment.