impy-array 2.4.8__tar.gz → 2.4.10__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 (72) hide show
  1. {impy_array-2.4.8 → impy_array-2.4.10}/PKG-INFO +1 -1
  2. {impy_array-2.4.8 → impy_array-2.4.10}/impy/__init__.py +1 -1
  3. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/_utils/_filters.py +6 -1
  4. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/imgarray.py +80 -29
  5. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/lazy.py +41 -0
  6. {impy_array-2.4.8 → impy_array-2.4.10}/impy/io/__init__.py +2 -2
  7. impy_array-2.4.10/impy/io/_czi.py +52 -0
  8. {impy_array-2.4.8 → impy_array-2.4.10}/impy/io/_mrc.py +10 -2
  9. {impy_array-2.4.8 → impy_array-2.4.10}/impy/io/_utils.py +4 -2
  10. {impy_array-2.4.8 → impy_array-2.4.10}/impy/random.py +2 -2
  11. {impy_array-2.4.8 → impy_array-2.4.10}/.gitignore +0 -0
  12. {impy_array-2.4.8 → impy_array-2.4.10}/LICENSE +0 -0
  13. {impy_array-2.4.8 → impy_array-2.4.10}/README.md +0 -0
  14. {impy_array-2.4.8 → impy_array-2.4.10}/impy/__main__.py +0 -0
  15. {impy_array-2.4.8 → impy_array-2.4.10}/impy/_const.py +0 -0
  16. {impy_array-2.4.8 → impy_array-2.4.10}/impy/_types.py +0 -0
  17. {impy_array-2.4.8 → impy_array-2.4.10}/impy/array_api.py +0 -0
  18. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/__init__.py +0 -0
  19. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/_imshow.py +0 -0
  20. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/_utils/__init__.py +0 -0
  21. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/_utils/_corr.py +0 -0
  22. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/_utils/_deconv.py +0 -0
  23. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/_utils/_docs.py +0 -0
  24. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/_utils/_glcm.py +0 -0
  25. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/_utils/_linalg.py +0 -0
  26. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/_utils/_misc.py +0 -0
  27. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/_utils/_plot.py +0 -0
  28. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/_utils/_process_numba.py +0 -0
  29. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/_utils/_skimage.py +0 -0
  30. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/_utils/_structures.py +0 -0
  31. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/_utils/_transform.py +0 -0
  32. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/axesmixin.py +0 -0
  33. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/bases/__init__.py +0 -0
  34. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/bases/metaarray.py +0 -0
  35. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/bases/overload.py +0 -0
  36. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/big.py +0 -0
  37. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/label.py +0 -0
  38. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/labeledarray.py +0 -0
  39. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/phasearray.py +0 -0
  40. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/specials.py +0 -0
  41. {impy_array-2.4.8 → impy_array-2.4.10}/impy/arrays/tiled.py +0 -0
  42. {impy_array-2.4.8 → impy_array-2.4.10}/impy/axes/__init__.py +0 -0
  43. {impy_array-2.4.8 → impy_array-2.4.10}/impy/axes/_axes.py +0 -0
  44. {impy_array-2.4.8 → impy_array-2.4.10}/impy/axes/_axes_tuple.py +0 -0
  45. {impy_array-2.4.8 → impy_array-2.4.10}/impy/axes/_axis.py +0 -0
  46. {impy_array-2.4.8 → impy_array-2.4.10}/impy/axes/_slicer.py +0 -0
  47. {impy_array-2.4.8 → impy_array-2.4.10}/impy/binder.py +0 -0
  48. {impy_array-2.4.8 → impy_array-2.4.10}/impy/collections.py +0 -0
  49. {impy_array-2.4.8 → impy_array-2.4.10}/impy/core.py +0 -0
  50. {impy_array-2.4.8 → impy_array-2.4.10}/impy/correlation.py +0 -0
  51. {impy_array-2.4.8 → impy_array-2.4.10}/impy/frame/__init__.py +0 -0
  52. {impy_array-2.4.8 → impy_array-2.4.10}/impy/frame/frames.py +0 -0
  53. {impy_array-2.4.8 → impy_array-2.4.10}/impy/io/_nd2.py +0 -0
  54. {impy_array-2.4.8 → impy_array-2.4.10}/impy/io/_npy.py +0 -0
  55. {impy_array-2.4.8 → impy_array-2.4.10}/impy/io/_registry.py +0 -0
  56. {impy_array-2.4.8 → impy_array-2.4.10}/impy/io/_tiff.py +0 -0
  57. {impy_array-2.4.8 → impy_array-2.4.10}/impy/io/_zarr.py +0 -0
  58. {impy_array-2.4.8 → impy_array-2.4.10}/impy/lazy/__init__.py +0 -0
  59. {impy_array-2.4.8 → impy_array-2.4.10}/impy/lazy/core.py +0 -0
  60. {impy_array-2.4.8 → impy_array-2.4.10}/impy/lazy/random.py +0 -0
  61. {impy_array-2.4.8 → impy_array-2.4.10}/impy/roi.py +0 -0
  62. {impy_array-2.4.8 → impy_array-2.4.10}/impy/utils/__init__.py +0 -0
  63. {impy_array-2.4.8 → impy_array-2.4.10}/impy/utils/axesop.py +0 -0
  64. {impy_array-2.4.8 → impy_array-2.4.10}/impy/utils/deco.py +0 -0
  65. {impy_array-2.4.8 → impy_array-2.4.10}/impy/utils/gauss.py +0 -0
  66. {impy_array-2.4.8 → impy_array-2.4.10}/impy/utils/misc.py +0 -0
  67. {impy_array-2.4.8 → impy_array-2.4.10}/impy/utils/slicer.py +0 -0
  68. {impy_array-2.4.8 → impy_array-2.4.10}/impy/utils/utilcls.py +0 -0
  69. {impy_array-2.4.8 → impy_array-2.4.10}/impy/viewer/__init__.py +0 -0
  70. {impy_array-2.4.8 → impy_array-2.4.10}/impy/viewer/utils.py +0 -0
  71. {impy_array-2.4.8 → impy_array-2.4.10}/impy/viewer/viewer.py +0 -0
  72. {impy_array-2.4.8 → impy_array-2.4.10}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: impy-array
3
- Version: 2.4.8
3
+ Version: 2.4.10
4
4
  Summary: Speed up coding/extending image analysis in Python.
5
5
  Project-URL: Download, https://github.com/hanjinliu/impy
6
6
  Author-email: Hanjin Liu <liuhanjin-sc@g.ecc.u-tokyo.ac.jp>
@@ -1,4 +1,4 @@
1
- __version__ = "2.4.8"
1
+ __version__ = "2.4.10"
2
2
  __author__ = "Hanjin Liu"
3
3
  __email__ = "liuhanjin-sc@g.ecc.u-tokyo.ac.jp"
4
4
 
@@ -52,6 +52,8 @@ binary_closing = get_func("binary_closing")
52
52
  closing = get_func("grey_closing")
53
53
  gaussian_filter = get_func("gaussian_filter")
54
54
  median_filter = get_func("median_filter")
55
+ min_filter = get_func("minimum_filter")
56
+ max_filter = get_func("maximum_filter")
55
57
  spline_filter = get_func("spline_filter")
56
58
  convolve = get_func("convolve")
57
59
  white_tophat = get_func("white_tophat")
@@ -69,6 +71,8 @@ if TYPE_CHECKING:
69
71
  closing = scipy_ndi.grey_closing
70
72
  gaussian_filter = scipy_ndi.gaussian_filter
71
73
  median_filter = scipy_ndi.median_filter
74
+ min_filter = scipy_ndi.minimum_filter
75
+ max_filter = scipy_ndi.maximum_filter
72
76
  spline_filter = scipy_ndi.spline_filter
73
77
  convolve = scipy_ndi.convolve
74
78
  white_tophat = scipy_ndi.white_tophat
@@ -151,7 +155,8 @@ def gabor_filter(img: np.ndarray, ker: np.ndarray, mode="reflect", cval=0.0):
151
155
 
152
156
  def skeletonize(img, selem):
153
157
  from skimage import morphology
