diff --git a/README.md b/README.md index c19e28d11287dad69238bcb7db080581541d6988..bf94b38d5c274b919f4c1eced25dedd375d22747 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ from thd_json.projection import get_projection_validator from pathlib import Path -FILE = Path("./examples/thd_json/test_thd.json") +FILE = Path("./examples/generated/example_projection.json") def main(): diff --git a/examples/generated/example_header.json b/examples/generated/example_header.json index 4fbfdd4f1a2e12fcfde73a313b596ab3131a2e00..ea5c26e7d61a140a111d0b00efd5a2dd10b876ea 100644 --- a/examples/generated/example_header.json +++ b/examples/generated/example_header.json @@ -1,4 +1,3 @@ { - "timestamp": "2000-01-01T00:00:00Z", "uuid": "" } \ No newline at end of file diff --git a/examples/generated/example_projection.json b/examples/generated/example_projection.json index e6f19765015ef42bc11483de9bb2b77b0e79d5ad..116f088f7bd588fe798e17045fdf62876905ea40 100644 --- a/examples/generated/example_projection.json +++ b/examples/generated/example_projection.json @@ -5,14 +5,11 @@ "pixel_pitch_height_mm": 0.001, "pixel_pitch_width_mm": 0.001 }, - "header": { - "timestamp": "2000-01-01T00:00:00Z", - "uuid": "" - }, "image": { - "image_path": ".tif", - "timestamp": "2000-01-01T00:00:00Z", - "uuid": "" + "header": { + "uuid": "" + }, + "image_path": ".tif" }, "projection_geometry": { "detector_center_orientation_quat": [ @@ -30,6 +27,9 @@ 0.0, 0.0, 0.0 - ] + ], + "header": { + "uuid": "" + } } } \ No newline at end of file diff --git a/examples/generated/example_roi.json b/examples/generated/example_roi.json index d72404715e031f7a9fd0047a4385ca8fcca8dd25..8a3fe382145456228eae386d479b968784c57d29 100644 --- a/examples/generated/example_roi.json +++ b/examples/generated/example_roi.json @@ -1,6 +1,5 @@ { "header": { - "timestamp": "2000-01-01T00:00:00Z", "uuid": "" }, "roi_center_position_mm": [ diff --git a/examples/generated/example_volume.json b/examples/generated/example_volume.json index 84956ac230ccf6e0bc49508c15f3d71653324db5..fc969bed3f980135482cf1184d66b719c0d25eed 100644 --- a/examples/generated/example_volume.json +++ b/examples/generated/example_volume.json @@ -1,5 +1,6 @@ { - "timestamp": "2000-01-01T00:00:00Z", - "uuid": "", + "header": { + "uuid": "" + }, "volume_path": ".tif" } \ No newline at end of file diff --git a/scripts/generate_example_data.py b/scripts/generate_example_data.py index f3642743a40d976ff437d4fd2f494478d397ed52..e7bd7a0f1ba725c090a2aac71464c9adc3cf885d 100644 --- a/scripts/generate_example_data.py +++ b/scripts/generate_example_data.py @@ -3,7 +3,6 @@ from thd_json.projection import get_projection_validator from thd_json.header import get_header_validator from thd_json.source import get_source_validator from thd_json.detector import get_detector_validator -from thd_json.image import get_image_validator from thd_json.roi import get_roi_validator from thd_json.volume import get_volume_validator from hypothesis import given, settings @@ -20,7 +19,7 @@ def main(): ("header", get_header_validator), ("source", get_source_validator), ("detector", get_detector_validator), - ("image", get_image_validator), + # ("image", get_image_validator), ("roi", get_roi_validator), ("volume", get_volume_validator), ]: diff --git a/scripts/validate_file.py b/scripts/validate_file.py index 2b27d3a4eb32dcc8320a809e16a756fd6f218711..cb1c10005f73ae37b541f7704f40e6d6fe635662 100644 --- a/scripts/validate_file.py +++ b/scripts/validate_file.py @@ -2,7 +2,7 @@ from thd_json.projection import get_projection_validator from pathlib import Path -FILE = Path("./examples/thd_json/test_thd.json") +FILE = Path("./examples/generated/example_projection.json") def main(): diff --git a/src/thd_json/header/header.json b/src/thd_json/header/header.json index 73ef475a91efe60c4d8eae1a1fa5a93127befdbf..091c90f02451b85937804400109c35ef0bcf0b00 100644 --- a/src/thd_json/header/header.json +++ b/src/thd_json/header/header.json @@ -17,7 +17,6 @@ } }, "required": [ - "timestamp", "uuid" ], "additionalProperties": false diff --git a/src/thd_json/image/image.json b/src/thd_json/image/image.json index ff2f8822e69f5847f8fbdf15dc7bceb4519f9b4f..e7cdec4c5a02cfcdd43dcff0ffa355e005662bac 100644 --- a/src/thd_json/image/image.json +++ b/src/thd_json/image/image.json @@ -5,15 +5,8 @@ "version": 0.6, "date": "19.11.2024", "properties": { - "timestamp": { - "type": "string", - "description": "Timestamp, e.g. 2018-11-13T20:20:39+00:00", - "format": "date-time" - }, - "uuid": { - "type": "string", - "description": "Unique identifier", - "format": "uuid" + "header": { + "$ref": "../header/header.json" }, "image_path": { "type": "string", @@ -22,8 +15,7 @@ } }, "required": [ - "timestamp", - "uuid", + "header", "image_path" ], "additionalProperties": false diff --git a/src/thd_json/projection/projection.json b/src/thd_json/projection/projection.json index 7868d0bdc4257927d2928d8aed3898dfa6c7cf17..2bc9dcb35c8fa434a0dd42a1681dc696663f513f 100644 --- a/src/thd_json/projection/projection.json +++ b/src/thd_json/projection/projection.json @@ -5,15 +5,15 @@ "version": 0.6, "date": "19.11.2024", "properties": { - "header": { - "$ref": "./header/header.json" - }, "image": { "$ref": "./image/image.json" }, "projection_geometry": { "$ref": "./projection_geometry/projection_geometry.json" }, + "projection_geometry_nominal": { + "$ref": "./projection_geometry/projection_geometry.json" + }, "detector": { "$ref": "./detector/detector.json" }, @@ -22,7 +22,6 @@ } }, "required": [ - "header", "projection_geometry", "detector", "image" diff --git a/src/thd_json/projection_geometry/projection_geometry.json b/src/thd_json/projection_geometry/projection_geometry.json index bc376b524918ea96328a70cdaf7e630892b431b9..bb7d2c06b31d930b63e850857f19136d6dea3517 100644 --- a/src/thd_json/projection_geometry/projection_geometry.json +++ b/src/thd_json/projection_geometry/projection_geometry.json @@ -5,6 +5,9 @@ "version": 0.6, "date": "19.11.2024", "properties": { + "header": { + "$ref": "../header/header.json" + }, "focal_spot_position_mm": { "type": "array", "description": "Position of the focal spot in millimeters.", @@ -61,6 +64,7 @@ } }, "required": [ + "header", "focal_spot_position_mm", "detector_center_position_mm", "detector_center_orientation_quat" diff --git a/src/thd_json/validation.py b/src/thd_json/validation.py index 40cf87505e900dbd893b464edf83a0648b16cfd7..c1829ae0bc932f790d7ec74ac3e16fa61358630c 100644 --- a/src/thd_json/validation.py +++ b/src/thd_json/validation.py @@ -39,9 +39,10 @@ class Validator: return True def get_schema(self): + schema_path = self.json_schema.parent.absolute().as_uri() with open(str(self.json_schema)) as schema_file: schema = json.load(schema_file) - schema_path = self.json_schema.parent.absolute().as_uri() + resolver = RefResolver(base_uri=schema_path, referrer=schema) return self.resolve_ref(resolver, schema) diff --git a/src/thd_json/volume/volume.json b/src/thd_json/volume/volume.json index 122db5041f028deeb5db2e745b35daf8053af994..3fe7ff18e4d55092bf7fa8b485e5a476fe582e82 100644 --- a/src/thd_json/volume/volume.json +++ b/src/thd_json/volume/volume.json @@ -5,15 +5,8 @@ "version": 0.6, "date": "20.11.2024", "properties": { - "timestamp": { - "type": "string", - "description": "Timestamp, e.g. 2018-11-13T20:20:39+00:00", - "format": "date-time" - }, - "uuid": { - "type": "string", - "description": "Unique identifier", - "format": "uuid" + "header": { + "$ref": "./header/header.json" }, "volume_path": { "type": "string", @@ -22,8 +15,7 @@ } }, "required": [ - "timestamp", - "uuid", + "header", "volume_path" ], "additionalProperties": false