Skip to content

Commit

Permalink
updated, passing tests. Updated version to 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
skim2257 committed Jun 22, 2022
1 parent 13f90fd commit 81d6795
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

setup(
name="med-imagetools",
version="0.2.3",
author="Michal Kazmierski, Sejin Kim, Vishwesh Ramanathan, Benjamin Haibe-Kains",
version="0.4",
author="Michal Kazmierski, Sejin Kim, Kevin Qu, Vishwesh Ramanathan, Benjamin Haibe-Kains",
author_email="benjamin.haibe.kains@utoronto.ca",
description="Transparent and reproducible image processing pipelines in Python.",
long_description=long_description,
Expand All @@ -20,7 +20,7 @@
extras_require={
'debug': ['pyvis'],
},
entry_points={'console_scripts': ['autopipe = imgtools.autopipeline:main', 'autotest = imgtools.autonew:main']},
entry_points={'console_scripts': ['autopipeline = imgtools.autopipeline:main',]},
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_modalities.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def modalities_path():
path["PT"] = pathlib.Path(qc_path, "08-27-1885-CA ORL FDG TEP POS TX-94629/532790.000000-LOR-RAMLA-44600").as_posix()
return path

@pytest.mark.parametrize("modalities", ["RTDOSE"])#["CT", "RTSTRUCT", "RTDOSE", "PT"])
@pytest.mark.parametrize("modalities", ["CT", "RTSTRUCT", "RTDOSE", "PT"])
def test_modalities(modalities, modalities_path):
path = modalities_path
img = read_dicom_auto(path["CT"]).image
Expand Down
17 changes: 11 additions & 6 deletions tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ def test_output(n_jobs, sample_input_output):
pipeline = SimplePipelineTest(input_paths[0], output_paths[0], n_jobs)
pipeline.run()

for input_file, output_file in zip(os.scandir(input_paths[0]), os.scandir(output_paths[0])):
assert os.path.exists(output_file.path)
test_output = sitk.GetArrayFromImage(sitk.ReadImage(output_file.path))
true_output = sitk.GetArrayFromImage(sitk.ReadImage(input_file.path))
input_dir, output_dir = input_paths[0], output_paths[0]

for input_file, output_file in zip(sorted(os.listdir(input_dir)), sorted(os.listdir(output_dir))):
assert os.path.exists(pathlib.Path(output_dir, output_file))
test_output = sitk.GetArrayFromImage(sitk.ReadImage(pathlib.Path(output_dir, output_file).as_posix()))
true_output = sitk.GetArrayFromImage(sitk.ReadImage(pathlib.Path(input_dir, input_file).as_posix()))
assert np.allclose(test_output, true_output)
print('passed assert')


class MultiInputPipelineTest(Pipeline):
Expand Down Expand Up @@ -97,6 +100,7 @@ def test_missing_handling(n_jobs, missing_strategy, sample_input_output):
input_paths, output_paths = sample_input_output
# simulate partial missing data
os.remove(pathlib.Path(input_paths[0], "test0.nrrd").as_posix())
print(input_paths, output_paths)

pipeline = MultiInputPipelineTest(input_paths[0],
input_paths[1],
Expand All @@ -109,15 +113,16 @@ def test_missing_handling(n_jobs, missing_strategy, sample_input_output):
assert len(w) == 1
assert missing_strategy in str(w[-1].message)

print(os.listdir(input_paths[1]), os.listdir(output_paths[1]))
if missing_strategy == "drop":
assert all([
not os.path.exists(pathlib.Path(output_paths[0], "test0.nrrd").as_posix()),
not os.path.exists(pathlib.Path(output_paths[1], "test0.nrrd").as_posix())
])
else:
assert all([
not os.path.exists(pathlib.Path(output_paths[0], "test0.nrrd").as_posix()),
os.path.exists(pathlib.Path(output_paths[1], "test0.nrrd").as_posix())
not os.path.exists(pathlib.Path(output_paths[0], "test0.nii.gz").as_posix()),
os.path.exists(pathlib.Path(output_paths[1], "test0.nii.gz").as_posix())
])


Expand Down

0 comments on commit 81d6795

Please sign in to comment.