Skip to content

Commit 60e3d01

Browse files
committed
Add option to crop region
1 parent d194e99 commit 60e3d01

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/imcflibs/imagej/bioformats.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
Memoizer,
2525
MetadataTools,
2626
ZeissCZIReader,
27+
Region,
2728
)
2829

2930

@@ -186,6 +187,7 @@ def import_image(
186187
t_start=None,
187188
t_end=None,
188189
t_interval=None,
190+
region=None,
189191
):
190192
"""Open an image file using the Bio-Formats importer.
191193
@@ -229,8 +231,11 @@ def import_image(
229231
only import a subset of time points ending with this one. Requires to
230232
set t_start and t_interval.
231233
t_interval : int, optional
232-
only import a subset of time points with thsi interval. Requires to set
234+
only import a subset of time points with this interval. Requires to set
233235
t_start and t_end.
236+
region : list, optional
237+
Bio-Formats crop region, by default None.
238+
Format = [start_x, start_y, width in px, height in px]
234239
235240
Returns
236241
-------
@@ -276,6 +281,12 @@ def import_image(
276281
options.setTEnd(series_number, t_end)
277282
options.setTStep(series_number, t_interval)
278283

284+
if region is not None:
285+
options.setCrop(True)
286+
options.setCropRegion(
287+
series_number, Region(region[0], region[1], region[2], region[3])
288+
)
289+
279290
log.info("Reading [%s]", filename)
280291
orig_imps = BF.openImagePlus(options)
281292
log.debug("Opened [%s] %s", filename, type(orig_imps))

0 commit comments

Comments
 (0)