Giter Site home page Giter Site logo

dwmri_visualizer's Introduction

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', ...
                             '[email protected]', ...
                             '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

dwmri_visualizer's People

Contributors

justinblaber avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

masilab

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.