Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constraints and Landmarks #355

Merged
merged 84 commits into from
Mar 18, 2024
Merged

Constraints and Landmarks #355

merged 84 commits into from
Mar 18, 2024

Conversation

annehaley
Copy link
Collaborator

@annehaley annehaley commented Nov 20, 2023

This PR adds two new features to the "Info" tab: landmark editing and constraint editing. Resolves #358.

shapeworks_editing_landmarks.mp4
shapeworks_constraints.mp4

This was referenced Nov 20, 2023
@annehaley annehaley force-pushed the constraints-and-landmarks branch from 695a3c9 to 810ca32 Compare December 13, 2023 03:16
@annehaley annehaley requested review from manthey and JakeWags January 31, 2024 19:42
…onflicts

(like with landmarks.csv and constraints.json)
…n the layer is enabled (even if no shapes are selected for rendering)
Copy link
Collaborator

@JakeWags JakeWags left a comment

Choose a reason for hiding this comment

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

Approved, with a few questions. None of the questions are critical and otherwise all looks great. No interaction bugs I can find that haven't already been exposed, fixed, or both.

Comment on lines +339 to +340
and locations[0] is not None
and len(locations[0]) == 3
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you clarify why these are needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This if statement is intended to ensure that incoming location data is valid and prevent any server error in the case of invalid format. The list of landmark locations must be a list with at least one element, and each element should be an [x, y, z] coordinate.

constraints_object, created = models.Constraints.objects.get_or_create(
project=project, subject=target_subject, anatomy_type=anatomy_type
)
file_name = 'constraints.json'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason constraints is saved as json and landmarks as csv?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is how they are stored with Studio, and I maintained that design to ensure compatibility.

Comment on lines +407 to +411
path_split = path.split('/')
file_item.download(
Path(folder, *path_split[:-1]),
file_name=path_split[-1],
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

To confirm: this is the file upload changes we've discussed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this change was done with the changes to swcc/swcc/models/file.py to ensure we download files with the expected file names from the project file (instead of the name of the internally-stored file).

This became a problem for projects with a custom file name for constraints or landmarks. After editing the data in Cloud, the file name is saved internally as "constraints.json" or "landmarks.csv". This internal name is fine, but when downloading, we needed to save these files with the expected names. Especially in cases with multiple domains, where more than one constraints file and/or more than one landmarks file can exist. If put in the same location with the default file name, one would overwrite the other.

Comment on lines +512 to +513
for (let p = 0; p < locationData.length; p+=3) {
const location = locationData.slice(p, p+3) as number[]
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the reasoning behind p+=3 and p+3? Can the 3 value ever change or is that a constant for landmarks? I believe this is the 2nd place I've seen that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The value for pointData.getPoints().getData() is actually a flattened array of points, like this: [x1, y1, z1, x2, y2, z2...] In order to iterate over the points in this list, we use a value p which increases by 3 on each iteration and we get a slice of the array from p to p+3. We can do this because we know each point must have three components.

@@ -302,17 +339,18 @@ export default {
renderMetaData.value = newRenderMetaData
}

const debouncedRefreshRender = _.debounce(refreshRender, 300)
const debouncedRefreshRender = _.debounce(refreshRender, 1000)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this need to be extended for a particular reason?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for pointing this out. I had originally done this to reduce redundant update calls before I had implemented the patchwise widget implementation. The render was getting refreshed too often as a user moved around the widgets. Now that we have patchwise updates, I can bring this number back down. I changed it back in 45ec6bc.

@annehaley annehaley merged commit a2b786b into master Mar 18, 2024
4 checks passed
@annehaley annehaley deleted the constraints-and-landmarks branch March 18, 2024 17: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.

Landmarks and Constraints interaction bugs
2 participants