Skip to content
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

Handling negative offset in warping sections #36

Open
aloejhb opened this issue Jan 13, 2023 · 1 comment
Open

Handling negative offset in warping sections #36

aloejhb opened this issue Jan 13, 2023 · 1 comment

Comments

@aloejhb
Copy link
Contributor

aloejhb commented Jan 13, 2023

During warping sections, I encountered the following error:

File "flows/warp_sections.py", line 204, in warp_and_save
    volume.write_section(
  File "/tungstenfs/scratch/gmicro_share/_prefect/miniconda3/envs/gfriedri-em-alignment-flows/lib/python3.9/site-packages/sbem/storage/Volume.py", line 147, in write_section
    self._reshape_storage(offsets, data.shape)
  File "/tungstenfs/scratch/gmicro_share/_prefect/miniconda3/envs/gfriedri-em-alignment-flows/lib/python3.9/site-packages/sbem/storage/Volume.py", line 291, in _reshape_storage
    self._extend(n_chunks=n_chunks, axis=i, z_level=storage)
  File "/tungstenfs/scratch/gmicro_share/_prefect/miniconda3/envs/gfriedri-em-alignment-flows/lib/python3.9/site-packages/sbem/storage/Volume.py", line 209, in _extend
    move(c, join(dir_name, str(int(chunk) + abs(n_chunks))))
  File "/tungstenfs/scratch/gmicro_share/_prefect/miniconda3/envs/gfriedri-em-alignment-flows/lib/python3.9/shutil.py", line 823, in move
    raise Error("Destination path '%s' already exists" % real_dst)
shutil.Error: Destination path '/tungstenfs/scratch/gmicro_sem/gfriedri/hubo/em_alignment/juvenile_ob_dp/20220524_Bo_juv20210731_volume1/ngff_volume.zarr/0/652/10/9' already exists

Flow run name: hubowarpphi198-chocola-field
Flow run ID: f077b55b-658a-40fc-9e0e-690ad0634c43

The offset of this section s1956 is (857, -505, -1431). The Offsets of the previous two sections, s1954 and s1955 are also both negative in X and Y.

It seems that the Volume._extend is trying to move a chunk to the path where another chunk is stored.

@aloejhb
Copy link
Contributor Author

aloejhb commented Jan 13, 2023

It looks that the current _extend method may lower the efficiency of volume saving, in the case that a large volume has already been written, and we would like to store a new section with even a small negative offset (e.g. 1 chunk) in X or Y.
The reason is that it will have to rename a considerable amount of folders in ngff_volume.zarr.

One way to deal with this is to pre-compute the offsets and image size for all sections. Then initialize the zarr volume accordingly, with some user defined safe margin. With this, no extension will be needed during warping.

Pre-computing offsets will also allow user to inspect the offset values and catch large offset values that indicate instability of the stage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant