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

Presets from Large Image Configuration file #1248

Merged
merged 25 commits into from
Aug 2, 2023
Merged

Conversation

annehaley
Copy link
Collaborator

@annehaley annehaley commented Jul 26, 2023

This PR allows a user to specify image view presets in their .large_image_config.yaml configuration file at the folder level. Presets specified in the configuration file will be added to the presets available for every image in that folder (as long as the preset is applicable to that image).

We can write more complicated logic for determining whether a preset is applicable to an image, but for now, the presetApplicable function simply evaluates whether the preset's mode and frame values are available for the image.

This PR also adds a section to the documentation explaining how to add presets to the configuration file. This section includes some basic example presets.

@annehaley annehaley requested a review from manthey July 26, 2023 16:39
@manthey
Copy link
Member

manthey commented Jul 28, 2023

This ends up adding all of the presets from the config file to the item's internal values when I create a different preset. We probably want to not add any preset to an item that matches a config preset exactly. Otherwise, for example, I change the name of the config preset and now I have two presets rather than one.

@annehaley
Copy link
Collaborator Author

This ends up adding all of the presets from the config file to the item's internal values when I create a different preset. We probably want to not add any preset to an item that matches a config preset exactly. Otherwise, for example, I change the name of the config preset and now I have two presets rather than one.

You're right, I changed this so that I'm keeping the item presets separate from the folder presets rather than grouping them together in availablePresets. When we save the preset list, 544945a only sends itemPresets now.

@manthey
Copy link
Member

manthey commented Jul 28, 2023

If there is a preset with the same name in the config and the item, we are showing both of them. The item preset should always win.

@annehaley
Copy link
Collaborator Author

If there is a preset with the same name in the config and the item, we are showing both of them. The item preset should always win.

Ok, I added a bit of logic to the presetApplicable function which will filter out any folder presets with the same name as an item preset: d2d4225

@manthey
Copy link
Member

manthey commented Jul 28, 2023

I'm getting an error: Error in mounted hook: "TypeError: styleArray.find is not a function" when I try to select a channel compositing preset.

@annehaley annehaley force-pushed the presets-from-config branch from 86c2d69 to 10d376e Compare July 31, 2023 14:59
@manthey
Copy link
Member

manthey commented Jul 31, 2023

When I switch to a preset that is just a frame or just a channel, I get an error:

Error in callback for watcher "currentFrame": "TypeError: Cannot read properties of undefined (reading 'bands')"
...
vue.js:1906 TypeError: Cannot read properties of undefined (reading 'bands')
    at VueComponent.checkPresetMatch (PresetsMenu.vue:95:1)

It seems like in these instances, checkPresetMatch is being called while this.currentStyle is undefined.

@annehaley
Copy link
Collaborator Author

It seems like in these instances, checkPresetMatch is being called while this.currentStyle is undefined.

Ok, thanks for catching that. I just added an extra if check to that function in 51345c0

@manthey
Copy link
Member

manthey commented Jul 31, 2023

I noticed an issue not related to this branch, but related to presets. I have two presets which only different based on if they have auto-range set on the active channels. Switch to the auto-on preset works fine, switching to the auto-off preset doesn't turn off the auto buttons.

@annehaley
Copy link
Collaborator Author

I noticed an issue not related to this branch, but related to presets. I have two presets which only different based on if they have auto-range set on the active channels. Switch to the auto-on preset works fine, switching to the auto-off preset doesn't turn off the auto buttons.

I added an else statement in 57514a4 that should fix this. Could you try with this change?

@manthey
Copy link
Member

manthey commented Jul 31, 2023

I noticed an issue not related to this branch, but related to presets. I have two presets which only different based on if they have auto-range set on the active channels. Switch to the auto-on preset works fine, switching to the auto-off preset doesn't turn off the auto buttons.

I added an else statement in 57514a4 that should fix this. Could you try with this change?

I'm not seeing any difference.

I'm using WD-76845-097.ome.tif and have the presets listed below.

I also don't see it change properly from preset "CD4RO" and "CD4RO Auto"

