Skip to content

Commit 0b0ba38

Browse files
committed
Merge branch 'dev' of github.com:VincentBeaud/scilpy into dev
2 parents f0031c6 + 2fa2574 commit 0b0ba38

File tree

1 file changed

+51
-35
lines changed

1 file changed

+51
-35
lines changed

docs/fibertube/DEMO.md

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
# Demo Workshop
1+
# Demo
22
In this demo, you will be introduced to the main scripts of this project as you apply them on simple data.
33
<br><br>
4-
Our main objective is better understand and quantify the fundamental limitations of tractography algorithms, and how they might evolve as we approach microscopy resolution where individual axons can be seen, tracked or segmented. To do so, we will be evaluating tractography's ability to reconstruct individual white matter fiber strands at various simulated extreme resolutions.
4+
Our main objective is better understand and quantify the fundamental limitations of tractography algorithms, and how they might evolve as we approach microscopy resolution where individual axons can be seen. To do so, we will be evaluating tractography's ability to reconstruct individual white matter fiber strands at various simulated extreme resolutions.
55
## Terminology
66
Here is a list of terms and definitions used in this project.
77

88
General:
99
- Axon: Bio-physical object. Portion of the nerve cell that carries out the electrical impulse to other neurons. (On the order of 0.1 to 1um)
10-
- Streamline: Virtual object. Series of equidistant 3D coordinates approximating an underlying fiberous structure.
10+
- Streamline: Virtual object. Series of 3D coordinates approximating an underlying fiber structure.
1111

1212
Fibertube Tracking:
13-
- Centerline: Virtual object. Series of equidistant 3D coordinates representing the directional information of a fibertube.
14-
- Fibertube: Virtual representation of an axon. It is composed of a centerline and a single diameter for its whole length.
15-
- Fibertube segment: Because centerlines are made of discrete coordinates, fibertubes end up being composed of a series of equally lengthed adjacent cylinders. A fibertube segment is any single one of those cylinders.
16-
- Fibertube Tractography: The application of a tractography algorithm directly on fibertubes to reconstruct them. Contrary to traditional white matter fiber tractography, fibertube tractography does not rely on a discretized grid of fODFs or peaks.
13+
- Fibertube: Virtual representation of an axon. Tube obtained from combining a diameter to a streamline.
14+
- Centerline: Virtual object. Streamline passing through the center of a tubular structure.
15+
- Fibertube segment: Cylindrical segment of a fibertube that comes as a result of the discretization of its centerline.
16+
- Fibertube Tractography: The computational tractography method that reconstructs fibertubes. Contrary to traditional white matter fiber tractography, fibertube tractography does not rely on a discretized grid of fODFs or peaks. It directly tracks and reconstructs fibertubes, i.e. streamlines that have an associated diameter.
17+
18+
19+
![Fibertube visualized in 3D](https://github.com/user-attachments/assets/e5dbeb23-ff2f-48ae-85c4-e0e98a0c0070)
1720

18-
![Fibertube visualized in Blender](https://github.com/VincentBeaud/fibertube_tracking/assets/77688542/25494d10-a8d5-46fa-93d9-0072287d0105)
1921

2022
## Methodology
2123
This project can be split into 3 major steps:
@@ -33,9 +35,9 @@ This project can be split into 3 major steps:
3335
3436
The data required to perform fibertube tractography comes in two files:
3537
- `./centerlines.trk` contains the entire ground-truth of the DISCO dataset.
36-
- `./diameters.txt` contains the diameters.
38+
- `./diameters.txt` contains the diameter to be applied to each centerline in the centerlines.trk file above.
3739

38-
![DISCO subset visualized in MI-Brain](https://github.com/VincentBeaud/fibertube_tracking/assets/77688542/197b3f1f-2f57-41d0-af0a-5f7377bab274)
40+
![DISCO subset visualized in 3D](https://github.com/VincentBeaud/fibertube_tracking/assets/77688542/197b3f1f-2f57-41d0-af0a-5f7377bab274)
3941

4042
The first thing to do is resample `centerlines.trk` so that each centerline is formed of
4143
segments no longer than 0.2 mm.
@@ -50,7 +52,7 @@ scil_tractogram_resample_nb_points.py centerlines.trk centerlines_resampled.trk
5052

5153
Next, we want to filter out intersecting fibertubes, to make the data anatomically plausible and remove any partial volume effect.
5254

53-
![Fibertube intersection visualized in Blender](https://github.com/VincentBeaud/perfect_tracking/assets/77688542/ede5d949-d7a5-4619-b75b-72fd41d65b38)
55+
![Fibertube intersection visualized in 3D](https://github.com/VincentBeaud/perfect_tracking/assets/77688542/ede5d949-d7a5-4619-b75b-72fd41d65b38)
5456

5557
This is accomplished using `scil_tractogram_filter_collisions.py`. <br>
5658

@@ -69,6 +71,12 @@ After a short wait, you should get something like:
6971

7072
As you may have guessed from the output name, this script automatically combines the diameter to the centerlines as data_per_streamline in the output tractogram. This is why we named it "fibertubes.trk".
7173

74+
If you wish to know how many fibertubes are left after filtering, you can run the following command:
75+
76+
```scil_tractogram_print_info.py fibertube.txt```
77+
78+
79+
7280
## Visualising collisions
7381
By calling:
7482
```
@@ -80,19 +88,20 @@ In white and lower opacity is the original tractogram passed as `--ref_tractogra
8088
![Filtered intersections visualized in 3D](https://github.com/VincentBeaud/fibertube_tracking/assets/77688542/4bc75029-0d43-4664-8502-fd528e9d93f4)
8189

8290
### Fibertube metrics
83-
Before we get into tracking. Here is an overview of the metrics that we saved in `metrics.txt`:
91+
Before we get into tracking. Here is an overview of the metrics that we saved in `metrics.txt`. They are all expressed in mm:
8492

8593
- `min_external_distance`: Smallest distance separating two fibertubes, outside their diameter.
8694
- `max_voxel_anisotropic`: Diagonal vector of the largest possible anisotropic voxel that would not intersect two fibertubes.
8795
- `max_voxel_isotropic`: Isotropic version of max_voxel_anisotropic made by using the smallest component. <br>
8896
Ex: max_voxel_anisotropic: (3, 5, 5) => max_voxel_isotropic: (3, 3, 3)
8997
- `max_voxel_rotated`: Largest possible isotropic voxel obtainable if the tractogram is rotated. It is only usable if the entire tractogram is rotated according to [rotation_matrix].
9098
Ex: max_voxel_anisotropic: (1, 0, 0) => max_voxel_rotated: (0.5774, 0.5774, 0.5774)
91-
- `rotation_matrix`: 4D transformation matrix representing the rotation to be applied on the tractogram to align max_voxel_rotated with the coordinate system (see scil_tractogram_apply_transform.py).
9299

93-
![Metrics (without max_voxel_rotated) visualized in Blender](https://github.com/VincentBeaud/perfect_tracking/assets/77688542/95cd4e50-1a36-49af-ac11-0d5f33d3f32e)
100+
![Metrics (without max_voxel_rotated) visualized in 3D](https://github.com/user-attachments/assets/43cebcbe-e3b1-4ca0-999e-e042db8aa937)
94101
<br>
95-
![max_voxel_rotated visualized in Blender](https://github.com/VincentBeaud/perfect_tracking/assets/77688542/72812e47-371f-4005-b289-1de0d70d2f33)
102+
103+
![max_voxel_rotated visualized in 3D](https://github.com/user-attachments/assets/924ab3f9-33da-458f-a98b-b4e88b051ae8)
104+
96105

97106
> [!NOTE]
98107
> This information can be useful for analyzing the reconstruction obtained through tracking, as well as for performing track density imaging.
@@ -101,7 +110,7 @@ Ex: max_voxel_anisotropic: (1, 0, 0) => max_voxel_rotated: (0.5774, 0.5774, 0.57
101110
We're finally at the tracking phase! Using the script `scil_fibertube_tracking.py`, you are able to track without relying on a discretized grid of directions or fODFs. Instead, you will be propagating a streamline through fibertubes and degrading the resolution by using a `blur_radius`. The way it works is as follows:
102111

103112
### Tracking
104-
When the tracking algorithm is about to select a new direction to propagate the current streamline, it will build a sphere of radius `blur_radius` and pick randomely from all the fibertube segments intersecting with it. The larger the intersection volume, the more likely a fibertube segment is to be picked and used as a tracking direction. This makes fibertube tracking inherently probabilistic.
113+
When the tracking algorithm is about to select a new direction to propagate the current streamline, it will build a sphere of radius `blur_radius` and pick randomly from all the fibertube segments intersecting with it. The larger the intersection volume, the more likely a fibertube segment is to be picked and used as a tracking direction. This makes fibertube tracking inherently probabilistic.
105114
Theoretically, with a `blur_radius` of 0, any given set of coordinates has either a single tracking direction because it is within a fibertube, or no direction at all from being out of one. In fact, this behavior won't change until the diameter of the sphere is larger than the smallest distance separating two fibertubes. When this happens, more than one fibertubes will intersect the `blur_radius` sphere and introduce partial volume effect.
106115

107116

@@ -124,36 +133,42 @@ By using the `scil_fibertube_score_tractogram.py` script, you are able to obtain
124133

125134
VC: "Valid Connection": Represents a streamline that ended in the final
126135
segment of the fibertube in which it was seeded.
127-
IC: "Invalid Connection": Represents a streamline that ended in the final
128-
segment of another fibertube.
129-
NC: "No Connection": Contains streamlines that have not ended in the final
130-
segment of any fibertube.
136+
IC: "Invalid Connection": Represents a streamline that ended in the first or
137+
final segment of another fibertube.
138+
NC: "No Connection": Contains streamlines that have not ended in the first or
139+
final segment of any fibertube.
131140

132-
A "coordinate absolute error" is the distance in mm between a streamline
141+
The "absolute error" of a coordinate is the distance in mm between this streamline
133142
coordinate and the closest point on its corresponding fibertube. The average
134143
of all coordinate absolute errors of a streamline is called the "Mean absolute
135144
error" or "mae".
136145

137146
Computed metrics:
138-
- truth_vc_ratio
147+
- truth_vc_ratio <br>
139148
Proportion of VC.
140-
- truth_ic_ratio
149+
- truth_ic_ratio <br>
141150
Proportion of IC.
142-
- truth_nc_ratio
151+
- truth_nc_ratio <br>
143152
Proportion of NC.
144-
- res_vc_ratio
145-
Proportion of VC at the resolution of the blur_radius parameter.
146-
- res_ic_ratio
147-
Proportion of IC at the resolution of the blur_radius parameter.
148-
- res_nc_ratio
149-
Proportion of NC at the resolution of the blur_radius parameter.
150-
- mae_min
153+
- res_vc_ratio <br>
154+
Proportion of VC at the resolution of the blur_radius parameter. The
155+
streamline passes at a distance of at most [blur_darius] away from
156+
the last segment of its fibertube.
157+
- res_ic_ratio <br>
158+
Proportion of IC at the resolution of the blur_radius parameter. The
159+
streamline passes at a distance of at most [blur_darius] away from the
160+
first or last segment of another fibertube.
161+
- res_nc_ratio <br>
162+
Proportion of NC at the resolution of the blur_radius parameter. The
163+
streamline does not pass below [blur_radius] away from the first or
164+
last segment of any fibertube.
165+
- mae_min <br>
151166
Minimum MAE for the tractogram.
152-
- mae_max
167+
- mae_max <br>
153168
Maximum MAE for the tractogram.
154-
- mae_mean
169+
- mae_mean <br>
155170
Average MAE for the tractogram.
156-
- mae_med
171+
- mae_med <br>
157172
Median MAE for the tractogram.
158173

159174
Let's do:
@@ -177,6 +192,7 @@ giving us the following output in `reconstruction_metrics.txt`:
177192
}
178193
```
179194

180-
This data tells us that none of our streamline managed to stay within the fibertube in which it was seeded (`"truth_vc_ratio": 0.0`). However, 40% of streamlinea are at most one `blur_radius` away from the end of their respective fibertube (`"res_vc_ratio": 0.4`). Lastly, we notice that the streamline with the "worst" trajectory was on average 5.5um away from its fibertube (`"mae_max": 0.0055722481609273775`). We can suspect that it started very good early on, but eventually drifted further than 10um, rendering it a NC.
195+
This data tells us that none of our streamline managed to stay within the fibertube in which it was seeded (`"truth_vc_ratio": 0.0`). However, 40% of streamlines are at most one `blur_radius` away from the end of their respective fibertube (`"res_vc_ratio": 0.4`). Lastly, we notice that the streamline with the "worst" trajectory was on average 5.5um away from its fibertube (`"mae_max": 0.0055722481609273775`). We can suspect that it started very good early on, but eventually drifted further than 10um, rendering it a NC.
181196

182197
## End of Demo
198+

0 commit comments

Comments
 (0)