SciKit-Surgery / scikit-surgeryvtk

image fusion or overlay, for augmented reality apps, using VTK and OpenCV for a calibrated overlay.
https://scikit-surgeryvtk.readthedocs.io/en/latest/
Other
21 stars 5 forks source link

Define colours to use for each part of vtk model #4

Closed thompson318 closed 4 years ago

thompson318 commented 4 years ago

In GitLab by @ThomasDowrick on Nov 14, 2018, 11:14

@StephenThompson @MattClarkson - in SmartLiver, how are the colours for each part of the liver model defined? Is it read in from a file?

thompson318 commented 4 years ago

In GitLab by @MattClarkson on Nov 14, 2018, 11:20

From memory, we load the models into NiftyIGI, set the colour as a property, but then you can save the model with the colour intact, so that when we toddle off to the Royal Free, it loads the model, and sets the property.

So, its manual. The nearest "python" equivalent might be something like having a .yaml file or some such that links a filename with a colour, so as we load the data, we load the colour and set it.

thompson318 commented 4 years ago

In GitLab by @StephenThompson on Nov 14, 2018, 18:45

The colours and any other visualisation information (eg opacity) are saved in a mitk scene file. This is a zip archive that contains (in our case) a set of vtk poly data plus text files defining the propeties for each polydata. There is a plugin in NiftySLS called igipreoperation that sets colours as below, based on the node names.

int n = 8; std::string namelist[] = {"portal vein", "liver", "liver tumors", "liver cysts", "hepatic veins", "gallbladder", "biliary tract", "arteries"}; float colorlist[][3] = { {255/255.0, 85/255.0, 255/255.0}, {255/255.0, 170/255.0, 127/255.0}, {255/255.0, 255/255.0, 0}, {0, 0, 255/255.0}, {170/255.0, 170/255.0, 255/255.0}, {85/255.0, 170/255.0, 0}, {85/255.0, 0, 0}, {255/255.0, 0, 0} };

thompson318 commented 4 years ago

In GitLab by @ThomasDowrick on Nov 15, 2018, 07:38

Thanks. For the time being I'm reusing the ardavin code, which just takes a path to a folder which contains .vtk/.ply/.stl models to render onto the scene, and assigns a set of default colours. There is a placeholder function that needs to be completed for assigning specific colours to specific models (read from a file or whatever).

Shall we stick with what I have for the moment, or is there any advantage to using the MITK scene?

thompson318 commented 4 years ago

In GitLab by @MattClarkson on Nov 15, 2018, 07:56

Could do either both, just MITK scene or just yaml (or similar)

I was imagining that any app would have a main function. One command line param would pass in a parameter describing a yaml file. The yaml data could be loaded into a class, for example ConfigurationManager. That said, I have not yet tried loading yaml, I do not know whether you can just hold it inside a very handy datastructure such that you dont need a wrapper class. But if we continue on with this example, the ConfigurationManager might have simple getters to retrieve values, or search for values. But the main point is that the ConfigurationManager is passed as a constructor argument to each thing that needs configuring. So you could have a ScreenManager, ModelManager, RegistrationManager etc (whatever services you like). So, each Manager/Service would know what parameters should be in the Configuration. So, something that manages VTK models would know to look for a certain section of the YAML file, retrieve a list of file names, and for each file retrieve initial settings of colour and opacity.

Then if you extend the concept. You could have an interface ConfigurationManager which is implemented be either a yaml reader, or MITK reader, but the yaml approach is simpler, easier to read, more extensible etc.

thompson318 commented 4 years ago

In GitLab by @MattClarkson on Nov 15, 2018, 07:58

And to add that such a ConfigurationManager would be one of those candidates that lives in a core module, or scikit-surgery itself, if indeed we assume that is the core.

thompson318 commented 4 years ago

In GitLab by @StephenThompson on Nov 15, 2018, 11:53

I wouldn't use the MITK scene. Along the lines of what Matt says above, my tracking library will also need to read config files, so it would make sense if that functionality is handled in similar ways by different bits of SNAPPY.

thompson318 commented 4 years ago

In GitLab by @StephenThompson on Nov 15, 2018, 13:40

The simplest way might be to specify such things in a config.py file.

thompson318 commented 4 years ago

In GitLab by @MattClarkson on Dec 13, 2018, 09:18

OK, so config file stuff is done, on master in scikit-surgerycore. Also, as part of Issue #11 in this project, ive got Tom's basic directory loader working, so we have 2 options for this.

So, closing this ticket.

thompson318 commented 4 years ago

In GitLab by @MattClarkson on Dec 13, 2018, 09:18

closed