[
    {
        "frame": 15,
        "mode": {
            "id": 1,
            "name": "Axis"
        },
        "name": "Aortic"
    },
    {
        "frame": 0,
        "mode": {
            "id": 2,
            "name": "Channel Compositing"
        },
        "name": "Auto Ranged Channels",
        "style": {
            "bands": [
                {
                    "autoRange": 0.2,
                    "framedelta": 0,
                    "palette": "#FF0000"
                },
                {
                    "autoRange": 0.2,
                    "framedelta": 1,
                    "palette": "#00FF00"
                },
                {
                    "autoRange": 0.2,
                    "framedelta": 2,
                    "palette": "#0000FF"
                },
                {
                    "autoRange": 0.2,
                    "framedelta": 4,
                    "palette": "#FF00FF"
                }
            ]
        }
    },
    {
        "frame": 0,
        "mode": {
            "id": 2,
            "name": "Channel Compositing"
        },
        "name": "DNA auto",
        "style": {
            "bands": [
                {
                    "autoRange": 0.2,
                    "framedelta": 0,
                    "palette": "#FF0000"
                },
                {
                    "autoRange": 0.2,
                    "framedelta": 4,
                    "palette": "#FF00FF"
                },
                {
                    "autoRange": 0.2,
                    "framedelta": 8,
                    "palette": "#00FF80"
                },
                {
                    "autoRange": 0.2,
                    "framedelta": 12,
                    "palette": "#FF8080"
                },
                {
                    "autoRange": 0.2,
                    "framedelta": 16,
                    "palette": "#80FFFF"
                },
                {
                    "autoRange": 0.2,
                    "framedelta": 20,
                    "palette": "#00FF40"
                },
                {
                    "autoRange": 0.2,
                    "framedelta": 24,
                    "palette": "#FF4040"
                },
                {
                    "autoRange": 0.2,
                    "framedelta": 28,
                    "palette": "#40FFFF"
                },
                {
                    "autoRange": 0.2,
                    "framedelta": 32,
                    "palette": "#00FFC0"
                }
            ]
        }
    },
    {
        "frame": 0,
        "mode": {
            "id": 2,
            "name": "Channel Compositing"
        },
        "name": "DNA",
        "style": {
            "bands": [
                {
                    "framedelta": 0,
                    "palette": "#FF0000"
                },
                {
                    "framedelta": 4,
                    "palette": "#FF00FF"
                },
                {
                    "framedelta": 8,
                    "palette": "#00FF80"
                },
                {
                    "framedelta": 12,
                    "palette": "#FF8080"
                },
                {
                    "framedelta": 16,
                    "palette": "#80FFFF"
                },
                {
                    "framedelta": 20,
                    "palette": "#00FF40"
                },
                {
                    "framedelta": 24,
                    "palette": "#FF4040"
                },
                {
                    "framedelta": 28,
                    "palette": "#40FFFF"
                },
                {
                    "framedelta": 32,
                    "palette": "#00FFC0"
                }
            ]
        }
    },
    {
        "frame": 11,
        "mode": {
            "id": 1,
            "name": "Axis"
        },
        "name": "CD4RO"
    },
    {
        "frame": 0,
        "mode": {
            "id": 2,
            "name": "Channel Compositing"
        },
        "name": "CD45RO Auto",
        "style": {
            "bands": [
                {
                    "autoRange": 0.2,
                    "framedelta": 11,
                    "palette": "#FFFFFF"
                }
            ]
        }
    }
]

@annehaley annehaley force-pushed the presets-from-config branch from 57514a4 to 75347c1 Compare July 31, 2023 16:48
@annehaley
Copy link
Collaborator Author

Oh I see, there are two places where I needed an else. Amended in 75347c1. Your example case works for me now.

@manthey
Copy link
Member

manthey commented Jul 31, 2023

Oh I see, there are two places where I needed an else. Amended in 75347c1. Your example case works for me now.

Now the auto range doesn't seem to be turning on for me. The autorange controls then don't change when clicked (like they are known to be on) and clicking the global autorange suddenly makes the style update.

@annehaley
Copy link
Collaborator Author

@manthey I made another adjustment in c1bfde7. I tried switching between a preset with no autoRanges, a preset with all channels autoRanged, and a preset with some channels autoRanged. I think it should work smoothly now. Could you give it another try? Thanks for your patience with the many iterations, and thanks for finding the edge cases.

@manthey
Copy link
Member

manthey commented Aug 1, 2023

I still see some issues: (a) after going to a present, if I click the auto-range all button, all the channels turn on (they don't show that they are turned on, but the image changes). (b) sometimes when switching between two presets where one has auto-range on (e.g., my samples with CD4RO and the auto-ranged version), the auto-ranged version isn't shown (the controls looks right, but the image isn't). (c) If a folder-level preset has the same name as a local preset, they are both shown, but you can't select the folder-level preset -- I don't think it should be shown. (d) ideally, we shouldn't include parameters in the style used for fetching images if they aren't used, since that reduces caching (e.g., preset=true, autoRange).

@manthey
Copy link
Member

manthey commented Aug 1, 2023

I still see: On the CD4RO / CD4RO auto, I select the first (not auto) and it shows properly. I select the auto and it briefly shows the auto and then shows the non-auto.

@annehaley annehaley force-pushed the presets-from-config branch from 344e450 to 7775456 Compare August 2, 2023 04:46
Copy link
Member

@manthey manthey left a comment

Choose a reason for hiding this comment

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

This is working in all of my test cases. Though I do see an occasional error in the console (probably unrelated to this specific PR): HistogramEditor.vue:151 Error: <rect> attribute width: A negative value is not valid. ("-9")

@annehaley
Copy link
Collaborator Author

annehaley commented Aug 2, 2023

This is working in all of my test cases. Though I do see an occasional error in the console (probably unrelated to this specific PR): HistogramEditor.vue:151 Error: <rect> attribute width: A negative value is not valid. ("-9")

Ok, thank you for testing. I'm not able to replicate this, though. Perhaps you could make an issue with how to replicate and I can address it in a separate PR?

@annehaley annehaley merged commit de8ee28 into master Aug 2, 2023
@annehaley annehaley deleted the presets-from-config branch August 2, 2023 18:55
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.

2 participants