Skip to content

Commit

Permalink
Merge pull request #1479 from AlexanderGetka-cbica/1.9.0.miscfixes
Browse files Browse the repository at this point in the history
COLLAGE feature additions/warnings (also a DeepMedic model version fix)
  • Loading branch information
AlexanderGetka-cbica authored Mar 13, 2022
2 parents 710af52 + e6d3525 commit 5c606df
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 8 deletions.
4 changes: 2 additions & 2 deletions 3_HowToGuides.txt
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ Multi-institutional Performance Evaluation of Deep Learning Methods and Robust M
<b>REQUIREMENTS:</b>
-# An image or a set of co-registered images.
-# An ROI file containing various labels, for which features will be extracted.
-# NOTE: CaPTk also extracts COLLAGE features [1] using the [Python implementation](https://github.com/radxtools/collageradiomics/).
-# NOTE: CaPTk can also extract COLLAGE features [1] using the [Python implementation](https://github.com/radxtools/collageradiomics/), but this functionality must be invoked from the separate "CollageFeatures" executable.

<b>USAGE:</b>
-# Once image(s) and an ROI file are loaded, go to the "Feature Extraction" panel.
Expand Down Expand Up @@ -1001,7 +1001,7 @@ This application is also available from the web on the [CBICA Image Processing P
-# If desired, enable registration of outputs and select a fixed image to register to.
-# Identify the diffusion measurements to be extracted, and the output directory.
-# Press the "Confirm" button.
-# The extracted measurements will be saved at the specified location (~5 minutes).
-# The extracted measurements will be saved at the specified location (~5 minutes).
\verbatim
${CaPTk_InstallDir}/bin/ DiffusionDerivatives.exe -i C:/inputDWI.nii.gz -m C:/mask.nii.gz -b C:/input.bval -g C:/input.bvec -a 1 -f 1 -r 1 -t 1 -z 1 -reg C:/template.nii.gz -o C:/output
\endverbatim
Expand Down
73 changes: 73 additions & 0 deletions data/cwlFiles/CollageFeatures.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
cwlVersion: v1.0
class: CommandLineTool
baseCommand: CollageFeatures
inputs:
input:
type: string
label: none
inputBinding:
position: 1
prefix: -i
doc: Path to an input image from which features will be extracted..
mask:
type: string
label: none
inputBinding:
position: 1
prefix: -m
doc: Path to a mask that will be considered as binary. The highest pixel value will be considered as information and all other values will be considered outside the mask..
outputfile:
type: string
label: none
inputBinding:
position: 1
prefix: -o
doc: Path to the output CSV file..
runtest:
type: string?
label: none
inputBinding:
position: 1
prefix: -rt
doc: Runs the tests.
cwl:
type: string?
label: none
inputBinding:
position: 1
prefix: -cwl
doc: Generates a .cwl file for the software.
dimensions:
type: int?
label: 2-3
inputBinding:
position: 1
prefix: -d
doc: Optional number of dimensions upon which to run collage. Supported values are 2 and 3. If left out, we will default to the dimensionality of the image itself, which may not reflect expected behavior if the image has an alpha channel..
svdradius:
type: int?
label: none
inputBinding:
position: 1
prefix: -s
doc: SVD radius is used for the dominant angle calculation pixel radius. DEFAULTS to 5 and is suggested to remain at the default..
binsize:
type: int?
label: none
inputBinding:
position: 1
prefix: -b
doc: Number of bins to use while calculating the grey level cooccurence matrix. DEFAULTS to 64..
Logger:
type: string?
label: log file which user has write access to
inputBinding:
position: 1
prefix: -L
doc: Full path to log file to store console outputs.By default, only console output is generated.
hints:
SoftwareRequirement:
packages:
CollageFeatures:
version:
- 1.9.0.Alpha
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 1.8.2
Minimum: 1.8.2
Maximum: 1.8.2
Version: 1.9.0
Minimum: 1.9.0
Maximum: 1.9.0
6 changes: 3 additions & 3 deletions data/deepMedic/saved_models/skullStripping/VERSION.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 1.7.0
Minimum: 1.7.0
Maximum: 1.8.2
Version: 1.9.0
Minimum: 1.9.0
Maximum: 1.9.0
5 changes: 5 additions & 0 deletions src/applications/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ SET( APPLICATIONS
SBRT_LungField
SBRT_Nodule
SBRT_Analysis
CollageFeatures
)
SET( CAPTK_APP_LIST "" )

Expand Down Expand Up @@ -195,6 +196,10 @@ FOREACH(application ${APPLICATIONS})
IF ( (${application} STREQUAL GeodesicTraining))
SET( CAPTK_APP_LIST "${CAPTK_APP_LIST} ${application}" )
ENDIF()

IF ( (${application} STREQUAL CollageFeatures))
ADD_APPLICATION( ${application} )
ENDIF()

ENDFOREACH()

Expand Down
60 changes: 60 additions & 0 deletions src/applications/CollageFeatures.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "cbicaCmdParser.h"
#include "cbicaLogging.h"


// This application simply wraps the collageradiomics cli (included in bin as part of FeatureExtraction being built) and shows warnings.
int main(int argc, char **argv)
{
cbica::CmdParser parser = cbica::CmdParser(argc, argv, "CollageFeatures");

// Right now we add these parameters explicitly, perhaps we can just use the wrapped executable's text.
parser.addRequiredParameter("i", "input", cbica::Parameter::STRING, "", "Path to an input image from which features will be extracted.");
parser.addRequiredParameter("m", "mask", cbica::Parameter::STRING, "", "Path to a mask that will be considered as binary. The highest pixel value will be considered as information and all other values will be considered outside the mask.");
parser.addRequiredParameter("o", "outputfile", cbica::Parameter::STRING, "", "Path to the output CSV file.");
parser.addOptionalParameter("v", "verbose", cbica::Parameter::BOOLEAN, "", "Provides additional debug output.");
parser.addOptionalParameter("d", "dimensions", cbica::Parameter::INTEGER, "2-3", "Optional number of dimensions upon which to run collage. Supported values are 2 and 3. If left out, we will default to the dimensionality of the image itself, which may not reflect expected behavior if the image has an alpha channel.");
parser.addOptionalParameter("s", "svdradius", cbica::Parameter::INTEGER, "", "SVD radius is used for the dominant angle calculation pixel radius. DEFAULTS to 5 and is suggested to remain at the default.");
parser.addOptionalParameter("h", "haralickwindow", cbica::Parameter::INTEGER, "", "Number of pixels around each pixel used to calculate the haralick texture. DEFAULTS to svdradius * 2 - 1.");
parser.addOptionalParameter("b", "binsize", cbica::Parameter::INTEGER, "", "Number of bins to use while calculating the grey level cooccurence matrix. DEFAULTS to 64.");

parser.addOptionalParameter("L", "Logger", cbica::Parameter::STRING, "log file which user has write access to", "Full path to log file to store console outputs", "By default, only console output is generated");
parser.addExampleUsage("-i C:/inputImage.nii.gz -m C:/inputMask.nii.gz -o C:/output.csv", "Generates COLLAGE features with default parameters");
parser.addApplicationDescription("CoLlAGe captures subtle anisotropic differences in disease pathologies by measuring entropy of co-occurrences of voxel-level gradient orientations onn imaging computed within a local neighborhood. The CoLlAGe features were developed by BrIC Lab and the RadxTools team (https://doi.org/10.1038/srep37241, https://github.com/radxtools/collageradiomics). Feature requests, bug reports, and any other CoLlAGe related considerations, should be directed to https://github.com/radxtools/collageradiomics/issues .");

std::string outputFile;
parser.getParameterValue("o", outputFile);

std::string argv_complete;
for (int i = 1; i < argc; i++) // 1 to ignore the current executable name
{
argv_complete += " \"" + std::string(argv[i]) + "\""; // double quote for command tokenization
}

auto collage_cli = cbica::getExecutablePath() + "/collageradiomics"
#ifdef _WIN32
+ ".exe"
#else

#endif
;

if (!cbica::isFile(collage_cli))
{
// If this happens, this is on our packaging and not on the RadxTools folks.
std::cerr << "Could not find the Collage CLI, so cannot extract collage features. Please report this bug to CBICA Software.\n";
return EXIT_FAILURE;
}


std::string commandToRun = collage_cli + argv_complete;
if(std::system(commandToRun.c_str()) > 0)
{
std::cerr << "Errors occurred while running the collageradiomics application. See logs for more details." << std::endl;
return EXIT_FAILURE;
}
else
{
std::cout << "Finished successfully.\n";
}
return EXIT_SUCCESS;
}
1 change: 1 addition & 0 deletions src/applications/CollageFeatures.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This is a blank header to ensure that CMake picks up the CollageFeatures wrapper for collageradiomics.
20 changes: 20 additions & 0 deletions src/applications/FeatureExtraction/src/FeatureExtraction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,26 @@ void algorithmRunner(std::vector<typename TImageType::Pointer> inputImages, type
features.SetValidMask();
features.SetMaskImage(mask);
features.SetRequestedFeatures(param_file);

// Interrupt here now that we have requested features if COLLAGE is present.
auto tmp_features = features.GetRequestedFeatures();
auto tmp_iterator = tmp_features.find(FeatureFamilyString[FeatureFamily::COLLAGE]);
// Below line checks if COLLAGE exists in the feature families at all, and if it does,
// then it checks if it's enabled in the struct
if (tmp_iterator != tmp_features.end() && (std::get<0>(tmp_iterator->second) == true))
{
std::string collageMessage = "COLLAGE features were requested for this computation, but are not available through this interface. Please note:\n\n";
collageMessage += "The COLLAGE features were developed by BrIC Lab and the RadxTools team \n (https://doi.org/10.1038/srep37241, https://github.com/radxtools/collageradiomics) \n\n";
collageMessage += "Based on published results indicating their importance, COLLAGE features are offered as part of the CaPTk platform to enable users to extract a more comprehensive and reproducible set of features, as shown in:\n[https://doi.org/10.1002/mp.14556] \n\n";
collageMessage += "Please note that extraction of COLLAGE features is a long running process (often >20 minutes) and might not produce results for all the input images.";
collageMessage += "In order to extract COLLAGE features, please use the separate COLLAGE command line executable (CollageFeatures) from the CaPTk install directory.";
collageMessage += "Future releases of CaPTk will include updated versions of COLLAGE when available.";
collageMessage += "\nTo continue with feature extraction, change parameters and try again. Exiting.";
std::cerr << collageMessage << std::endl;
exit(EXIT_FAILURE); // Using this to escape out, since no return code exists from this function... kind of hacky
}


features.SetOutputFilename(outputFilename);
features.SetVerticallyConcatenatedOutput(verticalConc);
features.SetWriteFeatureMaps(featureMaps);
Expand Down
5 changes: 5 additions & 0 deletions src/applications/FeatureExtraction/src/FeatureExtraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ class FeatureExtraction
\brief Populates the feature structure from the GUI
*/
void SetRequestedFeatures(std::map< std::string, std::vector< std::map<std::string, std::string> > > featuresFromUI, std::map<std::string, bool> selected_features);

/**
\brief Gets the requested features (as FeatureType)
*/
FeatureType GetRequestedFeatures();

/**
\brief This function is used to populate the variables throughout the Update() step which are then used to write to a file
Expand Down
14 changes: 14 additions & 0 deletions src/applications/FeatureExtraction/src/FeatureExtraction.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,11 @@ void FeatureExtraction< TImage >::SetSelectedROIsAndLabels(std::vector< std::str
m_algorithmDone = false;
}

template < class TImage >
FeatureType FeatureExtraction< TImage >::GetRequestedFeatures()
{
return m_Features;
}

template< class TImage >
void FeatureExtraction< TImage >::SetRequestedFeatures(std::string filename, std::string selected_features)
Expand Down Expand Up @@ -2857,6 +2862,15 @@ void FeatureExtraction< TImage >::Update()
}
case COLLAGE:
{
std::string collageMessage = "COLLAGE features were requested for this computation, but are not available through this interface. Please note:\n\n";
collageMessage += "The COLLAGE features were developed by BrIC Lab and the RadxTools team (https://doi.org/10.1038/srep37241, https://github.com/radxtools/collageradiomics) \n\n";
collageMessage += "Based on published results indicating their importance, COLLAGE features are offered as part of the CaPTk platform to enable users to extract a more comprehensive and reproducible set of features, as shown in : [https://doi.org/10.1002/mp.14556] \n\n";
collageMessage += "Please note that extraction of COLLAGE features is a long running process (often >20 minutes) and might not produce results for all the input images.\n";
collageMessage += "In order to extract COLLAGE features, please use the separate COLLAGE command line executable from the CaPTk install directory.\n";
collageMessage += "Future releases of CaPTk will include updated versions of COLLAGE when available.\n";
m_logger.Write(collageMessage);
break; // Display message and break out of these features if it gets here (this *should* be caught by CLI/GUI, but just in case)

// this is a special case, where a pre-compiled python binary is called for every image/mask
if (!allROIs[j].latticeGridPoint) // this is not currently working for lattice patches - https://github.com/radxtools/collageradiomics/issues/89
{ // start lattice check
Expand Down
26 changes: 26 additions & 0 deletions src/view/gui/fFeaturePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@ fFeaturePanel::fFeaturePanel(QWidget * parent) : QWidget(parent)
connect(m_btnBrowseSaveFile, SIGNAL(clicked()), this, SLOT(browseOutputFileName()));
connect(m_cmbFeatureType, SIGNAL(currentIndexChanged(int)), this, SLOT(featureTypeChanged(int)));
connect(HelpButton, SIGNAL(clicked()), this, SLOT(helpClicked()));

//csv_format->setChecked(true);
m_verticalConcat->setChecked(true);
radio1->setChecked(true);
loadFeatureFiles();
featureTypeChanged(0);

// Disable collage by default on GUI, so that users must be prompted with RadXTools info
m_Collage->setChecked(false);
connect(m_Collage, SIGNAL(toggled(bool)), this, SLOT(onCollageToggled(bool)));

}

void fFeaturePanel::helpClicked()
Expand Down Expand Up @@ -389,4 +394,25 @@ void fFeaturePanel::advancedButtonClicked()
m_featureDialog->exec();
m_FeatureMaps[selectedFeatureType] = m_featureDialog->getFeatureMap();

}

void fFeaturePanel::onCollageToggled(bool checked)
{
if (checked)
{
std::string collageMessage = "COLLAGE features were requested for this computation, but are not available through this interface. Please note:\n\n";
collageMessage += "The COLLAGE features were developed by BrIC Lab and the RadxTools team (https://doi.org/10.1038/srep37241, https://github.com/radxtools/collageradiomics) \n\n";
collageMessage += "Based on published results indicating their importance, COLLAGE features are offered as part of the CaPTk platform to enable users to extract a more comprehensive and reproducible set of features, as shown in : [https://doi.org/10.1002/mp.14556] \n\n";
collageMessage += "Please note that extraction of COLLAGE features is a long running process (often >20 minutes) and might not produce results for all the input images.\n";
collageMessage += "In order to extract COLLAGE features, please use the separate COLLAGE command line executable from the CaPTk install directory.\n";
collageMessage += "Future releases of CaPTk will include updated versions of COLLAGE when available.\n";
collageMessage += "Feature requests, bug reports, and any other COLLAGE related considerations, should be directed to https://github.com/radxtools/collageradiomics/issues.";
QMessageBox msgbox;
msgbox.setText(QString::fromStdString(collageMessage));
msgbox.setWindowTitle("COLLAGE Warning");
msgbox.setStandardButtons(QMessageBox::Ok);
msgbox.setDefaultButton(QMessageBox::Ok);
m_Collage->setChecked(false);
msgbox.exec();
}
}
1 change: 1 addition & 0 deletions src/view/gui/fFeaturePanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class fFeaturePanel : public QWidget, private Ui::fFeaturePanel
void featureTypeChanged(int type);
void advancedButtonClicked();
void helpClicked();
void onCollageToggled(bool checked);
std::map< std::string, bool > getEnabledFeatures();

private:
Expand Down

0 comments on commit 5c606df

Please sign in to comment.