further minify of orbital dataset
"for ct_uid, x_grid, y_grid, input_array, output_array in dataset:\n",
" ct_uid = ct_uid.numpy().decode()\n",
" \n",
- " display.display(display.Markdown(f\"## {ct_uid}\"))\n",
- " diagnostic_plotting(x_grid, y_grid, input_array, output_array)\n",
- " plt.show()\n",
+ "# display.display(display.Markdown(f\"## {ct_uid}\"))\n",
+ "# diagnostic_plotting(x_grid, y_grid, input_array, output_array)\n",
+ "# plt.show()\n",
" \n",
" \n",
" scaled_input_array = tf.convert_to_tensor(transform.downscale_local_mean(input_array, (dimension_downscale, dimension_downscale, 1)))\n",
" new_x_grid = tf.convert_to_tensor(x_grid[dimension_downscale//2::dimension_downscale])\n",
" new_y_grid = tf.convert_to_tensor(y_grid[dimension_downscale//2::dimension_downscale])\n",
" \n",
- " diagnostic_plotting(new_x_grid, new_y_grid, scaled_input_array, scaled_output_array)\n",
- " plt.show()\n",
+ "# diagnostic_plotting(new_x_grid, new_y_grid, scaled_input_array, scaled_output_array)\n",
+ "# plt.show()\n",
" \n",
" new_input_array = scaled_input_array.numpy()[:, :, 0]\n",
" new_input_array[new_input_array > max_hu] = max_hu\n",
" hu_scaled_to_uint8 = (new_input_array / hu_scale).astype(np.uint8)\n",
" masks_scaled_to_uint8 = ((scaled_output_array.numpy() + 1)/2 * 255).astype(np.uint8)\n",
" \n",
- " plt.imshow(hu_scaled_to_uint8)\n",
- " plt.show()\n",
- " plt.imshow(masks_scaled_to_uint8)\n",
- " plt.show()\n",
+ "# plt.imshow(hu_scaled_to_uint8)\n",
+ "# plt.show()\n",
+ "# plt.imshow(masks_scaled_to_uint8)\n",
+ "# plt.show()\n",
"\n",
- " imageio.imwrite(f'data/{ct_uid}_image.png', hu_scaled_to_uint8)\n",
- " imageio.imwrite(f'data/{ct_uid}_mask.png', masks_scaled_to_uint8)"
+ " ct_uid_split = ct_uid.split('.')\n",
+ " patient_component = \".\".join(ct_uid_split[0:-2])\n",
+ " slice_component = \".\".join(ct_uid_split[-2:])\n",
+ "\n",
+ " try:\n",
+ " os.mkdir(f'data/{patient_component}')\n",
+ " except FileExistsError:\n",
+ " pass\n",
+ " \n",
+ " imageio.imwrite(f'data/{patient_component}/{slice_component}_image.png', hu_scaled_to_uint8)\n",
+ " imageio.imwrite(f'data/{patient_component}/{slice_component}_mask.png', masks_scaled_to_uint8)"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
