Skip to content

Commit

Permalink
trying to sort out import issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Sep 18, 2024
1 parent 0fa9be6 commit df4e51d
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 2 deletions.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .data import get_data

__all__ = ["get_data"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import typing as ty
from pathlib import Path
import tempfile
from .header import get_image_header
from ..base import generate_raw_data


def get_data(out_dir: Path = None, **kwargs) -> ty.List[Path]:
tmp_dir = Path(tempfile.mkdtemp())
dicom_hdr_fspath = next(get_image_header(tmp_dir, **kwargs).iterdir())
return generate_raw_data(
dicom_hdr_fspath=dicom_hdr_fspath,
out_dir=out_dir,
)


Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
from medimages4tests.dummy.dicom.base import (
generate_dicom,
default_dicom_dir,
evolve_header,
)


def get_image_header(out_dir, **kwargs):
hdr = evolve_header(constant_hdr, **kwargs)
return generate_dicom(out_dir, num_vols, hdr, collated_data, {})


num_vols = 1


constant_hdr = {
"00080005": {"vr": "CS", "Value": ["ISO_IR 100"]},
"00080008": {"vr": "CS", "Value": ["ORIGINAL", "PRIMARY", "PET_CALIBRATION"]},
"00080012": {"vr": "DA", "Value": ["20230725"]},
"00080013": {"vr": "TM", "Value": ["071306.000000"]},
"00080016": {"vr": "UI", "Value": ["1.3.12.2.1107.5.9.1"]},
"00080018": {
"vr": "UI",
"Value": ["1.3.12.2.1107.5.1.4.10016.30000023072501543220300000001"],
},
"00080020": {"vr": "DA", "Value": ["20230725"]},
"00080021": {"vr": "DA", "Value": ["20230725"]},
"00080022": {"vr": "DA", "Value": ["20230725"]},
"00080030": {"vr": "TM", "Value": ["114938.720000"]},
"00080031": {"vr": "TM", "Value": ["115432.206000"]},
"00080032": {"vr": "TM", "Value": ["071306.000000"]},
"00080050": {"vr": "SH"},
"00080060": {"vr": "CS", "Value": ["PT"]},
"00080070": {"vr": "LO", "Value": ["SIEMENS"]},
"00080080": {"vr": "LO", "Value": ["An institute"]},
"00080081": {"vr": "ST", "Value": ["Address of said institute"]},
"00080090": {"vr": "PN"},
"00081010": {"vr": "SH", "Value": ["QUADRA10016"]},
"00081030": {"vr": "LO", "Value": ["Researcher^Project"]},
"0008103E": {"vr": "LO", "Value": ["PET Raw Data"]},
"00081040": {"vr": "LO", "Value": ["PET"]},
"00081090": {"vr": "LO", "Value": ["Biograph128_Vision Quadra Edge-1232"]},
"00082111": {"vr": "ST", "Value": ["PETCT"]},
"00100010": {"vr": "PN", "Value": ["FirstName^LastName"]},
"00100020": {"vr": "LO", "Value": ["Session Label"]},
"00100030": {"vr": "DA", "Value": ["19700101"]},
"00100040": {"vr": "CS", "Value": ["O"]},
"00101010": {"vr": "AS", "Value": ["053Y"]},
"00101030": {"vr": "DS", "Value": [1.27]},
"00181000": {"vr": "LO", "Value": ["10016"]},
"00181020": {"vr": "LO", "Value": ["VR20B"]},
"00181030": {"vr": "LO", "Value": ["Onco (Adult)"]},
"00181200": {"vr": "DA", "Value": ["20230725", "20230611"]},
"00181201": {"vr": "TM", "Value": ["071306.000000", "134228.000000"]},
"00185100": {"vr": "CS", "Value": ["HFS"]},
"0020000D": {
"vr": "UI",
"Value": ["1.3.12.2.1107.5.1.4.10016.30000023072501493873200000001"],
},
"0020000E": {
"vr": "UI",
"Value": ["1.3.12.2.1107.5.1.4.10016.30000023072501543220300000002"],
},
"00200010": {"vr": "SH", "Value": ["PROJECT_ID"]},
"00200011": {"vr": "IS", "Value": [602]},
"00200012": {"vr": "IS", "Value": [1]},
"00200013": {"vr": "IS", "Value": [1]},
"00200052": {
"vr": "UI",
"Value": ["1.3.12.2.1107.5.1.4.10016.30000023072501494590400000000"],
},
"00204000": {"vr": "LT", "Value": ["PET Normalization"]},
"00290010": {"vr": "LO", "Value": ["SIEMENS CSA NON-IMAGE"]},
"00290011": {"vr": "LO", "Value": ["SIEMENS CSA HEADER"]},
"00290012": {"vr": "LO", "Value": ["SIEMENS MEDCOM HEADER"]},
"00291008": {"vr": "CS", "Value": ["PET_CALIB_T"]},
"00291009": {"vr": "LO", "Value": ["1.3"]},
"00291108": {"vr": "CS", "Value": ["PET_HDR_QC"]},
"00291109": {"vr": "LO", "Value": ["1.3"]},
"7FE10010": {"vr": "LO", "Value": ["SIEMENS CSA NON-IMAGE"]},
"00104000": {"vr": "LT", "Value": ["Patient comments string"]},
"00081048": {"vr": "PN", "Value": [{"Alphabetic": "Some Phenotype"}]},
}


collated_data = {
"00291010": {"vr": "OB", "BinaryLength": 3168},
"00291110": {"vr": "OB", "BinaryLength": 1220},
"00291220": {"vr": "OB", "BinaryLength": 80},
"7FE11010": {"vr": "OB", "BinaryLength": 352},
}
2 changes: 1 addition & 1 deletion medimages4tests/import_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def raw_pet_to_gen_code(fspath: Path, out_dir: Path):
num_vols=1,
constant_hdr=json.dumps(constant_hdr, indent=" "),
varying_hdr=json.dumps(varying_hdr),
collated_data=json.dumps([data]),
collated_data=json.dumps(data),
)
)
init_fspath = out_dir / "__init__.py"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_raw_pet.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ def test_siemens_raw_pet_data_creation(siemens_raw_pet_data: ModuleType):
out_dir = Path(tempfile.mkdtemp())

# Generate raw PET data files
siemens_raw_pet_data.get_image(out_dir)
siemens_raw_pet_data.get_data(out_dir)

0 comments on commit df4e51d

Please sign in to comment.