Undocumented
Function | get |
value = prob_median_transform_func(value) |
Function | pixel |
Finds a mask for an image based on values in 'test'. |
Function | plot |
Undocumented |
Function | ssa2d |
Average standard deviation of a pixel from a region size around it. Same as ssa2d_sum_prob_map but a bit more efficient (less customisable). |
Function | ssa2d |
Computes a bad pixel map from an SSA2D object. Concentrates on hot/cold pixels w.r.t background. |
Variable | _lgr |
Undocumented |
- if 'median_prob' in transform_value_as:
- value = prob_median_transform_func(value)
- if 'ppf' in transform_value_as:
- cutoff_func = lambda _test, _value: EmpiricalDistribution(_test.ravel()).ppf(_value)
- else:
- cutoff_func = lambda _test, _value: _value
np.ndarray
:
¶
Finds a mask for an image based on values in 'test'.
- # ARGUMENTS #
- img : np.ndarray([:,:], type.T1)
- image to construct mask for (not actually used in calculation, but used in plotting)
- test : np.ndarray([:,:], type.T2)
- Array that cutoff will be applied to to find mask
- value : type.T3
- Value to calculate cutoff from using 'cutoff_func'
- show_plots : bool
- If True, will plot results of mapping.
- plot_kw : dict
Dictionary to pass optional arguments to plots. { 'suptitle' : str
A string to display as the super-title of the plotted figure
}
- cutoff_func : Callable[np.ndarray([:,:],type.T2), type.T3] -> type.T4
= lambda _t, _v: ut.sp.construct_ppf_from(_t.ravel())(_v)
A function that calculates the cutoff from 'value'. The cutoff is used to detemine the mask.
- bp_mask_func : Callable[np.ndarray([:,:],type.T2), type.T4] -> np.ndarray([:,:],bool)
= lambda _t, _c: _t > _c
A function that calculates the mask from the test and cutoff (cutoff is calculated from 'cutoff_func')
- # RETURNS #
- mask : np.ndarray([:,:],bool)
- A boolean array that can be used to mask 'img'
Average standard deviation of a pixel from a region size
around it.
Same as ssa2d_sum_prob_map
but a bit more efficient (less customisable).
Literal[ 'prob_frac_from_median'] | Literal[ 'n_std_dev_from_median']
= 'n_std_dev_from_median', show_plots=0, transform_value_as: list[ Literal[ 'median_prob', 'ppf']]
= [Computes a bad pixel map from an SSA2D object. Concentrates on hot/cold pixels w.r.t background.
Idea is that for a hot/cold pixel, the high frequency components of the SSA decomposition must also be hot/cold. Therefore, the hot/cold pixels will consistently be at the edges of the pixel probability distribution for the higher frequency SSA components. As high frequency SSA components outnumber low frequency SSA components, we can just use all components as long as we don't weight them by their eigenvalues (if we do, we should try and be selective to only the components where the scale of changes matches the scale of the hot/cold pixels).
For each component of the SSA decomposition, a map is made of how far a given pixel deviates from the median (range [-1,1]). The median differences for each component are combined together (by mean or weighted mean) to give a 'score' for each pixel. Bad pixels should have scores at the extreme ends of the [-1,1] range. A bad pixel map is chosen by taking the absolute value of the score, and selecting all pixels whose |score| is larger than a give value.
- # ARGUMENTS #
- ssa
- An SSA2D object
- start
- The first SSA component to include in the probability map
- stop
- The last SSA component to include in the probability map. If None, then will include as many SSA components as are present
- value
- A float that describes the quantile that denotes a 'bad pixel'
- strategy : 'prob_frac_from_median' | 'n_std_dev_from_median'
- How should we define an 'improbable' pixel?
- 'prob_frac_from_median'
- Fraction of probability space a pixel is away from the median value
- 'n_std_dev_from_median'
- Number of standard deviations a pixel is away from the median value
- show_plots
- 0 = do not show plots 1 = show some plots 2 = show interim plots
- transform_value_as
List of literal strings that tells us how to tranform the "value" argument after which it is used as the cutoff for a bad pixel. If no options are given, "value" is used as the cutoff directly, i.e., if "value" is 0.99, then only pixels which have a median probability > 0.99 are classified as "bad pixels".
- Options are:
- "identity"
- Use the value as-is, do not transform it
- "median_prob"
- Transform "value" using the same function that we use to change cumulative probabilities of pixels into probability a pixel is a certain distance from the median.
- "ppf"
- Transform "value" so that the cutoff is the percentage point function of the pixel median probabilities. I.e. if "value" is 0.9, then the cutoff will be set such that 10% of the pixels will be classified as "bad pixels"
- weight_by_evals
- If True, will weight each SSA component pixel probability by the component's eigenvalue when averaging into a combined score.
- # RETURNS #
- bp_mask
- A bad pixel mask. Pixels to reject are coded as True.