Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qim3d
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tools
qim3d
Commits
40354703
Commit
40354703
authored
1 year ago
by
Christian Kento Rasmussen
Browse files
Options
Downloads
Patches
Plain Diff
Added support for loading vol file
parent
715df62e
No related branches found
No related tags found
2 merge requests
!45
Save files function
,
!44
Load vol files
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
qim3d/io/load.py
+30
-6
30 additions, 6 deletions
qim3d/io/load.py
with
30 additions
and
6 deletions
qim3d/io/load.py
+
30
−
6
View file @
40354703
...
...
@@ -335,16 +335,40 @@ class DataLoader:
return
meta_data
def
load_vol
(
self
,
path
):
"""
Load a VOL
/VGI
file
from the specified path
"""
Load a VOL file
d based on the VGI metadata file
Args:
path (str): The path to the
VOL/
VGI file.
path (str): The path to the VGI file.
"""
meta_data
=
self
.
_load_vgi_metadata
(
path
)
file_path
=
meta_data
[
'
Volume1
'
][
"
file1
"
][
"
Name
"
]
return
None
# Extracts relevant information from the metadata
file_name
=
meta_data
[
'
volume1
'
][
"
file1
"
][
"
Name
"
]
path
=
path
.
rsplit
(
'
/
'
,
1
)[
0
]
# Remove characters after the last "/"
vol_path
=
os
.
path
.
join
(
path
,
file_name
)
dims
=
meta_data
[
'
volume1
'
][
'
file1
'
][
'
Size
'
]
dims
=
[
int
(
n
)
for
n
in
dims
.
split
()
if
n
.
isdigit
()]
dt
=
meta_data
[
'
volume1
'
][
'
file1
'
][
'
Datatype
'
]
match
dt
:
case
'
float
'
:
dt
=
np
.
float32
case
'
uint8
'
:
dt
=
np
.
uint8
case
'
unsigned integer
'
:
dt
=
np
.
uint16
case
_
:
raise
ValueError
(
f
"
Unsupported data type:
{
dt
}
"
)
vol
=
np
.
fromfile
(
vol_path
,
dtype
=
dt
,
count
=
np
.
prod
(
dims
))
# Reshape and transposes the volume to match standard orientation
vol
=
np
.
reshape
(
vol
,
(
dims
[
2
],
dims
[
0
],
dims
[
1
]))
vol
=
vol
.
transpose
((
0
,
2
,
1
))
if
self
.
return_metadata
:
return
vol
,
meta_data
else
:
return
vol
def
load
(
self
,
path
):
"""
...
...
@@ -368,7 +392,7 @@ class DataLoader:
# Stringify path in case it is not already a string
path
=
stringify_path
(
path
)
print
(
os
.
path
.
isfile
(
path
),
path
,
path
.
endswith
((
"
.vgi
"
)))
# Load a file
if
os
.
path
.
isfile
(
path
):
# Choose the loader based on the file extension
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment