Skip to content
Snippets Groups Projects
Commit c3b39654 authored by Simon Wittl's avatar Simon Wittl
Browse files

Public

parent 54962797
No related branches found
No related tags found
No related merge requests found
Showing
with 181 additions and 13 deletions
{ {
"uuid": "0060361f-056d-11f0-b60b-f46d3febaf36" "uuid": "06f48f47-059d-11f0-b60b-f46d3febaf36"
} }
\ No newline at end of file
{
"q": 0.0
}
\ No newline at end of file
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
"z": 0.0 "z": 0.0
}, },
"header": { "header": {
"uuid": "005f11bd-056d-11f0-b60b-f46d3febaf36" "uuid": "06f352d6-059d-11f0-b60b-f46d3febaf36"
} }
} }
} }
\ No newline at end of file
{ {
"header": { "header": {
"uuid": "00670fe0-056d-11f0-b60b-f46d3febaf36" "uuid": "06fe834b-059d-11f0-b60b-f46d3febaf36"
}, },
"roi_center_position_mm": [ "roi_center_position_mm": [
0.0, 0.0,
......
[project] [project]
name = "thd-json" name = "thd-json"
version = "0.1.11" version = "0.1.12"
description = "THD JSON schema and validation tools." description = "THD JSON schema and validation tools."
authors = [ authors = [
{ name = "swittl", email = "simon.wittl@th-deg.de" } { name = "swittl", email = "simon.wittl@th-deg.de" }
......
...@@ -4,6 +4,7 @@ from thd_json.header import get_header_validator, generate_header ...@@ -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.source import get_source_validator
from thd_json.detector import get_detector_validator from thd_json.detector import get_detector_validator
from thd_json.roi import get_roi_validator from thd_json.roi import get_roi_validator
from thd_json.joint import get_joint_validator
from hypothesis import given, settings from hypothesis import given, settings
import json import json
from pathlib import Path from pathlib import Path
...@@ -29,6 +30,7 @@ def main(): ...@@ -29,6 +30,7 @@ def main():
("source", get_source_validator), ("source", get_source_validator),
("detector", get_detector_validator), ("detector", get_detector_validator),
("roi", get_roi_validator), ("roi", get_roi_validator),
("joint", get_joint_validator),
]: ]:
validator = get_validator() validator = get_validator()
schema = validator.get_schema() schema = validator.get_schema()
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "THD Detector File Schema", "title": "THD Detector File Schema",
"type": "object", "type": "object",
"version": "0.1.11", "version": "0.1.12",
"date": "20.03.2025", "date": "20.03.2025",
"properties": { "properties": {
"pixel_pitch_mm": { "pixel_pitch_mm": {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "THD Data Metadata Header File Schema", "title": "THD Data Metadata Header File Schema",
"type": "object", "type": "object",
"version": "0.1.11", "version": "0.1.12",
"date": "20.03.2025", "date": "20.03.2025",
"properties": { "properties": {
"timestamp": { "timestamp": {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "THD Projection Image File Schema", "title": "THD Projection Image File Schema",
"type": "object", "type": "object",
"version": "0.1.11", "version": "0.1.12",
"date": "20.03.2025", "date": "20.03.2025",
"properties": { "properties": {
"header": { "header": {
......
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()
{
"$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
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "THD Projection File Schema", "title": "THD Projection File Schema",
"type": "object", "type": "object",
"version": "0.1.11", "version": "0.1.12",
"date": "20.03.2025", "date": "20.03.2025",
"properties": { "properties": {
"image": { "image": {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "THD Projection Geometry File Schema", "title": "THD Projection Geometry File Schema",
"type": "object", "type": "object",
"version": "0.1.11", "version": "0.1.12",
"date": "20.03.2025", "date": "20.03.2025",
"properties": { "properties": {
"header": { "header": {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "THD ROI File Schema", "title": "THD ROI File Schema",
"type": "object", "type": "object",
"version": "0.1.11", "version": "0.1.12",
"date": "20.03.2025", "date": "20.03.2025",
"properties": { "properties": {
"header": { "header": {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "THD X-Ray Source File Schema", "title": "THD X-Ray Source File Schema",
"type": "object", "type": "object",
"version": "0.1.11", "version": "0.1.12",
"date": "20.03.2025", "date": "20.03.2025",
"properties": { "properties": {
"voltage_kv": { "voltage_kv": {
......
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()
{
"$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
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "THD Projection Volume File Schema", "title": "THD Projection Volume File Schema",
"type": "object", "type": "object",
"version": "0.1.11", "version": "0.1.12",
"date": "20.03.2025", "date": "20.03.2025",
"properties": { "properties": {
"header": { "header": {
......
...@@ -356,7 +356,7 @@ wheels = [ ...@@ -356,7 +356,7 @@ wheels = [
[[package]] [[package]]
name = "thd-json" name = "thd-json"
version = "0.1.11" version = "0.1.12"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "hatchling" }, { name = "hatchling" },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment