Matlab Help Index Technical Documentation Index

thresholdStatMap

NAME ^

thresholdStatMap - threshold a statistical map

SYNOPSIS ^

function thresholdMap = thresholdStatMap(flag, statMap, threshold, signed)

DESCRIPTION ^

 thresholdStatMap - threshold a statistical map

 Usage: thresholdMap = thresholdStatMap(flag, statMap, threshold, signed)

 Thresholds an input stat map for use in creating an ROI.
 flag is any valid fsfast stat map (currently, only implimented
 for 'sig' and 't').  statMap is the
 stat map in the form numSlices by x by y.  Threshold is a number to
 threshold the stat map, which will be different for different types
 of stat maps.  Finally, signed says whether or not the thresholding 
 should be done in a signed or unsigned way (i.e., with actual values
 vs. absolute values).  Returns the threshold map with 1s in the thresholded
 voxels and 0s otherwise.

 This function is part of froi, available from http://froi.sourceforge.net,
 and is governed under the terms of the Artistic License.

 $Id: thresholdStatMap.m,v 1.5 2003/09/23 15:38:19 nknouf Exp $

CROSS-REFERENCE INFORMATION ^

This function calls:

This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function thresholdMap = thresholdStatMap(flag, statMap, threshold, signed)
0002 % thresholdStatMap - threshold a statistical map
0003 %
0004 % Usage: thresholdMap = thresholdStatMap(flag, statMap, threshold, signed)
0005 %
0006 % Thresholds an input stat map for use in creating an ROI.
0007 % flag is any valid fsfast stat map (currently, only implimented
0008 % for 'sig' and 't').  statMap is the
0009 % stat map in the form numSlices by x by y.  Threshold is a number to
0010 % threshold the stat map, which will be different for different types
0011 % of stat maps.  Finally, signed says whether or not the thresholding
0012 % should be done in a signed or unsigned way (i.e., with actual values
0013 % vs. absolute values).  Returns the threshold map with 1s in the thresholded
0014 % voxels and 0s otherwise.
0015 %
0016 % This function is part of froi, available from http://froi.sourceforge.net,
0017 % and is governed under the terms of the Artistic License.
0018 %
0019 % $Id: thresholdStatMap.m,v 1.5 2003/09/23 15:38:19 nknouf Exp $
0020 
0021 
0022 %% the default is for the threshold to be signed
0023 if (nargin < 4)
0024     signed = 1;
0025 end
0026 
0027 %% create basic structure to hold data
0028 stat.statMap = statMap;
0029 stat.threshold = threshold;
0030 stat.signed = signed;
0031 
0032 %% statMap is a three element vector (numSlices by x by y)
0033 [stat.slices, stat.xsize, stat.ysize] = size(stat.statMap);
0034 
0035 %% create an empty thresholdMap the same size as the input stat map
0036 thresholdMap = zeros(stat.slices, stat.xsize, stat.ysize);
0037 
0038 %% run different thresholding code depending on the input flag
0039 switch (flag)
0040     case {'-sig'},
0041         thresholdMap = threshTVolume(stat);
0042     case {'-t'},
0043         thresholdMap = threshTVolume(stat);
0044 end
0045 
0046 %% thresholding for t maps
0047 function thresholdMap = threshTVolume(stat)
0048     %% if signed, we only want to take positive tails
0049     %% (need to change this for the case when the threshold
0050     %% is negative; code below has not been tested for that
0051     %% case)
0052     if (stat.signed)
0053         if (stat.threshold > 0)
0054             thresholdMap = stat.statMap > stat.threshold;
0055         else
0056             thresholdMap = stat.statMap < stat.threshold;
0057         end
0058     %% if it's not signed, take all data
0059     else
0060         thresholdMap = abs(stat.statMap) > abs(stat.threshold);
0061     end
0062 
0063     %% check and see if we have anything in the resulting map
0064     if(isempty(find(thresholdMap==1)))
0065         oops(250);
0066     end
0067 return;
0068 
0069 %% compute the matrix intersection
0070 function intersection = computeIntersection(A, B)
0071     if (size(A) ~= size(B))
0072         %%error('Size of A is not the same as size of B');
0073         oops(950);
0074     end
0075 
0076     [numRows, numCols] = size(A);
0077     intersection = zeros(numRows, numCols);
0078 
0079     for i=1:numRows
0080         for j=1:numCols
0081             if (A(i,j) == B(i,j))
0082                 intersection(i,j) = A(i,j);
0083             end
0084         end
0085     end
0086 return;

Generated at 19:47:41 15-Oct-2003 by m2html © 2003