File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import pytest
2+ import itk
3+ import urllib .request
4+ import numpy as np
5+ from itk import PCT as pct
6+
7+
8+ def download_file_fixture (file_key , filename ):
9+
10+ @pytest .fixture (scope = "session" )
11+ def fixture (tmp_path_factory ):
12+ path = tmp_path_factory .getbasetemp () / filename
13+ url = f"https://data.kitware.com/api/v1/file/{ file_key } /download"
14+ with urllib .request .urlopen (url ) as response , open (path , "wb" ) as out_file :
15+ out_file .write (response .read ())
16+ return path
17+
18+ return fixture
19+
20+
21+ phasespacein_root = download_file_fixture (
22+ "69cbef28303cec2e64feb78a" , "PhaseSpaceIn.root"
23+ )
24+ phasespaceout_root = download_file_fixture (
25+ "69cbef2a303cec2e64feb78d" , "PhaseSpaceOut.root"
26+ )
27+ baseline_pairs_mhd = download_file_fixture ("69cbefdf303cec2e64feb790" , "pairs0000.mhd" )
28+ baseline_pairs_raw = download_file_fixture ("69cbefe0303cec2e64feb793" , "pairs0000.raw" )
29+
30+
31+ def test_pairprotons_application (
32+ tmp_path ,
33+ phasespacein_root ,
34+ phasespaceout_root ,
35+ baseline_pairs_mhd ,
36+ baseline_pairs_raw ,
37+ ):
38+ output = tmp_path / "pairs_test.mhd"
39+ pct .pctpairprotons (
40+ f"-i { phasespacein_root } -j { phasespaceout_root } -o { output } --plane-in -110 --plane-out 110 --psin PhaseSpaceIn --psout PhaseSpaceOut"
41+ )
42+ output0000 = tmp_path / "pairs_test0000.mhd"
43+ pairs_test = itk .array_from_image (itk .imread (output0000 ))
44+ pairs_baseline = itk .array_from_image (itk .imread (baseline_pairs_mhd ))
45+ assert np .array_equal (pairs_test , pairs_baseline )
You can’t perform that action at this time.
0 commit comments