Skip to content

Commit f6d0dc3

Browse files
proth17proth17
andauthored
PR_update (#31)
* Adding mouse mode to color surfaces/masks. Working on splitting tomogram, depending on indiviual coloring of connected triangles. * Coloring tomogram based on segmentation * Coloring tomogram based on segmentation * Coloring tomogram based on segmentation * Coloring tomogram based on segmentation * Coloring tomogram based on segmentation * Coloring tomogram based on segmentation works for surfaces. Next working on coloring of volume/image * Problem is shift, is being substracted from pos and then still written out in column Origin * Save * Add function to color segmentation * Add function to color segmentation * fixed position problem, also split Angle with proper rlnAngle values, also all columns that are not numbers will still be written out * fix selector, so that attributes that have non numerical values are excluded * Minor debugging * Editing flip particle function so that angles can be changed. Changing default pixelsize of particle lists that are being created from geomodels, no longer 1, but now pixelsize of currently selected particle list. * Adding option to decide during saving of relion5, if angles should be split into rlnSubtomogram and rlnAngle and rlnAnglePrior columns should be added. Also adding help buttons to relion5 import and export widgets * Adding option to delete particles that have the same coordinates * Adding option to delete particles that have the same coordinates * Minor debugging, allow to add particles to existing list, added default values for rlnAngle and rlnAnglePrior. Improved documentation. * Minor debugging, so that non-numerical attributes are excluded from selector widget and ColorRange widget. * Clean up * Clean up, bug fix of selector. Adding variable to remember column order from imported relion5 star file, so that order can be used during saving. * Adding button to select/manipulate tab * Fixing documentation * Bug-Fix and Clean up * Add default pixelsize also when generating particle list from sphere. * Improved and updated documentation. * Include tomogram arithmetics * Bug fix and including division * Clean up * Add Invert contrast button, to invert actual array values of tomogram * Bug fix by adding default pixelsize for particle list created from geomodel. Fixing documentation * Improve documentation. * Improve documentation. * Fixed the deletion, so that only particles from the same tomogram are check for neighbours within the radius. * Improve documentation for artiax flip * Improve documentation and fix bug for delete duplicates when no tomogram number information is available. * Fixed geo2vol bug * Added default, when no tomogram is provided, the currently selected one is used for scaling * Fix documentation for "artiax moveCameraAlongLine" * Fix documentation for "artiax generate points in/on surface" * change layout for "Line" Geomodel tab * fix "artiax generate points on surface" * fix "artiax generate points on surface" * Remove "color connected triangles" and "extract connected triangles" --------- Co-authored-by: proth17 <p.roth@biophysik.org>
1 parent 3534feb commit f6d0dc3

30 files changed

+1565
-237
lines changed

bundle_info.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,12 @@ will be displayed without the ChimeraX- prefix.
353353
<Provider tab="ArtiaX Models" section="Change Models" mouse_mode="mask connected triangles"
354354
name="Mask Connected Triangles" display_name="Mask Triangles" icon="mask_triangle.png"
355355
description="Hides all triangles connected to the picked triangle."/>
356+
<!-- <Provider tab="ArtiaX Models" section="Change Models" mouse_mode="color connected triangles"-->
357+
<!-- name="Color Connected Triangles" display_name="Color Triangles" icon="mask_triangle.png"-->
358+
<!-- description="Color all triangles connected to the picked triangle."/>-->
359+
<!-- <Provider tab="ArtiaX Models" section="Change Models" mouse_mode="extract connected triangles"-->
360+
<!-- name="Extract Connected Triangles" display_name="Extract Triangles" icon="mask_triangle.png"-->
361+
<!-- description="Extract all triangles connected to the picked triangle and save them as a new tomogram."/>-->
356362

357363
</Providers>
358364

@@ -438,7 +444,7 @@ will be displayed without the ChimeraX- prefix.
438444
Creates a triangle surface between all particles marked by links.</ChimeraXClassifier>
439445

440446
<ChimeraXClassifier>ChimeraX :: Command :: artiax flip :: General ::
441-
Rotates the selected particles 180 degrees around the given axis.</ChimeraXClassifier>
447+
Rotates the selected particles 180 degrees around the given axis. Default degree is 180. </ChimeraXClassifier>
442448

443449
<ChimeraXClassifier>ChimeraX :: Command :: artiax select inside surface :: General ::
444450
Selects all shown particles inside the selected surface.</ChimeraXClassifier>

src/ArtiaX.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ def __init__(self, session, add: bool = True, create_managers: bool = True):
135135
DeletePickedTriangleMode,
136136
DeletePickedTetraMode,
137137
MaskConnectedTrianglesMode,
138+
# ColorConnectedTrianglesMode,
139+
# ExtractConnectedTrianglesMode
138140
)
139141

