fuzzy_cmeans

nighres.segmentation.fuzzy_cmeans(image, clusters=3, max_iterations=50, max_difference=0.01, smoothing=0.1, fuzziness=2.0, mask_zero=True, map_intensity=False, save_data=False, overwrite=False, output_dir=None, file_name=None)[source]

Fuzzy C-means image segmentation

Estimates intensity clusters with spatial smoothness and partial voluming. Based on the RFCM algorithm of (Pham, 2001) [1].

Parameters:
  • image (niimg) – Input image to segment
  • clusters (int) – Number of clusters to estimate (default is 3)
  • max_iterations (int) – Maximum number of iterations to perform (default is 50)
  • max_difference (float) – Maximum difference between steps for stopping (default is 0.01)
  • smoothing (float) – Ratio of spatial smoothness to impose on the clusters (default is 0.1)
  • fuzziness (float) – Scaling of the C-means measure, in [1.0 - 3.0] (default is 2.0)
  • mask_zero (bool) – Whether to ignore zero values (default is True)
  • maP-intensity (bool) – Whether to compute a centroid-based intensity image (default is False)
  • save_data (bool) – Save output data to file (default is False)
  • overwrite (bool) – Overwrite existing results (default is False)
  • output_dir (str, optional) – Path to desired output directory, will be created if it doesn’t exist
  • file_name (str, optional) – Desired base name for output files with file extension (suffixes will be added)
Returns:

Dictionary collecting outputs under the following keys (suffix of output files in brackets)

  • memberships [niimg]: List of membership functions for each cluster in [0,1] (_rfcm-mem#cluster)
  • classification (niimg): Hard classification of most likely cluster per voxel (_rfcm-class)
  • intensity (niimg): Centroid-based intensity map, if created (_rfcm-map)

Return type:

dict

Notes

Original Java module by Pierre-Louis Bazin.

References

[1]D.L. Pham, Spatial Models for Fuzzy Clustering, CVIU, vol. 84, pp. 285–297, 2001