Streamlines¶
Convert TRK, TCK and TRX tractograms to streamline stores and back. Chunk
shape, --overwrite and the export options are in
Converting files.
Format |
In / out |
Extra |
Positions |
Memory |
|---|---|---|---|---|
|
in, out |
|
voxmm (RAS mm with |
streams the file; larger than RAM works |
|
in |
|
RAS mm |
loads the whole file |
|
in, out |
|
RAS mm |
loads the whole file |
zvtools convert tracts.trk tracts.zv --num-chunks 64 --workers 8
from zarr_vectors_tools.convert.ingest.trk_parallel import ingest_trk_parallel
ingest_trk_parallel("tracts.trk", "tracts.zv", num_chunks=64, build_multiscale=False)
TRK takes --num-chunks, not --chunk-shape. TCK and TRX need
--chunk-shape in mm. The CLI builds a pyramid only when given --coarsen or
--sparsity, and its --sparsity-strategy default is random. In Python,
ingest_trk_parallel runs serially unless given an executor, builds a
pyramid unless build_multiscale=False, and keeps the longest streamlines
(sparsity_strategy="length").
Option |
Format |
Effect |
|---|---|---|
|
trk |
Target chunk count (default 125), or chunks per axis. The chunk edge it picks is printed as |
|
trk |
Worker processes, and the byte ranges the file is cut into. See Large data. |
|
trk |
Keep part files here; with |
|
trk |
Store RAS mm instead of voxmm; see Coordinates. |
|
all |
|
|
all |
|
|
trk |
Generated demo attributes ( |
What the store holds¶
One object per streamline; its points are the object’s vertices.
TRK scalars and TRX
dpvas vertex attributes; TRK properties and TRXdpsas object attributes. TRX keeps its dtypes (float16 becomes float32). A TRK property of one value per streamline is one column, shape (N,).TRX
groupsas named groups anddpgas group attributes, on every level.The TRK or TRX header. Every streamline ingest records millimetres as the axis unit.
Every name: Headers and attributes.
Coordinates¶
A TRK file stores points in voxmm: voxel index × voxel size. Its
vox-to-RAS affine maps them to scanner RAS mm. TCK and TRX store RAS mm.
The viewer draws stored positions as they are. Use --apply-affine when TRK
tracts must line up with data in RAS mm, such as TCK or TRX stores or surfaces.
Exporters convert from either space.
LINC TRK¶
ingest_linc_trk (Python only) reads a TRK whose
data_per_streamline["label_id"] holds an atlas label, and makes one group per
label. Its lut_path file has lines ID NAME R G B A; its mapping_path JSON
maps the file name to its label, such as {"my_bundle.trk": 34}. The group id
is the label; its name and colour become group attributes.
Export to TRK and TRX¶
zvtools convert bundles.zv cst.trx --group-id 0
Vertex attributes become TRK scalars or TRX dpv; object attributes become
TRK properties or TRX dps. Text attributes are skipped. TRK holds at most 10
scalars and 10 properties, with names of up to 20 characters. The reference
image comes from the store’s TRK header, else its TRX header, else the identity.
Region selection and bundle summaries: Streamlines and skeletons.