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

ENH: Add loadable warning in case of loading failure #7163

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cpoetteCertis
Copy link
Contributor

The loadable warning flag can be used to manage loading failure if not empty

@jcfr
Copy link
Member

jcfr commented Aug 11, 2023

Thanks for the contribution 🙏

Could you provide more details regarding the workflow that required you to explicitly set the warning attribute of the DICOMLoadable 1 ?

My understanding is that the warning is usually set in the loading code of specific plugin. I suspect a specific plugin is not setting the warning attribute which in turn prevent the following code from working as expected:

def warnUserIfLoadableWarningsAndProceed(self):
warningsInSelectedLoadables = False
details = ""
for plugin in self.loadablesByPlugin:
for loadable in self.loadablesByPlugin[plugin]:
if loadable.selected and loadable.warning != "":
warningsInSelectedLoadables = True
logging.warning(_('Warning in DICOM plugin {load_type} when examining loadable {name}: {message}').format(
load_type=plugin.loadType, name=loadable.name, message=loadable.warning))
details += loadable.name + " [" + plugin.loadType + "]: " + loadable.warning + "\n"
if warningsInSelectedLoadables:
warning = _("Warnings detected during load. Examine data in Advanced mode for details. Load anyway?")
if not slicer.util.confirmOkCancelDisplay(warning, parent=self, detailedText=details):
return False
return True

cc: @pieper @lassoan

Footnotes

  1. https://github.com/Slicer/Slicer/blob/3f64c3780139447be3b0f2bbee3896dd3716ac54/Modules/Scripted/DICOMLib/DICOMPlugin.py#L24-L64

@lassoan
Copy link
Contributor

lassoan commented Aug 11, 2023

I agree that it could be useful to provide a mechanism to determine result of a loading, but warning property of DICOMLoadable class is used for something else (for storing result of examine step as a user-displayable warning message), so we should not overwrite this property during loading.

We could specify new properties in the loadable, such as loadingSuccess (True or False) and loadingMessage (user-displayable message about the loading result). Or, we could add an optional loadSuccess (list of flags, one for each loadable) or loadResults argument (list of success flag, message, maybe evennodeIDs for each loadable) to loadLoadables method that would return more detailed information about which loadable failed and why.

@cpoetteCertis Could you write a bit more about your use case? What information do you need and what do you do with it?

@cpoetteCertis
Copy link
Contributor Author

Dear All,

Both solutions seems suitable for us!

Here are more details:
Depending on the loading issues, a node can be added (for example if irregular volume geometry is detected, the user can keep it or discard it). In that case, we need to provide all the necessary information for the given patient.
Or the node is not added (for example if a scalar volume could not be loaded), in that case, no need to go further.

The problem is that currently we have no information about the loading state.

Thanks to this modification, we simply check if the warning message is empty (success) or not empty (failure or issue while loading). If it is not empty, we do checks to know if a node has been created or not...

But with your suggestions, it could be much easier!

@lassoan
Copy link
Contributor

lassoan commented Aug 12, 2023

@jcfr do you have any preference (add a list argument that is updated with loading status; add properties to each loadable object)?

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

Successfully merging this pull request may close these issues.

None yet

3 participants