https://public.kitware.com/Wiki/api.php?action=feedcontributions&user=Lantiga&feedformat=atomKitwarePublic - User contributions [en]2022-12-06T04:14:43ZUser contributionsMediaWiki 1.37.1https://public.kitware.com/Wiki/index.php?title=Refactoring_Level-Set_framework_-_V4&diff=30707Refactoring Level-Set framework - V42010-09-23T09:00:43Z<p>Lantiga: /* Thoughts on dependencies among terms */</p>
<hr />
<div>This page outlines the proposed changes to the current Level-Set framework. A number of these changes will break backwards compatibility.<br />
<br />
== Authors ==<br />
<br />
The proposed changes for the Level-Set framework are being proposed by the [https://wiki.med.harvard.edu/SysBio/Megason/ Megason-Lab], Systems Biology Department, Harvard Medical School.<br />
<br />
Questions and comments regarding these changes should be sent to<br />
* Arnaud Gelas (arnaud_gelas -at- hms.harvard.edu)<br />
* Sean Megason (sean_megason -at- hms.harvard.edu) <br />
<br />
Other team members include:<br />
* Kishore Mosaliganti (kishore_mosaliganti -at- hms.harvard.edu)<br />
* Nicolas Rannou (nicolas_rannou -at- hms.harvard.edu)<br />
<br />
== Tcons ==<br />
<br />
* 29 July. Attendees: Karthik Krishnan (Kitware), Lucas Antiga (Orobix), Kishore Mosaliganti (Harvard), Arnaud Gelas (Harvard)<br />
* 11 August. Attendees: Luis Ibanez (Kitware), Ivo Sbalzarini (ETH), Kishore Mosaliganti (Harvard), Arnaud Gelas (Harvard)<br />
* 18 August. Attendees: Gregory Paul (ETH), Kishore Mosaliganti (Harvard), Arnaud Gelas (Harvard)<br />
* 1 September. Attendees: Olivier Bernard (Creatis), Joel Schaerer (Creatis), Kishore Mosaliganti (Harvard), Arnaud Gelas (Harvard)<br />
* [[ITK_Release_4/Refactoring Level Set Framework/Tcon 2010-09-09|Tcon 2010-09-10]]<br />
<br />
== Ideas ==<br />
<br />
=== Term ===<br />
==== Term class ====<br />
<br />
Represent on term of the PDE. <br />
First example of implementation (not complete) located at http://github.com/lantiga/ModularLevelSets.<br />
<br />
* One weight (scalar)<br />
* One Level Set Function<br />
* virtual GetCFLContribution() = 0;<br />
* virtual Value() = 0;<br />
* virtual bool IsStreamable() = 0<br />
<br />
==== Term Container class ====<br />
<br />
* std::map< id, Term > to be able to dynamically add/remove terms at any time during the evolution<br />
* Virtual Value() = 0;<br />
* bool IsStreamable(); // iterate on all term elements as long as there is streamable element.<br />
<br />
==== Term Sum Container ====<br />
<br />
* Inherit form Term Container<br />
* Implement Value as sum of all elements from the container<br />
<br />
==== Term Product Container ====<br />
(Don't know yet the application, but it is theoretically possible to implement it as noticed by Joel Schaerer).<br />
<br />
* Inherit form Term Container<br />
* Implement Value as product of all elements from the container<br />
<br />
=== LevelSetFunctionBase ===<br />
The level set function representation could be discrete, parametric (continuous)<br />
<br />
* Virtual Value() = 0;<br />
* Virtual Grad() = 0;<br />
* Virtual Hessian() = 0;<br />
* Virtual bool IsStreamable() = 0;<br />
<br />
=== LocalStructure ===<br />
This structure will be used to pass information add each step for a single location x<br />
<br />
* Location x<br />
* std::pair< bool, xxx > value (bool encode if its characteristics has already been computed)<br />
* std::pair< bool, xxx > grad<br />
* Etcâ€¦<br />
<br />
=== Reinitialization Filter ===<br />
<br />
* Input: one level set function<br />
* Output: one level set function<br />
* Virtual void GenerateData() = 0; // processing<br />
<br />
=== Stopping criterion ===<br />
<br />
* Functor?<br />
* Inputs: Phi^{n}, Phi^{n-1}, Number of iterations<br />
* Check for additional values that can be passed (to avoid as much as possible explosion of computational cost!!!)<br />
<br />
=== SamplingDomain ===<br />
<br />
* Represents the domain where the level set PDE is sampled, and thus used to solve the PDE equation.<br />
* Iterator Begin();<br />
* Iterator End();<br />
* Iterator Iterator::operator ++ ( -- ? )<br />
<br />
<br />
=== Thoughts on dependencies among terms ===<br />
<br />
In order to make term implementation modular and reusable, terms should include a way to be reusable by each other.<br />
For instance, a curvature term should depend on a "first derivatives" and a "hessian" term, and only implement the formula for curvature. In fact, how the first and second derivatives are implemented should be kept modular, so that one can adopt, for instance, a finite differences or a Gaussian convolution approach to compute them, and the curvature code could stay the same.<br />
<br />
I see two ways of achieving this:<br />
1. reuse terms in other terms by referring to their (expected) name in the term container (global workspace approach)<br />
2. specify dependencies by instantiating them and storing them in a dependency container in each term class (dependency approach, adopted in [[http://github.com/lantiga/ModularLevelSets ModularLevelSets]], see for instance the itk::LevelSetCurvatureTerm and how it depends on two other terms itk::LevelSetDerivativesTerm and itk::LevelSetHessianTerm).<br />
<br />
I now recall the process that led me to having dependencies in [[http://github.com/lantiga/ModularLevelSets ModularLevelSets]] and not a global workspace.<br />
<br />
If you have a global workspace, then you may end up having a couple of potential maintenance issues:<br />
<br />
1. all terms have to know what names are used for each quantities and don't have a chance to know if something has changed in other classes in the container. Say Term1 computes "Hessian" and puts it in the workspace. Term2 needs Hessian and grabs it from the workspace. If Term1 changes the name of the term to FiniteDifferenceHessian, Term2 will still call it Hessian (unless we require that the user checks that dependencies are built with correct names). There would really be no way of knowing if things are ok or not until we assemble all the terms and run them.<br />
<br />
2. you'd have a hard time detecting inconsistencies compile time: say Term1 computes Hessian using finite differences, while Term2 computes Hessian using convolution, but they both call it Hessian. Term1 puts the "Hessian" in the workspace, and Term2 finds a "Hessian" in the workspace and uses it, but it's not the Hessian Term2 needs.<br />
<br />
Of course careful development will avoid all this sort of issues, but a newcomer would have to know about any quantities the other terms generate.<br />
<br />
On the other hand there are a few advantages using dependencies:<br />
<br />
1. if Term2 depends on the Hessian term, there's a way to have term compatibility checked at compile-time (see term constructor in [[http://github.com/lantiga/ModularLevelSets ModularLevelSets]], in particular itk::LevelSetCurvatureTerm). <br />
<br />
2. since Hessian is a term, i.e. a class, there's no chance of creating conflicting classes with the same name. If Term1 depends on Hessian computed using finite differences, the developer of Term2 will be forced to implement a ConvolutionHessian term. In other words, the dependency of the two terms will be local to the terms, no chance of collisions in the global workspace, irrespective on how the terms are assembled.<br />
<br />
Dependencies have to analyzed only once, when it's time for level sets to run. You can decide the order in which to evaluate terms and cache the results of a term if that term is a dependency of more than one term, so there's really no extra cost compared to the global workspace option, terms are computed the same number of times.<br />
<br />
This is just my view on the topic, but in general I think this is a really important issue, as we expect that terms will grow in number.<br />
<br />
Luca</div>Lantigahttps://public.kitware.com/Wiki/index.php?title=Refactoring_Level-Set_framework_-_V4&diff=30706Refactoring Level-Set framework - V42010-09-23T09:00:14Z<p>Lantiga: </p>
<hr />
<div>This page outlines the proposed changes to the current Level-Set framework. A number of these changes will break backwards compatibility.<br />
<br />
== Authors ==<br />
<br />
The proposed changes for the Level-Set framework are being proposed by the [https://wiki.med.harvard.edu/SysBio/Megason/ Megason-Lab], Systems Biology Department, Harvard Medical School.<br />
<br />
Questions and comments regarding these changes should be sent to<br />
* Arnaud Gelas (arnaud_gelas -at- hms.harvard.edu)<br />
* Sean Megason (sean_megason -at- hms.harvard.edu) <br />
<br />
Other team members include:<br />
* Kishore Mosaliganti (kishore_mosaliganti -at- hms.harvard.edu)<br />
* Nicolas Rannou (nicolas_rannou -at- hms.harvard.edu)<br />
<br />
== Tcons ==<br />
<br />
* 29 July. Attendees: Karthik Krishnan (Kitware), Lucas Antiga (Orobix), Kishore Mosaliganti (Harvard), Arnaud Gelas (Harvard)<br />
* 11 August. Attendees: Luis Ibanez (Kitware), Ivo Sbalzarini (ETH), Kishore Mosaliganti (Harvard), Arnaud Gelas (Harvard)<br />
* 18 August. Attendees: Gregory Paul (ETH), Kishore Mosaliganti (Harvard), Arnaud Gelas (Harvard)<br />
* 1 September. Attendees: Olivier Bernard (Creatis), Joel Schaerer (Creatis), Kishore Mosaliganti (Harvard), Arnaud Gelas (Harvard)<br />
* [[ITK_Release_4/Refactoring Level Set Framework/Tcon 2010-09-09|Tcon 2010-09-10]]<br />
<br />
== Ideas ==<br />
<br />
=== Term ===<br />
==== Term class ====<br />
<br />
Represent on term of the PDE. <br />
First example of implementation (not complete) located at http://github.com/lantiga/ModularLevelSets.<br />
<br />
* One weight (scalar)<br />
* One Level Set Function<br />
* virtual GetCFLContribution() = 0;<br />
* virtual Value() = 0;<br />
* virtual bool IsStreamable() = 0<br />
<br />
==== Term Container class ====<br />
<br />
* std::map< id, Term > to be able to dynamically add/remove terms at any time during the evolution<br />
* Virtual Value() = 0;<br />
* bool IsStreamable(); // iterate on all term elements as long as there is streamable element.<br />
<br />
==== Term Sum Container ====<br />
<br />
* Inherit form Term Container<br />
* Implement Value as sum of all elements from the container<br />
<br />
==== Term Product Container ====<br />
(Don't know yet the application, but it is theoretically possible to implement it as noticed by Joel Schaerer).<br />
<br />
* Inherit form Term Container<br />
* Implement Value as product of all elements from the container<br />
<br />
=== LevelSetFunctionBase ===<br />
The level set function representation could be discrete, parametric (continuous)<br />
<br />
* Virtual Value() = 0;<br />
* Virtual Grad() = 0;<br />
* Virtual Hessian() = 0;<br />
* Virtual bool IsStreamable() = 0;<br />
<br />
=== LocalStructure ===<br />
This structure will be used to pass information add each step for a single location x<br />
<br />
* Location x<br />
* std::pair< bool, xxx > value (bool encode if its characteristics has already been computed)<br />
* std::pair< bool, xxx > grad<br />
* Etcâ€¦<br />
<br />
=== Reinitialization Filter ===<br />
<br />
* Input: one level set function<br />
* Output: one level set function<br />
* Virtual void GenerateData() = 0; // processing<br />
<br />
=== Stopping criterion ===<br />
<br />
* Functor?<br />
* Inputs: Phi^{n}, Phi^{n-1}, Number of iterations<br />
* Check for additional values that can be passed (to avoid as much as possible explosion of computational cost!!!)<br />
<br />
=== SamplingDomain ===<br />
<br />
* Represents the domain where the level set PDE is sampled, and thus used to solve the PDE equation.<br />
* Iterator Begin();<br />
* Iterator End();<br />
* Iterator Iterator::operator ++ ( -- ? )<br />
<br />
<br />
=== Thoughts on dependencies among terms ===<br />
<br />
In order to make term implementation modular and reusable, terms should include a way to be reusable by each other.<br />
For instance, a curvature term should depend on a "first derivatives" and a "hessian" term, and only implement the formula for curvature. In fact, how the first and second derivatives are implemented should be kept modular, so that one can adopt, for instance, a finite differences or a Gaussian convolution approach to compute them, and the curvature code could stay the same.<br />
<br />
I see two ways of achieving this:<br />
1. reuse terms in other terms by referring to their (expected) name in the term container (global workspace approach)<br />
2. specify dependencies by instantiating them and storing them in a dependency container in each term class (dependency approach, adopted in [[http://github.com/lantiga/ModularLevelSets ModularLevelSets]], see for instance the itk::LevelSetCurvatureTerm and how it depends on two other terms itk::LevelSetDerivativesTerm and itk::LevelSetHessianTerm).<br />
<br />
I now recall the process that led me to having dependencies in [[http://github.com/lantiga/ModularLevelSets ModularLevelSets]] and not a global workspace.<br />
<br />
If you have a global workspace, then you may end up having a couple of potential maintenance issues:<br />
<br />
1. all terms have to know what names are used for each quantities and don't have a chance to know if something has changed in other classes in the container. Say Term1 computes "Hessian" and puts it in the workspace. Term2 needs Hessian and grabs it from the workspace. If Term1 changes the name of the term to FiniteDifferenceHessian, Term2 will still call it Hessian (unless we require that the user checks that dependencies are built with correct names). There would really be no way of knowing if things are ok or not until we assemble all the terms and run them.<br />
<br />
2. you'd have a hard time detecting inconsistencies compile time: say Term1 computes Hessian using finite differences, while Term2 computes Hessian using convolution, but they both call it Hessian. Term1 puts the "Hessian" in the workspace, and Term2 finds a "Hessian" in the workspace and uses it, but it's not the Hessian Term2 needs.<br />
<br />
Of course careful development will avoid all this sort of issues, but a newcomer would have to know about any quantities the other terms generate.<br />
<br />
On the other hand there are a few advantages using dependencies:<br />
<br />
1. if Term2 depends on the Hessian term, there's a way to have term compatibility checked at compile-time (see term constructor in [[http://github.com/lantiga/ModularLevelSets ModularLevelSets]], in particular itk::LevelSetCurvatureTerm). <br />
<br />
2. since Hessian is a term, i.e. a class, there's no chance of creating conflicting classes with the same name. If Term1 depends on Hessian computed using finite differences, the developer of Term2 will be forced to implement a ConvolutionHessian term. In other words, the dependency of the two terms will be local to the terms, no chance of collisions in the global workspace, irrespective on how the terms are assembled.<br />
<br />
Dependencies have to analyzed only once, when it's time for level sets to run. You can decide the order in which to evaluate terms and cache the results of a term if that term is a dependency of more than one term, so there's really no extra cost compared to the global workspace option, terms are computed the same number of times.<br />
<br />
This is just my view on the topic, but in general I think this is a really important issue, as we expect that terms will grow in number.</div>Lantiga