pystackreg 0.2.6.post1__tar.gz → 0.2.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/.pre-commit-config.yaml +15 -7
  2. pystackreg-0.2.8/CHANGELOG.rst +74 -0
  3. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/PKG-INFO +59 -41
  4. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/README.rst +4 -0
  5. pystackreg-0.2.8/docs/conf.py +58 -0
  6. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/pyproject.toml +3 -1
  7. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/pystackreg/pystackreg.py +1 -2
  8. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/pystackreg/util/__init__.py +2 -1
  9. pystackreg-0.2.8/pystackreg/version.py +1 -0
  10. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/pystackreg.egg-info/PKG-INFO +59 -41
  11. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/pystackreg.egg-info/SOURCES.txt +2 -1
  12. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/setup.py +15 -11
  13. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/src/pymain.cpp +30 -13
  14. pystackreg-0.2.8/tests/test_pystackreg.py +128 -0
  15. pystackreg-0.2.8/tox.ini +15 -0
  16. pystackreg-0.2.6.post1/CHANGELOG.rst +0 -63
  17. pystackreg-0.2.6.post1/docs/conf.py +0 -58
  18. pystackreg-0.2.6.post1/pystackreg/version.py +0 -1
  19. pystackreg-0.2.6.post1/tox.ini +0 -15
  20. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/.codespellignore +0 -0
  21. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/.flake8 +0 -0
  22. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/.readthedocs.yml +0 -0
  23. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/AUTHORS.rst +0 -0
  24. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/LICENSE.txt +0 -0
  25. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/MANIFEST.in +0 -0
  26. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/+ +0 -0
  27. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/Makefile +0 -0
  28. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/authors.rst +0 -0
  29. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/changelog.rst +0 -0
  30. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/import_ipynb.sh +0 -0
  31. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/index.rst +0 -0
  32. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/make.bat +0 -0
  33. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/readme.rst +0 -0
  34. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/reference/index.rst +0 -0
  35. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/reference/pystackreg.rst +0 -0
  36. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/requirements.txt +0 -0
  37. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/tutorial.rst +0 -0
  38. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/tutorial_files/tutorial_13_0.png +0 -0
  39. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/tutorial_files/tutorial_18_0.png +0 -0
  40. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/tutorial_files/tutorial_24_0.png +0 -0
  41. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/tutorial_files/tutorial_28_1.png +0 -0
  42. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/docs/tutorial_files/tutorial_32_0.png +0 -0
  43. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/examples/data/imagej-perform-stackreg.ijm +0 -0
  44. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/examples/data/imagej-perform-turboreg-bilinear.ijm +0 -0
  45. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/examples/data/pc12-reg-affine.tif +0 -0
  46. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/examples/data/pc12-reg-bilinear.tif +0 -0
  47. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/examples/data/pc12-reg-rigid-body.tif +0 -0
  48. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/examples/data/pc12-reg-scaled-rotation.tif +0 -0
  49. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/examples/data/pc12-reg-translation.tif +0 -0
  50. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/examples/data/pc12-unreg.tif +0 -0
  51. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/examples/notebooks/tutorial.ipynb +0 -0
  52. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/inc/TurboReg.h +0 -0
  53. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/inc/TurboRegImage.h +0 -0
  54. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/inc/TurboRegMask.h +0 -0
  55. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/inc/TurboRegPointHandler.h +0 -0
  56. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/inc/TurboRegTransform.h +0 -0
  57. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/inc/matrix.h +0 -0
  58. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/pystackreg/__init__.py +0 -0
  59. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/pystackreg/conftest.py +0 -0
  60. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/pystackreg.egg-info/dependency_links.txt +0 -0
  61. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/pystackreg.egg-info/requires.txt +0 -0
  62. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/pystackreg.egg-info/top_level.txt +0 -0
  63. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/requirements.txt +0 -0
  64. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/setup.cfg +0 -0
  65. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/src/TurboReg.cpp +0 -0
  66. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/src/TurboRegImage.cpp +0 -0
  67. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/src/TurboRegMask.cpp +0 -0
  68. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/src/TurboRegPointHandler.cpp +0 -0
  69. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/src/TurboRegTransform.cpp +0 -0
  70. {pystackreg-0.2.6.post1 → pystackreg-0.2.8}/src/test_TurboReg.cpp +0 -0
@@ -1,26 +1,34 @@
1
1
  exclude: '^docs/'
2
2
  repos:
3
+ - repo: https://github.com/pycqa/isort
4
+ rev: 5.13.2
5
+ hooks:
6
+ - id: isort
7
+ name: isort (python)
8
+ args: ["--profile", "black", "--filter-files"]
3
9
  - repo: https://github.com/pre-commit/pre-commit-hooks
4
- rev: v4.3.0
10
+ rev: v4.6.0
5
11
  hooks:
6
12
  - id: trailing-whitespace
13
+ exclude: '^.bumpversion.cfg$'
7
14
  - id: end-of-file-fixer
8
15
  - id: mixed-line-ending
9
16
  - id: pretty-format-json
17
+ args: ['--autofix', '--no-sort-keys']
10
18
  - repo: https://github.com/ambv/black
11
- rev: 22.6.0
19
+ rev: 24.8.0
12
20
  hooks:
13
21
  - id: black
14
- - repo: https://gitlab.com/pycqa/flake8
15
- rev: 4.0.1
22
+ - repo: https://github.com/PyCQA/flake8
23
+ rev: '7.1.1'
16
24
  hooks:
17
- - id: flake8
25
+ - id: flake8
18
26
  - repo: https://github.com/pre-commit/mirrors-mypy
19
- rev: v0.961
27
+ rev: v1.11.2
20
28
  hooks:
21
29
  - id: mypy
22
30
  - repo: https://github.com/codespell-project/codespell
23
- rev: 'v2.1.0'
31
+ rev: 'v2.3.0'
24
32
  hooks:
25
33
  - id: codespell
26
34
  name: codespell
@@ -0,0 +1,74 @@
1
+ Changelog
2
+ =========
3
+
4
+ 0.2.8
5
+ -----
6
+
7
+ Fixed
8
+ .....
9
+ - Add NumPy 2 support
10
+
11
+ 0.2.7
12
+ -----
13
+
14
+ Fixed
15
+ .....
16
+ - Axis argument not used for method "mean" in register_stack() (`PR #26 <https://github.com/glichtner/pystackreg/pull/26>`_)
17
+
18
+ 0.2.6
19
+ -----
20
+
21
+ Added
22
+ .....
23
+ - Exposing `simple_slice` and `running_mean` functions in the util package
24
+ - Added conversion function to any integer dtype
25
+
26
+ 0.2.5
27
+ -----
28
+
29
+ Fixed
30
+ .....
31
+ - Compilation in environments without NumPy
32
+
33
+ 0.2.3
34
+ -----
35
+
36
+ Added
37
+ .....
38
+ - Added example data and tutorial notebook
39
+ - Added unit tests
40
+ - Additional documentation
41
+ - Detection of time series axis in stacks – will raise a warning if supplied axis in stack registration does not correspond to the detected axis
42
+
43
+ Changed
44
+ .....~~
45
+ - `progress_callback` function now gets called with the iteration number, not the iteration index (iteration number = iteration index + 1)
46
+
47
+ Fixed
48
+ .....
49
+ - Fixed exception when using a different axis than 0 for registering stacks
50
+
51
+ 0.2.2
52
+ -----
53
+
54
+ Changed
55
+ .....~~
56
+ - License changed to allow distribution on Python package repositories
57
+
58
+ 0.2.1
59
+ -----
60
+
61
+ Added
62
+ .....
63
+ - Progress callback function can be supplied to `register_stack()` and `register_transform_stack()` functions via the `progress_callback` parameter. It is called after every iteration (i.e., after each image registration).
64
+
65
+ Changed
66
+ .....~~
67
+ - Progress bar output is not shown by default, has to be enabled by using the `verbose=True` parameter in the `register_stack()` and `register_transform_stack()` functions
68
+
69
+ 0.2.0
70
+ -----
71
+
72
+ Added
73
+ .....
74
+ - Bilinear transformation
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pystackreg
3
- Version: 0.2.6.post1
3
+ Version: 0.2.8
4
4
  Summary: Image registration tool (python implementation of the ImageJ/FIJI Plugin TurboReg/StackReg)
5
5
  Home-page: https://github.com/glichtner/pystackreg
6
6
  Author: Gregor Lichtner (python/C++ port);TurboReg Author: Philippe Thévenaz, Biomedical Imaging Group,Swiss Federal Institute of Technology Lausanne
@@ -12,16 +12,19 @@ Classifier: Operating System :: Unix
12
12
  Classifier: Operating System :: POSIX
13
13
  Classifier: Programming Language :: C++
14
14
  Classifier: Programming Language :: Python
15
- Classifier: Programming Language :: Python :: 2.7
16
- Classifier: Programming Language :: Python :: 3.5
17
- Classifier: Programming Language :: Python :: 3.6
18
15
  Classifier: Programming Language :: Python :: 3.7
19
16
  Classifier: Programming Language :: Python :: 3.8
20
17
  Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Topic :: Scientific/Engineering :: Image Processing
22
22
  Classifier: Topic :: Utilities
23
+ Description-Content-Type: text/x-rst
23
24
  License-File: LICENSE.txt
24
25
  License-File: AUTHORS.rst
26
+ Requires-Dist: numpy
27
+ Requires-Dist: tqdm
25
28
 
26
29
  pyStackReg
27
30
  ==========
@@ -76,6 +79,10 @@ pyStackReg supports the full functionality of StackReg plus some additional opti
76
79
 
77
80
  Please note: The bilinear transformation cannot be propagated, as a combination of bilinear transformations does not generally result in a bilinear transformation. Therefore, stack registration/transform functions won't work with bilinear transformation when using "previous" image as reference image. You can either use another reference ("first" or "mean" for first or mean image, respectively), or try to register/transform each image of the stack separately to its respective previous image (and use the already transformed previous image as reference for the next image).
78
81
 
