Skip to content

DemoCamera: add objective- and channel-aware Multicolor Beads mode - #1042

Open
mutterer wants to merge 1 commit into
micro-manager:mainfrom
mutterer:demo-camera-multicolor-beads
Open

mutterer wants to merge 1 commit into
micro-manager:mainfrom
mutterer:demo-camera-multicolor-beads

Conversation

@mutterer

Copy link
Copy Markdown
Contributor

Add a separate Multicolor Beads mode with objective-dependent specimen scale and deterministic DAPI, FITC, Rhodamine, and Cy5 populations. Support the standard demo filter and multiband LED presets, RGB pseudocolors, and read-only simulation diagnostics.

Preserve legacy Fluorescent Beads rendering, retaining the RGB buffer-clear safety fix and defined unsigned tile hashing.

Validation: Linux build; specimen geometry, ROI, binning, stage movement, channel populations and RGB tests; 45 legacy image cases match a separately compiled official baseline pixel-for-pixel.

Add a separate Multicolor Beads mode with objective-dependent specimen scale and deterministic DAPI, FITC, Rhodamine, and Cy5 populations. Support the standard demo filter and multiband LED presets, RGB pseudocolors, and read-only simulation diagnostics.

Preserve legacy Fluorescent Beads rendering, retaining the RGB buffer-clear safety fix and defined unsigned tile hashing.

Validation: Linux build; specimen geometry, ROI, binning, stage movement, channel populations and RGB tests; 45 legacy image cases match a separately compiled official baseline pixel-for-pixel.
@mutterer

Copy link
Copy Markdown
Contributor Author

This was done using Codex GPT6.1 for a Smart Microscopy Hackathon and helps implement the canonical Overview>Detect Objects>Analyse>Change Objective>Revisit objects. workflow

@marktsuchida marktsuchida left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool stuff! However, I'm a little worried about adding more and more to the already-bloated DemoCamera, without making sure at each step that everything works consistently and predictably.

The position label–based wavelength selection and pixel size are going to be fragile, and probably a little confusing, if not just using the demo config unmodified. At the very least, we need to have simple rules that can easily be documented. (In theory I'd favor adjusting the demo config to work with the demo devices, rather than the other way around. However, we'd need to check how the demo config is currently used in tests, e.g. by pymmcore-plus. Another reason why DemoCamera is no longer easy to change.)

You might also be interested in the in-development SimulatedMicroscope adapter (not in nightly builds yet but the GitHub release has binaries), which we started as a new adapter so that every device could be purpose-built for simulation without unrelated baggage. It doesn't yet have any wavelength-based behavior, though, and some details are subject to change.

I'm not opposed to adding this to DemoCamera for now, if the following points can more or less be addressed.

bead.worldY = tileWorldY + (double)std::rand() / RAND_MAX * tileSize;
bead.intensityFactor = 0.8 + 0.4 * (double)std::rand() / RAND_MAX; // 80-120%
bead.sizeFactor = 0.8 + 0.4 * (double)std::rand() / RAND_MAX; // 80-120%
beads.push_back(bead);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bead.channelMask left uninitialized?

}


// Original Fluorescent Beads mode from the checked-out official repository.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment won't make sense once merged.

// Use tile hash as seed for deterministic random generation
unsigned int seed = HashTileCoords(tileX, tileY);
std::srand(seed);
// Separate RNG keeps the existing specimen positions unchanged.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"existing" won't make sense once merged.


// Generate beads for a specific tile using procedural generation
void CDemoCamera::GenerateBeadsForTile(int tileX, int tileY, std::vector<Bead>& beads)
void CDemoCamera::GenerateMulticolorBeadsForTile(int tileX, int tileY, std::vector<Bead>& beads)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any chance of combining the multicolor implementation with the existing non-multicolor version instead of duplicating much of the code? Same for the other multicolor functions (generate positions, render to image, and generate image).

Comment on lines +843 to +846
double magnification = LabelMagnification(DeviceLabel(objective));
if (!(magnification > 0)) magnification = 10.0;
return binSize_ * 10.0 / magnification;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to being fragile (makes assumptions about objective position labels), this ignores the Magnifier (DOptovar) setting. And I don't think it make sense to have fixed 1 µm/px for fluorescent beads and variable for the multi-color beads (assuming I'm reading that right).

@marktsuchida

Copy link
Copy Markdown
Member

I suggest to close this PR

Closing for now. Created marktsuchida/mmdev-SimulatedMicroscope#19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants