[chimera-dev] Patch to center_of_points()
Tom Goddard
goddard at sonic.net
Tue Jul 10 11:17:18 PDT 2012
Thanks Nader! I've fixed this in the Chimera daily build. Also the
updated Segger will include some handy buttons for showing and selecting
segmented regions added by Greg Pintilie.
Surprisingly if x is a numpy 1.6.2 float32 array then x/10000 is a
float32 array but x/100000 is a float64 array.
Tom
> It seems that the code in the Segger module for calculating the center
> of a region breaks when the region contain a large number of points. I
> don't have the error message on hand, but it complains about calling
> _contour.affine_transform_vertices with a double, rather than a float.
>
> It seems that in regions.py the summed coordinate is cast to a float32,
> then divided by the number of points, which can cause an implicit cast
> up to float64's when point_count is large!
>
> Here's a simple patch to share/Segger/regions.py that re-orders the
> calls to cast after division, rather than before:
>
> --- old/share/Segger/regions.py 2012-03-19 13:45:34.000000000 -0700
> +++ new/share/Segger/regions.py 2012-07-09 14:55:26.241372503 -0700
> @@ -873,7 +873,7 @@
>
> plists = [r.points() for r in self.childless_regions()]
> s = numpy.sum([numpy.sum(plist, axis=0) for plist in plists], axis=0)
> - com = s.astype(numpy.float32) / self.point_count()
> + com = (s / self.point_count()).astype(numpy.float32)
> if transform:
> tf = self.segmentation.point_transform()
> import _contour
>
> --
> Nader Morshed <morshed.nader at berkeley.edu>
> _______________________________________________
> Chimera-dev mailing list
> Chimera-dev at cgl.ucsf.edu
> http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev
>
More information about the Chimera-dev
mailing list