82
+ Known issues
83
+ ............
84
+ - pystackreg (and StackReg/TurboReg) have known issues with processing strongly rotated images (e.g. by ~90°; see https://github.com/glichtner/pystackreg/issues/30 for a workaround).
85
+
79
86
 
80
87
  Installation
81
88
  ------------
@@ -279,66 +286,77 @@ License
279
286
  derived from this software.
280
287
 
281
288
 
282
- #########
283
289
  Changelog
284
- #########
290
+ =========
285
291
 
286
- 0.2.6
287
- =====
292
+ 0.2.8
293
+ -----
288
294
 
289
- added
295
+ Fixed
296
+ .....
297
+ - Add NumPy 2 support
298
+
299
+ 0.2.7
290
300
  -----
291
- - exposing simple_slice and running_mean functions in util package
292
- - added conversion function to any integer dtype
293
301
 
294
- 0.2.5
295
- =====
302
+ Fixed
303
+ .....
304
+ - Axis argument not used for method "mean" in register_stack() (`PR #26 <https://github.com/glichtner/pystackreg/pull/26>`_)
296
305
 
297
- fixed
306
+ 0.2.6
298
307
  -----
299
- - Compilation in environment without numpy
300
308
 
301
- 0.2.3
302
- =====
309
+ Added
310
+ .....
311
+ - Exposing `simple_slice` and `running_mean` functions in the util package
312
+ - Added conversion function to any integer dtype
313
+
314
+ 0.2.5
315
+ -----
316
+
317
+ Fixed
318
+ .....
319
+ - Compilation in environments without NumPy
303
320
 
304
- added
321
+ 0.2.3
305
322
  -----
323
+
324
+ Added
325
+ .....
306
326
  - Added example data and tutorial notebook
307
327
  - Added unit tests
308
328
  - Additional documentation
309
- - Detection of time series axis in stacks - will raise a warning if supplied axis in
310
- stack registration does not correspond to the detected axis
329
+ - Detection of time series axis in stacks – will raise a warning if supplied axis in stack registration does not correspond to the detected axis
311
330
 
312
- changed
313
- -------
314
- - `progress_callback` function now gets called with the iteration number, not
315
- iteration index (iteration number = iteration index + 1)
331
+ Changed
332
+ .....~~
333
+ - `progress_callback` function now gets called with the iteration number, not the iteration index (iteration number = iteration index + 1)
316
334
 
317
- fixed
318
- -----
335
+ Fixed
336
+ .....
319
337
  - Fixed exception when using a different axis than 0 for registering stacks
320
338
 
321
339
  0.2.2
322
- =====
340
+ -----
323
341
 
324
- changed
325
- -------
326
- - License changed to allow distribution on python package repositories
342
+ Changed
343
+ .....~~
344
+ - License changed to allow distribution on Python package repositories
327
345
 
328
346
  0.2.1
329
- =====
330
-
331
- added
332
347
  -----
333
- - progress callback function can be supplied to `register_stack()` and `register_transform_stack()` functions via the `progress_callback` that is then called after every iteration (i.e. after each image registration)
334
348
 
335
- changed
336
- -------
337
- - progress bar output not shown by default, has to be enabled by using the `verbose=True` parameter in the `register_stack()` and `register_transform_stack()` functions
349
+ Added
350
+ .....
351
+ - Progress callback function can be supplied to `register_stack()` and `register_transform_stack()` functions via the `progress_callback` parameter. It is called after every iteration (i.e., after each image registration).
338
352
 
339
- 0.2.0
340
- =====
353
+ Changed
354
+ .....~~
355
+ - Progress bar output is not shown by default, has to be enabled by using the `verbose=True` parameter in the `register_stack()` and `register_transform_stack()` functions
341
356
 
342
- added
357
+ 0.2.0
343
358
  -----
344
- - bilinear transformation
359
+
360
+ Added
361
+ .....
362
+ - Bilinear transformation
@@ -51,6 +51,10 @@ pyStackReg supports the full functionality of StackReg plus some additional opti
51
51
 
52
52
  Please note: The bilinear transformation cannot be propagated, as a combination of bilinear transformations does not generally result in a bilinear transformation. Therefore, stack registration/transform functions won't work with bilinear transformation when using "previous" image as reference image. You can either use another reference ("first" or "mean" for first or mean image, respectively), or try to register/transform each image of the stack separately to its respective previous image (and use the already transformed previous image as reference for the next image).
53
53
 
54
+ Known issues
55
+ ............
56
+ - pystackreg (and StackReg/TurboReg) have known issues with processing strongly rotated images (e.g. by ~90°; see https://github.com/glichtner/pystackreg/issues/30 for a workaround).
57
+
54
58
 
55
59
  Installation
56
60
  ------------
@@ -0,0 +1,58 @@
1
+ import os
2
+ import time
3
+
4
+ # cannot directly import because __init__.py imports pystackreg which imports the
5
+ # compiled plugin, which is not available before setup.py is run
6
+ __version__ = "" # placeholder for linters
7
+ exec(open("../pystackreg/version.py").read())
8
+
9
+ extensions = [
10
+ "sphinx.ext.autodoc",
11
+ "sphinx.ext.autosummary",
12
+ "sphinx.ext.coverage",
13
+ "sphinx.ext.doctest",
14
+ "sphinx.ext.extlinks",
15
+ "sphinx.ext.ifconfig",
16
+ "sphinx.ext.napoleon",
17
+ "sphinx_autodoc_typehints",
18
+ "sphinx.ext.todo",
19
+ "sphinx.ext.viewcode",
20
+ ]
21
+
22
+
23
+ if os.getenv("SPELLCHECK"):
24
+ extensions += ("sphinxcontrib.spelling",)
25
+ spelling_show_suggestions = True
26
+ spelling_lang = "en_US"
27
+
28
+ source_suffix = ".rst"
29
+ master_doc = "index"
30
+ project = "pystackreg"
31
+ author = "Gregor Lichtner, Philippe Thevenaz"
32
+ year = f'2018-{time.strftime("%Y")}'
33
+ copyright = "{0}, {1}".format(year, author)
34
+ version = release = __version__
35
+
36
+ pygments_style = "trac"
37
+ templates_path = ["."]
38
+ extlinks = {
39
+ "issue": ("https://github.com/glichtner/pystackreg/%s", "#"),
40
+ "pr": ("https://github.com/glichtner/pystackreg/pull/%s", "PR #"),
41
+ }
42
+ # on_rtd is whether we are on readthedocs.org
43
+ on_rtd = os.environ.get("READTHEDOCS", None) == "True"
44
+
45
+ if not on_rtd: # only set the theme if we're building docs locally
46
+ html_theme = "sphinx_rtd_theme"
47
+
48
+ html_use_smartypants = True
49
+ html_last_updated_fmt = "%b %d, %Y"
50
+ html_split_index = False
51
+ html_sidebars = {
52
+ "**": ["searchbox.html", "globaltoc.html", "sourcelink.html"],
53
+ }
54
+ html_short_title = "%s-%s" % (project, version)
55
+
56
+ napoleon_use_ivar = True
57
+ napoleon_use_rtype = True
58
+ napoleon_use_param = True
@@ -1,5 +1,7 @@
1
1
  [build-system]
2
- requires = ["setuptools", "wheel", "oldest-supported-numpy"]
2
+ requires = ["setuptools", "wheel", "numpy"]
3
+ build-backend = "setuptools.build_meta"
4
+
3
5
 
4
6
  [tool.cibuildwheel]
5
7
  test-requires = ["pytest", "tqdm", "tifffile"]
@@ -350,7 +350,7 @@ class StackReg:
350
350
  if reference == "first":
351
351
  ref = np.mean(img.take(range(n_frames), axis=axis), axis=axis)
352
352
  elif reference == "mean":
353
- ref = img.mean(axis=0)
353
+ ref = img.mean(axis=axis)
354
354
  idx_start = 0
355
355
  elif reference == "previous":
356
356
  pass
@@ -363,7 +363,6 @@ class StackReg:
363
363
  iterable = tqdm(iterable)
364
364
 
365
365
  for i in iterable:
366
-
367
366
  slc = [slice(None)] * len(img.shape)
368
367
  slc[axis] = i
369
368
 
@@ -1,6 +1,7 @@
1
1
  """
2
2
  Collection of utility functions for pystackreg
3
3
  """
4
+
4
5
  import numpy as np
5
6
 
6
7
 
@@ -44,7 +45,7 @@ def to_int_dtype(arr: np.ndarray, dtype: type):
44
45
  :rtype: ndarray(Ni..., Nj..., Nk...)
45
46
  :return: Input array clipped & rounded to integer dtype
46
47
  """
47
- assert type(arr) == np.ndarray, "Input must be a numpy array"
48
+ assert isinstance(arr, np.ndarray), "Input must be a numpy array"
48
49
 
49
50
  if not np.issubdtype(dtype, np.integer):
50
51
  return arr
@@ -0,0 +1 @@
1
+ __version__ = "0.2.8"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pystackreg
3
- Version: 0.2.6.post1
3
+ Version: 0.2.8
4
4
  Summary: Image registration tool (python implementation of the ImageJ/FIJI Plugin TurboReg/StackReg)
5
5
  Home-page: https://github.com/glichtner/pystackreg
6
6
  Author: Gregor Lichtner (python/C++ port);TurboReg Author: Philippe Thévenaz, Biomedical Imaging Group,Swiss Federal Institute of Technology Lausanne
@@ -12,16 +12,19 @@ Classifier: Operating System :: Unix
12
12
  Classifier: Operating System :: POSIX
13
13
  Classifier: Programming Language :: C++
14
14
  Classifier: Programming Language :: Python
15
- Classifier: Programming Language :: Python :: 2.7
16
- Classifier: Programming Language :: Python :: 3.5
17
- Classifier: Programming Language :: Python :: 3.6
18
15
  Classifier: Programming Language :: Python :: 3.7
19
16
  Classifier: Programming Language :: Python :: 3.8
20
17
  Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Topic :: Scientific/Engineering :: Image Processing
22
22
  Classifier: Topic :: Utilities
23
+ Description-Content-Type: text/x-rst
23
24
  License-File: LICENSE.txt
24
25
  License-File: AUTHORS.rst
26
+ Requires-Dist: numpy
27
+ Requires-Dist: tqdm
25
28
 
26
29
  pyStackReg
27
30
  ==========
@@ -76,6 +79,10 @@ pyStackReg supports the full functionality of StackReg plus some additional opti
76
79
 
77
80
  Please note: The bilinear transformation cannot be propagated, as a combination of bilinear transformations does not generally result in a bilinear transformation. Therefore, stack registration/transform functions won't work with bilinear transformation when using "previous" image as reference image. You can either use another reference ("first" or "mean" for first or mean image, respectively), or try to register/transform each image of the stack separately to its respective previous image (and use the already transformed previous image as reference for the next image).
78
81
 
82
+ Known issues
83
+ ............
84
+ - pystackreg (and StackReg/TurboReg) have known issues with processing strongly rotated images (e.g. by ~90°; see https://github.com/glichtner/pystackreg/issues/30 for a workaround).
85
+
79
86
 
80
87
  Installation
81
88
  ------------
@@ -279,66 +286,77 @@ License
279
286
  derived from this software.
280
287
 
281
288
 
282
- #########
283
289
  Changelog
284
- #########
290
+ =========
285
291
 
286
- 0.2.6
287
- =====
292
+ 0.2.8
293
+ -----
288
294
 
289
- added
295
+ Fixed
296
+ .....
297
+ - Add NumPy 2 support
298
+
299
+ 0.2.7
290
300
  -----
291
- - exposing simple_slice and running_mean functions in util package
292
- - added conversion function to any integer dtype
293
301
 
294
- 0.2.5
295
- =====
302
+ Fixed
303
+ .....
304
+ - Axis argument not used for method "mean" in register_stack() (`PR #26 <https://github.com/glichtner/pystackreg/pull/26>`_)
296
305
 
297
- fixed
306
+ 0.2.6
298
307
  -----
299
- - Compilation in environment without numpy
300
308
 
301
- 0.2.3
302
- =====
309
+ Added
310
+ .....
311
+ - Exposing `simple_slice` and `running_mean` functions in the util package
312
+ - Added conversion function to any integer dtype
313
+
314
+ 0.2.5
315
+ -----
316
+
317
+ Fixed
318
+ .....
319
+ - Compilation in environments without NumPy
303
320
 
304
- added
321
+ 0.2.3
305
322
  -----
323
+
324
+ Added
325
+ .....
306
326
  - Added example data and tutorial notebook
307
327
  - Added unit tests
308
328
  - Additional documentation
309
- - Detection of time series axis in stacks - will raise a warning if supplied axis in
310
- stack registration does not correspond to the detected axis
329
+ - Detection of time series axis in stacks – will raise a warning if supplied axis in stack registration does not correspond to the detected axis
311
330
 
312
- changed
313
- -------
314
- - `progress_callback` function now gets called with the iteration number, not
315
- iteration index (iteration number = iteration index + 1)
331
+ Changed
332
+ .....~~
333
+ - `progress_callback` function now gets called with the iteration number, not the iteration index (iteration number = iteration index + 1)
316
334
 
317
- fixed
318
- -----
335
+ Fixed
336
+ .....
319
337
  - Fixed exception when using a different axis than 0 for registering stacks
320
338
 
321
339
  0.2.2
322
- =====
340
+ -----
323
341
 
324
- changed
325
- -------
326
- - License changed to allow distribution on python package repositories
342
+ Changed
343
+ .....~~
344
+ - License changed to allow distribution on Python package repositories
327
345
 
328
346
  0.2.1
329
- =====
330
-
331
- added
332
347
  -----
333
- - progress callback function can be supplied to `register_stack()` and `register_transform_stack()` functions via the `progress_callback` that is then called after every iteration (i.e. after each image registration)
334
348
 
335
- changed
336
- -------
337
- - progress bar output not shown by default, has to be enabled by using the `verbose=True` parameter in the `register_stack()` and `register_transform_stack()` functions
349
+ Added
350
+ .....
351
+ - Progress callback function can be supplied to `register_stack()` and `register_transform_stack()` functions via the `progress_callback` parameter. It is called after every iteration (i.e., after each image registration).
338
352
 
339
- 0.2.0
340
- =====
353
+ Changed
354
+ .....~~
355
+ - Progress bar output is not shown by default, has to be enabled by using the `verbose=True` parameter in the `register_stack()` and `register_transform_stack()` functions
341
356
 
342
- added
357
+ 0.2.0
343
358
  -----
344
- - bilinear transformation
359
+
360
+ Added
361
+ .....
362
+ - Bilinear transformation
@@ -60,4 +60,5 @@ src/TurboRegMask.cpp
60
60
  src/TurboRegPointHandler.cpp
61
61
  src/TurboRegTransform.cpp
62
62
  src/pymain.cpp
63
- src/test_TurboReg.cpp
63
+ src/test_TurboReg.cpp
64
+ tests/test_pystackreg.py
@@ -1,10 +1,9 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  import os
4
- from setuptools import setup, Extension, find_packages
5
4
 
6
- # cannot directly import because __init__.py imports pystackreg which imports the
7
- # compiled plugin, which is not available before setup.py is run
5
+ from setuptools import Extension, find_packages, setup
6
+
8
7
  __version__ = "" # placeholder for linters
9
8
  exec(open("pystackreg/version.py").read())
10
9
 
@@ -26,13 +25,18 @@ if __name__ == "__main__":
26
25
 
27
26
  setup(
28
27
  name="pystackreg",
29
- description="Image registration tool (python implementation of the ImageJ/FIJI "
30
- "Plugin TurboReg/StackReg)",
28
+ description=(
29
+ "Image registration tool (python implementation of the ImageJ/FIJI "
30
+ "Plugin TurboReg/StackReg)"
31
+ ),
31
32
  long_description="\n\n".join([readme, change]),
33
+ long_description_content_type="text/x-rst",
32
34
  version=__version__,
33
- author="Gregor Lichtner (python/C++ port);"
34
- "TurboReg Author: Philippe Thévenaz, Biomedical Imaging Group,"
35
- "Swiss Federal Institute of Technology Lausanne",
35
+ author=(
36
+ "Gregor Lichtner (python/C++ port);"
37
+ "TurboReg Author: Philippe Thévenaz, Biomedical Imaging Group,"
38
+ "Swiss Federal Institute of Technology Lausanne"
39
+ ),
36
40
  url="https://github.com/glichtner/pystackreg",
37
41
  packages=find_packages("."),
38
42
  ext_modules=[
@@ -62,12 +66,12 @@ if __name__ == "__main__":
62
66
  "Operating System :: POSIX",
63
67
  "Programming Language :: C++",
64
68
  "Programming Language :: Python",
65
- "Programming Language :: Python :: 2.7",
66
- "Programming Language :: Python :: 3.5",
67
- "Programming Language :: Python :: 3.6",
68
69
  "Programming Language :: Python :: 3.7",
69
70
  "Programming Language :: Python :: 3.8",
70
71
  "Programming Language :: Python :: 3.9",
72
+ "Programming Language :: Python :: 3.10",
73
+ "Programming Language :: Python :: 3.11",
74
+ "Programming Language :: Python :: 3.12",
71
75
  "Topic :: Scientific/Engineering :: Image Processing",
72
76
  "Topic :: Utilities",
73
77
  ],
@@ -7,6 +7,7 @@
7
7
  * Author: Gregor Lichtner
8
8
  */
9
9
 
10
+ #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
10
11
  #include <Python.h>
11
12
  #include <numpy/arrayobject.h>
12
13
 
@@ -31,7 +32,7 @@ typedef struct regMat {
31
32
  } regMat;
32
33
 
33
34
  static PyObject *turbogreg_register(PyObject *self, PyObject *args);
34
- static PyObject *turbogreg_transform(PyObject *self, PyObject *args);
35
+ static PyArrayObject *turbogreg_transform(PyObject *self, PyObject *args);
35
36
 
36
37
  static char pystackreg_docs[] = "PyStackReg\n";
37
38
  static PyMethodDef module_methods[] = {
@@ -147,8 +148,16 @@ PyObject *turbogreg_register(PyObject *self, PyObject *args) {
147
148
  }
148
149
 
149
150
  /* Interpret the input objects as numpy arrays. */
150
- PyObject *ref_array = PyArray_FROM_OTF(ref, NPY_DOUBLE, NPY_IN_ARRAY);
151
- PyObject *mov_array = PyArray_FROM_OTF(mov, NPY_DOUBLE, NPY_IN_ARRAY);
151
+ PyObject *po_ref_array = PyArray_FROM_OTF(ref, NPY_DOUBLE, NPY_ARRAY_IN_ARRAY);
152
+ PyObject *po_mov_array = PyArray_FROM_OTF(mov, NPY_DOUBLE, NPY_ARRAY_IN_ARRAY);
153
+
154
+ if (!PyArray_Check(po_ref_array) || !PyArray_Check(po_mov_array)) {
155
+ PyErr_SetString(PyExc_TypeError, "Expected a numpy array");
156
+ return NULL;
157
+ }
158
+
159
+ PyArrayObject *ref_array = (PyArrayObject *)po_ref_array;
160
+ PyArrayObject *mov_array = (PyArrayObject *)po_mov_array;
152
161
 
153
162
  /* If that didn't work, throw an exception. */
154
163
  if (ref_array == NULL || mov_array == NULL) {
@@ -199,9 +208,9 @@ PyObject *turbogreg_register(PyObject *self, PyObject *args) {
199
208
  dims_pts[0] = rm.refPts.nrows();
200
209
  dims_pts[1] = rm.refPts.ncols();
201
210
 
202
- PyObject *retMat = PyArray_SimpleNew(2, (npy_intp *)&dims_mat, NPY_DOUBLE);
203
- PyObject *retPtsRef = PyArray_SimpleNew(2, (npy_intp *)&dims_pts, NPY_DOUBLE);
204
- PyObject *retPtsMov = PyArray_SimpleNew(2, (npy_intp *)&dims_pts, NPY_DOUBLE);
211
+ PyArrayObject *retMat = (PyArrayObject*)PyArray_SimpleNew(2, (npy_intp *)&dims_mat, NPY_DOUBLE);
212
+ PyArrayObject *retPtsRef = (PyArrayObject*)PyArray_SimpleNew(2, (npy_intp *)&dims_pts, NPY_DOUBLE);
213
+ PyArrayObject *retPtsMov = (PyArrayObject*)PyArray_SimpleNew(2, (npy_intp *)&dims_pts, NPY_DOUBLE);
205
214
 
206
215
  memcpy((void *)PyArray_DATA(retMat), rm.mat.begin(),
207
216
  (dims_mat[0] * dims_mat[1] * sizeof(double)));
@@ -213,7 +222,7 @@ PyObject *turbogreg_register(PyObject *self, PyObject *args) {
213
222
  return Py_BuildValue("OOO", retMat, retPtsRef, retPtsMov);
214
223
  }
215
224
 
216
- PyObject *turbogreg_transform(PyObject *self, PyObject *args) {
225
+ PyArrayObject *turbogreg_transform(PyObject *self, PyObject *args) {
217
226
  PyObject *mov;
218
227
  PyObject *mat;
219
228
 
@@ -223,16 +232,24 @@ PyObject *turbogreg_transform(PyObject *self, PyObject *args) {
223
232
  }
224
233
 
225
234
  /* Interpret the input objects as numpy arrays. */
226
- PyObject *mov_array = PyArray_FROM_OTF(mov, NPY_DOUBLE, NPY_IN_ARRAY);
227
- PyObject *mat_array = PyArray_FROM_OTF(mat, NPY_DOUBLE, NPY_IN_ARRAY);
235
+ PyObject *po_mov_array = PyArray_FROM_OTF(mov, NPY_DOUBLE, NPY_ARRAY_IN_ARRAY);
236
+ PyObject *po_mat_array = PyArray_FROM_OTF(mat, NPY_DOUBLE, NPY_ARRAY_IN_ARRAY);
228
237
 
229
238
  /* If that didn't work, throw an exception. */
230
- if (mov_array == NULL || mat_array == NULL) {
231
- Py_XDECREF(mat_array);
232
- Py_XDECREF(mov_array);
239
+ if (po_mov_array == NULL || po_mat_array == NULL) {
240
+ Py_XDECREF(po_mat_array);
241
+ Py_XDECREF(po_mov_array);
233
242
  return NULL;
234
243
  }
235
244
 
245
+ if (!PyArray_Check(po_mat_array) || !PyArray_Check(po_mov_array)) {
246
+ PyErr_SetString(PyExc_TypeError, "Expected a numpy array");
247
+ return NULL;
248
+ }
249
+
250
+ PyArrayObject *mov_array = (PyArrayObject *)po_mov_array;
251
+ PyArrayObject *mat_array = (PyArrayObject *)po_mat_array;
252
+
236
253
  int ndim_mov = (int)PyArray_NDIM(mov_array);
237
254
  int ndim_mat = (int)PyArray_NDIM(mat_array);
238
255
 
@@ -275,7 +292,7 @@ PyObject *turbogreg_transform(PyObject *self, PyObject *args) {
275
292
 
276
293
  npy_intp dims[2] = {Nx_mov, Ny_mov};
277
294
 
278
- PyObject *ret = PyArray_SimpleNew(2, (npy_intp *)&dims, NPY_DOUBLE);
295
+ PyArrayObject *ret = (PyArrayObject*)PyArray_SimpleNew(2, (npy_intp *)&dims, NPY_DOUBLE);
279
296
 
280
297
  memcpy((void *)PyArray_DATA(ret), &imgout[0],
281
298
  (Nx_mov * Ny_mov * sizeof(double)));
@@ -0,0 +1,128 @@
1
+ import os
2
+ import pytest
3
+ import numpy as np
4
+ from pystackreg import StackReg
5
+ import tifffile as tif
6
+
7
+ BASE_PATH = os.path.dirname(__file__) + "/data/"
8
+ prefix = "pc12"
9
+
10
+
11
+ def np_school_round(x):
12
+ """
13
+ Rounding function that always round .5 value up (as opposed to standard
14
+ python/numpy behaviour, which round .5 values to the next even number.
15
+ This function here mimics the behavior of ImageJ for comparability of
16
+ StackReg/TurboReg registrations from ImageJ and pystackreg.
17
+
18
+ :param x: (float) number
19
+ :return: (float) rounded number (.5 always rounded up)
20
+ """
21
+ x = np.array(x)
22
+ r = x.copy()
23
+ idx = x - np.floor(x) < 0.5
24
+ r[idx] = np.floor(x[idx])
25
+ r[~idx] = np.ceil(x[~idx])
26
+
27
+ return r
28
+
29
+
30
+ def to_uint16(img):
31
+ return np_school_round(img.clip(min=0, max=65535)).astype(np.uint16)
32
+
33
+
34
+ @pytest.fixture
35
+ def stack_unregistered():
36
+ return load_file("unregistered")
37
+
38
+
39
+ @pytest.fixture
40
+ def stack_translation():
41
+ return load_file("translation")
42
+
43
+
44
+ @pytest.fixture
45
+ def stack_rigid_body():
46
+ return load_file("rigid-body")
47
+
48
+
49
+ @pytest.fixture
50
+ def stack_scaled_roation():
51
+ return load_file("scaled-rotation")
52
+
53
+
54
+ @pytest.fixture
55
+ def stack_affine():
56
+ return load_file("affine")
57
+
58
+
59
+ @pytest.fixture
60
+ def stack_bilinear():
61
+ return load_file("bilinear")
62
+
63
+
64
+ def load_file(transformation):
65
+ if transformation == "unregistered":
66
+ fname = prefix + "-unreg"
67
+ else:
68
+ fname = prefix + "-reg-" + transformation
69
+
70
+ return tif.imread(os.path.join(BASE_PATH, fname + ".tif"))
71
+
72
+
73
+ @pytest.fixture(
74
+ params=[
75
+ StackReg.TRANSLATION,
76
+ StackReg.RIGID_BODY,
77
+ StackReg.SCALED_ROTATION,
78
+ StackReg.AFFINE,
79
+ StackReg.BILINEAR,
80
+ ]
81
+ )
82
+ def stack(request):
83
+ transformation_map = {
84
+ StackReg.TRANSLATION: "translation",
85
+ StackReg.RIGID_BODY: "rigid-body",
86
+ StackReg.SCALED_ROTATION: "scaled-rotation",
87
+ StackReg.AFFINE: "affine",
88
+ StackReg.BILINEAR: "bilinear",
89
+ }
90
+
91
+ return {
92
+ "transformation": request.param,
93
+ "registered": load_file(transformation_map[request.param]),
94
+ }
95
+
96
+
97
+ def test_registration_transformation(stack, stack_unregistered):
98
+ sr = StackReg(stack["transformation"])
99
+ reference = (
100
+ "previous" if not stack["transformation"] == StackReg.BILINEAR else "first"
101
+ )
102
+ out = sr.register_transform_stack(stack_unregistered, reference=reference)
103
+
104
+ np.testing.assert_allclose(
105
+ to_uint16(out), to_uint16(stack["registered"]), rtol=1e-7, atol=1
106
+ )
107
+
108
+
109
+ @pytest.mark.parametrize("frame_axis", [1, 2])
110
+ def test_different_axis(stack, stack_unregistered, frame_axis):
111
+ stack["registered"] = np.moveaxis(stack["registered"], 0, frame_axis)
112
+ stack_unregistered = np.moveaxis(stack_unregistered, 0, frame_axis)
113
+
114
+ sr = StackReg(stack["transformation"])
115
+ reference = (
116
+ "previous" if not stack["transformation"] == StackReg.BILINEAR else "first"
117
+ )
118
+ out = sr.register_transform_stack(
119
+ stack_unregistered, reference=reference, axis=frame_axis
120
+ )
121
+
122
+ assert out.shape == stack["registered"].shape
123
+ np.testing.assert_allclose(
124
+ to_uint16(out),
125
+ to_uint16(stack["registered"]),
126
+ rtol=1e-7,
127
+ atol=1,
128
+ )
@@ -0,0 +1,15 @@
1
+ [tox]
2
+ envlist = py
3
+
4
+ [testenv]
5
+ deps =
6
+ pytest
7
+ tifffile
8
+ numpy=={env:NUMPY_VERSION}
9
+ setuptools
10
+ wheel
11
+ -rrequirements.txt
12
+
13
+ commands =
14
+ pip install -e .
15
+ pytest {posargs:}
@@ -1,63 +0,0 @@
1
- #########
2
- Changelog
3
- #########
4
-
5
- 0.2.6
6
- =====
7
-
8
- added
9
- -----
10
- - exposing simple_slice and running_mean functions in util package
11
- - added conversion function to any integer dtype
12
-
13
- 0.2.5
14
- =====
15
-
16
- fixed
17
- -----
18
- - Compilation in environment without numpy
19
-
20
- 0.2.3
21
- =====
22
-
23
- added
24
- -----
25
- - Added example data and tutorial notebook
26
- - Added unit tests
27
- - Additional documentation
28
- - Detection of time series axis in stacks - will raise a warning if supplied axis in
29
- stack registration does not correspond to the detected axis
30
-
31
- changed
32
- -------
33
- - `progress_callback` function now gets called with the iteration number, not
34
- iteration index (iteration number = iteration index + 1)
35
-
36
- fixed
37
- -----
38
- - Fixed exception when using a different axis than 0 for registering stacks
39
-
40
- 0.2.2
41
- =====
42
-
43
- changed
44
- -------
45
- - License changed to allow distribution on python package repositories
46
-
47
- 0.2.1
48
- =====
49
-
50
- added
51
- -----
52
- - progress callback function can be supplied to `register_stack()` and `register_transform_stack()` functions via the `progress_callback` that is then called after every iteration (i.e. after each image registration)
53
-
54
- changed
55
- -------
56
- - progress bar output not shown by default, has to be enabled by using the `verbose=True` parameter in the `register_stack()` and `register_transform_stack()` functions
57
-
58
- 0.2.0
59
- =====
60
-
61
- added
62
- -----
63
- - bilinear transformation
@@ -1,58 +0,0 @@
1
- import os
2
- import time
3
-
4
- # cannot directly import because __init__.py imports pystackreg which imports the
5
- # compiled plugin, which is not available before setup.py is run
6
- __version__ = "" # placeholder for linters
7
- exec(open("../pystackreg/version.py").read())
8
-
9
- extensions = [
10
- 'sphinx.ext.autodoc',
11
- 'sphinx.ext.autosummary',
12
- 'sphinx.ext.coverage',
13
- 'sphinx.ext.doctest',
14
- 'sphinx.ext.extlinks',
15
- 'sphinx.ext.ifconfig',
16
- 'sphinx.ext.napoleon',
17
- 'sphinx_autodoc_typehints',
18
- 'sphinx.ext.todo',
19
- 'sphinx.ext.viewcode',
20
- ]
21
-
22
-
23
- if os.getenv('SPELLCHECK'):
24
- extensions += 'sphinxcontrib.spelling',
25
- spelling_show_suggestions = True
26
- spelling_lang = 'en_US'
27
-
28
- source_suffix = '.rst'
29
- master_doc = 'index'
30
- project = 'pystackreg'
31
- author = "Gregor Lichtner, Philippe Thevenaz"
32
- year = f'2018-{time.strftime("%Y")}'
33
- copyright = '{0}, {1}'.format(year, author)
34
- version = release = __version__
35
-
36
- pygments_style = 'trac'
37
- templates_path = ['.']
38
- extlinks = {
39
- 'issue': ('https://github.com/glichtner/pystackreg/%s', '#'),
40
- 'pr': ('https://github.com/glichtner/pystackreg/pull/%s', 'PR #'),
41
- }
42
- # on_rtd is whether we are on readthedocs.org
43
- on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
44
-
45
- if not on_rtd: # only set the theme if we're building docs locally
46
- html_theme = 'sphinx_rtd_theme'
47
-
48
- html_use_smartypants = True
49
- html_last_updated_fmt = '%b %d, %Y'
50
- html_split_index = False
51
- html_sidebars = {
52
- '**': ['searchbox.html', 'globaltoc.html', 'sourcelink.html'],
53
- }
54
- html_short_title = '%s-%s' % (project, version)
55
-
56
- napoleon_use_ivar = True
57
- napoleon_use_rtype = True
58
- napoleon_use_param = True
@@ -1 +0,0 @@
1
- __version__ = "0.2.6-1"
@@ -1,15 +0,0 @@
1
- [tox]
2
- requires =
3
- numpy
4
- tqdm
5
-
6
- [testenv]
7
- deps=
8
- -rrequirements.txt
9
- tifffile
10
- pytest
11
-
12
- commands=
13
- python setup.py build_ext --inplace
14
- python setup.py install
15
- pytest {posargs:}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes