Skip to content

Conversation

@ascibisz
Copy link
Contributor

@ascibisz ascibisz commented Jun 7, 2023

Problem

It's confusing for users to have to come up with an appropriate scale factor that'll look good in the simularium viewer. Instead, simulariumio should be able to choose an appropriate scale factor based on the spatial positions.
Link to ticket

Solution

Based on manually trying on different scale factors and seeing what positional ranges looked bad, I decided the viewer's ideal range is 5-70, so I made a new constant for that. In each of the converters, I kept track of the ranges of the XYZ coordinates when spatial data is being processed, and then come up with a scale factor accordingly. I then scale radii, positions, subpoints, and box size accordingly. If a scale factor was provided, that will still be used instead of the calculated one, to maintain previous functionality.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires updated or new tests

@ascibisz ascibisz linked an issue Jun 7, 2023 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Jun 7, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (983c99b) 92.56% compared to head (fa8ab17) 92.74%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #148      +/-   ##
==========================================
+ Coverage   92.56%   92.74%   +0.18%     
==========================================
  Files         101      101              
  Lines        4546     4673     +127     
==========================================
+ Hits         4208     4334     +126     
- Misses        338      339       +1     
Files Coverage Δ
simulariumio/constants.py 100.00% <100.00%> (ø)
simulariumio/cytosim/cytosim_converter.py 97.12% <100.00%> (+0.04%) ⬆️
simulariumio/data_objects/meta_data.py 97.43% <100.00%> (ø)
simulariumio/mcell/mcell_converter.py 99.45% <100.00%> (+<0.01%) ⬆️
simulariumio/md/md_converter.py 96.11% <100.00%> (+0.03%) ⬆️
simulariumio/medyan/medyan_converter.py 98.02% <100.00%> (+0.01%) ⬆️
simulariumio/physicell/physicell_converter.py 97.81% <100.00%> (+0.09%) ⬆️
simulariumio/readdy/readdy_converter.py 100.00% <100.00%> (ø)
simulariumio/smoldyn/smoldyn_converter.py 100.00% <100.00%> (ø)
simulariumio/springsalad/springsalad_converter.py 99.00% <100.00%> (+0.02%) ⬆️
... and 10 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ascibisz ascibisz marked this pull request as ready for review June 8, 2023 21:06
@ascibisz ascibisz requested a review from a team as a code owner June 8, 2023 21:06
@ascibisz ascibisz requested review from blairlyons, frasercl, interim17 and toloudis and removed request for a team June 8, 2023 21:06
@ascibisz ascibisz requested a review from meganrm July 18, 2023 17:12
self.progress_callback(percent_complete)
self.last_report_time = current_time

def _filter_agent_data(data: np.array, n_agents: np.array):

This comment was marked as resolved.

This comment was marked as resolved.

else:
scale_factor = input_data.meta_data.scale_factor
for index in range(dimensions.total_steps):
# do not scale radii for subcells

Choose a reason for hiding this comment

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

why don't we want to scale subcell radii?

Copy link
Contributor Author

@ascibisz ascibisz Oct 3, 2023

Choose a reason for hiding this comment

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

oh goodness I don't remember, I think this came out of when I manually checked that all of the scaled results looked like what I would expect them to be. I'll double check, and if there is a good reason I'll make the comment more descriptive

  • figure out why "do not scale radii for subcells"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok so I lied, I came across this because this matches the previous functionality so if i just did radii *= scale_factor for all radii, a previous test would fail. That's because "subcells" are represented as sphere groups, and so previously if someone had provided a scale factor, we wouldn't apply that to the agent of the sphere group's radii. I imagine it doesn't actually matter which way we do it, because I don't think the sphere group's agent radii matters? since the radii for each of the spheres of the sphere group is in the subpoints?

assert box_size == expected_box_size


auto_scale_factor = VIEWER_DIMENSION_RANGE.MIN / (0.400052 + 0.001)

Choose a reason for hiding this comment

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

where do these numbers come from?

Copy link
Contributor Author

@ascibisz ascibisz Oct 3, 2023

Choose a reason for hiding this comment

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

they're pulled from the test data, that represents the max range of the positional data, which determines the scale factor. I can pull that out and call it the range, so it's a little more clear?

  • make range variable

@ascibisz ascibisz force-pushed the feature/auto-handle-scale-factor branch from 6b3e497 to f2cc98a Compare October 3, 2023 23:53
@ascibisz ascibisz merged commit 8abae38 into main Oct 5, 2023
@ascibisz ascibisz deleted the feature/auto-handle-scale-factor branch October 5, 2023 16:15
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.

Automatically handle scale factor

6 participants