How to restrict fixelcfestats to subset of tracts

Hi everyone. I am trying to restrict fixelcfestats to run in an roi-based manner, using a seed-to-target region that I generated from tckgen (using the population template). Simply swapping out the track ROI for the full tractogram in fixelcfestats does not work, probably because I’m still feeding it the whole-brain FD images and/or whole brain analysis masks. Maybe I need to max out height or extent? Or maybe there is a way to convert the tractogram ROI to a fixel analysis mask ROI ? I also tried using tcksample to create a track or vector file for each subject, but it’s not working :

tcksample  tracks_20k_ROI.tck Subject1_fd.msf Subject1_fd_ROI.tck -force
tcksample  tracks_20k_ROI.tck Subject1_fd.msf Subject1_fd_ROI.msf -force

The command seems to run, but when I try to open the resulting .tck or .msf files, I get exceptions:

mrinfo: [ERROR] unknown format for image "Subject1_fd_ROI.tck"

I have tried using other options in tcksample (-stat_tck, -precise) but I’m still getting the same error. For reference, here is the track ROI overlaid on Subject1_fd.msf:

In sum, I need advice on either: 1. restricting analysis to a tractogram-based ROI w/in fixelcfestats or 2. successfully creating ROI fixel maps for all subjects using tcksample.

Thanks in advance-happy to provide any other info.

Rachael

Hi Rachael,
You could try the new tck2fixel command in the 3.0 release. This uses the new directory-based fixel format.

To do this first convert your fixel template analysis mask that you previously computed for input to fixelcfestats:

fixelconvert template_fixel_mask.msf template_fixel_mask_dir

Then compute a fixel track density image, where each fixel value contains the number of streamlines associated with it:

tck2fixel track_of_interest.tck template_fixel_mask_dir template_fixel_mask_dir track_of_interest_TDI.mif

Note that in the above command the output will be placed inside the input fixel directory (hence why I have template_fixel_mask_dir twice). I.e. the track_of_interest_TDI.mif file will be found inside the template_fixel_mask_dir directory. You can view all “data” files in the fixel directory using the 3.0 mrview fixel plot tool.

To convert the fixel TDI to a mask, just threshold:

mrthresold -abs  1 template_fixel_mask_dir/track_of_interest_TDI.mif template_fixel_mask_dir/track_of_interest_mask.mif

For each subject in your study, convert fixel images (the ones previously input to fixelcfestats) to the format:

fixelconvert patient-fdc-01.msf all_patients_fdc_dir -name 01

Note that here fdc data from all subjects ends up in a single fixel directory (since they share the same ‘directions.mif’ file). This will be the input to the new MRtrix v3.0 fixelcfestats (checkout the new documentation to get a feel for how this works)

Finally, you will want to mask the input data by cropping/removing the fixels not in your tract-of-interest mask. This can be done with:

fixelcrop all_patients_fdc_dir template_fixel_mask_dir/track_of_interest_TDI.mif all_patients_fdc_dir_cropped

The all_patients_fdc_dir_cropped directory now contains all data (fixel directions, and FDC values for all subjects) ready for input to fixelcfestats.

I’ve just typed these instructions out without running the commands, so let me know if you run into any issues.
Cheers,
Dave

2 Likes

Thanks, I really appreciate the detailed reply! I haven’t tried out the new release yet, since I am in the middle of analyses using the previous version. I ended up having some luck using tckmap, and I’ll try what you suggested once I upgrade.

I am trying to restrict fixelcfestats to run in an roi-based manner, using a seed-to-target region that I generated from tckgen (using the population template).

Excuse me while I mould your question a little…

Within this experiment, once you have performed a segmentation of sorts of the pathway of interest, is it still necessary to provide fixel sensitivity and specificity during the statistical analysis? I.e. Would it still be of interest if the observed statistical effect only consitituted a fraction of the bundle cross-section, or a fraction of its length?

Or would it instead be adequate to “collapse” your quantitative measure of interest (e.g. FD, FC, FDC) into a single scalar measure per subject (e.g. the mean value within the fixels corresponding to the pathway of interest), and then perform your statistical inference on those values directly rather than doing a full-blown CFE?

