Skip to content

Conversation

@ascibisz
Copy link
Contributor

@ascibisz ascibisz commented Apr 24, 2025

Time estimate or Size

small

Problem

A user reported that scaling wasn't working as expected for the Cytosim converter.

Looking at the code, we were erroneously scaling all agent data that had been read thus far with each file read. So for example, for the user that reported the bug, there were 4 input files, so the first file that was read would get scaled by the scale factor 4 times, the second would get scaled 3 times, the third would get scaled twice, and the final file would get scaled the expected one time. This resulted in things looking very weird and unexpected!

Link to story or ticket

Solution

Let's just apply the scale factor once per conversion, after we have all the data read in. This is a very small change, just moving the scale factor part to be after the for loop where we're going through the input files.

Also let's update the test to make sure this doesn't happen again. Our original scale factor test only read in one file, so thus the problem with multiple files was missed.

@ascibisz ascibisz linked an issue Apr 24, 2025 that may be closed by this pull request
@ascibisz ascibisz marked this pull request as ready for review April 24, 2025 19:30
@ascibisz ascibisz requested a review from a team as a code owner April 24, 2025 19:30
@ascibisz ascibisz requested review from rugeli and toloudis and removed request for a team April 24, 2025 19:30
Copy link
Contributor

@toloudis toloudis left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for the quick fix. Too bad we don't have "simpler" test data so it's easier to see how the tests work.

# value of automatically generated scale factor, so that position
# data fits within VIEWER_DIMENSION_RANGE
range = 0.400052 - -0.001
range = 0.00808633 - -0.39575567
Copy link
Contributor

Choose a reason for hiding this comment

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

curious why these changed? they used to be much cleaner looking numbers...is this a result of the bugfix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how I came up with the other numbers previously, but the new ones are the actual min / max numbers that define the range. I just noticed this as I was testing, since I was also in the weeds on testing the autoscaling

used_unique_IDs: List[int],
overall_line: int,
total_lines: int,
scale_factor: float = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just curious: what's deciding the scale_factor should be a float or not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So scale_factor is an optional input parameter that the user may or may not provide when setting up their CytosimData object. Then, in TrajectoryConverter.scale_agent_data(), which I didn't change in this PR, if scale_factor is None, we generate a scale factor to get the data to look decent in the viewer (so like not be so tiny you can't see anything or so huge that it's out of frame).

@ascibisz ascibisz merged commit 7281356 into main Apr 25, 2025
5 checks passed
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.

Rescaling outputs from Cytosim

4 participants