def test_info_html_table(self):
        from jicbioimage.core.image import MicroscopyImage
        microscopy_image = MicroscopyImage('dummy.tif',
            dict(series=0, channel=1, zslice=2, timepoint=3))
        self.assertEqual(
            microscopy_image.__info_html_table__(30).strip().replace(' ', ''),
'''
<table>
    <tr>
        <th>Index</th>
        <th>Series</th>
        <th>Channel</th>
        <th>Z-slice</th>
        <th>Time point</th>
    </tr>
    <tr>
        <td>30</td>
        <td>0</td>
        <td>1</td>
        <td>2</td>
        <td>3</td>
    </tr>
</table>
'''.strip().replace(' ', '')
        ) 
Esempio n. 2
0
    def test_proxy_image(self):
        from jicbioimage.core.image import MicroscopyCollection, MicroscopyImage
        microscopy_collection = MicroscopyCollection()
        microscopy_collection.append(
            MicroscopyImage('test0.tif',
                            dict(series=0, channel=0, zslice=0, timepoint=0)))
        microscopy_collection.append(
            MicroscopyImage('test1.tif',
                            dict(series=1, channel=1, zslice=1, timepoint=1)))

        proxy_image = microscopy_collection.proxy_image()
        self.assertEqual(proxy_image.fpath, 'test0.tif')

        proxy_image = microscopy_collection.proxy_image(s=1, c=1, z=1, t=1)
        self.assertEqual(proxy_image.fpath, 'test1.tif')
Esempio n. 3
0
 def test_repr(self):
     from jicbioimage.core.image import MicroscopyImage
     microscopy_image = MicroscopyImage(
         'dummy.tif', dict(series=0, channel=1, zslice=2, timepoint=3))
     self.assertEqual(
         repr(microscopy_image),
         '<MicroscopyImage(s=0, c=1, z=2, t=3) object at {}>'.format(
             hex(id(microscopy_image))))
Esempio n. 4
0
 def test_instantiation(self):
     from jicbioimage.core.image import MicroscopyImage
     microscopy_image = MicroscopyImage(
         'dummy.tif', dict(series=0, channel=1, zslice=2, timepoint=3))
     self.assertEqual(microscopy_image.fpath, 'dummy.tif')
     self.assertEqual(microscopy_image.series, 0)
     self.assertEqual(microscopy_image.channel, 1)
     self.assertEqual(microscopy_image.zslice, 2)
     self.assertEqual(microscopy_image.timepoint, 3)
Esempio n. 5
0
    def test_manifest_data(self):
        from jicbioimage.core.image import MicroscopyCollection, MicroscopyImage
        microscopy_collection = MicroscopyCollection()
        microscopy_collection.append(
            MicroscopyImage('test0.tif',
                            dict(series=0, channel=0, zslice=0, timepoint=0)))
        microscopy_collection.append(
            MicroscopyImage('test0.tif',
                            dict(series=0, channel=1, zslice=2, timepoint=3)))
        microscopy_collection.append(
            MicroscopyImage('test1.tif',
                            dict(series=1, channel=2, zslice=3, timepoint=4)))

        self.assertEqual(microscopy_collection.series, [0, 1])
        self.assertEqual(microscopy_collection.channels(), [0, 1])
        self.assertEqual(microscopy_collection.channels(s=1), [2])
        self.assertEqual(microscopy_collection.zslices(), [0, 2])
        self.assertEqual(microscopy_collection.zslices(s=1), [3])
        self.assertEqual(microscopy_collection.timepoints(), [0, 3])
        self.assertEqual(microscopy_collection.timepoints(s=1), [4])
Esempio n. 6
0
    def test_info_html_table(self):
        from jicbioimage.core.image import MicroscopyImage
        microscopy_image = MicroscopyImage(
            'dummy.tif', dict(series=0, channel=1, zslice=2, timepoint=3))
        self.assertEqual(
            microscopy_image.__info_html_table__(30).strip().replace(' ', ''),
            '''
<table>
    <tr>
        <th>Index</th>
        <th>Series</th>
        <th>Channel</th>
        <th>Z-slice</th>
        <th>Time point</th>
    </tr>
    <tr>
        <td>30</td>
        <td>0</td>
        <td>1</td>
        <td>2</td>
        <td>3</td>
    </tr>
</table>
'''.strip().replace(' ', ''))
Esempio n. 7
0
    def test_repr_html(self):
        from jicbioimage.core.image import MicroscopyCollection, MicroscopyImage, Image
        microscopy_collection = MicroscopyCollection()
        image = Image((50, 50))
        image.png = MagicMock(
            return_value=bytearray('image', encoding='utf-8'))
        with patch('jicbioimage.core.image.Image.from_file',
                   return_value=image) as patched_image:
            microscopy_collection.append(
                MicroscopyImage(
                    'test0.tif',
                    dict(series=1, channel=2, zslice=3, timepoint=4)))
            html = microscopy_collection._repr_html_()
            self.assertEqual(
                html.strip().replace(' ', '').replace('\n', ''), '''
<div style="float: left; padding: 2px;" >
    <p>
        <table>
            <tr>
                <th>Index</th>
                <th>Series</th>
                <th>Channel</th>
                <th>Z-slice</th>
                <th>Time point</th>
            </tr>
            <tr>
                <td>0</td>
                <td>1</td>
                <td>2</td>
                <td>3</td>
                <td>4</td>
            </tr>
        </table>
    </p>
    <img style="margin-left: auto; margin-right: auto;" src="data:image/png;base64,aW1hZ2U=" />
</div>
'''.strip().replace(' ', '').replace('\n', ''))
 def test_repr_png_return_type(self):
     from jicbioimage.core.image import MicroscopyImage
     fpath = os.path.join(DATA_DIR, 'tjelvar.png')
     microscopy_image = MicroscopyImage(
         fpath, dict(series=0, channel=0, zslice=0, timepoint=0))
     self.assertEqual(type(microscopy_image._repr_png_()), bytes)
 def test_in_zstack(self):
     from jicbioimage.core.image import MicroscopyImage
     microscopy_image = MicroscopyImage('dummy.tif',
         dict(series=0, channel=1, zslice=2, timepoint=3))
     self.assertTrue(microscopy_image.in_zstack(s=0, c=1, t=3))
     self.assertFalse(microscopy_image.in_zstack(s=5, c=1, t=3))
 def test_repr_png_return_type(self):
     from jicbioimage.core.image import MicroscopyImage
     fpath = os.path.join(DATA_DIR, 'tjelvar.png')
     microscopy_image = MicroscopyImage(fpath,
         dict(series=0, channel=0, zslice=0, timepoint=0))
     self.assertEqual(type(microscopy_image._repr_png_()), bytes)
Esempio n. 11
0
 def test_in_zstack(self):
     from jicbioimage.core.image import MicroscopyImage
     microscopy_image = MicroscopyImage(
         'dummy.tif', dict(series=0, channel=1, zslice=2, timepoint=3))
     self.assertTrue(microscopy_image.in_zstack(s=0, c=1, t=3))
     self.assertFalse(microscopy_image.in_zstack(s=5, c=1, t=3))