140142
self.translate_selected = TranslateSelectedParticlesMode(self.session)
@@ -146,6 +148,8 @@ def __init__(self, session, add: bool = True, create_managers: bool = True):
146148
self.delete_picked_triangle = DeletePickedTriangleMode(self.session)
147149
self.delete_picked_tetra = DeletePickedTetraMode(self.session)
148150
self.mask_connected_triangles = MaskConnectedTrianglesMode(self.session)
151+
# self.color_connected_triangles = ColorConnectedTrianglesMode(self.session)
152+
# self.extract_connected_triangles = ExtractConnectedTrianglesMode(self.session)
149153
self.session.ui.mouse_modes.add_mode(self.translate_selected)
150154
self.session.ui.mouse_modes.add_mode(self.rotate_selected)
151155
self.session.ui.mouse_modes.add_mode(self.translate_picked)
@@ -155,6 +159,8 @@ def __init__(self, session, add: bool = True, create_managers: bool = True):
155159
self.session.ui.mouse_modes.add_mode(self.delete_picked_triangle)
156160
self.session.ui.mouse_modes.add_mode(self.delete_picked_tetra)
157161
self.session.ui.mouse_modes.add_mode(self.mask_connected_triangles)
162+
# self.session.ui.mouse_modes.add_mode(self.color_connected_triangles)
163+
# self.session.ui.mouse_modes.add_mode(self.extract_connected_triangles)
158164

159165
@property
160166
def tomograms(self):
@@ -316,7 +322,6 @@ def add_particlelist(self, model):
316322
self.selected_partlist = model.id
317323
self.options_partlist = model.id
318324
run(self.session, "artiax clip off")
319-
print("add_particlelist is being run")
320325

321326
def add_geomodel(self, model):
322327
"""Add a geometric model."""

src/cmd/cmd.py

Lines changed: 114 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def artiax_triangles_from_links(session):
283283
surface_from_links(session)
284284

285285

