Active sh

240 views
Skip to first unread message

Massimo Audrito

unread,
Jun 2, 2016, 3:59:09 AM6/2/16
to scalismo
Dear All,

for a project I am working to , i would to need an help or tutorial regarding active shape modeling. I saw in the Scalismo material that there should be a function that could be used regarding this technique.
DO you have any example how to used it and to share? ....I have followed the tutorial on Scalismo Lab, and I am learning how to use Scala as programming language and there is an approach to this Active shape modelling in a part of the Tutorial "Finding correspondence in an image" but the latter  do not use the above mentioned function.

Thanks for any help.

Massimo

Marcel Luethi

unread,
Jun 6, 2016, 6:41:11 AM6/6/16
to Massimo Audrito, scalismo
Dear Massimo,

Welcome to the scalismo community :-)

I am sorry for the late reply. Your message completely slipped our attention.

Unfortunately we have no up-to-date tutorial document for the Active Shape Model Fitting. But I have posted example code how you can build and fit an Active Shape Model here:
https://gist.github.com/marcelluethi/946f8fc3db62da9b6453add5845c81af
 
Don't hesitate to ask if you have any further questions.

Best regards,

Marcel



--
You received this message because you are subscribed to the Google Groups "scalismo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalismo+u...@googlegroups.com.
To post to this group, send email to scal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalismo/616dda4c-ff91-457c-9901-98b83351a14b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Massimo Audrito

unread,
Jun 7, 2016, 9:10:16 AM6/7/16
to scalismo, m.au...@gmail.com
Dear MArcel,

many thanks for the reply , I will play with the example code  you posted.

A silly question.

 I know that  Scalismo handle images in VTK or nii format. Unfortunatly, I am having problem to import vtk file generated with third part software as paraview. I have read the tutorial and you recommend to export with coordinate system. Could you suggest any software where I can export a jpg file in vtk to import in scalismo.

Best regards

Massimo

Massimo Audrito

unread,
Jun 7, 2016, 9:32:37 AM6/7/16
to scalismo, m.au...@gmail.com
Dear Marcel,

in which way did you save lena.vtk from the classical image file? ( .../scalismo-master/src/test/resources/lena.vtk)

many many thanks for any advice


Massimo

Il giorno lunedì 6 giugno 2016 12:41:11 UTC+2, Marcel Luethi ha scritto:

bouabene ghazi

unread,
Jun 7, 2016, 11:17:21 AM6/7/16
to scalismo
Hi Massimo,

For the lena.vtk image, we used Paraview (paraview.org) to convert the 
image from jpg to vtk.

This said, I have to ask you, are you considering to fit 2D Active Shape 
Models to 2D images?

If that is the case, please bear in mind that the current version of 
Scalismo does not support 2D Active Shape Models, as only 3D meshes are 
supported currently.

We are working on an implementation of 2D meshes, which would eventually 
result in a support for 2D Active Shape Models.

So this issue should be solved in future versions of Scalismo.

Best,
Ghazi

-- 
Ghazi Bouabene, PhD
Department of Mathematics and Computer Science 
University of Basel, Switzerland
https://github.com/Ghazi-Bouabene

bhfo...@ucdavis.edu

unread,
Aug 7, 2017, 3:49:27 PM8/7/17
to scalismo, m.au...@gmail.com
Hi Marcel

I attended the 2016 EMBS imaging summer school that you taught at, and I have been very interested in shape modeling since then. I've been using Scalismo quite frequently for my research, and I am trying to create an active shape model now. I've spent about 6+ hours or so trying to get this example to work, and I was hoping you could help me out.

Here is what I have done so far: 

So far I have been using the Scalismo Lab editor for my code. Using the gist you wrote in the editor unfortunately gives the error that it does not have the ImageIO.read3DScalarImageAsType function. I believe it's an older version of Scalismo which doesn't have this function. I tried changing it to a function it does have (i.e.  ImageIO.read3DScalarImage) which then fails with the training asm data that came with Scalismo Lab because the .vtk files are "Short" while it needs "Float". I then converted the example MRIs to Float using 3D Slicer, but now I get a different error "java.lang.IllegalArgumentException: requirement failed". I made sure the surfaces still aligned with the images after conversion so I can't figure out what this error means. 

Next, I then tried to compile the gist code using an updated version of Scalismo with the minimal seed, but I can't figure out how to modify the build file so that it will create the .jar file. What do I exactly type into the command window to create the .jar file? I've tried various things with sbt but it hasn't compiled so far. 

Do you have any suggestions on how to use your gist to create an active shape model using the dataset provided with Scalismo Lab? The Scalismo Lab is excellent so it would be really great if I could slightly modify the gist code to make it run. If not, a separate .jar file could work as well. 

Thank you very much!
Brent

Marcel Luethi

unread,
Aug 8, 2017, 9:37:59 AM8/8/17
to bhfo...@ucdavis.edu, scalismo
Hi Brent,

I am happy to hear that you find Scalismo(Lab) useful.

