diff --git a/docs/source/conf.py b/docs/source/conf.py index c25492cc..da5dc2b5 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -8,7 +8,7 @@ project = 'mdreg' copyright = '2024, mdreg maintainers' author = 'mdreg maintainers' -release = '0.4.3' +release = '0.4.4' # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, diff --git a/docs/source/releases/index.rst b/docs/source/releases/index.rst index cc241a31..dab065fc 100644 --- a/docs/source/releases/index.rst +++ b/docs/source/releases/index.rst @@ -11,6 +11,7 @@ Releases .. toctree:: :maxdepth: 2 + release_0.4.4 release_0.4.3 release_0.4.2 release_0.4.1 diff --git a/docs/source/releases/release_0.4.4.rst b/docs/source/releases/release_0.4.4.rst new file mode 100644 index 00000000..34816b92 --- /dev/null +++ b/docs/source/releases/release_0.4.4.rst @@ -0,0 +1,20 @@ +mdreg 0.4.4 +=========== + +Summary +------- + +- Added error handling for elastix + +Contributors +------------ + +1 authors added to this release (alphabetically): + +- Steven Sourbron (`@plaresmedima `_) + +1 reviewers added to this release (alphabetically): + +- Steven Sourbron (`@plaresmedima `_) + + diff --git a/pyproject.toml b/pyproject.toml index 644ae71c..876f867b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ requires = ['setuptools>=61.2'] [project] name = "mdreg" -version = "0.4.3" +version = "0.4.4" dependencies = [ 'importlib-resources>=1.1.0', 'tqdm', @@ -50,7 +50,8 @@ keywords = ['python', "medical imaging", "motion correction", "registration"] requires-python = ">=3.6" [project.urls] -"Homepage" = "https://github.com/QIB-Sheffield/mdreg" +"Homepage" = "https://qib-sheffield.github.io/mdreg/" +"Source Code" = "https://github.com/QIB-Sheffield/mdreg" [tool.setuptools] # ... diff --git a/sops.txt b/sops.txt deleted file mode 100644 index a6c4d5c0..00000000 --- a/sops.txt +++ /dev/null @@ -1,83 +0,0 @@ -SOPs for maintainers -******************** - -Building a virtual environment ------------------------------- - -On windows: ->>> py -3 -m venv .venv # create virtual environment ->>> .venv/Scripts/activate # activate virtual environment - -Then select the Python interpreter in the .venv folder. In VSCode: -View > Command Palette > Python select interpreter -> enter interpreter path (.venv/Scripts/python.exe) - -Then install requirements - ->>> pip install -r requirements.txt - -To leave: ->>> deactivate - - -Creating a new release (from a fork) ------------------------------------- - -- Check test coverage is 100% (see below) -- Update the version number in the below locations, push and check that the test action passes. If it passes, make a pull-request to push to dev. - - pyproject.toml - - docs/source/conf.py -- Merge the dev branch with the main branch. Check that the documentation builds OK. -- Build release notes (see below) and push changes to dev and main. Check docs, actions, and badges on README. -- Create a release on github, with the main branch as target -- Create a release on PyPI (see below) -- Create a release on Zenodo (v1.0 and onwards) - -Check test coverage -------------------- - -cd to /dcmri top folder ->>> pytest --cov=dcmri --cov-report term-missing - -Build release notes -------------------- -- Get a personal token on https://github.com/settings/tokens (does not need any permissions) -- Save the token in the environment variable GH_TOKEN. On windows: ->>> $env:GH_TOKEN='token' -- Build the changelog from current version to current main. For instance: ->>> changelist QIB-Sheffield/mdreg v0.3.8 main --format rst -- Copy-paste the terminal output in an .rst file and save it in docs/source/releases -- Add an entry in the index of docs/source/releases - - -Creating a PyPi release ------------------------ - -If needed: - ->>> pip install build ->>> pip install twine - -In the terminal, cd to the /dcmri directory, and: - ->>> python -m build ->>> twine upload dist/* - -When prompted for user name, enter __token__ - -As password paste the API token generated in PyPi dcmri repository settings (https://pypi.org/manage/project/dcmri/settings/). Note: Paste with Ctrl-V does not work in Windows. Use Edit > Paste via the menu. - - - - -Changing dependencies ---------------------- - -- update requirements.txt -- update pyproject.toml -- generate a new poetry.lock file. On the terminal, run ->>> poetry lock - - - - - diff --git a/src/mdreg/elastix.py b/src/mdreg/elastix.py index ceee3a06..472f872f 100644 --- a/src/mdreg/elastix.py +++ b/src/mdreg/elastix.py @@ -1,5 +1,6 @@ import __main__ import os +import warnings import multiprocessing import numpy as np from tqdm import tqdm @@ -262,10 +263,16 @@ def _coreg_2d(source_large, target_large, spacing, downsample, log, mask, target_small.SetSpacing(spacing_small) source_small.SetOrigin(origin_small) target_small.SetOrigin(origin_small) - coreg_small, result_transform_parameters = itk.elastix_registration_method( - target_small, source_small, - parameter_object=params_obj, - log_to_console=log) + try: + coreg_small, result_transform_parameters = itk.elastix_registration_method( + target_small, source_small, + parameter_object=params_obj, + log_to_console=log) + except: + warnings.warn('Elastix coregistration failed. Returning zero ' + 'deformation field. To find out the error, set log=True.') + deformation_field = np.zeros(source_large.shape + (len(source_large.shape), )) + return source_large.copy(), deformation_field # Get coregistered image at original size large_shape_x, large_shape_y = source_large.shape @@ -331,10 +338,16 @@ def _coreg_3d(source_large, target_large, spacing, downsample, log, mask, target_small.SetSpacing(spacing_small) source_small.SetOrigin(origin_small) target_small.SetOrigin(origin_small) - coreg_small, result_transform_parameters = itk.elastix_registration_method( - target_small, source_small, - parameter_object=params_obj, - log_to_console=log) # perform registration of downsampled image + try: + coreg_small, result_transform_parameters = itk.elastix_registration_method( + target_small, source_small, + parameter_object=params_obj, + log_to_console=log) # perform registration of downsampled image + except: + warnings.warn('Elastix coregistration failed. Returning zero ' + 'deformation field. To find out the error, set log=True.') + deformation_field = np.zeros(source_large.shape + (len(source_large.shape), )) + return source_large.copy(), deformation_field # Get coregistered image at original size result_transform_parameters.SetParameter(0, "Size", [str(large_shape_z), str(large_shape_y), str(large_shape_x)])