Example #1
0
	def doAlignment(self, conv):
		d=self.getElements("Data")
		a=self.getElements("AbstractModel")
		if a:
			#FIXME: analytical fields aren't supported yet
			raise StandardError('No support of analytical fields yet')
		trans = [conv.get("Trans_x", 0.0), conv.get("Trans_y", 0.0), conv.get("Trans_z", 0.0)]
		scale = array([conv.get("Scale_x", 1.0), conv.get("Scale_y", 1.0), conv.get("Scale_z", 1.0)])
		rot = array([conv.get("Rot_x", 0.0), conv.get("Rot_y", 0.0), conv.get("Rot_z", 0.0)])
		if d:
			if any(rot):
				vects = row_stack([self.attributes.get("Vertical", (0,1,0.0)), 
					self.attributes.get("Depth", (0,0,-1.0)),
					self.attrib("Origin")
					])
				vects=rotate3D(vects, rot)
				self.setAttrib("Vertical", vects[0,:].tolist())
				self.setAttrib("Depth", vects[1,:].tolist())
				self.setAttrib("Origin", vects[2,:].tolist())
			if any(scale!=1.0):
				e=array(self.attrib("Edge"))*scale
				o=array(self.attrib("Origin"))*scale
				self.setAttrib('Origin', o.tolist())	
				self.setAttrib('Edge', e.tolist())	
			if any(trans):
				o=array(self.attrib("Origin"))+trans
				self.setAttrib('Origin', o.tolist())
Example #2
0
def arrayfromstring(s, prec=None):
	if '(' in s:
		shape, values=s.split(':')
		return reshape(arrayfromstring(values), eval(shape))
	elif ";" in s:
		return vstack([arrayfromstring(l) for l in s.split(';')])
	elif prec or ("." in s):
		return array(map(float, s.split(',')))
	else:
		return array(map(int, s.split(',')))
Example #3
0
	def setPoints(self, a, append=None):
		'''a (array), append (bool=False) => None
sets self.points to the specified array. If append is true, it
adds this array to the existing self.points'''
		if type(a)!=ArrayType:
			a=array(a, Float32)
		if not append or self.points==None or self.points.shape[0]==0:
			if len(a.shape)==1:
				a=array([a])
			self.points = a.copy()
		else:
			if len(a.shape)==2:
				self.points = concatenate([self.points, a])
			else:
				self.points = add_point(self.points, a)
Example #4
0
	def getData(self):
		de = self.getElements("Data")
		if de:
			return de[0]
		else:
			print "Can't find a data element. Making an empty one"
			from mien.nmpml.data import newData
			attrs = {"Type":"sfield", "Edge":self.attrib("Edge"), "Origin":self.attrib("Origin")}
			a=array([[[]]])
			d = newData(a, attrs)
			self.newElement(d)
			return d
Example #5
0
def readDens(inf, **kwargs):
	l=inf.readlines()	
	if len(l)==1000002:
		l=array([float(line.split()[3]) for line in l[2:]])	
		l=reshape(l, (100,100,100))
	else:
		v=array([float(line.split()[3]) for line in l[2:]])	
		ind=array([map(int, line.split()[:3]) for line in l[2:]])
		l=zeros((ind[:,0].max()+1, ind[:,1].max()+1, ind[:,2].max()+1), Float32)
		for i in range(v.shape[0]):
			l[ind[i,0],ind[i,1], ind[i,2]]=v[i]
	
	mv = l.max()	
	l/=mv
	o = mien.parsers.nmpml.createElement("SpatialField", {"Origin":ORIGIN.tolist(), "Edge":(EDGE,EDGE,EDGE),
			"Vertical":(0.0,1.0,0.0), "Depth":(0.0,0.0,-1.0), "MaxValue":mv,
			"mindensity":.0001, "maxdensity":.1})
	n = mien.parsers.nmpml.blankDocument()
	n.newElement(o)
	d=o.getData()
	d.datinit(l)
	return n
Example #6
0
def treeToPoints(nodes):
	points = []
	labels={}
	for i, n in enumerate(nodes):
		point=[]
		for v in ['x' , 'y', 'z' ]:
			point.append(float(n['attributes'][v]))
		if n['attributes'].has_key('d'):
			point.append(float(n['attributes']['d']))
		l=n['attributes'].get('Description')
		if l:
			labels[i]=l
		points.append(point)	
	points=array(points)		
	return (points, labels)
Example #7
0
def pypos2fed(f):
    points, head = readPyPos(f)
    correctedpoints = []
    labels = {}
    for n in points.keys():
        labels[len(correctedpoints)] = n.strip()
        p = points[n]
        p = (p[1], p[0], -p[2])
        correctedpoints.append(p)
    points = array(correctedpoints)
    fed = mien.nmpml.elements["Fiducial"](
        attribs={"Name": "LeicaStageCoordinates", "Style": "points", "MarkerType": "OpenQuadStar"},
        container=None,
        points=points,
        labels=labels,
    )
    n = mien.nmpml.elements["NmpmlDocument"](attribs={"Name": "Doc"}, tag="NmpmlDocument")
    n.newElement(fed)
    return n
Example #8
0
## You should have received a copy of the GNU General Public License along with 
## this program; if not, write to the Free Software Foundation, Inc., 59 Temple 
## Place, Suite 330, Boston, MA 02111-1307 USA
## 
from mien.math.array import array,zeros,Float32

######### Spike Wave Forms =========

SPIKE10_3={'tmin': 0.0009, 'rp':-61.0,'decay': -192151.25, 'attack': 145800.75, 'height': 76.813189999999992, 'width': 0.00050000000000000001, 'depth': 4.604920000000007, 'zc1': 0.0005, 'ahprec': -63.936369999999997, 'wave': array([  0.54263 ,   0.56312 ,   0.58361 ,   0.619675,   0.65574 ,
         0.68033 ,   0.70492 ,   0.749185,   0.79345 ,   0.8664  ,
         0.93935 ,   1.15738 ,   1.37541 ,   3.47299 ,   6.10088 ,
        11.62651 ,  19.49572 ,  35.26103 ,  56.1815  ,  72.74056 ,
        76.81319 ,  76.12871 ,  72.58464 ,  64.29499 ,  48.45283 ,
        27.14701 ,  17.2904  ,  10.02258 ,   5.39836 ,   2.794265,
         0.19017 ,  -1.19344 ,  -2.57705 ,  -3.25246 ,  -3.92787 ,
        -4.19672 ,  -4.46557 ,  -4.535245,  -4.60492 ,  -4.56803 ,
        -4.53114 ,  -4.430325,  -4.32951 ,  -4.208195,  -4.08688 ,
        -3.929505,  -3.77213 ,  -3.633605,  -3.49508 ,  -3.34508 ,
        -3.19508 ,  -3.04836 ,  -2.90164 ,  -2.77705 ,  -2.65246 ,
        -2.535245,  -2.41803 ,  -2.300815,  -2.1836  ,  -2.079505,
        -1.97541 ,  -1.854095,  -1.73278 ,  -1.64262 ,  -1.55246 ,
        -1.47623 ,  -1.4     ,  -1.31967 ,  -1.23934 ,  -1.174585,
        -1.10983 ,  -1.047535,  -0.98524 ,  -0.9336  ,  -0.88196 ,
        -0.83606 ,  -0.79016 ,  -0.74098 ,  -0.6918  ,  -0.654915]), 't': 0.0043}
#used rp= -61.75276999, t1=-41.75, t2=-21.75

BLANKSPIKE ={'tmin': 0.004, 'decay':0, 'attack': 0, 'height': 0, 'width': 0.004, 'depth': 0, 'zc1': 0.004, 'ahprec': 0, 'wave': zeros(80, Float32), 't': 0.0043, 'rp':0}

######### Bode Plots (input and transfer)
#first sample at 1Hz, sampzed every 4 Hz, last sample at 357Hz, first col is amp, second is phase

BODE10_3SOMARin=array([[ 10.        ,  -0.120411  ],
Example #9
0
## 
## This program is distributed in the hope that it will be useful, but WITHOUT ANY 
## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
## PARTICULAR PURPOSE. See the GNU General Public License for more details.
## 
## You should have received a copy of the GNU General Public License along with 
## this program; if not, write to the Free Software Foundation, Inc., 59 Temple 
## Place, Suite 330, Boston, MA 02111-1307 USA
## 

from mien.math.array import nonzero1d, zeros, Float32, array, reshape
import mien.parsers.nmpml

EDGE=4.2
EXTENT=(100,100,100)
ORIGIN=array((-161.89,-298.07,-131.32))


def writeDensityFile(of, a,  **kwargs):
	thresh=kwargs.get('thresh', .000001)
	norm=kwargs.get('norm', None)
	of.write("%.6g  #Max Density\n" % a.max())
	of.write("0  #Directional tuning (meaningless)\n")
	if norm:
		a=a*norm*(1.0/a.max())
	if thresh:
		nz=nonzero1d(a>thresh*a.max())
		#print nz[0].min(), nz[0].max()
		#print nz[1].min(), nz[1].max()
		#print nz[2].min(), nz[2].max()
		xr=range(nz[0].min(), nz[0].max())