Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjinliu committed Dec 26, 2023
1 parent 2318841 commit 37abff0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
6 changes: 4 additions & 2 deletions cylindra/widgets/batch/sta.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ def filter_loader(
@nogui
def get_loader(self, name: str) -> BatchLoader:
"""Return the acryo.BatchLoader object with the given name"""
if not isinstance(name, str):
raise TypeError(f"Name must be a string, got {type(name).__name__}")
return self._get_parent().loader_infos[name].loader

@set_design(text="Average all molecules", location=BatchSubtomogramAnalysis)
Expand Down Expand Up @@ -545,7 +547,7 @@ def show_template_original(self):
@do_not_record
def show_mask(self):
"""Load and show mask image in the scale of the tomogram."""
loader = self._get_parent().loader_infos[self.loader_name].loader
loader = self.get_loader(self.loader_name)
_, mask = loader.normalize_input(
self.params._norm_template_param(
self.params._get_template_input(allow_multiple=False),
Expand All @@ -572,7 +574,7 @@ def _get_shape_in_px(
return (roundint(default / loader.scale),) * 3

def _get_template_image(self) -> ip.ImgArray:
scale = self._get_parent().loader_infos[self.loader_name].loader.scale
scale = self.get_loader(self.loader_name).scale

template = self.params._norm_template_param(
self.params._get_template_input(allow_multiple=True),
Expand Down
8 changes: 5 additions & 3 deletions cylindra/widgets/sta.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def _get_choice(self: "SubtomogramAveraging", w=None) -> list[str]:
return features.columns
return [c for c in features.columns if features[c].dtype.kind in dtype_kind]

_get_choice.__qualname__ = "CylindraMainWidget.sta._get_choice"
_get_choice.__qualname__ = "SubtomogramAveraging._get_choice"
return _get_choice


Expand Down Expand Up @@ -1629,7 +1629,7 @@ def seam_search_by_feature(
Name of the feature that will be used for seam search.
"""
layer = assert_layer(layer, self.parent_viewer)
feat = layer.features
feat = layer.molecules.features
if by not in feat.columns:
raise ValueError(f"Column {by} does not exist.")
npf = utils.roundint(layer.molecules.features[Mole.pf].max() + 1)
Expand All @@ -1648,14 +1648,16 @@ def seam_search_manually(
"""
Search for seams manually.
Seam location is represented by a number in the range [0, 2 * npf - 1].
Parameters
----------
{layer}
location : int
Seam location.
"""
layer = assert_layer(layer, self.parent_viewer)
feat = layer.features
feat = layer.molecules.features
npf = utils.roundint(layer.molecules.features[Mole.pf].max() + 1)
seam_searcher = ManualSeamSearcher(npf)
result = seam_searcher.search(location)
Expand Down
2 changes: 1 addition & 1 deletion docs/alignment/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cryo-ET analysis workflows. `cylindra` provides methods to perform the analyses.
GUI, these methods are all in a separate dock widget titled "STA widget". You can open
via `Analysis > Open STA widget` (++ctrl+k++ → ++s++).

![STA widget](../images/sta_widget.png)
![STA widget](../images/sta_widget.png){ loading=lazy, width=480px }

Since many methods share the same parameters, the STA widget uses the same widget for
these parameters.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies = [
"acryo>=0.4.7",
"macro-kit>=0.4.6",
"magicgui>=0.8.1",
"magic-class>=0.7.6",
"magic-class>=0.7.7",
"psygnal>=0.9.1",
"superqt[iconify]>=0.6.1",
"pyqtgraph>=0.12.4",
Expand Down
5 changes: 4 additions & 1 deletion tests/test_gui_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,14 @@ def assert_orientation(ui: CylindraMainWidget, ori: str):

def test_click_buttons(ui: CylindraMainWidget):
mcls_testing.check_function_gui_buildable(ui)
mcls_testing.check_function_gui_buildable(ui.sta)
mcls_testing.check_function_gui_buildable(ui.simulator)


def test_tooltip(ui: CylindraMainWidget):
mcls_testing.check_tooltip(ui)
mcls_testing.check_tooltip(ui.sta)
mcls_testing.check_tooltip(ui.simulator)


def test_misc_actions(ui: CylindraMainWidget):
Expand Down Expand Up @@ -561,7 +564,7 @@ def test_sub_widgets(ui: CylindraMainWidget):
@pytest.mark.parametrize("bin_size", [1, 2])
def test_sta(ui: CylindraMainWidget, bin_size: int):
ui.load_project(PROJECT_DIR_13PF, filter=None)
ui.AnalysisMenu.open_subtomogram_analyzer()
ui.AnalysisMenu.open_sta_widget()
ui.sta.average_all("Mole-0", size=12.0, bin_size=bin_size)
ui.sta.average_all("Mole-0", size=12.0, bin_size=bin_size) # check coerce name
for method in ["steps", "first", "last", "random"]:
Expand Down

0 comments on commit 37abff0

Please sign in to comment.