HenriquesLab / HenriquesLab/VLab4Mic

random_seed not propagated to randomise_axial_position (dormant reproducibility gap)

Open
#135 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Follow-up from the random-seed propagation work in #134.

What
CoordinatesField.randomise_axial_position() (src/vlab4mic/generate/coordinates_field.py) builds its RNG as np.random.default_rng(seed=random_seed), but its only caller, _gen_abs_from_rel_positions() (line ~501), invokes it with no argument:

if self.axial_offset is not None:
    self.randomise_axial_position()   # random_seed defaults to None

So when axial offsets are in use, the axial z-placement draws from a fresh non-deterministic Generator and ignores the seed (a default_rng(None) does not read the global np.random.seed set in experiments.py). All other stochastic inputs (positions via the global seed, orientations and rotations via the threaded random_seed) are reproducible after #134.

Impact: dormant. randomise_axial_position only runs when self.axial_offset is not None. No current article-figure script sets axial_offset (the NPC scripts use axial_precision / axial_resolution_nm, which are unrelated PSF params), so the manuscript figures are unaffected and reproducible. This only bites a user who explicitly configures axial_offset.

Suggested fix
_gen_abs_from_rel_positions() is a no-arg helper called from many places, so threading the seed through the call site is awkward. Cleaner: persist the seed on the field instance (e.g. set self.random_seed in set_molecules_params / create_minimal_field) and have randomise_axial_position default to self.random_seed. Then drop the now-redundant random_seed params that are accepted but unused in the global-np.random position helpers (generate_random_positions), or wire them similarly, for a consistent seeding story.

Priority: low (latent; does not affect current figures).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/vlab4mic/generate/coordinates_field.py, reading CoordinatesField.randomise_axial_position() and its call from _gen_abs_from_rel_positions() around line 501. Trace how set_molecules_params or create_minimal_field handles the seed, then verify that configurations using axial_offset produce repeatable axial placement with the same seed without breaking the existing position and orientation behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.