Reason I ask is that it wouldn’t be a whole lot of effort to implement a -mask option for fixelcfestats (which would avoid the need for the fixelcrop step), but as I thought about it I couldn’t fully rationalise it.

Hi Robert, see answers below…

Regarding whether it would be of interest to do a mask that includes partial-bundles, I have actually done this before, so yes it is sometimes of interest (I fed an a priori voxel-based ROI through the “analysis voxel/fixel mask” creation process, and swapped it into the analysis_fixel_mask position). Having a -mask option available would have definitely made my life easier in those analyses, but it wasn’t overly difficult to accomplish. In the current scenario, though, I am interested in a specific tractography-based bundle, not a voxel-based region that may overlap with several tracts.

Actually, this is precisely what I’d like to avoid :slight_smile:

The effects I am targeting virtually never seem to affect an entire pathway, at least in my experience, in my field. So I really need the power of fixelcfestats so that I can analyze effects at all locations along a pathway.

2 Likes

The effects I am targeting virtually never seem to affect an entire pathway, at least in my experience, in my field. So I really need the power of fixelcfestats so that I can analyze effects at all locations along a pathway.

Slightly extending the question: is the identification of an effect only for a subset of a pathway indicative of only a subset of the pathway genuinely being affected, or is it a statistical power issue? We often see this in CFE results where the statistical significance mask doesn’t include the full extent of the pathway as it branches / merges with other pathways / goes through crossing fibre regions: the effect is probably there, but it gets diluted / the variance increases.


Overall I think having -mask option for fixelcfestats is the most targeted solution: it avoids having to re-derive the subject fixel images for a specific analysis. I’ve added that as a feature request.

tck2fixel is actually a bit of an in-between solution: Eventually tckmap will be capable of generating fixel-wise TDIs / TWIs / whatever, it’s just that it’s part of a bigger set of changes. Maybe one day we’ll even have a fixel ROI editor in mrview? :stuck_out_tongue:

Hi all,

I would like to follow up on this thread. I am working with mrtrix3 released and installed on the 10th of May (so I’m using the new fixel directory format). Just as Rachael I’m trying to look into effects along a specific pathway. So this thread has been really helpful. I followed the steps suggested by Dave, however, fixeclrop errors out, with the following message:

terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoul
Aborted

The command I use is:

fixelcrop fd tracts/UNC_L_TDI_mask.nii.gz fd_cropped

Where fd contains the subjects FD files, index and directions file (which are the same I used to convert the .tck to the TDI image). I can’t really make anything of the error message (the debug option returned the same info and digging into C++ threads on stoul also didn’t help me). Does anyone know what’s going on? The inputs seem to be fine, right? Or is the .nii extension messing things up here?

In addition:

  1. Just out of curiosity, is there a -mask option going to be implemented for fixcelcfestats anywhere soon (as Rob suggested)?
  2. Is there a way to combine multiple .tck, or TDI (mask) files into one single file? (this question might be a bit trivial…)

Thanks for all the help, and of course many thanks for the wonderful mrtrix software package!!
Best,
Jon