You are right that ScalismoLab uses a relatively old version of
Scalismo. We are using ScalismoLab mainly as a tool for teaching, as
it allows people to get started immediately. But for serious work, we
recommend the use of an IDE, since modern IDEs make it much much more
comfortable to work with Scala and Scalismo.

It is quite simple to convert images from Short to Float in Scalismo.
You can do it with the following code:
'''
val shortimg = ImageIO.read3DScalarImage[Short]("myshortImage").get
val floatimg = shortimg.map(pixel => pixel.toFloat)
'''

Does this help with your problem or do you still encounter the Illegal
Argument exception after conversion with Scalismo?


Best regards,

Marcel
> https://groups.google.com/d/msgid/scalismo/b54478a5-81ba-4d53-b161-d04dd88b734d%40googlegroups.com.

Marcel Luethi

unread,
Aug 8, 2017, 3:46:41 PM8/8/17
to Brent Foster, scalismo
Hi Brent,

My hope was that it was the conversion with Slicer that led to the
Illegal Argument Exception.

To diagnose what is happening, it would be helpful to see the full
error message. You should see a stack trace in the console window.
Could you post it here? Also, could you post the code that causes the
problem?

Best regards,
Marcel


On Tue, Aug 8, 2017 at 7:46 PM, Brent Foster <bhfo...@ucdavis.edu> wrote:
> Hi Marcel
>
> Thank you very much for the quick reply. That is a great suggestion for
> using an IDE and I will look into doing that soon. I should also improve my
> Scala skills since I've only used Python thus far.
>
> The code you provided does fix the pixel type error, but I'm still receiving
> the illegal argument exception. Do you have any hints on why this could be?
> Could it be that the version in ScalismoLab (version 0.10.0) having
> different inputs?
>
> I'll next try to get it running in an IDE instead of ScalismoLab and maybe
> that would fix it.
>
> Thank you,
> Brent

Brent Foster

unread,
Aug 8, 2017, 4:14:50 PM8/8/17
to Marcel Luethi, scalismo
Sorry I wasn't clear. I actually tried the code using the asmData provided with ScalismoLab. I previously ran the code using the asmData images that I converted to float using 3D Slicer, but I went back to the provided data to remove that potential source of error. 

Here is a link to a GitHub gist with the code I used. I copy and pasted this entire code into the editor of ScalismoLab using the asmData provided with it.



The error message I get is: 

Building Active Shape Model from ${imgAndMeshFiles.length} training data...
datasets\asmData\mri\19.vtk, datasets\asmData\faces\19.stl
java.lang.IllegalArgumentException: requirement failed
  at scala.Predef$.require(Predef.scala:212)
  at ASMBuild$.surfaceToTransform(<console>:194)
  at ASMBuild$.$line35$$read$ASMBuild$$trainingDatum$1(<console>:168)
  at ASMBuild$$anonfun$makeTrainingData$1.apply(<console>:182)
  at ASMBuild$$anonfun$makeTrainingData$1.apply(<console>:182)
  at scala.collection.Iterator$$anon$11.next(Iterator.scala:409)
  at scala.collection.Iterator$$anon$12.nextCur(Iterator.scala:434)
  at scala.collection.Iterator$$anon$12.hasNext(Iterator.scala:440)
  at scala.collection.Iterator$class.foreach(Iterator.scala:893)
  at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
  at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:59)
  at scala.collection.immutable.VectorBuilder.$plus$plus$eq(Vector.scala:732)
  at scala.collection.immutable.VectorBuilder.$plus$plus$eq(Vector.scala:708)
  at scala.collection.TraversableOnce$class.to(TraversableOnce.scala:310)
  at scala.collection.AbstractIterator.to(Iterator.scala:1336)
  at scala.collection.TraversableOnce$class.toIndexedSeq(TraversableOnce.scala:300)
  at scala.collection.AbstractIterator.toIndexedSeq(Iterator.scala:1336)
  at scalismo.statisticalmodel.asm.ActiveShapeModel$.trainModel(ActiveShapeModel.scala:46)
  at ASMBuild$.main(<console>:276)
  ... 30 elided

If it is relevant I downloaded ScalismoLab on February 13, 2017. 

Thank you again for all of your help! 

Brent





Marcel Luethi

unread,
Aug 9, 2017, 2:31:02 AM8/9/17
to Brent Foster, scalismo
Hi Brent,

The problem occurs here:
https://gist.github.com/BrentFoster/30f184316f2c36a8830179cbc4eff0ab#file-gistfile1-txt-L58
It arises because the mesh that denotes the contour of your structure
has not the same number of points as (the reference of) your model.

This indicates that (at least some of) your meshes in the "meshesDir"
directory are not in correspondence with the model. In order to build
an ASM, the meshes you use as training data need to be registered. To
register the meshes, you can use exactly the same procedure as for
building the model.

Best regards,

Marcel

Brent Foster

unread,
Aug 9, 2017, 3:04:01 PM8/9/17
to Marcel Luethi, scalismo
Hi Marcel

Thank you very much for all of your help! I will try this out and will also start using an IDE which should help too. I look forward to continuing to use Scalismo in my research.

Best,
Brent


Reply all
Reply to author
Forward
0 new messages