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

color legend #31

Open
meghalithic opened this issue Jul 25, 2022 · 13 comments
Open

color legend #31

meghalithic opened this issue Jul 25, 2022 · 13 comments
Assignees
Labels
next version Enhancements for the next version

Comments

@meghalithic
Copy link
Contributor

Create a look up (number) for each segmentation so that it is scalable, as suggested by @muratmaga.

See example for Slicer.

Or @johnbradley suggested making a configuration file.

@johnbradley
Copy link
Contributor

The colors seem to come from here:
https://github.com/hdr-bgnn/BGNN-trait-segmentation/blob/5dc0ab34201ac2b715e784849acdb2a38e962da5/Segment_mini/scripts/helper_mini.py#L12-L31

    colors[0] = np.array([0, 0, 0])        # Background      0
    colors[1] = np.array([254, 0, 0])      # Dorsal Fin      1
    colors[2] = np.array([0, 254, 0])      # Adipos Fin      2
    colors[3] = np.array([0, 0, 254])      # Caudal Fin      3
    colors[4] = np.array([254, 254, 0])    # Anal Fin        4
    colors[5] = np.array([0, 254, 254])    # Pelvic Fin      5
    colors[6] = np.array([254, 0, 254])    # Pectoral Fin    6
    colors[7] = np.array([254, 254, 254])  # Head            7
    colors[8] = np.array([0, 254, 102])    # Eye             8
    colors[9] = np.array([254, 102, 102])  # Caudal Fin Ray  9
    colors[10] = np.array([254, 102, 204]) # Alt Fin Ray     10
    colors[11] = np.array([254, 204, 102]) # Alt Fin Spine   11
    colors[12] = np.array([0, 124, 124])   # Trunk           12

@thibaulttabarin
Copy link
Member

Yes, I confirmed that the color come from there!

@johnbradley
Copy link
Contributor

@megbalk My suggestion was related to the input CSV file columns: hdr-bgnn/BGNN_Core_Workflow#24 (comment)

@thibaulttabarin
Copy link
Member

yes sorry, I created some confusion with my comment (I mixed up conversation), but in the same way the lookup table trait/color could be stored in a config file.

@johnbradley
Copy link
Contributor

yes sorry, I created some confusion with my comment (I mixed up conversation), but in the same way the lookup table trait/color could be stored in a config file.

So the idea is we would let users customize the colors for the various segments? "I want a blue dorsal fin."

@thibaulttabarin
Copy link
Member

this is where is hard coded in the class used in the trait.

self.trait_color_dict={'background': [0, 0, 0],'dorsal_fin': [254, 0, 0],'adipos_fin': [0, 254, 0],
'caudal_fin': [0, 0, 254],'anal_fin': [254, 254, 0],'pelvic_fin': [0, 254, 254],
'pectoral_fin': [254, 0, 254],'head': [254, 254, 254],'eye': [0, 254, 102],
'caudal_fin_ray': [254, 102, 102],'alt_fin_ray': [254, 102, 204],
'trunk': [0, 124, 124]}

@thibaulttabarin
Copy link
Member

yes sorry, I created some confusion with my comment (I mixed up conversation), but in the same way the lookup table trait/color could be stored in a config file.

So the idea is we would let users customize the colors for the various segments? "I want a blue dorsal fin."

Ok I see but I feel that is to much front end, make things look good or customize for user?

@johnbradley
Copy link
Contributor

johnbradley commented Jul 25, 2022

@muratmaga could you elaborate on the use case for this change? Thanks.

@thibaulttabarin
Copy link
Member

That is the link Murat post during the meeting
https://slicer.readthedocs.io/en/latest/user_guide/modules/terminologies.html

@hlapp
Copy link
Member

hlapp commented Jul 25, 2022

That is the link Murat post during the meeting

@thibaulttabarin Meghan included this already in her OG post above.

@hlapp
Copy link
Member

hlapp commented Jul 25, 2022

I think the point here is to have these kinds of static (two or multi-dimensional) tables be in a place where they aren't buried deep in the code (such as being hard-coded in some object's constructor method as is the case here), and where if desired (for optics or other reasons) or necessary (segmenting more or differently named traits, for example) they can be modified by a project or user without fundamentally altering the codebase.

Whether that's a file in non-Python syntax, or a Python data structure defined in its own file or as part of a file that defined multiple such static data structures, doesn't matter, it's either way conceptually a configuration file.

@muratmaga
Copy link

muratmaga commented Jul 25, 2022

So there are multiple levels of things going in here. First, and foremost I would like to avoid this mistake done by Nvidia developers, which was hard coding labels in a ML Segmentation framework: https://github.com/Project-MONAI/MONAILabel/blob/52b8758ce70fbcee9fc1735e18ac8f784f0ba200/sample-apps/radiology/lib/configs/deepedit.py#L36-L55

At the minimum, this should be a user configurable setting, so that people can use whatever label they need to use.

Secondly, the selection of labels and indices is completely free when you are working with a single dataset. But still, it is better to pull terms from an ontology, which probably also a has a unique identified attached to it. That way, you can start making your own lookup tables with indices, and colors.

I provided the Terminology module of Slicer as a related concept. They use a complex JSON schema, e.g., this uses the terms used in DICOM standard , but it can be simplified to match your needs.

My point is that this is not an easy thing to do, and there can be multiple solutions with different complexities. I just wanted to make you aware of it early on.

@meghalithic meghalithic transferred this issue from hdr-bgnn/BGNN_Core_Workflow Jul 26, 2022
@meghalithic meghalithic added the enhancement New feature or request label Jul 26, 2022
@meghalithic
Copy link
Contributor Author

Moved this from BGNN_Snakemake to Morphology_Analysis. I also added the label "enhancement" as this will be a great feature for version 2.0.0, after we have a working version for the minnowTraits project (version 1.0.0).

@meghalithic meghalithic added next version Enhancements for the next version and removed enhancement New feature or request labels Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next version Enhancements for the next version
Projects
None yet
Development

No branches or pull requests

5 participants