pystackreg 0.2.7__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 (69) hide show
  1. {pystackreg-0.2.7 → pystackreg-0.2.8}/.pre-commit-config.yaml +13 -7
  2. pystackreg-0.2.8/CHANGELOG.rst +74 -0
  3. {pystackreg-0.2.7 → pystackreg-0.2.8}/PKG-INFO +55 -44
  4. {pystackreg-0.2.7 → pystackreg-0.2.8}/README.rst +4 -0
  5. {pystackreg-0.2.7 → pystackreg-0.2.8}/pyproject.toml +3 -1
  6. {pystackreg-0.2.7 → pystackreg-0.2.8}/pystackreg/pystackreg.py +0 -1
  7. {pystackreg-0.2.7 → pystackreg-0.2.8}/pystackreg/util/__init__.py +2 -1
  8. pystackreg-0.2.8/pystackreg/version.py +1 -0
  9. {pystackreg-0.2.7 → pystackreg-0.2.8}/pystackreg.egg-info/PKG-INFO +55 -44
  10. {pystackreg-0.2.7 → pystackreg-0.2.8}/pystackreg.egg-info/SOURCES.txt +2 -1
  11. {pystackreg-0.2.7 → pystackreg-0.2.8}/setup.py +15 -11
  12. {pystackreg-0.2.7 → pystackreg-0.2.8}/src/pymain.cpp +30 -13
  13. pystackreg-0.2.8/tests/test_pystackreg.py +128 -0
  14. pystackreg-0.2.8/tox.ini +15 -0
  15. pystackreg-0.2.7/CHANGELOG.rst +0 -70
  16. pystackreg-0.2.7/pystackreg/version.py +0 -1
  17. pystackreg-0.2.7/tox.ini +0 -15
  18. {pystackreg-0.2.7 → pystackreg-0.2.8}/.codespellignore +0 -0
  19. {pystackreg-0.2.7 → pystackreg-0.2.8}/.flake8 +0 -0
  20. {pystackreg-0.2.7 → pystackreg-0.2.8}/.readthedocs.yml +0 -0
  21. {pystackreg-0.2.7 → pystackreg-0.2.8}/AUTHORS.rst +0 -0
  22. {pystackreg-0.2.7 → pystackreg-0.2.8}/LICENSE.txt +0 -0
  23. {pystackreg-0.2.7 → pystackreg-0.2.8}/MANIFEST.in +0 -0
  24. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/+ +0 -0
  25. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/Makefile +0 -0
  26. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/authors.rst +0 -0
  27. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/changelog.rst +0 -0
  28. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/conf.py +0 -0
  29. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/import_ipynb.sh +0 -0
  30. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/index.rst +0 -0
  31. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/make.bat +0 -0
  32. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/readme.rst +0 -0
  33. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/reference/index.rst +0 -0
  34. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/reference/pystackreg.rst +0 -0
  35. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/requirements.txt +0 -0
  36. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/tutorial.rst +0 -0
  37. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/tutorial_files/tutorial_13_0.png +0 -0
  38. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/tutorial_files/tutorial_18_0.png +0 -0
  39. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/tutorial_files/tutorial_24_0.png +0 -0
  40. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/tutorial_files/tutorial_28_1.png +0 -0
  41. {pystackreg-0.2.7 → pystackreg-0.2.8}/docs/tutorial_files/tutorial_32_0.png +0 -0
  42. {pystackreg-0.2.7 → pystackreg-0.2.8}/examples/data/imagej-perform-stackreg.ijm +0 -0
  43. {pystackreg-0.2.7 → pystackreg-0.2.8}/examples/data/imagej-perform-turboreg-bilinear.ijm +0 -0
  44. {pystackreg-0.2.7 → pystackreg-0.2.8}/examples/data/pc12-reg-affine.tif +0 -0
  45. {pystackreg-0.2.7 → pystackreg-0.2.8}/examples/data/pc12-reg-bilinear.tif +0 -0
  46. {pystackreg-0.2.7 → pystackreg-0.2.8}/examples/data/pc12-reg-rigid-body.tif +0 -0
  47. {pystackreg-0.2.7 → pystackreg-0.2.8}/examples/data/pc12-reg-scaled-rotation.tif +0 -0
  48. {pystackreg-0.2.7 → pystackreg-0.2.8}/examples/data/pc12-reg-translation.tif +0 -0
  49. {pystackreg-0.2.7 → pystackreg-0.2.8}/examples/data/pc12-unreg.tif +0 -0
  50. {pystackreg-0.2.7 → pystackreg-0.2.8}/examples/notebooks/tutorial.ipynb +0 -0
  51. {pystackreg-0.2.7 → pystackreg-0.2.8}/inc/TurboReg.h +0 -0
  52. {pystackreg-0.2.7 → pystackreg-0.2.8}/inc/TurboRegImage.h +0 -0
  53. {pystackreg-0.2.7 → pystackreg-0.2.8}/inc/TurboRegMask.h +0 -0
  54. {pystackreg-0.2.7 → pystackreg-0.2.8}/inc/TurboRegPointHandler.h +0 -0
  55. {pystackreg-0.2.7 → pystackreg-0.2.8}/inc/TurboRegTransform.h +0 -0
  56. {pystackreg-0.2.7 → pystackreg-0.2.8}/inc/matrix.h +0 -0
  57. {pystackreg-0.2.7 → pystackreg-0.2.8}/pystackreg/__init__.py +0 -0
  58. {pystackreg-0.2.7 → pystackreg-0.2.8}/pystackreg/conftest.py +0 -0
  59. {pystackreg-0.2.7 → pystackreg-0.2.8}/pystackreg.egg-info/dependency_links.txt +0 -0
  60. {pystackreg-0.2.7 → pystackreg-0.2.8}/pystackreg.egg-info/requires.txt +0 -0
  61. {pystackreg-0.2.7 → pystackreg-0.2.8}/pystackreg.egg-info/top_level.txt +0 -0
  62. {pystackreg-0.2.7 → pystackreg-0.2.8}/requirements.txt +0 -0
  63. {pystackreg-0.2.7 → pystackreg-0.2.8}/setup.cfg +0 -0
  64. {pystackreg-0.2.7 → pystackreg-0.2.8}/src/TurboReg.cpp +0 -0
  65. {pystackreg-0.2.7 → pystackreg-0.2.8}/src/TurboRegImage.cpp +0 -0
  66. {pystackreg-0.2.7 → pystackreg-0.2.8}/src/TurboRegMask.cpp +0 -0
  67. {pystackreg-0.2.7 → pystackreg-0.2.8}/src/TurboRegPointHandler.cpp +0 -0
  68. {pystackreg-0.2.7 → pystackreg-0.2.8}/src/TurboRegTransform.cpp +0 -0
  69. {pystackreg-0.2.7 → pystackreg-0.2.8}/src/test_TurboReg.cpp +0 -0
@@ -1,7 +1,13 @@
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
7
13
  exclude: '^.bumpversion.cfg$'
@@ -10,19 +16,19 @@ repos:
10
16
  - id: pretty-format-json
11
17
  args: ['--autofix', '--no-sort-keys']
12
18
  - repo: https://github.com/ambv/black
13
- rev: 22.6.0
19
+ rev: 24.8.0
14
20
  hooks:
15
21
  - id: black
16
- - repo: https://gitlab.com/pycqa/flake8
17
- rev: 4.0.1
22
+ - repo: https://github.com/PyCQA/flake8
23
+ rev: '7.1.1'
18
24
  hooks:
19
- - id: flake8
25
+ - id: flake8
20
26
  - repo: https://github.com/pre-commit/mirrors-mypy
21
- rev: v0.961
27
+ rev: v1.11.2
22
28
  hooks:
23
29
  - id: mypy
24
30
  - repo: https://github.com/codespell-project/codespell
25
- rev: 'v2.1.0'
31
+ rev: 'v2.3.0'
26
32
  hooks:
27
33
  - id: codespell
28
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.7
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,73 +286,77 @@ License
279
286
  derived from this software.
280
287
 
281
288
 
282
- #########
283
289
  Changelog
284
- #########
290
+ =========
291
+
292
+ 0.2.8
293
+ -----
294
+
295
+ Fixed
296
+ .....
297
+ - Add NumPy 2 support
285
298
 
286
299
  0.2.7
287
- =====
300
+ -----
288
301
 
289
- fixed
290
- ------
302
+ Fixed
303
+ .....
291
304
  - Axis argument not used for method "mean" in register_stack() (`PR #26 <https://github.com/glichtner/pystackreg/pull/26>`_)
292
305
 
293
306
  0.2.6
294
- =====
295
-
296
- added
297
307
  -----
298
- - exposing simple_slice and running_mean functions in util package
299
- - added conversion function to any integer dtype
300
308
 
301
- 0.2.5
302
- =====
309
+ Added
310
+ .....
311
+ - Exposing `simple_slice` and `running_mean` functions in the util package
312
+ - Added conversion function to any integer dtype
303
313
 
304
- fixed
314
+ 0.2.5
305
315
  -----
306
- - Compilation in environment without numpy
307
316
 
308
- 0.2.3
309
- =====
317
+ Fixed
318
+ .....
319
+ - Compilation in environments without NumPy
310
320
 
311
- added
321
+ 0.2.3
312
322
  -----
323
+
324
+ Added
325
+ .....
313
326
  - Added example data and tutorial notebook
314
327
  - Added unit tests
315
328
  - Additional documentation
316
- - Detection of time series axis in stacks - will raise a warning if supplied axis in
317
- 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
318
330
 
319
- changed
320
- -------
321
- - `progress_callback` function now gets called with the iteration number, not
322
- 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)
323
334
 
324
- fixed
325
- -----
335
+ Fixed
336
+ .....
326
337
  - Fixed exception when using a different axis than 0 for registering stacks
327
338
 
328
339
  0.2.2
329
- =====
340
+ -----
330
341
 
331
- changed
332
- -------
333
- - License changed to allow distribution on python package repositories
342
+ Changed
343
+ .....~~
344
+ - License changed to allow distribution on Python package repositories
334
345
 
335
346
  0.2.1
336
- =====
337
-
338
- added
339
347
  -----
340
- - 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)
341
348
 
342
- changed
343
- -------
344
- - 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).
345
352
 
346
- 0.2.0
347
- =====
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
348
356
 
349
- added
357
+ 0.2.0
350
358
  -----
351
- - 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
  ------------
@@ -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"]
@@ -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.7
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,73 +286,77 @@ License
279
286
  derived from this software.
280
287
 
281
288
 
282
- #########
283
289
  Changelog
284
- #########
290
+ =========
291
+
292
+ 0.2.8
293
+ -----
294
+
295
+ Fixed
296
+ .....
297
+ - Add NumPy 2 support
285
298
 
286
299
  0.2.7
287
- =====
300
+ -----
288
301
 
289
- fixed
290
- ------
302
+ Fixed
303
+ .....
291
304
  - Axis argument not used for method "mean" in register_stack() (`PR #26 <https://github.com/glichtner/pystackreg/pull/26>`_)
292
305
 
293
306
  0.2.6
294
- =====
295
-
296
- added
297
307
  -----
298
- - exposing simple_slice and running_mean functions in util package
299
- - added conversion function to any integer dtype
300
308
 
301
- 0.2.5
302
- =====
309
+ Added
310
+ .....
311
+ - Exposing `simple_slice` and `running_mean` functions in the util package
312
+ - Added conversion function to any integer dtype
303
313
 
304
- fixed
314
+ 0.2.5
305
315
  -----
306
- - Compilation in environment without numpy
307
316
 
308
- 0.2.3
309
- =====
317
+ Fixed
318
+ .....
319
+ - Compilation in environments without NumPy
310
320
 
311
- added
321
+ 0.2.3
312
322
  -----
323
+
324
+ Added
325
+ .....
313
326
  - Added example data and tutorial notebook
314
327
  - Added unit tests
315
328
  - Additional documentation
316
- - Detection of time series axis in stacks - will raise a warning if supplied axis in
317
- 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
318
330
 
319
- changed
320
- -------
321
- - `progress_callback` function now gets called with the iteration number, not
322
- 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)
323
334
 
324
- fixed
325
- -----
335
+ Fixed
336
+ .....
326
337
  - Fixed exception when using a different axis than 0 for registering stacks
327
338
 
328
339
  0.2.2
329
- =====
340
+ -----
330
341
 
331
- changed
332
- -------
333
- - License changed to allow distribution on python package repositories
342
+ Changed
343
+ .....~~
344
+ - License changed to allow distribution on Python package repositories
334
345
 
335
346
  0.2.1
336
- =====
337
-
338
- added
339
347
  -----
340
- - 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)
341
348
 
342
- changed
343
- -------
344
- - 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).
345
352
 
346
- 0.2.0
347
- =====
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
348
356
 
349
- added
357
+ 0.2.0
350
358
  -----
351
- - 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,70 +0,0 @@
1
- #########
2
- Changelog
3
- #########
4
-
5
- 0.2.7
6
- =====
7
-
8
- fixed
9
- ------
10
- - Axis argument not used for method "mean" in register_stack() (`PR #26 <https://github.com/glichtner/pystackreg/pull/26>`_)
11
-
12
- 0.2.6
13
- =====
14
-
15
- added
16
- -----
17
- - exposing simple_slice and running_mean functions in util package
18
- - added conversion function to any integer dtype
19
-
20
- 0.2.5
21
- =====
22
-
23
- fixed
24
- -----
25
- - Compilation in environment without numpy
26
-
27
- 0.2.3
28
- =====
29
-
30
- added
31
- -----
32
- - Added example data and tutorial notebook
33
- - Added unit tests
34
- - Additional documentation
35
- - Detection of time series axis in stacks - will raise a warning if supplied axis in
36
- stack registration does not correspond to the detected axis
37
-
38
- changed
39
- -------
40
- - `progress_callback` function now gets called with the iteration number, not
41
- iteration index (iteration number = iteration index + 1)
42
-
43
- fixed
44
- -----
45
- - Fixed exception when using a different axis than 0 for registering stacks
46
-
47
- 0.2.2
48
- =====
49
-
50
- changed
51
- -------
52
- - License changed to allow distribution on python package repositories
53
-
54
- 0.2.1
55
- =====
56
-
57
- added
58
- -----
59
- - 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)
60
-
61
- changed
62
- -------
63
- - 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
64
-
65
- 0.2.0
66
- =====
67
-
68
- added
69
- -----
70
- - bilinear transformation
@@ -1 +0,0 @@
1
- __version__ = "0.2.7"
pystackreg-0.2.7/tox.ini DELETED
@@ -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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes