Skip to content

Commit

Permalink
Merge pull request #120 from DiamondLightSource/notebooks
Browse files Browse the repository at this point in the history
Notebooks updates, GA token
  • Loading branch information
dkazanc authored Apr 24, 2024
2 parents 063e026 + e7ee568 commit 9352fca
Show file tree
Hide file tree
Showing 13 changed files with 574 additions and 183 deletions.
2 changes: 1 addition & 1 deletion .scripts/conda_upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export CONDA_BLD_PATH=~/conda-bld
$CONDA/bin/conda install conda-build
$CONDA/bin/conda install -c anaconda anaconda-client

$CONDA/bin/conda build . -c conda-forge -c httomo -c astra-toolbox --no-test
$CONDA/bin/conda build . -c conda-forge -c httomo -c astra-toolbox -c rapidsai --no-test

# upload packages to conda
find $CONDA_BLD_PATH/$OS -name *.tar.bz2 | while read file
Expand Down
Binary file modified .scripts/my_secret.json.gpg
Binary file not shown.
37 changes: 12 additions & 25 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ HTTomolibGPU is a library of GPU accelerated methods for tomography

**HTTomolibGPU** is a collection of image processing methods in Python for computed tomography.
The methods are GPU-accelerated with the open-source Python library `CuPy <https://cupy.dev/>`_. Most of the
methods migrated from `TomoPy <https://tomopy.readthedocs.io/en/stable/>`_ and `Savu <https://savu.readthedocs.io/en/latest/>`_ software packages. They have been
optimised to ensure computational efficiency and high-throughput.
methods migrated from `TomoPy <https://tomopy.readthedocs.io/en/stable/>`_ and `Savu <https://savu.readthedocs.io/en/latest/>`_ software packages.
They have been optimised to ensure higher computational efficiency.

Purpose of HTTomolibGPU
=======================

**HTTomolibGPU** can be used as a stand-alone library, but it has been specifically developed to
work together with the `HTTomo <https://diamondlightsource.github.io/httomo/>`_ package.
Expand All @@ -15,7 +18,7 @@ Install HTTomolibGPU as a pre-built conda Python package
.. code-block:: console
$ conda create --name httomolibgpu # create a fresh conda environment
$ conda install -c httomo httomolibgpu
$ conda install httomo::httomolibgpu
Setup the development environment:
==================================
Expand All @@ -25,32 +28,16 @@ Setup the development environment:
$ git clone [email protected]:DiamondLightSource/httomolibgpu.git # clone the repo
$ conda env create --name httomolibgpu --file conda/environment.yml # install dependencies
$ conda activate httomolibgpu # activate the environment
$ pip install .[dev] # development mode
$ pip install -e .[dev] # editable/development mode
Build HTTomolibGPU as a conda Python package
=============================================
============================================

.. code-block:: console
$ conda build conda/recipe/ -c conda-forge -c httomo -c astra-toolbox
An example of using the API
===========================
* The file :code:`examples/normalize-data.py` shows how to apply dark-flat field correction to the :code:`tests/test_data/tomo_standard.npz` data.
* The file :code:`examples/fresnel-filter.py` shows how to apply Fresnel filtering to the :code:`tests/test_data/tomo_standard.npz` data.

Input data for methods
======================
$ conda build conda/recipe/ -c conda-forge -c httomo -c astra-toolbox -c rapidsai
* We load the projection data from the file :code:`tests/test_data/tomo_standard.npz` using :code:`numpy.load`, which returns a dictionary-like object that can be indexed using the keys :code:`'data'` (to get :code:`host_data`), :code:`'flats'`, and :code:`'darks'`.
* The dataset :code:`/data` in :code:`tests/test_data/normalized-projs.h5` is the input for methods in :code:`httomolibgpu.prep.stripe`
* The dataset :code:`/data` in :code:`tests/test_data/removed-stripes.h5` is the input for methods in :code:`httomolibgpu.recon.rotation`

Run tests
Examples
=========
* Run all tests with :code:`$ pytest`. To increase verbosity, use :code:`$ pytest -v`.
* Run GPU tests separately with :code:`$ pytest -v -m gpu`.
* Run CPU tests separately with :code:`$ pytest -v -m "not gpu"`.
* Run performance tests (only) with :code:`$ pytest --performance`
(note that performance tests always fail - they report the execution time in an assertion
to see them in the summary easily)

There are series of Jupyter Notebooks located in :code:`examples/*` to demonstrate how some of the functions can be used.
1 change: 1 addition & 0 deletions conda/recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ python:
- 3.10
numpy:
- 1.24
- 1.25
124 changes: 124 additions & 0 deletions examples/DistortionCorr.ipynb

Large diffs are not rendered by default.

31 changes: 0 additions & 31 deletions examples/correct-distortion.py

This file was deleted.

22 changes: 0 additions & 22 deletions examples/fresnel-filter.py

This file was deleted.

19 changes: 0 additions & 19 deletions examples/normalize-data.py

This file was deleted.

15 changes: 0 additions & 15 deletions examples/paganin-filter.py

This file was deleted.

240 changes: 240 additions & 0 deletions examples/pipeline1_FBP.ipynb

Large diffs are not rendered by default.

193 changes: 193 additions & 0 deletions examples/pipeline2_iterative.ipynb

Large diffs are not rendered by default.

67 changes: 0 additions & 67 deletions examples/pipeline_preproc.py

This file was deleted.

6 changes: 3 additions & 3 deletions httomolibgpu/misc/corr.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
import nvtx
from cupy import float32

from cucim.skimage.filters import median
from cucim.skimage.morphology import disk

from httomolibgpu.cuda_kernels import load_cuda_module

__all__ = [
Expand Down Expand Up @@ -72,6 +69,9 @@ def median_filter(
ValueError
If the input array is not three dimensional.
"""
from cucim.skimage.filters import median
from cucim.skimage.morphology import disk

input_type = data.dtype

if input_type not in ["float32", "uint16"]:
Expand Down

0 comments on commit 9352fca

Please sign in to comment.