Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.4.4 #69

Merged
merged 6 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions docs/source/releases/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Releases
.. toctree::
:maxdepth: 2

release_0.4.4
release_0.4.3
release_0.4.2
release_0.4.1
Expand Down
20 changes: 20 additions & 0 deletions docs/source/releases/release_0.4.4.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/plaresmedima>`_)

1 reviewers added to this release (alphabetically):

- Steven Sourbron (`@plaresmedima <https://github.com/plaresmedima>`_)


5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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]
# ...
Expand Down
83 changes: 0 additions & 83 deletions sops.txt

This file was deleted.

29 changes: 21 additions & 8 deletions src/mdreg/elastix.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import __main__
import os
import warnings
import multiprocessing
import numpy as np
from tqdm import tqdm
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)])
Expand Down
Loading