-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reference datasets #20
Comments
Great suggestion! Here is the PR #22 |
@frheault thanks for your quick work. Your converter appears to work. I do have a couple of comments:
The detail of my comments reflect my enthusiasm for this format, rather than a core criticism. I am working on a JavaScript implementation which is designed to work on computers, tablets and phones, so memory considerations are at the top of my mind. |
Thanks for the feedback!
|
This is outside my domain, so maybe experts like @jdtournier want to weigh in, but my sense is that if you are trying to track more that 4294967296 vertices, you should try to work on making the software smarter. One option would be vertex reuse (afterall, if you are OK with float16 precision, the vertices from all these streamlines will use many of the same vertices), maybe you want to work on signal averaging to create more accurate rather than more streamlines. I can certainly see the logic for creating a new format with headroom for the future. However, the human brain is of known, limited volume and MR signal is based on the volume of hydrogen, e.g. so a 2mm isotropic scan has 8 times (2^3) more signal than a 1mm voxel, with SNR effectively linear with field strengths for most modalities. |
@neurolabusc I added a new script ( Also, the NIFTI seems to spatially aligned with MNI152, but the streamlines are not (all software but TrackVis are in rasmm/world space/scanner space, TrackVIs is in voxmm: This leads to my script tff_visualize_overlap.py to expose that problem. So I made a special script (kind of hacky/experimental) to fix it separately. Modifying the loading/saving code of DSI-Studio to increase compatibility with other tools would be nice! @frankyeh Technical note, once these operations are done, the resulting streamlines can be saved with Dipy StatefulTractogram and they can be visualized in MITK, MI-Brain (TRK/TCK/FIB), SurfIce, TrackVis, Dipy and if saved in TCK-> mrtrix.
EDIT: I took TRK from https://pitt-my.sharepoint.com/:f:/g/personal/yehfc_pitt_edu/Ek0DdO67iQ9NvkJUci91lzMBXCVBq926QXTTY7JK6LIjgw?e=jvydcC |
@frheault this is an elegant script. One unusual feature is that it can convert compressed .trk.gz files but not uncompressed trk files:
|
I will add an extra line, I forgot that part! I was too focused on the data online I forgot trk.gz can be decompressed manually. Also, for now, it only converts to TRK/TCK/FIB, TRX will be added this afternoon. |
Sorry about the bug in DSI-STUDIO. There is a recent update to fix it. The
trk from previous DSI-STUDIO can be loaded and saved by the updated version
to correct the error.
Best regards
Frank
…On Thu, Apr 7, 2022, 12:33 PM Francois Rheault ***@***.***> wrote:
I will add an extra line, I forgot that part! I was too focused on the
data online I forgot trk.gz can be decompressed manually.
Also, for now, it only converts to TRK/TCK/FIB, TRX will be added this
afternoon.
—
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACDI4NPDOWTOZBGAPQANF3VD4E5BANCNFSM5SPMZCNA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@frheault I have one other issue with tff_convert_dsi_studio.py: it does not preserve properties or scalars. Here is an example of a mis-aligned TRK scan and anatomical image as well as the output from your script. Notice that the property "DATASETID" does not survive. |
@frankyeh Thank you for the quick answer! Do you have an example for me of an old.trk.gz (not fixed yet) and a new.trk.gz (loaded and saved with the fix) from DSI-Studio so I can make sure my code works well with as many tools as possible? @neurolabusc Thanks for the example data, I will incorporate the change (the metadata is kept in the other conversion script, but not the DSI-Studio one, because it was kind of hacky in the first place). EDIT: Should keep data_per_*, and load trk/trk.gz and save trx now |
There are trk.gz file in this thread:
https://groups.google.com/g/dsi-studio/c/Ez4AsTmKj8s/m/1L_p2Z6aAAAJ?utm_medium=email&utm_source=footer&pli=1
including the one from the older version (shared by the user) and one I
generated using the updated version.
Hope this helps,
Frank
…On Thu, Apr 7, 2022 at 5:04 PM Francois Rheault ***@***.***> wrote:
@frankyeh <https://github.com/frankyeh> Do you have an example for me of
an old.trk.gz (not fixed yet) and a new.trk.gz (loaded and saved with the
fix) from DSI-Studio so I can make sure my code works well with as many
tools as possible?
And is there a way to know if it's a pre/postfix trk? That way one script
could crash and warn the user to fix it, either with the above mention
script or a more recent DSI-Studio
@neurolabusc <https://github.com/neurolabusc> Thanks for the example
data, I will incorporate the change (the metadata is kept in the other
conversion script, but not the DSI-Studio one, because it was kind of hacky
in the first place).
—
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACDI4N2PZV2OXT2F3ZJPSTVD5EV5ANCNFSM5SPMZCNA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@frankyeh Thanks for the data. After looking at it I think the new version still has a problem. Also assuming the provided NIFTI is the right one, both the older and newer version of the TRK load outside of the volume in a RASMM viewer and my I am not sure how, but it seems my I am not sure exactly what is the source of the problem. But I think the inconsistencies between the headers' affine is the start of it. They should be identical. (Assuming the user provided the right reference NIFTI) |
Thank you very much for checking it!
DSI Studio always outputs TRK at LPS orientation because it converts all
DWI sources (DICOM, NIFTI...etc.) to LPS at the very beginning of
the pipeline.
The NIFTI orientation is thus not available at the end of the tractography
output.
It seems to me that a workaround is to modify the LPS trk based on the
NIFTI header information.
…On Thu, Apr 7, 2022 at 8:55 PM Francois Rheault ***@***.***> wrote:
@frankyeh <https://github.com/frankyeh> Thanks for the data. After
looking at it I think the new version still has a problem.
First I would expect the header of the TRK to be identical to the NIFTI.
Right now the voxel order is not the same (LAS for the NIFTI and LPS for
the TRK) and the translation do not match (possibility due to the voxel
order)
[image: image]
<https://user-images.githubusercontent.com/10820351/162341879-05d32435-d10d-4cfb-bdd7-873a7c8f915c.png>
Also assuming the provided NIFTI is the right one, both the older and
newer version of the TRK load outside of the volume in a RASMM viewer and
my tff_visualize_overlap.py show the same problem.
[image: image]
<https://user-images.githubusercontent.com/10820351/162341841-36457dc4-3dad-4636-9931-769f98bff25a.png>
I am not sure how, but it seems my tff_convert_dsi_studio.py does the job
for both TRK file (green-ish in the middle of the volume above).
I am not sure exactly what is the source of the problem. But I think the
inconsistencies between the headers' affine is the start of it. They should
be identical.
—
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACDI4JSRYIRY6UHXJN3OIDVD57WFANCNFSM5SPMZCNA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
So the NIFTI provided by the user was the wrong one? Also no matter the voxel order (or stride) of a NIFTI, it should not change its world space coordinates if the affine is modified accordingly. Same thing with the TRK, the coordinates written on disk should always be in voxel/grid space and the affine bring the coordinates to world space. Do you have another example data with an old vs new TRK file with the right NIFTI you expect it to overlap with? If it matches the NIFTI it is expected to match with, that's fine. But if it doesn't it means something is wrong. I would expect a FA and bundle saved by the new DSI-Studio to overlap in TrackVis and Nibabel or Mi-brain, do you have that lying around? |
@frheault thanks your latest version of I see you are using the Imeka mi-brain. I am unable to open TRX files using the latest 2020.04.09 release on macOS. Do I need a plug in, or are you using a developmental version (or merely viewing TRK files)? |
Do you have another example data with an old vs new TRK file with the
right NIFTI you expect it to overlap with?
Sorry I don't have other examples.
Frank
… —
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACDI4JL3PHHP76HX3XFUHTVEAOFRANCNFSM5SPMZCNA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@neurolabusc I am not loading TRX in MI-Brain, only TRK/TCK. Since I worked on the Python code to load TRX, the StatefulTractogram in Dipy and coded the C++ TRK loader in MI-Brain I know that Dipy and MI-Brain work the same way. Once we have the C++ prototype for the TRX file, I will try to convince people at Imeka (MI-Brain) to add it to their list of supported file formats. I know they would not use most functionalities, but loading/saving with basic data_per_point/streamline with the TRX would be very nice! But I also know they will likely prefer to wait for us (the research branch of the project) to somewhat agree on the design to avoid wasting resources. @frankyeh I will try to generate it myself using the latest available version online for Windows. I will share the file and version number here (likely next week) with the steps I did so you can confirm (or not) that what I did is right/wrong. |
@frheault thanks to your conversion tool, it is helping me create a JavaScript implementation. One issue I have with benchmarking my solution is that the script does not generate valid vtk files. Specifically,
Will create a binary file that includes
whereas the specification only allows int32 and therefore there is no data type for lines (and VTK files that do allow a custom datatype require it on the same line as the data kind):
Beyond this clear violation: while legal, it is also unusual that the VTK file uses float64 ( |
At the moment this VTK code is in Dipy and was not intended to be customizable (for benchmarking or other uses), but rather a simple conversion to VTK with no specific "target" software/tool in mind. For this specific benchmarking task, you would like to be able to customize the offsets and positions data type of the VTK file format? |
@frheault DiPy is able to leverage the collective work of 124 contributors. It is a terrific tool that plays a key role in our community. However, the DiPy group did not create the VTK standard, nor did they update the standard. The streamlines created by DiPy retain the signature of the VTK format. I think the DiPy team needs to be conscientious of all the smaller teams that are unaware to these unilateral changes and may not have the resources to support them. Off the top of my head Camino, MedInria, TVFromEigenSystem, VTK, SingleTensorFT, FSL tools, Surfice, Slicer3D. If DiPy wants to make these unilateral changes they should use a different extension and signature or alternatively commit to supporting these other tools in adopting this standard. All these other tools will now mysteriously fail for no fault of the original developers who faithfully implemented the standard and with no explanation for the end user. I have updated my own JavaScript code to support this data, but please do not see this as an endorsement for this behavior. |
@neurolabusc It seems that the problem is simply that the Anyway, this is breaking for various tools, so I can try to fix this in the code and set the default to int32/float32? Do you know which of the listed software above supports the newer VTK file format vs the legacy file format (or both) EDIT: Here is two identical files (ASCII), one is when the default (previous problematic version) and the other I specified the data type to float32 and int32. Is the second one valid/working in your application? |
@frheault ASCII does not make sense for scientific data: there are implementation differences in rounding, the files are slow to load and require a lot of disk space. I adapted my script to handle the binary DiPy version as well as legitimate VTK binary lines data. Regardless, your samples are not valid VTK files:
Note that DiPy stores the OFFSETS, with each entry listing the start of a sequential streamline. While this is efficient for sequential streamlines, it does not allow vertex reuse and is not what the VTK format specifies. The VTK format would look something like
I can completely understand the rationale for the DiPy format, but these should not have the .vtk extension or the VTK signature on the first line |
@neurolabusc Maybe there is a misunderstanding. Isn't the offsets/connectivity the new file format convention of VTK (with VTK 9, spring 2020). I see now that this change from VTK caused a problem elsewhere, I think that Dipy follows the VTK current file format convention (version >5). But it is true that the vast majority of applications are following the legacy (version <5) file format. Apparently there is code in VTK to switch back and forth between the old and the new format. Maybe Dipy could support (and even default to) the legacy convention? What do you think? EDIT: All of this is indeed a major VTK update that was not properly announced or transitioned. The current VTK file format convention is not backward compatible and the new default is breaking the application expecting the older version (<5). PS: If VTK is 'pushing' forward with this, what is the best approach? Defaulting to legacy format or the newest format? |
OK, so they never updated a specification, they just added notes to the vtkCellArray class documentation? Despite the comments from users, it is not available in the current Slicer 4.11.20210226, though it is supported by the Preview release. I guess if this was initiated by the VTK group it is technically legal, but the description of the legacy implementation seems very sparse. I guess I (and others) will have to update our code for this variation. Well mea culpa, I retract my comments regrading the rogue DiPy team. |
@neurolabusc No problem I understand the confusion, I struggled to find documentation about the changes and I looked for it. This seems to be a very sneaky and breaking update from VTK and I guess Dipy went along very fast without warning (well, as much warning as VTK gave us). This is yet another example of a challenge with file formats! I'm glad we figured it out, I think my understanding of VTK file format is better than it was, I was not really sure about the new convention (and I sure thought it would be better detailled) |
Closing the issue. Thanks @frheault for scripts that allow us to create datasets. |
@frheault is it possible to have some demo code that converts from/to TRX to help validate upcoming TRX tools? You have TRK/TCK/VTK(FIB) samples here. Can you provide a simple script that reads each of these images and writes the output as TRX? Some concrete real world examples would be a great help.
The text was updated successfully, but these errors were encountered: