Esempio n. 1
0
 def test_Read_ExportElan_Read(self):
     tg1 = Antx()
     tg1.read(os.path.join(SAMPLES, "Example_with_TGA.antx"))
     annotationdata.io.write( os.path.join(SAMPLES, "Example.eaf"), tg1 )
     tg2 = Elan()
     tg2.read(os.path.join(SAMPLES, "Example.eaf"))
     os.remove( os.path.join(SAMPLES, "Example.eaf") )
Esempio n. 2
0
    def test_Read_Write_Read(self):
        tg1 = Elan()
        tg2 = Elan()
        tg1.read(os.path.join(SAMPLES,"sample.eaf"))
        tg1.write(os.path.join(SAMPLES,"sample2.eaf"))
        tg2.read(os.path.join(SAMPLES,"sample2.eaf"))

        # Compare annotations of tg1 and tg2
        for t1, t2 in zip(tg1, tg2):
            self.assertEqual(t1.GetSize(), t2.GetSize())
            self.assertEqual(t1.GetName(), t2.GetName())
            for a1, a2 in zip(t1, t2):
                self.assertEqual(a1.GetLabel().GetValue(),    a2.GetLabel().GetValue())
                self.assertEqual(a1.GetLocation().GetBegin(), a2.GetLocation().GetBegin())
                self.assertEqual(a1.GetLocation().GetEnd(),   a2.GetLocation().GetEnd())
        # Compare media

        # Compare controlled vocabularies
        for t1, t2 in zip(tg1, tg2):
            ctrl1 = t1.GetCtrlVocab() # a CtrlVocab() instance or None
            ctrl2 = t2.GetCtrlVocab() # a CtrlVocab() instance or None
            if ctrl1 is None and ctrl2 is None:
                continue
            self.assertEqual(ctrl1.GetSize(), ctrl2.GetSize())
            for entry in ctrl1:
                self.assertTrue(ctrl2.Contains(entry.Text))

        os.remove( os.path.join(SAMPLES, "sample2.eaf") )
Esempio n. 3
0
    def test_Import_XRA(self):
        tg1 = annotationdata.io.read(os.path.join(XRADEF, "sample-1.2.xra"))
        annotationdata.io.write(os.path.join(SAMPLES,"sample-1.2.eaf"),tg1)
        tg2 = Elan()
        tg2.read(os.path.join(SAMPLES, "sample-1.2.eaf"))
        annotationdata.io.write(os.path.join(SAMPLES,"sample-1.2.xra"),tg2)

        # Compare annotations of tg1 and tg2
        for t1, t2 in zip(tg1, tg2):
            self.assertEqual(t1.GetSize(), t2.GetSize())
            self.assertEqual(t1.GetName(), t2.GetName())
            for a1, a2 in zip(t1, t2):
                self.assertEqual(a1.GetLabel().GetValue(), a2.GetLabel().GetValue())
                if t1.IsInterval():
                    self.assertEqual(a1.GetLocation().GetBegin(), a2.GetLocation().GetBegin())
                    self.assertEqual(a1.GetLocation().GetEnd(),   a2.GetLocation().GetEnd())
                else:
                    # Elan uses milliseconds.
                    # ELAN radius is 0.02 seconds
                    p = round( a1.GetLocation().GetPoint().GetMidpoint()-0.02, 3)
                    self.assertEqual(p, round(a2.GetLocation().GetBegin().GetMidpoint(),3))

        os.remove( os.path.join(SAMPLES, "sample-1.2.xra") )
        os.remove( os.path.join(SAMPLES, "sample-1.2.eaf") )