def test_group_can_select_channel_nested(self):

        tempdir = self.tempdir

        d1 = tempdir / 'TL Brightfield' / 's04'
        d2 = tempdir / 'TL Brightfield' / 's03'
        d3 = tempdir / 'mCherry' / 's04'
        d4 = tempdir / 'mCherry' / 's05'
        d1.mkdir(parents=True)
        d2.mkdir(parents=True)
        d3.mkdir(parents=True)
        d4.mkdir(parents=True)

        f1 = d1 / 'TL Brightfield-s04t045.tif'
        f2 = d2 / 'TL Brightfield-s03t045.tif'
        f3 = d3 / 'mCherry-s04t046.tif'
        f4 = d4 / 'mCherry-s05t046.tif'
        f1.touch()
        f2.touch()
        f3.touch()
        f4.touch()

        res = utils.group_image_files(tempdir, mode='nested', channel='brightfield')
        exp = utils.TileGroup()
        exp.extend([f1, f2])

        self.assertEqual(res, exp)

        res = utils.group_image_files(tempdir, mode='nested', channel='mcherry')
        exp = utils.TileGroup()
        exp.extend([f3, f4])

        self.assertEqual(res, exp)
    def test_group_single_tile_multi_channel_flat(self):

        tempdir = self.tempdir

        f1 = tempdir / 'TL Brightfield-s04t045.tif'
        f2 = tempdir / 'mCherry-s04t046.tif'
        f1.touch()
        f2.touch()

        res = utils.group_image_files(tempdir, mode='flat')
        exp = utils.TileGroup()
        exp.extend([f1, f2])

        self.assertEqual(res, exp)
    def test_group_can_select_channel_flat(self):

        tempdir = self.tempdir

        f1 = tempdir / 'TL Brightfield-s04t045.tif'
        f2 = tempdir / 'TL Brightfield-s03t045.tif'
        f3 = tempdir / 'mCherry-s04t046.tif'
        f4 = tempdir / 'mCherry-s05t046.tif'
        f1.touch()
        f2.touch()
        f3.touch()
        f4.touch()

        res = utils.group_image_files(tempdir, mode='flat', channel='brightfield')
        exp = utils.TileGroup()
        exp.extend([f1, f2])

        self.assertEqual(res, exp)

        res = utils.group_image_files(tempdir, mode='flat', channel='mcherry')
        exp = utils.TileGroup()
        exp.extend([f3, f4])

        self.assertEqual(res, exp)
    def test_group_single_tile_single_channel_nested(self):

        tempdir = self.tempdir
        d1 = tempdir / 'TL Brightfield' / 's04'
        d1.mkdir(parents=True)

        f1 = d1 / 'TL Brightfield-s04t045.tif'
        f2 = d1 / 'TL Brightfield-s04t046.tif'
        f1.touch()
        f2.touch()

        res = utils.group_image_files(tempdir, mode='nested')
        exp = utils.TileGroup()
        exp.extend([f1, f2])

        self.assertEqual(res, exp)