Skip to content

Commit

Permalink
Merge pull request #154 from friskluft/POL3595_unify_col_naming
Browse files Browse the repository at this point in the history
POL3595 unified column name | customizable output file name
  • Loading branch information
sameeul authored Oct 23, 2023
2 parents 65ae181 + 786df8d commit 483fa1d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
15 changes: 13 additions & 2 deletions src/nyx/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 << "=<separatecsv or singlecsv for csv output. arrowipc or parquet for arrow output> \n"
<< "\t\t\tDefault: separatecsv \n"
<< "\t\t" << SEGDIR << "=<directory of segmentation images> \n"
<< "\t\t" << SEGDIR << "=<directory of segmentation mask images> \n"
<< "\t\t" << INTDIR << "=<directory of intensity images> \n"
<< "\t\t" << OUTDIR << "=<output directory> \n"
<< "\t\t" << OPT << FEATURES << "=<specific feature or comma-separated features or feature group> \n"
Expand Down Expand Up @@ -201,7 +201,10 @@ void Environment::show_cmdline_help()
<< "\t\t" << OPT << SKIPROI << "=<ROI blacklist> \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 << "=<file name without extension> \n"
<< "\t\t\tDefault: NyxusFeatures \n"
<< "\t\t\tExample: " << RESULTFNAME << "=training_set_features";

#ifdef CHECKTIMING
std::cout << "\t\t" << OPT << EXCLUSIVETIMING << "=<false or true> \n"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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");
Expand Down
11 changes: 6 additions & 5 deletions src/nyx/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <label[,label,label,...]>

#define RESULTFNAME "--resultFname" // Environment :: nyxus_result_fname

#ifdef CHECKTIMING
#define EXCLUSIVETIMING "--exclusivetiming"
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/nyx/output_2_csv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> mandatory_output_columns {"intensity_image", "segmentation_image", "ROI_label"};
const std::vector<std::string> 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)
Expand Down
8 changes: 4 additions & 4 deletions src/nyx/python/new_bindings_py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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];
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 483fa1d

Please sign in to comment.