Skip to content

Commit

Permalink
Merge pull request #71 from dkazanc/pyproject
Browse files Browse the repository at this point in the history
reformating the project with pyproject
  • Loading branch information
dkazanc authored Mar 21, 2023
2 parents 79bee77 + d06aea2 commit 10152d8
Show file tree
Hide file tree
Showing 51 changed files with 234 additions and 1,282 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/tomobar_conda_upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: tomobar_conda_upload

on: [push]

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

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

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'

- name: Install dependencies with Conda
run: |
$CONDA/bin/conda env update --file conda-recipe/environment/environment.yml --name base
- 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
88 changes: 0 additions & 88 deletions .github/workflows/ubuntu.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .scripts/conda_upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

PKG_NAME=tomobar
USER=dkazanc
OS=linux-64
CONDA_TOKEN=$(cat $HOME/.secrets/my_secret.json)

mkdir ~/conda-bld
conda config --set anaconda_upload no
export CONDA_BLD_PATH=~/conda-bld
#export VERSION=`date +%Y.%m`
#conda install --yes anaconda-client
#conda build . --numpy=1.20 --python=3.9
#conda build . --numpy=1.21 --python=3.9
#conda build . --numpy=1.22 --python=3.9
#conda build . --numpy=1.20 --python=3.10
#conda build . --numpy=1.21 --python=3.10
#conda build . --numpy=1.22 --python=3.10

for python_ver in 3.9 3.10; do
for numpy_ver in 1.21 1.22 1.23 1.24; do
export VERSION=`date +%Y.%m`"-py"$python_ver"_np"$numpy_ver
conda build . --numpy $numpy_ver --python $python_ver
done
done

# 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
4 changes: 2 additions & 2 deletions scripts/decrypt_secret.sh → .scripts/decrypt_secret.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/sh

# Decrypt the file
mkdir $HOME/secrets
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
--output $HOME/.secrets/my_secret.json ./.scripts/my_secret.json.gpg
File renamed without changes.
32 changes: 0 additions & 32 deletions CMakeLists.txt

This file was deleted.

27 changes: 0 additions & 27 deletions Demos/Python/DemoFISTA_artifacts3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,33 +255,6 @@
plt.title('3D Huber Rec, sagittal')
plt.show()

# adding RING minimisation component (better model for data with rings - different from GH!)
#data.update({'huber_threshold' : None})
_data_.update({'ring_weights_threshold' : 2.0})
_data_.update({'ring_tuple_halfsizes' : (9,7,9)})

# Run FISTA reconstrucion algorithm with 3D regularisation and a better ring model
RecFISTA_HuberRING_TV = Rectools.FISTA(_data_, _algorithm_, _regularisation_)

Qtools = QualityTools(phantom_tm, RecFISTA_HuberRING_TV)
RMSE_FISTA_HUBER_RING_TV = Qtools.rmse()
print("RMSE for FISTA-OS-Huber-Ring-TV is {}".format(RMSE_FISTA_HUBER_RING_TV))

sliceSel = int(0.5*N_size)
max_val = 1
plt.figure()
plt.subplot(131)
plt.imshow(RecFISTA_HuberRING_TV[sliceSel,:,:],vmin=0, vmax=max_val)
plt.title('3D HuberRing Rec, axial')

plt.subplot(132)
plt.imshow(RecFISTA_HuberRING_TV[:,sliceSel,:],vmin=0, vmax=max_val)
plt.title('3D HuberRing Rec, coronal')

plt.subplot(133)
plt.imshow(RecFISTA_HuberRING_TV[:,:,sliceSel],vmin=0, vmax=max_val)
plt.title('3D HuberRing Rec, sagittal')
plt.show()
#%%
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print ("Reconstructing with FISTA-OS-SWLS-TV using tomobar")
Expand Down
20 changes: 0 additions & 20 deletions INSTALLATION

This file was deleted.

