-
Notifications
You must be signed in to change notification settings - Fork 65
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
Feature/modularize statismo io for better composition #425
Feature/modularize statismo io for better composition #425
Conversation
Good idea. This would allow us to write a group of models to the same file, or just store different resolution versions of the same model in the same file, I see that this could be useful. I was wondering if it could be made more abstract such that each model could have a separate |
Note sure if I misunderstood something, but I think this is already possible. You just have to keep track of your model paths yourself at the moment. There would be the model catalogue which was maybe intended to do so somewhen, but it is never written anywhere. I guess the following should work: val linePDM2d: PointDistributionModel[_2D, LineMesh] = ???
val linePDM3d: PointDistributionModel[_3D, LineMesh] = ???
val triangleModel3d: StatisticalMeshModel = ???
val trianglePDM3d: PointDistributionModel[_3D, TriangleMesh] = PointDistributionModel(
triangleModel3d.gp
)
val tetrahedralPDM3d: PointDistributionModel[_3D, TetrahedralMesh] = ???
val imageIntensityModel3d: DiscreteLowRankGaussianProcess[_3D, DiscreteImageDomain, Float] = ???
val file: File = ???
Using(StatisticalModelIOUtils.openFileForWriting(file).get) { h5file =>
for {
_ <- StatismoIO.writeStatismoPDM(linePDM2d, h5file, HDFPath("/2d-line-model/"))
_ <- StatismoIO.writeStatismoPDM(linePDM3d, h5file, HDFPath("/3d-line-model/"))
_ <- StatismoIO.writeStatismoPDM(trianglePDM3d, h5file, HDFPath("/3d-mesh-model/"))
_ <- StatismoIO.writeStatismoPDM(tetrahedralPDM3d, h5file, HDFPath("/3d-tetra-model/"))
_ <- StatismoIO.writeStatismoImageModel(imageIntensityModel3d, h5file, HDFPath("/image-model/"))
} yield ()
} |
We the recent commit, also an ASM (shape and appearance) can be written at a customizable path. |
For the example above, I was thinking if it would be possible to have a function like:
And then inside the function match the type of model (D, Domain) with specific writers. Then in your example above you wouldn't need to manually open the file and specify the paths, but just create a Seq of all the models and apply those to the write function. But even the suggested update, I also like. I'm just throwing ideas around. :) |
8b51027
to
ad460ad
Compare
Thank you for the clarification. I got now your idea. Using this PR one could start experimenting around. As there are aside of PDMs also intensity and image models, I am not sure if we can easily provide a useful function that is not too generic or complex. |
That is true. In that case, I'm fine with merging in the MR as there is no change in the interface. Then it can be extended later if/when needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this feature. Would be happy to merge it.
This is a proposal for a change. Please comment or suggest freely.
Currently it is not possible to write two models into one hdf5file. One place where this is used is the ASM model. But having intensity models and volume models, it could also be interesting to write two models into one file.
This PR splits the functions into the file handling part and the actual writing of the data. Like this one could also open a file to write and write two models at different locations. The decision to make them private was to guard them somehow against accidental use due to IDE suggestion.