Skip to content

Commit

Permalink
merge 'of-0.11.2' branch to 'master'
Browse files Browse the repository at this point in the history
Signed-off-by: Miaofei <[email protected]>
  • Loading branch information
mm318 committed Aug 29, 2023
2 parents adbf78f + 4ff451f commit ecb399e
Show file tree
Hide file tree
Showing 681 changed files with 189 additions and 214,493 deletions.
184 changes: 125 additions & 59 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,71 +1,137 @@
# ======================= ofxCMake Vers. 0.1 =============
# PUT THIS FILE INTO YOUR OPENFRAMEWORKS PROJECT FOLDER

# ========================================================
# ===================== CMake Settings ===================
# ========================================================
cmake_minimum_required( VERSION 3.3 )
project( openframeworks )
cmake_minimum_required(VERSION 3.3)

include(ExternalProject)
include(GNUInstallDirs)
include(ProcessorCount)

ProcessorCount(NUM_CPUS)
if(NUM_CPUS EQUAL 0)
set(NUM_CPUS 1)
endif()

# ========================================================
# ===================== User Settings ====================
# ========================================================
# ------------------------ OF Path -----------------------
# --- If outside the OF structure, set an absolute OF path
set( OF_DIRECTORY_BY_USER "${CMAKE_CURRENT_LIST_DIR}/openFrameworks-0.10.1" )

project(mrg-cpp)

# ---------------------- App name -----------------------
set( APP_NAME mrg_axon_model )
set(APP_NAME mrg_axon_model)

# --------------------- Source Files ---------------------
set( ${APP_NAME}_SOURCE_FILES
src/MRG_main.cpp
src/MRG_init.cpp
src/MRG_ode.cpp
src/utils.cpp
src/ofApp.cpp
)

# ------------------------ AddOns -----------------------
set( OFX_ADDONS_ACTIVE
ofxPoco
ofxVideoRecorder
# ofxXmlSettings
# ofxOsc
# ofxGui
# ofxNetwork
# ofxVectorGraphics
# ofxThreadedImageLoader
# ofxAssimpModelLoader
# ofxKinect
# ofxOpenCv
# ofxSvg
# ofxEmscripten (untested)
)

# =========================================================================
# ============================== OpenFrameworks ===========================
# =========================================================================
include( ${OF_DIRECTORY_BY_USER}/addons/ofxCMake/modules/main.cmake )
# =========================================================================

# =========================================================================
# ============================== Armadillo ================================
# =========================================================================
target_include_directories(${APP_NAME} PRIVATE src/libs/armadillo-9.200.5)
# =========================================================================

# =========================================================================
# ============================== SUNDIALS =================================
# =========================================================================
add_subdirectory(src/libs/sundials-4.0.0 "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/sundials")
target_include_directories(${APP_NAME} PRIVATE ${sundials_SOURCE_DIR}/include)
set(${APP_NAME}_SOURCE_FILES
src/MRG_main.cpp
src/MRG_init.cpp
src/MRG_ode.cpp
src/ofApp.cpp
src/utils/utils.cpp
)

# ========================================================


# ===============================================================
# ==================== External Dependencies ====================
# ===============================================================

find_package(PkgConfig)
pkg_check_modules(GLIB REQUIRED glib-2.0)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
pkg_check_modules(GSTREAMER_APP REQUIRED gstreamer-app-1.0)
pkg_check_modules(GSTREAMER_VIDEO REQUIRED gstreamer-video-1.0)
pkg_check_modules(CAIRO REQUIRED cairo)

add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)

ExternalProject_Add(armadillo
URL "${CMAKE_SOURCE_DIR}/external_libs/armadillo-9.200.5.tar.bz2"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory <SOURCE_DIR>
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}"
)

ExternalProject_Add(sundials
URL "${CMAKE_SOURCE_DIR}/external_libs/sundials-4.0.2.tar.gz"
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}"
)

ExternalProject_Add(openframeworks
URL "${CMAKE_SOURCE_DIR}/external_libs/of_v0.11.2_linux64gcc6_release"
CONFIGURE_COMMAND ""
BUILD_COMMAND <SOURCE_DIR>/scripts/linux/compileOF.sh -j${NUM_CPUS}
BUILD_IN_SOURCE 1
INSTALL_COMMAND ${CMAKE_COMMAND}
-DSRC_PREFIX=<SOURCE_DIR>
-DDST_PREFIX=${CMAKE_BINARY_DIR}
-P ${CMAKE_SOURCE_DIR}/external_libs/install_openframeworks.cmake
)

link_directories("${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")

# ===============================================================


# =======================================================
# ==================== Build Project ====================
# =======================================================

add_executable(${APP_NAME}
${${APP_NAME}_SOURCE_FILES}
)

target_include_directories(${APP_NAME} BEFORE
PRIVATE "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}"
${GLIB_INCLUDE_DIRS}
${GSTREAMER_INCLUDE_DIRS}
${CAIRO_INCLUDE_DIRS}
)

target_link_libraries(${APP_NAME}
ofxPoco
sundials_cvode_static
sundials_sunlinsoldense_static
sundials_sunmatrixdense_static
sundials_nvecserial_static
ofxVideoRecorder
)
# =========================================================================
libsundials_cvode.a
libsundials_sunlinsoldense.a
libsundials_sunmatrixdense.a
libsundials_nvecserial.a
libopenFrameworks.a
GLEW
GLU
GL
glut
glfw
openal
sndfile
kiss
tess2
PocoUtil
PocoFoundation
fontconfig
freetype
freeimage
X11
${GSTREAMER_LIBRARIES}
${GSTREAMER_APP_LIBRARIES}
${GSTREAMER_VIDEO_LIBRARIES}
${CAIRO_LIBRARIES}
${GLIB_LIBRARIES}
uriparser
curl
boost_filesystem
boost_system
pthread
)