154
- skl = morphology.skeletonize_3d(img)
158
+
159
+ skl = morphology.skeletonize(img)
155
160
  if selem is not None:
156
161
  skl = morphology.binary_dilation(skl, selem)
157
162
  return skl
@@ -708,8 +708,7 @@ class ImgArray(LabeledArray):
708
708
  @dims_to_spatial_axes
709
709
  @check_input_and_output
710
710
  def structure_tensor_eig(self, sigma: nDFloat = 1, *, dims: Dims = None)-> tuple[ImgArray, ImgArray]:
711
- """
712
- Calculate structure tensor's eigenvalues and eigenvectors.
711
+ """Calculate structure tensor's eigenvalues and eigenvectors.
713
712
 
714
713
  Parameters
715
714
  ----------
@@ -749,8 +748,7 @@ class ImgArray(LabeledArray):
749
748
  dims: Dims = None,
750
749
  update: bool = False
751
750
  ) -> ImgArray:
752
- """
753
- Sobel filter. This filter is useful for edge detection.
751
+ """Edge detection such as Sobel filter.
754
752
 
755
753
  Parameters
756
754
  ----------
@@ -785,8 +783,7 @@ class ImgArray(LabeledArray):
785
783
  dims: Dims = None,
786
784
  update: bool = False,
787
785
  ) -> ImgArray:
788
- """
789
- Butterworth low-pass filter.
786
+ """Butterworth low-pass filter.
790
787
 
791
788
  Parameters
792
789
  ----------
@@ -831,9 +828,10 @@ class ImgArray(LabeledArray):
831
828
  dims: Dims = None,
832
829
  update: bool = False
833
830
  ) -> ImgArray:
834
- """
835
- Butterworth low-pass filter in real space. Butterworth kernel is created first using inverse
836
- Fourier transform of weight function.
831
+ """Butterworth low-pass filter in real space.
832
+
833
+ Butterworth kernel is created first using inverse Fourier transform of weight
834
+ function.
837
835
 
838
836
  Parameters
839
837
  ----------
@@ -876,8 +874,7 @@ class ImgArray(LabeledArray):
876
874
  dims: Dims = None,
877
875
  update: bool = False
878
876
  ) -> ImgArray:
879
- """
880
- Butterworth high-pass filter.
877
+ """Butterworth high-pass filter.
881
878
 
882
879
  Parameters
883
880
  ----------
@@ -918,8 +915,7 @@ class ImgArray(LabeledArray):
918
915
  dims: Dims = None,
919
916
  update: bool = False
920
917
  ):
921
- """
922
- Butterworth band-pass filter.
918
+ """Butterworth band-pass filter.
923
919
 
924
920
  Parameters
925
921
  ----------
@@ -963,8 +959,7 @@ class ImgArray(LabeledArray):
963
959
  dims: Dims = None,
964
960
  update: bool = False,
965
961
  ) -> ImgArray:
966
- """
967
- General linear convolution by running kernel filtering.
962
+ """General linear convolution by running kernel filtering.
968
963
 
969
964
  Parameters
970
965
  ----------
@@ -998,8 +993,7 @@ class ImgArray(LabeledArray):
998
993
  dims: Dims = None,
999
994
  update: bool = False,
1000
995
  ) -> ImgArray:
1001
- """
1002
- Morphological erosion.
996
+ """Morphological erosion.
1003
997
 
1004
998
  If input is binary image, the running function will automatically switched to
1005
999
  ``binary_erosion`` to speed up calculation.
@@ -1039,8 +1033,9 @@ class ImgArray(LabeledArray):
1039
1033
  dims: Dims = None,
1040
1034
  update: bool = False,
1041
1035
  ) -> ImgArray:
1042
- """
1043
- Morphological dilation. If input is binary image, the running function will automatically switched to
1036
+ """Morphological dilation.
1037
+
1038
+ If input is binary image, the running function will automatically switched to
1044
1039
  ``binary_dilation`` to speed up calculation.
1045
1040
 
1046
1041
  Parameters
@@ -1078,8 +1073,9 @@ class ImgArray(LabeledArray):
1078
1073
  dims: Dims = None,
1079
1074
  update: bool = False,
