shapeworks-users

Text archives Help


Re: [shapeworks-users] Help with parameters for Complex shapes


Chronological Thread 
  • From: Shireen Elhabian <shireen@sci.utah.edu>
  • To: shapeworks-users@sci.utah.edu
  • Cc: Elizabeth Jurrus <liz@sci.utah.edu>, Brig Bagley <brig@sci.utah.edu>, "shireen@sci.utah.edu" <shireen@sci.utah.edu>
  • Subject: Re: [shapeworks-users] Help with parameters for Complex shapes
  • Date: Fri, 31 Jul 2015 13:47:50 -0600

Hi Prabhu,

I made some progress with your data. I hope this might help ….

First of all, I am facing problems with 6.mha and 7.mha since they are out of alignment compared to the other samples. I would really recommend that you start with a set of shapes that share the same bounding box and volume size. Also it is recommended to work with isotropic voxel spacing which is not the case of your data.

Second, you data is suffering from a very low resolution, that is, the voxel spacing is too large compared to the shape complexity that you are having. Hence, any blurring that will be applied to the data will eat up thin structures whose thickness only occupy couple of voxels.  So I have written an itk-based command line tool (kindly see attached) that would allow you to resample your data to smaller voxel size that you can control. 

To test my hypothesis, I have resampled your data to 0.5 isotropic voxel spacing and applied the groom stage, kindly see the below snapshot, you can see that even if a Gaussian blurring has been applied with sigma = 2, we still preserve your shapes structure. 

PNG image



Here is the result of the grooming stage with the same parameters using your original data, as you can see, think structures and even the vertebra itself is overly smoothed ...

PNG image




Hope this helps …

best regards
Shireen

On 07/30/2015 09:36 PM, Prabhu Teja wrote:
Thank you, Rabia. I've tried playing with the sigma of the gaussian (smoothing), but I either end up over smoothing, with loss of image info, or undersmoothing when the generated model is all over the place. Should I be doing something in the image domain itself, that I'm missing out on? 

Regards
Prabhu Teja

On Thu, Jul 30, 2015 at 10:45 PM, Rabia Haq <rhaqx001@odu.edu> wrote:
Hello Prabhu,

It seems  that you might be oversmoothing your images during the groom (image preprocessing) stage. Perhaps your Gaussian blurring kernel is too high? You can save the images in-between preprocessing steps and reconstruct surfaces using Slicer( slicer->volume rendering) to make sure the distance maps you are generating are correct and meaningful. I would also suggest monitoring the number of anti-aliasing iterations, to make sure its not oversmoothing the image boundaries.

best of luck!

regards,

Rabia

Ph.D. Candidate, Research Assistant
Department of Modeling, Simulation and Visualization Engineering,
Old Dominion University,
Norfolk, VA.

On Thu, Jul 30, 2015 at 6:55 AM, Prabhu Teja <prabhuteja12@gmail.com> wrote:
Using the Studio module, one of the main problems I seem to be encountering is with the gaussian smoothing. Without it, the models are bad (very jagged ends), which is not very useful. With a sigma that causes surface smoothness, the attached image is the result. How can this be mitigated?

PNG image



On Thu, Jul 30, 2015 at 9:46 AM, Prabhu Teja <prabhuteja12@gmail.com> wrote:
Hi, 

I'm trying to find the shape models for Vertebra. I'm utterly failing in finding them and I think that might be because of the parameters that I haven't appropriately set. 

Can you please help me with this?

The segmentations are available here. 




--
Prabhu Teja


NOTE: This message was trained as non-spam. If this is wrong, please correct the training as soon as possible.
Spam
Not spam
Forget previous vote




--
Prabhu Teja


#include <fstream>
#include "itkImage.h"
#include "itkIdentityTransform.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkResampleImageFilter.h"
#include "itkNearestNeighborInterpolateImageFunction.h"

