Skip to content

Commit

Permalink
Merge pull request #508 from rafalkowalewski1/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
rafalkowalewski1 authored Dec 14, 2024
2 parents 883e9f1 + a3e4961 commit 45d2713
Show file tree
Hide file tree
Showing 14 changed files with 553 additions and 243 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.7.3
current_version = 0.7.4
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down
12 changes: 10 additions & 2 deletions changelog.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
Changelog
=========

Last change: 02-OCT-2024 MTS
Last change: 14-DEC-2024 MTS

0.7.1 - 0.7.3
0.7.1 - 0.7.4
-------------
- SMLM clusterer in picked regions deleted
- Show legend in Render property displayed rounded tick label values
- Pick circular area does not save the area for each pick in localization's metadata
- Picasso: Render - adjust the scale bar's size automatically based on the current FOV's width
- Picasso: Render - RESI dialog fixed, units in nm
- Picasso: Render - show drift in nm, not camera pixels
- Picasso: Render - masking localizations saves the mask area in its metadata
- Picasso: Render - export current view across channels in grayscale
- Picasso: Render - title bar displays the file only the names of the currently opened files
- CMD implementation of AIM undrifting, see ``picasso aim -h`` in terminal
- CMD localize saves camera information in the metadata file
- Other minor bug fixes

0.7.0
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.7.3
AppVersion=0.7.4
DefaultDirName={commonpf}\Picasso
DefaultGroupName=Picasso
OutputBaseFilename="Picasso-Windows-64bit-0.7.3"
OutputBaseFilename="Picasso-Windows-64bit-0.7.4"
ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode=x64

Expand Down
4 changes: 4 additions & 0 deletions docs/cmd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ undrift
-------
Correct localization coordinates for drift with RCC.

aim
-------
Correct localization coordinates for drift with AIM.

density
-------
Compute the local density of localizations
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.7.3"
release = "0.7.4"

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

Expand Down
2 changes: 1 addition & 1 deletion picasso/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os.path as _ospath
import yaml as _yaml

__version__ = "0.7.3"
__version__ = "0.7.4"

_this_file = _ospath.abspath(__file__)
_this_dir = _ospath.dirname(_this_file)
Expand Down
77 changes: 71 additions & 6 deletions picasso/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,26 @@ def _undrift(files, segmentation, display=True, fromfile=None):
savetxt(base + "_drift.txt", drift, header="dx\tdy", newline="\r\n")


def _undrift_aim(
files, segmentation, intersectdist=20/130, roiradius=60/130
):
import glob
from . import io, aim
from numpy import savetxt

paths = glob.glob(files)
for path in paths:
try:
locs, info = io.load_locs(path)
except io.NoMetadataFileError:
continue
print("Undrifting file {}".format(path))
locs, new_info, drift = aim.aim(locs, info, segmentation, intersectdist, roiradius)
base, ext = os.path.splitext(path)
io.save_locs(base + "_aim.hdf5", locs, new_info)
savetxt(base + "_aimdrift.txt", drift, header="dx\tdy", newline="\r\n")


def _density(files, radius):
import glob

Expand Down Expand Up @@ -985,6 +1005,7 @@ def prompt_info():
print("------------------------------------------")

info.append(localize_info)
info.append(camera_info)

base, ext = splitext(path)

Expand Down Expand Up @@ -1210,12 +1231,12 @@ def main():
" specified by a unix style path pattern"
),
)
undrift_parser.add_argument(
"-m",
"--mode",
default="render",
help='"std", "render" or "framepair")',
)
# undrift_parser.add_argument(
# "-m",
# "--mode",
# default="render",
# help='"std", "render" or "framepair")',
# )
undrift_parser.add_argument(
"-s",
"--segmentation",
Expand All @@ -1239,6 +1260,48 @@ def main():
help="do not display estimated drift",
)

# undrift by AIM parser
undrift_aim_parser = subparsers.add_parser(
"aim", help="correct localization coordinates for drift with AIM"
)
undrift_aim_parser.add_argument(
"files",
help=(
"one or multiple hdf5 localization files"
" specified by a unix style path pattern"
),
)
undrift_aim_parser.add_argument(
"-s",
"--segmentation",
type=float,
default=100,
help=(
"the number of frames to be combined"
" for one temporal segment (default=100)"
),
)
undrift_aim_parser.add_argument(
"-i",
"--intersectdist",
type=float,
default=20/130,
help=(
"max. distance (cam. pixels) between localizations in"
" consecutive segments to be considered as intersecting"
),
)
undrift_aim_parser.add_argument(
"-r",
"--roiradius",
type=float,
default=60/130,
help=(
"max. drift (cam. pixels) between two consecutive"
" segments"
),
)

# local densitydd
density_parser = subparsers.add_parser(
"density", help="compute the local density of localizations"
Expand Down Expand Up @@ -1708,6 +1771,8 @@ def main():
)
elif args.command == "undrift":
_undrift(args.files, args.segmentation, args.nodisplay, args.fromfile)
elif args.command == "aim":
_undrift_aim(args.files, args.segmentation, args.intersectdist, args.roiradius)
elif args.command == "density":
_density(args.files, args.radius)
elif args.command == "dbscan":
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.7.3"
VERSION_NO = "0.7.4"
18 changes: 13 additions & 5 deletions picasso/aim.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,8 @@ def aim(
-------
locs : _np.rec.array
Undrifted localizations.
new_info : list of 1 dict
Updated metadata.
drift : _np.rec.array
Drift in x and y directions (and z if applicable).
"""
Expand Down Expand Up @@ -686,9 +688,13 @@ def aim(
drift_x = drift_x1 + drift_x2
drift_y = drift_y1 + drift_y2

# # shift the drifts by the mean value
drift_x -= _np.mean(drift_x)
drift_y -= _np.mean(drift_y)
# shift the drifts by the mean value
shift_x = _np.mean(drift_x)
shift_y = _np.mean(drift_y)
drift_x -= shift_x
drift_y -= shift_y
x_pdc += shift_x
y_pdc += shift_y

# combine to Picasso format
drift = _np.rec.array((drift_x, drift_y), dtype=[("x", "f"), ("y", "f")])
Expand All @@ -713,7 +719,9 @@ def aim(
aim_round=2, progress=progress,
)
drift_z = drift_z1 + drift_z2
drift_z -= _np.mean(drift_z)
shift_z = _np.mean(drift_z)
drift_z -= shift_z
z_pdc += shift_z
drift = _np.rec.array(
(drift_x, drift_y, drift_z),
dtype=[("x", "f"), ("y", "f"), ("z", "f")]
Expand All @@ -726,7 +734,7 @@ def aim(
locs["z"] = z_pdc

new_info = {
"Undrifted by": "AIM",
"Generated by": "AIM undrift",
"Intersect distance (nm)": intersect_d * pixelsize,
"Segmentation": segmentation,
"Search regions radius (nm)": roi_r * pixelsize,
Expand Down
Loading

0 comments on commit 45d2713

Please sign in to comment.