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

Add combination compartments #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ma3ke
Copy link
Collaborator

@ma3ke ma3ke commented Jan 9, 2025

Combine different compartments from the input configuration.

For instance, this would allow us to combine an analytical sphere compartment that is created when the configuration is loaded with a mask that is loaded from an npz file.

I think that this does warrant a better syntax, as I'm currently relying on deserialization of the json to give the rudimentary syntax tree.

Example input file

Here is the space section of an input file that uses this ability.

	"space": {
		"size": [153.0, 142.0, 148.0],
		"resolution": 0.5,
		"compartments": [
			{
				"id": "droplet",
				"analytical": {
					"shape": "spherical"
				}
			},
			{
				"id": "outside_virion",
				"voxels": {
					"path": "masks/outside.npz"
				}
			},
			{
				"id": "outside",
				"combination": [{ "or": [ 
					{ "id": "outside_virion" }, 
					{ "id": "droplet" } 
				]}]
			},
			{
				"id": "inside",
				"voxels": {
					"path": "masks/inside.npz"
				}
			},
			{
				"id": "m_proteins",
				"voxels": {
					"path": "masks/m_proteins.npz"
				}
			}
		]
	}

Note that I think that I may currently have the or and and directives flipped around, because this expression for the outside combination compartment seems rather silly.

That is to be addressed before this PR merges.

@ma3ke
Copy link
Collaborator Author

ma3ke commented Jan 9, 2025

The example config above is part of a setup to create the following example system.

This is not final, but just placing it here to help communicating the change.

image

@@ -26,6 +26,14 @@ impl std::fmt::Display for Shape {
}
}

#[derive(Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum CombinationExpression {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think that we want a proper and and xor combinator in here as well.

distance_masks: Default::default(),
};
compartments.push(baked);
}
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 code duplication in the above section screams for refactoring.

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