informatics-isi-edu / synspy

Synaptic segmentation and visualization with fluorescence microscopy
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

Image unit vectors #56

Closed karlcz closed 6 years ago

karlcz commented 7 years ago

@BDemps would like to experiment gross alignment of images to a normalized coordinate system.

We need to add some optional fields to the Image record consisting of three reference points:

  1. An "origin" such as a point near the brain stem
  2. An anterior point to orient the brain and establish a unit length from the "origin" point
  3. An off-axis point to orient the brain around the axial vector established by the other two points, e.g. this could be some easily identified dorsal point

@BDemps do you have any clear idea how you will define these points anatomically and what we should call the fields in the Image record to minimize confusion?

BDemps commented 7 years ago

I have an idea of what I am going to do, but I'm not sure what the exact definitions will be. as a proof of principle, I will be using the tectum neuropil, getting an original at the midbrain/forebrainboundary and trying for two vectors defining the neuropil or perhaps an ear-to-eye distance measure.

On Dec 1, 2017 12:46 PM, "Karl Czajkowski" notifications@github.com wrote:

@BDemps https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_bdemps&d=DwMCaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=Lssj6JKak_DaRnExGYcKnQ&m=mOFA92ipP1C0r4a3FL3oNCE2AYax4jCHducNVBjNrQE&s=Q437pkX1Lvhe6wbACvLrxrOrWjGyIYMyWevlSg0VnQc&e= would like to experiment gross alignment of images to a normalized coordinate system.

We need to add some optional fields to the Image record consisting of three reference points:

  1. An "origin" such as a point near the brain stem
  2. An anterior point to orient the brain and establish a unit length from the "origin" point
  3. An off-axis point to orient the brain around the axial vector established by the other two points, e.g. this could be some easily identified dorsal point

@BDemps https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_bdemps&d=DwMCaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=Lssj6JKak_DaRnExGYcKnQ&m=mOFA92ipP1C0r4a3FL3oNCE2AYax4jCHducNVBjNrQE&s=Q437pkX1Lvhe6wbACvLrxrOrWjGyIYMyWevlSg0VnQc&e= do you have any clear idea how you will define these points anatomically and what we should call the fields in the Image record to minimize confusion?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_informatics-2Disi-2Dedu_synspy_issues_56&d=DwMCaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=Lssj6JKak_DaRnExGYcKnQ&m=mOFA92ipP1C0r4a3FL3oNCE2AYax4jCHducNVBjNrQE&s=ywspWUX733_q1jULw_uAG_eFrc6BCmxzYaw-y4Ewc98&e=, or mute the thread https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AbQSt0ouOdDQ94NeXRChYwT44SOC-2D1sKks5s8GV-5FgaJpZM4Qy5Cs&d=DwMCaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=Lssj6JKak_DaRnExGYcKnQ&m=mOFA92ipP1C0r4a3FL3oNCE2AYax4jCHducNVBjNrQE&s=BSbHU6KB5UEqdXCZr7ILrTNCiU5VvdyNmV6lZcNpVKc&e= .

BDemps commented 6 years ago

It was a little harder than I originally anticipated, but here is what I've come up with. As far as origin goes, I chose the anteriormost portion of the pineal gland in the pallium Images (#3 or #6 images for each dataset). I would say X and Y coordinates are pretty accurate, but the Z coordinate is probably a bit off.

