예제 #1
0
파일: sorter.py 프로젝트: gic888/mienblocks
def precondition(ds, ct, report=report):
	if ct.attrib('zeroMean'):
		zeromean(ds)
		report('removed means')
	if ct.attrib('zeroStart'):
		ds.setAttrib('StartTime', 0.0)
		report('set 0 start time')
	if ct.attrib('normalize'):
		nv=ds.data.std()
		normalize(ds, mode='std', normVal=nv)
		report('noise normalized')
	if ct.attrib('stimulus'):
		schan=ct.attrib('stimulus')
		subdata.extract(ds, (None, schan , None), "/hidden/stimulus", delete=True)
		report("Channels %s copied to stimulus" % (str(schan),))
	if ct.attrib('deleted'):
		kill=[ct.attrib('deleted')]
		delChans(ds, kill[0])
		report("Deleted channels %s" % (str(kill),))	
예제 #2
0
def setTestData(ds, xindexStart=70, xindexStop=100, percent=True):
	'''Sets all data between the indicated indexes for use as validation data. These data are extracted from "/" and stored in "/testdata". In addition, for every "events" or "labeledevents" element at nesting level 1 the same set of indexes are extracted and stored in sub-elements of "/testdata". Essentially, this is a macro around 2 or more calls to subdata.extract. If percent is set to true, the values of the xindex parameters are treated as percentages of the total length of the data rather than integer indexes.
	
	SWITCHVALUES(percent)=[True, False]'''
	if percent:
		l=ds.getData().shape[0]
		xindexStart=int(l*xindexStart/100.0)
		if xindexStop in [':', None, 100]:
			xindexStop=l
		else:	
			xindexStop=int(l*xindexStop/100.0)
	import mien.dsp.subdata as sd
	sd.extract(ds, (None, None, (xindexStart, xindexStop)), "/testdata", True)
	d1d=ds.getElements('Data', depth=1)
	e1d=[d for d in d1d if isSampledType(d)=='e']
	for e in e1d:
		op=e.dpath()
		np="/testdata"+op
		sd.extract(ds, (op, None, (xindexStart, xindexStop)), np, True)
	return ds