Class: SectionImage
- Inherits:
-
SubImage
- Object
- ActiveRecord::Base
- SubImage
- SectionImage
- Includes:
- CoreBase
- Defined in:
- app/models/section_image.rb
Overview
SectionImages belong to a [SectionDataSet], which is an experiment comprised of sectioned tissue.
Direct Known Subclasses
Instance Method Summary (collapse)
-
- (Object) image_to_reference(sx, sy)
Find the closest specified 3D location to user specified 2D position.
-
- (Object) reference_to_location(rx, ry, rz)
Find the closest (x,y) location in this image to user specified 3D location.
Instance Method Details
- (Object) image_to_reference(sx, sy)
Find the closest specified 3D location to user specified 2D position
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/models/section_image.rb', line 24 def image_to_reference(sx, sy) ds = self.section_data_set return nil if not ds # ---- transform sub_image sx,sy to volume vx,vy,vz vz = self.section_number * ds.section_thickness xvs = self.alignment2d if xvs vx = xvs.tsv_00 * sx + xvs.tsv_01 * sy + xvs.tsv_04 vy = xvs.tsv_02 * sx + xvs.tsv_03 * sy + xvs.tsv_05 else return nil end # ---- transform volume vx,vy,vx to reference rx,ry,rz xrv = ds.alignment3d if xrv rx = xrv.tvr_00 * vx + xrv.tvr_01 * vy + xrv.tvr_02 * vz + xrv.tvr_09 ry = xrv.tvr_03 * vx + xrv.tvr_04 * vy + xrv.tvr_05 * vz + xrv.tvr_10 rz = xrv.tvr_06 * vx + xrv.tvr_07 * vy + xrv.tvr_08 * vz + xrv.tvr_11 else return nil end return rx, ry, rz end |
- (Object) reference_to_location(rx, ry, rz)
Find the closest (x,y) location in this image to user specified 3D location
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/models/section_image.rb', line 58 def reference_to_location(rx, ry, rz) ds = self.section_data_set return nil if not ds # ------ transform reference rx,ry,rz to volume vx,vy,vz xrv = ds.alignment3d if xrv vx = xrv.trv_00 * rx + xrv.trv_01 * ry + xrv.trv_02 * rz + xrv.trv_09 vy = xrv.trv_03 * rx + xrv.trv_04 * ry + xrv.trv_05 * rz + xrv.trv_10 # vz = xrv.trv_06 * rx + xrv.trv_07 * ry + xrv.trv_08 * rz + xrv.trv_11 else vx = rx vy = ry # vz = rz end # ------ transform vx,vy to sub_image sx,sy xvs = self.alignment2d if xvs sx = xvs.tvs_00 * vx + xvs.tvs_01 * vy + xvs.tvs_04 sy = xvs.tvs_02 * vx + xvs.tvs_03 * vy + xvs.tvs_05 else return nil end return sx, sy end |