This error results from an attempt at converting an invalid string (most likely empty) to an integer, and occurs at this point in the code. This is because the input image does not contain the nfixels header entry, which is fully expected since the NIfTI format doesn’t support storing such values (only the MRtrix-specific *.mif/*.mih format does).

This sounds like a bug in that command, my guess is we should be using this convenience function to detect the number of fixels when the format doesn’t support storing it in the header. @Dave/@rsmith: can you confirm?

No idea, hopefully others will confirm one way or the other.

Yes, for .tck files, you can simply use tckedit with multiple inputs. For TDI images, you can simply add them using mrcalc:

mrcalc TDI1.mif TDI2.mif -add TDI_sum.mif

or if they are genuinely binary mask images, take the maximum value (a poor man’s version of OR…), again with mrcalc:

mrcalc mask1.mif mask2.mif -max combined_mask.mif

Hi Donald,

Thanks for the prompt response and for the time to explain the code!
I’ll wait for Dave/Rob’s reply.

Best,
Jon

Hi there Robert, I have been thinking a lot about this issue that you posed in a couple of posts in this thread:

Since I need to run some fairly complex mixed models (which am pretty sure fixelcfestats can’t handle), I would like to try out your suggestion to collapse FD/FC into a mean-value-per-track for each subject. I am hoping that you or someone else could provide a brief tutorial for systematically extracting pathways of interest from the FOD population_template. It looks like you and @Dave et al. accomplished this kind of ROI extraction by coregistering the SRI24 atlas to the population template:

"To identify each fibre ROI (Fig. 4e), streamlines were extracted from the template-generated tractogram using grey matter include-regions defined by the SRI24 atlas (Fig. 4d) (Rohlfing et al., 2010). The SRI24 atlas was co-registered to the group-average template using fractional anisotropy and mean diffusivity maps simultaneously (using the ANTS software package; ANTs | picsl). Spurious streamlines were removed with exclude-regions defined by a neurolo- gist. In addition we cropped streamlines in regions where the stream- line density was less than 2% of the maximum density within that tract. "

If anyone could share code or tips for accomplishing said co-registration and subsequently performing the pathway extraction based on “grey matter include-regions”, I would be very grateful!

Just out of curiosity, is there a -mask option going to be implemented for fixcelcfestats anywhere soon (as Rob suggested)?

I’ve already added it to the list; if there’s demand for it, I’ll try to get to it…

This sounds like a bug in that command, my guess is we should be using this convenience function to detect the number of fixels when the format doesn’t support storing it in the header. @Dave/@rsmith: can you confirm?

Certainly looks to be the case.

Since I need to run some fairly complex mixed models (which am pretty sure fixelcfestats can’t handle), I would like to try out your suggestion to collapse FD/FC into a mean-value-per-track for each subject.

If it’s something that you can’t express as a GLM, then yes, you might have to look at such summary statistics in order to make your data compatible with other software. If however it’s something that we should conceptually be able to support but don’t currently, this is something we’d like to know more about.

To identify each fibre ROI (Fig. 4e), streamlines were extracted …

I don’t think the registration looks terribly difficult. SRI24 comes with an “EPI” image template; you could probably warp the per-subject b=0 images (without modulation) according to the non-linear warps for the FOD template, and use the resulting b=0 template as the registration target. I’m guessing you’d want to use a 12 DOF affine?

For the pathway extraction, I don’t have the code that Dave used, but there are two logical ways to do it:

  • Use tckedit to select streamlines that go through one of a set of regions at one end of the pathway, and one of a set of regions at the other end of the pathway. From the parcellation index, you can produce mask ROIs of individual parcels using mrcalc with the -eq operator; multiple masks can be combined together using mrmath.

  • Generate a connectome, using the -out_assignments option in tck2connectome to keep track of which nodes each streamline is assigned to, then use connectome2tck to extract tracks corresponding to particular edges of the connectome. If the pathway spans multiple edges, the resulting multiple track files can be merged together using tckedit.

Use tckedit to select streamlines that go through one of a set of regions at one end of the pathway, and one of a set of regions at the other end of the pathway. From the parcellation index, you can produce mask ROIs of individual parcels using mrcalc with the -eq operator; multiple masks can be combined together using mrmath.

Finally getting around to fiddling with this, so reviving an old thread–Rob, I am having a hard time seeing the options in tckedit that would accomplish what you’re describing. How would I use tckedit to generate a parcellation index?

For the first of the two techniques I described previously, I think the issue is that I described the required steps in the reverse order to how they would actually be used:

  1. Identify the integer values within the parcellation image / lookup taable that correspond to your regions of interest for extracting your pathway of interest.

  2. Use mrcalc with the -eq operator.
    Say that one of your parcels of interest is number 23. You would use:
    mrcalc parcellation.mif 23 -eq 23.mif -datatype bit
    to produce a mask (binary) image that is 1 in voxels where the parcellation image value is 23, and 0 everywhere else. This is literally your “Region Of Interest (ROI)”.

  3. Use tckedit with the -include option to select only those tracks that pass through your region(s) of interest.

Ah–thanks, Rob, I misunderstood your original post (I thought you meant there was an automated way to index tractography output based on feeding in a given set of parcellations). I appreciate the clarification, this is what I have been doing.