| ifcb_psd | R Documentation |
This function generates and saves data about a dataset's Particle Size Distribution (PSD) from Imaging FlowCytobot (IFCB) feature and hdr files, which can be used for data quality assurance and quality control.
ifcb_psd(
feature_folder,
hdr_folder,
bins = NULL,
save_data = FALSE,
output_file = NULL,
plot_folder = NULL,
use_marker = FALSE,
start_fit = 10,
r_sqr = 0.5,
beads = NULL,
bubbles = NULL,
incomplete = NULL,
missing_cells = NULL,
biomass = NULL,
bloom = NULL,
humidity = NULL,
micron_factor = 1/3.4,
fea_v = 2,
use_plot_subfolders = TRUE,
...
)
The PSD function originates from the PSD Python repository (Hayashi et al. 2025),
which can be found at https://github.com/kudelalab/PSD.
Python must be installed to use this function. The required Python packages can be
installed in a virtual environment using ifcb_py_install().
A list containing three tibbles:
A tibble with flattened PSD data for each sample.
A tibble containing curve fit parameters for each sample.
A tibble of flags for each sample, or NULL if no flags are found.
The save_data parameter only controls whether CSV files are written to disk; the
function always returns this list.
The PSD is built from one feature, EquivDiameter, converted to microns with
micron_factor and binned into 1 micron bins. The fitted curve, max_ESD_diff
and every flag derived from them all follow from that single distribution.
EquivDiameter is not directly comparable between feature set versions. The
version 4 extractor (ifcb-features, see ifcb_extract_features()) segments a
tighter blob boundary than the version 2 MATLAB extractor (ifcb-analysis), so
it reports a smaller equivalent diameter for the same image. The difference is
roughly a fixed number of pixels rather than a fixed proportion. It therefore
converts to microns through micron_factor, and moves the whole ESD histogram
towards smaller bins by about that many microns. Small particles lose a larger
share of their diameter than large ones.
The thresholds published by Hayashi et al. (2025) were calibrated on version 2 features and do not carry over unchanged:
start_fit selects a histogram bin. When the distribution moves, the fit
window sits at a different position relative to the peak, which changes the
fitted exponent as well as the multiplier. The r_sqr and beads flags read
those two values.
bloom and bubbles are evaluated against max_ESD_diff, which is
measured relative to start_fit. They move with the shifted distribution, and
again with any compensating change to start_fit.
biomass and incomplete depend on the height of the most populated bin,
which changes as the shift moves targets between bins.
With a version other than 2, measure the offset on your own data instead of
assuming a published value: extract both feature versions for a set of
representative bins, compare EquivDiameter per ROI, and lower start_fit by the
median difference in whole microns. Re-derive the flag thresholds on that basis,
and report the feature version together with any quality flags you publish.
micron_factor sets what the offset amounts to in microns, so an instrument with
a different pixel size needs its own value.
The file name is the only other place the version is used: features are read as
<bin>_fea_v<fea_v>.csv. ifcb_extract_features() writes <bin>_features_v4.csv
by default, so pass feature_tag = "fea" there to get the names this function
searches for.
Hayashi, K., Enslein, J., Lie, A., Smith, J., Kudela, R.M., 2025. Using particle size distribution (PSD) to automate imaging flow cytobot (IFCB) data quality in coastal California, USA. International Society for the Study of Harmful Algae. https://doi.org/10.15027/0002041270
ifcb_py_install, ifcb_extract_features,
https://github.com/kudelalab/PSD
## Not run:
# Initialize the Python session if not already set up
ifcb_py_install()
ifcb_psd(
feature_folder = 'path/to/features',
hdr_folder = 'path/to/hdr_data',
bins = c("D20211021T133007_IFCB134", "D20211021T140753_IFCB134"),
save_data = TRUE,
output_file = 'psd/svea_2021',
plot_folder = 'psd/plots',
use_marker = FALSE,
start_fit = 13,
r_sqr = 0.5,
beads = 10 ** 9,
bubbles = 150,
incomplete = c(1500, 3),
missing_cells = 0.7,
biomass = 1000,
bloom = 5,
humidity = NULL,
micron_factor = 1/2.77,
fea_v = 2
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.