Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Fiber void analysis
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tools
Fiber void analysis
Commits
9655bfd5
Commit
9655bfd5
authored
4 years ago
by
abda
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
6114f123
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
volread.py
+50
-0
50 additions, 0 deletions
volread.py
with
50 additions
and
0 deletions
volread.py
0 → 100644
+
50
−
0
View file @
9655bfd5
"""
Created on Tue Oct 13 2020
@author: Anders Bjorholm Dahl
abda@dtu.dk
"""
import
numpy
as
np
import
io
def
readvol
(
file_name
):
"""
Todo: Test this function on images of uint8, uint16, and when dimensions are
not all the same.
Parameters
----------
file_name : Sting
name of .vol and .vgi files without extension
Returns
-------
V : numpy array (float32, uint8, or uint16)
3D volume.
"""
vgi_name
=
file_name
+
'
.vgi
'
f
=
io
.
open
(
vgi_name
,
'
r
'
)
t
=
f
.
read
()
f
.
close
()
elem
=
[]
dt
=
''
for
l
in
t
.
splitlines
():
if
(
l
.
startswith
(
'
Size =
'
)):
elem
=
[
int
(
n
)
for
n
in
l
.
split
()
if
n
.
isdigit
()]
if
(
l
.
startswith
(
'
Datatype = float
'
)):
dt
=
np
.
float32
elif
(
l
.
startswith
(
'
Datatype = uint8
'
)):
dt
=
np
.
uint8
elif
(
l
.
startswith
(
'
Datatype = uint16
'
)):
dt
=
np
.
uint16
vol_name
=
file_name
+
'
.vol
'
V
=
np
.
fromfile
(
vol_name
,
dtype
=
dt
,
count
=
elem
[
0
]
*
elem
[
1
]
*
elem
[
2
])
V
=
np
.
reshape
(
V
,
(
elem
[
2
],
elem
[
0
],
elem
[
1
]))
V
=
V
.
transpose
((
0
,
2
,
1
))
return
V
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