Home > fe > feConnectomeReduceVoxels.m

feConnectomeReduceVoxels

PURPOSE ^

Select the voxels to keep (extract) in a connectome matrix

SYNOPSIS ^

function [fe, indicesFibersKept] = feConnectomeReduceVoxels(fe,voxelsToKeep)

DESCRIPTION ^

 Select the voxels to keep (extract) in a connectome matrix

   [fe, indicesFibersKept] = feConnectomeReduceVoxels(fe,voxelToKeep)

 voxelsToKeep:  Is a binary list of voxels we preserve.

 We expand the voxelsToKeep into a binary list of 0's and 1's that in
 which each is expanded by nBvecs.  The 1s are the rows of the M matrix we
 will keep.

  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, indicesFibersKept] = feConnectomeReduceVoxels(fe,voxelsToKeep)
0002 % Select the voxels to keep (extract) in a connectome matrix
0003 %
0004 %   [fe, indicesFibersKept] = feConnectomeReduceVoxels(fe,voxelToKeep)
0005 %
0006 % voxelsToKeep:  Is a binary list of voxels we preserve.
0007 %
0008 % We expand the voxelsToKeep into a binary list of 0's and 1's that in
0009 % which each is expanded by nBvecs.  The 1s are the rows of the M matrix we
0010 % will keep.
0011 %
0012 %  Example:
0013 %
0014 % Copyright (2013-2014), Franco Pestilli, Stanford University, pestillifranco@gmail.com.
0015 
0016 % Get the indices to each voxels' signal
0017 vxRows = feGet(fe,'voxelrows',voxelsToKeep);
0018 
0019 % Return only the mode and the signal for the voxels we want to keep
0020 fe.life.Mfiber = fe.life.Mfiber(vxRows,:);
0021 fe.life.dSig   = fe.life.dSig(vxRows);
0022 
0023 % Set the new number of voxels, by indexing inside the roi and
0024 % returning it as an ROI.
0025 fe.roi.coords = feGet(fe,'roi coords subset',voxelsToKeep);
0026 
0027 % Set the new diffusion signal, the one for only these subset of voxels.
0028 fe.life.diffusion_signal_img = fe.life.diffusion_signal_img(voxelsToKeep,:);
0029 
0030 % Set the diffusion signal at 0 diffusion weighting (B0) for this voxel:
0031 if ~isempty(fe.life.diffusion_S0_img)
0032 fe.life.diffusion_S0_img = fe.life.diffusion_S0_img(voxelsToKeep);
0033 end
0034 
0035 % Set the voxels to fiber/node pairs for a subset of voxels in the conncetome.
0036 fe.life.vovel2FNpair = [];
0037 
0038 % Now remove singals for the second data set if it was loaded
0039 if isfield(fe,'rep')   
0040     if ~isempty(fe.rep.diffusion_signal_img)
0041     % Set the new diffusion signal, the one for only these subset of voxels.
0042     fe.rep.diffusion_signal_img = fe.rep.diffusion_signal_img(voxelsToKeep,:);
0043     end
0044     
0045     if ~isempty(fe.rep.diffusion_S0_img)
0046     % Set the diffusion signal at 0 diffusion weighting (B0) for this voxel:
0047     fe.rep.diffusion_S0_img = fe.rep.diffusion_S0_img(voxelsToKeep); 
0048     end
0049     
0050 end
0051 
0052 % Now that we have removed some voxels fom the model, we need to remove also
0053 % the fibers that do not go through the coordinates left in the roi of the model.
0054 % These fibers make no contribution to the signal in the voxels.
0055 % Find the unique fibers in the new ROI.
0056 fibersToKeep = feGet(fe,'uniquefibersindicesinroi');
0057 
0058 % Find the indices of the fibers that were deleted
0059 indicesFibersKept = zeros(size(feGet(fe,'fiber weights')));
0060 indicesFibersKept(fibersToKeep) = 1;
0061 
0062 % Remove the fibers of the fascicle from the fe.
0063 fe = feConnectomeReduceFibers(fe, fibersToKeep );
0064 
0065 
0066 return

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