Home > fe > feConnectomeInit.m

feConnectomeInit

PURPOSE ^

Initialize a new connectome (fe) structure.

SYNOPSIS ^

function fe = feConnectomeInit(dwiFile,fgFileName,feFileName,savedir,dwiFileRepeated,anatomyFile,varargin)

DESCRIPTION ^

 Initialize a new connectome (fe) structure. 

    fe = feConnectomeInit(dwiFile,dtFile,fgFileName,feFileName,savedir,dwiFileRepeated,anatomyFile,varargin);
    
 We allow a set of (paramName,val) pairs in the varargin that will be
 executed as fe = feSet(fe,paramName,val)

 Example: 

 Copyright (2013-2014), Franco Pestilli, Stanford University, pestillifranco@gmail.com.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function fe = feConnectomeInit(dwiFile,fgFileName,feFileName,savedir,dwiFileRepeated,anatomyFile,varargin)
0002 % Initialize a new connectome (fe) structure.
0003 %
0004 %    fe = feConnectomeInit(dwiFile,dtFile,fgFileName,feFileName,savedir,dwiFileRepeated,anatomyFile,varargin);
0005 %
0006 % We allow a set of (paramName,val) pairs in the varargin that will be
0007 % executed as fe = feSet(fe,paramName,val)
0008 %
0009 % Example:
0010 %
0011 % Copyright (2013-2014), Franco Pestilli, Stanford University, pestillifranco@gmail.com.
0012 
0013 feOpenLocalCluster
0014 
0015 % Intialize the fe structure.
0016 fe = feCreate;
0017 
0018 % Set the based dir for fe, this dire will be used
0019 if notDefined('savedir'),  savedir = fullfile(fileparts(fgFileName),'life');
0020 end
0021 fe = feSet(fe,'savedir',savedir);
0022 
0023 % Set the xforms (transformations from diffusion data to acpc)
0024 tempNi = niftiRead(dwiFile);
0025 fe = feSet(fe, 'img2acpc xform', tempNi.qto_xyz);
0026 fe = feSet(fe, 'acpc2img xform', inv(tempNi.qto_xyz));
0027 clear tempNi
0028 
0029 % Set up the fe name
0030 if isstruct(fgFileName),  n  = fgFileName.name;
0031 else                   [~,n] = fileparts(fgFileName);
0032 end
0033 
0034 if notDefined('feFileName'),
0035   feFileName = sprintf('%s-%s', datestr(now,30),n);
0036 end
0037 fe = feSet(fe, 'name',feFileName);
0038 
0039 % Load a connectome
0040 if isstruct(fgFileName), fg = fgFileName; clear fgFileName
0041 else % A file name was passed load the fibers from disk
0042   fprintf('\n[%s]\n loading fiber from file: %s\n',mfilename,fgFileName)
0043   fg = fgRead(fgFileName);
0044 end
0045 
0046 % Set fg in the fe structure identifying the fg coordinate frame.
0047 % Everything in LiFE is in img coordinates, but everyting in mrDiffusion is in acpc.
0048 % So here we assume the fibers are read in acpc and we xform them in img.
0049 fe = feSet(fe,'fg from acpc',fg);
0050 
0051 % When the ROI is set to empty, LiFE uses all of the voxels within the
0052 % connectome as the ROI.
0053 fe = feSet(fe,'roi fg',[]);
0054 clear fg
0055 
0056 % Precompute the canonical tensors for each node in each fiber.
0057 tic
0058 if ~isempty(varargin)
0059   axialDiffusion  = varargin{1}(1);
0060   radialDiffusion = varargin{1}(2);
0061 else % Default to stick and ball
0062   axialDiffusion  = 1;
0063   radialDiffusion = 0;
0064 end
0065 dParms(1) =  axialDiffusion; 
0066 dParms(2) = radialDiffusion; 
0067 dParms(3) = radialDiffusion;
0068 
0069 fe = feSet(fe,'model tensor',dParms);
0070 
0071 fprintf('\n[%s] Computing fibers'' tensors... ',mfilename); 
0072 fe = feSet(fe, 'tensors', feComputeCanonicalDiffusion(fe.fg.fibers, dParms));  
0073 toc
0074 
0075 % We disregard fibers that have identical trajectories within the ROI.
0076 roi = feGet(fe,'roi coords');
0077 fe  = feSet(fe,'voxel 2 fiber node pairs',fefgGet(feGet(fe,'fg img'),'v2fn',roi));
0078 fe  = feGetConnectomeInfo(fe);
0079 
0080 % Install the information about the diffusion data.
0081 fe = feConnectomeSetDwi(fe,dwiFile,0);
0082 
0083 % Install the information about a repeated measurement of the diffusion
0084 % data.
0085 if ~notDefined('dwiFileRepeated')
0086   fe = feConnectomeSetDwi(fe,dwiFileRepeated,1);
0087 end
0088 
0089 % Install the path tot he anatomical high-resolution file.
0090 if ~notDefined('anatomyFile')
0091   fe = feSet(fe,'anatomy file',anatomyFile);
0092 end
0093 
0094 % Build LiFE tensors and key connection matrices
0095 fe = feConnectomeBuildModel(fe);
0096 
0097 return

Generated on Wed 02-Jul-2014 17:17:39 by m2html © 2005