int main(int argc, char* argv[])
{
    if(argc < 6){
        std::cerr << "Usage: " << std::endl;
        std::cerr << argv[0] << " Input_File Output_File output_spacing_x output_spacing_y output_spacing_z\n";
        return EXIT_FAILURE;
    }

    const int Dimension = 3;
    typedef unsigned char PixelType;
    typedef itk::Image<PixelType, Dimension> ImageType;
    typedef  itk::ImageFileReader<ImageType> ReaderType;
    typedef  itk::ImageFileWriter<ImageType> WriterType;
    typedef itk::IdentityTransform<double, Dimension> TransformType;
    typedef itk::NearestNeighborInterpolateImageFunction<ImageType, double> InterpolatorType;
    typedef itk::ResampleImageFilter<ImageType, ImageType> ResampleImageFilterType;

    std::string inputfilename  = argv[1];
    std::string outputfilename = argv[2];
    float output_spacing_x     = atof(argv[3]);
    float output_spacing_y     = atof(argv[4]);
    float output_spacing_z     = atof(argv[5]);

    // read input image
    std::ifstream inputfile(inputfilename.c_str());
    if(inputfile.fail()){
        std::cout << "Error reading file: " << inputfilename << "\n";
    }

    ReaderType::Pointer reader = ReaderType::New();
    reader->SetFileName( inputfilename );
    reader ->Update();
    ImageType::Pointer input = reader->GetOutput();

    //    WriterType::Pointer inputWriter = WriterType::New();
    //    inputWriter->SetFileName("input.nrrd");
    //    inputWriter->SetInput(input);
    //    inputWriter->Update();

    ImageType::SizeType inputSize = input->GetLargestPossibleRegion().GetSize();

    std::cout << "Input size: " << inputSize << std::endl;

    // Resample
    //ImageType::SpacingType inputSpacing = input->GetSpacing();
    ImageType::SpacingType outputSpacing;
    outputSpacing[0] = output_spacing_x;
    outputSpacing[1] = output_spacing_y;
    outputSpacing[2] = output_spacing_z;

    ImageType::SizeType outputSize;
    outputSize[0] = std::floor(input->GetSpacing()[0] * (static_cast<double>(inputSize[0]) / static_cast<double>(outputSpacing[0])));
    outputSize[1] = std::floor(input->GetSpacing()[1] * (static_cast<double>(inputSize[1]) / static_cast<double>(outputSpacing[1])));
    outputSize[2] = std::floor(input->GetSpacing()[2] * (static_cast<double>(inputSize[2]) / static_cast<double>(outputSpacing[2])));

    outputSpacing[0] = input->GetSpacing()[0] * (static_cast<double>(inputSize[0]) / static_cast<double>(outputSize[0]));
    outputSpacing[1] = input->GetSpacing()[1] * (static_cast<double>(inputSize[1]) / static_cast<double>(outputSize[1]));
    outputSpacing[2] = input->GetSpacing()[2] * (static_cast<double>(inputSize[2]) / static_cast<double>(outputSize[2]));


    ResampleImageFilterType::Pointer resample = ResampleImageFilterType::New();
    resample->SetInput(input);
    resample->SetSize(outputSize);
    resample->SetOutputSpacing(outputSpacing);
    resample->SetTransform(TransformType::New());
    resample->SetInterpolator(InterpolatorType::New());
    resample->SetOutputOrigin(input->GetOrigin());
    resample->UpdateLargestPossibleRegion();
    resample->Update();

    ImageType::Pointer output = resample->GetOutput();

    std::cout << "Output size: " << output->GetLargestPossibleRegion().GetSize() << std::endl;

    std::cout << "Writing output... " << std::endl;

    WriterType::Pointer outputWriter = WriterType::New();
    outputWriter->SetFileName(outputfilename);
    outputWriter->SetInput(output);
    outputWriter->Update();

    return EXIT_SUCCESS;
}




Archive powered by MHonArc 2.6.18.

Top of page