Skip to content

Fix IADDAT visualization anchoring to model coordinates instead of periodic images#6

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-vector-mapping-visualization
Draft

Fix IADDAT visualization anchoring to model coordinates instead of periodic images#6
Copilot wants to merge 3 commits intomainfrom
copilot/fix-vector-mapping-visualization

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

Displacement vectors and density peaks were displayed at shifted unit cell copies rather than around the atomic model. The visualization logic incorrectly used mark.pos (nearest atom image from gemmi.NeighborSearch, which may be a periodic copy) as the anchor point.

Changes

Map Generation

  • Use full unit cell map instead of ASU-masked map in IADDAT_peaks_table
  • Enables peak finding throughout the cell regardless of model placement
# Before: Limited to asymmetric unit
asu_map = sf.masked_asu()
realmap = np.array(asu_map.grid, copy=False)

# After: Full unit cell
realmap = np.array(sf, copy=False)

Vector Calculation

  • Anchor displacement vectors to original atom coordinates (coordx, coordy, coordz) instead of mark coordinates in calculate_per_atom_vectors
  • Compute vectors as peak - coord rather than peak - mark

Peak Visualization

  • Position peaks at coord + delta relative to model atoms in create_peak_objects_single_model and create_carved_peak_objects_single_model
  • Ensures peaks appear superimposed on the model structure

Removed Incorrect Symmetry Logic

  • Deleted 8 functions (~430 lines) that misinterpreted image_idx from gemmi.NeighborSearch as space group operations
  • image_idx represents PBC shifts, not crystallographic symmetry operations
  • Removed: map_symmetry_features_to_model, extract_symmetry_transformations, apply_inverse_transformations_to_peaks, and related validation functions
Original prompt

Fix vector mapping and peak visualization in IADDAT plugin.

Currently, displacement vectors and density peaks may be displayed in shifted unit cell copies rather than around the atomic model. This occurs because the visualization logic uses the coordinates of the "mark" (nearest atom image found by neighbor search, which may be a periodic copy) as the anchor, rather than the original atom coordinates. Additionally, the plugin attempts to map symmetry using image_idx as a space group operation index, which is incorrect for gemmi.NeighborSearch (where it represents PBC shifts).

This PR fixes these issues by:

  1. Using the full unit cell map instead of an ASU-masked map in IADDAT_peaks_table. This ensures peaks are found throughout the cell, allowing NeighborSearch to find matches near the model regardless of its placement relative to the standard ASU.
  2. Anchoring visualization to the model:
    • Displacement vectors are now drawn starting from the original atom coordinates (coordx, coordy, coordz).
    • Peaks are visualized at positions relative to the model atoms (coord + delta), ensuring they appear superimposed on the model structure.
  3. Removing incorrect symmetry mapping logic: The functions map_symmetry_features_to_model, extract_symmetry_transformations, apply_inverse_transformations_to_peaks, and related validation methods are removed. These were based on a misunderstanding of gemmi's image_idx in this context and caused the "shifted unit cell" artifacts.

This ensures that the IADDAT analysis correctly visualizes the difference density and displacement vectors directly on the loaded model, solving the issue of vectors pointing to shifted unit cell copies.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 15, 2026 22:52
…ring

Co-authored-by: LifeHasOrder <12899220+LifeHasOrder@users.noreply.github.com>
Co-authored-by: LifeHasOrder <12899220+LifeHasOrder@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix vector mapping and peak visualization in IADDAT plugin Fix IADDAT visualization anchoring to model coordinates instead of periodic images Jan 15, 2026
Copilot AI requested a review from LifeHasOrder January 15, 2026 22:56
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.

2 participants