-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
czi.read_mosiac_size gives different shape than the actual array has when using czi.read_mosaic #77
Comments
Hi @sebi06 Thank you for bringing this to my attention, I will try and see if there's a way to get the stitched value without having to load all the data.
|
Hi @heeler, the tile overlap for this image is around 10%. I also checked if there are any "black" pixels on the out edges of some tile, but there are not. The overall image incl the overlap is exactly 7392 x 3212 pixels. Silly idea: Rounding issues? |
@sebi06 your guess sounds likely to me. I got my wires crossed when I looked at what you were saying initially. I thought the bounding box size was wrong but it is correct. It seems the error is in libCZI's reconstruction function. I'm going to have a look at it in more depth right now to see if I can fix it. Thanks for pointing this out in detail. |
Hi @heeler, If it turns out that this is rather an issue of ibCZI itself, it would be possible to ask the person who wrote directly (since he is my colleague). |
Hi @heeler , i did some more digging. When I read the bboxes of all tiles (M=120) and calculate the rsulting overall bbox I get (7398 x 3212) def get_bbox_scene(cziobject, sceneindex=0):
"""Get the min / max extend of a given scene from a CZI mosaic image
at pyramid level = 0 (full resolution)
:param czi: CZI object for from aicspylibczi
:type czi: Zeiss CZI file object
:param sceneindex: index of the scene, defaults to 0
:type sceneindex: int, optional
:return: tuple with (XSTART, YSTART, WIDTH, HEIGHT) extend in pixels
:rtype: tuple
"""
# get all bounding boxes
bboxes = cziobject.mosaic_scene_bounding_boxes(index=sceneindex)
# initialize lists for required values
xstart = []
ystart = []
tilewidth = []
tileheight = []
# loop over all tiles for the specified scene
for box in bboxes:
# get xstart, ystart amd tile widths and heights
xstart.append(box[0])
ystart.append(box[1])
tilewidth.append(box[2])
tileheight.append(box[3])
# get bounding box for the current scene
XSTART = min(xstart)
YSTART = min(ystart)
# do not forget to add the width and height of the last tile :-)
WIDTH = max(xstart) - XSTART + tilewidth[-1]
HEIGHT = max(ystart) - YSTART + tileheight[-1]
return XSTART, YSTART, WIDTH, HEIGHT The result of this I use for the following call: scene_array_c = czi.read_mosaic(region=(scene.xstart, scene.ystart, scene.width, scene.height), scale_factor=1.0, C=0) and this gives me an array with So why does this approach gives me the correct result, while reading the array directly gives an array with is a few pixel too big? |
Hi @sebi06, I've been working on this in the context of reconstructing the image in aicsimageio as a dask.array. Using your example file I get the results you expect when I use the subblock (tile) bounding boxes. Side note: |
I think I am running into this issue as well. For this file, the bounding box shape should be
When I try your snippet I just pip updated to aicspylibczi-3.0.2 and still get that issue. Let me know if I am doing something wrong. |
Ok, I see where mosaic bboxes can get gotten from cziobjects
That returns the correct shape (1,2048,6349). I think that should be the default behavior with |
Hi @heeler , I am not 100% sure if I got you question correctly. Are you talking about CZIs like this one below. The ZEN software can acquire it easily so, even if this is probably not a common use case. Does that help? CZI File: https://www.dropbox.com/s/8n4pns3q8pp4248/doughnut.czi?dl=0 |
Hi,
here is something which bothers me for a while and I hope you might be able to help me
CZI Testfile
This is a tiles image which I want to read. Here is the minimal code
What I do not understand so far is the output, where the actual size of the returner array does not have the same XY number of pixel as it should have. The value returned by czi.read_mosaic is correct and corresponds to what is shown in ZEN.
Do you have any idea where those additional pixels come from?
The text was updated successfully, but these errors were encountered: