Home > fe > feConnectomeReduceFibers.m

feConnectomeReduceFibers

PURPOSE ^

Deletes a set of fibers from the signal and the M matrix.

SYNOPSIS ^

function [fe, removedFibers] = feConnectomeReduceFibers(fe, fibersToKeep)

DESCRIPTION ^

 Deletes a set of fibers from the signal and the M matrix.

   [fe, removedFibers] = feConnectomeDeleteFibers(fe,fibersToKeep)

 Inputs:
   - fe, an fe structure, see feCreate.m, and v_lifeExample.m
   - fibersToKeep, a list of indexes to the fibers to keep e.g., [1 10 100].
   - reduceVoxels, (optional), if set to 1 it will remove all the voxels
       from the fe structure where the fibers left inside the fe structure do
       not have go through.

 Example:
   fibersToKeep = 1:50;
   feConnectomeReduceFibers(fe, fibersToKeep)

 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, removedFibers] = feConnectomeReduceFibers(fe, fibersToKeep)
0002 % Deletes a set of fibers from the signal and the M matrix.
0003 %
0004 %   [fe, removedFibers] = feConnectomeDeleteFibers(fe,fibersToKeep)
0005 %
0006 % Inputs:
0007 %   - fe, an fe structure, see feCreate.m, and v_lifeExample.m
0008 %   - fibersToKeep, a list of indexes to the fibers to keep e.g., [1 10 100].
0009 %   - reduceVoxels, (optional), if set to 1 it will remove all the voxels
0010 %       from the fe structure where the fibers left inside the fe structure do
0011 %       not have go through.
0012 %
0013 % Example:
0014 %   fibersToKeep = 1:50;
0015 %   feConnectomeReduceFibers(fe, fibersToKeep)
0016 %
0017 % Copyright (2013-2014), Franco Pestilli, Stanford University, pestillifranco@gmail.com.
0018 
0019 % Return the indices to the fibers removed from the connectome
0020 removedFibers = find(~fibersToKeep);
0021 
0022 if all(fibersToKeep==0)
0023     fe.life.Mfiber = sparse(size(fe.life.Mfiber,1),size(fe.life.Mfiber,2));
0024 else
0025     % Delete fibers' columns from the model
0026     fe.life.Mfiber = fe.life.Mfiber(:,fibersToKeep);
0027 end
0028 
0029 % Clear the fields that depend o the original fiber group. These are:
0030 % (1) The fit of the model.
0031 if isfield(fe.life,'fit') && ~isempty(fe.life.fit)
0032     fe.life.fit.weights         = fe.life.fit.weights(fibersToKeep);
0033     fe.life.fit.results.nParams = sum(fibersToKeep);
0034 end
0035 if isfield(fe.life,'voxfit') && ~isempty(fe.life.voxfit)
0036     fe.life.voxfit = [];
0037 end
0038 % The field 'fibers' containing some statistics obtained from the original
0039 % fg
0040 if isfield(fe.life,'fibers') && ~isempty(fe.life.fibers.tensors)
0041     fe.life.fibers.tensors = [];
0042     fe.life.fibers.total   = [];
0043     fe.life.fibers.unique  = [];
0044 end
0045 
0046 % The actual fiber group.
0047 if all(fibersToKeep==0)
0048     fe = feSet(fe,'fg img',fgCreate('all fibers were deleted',fe.fg.name,'img'));
0049 else
0050     % feExtract requires indices to each fibers and does not accept logical
0051     % inuts. Here we make sure we are passing indices not a logical vector.
0052     if (length(unique(fibersToKeep)) == 2)
0053         if   (all(unique(fibersToKeep) == [0, 1]'))
0054             fibersToKeep = find(fibersToKeep);end
0055     end
0056     fe = feSet(fe,'fg img',fgExtract(feGet(fe,'fibers img'),fibersToKeep,'keep'));
0057 end
0058 
0059 return
0060

Generated on Wed 16-Jul-2014 19:56:13 by m2html © 2005