-
Notifications
You must be signed in to change notification settings - Fork 7
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
[ROIs] Use FOV ROIs for labeling (at arbitrary pyramid level) #19
Comments
* Generalize image_labeling to work with ROIs; * Generalize image_labeling to work at arbitrary resolution level; * Add lib_zattrs_utils.py, also with rescale_datasets; * Rename extract_zyx_pixel_sizes_from_zattrs to extract_zyx_pixel_sizes;
Current status of the per-FOV image-labeling task:
def rescale_datasets(datasets : List[Dict] = None,
coarsening_xy : int = None,
reference_level : int = None,) -> List[Dict]:
if datasets is None or coarsening_xy is None or reference_level is None:
raise TypeError("Missing argument in rescale_datasets")
# Construct rescaled datasets
new_datasets = []
for ds in datasets:
new_ds = {}
# Copy all keys that are not coordinateTransformations (e.g. path)
for key in ds.keys():
if key != "coordinateTransformations":
new_ds[key] = ds[key]
# Update coordinateTransformations
old_transformations = ds["coordinateTransformations"]
new_transformations = []
for t in old_transformations:
if t["type"] == "scale":
new_t = {"type": "scale"}
new_t["scale"] = [
t["scale"][0],
t["scale"][1] * coarsening_xy**reference_level,
t["scale"][2] * coarsening_xy**reference_level,
]
new_transformations.append(new_t)
else:
new_transformations.append(t)
new_ds["coordinateTransformations"] = new_transformations
new_datasets.append(new_ds) Note that we explicitly forbid the existence of a global coordinateTransformation, at the moment. We can also decide to allow this feature, and then we need to combine the two There a few of relatively simple open points:
|
Sounds great! 👏🏻
Per FOV 2D segmentation can still be useful, because it allows for 2D segmentation at full resolution, while whole well 2D segmentation needs to be done at a lower resolution for memory reasons.
If it's simple to do, why not. Otherwise, let's wait how transformations change in the v0.5 spec and eventually refactor for that
There are some cases we know would be save. e.g. at level 0. Is there a way to detect if parallel writing will be save? Also interesting to explore whether it can be safely done in cases where FOV are in overlapping chunks. |
Ok. |
Partial update on status:
|
Concerning memory usage, here is the profiling for three single-well cases. TL;DR Everything looks OK. Note that multi-well examples may lead to a known issue - see fractal-analytics-platform/fractal-client#109 (comment). In all three cases below, segmentation takes place per-FOV, at the highest-resolution level, and with relabeling. Case 1: 2x2 well with 10 Z planes ( Case 2: 2x2 well with 42 Z planes ( Case 3: 9x8 well with 19 Z planes ( |
Awesome progress, very nice to see that memory is stable as well! A
Sound good. Let's make this the focus. I agree, only if parallel writing is possible, but causes issues in some cases will we need to implement some check as in 5. Eventually, we may also want to check that there is no ROI overlap (e.g. for the organoid case). But let's have a look first at how save the to_zarr is. I like the idea of provoking simultaneous writes, could also do this for some synthetic examples. If to_zarr handles this well, than we only need to worry about actual pixel overlap, not parallel chunk access :) 👏🏻👏🏻👏🏻 |
Here is some first anecdotal evidence of successful parallel writing. For a single 9x8 well, I performed per-FOV segmentation at resolution level 4, where a FOV has YX shape 135x160 and a single 2160x2560 chunk may host 256 FOVs (that is, more than the 72 FOVs of the well). Observations:
This points in the good direction! |
Oh, this sounds great! Very promising indeed! 🎉 |
Based on the discussion in #20 (and under the assumptions described there), we consider parallel writing as safe - until further notice. This ends the current work on per-ROI labeling, and I'm closing this issue. Things that are not addressed here:
|
Starting from discussion in
we are now splitting the work on ROIs into several steps/issues:
Useful resources:
This is the slightly more complex that the illumination-correction case, because:
Other than that, the tentative plan is similar to the illumination-correction one:
map_blocks
to an explicit loop over ROIs which constructs an array bydelayed
correction functions. In v0, this should be constrained to never act on more than a single ROI at a time.level>0
there are some additionalscale
prefactors to introduce - see https://github.com/fractal-analytics-platform/fractal/blob/tasks/fractal/tasks/image_labeling_whole_well.py#L159-L175.The text was updated successfully, but these errors were encountered: