tracts
ngtools.local.tracts
Specialized SkeletonSource that loads and serves tractography data.
TractDataSource
Bases:
Data source for local skeletons.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
TractSkeleton
Bases:
Local tractography source loaded into a neuroglancer skeleton.
This class reads a TRK stremalines file (using nibabel) and implements methods that allow serving and/or converting the streamlines data into neuroglancer's precomputed skeleton format.
The skeleton format was originally implemented to render skeletonized volumetric segmentations, with a relatively small number of individual objects. Since tractography (especially high-resolution tractography) can generate millions of streamlines, saving each streamline as an individual skeleton is very inefficient -- both for querying and rendering.
Instead, we combine all streamlines into a single skeleton. Still,
the large number of streamlines slows down rendering quite a lot, so
I currently sample MAX_TRACTS streamlines from the file to display
(currently set to 10,000).
There is no "multi-scale" representation of the tracts in neuroglancer (i.e., generate tracts with a smaller or larger number of edges based on the current rendering scale). Maybe this is something that we should ask be added to neuroglancer.
If a segmentation of the tractogram is available, it would probably make sense to save the tracts belonging to each segment in a different skeleton. This would allow switching each segment on and off, and would allow segments to be displayed in different colors.
I also save a unit-norm orientation vector for each vertex. Saving
this information as vertex_attribute allows using it for rendering
(e.g., it can be used to render orientation-coded tracts).
The specification of the precomputed skeleton format is available here: https://github.com/google/neuroglancer/blob/master/ src/neuroglancer/datasource/precomputed/skeletons.md
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fileobj
|
|
TCK or TRK file |
required |
max_tracts
|
|
Maximum number of tracts to display |
|
format
|
[list of] {'tck', 'trk'}
|
Format hint |
None
|
compute_orientation
classmethod
Compute the orientation of a tract at each vertex.
get_skeleton
Neuroglancer Python API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i
|
|
Segment index (should be zero in our case) |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
skel |
|
|
precomputed_prop_info
Return precomputed format's "property info" file.
https://github.com/google/neuroglancer/blob/master/
src/neuroglancer/datasource/precomputed/segment_properties.md
precomputed_skel_info
Return precomputed format's "skeleton info" file.
https://github.com/google/neuroglancer/blob/master/
src/neuroglancer/datasource/precomputed/skeletons.md