Skip to content

fix: particle deletion bug#42

Open
daniel-ji wants to merge 1 commit intoFrangakisLab:mainfrom
daniel-ji:main
Open

fix: particle deletion bug#42
daniel-ji wants to merge 1 commit intoFrangakisLab:mainfrom
daniel-ji:main

Conversation

@daniel-ji
Copy link

In the current verison of ArtiaX / copick, when a user does the following sequence:

  • place particles (any amount)
  • delete particle (any amount)
  • place particles (more than one)
  • delete selected particles (the last selected particle, so one)

The actions work as intended. However, if a user does the following:

  • place particles (any amount)
  • delete particle (any amount)
  • place particles again (one)
  • delete selected particles (the last selected particle, so one)

The last delete particle, even though only intended for one particle, deletes all the particles.

This is due to a Numpy broadcasting issue somewhere in the code, which might exist in ChimeraX.

What ends up happening is in (see PR, or src/particle/ParticleList.py):

            position_masks.append(
                np.logical_or(scm.position_mask(), markers.position_mask())
            )

the np.logical_or() evaluates to all true during the bugged action sequence, because scm.position_mask() ends up being all true, Tracing through the inherited classes, we end up with the _position_mask call of the Drawing class in ChimeraX, which seems to possibly be doing some broadcasting errors somewhere in the ChimeraX codebase: https://github.com/RBVI/ChimeraX/blob/56c7172631f802908efe39dda35eb8ec9a6e6baa/src/bundles/graphics/src/drawing.py#L967

    def _position_mask(self, highlighted_only=False):
        dp = self._displayed_positions        # bool array
        if highlighted_only:
            sp = self._highlighted_positions
            if sp is not None:
                import numpy
                dp = sp if dp is None else numpy.logical_and(dp, sp)
        return dp

I can go more down this rabbithole if desired, but the fix I've provided just skips that all entirely and just determines the selected_particles in a more intuitive way.

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.

1 participant