Tcksample from thresholded FA images

I’ve created a set of streamlines for a few different tracts like fornix and uncinate that may have some spurious as well as anatomically accurate streamlines, and would like to sample from thresholded data (i.e., FA > .2) to restrict sampling to white matter. However, tcksample outputs a lot of non-zero values below the threshold. Can you tell me why this might be and if there’s anything to do to avoid this? Similarly, is there any way to limit sampling to non-zero values? And last, I’m wondering if the order of values per line in the tcksample output corresponds to some anatomical orientation.

Thanks in advance for your help!

-Drew

Hi Drew,

There’s quite a few points here; let’s see how I go disentangling it all…

… and would like to sample from thresholded data (i.e., FA > .2) to restrict sampling to white matter. However, tcksample outputs a lot of non-zero values below the threshold. Can you tell me why this might be and if there’s anything to do to avoid this? Similarly, is there any way to limit sampling to non-zero values?

Firstly, I’m going to interpret from this that you are not calculating a streamline-wise statistic using the -stat_tck option, and therefore having tcksample output one value for every vertex point along each streamline.

Now if you are “sampling from thresholded data”, i.e. you have set the image value to 0 for any voxel where FA<0.2, then yes, the sampled value underneath some streamline points will still be non-zero but less than 0.2. This is because of the use of interpolation: if a vertex lies precisely in between one voxel with a value of 0.0 and another voxel with a value of 0.2, then that vertex will be assigned a value of 0.1. It would be technically possible to provide a command-line option in tcksample to disable this interpolation, but this may not be the best solution to what you’re trying to achieve (let’s see).

One possible alternative way of doing this is to mask the streamlines rather than the image data. If you derive a mask image containing voxels with FA>0.2, you can use this in tckedit with the -mask option, and any streamline vertex outside the mask image will be discarded. Note that by doing this, depending on your mask image it’s possible for one input streamline to be ‘split’ into multiple output streamlines; so if this were to be problematic for your analysis something would need to be done about it (for which there’s a few possible solutions). Also, even once this masking is performed there may still be some streamline vertices where the sampled value is less than your FA threshold (since the mask is a binary image and therefore streamline cropping is performed without interpolation, but the sampling will use interpolation).

Another alternative, which may or may not be of any use to you depending on exactly what you’re wanting to do with the sampled data subsequently, is to simply apply the FA>0.2 threshold directly to the output from tcksample. This is only an option because you are using the image that you are sampling (FA) to also define your ‘white matter mask’; the advantage of the previous suggestion is that the masking of areas to be sampled is independent of the image that you intend to sample from.

And last, I’m wondering if the order of values per line in the tcksample output corresponds to some anatomical orientation.

In the absence of the -stat_tck option, the values provided by tcksample are literally the sampled values underlying each streamline vertex. Importantly, this means that depending on how the streamlines corresponding to your pathway of interest were generated / extracted, for some streamlines the sample values may be in the reverse order with respect to those from other streamlines.

If you are looking to derive image values underlying streamlines according to some anatomical orientation or pre-defined path, that functionality is now provided by the tckresample command.

Cheers
Rob

Hi Rob,

First, many thanks for disentangling the multiple questions included in my original inquiry. That makes a lot of sense regarding the issues of interpolation along every vertex. I should emphasize that this is primarily an issue with the fornices where, in my sample, there are multiple streamlines (and vertices) that include adjacent CSF. So, in addition to your suggestions, it’s also possible this problem might also be somewhat improved by reducing the number of streamlines I’m generating for fornix. However, even with a more conservative approach for streamline generation, I’m concerned that would not eliminate the problem altogether.

I’ve tried this both with and without the -stat_tck option, but the problem I’m having is that the mean or median values using stat_tck option appear skewed or at least strongly influenced by those values sampled from interpolated vertices. Because of this, I wonder if disabling interpolation may be a feasible option.

Yes, that seems like worth trying, although I’m working with a rather large sample of >400 cases, so creating individually-specific fornix masks may also prove challenging, particularly in light of the limitations you’ve highlighted. Nevertheless, it’s good to know that masking the streamlines is a possible option, and avoids the issue of sampling from the same (i.e., FA) image used to define the white matter mask. However, if I wish to try this latter appraoch of applying the threshold to the output from tcksample, how would I go about this?

Ok - got it. So tckresample may be a better option if I wish to have clearer correspondence between sampled values and some anatomical orientation.

Many thanks again for your assistance and for the great software!

Cheers,
Drew

I should emphasize that this is primarily an issue with the fornices where, in my sample, there are multiple streamlines (and vertices) that include adjacent CSF. So, in addition to your suggestions, it’s also possible this problem might also be somewhat improved by reducing the number of streamlines I’m generating for fornix. However, even with a more conservative approach for streamline generation, I’m concerned that would not eliminate the problem altogether.

This is really an issue of quantifying FA in the presence of CSF contamination over and above image interpolation. Independently of sampling such values along streamlines, just deriving a good set of image voxels where the FA is not substantially corrupted by ventricular signal is very difficult at typical DWI resolutions. Whether or not there’s sufficient image data to justify sampling these values along the length of the fornix rather than just taking a mean value within a mask image, I honestly don’t know.

I’ve tried this both with and without the -stat_tck option, but the problem I’m having is that the mean or median values using stat_tck option appear skewed or at least strongly influenced by those values sampled from interpolated vertices. Because of this, I wonder if disabling interpolation may be a feasible option.

It’s definitely an option, I’m just not sure whether or not it’s the most direct solution to the problem: you’d still be relying on your own code/scripts to then process the values from each streamline, perhaps removing zeroes before calculating a mean per streamline or something like that. A more general / integrated solution might be more beneficial - perhaps something involving .tsf files…

Another thing to try is the -precise option in tcksample. Rather than performing trilinear interpolation per streamline vertex, this instead detects the points at which the streamline crosses the boundaries between voxels, and determines the precise length of the streamline within each voxel it traverses. So unlike image interpolation, you won’t get a nearby voxel that the streamline doesn’t actually go through influencing the result; but obviously if the streamline actually traverses such a voxel, the value in that voxel will be included in whatever calculation is performed (with weighting according to the length of the streamline contained within that particular voxel). The disadvantage of this approach is that you can no longer generate sample values along the length of the streamline, so are restricted to using a streamline-wise statistic such as mean or median (which may additionally assist to reduce the influence of outliers).

However, if I wish to try this latter approach of applying the threshold to the output from tcksample, how would I go about this?

This is a hypothetical that would rely on your own code / scripts: Just zero / reject any streamline vertex sample value that’s lower than your FA threshold before you do anything else with those values. But generally the reason why one would retain sample values along the length of the streamline rather than taking a streamline-wise statistic would be to retain the contrast in values along the streamline length; and if you’re trying to do that, then rejecting some values along the streamline doesn’t really gel well with the overall aim of the experiment. So whether or not this is a logical thing to do depends on the particulars of your experiment.

So tckresample may be a better option if I wish to have clearer correspondence between sampled values and some anatomical orientation.

tckresample can alter the positions of the streamline vertices according to some orientation / trajectory; these re-sampled streamlines can then be fed to tcksample in order to generate the sampled values from your image of interest.

Many thanks again for your assistance and for the great software!

:blush:

Rob