Rgb text file

Simple question. I want to use the track file as an overlay in another program. Is there an RGB text file to which this file refers so I could color code the directions in this external program? Currently the file loads in B + W. Thanks!

Anthony

To clarify, I exported the track file as a .nii.

Hi Anthony,

The RGB coloring of streamline tangents is never explicitly pre-calculated and stored; even when rendering in mrview, the colors are calculated on-the-fly based on the spatial offsets to the previous and next points. Explicitly storing all of these would double the GPU memory usage, which wouldn’t be great.

If you’re looking to achieve the same coloring in other software, it may well be easier to implement this form of streamline coloring within that software than to import such data. Otherwise, if this information absolutely needs to be pre-calculated, it’s a fairly trivial calculation (just the XYZ offset between the next and previous points, normalized to unit amplitude, then take the absolute value for each axis), so could be achieved e.g. by importing the track data into MatLab (using the provided functions) and computed there.

To clarify, I exported the track file as a .nii.

I’m not quite sure what you’ve done here, but track file data is very much different to NIfTI (which contains volumetric image information), so such a conversion should not be possible unless you’ve performed some kind of explicit calculation, e.g. using tckmap. Or if you’ve used a .nii extension for the output file when generating the tracks, then chances are you’ve just got a track file that has a .nii eextension instead of .tck, and any software will fail to open it since it doesn’t conform to the NIfTI standard.

Cheers
Rob

Hello Rob,

Thanks for the detailed reply. I did save the .tck file with the file extension .nii. It opens fine in both AFNI and DSI studio, but it does so as a grey scale image. However, the dec information does not come with it. DSI studio allows one to load an RGB text file so I thought that might provide the directional information, but it sounds like it is not encoded in the .nii file.

Anthony

I did save the .tck file with the file extension .nii. It opens fine in both AFNI and DSI studio, but it does so as a grey scale image.

In these softwares, are you opening this file as an image, or explicitly as a track file? If the latter, it’s possible that the software is figuring out that the data are in fact stored in the MRtrix track file format despite the erroneous file extension; and even though it ‘works’, I would most definitely advocate changing the file type extension to .tck to reflect the actual file contents. Opening this file as a NIfTI image (as indicated by the .nii extension) should almost certainly fail in any software. I would also avoid referring to the result as a ‘greyscale image’ if this is the case, particularly given the ambiguity regarding whether you’re dealing with track data or an actual image.

I would also check to see whether DSI Studio is capable of importing a text file where an RGB triplet is provided per streamline point, or only a single RGB triplet per streamline. Either of these should be relatively easy to calculate yourself, though the visual results will certainly differ (you can achieve the latter in mrview using the ‘Colour by endpoints’ option).

Rob

Any chance this image might have been generated using tckmap…? I agree with Rob, the chances of any software handling an MRtrix3 tracks file with the wrong extension correctly is close to zero… If you actually did use tckmap, you can use the -dec option to get an RGB map.

Very sorry for the confusion. Of course you are both right. This was a .mif file loaded and then saved as .nii. Still learning to use the program correctly…

The command was

tckmap DWI_brainstem2.tck DWI_tdinewest.1.mif -vox .1 -dec -force

The color coding loads great in mrview but does not export with the file (or maybe it does and I don’t know how to display it?)

Anthony

OK, everything makes sense now…

I’ve no idea what ‘external program’ you’re trying to use to display these images, but they’re simply stored as a 4D image with 3 volumes, one for each RGB component. There’s no guarantee that any other package would interpret these images this way. I think technically there’s a way to store RGB triplets in NIfTI images, but personally I don’t see much point in that…

You might find some other package that can take a 3 volume image and convert it into an RGB NIfTI, maybe other users on this forum might be able to help…?