Skip to content

Extend pipeline tests#132

Closed
raymondwjang wants to merge 21 commits into
mainfrom
extend-pipeline-tests
Closed

Extend pipeline tests#132
raymondwjang wants to merge 21 commits into
mainfrom
extend-pipeline-tests

Conversation

@raymondwjang
Copy link
Copy Markdown
Member

@raymondwjang raymondwjang commented Aug 19, 2025

🔍 Type of Change

🧪 Improvement: Enhancements or optimizations to existing code

📝 Description

Extending test cases to multiple cells, connected and overlapping.

  • noob updated to handle class methods returning generators
  • cell size estimations
  • detected-on used as a proxy to confidence
  • max-iter implemented for trace and footprint frame ingestions
  • new components get merged with "touching" footprints as well (could be eventually extended to merging existing cells with each other)
  • energy is frobenius-norm of V instead of its square sum. This means the actual values align with the true brightness of the video, positioning it to better serve as a physical metric.

after some parameter tweaking, the algorithm successfully extracted correct footprints and (roughly) correct traces from all tests.

As expected, if the movie begins with all overlapping components active and none of them go silent long enough for other components to fill out the overlapping portions, the algorithm never fully completes the video. This is an expected behavior, as we have chosen a more conservative approach to growing / adding components.

Separate cells get initialized and tracked with little to no error, as expected as well.

More minor test cases, e.g. two overlapping cells, output satisfactory reproduction score as well.

The more stringent, but visible and satisfying test case involves an original movie starting with 5 overlapping components, as following:

Y_81

the brightness signature of these 5 blobs are set as following:

decr = np.array(range(self.n_frames - 1, 0, -1), dtype=float)  # monotonically decreasing
sine = np.abs(np.sin(np.linspace(0, 2 * np.pi, self.n_frames - gap)) * self.n_frames)  # absolute sine function
incr = np.array(range(self.n_frames - gap * 2), dtype=float)  # monotonically increasing
expo = (
    np.linspace(0, np.exp(3), self.n_frames - gap * 3)
    * np.exp(-np.linspace(0, np.exp(2), self.n_frames - gap * 3))
    * self.n_frames
)  # y = xe^-x
tanh = np.tanh(np.linspace(0, 5, self.n_frames - gap * 4)) * self.n_frames  # hyperbolic tangent

These signatures begin 20 frames apart from each other, starting from top to bottom.

Results:
5 components detected

footprints

A_0 A_1 A_2 A_3 A_4

traces

monotonically decreasing: the "wobble" grows as the frame number increases, possibly reflecting the error and instability propagating from adding overlapping cells in other parts of the frame.
C_0

absolute sine function
C_1

monotincally increasing: You can observe the moment two overlapping cells got initialized (the irregularities in the graph), and the algorithm pushing the momentum back to the original trace.
C_2

y = xe^-x
C_3

hyperbolic tangent: simulating a steeper, sudden onset of an overlapping component
C_4

max residual per frame

R_max

the overlapping parts are clearly causing some level of error - we can see residuals rising from 40-60 and 60-80. Have not fully investigated why this is the case yet. My initial guess is that it's having trouble fully reproducing the overlap with the 5 latest components but i cannot readily guess why.

ex:
residuals from 64 to 80, 4 frames apart each
R_64
R_68
R_72
R_76
R_80
The actual value of the residuals are small.

Final movie reproduction

Frame 99:
A@C:
AC_97
Y:
Y_97

🧪 Testing

  • Ran unit tests
  • Ran integration tests
  • Performed manual testing
  • Updated existing tests

🛠️ Dependencies

✅ Checklist

  • My code follows the project's style guidelines
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

📚 Documentation preview 📚: https://cala--132.org.readthedocs.build/en/132/

@raymondwjang
Copy link
Copy Markdown
Member Author

raymondwjang commented Aug 19, 2025

TODO: add splitting test, refit existing tests

improve parameters:
residual -> clip_threshold
slicenmf -> detect_thresh

Finish test conditions:
cell count
footprint match
trace match

@raymondwjang raymondwjang force-pushed the extend-pipeline-tests branch from cdb7eab to d16ebec Compare August 19, 2025 23:07
@raymondwjang
Copy link
Copy Markdown
Member Author

Footprint frame ingestion occurs between trace frame ingestion and residual update, since it expands and essentially gives a set of "wrong" footprints. So we try to:

  1. update traces with the best guesses, and then
  2. try to expand the footprints,
  3. subsequently whittling them down with residual testing.

@raymondwjang raymondwjang force-pushed the extend-pipeline-tests branch from d16ebec to 212c819 Compare August 19, 2025 23:47
@raymondwjang raymondwjang force-pushed the extend-pipeline-tests branch from 212c819 to a700d1a Compare August 20, 2025 00:37
@raymondwjang raymondwjang mentioned this pull request Aug 22, 2025
10 tasks
@raymondwjang raymondwjang marked this pull request as draft September 4, 2025 17:56
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.

1 participant