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

Catch error in case of image/mask geometry mismatch #252

Merged
merged 5 commits into from
May 16, 2017

Conversation

JoostJM
Copy link
Collaborator

@JoostJM JoostJM commented May 3, 2017

Catch the error in checkMask and print out user-friendly error message. Then return None to prevent further feature extraction with this invalid image/mask combination.

Fixes #251

lsif.Execute(imageNode, maskNode)
except RuntimeError as e:
if "Both images for LabelStatisticsImageFilter don't match type or dimension!" in e.message:
logger.error('Image/Mask datatype or size mismatch. Potential solution: enable resampling')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be very helpful to point to the specific section of documentation on how this can be done!

@fedorov
Copy link
Collaborator

fedorov commented May 3, 2017

Would be good to also update the documentation in the same PR to clarify the instructions about how to implement the suggestions made in the error messages.

@fedorov
Copy link
Collaborator

fedorov commented May 10, 2017

@JoostJM sorry, I am still missing the location in the documentation that specifies: 1) how to toggle resampling of the mask to the image raster; 2) how to change tolerance for SimpleITK geometry comparison operations. The comments contributed in the commit below provide explanation that would require modifying the code, or running an extra script. I thought you said it is possible to control those options from the yml configuration file - is this correct?

Also, where in the documentation all the parameters that can be passed using the configuration file described? I think it would be nice to have those in one location. What do you think?

@JoostJM
Copy link
Collaborator Author

JoostJM commented May 10, 2017

@fedorov, it is currently only possible to control resampling in general (i.e. resampling of both image and mask) from the yml file. However, I will add to parameters to control the global tolerance used by SimpleITK and a parameter to specify wheter to try to resample the mask if that geometry does not match.
The latter will 'fail' if the ROI in the mask contains areas outside the physical space of the image.

@JoostJM
Copy link
Collaborator Author

JoostJM commented May 10, 2017

Moreover, I am restructuring the documentation a bit, by adding documentation on customizing the extraction to the "usage" section, with additionally some documentation on setting up logging and how the parameter file works. Most of it is already documented, but at the start of the feature extractor module, which maybe not the best location.

@JoostJM
Copy link
Collaborator Author

JoostJM commented May 10, 2017

@fedorov, this last commit only represents the restructuring of the documentation, still working on the 2 paramters I want to add.

JoostJM added 3 commits May 15, 2017 13:56
Catch the error in checkMask and print out user-friendly error message. Then return None to prevent further feature extraction with this invalid image/mask combination.
Add documentation on what goes wrong in case of geometry errors and how to fix it. Also include reference to this in the error message that is logged. Add the SimpleITK stacktrace as a debug-level log message in case of geometry errors.

Additionally, add more extensive documentation on how to set up logging (both to output and/or log file) in interactive and commandline usage of PyRadiomics.
Remove global PyRadiomics Function `debug`, the functionality exposed by this function is already covered by `setVerbosity`.
Add section on customizing the extraction in the "Usage" section. Here, specify what and how the extraction can be customized in PyRadiomics.
For this, move the documentation of the possible settings from the docstring in the featureextractor module to this new section. Also move the documentation that explains how the parameter file works.

Change the name of `self.kwargs` to `self.settings` in the feature extractor module, this better reflects what that variable holds.

 Make the distances setting only affect the GLCM (distance to neighbor should always be 1 in GLRLM and GLSZM).
@JoostJM JoostJM force-pushed the checkMask-update branch 5 times, most recently from b3a4ccc to 53b394c Compare May 15, 2017 12:54
Add two parameter to specify how to handle geometry mismatch between image and mask.

`geometryTolerance` controls the default global tolerance used by SimpleITK and set in ProcessObject.
`correctMask` will attempt to resample the mask to the image geometry if a mismatch occurs. Prior to resampling, the mask is checked for ROI validity.

Update documentation accordingly.
@JoostJM JoostJM force-pushed the checkMask-update branch from 53b394c to 5f83aba Compare May 15, 2017 13:05
The helloRadiomics notebook was failing due to an error that was thrown by the Click progressbar. Remove the Click progressbar example, as it also does not render the progressbar if the output is not a terminal (as is the case in a jupyter notebook).
@JoostJM JoostJM force-pushed the checkMask-update branch from 756bfcf to 1b69bdd Compare May 16, 2017 06:39
@JoostJM JoostJM merged commit cb35d66 into AIM-Harvard:master May 16, 2017
@JoostJM JoostJM deleted the checkMask-update branch June 8, 2017 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants