NISTHRESH(1) NIS 3.4 September 8, 2000 NAME nisthresh - remove the image background by automatic thresholding SYNOPSYS nisthresh [-hvzn] [-g greys] [-l length] [-p position] [-c cut] [-s search] [-t thresholds] [-d outdir] [-o outstem] [-f filelist] DESCRIPTION This program is designed to remove the background on a brain fMRI image. It computes an intensity (or grey level) threshold below which all voxels are considered to be part of the background, and consequently set to 0. The choice of the threshold is performed by analyzing the grey level histogram of the image. This assumes that this histogram has a certain shape. It must exhibit two peaks. The primary peak--the highest one--is located in the low grey levels: it represents the background; and the secondary in the high grey levels: it represents the brain. The threshold will be chosen somewhere between these two peaks, as described below in a step by step description of the algorithm. See the HTML man page for a more graphical description of the algorithm. 1. Compute the histogram of the image. The histogram is the curve associated with a grey-level image that shows the number of pixels in the image which have a certain grey level. . We don't consider pixels with grey level 0 because they are useless in the algorithm. You can choose the number of grey levels you want per histogram bin by specifying the variable greys with option '-g'. It has to be a positive integer. For example, if you put 3, the first point of the histogram will be the number of pixels which have grey level 1, 2 and 3, the second point will be the number of pixels which have grey levels 4, 5 and 6.The default is 2 for this option. 2. Smooth the histogram The next step consists in smoothing the resulting curve so that the histogram is easier to process. This is controlled by option '-l', which allows the user to specify the half length for the smoothing. This must be a positive integer, named length. For each point of the histogram, we compute the mean in a window of length 2*length+1 centered on the current point. The result is the smoothed histogram (which will be called 'histogram' in what follows). The default for this option is 5. 3. Search for the primary peak The primary peak is simply given by the absolute maximum of the histogram. Its position is named pos_max1. 4. Search for the secondary peak Then we look for the secondary peak. We find it by computing the maximum of a sub-part of the histogram, beginning a "certain amount away" from pos_max1. The starting point pos_start of the search is defined by the equation search = (pos_start - pos_max1) / (max_grey - pos_max1), where search is a floating point number between 0 and 1 specified by the option '-s'. The default value for this option is 0.2. We get through this operation the position pos_max2 and value val_max2 of the secondary peak. 5. Search for the minimum between the two peaks This operation is straightforward: pos_min is the position of the minimum value, then denoted as val_min, of the histogram between pos_max1 and pos_max2. 6. Find the limits of the range where we will choose the threshold We define a cut value val_cut (a horizontal line on the histogram) by the equation cut = (val_cut - val_min) / (val_max2 - val_min), where cut is a floating point number between 0 and 1 specified by the option '-c'. The default value for this option is 0.3. We now consider the intersecting points between this horizontal line at value val_cut and the histogram curve. And we define min_range as being the lowest position of these points above pos_max1, and max_range as being the highest position of these points below pos_max2. 7. Choose the threshold We now choose the position of the threshold pos_thresh between min_range and max_range according to the value position of the option '-p', which is a floating point value between 0 and 1, defined by the equation position = (pos_thresh - min_range) / (max_range - min_range). The default value for this option is 0.5 (middle of the range). OPTIONS -h help: print this usage statement -v verbose mode (to see the threshold value computed by the algorithm) -z compress output -g greys number of grey levels per histogram bin (default: 2) -l length half-length of the histogram smoothing (0: no smoothing; default: 5) -s search define where to search for the second peak (default: 0.2) -c cut define how to find the threshold range(default: 0.3) -p position position of the threshold (default: 0.5, middle of the range) -t thresholds name of the file where the thresholds values are written (default: none) -n no output: the thresholded images are not written to disk -d outdir output directory (default: ./) -o outstem output stem (default: prepend a 't' to image name) -f filelist file with filenames to be thresholded ARGUMENTS inputfile input image filename (w/complete path if not ./) You have to specify an inputfile or a filelist. If both are given, the inputfile will be added at the beginning of the filelist. EXAMPLES To remove the background of an image in ANALYZE format named "func" (which consists in two files "func.hdr" and "func.img") using all the default values of the algorithm: nisthresh -v func This will create a thresholded image in ANALYZE format named "func_t" (with two files "func_t.hdr" and "func_t.img") and display the value of the threshold used. To study the stability of the thresholding process through a set of images listed in the file "image_list.txt" by writing the computed thresholds values to a file "thresholds.txt", without writing the thresholded images themselves: nisthresh -t thresholds.txt -f image_list.txt -n NOTES Written by Sylvain Takerkart at Princeton University's CSBMB.