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

added roi and volume

parent 52049e27
No related branches found
No related tags found
No related merge requests found
{
"header": {
"timestamp": "2000-01-01T00:00:00Z",
"uuid": ""
},
"roi_center_position_mm": [
0.0,
0.0,
0.0
],
"roi_orientation_quat": [
0.0,
0.0,
0.0,
0.0
],
"roi_resolution_mm": [
0.0,
0.0,
0.0
],
"roi_voxels": [
1,
1,
1
]
}
\ No newline at end of file
{
"timestamp": "2000-01-01T00:00:00Z",
"uuid": "",
"volume_path": ".tif"
}
\ No newline at end of file
......@@ -4,6 +4,8 @@ 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
import json
from pathlib import Path
......@@ -19,6 +21,8 @@ def main():
("source", get_source_validator),
("detector", get_detector_validator),
("image", get_image_validator),
("roi", get_roi_validator),
("volume", get_volume_validator),
]:
validator = get_validator()
schema = validator.get_schema()
......
from thd_json import Validator
from pathlib import Path
import argparse
def get_roi_validator(json_suffix: str = "*.json") -> Validator:
return Validator(Path(__file__).parent / Path("roi.json"), json_suffix)
def roi_cli():
parser = argparse.ArgumentParser(description="JSON THD ROI 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_roi_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__":
roi_cli()
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "THD ROI File Schema",
"type": "object",
"version": 0.6,
"date": "20.11.2024",
"properties": {
"header": {
"$ref": "./header/header.json"
},
"roi_center_position_mm": {
"type": "array",
"description": "Position of the focal spot in millimeters.",
"items": {
"type": "number"
},
"minItems": 3,
"maxItems": 3
},
"roi_orientation_quat": {
"type": "array",
"description": "Quaternion representing the detector's center orientation.",
"items": {
"type": "number"
},
"minItems": 4,
"maxItems": 4
},
"roi_resolution_mm": {
"type": "array",
"description": "Center position of the detector in millimeters.",
"items": {
"type": "number"
},
"minItems": 3,
"maxItems": 3
},
"roi_voxels": {
"type": "array",
"description": "Center position of the detector in millimeters.",
"items": {
"type": "integer",
"minimum": 1
},
"minItems": 3,
"maxItems": 3
}
},
"required": [
"header",
"roi_center_position_mm",
"roi_orientation_quat",
"roi_resolution_mm",
"roi_voxels"
],
"additionalProperties": false
}
\ No newline at end of file
from thd_json import Validator
from pathlib import Path
import argparse
def get_volume_validator(json_suffix: str = "*.json") -> Validator:
return Validator(Path(__file__).parent / Path("volume.json"), json_suffix)
def volume_cli():
parser = argparse.ArgumentParser(
description="JSON THD Volume 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_volume_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__":
volume_cli()
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "THD Projection Volume File Schema",
"type": "object",
"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"
},
"volume_path": {
"type": "string",
"description": "Path to TIFF file.",
"pattern": "^.*\\.(tif|tiff)$"
}
},
"required": [
"timestamp",
"uuid",
"volume_path"
],
"additionalProperties": false
}
\ No newline at end of file
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