@@ -16,9 +16,9 @@ nibabel objects and functions.
1616Motivation
1717**********
1818
19- It is very common to convert source DICOM images to another format, typically
20- Nifti, before doing any image processing. The Nifti format is significantly
21- easier to work with and has wide spread compatibility. However, the vast
19+ It is very common to convert source DICOM images to another format, typically
20+ Nifti, before doing any image processing. The Nifti format is significantly
21+ easier to work with and has wide spread compatibility. However, the vast
2222amount of meta data stored in the source DICOM files will be lost.
2323
2424After implementing this proposal, users will be able to preserve all of the
@@ -32,7 +32,7 @@ private elements. The meta data will then be easily accessible through the
3232 (256, 256, 24, 8)
3333 >>> print nii.get_meta('RepetitionTime')
3434 3500.0
35- >>> echo_times = [nii.get_meta('EchoTime', (0, 0, 0, idx))
35+ >>> echo_times = [nii.get_meta('EchoTime', (0, 0, 0, idx))
3636 for idx in xrange(data.shape[-1])]
3737 >>> print echo_times
3838 [16.4, 32.8, 49.2, 65.6, 82.0, 98.4, 114.8, 131.2]
@@ -50,25 +50,25 @@ Overview
5050********
5151
5252dcmstack reads a series of DICOM images, works out their relationship in terms
53- of slices and volumes, and compiles them into multidimensional volumes. It can
54- produce the corresponding data volume and affine, or a Nifti image (with any
53+ of slices and volumes, and compiles them into multidimensional volumes. It can
54+ produce the corresponding data volume and affine, or a Nifti image (with any
5555additional header information set appropriately).
5656
57- In the course of the read, dcmstack creates a `DcmMeta ` object for
58- each input file. This object is an ordered mapping that can contain a copy
59- of all the meta data in the DICOM header. By default some filtering is
60- applied to reduce the chance of including PHI. The set of DcmMeta objects are
61- then merged together in the same order as the image data to create a single
57+ In the course of the read, dcmstack creates a `DcmMeta ` object for
58+ each input file. This object is an ordered mapping that can contain a copy
59+ of all the meta data in the DICOM header. By default some filtering is
60+ applied to reduce the chance of including PHI. The set of DcmMeta objects are
61+ then merged together in the same order as the image data to create a single
6262DcmMeta object that summarizes all of the meta data for the series.
6363
64- To summarize the meta data, each element is classified based on how the values
65- repeat (e.g. const, per_slice, per_volume, etc.). Each element has a name (the
66- keyword from the DICOM standard) and one or more values (the number of values
67- depends on the classification and the shape of the image). Each classification's
64+ To summarize the meta data, each element is classified based on how the values
65+ repeat (e.g. const, per_slice, per_volume, etc.). Each element has a name (the
66+ keyword from the DICOM standard) and one or more values (the number of values
67+ depends on the classification and the shape of the image). Each classification's
6868meta data is stored stored in a separate nested dictionary.
6969
70- While creating the Nifti image output, the `DcmMeta ` is stored in a
71- `DcmMetaExtension ` which can be added as a header extension. This extension
70+ While creating the Nifti image output, the `DcmMeta ` is stored in a
71+ `DcmMetaExtension ` which can be added as a header extension. This extension
7272simply does a JSON encoding directly on the `DcmMeta ` object.
7373
7474When working with these images, it's possible to keep track of the
@@ -78,7 +78,7 @@ slice, and remove information for other slices. Or when merging 3D volumes to
7878a 4D time series, we want to merge together the meta data too.
7979
8080At the moment, dcmstack only creates Nifti images. There's no reason that this
81- should be so, and the relationship of dcmstack to other spatial images should be
81+ should be so, and the relationship of dcmstack to other spatial images should be
8282more flexible.
8383
8484******
@@ -105,10 +105,10 @@ wrapping the `DcmMeta` in the Extension API?
105105Status
106106------
107107
108- Resolved. We now have a separate `DcmMeta ` object which inherits from
109- `OrderedDict ` and contains all of the functionality previously in
110- `DcmMetaExtension ` except those related to acting as a Nifti1Extension.
111- The `DcmMetaExtension ` now provides just the functionality for being
108+ Resolved. We now have a separate `DcmMeta ` object which inherits from
109+ `OrderedDict ` and contains all of the functionality previously in
110+ `DcmMetaExtension ` except those related to acting as a Nifti1Extension.
111+ The `DcmMetaExtension ` now provides just the functionality for being
112112a Nifti1Extension.
113113
114114Keeping track of metadata when manipulating images
@@ -117,13 +117,13 @@ Keeping track of metadata when manipulating images
117117When slicing images, it is good to be able to keep track of the relevant DICOM
118118metadata for the particular slice. Or when merging images, it is good to be
119119able to compile the metadata across slices into the (e.g) volume metadata. Or,
120- say, when coregistering an image, it is good to be able to know that the
121- metadata that is per-slice no longer directly corresponds to a slice of the
122- data array.
120+ say, when coregistering an image, it is good to be able to know that the
121+ metadata that is per-slice no longer directly corresponds to a slice of the
122+ data array.
123123
124124At the moment, dcmstack deals with this by wrapping the image with DICOM meta
125125information in `NiftiWrapper ` object : see
126- https://github.com/moloney/dcmstack/blob/master /src/dcmstack/dcmmeta.py#L1185 .
126+ https://github.com/moloney/dcmstack/blob/d1577412860fecd93365e0e0e097f6f87e14aee0 /src/dcmstack/dcmmeta.py#L1232 .
127127This object accepts a Nifti image as input, that usually contains a
128128`DcmMetaExtension `, and has methods `get_meta ` (to get metadata from extension),
129129`split ` (for taking slice specific metadata into the split parts), `meta_valid `
@@ -146,8 +146,8 @@ Put the `DcmMeta` data into the `extra` object that is input to the
146146Add a `get_meta ` method to `SpatialImage ` that uses the to-be-defined API of the
147147`extra ` object. Maybe, by default, this would just get keys out of the mapping.
148148
149- Define an API for the `extra ` object to give back metadata that is potentially
150- varying (per slice or volume). We also need a way to populate the `extra ` object
149+ Define an API for the `extra ` object to give back metadata that is potentially
150+ varying (per slice or volume). We also need a way to populate the `extra ` object
151151when loading an image that has an associated `DcmMeta ` object.
152152
153153Use this API to get metadata. Try and make this work with functions outside the
@@ -179,57 +179,57 @@ Add `create_dcmmeta` method to the nibabel DICOM wrapper objects, that can be
179179specialized for each known DICOM format variation. Put the rules for slice
180180information etc into each class.
181181
182- For the Siemens files, we will need to make a list of elements from the private
183- CSA headers that are known to be slice specific. For the multiframe DICOM files
184- we should be able to do this in a programmatic manner, since the varying data
185- should live in the PerFrameFunctionalSequence DICOM element. Each element that
186- is reclassified should be simplified with the `DcmMeta.simplify ` method so that
187- it can be classified appropriately.
182+ For the Siemens files, we will need to make a list of elements from the private
183+ CSA headers that are known to be slice specific. For the multiframe DICOM files
184+ we should be able to do this in a programmatic manner, since the varying data
185+ should live in the PerFrameFunctionalSequence DICOM element. Each element that
186+ is reclassified should be simplified with the `DcmMeta.simplify ` method so that
187+ it can be classified appropriately.
188188
189189Meta data in nested DICOM sequences can not be independently classified
190190=======================================================================
191191
192- The code for summarizing meta data only works on the top level of key/value
193- pairs. Any value that is a nested dataset is treated as a single entity,
194- which prevents us from classifying its individual elements differently.
192+ The code for summarizing meta data only works on the top level of key/value
193+ pairs. Any value that is a nested dataset is treated as a single entity,
194+ which prevents us from classifying its individual elements differently.
195195
196- In a DICOM data set, any element that is a sequence contains one or more
197- nested DICOM data sets. For most MRI images this is not an issue since
198- they rarely contain many sequences, and the ones they do are usually small
199- and relatively unimportant. However in multiframe DICOM files make heavy
196+ In a DICOM data set, any element that is a sequence contains one or more
197+ nested DICOM data sets. For most MRI images this is not an issue since
198+ they rarely contain many sequences, and the ones they do are usually small
199+ and relatively unimportant. However in multiframe DICOM files make heavy
200200use of nested sequences to store data.
201201
202202Plan
203203----
204- This same issue was solved for the translated Siemens CSA sub headers by
205- unpacking each nested dataset by joining the keys from each level with a
206- dotted notation. For example, in the `CsaSeries ` subheader there is a nested
207- `MrPhoenixProtocol ` dataset which has an element `ulVersion ` so the key we
208- use after unpacking is `CsaSeries.MrPhoenixProtocol.ulVersion `.
204+ This same issue was solved for the translated Siemens CSA sub headers by
205+ unpacking each nested dataset by joining the keys from each level with a
206+ dotted notation. For example, in the `CsaSeries ` subheader there is a nested
207+ `MrPhoenixProtocol ` dataset which has an element `ulVersion ` so the key we
208+ use after unpacking is `CsaSeries.MrPhoenixProtocol.ulVersion `.
209209
210- We can take the same approach for DICOM sequence elements. One additional
210+ We can take the same approach for DICOM sequence elements. One additional
211211consideration is that each of these element is actually a list of data sets,
212212so we would need to add an index number to the key somehow.
213213
214- The alternative is to handle nested data sets recursively in the meta data
215- summarizing code. This would be fairly complex and you would no longer be
216- able to refer to each element with a single string, at least not without
214+ The alternative is to handle nested data sets recursively in the meta data
215+ summarizing code. This would be fairly complex and you would no longer be
216+ able to refer to each element with a single string, at least not without
217217some mini-language for traversing the nested datasets.
218218
219219Improving access to varying meta data through the Nifti
220220=======================================================
221221
222- Currently, when accessing varying meta data through the `get_meta ` method
222+ Currently, when accessing varying meta data through the `get_meta ` method
223223you can only get one value at a time::
224224
225- >>> echo_times = [nii.get_meta('EchoTime', (0, 0, 0, idx))
225+ >>> echo_times = [nii.get_meta('EchoTime', (0, 0, 0, idx))
226226 for idx in xrange(data.shape[-1])]
227227
228- You can easily get multiple values from the `DcmMeta ` object itself, but
229- then you lose the capability to automatically check if the meta data is
228+ You can easily get multiple values from the `DcmMeta ` object itself, but
229+ then you lose the capability to automatically check if the meta data is
230230valid in relation to the current image.
231231
232232
233233.. _dcmstack : https://github.com/moloney/dcmstack
234- .. _DcmMetaExtension : https://github.com/moloney/dcmstack/blob/master /src/dcmstack/dcmmeta.py#L92
234+ .. _DcmMetaExtension : https://github.com/moloney/dcmstack/blob/d1577412860fecd93365e0e0e097f6f87e14aee0 /src/dcmstack/dcmmeta.py#L112
235235.. vim: ft=rst
0 commit comments