Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mu-map
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tamino Huxohl
mu-map
Commits
cfb837ca
Commit
cfb837ca
authored
2 years ago
by
Tamino Huxohl
Browse files
Options
Downloads
Patches
Plain Diff
remove load_dcm_img function from dataset utils
parent
4bf37715
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mu_map/dataset/util.py
+11
-25
11 additions, 25 deletions
mu_map/dataset/util.py
mu_map/vis/hist2d.py
+2
-1
2 additions, 1 deletion
mu_map/vis/hist2d.py
with
13 additions
and
26 deletions
mu_map/dataset/util.py
+
11
−
25
View file @
cfb837ca
from
typing
import
Tuple
import
numpy
as
np
import
pydicom
"""
Since DICOM images only allow images stored in short integer format,
the Siemens scanner software multiplies values by a factor before storing
so that no precision is lost.
The scale can be found in this private DICOM tag.
"""
DCM_TAG_PIXEL_SCALE_FACTOR
=
0x00331038
def
load_dcm_img
(
filename
:
str
)
->
np
.
ndarray
:
"""
Load a DICOM image as a numpy array and apply normalization of the Siemens SPECT/CT
Scanner.
:param filename: filename of the DICOM image
:return: the image scaled and loaded into a numpy array
"""
image
=
pydicom
.
dcmread
(
filename
)
image
=
image
.
pixel_array
/
image
[
DCM_TAG_PIXEL_SCALE_FACTOR
].
value
return
image
def
align_images
(
...
...
@@ -31,9 +9,17 @@ def align_images(
"""
Center align the image with more slices to the one with fewer slices on the first axis (z-axis).
:param image_1: the image to be aligned
:param image_2: the image to which image_1 is aligned
:return: both images aligned in the order they were put in
Parameters
----------
image_1: np.ndarray
the image to be aligned
image_2: np.ndarray
the image to which image_1 is aligned
Returns
-------
Tuple[np.ndarray, np.ndarray]
both images aligned in the order they were put in
"""
# reverse function if image_2 has more slices
if
image_2
.
shape
[
0
]
>
image_1
.
shape
[
0
]:
...
...
This diff is collapsed.
Click to expand it.
mu_map/vis/hist2d.py
+
2
−
1
View file @
cfb837ca
...
...
@@ -3,7 +3,8 @@ import matplotlib.pyplot as plt
import
numpy
as
np
import
pydicom
from
mu_map.dataset.util
import
load_dcm_img
,
align_images
from
mu_map.dataset.util
import
align_images
from
mu_map.file.dicom
import
load_dcm_img
from
mu_map.util
import
to_grayscale
mu_map
=
load_dcm_img
(
"
./data/second/images/0085-stress-mu_map.dcm
"
)
...
...
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