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

Sort layout and img_paths jointly #13

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/ez_zarr/ome_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,11 @@ def import_Fractal_plate(path: str, image_name: str = '0') -> "ImageList":

# build layout
layout = pd.DataFrame({'row_index': row_index,
'column_index': column_index})
'column_index': column_index,
'img_paths': img_paths})
layout = layout.sort_values(by=['row_index', 'column_index']).reset_index(drop=True)
img_paths = layout.img_paths.tolist()
layout = layout.drop('img_paths', axis='columns')

# set nrow, ncol
known_plate_dims = [(2, 3), (4, 6), (8, 12), (16, 24)]
Expand Down
17 changes: 17 additions & 0 deletions tests/test_ome_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ def test_import_Fractal_plate(tmpdir: str):
assert imgL2.nrow == 8
assert imgL2.ncol == 12

shutil.copytree('tests/example_data/plate_ones_mip.zarr',
str(tmpdir) + '/example_img_multi')
assert tmpdir.join('/example_img_multi/.zattrs').check()
shutil.copytree(str(tmpdir) + '/example_img_multi/B/03',
str(tmpdir) + '/example_img_multi/C/02')
shutil.copytree(str(tmpdir) + '/example_img_multi/B/03',
str(tmpdir) + '/example_img_multi/G/06')
imgL3 = ome_zarr.import_Fractal_plate(str(tmpdir) + '/example_img_multi')
assert imgL3.nrow == 8
assert imgL3.ncol == 12
assert imgL3.layout.row_index.tolist() == [2, 3, 7]
assert imgL3.layout.column_index.tolist() == [3, 2, 6]
assert imgL3['B03'].get_path() == str(tmpdir) + '/example_img_multi/B/03/0'
assert imgL3['C02'].get_path() == str(tmpdir) + '/example_img_multi/C/02/0'
assert imgL3['G06'].get_path() == str(tmpdir) + '/example_img_multi/G/06/0'
assert imgL3.paths == [str(tmpdir) + '/example_img_multi/B/03/0', str(tmpdir) + '/example_img_multi/C/02/0', str(tmpdir) + '/example_img_multi/G/06/0']
assert imgL3.names == ['B03', 'C02', 'G06']

# ome_zarr.Image ----------------------------------------------------
# ... helper functions ..............................................
Expand Down