From 55ea6bfb6efed51c560f935c2713d3de80942f54 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Thu, 10 Aug 2017 16:05:48 -0500 Subject: [PATCH] ... --- appli/CTBronchi/CTBronchi_process.sh | 96 ++++++++++++++++++---------- appli/CTBronchi/MoriSegmentation.cxx | 29 +++------ appli/CTBronchi/Process.cxx | 28 ++++++++ lib/fpa/Base/Mori.h | 9 --- 4 files changed, 99 insertions(+), 63 deletions(-) create mode 100644 appli/CTBronchi/Process.cxx diff --git a/appli/CTBronchi/CTBronchi_process.sh b/appli/CTBronchi/CTBronchi_process.sh index 26257be..f22b699 100755 --- a/appli/CTBronchi/CTBronchi_process.sh +++ b/appli/CTBronchi/CTBronchi_process.sh @@ -1,45 +1,74 @@ #!/bin/bash ## Command line arguments -if [ "$#" -lt 5 ]; then - echo "Usage: $0 input_image [index/point] seed_x seed_y seed_z" +while [[ "$#" -gt 1 ]]; do + key="$1" + case $key in + -input) + input="$2" + shift + ;; + -seed) + sx="$2" + sy="$3" + sz="$4" + shift + ;; + -mori) + mori="$2" + shift + ;; + -labels) + labels="$2" + shift + ;; + -output) + output="$2" + shift + ;; + *) + # Do nothing + ;; + esac + shift +done +if [ -z "$input" ] || [ -z "$sx" ] || [ -z "$sy" ] || [ -z "$sz" ]; then + (>&2 echo "Usage: $0 -input input_raw_image -seed x y z [-mori mori_image_dfilename] [-labels labels_image_filename] [-output output_image_filename] [-mori_init_threshold value] [-mori_end_threshold value] [-mori_delta value] [-mori_minimum_threshold value] [-mori_inside_value value] [-mori_outside_value value] [-mori_signal_kernel_size value] [-mori_signal_threshold value] [-mori_signal_influence value] [-label_upper_threshold value] [-label_inside value] [-label_outside value] [-random_walker_beta value]") exit 1 fi +if [ -z "$mori_init_threshold" ]; then mori_init_threshold="-1024"; fi +if [ -z "$mori_end_threshold" ]; then mori_end_threshold="0"; fi +if [ -z "$mori_delta" ]; then mori_delta="1"; fi +if [ -z "$mori_minimum_threshold" ]; then mori_minimum_threshold="-850"; fi +if [ -z "$mori_inside_value" ]; then mori_inside_value="255"; fi +if [ -z "$mori_outside_value" ]; then mori_outside_value="0"; fi +if [ -z "$mori_signal_kernel_size" ]; then mori_signal_kernel_size="20"; fi +if [ -z "$mori_signal_threshold" ]; then mori_signal_threshold="500"; fi +if [ -z "$mori_signal_influence" ]; then mori_signal_influence="0.5"; fi +if [ -z "$label_upper_threshold" ]; then label_upper_threshold="-600"; fi +if [ -z "$label_inside" ]; then label_inside="1"; fi +if [ -z "$label_outside" ]; then label_outside="2"; fi +if [ -z "$random_walker_beta" ]; then random_walker_beta="20"; fi + +base_name=`dirname $input`/`basename $input .mhd` +if [ -z "$mori" ]; then + mori="$base_name"_mori.mhd +fi +signal="$mori"_signal.txt +if [ -z "$labels" ]; then + labels="$base_name"_labels.mhd +fi +if [ -z "$output" ]; then + output="$base_name"_rw.mhd +fi exec_dir=`dirname $0` mori_seg=`dirname $0`/fpa_CTBronchi_MoriSegmentation mori_lab=`dirname $0`/fpa_CTBronchi_MoriLabelling random_walker=`dirname $0`/fpa_CTBronchi_RandomWalker -input_image=$1 -seed_type=$2 -seed_x=$3 -seed_y=$4 -seed_z=$5 - -base_name=`dirname $input_image`/`basename $input_image .mhd` - -mori_output_image="$base_name"_mori.mhd -mori_output_signal="$base_name"_mori_signal.txt -mori_init_threshold=-1024 -mori_end_threshold=0 -mori_delta=1 -mori_minimum_threshold=-850 -mori_inside_value=255 -mori_outside_value=0 -mori_signal_kernel_size=20 -mori_signal_threshold=500 -mori_signal_influence=500 - -labels_output_image="$base_name"_labels.mhd -label_upper_threshold=-600 -label_inside=1 -label_outside=2 - -random_walker_output_image="$base_name"_rw.mhd -random_walker_beta=20 $mori_seg \ - $input_image $mori_output_image $mori_output_signal \ + $input $mori $signal \ $mori_init_threshold \ $mori_end_threshold \ $mori_delta \ @@ -49,18 +78,17 @@ $mori_seg \ $mori_signal_kernel_size \ $mori_signal_threshold \ $mori_signal_influence \ - $seed_type \ - $seed_x $seed_y $seed_z + $sx $sy $sz $mori_lab \ - $input_image $mori_output_image $labels_output_image \ + $input $mori $labels \ $label_upper_threshold \ $mori_inside_value \ $label_inside \ $label_outside $random_walker \ - $input_image $labels_output_image $random_walker_output_image \ + $input $labels $output \ $label_inside \ $random_walker_beta diff --git a/appli/CTBronchi/MoriSegmentation.cxx b/appli/CTBronchi/MoriSegmentation.cxx index 0b26649..39b9e0d 100644 --- a/appli/CTBronchi/MoriSegmentation.cxx +++ b/appli/CTBronchi/MoriSegmentation.cxx @@ -17,17 +17,17 @@ typedef fpa::Image::Mori< TInputImage, TLabelImage > TFilter; int main( int argc, char* argv[] ) { // Get arguments - if( argc < 17 ) + if( argc < 16 ) { std::cerr << "Usage: " << argv[ 0 ] << std::endl << " input_image output_image output_signal" << std::endl - << " init_threshold(-1024) end_threshold(0) delta(1)" << std::endl - << " minimum_threshold(-850)" << std::endl - << " inside_value(255) outside_value(0)" << std::endl - << " signal_kernel_size(20) signal_threshold(500) signal_influence(0.5)" + << " init_threshold end_threshold delta" << std::endl + << " minimum_threshold" << std::endl + << " inside_value outside_value" << std::endl + << " signal_kernel_size signal_threshold signal_influence" << std::endl - << " [index/point] seed_x seed_y seed_z" + << " seed_x seed_y seed_z" << std::endl; return( 1 ); @@ -44,17 +44,9 @@ int main( int argc, char* argv[] ) unsigned long signal_kernel_size = std::atoi( argv[ 10 ] ); double signal_threshold = std::atof( argv[ 11 ] ); double signal_influence = std::atof( argv[ 12 ] ); - std::string seed_type = argv[ 13 ]; - TInputImage::IndexType iseed; TInputImage::PointType pseed; - for( unsigned int i = 0; i < Dim; ++i ) - { - if( seed_type == "index" ) - iseed[ i ] = std::atoi( argv[ 14 + i ] ); - else - pseed[ i ] = std::atof( argv[ 14 + i ] ); - - } // rof + for( int i = 0; i < Dim; ++i ) + pseed[ i ] = std::atof( argv[ 13 + i ] ); // Read image itk::ImageFileReader< TInputImage >::Pointer input_image_reader = @@ -64,10 +56,7 @@ int main( int argc, char* argv[] ) // Prepare filter TFilter::Pointer filter = TFilter::New( ); filter->SetInput( input_image_reader->GetOutput( ) ); - if( seed_type == "index" ) - filter->SetSeed( iseed ); - else - filter->SetSeed( pseed ); + filter->SetSeed( pseed ); filter->SetThresholds( init_threshold, end_threshold, delta ); filter->SetMinimumThreshold( minimum_threshold ); filter->SetInsideValue( inside_value ); diff --git a/appli/CTBronchi/Process.cxx b/appli/CTBronchi/Process.cxx new file mode 100644 index 0000000..8fb3e17 --- /dev/null +++ b/appli/CTBronchi/Process.cxx @@ -0,0 +1,28 @@ +int main( int argc, char* argv[] ) +{ + /* TODO + -input input_raw_image + -seed x y z + [-mori mori_image_dfilename] + [-labels labels_image_filename] + [-output output_image_filename] + */ + + /* TODO + if [ -z "$mori_init_threshold" ]; then mori_init_threshold="-1024"; fi + if [ -z "$mori_end_threshold" ]; then mori_end_threshold="0"; fi + if [ -z "$mori_delta" ]; then mori_delta="1"; fi + if [ -z "$mori_minimum_threshold" ]; then mori_minimum_threshold="-850"; fi + if [ -z "$mori_inside_value" ]; then mori_inside_value="255"; fi + if [ -z "$mori_outside_value" ]; then mori_outside_value="0"; fi + if [ -z "$mori_signal_kernel_size" ]; then mori_signal_kernel_size="20"; fi + if [ -z "$mori_signal_threshold" ]; then mori_signal_threshold="500"; fi + if [ -z "$mori_signal_influence" ]; then mori_signal_influence="0.5"; fi + if [ -z "$label_upper_threshold" ]; then label_upper_threshold="-600"; fi + if [ -z "$label_inside" ]; then label_inside="1"; fi + if [ -z "$label_outside" ]; then label_outside="2"; fi + if [ -z "$random_walker_beta" ]; then random_walker_beta="20"; fi + */ + + return( 0 ); +} diff --git a/lib/fpa/Base/Mori.h b/lib/fpa/Base/Mori.h index e7ea726..0cc7a24 100644 --- a/lib/fpa/Base/Mori.h +++ b/lib/fpa/Base/Mori.h @@ -33,15 +33,6 @@ namespace fpa typedef typename _TAlgorithm::TTraits TTraits; fpa_Base_TraitTypes( typename TTraits ); - /* TODO - typedef typename _TAlgorithm::TNode TNode; - typedef typename _TAlgorithm::TNodes TNodes; - typedef typename _TAlgorithm::TInputValue TInputValue; - typedef typename _TAlgorithm::TOutputValue TOutputValue; - typedef typename _TAlgorithm::TFrontId TFrontId; - typedef typename _TAlgorithm::TVertex TVertex; - */ - typedef std::deque< TNode > TQueue; typedef std::set< TInputValue > TThresholds; -- 2.47.1