Origin Point: Anterior portion of Pineal Gland Z Y X ImgZfDsy20170316A3 28.8 150.542 52.261 ImgZfDsy20170316B3 10.4 132.602 64.741 ImgZfDsy20170317B3 21.2 150.282 75.921 ImgZfDsy20170426A3 31.6 132.602 35.881 ImgZfDsy20170505A6 16.4 141.442 49.921 ImgZfZdu20170516A3 18.4 117.002 53.041 As far as "unit vectors" go, I tried to get one direction in Y and one direction in X. I chose the anterior portion of the pineal gland to the anterior end of the telencephalon in the Y direction (approximate origin and extent) for one unit vector (using #3 or #6 datasets). I chose the approximate X extent of the widest portion of the habenula for the other unit vector in X (using @2 datasets). Anterior Pineal to Front of TE Across Habenula (rotated fish) Dataset Standard Length (mm) Y start (um) Y extent (µm) X start (µm) X extent (µm) ImgZfDsy20170316A2 and 3 5 150.542 134.938 96.2 97.24 ImgZfDsy20170316B2 and 3 4.7 132.602 136.498 95.42 94.38 ImgZfDsy20170317B2 and 3 4.1 150.282 105.558 102.96 70.46 ImgZfDsy20170426A2 and 3 4.9 132.602 147.678 87.36 91.52 ImgZfDsy20170505A2 and 6 4.5 141.442 137.798 89.44 88.66 ImgZfZdu20170516A2 and 3 4.2 117.002 128.698 84.24 87.62 Does this seem like something reasonable to start with, or do you need better coordinates defined? I tried keeping things cartesian, but I'm not exactly sure what makes the most sense to you!

On Fri, Dec 1, 2017 at 1:43 PM, William Dempsey wdempsey@usc.edu wrote:

I have an idea of what I am going to do, but I'm not sure what the exact definitions will be. as a proof of principle, I will be using the tectum neuropil, getting an original at the midbrain/forebrainboundary and trying for two vectors defining the neuropil or perhaps an ear-to-eye distance measure.

On Dec 1, 2017 12:46 PM, "Karl Czajkowski" notifications@github.com wrote:

@BDemps https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_bdemps&d=DwMCaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=Lssj6JKak_DaRnExGYcKnQ&m=mOFA92ipP1C0r4a3FL3oNCE2AYax4jCHducNVBjNrQE&s=Q437pkX1Lvhe6wbACvLrxrOrWjGyIYMyWevlSg0VnQc&e= would like to experiment gross alignment of images to a normalized coordinate system.

We need to add some optional fields to the Image record consisting of three reference points:

  1. An "origin" such as a point near the brain stem
  2. An anterior point to orient the brain and establish a unit length from the "origin" point
  3. An off-axis point to orient the brain around the axial vector established by the other two points, e.g. this could be some easily identified dorsal point

@BDemps https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_bdemps&d=DwMCaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=Lssj6JKak_DaRnExGYcKnQ&m=mOFA92ipP1C0r4a3FL3oNCE2AYax4jCHducNVBjNrQE&s=Q437pkX1Lvhe6wbACvLrxrOrWjGyIYMyWevlSg0VnQc&e= do you have any clear idea how you will define these points anatomically and what we should call the fields in the Image record to minimize confusion?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_informatics-2Disi-2Dedu_synspy_issues_56&d=DwMCaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=Lssj6JKak_DaRnExGYcKnQ&m=mOFA92ipP1C0r4a3FL3oNCE2AYax4jCHducNVBjNrQE&s=ywspWUX733_q1jULw_uAG_eFrc6BCmxzYaw-y4Ewc98&e=, or mute the thread https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AbQSt0ouOdDQ94NeXRChYwT44SOC-2D1sKks5s8GV-5FgaJpZM4Qy5Cs&d=DwMCaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=Lssj6JKak_DaRnExGYcKnQ&m=mOFA92ipP1C0r4a3FL3oNCE2AYax4jCHducNVBjNrQE&s=BSbHU6KB5UEqdXCZr7ILrTNCiU5VvdyNmV6lZcNpVKc&e= .

-- William Dempsey, Ph.D. Postdoctoral Scholar Molecular and Computational Biology Dana and David Dornsife College of Letters, Arts and Sciences University of Southern California wdempsey@usc.edu Lab #: 213-821-1818

BDemps commented 6 years ago

Okay, take two: Here are three "origin points" and an accompanying cartoon to give a general idea of the geometry of the "target areas" (regions with the "bulls eye" targets on them) and what I'm selecting. 3OriginPoints_ForRegistration.pdf zebrafishlarvaeforebrainarea_20degrotation_labeled zebrafishlarvaeforebrainarea_20degrotation_targetareas

BDemps commented 6 years ago

Sorry, I had labeled some regions incorrectly. Think about this image as being ~20 degrees from dorsal such that you are imaging a sheet from the left side to the right side of the image. The LEFT brain areas are accessible this way as the shallowest optical sections! zebrafishlarvaeforebrainarea_20degrotation_labeled

karlcz commented 6 years ago

The new data-entry fields "Align P0 ZYX", "Align P1 ZYX", and "Align P2 ZYX" are configured on the Image table on the dev server.

@BDemps I chose a slightly richer column type here to store the 3 points as 3 columns, rather than having to add 9 columns for each component of each point. Can you play with this a little and see if it is usable enough for you to do data entry and understand the results that are printed in the catalog?

https://synapse-dev.isrd.isi.edu/chaise/recordedit/#1/Zebrafish:Image/ID=ImgZfZdu20171012C10?invalidate=425297823689513

I arbitrarily set the P0 point as 0, 0, 0 here just to test the display of the coordinates.

karlcz commented 6 years ago

By the way, I noticed in your PDF that you have some fractional values. Is this because you are using some other tool to compute center-of-mass locations? I would have expected whole integers since the locations should be voxel coordinates, shouldn't they?

BDemps commented 6 years ago

Shoot, I have it in microns, not pixels. I'll do the conversion... Should we make sure that it ends up in the right place given that your coordinate system and Fiji's can differ?

On Mon, Dec 11, 2017 at 11:50 AM, Karl Czajkowski notifications@github.com wrote:

By the way, I noticed in your PDF that you have some fractional values. Is this because you are using some other tool to compute center-of-mass locations? I would have expected whole integers since the locations should be voxel coordinates, shouldn't they?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_informatics-2Disi-2Dedu_synspy_issues_56-23issuecomment-2D350837541&d=DwMFaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=Lssj6JKak_DaRnExGYcKnQ&m=qiDbqO6JNTz8hHGKGlFfEXFqzN10a5c1UQ-NDwfK3r0&s=hOk5TXTtgapVqBhla4Xa8Lawi7d9NNWnj8ZKPaVDiEQ&e=, or mute the thread https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AbQSt4BJZgFH7kbCNwddB1tP4X5p7EtAks5s-5FYeIgaJpZM4Qy5Cs&d=DwMFaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=Lssj6JKak_DaRnExGYcKnQ&m=qiDbqO6JNTz8hHGKGlFfEXFqzN10a5c1UQ-NDwfK3r0&s=krfwF_aEDLGlv2zqzOO8e3MKhvkTBAuiOsTN01Ch65g&e= .

-- William Dempsey, Ph.D. Postdoctoral Scholar Molecular and Computational Biology Dana and David Dornsife College of Letters, Arts and Sciences University of Southern California wdempsey@usc.edu Lab #: 213-821-1818

karlcz commented 6 years ago

Unfortunately, you should ignore the fiji micron measurements and go do them over in pixel coordinates. This will have all the same issues we encountered before trying to get crop boxes out of fiji. E.g. fiji is inconsistent in how it orients its axes between the two modes, and the micron measurements are fragile when you sometimes produce bogus grid spacing metadata from the SPIM scope.

karlcz commented 6 years ago

@BDemps I've added the new gross alignment columns to the Image table on the production server. So, you can start recording actual positions now...

karlcz commented 6 years ago

I've added a support class in synspy.analyze.pair.ImageGrossAlignment which aligns to a common "unit-space" so that any number of aligned images' pointclouds could potentially be composed in one plot:

  1. The Align P0 ZYX point is relocated to the origin 0,0,0 via translation
  2. The Align P1 ZYZ point is scaled and rotated as the unit vector 0,1,0 on the Y axis
  3. The Align P2 ZYX point is relocated to the Z=0 XY plane by rolling about the Y axis