Message Boards Message Boards

1
|
7169 Views
|
5 Replies
|
4 Total Likes
View groups...
Share
Share this post:

FindCurvePath doesn't give reliable results for worm images

Posted 10 years ago

Hi guys,

I'm working on worm images. After image processing, a worm looks like this:

After Image Processing

Positions of the worm points / pixels:

wormpoints = Position[Transpose@ImageData[worm, "Bit", DataReversed -> True], 1]

Here's the problem:

The points are not necessarily ordered correctly, from the worm head (left) to its tail. I've tried ordering them by:

wormpointsordered = wormpoints[[First@FindCurvePath[wormpoints]]];

Unfortunately, this step is not very reliable. It should give me all worm points, but ordered. In reality, it sometimes gives me only 10 points. Sometimes even only 3 points!

Any ideas? Thanks

David.

POSTED BY: David Thissen
5 Replies

Hi Henrik,

thanks for your response! And thanks a lot for the notebook file you attached as well! Your routine seems to be a lot more robust than FindCurvePath. I'm gladly using it instead!

While crawling, the worm uses only a very low-dimensional set of body shapes [STEPHENS, Greg J., et al. Dimensionality and dynamics in the behavior of C. elegans. PLoS computational biology, 2008]. I want to extract these body shapes. For the moment, I'm using a PCA, where I can reproduce a large amount of the body shapes with only the first two components / modes.

To find the modes, I need a functional representation of the curvature along the body. The more angles I extract, the more precise is this representation.

Thanks again, Best wishes,

David.

POSTED BY: David Thissen

Hi David,

sorry for my late response - it is an interesting problem you brought up! Yes, FindCurvePath is not working correctly. I myself found this disturbing, so I eventually wrote my own routine. You can find this in the attached notebook; it should be self expaining. (The routine is not very much tested - I am not promising anything!)

You were thinking about extracting all the angles along the worm line. I can not think of anything meaningful to be done with this large amount of tiny angle values - if you do can, I am not saying anything. But how about starting with something very simple: Dividing the worm line into 4 equal (?) pieces. Then there are only 3 angle values which define the configuration of the worm (this way) completely. As the worm moves the changes of the angles in time can be represented by a 3D trajectory which can be visualized - this is always an advantage! If the motion of the worm is in some way periodic, the corresponding trajectories will most likely show a pattern. ... Well, just a suggestion!

Greetings Henrik

PS: If you ever try this simple experiment I would be interesting in seeing the result.

Attachments:
POSTED BY: Henrik Schachner

Ok, I think I found the problem: FindCurvePath split the worm into several curve paths.

Not what I wanted, but just taking the longest curve path

wormpointsordered = wormpoints[[First@With[{L = Length /@ FindCurvePath@wormpoints}, 
     Pick[FindCurvePath@wormpoints, L, Max@L]]]];

Seems to work for the moment...

Thanks, and have a nice weekend everyone!

POSTED BY: David Thissen
wormpoints = {{220, 276}, {220, 277}, {220, 278}, {220, 279}, {221, 274}, {221, 275}, {222, 272}, {222, 273}, {223, 270}, {223, 271}, {224, 269}, {225, 268}, {226, 266}, {226, 267}, {227, 265}, {228, 263}, {228, 264}, {229, 262}, {230, 260}, {230, 261}, {231, 
  259}, {232, 258}, {233, 257}, {234, 256}, {235, 256}, {236, 255}, {237, 254}, {238, 254}, {239, 254}, {240, 254}, {241, 
  253}, {242, 253}, {243, 253}, {244, 252}, {245, 252}, {246, 253}, {247, 253}, {248, 253}, {249, 253}, {250, 253}, {251, 
  253}, {252, 253}, {253, 254}, {254, 254}, {255, 254}, {256, 254}, {257, 254}, {258, 255}, {259, 255}, {260, 255}, {261, 
  255}, {262, 256}, {263, 256}, {264, 256}, {265, 257}, {266, 257}, {267, 258}, {268, 258}, {269, 259}, {270, 259}, {271, 
  260}, {272, 260}, {273, 260}, {274, 261}, {275, 261}, {276, 262}, {277, 262}, {278, 262}, {279, 263}, {280, 263}, {281, 
  264}, {282, 264}, {283, 265}, {284, 265}, {285, 265}, {286, 265}, {287, 265}, {288, 266}, {289, 266}, {290, 266}, {291, 
  266}, {292, 266}, {293, 266}, {294, 266}, {295, 266}, {296, 266}, {297, 266}, {298, 265}, {299, 265}, {300, 265}, {301, 
  264}, {302, 264}, {303, 264}, {304, 263}, {305, 262}, {306, 262}, {307, 261}, {308, 260}, {309, 260}, {310, 259}, {311, 
  258}, {312, 257}, {313, 255}, {313, 256}, {314, 254}, {315, 253}, {316, 252}, {317, 251}, {318, 249}, {318, 250}, {319, 
  248}, {320, 246}, {320, 247}, {321, 244}, {321, 245}, {322, 242}, {322, 243}, {323, 241}, {324, 239}, {324, 240}, {325, 
  238}, {326, 236}, {326, 237}, {327, 234}, {327, 235}, {328, 233}, {329, 232}, {330, 231}, {331, 230}, {332, 229}, {333, 
  228}, {334, 227}, {335, 226}, {336, 225}, {337, 225}, {338, 224}, {339, 223}, {340, 223}, {341, 222}, {342, 222}, {343, 
  222}, {344, 221}, {345, 220}, {346, 220}, {347, 220}, {348, 220}, {349, 219}, {350, 219}, {351, 218}, {352, 218}, {353, 
  218}, {354, 218}, {355, 217}, {356, 217}, {357, 217}, {358, 217}, {359, 217}, {360, 216}, {361, 216}, {362, 216}, {363, 
  215}, {364, 215}, {365, 215}, {366, 215}, {367, 215}, {368, 214}, {369, 214}, {370, 214}, {371, 214}}

wormpointsordered = {{221, 275}, {220, 276}, {220, 278}}
POSTED BY: David Thissen

By the way, in the end I want to extract the angles along the worm body, starting at the head (left, s=0), and ending at the tail (right, s=1).

ArcTan[wormpoints[[i + 1, 1]] - wormpoints[[i, 1]], wormpoints[[i + 1, 2]] - wormpoints[[i, 2]]]    {i, 1, Length[wormpoints]}

Maybe there's a much easier / better way to do this?!?

POSTED BY: David Thissen
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract