def test_no_rootdir(self):
        inpath = self.tempdir / 'foo/bar'
        inpath.mkdir(parents=True)

        res = utils.get_rootdir(inpath)

        self.assertIsNone(res)
    def test_gets_rootdir_from_channeldir(self):
        rootdir = self.tempdir / 'foo/bar/2017-02-12'
        rootdir.mkdir(parents=True)

        inpath = rootdir / 'EGFP/'

        res = utils.get_rootdir(inpath)
        self.assertEqual(res, rootdir)
    def test_gets_rootdir_from_imagefile(self):
        rootdir = self.tempdir / 'foo/bar/2017-02-12'
        rootdir.mkdir(parents=True)

        inpath = rootdir / 'EGFP/s04-bees/foo-s04t003.tif'

        res = utils.get_rootdir(inpath)
        self.assertEqual(res, rootdir)
    def test_ignores_non_existant_rootdir(self):

        rootdir = self.tempdir / 'foo/bar/2017-02-12'
        self.assertFalse(rootdir.is_dir())

        inpath = rootdir / 'EGFP/'

        res = utils.get_rootdir(inpath)
        self.assertIsNone(res)
    def test_ignores_weird_rootdir(self):

        rootdir = self.tempdir / 'foo/bar/2017-02-12-bees'
        rootdir.mkdir(parents=True)

        inpath = rootdir / 'EGFP/'

        res = utils.get_rootdir(inpath)
        self.assertIsNone(res)
    def test_gets_rootdir_from_imagefile_config_file(self):
        rootdir = self.tempdir / 'foo/bar/baz'
        rootdir.mkdir(parents=True)

        (rootdir / 'deep_tracking.ini').touch()
        inpath = rootdir / 'EGFP/s04-bees/foo-s04t003.tif'

        res = utils.get_rootdir(inpath)
        self.assertEqual(res, rootdir)
Esempio n. 7
0
def get_names_for_plots(image_file: pathlib.Path,
                        plotdir: Optional[pathlib.Path] = None):
    """ Get the names for the plotfile

    :param Path image_file:
        The image to evaluate
    :param Path plotdir:
        The directory to save plots to
    :returns:
        A tuple of plotfile, pointfile, response_file
    """

    if plotdir is None:
        rootdir = get_rootdir(image_file)
        plotrel = image_file.relative_to(rootdir)
        plotdir = rootdir / 'SingleCell' / plotrel.parent

    plotfile = plotdir / (image_file.stem + '.png')
    response_file = plotdir / (image_file.stem + '_resp.png')
    pointfile = plotdir / (image_file.stem + '.csv')
    return plotfile, pointfile, response_file
    def test_gets_rootdir_from_rootdir(self):
        inpath = self.tempdir / 'foo/bar/2017-02-12'
        inpath.mkdir(parents=True)

        res = utils.get_rootdir(inpath)
        self.assertEqual(res, inpath)