Skip to content

Commit

Permalink
add transformation data json schema
Browse files Browse the repository at this point in the history
  • Loading branch information
fanghanonline committed Aug 9, 2024
1 parent d631e87 commit 7d3363e
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 122 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.PHONY: all

all: createindex

createindex:
python createindex.py
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# schema
Schema used in the SPEBT project codebase

## make and upload
If you change the `JSON` file names or add `JSON` file, run `make` before `git push`
17 changes: 17 additions & 0 deletions createindex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pathlib
from bs4 import BeautifulSoup as bs


# Get all json files in v1 folder
path_posix_list = list(pathlib.Path('v1').glob('*.json'))
# Make raw html
raw_html = ""
raw_html += '<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Schema API Usage</title></head><body>'
raw_html += '<h1>Available API:</h1>'
for path in path_posix_list:
raw_html += '<li>/' + str(path)+'</li>'
soup = bs(raw_html, 'html.parser')

# Write to index.html
with open('index.html', 'w') as f:
f.write(soup.prettify())
50 changes: 28 additions & 22 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Schema API Usage</title>
</head>
<body>
<h1>Schema API Usage</h1>
<h2>Available methods:</h2>
<table>
<tr>
<th>Method</th>
<th>Path</th>
<th>Description</th>
</tr>
<tr>
<td>GET</td>
<td>https://spebt.github.io/schema/v1/pymatcal_main.json</td>
<td>Pymatcal system matrix generattion configuration file schema</td>
</tr>
</table>
</body>
</html>
<head>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title>
Schema API Usage
</title>
</head>
<body>
<h1>
Available API:
</h1>
<li>
/v1/relation.json
</li>
<li>
/v1/FOV.json
</li>
<li>
/v1/detector.json
</li>
<li>
/v1/transformation_data.json
</li>
<li>
/v1/main.json
</li>
</body>
</html>
38 changes: 38 additions & 0 deletions v1/FOV.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "FOV.json",
"title": "FOV schema",
"description": "FOV section of the YAML configuration file schema.",
"type": "object",
"properties": {
"N-voxels xyz": {
"type": "array",
"items": {
"type": "integer"
},
"minItems": 3,
"maxItems": 3
},
"mm-per-voxel xyz": {
"type": "array",
"items": {
"type": "number"
},
"minItems": 3,
"maxItems": 3
},
"N-subdivision xyz": {
"type": "array",
"items": {
"type": "integer"
},
"minItems": 3,
"maxItems": 3
}
},
"required": [
"N-voxels xyz",
"mm-per-voxel xyz",
"N-subdivision xyz"
]
}
37 changes: 37 additions & 0 deletions v1/detector.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "detector.json",
"title": "detector schema",
"description": "Detector section of the YAML configuration file schema.",
"type": "object",
"properties": {
"detector geometry": {
"description": "Detector geometry",
"type": "array",
"items": {
"type": "array"
},
"minItems": 1
},
"N-subdivision xyz": {
"type": "array",
"items": {
"type": "integer"
},
"minItems": 3,
"maxItems": 3
},
"active geometry indices": {
"type": "array",
"items": {
"type": "integer"
},
"minItems": 1
}
},
"required": [
"detector geometry",
"N-subdivision xyz",
"active geometry indices"
]
}
23 changes: 23 additions & 0 deletions v1/main.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "main.json",
"title": "Pymatcal main schema",
"description": "SPEBT system response matrix generation package configuration file schema. The configuration file is a YAML file.",
"type": "object",
"properties": {
"detector": {
"$ref": "detector.json"
},
"FOV": {
"$ref": "FOV.json"
},
"relation": {
"$ref": "relation.json"
}
},
"required": [
"detector",
"FOV",
"relation"
]
}
100 changes: 0 additions & 100 deletions v1/pymatcal_main.json

This file was deleted.

21 changes: 21 additions & 0 deletions v1/relation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "relation.json",
"title": "Detector to FOV relation schema",
"description": "Detector to FOV relation section of the YAML configuration file schema.\n Unit of length is mm. Unit of angle is degrees.",
"type": "object",
"properties": {
"radial distance": {
"$ref": "transformation_data.json"
},
"tangential shift": {
"$ref": "transformation_data.json"
},
"rotations": {
"$ref": "transformation_data.json"
}
},
"required": [
"radial distance, rotations"
]
}
49 changes: 49 additions & 0 deletions v1/transformation_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "transformation_data.json",
"title": "Pymatcal transformation data schema",
"description": "transformation data schema, used to define the transformation for the detector to FOV relation.",
"type": "object",
"properties": {
"format": {
"type": "string",
"enum": [
"enumerate",
"range"
]
},
"if": {
"properties": {
"format": {
"const": "range"
}
}
},
"then": {
"properties": {
"angles": {
"type": "array",
"items": {
"type": "number"
},
"minItems": 3,
"maxItems": 3
}
}
},
"else": {
"properties": {
"angles": {
"type": "array",
"items": {
"type": "number"
},
"minItems": 1
}
}
}
},
"required": [
"format"
]
}

0 comments on commit 7d3363e

Please sign in to comment.