From 786df8de81b198423a3f553380064d728d7855b2 Mon Sep 17 00:00:00 2001 From: Andriy Date: Fri, 20 Oct 2023 10:32:24 -0400 Subject: [PATCH] unified column name, customizable output fname --- src/nyx/environment.cpp | 15 +++++++++++++-- src/nyx/environment.h | 11 ++++++----- src/nyx/output_2_csv.cpp | 4 ++-- src/nyx/python/new_bindings_py.cpp | 8 ++++---- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/nyx/environment.cpp b/src/nyx/environment.cpp index 7519a462..7ae3e02b 100644 --- a/src/nyx/environment.cpp +++ b/src/nyx/environment.cpp @@ -166,7 +166,7 @@ void Environment::show_cmdline_help() << "\t\t\tExample: " << FILEPATTERN << "=.* for all files, " << FILEPATTERN << "=*.tif for .tif files \n" << "\t\t" << OUTPUTTYPE << "= \n" << "\t\t\tDefault: separatecsv \n" - << "\t\t" << SEGDIR << "= \n" + << "\t\t" << SEGDIR << "= \n" << "\t\t" << INTDIR << "= \n" << "\t\t" << OUTDIR << "= \n" << "\t\t" << OPT << FEATURES << "= \n" @@ -201,7 +201,10 @@ void Environment::show_cmdline_help() << "\t\t" << OPT << SKIPROI << "= \n" << "\t\t\tDefault: void blacklist \n" << "\t\t\tExample 1: " << SKIPROI << "=34,35,36 \n" - << "\t\t\tExample 2: " << SKIPROI << "=image1.ome.tif:34,35,36;image2.ome.tif:42,43 \n"; + << "\t\t\tExample 2: " << SKIPROI << "=image1.ome.tif:34,35,36;image2.ome.tif:42,43 \n" + << "\t\t" << OPT << RESULTFNAME << "= \n" + << "\t\t\tDefault: NyxusFeatures \n" + << "\t\t\tExample: " << RESULTFNAME << "=training_set_features"; #ifdef CHECKTIMING std::cout << "\t\t" << OPT << EXCLUSIVETIMING << "= \n" @@ -751,6 +754,7 @@ bool Environment::parse_cmdline(int argc, char **argv) || find_string_argument(i, NESTEDROI_PARENT_CHNL, nestedOptions.rawParentChannelNo) || find_string_argument(i, NESTEDROI_CHILD_CHNL, nestedOptions.rawChildChannelNo) || find_string_argument(i, NESTEDROI_AGGREGATION_METHOD, nestedOptions.rawAggregationMethod) + || find_string_argument(i, RESULTFNAME, nyxus_result_fname) #ifdef CHECKTIMING || find_string_argument(i, EXCLUSIVETIMING, rawExclusiveTiming) @@ -826,6 +830,13 @@ bool Environment::parse_cmdline(int argc, char **argv) rawFeatures = FEA_NICK_ALL; } + //==== Parse optional result file name + if (nyxus_result_fname == "") + { + std::cout << "Error: void argument " << RESULTFNAME << "\n"; + return false; + } + //==== Output type #ifdef USE_ARROW VERBOSLVL1(std::cout << "\n*-*-*-*- Using Apache output -*-*-*-*\n"); diff --git a/src/nyx/environment.h b/src/nyx/environment.h index a1d0f958..b7cb0fa5 100644 --- a/src/nyx/environment.h +++ b/src/nyx/environment.h @@ -40,7 +40,7 @@ #define TEMPDIR "--tempDir" // Optional. Used in processing non-trivial features. Default - system temp directory #define IBSICOMPLIANCE "--ibsi" // skip binning for grey level and grey tone features #define SKIPROI "--skiproi" // Optional. Skip ROIs having specified labels. Sybtax: --skiproi - +#define RESULTFNAME "--resultFname" // Environment :: nyxus_result_fname #ifdef CHECKTIMING #define EXCLUSIVETIMING "--exclusivetiming" @@ -110,10 +110,11 @@ class Environment: public BasicEnvironment void show_summary(const std::string &head, const std::string &tail); std::string labels_dir = "", - intensity_dir = "", - output_dir = "", - intSegMapDir = "", - intSegMapFile = ""; + intensity_dir = "", + output_dir = "", + intSegMapDir = "", + intSegMapFile = ""; + std::string nyxus_result_fname = "NyxusFeatures"; // Default file name without extension ".csv", ".arrow", etc bool singleROI = false; // is set to 'true' parse_cmdline() if labels_dir==intensity_dir diff --git a/src/nyx/output_2_csv.cpp b/src/nyx/output_2_csv.cpp index bae4742f..95f5c3a6 100644 --- a/src/nyx/output_2_csv.cpp +++ b/src/nyx/output_2_csv.cpp @@ -178,12 +178,12 @@ namespace Nyxus } else { - retval = theEnvironment.output_dir + "/" + "NyxusFeatures.csv"; + retval = theEnvironment.output_dir + "/" + theEnvironment.nyxus_result_fname + ".csv"; } return retval; } - const std::vector mandatory_output_columns {"intensity_image", "segmentation_image", "ROI_label"}; + const std::vector mandatory_output_columns {"intensity_image", "mask_image", "ROI_label"}; // Saves the result of image scanning and feature calculation. Must be called after the reduction phase. bool save_features_2_csv (const std::string & intFpath, const std::string & segFpath, const std::string & outputDir) diff --git a/src/nyx/python/new_bindings_py.cpp b/src/nyx/python/new_bindings_py.cpp index 3c99add7..649f5123 100644 --- a/src/nyx/python/new_bindings_py.cpp +++ b/src/nyx/python/new_bindings_py.cpp @@ -287,7 +287,7 @@ py::tuple featurize_montage_imp ( } - std::string path = output_dir + "NyxusFeatures."; + std::string path = output_dir + theEnvironment.nyxus_result_fname + "."; return py::make_tuple(error_message, path); } @@ -312,9 +312,9 @@ py::tuple featurize_fname_lists_imp (const py::list& int_fnames, const py::list if (intensFiles.size() == 0) throw std::runtime_error("Intensity file list is blank"); if (labelFiles.size() == 0) - throw std::runtime_error("Segmentation file list is blank"); + throw std::runtime_error("Segmentation mask file list is blank"); if (intensFiles.size() != labelFiles.size()) - throw std::runtime_error("Imbalanced intensity and segmentation file lists"); + throw std::runtime_error("Imbalanced intensity and segmentation mask file lists"); for (auto i = 0; i < intensFiles.size(); i++) { const std::string& i_fname = intensFiles[i]; @@ -588,7 +588,7 @@ PYBIND11_MODULE(backend, m) m.def("featurize_directory_imp", &featurize_directory_imp, "Calculate features of images defined by intensity and mask image collection directories"); m.def("featurize_montage_imp", &featurize_montage_imp, "Calculate features of images defined by intensity and mask image collection directories"); m.def("featurize_fname_lists_imp", &featurize_fname_lists_imp, "Calculate features of intensity-mask image pairs defined by lists of image file names"); - m.def("findrelations_imp", &findrelations_imp, "Find relations in segmentation images"); + m.def("findrelations_imp", &findrelations_imp, "Find relations in segmentation mask images"); m.def("gpu_available", &Environment::gpu_is_available, "Check if CUDA gpu is available"); m.def("use_gpu", &use_gpu, "Enable/disable GPU features"); m.def("get_gpu_props", &get_gpu_properties, "Get properties of CUDA gpu");