Exemplo n.º 1
0
def test_clean_removes_thumbnails():
    """parserix.clean removes thumbnail images"""
    cleaned_up = clean.clean(test_paths)
    for line in cleaned_up:
        assert "thumb" not in line
    cleaned_up_new = clean.clean(new_test_paths)
    for line in cleaned_up_new:
        assert "thumb" not in line
Exemplo n.º 2
0
from parserix import clean
from parserix import parse
import datetime
import pytest
import os

test_list_path = os.path.join(os.path.abspath("tests"), "images.txt")
new_test_list_path = os.path.join(os.path.abspath("tests"), "new_images.txt")

test_paths = [line.strip() for line in open(test_list_path)]
new_test_paths = [line.strip() for line in open(new_test_list_path)]

# remove rubbish mixed in with file paths
clean_paths = clean.clean(test_paths)
new_clean_paths = clean.clean(new_test_paths)

EXAMPLE_PATH = "/mnt/ImageXpress/2015-07-31 val screen/val screen/HCC15691/2015-07-31/4014/val screen_B02_s1_w1_thumb62D4A363-7C7E-40D0-8A9E-55EC6681574D.tif"
NEW_EXAMPLE_PATH = "/mnt/Datastore/IGMM/ImageXpress2020/drug-discovery/GCGR-FDA/E13FDAa1/2021-04-03/490/TimePoint_1/val screen_B02_s1_w1_thumb62D4A363-7C7E-40D0-8A9E-55EC6681574D.tif"


def test_img_filename():
    expected = "val screen_B02_s1_w1_thumb62D4A363-7C7E-40D0-8A9E-55EC6681574D.tif"
    assert parse.img_filename(EXAMPLE_PATH) == expected
    assert parse.img_filename(NEW_EXAMPLE_PATH) == expected


def test_path():
    assert parse.path(
        EXAMPLE_PATH
    ) == "/mnt/ImageXpress/2015-07-31 val screen/val screen/HCC15691/2015-07-31/4014"
    assert parse.path(
Exemplo n.º 3
0
"""
tests for nncell.image_prep
"""
import os
from nncell import image_prep
from parserix import parse
from parserix import clean
import numpy as np
import pytest

# sort out data for tests
TEST_DIR = os.path.abspath("tests")
PATH_TO_IMG_URLS = os.path.join(TEST_DIR, "test_images/images.txt")
IMG_URLS = clean.clean([i.strip() for i in open(PATH_TO_IMG_URLS).readlines()])

#####################################
# ImageDict tests
#####################################


def test_ImageDict_remove_channels():
    channels_to_remove = [4, 5]
    ImgDict = image_prep.ImageDict()
    ans = ImgDict.remove_channels(IMG_URLS, channels_to_remove)
    # parse channel numbers out of ans
    img_names = [parse.img_filename(f) for f in ans]
    img_channels = [parse.img_channel(name) for name in img_names]
    for channel in img_channels:
        assert channel not in channels_to_remove

Exemplo n.º 4
0
def test_clean_removes_db_files():
    """parserix.clean removes Thumbs.db file left by windows"""
    cleaned_up = clean.clean(test_paths)
    assert "Thumbs.db" not in cleaned_up
    cleaned_up_new = clean.clean(new_test_paths)
    assert "Thumbs.db" not in cleaned_up_new
Exemplo n.º 5
0
def test_clean_removes_something():
    """clean actually removes something"""
    assert len(test_paths) > len(clean.clean(test_paths))
    assert len(new_test_paths) > len(clean.clean(new_test_paths))