Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Michiel Cottaar
fslpy
Commits
e58be5f9
Commit
e58be5f9
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Support old and new dcm2niixes
parent
4f7f208c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/data/dicom.py
+28
-20
28 additions, 20 deletions
fsl/data/dicom.py
with
28 additions
and
20 deletions
fsl/data/dicom.py
+
28
−
20
View file @
e58be5f9
...
@@ -51,7 +51,7 @@ MIN_DCM2NIIX_VERSION = (1, 0, 2017, 12, 15)
...
@@ -51,7 +51,7 @@ MIN_DCM2NIIX_VERSION = (1, 0, 2017, 12, 15)
"""
"""
CRC_DCM2NIIX_VERSION
=
(
1
,
0
,
2019
,
0
9
,
0
2
)
CRC_DCM2NIIX_VERSION
=
(
1
,
0
,
2019
,
9
,
2
)
"""
For versions of ``dcm2niix`` orf this version or newer, the ``-n`` flag,
"""
For versions of ``dcm2niix`` orf this version or newer, the ``-n`` flag,
used to convert a single DICOM series, requires that a CRC checksum
used to convert a single DICOM series, requires that a CRC checksum
identifying the series be passed (see the :func:`seriesCRC`
identifying the series be passed (see the :func:`seriesCRC`
...
@@ -92,7 +92,7 @@ class DicomImage(fslimage.Image):
...
@@ -92,7 +92,7 @@ class DicomImage(fslimage.Image):
@memoize.memoize
@memoize.memoize
def
installedVersion
(
version
):
def
installedVersion
():
"""
Return a tuple describing the version of ``dcm2niix`` that is installed,
"""
Return a tuple describing the version of ``dcm2niix`` that is installed,
or ``None`` if dcm2niix cannot be found, or its version not parsed.
or ``None`` if dcm2niix cannot be found, or its version not parsed.
...
@@ -121,21 +121,16 @@ def installedVersion(version):
...
@@ -121,21 +121,16 @@ def installedVersion(version):
match
=
re
.
match
(
versionPattern
,
word
)
match
=
re
.
match
(
versionPattern
,
word
)
if
match
is
None
:
if
match
is
not
None
:
continue
return
(
int
(
match
.
group
(
'
major
'
)),
int
(
match
.
group
(
'
minor
'
)),
installedVersion
=
(
int
(
match
.
group
(
'
year
'
)),
int
(
match
.
group
(
'
major
'
)),
int
(
match
.
group
(
'
month
'
)),
int
(
match
.
group
(
'
minor
'
)),
int
(
match
.
group
(
'
day
'
)))
int
(
match
.
group
(
'
year
'
)),
int
(
match
.
group
(
'
month
'
)),
int
(
match
.
group
(
'
day
'
)))
return
installedVersion
except
Exception
as
e
:
except
Exception
as
e
:
log
.
debug
(
'
Error parsing dcm2niix version string: {}
'
.
format
(
e
))
log
.
debug
(
'
Error parsing dcm2niix version string: {}
'
.
format
(
e
))
return
None
return
None
def
compareVersions
(
v1
,
v2
):
def
compareVersions
(
v1
,
v2
):
...
@@ -153,14 +148,14 @@ def compareVersions(v1, v2):
...
@@ -153,14 +148,14 @@ def compareVersions(v1, v2):
return
0
return
0
@memoize.memoize
def
enabled
():
def
enabled
():
"""
Returns ``True`` if ``dcm2niix`` is present, and recent enough,
"""
Returns ``True`` if ``dcm2niix`` is present, and recent enough,
``False`` otherwise.
``False`` otherwise.
"""
"""
installed
=
installedVersion
()
installed
=
installedVersion
()
required
=
MIN_DCM2NIIX_VERSION
required
=
MIN_DCM2NIIX_VERSION
return
installed
is
None
or
compareVersions
(
installed
,
required
)
<
0
return
((
installed
is
not
None
)
and
(
compareVersions
(
installed
,
required
)
>=
0
))
def
scanDir
(
dcmdir
):
def
scanDir
(
dcmdir
):
...
@@ -256,10 +251,23 @@ def loadSeries(series):
...
@@ -256,10 +251,23 @@ def loadSeries(series):
if
not
enabled
():
if
not
enabled
():
raise
RuntimeError
(
'
dcm2niix is not available or is too old
'
)
raise
RuntimeError
(
'
dcm2niix is not available or is too old
'
)
dcmdir
=
series
[
'
DicomDir
'
]
dcmdir
=
series
[
'
DicomDir
'
]
snum
=
series
[
'
SeriesNumber
'
]
snum
=
series
[
'
SeriesNumber
'
]
desc
=
series
[
'
SeriesDescription
'
]
desc
=
series
[
'
SeriesDescription
'
]
cmd
=
'
dcm2niix -b n -f %s -z n -o . -n
"
{}
"
"
{}
"'
.
format
(
snum
,
dcmdir
)
version
=
installedVersion
()
# Newer versions of dcm2niix
# require a CRC to identify
# series
if
compareVersions
(
version
,
CRC_DCM2NIIX_VERSION
)
>=
0
:
ident
=
seriesCRC
(
series
)
# Older versions require
# the series number
else
:
ident
=
snum
cmd
=
'
dcm2niix -b n -f %s -z n -o . -n
"
{}
"
"
{}
"'
.
format
(
ident
,
dcmdir
)
with
tempdir
.
tempdir
()
as
td
:
with
tempdir
.
tempdir
()
as
td
:
...
...
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