Skip to content

Commit 7e77264

Browse files
Update data export scripts
1 parent 1efd0d3 commit 7e77264

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

scripts/export_lower_resolution.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import zarr
88

99
from flamingo_tools.s3_utils import get_s3_path, BUCKET_NAME, SERVICE_ENDPOINT
10-
# from skimage.segmentation import relabel_sequential
10+
from skimage.segmentation import relabel_sequential
1111

1212

1313
def filter_component(fs, segmentation, cochlea, seg_name, components):
@@ -22,7 +22,8 @@ def filter_component(fs, segmentation, cochlea, seg_name, components):
2222
filter_mask = ~np.isin(segmentation, keep_label_ids)
2323
segmentation[filter_mask] = 0
2424

25-
# segmentation, _, _ = relabel_sequential(segmentation)
25+
segmentation, _, _ = relabel_sequential(segmentation)
26+
segmentation = segmentation.astype("uint16")
2627
return segmentation
2728

2829

@@ -41,7 +42,7 @@ def export_lower_resolution(args):
4142
s3_store, fs = get_s3_path(internal_path, bucket_name=BUCKET_NAME, service_endpoint=SERVICE_ENDPOINT)
4243
with zarr.open(s3_store, mode="r") as f:
4344
data = f[input_key][:]
44-
print(data.shape)
45+
4546
if args.filter_by_components is not None:
4647
data = filter_component(fs, data, args.cochlea, channel, args.filter_by_components)
4748
if args.binarize:

scripts/export_synapse_detections.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from tqdm import tqdm
1313

1414

15+
# TODO
1516
def export_synapse_detections(cochlea, scale, output_folder, synapse_name, reference_ihcs, max_dist, radius):
1617
s3 = create_s3_target()
1718

@@ -53,14 +54,18 @@ def export_synapse_detections(cochlea, scale, output_folder, synapse_name, refer
5354
coordinates /= (2 ** scale)
5455
coordinates = np.round(coordinates, 0).astype("int")
5556

57+
ihc_ids = syn_table["matched_ihc"].values
58+
5659
# Create the output.
5760
output = np.zeros(shape, dtype="uint16")
5861
mask = ball(radius).astype(bool)
5962

60-
for coord in tqdm(coordinates, desc="Writing synapses to volume"):
63+
for coord, matched_ihc in tqdm(
64+
zip(coordinates, ihc_ids), total=len(coordinates), desc="Writing synapses to volume"
65+
):
6166
bb = tuple(slice(c - radius, c + radius + 1) for c in coord)
6267
try:
63-
output[bb][mask] = 1
68+
output[bb][mask] = matched_ihc
6469
except IndexError:
6570
print("Index error for", coord)
6671
continue

0 commit comments

Comments
 (0)