X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=segmentation%2FclitkExtractPatientFilter.txx;h=bf84ef79de31c6a8077005af82034aa005371b09;hb=5668d4a49a5a6b68dc80fa28f0f82b54187cb70c;hp=e9dd6fe57bd8da7f034b7c27634c99376ebbccad;hpb=ed06e00b83f159033fdb9f0982a409833d9bffab;p=clitk.git diff --git a/segmentation/clitkExtractPatientFilter.txx b/segmentation/clitkExtractPatientFilter.txx index e9dd6fe..bf84ef7 100644 --- a/segmentation/clitkExtractPatientFilter.txx +++ b/segmentation/clitkExtractPatientFilter.txx @@ -35,11 +35,12 @@ #include "itkCastImageFilter.h" //-------------------------------------------------------------------- -template -clitk::ExtractPatientFilter:: +template +clitk::ExtractPatientFilter:: ExtractPatientFilter(): clitk::FilterBase(), - itk::ImageToImageFilter() + clitk::FilterWithAnatomicalFeatureDatabaseManagement(), + itk::ImageToImageFilter() { this->SetNumberOfRequiredInputs(1); SetBackgroundValue(0); // Must be zero @@ -71,16 +72,16 @@ ExtractPatientFilter(): SetLastKeep(1); // Step 4: OpenClose (option) - FinalOpenCloseOn(); - AutoCropOff(); + FinalOpenCloseOff(); + AutoCropOn(); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- -template +template void -clitk::ExtractPatientFilter:: +clitk::ExtractPatientFilter:: SetInput(const TInputImageType * image) { this->SetNthInput(0, const_cast(image)); @@ -89,10 +90,10 @@ SetInput(const TInputImageType * image) //-------------------------------------------------------------------- -template +template template void -clitk::ExtractPatientFilter:: +clitk::ExtractPatientFilter:: SetArgsInfo(ArgsInfoType arg) { SetVerboseOption_GGO(arg); @@ -100,6 +101,8 @@ SetArgsInfo(ArgsInfoType arg) SetWriteStep_GGO(arg); SetVerboseWarningOff_GGO(arg); + SetOutputPatientFilename_GGO(arg); + SetUpperThreshold_GGO(arg); SetLowerThreshold_GGO(arg); @@ -118,20 +121,22 @@ SetArgsInfo(ArgsInfoType arg) SetFinalOpenClose_GGO(arg); SetAutoCrop_GGO(arg); + + SetAFDBFilename_GGO(arg); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- -template +template void -clitk::ExtractPatientFilter:: +clitk::ExtractPatientFilter:: GenerateOutputInformation() { Superclass::GenerateOutputInformation(); input = dynamic_cast(itk::ProcessObject::GetInput(0)); - // OutputImagePointer outputImage = this->GetOutput(0); + // MaskImagePointer outputImage = this->GetOutput(0); // outputImage->SetRegions(input->GetLargestPossibleRegion()); // Get input pointers @@ -209,6 +214,10 @@ GenerateOutputInformation() { relabelFilter2->SetInput(connectFilter2->GetOutput()); relabelFilter2->Update(); working_image = relabelFilter2->GetOutput(); + + // Keep main label + working_image = KeepLabels + (working_image, GetBackgroundValue(), GetForegroundValue(), 1, 1, true); StopCurrentStep(working_image); //-------------------------------------------------------------------- @@ -263,7 +272,7 @@ GenerateOutputInformation() { //-------------------------------------------------------------------- //-------------------------------------------------------------------- // Final Cast - typedef itk::CastImageFilter CastImageFilterType; + typedef itk::CastImageFilter CastImageFilterType; typename CastImageFilterType::Pointer caster= CastImageFilterType::New(); caster->SetInput(working_image); caster->Update(); @@ -274,25 +283,28 @@ GenerateOutputInformation() { // [Optional] if (GetAutoCrop()) { StartNewStep("AutoCrop"); - typedef clitk::AutoCropFilter CropFilterType; + typedef clitk::AutoCropFilter CropFilterType; typename CropFilterType::Pointer cropFilter = CropFilterType::New(); cropFilter->SetInput(output); cropFilter->SetBackgroundValue(GetBackgroundValue()); cropFilter->Update(); output = cropFilter->GetOutput(); - StopCurrentStep(output); + StopCurrentStep(output); } } //-------------------------------------------------------------------- //-------------------------------------------------------------------- -template +template void -clitk::ExtractPatientFilter:: +clitk::ExtractPatientFilter:: GenerateData() { - //this->SetNthOutput(0, output); // -> no because redo filter otherwise + // Final Graft this->GraftOutput(output); + // Store image filename into AFDB + GetAFDB()->SetImageFilename("patient", this->GetOutputPatientFilename()); + WriteAFDB(); } //--------------------------------------------------------------------