Skip to content

Use LiFE to refine a candidate connectome to a optimized connectome

Rosemary Le edited this page Jul 14, 2016 · 4 revisions

Example Matlab script:


%% modify the cell below -------------------------------------

% path to diffusion data
dwiPath = '/pathToDWIData/dti_aligned_trilin.nii.gz';

% path to t1 anatomy
t1Path  = '/pathToAnatomy/t1.nii.gz';

% path to the candidate connectome (e.g. whole brian fiber group)
% both pdb and mat files should work
connectomeCandidatePath = '/pathToConnectome/connectomeName.pdb';

% name that we will give to the optimized connectome and data structure
optimizedName = 'LiFEOptimized_connectome.pdb' ;

% full directory path of where to save optimized connectome
saveDir = '/pathToSaveDirectory/';

%% Do things ----------------------------------------------------
%% (1.1) Initialize the LiFE-BD model structure
% USE MATLAB 2015A IF POSSIBLE
% This cell takes approximately 3 days on a GLXA64 box using Matlab 2015a

N = 360; % Discretization parameter
mycomputer = computer(); 
release = version('-release');

switch strcat(mycomputer,'_',release)
    %  case {'GLNXA64_2015a','MACI64_2014b'} 
    case {'GLNXA64_2015a','MACI64_2014b', 'GLNXA64_2015b'}
    fe = feConnectomeInit(dwiPath,connectomeCandidatePath,optimizedName,saveDir,[],t1Path,N,[1,0],0);
    otherwise
    sprintf('WARNING: currently LiFE is optimized for an efficient usage of memory \n using the Sparse Tucker Decomposition aproach (Caiafa&Pestilli, 2015) \n ONLY for Linux (MatlabR2015a) and MacOS (MatlabR2014b). \n If you have a different system or version you can still \n use the old version of LiFE (memory intensive). \n\n')
    sprintf('\n Starting building big matrix M in OLD LiFE...\n')
    fe = feConnectomeInit(dwiPath,connectomeCandidatePath,optimizedName,saveDir,[],t1Path,N,[1,0],1);
end

%% (1.2) Fit the model. 
% Hereafter we fit the forward model of tracrography using a least-squared
% method. The information generated by fitting the model (fiber weights
% etc) is then installed in the LiFE-BD structure.
fe = feSet(fe,'fit',feFitModel(feGet(fe,'model'),feGet(fe,'dsigdemeaned'),'bbnnls'));

%% Get the optimized connectome -- fibers with weights < 0
FG = feGet(fe, 'fibers acpc');
W = feGet(fe,'fiber weights');
FG = fgExtract(FG, W > 0, 'keep');

%% Save the optimized connectome
chdir(saveDir)

% save as mat and pdb
fgWrite(FG, optimizedName, 'pdb');
fgWrite(FG, optimizedName, 'mat');

Clone this wiki locally