Visualization toolbox for DWMRI related processing, including DTI, spherical harmonics, etc...
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
external
tests
README.md
dwmri_axial_coronal_plot.m
dwmri_base_plot.m
dwmri_info_plot.m
dwmri_visualizer.m

README.md

dwmri_visualizer

Visualization toolbox for DWMRI related processing, including: DTI, spherical harmonics, etc...

If you use this tool in your research, please cite with: DOI

Installation instructions:

  1. Install FSL
  2. (optional - only if plotting PASMRI) Install camino
  3. Download repos and (optional) example data:
git clone https://github.com/justinblaber/nifti_utils.git
git clone https://github.com/justinblaber/dwmri_visualizer.git

# Optionally download example data (note this is quite large... sorry)
wget https://justinblaber.org/downloads/github/dwmri_visualizer/data.zip
unzip data.zip
  1. In MATLAB:
>> addpath(genpath('nifti_utils'));
>> addpath(genpath('dwmri_visualizer'));
>> data_path = 'data';

If you've downloaded the example data, then run specific cells in each script:

>> edit test_dwmri_visualizer.m
>> edit test_dwmri_plot.m

Select cells from test_dwmri_visualizer.m and test_dwmri_plot.m are shown below:

%% Directions test - bedpostX

% Load data
dyads1_vol = nifti_utils.load_untouch_nii4D_vol_scaled(fullfile(data_path,'dyads1.nii.gz'),'double');
dyads2_vol = nifti_utils.load_untouch_nii4D_vol_scaled(fullfile(data_path,'dyads2.nii.gz'),'double');
mean_f1samples_vol = nifti_utils.load_untouch_nii4D_vol_scaled(fullfile(data_path,'mean_f1samples.nii.gz'),'double');
mean_f2samples_vol = nifti_utils.load_untouch_nii4D_vol_scaled(fullfile(data_path,'mean_f2samples.nii.gz'),'double');
mean_fsumsamples_vol = nifti_utils.load_untouch_nii4D_vol_scaled(fullfile(data_path,'mean_fsumsamples.nii.gz'),'double');
mask_vol = nifti_utils.load_untouch_nii_vol_scaled(fullfile(data_path,'mask.nii.gz'),'logical');
xform_RAS = nifti_utils.get_voxel_RAS_xform(fullfile(data_path,'dwmri.nii.gz'));

% Get visualizer
dv = dwmri_visualizer({dyads1_vol,dyads2_vol; ...
                       ones(size(mask_vol)),mean_f2samples_vol}, ...
                      mean_fsumsamples_vol, ... 
                      mask_vol, ...
                      xform_RAS, ...
                      'directions', ...
                      {'r','b'; ...
                        0.25,0.25; ...
                        1,0.05});

% Make a plot
dv.plot_slice(47,'coronal','boundingbox');
axis image


%% DTI  - colorized by v1 direction

% Load data
dwmri_vol = nifti_utils.load_untouch_nii4D_vol_scaled(fullfile(data_path,'dwmri.nii.gz'),'double');
bvals = dlmread(fullfile(data_path,'dwmri.bval'));
dt_vol = nifti_utils.load_untouch_nii4D_vol_scaled(fullfile(data_path,'dt.nii.gz'),'double');
v1_vol = nifti_utils.load_untouch_nii4D_vol_scaled(fullfile(data_path,'v1.nii.gz'),'double');
fa_vol = nifti_utils.load_untouch_nii_vol_scaled(fullfile(data_path,'fa.nii.gz'),'double');
xform_RAS = nifti_utils.get_voxel_RAS_xform(fullfile(data_path,'dwmri.nii.gz'));

% Get visualizer
dv = dwmri_visualizer({dt_vol(:,:,:,3:end),v1_vol}, ...    
                      mean(dwmri_vol(:,:,:,bvals == max(bvals)),4)-0.25, ...
                      fa_vol*1.75, ...
                      xform_RAS, ...
                      'DT', ...
                      {40,1});

% Make a plot
dv.plot_slice(26,'axial','boundingbox');
axis image
light('Position', [5, 5, 5], 'Style', 'infinite')


%% sh_coefs test - MT_SCSD

% Load data
dwmri_vol = nifti_utils.load_untouch_nii4D_vol_scaled(fullfile(data_path,'dwmri.nii.gz'),'double');
bvals = dlmread(fullfile(data_path,'dwmri.bval'));
sh_coefs_vol = nifti_utils.load_untouch_nii4D_vol_scaled(fullfile(data_path,'mt_scsd_sh_coefs.nii.gz'),'double');
fa_vol = nifti_utils.load_untouch_nii_vol_scaled(fullfile(data_path,'fa.nii.gz'),'double');
xform_RAS = nifti_utils.get_voxel_RAS_xform(fullfile(data_path,'dwmri.nii.gz'));

% Get visualizer
dv = dwmri_visualizer(sh_coefs_vol, ...
                      mean(dwmri_vol(:,:,:,bvals == max(bvals)),4)-0.25, ...
                      fa_vol*2, ...
                      xform_RAS, ...
                      'sh_coefs', ...
                      {8,60,true});

% Make a plot
dv.plot_slice(47,'coronal','top-centroid',1);
axis image
light('Position', [5, 5, 5], 'Style', 'infinite')


%% sh_coefs test - MT_SCSD

% Load data
dwmri_vol = nifti_utils.load_untouch_nii4D_vol_scaled(fullfile(data_path,'dwmri.nii.gz'),'double');
bvals = dlmread(fullfile(data_path,'dwmri.bval'));
sh_coefs_vol = nifti_utils.load_untouch_nii4D_vol_scaled(fullfile(data_path,'mt_scsd_sh_coefs.nii.gz'),'double');
fa_vol = nifti_utils.load_untouch_nii_vol_scaled(fullfile(data_path,'fa.nii.gz'),'double');
xform_RAS = nifti_utils.get_voxel_RAS_xform(fullfile(data_path,'dwmri.nii.gz'));

% Get visualizer
dv = dwmri_visualizer(sh_coefs_vol, ...
                      mean(dwmri_vol(:,:,:,bvals == max(bvals)),4)-0.25, ...
                      fa_vol*2, ...
                      xform_RAS, ...
                      'sh_coefs', ...
                      {8,60,true});

% Make the plot
dwmri_hdr = load_untouch_header_only(fullfile(data_path,'dwmri.nii.gz'));
f = dwmri_axial_coronal_plot(dv, ...
                             {'MT_SCSD', ...
                             ['   B-values: ' num2str(unique(bvals)) '; lmax: 8; mrtrix path: ~/mrtrix3'], ...
                             ['   Gradient Directions: ' num2str(length(find(bvals ~= 0)))], ...
                             ['   Slice Dimensions: ' num2str(dwmri_hdr.dime.dim(2)) ',' num2str(dwmri_hdr.dime.dim(3))], ...
                             ['   Slices: ' num2str(dwmri_hdr.dime.dim(4))], ...
                             ['   Voxel Resolution: ' num2str(round(dwmri_hdr.dime.pixdim(2),1)) ' x ' num2str(round(dwmri_hdr.dime.pixdim(3),1)) ' x ' num2str(round(dwmri_hdr.dime.pixdim(4),1))], ...
                             'Justin Blaber', ...
                             'justin.blaber@vanderbilt.edu', ...
                             'Multi-tissue constrained spherical deconvolution for improved analysis of multi-shell diffusion MRI data (Tournier et al 2014)', ...
                             'N/A', ...
                             'MT_SCSD_v1_1_0'});
                     
% Apply light to axes
all_axes = findall(f,'type','axes');
for i = 1:length(all_axes)
    light(all_axes(i), 'Position', [5, 5, 5], 'Style', 'infinite');
end