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

Make sanitize section deletion non-recursive #107

Merged
merged 7 commits into from
Jun 3, 2022

Conversation

eleftherioszisis
Copy link
Contributor

@eleftherioszisis eleftherioszisis commented Jun 2, 2022

When a zero length section is encountered, the sanitization deleted the entire subtree.

This change limits the deletion to the zero-length section only. If a root section with zero length is encountered, an error will be raised.

#99 #105 #106

@eleftherioszisis
Copy link
Contributor Author

eleftherioszisis commented Jun 2, 2022

Before fixing the rest of the tests that use morphologies with zero length root sections, I wonder if raising an error is the desirable way to go.

Alternatively, we could skip the root sections that have zero lengths and emit a warning. This less aggressive approach would allow to sanitize a morphology even if it has zero length root sections. The root sections would be left untouched.

@mgeplf @FrancescoCasalegno @lidakanari @arnaudon @adrien-berchet

@adrien-berchet
Copy link
Member

adrien-berchet commented Jun 2, 2022

But that we would end up with sanitized neurites (the ones whose root section has length > 0) and with not sanitized neurites (the ones with 0-length root section), which is a bit weird, isn't it? Or maybe we could still sanitize all the sections except the root when it has length = 0?

@eleftherioszisis
Copy link
Contributor Author

But that we would end up with sanitized neurites (the ones whose root section has length > 0) and with not sanitized neurites (the ones with 0-length root section), which is a bit weird, isn't it? Or maybe we could still sanitize the all sections except the root when it has length = 0?

I rephrased the last sentence. I meant to sanitize the length of all sections but the root ones. Sorry, for the confusion.

@adrien-berchet
Copy link
Member

adrien-berchet commented Jun 2, 2022

But that we would end up with sanitized neurites (the ones whose root section has length > 0) and with not sanitized neurites (the ones with 0-length root section), which is a bit weird, isn't it? Or maybe we could still sanitize all the sections except the root when it has length = 0?

I rephrased the last sentence. I meant to sanitize the length of all sections but the root ones. Sorry, for the confusion.

Ah ok ok, sorry I miss understood. I agree with that then :)

@FrancescoCasalegno
Copy link

Alternatively, we could skip the root sections that have zero lengths and emit a warning. This less aggressive approach would allow to sanitize a morphology even if it has zero length root sections. The root sections would be left untouched.

Hi @eleftherioszisis ! As far as I understand there is no 100% clear reason why cannot just have 0-length root sections (NEURON or something else may break?), but as we discussed yesterday it seems dangerous to leave them there.

Now, how do we handle those 0-length root sections during sanitize? These seems to be the options:

  1. We leave the 0-length root sections there, and potentially just log a Warning so the user. --- But then NEURON or other BBP tool may fail.
  2. We drop the entire sub-tree. --- But this makes the output morphology almost unusable for all practical purposes.
  3. We extend the 0-length to be of min_len > 0. --- But this may not be what all users want, so better to do it elsewhere (see Fix 0-length root sections in CheckNeurites task morphology-workflows#31).

So, since there was no agreement on the what is the most "logical" solution to the issue, I think that raising an Error may be a good solution. An alternative would be to create a parameter if_zero_root_len that defines how to behave (e.g. if_zero_root_len: Literal["raise", "ignore", "extend"]) but @mgeplf said we don't want to have thousands of parameters (also: what would be the default of this parameter anyway? we are back to starting point...)

@eleftherioszisis
Copy link
Contributor Author

So, since there was no agreement on the what is the most "logical" solution to the issue, I think that raising an Error may be a good solution. An alternative would be to create a parameter if_zero_root_len that defines how to behave (e.g. if_zero_root_len: Literal["raise", "ignore", "extend"]) but @mgeplf said we don't want to have thousands of parameters (also: what would be the default of this parameter anyway? we are back to starting point...)

Sure, I prefer raising an error to adding a parameter too. I will keep it strict, thanks.

@mgeplf
Copy link
Contributor

mgeplf commented Jun 2, 2022

I think that raising an Error may be a good solution.

I second raising an error; warning tend to get ignored, IMO, and parameters opens the pandoras box for having options for all the sanitization.

@@ -6,68 +6,72 @@
DATA = Path(__file__).parent / 'data'


def _run(command):
Copy link
Contributor Author

@eleftherioszisis eleftherioszisis Jun 2, 2022

Choose a reason for hiding this comment

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

The changes in this module are just some refactoring mainly for not filtering the exception when an error is thrown and some formatting. You can ignore them.

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

Successfully merging this pull request may close these issues.

5 participants