Using SPIDER in Segmenting Volumes or Images


Segmentation is loosely defined as the separation and identification of areas/ objects of interest from an image or volume. This topic is discussed in detail in image processing texts such as: Russ's "The Image Processing Handbook, from CRC Press. SPIDER contains many operations which are useful in segmentation. I will not into any detail except to mention some SPIDER features which may differ from those found in other imaging packages or which are useful for investigating segmentation strategies.

There are many different strategies for segementation and I will only discuss some that we have found useful for segmenting electron tomographic and single particle reconstructions. Since electron tomographic volumes have a very low signal to noise ratio, anisotropic resolution, and artifacts from missing cone/wedges many conventional strategies are not useful.

Density Thresholding

Direct application of density thresholding is seldom useful in segementing electron tomograms or single particle reconstructions due to overlap of density among items of interest, variable staining in stained objects, and the anisotropic resolution in electron tomographic volumes. However it is often possible to utilize various imaging filters in either 3D or slice-by-slice to process a volume to a form that can be thresholded by density. SPIDER contains a rich variety of filters and operations which can be applied to a volume.

Denoising

In general we have found that denoising electron tomographs is a useful first step in segmentation. Anisotropic diffusion is usually the most effective method especially when dealing with membranous or filamentous structures. The anisotropic diffusion operation CE AD in SPIDER requires one or two input parameters depending upon the implementation requested. The settings for these parameters is somewhat sample dependent and determining appropriate parameter settings for Frangakis & Hegerl's implementation is somewhat difficult.

There is a procedure in this directory: cead_test.spi which can assist the user in determining denoising parameters. The procedure operates on a volume using a single relevant slice.

Example of using: cead_test.spi for denoising

Set input/output file name and parameters in the procedure: cead_test.spi

run the procedure using SPIDER:
spider spi/dat @cead_test

Output

 
 Size:       0840 x 0840 x 0130
 Windowed:   0200 x 0200 x 011
       At:   0260,  0040,   0060
 Avg:        126
  
 Iterations: 003    Times:      003
 Sigmas:     001    Lambdas:    001
 Tests:      009
  
 Output stack: cead_stk
 Output volume: cead_denoisedvol
  
 N: 004       Iter: 003  Time: .01  S: 3.0 L: 010
 N: 005   FC  Iter: 003  Time: .01  S: 3.0 L: 010
 N: 006   PS  Iter: 003  Time: .01  S: 3.0 L: 010
 N: 007       Iter: 003  Time: .07  S: 3.0 L: 010
 N: 008   FC  Iter: 003  Time: .07  S: 3.0 L: 010
 N: 009   PS  Iter: 003  Time: .07  S: 3.0 L: 010
 N: 010       Iter: 003  Time: .13  S: 3.0 L: 010
 N: 011   FC  Iter: 003  Time: .13  S: 3.0 L: 010
 N: 012   PS  Iter: 003  Time: .13  S: 3.0 L: 010
 N: 013       Iter: 013  Time: .01  S: 3.0 L: 010
 N: 014   FC  Iter: 013  Time: .01  S: 3.0 L: 010
 N: 015   PS  Iter: 013  Time: .01  S: 3.0 L: 010
 N: 016       Iter: 013  Time: .07  S: 3.0 L: 010
 N: 017   FC  Iter: 013  Time: .07  S: 3.0 L: 010
 N: 018   PS  Iter: 013  Time: .07  S: 3.0 L: 010
 N: 019       Iter: 013  Time: .13  S: 3.0 L: 010
 N: 020   FC  Iter: 013  Time: .13  S: 3.0 L: 010
 N: 021   PS  Iter: 013  Time: .13  S: 3.0 L: 010
 N: 022       Iter: 023  Time: .01  S: 3.0 L: 010
 N: 023   FC  Iter: 023  Time: .01  S: 3.0 L: 010
 N: 024   PS  Iter: 023  Time: .01  S: 3.0 L: 010
 N: 025       Iter: 023  Time: .07  S: 3.0 L: 010
 N: 026   FC  Iter: 023  Time: .07  S: 3.0 L: 010
 N: 027   PS  Iter: 023  Time: .07  S: 3.0 L: 010
 N: 028       Iter: 023  Time: .13  S: 3.0 L: 010
 N: 029   FC  Iter: 023  Time: .13  S: 3.0 L: 010
 N: 030   PS  Iter: 023  Time: .13  S: 3.0 L: 010
 Total Frames: 030
 Output montage: cead_montage
   

Use: Web or JWeb for displaying the results of denoising using the different parameter choices and choose the best parameters.

E.g: web dat &

Display: cead_stk.dat Denoised slice montage (output)
Display: cead_montage.dat Denoised slice montage (output)
Display: cead_denoisedvol.datDenoised volume (output)

Testing Segmentation Operations

It is often tedious to apply many segmentation operations/filters with their various required input parameters in order to determine whether a particular operation is of use for a particlular sample. There are two procedures in this directory which can assist the SPIDER user in this investigation.

seg_test.spi Operates on a window from the volume.
rib_seg.spi Operates on a whole volume.

Example of using: seg_test.spi to investigate some SPIDER operations which may be useful in segmentation

  spider spi/dat @seg_test 

  bzvol.dat          ; Input Volume                  
  260,40,66          ; Window location   
  13,.07             ; Denoising iterations & time

Sample output from segtest procedure showing the operations and the input parameters which are tested.

  Denoising Iter:013  Time:.07  S:3.0 L: 10
  
  N: 001 Original
  N: 002 CE AD Denoised Original
  N: 003 CE Median Radius: 003
  N: 004 CE Median Radius: 005
  N: 005 CE Median Radius: 007
  N: 006 CE GNC Lambda: 003
  N: 007 CE GNC Lambda: 005
  N: 008 CE GNC Lambda: 007
  N: 009 CE HI
  N: 010 CE LAH Radius: 03 Bins: 064
  N: 011 CE LAH Radius: 05 Bins: 064
  N: 012 CE LAH Radius: 07 Bins: 064
  N: 013 CE Haralick Radius: 09 Mode: 1 Off: 2
  N: 014 CE Haralick Radius: 09 Mode: 2 Off: 2
  N: 015 CE Haralick Radius: 09 Mode: 3 Off: 2
  N: 016 CE Haralick Radius: 09 Mode: 4 Off: 2
  N: 017 CE Haralick Radius: 09 Mode: 5 Off: 2
  N: 018 CE Haralick Radius: 09 Mode: 6 Off: 2
  N: 019 CE Haralick Radius: 15 Mode: 1 Off: 2
  N: 020 CE Haralick Radius: 15 Mode: 2 Off: 2
  N: 021 CE Haralick Radius: 15 Mode: 3 Off: 2
  N: 022 CE Haralick Radius: 15 Mode: 4 Off: 2
  N: 023 CE Haralick Radius: 15 Mode: 5 Off: 2
  N: 024 CE Haralick Radius: 15 Mode: 6 Off: 2
  N: 025 CE Haralick Radius: 11 Mode: 1 Off: 4
  N: 026 CE Haralick Radius: 11 Mode: 2 Off: 4
  N: 027 CE Haralick Radius: 11 Mode: 3 Off: 4
  N: 028 CE Haralick Radius: 11 Mode: 4 Off: 4
  N: 029 CE Haralick Radius: 11 Mode: 5 Off: 4
  N: 030 CE Haralick Radius: 11 Mode: 6 Off: 4
  N: 031 CE Haralick Radius: 17 Mode: 1 Off: 4
  N: 032 CE Haralick Radius: 17 Mode: 2 Off: 4
  N: 033 CE Haralick Radius: 17 Mode: 3 Off: 4
  N: 034 CE Haralick Radius: 17 Mode: 4 Off: 4
  N: 035 CE Haralick Radius: 17 Mode: 5 Off: 4
  N: 036 CE Haralick Radius: 17 Mode: 6 Off: 4
  N: 037 CE Hurst Radius: 003
  N: 038 CE Hurst Radius: 005
  N: 039 CE Hurst Radius: 007
  N: 040 CE Max Radius: 003
  N: 041 CE Max Radius: 005
  N: 042 CE Max Radius: 007
  N: 043 CE VAR Radius: 003
  N: 044 CE VAR Radius: 005
  N: 045 CE VAR Radius: 007
  N: 046 CE Range Radius: 003
  N: 047 CE Range Radius: 005
  N: 048 CE Range Radius: 007
  N: 049 CE Gradient
  N: 050 CE Laplacian Radius: 003
  N: 051 CE Laplacian Radius: 007
  N: 052 CE Laplacian Radius: 011
  N: 053 CE Sobel
  N: 054 CE Frei-Chen 
  N: 055 CE Prewitt
  N: 056 FC Levels: 04
  N: 057 ED Mode: 01 Thresh: 1
  N: 058 ED Mode: 02 Thresh: 1
  N: 059 ED Mode: 03 Thresh: 1
  N: 060 ED Mode: 04 Thresh: 1
  N: 061 ED Mode: 01 Thresh: 2
  N: 062 ED Mode: 02 Thresh: 2
  N: 063 ED Mode: 03 Thresh: 2
  N: 064 ED Mode: 04 Thresh: 2
  N: 065 ED Mode: 01 Thresh: 3
  N: 066 ED Mode: 02 Thresh: 3
  N: 067 ED Mode: 03 Thresh: 3
  N: 068 ED Mode: 04 Thresh: 3
  N: 069 CE Watershed
  N: 070 ER WA
  N: 071 CE Ridge
  N: 072 ER EDM Level: 100
  N: 073 CE TopHat Radius: 005
  N: 074 CE TopHat Radius: 007
  N: 075 CE TopHat Radius: 009
  N: 076 CE TopHat Radius: 011
  N: 077 CE TopHat Radius: 013
  Total Frames: 077
  Montage in: seg_montage.dat

