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
a1222357
Commit
a1222357
authored
1 year ago
by
Tamino Huxohl
Browse files
Options
Downloads
Patches
Plain Diff
use is_dicom from pydicom and only scale dicom images if scaling is available
parent
ef14b677
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/file/dicom.py
+3
-25
3 additions, 25 deletions
mu_map/file/dicom.py
mu_map/file/util.py
+2
-1
2 additions, 1 deletion
mu_map/file/util.py
with
5 additions
and
26 deletions
mu_map/file/dicom.py
+
3
−
25
View file @
a1222357
...
...
@@ -251,7 +251,9 @@ def update_dcm(dcm: DICOM, image: np.ndarray) -> DICOM:
DOICOM
the updated DICOM file
"""
image
,
scale
=
scale_image
(
image
)
if
DCM_TAG_PIXEL_SCALE_FACTOR
in
dcm
:
image
,
scale
=
scale_image
(
image
)
dcm
[
DCM_TAG_PIXEL_SCALE_FACTOR
].
value
=
scale
dcm
.
NumberOfFrames
=
image
.
shape
[
0
]
dcm
.
NumberOfSlices
=
image
.
shape
[
0
]
...
...
@@ -262,7 +264,6 @@ def update_dcm(dcm: DICOM, image: np.ndarray) -> DICOM:
dcm
.
WindowWidth
=
image
.
max
()
dcm
.
WindowCenter
=
image
.
max
()
/
2
dcm
.
LargestImagePixelValue
=
image
.
max
()
dcm
[
DCM_TAG_PIXEL_SCALE_FACTOR
].
value
=
scale
return
dcm
...
...
@@ -288,29 +289,6 @@ def change_uid(dcm: DICOM) -> DICOM:
return
dcm
def
is_dicom
(
filename
:
str
)
->
bool
:
"""
Check if a file is a DICOM file or not.
This id done by trying to load it with `pydicom`.
Parameters
----------
filename: str
the file to be checked
Returns
-------
bool
if it is a DICOM file or not
"""
try
:
pydicom
.
dcmread
(
filename
,
stop_before_pixels
=
True
)
return
True
except
:
return
False
if
__name__
==
"
__main__
"
:
import
argparse
...
...
This diff is collapsed.
Click to expand it.
mu_map/file/util.py
+
2
−
1
View file @
a1222357
...
...
@@ -2,9 +2,10 @@
Utility methods for dealing with different file types.
"""
import
numpy
as
np
from
pydicom.misc
import
is_dicom
from
mu_map.file.convert
import
dicom_to_interfile
from
mu_map.file.dicom
import
is_dicom
,
load_dcm
,
load_dcm_img
from
mu_map.file.dicom
import
load_dcm
,
load_dcm_img
from
mu_map.file.interfile
import
load_interfile
,
load_interfile_img
,
Interfile
...
...
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