Skip to content

Commit

Permalink
Merge pull request #322 from jungmannlab/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
rafalkowalewski1 authored Feb 17, 2023
2 parents 7f4d285 + ab8ee77 commit 51e9ec3
Show file tree
Hide file tree
Showing 23 changed files with 513 additions and 60 deletions.
4 changes: 3 additions & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.5.7
current_version = 0.6.0
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
Expand All @@ -13,6 +13,8 @@ serialize =

[bumpversion:file:./distribution/picasso.iss]

[bumpversion:file:./picasso/__init__.py]

[bumpversion:file:./picasso/__version__.py]

[bumpversion:file:./release/one_click_windows_gui/picasso_innoinstaller.iss]
Expand Down
8 changes: 7 additions & 1 deletion changelog.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
Changelog
=========

Last change: 07-FEB-2023 MTS
Last change: 16-FEB-2023 MTS

0.6.0
-----
- New RESI (Resolution Enhancement by Sequential Imaging) dialog in Picasso Render allowing for a substantial resolution boost, (*to be published*)
- Remove quantum efficiency when converting raw data into photons in Picasso Localize
- Input ROI using command-line ``picasso localize``, see `here <https://picassosr.readthedocs.io/en/latest/cmd.html>`_.

0.5.7
-----
Expand Down
4 changes: 2 additions & 2 deletions distribution/picasso.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
AppName=Picasso
AppPublisher=Jungmann Lab, Max Planck Institute of Biochemistry

AppVersion=0.5.7
AppVersion=0.6.0
DefaultDirName={pf}\Picasso
DefaultGroupName=Picasso
OutputBaseFilename="Picasso-Windows-64bit-0.5.7"
OutputBaseFilename="Picasso-Windows-64bit-0.6.0"
ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode=x64

Expand Down
1 change: 1 addition & 0 deletions docs/cmd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The reconstruction parameters can be specified by adding respective arguments. I
‘-a’, ‘–fit-method’, choices=["mle", "lq", "lq-gpu", "lq-3d", "lq-gpu-3d", "avg"], default=‘mle’
‘-g’, ‘–gradient’, type=int, default=5000, help=‘minimum net gradient’
‘-d’, ‘–drift’, type=int, default=1000, help=‘segmentation size for subsequent RCC, 0 to deactivate’
‘-r’, ‘-roi‘, type=int, nargs=4, default=None, help=‘ROI (y_min, x_min, y_max, x_max) in camera pixels’
‘-bl’, ‘–baseline’, type=int, default=0, help=‘camera baseline’
‘-s’, ‘–sensitivity’, type=int, default=1, help=‘camera sensitivity’
‘-ga’, ‘–gain’, type=int, default=1, help=‘camera gain’
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# The short X.Y version
version = ""
# The full version, including alpha/beta/rc tags
release = "0.5.7"
release = "0.6.0"

# -- General configuration ---------------------------------------------------

Expand Down
4 changes: 3 additions & 1 deletion docs/localize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Localize allows performing super-resolution reconstruction of image stacks. For

- MLE, integrated Gaussian (based on `Smith et al., 2014 <https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2862147/>`_.)
- LQ, Gaussian (least squares)
- Average of ROI
- Average of ROI (finds summed intensity of spots)

**Please note:** Picasso Localize supports five file formats: ``.ome.tif``, ``NDTiffStack`` with extension ``.tif``, ``.raw``, ``.ims`` and ``.nd2``. If your file has the extension ``.tiff`` or ``.ome.tiff``, it cannot be read. Usually it is enough to change the extension to ``.ome.tif``, i.e., remove the last letter.

