Skip to content
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
07d8620
ENH: Add scripts for OpenCV detection
Jul 22, 2025
4bed7b7
TST: Modified test scripts
Aug 13, 2025
4dee8a8
neat_ml/tests/baseline/raw_detection.png,neat_ml/tests/baseline/raw_p…
Aug 13, 2025
cbaf765
DOC: Updated README.md with instructions
Sep 8, 2025
fb3e53d
ENH: Added BubbleSAM detection method
Sep 3, 2025
a4e60cb
ENH: Created workflow module
Sep 10, 2025
3dbd68a
ENH: Added analysis module
Sep 10, 2025
42b2430
TST: Fixed test_workflow.py to improve coverage
Sep 11, 2025
8c3963f
TST: Added test scripts to improve coverage
Sep 16, 2025
543e80e
MAINT: PR #4 revisions
ajwitmer Feb 17, 2026
281313e
MAINT, TST, DOC, BUG: PR #4 revisions
ajwitmer Feb 17, 2026
0facd63
MAINT, TST: PR #4 revisions
ajwitmer Feb 18, 2026
0d61f0f
MAINT: fix conflicts after rebase
ajwitmer Mar 11, 2026
639c731
MAINT, TST, DOC: PR #4 revisions
ajwitmer Mar 9, 2026
a553912
BUG, TST: fix logic for aggregating metrics
ajwitmer Mar 12, 2026
dd48f7e
MAINT, TST, DOC: PR #4 revisions
ajwitmer Mar 12, 2026
23799cf
MAINT, TST, DOC: PR #4 revisions
adamwitmer Mar 13, 2026
fa1b01e
DOC, TST: fix inline test comment
adamwitmer Mar 13, 2026
085d96e
TST: loosen floating point tolerance for voronoi calculation
adamwitmer Mar 13, 2026
d5a3a3d
TST, MAINT: replace general exceptions and add new test cases
ajwitmer Mar 20, 2026
5e9b96a
MAINT: address reviewer comments
Apr 23, 2026
11f2064
MAINT, TST: modify test assertion for dict comparison
ajwitmer Apr 24, 2026
bd11fd4
MAINT, TST: modify dict assertions to use assert_allclose
ajwitmer Apr 25, 2026
429fe14
MAINT: address remaining reviewer comments
ajwitmer Apr 29, 2026
c327073
BUG: fix parquet loading logic
ajwitmer May 1, 2026
b887112
MAINT: address reviewer comments
ajwitmer May 3, 2026
e8565b6
MAINT: address reviewer comments
ajwitmer May 4, 2026
64a9454
MAINT: address AI reviewer comments
Jun 3, 2026
2d09911
MAINT: address reviewer comments
Jun 9, 2026
05912a2
ENH: vectorize bubblesam centroid calculation
Jun 9, 2026
d214811
MAINT: modify handling of results csv filepaths
Jun 9, 2026
3d0d74e
MAINT: PR #4 revisions
Jun 9, 2026
6b9a1b6
MAINT: address AI reviewer comment
Jun 10, 2026
f57eaa5
MAINT: modify pandas agg operation to use lambda function
adamwitmer Jun 22, 2026
62b38c9
MAINT: PR #4 revisions
adamwitmer Jun 23, 2026
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
43 changes: 41 additions & 2 deletions README.md
Comment thread
adamwitmer marked this conversation as resolved.
Comment thread
adamwitmer marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,26 @@ This `yaml` input file is separate from the `yaml` files used by `SAM-2` to
build the model architecture, e.g. `sam2.1-hiera-l.yaml`, but user provided
mask parameters override the built-in parameters for the `SAM-2` model.

When performing analysis/metric calculation of the resulting bubble detections,
the `yaml` file provides the necessary paths for finding the detection parquet
files; the user generated composition csv file that stores per-image sample
information related to the experimental setup and data collection including
phase separation ground-truth labels and composition weight percentages;
the paths for storing per-image and aggregate metrics. The user also provides
a choice of method for calculating graph-based metrics of bubble connectivity
(`knn`, `radius` or `delaunay`). With `graph_method == knn`, the user must provide
a `k_param` integer value denoting the number of nearest neighbors to use for
building the graph. With `graph_method == radius`, the user must provide an
`r_param` integer or float value denoting the radius in pixels to search
for neighboring nodes with which to build the graph. Optionally, the user
can also provide the column names on which to group the aggregate metrics
during analysis. The same per-image and aggregate metrics are calculated for
both detection methods (OpenCV and BubbleSAM).

The `.yaml` file should follow the format below (examples
can be found at `neat_ml/data/opencv_detection_test.yaml`
and `neat_ml/data/bubblesam_detection_test.yaml`).
`neat_ml/data/bubblesam_detection_test.yaml`, and
`neat_ml/data/opencv_analysis_test.yaml`).
Input paths for `work` and `img_dir` parameters can be
provided as either absolute or relative file paths.

Expand All @@ -43,6 +60,10 @@ datasets:
method: Supports ``OpenCV`` or ``BubbleSAM`` as input
class: subfolder_for_image_class
time_label: subfolder_for_timestamp
# `composition_cols` used for step: analysis
composition_cols:
- "Dextran 500 kg/mol (wt%)"
- "PEO 20 kg/mol (wt%)"

detection:
img_dir: path/to/image/data (Can be a directory of ``.tiff`` images or a path to a single ``.tiff`` image.)
Expand Down Expand Up @@ -70,6 +91,20 @@ datasets:
# for list of available checkpoints
checkpoint_path: "facebook/sam2.1-hiera-large"
device: "gpu" OR "cpu"
# only include the content below when calling steps: analysis
analysis:
input_dir: path/to/parquet/files
composition_csv: path/to/composition/information

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is it obvious what this is/how this is made available from an earlier step?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I have added a sentence clarifying that the composition csv file is a user generated file with relevant information for generating the aggregate dataset.

per_image_csv: path/to/save/per/image/csv
aggregate_csv: path/to/save/aggregate/csv
group_cols:
- Group
- Label
- Time
- Class
graph_method: radius OR knn OR delaunay
k_param: the number of neighbors to use (int; when using ``graph_method == knn``)
r_param: the neighborhood radius in pixels (int, float; when using ``graph_method == radius``)
```

### To run the code on CHICOMA:
Expand Down Expand Up @@ -119,7 +154,7 @@ https://github.com/facebookresearch/sam2/blob/2b90b9f5ceec907a1c18123530e92e794a

To run the workflow with a given `.yaml` file:

`python run_workflow.py --config <YAML file> --steps detect`
`python run_workflow.py --config <YAML file> --steps detect,analysis (i.e. all)`

To run the workflow using ``opencv_detection_test.yaml`` (and similarly with ``bubblesam_detection_test.yaml``):
Comment thread
adamwitmer marked this conversation as resolved.

Expand All @@ -137,6 +172,10 @@ python -c "import pooch; print(pooch.os_cache('test_images'))"
This should process and detect bubbles from the image file `images_raw.tiff` and
place the outputs under ``roots:work`` filepath from the `.yaml` file

For the `analysis` step, the lines provided in `opencv_analysis_test.yaml` also need to be added to the
input `yaml` file (a description of which can also be found above). These steps process the output bubble
detection data and save 'csv' files containing per-image and aggregated metrics.

For information relevant to running the workflow:

`python run_workflow.py --help`
Expand Down
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ ignore_missing_imports = True

[mypy-cupy.*]
ignore_missing_imports = True

[mypy-networkx.*]
ignore_missing_imports = True
Empty file added neat_ml/analysis/__init__.py
Empty file.
Loading