Some basic utility functions. More...
#include <string>
#include <typeinfo>
#include <vector>
#include <set>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdexcept>
#include <iterator>
#include <cmath>
#include <numeric>
#include <memory.h>
#include <map>
#include <random>
#include <iomanip>
#include <limits>
Go to the source code of this file.
Classes | |
struct | CSVDict |
A Dictionary structure to for CSV parsing. More... | |
struct | FileNameParts |
Holds the different parts of a file name (path, base and extension) More... | |
Functions | |
std::map< std::string, size_t > | ConfusionMatrix (const std::vector< float > &inputRealLabels, const std::vector< float > &inputPredictedLabels) |
Calculates the Confusion Matrix for a set of real and predicted labels. More... | |
char * | constCharToChar (const std::string &input) |
Convert const char* to char*. More... | |
char * | constCharToChar (const char *input) |
Convert const char* to char*. More... | |
template<typename TConvertType > | |
TConvertType | convertCharacter (const std::string &input_string) |
Convert first character to integer, double, unsigned int, etc. More... | |
template<typename TConvertType = int> | |
std::vector< TConvertType > | convertString (const std::string &input_string) |
Convert entire string to integer, double, unsigned int, etc. More... | |
bool | copyDir (const std::string &inputFolder, const std::string &destination, bool recursion=true) |
Copy a folder and if recursion enabled, all its contents. More... | |
bool | copyDirectory (const std::string &inputFolder, const std::string &destination, bool recursion=true) |
Copy a folder and if recursion enabled, all its contents. More... | |
bool | copyFile (const std::string &inputFile, const std::string &destination) |
Copy a folder and if recursion enabled, all its contents. More... | |
bool | copyFolder (const std::string &inputFolder, const std::string &destination, bool recursion=true) |
Copy a folder and if recursion enabled, all its contents. More... | |
bool | createDir (const std::string &dir_name) |
Create a directory. More... | |
bool | createDirectory (const std::string &dir_name) |
Create a directory. More... | |
bool | createFolder (const std::string &dir_name) |
Create a directory. More... | |
std::string | createTemporaryDirectory () |
Create a temporary directory. More... | |
std::string | createTmpDir () |
Create a temporary directory. More... | |
bool | deleteDir (const std::string &path) |
Delete a folder and contents. More... | |
bool | deleteEnvironmentVariable (const std::string &variable_name) |
Delete the environment variable. More... | |
bool | directoryExists (const std::string &dName) |
Check if directory exists. More... | |
void | dos2unix (const std::string inputFile) |
Ensuring files written using Windows don't mess stuff up. More... | |
bool | exists (const std::string &path) |
Return True if path exists and false for broken symbolic links. More... | |
bool | fileExists (const std::string &fName) |
Check if file exists using istream. More... | |
std::vector< std::string > | filesInDirectory (const std::string &dirName, bool returnFullPath=true) |
Find all files inside a directory. More... | |
template<typename TContainerType = std::string> | |
std::pair< bool, int > | findInVector (std::vector< TContainerType > &vector_to_search_in, TContainerType element_to_search_for) |
Searches for an element in a vector and returns true/false and position. More... | |
std::string | getCurrentGMT () |
Get current GMT as string delineated as HH:MM:SS. | |
std::string | getCurrentGMTDate () |
Get current GMT as string delineated as YYYY:MM:DD. | |
std::string | getCurrentGMTDateAndTime () |
Get current GMT as string delineated as YYYY:MM:DD,HH:MM:SS. | |
std::string | getCurrentLocalDate () |
Get current local time as string delineated as YYYY:MM:DD. | |
std::string | getCurrentLocalDateAndTime () |
Get current local time as string delineated as YYYY:MM:DD,HH:MM:SS. | |
std::string | getCurrentLocalTime () |
Get current local time as string delineated as HH:MM:SS. | |
std::string | getCurrentProcessID () |
Get the current process ID. More... | |
std::string | getCurrentYear () |
Get current Year as string delineated as YYYY. | |
std::string | getCWD () |
Get the current working directory. More... | |
std::vector< std::string > | getCWLFilesInApplicationDir () |
size_t | getDirectorySize (const std::string &rootFolder) |
Get the size of the folder. More... | |
size_t | getDirSize (const std::string &rootFolder) |
Get the size of the folder. More... | |
std::string | getEnvironmentVariableValue (const std::string &environmentVariable) |
Gets the value of the specified environment variable. | |
std::string | getExecutableName () |
Get the name of the Executable which is calling the function. More... | |
std::string | getExecutablePath () |
Get the path of the Executable which is calling the function. More... | |
std::string | getFilenameBase (const std::string &filename, bool checkFile=true) |
Gets the base of the supplied file name using splitFileName() More... | |
std::string | getFilenameExtension (const std::string &filename, bool checkFile=true) |
Gets the extension of the supplied file name using splitFileName() More... | |
std::string | getFilenamePath (const std::string &filename, bool checkFile=true) |
Gets the path of the supplied file name using splitFileName() More... | |
size_t | getFileSize (const std::string &inputFile) |
Get the size of the file in bytes. More... | |
size_t | getFolderSize (const std::string &rootFolder) |
Get the size of the folder. More... | |
std::string | getFullPath () |
Get the name of the Executable which is calling the function. More... | |
template<class TDataType = std::string> | |
std::vector< TDataType > | GetUniqueElements (const std::vector< TDataType > &inputVector) |
Find the unique elements in a vector. More... | |
std::string | getUserHomeDirectory () |
Get the home directory of the user. More... | |
std::string | getUserName () |
Get the name of the user who is calling the function. More... | |
bool | IsCompatible (const std::string inputVersionFile) |
bool | isDir (const std::string &path) |
Return True if path is an existing directory. More... | |
bool | isFile (const std::string &path) |
Return True if path is an existing regular file. More... | |
bool | isLink (const std::string &path) |
Return True if path refers to a directory entry that is a symbolic link. More... | |
bool | isSymbolicLink (const std::string &path) |
Check if path refers to a symbolic entry. More... | |
bool | makeDir (const std::string &dir_name) |
Create a directory. More... | |
bool | makeDirectory (const std::string &dir_name) |
Create a directory. More... | |
bool | makeFolder (const std::string &dir_name) |
Create a directory. More... | |
bool | makeSymbolicLink (const std::string &input_fileName, const std::string &ouput_fileName) |
Make a symbolic link from file to another. More... | |
std::string | makeTempDir () |
Create a temporary directory. More... | |
std::string | makeTemporaryDirectory () |
Create a temporary directory. More... | |
std::string | normalizePath (const std::string &path) |
Normalize a pathname by collapsing redundant separators and up-level references. More... | |
std::string | normPath (const std::string &path) |
Normalize a pathname by collapsing redundant separators and up-level references. More... | |
size_t | numberOfColsInFile (const std::string &csvFileName, const std::string &delim=",") |
Find number of cols in CSV file. | |
size_t | numberOfRowsInFile (const std::string &csvFileName, const std::string &delim="\n") |
Find number of rows in CSV file. | |
std::vector< CSVDict > | parseCSVFile (const std::string &csvFileName, const std::string &inputColumns, const std::string &inputLabels, bool checkFile=true, bool pathsRelativeToCSV=false, const std::string &rowsDelimiter="\n", const std::string &colsDelimiter=",", const std::string &optionsDelimiter=",") |
Parse the supplied CSV File and obtain Row and Column information. More... | |
template<class TDataType = float> | |
std::vector< TDataType > | randn (const TDataType start, const TDataType end, size_t sizeOfReturn=1) |
A good random number generator using c++11 that gives a random value within a range. More... | |
template<class TDataType = float> | |
std::vector< TDataType > | randn (size_t sizeOfReturn=1) |
A good random number generator using c++11 that gives a random value within a range. More... | |
template<class TDataType = double> | |
std::vector< std::vector< TDataType > > | readCSVDataFile (const std::string &csvFileName, bool columnMajor=false) |
Read a CSV file which has no header information. More... | |
std::vector< std::vector< std::string > > | readCSVDataFile (const std::string &csvFileName) |
Read a CSV file which has no header information. More... | |
std::string | realPath (const std::string &path) |
Return the canonical path of the specified filename. More... | |
std::string | relativePath (const std::string &path, const std::string &base) |
Return a relative filepath to path. More... | |
std::string | relPath (const std::string &path, const std::string &base) |
Return a relative filepath to path. More... | |
bool | removeDir (const std::string &path) |
Delete a folder and contents. More... | |
int | removeDirectoryRecursively (const std::string &dirname, bool bDeleteSubdirectories) |
Recursively delete a folder and contents [internal function]. More... | |
std::string | replaceString (const std::string &entireString, const std::string &toReplace, const std::string &replaceWith) |
Searches for smaller string in larger string and then replaces it with user-defined input. More... | |
std::map< std::string, float > | ROC_Values (const std::vector< float > &inputRealLabels, const std::vector< float > &inputPredictedLabels) |
Calculates the ROC Values (see https://en.wikipedia.org/wiki/Receiver_operating_characteristic of all estimates) for a set of real and predicted labels. More... | |
bool | setEnvironmentVariable (const std::string &variable_name, const std::string &variable_value) |
Sets the environment variable. More... | |
void | sleep (size_t ms=std::rand() % 1000+1) |
Cross platform sleep. More... | |
bool | splitFileName (const std::string &dataFile, std::string &path, std::string &baseName, std::string &extension) |
Splits the input file name into its constituents. More... | |
std::vector< std::string > | stringSplit (const std::string &str, const std::string &delim) |
Splits the string. More... | |
std::vector< std::string > | subdirectoriesInDirectory (const std::string &dirName, bool recursiveSearch=false, bool returnFullPath=false) |
Find all sub-directories inside a directory. More... | |
Some basic utility functions.
This needs c++11 flag enabled in gcc < 5.
https://www.med.upenn.edu/sbia/software///
softw are@ cbica .upe nn.ed u
Copyright (c) 2018 University of Pennsylvania. All rights reserved.
See COPYING file or https://www.med.upenn.edu/cbica/software-agreement.html
std::map< std::string, size_t > cbica::ConfusionMatrix | ( | const std::vector< float > & | inputRealLabels, |
const std::vector< float > & | inputPredictedLabels | ||
) |
Calculates the Confusion Matrix for a set of real and predicted labels.
Values returned: True Positive (TP), False Positive (FP), True Negative (TN), False Negative (FN), Real Positive (RP), Preditcted Positive (PP)
inputRealLabels | Vector structure containing real labels |
inputPredictedLabels | Vector structure containing predicted labels |
char* cbica::constCharToChar | ( | const std::string & | input | ) |
Convert const char* to char*.
input | constant std::string |
char* cbica::constCharToChar | ( | const char * | input | ) |
Convert const char* to char*.
input | constant character pointer |
TConvertType cbica::convertCharacter | ( | const std::string & | input_string | ) |
Convert first character to integer, double, unsigned int, etc.
input_string | Input character to be converted |
References cbica::convertCharacter().
Referenced by cbica::convertCharacter().
std::vector< TConvertType> cbica::convertString | ( | const std::string & | input_string | ) |
Convert entire string to integer, double, unsigned int, etc.
input_string | Input character to be converted |
References cbica::convertString().
Referenced by cbica::convertString().
bool cbica::copyDir | ( | const std::string & | inputFolder, |
const std::string & | destination, | ||
bool | recursion = true |
||
) |
Copy a folder and if recursion enabled, all its contents.
https://msdn.microsoft.com/en-us/library/hh874694.aspx?f=255&MSPPError=-2147217396
inputFolder | Folder to copy |
destination | Where to copy to |
recursion | Do recursion and copy, defaults to true |
bool cbica::copyDirectory | ( | const std::string & | inputFolder, |
const std::string & | destination, | ||
bool | recursion = true |
||
) |
Copy a folder and if recursion enabled, all its contents.
https://msdn.microsoft.com/en-us/library/hh874694.aspx?f=255&MSPPError=-2147217396
inputFolder | Folder to copy |
destination | Where to copy to |
recursion | Do recursion and copy, defaults to true |
bool cbica::copyFile | ( | const std::string & | inputFile, |
const std::string & | destination | ||
) |
Copy a folder and if recursion enabled, all its contents.
inputFile | File to copy |
destination | Where to copy to |
bool cbica::copyFolder | ( | const std::string & | inputFolder, |
const std::string & | destination, | ||
bool | recursion = true |
||
) |
Copy a folder and if recursion enabled, all its contents.
https://msdn.microsoft.com/en-us/library/hh874694.aspx?f=255&MSPPError=-2147217396
inputFolder | Folder to copy |
destination | Where to copy to |
recursion | Do recursion and copy, defaults to true |
bool cbica::createDir | ( | const std::string & | dir_name | ) |
Create a directory.
dir_name | Name of directory to be created with full path |
Referenced by cbica::WriteDicomImage().
bool cbica::createDirectory | ( | const std::string & | dir_name | ) |
Create a directory.
dir_name | Name of directory to be created with full path |
bool cbica::createFolder | ( | const std::string & | dir_name | ) |
Create a directory.
dir_name | Name of directory to be created with full path |
std::string cbica::createTemporaryDirectory | ( | ) |
std::string cbica::createTmpDir | ( | ) |
Create a temporary directory.
Creates a user-writable file using the following format: USER_HOME_DIR + EXE_NAME + tmp_ + processID;
If this file is existing, for whatever reason, then a new is created which has the time stamp appended.
bool cbica::deleteDir | ( | const std::string & | path | ) |
Delete a folder and contents.
path | Folder to delete |
bool cbica::deleteEnvironmentVariable | ( | const std::string & | variable_name | ) |
Delete the environment variable.
variable_name | Name of the Variable |
bool cbica::directoryExists | ( | const std::string & | dName | ) |
Check if directory exists.
dName | String to check |
void cbica::dos2unix | ( | const std::string | inputFile | ) |
Ensuring files written using Windows don't mess stuff up.
Base implementation from https://www.digitalpeer.com/blog/simple-text-processing-with-cpp-dos2unix-example
bool cbica::exists | ( | const std::string & | path | ) |
Return True if path exists and false for broken symbolic links.
Reimplementation of python's "os.path.exists": On some platforms, this function may return False if permission is not granted to execute os.stat() on the requested file, even if the path physically exists.
path | Path to check |
bool cbica::fileExists | ( | const std::string & | fName | ) |
Check if file exists using istream.
fName | Filename to check |
std::vector< std::string > cbica::filesInDirectory | ( | const std::string & | dirName, |
bool | returnFullPath = true |
||
) |
Find all files inside a directory.
dirName | The directory to do the search in |
Referenced by cbica::GetImageReader().
std::pair<bool, int> cbica::findInVector | ( | std::vector< TContainerType > & | vector_to_search_in, |
TContainerType | element_to_search_for | ||
) |
Searches for an element in a vector and returns true/false and position.
Templated function to take in any kind of vector and element.
vector_to_search_in | Vector to do the search in |
element_to_search_for | Element to search for |
position | Last position of found element in vector (-1) if not found |
References cbica::findInVector().
Referenced by cbica::findInVector().
std::string cbica::getCurrentProcessID | ( | ) |
Get the current process ID.
Provides wraps to _getpid() in OS-specific ways
std::string cbica::getCWD | ( | ) |
Get the current working directory.
[Wrap for cbica::getcwd()]
size_t cbica::getDirectorySize | ( | const std::string & | rootFolder | ) |
Get the size of the folder.
rootFolder | The input folder |
size_t cbica::getDirSize | ( | const std::string & | rootFolder | ) |
Get the size of the folder.
rootFolder | The input folder |
std::string cbica::getExecutableName | ( | ) |
Get the name of the Executable which is calling the function.
std::string cbica::getExecutablePath | ( | ) |
Get the path of the Executable which is calling the function.
returns the path after calling splitFileName on getFullPath
std::string cbica::getFilenameBase | ( | const std::string & | filename, |
bool | checkFile = true |
||
) |
Gets the base of the supplied file name using splitFileName()
Prefer to use "/" as file path delimiter.
filename | The input filename |
checkFile | Checks existence of file using fileExists |
std::string cbica::getFilenameExtension | ( | const std::string & | filename, |
bool | checkFile = true |
||
) |
Gets the extension of the supplied file name using splitFileName()
Prefer to use "/" as file path delimiter.
filename | The input filename |
checkFile | Checks existence of file using fileExists |
Referenced by cbica::GetImageReader(), cbica::ReadImageWithOrientFix(), and cbica::WriteImage().
std::string cbica::getFilenamePath | ( | const std::string & | filename, |
bool | checkFile = true |
||
) |
Gets the path of the supplied file name using splitFileName()
Prefer to use "/" as file path delimiter.
filename | The input filename |
checkFile | Checks existence of file using fileExists |
Referenced by cbica::GetDicomImageReader(), and cbica::GetImageReader().
size_t cbica::getFileSize | ( | const std::string & | inputFile | ) |
Get the size of the file in bytes.
inputFile | The input file |
size_t cbica::getFolderSize | ( | const std::string & | rootFolder | ) |
Get the size of the folder.
rootFolder | The input folder |
std::string cbica::getFullPath | ( | ) |
Get the name of the Executable which is calling the function.
std::vector< TDataType > cbica::GetUniqueElements | ( | const std::vector< TDataType > & | inputVector | ) |
Find the unique elements in a vector.
Implementation incorporated from the SO answer in https://stackoverflow.com/a/1041939/1228757
inputVector | The vector on which to search for unique elements |
References cbica::GetUniqueElements().
Referenced by cbica::GetDicomImageReader(), and cbica::GetUniqueElements().
std::string cbica::getUserHomeDirectory | ( | ) |
Get the home directory of the user.
Windows - C:/Users/XYZ Linux - /home/XYZ
std::string cbica::getUserName | ( | ) |
Get the name of the user who is calling the function.
bool cbica::isDir | ( | const std::string & | path | ) |
Return True if path is an existing directory.
Reimplementation of python's "os.path.isdir": This follows symbolic links, so both islink() and isdir() can be true for the same path.
[Wrap of cbica::directoryExists()]
path | Directory name to check |
Referenced by cbica::GetDicomImageReader(), and cbica::WriteDicomImage().
bool cbica::isFile | ( | const std::string & | path | ) |
Return True if path is an existing regular file.
Reimplementation for python's "os.path.isfile": This follows symbolic links, so both islink() and isfile() can be true for the same path.
[Wrap of cbica::fileExists()]
path | Filename of file to check |
Referenced by cbica::readCSVDataFile().
bool cbica::isLink | ( | const std::string & | path | ) |
Return True if path refers to a directory entry that is a symbolic link.
Reimplementation of python's "os.path.islink": Always False if symbolic links are not supported by the python runtime.
path | Path to check |
bool cbica::isSymbolicLink | ( | const std::string & | path | ) |
Check if path refers to a symbolic entry.
[Wrap of cbica::isLink()]
path | Path to check |
bool cbica::makeDir | ( | const std::string & | dir_name | ) |
Create a directory.
dir_name | Name of directory to be created with full path |
bool cbica::makeDirectory | ( | const std::string & | dir_name | ) |
Create a directory.
dir_name | Name of directory to be created with full path |
bool cbica::makeFolder | ( | const std::string & | dir_name | ) |
Create a directory.
dir_name | Name of directory to be created with full path |
bool cbica::makeSymbolicLink | ( | const std::string & | input_fileName, |
const std::string & | ouput_fileName | ||
) |
Make a symbolic link from file to another.
input_fileName | Input file name for which symbolic link needs to be created |
output_fileName | Output file name which is the symbolic link for input_fileName |
std::string cbica::makeTempDir | ( | ) |
std::string cbica::makeTemporaryDirectory | ( | ) |
std::string cbica::normalizePath | ( | const std::string & | path | ) |
Normalize a pathname by collapsing redundant separators and up-level references.
[Wrap for cbica::normPath()]
path | Path to normalize |
std::string cbica::normPath | ( | const std::string & | path | ) |
Normalize a pathname by collapsing redundant separators and up-level references.
Reimplementation of python's "os.path.normpath": Normalize a pathname by collapsing redundant separators and up-level references so that A//B, A/B/, A/./B and A/foo/../B all become A/B. This string manipulation may change the meaning of a path that contains symbolic links. On Windows, it converts forward slashes to backward slashes.
path | Path to normalize |
Referenced by cbica::GetDicomImageReader(), and cbica::GetImageReader().
std::vector< CSVDict > cbica::parseCSVFile | ( | const std::string & | csvFileName, |
const std::string & | inputColumns, | ||
const std::string & | inputLabels, | ||
bool | checkFile = true , |
||
bool | pathsRelativeToCSV = false , |
||
const std::string & | rowsDelimiter = "\n" , |
||
const std::string & | colsDelimiter = "," , |
||
const std::string & | optionsDelimiter = "," |
||
) |
Parse the supplied CSV File and obtain Row and Column information.
Assumptions:
csvFileName | The full path of the file to parse, all paths are absolute or relative to current working directory |
inputColumns | The string of input columns which contain the data to be used for further processing |
inputLabels | The string of input labels per subject based on which further processing is to be done; if this is empty, it is initialized as 1 for all subjects |
checkFile | Check the validity of the file; defaults to true |
pathsRelativeToCSV | The paths in the CSV file are relative to the location of CSV file otherwise, they are checked relative to the CWD |
rowsDelimiter | The delimiters used to distinguish rows in the file |
colsDelimiter | The delimiters used to distinguish cols in the file |
optionsDelimiter | The delimiters used in inputColumns and inputLabel |
std::vector< TDataType > cbica::randn | ( | const TDataType | start, |
const TDataType | end, | ||
size_t | sizeOfReturn = 1 |
||
) |
A good random number generator using c++11 that gives a random value within a range.
start | Start value of range; defaults to 0 |
end | End value of range; defaults to 1 |
sizeOfReturn | Size of the returned vector |
References cbica::randn().
Referenced by cbica::randn().
std::vector< TDataType > cbica::randn | ( | size_t | sizeOfReturn = 1 | ) |
A good random number generator using c++11 that gives a random value within a range.
sizeOfReturn | Size of the returned vector |
References cbica::randn().
std::vector< std::vector< TDataType > > cbica::readCSVDataFile | ( | const std::string & | csvFileName, |
bool | columnMajor = false |
||
) |
Read a CSV file which has no header information.
To read CSV file with header information, check parseCSVFile() function. This should not be used for obtaining strings
csvFileName | The full path of the file to parse, all paths are absolute or relative to current working directory |
columnMajor | If true, then return is a vector of all the columns; otherwise it is a vector of the rows |
References cbica::isFile(), cbica::numberOfColsInFile(), cbica::numberOfRowsInFile(), and cbica::readCSVDataFile().
Referenced by cbica::readCSVDataFile().
std::vector< std::vector< std::string > > cbica::readCSVDataFile | ( | const std::string & | csvFileName | ) |
Read a CSV file which has no header information.
To read CSV file with header information, check parseCSVFile() function. This should be used for obtaining strings
csvFileName | The full path of the file to parse, all paths are absolute or relative to current working directory |
std::string cbica::realPath | ( | const std::string & | path | ) |
Return the canonical path of the specified filename.
Reimplementation of python's "os.path.realpath": Return the canonical path of the specified filename, eliminating any symbolic links encountered in the path (if they are supported by the operating system).
path | Filename to check |
std::string cbica::relativePath | ( | const std::string & | path, |
const std::string & | base | ||
) |
Return a relative filepath to path.
Wrap of cbica::relPath()
path | Path to check |
base | Base file name |
std::string cbica::relPath | ( | const std::string & | path, |
const std::string & | base | ||
) |
Return a relative filepath to path.
Reimplementation for python's "os.path.relpath": Return a relative filepath to path either from the current directory or from an optional start directory. This is a path computation: the filesystem is not accessed to confirm the existence or nature of path or start.
path | Path to check |
base | Base file name |
bool cbica::removeDir | ( | const std::string & | path | ) |
Delete a folder and contents.
path | Folder to delete |
int cbica::removeDirectoryRecursively | ( | const std::string & | dirname, |
bool | bDeleteSubdirectories | ||
) |
Recursively delete a folder and contents [internal function].
dirname | Folder to delete |
std::string cbica::replaceString | ( | const std::string & | entireString, |
const std::string & | toReplace, | ||
const std::string & | replaceWith | ||
) |
Searches for smaller string in larger string and then replaces it with user-defined input.
entireString | String to search |
toReplace | String to replace |
replaceWith | String to replace toReplace with |
std::map< std::string, float > cbica::ROC_Values | ( | const std::vector< float > & | inputRealLabels, |
const std::vector< float > & | inputPredictedLabels | ||
) |
Calculates the ROC Values (see https://en.wikipedia.org/wiki/Receiver_operating_characteristic of all estimates) for a set of real and predicted labels.
Values returned: True Positive (TP), False Positive (FP), True Negative (TN), False Negative (FN), Real Positive (RP), Preditcted Positive (PP) [all from ConfusionMatrix()], Accuracy, Positive Predictive Value (PPV) [aka Precision], False Discovery Rate (FDR), False Omission Rate (FOR), Negative Predictive Value (NPV), Prevalence, True Positive Rate (TPR) [aka Sensitivity, Recall, Probability of Detection (POD)], False Positive Rate (FPR) [aka Fall-out], False Negative Rate (FNR) [aka Miss Rate (MR)], True Negative Rate (TNR) [aka Specificity], Positive Likelihood Ratio (LR+), Negative Likelihood Ratio (LR−), Diagnostic Odds Ratio (DOR), Dice Score (Dice), Jaccard ratio/index (JR)
inputRealLabels | Vector structure containing real labels |
inputPredictedLabels | Vector structure containing predicted labels |
bool cbica::setEnvironmentVariable | ( | const std::string & | variable_name, |
const std::string & | variable_value | ||
) |
Sets the environment variable.
variable_name | Name of the Variable |
variable_value | Value of variable_name |
void cbica::sleep | ( | size_t | ms = std::rand() % 1000+1 | ) |
Cross platform sleep.
Defaults to "std::rand() % 1000 + 1"
bool cbica::splitFileName | ( | const std::string & | dataFile, |
std::string & | path, | ||
std::string & | baseName, | ||
std::string & | extension | ||
) |
Splits the input file name into its constituents.
dataFile | The full file name which is the input |
baseName | Overwritten with file name without extension |
extension | Overwritten with extension without '.' |
path | Overwritten with path to file |
std::vector<std::string> cbica::stringSplit | ( | const std::string & | str, |
const std::string & | delim | ||
) |
Splits the string.
str | String to split |
delim | Delimiter on the basis of which splitting is to be done |
Referenced by cbica::ChangeImageValues(), and cbica::GetImageReader().
std::vector<std::string> cbica::subdirectoriesInDirectory | ( | const std::string & | dirName, |
bool | recursiveSearch = false , |
||
bool | returnFullPath = false |
||
) |
Find all sub-directories inside a directory.
dirName | The directory to do the search in |
recursiveSearch | Whether to do a recursive search or on a single level |