1080
1075
  ) -> ImgArray:
1081
- """
1082
- Morphological opening. If input is binary image, the running function will automatically switched to
1076
+ """Morphological opening.
1077
+
1078
+ If input is binary image, the running function will automatically switched to
1083
1079
  ``binary_opening`` to speed up calculation.
1084
1080
 
1085
1081
  Parameters
@@ -1117,8 +1113,7 @@ class ImgArray(LabeledArray):
1117
1113
  dims: Dims = None,
1118
1114
  update: bool = False,
1119
1115
  ) -> ImgArray:
1120
- """
1121
- Morphological closing.
1116
+ """Morphological closing.
1122
1117
 
1123
1118
  If input is binary image, the running function will automatically switched to
1124
1119
  ``binary_closing`` to speed up calculation.
@@ -1158,8 +1153,7 @@ class ImgArray(LabeledArray):
1158
1153
  dims: Dims = None,
1159
1154
  update: bool = False,
1160
1155
  ) -> ImgArray:
1161
- """
1162
- Tophat morphological image processing. This is useful for background subtraction.
1156
+ """Tophat morphological image processing. This is useful for background subtraction.
1163
1157
 
1164
1158
  Parameters
1165
1159
  ----------
@@ -1190,8 +1184,7 @@ class ImgArray(LabeledArray):
1190
1184
  *,
1191
1185
  dims: Dims = None
1192
1186
  ) -> ImgArray:
1193
- """
1194
- Smoothen binary mask image at its edges. This is useful to make a "soft mask".
1187
+ """Smoothen binary mask image at its edges. This is useful to make a "soft mask".
1195
1188
 
1196
1189
  This method applies erosion/dilation to a binary image and then smooth its edges by Gaussian.
1197
1190
  The total value is always larger after Gaussian smoothing.
@@ -1243,8 +1236,7 @@ class ImgArray(LabeledArray):
1243
1236
  cval: float = 0.0,
1244
1237
  dims: Dims = None,
1245
1238
  update: bool = False) -> ImgArray:
1246
- """
1247
- Mean filter. Kernel is filled with same values.
1239
+ """Mean filter. Kernel is filled with same values.
1248
1240
 
1249
1241
  Parameters
1250
1242
  ----------
@@ -1264,6 +1256,65 @@ class ImgArray(LabeledArray):
1264
1256
  kwargs=dict(mode=mode, cval=cval),
1265
1257
  )
1266
1258
 
1259
+
1260
+ @_docs.write_docs
1261
+ @dims_to_spatial_axes
1262
+ @check_input_and_output
1263
+ def min_filter(
1264
+ self,
1265
+ radius: float = 1,
1266
+ *,
1267
+ mode: PaddingMode = "reflect",
1268
+ cval: float = 0.0,
1269
+ dims: Dims = None,
1270
+ ) -> ImgArray:
1271
+ """Minimum filter.
1272
+
1273
+ Parameters
1274
+ ----------
1275
+ {radius}{mode}{cval}{dims}
1276
+
1277
+ Returns
1278
+ -------
1279
+ ImgArray
1280
+ Filtered image
1281
+ """
1282
+ disk = _structures.ball_like(radius, len(dims))
1283
+ return self.as_float()._apply_dask(
1284
+ _filters.min_filter,
1285
+ c_axes=complement_axes(dims, self.axes),
1286
+ kwargs=dict(footprint=disk, mode=mode, cval=cval),
1287
+ )
1288
+
1289
+ @_docs.write_docs
1290
+ @dims_to_spatial_axes
1291
+ @check_input_and_output
1292
+ def max_filter(
1293
+ self,
1294
+ radius: float = 1,
1295
+ *,
1296
+ mode: PaddingMode = "reflect",
1297
+ cval: float = 0.0,
1298
+ dims: Dims = None,
1299
+ ) -> ImgArray:
1300
+ """Maximum filter.
1301
+
1302
+ Parameters
1303
+ ----------
1304
+ {radius}{mode}{cval}{dims}
1305
+
1306
+ Returns
1307
+ -------
1308
+ ImgArray
1309
+ Filtered image
1310
+ """
1311
+ disk = _structures.ball_like(radius, len(dims))
1312
+ return self.as_float()._apply_dask(
1313
+ _filters.max_filter,
1314
+ c_axes=complement_axes(dims, self.axes),
1315
+ kwargs=dict(footprint=disk, mode=mode, cval=cval),
1316
+ )
1317
+
1267
1318
  @_docs.write_docs
