Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ More in [the Python guide](docs/python.md). Once a release is on PyPI,
Channel alignment works on a single timepoint. For a multichannel
time-lapse, the drift is measured on the reference channel and the same
correction is applied to every channel.
3. **Z drift needs enough slices.** Z drift is measured on side projections of
the stack. On stacks of about 10 slices or fewer it may not be found at
all; check the `dz` column of the drift table.
3. **Z drift needs enough slices.** Z drift is measured on a side view of the
stack. On stacks of about 10 slices or fewer it is underestimated, down to
almost zero for smooth, textured images; the original Fiji Fast4DReg gives
the same numbers. Check the `dz` column of the drift table.

More in [Troubleshooting](docs/troubleshooting.md).

Expand Down
10 changes: 6 additions & 4 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ settings.
Try the `mean` projection (better for noisy images), time averaging, or a
maximum expected drift a little above the real drift.

**The Z drift stays at 0 although the sample moves in Z.** The stack may have
too few slices: on about 10 slices or fewer, Z drift may not be measured. With
20 slices or more it is. Check that Z correction is ticked and that the axes
put Z where it is in the file.
**The Z drift is too small, or stays near 0, although the sample moves in Z.**
The stack may have too few slices: on about 10 slices or fewer, Z drift is
underestimated, down to almost zero for smooth images (Fiji Fast4DReg does the
same; see [Before you start](workflow.md#before-you-start)). With about 20
slices it is measured correctly. Also check that Z correction is ticked and
that the axes put Z where it is in the file.

**The corrected movie still drifts slowly (live samples).** Compare with the
previous frame (`reference: previous`) instead of the first.
Expand Down
20 changes: 17 additions & 3 deletions docs/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,23 @@ Fiji saves hyperstacks in the order T, Z, C, Y, X and leaves out the
dimensions of size 1. If the axes do not match the image, Fast4DRegPy stops
and tells you the image's shape.

**Z drift needs enough slices.** On stacks of about 10 slices or fewer, Z drift
may not be found at all (the `dz` column stays near 0). With 20 slices or
more it is measured reliably.
**Z drift needs enough slices.** Z drift is measured on a side view of the
stack (Z against X), stretched to a square and cross-correlated. On a thin
stack that view is only a few rows tall: its top and bottom edges and its
brightness profile along Z do not move with the drift, and a drift of one or
two slices replaces a large part of it. The estimate is then pulled towards
zero. On stacks of about 10 slices or fewer, Z drift is underestimated: by a
quarter to a half for sharp, scattered structures, down to almost zero for
smooth texture. With about 20 slices it is measured correctly. The original
Fiji Fast4DReg gives exactly the same numbers on such stacks; this is a
property of the method, not of the Python version. If you need Z correction,
acquire more slices, and check the `dz` column of the drift table.

| Test movie, true Z drift 0, 1, 2, 1 slices | Fiji Fast4DReg | Fast4DRegPy |
|---|---|---|
| Smooth texture, 10 slices | 0, 0.02, 0.03, 0.02 | 0, 0.02, 0.03, 0.02 |
| Beads, 10 slices | 0, 0.74, 1.65, 0.74 | 0, 0.74, 1.65, 0.74 |
| Smooth texture, 20 slices | 0, 0.99, 1.99, 0.99 | 0, 0.99, 1.99, 0.99 |

## Running it in the notebook

Expand Down
3 changes: 2 additions & 1 deletion lc_tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ labconstrictor-tools test --module fast4dreg_lc_tools --cases cases.json
`make_fixtures.py` writes four small images cut out of one random scene at
known whole-pixel offsets (Y and X sizes differ, so an axis swap shows):
a 2D and a 3D time-lapse, and a 2D and a 3D multichannel image. The 3D
images have 20 slices: with about 10, Fast4DRegPy does not measure the Z drift.
images have 20 slices: on 10, the Z drift of this smooth scene is measured
as almost zero (by Fiji Fast4DReg too).

`cases.json` runs each tool on them and checks what the hosts rely on: the
shape and type of the corrected image, the columns and rows of the drift
Expand Down
2 changes: 1 addition & 1 deletion lc_tests/make_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def write(folder: Path) -> None:
metadata={"axes": "TYX"},
)

volume = scene((38, 96, 104), seed=2) # 20 slices: Z drift is not measured on ~10
volume = scene((38, 96, 104), seed=2) # 20 slices: Z is underestimated on ~10
frames = [cut(volume, o, (20, 64, 72)) for o in TIME_Z_OFFSETS]
tifffile.imwrite(
folder / "drift_tzyx.tif",
Expand Down
Loading