Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShapeWorks Optimize needs some input verification #910

Open
akenmorris opened this issue Jan 22, 2021 · 17 comments
Open

ShapeWorks Optimize needs some input verification #910

akenmorris opened this issue Jan 22, 2021 · 17 comments

Comments

@akenmorris
Copy link
Contributor

akenmorris commented Jan 22, 2021

Many users and developers struggle with crashes in ShapeWorks Optimize step that are the result of grooming errors and other input errors. It would be nice if the optimizer did some input verification before running.

Some things that could be checked:

  1. DT inputs are actually DTs
  2. Surface on DT doesn't run off the end of the image (e.g. needs more padding)
  3. ...

Mesh : confirm mesh is manifold.

Others?

@medakk
Copy link
Contributor

medakk commented Jan 22, 2021

Here's an example of the surface clipping the domain:

image

(in this instance, the optimizer would crash complaining about the narrow band)

@akenmorris
Copy link
Contributor Author

akenmorris commented Jan 22, 2021

Thanks, @medakk , good example. We will need to add the nrrd files to our tests (once we have the checks)

@iyerkrithika21
Copy link
Contributor

Thanks, @medakk , good example. We will need to add the nrrd files to our tests (once we have the checks)

I can share the files which have such clipping.

@medakk
Copy link
Contributor

medakk commented Jan 27, 2021

+optimize should check whether the provided XML file actually exists. Currently it exits with a vague error:

Could not parse XML
Inconsistency in parameters... m_domains_per_shape != m_number_of_particles.size()

@medakk
Copy link
Contributor

medakk commented Jan 27, 2021

+if the an input filename doesn't exist, optimize should exit immediately. currently it floods the terminal with other diagnostic info and makes it hard to realize the actual problem

+if the output dir is /existing_folder/folder_that_doesnt_exist/another_folder_that_doesnt_exist/ optimize just segfaults. check for this

@iyerkrithika21
Copy link
Contributor

Not sure if you have covered this scenario in the previous comments.
When a list of meshes/segs/images is passed to the optimize function, it should check if the list is empty or not. Right now it crashes with the following error message :

Unzipping Data/ellipsoid_md_dist.zip into Output/ellipsoid_md_dist/
CALLING OPTIMIZATION CODE
Output/ellipsoid_md_dist/shape_models/correspondence_512_512.xml
'optimize' FAILED: basic_string::_M_construct null not valid
General exception caught.
	Returncode: 1
	Output: None

@akenmorris
Copy link
Contributor Author

+if the an input filename doesn't exist, optimize should crash immediately.

I assume you mean exit, not crash? :)

@medakk
Copy link
Contributor

medakk commented Jan 27, 2021

@iyerkrithika21 Thanks!

@akenmorris Yikes, yes. :'D

@medakk
Copy link
Contributor

medakk commented Mar 9, 2021

@iyerkrithika21
Copy link
Contributor

iyerkrithika21 commented Jun 2, 2021

When running a use case with segmentations/dt images, if the parameter dictionary has domain type "mesh" then the optimize command breaks with the message unable to read the file.nrrd.
It would be nice to see a message that says the domain type and the input file extension are not compatible.

@patkins
Copy link

patkins commented Jul 7, 2021

  • If the domain_type is not recognized, the error implies as issue with reading the file, not with the parameter input.
Reading inputfile: ../aligned/dod_n02_R_femur_aligned.vtk...
'optimize' FAILED: /home/runner/install/include/ITK-5.0/itkImageFileReader.hxx:136:
 Could not create IO object for reading file ../aligned/dod_n02_R_femur_aligned.vtk
  Tried to create one of the following:
    BMPImageIO
    BioRadImageIO
    Bruker2dseqImageIO
    GDCMImageIO
    GE4ImageIO
    GE5ImageIO
    GiplImageIO
    HDF5ImageIO
    JPEGImageIO
    JPEG2000ImageIO
    LSMImageIO
    MINCImageIO
    MRCImageIO
    MetaImageIO
    NiftiImageIO
    NrrdImageIO
    PNGImageIO
    StimulateImageIO
    TIFFImageIO
    VTKImageIO
  You probably failed to set a file suffix, or
    set the suffix to an unsupported type.

@patkins
Copy link

patkins commented Jul 7, 2021

+The error for issues with cutting plane input assumes that too few cutting plane inputs were provided, maybe the error could instead state how many were read and how many were expected. Further it does not seem to check whether the length of num_planes_per_input matches the length of cutting_planes.
(Running a multi-domain model with a cutting plane, I assumed I needed to have a plane for each input, not each domain, based on the parameter name, so the naming and/or logic behind this could also be re-evaluated.)

ERROR: Incomplete cutting plane data! Number of cutting planes for every input shape is required!!
terminate called after throwing an instance of 'int'
Aborted (core dumped)

@patkins
Copy link

patkins commented Jul 16, 2021

+When using normals in an xml, parameters of use_xyz, mesh_based_parameters, and attribute_scales are needed in addition to use_normals, if not included shapeworks optimize with segmentation fault or not use normals without any error message.

@akenmorris akenmorris removed this from the 6.2 Release (August 2021) milestone Aug 7, 2021
@akenmorris
Copy link
Contributor Author

Another example, if a distance transform gets resampled incorrectly, it can become invalid. For example, we came across a DT generated by some old python/bash scripts with 0.5 isotropic spacing. Inspection of the DT showed that near the 0 level set border, values of 0.308 and then -0.692, these add up to 1.0 and indicate the the DT was generated when the spacing was 1.0. A pixel of -0.692 with spacing 0.5 is telling us the border is more than one pixel away, yet the neighboring pixel says it's 0.308 the other direction.

Running Distance Transform from Studio Groom on this correctly fixes is to values such as 0.152 and -0.349 (0.5 between them, matching the spacing).

These invalid DTs do not crash ShapeWorks, but they cause it to make nearly zero progress in optimization. The particles bounce around in place and generally can't move. Profiling shows all time is spending following vectors in the gradient image.

@HeavenlyBerserker
Copy link
Contributor

@akenmorris Are there any actionable items for me on this issue? We can discuss this if you like.

@akenmorris
Copy link
Contributor Author

@HeavenlyBerserker , Karthik's comment to you when he added you was:

verify if constraints create multiple (disjoint) components @HeavenlyBerserker

I assume he means that we would check if the constraint creates unreachable islands?

I don't know if we really need to do that, but I suppose we could.

@HeavenlyBerserker
Copy link
Contributor

Yeah, pretty sure that's what he meant. That should be easy and might be useful. I'll do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants