Skip to content

Commit

Permalink
Merge pull request #49 from sarthakpati/master
Browse files Browse the repository at this point in the history
Patch based validation is now default
  • Loading branch information
sarthakpati authored Apr 27, 2021
2 parents 306245e + 704152d commit 94333bc
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SET( ${PROJECT_NAME}_Variant "Full" ) # the particular variant of CaPTk (Full/Ne

SET( PROJECT_VERSION_MAJOR 0 )
SET( PROJECT_VERSION_MINOR 0 )
SET( PROJECT_VERSION_PATCH 6 )
SET( PROJECT_VERSION_PATCH 7 )
SET( PROJECT_VERSION_TWEAK )

# check for the string "nonRelease" in the PROJECT_VERSION_PATCH variable
Expand Down
2 changes: 1 addition & 1 deletion OpenFederatedLearning
9 changes: 0 additions & 9 deletions docs/runningApplication.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,6 @@ The aforementioned command will perform the following steps:
- Leverage the GPU
- Perform full-image validation during training
**NOTE**: If you run into "CUDA out of memory" issues, please run the following command, instead:
```bash
${fets_root_dir}/bin/FeTS_CLI -d /path/to/output/DataForFeTS \ # input data, ensure "final_seg" is present for each subject
-c ${collaborator_common_name} \ # common collaborator name created during setup
-g 1 -t 1 # request gpu and enable training mode
-vp 1 # performs patch-based validation
```
[Back To Top ↑](#table-of-contents)
---
Expand Down
7 changes: 6 additions & 1 deletion docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
## Requirements

- OS: Linux (Ubuntu 18.04) [note that Ubuntu 20.04 does **not** work, and we will support Windows for Phase-2]
- Python 3.6+: we have tested on [Python distributed by Anaconda](https://www.anaconda.com/products/individual) 3.6, 3.7
- Python 3.6+: we have tested on [Python distributed by Anaconda](https://www.anaconda.com/products/individual) 3.6, 3.7, 3.8
Example installation on Ubuntu 18.04:
```bash
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.6 python3.6-venv python3.6-dev python3-setuptools
```
- When using Anaconda, simply activate an environment with either of the following versions of python **before** starting the installation:
- 3.6.5
- 3.7
- 3.8
- **NOTE**: Python 3.9 does **not** work with underlying dependencies
- GPU: for faster training and inference
- [CUDA 9.2 - 10.2](https://developer.nvidia.com/cuda-toolkit)
- **Note**: CUDA 11 is currently _not_ supported
Expand Down
7 changes: 7 additions & 0 deletions scripts/linux-makeself
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ install_captk () {
cd ${target_dir}/squashfs-root/usr/bin/OpenFederatedLearning
doc_setup=https://fets-ai.github.io/Front-End/setup#set-up-the-environment
nnunet_link=https://upenn.box.com/shared/static/f7zt19d08c545qt3tcaeg7b37z6qafum.zip
max=8
ver=`python3 -c 'import sys; print(sys.version_info.minor)'`
if [ "$ver" -gt "$max" ]; then
echo "Python version >3.8 detected, please change default version to either 3.6.5, 3.7 or 3.8"
exit 1
fi

echo "Setting up the Python environment for OpenFederatedLearning..."
if make install_openfl ; then
./venv/bin/pip install torch==1.7.1+cu92 torchvision==0.8.2+cu92 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
Expand Down
34 changes: 23 additions & 11 deletions src/applications/FeTS_CLI.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ int main(int argc, char** argv)
parser.addOptionalParameter("lF", "labelFuse", cbica::Parameter::STRING, "STAPLE,ITKVoting,SIMPLE,MajorityVoting", "The label fusion strategy to follow for multi-arch inference", "Comma-separated values for multiple options", "Defaults to: " + fusionMethod);
parser.addOptionalParameter("g", "gpu", cbica::Parameter::BOOLEAN, "0-1", "Whether to run the process on GPU or not", "Defaults to '0'");
parser.addOptionalParameter("c", "colName", cbica::Parameter::STRING, "", "Common name of collaborator", "Required for training");
parser.addOptionalParameter("vp", "valPatch", cbica::Parameter::BOOLEAN, "0-1", "Whether to perform per-patch validation or not", "Used for training, defaults to '0'");
// parser.addOptionalParameter("vp", "valPatch", cbica::Parameter::BOOLEAN, "0-1", "Whether to perform per-patch validation or not", "Used for training, defaults to '0'");

parser.addApplicationDescription("This is the CLI interface for FeTS");
parser.addExampleUsage("-d /path/DataForFeTS -a deepMedic,nnUNet -lF STAPLE,ITKVoting,SIMPLE -g 1 -t 0", "This command performs inference using deepMedic,nnUNet using multiple fusion strategies on GPU and saves in data directory");
parser.addExampleUsage("-d /path/DataForFeTS -t 1 -g 1 -c upenn", "This command starts training performs inference using deepMedic,nnUNet using multiple fusion strategies on GPU and saves in data directory");

bool gpuRequested = false, trainingRequested = false, patchValidation = false;
bool gpuRequested = false, trainingRequested = false, patchValidation = true;

parser.getParameterValue("d", dataDir);
parser.getParameterValue("t", trainingRequested);
Expand All @@ -60,7 +60,7 @@ int main(int argc, char** argv)
}
else
{
loggingDir = cbica::createTemporaryDirectory() + "/logs";
loggingDir = dataDir + "/logs";
std::cout << "Using the following directory as logging directory: " << loggingDir << "\n";
cbica::createDir(loggingDir);
}
Expand All @@ -76,10 +76,10 @@ int main(int argc, char** argv)
std::cerr << "Collaborator name is required to beging training; please specify this using '-c'.\n";
return EXIT_FAILURE;
}
if (parser.isPresent("vp"))
{
parser.getParameterValue("vp", patchValidation);
}
// if (parser.isPresent("vp"))
// {
// parser.getParameterValue("vp", patchValidation);
// }
}
else
{
Expand Down Expand Up @@ -418,7 +418,7 @@ int main(int argc, char** argv)
if (!cbica::fileExists(split_info_val))
{
auto full_plan_path = hardcodedOpenFLPath + hardcodedPlanName;
auto command_to_run = hardcodedPythonPath + " " + hardcodedOpenFLPath + "submodules/Algorithms/fets/bin/initialize_split_info.py -pp " + full_plan_path + " -dp " + dataDir;
auto command_to_run = hardcodedPythonPath + " " + hardcodedOpenFLPath + "submodules/Algorithms/fets_ai/bin/initialize_split_info.py -pp " + full_plan_path + " -dp " + dataDir;
if (std::system(command_to_run.c_str()) != 0)
{
std::cerr << "Initialize split did not work, continuing with validation.\n";
Expand All @@ -431,7 +431,7 @@ int main(int argc, char** argv)
bool firstRow = true;
int row_index = -1;
auto regions_of_interest = { "WT", "TC", "ET" },
measures_of_interest = { "Dice", "Hausdorff95" };
measures_of_interest = { "Dice", "Hausdorff95", "Sensitivity", "Specificity" };

auto yaml_config_to_send = YAML::Node();
auto yaml_config_internal = YAML::Node();
Expand All @@ -457,11 +457,23 @@ int main(int argc, char** argv)
auto subject_id = cell;
auto subject_index_str = std::to_string(row_index);

bool previous_validation_file_is_okay = true;

if (yaml_config_internal[subject_id]) // check if subject is present in internal validation file
{
yaml_config_to_send[subject_index_str] = yaml_config_internal[subject_id]; // if present, take all stats from there
auto to_check = yaml_config_internal[subject_id]["WT"];
if (!yaml_config_internal[subject_id]["WT"]["Sensitivity"]) // check if sensitivity is present for subject
{
previous_validation_file_is_okay = false;
}
}
else // otherwise, run the stats calculation
else
{
previous_validation_file_is_okay = false;
}

if (!previous_validation_file_is_okay)
{
auto current_subject_folder = dataDir + "/" + subject_id;
auto final_seg = current_subject_folder + "/" + subject_id + "_final_seg.nii.gz";
Expand Down Expand Up @@ -536,7 +548,7 @@ int main(int argc, char** argv)
std::string fullCommandToRun = hardcodedPythonPath + " " + fetsApplicationPath;
fullCommandToRun += "/OpenFederatedLearning/bin/run_collaborator_from_flplan.py";

auto temp_args = args + " -p " + hardcodedPlanName + ".yaml" + " -bsuf " + validation_to_send;
auto temp_args = args + " -p " + hardcodedPlanName + ".yaml" + " -bsuf " + validation_to_send + " -nlo";

std::cout << "Starting training...\n";

Expand Down

0 comments on commit 94333bc

Please sign in to comment.