Identification and fitting of single-molecule spots
---------------------------------------------------
Expand Down
45 changes: 31 additions & 14 deletions docs/render.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Redundant cross-correlation drift correction
Marker-based drift correction
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1. In ``Picasso: Render``, pick drift markers as described in ``Picking of regions of interest``. Use the ``Pick similar`` option to automatically detect a large number of drift markers similar to a few manually selected ones.
1. In ``Picasso: Render``, pick drift markers as described in **Picking of regions of interest**. Use the ``Pick similar`` option to automatically detect a large number of drift markers similar to a few manually selected ones.
2. If the structures used as drift markers have an intrinsic size larger than the precision of individual localizations (e.g., DNA origami, large protein complexes), it is critical to select a large number of structures. Otherwise, the statistic for calculating the drift in each frame (the mean displacement of localization to the structure's center of mass) is not valid.
3. Select ``Postprocess > Undrift from picked`` to compute and apply the drift correction.
4. (Optional) Save the drift-corrected localizations by selecting ``File > Save localizations``.
Expand Down Expand Up @@ -54,6 +54,21 @@ Rotation around z-axis is available by pressing Ctrl/Command. Rotation axis can

There are several things to keep in mind when using the rotation window. Firstly, using individual localization precision is very slow and is not recommended as a default blur method. Also, the size of the rotation window can be altered, however, if it becomes too large, rendering may start to lag.

RESI
----
.. image:: ../docs/render_resi.png
:width: 374
:alt: UML Render RESI


In Picasso 0.6.0, a new RESI (Resolution Enhancement by Sequential Imaging) dialog was introduced. It allows for a substantial resolution boost by sequential imaging of a single target with multiple labels with Exchange-PAINT (*to be published*).

To use RESI, prepare your individual RESI channels (localization, undrifting, filtering and **alignment**). Load such localization lists into Picasso Render and open ``Postprocess > RESI``. The dialog shown above will appear. Each channel will be clustered using the SMLM clusterer (other clustering algorithms could be applied as well although only the SMLM clusterer is implemented for RESI in Picasso). Clustering parameters can be defined for each RESI channel individually, although it is possible to apply the same parameters to all channels by clicking ``Apply the same clustering parameters to all channels``, which will copy the clustering parameters from the first row and paste it to all other channels.

Next, the user needs to specify whether or not to save clustered localizations or cluster centers from each of the RESI channels individually, and whether to apply basic frame analysis (to minimize the effect of sticking events). For the explanation of the parameters, see `SMLM clusterer <https://picassosr.readthedocs.io/en/latest/render.html#smlm-clusterer>`_.

Upon clicking ``Perform RESI analysis``, each of the loaded channels is clustered, cluster centers are extracted and combined from all RESI channels to create the final RESI file.

Dialogs
-------

Expand Down Expand Up @@ -378,7 +393,11 @@ Apply expressions to localizations
This tool allows you to apply expressions to localizations, for example:

- ``x +=1`` will shift all localization by one to the right
- ``x +=1;y+=1`` will shift all localization by one to the right and one up.
- ``x +=1; y+=1`` will shift all localization by one to the right and one up.
- ``flip x z`` will exchange the x-axis with y-axis if z localizations are present (side projection), similar for ``flip y z``.
- ``spiral r n`` will plot each localization over the time of the movie in a spiral with radius r and n number of turns (e.g., to detect repetitive binding), ``uspiral`` to reverse.

**NOTE:** using two variables in one statement is not supported (e.g. ``x = y``) To filter localizations use picasso filter.

DBSCAN
^^^^^^
Expand All @@ -390,23 +409,21 @@ Cluster localizations with the hdbscan clustering algorithm.

SMLM clusterer
^^^^^^^^^^^^^^
Cluster localizations with the custom algorithm designed for SMLM. In short, localizations with the maximum number of neighboring localizations within a user-defined radius are chosen as cluster centers, around which all localizations withing the given radius belong to one cluster. If two or more such clusters overlap, they are combined.
Cluster localizations with the custom algorithm designed for SMLM. In short, localizations with the maximum number of neighboring localizations within a user-defined radius are chosen as cluster centers, around which all localizations within the given radius belong to one cluster. If two or more local maxima are within the radius, the clusters are merged.

SMLM clusterer requires three (or four if 3D data is processed) arguments:

- Radius: final size of the clusters.
- Radius z (3D only): final size of the clusters in the z axis. If the value is different from radius in xy plane, clusters have ellipsoidal shape. Radius z can have a different value to account for a difference in localization precision in lateral and axial directions.
- Min. locs: minimum number of localizations in a cluster.
- Basic frame analysis: If True, each cluster is checked for its value of mean frame (if it is within the first or the last 20% of the total acquisition time, it is discarded). Moreover, localizations inside each cluster are split into 20 time bins (across the whole acquisition time). If a single time bin contains more than 80% of localizations per cluster, the cluster is discarded.

*NOTE:* it is highly recommended to remove any fiducial markers before clustering, to lower clustering time, given they are of no interest to the user. To do that, the markers can be picked and removed using ``Tools > Remove localizations in picks``.
**Note to all clustering algorithms:** it is highly recommended to remove any fiducial markers before clustering, to lower clustering time, given they are of no interest to the user. To do that, the markers can be picked and removed using ``Tools > Remove localizations in picks``.

Test clusterer
^^^^^^^^^^^^^^
Opens a dialog where different clustering parameters can be checked on the loaded dataset. Requires a single pick region of interest to be selected.

Nearest Neighbor Analysis
^^^^^^^^^^^^^^^^^^^^^^^^^
Calculates distances to the ``k``-th nearest neighbors between two channels (can be the same channel). ``k`` is defined by the user. The distances are stored in nm as a .csv file.

Notes
+++++
Using two variables in one statement is not supported (e.g. ``x = y``) To filter localizations use picasso filter.

Additional commands
+++++++++++++++++++
``flip x z`` will exchange the x-axis with y-axis if z localizations are present (side projection), similar for ``flip y z``.
``spiral r n`` will plot each localization over the time of the movie in a spiral with radius r and n number of turns (e.g., to detect repetitive binding), ``uspiral`` to reverse.
Calculates distances to the ``k``-th nearest neighbors between two channels (can be the same channel). ``k`` is defined by the user. The distances are stored in nm as a .csv file.
Binary file added docs/render_resi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions picasso/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
picasso/__init__.py
~~~~~~~~~~~~~~~~~~~~
:authors: Joerg Schnitzbauer, Maximilian Thomas Strauss, 2016-2018
:authors: Joerg Schnitzbauer, Maximilian Thomas Strauss, Rafal Kowalewski 2016-2023
:copyright: Copyright (c) 2016-2018 Jungmann Lab, MPI of Biochemistry
"""
import os.path as _ospath
import yaml as _yaml

__version__ = "0.6.0"

_this_file = _ospath.abspath(__file__)
_this_dir = _ospath.dirname(_this_file)
Expand All @@ -17,4 +18,4 @@
if CONFIG is None:
CONFIG = {}
except FileNotFoundError:
CONFIG = {}
CONFIG = {}
26 changes: 22 additions & 4 deletions picasso/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,6 @@ def _localize(args):
locs_from_fits,
add_file_to_db,
)

from os.path import splitext, isdir
from time import sleep
from . import gausslq, avgroi
Expand All @@ -780,7 +779,10 @@ def _localize(args):
raise Exception("GPUfit not installed. Aborting.")

for index, element in enumerate(vars(args)):
print("{:<8} {:<15} {:<10}".format(index + 1, element, getattr(args, element)))
try:
print("{:<8} {:<15} {:<10}".format(index + 1, element, getattr(args, element)))
except TypeError: # if None is default value
print("{:<8} {:<15} {}".format(index + 1, element, "None"))
print("------------------------------------------")

def check_consecutive_tif(filepath):
Expand Down Expand Up @@ -849,8 +851,13 @@ def prompt_info():
save_info(info_path, [info])

if paths:
print(args)
box = args.box_side_length
min_net_gradient = args.gradient
roi = args.roi
if roi is not None:
y_min, x_min, y_max, x_max = roi
roi = [[y_min, x_min], [y_max, x_max]]
camera_info = {}
camera_info["baseline"] = args.baseline
camera_info["sensitivity"] = args.sensitivity
Expand Down Expand Up @@ -898,7 +905,7 @@ def prompt_info():
print("Processing {}, File {} of {}".format(path, i + 1, len(paths)))
print("------------------------------------------")
movie, info = load_movie(path)
current, futures = identify_async(movie, min_net_gradient, box)
current, futures = identify_async(movie, min_net_gradient, box, roi=roi)
n_frames = len(movie)
while current[0] < n_frames:
print(
Expand Down Expand Up @@ -1435,6 +1442,17 @@ def main():
default=1000,
help="segmentation size for subsequent RCC, 0 to deactivate",
)
localize_parser.add_argument(
"-r",
"--roi",
type=int,
nargs=4,
default=None,
help=(
"ROI (y_min, x_min, y_max, x_max) in camera pixels;\n"
"note the origin of the image is in the top left corner"
),
)
localize_parser.add_argument(
"-bl", "--baseline", type=int, default=0, help="camera baseline"
)
Expand Down Expand Up @@ -1468,7 +1486,7 @@ def main():
default="",
help="Suffix to add to files",
)

localize_parser.add_argument(
"-db",
"--database",
Expand Down
2 changes: 1 addition & 1 deletion picasso/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION_NO = "0.5.7"
VERSION_NO = "0.6.0"
Loading

0 comments on commit 51e9ec3

Please sign in to comment.