Skip to content

Commit

Permalink
Print out resolution estimate
Browse files Browse the repository at this point in the history
  • Loading branch information
jojoelfe committed Aug 20, 2024
1 parent 44ef771 commit c81e9af
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

Use Fourier shell correlation to estimate the resolution of cryo-EM images and volumes

Usage:
# Usage:

```
$ ttfsc map1.mrc map2.mrc
Estimated resolution using 0.143 criterion: 2.36 Å
(Y) ^
1 |
0.95000000 | ⠀⠀⠀⠀⠈⠒⠢⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ dependencies = [
"ttmask",
"matplotlib",
"mrcfile",
"plotille"
"plotille",
"rich"
]

# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
Expand Down
8 changes: 6 additions & 2 deletions src/ttfsc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import typer
import torch
from torch_fourier_shell_correlation import fsc

from rich import print as rprint

cli = typer.Typer(name='ttctf', no_args_is_help=True, add_completion=False)

Expand All @@ -14,7 +14,8 @@ def ttfsc_cli(
map1: Annotated[Path, typer.Argument(show_default=False)],
map2: Annotated[Path, typer.Argument(show_default=False)],
pixel_spacing_angstroms: Annotated[Optional[float], typer.Option('--pixel-spacing-angstroms', show_default=False, help="Pixel spacing in Å/px, taken from header if not set")] = None,
plot_with_matplotlib: Annotated[bool, typer.Option('--plot-with-matplotlib')] = False
plot_with_matplotlib: Annotated[bool, typer.Option('--plot-with-matplotlib')] = False,
fsc_treshold: Annotated[float, typer.Option('--fsc-treshold', show_default=False, help="FSC treshold")] = 0.143
):
with mrcfile.open(map1) as f:
map1_tensor = torch.tensor(f.data)
Expand All @@ -28,6 +29,9 @@ def ttfsc_cli(
resolution_angstrom = 1 / (bin_centers * pixel_spacing_angstroms)
fsc_values = fsc(map1_tensor, map2_tensor)

estimated_resolution_angstrom = resolution_angstrom[(fsc_values < fsc_treshold).nonzero()[0]-1]
rprint(f"Estimated resolution using {fsc_treshold} criterion: {estimated_resolution_angstrom[0]:.2f} Å")

if plot_with_matplotlib:
from matplotlib import pyplot as plt
plt.plot(resolution_angstrom, fsc_values)
Expand Down

0 comments on commit c81e9af

Please sign in to comment.