286-
def artiax_flip(session, axis=None):
286+
def artiax_flip(session, axis=None, angle=180):
287287
if not hasattr(session, "ArtiaX"):
288288
session.logger.warning(
289289
"ArtiaX is not currently running, so no particles can be reoriented."
@@ -303,7 +303,7 @@ def artiax_flip(session, axis=None):
303303

304304
for particle in particles:
305305
external_axis = particle.rotation.transform_vector(axis)
306-
particle.rotation = rotation(external_axis, 180) * particle.rotation
306+
particle.rotation = rotation(external_axis, angle) * particle.rotation
307307

308308
for particle_list in session.ArtiaX.partlists.iter():
309309
particle_list.update_places()
@@ -759,18 +759,38 @@ def artiax_gen_on_surface(session, model, method, num_pts, radius=None, exactNum
759759

760760

761761
def artiax_geomodel_to_volume(
762-
session, model=None, geomodels=None, subdivide_length=None
762+
session, model=None, geomodels=None, subdivide_length=None, merge=False
763763
):
764764
from ..volume.Tomogram import Tomogram
765765
from chimerax.surface._surface import subdivide_mesh
766766
from chimerax.map_data import ArrayGridData
767767

768768
new_model = False
769+
noTomo=False
769770
if model is None:
770-
new_model = True
771-
ps = [1, 1, 1]
772-
name = "segmented surfaces"
773-
elif not isinstance(model, Tomogram):
771+
#ps = [1, 1, 1]
772+
#name = "segmented surfaces"
773+
#noTomo=True
774+
#model = [m for m in session.ArtiaX.tomograms.child_models() if m.visible]
775+
count=0
776+
for models in session.selection.models():
777+
if isinstance(models, Volume):
778+
print(f"found volume {models}")
779+
model=models
780+
count=count+1
781+
if count ==0:
782+
if merge == True:
783+
raise UserError("Please indicate one tomogram for scaling purposes and for merging, either by command line or with the selection mouse mode.")
784+
else:
785+
raise UserError("Please indicate one tomogram for scaling purposes, either by command line or with the selection mouse mode.")
786+
if count >=2:
787+
if merge == True:
788+
raise UserError("Please indicate only one tomogram for scaling purposes and merging not more.\nIf you want to combine multiple tomograms, please use the tomogram arithmetics section in ArtiaX Options Tomogram tab.")
789+
else:
790+
raise UserError("Please indicate only one tomogram for scaling purposes and not more.")
791+
#if merge is True:
792+
#raise UserError("Geomodel can not be merge with existing tomogram if it is not provided. Please indicate the tomogram.")
793+
if not isinstance(model, Tomogram):
774794
session.logger.warning("{} is not a tomogram loaded into ArtiaX".format(model))
775795
return
776796
else:
@@ -779,10 +799,15 @@ def artiax_geomodel_to_volume(
779799
ps = tomo.pixelsize
780800
mat = tomo.data.matrix().copy()
781801

802+
if merge is False:
803+
new_model = True
804+
805+
806+
782807
if geomodels is None:
783808
geomodels = [g for g in session.ArtiaX.geomodels.child_models() if g.visible]
784809

785-
if new_model:
810+
if noTomo:
786811
from chimerax.geometry.bounds import union_bounds
787812

788813
union = union_bounds([gm.geometry_bounds() for gm in geomodels])
@@ -816,7 +841,7 @@ def artiax_geomodel_to_volume(
816841
# Set voxels
817842
for i, v in enumerate(vs):
818843

819-
if new_model:
844+
if noTomo:
820845
index = (v - xyz_min) / ps[0]
821846
else:
822847
index = tomo.data.xyz_to_ijk(v)
@@ -925,6 +950,34 @@ def artiax_mask_triangles_radius(session, radius=None):
925950
session.ui.mouse_modes.add_mode(mct)
926951
run(session, 'ui mousemode right "mask connected triangles"')
927952

953+
# def artiax_color_triangles_radius(session, radius=None):
954+
# if radius is not None and radius <= 0:
955+
# session.logger.warning("Select a positive radius.")
956+
# return
957+
# from ..mouse import ColorConnectedTrianglesMode
958+
#
959+
# mct = session.ArtiaX.color_connected_triangles
960+
# session.ui.mouse_modes.remove_mode(mct)
961+
# mct = session.ArtiaX.color_connected_triangles = ColorConnectedTrianglesMode(
962+
# session, radius
963+
# )
964+
# session.ui.mouse_modes.add_mode(mct)
965+
# run(session, 'ui mousemode right "color connected triangles"')
966+
#
967+
# def artiax_extract_triangles_radius(session, radius=None):
968+
# if radius is not None and radius <= 0:
969+
# session.logger.warning("Select a positive radius.")
970+
# return
971+
# from ..mouse import ExtractConnectedTrianglesMode
972+
#
973+
# mct = session.ArtiaX.extract_connected_triangles
974+
# session.ui.mouse_modes.remove_mode(mct)
975+
# mct = session.ArtiaX.extract_connected_triangles = ExtractConnectedTrianglesMode(
976+
# session, radius
977+
# )
978+
# session.ui.mouse_modes.add_mode(mct)
979+
# run(session, 'ui mousemode right "extract connected triangles"')
980+
928981

929982
def artiax_filter_tomo(
930983
session,
@@ -1569,6 +1622,45 @@ def artiax_user_guide(session:Session):
15691622
raise UserError(
15701623
"To open artiax user guide, type 'help artiax user guide'.")
15711624

1625+
def artiax_delete_duplicates(session:Session, models=None, radius=0):
1626+
1627+
if not hasattr(session, "ArtiaX"):
1628+
session.logger.warning("ArtiaX is not currently running.")
1629+
1630+
# No Models
1631+
if models is None:
1632+
models = session.ArtiaX.partlists.child_models()
1633+
1634+
# Filter models
1635+
ms = []
1636+
for model in models:
1637+
# Is it a particle list?
1638+
from ..particle import ParticleList
1639+
1640+
if not isinstance(model, ParticleList):
1641+
# Is it a model that likely belongs to a particle list?
1642+
from chimerax.core.models import ancestor_models
1643+
1644+
if session.ArtiaX in ancestor_models([model]):
1645+
continue
1646+
else:
1647+
session.logger.warning(
1648+
'artiax unlock: Model #{} - "{}" is not a particle list'.format(
1649+
model.id_string, model.name
1650+
)
1651+
)
1652+
continue
1653+
_id = model.id_string
1654+
ms.append(_id)
1655+
1656+
from ..particle.ParticleList import delete_duplicates
1657+
1658+
delete_duplicates(session,ms, radius)
1659+
1660+
1661+
1662+
1663+
15721664

15731665
def register_artiax(logger):
15741666
"""Register all commands with ChimeraX, and specify expected arguments."""
@@ -1735,8 +1827,8 @@ def register_artiax_triangles_from_links():
17351827

17361828
def register_artiax_flip():
17371829
desc = CmdDesc(
1738-
optional=[("axis", AxisArg)],
1739-
synopsis="Rotates the selected particles 180 degrees around their y-axis.",
1830+
optional=[("axis", AxisArg), ("angle", FloatArg)],
1831+
synopsis="Rotates the selected particles. Specify the axis and degree",
17401832
url="help:user/commands/artiax_flip.html",
17411833
)
17421834
register("artiax flip", desc, artiax_flip)
@@ -1821,7 +1913,7 @@ def register_artiax_gen_on_surface():
18211913

18221914
def register_artiax_geomodel_to_volume():
18231915
desc = CmdDesc(
1824-
optional=[("model", ModelArg)],
1916+
optional=[("model", ModelArg), ("merge", BoolArg)],
18251917
keyword=[("geomodels", ListOf(ModelArg)), ("subdivide_length", FloatArg)],
18261918
synopsis="Adds the specified geomodels to the specified volume. If no model is specified, a new one is"
18271919
" created. If no geomodels are specified, all shown are used. The subdivide_length keyword sets"
@@ -1997,6 +2089,15 @@ def register_artiax_user_guide():
19972089
)
19982090
register("artiax user guide", desc, artiax_user_guide)
19992091

2092+
def register_artiax_delete_duplicates():
2093+
desc = CmdDesc(
2094+
required=[("models", Or(ModelsArg, EmptyArg))],
2095+
optional=[("radius", FloatArg)],
2096+
synopsis="Delete duplicates in particle list",
2097+
url="help:user/artiax_index.html",
2098+
)
2099+
register("artiax delete duplicates", desc, artiax_delete_duplicates)
2100+
20002101

20012102
register_artiax_start()
20022103
register_artiax_open_tomo()
@@ -2040,6 +2141,7 @@ def register_artiax_user_guide():
20402141
register_artiax_open()
20412142
register_artiax_save()
20422143
register_artiax_user_guide()
2144+
register_artiax_delete_duplicates()
20432145

20442146

20452147
# Possible styles

src/docs/user/artiax_index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ <h2> <a name="top"></a> <a href="./artiax_index.html"> <img src="./ArtiaX-docs-i
4848
<div id="tools" class="expanded">
4949
<ul>
5050
<li><b><a href="tools/artiax.html">ArtiaX</a></b> &nbsp;– Tool for
51-
Tomogram and Particle list model management.</li>
51+
Tomogram, Particle list and Geometric model management.</li>
5252
<b></b>
5353
<li><b><a href="tools/artiax_options.html">ArtiaX Options</a></b>
54-
&nbsp;– Tool for Tomogram and Particle list manipulation.</li>
54+
&nbsp;– Tool for Tomogram, Particle list and Geometric model manipulation.</li>
5555
<b></b>
5656
<li><b><a href="tools/artiax_toolbar.html">ArtiaX Toolbar</a></b>
5757
&nbsp;– ArtiaX toolbar tab.</li>
@@ -76,6 +76,8 @@ <h2> <a name="top"></a> <a href="./artiax_index.html"> <img src="./ArtiaX-docs-i
7676
<li><b><a href="commands/artiax_colormap.html">colormap</a></b>
7777
&nbsp;– set a colormap for a particle list</li>
7878
<b></b>
79+
<li><b><a href="commands/artiax_delete_duplicate.html">delete duplicate</a></b> delete particle duplicates </li>
80+
<b></b>
7981
<li><b><a href="commands/artiax_filter.html">filter tomo</a></b> – filter a tomogram using low, high,
8082
or band-pass filters </li>
8183
<b></b>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<html>
2+
<head>
3+
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
4+
<link rel="stylesheet" type="text/css" href="../userdocs.css">
5+
<title>Command:artiax delete duplicate</title>
6+
</head>
7+
<body> <a name="top"></a> <a href="../artiax_index.html"> <img src="../ArtiaX-docs-icon.svg"
8+
alt="ArtiaX docs icon" class="clRight" title="User Guide Index" width="60px"></a>
9+
<h3><a href="../artiax_index.html#commands">Command</a>: artiax delete duplicate</h3>
10+
<h3 class="usage"><a href="usageconventions.html">Usage</a>: <br>
11+
<b>artiax delete duplicate</b> [ <a href="atomspec.html#hierarchy"><i>model-spec</i></a>
12+
] [<strong>radius</strong> <i>value</i>] </h3>
13+
<p> The <b>artiax delete duplicates</b> command allows deleting particle duplicates or particles that are within a specified radius (in angstrom) to each other. The particles will be sorted and processed by tomogram affiliation if they belong to multiple tomograms and this information is available. Default radius is 0. </p>
14+
15+
<p> Examples: </p>
16+
<blockquote> <b>artiax delete duplicate #1.2.1 radius 1</b><br>
17+
<b>artiax delete duplicate #1.2.1 <br>
18+
</b></blockquote>
19+
<p></p>
20+
<hr>
21+
<address>BMLS Frangakis Group / December 2024</address>
22+
</body>
23+
</html>

src/docs/user/commands/artiax_flip.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
class="clRight" title="User Guide Index"/></a>
1212
<h3><a href="../artiax_index.html#commands">Command</a>: artiax flip</h3>
1313
<h3 class="usage"><a href="usageconventions.html">Usage</a>:
14-
<br><b>artiax flip</b> [<a href="pointspec.html#vector"><i>vector-spec</i></a>] </h3>
14+
<br><b>artiax flip</b> [<a href="pointspec.html#vector"><i>vector-spec</i></a>] [<i>degree</i>] </h3>
1515
<p>
16-
Rotates the selected particles 180 degrees around the given axis. Default axis is <strong>z</strong>.
16+
Rotates the selected particles 180 degrees around the given axis x,y or z. Default axis is <strong>z</strong>. Default degree is 180.
1717
</p>
1818
<p> Examples: </p>
1919
<blockquote> <b>artiax flip<br>
2020
artiax flip x <br>
21-
artiax flip 1,1,1
21+
artiax flip 1,1,1 <br>
22+
artiax flip y 65
2223
</b> </blockquote>
2324
<p></p>
2425
<hr>

src/docs/user/commands/artiax_generate_points_in_surface.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h3 class="usage"><a href="usageconventions.html">Usage</a>: <br>
1313
ts</strong> <i>value</i>]
1414
[<strong>radius</strong> <i>value</i>] </h3>
1515
<p> The <b>artiax gen in surface</b> command generates points inside the closed volume of the chosen
16-
surface. Three different methods of generating points are available. Similar to the
16+
surface. Three different methods of generating points are available. The pixelsize of this new particle list will be the same as for the currently activated (options selected) particle list. If no particle list is selected, the default pixelsize is 1. Similar to the
1717
<a href="artiax_generate_points_on_surface.html"> <i>artiax gen on surface</i></a> command.</p>
1818
<table style="width: 1006px; height: 380px;" border="1">
1919
<tbody>
@@ -42,7 +42,7 @@ <h3 class="usage"><a href="usageconventions.html">Usage</a>: <br>
4242
</tr>
4343
<tr>
4444
<td style="text-align: center;"><strong>radius</strong></td>
45-
<td>The poisson disk radius used for the <strong>poisson</strong> method.</td>
45+
<td>The poisson disk radius in angstrom used for the <strong>poisson</strong> method.</td>
4646
<td style="text-align: center;"><em>float</em></td>
4747
</tr>
4848
</tbody>

src/docs/user/commands/artiax_generate_points_on_surface.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ <h3><a href="../artiax_index.html#commands">Command</a>: artiax gen on surface</
1010
<h3 class="usage"><a href="usageconventions.html">Usage</a>: <br>
1111
<b>artiax gen on surface</b> <a href="atomspec.html#hierarchy"><i>model-spec</i></a>
1212
<i>method</i> <i>numPts</i> [<strong>radius</strong> <i>value</i>] </h3>
13-
<p> The <b>artiax gene on surface</b> command generates points on the chosen surface. Two different
14-
methods of generating points are available. Similar to the
13+
<p> The <b>artiax gen on surface</b> command generates points on the chosen surface. Two different
14+
methods of generating points are available. The pixelsize of this new particle list will be the same as for the currently activated (options selected) particle list. If no particle list is selected, the default pixelsize is 1. Similar to the
1515
<a href="artiax_generate_points_in_surface.html"><i>artiax gen in surface</i></a> command.</p>
1616
<table style="width: 1006px; height: 380px;" border="1">
1717
<tbody>
@@ -41,14 +41,14 @@ <h3 class="usage"><a href="usageconventions.html">Usage</a>: <br>
4141
</tr>
4242
<tr>
4343
<td style="text-align: center;"><strong>radius</strong></td>
44-
<td>The poisson disk radius used for the <strong>poisson</strong> method.</td>
44+
<td>The poisson disk radius in angstrom used for the <strong>poisson</strong> method.</td>
4545
<td style="text-align: center;"><em>float</em></td>
4646
</tr>
4747
</tbody>
4848
</table>
4949
<p> Examples: </p>
5050
<blockquote> <b>artiax gen on surface #1.3.1 uniform 100 <br>
51-
artiax gen on surface #1.3.1 poisson 50 radius 10 </b> </blockquote>
51+
artiax gen on surface #1.3.1 poisson 50 radius 20 </b> </blockquote>
5252
<p></p>
5353
<hr>
5454
<address>BMLS Frangakis Group / August 2023</address>

0 commit comments

Comments
 (0)