This function reads a specified variable from a .mat file generated by the ifcb-analysis repository (Sosik and Olson 2007).
It can be used, for example, to extract lists of classes from the file.
Arguments
- mat_file
A character string specifying the path to the
.matfile containing the class information.- variable_name
A character string specifying the variable name in the
.matfile that contains the class information. The default is "class2use". Other examples include "class2use_manual" from a manual file, or "class2use_auto" for a class list used for automatic assignment. You can find available variable names using the functionifcb_get_mat_names.- use_python
Logical. If
TRUE, attempts to read the.matfile using a Python-based method. Default isFALSE.
Details
If use_python = TRUE, the function tries to read the .mat file using ifcb_read_mat(), which relies on SciPy.
This approach may be faster than the default approach using R.matlab::readMat(), especially for large .mat files.
To enable this functionality, ensure Python is properly configured with the required dependencies.
You can initialize the Python environment and install necessary packages using ifcb_py_install().
If use_python = FALSE or if SciPy is not available, the function falls back to using R.matlab::readMat().
References
Sosik, H. M. and Olson, R. J. (2007), Automated taxonomic classification of phytoplankton sampled with imaging-in-flow cytometry. Limnol. Oceanogr: Methods 5, 204–216.
Examples
# \donttest{
# Example .mat file included in the package
mat_file <- system.file("exdata/example.mat", package = "iRfcb")
# Get class names from a class2use file
classifier_name <- ifcb_get_mat_variable(mat_file, "classifierName")
print(classifier_name)
#> [,1]
#> [1,] "Z:\\data\\manual\\Skagerrak-Kattegat\\summary\\results_21May202421May2024"
# Get class names from a classifier file
class2useTB <- ifcb_get_mat_variable(mat_file, "class2useTB")
print(class2useTB)
#> [1] "Cerataulina_pelagica" "Chaetoceros_cf_convolutus"
#> [3] "Chaetoceros_chain" "Chaetoceros_danicus"
#> [5] "Chaetoceros_single_cell" "Ciliates"
#> [7] "Cryptomonadales" "Cylindrotheca_Nitzschia_longissima"
#> [9] "Dactyliosolen_fragilissimus" "Dino_larger_than_30unidentified"
#> [11] "Dino_smaller_than_30unidentified" "Ditylum_brightwellii"
#> [13] "Enisiculifera_carinata" "Guinardia_delicatula"
#> [15] "Gymnodiniales_smaller_than_30" "Heterocapsa_rotundata"
#> [17] "Katodinium-like" "Leptocylindrus_danicus"
#> [19] "Leptocylindrus_danicus_minimus" "Mesodinium_rubrum"
#> [21] "Octactis_speculum" "Prorocentrum_micans"
#> [23] "Prorocentrum_triestinum" "Pseudo-nitzschia_spp"
#> [25] "Pseudosolenia_calcar-avis" "Rhizosolenia_setigera"
#> [27] "Scrippsiella_group" "Skeletonema_marinoi"
#> [29] "Strombidium_like" "Thalassionema_nitzschioides"
#> [31] "Thalassiosira_gravida" "Thalassiosira_nordenskioeldii"
#> [33] "Thalassiosira_punctigera" "Thalassiosira_spp"
#> [35] "Torodinium_robustum" "Tripos_lineatus"
#> [37] "unclassified"
# }
