Skip to content
johncolby edited this page Dec 18, 2011 · 6 revisions

trk_plot.m

trk_plot has several different plotting modes that we will demonstrate in this example. Let’s start by loading in the example data:

exDir   = '/path/to/along-tract-stats/example';
subDir  = fullfile(exDir, 'subject1');         
trkPath = fullfile(subDir, 'CST_L.trk');       
volPath = fullfile(subDir, 'dti_fa.nii.gz');   

volume          = read_avw(volPath);                   
[header tracks] = trk_read(trkPath);

Now we’ll process it a bit to reorient the streamlines and attach an FA scalar.

tracks = trk_flip(header, tracks, [], volume);
[header tracks] = trk_add_sc(header, tracks, volume, 'FA');

Default

By default, trk_plot will plot the streamlines in blue, and will highlight the first vertex of each one with a red dot. This is most useful for using the interactive trk_flip tool to reorient the streamlines.

trk_plot(header, tracks, volume)
view([110 10])

Rainbow

This mode color-codes the vertex index. It is most useful for examining the correspondence scheme. For example, Fig. 9A in Colby et al. 2012 uses this approach. See Correspondence for more info.

trk_plot(header, tracks, volume, [], 'rainbow')
view([110 10])

Scalar

Color can also be used to highlight variation in scalar measures that have been added to the tracks structure with trk_add_sc. These may be imaging metrics like FA (see below), but may also be alternative correspondence labels that have been added with trk_add_labs. Fig. 9B in Colby et al. 2012 uses this approach.

trk_plot(header, tracks, volume, [], 'scalar', 1)
view([110 10])

Debug

Similar to the default option, this mode plots the streamlines in blue. Instead of just highlighting the first vertex, however, it marks every vertex with a red dot. I sometimes find this mode (or some variation of it) useful for debugging the outputs of the different processing tools.

trk_plot(header, tracks(1:10), [], [], [], [], 1)

Other notes

  • Using the MATLAB hold command, you can add multiple tract groups to the same plot. This is enabled by default when you make a new plot with trk_plot.
  • For exporting good-looking figures from MATLAB, I highly recommend export_fig from the FileExchange.