ComputationalBiomechanicsLab / opensim-creator

A UI for building OpenSim models
https://opensimcreator.com
Apache License 2.0
154 stars 18 forks source link

Add an ISB Frame Definition Workflow UI (top-level issue) #490

Closed adamkewley closed 1 year ago

adamkewley commented 1 year ago

This issue was broken out from #467 , which was originally an all encompassing issue for building an OpenSim model warping UI.

Issue Background

It turned out that creating a warping UI will require a lot of auxiliary tooling+code to do robustly, so that UI idea was broken into three separate pieces that were deemed to be handy in isolation:

Work List

High-Level Work List

Detailed Work List

Feature Specification List

Note: this was written pre-development: see this are more of a wishlist

Example Frame Definition Cases

Knee (Grood, 1983)

Tibia (Frame, Body-Fixed Axis (e3), and Reference Axis (e3r)

e3 is defined as passing midway between two intercondylar eminences proximally and through the center of the ankle distally... etc.

Rough dependency diagram (gist):

graphviz(4)

Femur (Frame, Body-Fixed Axis (e1) and Reference Axis (e1r)

In the femur, the body fixed axis is chosen so that rotations about it correspond to the clinical motion of flexion-extension.

Rough dependency diagram (gist)

graphviz(5)

Knee Joint (excl. translations)

Rough dependency diagram (gist)

graphviz(7)

Academic References

Software References

JuliaVanBeesel commented 1 year ago

This is the link to Peter Bishop's paper "How to build a dinosaur": https://www.cambridge.org/core/journals/paleobiology/article/how-to-build-a-dinosaur-musculoskeletal-modeling-and-simulation-of-locomotor-biomechanics-in-extinct-animals/CE84BB804E697DF47C0A3A367CC16B22 And here is where you can access the supplementary material, including the open access matlab code, which also includes the primitive shape fitting algorithm: https://datadryad.org/stash/dataset/doi:10.5061/dryad.73n5tb2v9

adamkewley commented 1 year ago

Based on a couple of discussions, it looks like the UI needs to support (minimum viable product):

adamkewley commented 1 year ago

e.g. the software would ultimately be defining data that would be serialized like this:

[landmarks]

    [landmarks.l1]
    type = "basic"
    location = [20.0, 0.0, 3.7]

    [landmarks.l2]
    type = "basic"
    location = [20.0, 0.0, 3.7]

    [landmarks.middle]
    type = "midpoint"
    first_landmark = "l1"
    second_landmark = "l2"
    # cached_location = [30.0, 20.0, 10.0]  # TODO: caching for error recovery

    [landmarks.external_l3]
    type = "external"
    external_file = "some_other_landmark_file"
    landmark_name_in_external_file = "l3"
    # cached_location = [30.0, 20.0, 10.0]  # TODO: caching for error recovery

    [landmarks.external_l4]
    type = "external"
    external_file = "some_other_landmark_file"
    landmark_name_in_external_file = "l4"
    # cached_location = [30.0, 20.0, 10.0]  # TODO: caching for error recovery

    # extensibility example: not MVP
    #
    # e.g. would show a sphere in the UI that the user can use to eyeball locations
    #      but it would ultimately resolve to the sphere's origin for frame
    #      calculations
    [landmarks.sphere]
    type = "sphere"
    origin = [0.5, 5.0, 7.0]
    radius = 5.0
    # cached_location = [30.0, 20.0, 10.0]  # TODO: caching for error recovery

[frames]

    [frames.f1]
    type = "grood_suntay"
    e1_start = "external_l3"
    e1_end = "external_l4"
    e3_start = "l1"
    e3_end = "l2"
    # e2 is the common perpendicular "floating" axis (F): F = normalize(cross(e3, e1))
adamkewley commented 1 year ago

The core original paper:

E.S. Grood, A Joint Coordinate System for the Clinical Description of Three-Dimensional Motions: Application to the Knee, 1983

Is what most of the other ISB standards are effectively based on. The original spec appears to be "looser" than its concrete usage in the ISB standards, though, because it defines (e.g.) the two edges ("fixed" axes) potentially on different bodies in different coordinate systems, and it seems to rigidly define angles? Probably needs to be studied before going through each ISB recommendation.

Note: up to p138

adamkewley commented 1 year ago

The commit onslaught above effectively:

adamkewley commented 1 year ago

@JuliaVanBeesel / @pepbos / @aseth1 initial prototyping of the frame definition UI is underway and is being continuously deployed to the main branch as a custom tab (press + in OSC's tab bar experimental, OpenSim/FrameDefinition).

The current in-development version needs some work (more actions, easier interaction when moving things around) but the current idea is:

Demo video:

https://github.com/ComputationalBiomechanicsLab/opensim-creator/assets/4730570/f0849ae2-5895-479a-be3a-8e23214f836e

(green spheres: "landmarks", teal spheres: "midpoints", "green plane": cross product plane - all user defined points are moveable and all derived quantities (edges, cross products, midpoints, etc.) automatically recompute while editing happens.

In-development builds are available on the actions page under the main branch:

adamkewley commented 1 year ago

@JuliaVanBeesel / @aseth1 this top-level feature-push issue will now be closed (it will remain here, online, but further work will be done under different issues).

I have updated the original issue post with what parts of the original feature idea have been implemented/DROPPED/LIMITED so that it's clear how development proceeded (the ~50 code commits are harder to read).

The reason some things are DROPPED/LIMITED may be due to time constraints. The delivery date of this feature was scheduled for approximately 2 weeks before TGCS/ISB, so that the overall project, which includes:

Can be done in the remaining 1-2 weeks.

Rough project schedule here: https://github.com/orgs/ComputationalBiomechanicsLab/projects/9/views/1


I'll repost any important (but, unreleaseable within the desired timeframe) changes/fixes/steps etc. as separate issues. Those issues will then be prioritized according to the general OSC project schedule etc.

adamkewley commented 1 year ago

Individual nice-to-haves were broken out into new issues that will be assigned as part of project development - it might be that a few of the easier ones make this window.