Datasets with missing frames cause various problems in subsequent processing
During conversion of Merlin data using the fpd_file.MerlinBinary
class, fpd allows the data to be processed if there are missing frames at the end of the dataset. This behavior is helpful since it permits the conversion to continue and note interrupted due to one or two missing frames at the end of the dataset. However, the presence of empty frames causes issues during subsequent processing.
For example, in calculating the center of mass, the statistical output becomes unhelpful if a single frames is empty:
com_yx = fpd.fpd_processing.center_of_mass(ds, thr=100)
Statistics y x m
----------------------------------------
Mean : nan nan nan
Min : nan nan nan
Max : nan nan nan
Std : nan nan nan
Range : nan nan nan
This is simply a cosmetic issue and could be corrected by ignoring the nans when calculating the statistical values. The software should probably return a warning of some kind that nans were returned during the measurement as well.
The empty frames also prevent the use of the Otsu thresholding option in the center of mass measurement entirely. The following code fails with a ValueError because the Otsu thresholding application is expecting each frame to contain at least two grayscale values:
com_yx = fpd.fpd_processing.center_of_mass(ds, thr='otsu')
ValueError: threshold_otsu is expected to work with images having more than one color. The input image seems to have just one color 0.
In this case, it might be best to check whether any frames contain only zeros or any other single value and simply assign that value as the threshold rather than calculating it via skimage.filters.threshold_otsu
.
There are probably more examples of problems caused by the empty frames, but these are the ones I have identified thus far.