Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aRTist API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RoboCT (Public)
aRTist API
Compare revisions
48c4ac631ed02f625f70faf4d4e8213999332ae9 to 5b27a6089bcb038b8be4ed28c785f5dd0c41e527
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
roboct-public/artist-api
Select target project
No results found
5b27a6089bcb038b8be4ed28c785f5dd0c41e527
Select Git revision
Branches
main
Swap
Target
roboct-public/artist-api
Select target project
roboct-public/artist-api
1 result
48c4ac631ed02f625f70faf4d4e8213999332ae9
Select Git revision
Branches
main
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
added public repo
· 9e253403
Simon Wittl
authored
3 weeks ago
9e253403
linter
· 5b27a608
Simon Wittl
authored
3 weeks ago
5b27a608
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
pyproject.toml
+1
-1
1 addition, 1 deletion
pyproject.toml
src/artist_pythonlib/api.py
+52
-41
52 additions, 41 deletions
src/artist_pythonlib/api.py
src/artist_pythonlib/geometries/thd_format.py
+2
-2
2 additions, 2 deletions
src/artist_pythonlib/geometries/thd_format.py
uv.lock
+2
-2
2 additions, 2 deletions
uv.lock
with
57 additions
and
46 deletions
pyproject.toml
View file @
5b27a608
...
...
@@ -28,4 +28,4 @@ build-backend = "hatchling.build"
[tool.uv.sources]
thd-json
=
{
git
=
"https://mygit.th-deg.de/roboct-public/roboct-schemas"
}
h5schemas
=
{
git
=
"https://mygit.th-deg.de/roboct
/definitions/h5schemas
"
}
h5schemas
=
{
git
=
"https://mygit.th-deg.de/roboct
-public/roboct-h5
"
}
This diff is collapsed.
Click to expand it.
src/artist_pythonlib/api.py
View file @
5b27a608
...
...
@@ -23,13 +23,17 @@ from h5py import File, Group
from
artist_pythonlib.geometries
import
projection_geometry
,
thd_projection_geometry
from
artist_pythonlib.common_types
import
PROJECTIONGEOMETRIES
,
SAVEMODES
from
artist_pythonlib.remote_connection
import
Junction
,
_rc
from
h5schemas.projection.add_projection
import
init_projection_dataset
,
add_projection_sample
from
h5schemas.projection.add_projection
import
(
init_projection_dataset
,
add_projection_sample
,
)
import
tempfile
from
artist_pythonlib.utility
import
load_projection
H5_INIT
=
True
class
API
:
def
__init__
(
self
,
remote_control
:
Junction
=
None
)
->
None
:
if
remote_control
is
None
:
...
...
@@ -68,10 +72,10 @@ class API:
if
save_projection_geometry
==
PROJECTIONGEOMETRIES
.
THD
:
geom
=
self
.
projection_geometry
(
save_projection_geometry
)
name
=
f
'
{
geom
[
"
image
"
][
"
image_path
"
][
:
-
4
]
}
_
{
save_path
.
stem
}
'
name
=
f
"
{
geom
[
'
image
'
][
'
image_path
'
][
:
-
4
]
}
_
{
save_path
.
stem
}
"
save_path
=
save_path
.
parent
/
f
"
{
name
}
.tif
"
save_path_json
=
save_path
.
parent
/
f
"
{
name
}
.json
"
geom
[
'
image
'
][
'
image_path
'
]
=
save_path
.
name
geom
[
"
image
"
][
"
image_path
"
]
=
save_path
.
name
elif
save_projection_geometry
==
PROJECTIONGEOMETRIES
.
STANDARD
:
save_path_json
=
save_path
.
parent
/
f
"
{
save_path
.
stem
}
.json
"
...
...
@@ -90,61 +94,68 @@ class API:
self
.
_save_image_png
(
save_path
)
return
save_path
def
save_hdf5
(
self
,
save_path
:
Path
|
File
|
Group
,
initialize_dataset
:
bool
=
False
):
def
save_hdf5
(
self
,
save_path
:
Path
|
File
|
Group
,
initialize_dataset
:
bool
=
False
):
global
H5_INIT
if
isinstance
(
save_path
,
Path
):
save_path
=
File
(
save_path
,
'
a
'
)
save_path
=
File
(
save_path
,
"
a
"
)
file
=
Path
(
tempfile
.
gettempdir
())
/
'
image.tif
'
file
=
Path
(
tempfile
.
gettempdir
())
/
"
image.tif
"
file
=
self
.
save_image
(
file
,
save_projection_geometry
=
PROJECTIONGEOMETRIES
.
THD
)
projection
,
current_geometry
=
load_projection
(
file
)
if
H5_INIT
or
initialize_dataset
:
H5_INIT
=
False
image_dimensions_px
=
[
current_geometry
[
'
detector
'
][
'
image_dimensions_px
'
][
'
u
'
],
current_geometry
[
'
detector
'
][
'
image_dimensions_px
'
][
'
v
'
]]
pixel_pitch_mm
=
[
current_geometry
[
'
detector
'
][
'
pixel_pitch_mm
'
][
'
u
'
],
current_geometry
[
'
detector
'
][
'
pixel_pitch_mm
'
][
'
v
'
]]
init_projection_dataset
(
save_path
,
False
,
image_dimensions_px
,
pixel_pitch_mm
)
image_dimensions_px
=
[
current_geometry
[
"
detector
"
][
"
image_dimensions_px
"
][
"
u
"
],
current_geometry
[
"
detector
"
][
"
image_dimensions_px
"
][
"
v
"
],
]
pixel_pitch_mm
=
[
current_geometry
[
"
detector
"
][
"
pixel_pitch_mm
"
][
"
u
"
],
current_geometry
[
"
detector
"
][
"
pixel_pitch_mm
"
][
"
v
"
],
]
init_projection_dataset
(
save_path
,
False
,
image_dimensions_px
,
pixel_pitch_mm
)
source_pos
=
[
current_geometry
[
'
projection_geometry
'
][
'
focal_spot_position_mm
'
][
'
x
'
],
current_geometry
[
'
projection_geometry
'
][
'
focal_spot_position_mm
'
][
'
y
'
],
current_geometry
[
'
projection_geometry
'
][
'
focal_spot_position_mm
'
][
'
z
'
],
current_geometry
[
"
projection_geometry
"
][
"
focal_spot_position_mm
"
][
"
x
"
],
current_geometry
[
"
projection_geometry
"
][
"
focal_spot_position_mm
"
][
"
y
"
],
current_geometry
[
"
projection_geometry
"
][
"
focal_spot_position_mm
"
][
"
z
"
],
]
detector_pos
=
[
current_geometry
[
'
projection_geometry
'
][
'
detector_center_position_mm
'
][
'
x
'
],
current_geometry
[
'
projection_geometry
'
][
'
detector_center_position_mm
'
][
'
y
'
],
current_geometry
[
'
projection_geometry
'
][
'
detector_center_position_mm
'
][
'
z
'
],
current_geometry
[
"
projection_geometry
"
][
"
detector_center_position_mm
"
][
"
x
"
],
current_geometry
[
"
projection_geometry
"
][
"
detector_center_position_mm
"
][
"
y
"
],
current_geometry
[
"
projection_geometry
"
][
"
detector_center_position_mm
"
][
"
z
"
],
]
source_ori
=
[
current_geometry
[
'
projection_geometry
'
][
'
focal_spot_orientation_quat
'
][
'
x
'
],
current_geometry
[
'
projection_geometry
'
][
'
focal_spot_orientation_quat
'
][
'
y
'
],
current_geometry
[
'
projection_geometry
'
][
'
focal_spot_orientation_quat
'
][
'
z
'
],
current_geometry
[
'
projection_geometry
'
][
'
focal_spot_orientation_quat
'
][
'
w
'
],
current_geometry
[
"
projection_geometry
"
][
"
focal_spot_orientation_quat
"
][
"
x
"
],
current_geometry
[
"
projection_geometry
"
][
"
focal_spot_orientation_quat
"
][
"
y
"
],
current_geometry
[
"
projection_geometry
"
][
"
focal_spot_orientation_quat
"
][
"
z
"
],
current_geometry
[
"
projection_geometry
"
][
"
focal_spot_orientation_quat
"
][
"
w
"
],
]
detector_ori
=
[
current_geometry
[
'
projection_geometry
'
][
'
detector_center_orientation_quat
'
][
'
x
'
],
current_geometry
[
'
projection_geometry
'
][
'
detector_center_orientation_quat
'
][
'
y
'
],
current_geometry
[
'
projection_geometry
'
][
'
detector_center_orientation_quat
'
][
'
z
'
],
current_geometry
[
'
projection_geometry
'
][
'
detector_center_orientation_quat
'
][
'
w
'
],
current_geometry
[
"
projection_geometry
"
][
"
detector_center_orientation_quat
"
][
"
x
"
],
current_geometry
[
"
projection_geometry
"
][
"
detector_center_orientation_quat
"
][
"
y
"
],
current_geometry
[
"
projection_geometry
"
][
"
detector_center_orientation_quat
"
][
"
z
"
],
current_geometry
[
"
projection_geometry
"
][
"
detector_center_orientation_quat
"
][
"
w
"
],
]
add_projection_sample
(
save_path
,
projection
,
detector_pos
,
detector_ori
,
source_pos
,
source_ori
save_path
,
projection
,
detector_pos
,
detector_ori
,
source_pos
,
source_ori
)
def
_save_image_uint16
(
self
,
save_path
:
Path
):
...
...
@@ -156,7 +167,7 @@ class API:
# self.rc.send('set imgList [Engine::Go]')
save_path_projection
=
str
(
save_path
.
absolute
()).
replace
(
"
\\
"
,
"
\\\\
"
)
self
.
rc
.
send
(
f
'
set imgList [Engine::Go]; Image::SaveFloatTIFF [lindex $imgList 0]
{
save_path_projection
}
True;
{
r
"
foreach i $imgList
{
$
i
Delete
}
"
}
'
f
"
set imgList [Engine::Go]; Image::SaveFloatTIFF [lindex $imgList 0]
{
save_path_projection
}
True;
{
r
'
foreach i $imgList
{
$
i
Delete
}
'
}
"
)
def
_save_image_uint8
(
self
,
save_path
:
Path
):
...
...
@@ -171,7 +182,7 @@ class API:
save_path
.
parent
/
(
save_path
.
stem
+
"
.json
"
)
)
# Image::SaveFile [lindex $imgList 0] [file join $env(HOME) Pictures/artistlib2.tif] true',
self
.
rc
.
send
(
f
'
set imgList [Engine::Go]; Image::SaveFloatTIFF [lindex $imgList 0]
{
save_path_projection
}
True;
{
r
"
foreach i $imgList
{
$
i
Delete
}
"
}
'
f
"
set imgList [Engine::Go]; Image::SaveFloatTIFF [lindex $imgList 0]
{
save_path_projection
}
True;
{
r
'
foreach i $imgList
{
$
i
Delete
}
'
}
"
)
with
open
(
str
(
save_path_json
),
"
w
"
)
as
f
:
...
...
@@ -186,7 +197,7 @@ class API:
# self.rc.send('set imgList [Engine::Go]')
save_path_projection
=
str
(
save_path
.
absolute
()).
replace
(
"
\\
"
,
"
\\\\
"
)
self
.
rc
.
send
(
f
'
set imgList [Engine::Go]; Image::SaveFloatTIFF [lindex $imgList 0]
{
save_path_projection
}
True;
{
r
"
foreach i $imgList
{
$
i
Delete
}
"
}
'
f
"
set imgList [Engine::Go]; Image::SaveFloatTIFF [lindex $imgList 0]
{
save_path_projection
}
True;
{
r
'
foreach i $imgList
{
$
i
Delete
}
'
}
"
)
# self.rc.send('foreach i $imgList {$i Delete}')
...
...
@@ -202,7 +213,7 @@ class API:
save_path
.
parent
/
(
save_path
.
stem
+
"
.json
"
)
)
# Image::SaveFile [lindex $imgList 0] [file join $env(HOME) Pictures/artistlib2.tif] true',
self
.
rc
.
send
(
f
'
set imgList [Engine::Go]; Image::SaveFloatTIFF [lindex $imgList 0]
{
save_path_projection
}
True;
{
r
"
foreach i $imgList
{
$
i
Delete
}
"
}
'
f
"
set imgList [Engine::Go]; Image::SaveFloatTIFF [lindex $imgList 0]
{
save_path_projection
}
True;
{
r
'
foreach i $imgList
{
$
i
Delete
}
'
}
"
)
with
open
(
str
(
save_path_json
),
"
w
"
)
as
f
:
...
...
@@ -217,7 +228,7 @@ class API:
# self.rc.send('set imgList [Engine::Go]')
save_path_projection
=
str
(
save_path
.
absolute
()).
replace
(
"
\\
"
,
"
\\\\
"
)
self
.
rc
.
send
(
f
'
set imgList [Engine::Go]; Image::SaveFloatTIFF [lindex $imgList 0]
{
save_path_projection
}
True;
{
r
"
foreach i $imgList
{
$
i
Delete
}
"
}
'
f
"
set imgList [Engine::Go]; Image::SaveFloatTIFF [lindex $imgList 0]
{
save_path_projection
}
True;
{
r
'
foreach i $imgList
{
$
i
Delete
}
'
}
"
)
def
translate
(
...
...
@@ -450,4 +461,4 @@ class API:
)
self
.
rc
.
send
(
f
'
::XRayProject::LoadProject
"
{
self
.
path_to_artist
(
project_file
)
}
"'
)
\ No newline at end of file
)
This diff is collapsed.
Click to expand it.
src/artist_pythonlib/geometries/thd_format.py
View file @
5b27a608
...
...
@@ -40,7 +40,7 @@ def thd_projection_geometry(api) -> dict:
np
.
asarray
(
detector_pixel_count
),
np
.
asarray
(
detector_resolution
),
json_header
,
Rotation
.
from_matrix
(
source_orientation
).
as_quat
()
)
Rotation
.
from_matrix
(
source_orientation
).
as_quat
()
,
)
return
data_dict
This diff is collapsed.
Click to expand it.
uv.lock
View file @
5b27a608
...
...
@@ -22,7 +22,7 @@ thd = [
[package.metadata]
requires-dist = [
{ name = "h5schemas", git = "https://mygit.th-deg.de/roboct
/definitions/h5schemas
" },
{ name = "h5schemas", git = "https://mygit.th-deg.de/roboct
-public/roboct-h5
" },
{ name = "matplotlib", specifier = "<=3.9" },
{ name = "numpy", specifier = ">=1.23" },
{ name = "pillow", specifier = ">=10.0" },
...
...
@@ -249,7 +249,7 @@ wheels = [
[[package]]
name = "h5schemas"
version = "0.1.0"
source = { git = "https://mygit.th-deg.de/roboct
/definitions/h5schemas
#3624c61163e3230bd2ac42884aa7b39d2cfcdeb8" }
source = { git = "https://mygit.th-deg.de/roboct
-public/roboct-h5
#3624c61163e3230bd2ac42884aa7b39d2cfcdeb8" }
dependencies = [
{ name = "h5py" },
{ name = "jsonref" },
...
...
This diff is collapsed.
Click to expand it.