Closed tashrifbillah closed 3 years ago
Thanks for the report.
@haehn do you remember where in the code the tensors are encoded to glTF? Does that just need to be generalized?
I would like to credit @justinec98 who detected it in the first place :)
Ping folks ...
Please provide example data to replicate the issue (e.g. a vtk file with two tensors that does not come back correctly from a round trip to trako)
Get my container:
singularity pull library://tbillah/collection/trako.sif
Get the data:
Trakofy:
singularity run --bind
pwd
:/data trako.sif trakofy -i /data/0381.vtk -o /data/0381.tko
Untrakofy:
singularity run --bind
pwd
:/data trako.sif untrakofy -i /data/0381.tko -o /data/0381.vtp
Check tracts:
Slicer --launch FiberTractMeasurements --inputtype Fibers_File_Folder --format Column_Hierarchy --separator Comma --inputdirectory /dir/of/vtk_or_vtp/ --outputfile measures.csv
Please modify /dir/of/vtk_or_vtp/
according to the requirement for FiberTractMeasurements
so you can get measures for vtk and vtp one at a time. I trust you to be more knowledgeable on it than I am :D
Issue:
You should see the absence of tensor2
in vtp.
@tashrifbillah - I spent some time reviewing this and from what I can tell the issue is that trako creates a valid vtp file, but it's in a slightly different form than the input file was. All the scalar fields, FreeWater, tensor2, tensor1, and EstimatedUncertainty are in both the input and output, but the FiberTractMeasurements CLI is interpreting them differently. I believe this is a unique issue with the CLI, because Slicer seems to be able to display either tensor.
Below is the script I used to test the round trip. You can see that untrakofy lists that both tensors are being uncompressed and that tkompare lists the data as being present.
I'll try to single step through FiberTractMeasurements to see why it's not detecting the second tensor.
Based on reading the code it appears that this setTensors
function is assuming something about the form of the file that may not cover all cases.
I'll leave this issue open for now in case a workaround should be added to trako, but for now it appears this is a SlicerDMRI issue since it should be able to handle valid VTK files.
#!/bin/bash
VTKIN=/opt/data/SlicerDMRI/trako/two-tensor-0381.vtk TKO=/tmp/two-tensor-0381.tko VTKOUT=/tmp/two-tensor-0381-out.vtp
./trakofy -i $VTKIN -o $TKO ./untrakofy -i $TKO -o $VTKOUT ./tkompare -a $VTKIN -b $VTKOUT
* Output of test script:
bash-3.2$ ./test-2tensor.sh
T R A K O.
Loading scalar FreeWater Loading scalar tensor2 Loading scalar tensor1 Loading scalar EstimatedUncertainty
From 1249228464 bytes to 528109301 bytes. Ratio 2.3654733246214876
(x_x) tko-ed.
vtkDebugLeaks has found no leaks.
T R A K O.
Restored scalar FreeWater Restored scalar tensor2 Restored scalar tensor1 Restored scalar EstimatedUncertainty
Restored 945186135 bytes.
(x_x) tko-ed.
vtkDebugLeaks has found no leaks.
T R A K O - Comparison
+-------------------------+------------+-------------+ | File | Bytes | Streamlines | +-------------------------+------------+-------------+ | two-tensor-0381.vtk | 1249228464 | 152774 | | two-tensor-0381-out.vtp | 945186135 | 152774 | +-------------------------+------------+-------------+ +--------------+---------------+-------------+--------------+--------------+ | Geometry | Min. Delta | Max. Delta | Mean. Delta | StdDev. | +--------------+---------------+-------------+--------------+--------------+ | XYZ Points | 2.9316761e-05 | 0.009193526 | 0.0051192925 | 0.0014815433 | | Line Indices | 0.0 | 0.0 | 0.0 | 0.0 | +--------------+---------------+-------------+--------------+--------------+ +----------------------+------------+------------+-------------+----------+ | Scalars | Min. Delta | Max. Delta | Mean. Delta | StdDev. | +----------------------+------------+------------+-------------+----------+ | FreeWater | 0.0 | 2.8e-05 | 1.4e-05 | 8e-06 | | tensor2 | 0.0 | 1e-06 | 1e-06 | 0.0 | | tensor1 | 0.0 | 1e-06 | 1e-06 | 0.0 | | EstimatedUncertainty | 0.0 | 0.297852 | 0.147087 | 0.086919 | +----------------------+------------+------------+-------------+----------+ +------------+------------+------------+-------------+---------+ | Properties | Min. Delta | Max. Delta | Mean. Delta | StdDev. | +------------+------------+------------+-------------+---------+ +------------+------------+------------+-------------+---------+
(x_x) tko-ed.
Hi @pieper , I have read your interesting finding and wanted to confirm that. However, tkompare
kicks me out write at the beginning:
Singularity> tkompare -a vtk/0381.vtk -b uncompressed_vtk/0381.vtp
>> T R A K O - Comparison
ERROR: Only .vtp and .vtk files are currently supported.
The ERROR is right according to this logic--it expects both pair vtk
s or vtp
s but not a mix.
How are you able to run the comparison then?
Thanks for testing @tashrifbillah - yes, I ran into that too and addressed it in an independent PR (https://github.com/bostongfx/TRAKO/pull/12). Sorry, I should have thought to flag that there. Anyway it's a small change so you should be able to apply it for testing.
Okay, I confirm your finding. By the way, is it surprising that the comparison took 1.5 hours at my end?
I guess that is a bit surprising. I don't think anything took more than a few minutes on my computer. Which part took so long? Was it the trako parts or the FiberTractsMeasurements?
Hi all, with the default config, do you compress/uncompress tensor1 only?
We compressed and uncompressed a couple of vtks. From the resultant vtps, only tensor1 is reported by
Slicer/FiberTractMeasurements
while both tensor1 and 2 were reported from the given vtks.cc @yrathi