Preselect standard deviation value for chosen index/mode

52 views
Skip to first unread message

Cory Ferraz

unread,
Mar 15, 2022, 3:44:45 AM3/15/22
to scalismo
Hello!

Is it possible to preselect the control value (standard deviation) for specific indices on a shape model? For example, I would like to choose a 3.0 setting for Index 0 of my model via the IDE then run a writeMesh at my (index 0, 3.0 value) model value to save my mesh at that (0,3.0) value. 

Normally I would right click on the model at my specific (index,value) and save the mesh that way, but I am hoping to bypass the UI if possible. 

Regards,
Cory Ferraz

Marcel Luethi

unread,
Mar 15, 2022, 4:05:21 AM3/15/22
to Cory Ferraz, scalismo
Hi Cory

Yes, this is possible. You can define a vector of shape coefficients, for which you set the coefficients to the desired values. Then you can call the instance method on the PointDistributionModel to obtain the corresponding shape.
For example, if you would like to set the first component to 3 (stddev), you would write the following:

  val pdm : PointDistributionModel[_3D, TriangleMesh] = ???
  val coeffs = DenseVector.zeros(pdm.rank)
  coeffs(0) = 3
  val shapeInstance : TriangleMesh[_3D] = pdm.instance(coeffs)


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 view this discussion on the web visit https://groups.google.com/d/msgid/scalismo/dbf71c37-df4c-490c-b971-ba608dd6bef7n%40googlegroups.com.
Message has been deleted

Cory Ferraz

unread,
Mar 17, 2022, 2:38:32 AM3/17/22
to scalismo
Is there any way you can make a variable state how many modes there are automatically? For cumulative variance I want to have it run from (0 to numberOFmodes) however, currently I either have to open the UI to find the # of modes (then input it manually into the code) or just say numberOFmodes = samplesize - 3 and make a guess of it. 

Cory

Marcel Luethi

unread,
Mar 17, 2022, 4:26:40 AM3/17/22
to Cory Ferraz, scalismo
Hi Cory,

The function you are looking for is called rank and it is defined on the PointDistributionModel. You can use it like this:

val pdm : PointDistributionModel[_3D, TriangleMesh] = ???
println("number of modes: " +pdm.rank)

Best regards,
Marcel

Cory Ferraz

unread,
Mar 17, 2022, 10:43:20 AM3/17/22
to scalismo
The issue I am running into is the pdm.rank is always 1 (or 2) higher than the # of modes in the model so I need to take my cumulative variance from (1 to pdm.rank-1) for it to work correctly. Is that working as intended?

Cory

Marcel Luethi

unread,
Mar 17, 2022, 11:28:10 AM3/17/22
to Cory Ferraz, scalismo
No, this is not how it should be. Actually the rank is defined as the number of modes. What makes you think that the number of modes is smaller than pdm.rank?

Best,
Marcel

Cory Ferraz

unread,
Mar 18, 2022, 1:29:33 AM3/18/22
to scalismo
I figured out the issue. The rank is the total # of modes, however when calculating the variance I am doing it from (0 to pdm.rank) which makes it out of range by 1 since we're counting from 0, not 1.  (0 to pdm.rank) = (pdm.rank + 1). Silly mistake.
Reply all
Reply to author
Forward
0 new messages