add_dependencies(${APP_NAME} armadillo sundials openframeworks)

set_target_properties(${APP_NAME}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)

file(COPY reference/activateF.txt DESTINATION bin/)

# =======================================================
46 changes: 21 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,45 @@ Visualization (implemented using openFrameworks) is also addded.

- Obtain the source:

```bash
$ git clone https://github.com/mm318/mrg-cpp.git
$ cd mrg-cpp
```

- Setup openFrameworks 0.10.1 and its CMake build:

```bash
$ wget https://github.com/openframeworks/openFrameworks/archive/0.10.1.tar.gz && tar xvzf 0.10.1.tar.gz && rm 0.10.1.tar.gz
```bash
git clone https://github.com/mm318/mrg-cpp.git
cd mrg-cpp/
```

# optional if dependencies are already installed
$ sudo openFrameworks-0.10.1/scripts/linux/ubuntu/install_dependencies.sh
- Setup openFrameworks 0.11.2 and its CMake build:

$ openFrameworks-0.10.1/scripts/linux/download_libs.sh
$ rm -rf openFrameworks-0.10.1/addons/ofxPoco/libs/
$ tar xvjf libs/libPoco-1.9.0.tar.bz2 -C openFrameworks-0.10.1/addons/ofxPoco/
```bash
wget https://github.com/openframeworks/openFrameworks/releases/download/0.11.2/of_v0.11.2_linux64gcc6_release.tar.gz \
&& tar xvzf of_v0.11.2_linux64gcc6_release.tar.gz -C external_libs/ \
&& rm of_v0.11.2_linux64gcc6_release.tar.gz

$ git clone https://github.com/mm318/ofxCMake.git openFrameworks-0.10.1/addons/ofxCMake
$ git clone https://github.com/timscaffidi/ofxVideoRecorder.git openFrameworks-0.10.1/addons/ofxVideoRecorder
```
# optional if dependencies are already installed
sudo external_libs/of_v0.11.2_linux64gcc6_release/scripts/linux/ubuntu/install_dependencies.sh
```

- Build like an usual CMake project, for example:

```bash
$ mkdir build
$ cd build
$ cmake ..
$ make -j4
```
```bash
mkdir build
cd build/
cmake ..
make -j4
```


## Usage

```
mrg_axon_model [--record-video=<video name>] <axon file> <V_fe (mV)> <V_applied (mV)> <duration (ms)> <stim start (ms)> <stim end (ms)>
mrg_axon_model <axon file> <V_fe (mV)> <V_applied (mV)> <duration (ms)> <stim start (ms)> <stim end (ms)>
```

The axon file is in the format (tab separated): `<x (m)> <y (m)> <z (m)> <Ve_pulse (V)>`

### Example

```bash
mrg_axon_model reference/activateF.txt --record-video=replay 1 3 3 2 2.5
cd build/bin/
./mrg_axon_model activateF.txt 1 3 3 2 2.5
```

![Example visualization](reference/example_screenshot.png "Example visualization")
Expand Down
Binary file added external_libs/armadillo-9.200.5.tar.bz2
Binary file not shown.
30 changes: 30 additions & 0 deletions external_libs/install_openframeworks.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.6)

include(GNUInstallDirs)

file(GLOB_RECURSE of_libs
LIST_DIRECTORIES false
${SRC_PREFIX}/*.a)

list(FILTER of_libs EXCLUDE REGEX "/emscripten/")

file(GLOB_RECURSE of_includes
LIST_DIRECTORIES false
${SRC_PREFIX}/libs/openFrameworks/of*.h)

file(GLOB_RECURSE of_inlines
LIST_DIRECTORIES false
${SRC_PREFIX}/libs/openFrameworks/of*.inl)

file(GLOB of_dep_include_dirs
LIST_DIRECTORIES true
${SRC_PREFIX}/libs/*/${CMAKE_INSTALL_INCLUDEDIR})

file(COPY ${of_libs}
DESTINATION ${DST_PREFIX}/${CMAKE_INSTALL_LIBDIR})

file(COPY ${of_includes} ${of_inlines}
DESTINATION ${DST_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})

file(COPY ${of_dep_include_dirs}
DESTINATION ${DST_PREFIX})
Binary file added external_libs/sundials-4.0.2.tar.gz
Binary file not shown.
Binary file removed libs/libPoco-1.9.0.tar.bz2
Binary file not shown.
2 changes: 1 addition & 1 deletion src/MRG.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
typedef realtype MRG_REAL;
typedef arma::Mat<MRG_REAL> MRG_MATRIX_REAL;

#include "utils.h"
#include "utils/utils.h"


class MRG
Expand Down
2 changes: 1 addition & 1 deletion src/MRG_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <fstream>

#include "MRG.h"
#include "utils.h"
#include "utils/utils.h"

#include <nvector/nvector_serial.h>
#include <cvode/cvode.h>
Expand Down
2 changes: 1 addition & 1 deletion src/MRG_ode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <thread>

#include "MRG.h"
#include "utils.h"
#include "utils/utils.h"

#include <nvector/nvector_serial.h>
#include <sunmatrix/sunmatrix_dense.h> /* access to dense SUNMatrix */
Expand Down
Loading

0 comments on commit ecb399e

Please sign in to comment.