diff --git a/examples/generated/example_header.json b/examples/generated/example_header.json index 0013cf5cdc39ff3d80de18864b429be1c4bbc013..935eea3b0a02232ed6edcc901850d7ea64275dc7 100644 --- a/examples/generated/example_header.json +++ b/examples/generated/example_header.json @@ -1,3 +1,3 @@ { - "uuid": "0060361f-056d-11f0-b60b-f46d3febaf36" + "uuid": "06f48f47-059d-11f0-b60b-f46d3febaf36" } \ No newline at end of file diff --git a/examples/generated/example_joint.json b/examples/generated/example_joint.json new file mode 100644 index 0000000000000000000000000000000000000000..0f05187ac03208d16d092c6ec2d87d165add2a96 --- /dev/null +++ b/examples/generated/example_joint.json @@ -0,0 +1,3 @@ +{ + "q": 0.0 +} \ No newline at end of file diff --git a/examples/generated/example_projection.json b/examples/generated/example_projection.json index 4f6758240b259f5a6a958369ca469019e46cebe7..98003fdff3ddfe14ffe3160c66c882b11e8bd131 100644 --- a/examples/generated/example_projection.json +++ b/examples/generated/example_projection.json @@ -36,7 +36,7 @@ "z": 0.0 }, "header": { - "uuid": "005f11bd-056d-11f0-b60b-f46d3febaf36" + "uuid": "06f352d6-059d-11f0-b60b-f46d3febaf36" } } } \ No newline at end of file diff --git a/examples/generated/example_roi.json b/examples/generated/example_roi.json index 9472b2c7c1dd9c594641a913665f73fc9263322a..d343267c8c17c93e15381e3834c71ceacbdbaf65 100644 --- a/examples/generated/example_roi.json +++ b/examples/generated/example_roi.json @@ -1,6 +1,6 @@ { "header": { - "uuid": "00670fe0-056d-11f0-b60b-f46d3febaf36" + "uuid": "06fe834b-059d-11f0-b60b-f46d3febaf36" }, "roi_center_position_mm": [ 0.0, diff --git a/pyproject.toml b/pyproject.toml index fe481c203f9643437bcc1f240116f00bc43704a9..529f06742ac5d8df1bc799f1716393f2b25112a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "thd-json" -version = "0.1.11" +version = "0.1.12" description = "THD JSON schema and validation tools." authors = [ { name = "swittl", email = "simon.wittl@th-deg.de" } diff --git a/scripts/generate_example_data.py b/scripts/generate_example_data.py index b9a62e6304d4c491e9564fe1e6e0ec7d3de3093a..9e7e24a4fb68314e8fddb97b5373ea6d66d5ac97 100644 --- a/scripts/generate_example_data.py +++ b/scripts/generate_example_data.py @@ -4,6 +4,7 @@ from thd_json.header import get_header_validator, generate_header from thd_json.source import get_source_validator from thd_json.detector import get_detector_validator from thd_json.roi import get_roi_validator +from thd_json.joint import get_joint_validator from hypothesis import given, settings import json from pathlib import Path @@ -29,6 +30,7 @@ def main(): ("source", get_source_validator), ("detector", get_detector_validator), ("roi", get_roi_validator), + ("joint", get_joint_validator), ]: validator = get_validator() schema = validator.get_schema() diff --git a/src/thd_json/detector/detector.json b/src/thd_json/detector/detector.json index 2eb3f6df16a4f9f3e15c2a2c6572545f07f645ee..07c770038de555911474b9b4aef2d81e4de7f9ec 100644 --- a/src/thd_json/detector/detector.json +++ b/src/thd_json/detector/detector.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "THD Detector File Schema", "type": "object", - "version": "0.1.11", + "version": "0.1.12", "date": "20.03.2025", "properties": { "pixel_pitch_mm": { diff --git a/src/thd_json/header/header.json b/src/thd_json/header/header.json index 38f1ba0c688ccfb2870d86396d1f5413229e7dbc..5917ce3586aae33b02470fdc1de188a3225e1048 100644 --- a/src/thd_json/header/header.json +++ b/src/thd_json/header/header.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "THD Data Metadata Header File Schema", "type": "object", - "version": "0.1.11", + "version": "0.1.12", "date": "20.03.2025", "properties": { "timestamp": { diff --git a/src/thd_json/image/image.json b/src/thd_json/image/image.json index 00462f8ddfcb4341e7c8a550724218f424a4ac41..4c1a0180e5f90de9bb12972efe3e0757d54e27a6 100644 --- a/src/thd_json/image/image.json +++ b/src/thd_json/image/image.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "THD Projection Image File Schema", "type": "object", - "version": "0.1.11", + "version": "0.1.12", "date": "20.03.2025", "properties": { "header": { diff --git a/src/thd_json/joint/__init__.py b/src/thd_json/joint/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e7813361a882ac78c3342b76ff0f55e6e0127a6b --- /dev/null +++ b/src/thd_json/joint/__init__.py @@ -0,0 +1,35 @@ +from thd_json import Validator + +from pathlib import Path +import argparse + + +def get_joint_validator(json_suffix: str = "*.json") -> Validator: + return Validator(Path(__file__).parent / Path("joint.json"), json_suffix) + + +def joint_cli(): + parser = argparse.ArgumentParser( + description="JSON THD Joint Validator CLI with uv." + ) + parser.add_argument("folder", help="Folder to check.", type=str) + parser.add_argument( + "suffix", help="Projection suffix.", default="*.json", type=Path, nargs="?" + ) + args = parser.parse_args() + + suffix = str(args.suffix) + if not suffix.startswith("*"): + raise ValueError(f'The suffix must always start with: "*". \nIt is: {suffix}') + + validator = get_joint_validator(suffix) + + folder = Path(args.folder) + if not folder.exists(): + raise FileNotFoundError(f"Folder: {folder} does not exist") + + validator.folder(Path(args.folder)) + + +if __name__ == "__main__": + joint_cli() diff --git a/src/thd_json/joint/joint.json b/src/thd_json/joint/joint.json new file mode 100644 index 0000000000000000000000000000000000000000..83c537872be30c4c61ffce032744ccb4659d36e6 --- /dev/null +++ b/src/thd_json/joint/joint.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "THD Data Metadata Joint File Schema", + "type": "object", + "version": "0.1.12", + "date": "20.03.2025", + "properties": { + "q": { + "type": "number", + "description": "Current angle of one joint.", + "format": "uuid" + } + }, + "required": [ + "q" + ], + "additionalProperties": false +} \ No newline at end of file diff --git a/src/thd_json/projection/projection.json b/src/thd_json/projection/projection.json index 338f5b191f46a15f31c8d0a730abef4a06752efb..1bd11629a952e61dfeca42917c6cfeec820b5437 100644 --- a/src/thd_json/projection/projection.json +++ b/src/thd_json/projection/projection.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "THD Projection File Schema", "type": "object", - "version": "0.1.11", + "version": "0.1.12", "date": "20.03.2025", "properties": { "image": { diff --git a/src/thd_json/projection_geometry/projection_geometry.json b/src/thd_json/projection_geometry/projection_geometry.json index 6db5d1a987ea9938d632049e0e0503cd3a4eabf1..67da1d8773ce6f4af3d82818abbf6ae9b4d28016 100644 --- a/src/thd_json/projection_geometry/projection_geometry.json +++ b/src/thd_json/projection_geometry/projection_geometry.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "THD Projection Geometry File Schema", "type": "object", - "version": "0.1.11", + "version": "0.1.12", "date": "20.03.2025", "properties": { "header": { diff --git a/src/thd_json/roi/roi.json b/src/thd_json/roi/roi.json index 93ef935367733a9496ec936614986e964af9d59b..16235de86ea4192f5d02ef4445197e0b8b4e40e4 100644 --- a/src/thd_json/roi/roi.json +++ b/src/thd_json/roi/roi.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "THD ROI File Schema", "type": "object", - "version": "0.1.11", + "version": "0.1.12", "date": "20.03.2025", "properties": { "header": { diff --git a/src/thd_json/source/source.json b/src/thd_json/source/source.json index 09200901060503d671dee3e4fdda09a9dad54ef3..165f6a465d575bf886dd0b7ffe266e7ecd10ff04 100644 --- a/src/thd_json/source/source.json +++ b/src/thd_json/source/source.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "THD X-Ray Source File Schema", "type": "object", - "version": "0.1.11", + "version": "0.1.12", "date": "20.03.2025", "properties": { "voltage_kv": { diff --git a/src/thd_json/thd_joint_states/__init__.py b/src/thd_json/thd_joint_states/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..a7f72930c27473e988e9515694fe8909caaf70e9 --- /dev/null +++ b/src/thd_json/thd_joint_states/__init__.py @@ -0,0 +1,35 @@ +from thd_json import Validator + +from pathlib import Path +import argparse + + +def get_thd_joint_states_validator(json_suffix: str = "*.json") -> Validator: + return Validator(Path(__file__).parent / Path("thd_joint_states.json"), json_suffix) + + +def thd_joint_states_cli(): + parser = argparse.ArgumentParser( + description="JSON THD Joint Validator CLI with uv." + ) + parser.add_argument("folder", help="Folder to check.", type=str) + parser.add_argument( + "suffix", help="Projection suffix.", default="*.json", type=Path, nargs="?" + ) + args = parser.parse_args() + + suffix = str(args.suffix) + if not suffix.startswith("*"): + raise ValueError(f'The suffix must always start with: "*". \nIt is: {suffix}') + + validator = get_thd_joint_states_validator(suffix) + + folder = Path(args.folder) + if not folder.exists(): + raise FileNotFoundError(f"Folder: {folder} does not exist") + + validator.folder(Path(args.folder)) + + +if __name__ == "__main__": + thd_joint_states_cli() diff --git a/src/thd_json/thd_joint_states/thd_joint_states.json b/src/thd_json/thd_joint_states/thd_joint_states.json new file mode 100644 index 0000000000000000000000000000000000000000..c667f9c7a4fca3e842bf1030337c04200118a2f9 --- /dev/null +++ b/src/thd_json/thd_joint_states/thd_joint_states.json @@ -0,0 +1,75 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "THD Data Metadata Joint States File Schema", + "type": "object", + "version": "0.1.12", + "date": "20.03.2025", + "properties": { + "header": { + "$ref": "../header/header.json" + }, + "master_joint_e1": { + "$ref": "../joint/joint.json" + }, + "master_joint_a1": { + "$ref": "../joint/joint.json" + }, + "master_joint_a2": { + "$ref": "../joint/joint.json" + }, + "master_joint_a3": { + "$ref": "../joint/joint.json" + }, + "master_joint_a4": { + "$ref": "../joint/joint.json" + }, + "master_joint_a5": { + "$ref": "../joint/joint.json" + }, + "master_joint_a6": { + "$ref": "../joint/joint.json" + }, + "slave_joint_e1": { + "$ref": "../joint/joint.json" + }, + "slave_joint_a1": { + "$ref": "../joint/joint.json" + }, + "slave_joint_a2": { + "$ref": "../joint/joint.json" + }, + "slave_joint_a3": { + "$ref": "../joint/joint.json" + }, + "slave_joint_a4": { + "$ref": "../joint/joint.json" + }, + "slave_joint_a5": { + "$ref": "../joint/joint.json" + }, + "salve_joint_a6": { + "$ref": "../joint/joint.json" + }, + "table_joint_a1": { + "$ref": "../joint/joint.json" + } + }, + "required": [ + "master_joint_e1", + "master_joint_a1", + "master_joint_a2", + "master_joint_a3", + "master_joint_a4", + "master_joint_a5", + "master_joint_a6", + "slave_joint_e1", + "slave_joint_a1", + "slave_joint_a2", + "slave_joint_a3", + "slave_joint_a4", + "slave_joint_a5", + "slave_joint_a6", + "table_joint_a1" + ], + "additionalProperties": false +} \ No newline at end of file diff --git a/src/thd_json/volume/volume.json b/src/thd_json/volume/volume.json index 135ff14ac2d3765e68122a45c1eeadeb0010f2df..6c7f51d075eac0288debf059479dbddaf38a1b8d 100644 --- a/src/thd_json/volume/volume.json +++ b/src/thd_json/volume/volume.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "THD Projection Volume File Schema", "type": "object", - "version": "0.1.11", + "version": "0.1.12", "date": "20.03.2025", "properties": { "header": { diff --git a/uv.lock b/uv.lock index 5cb9495986414bf53084afd1f3b17341e0368223..b601f3e9962e1c0a2027e97572df969759d9bf84 100644 --- a/uv.lock +++ b/uv.lock @@ -356,7 +356,7 @@ wheels = [ [[package]] name = "thd-json" -version = "0.1.11" +version = "0.1.12" source = { editable = "." } dependencies = [ { name = "hatchling" },