Use: Web or JWeb for displaying the results of segmentation using different operation and parameter choices and study the best strategy.

E.g: web dat &

Display: seg_stk.dat Filtered slices in a stack
Display: seg_montage.datFiltered slices in a montage

Extracting "Connected" Voxel Clusters from a Volume

There is a set of operations in SPIDER that are useful in extracting connected voxel clusters from a volume. The clusters are connected in the sense that their voxel;s density is above some threshold and they are contiguous (in 6 directional space) with other such voxels. Thus they are the equivalent of islands in the volume.

EC CL
Segments a volume that contains two or more unconnected objects of the same intensity. The resulting volume can be used for masking or with other 'EC' operations. 'EC CL' works by reading a SPIDER 3D image file and a threshold level. It locates connected clusters of voxels that are above the threshold. Each cluster is given a number. A new 3D image file is created that contains a cluster number for each object voxel or zero for background voxels. Connectivity is six fold here (left, right , up, down, above, & below).
EC STAT
occurances of each integral intensity in a SPIDER 3D file as well as center mass of each intensity value. Creates a SPIDER document file for statistics output containing intensity value; number of voxels with this intensity; This operation is normally used on the output volume from the 'EC' operation. It is meaningless with volumes having negative or non-integral voxel values.
EC SELECT
Reads a SPIDER document file for mapping an image file into a new image file. The document file contains X, Y, and Z locations of a voxel in the image file. All voxels in the file having the cluster number found at this location are transferred into a new file. All other voxels are set to zero.
EC CLOSE
Merges neighboring clusters of voxels in a 3D volume into a single "object" or lower hierarchical-level cluster. Reads a SPIDER document file containing cluster centers of mass. Determines distances between all clusters. If the distance between two clusters is less than the solicited threshold, it sets higher-numbered cluster voxels to the same number as the lower-numbered cluster.
EC FILTER
Reads a SPIDER document file containing cluster number (index) and number of voxels (register:1) in the cluster. If the number of voxels < solicited minimum number or > solicited maximum number, then the voxels belonging to this cluster are set to value zero.

Cluster Extraction Usage Example

  eccl.spi
   
[thresh] = 210 ;  Threshold density
   
FS ;  File Statistics
vol001 ;  (input)
   
AR SCA ;  Scale densities 0...255
vol001 ;  Raw volume (input)
vol002 ;  Scaled volume (output)
0 255 ;  Scaling range
   
FS ;  File Statistics
vol002 ;  Scaled volume (input)
   
EC CL ;  Cluster extraction
vol002 ;  Scaled volume (input)
1-130 ;  Slices
[thresh] ;  Threshold
vol_eccl ;  Cluster file (output)
   
EC STAT;  Cluster statistics
vol_eccl ;  Cluster file (input)
doc_eccl ;  Cluster statistics file (output)
   
EC CLOSE ;  Merge close clusters
doc_eccl ;  Cluster statistics file
10,2 ;  Cluster distance threshold & starting cluster
vol_eccl ;  Cluster file (input)
vol_eccl_close ;  Merged cluster file (output)
   
EC FILTER ;  Filter out small/large clusters
doc_eccl ;  Cluster statistics file
vol_eccl ;  Cluster file (input)
vol_eccl_filt ;  Cluster file (output)
10 1000000 ;  Retained sizes
   
EC STAT ;  Cluster statistics
vol_eccl_filt ;  Cluster file (input)
doc_eccl_filt ;  Cluster statistics file (output)
   
TH M ;  Create mask based on threshold
vol_eccl_filt ;  Cluster file (input)
vol_eccl_filt_th ;  Mask file (output)
B ;  Mask gets 1's wherever pixel values exceed threshold, 0's elsewhere.
1.9 ;  Mask threshold
   
CP ;  Copy
vol002 ;  Source file (input)
vol_eccl_masked ;  Masked file (output)
   
FS ;  File statistics
vol_eccl_masked ;  Masked file (output)
   
MM ;  Mask multiplication
vol_eccl_filt_th ;  Mask file (input)
vol_eccl_masked ;  Masked file (output)
0 ;  Background
   
FS
vol_eccl_masked ;  Masked file (output)
   
EC SELECT ;  Save clusters at selected locations


Source: segment.html     Last update: 27 Dec. 2017     ArDean Leith