Skip to content

Commit

Permalink
feat: allow slicing in SeriesData.saveh5
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Mar 4, 2019
1 parent c958262 commit a9da473
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.9.0
- feat: allow to specify a slice in SeriesData.saveh5 (useful
when only a specific region needs to be extracted)
0.8.0
- feat: allow tracking the progress of SeriesData.saveh5 using
multiprocessing.Value objects
Expand Down
10 changes: 9 additions & 1 deletion qpformat/file_formats/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,17 @@ def get_qpimage_raw(self, idx):
the "identifier" metadata key set!
"""

def saveh5(self, h5file, count=None, max_count=None):
def saveh5(self, h5file, qpi_slice=None, count=None, max_count=None):
"""Save the data set as an hdf5 file (qpimage.QPSeries format)
Parameters
----------
h5file: str, pathlib.Path, or h5py.Group
Where to store the series data
qpi_slice: slice
If not None, only store a slice of each QPImage
in `h5file`. A value of None is equivalent to
``(slice(0, -1), slice(0, -1))``.
count, max_count: multiprocessing.Value
Can be used to monitor the progress of the algorithm.
Initially, the value of `max_count.value` is incremented
Expand All @@ -230,10 +234,14 @@ def saveh5(self, h5file, count=None, max_count=None):
# initial image or series data where each image
# has a unique background image
qpi = self.get_qpimage(ii)
if qpi_slice is not None:
qpi = qpi[qpi_slice]
qps.add_qpimage(qpi)
else:
# hard-link the background data
qpiraw = self.get_qpimage_raw(ii)
if qpi_slice is not None:
qpiraw = qpiraw[qpi_slice]
qps.add_qpimage(qpiraw, bg_from_idx=0)
if count is not None:
count.value += 1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
install_requires=["h5py>=2.7.0",
"nrefocus>=0.1.5",
"numpy>=1.12.0",
"qpimage>=0.4.3",
"qpimage>=0.5.0",
"scikit-image>=0.11.0",
"scipy>=0.18.0",
],
Expand Down

0 comments on commit a9da473

Please sign in to comment.