예제 #1
0
파일: viewpoints.py 프로젝트: gic888/MIEN
def viewGroup(cv):
	try:
		vg=cv.document.getInstance('/Data:CVViewpoints')
	except StandardError:
		vg=addPath(cv.document, '/Data:CVViewpoints')
		vg.datinit(None, {'SampleTye':'group'})
	return vg
예제 #2
0
파일: imagetools.py 프로젝트: gic888/MIEN
def setImageData(dat, path, doc, h=None, replace=1):
	'''Sets the image data in the element at path, in doc, to dat. If h is specified, sets the header also to contain the header information in h. If replace is 1 (default), reinitializes an existing element at the path. If it is 2, hard deletes any such element. If it is 0, changes path to be unique, so nothing is ever overwritten. If path doesn't include a colon, it is changed to "/Data:path (e.g. it is treated as "name" and the element is assumed to be at the top level in the document). '''
	if not ":" in path:
		path="/Data:"+path	
	if replace==1:
		e=forceGetPath(doc, path)
	else:
		e=addPath(doc, path, replace)
	dat, h=imageShape(dat, h)
	e.datinit(dat, h)
예제 #3
0
파일: viewpoints.py 프로젝트: gic888/MIEN
def selectView(cv):
	vg=viewGroup(cv)
	pv = vg.getElements('Data', {'SampleType':'CVViewpoint'}, depth=1)
	pvn= [d.name() for d in pv]
	if not pvn:
		cv.report('no saved viewpoints. Using current view')
		vp=getCurrentVP(cv)
		dv=addPath(cv.document, '/Data:CVViewpoints/Data:ViewPoint')
		dv.datinit(vp, {'SampleType':'CVViewpoint'})
		return dv
	if len(pvn)==1:
		return pv[0]
	d=cv.askParam([{'Name':'Which Viewpoint', 'Type':'List', 'Value':pvn}])
	if not d:
		return
	return vg.getElements('Data', d[0], depth=1)[0]
예제 #4
0
def getTests(dsheet=None):
	cells = getDsheet(dsheet)
	files = {}
	for c in cells:
		etrack = c[ mouseNoLab]
		mouse = numOrRan(etrack)[0]
		dfpath = os.path.join(basedir, pathprefix+str(mouse), pathprefix +etrack)
		pstpath = os.path.join(dfpath, pathprefix + etrack + '.pst')
		if os.path.isfile(pstpath):
			print "found data for cell %s" % c[cellIdLab]
			if not pstpath in files:
				files[pstpath] = []
			files[pstpath].append(c)
		else:
			print "No data for %s, %s" % (c[cellIdLab], pstpath)
	doc = nmp.blankDocument()		
	for fn in files:
		pstmeta, tests = parsePST.parse(fn)
		pstmeta[1] = 'Date: ' +  pstmeta[1]
		for c in files[fn]:
			dat = nmp.addPath(doc, "/Data:Cell%s" % c[cellIdLab])
			dat.setAttrib('SampleType', "group")
			for k in c:
				safek = k.replace('#','Num').replace(' ', '_').replace('+', 'and').replace('?', '')
				dat.setAttrib(safek, c[k])
			dat.setAttrib('ExperimentMetaData', pstmeta)
			dat.setAttrib('RawTraceFilename', fn[:-4] + '.raw')
			for i, t in enumerate(c[testLab]):
				tids = numOrRan(t)
				for tid in tids:
					test = tests[tid-1]
					drug = bool(c[conditionLab][i]=='yes')
					tdat = nmp.createElement('Data', {'Name':'Test%i' % tid,'SampleType':'group', 'Drug':drug})
					for k in test:
						if not k == 'traces':
							tdat.setAttrib(k, test[k])
					dat.newElement(tdat)
					addTraces(tdat, test['traces'], drug)
	return doc
예제 #5
0
파일: call.py 프로젝트: gic888/mienblocks
def read(f, **kw):
    a = reshape(fromstring(f.read(), int16), (-1, 1))
    d = nmp.blankDocument()
    dat = nmp.addPath(d, "/Data:call")
    dat.datinit(a, {"SampleType": "timeseries", "SamplesPerSecond": 40000.0})
    return d