Algorithm 4.
Inferring 3D segmentation of cell nuclei
| Require: : 3D array of final 3D cell regions with unique indices from Algorithm 3 | |
| Require: : 3D array of 2D nuclear regions from the Z-axis, each uniquely indexed at its Z-slice | |
| 1: | ← empty 3D array for final 3D nuclear regions |
| 2: | final_indices ← list of unique indices of 3D cell regions in |
| 3: | for index in final_indices do |
| 4: | {Iterate over each final 3D cell region} |
| 5: | for in unique(where()) do |
| 6: | {Iterate over the Z-slices where the current 3D cell region exists} |
| 7: | 2D_region_coords ← where() |
| 8: | ⟵empty 2D array with the same XY dimensions as {Initialize array for individual final 3D cell region at slice z } |
| 9: | ⟵ empty 2D array with the same XY dimensions as {Initialize array for individual final 3D nuclear region at slice z} |
| 10: | [2D_region_coords] ← index {2D array with index value at the coordinates of current final 3D cell region at slice } |
| 11: | [2D_region_coords] ← [, 2D_region_coords] {2D array with indexed 2D nuclear regions overlapping with } |
| 12: | if num(unique())> 1 then |
| 13: | {If more than one nucleus is present} |
| 14: | ⟵selectNucleus() |
| 15: | {Keep the nucleus with the smallest fraction beyond and on cell boundaries} |
| 16: | end if |
| 17: | ⟵trimNucleus() |
| 18: | {Remove nuclear pixels outside or on cell boundaries} |
| 19: | ← index |
| 20: | {Store the trimmed 2D nuclear region} |
| 21: | end for |
| 22: | end for |
| 23: | for index in final_indices do |
| 24: | 3D_region_coords ⟵ where () |
| 25: | {Get the 3D coordinates of the current final 3D cell region} |
| 26: | num_overlap ⟵ findNucleus(3D_region_coords, ) |
| 27: | {Find the number of overlapping 3D nuclear regions} |
| 28: | if num overlap = = 0 then |
| 29: | [3D_region_coords] ← 0 |
| 30: | {Remove final 3D cell regions that do not have corresponding 3D nuclear region} |
| 31: | end if |
| 32: | end for |