Skip to content

Commit

Permalink
Merge pull request #118 from dkazanc/tomophantom3
Browse files Browse the repository at this point in the history
tomophantom version 3
  • Loading branch information
dkazanc authored Dec 22, 2023
2 parents 6e3b949 + e101520 commit 0be01d5
Show file tree
Hide file tree
Showing 182 changed files with 9,951 additions and 36,907 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/tomophantom_conda_upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: tomohantom_conda_upload

on: [push]

jobs:
build-linux:
runs-on: ubuntu-20.04

defaults:
run:
shell: bash -l {0}

steps:
- name: Checkout repository code
uses: actions/checkout@v3
with:
ref: "master"
fetch-depth: 0

# setup Python 3.9
- name: Setup Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install dependencies with Conda
run: |
$CONDA/bin/conda install -c conda-forge conda-build anaconda-client
$CONDA/bin/conda update conda
$CONDA/bin/conda update conda-build
$CONDA/bin/conda list
- name: Decrypt a secret
run: ./.scripts/decrypt_secret.sh
env:
LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}

- name: Upload the tested package to conda cloud
run: |
chmod +x ./.scripts/conda_upload.sh
./.scripts/conda_upload.sh
20 changes: 20 additions & 0 deletions .scripts/conda_upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

PKG_NAME=tomophantom
USER=httomo-team
OS=noarch
CONDA_TOKEN=$(cat $HOME/.secrets/my_secret.json)

mkdir ~/conda-bld
conda config --set anaconda_upload no
export CONDA_BLD_PATH=~/conda-bld

export CIL_VERSION=3.0
$CONDA/bin/conda build conda-recipe . -c httomo

# upload packages to conda
find $CONDA_BLD_PATH/$OS -name *.tar.bz2 | while read file
do
echo $file
$CONDA/bin/anaconda -v --show-traceback --token $CONDA_TOKEN upload $file --force
done
8 changes: 8 additions & 0 deletions .scripts/decrypt_secret.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# Decrypt the file
mkdir $HOME/.secrets
# --batch to prevent interactive command
# --yes to assume "yes" for questions
gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" \
--output $HOME/.secrets/my_secret.json ./.scripts/my_secret.json.gpg
Binary file added .scripts/my_secret.json.gpg
Binary file not shown.
50 changes: 9 additions & 41 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,11 @@
# ChangeLog

## v1.4.9
* Artifacts function syntax has changed. Now the dictionaries with keys can be be provided in a random order. Demos updated to make use of the updated function
* Partial volume effect generator added to the Artifacts script
* Fresnel propagator simulator added to the Artifacts script

## v1.4.7
* Flat field simulator has been modified to be based on a speckle generator of the background
* Flat fields and the background jitter has been incorporated
* Model 17 has been added to simulate i23 data

## v1.4.5
* Flat field simulation for 3D case has been re-written to conform the traditional imaging scenario. One can modify the
inensity of the X-ray source which leads to more imaging artefacts
* Demo ReconASTRA3D_realistic shows the incorporated changes
* normraw function has been deleted and replaced with the conventional normaliser from the ToMoBAR software

## v1.4.3
* Artifacts simulation module has been modified. It is based now on specifying the dictionaries where artifact types are
described. Stipes can be simulated to be partial and with variable intensity.
* 2D Model 15 added - DLS phantom


## v1.4.2
* Jupiter Notebook demo added which uses deep learning algorithms to employ TomoPhantom for data generation

## v1.4.1
* All demos renamed and placed into categories: 2D/3D/4D, Random
* Random generation of 2D/3D phantoms is initiated using methods from "generator.py" script
* Foam phantoms can be built
* Demo 'RandPhantGen.py' shows how phantoms can be generated

## v1.4

* Artifacts generation have been re-written from the class-based structure to function based structure
* Each method in Artifacts can be called independently or all artefacts+noise can be simulated using _Artifacts_ method
* Seeding added for noise module
* Demos changed to adapt new artefacts functions and ToMoBAR changes

## v1.3

* Objects3D (generation of the customised objects) function is fixed
## v3.0 (2023.12)
* Project reorganised into two parts: a library that is build as a shared object using Cmake and Ctypes bindings and pure Python part that can be
installed separately.
* In general, ver.3.* should be fully compatabile to ver2.*, however, please note that paths for some functions have been changed. For instance,
```python
from tomophantom.artefacts import artefacts_mix
```
* Documentation is now available, please check all API for TomoPhantom.
* Demos were updated
12 changes: 4 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required (VERSION 3.0)
cmake_minimum_required(VERSION 3.5)

project(TomoPhantom)
#https://stackoverflow.com/questions/13298504/using-cmake-with-setup-py
project(tomophantom)

# The version number.
set (CIL_VERSION_MAJOR 0)
Expand All @@ -24,14 +23,11 @@ set (CIL_VERSION_PATCH 0)

set (CIL_VERSION '${CIL_VERSION_MAJOR}.${CIL_VERSION_MINOR}.${CIL_VERSION_PATCH}' CACHE INTERNAL "Core Imaging Library version" FORCE)

# set the Python variables for the Conda environment
#include(${CMAKE_SOURCE_DIR}/CMake/FindAnacondaEnvironment.cmake)

set(CMAKE_BUILD_TYPE "Release")

option (BUILD_MATLAB_WRAPPER "Build Matlab Wrappers" OFF)
option (BUILD_PYTHON_WRAPPER "Build Python Wrappers" ON)
option (BUILD_PYTHON_WRAPPER "Build Python Wrappers" OFF)
option (CONDA_BUILD "Conda Build" OFF)

add_subdirectory(Core)
add_subdirectory(Wrappers)

