initial label added
"mask_assignment_order"
]
},
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "objects_map = [\n",
+ " {\n",
+ " \"instance_id\": get_instance_id(name),\n",
+ " \"category_id\": category_id_map[name]\n",
+ " }\n",
+ " for name in contours_on_this_slice\n",
+ "]\n",
+ "\n",
+ "objects_map"
+ ]
+ },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
- "catagorised_mask = np.zeros(ct_size)\n",
+ "catagorised_mask = np.zeros(ct_size).astype(np.uint8)\n",
"for structure_name in mask_assignment_order:\n",
" instance_id = get_instance_id(structure_name)\n",
" catagorised_mask[masks[structure_name]] = instance_id"
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": []
+ "source": [
+ "png_file = io.BytesIO()\n",
+ "imageio.imsave(png_file, catagorised_mask, format='png', prefer_uint8=True)\n",
+ " \n",
+ "sample_name = f\"{ct_uid}_mask.png\"\n",
+ "asset = client.upload_asset(png_file, filename=sample_name)\n",
+ "image_url = asset[\"url\"]\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "sample_uuid = ct_uid_to_upload_uuid[ct_uid]\n",
+ "task_name = \"contouring\"\n",
+ "attributes = {\n",
+ " \"segmentation_bitmap_url\": image_url,\n",
+ " \"objects\": objects_map\n",
+ "}\n",
+ "\n",
+ "client.add_label(sample_uuid, task_name, attributes)"
+ ]
}
],
"metadata": {
