def rescale(x,y,z,invert_y=True,**surf_properties_kwargs): import volume surf_xmin,surf_ymin,surf_zmin,surf_xmax,surf_ymax,surf_zmax=( volume.surf_properties(**surf_properties_kwargs)) pad_nr=2 surf_xmin+=pad_nr; surf_xmax-=pad_nr surf_ymin+=pad_nr; surf_ymax-=pad_nr surf_zmin+=pad_nr; surf_zmax-=pad_nr xmax=np.max(x) xmin=np.min(x) xrng=xmax-xmin+1 ymax=np.max(y) ymin=np.min(y) yrng=ymax-ymin+1 zmax=np.max(z) zmin=np.min(z) zrng=zmax-zmin+1 xmap=lambda x:(x-xmin)*(surf_xmax-surf_xmin+1)/xrng+surf_xmin if invert_y: ymap=lambda y:(y-ymin)*(surf_ymin-surf_ymax-1)/yrng+surf_ymax print surf_ymin-surf_ymax-1 print yrng else: ymap=lambda y:(y-ymin)*(surf_ymax-surf_ymin+1)/yrng+surf_ymin zmap=lambda z:(z-zmin)*(surf_zmax-surf_zmin+1)/zrng+surf_zmin retx=xmap(x) rety=ymap(y) retz=zmap(z) return retx,rety,retz
def rescale(x, y, z, invert_y=True, **surf_properties_kwargs): import volume surf_xmin, surf_ymin, surf_zmin, surf_xmax, surf_ymax, surf_zmax = ( volume.surf_properties(**surf_properties_kwargs)) pad_nr = 2 surf_xmin += pad_nr surf_xmax -= pad_nr surf_ymin += pad_nr surf_ymax -= pad_nr surf_zmin += pad_nr surf_zmax -= pad_nr xmax = np.max(x) xmin = np.min(x) xrng = xmax - xmin + 1 ymax = np.max(y) ymin = np.min(y) yrng = ymax - ymin + 1 zmax = np.max(z) zmin = np.min(z) zrng = zmax - zmin + 1 xmap = lambda x: (x - xmin) * (surf_xmax - surf_xmin + 1 ) / xrng + surf_xmin if invert_y: ymap = lambda y: (y - ymin) * (surf_ymin - surf_ymax - 1 ) / yrng + surf_ymax print surf_ymin - surf_ymax - 1 print yrng else: ymap = lambda y: (y - ymin) * (surf_ymax - surf_ymin + 1 ) / yrng + surf_ymin zmap = lambda z: (z - zmin) * (surf_zmax - surf_zmin + 1 ) / zrng + surf_zmin retx = xmap(x) rety = ymap(y) retz = zmap(z) return retx, rety, retz
def fix_skewing(s, **surf_properties_kwargs): import volume surf_xmin, surf_ymin, surf_zmin, surf_xmax, surf_ymax, surf_zmax = ( volume.surf_properties(**surf_properties_kwargs)) xrng = (surf_xmax - surf_xmin + 1) tx = s.mlab_source.x trk_xrng = (np.max(tx) - np.min(tx) + 1) xscale = .97 / (trk_xrng / xrng) xmid = (surf_xmax - surf_xmin) / 2 + surf_xmin trk_xmid = (np.max(tx) - np.min(tx)) / 2 + np.min(tx) s.mlab_source.x = (tx - trk_xmid) * xscale + xmid yrng = (surf_ymax - surf_ymin + 1) ty = s.mlab_source.y trk_yrng = (np.max(ty) - np.min(ty) + 1) yscale = .96 / (trk_yrng / yrng) ymid = (surf_ymax - surf_ymin) / 2 + surf_ymin trk_ymid = (np.max(ty) - np.min(ty)) / 2 + np.min(ty) s.mlab_source.y = (ty - trk_ymid) * yscale + ymid zrng = (surf_zmax - surf_zmin + 1) tz = s.mlab_source.z trk_zrng = (np.max(tz) - np.min(tz) + 1) print trk_zrng / zrng #if .5 < trk_zrng/zrng < 1.15: if trk_zrng / trk_yrng < .70: zscale = .95 zmid = (surf_zmax - surf_zmin) / 2 + surf_zmin trk_zmid = (np.max(tz) - np.min(tz)) / 2 + np.min(tz) s.mlab_source.z = (tz - trk_zmid) * zscale + zmid #elif 1.25 < trk_zrng/zrng < 1.55: else: zscale = 1.33 / (trk_zrng / zrng) s.mlab_source.z = (tz - np.max(tz)) * zscale + surf_zmax - 0.5
def fix_skewing(s,**surf_properties_kwargs): import volume surf_xmin,surf_ymin,surf_zmin,surf_xmax,surf_ymax,surf_zmax=( volume.surf_properties(**surf_properties_kwargs)) xrng = (surf_xmax-surf_xmin+1) tx = s.mlab_source.x trk_xrng = (np.max(tx)-np.min(tx)+1) xscale = .97 / (trk_xrng/xrng) xmid = (surf_xmax-surf_xmin)/2 + surf_xmin trk_xmid = (np.max(tx)-np.min(tx))/2 + np.min(tx) s.mlab_source.x = (tx-trk_xmid)*xscale+xmid yrng = (surf_ymax-surf_ymin+1) ty = s.mlab_source.y trk_yrng = (np.max(ty)-np.min(ty)+1) yscale = .96 / (trk_yrng/yrng) ymid = (surf_ymax-surf_ymin)/2 + surf_ymin trk_ymid = (np.max(ty)-np.min(ty))/2 + np.min(ty) s.mlab_source.y = (ty-trk_ymid)*yscale+ymid zrng = (surf_zmax-surf_zmin+1) tz = s.mlab_source.z trk_zrng = (np.max(tz)-np.min(tz)+1) print trk_zrng/zrng #if .5 < trk_zrng/zrng < 1.15: if trk_zrng / trk_yrng < .70: zscale = .95 zmid = (surf_zmax-surf_zmin)/2 + surf_zmin trk_zmid = (np.max(tz)-np.min(tz))/2 + np.min(tz) s.mlab_source.z = (tz-trk_zmid)*zscale+zmid #elif 1.25 < trk_zrng/zrng < 1.55: else: zscale = 1.33 / (trk_zrng/zrng) s.mlab_source.z = (tz-np.max(tz))*zscale+surf_zmax-0.5