```from rsfproj import * n1 = 100 thr = 2 min = -3 max = 3 def mygraph(title): return ''' graph title="%s" min2=%f max2=%f ''' %(title,min,max) # DEFINITIONS # Create range and threshold level Flow('range',None, ''' math n1=%f n2=1 output="%f+(%f-%f)/(%f-1)*x1" ''' %(n1,min,max,min,n1) ) Flow('thrpos',None,'math n1=%f n2=1 output="%f" ' %(n1,thr) ) Flow('thrneg',None,'math n1=%f n2=1 output="%f" ' %(n1,-thr) ) # Thresholding ## Soft Flow('soft','range','thr thr=%f' % thr) ## Hard Flow('hard','range','thr thr=%f mode=hard' % thr) ## NNG Flow('nng','range','thr thr=%f mode=nng' % thr) # Plots Plot('range',mygraph("Data with threshold level") ) Plot('thrpos',mygraph(" ") + 'dash=1') Plot('thrneg',mygraph(" ") + 'dash=1') Result('data','range thrpos thrneg','Overlay') Result('soft',mygraph("Soft thresholded data") ) Result('hard',mygraph("Hard thresholded data") ) Result('nng',mygraph("NNG thresholded data") ) # EXAMPLE 1 # Create data Flow('data',None, ''' math n1=%f n2=1 output="1" | noise rep=y ''' % n1 ) # Thresholding ## Soft Flow('res1','data','thr thr=%f' % thr) ## Hard Flow('res4','data','thr thr=%f mode=hard' % thr) ## NNG Flow('res5','data','thr thr=%f mode=nng' % thr) # Plots Plot('data',mygraph("Data with threshold level") ) Result('data1','data thrpos thrneg','Overlay') Result('soft1','res1',mygraph("Soft thresholded data") ) Result('hard1','res4',mygraph("Hard thresholded data") ) Result('nng1','res5',mygraph("NNG thresholded data") ) End()```