WrightTools.data.Channel.trim

Channel.trim(neighborhood, method='ztest', factor=3, replace='nan', verbose=True)[source]

Remove outliers from the dataset.

Identifies outliers by comparing each point to its neighbors using a statistical test.

Parameters:
  • neighborhood (list of integers) – Size of the neighborhood in each dimension. Length of the list must be equal to the dimensionality of the channel.
  • method ({'ztest'} (optional)) –

    Statistical test used to detect outliers. Default is ztest.

    ztest
    Compare point deviation from neighborhood mean to neighborhood standard deviation.
  • factor (number (optional)) – Tolerance factor. Default is 3.
  • replace ({'nan', 'mean', number} (optional)) –

    Behavior of outlier replacement. Default is nan.

    nan
    Outliers are replaced by numpy nans.
    mean
    Outliers are replaced by the mean of its neighborhood.
    number
    Array becomes given number.
Returns:

Indicies of trimmed outliers.

Return type:

list of tuples

See also

clip()
Remove pixels outside of a certain range.