|
| 1 | +# How it Works |
| 2 | + |
| 3 | +This is document extracted from [How it works.doc](./How%20it%20works.doc) |
| 4 | + |
| 5 | +## Terminology |
| 6 | + |
| 7 | +* **Vertex** – point with 3D coordinates (retrieved from `.wrl` or Blender file) |
| 8 | +* **Vertices** – collection of vertex |
| 9 | +* **Face** – a collection of 3, 4, or more vertices. It contains only indices of vertices from the `Vertices` collection (from `.wrl` or Blender) |
| 10 | +* **Faces** – collection of face |
| 11 | +* **Slice** – a collection of vertices located at the junction of two segments of an object. It is not a face. |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +* **Resulting\_point** – the center of mass of a slice |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## 1. First Step of the Algorithm |
| 20 | + |
| 21 | +We need to find the **start point**, which is a point located in the **soma**. |
| 22 | + |
| 23 | +What soma is, in **Fig.1**, is obvious – it's the segment with the slice that has the **maximum perimeter**. |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +## 2. Algorithm for Finding All Resulting Points |
| 30 | + |
| 31 | +* Add the current center point to the `resulting_points` collection. |
| 32 | +* Fill up the `vector_len` collection, which contains objects with: |
| 33 | + |
| 34 | + * `index` of vertex from the `vertices` collection |
| 35 | + * `distance` from this point to the current center point |
| 36 | + |
| 37 | +### Step 1 |
| 38 | + |
| 39 | +**Initialization:** |
| 40 | + |
| 41 | +```text |
| 42 | +iteration = 0 |
| 43 | +``` |
| 44 | + |
| 45 | +* Find, for the current center point, the **nearest slice** from `vector_len`. |
| 46 | +* Calculate center point for the found slice. |
| 47 | +* Put vertices of this slice into the `checked_points` collection. |
| 48 | +* Set `current center point = new center point` |
| 49 | +* Increment `iteration += 1` |
| 50 | +* Recursively repeat with new center point. |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +### If `iteration != 0`, then: |
| 55 | + |
| 56 | +#### Find next center point: |
| 57 | + |
| 58 | +1. If `_slice = None`, initialize `slice` from `vector_len` collection. |
| 59 | +2. Else (`_slice != None`) => `slice = _slice` |
| 60 | +3. Find **adjacent points** for all points in the slice. |
| 61 | + |
| 62 | + * Adjacent points collection contains only those points **not** already in the `checked_points` collection. |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +### Adjacent Point Scenarios |
| 69 | + |
| 70 | +#### a. 4 Points |
| 71 | + |
| 72 | +* Simple segment without branching. |
| 73 | +* Find slice from this 4-point collection, compute new center point. |
| 74 | +* Update `current center point`, increment iteration. |
| 75 | +* Add this slice's vertices to `checked_points`. |
| 76 | +* Go to Step 1. |
| 77 | + |
| 78 | +#### b. 6 Points |
| 79 | + |
| 80 | +* If `isBrunchStart = false`: branching segment. |
| 81 | + |
| 82 | + * Two slices (**Slice1**, **Slice2**) found by analyzing adjacent points. |
| 83 | + |
| 84 | + * Compute center point for both slices. |
| 85 | + |
| 86 | + * Go to Step 1 for **each** new center point. |
| 87 | + |
| 88 | + * Add slice vertices to `checked_points`. |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | +* If `isBrunchStart = true`: in first segment after branching. |
| 93 | + |
| 94 | + * Create slice from adjacent points, compute center point. |
| 95 | + * Update `current center point` |
| 96 | + * Add slice vertices to `checked_points` |
| 97 | + * Go to Step 1 |
| 98 | + |
| 99 | +#### c. 8 Points |
| 100 | + |
| 101 | +* Try to find two slices (Slice1 and Slice2) from adjacent points. |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +* If 2 slices found: |
| 106 | + |
| 107 | + * Compute center point for each |
| 108 | + * Add their vertices to `checked_points` |
| 109 | + * Go to Step 1 for each |
| 110 | + |
| 111 | +* If 0 slices found: |
| 112 | + |
| 113 | + * We are in the first point of **axon** or **dendrite** |
| 114 | + * Select the slice with the **smaller perimeter** |
| 115 | + * Compute new center point |
| 116 | + * Add vertices to `checked_points` |
| 117 | + * Go to Step 1 for new center point |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +## Step 2 |
| 124 | + |
| 125 | +If `iteration = 1`: |
| 126 | + |
| 127 | +* Check if **Soma** has **other dendrites**. |
| 128 | +* Check the **5 nearest slices** to the start center point. |
| 129 | +* If such a slice is found, return to **Step 1** using the center point from that slice. |
| 130 | + |
0 commit comments