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 layer_name to kwargs of from_images #1054

Merged
merged 4 commits into from
Apr 29, 2024
Merged

Conversation

markbader
Copy link
Contributor

@markbader markbader commented Apr 24, 2024

Description:

  • This PR adds the argument layer_name to the Dataset.from_images method. If from_images generates a Dataset with one layer, it uses the given layer_name as name for this layer. In case multiple layers are created, the given layer name is a shared prefix of all layers.

Issues:

Todos:

Make sure to delete unnecessary points or to check all before merging:

  • Updated Changelog
  • Added / Updated Tests

@markbader markbader requested a review from normanrz April 24, 2024 11:15
@markbader markbader self-assigned this Apr 24, 2024
Copy link
Member

@normanrz normanrz left a comment

Choose a reason for hiding this comment

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

Can you comment how the layer names for multiple layers are constructed? I don't think I understand that yet. Would it make sense to strip the current prefix (ie. file name based) in that case?

webknossos/webknossos/dataset/dataset.py Outdated Show resolved Hide resolved
Co-authored-by: Norman Rzepka <code@normanrz.com>
@markbader
Copy link
Contributor Author

It depends, we currently use the Callable map_filepath_to_layername to generate the layer names. It can either be used by selecting one of the predefined methods defined in ConversionLayerMapping or by delivering a custom Callable to convert the file paths to layer names.
The default behavior is INSPECT_SINGLE_FILE, which distinguishes two different cases. If the first file that is found is 2D ENFORCE_LAYER_PER_FOLDER is used, otherwise ENFORCE_LAYER_PER_FILE will be applied.
ENFORCE_LAYER_PER_FOLDER uses the folder name, where the image file is stored in.
ENFORCE_LAYER_PER_FILE uses the filename.
I think as there are many options for functions that can convert the file path to a layer name, it would not be easy to strip a part of it, and still get unique layer names. Either we decide, that another behavior should be used when the layer_name is set, e.g., just numbering the layers after the common prefix, or we stay with the full filename or folder name based approach. But I would prefer the filename approach because it makes the layers easier to distinguish.

Copy link
Member

@normanrz normanrz left a comment

Choose a reason for hiding this comment

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

Thanks for explaining.

@markbader markbader merged commit 7bc9773 into master Apr 29, 2024
19 checks passed
@markbader markbader deleted the layer_name_in_from_images branch April 29, 2024 11:27
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.

Add layer_name to Dataset.from_images
2 participants