Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD 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
FSL
fslpy
Commits
07fe08cf
Commit
07fe08cf
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
dcmstack.parse_and_group allows open pydicom objects to be passed in.
parent
69ad3ffb
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
fsl/data/dcmstack/dcmstack.py
+17
-9
17 additions, 9 deletions
fsl/data/dcmstack/dcmstack.py
with
17 additions
and
9 deletions
fsl/data/dcmstack/dcmstack.py
+
17
−
9
View file @
07fe08cf
...
...
@@ -1014,7 +1014,8 @@ def parse_and_group(src_paths, group_by=default_group_keys, extractor=None,
Parameters
----------
src_paths : sequence
A list of paths to the source DICOM files.
A list of paths to the source DICOM files, or a list of open
pydicom FileDataset objects.
group_by : tuple
Meta data keys to group data sets with. Any data set with the same
...
...
@@ -1047,18 +1048,25 @@ def parse_and_group(src_paths, group_by=default_group_keys, extractor=None,
from
.extract
import
default_extractor
extractor
=
default_extractor
are_paths
=
isinstance
(
src_paths
[
0
],
six
.
string_types
)
results
=
{}
close_elems
=
{}
for
dcm_path
in
src_paths
:
#Read the DICOM file
try
:
dcm
=
dicom
.
read_file
(
dcm_path
,
force
=
force
)
except
Exception
as
e
:
if
warn_on_except
:
warnings
.
warn
(
'
Error reading file %s: %s
'
%
(
dcm_path
,
str
(
e
)))
continue
else
:
raise
if
are_paths
:
try
:
dcm
=
dicom
.
read_file
(
dcm_path
,
force
=
force
)
except
Exception
as
e
:
if
warn_on_except
:
warnings
.
warn
(
'
Error reading file %s: %s
'
%
(
dcm_path
,
str
(
e
)))
continue
else
:
raise
else
:
dcm
=
dcm_path
dcm_path
=
getattr
(
dcm
,
'
filename
'
,
None
)
#Extract the meta data and group
meta
=
extractor
(
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