16 changes: 0 additions & 16 deletions Core/CCPiDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Code is derived from code developed by Prof. Brian Bay
*/

#ifndef CCPIDEFINES_H
Expand All @@ -36,12 +28,4 @@
#define CCPI_EXPORT
#endif

// Revised:

#define DAY_REV 25
#define MONTH_REV "Nov"
#define YEAR_REV 2017

#define VERSION 1.30

#endif
92 changes: 36 additions & 56 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Copyright 2018 Edoardo Pasca
#cmake_minimum_required (VERSION 3.0)
# Copyright 2017 Edoardo Pasca
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

project(tomophantom)

project(RGL_core)
#https://stackoverflow.com/questions/13298504/using-cmake-with-setup-py

# The version number.

#set (CIL_VERSION $ENV{CIL_VERSION} CACHE INTERNAL "Core Imaging Library version" FORCE)

# conda orchestrated build
message("CIL_VERSION ${CIL_VERSION}")
#include (GenerateExportHeader)


find_package(OpenMP REQUIRED)
if (OPENMP_FOUND)
Expand All @@ -23,9 +26,7 @@ if (OPENMP_FOUND)

endif()

## Build the regularisers package as a library
message("Building TomoPhantom as a shared library")

message("Building TomoPhantom core modules as a shared library")
message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}")
message("CMAKE_C_FLAGS ${CMAKE_C_FLAGS}")
message("CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}")
Expand All @@ -35,17 +36,14 @@ message("CMAKE_STATIC_LINKER_FLAGS ${CMAKE_STATIC_LINKER_FLAGS}")
set(CMAKE_BUILD_TYPE "Release")

if(WIN32)
set (FLAGS "/DWIN32 /EHsc /DCCPi_EXPORTS")
set (FLAGS "/DWIN32 /EHsc /DCCPi_EXPORTS /openmp:experimental")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT.lib")

set (EXTRA_LIBRARIES)

message("library lib: ${LIBRARY_LIB}")

set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT.lib")
set (EXTRA_LIBRARIES)
message("library lib: ${LIBRARY_LIB}")
elseif(UNIX)
set (FLAGS "-O2 -funsigned-char -Wall -Wl,--no-undefined -DCCPiReconstructionIterative_EXPORTS ")
set (FLAGS "-O2 -funsigned-char -Wall -Wl,--no-undefined -DCCPiReconstructionIterative_EXPORTS")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
if (OPENMP_FOUND)
Expand All @@ -61,59 +59,41 @@ elseif(UNIX)
endif()
message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}")

## Build the regularisers package as a library
message("Building TomoPhantom as a shared library")

#set(CMAKE_C_COMPILER /apps/pgi/linux86-64/17.4/bin/pgcc)
#set(CMAKE_C_FLAGS "-acc -Minfo -ta=tesla:cc20 -openmp")
#set(CMAKE_C_FLAGS "-acc -Minfo -ta=multicore -openmp -fPIC")
add_library(ctomophantom "SHARED"
add_library(tomophantom "SHARED"
${CMAKE_CURRENT_SOURCE_DIR}/TomoP2DModel_core.c
${CMAKE_CURRENT_SOURCE_DIR}/TomoP2DModelSino_core.c
${CMAKE_CURRENT_SOURCE_DIR}/TomoP3DModel_core.c
${CMAKE_CURRENT_SOURCE_DIR}/TomoP3DModelSino_core.c
${CMAKE_CURRENT_SOURCE_DIR}/TomoP3DModel_core.c
${CMAKE_CURRENT_SOURCE_DIR}/TomoP3DModelSino_core.c
${CMAKE_CURRENT_SOURCE_DIR}/TomoP2DSinoNum_core.c
${CMAKE_CURRENT_SOURCE_DIR}/utils.c
)
#add_library(ctomophantom_static "STATIC"
# ${CMAKE_CURRENT_SOURCE_DIR}/TomoP2DModel_core.c
# ${CMAKE_CURRENT_SOURCE_DIR}/TomoP2DModelSino_core.c
# ${CMAKE_CURRENT_SOURCE_DIR}/TomoP3DModel_core.c
# ${CMAKE_CURRENT_SOURCE_DIR}/utils.c
# ${CMAKE_CURRENT_SOURCE_DIR}/TomoP2DSinoNum_core.c
# )
target_link_libraries(ctomophantom ${EXTRA_LIBRARIES} )
include_directories(ctomophantom PUBLIC
target_link_libraries(tomophantom ${EXTRA_LIBRARIES} )
include_directories(tomophantom PUBLIC
${LIBRARY_INC}/include
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)

## Install

set(INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin)
set(INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib)
set(INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
set(PYTHON_SITE_DIR ${CMAKE_INSTALL_PREFIX}/source)
set(CMAKE_POSITION_INDEPENDENT_CODE
ON
CACHE BOOL "Position independent code" FORCE)
#set(INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin)
#set(INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib)
#set(INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)

if (UNIX)
message ("I'd install into ${CMAKE_INSTALL_PREFIX}/lib")
install(TARGETS ctomophantom
install(TARGETS tomophantom
LIBRARY DESTINATION lib
CONFIGURATIONS ${CMAKE_BUILD_TYPE}
)
elseif(WIN32)
message ("I'd install into ${CMAKE_INSTALL_PREFIX} lib bin")
install(TARGETS ctomophantom
install(TARGETS tomophantom
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
CONFIGURATIONS ${CMAKE_BUILD_TYPE}
)
endif()


#install(TARGETS ctomophantom
# LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
# PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}" COMPONENT dev
# RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
# ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
# CONFIGURATIONS ${CMAKE_BUILD_TYPE}
# )
Loading

0 comments on commit 0be01d5

Please sign in to comment.