1268
1319
  @dims_to_spatial_axes
1269
1320
  @check_input_and_output
@@ -890,6 +890,47 @@ class LazyImgArray(AxesMixin):
890
890
  kwargs=dict(footprint=disk, mode=mode, cval=cval),
891
891
  )
892
892
 
893
+ @_docs.copy_docs(ImgArray.min_filter)
894
+ @dims_to_spatial_axes
895
+ @same_dtype
896
+ @check_input_and_output_lazy
897
+ def min_filter(
898
+ self,
899
+ radius: float = 1,
900
+ *,
901
+ mode: PaddingMode = "reflect",
902
+ cval: float = 0,
903
+ dims: Dims = None,
904
+ update: bool = False
905
+ ) -> LazyImgArray:
906
+ disk = _structures.ball_like(radius, len(dims))
907
+ return self._apply_map_overlap(
908
+ xp.ndi.minimum_filter,
909
+ depth=_ceilint(radius),
910
+ c_axes=complement_axes(dims, self.axes),
911
+ kwargs=dict(footprint=disk, mode=mode, cval=cval),
912
+ )
913
+
914
+ @_docs.copy_docs(ImgArray.max_filter)
915
+ @dims_to_spatial_axes
916
+ @same_dtype
917
+ @check_input_and_output_lazy
918
+ def max_filter(
919
+ self,
920
+ radius: float = 1,
921
+ *,
922
+ mode: PaddingMode = "reflect",
923
+ cval: float = 0,
924
+ dims: Dims = None,
925
+ update: bool = False
926
+ ) -> LazyImgArray:
927
+ disk = _structures.ball_like(radius, len(dims))
928
+ return self._apply_map_overlap(
929
+ xp.ndi.maximum_filter,
930
+ depth=_ceilint(radius),
931
+ c_axes=complement_axes(dims, self.axes),
932
+ kwargs=dict(footprint=disk, mode=mode, cval=cval),
933
+ )
893
934
 
894
935
  @_docs.copy_docs(ImgArray.std_filter)
895
936
  @dims_to_spatial_axes
@@ -1,7 +1,7 @@
1
1
  from ._registry import imread, imread_dask, imsave, mark_reader, mark_writer, read_header
2
- from . import _tiff, _mrc, _npy, _zarr, _nd2
2
+ from . import _tiff, _mrc, _npy, _zarr, _nd2, _czi
3
3
 
4
- del _tiff, _mrc, _npy, _zarr, _nd2
4
+ del _tiff, _mrc, _npy, _zarr, _nd2, _czi
5
5
 
