|
| 1 | +import json |
| 2 | +import logging |
| 3 | + |
| 4 | +from cryoet_data_portal_neuroglancer.precompute.points import encode_annotation |
| 5 | +from cryoet_data_portal_neuroglancer.precompute.instance_mesh import ( |
| 6 | + encode_oriented_mesh, |
| 7 | +) |
| 8 | +from cryoet_data_portal_neuroglancer.state_generator import ( |
| 9 | + generate_oriented_point_layer, |
| 10 | + combine_json_layers, |
| 11 | + generate_segmentation_mask_layer, |
| 12 | +) |
| 13 | +from cryoet_data_portal_neuroglancer.io import load_glb_file, load_oriented_point_data |
| 14 | +from pathlib import Path |
| 15 | +from cryoet_data_portal_neuroglancer.precompute.mesh import ( |
| 16 | + generate_mesh_from_lods, |
| 17 | +) |
| 18 | + |
| 19 | + |
| 20 | +JSON_PATH = Path( |
| 21 | + r"/media/starfish/LargeSSD/data/cryoET/data/Annotations-test-run/100-proton_transporting_atp_synthase_complex-1.0.json" |
| 22 | +) |
| 23 | + |
| 24 | +MESH_PATH = Path( |
| 25 | + r"/media/starfish/LargeSSD/data/cryoET/data/meshes-oriented/atpase.glb" |
| 26 | +) |
| 27 | + |
| 28 | +OUTPUT_PATH = Path(r"/media/starfish/LargeSSD/data/cryoET/data/converted-01122021/") |
| 29 | + |
| 30 | +metadata, data = load_oriented_point_data( |
| 31 | + JSON_PATH, JSON_PATH.with_name(JSON_PATH.stem + "_orientedpoint.ndjson") |
| 32 | +) |
| 33 | + |
| 34 | +encode_annotation( |
| 35 | + data, metadata, OUTPUT_PATH, 0.784 * 1e-9, shard_by_id=(0, 10), is_oriented=True |
| 36 | +) |
| 37 | +logging.basicConfig(level=logging.DEBUG, force=True) |
| 38 | +scene = load_glb_file(MESH_PATH) |
| 39 | + |
| 40 | +copy_pasted_lods = encode_oriented_mesh( |
| 41 | + scene, |
| 42 | + data, |
| 43 | + max_lod=2, |
| 44 | + max_faces_for_first_lod=10e6, |
| 45 | + decimation_aggressiveness=5.5, |
| 46 | +) |
| 47 | +generate_mesh_from_lods( |
| 48 | + copy_pasted_lods, |
| 49 | + OUTPUT_PATH / "meshoutput", |
| 50 | + min_mesh_chunk_dim=2, |
| 51 | + string_label="mesh", |
| 52 | +) |
| 53 | + |
| 54 | +SOURCE = "http://127.0.0.1:9000/converted-01122021/" |
| 55 | + |
| 56 | +output = generate_oriented_point_layer( |
| 57 | + source=SOURCE, |
| 58 | + name="Test Oriented Points", |
| 59 | + color="#FFFFFF", |
| 60 | + point_size_multiplier=0.5, |
| 61 | + line_width=2.0, |
| 62 | + is_visible=True, |
| 63 | + is_instance_segmentation=False, |
| 64 | + scale=0.784 * 1e-9, |
| 65 | +) |
| 66 | + |
| 67 | +output2 = generate_segmentation_mask_layer( |
| 68 | + source="http://localhost:1337", |
| 69 | + name="Test Mesh", |
| 70 | + color="#FF0000", |
| 71 | + scale=0.784 * 1e-9, |
| 72 | +) |
| 73 | +layer_json = combine_json_layers([output, output2], 0.784, units="nm") |
| 74 | +json.dump(layer_json, open("oriented_point_layer.json", "w"), indent=2) |
0 commit comments