Skip to content

Stardist and draft cp_plugin#110

Merged
bethac07 merged 44 commits intomainfrom
cp_plus_stardist
Nov 19, 2025
Merged

Stardist and draft cp_plugin#110
bethac07 merged 44 commits intomainfrom
cp_plus_stardist

Conversation

@rajavishah
Copy link
Copy Markdown
Collaborator

No description provided.

@rajavishah
Copy link
Copy Markdown
Collaborator Author

This is the basic template, but updation in the spec file, we need to look if the display function and categories are performing as expected. As of now, I have kept the previously commented code also (in case that helps to refactor the current version)

@rajavishah rajavishah marked this pull request as ready for review April 11, 2025 21:29
@rajavishah
Copy link
Copy Markdown
Collaborator Author

rajavishah commented Jun 20, 2025

Some Notes (might be helpful for PR review)

  1. Plugin’s category (like Image Processing, Object Processing, etc.) are defined after looking at the types of inputs and outputs defined from the config. These types (image, measurement, array, file or executable) are normalized to core types—image, object, or measurement—and matched against a predefined sparse matrix to classify the plugin
    1a. But in my understanding cellpose, stardist etc. falls under Object Processing whilst dynamically running this it would be Image Processing. So, feel free to correct the mapping here

  2. Currently, the Docker mount path is hardcoded as /data in the generated plugin. To make this more flexible, we could introduce a configurable flag like docker_mount_path so users can customize it as needed. Or we can document that all CellProfiler plugins generated by Bilayers expect /data to be the mounted directory inside the container, and users should ensure their volume mounts follow this convention

  3. Current plugin generation is based on CellProfiler’s segmentation template, which defines ImageSegmentation as the hardcoded superclass. Hence, all generated plugins currently inherit from ImageSegmentation, regardless of the actual algorithm type

  4. One more thing to verify, type mappings here

Points 2 & 3 may be revisited in future PRs to avoid overloading the current ones

Base automatically changed from cli to fix_documentation July 30, 2025 15:10
Base automatically changed from fix_documentation to selfhosted_runner July 30, 2025 15:11
Base automatically changed from selfhosted_runner to clean_bilayers_cli July 30, 2025 15:11
Base automatically changed from clean_bilayers_cli to main July 30, 2025 15:11
@rajavishah
Copy link
Copy Markdown
Collaborator Author

In Object Processing modules (eg. classical segmentation), the template currently assigns LabelSubscriber to inputs (here) even when the pipeline is providing an image (e.g., "DNA").
fix - it should be simple ImageSubscriber?

@rajavishah
Copy link
Copy Markdown
Collaborator Author

For the output — here
--> the current implementation is breaking because the generated output is ImageName. This needs to be fixed, as my implementation fails at this point

I was thinking to resolve this comment

I think we want to do this based on subtype of label (or not), right? Because a segmenter might make an image AND an object, for example

@bethac07
Copy link
Copy Markdown
Contributor

The label subscriber might at least partially be an us problem - I notice that in at least Cellpose and Classical Segmentation, we have "labeled" as one of the input types, which it shouldn't be - you shouldn't be segmenting on labels.

I don't fully understand your second question?

@rajavishah
Copy link
Copy Markdown
Collaborator Author

Ahh I see! For the classical segmentation algorithm, the issue was that the template generated LabelSubscriber/LabelName in the inputs/outputs. This broke the pipeline because CellProfiler was expecting an image, but a label was provided instead. This should now be resolved if labeled is not passed in the config

@rajavishah
Copy link
Copy Markdown
Collaborator Author

I havent tested - but is run function breaking in saving files now?

@rajavishah
Copy link
Copy Markdown
Collaborator Author

Sorry, would you plz delete this line in your next commit @bethac07? I missed this whilst merging main into cp_plus_stardist

@bethac07
Copy link
Copy Markdown
Contributor

I havent tested - but is run function breaking in saving files now?

Of the 5 possible plugins, 3 fail to load (instanseg, cellpose, and gaussian) due to errors in writing the config - not great, but not terrible for a first test. Classical and Stardist load but don't work (but I've worked out what needs to be changed for at least Classical, and Stardist needs some of the same changes). I'll plug away at the fixes!

@bethac07
Copy link
Copy Markdown
Contributor

All modules now load in CellProfiler

description: "Segments images using stardist"

docker_image:
org: rajavishah
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you want to keep this in your personal account, or should we re-tag into to the Bilayers org?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Nope, let's keep it into official org

org: rajavishah
name: stardist
tag: "7.0.0"
platform: "linux/arm64/v8"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we also/instead make an amd64, since it's more-cross-platform?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Since, it was built on my laptop the platform flag needs to be passed in as arm64 - to resolve the `docker ... --platform linux/arm64/v8 .." for a non-arm user

But sure, we can make it amd64 w/ new tags

Copy link
Copy Markdown
Contributor

@bethac07 bethac07 Oct 2, 2025

Choose a reason for hiding this comment

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

Probably time to return to #55 , and also think about arches as a thing to matrix there

@rajavishah rajavishah mentioned this pull request Oct 23, 2025
* [add] unique_string at parsing level

* [mod] use glob-based matching for outputs

* [fix] '

* [fix] normalize bool to avoid string/True confusion

* [readd] somehow deleted stardist_inference.py

* chore: trigger GitHub recheck after merge

* [fix] correctly handle single vs multiple output files in plugin generation

Now loads a single image as ndarray and multiple outputs as list of ndarrays

* [fix] unify output handling

- Replaced per-type output blocks with single dynamic loader
- Added dynamic workspace + display_data registration for all outputs
- Improved measurement saving and logging consistency

* [add] unique_string support for inputs

[fix] wildcard * support for outputs

* [add] dynamic mount handling

separated input/output mounts, added fallbacks, deduplication, and safe image saving
@bethac07 bethac07 merged commit 9bd76f9 into main Nov 19, 2025
2 checks passed
@bethac07 bethac07 deleted the cp_plus_stardist branch November 19, 2025 16:17
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.

3 participants