From 7a1d357d7f9bd4e26920da4698ad114806e23f1a Mon Sep 17 00:00:00 2001 From: Bishesh Khanal Date: Thu, 7 Jul 2016 11:27:15 +0200 Subject: [PATCH] Updates cmake files and installation info. Cleans and updates cmakelist files and updates installation info accordingly in readme file. Also renames the main executable file to simul_atrophy. --- CMakeLists.txt | 59 ++++++------------- readme.md | 48 ++++++++++++--- scripts/bish_utils.py | 2 +- scripts/compare_with_reg.py | 39 ------------ scripts/create_atrophy_map.py | 2 +- scripts/extractSliceVideoFrom4d.py | 7 +++ .../{runAdLemModel.py => simul_atrophy.py} | 6 ++ ...es.py => simul_atrophy_multiple_images.py} | 6 ++ src/CMakeLists.txt | 4 +- 9 files changed, 82 insertions(+), 91 deletions(-) delete mode 100644 scripts/compare_with_reg.py rename scripts/{runAdLemModel.py => simul_atrophy.py} (98%) rename scripts/{runAdLemModelMultipleImages.py => simul_atrophy_multiple_images.py} (92%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d228d4..b11edb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,47 +1,14 @@ cmake_minimum_required(VERSION 2.8) -project(ADDeformationModeling) - -# For cluster use argument: -DIS_CLUSTER:bool=true -set(IS_CLUSTER false CACHE BOOL "cmake run in the cluster: true or false") - -# For new cluster also use argument: -DIS_NEW_CLUSTER:bool=true -set(IS_NEW_CLUSTER false CACHE BOOL "cmake run in new cluster: true or false") +project(simul@atrophy) +# add cmake modules path to the default one: MESSAGE("The directory is: ${CMAKE_SOURCE_DIR}") -#add cmake modules path to the default one: set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules") -#Find the external library for Petsc -find_package(PETSc COMPONENTS CXX REQUIRED) -#find_package(PETSc COMPONENTS) -set(CMAKE_CXX_COMPILER ${PETSC_COMPILER}) - -#Home directory -if(IS_CLUSTER) - if(IS_NEW_CLUSTER) - set(ITK_DIR /data/asclepios/user/bkhanal/softwares/ITK-build) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - # This part taken from: http://stackoverflow.com/questions/10851247/how-to-activate-c-11-in-cmake - include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) - CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) - if(COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - elseif(COMPILER_SUPPORTS_CXX0X) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") - else() - message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") - endif() - message("setting up for new cluster") - - else(IS_NEW_CLUSTER) - set(ITK_DIR /epi/asclepios2/bkhanal/ITK-build) - message("setting up for legacy cluster") - endif(IS_NEW_CLUSTER) +# Use cxx11 or not; If yes run cmake as: cmake -DUSE_CXX11:bool=true .. +set(USE_CXX11 false CACHE BOOL "use cxx11: true or false") -else(IS_CLUSTER) - set(ITK_DIR /home/bkhanal/Documents/softwares/ITK-build) - set(CMAKE_EXPORT_COMPILE_COMMANDS on) #Will generate compile_commands.json file used by irony-mode in emacs code completion. +if(USE_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # This part taken from: http://stackoverflow.com/questions/10851247/how-to-activate-c-11-in-cmake include(CheckCXXCompilerFlag) @@ -54,9 +21,19 @@ else(IS_CLUSTER) else() message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() - message("setting up for delorme") -endif(IS_CLUSTER) +endif(USE_CXX11) + + +# Find the external library for PETSc +# PETSc must have been configured with --with-clanguage=cxx option! +find_package(PETSc COMPONENTS CXX REQUIRED) +set(CMAKE_CXX_COMPILER ${PETSC_COMPILER}) + +# Generate compile_commands.json file used by irony-mode in emacs code completion. +set(CMAKE_EXPORT_COMPILE_COMMANDS on) + +# Find ITK FIND_PACKAGE(ITK) IF(ITK_FOUND) INCLUDE(${ITK_USE_FILE}) @@ -65,7 +42,7 @@ ELSE(ITK_FOUND) "ITK not found. Please set ITK_DIR.") ENDIF(ITK_FOUND) -#boost +# Find boost find_package(Boost COMPONENTS program_options REQUIRED) add_subdirectory(src) diff --git a/readme.md b/readme.md index 7880a9c..1c6db4f 100644 --- a/readme.md +++ b/readme.md @@ -4,18 +4,52 @@ ### Requirements 1. Cmake > 2.8 2. [PETSc](https://www.mcs.anl.gov/petsc/index.html) version 3.6.3.1 +**Use `--with-clanguage=cxx` option** when configuring PETSc. 3. [ITK](https://itk.org/) version 4.9 -First install right versions of PETSc and ITK. +## Installation +First make sure that: -## Quickstart -Clone this repository and create a `build` directory inside it. -Get into the `build` directory and run `cmake ..` followed by `make all` +* You have **right versions** of PETSc and ITK. +* That you configured PETSc with `--with-clanguage=cxx` option. +* Set `PETSC_DIR`, `PETSC_ARCH` and `ITK_DIR`. +For example, I have my `.bashrc` with: +``` +ITK_DIR=/home/bkhanal/Documents/softwares/ITK-build +export ITK_DIR +PETSC_DIR=/home/bkhanal/Documents/softwares/petsc +export PETSC_DIR +PETSC_ARCH=arch-linux2-cxx-debug +export PETSC_ARCH +``` + +Now, build `simul@trophy` with the following steps. *I assume that you are inside a `curr_dir`, replace `curr_dir` with a directory of your choice.* + +```bash +curr_dir$ git clone https://github.com/Inria-Asclepios/simul-atrophy.git +curr_dir$ cd simul-atrophy +simul-atrophy$ mkdir build && cd build +``` +Use `cmake` to build the files. +```bash +build$ cmake .. +build$ make +``` + +If you have ITK installed with `c++11`, then use the following options with cmake: -The main simulator executable is `build/src/AdLemMain`. -Run with `-h` option to see the arguments that must be given. +```bash +build$ cmake -DUSE_CXX11:bool=true .. +build$ make +``` + +This should install the software to your machine. + +## Quickstart +The main simulator executable is `build/src/simul_atrophy`. +Run with `-h` option to see in detail how to use it. -If you have python, it might be easier to use `scripts/runAdLemModel.py` instead of the executable. +Otherwise, there is also a python script at 'simul-atrophy/scripts/simul_atrophy.py' which you can use. Once again, use `-h` option to see the details. diff --git a/scripts/bish_utils.py b/scripts/bish_utils.py index 13bf241..9d0632e 100644 --- a/scripts/bish_utils.py +++ b/scripts/bish_utils.py @@ -3,7 +3,7 @@ Copying a directory tree. """ # Author: Bishesh Khanal -# +# Asclepios INRIA Sophia Antipolis # import subprocess diff --git a/scripts/compare_with_reg.py b/scripts/compare_with_reg.py deleted file mode 100644 index 0a8eef8..0000000 --- a/scripts/compare_with_reg.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/python -""" Compare Jacobian determinant of registartion algorithm with the prescribed -one. - -""" -# Author: Bishesh Khanal -# -# - -import argparse as ag -import os -import os.path as op -import numpy as np -import nibabel as nib - - -def get_input_options(): - """ Command line interface, get input options and interact with the user. - """ - parser = ag.ArgumentParser('''Compare registration vs prescribed simulated - atrophy. - ''') - parser.add_argument('fixed_img', help='fixed image, the baseline.') - parser.add_argument('moving_img', help='moving image, simulated') - ops = parser.parse_args() - return ops - - -def main(): - """ Launch recon_all long jobs. Run with -h to see options.""" - ops = get_input_options() - #img_data = box_with_spheres(5, 10, 14) - - - - - -if __name__ == "__main__": - main() diff --git a/scripts/create_atrophy_map.py b/scripts/create_atrophy_map.py index 8781069..eb5665f 100644 --- a/scripts/create_atrophy_map.py +++ b/scripts/create_atrophy_map.py @@ -3,7 +3,7 @@ or input images. """ # Author: Bishesh Khanal -# +# Asclepios INRIA Sophia Antipolis # import argparse as ag diff --git a/scripts/extractSliceVideoFrom4d.py b/scripts/extractSliceVideoFrom4d.py index a539c02..dc23f97 100755 --- a/scripts/extractSliceVideoFrom4d.py +++ b/scripts/extractSliceVideoFrom4d.py @@ -1,4 +1,11 @@ #!/usr/bin/env python +""" Script to: + Extract 3D images from a 4D image and then extract one selected slice + from each of these 3D images and combine them as a gif. +""" +# Author: Bishesh Khanal +# Asclepios INRIA Sophia Antipolis + import subprocess import sys import argparse as ag diff --git a/scripts/runAdLemModel.py b/scripts/simul_atrophy.py similarity index 98% rename from scripts/runAdLemModel.py rename to scripts/simul_atrophy.py index b83be1d..3434b93 100644 --- a/scripts/runAdLemModel.py +++ b/scripts/simul_atrophy.py @@ -1,4 +1,10 @@ #!/usr/bin/env python +""" Script to run simul@atrophy +""" +# Author: Bishesh Khanal +# Asclepios INRIA Sophia Antipolis +# + import os import os.path as op import argparse as ag diff --git a/scripts/runAdLemModelMultipleImages.py b/scripts/simul_atrophy_multiple_images.py similarity index 92% rename from scripts/runAdLemModelMultipleImages.py rename to scripts/simul_atrophy_multiple_images.py index bfdbb6e..faaf584 100644 --- a/scripts/runAdLemModelMultipleImages.py +++ b/scripts/simul_atrophy_multiple_images.py @@ -1,4 +1,10 @@ #!/usr/bin/env python +""" Script to run simul@atrophy for multiple images +""" +# Author: Bishesh Khanal +# Asclepios INRIA Sophia Antipolis +# + import os import os.path as op import argparse as ag diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index da87812..03e023e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,10 +11,10 @@ link_directories(${PETSC_LIBRARIES}) # PetscAdLemMain.cxx # ) -add_executable(AdLemMain +add_executable(simul_atrophy PetscAdLemMain.cxx ) -target_link_libraries(AdLemMain ${PETSC_LIBRARIES} ${ITK_LIBRARIES}) +target_link_libraries(simul_atrophy ${PETSC_LIBRARIES} ${ITK_LIBRARIES}) add_executable(UpdateMaskAndAtrophy