Skip to content

Commit

Permalink
put passive viewers in one program
Browse files Browse the repository at this point in the history
  • Loading branch information
alisterburt committed May 5, 2023
1 parent c8375f1 commit e63bd28
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 11 deletions.
12 changes: 3 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@ dev = [
"pytest",
"rich",
]
gui = [
"napari",
"qtpy",
"psygnal"
]
gui-pyqt = [
vis = [
"napari",
"qtpy",
"psygnal",
Expand All @@ -84,11 +79,10 @@ repository = "https://github.com/3dem/relion"
# same as console_scripts entry point
[project.scripts]
relion_tomo_import = "tomography_python_programs.import_tilt_series:cli"
relion_tomo_view_tilt_series = "tomography_python_programs.view_tilt_series:cli"
relion_tomo_view_tomograms = "tomography_python_programs.view_tomograms:cli"
relion_tomo_exclude_tilt_images = "tomography_python_programs.exclude_tilt_images:cli"
relion_tomo_pick = "tomography_python_programs.pick:cli"
relion_tomo_align_tilt_series = "tomography_python_programs.align_tilt_series:cli"
relion_tomo_view = "tomography_python_programs.view:cli"
relion_tomo_pick = "tomography_python_programs.pick:cli"
relion_tomo_denoise = "tomography_python_programs.denoise:cli"


Expand Down
4 changes: 2 additions & 2 deletions src/gui_mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ void GuiMainWindow::cb_display_io_node_i()
else if (pipeline.nodeList[mynode].type.find(LABEL_TOMO_TILTSERIES) != std::string::npos )
{

command = "relion_tomo_view_tilt_series --tilt-series-star-file " + pipeline.nodeList[mynode].name;
command = "relion_tomo_view tilt-series --tilt-series-star-file " + pipeline.nodeList[mynode].name;

// Read cache-size from gui_tomo_exclude_tilt_imagesjob.star if that file exists
RelionJob excludetiltseriesjob;
Expand All @@ -1489,7 +1489,7 @@ void GuiMainWindow::cb_display_io_node_i()
else if (pipeline.nodeList[mynode].type.find(LABEL_TOMO_TOMOGRAMS) != std::string::npos )
{

command = "relion_tomo_view_tomograms --tilt-series-star-file " + pipeline.nodeList[mynode].name;
command = "relion_tomo_view tomograms --tilt-series-star-file " + pipeline.nodeList[mynode].name;

// Read cache-size from gui_tomo_exclude_tilt_imagesjob.star if that file exists
RelionJob excludetiltseriesjob;
Expand Down
6 changes: 6 additions & 0 deletions src/tomography_python_programs/view/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Passive visualisation tools for browsing RELION cryo-ET data."""

from .tilt_series import view_tilt_series
from .tomograms import view_tomograms

from ._cli import cli
4 changes: 4 additions & 0 deletions src/tomography_python_programs/view/_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import typer

CLI_NAME = 'relion_tomo_view'
cli = typer.Typer(name=CLI_NAME, add_completion=False, no_args_is_help=True)
33 changes: 33 additions & 0 deletions src/tomography_python_programs/view/tilt_series.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from pathlib import Path

import typer

from .._qt.components.tilt_series_browser import TiltSeriesBrowserWidget
from .._metadata_models.relion.tilt_series_set import RlnTiltSeriesSet
from ..view._cli import cli

COMMAND_NAME = 'tilt-series'


@cli.command(name=COMMAND_NAME, no_args_is_help=True)
def view_tilt_series(
tilt_series_star_file: Path = typer.Option(...),
cache_size: int = typer.Option(5, help='number of cached tilt-series')
):
import napari # local to speedup CLI
viewer = napari.Viewer(ndisplay=3)
relion_metadata = RlnTiltSeriesSet.from_star_file(tilt_series_star_file)
for tilt_series in relion_metadata.tilt_series:
tilt_series.data = tilt_series.data.sort_values(
by='rlnTomoNominalStageTiltAngle')
gui_model = relion_metadata.as_gui_model()
dock_widget = TiltSeriesBrowserWidget(viewer, gui_model, cache_size=cache_size)
viewer.window.add_dock_widget(
dock_widget, name='RELION tilt-series viewer', area='left'
)
viewer.text_overlay.text = """
keyboard shortcuts
- '[' and ']' for previous/next tilt-series
"""
viewer.text_overlay.visible = True
napari.run()
37 changes: 37 additions & 0 deletions src/tomography_python_programs/view/tomograms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from pathlib import Path
import typer

from .._qt.components.tomogram_browser import TomogramBrowserWidget
from .._metadata_models.relion.tilt_series_set import RlnTiltSeriesSet
from ..view._cli import cli

COMMAND_NAME = 'tomograms'


@cli.command(name=COMMAND_NAME, no_args_is_help=True)
def view_tomograms(
tilt_series_star_file: Path = typer.Option(...),
cache_size: int = typer.Option(3, help='number of cached tomograms')
):
import napari # local to speed up CLI
viewer = napari.Viewer(ndisplay=3)
relion_metadata = RlnTiltSeriesSet.from_star_file(tilt_series_star_file)
gui_model = relion_metadata.as_gui_model()
dock_widget = TomogramBrowserWidget(viewer, gui_model, cache_size=cache_size)
viewer.window.add_dock_widget(
dock_widget, name='RELION tomogram viewer', area='left'
)
viewer.axes.visible = True
viewer.axes.labels = False
viewer.camera.angles = (-15, 30, 150)
viewer.camera.zoom *= 0.7
viewer.text_overlay.text = """
keyboard shortcuts
- '[' and ']' for previous/next tomogram
- 'x'/'y'/'z'/'o' to reorient the plane (around the cursor)
mouse controls
- 'Shift' + click + drag to move the plane along its normal
"""
viewer.text_overlay.visible = True
napari.run()

0 comments on commit e63bd28

Please sign in to comment.