Skip to content

Commit 02bd1a5

Browse files
committed
Update lib_regions_of_interests (ref #131)
* Remove split_3D_indices_into_z_layers; * Remove temporary_test; * Update test.
1 parent 80e867d commit 02bd1a5

File tree

2 files changed

+0
-129
lines changed

2 files changed

+0
-129
lines changed

fractal/tasks/lib_regions_of_interest.py

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ def convert_ROI_table_to_indices(
107107
indices = [start_z, end_z, start_y, end_y, start_x, end_x]
108108

109109
# Round indices to lower integer
110-
# FIXME: to be checked/tested
111110
indices = list(map(math.floor, indices))
112111

113112
# Append ROI indices to to list
@@ -116,27 +115,6 @@ def convert_ROI_table_to_indices(
116115
return list_indices
117116

118117

119-
def split_3D_indices_into_z_layers(
120-
list_indices: List[List[int]],
121-
) -> List[List[int]]:
122-
123-
num_z_layers = None
124-
new_list_indices = []
125-
for indices in list_indices:
126-
if num_z_layers is None:
127-
num_z_layers = indices[1]
128-
else:
129-
if indices[1] != num_z_layers:
130-
raise Exception(
131-
"Inconsistent num_z_layers in split_indices_into_2D_layers"
132-
)
133-
for ind_z in range(num_z_layers):
134-
new_indices = [ind_z, ind_z + 1] + indices[2:]
135-
new_list_indices.append(new_indices)
136-
137-
return new_list_indices
138-
139-
140118
def _inspect_ROI_table(
141119
path: str = None,
142120
level: int = 0,
@@ -157,95 +135,9 @@ def _inspect_ROI_table(
157135
full_res_pxl_sizes_zyx=full_res_pxl_sizes_zyx,
158136
)
159137

160-
list_indices = split_3D_indices_into_z_layers(list_indices)
161-
162138
print(f"level: {level}")
163139
print(f"coarsening_xy: {coarsening_xy}")
164140
print("list_indices:")
165141
for indices in list_indices:
166142
print(indices)
167143
print()
168-
169-
170-
def temporary_test():
171-
172-
pixel_size_z = 1.0
173-
pixel_size_y = 0.1625
174-
pixel_size_x = 0.1625
175-
176-
df = pd.DataFrame(np.zeros((2, 10)), dtype=int)
177-
df.index = ["FOV1", "FOV2"]
178-
df.columns = [
179-
"x_micrometer",
180-
"y_micrometer",
181-
"z_micrometer",
182-
"x_pixel",
183-
"y_pixel",
184-
"z_pixel",
185-
"pixel_size_x",
186-
"pixel_size_y",
187-
"pixel_size_z",
188-
"bit_depth",
189-
]
190-
df["x_micrometer"] = [0.0, 416.0]
191-
df["y_micrometer"] = [0.0, 0.0]
192-
df["z_micrometer"] = [0.0, 0.0]
193-
df["x_pixel"] = [2560, 2560]
194-
df["y_pixel"] = [2160, 2160]
195-
df["z_pixel"] = [5, 5]
196-
df["pixel_size_x"] = [pixel_size_x] * 2
197-
df["pixel_size_y"] = [pixel_size_y] * 2
198-
df["pixel_size_z"] = [pixel_size_z] * 2
199-
df["bit_depth"] = [16.0, 16.0]
200-
201-
print("DataFrame")
202-
print(df)
203-
print()
204-
205-
adata = prepare_FOV_ROI_table(df)
206-
207-
print("AnnData table")
208-
print(adata.var_names)
209-
print(adata.obs_names)
210-
print(adata.X)
211-
print()
212-
213-
print("Indices 3D")
214-
full_res_pxl_sizes_zyx = [pixel_size_z, pixel_size_y, pixel_size_x]
215-
list_indices = convert_ROI_table_to_indices(
216-
adata,
217-
level=0,
218-
coarsening_xy=2,
219-
full_res_pxl_sizes_zyx=full_res_pxl_sizes_zyx,
220-
)
221-
for indices in list_indices:
222-
print(indices)
223-
print()
224-
225-
print("Indices 3D / split")
226-
list_indices = split_3D_indices_into_z_layers(list_indices)
227-
for indices in list_indices:
228-
print(indices)
229-
print()
230-
231-
print("Indices 2D")
232-
adata = convert_FOV_ROIs_3D_to_2D(adata, pixel_size_z)
233-
list_indices = convert_ROI_table_to_indices(
234-
adata,
235-
level=0,
236-
coarsening_xy=2,
237-
full_res_pxl_sizes_zyx=full_res_pxl_sizes_zyx,
238-
)
239-
for indices in list_indices:
240-
print(indices)
241-
print()
242-
243-
244-
if __name__ == "__main__":
245-
# import sys
246-
# args = sys.argv[1:]
247-
# types = [str, int, int]
248-
# args = [types[ix](x) for ix, x in enumerate(args)]
249-
# _inspect_ROI_table(*args)
250-
251-
temporary_test()

tests/test_unit_ROI_indices.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
from fractal.tasks.lib_regions_of_interest import convert_FOV_ROIs_3D_to_2D
66
from fractal.tasks.lib_regions_of_interest import convert_ROI_table_to_indices
77
from fractal.tasks.lib_regions_of_interest import prepare_FOV_ROI_table
8-
from fractal.tasks.lib_regions_of_interest import (
9-
split_3D_indices_into_z_layers,
10-
)
118

129

1310
PIXEL_SIZE_X = 0.1625
@@ -133,24 +130,6 @@ def test_ROI_indices_3D(level, coarsening_xy):
133130
assert indices[1] == NUM_Z_PLANES
134131

135132

136-
@pytest.mark.parametrize("level,coarsening_xy", list_params)
137-
def test_ROI_indices_split(level, coarsening_xy):
138-
139-
metadata_dataframe = get_metadata_dataframe()
140-
adata = prepare_FOV_ROI_table(metadata_dataframe)
141-
142-
full_res_pxl_sizes_zyx = [PIXEL_SIZE_Z, PIXEL_SIZE_Y, PIXEL_SIZE_X]
143-
list_indices = convert_ROI_table_to_indices(
144-
adata,
145-
level=level,
146-
coarsening_xy=coarsening_xy,
147-
full_res_pxl_sizes_zyx=full_res_pxl_sizes_zyx,
148-
)
149-
150-
list_indices = split_3D_indices_into_z_layers(list_indices)
151-
assert len(list_indices) == NUM_Z_PLANES * 2 * 2
152-
153-
154133
@pytest.mark.parametrize("level,coarsening_xy", list_params)
155134
def test_ROI_indices_2D(level, coarsening_xy):
156135

0 commit comments

Comments
 (0)