6
6
  __all__ = [
7
7
  "imread",
@@ -0,0 +1,52 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+ import numpy as np
5
+ from impy.io._registry import IO
6
+ from impy.io._utils import ImageData, ImageMetadata
7
+
8
+ if TYPE_CHECKING:
9
+ from czifile import CziFile
10
+
11
+ @IO.mark_reader(".czi")
12
+ def _(path: str, memmap: bool = False) -> ImageData:
13
+ """The CZI format reader"""
14
+ import czifile
15
+
16
+ if memmap:
17
+ raise NotImplementedError("CZI reader does not support memmap mode yet.")
18
+ else:
19
+ out = None
20
+ with czifile.CziFile(path) as czi:
21
+ data = np.squeeze(czi.asarray(out=out))
22
+ meta = _parse_czi_meta(czi)
23
+
24
+ return ImageData.from_metadata(data, meta)
25
+
26
+ def _parse_czi_meta(czi: CziFile) -> ImageMetadata:
27
+ """Parse metadata from a CZI file."""
28
+ axes_all: str = czi.axes
29
+ shape = czi.shape
30
+ axes = "".join(a.lower() for s, a in zip(shape, axes_all) if s > 1)
31
+ try:
32
+ img_meta = czi.metadata(raw=False)["ImageDocument"]["Metadata"]
33
+ scale = {}
34
+ for item in img_meta["Scaling"]["Items"]["Distance"]:
35
+ a = item["Id"].lower()
36
+ if a in axes:
37
+ scale[a] = item.get("Value", 1e-6) * 1e6 # as micron
38
+ try:
39
+ labels = [item["ImageChannelName"] for item in img_meta["Experiment"]["ExperimentBlocks"]["AcquisitionBlock"]["MultiTrackSetup"]["TrackSetup"]["Detectors"]["Detector"]]
40
+ except Exception:
41
+ labels = None
42
+ except KeyError:
43
+ scale = None
44
+ labels = None
45
+
46
+ return ImageMetadata(
47
+ axes=axes,
48
+ scale=scale,
49
+ unit="μm",
50
+ metadata=img_meta,
51
+ labels=labels,
52
+ )
@@ -3,7 +3,6 @@ from __future__ import annotations
3
3
  from pathlib import Path
4
4
  from typing import TYPE_CHECKING
5
5
  import warnings
6
- import os
7
6
  import numpy as np
8
7
  from impy.io._registry import IO
9
8
  from impy.io._utils import rechunk_to_ones, MemmapArrayWriter, ImpyArray, ImageData, ImageMetadata
@@ -113,14 +112,23 @@ def _parse_mrcfile(mrc: MrcObject) -> ImageMetadata:
113
112
  else:
114
113
  axes = "zyx"
115
114
 
115
+ metadata = {}
116
116
  scale = dict.fromkeys(axes, 1.0)
117
117
  for a in axes:
118
118
  scale[a] = mrc.voxel_size[a] / 10
119
+ try:
120
+ orig_x, orig_y, orig_z = mrc.header["origin"].item()
121
+ except Exception:
122
+ pass
123
+ else:
124
+ metadata["origin_nm"] = np.array([orig_z, orig_y, orig_x], dtype=np.float32) / 10
125
+
126
+ metadata["labels"] = mrc.get_labels()
119
127
 
120
128
  return ImageMetadata(
121
129
  axes=axes,
122
130
  scale=scale,
123
131
  unit={a: "nm" for a in axes},
124
- metadata={},
132
+ metadata=metadata,
125
133
  labels=None,
126
134
  )
@@ -40,7 +40,7 @@ class MemmapArrayWriter:
40
40
  chunksize: tuple[int, ...],
41
41
  ):
42
42
  self._path = path
43
- self._offset = offset
43
+ self._offset = int(offset)
44
44
  self._shape = shape # original shape
45
45
  self._chunksize = chunksize # chunk size
46
46
  # shape = (33, 160, 1000, 1000)
@@ -56,7 +56,9 @@ class MemmapArrayWriter:
56
56
  # efficient: shape = (10, 100, 150) and sl = (3:5, 0:100, 0:150)
57
57
  # sl = (0:1, 16:32, 0:1000, 0:1000)
58
58
 
59
- offset = np.sum([sl[i].start * arr.strides[i] for i in range(self._border + 1)])
59
+ # if input array is e.g. flipped, we need to make it contiguous
60
+ arr = np.ascontiguousarray(arr)
61
+ offset = sum(int(sl[i].start * arr.strides[i]) for i in range(self._border + 1))
60
62
  arr_ravel = arr.ravel()
61
63
  mmap = np.memmap(
62
64
  self._path,
@@ -184,10 +184,10 @@ class ImageGenerator:
184
184
  ) -> ImgArray:
185
185
  size, name, axes = _normalize_like(size, name, axes, like)
186
186
 
187
- arr = self._rng.normal(loc=loc, scale=scale, size=size).astype(np.float32)
187
+ arr = self._rng.normal(loc=loc, scale=scale, size=size)
188
188
  if np.isscalar(arr):
189
189
  return arr
190
- return asarray(xp.asnumpy(arr), axes=axes, name=name)
190
+ return asarray(xp.asnumpy(arr), axes=axes, name=name).astype(np.float32)
191
191
 
192
192
  def poisson(
193
193
  self,
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