def test_nss(self): fm = fixmat.TestFixmatFactory(points=zip([0,500,1000],[1,10,10]), params = {'image_size':[100,10]}) fm.SUBJECTINDEX = np.array([1,1,1]) fm.filenumber = np.array([1,1,1]) fm.category = np.array([1,1,1]) fm.x = np.array([0,50,1000]) fm.y = np.array([1,10,10]) fm.fix = np.array([1,2,3]) fm._num_fix = 3 fdm = fixmat.compute_fdm(fm[(fm.x<10) & (fm.y<10)]) self.assertRaises(IndexError, lambda: measures.nss(fdm, (fm.y, fm.x)))
def test_nss_values(self): fm = fixmat.TestFixmatFactory(categories = [1,2,3], filenumbers = [1,2,3,4,5,6], subjectindices = [1, 2, 3, 4, 5, 6], params = {'pixels_per_degree':0.1, 'image_size':[200,500]}) # Arr has zero variance, should return nan arr = np.ones(fm.image_size) nss = measures.nss_model(arr, fm) self.assertTrue(np.isnan(nss)) # With itself should yield a high value fdm = fixmat.compute_fdm(fm) nss = measures.nss_model(fdm, fm) self.assertTrue(nss>15) # Fixations at these locations should give nss < 0 nss = measures.nss(fdm, [[100, 101, 102, 103, 104, 105],[0, 0, 0, 0, 0, 0]]) self.assertTrue(nss < 0)