17 changes: 10 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* A wrapper around [ASTRA-toolbox](https://www.astra-toolbox.com/) to simplify access to various reconstruction methods available in ASTRA
* Regularised iterative ordered-subsets [FISTA](https://epubs.siam.org/doi/10.1137/080716542) reconstruction algorithm with linear and non-linear data fidelities
* Regularised iterative [ADMM](https://ieeexplore.ieee.org/document/7744574/) reconstruction algorithm
* Access to multi-GPU capability through mpi4py
* Access to multi-GPU capability through mpi4py library
* Demos to reconstruct synthetic and also real data (provided) [4-6]

<div align="center">
Expand All @@ -36,7 +36,7 @@
* The FISTA algorithm offers various modifications: convergence acceleration with ordered-subsets method; data fidelities: PWLS, Kullback-Leibler, Huber, Group-Huber[2], Students't [3,4], and SWLS [5] to deal with noise and imaging artifacts (rings, streaks).

### General software prerequisites
* Python or [MATLAB](http://www.mathworks.com/products/matlab/)
* Python or [MATLAB](http://www.mathworks.com/products/matlab/) (not actively maintained currently)

### Software dependencies
* [ASTRA-toolbox](https://www.astra-toolbox.com/) for projection operations
Expand All @@ -63,11 +63,14 @@ conda install -c savu-dep tomobar
export VERSION=`date +%Y.%m` (unix) / set VERSION=2020.10 (Windows)
conda build conda-recipe/ --numpy 1.15 --python 3.7
conda install -c file://${CONDA_PREFIX}/conda-bld/ tomobar --force-reinstall
conda install tomobar --use-local --force-reinstall # if Python2
```

### Python standalone
For building on Linux, modify and run the following [script](https://github.com/dkazanc/ToMoBAR/blob/master/run.sh)
### Python development environment
* Clone the repository from GitHub page
* Install dependencies from the environment file
* Alternatively you can install from the existing explicit file
* Activate the environment with :code:`conda activate tomobar`
* From the root directory install the enviroment in development mode with :code:`pip install -e .[dev]`

### MultiGPU capability
ToMoBAR can be used by running in parallel across multiple GPU devices on a PC or a compute node of a cluster. In order to initiate a parallel run on multiple GPUs you will need an MPI library, such as, [mpi4py](https://mpi4py.readthedocs.io/en/stable/). See this [demo](https://github.com/dkazanc/ToMoBAR/blob/master/Demos/Python/MultiGPU_demo.py).
Expand All @@ -76,12 +79,12 @@ ToMoBAR can be used by running in parallel across multiple GPU devices on a PC o
Use available m-functions, see [Demos](https://github.com/dkazanc/ToMoBAR/tree/master/Demos/Matlab).

## How to use ToMoBAR in Python:
Detailed information about the methods and its parameters can be obtained with:
Detailed information about the methods and parameters can be obtained with:
```
from tomobar.methodsIR import RecToolsIR
help(RecToolsIR)
from tomobar.methodsDIR import RecToolsDIR
help(RecToolsIR)
help(RecToolsDIR)
```

A typical setup for iterative reconstruction would include building three dictionaries: `_data_`, `_algorithm_` and `_regularisation_`
Expand Down
11 changes: 2 additions & 9 deletions conda-recipe/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,5 @@ ECHO VERSION Not Defined.
exit 1
)

mkdir "%SRC_DIR%\test"
ROBOCOPY /E "%RECIPE_DIR%\..\test" "%SRC_DIR%\test"
cd %SRC_DIR%

:: issue cmake to create setup.py
cmake -G "NMake Makefiles" %RECIPE_DIR%\..\ -DBUILD_PYTHON_WRAPPERS=ON -DCONDA_BUILD=ON -DCMAKE_BUILD_TYPE="Release" -DLIBRARY_LIB="%CONDA_PREFIX%\lib" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%PREFIX%\Library"

nmake install
if errorlevel 1 exit 1
"%PYTHON%" -m pip install .
if errorlevel 1 exit 1
9 changes: 2 additions & 7 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
set -xe
cp -rv "$RECIPE_DIR/../test" "$SRC_DIR/"
#!/bin/bash

cd $SRC_DIR

cmake -G "Unix Makefiles" $RECIPE_DIR/../ -DBUILD_PYTHON_WRAPPER=ON -DCONDA_BUILD=ON -DCMAKE_BUILD_TYPE="Release" -DLIBRARY_LIB=$CONDA_PREFIX/lib -DLIBRARY_INC=$CONDA_PREFIX -DCMAKE_INSTALL_PREFIX=$PREFIX

make install
python -m pip install .
10 changes: 2 additions & 8 deletions conda-recipe/conda_build_config.yaml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
python:
- 3.5
- 3.6
- 3.7
- 3.10
numpy:
- 1.12
- 1.14
- 1.15
- 1.16
- 1.21
- 1.24
17 changes: 17 additions & 0 deletions conda-recipe/environment/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: tomobar
channels:
- conda-forge
- anaconda
dependencies:
- conda-forge::numpy
- conda-forge::python
- conda-forge::pytest
- conda-forge::pytest-xdist
- conda-forge::pytest-cov
- conda-forge::flake8
- conda-forge::pyproject-flake8
- conda-forge::pydocstyle
- conda-forge::setuptools
- anaconda::ipython
- anaconda::conda-build
- anaconda::anaconda-client
File renamed without changes.
Loading

0 comments on commit 10152d8

Please sign in to comment.