off-topic qform matrix

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

off-topic qform matrix

Felix
Hi all,

I'm using Slicer as part of a pipeline for ADC quantification. I convert T1
and T2 files from dicom 2 nifti using dcm2niix and DWI dicom to nifti using
DWIConvert. ADC is easily computed using a R script. ROI are drawn on the
registered T1w and T2w images using Slicer editor (T1w as master volume).

All the series were acquired using the same orientation (purely axial) but
qform matrix differ if I use DWIConvert or dcm2niix or mcverter in order to
transform them from DICOM to NIFTI. Quite strange but this is the situation
so I need to solve this issue.

I use a R script to obtain the statistics so I need to move the ROI from its
T1w's ijk space to the ijk space of the ADC nifti. I use  (qform_ADC)^-1 *
qform_ROI to transform the ijk indexes of those positions labeled in the ROI
.

It looks quite easy but labelled regions do not move to the place where they
are supposed to move to. i.e. I label a slice of one ventricle and I look
where this region is moved on the ADC, it does not match with that region on
the ADC after this operation.

Is (qform_ADC)^-1 * qform_ROI the correct operation? (* means matrix
multiplication, ^-1 means matrix inversion)

Any help would be appreciated.

Thanks in advance.



--
View this message in context: http://slicer-users.65878.n3.nabble.com/off-topic-qform-matrix-tp4031693.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: off-topic qform matrix

Steve Pieper-2
Hi Felix - 

The complexities and ambiguities of qforms and sforms in nifti headers is one reason we prefer to use NRRD in Slicer.

For your question though, if you know the pixel rasters are the same, maybe use the .hdr/.img form of nifti and just copy the same .hdr for all your images to ensure that the coordinates are uniform?

Best of luck,
Steve

On Wed, Feb 1, 2017 at 6:30 PM, Felix <[hidden email]> wrote:
Hi all,

I'm using Slicer as part of a pipeline for ADC quantification. I convert T1
and T2 files from dicom 2 nifti using dcm2niix and DWI dicom to nifti using
DWIConvert. ADC is easily computed using a R script. ROI are drawn on the
registered T1w and T2w images using Slicer editor (T1w as master volume).

All the series were acquired using the same orientation (purely axial) but
qform matrix differ if I use DWIConvert or dcm2niix or mcverter in order to
transform them from DICOM to NIFTI. Quite strange but this is the situation
so I need to solve this issue.

I use a R script to obtain the statistics so I need to move the ROI from its
T1w's ijk space to the ijk space of the ADC nifti. I use  (qform_ADC)^-1 *
qform_ROI to transform the ijk indexes of those positions labeled in the ROI
.

It looks quite easy but labelled regions do not move to the place where they
are supposed to move to. i.e. I label a slice of one ventricle and I look
where this region is moved on the ADC, it does not match with that region on
the ADC after this operation.

Is (qform_ADC)^-1 * qform_ROI the correct operation? (* means matrix
multiplication, ^-1 means matrix inversion)

Any help would be appreciated.

Thanks in advance.



--
View this message in context: http://slicer-users.65878.n3.nabble.com/off-topic-qform-matrix-tp4031693.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: off-topic qform matrix

Felix
This post has NOT been accepted by the mailing list yet.
Many thanks for your answer Steve.

Is there any other way, apart from DWIConvert, to convert dicom series to nrrd using command line?

ADC images from the Ivy GAP collection in the TCIA, when converted using DWIConvert, behave in a quite strange manner. DWIConvert returns a nift file per dicom file in the folder.

By the way, I agree, nifti standard is very cumbersome.
Reply | Threaded
Open this post in threaded view
|

Re: off-topic qform matrix

Felix
In reply to this post by Steve Pieper-2
Many thanks for your answer Steve.

Is there any other way, apart from DWIConvert, to convert dicom series to
nrrd using command line?

ADC images from the Ivy GAP collection in the TCIA, when converted using
DWIConvert, behave in a quite strange manner. DWIConvert returns a nift file
per dicom file in the folder.

By the way, I agree, nifti standard is very cumbersome.



--
View this message in context: http://slicer-users.65878.n3.nabble.com/off-topic-qform-matrix-tp4031694p4031697.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: off-topic qform matrix

Steve Pieper-2
Hi Felix -

Hmm, I'm not familiar with that data but maybe you should convert all the modalities to nrrd or nift using DWIConvert (it should work on the T1 and T2 I believe).  At least then they should be consistent.  In my experience DWIConvert is the best for handling a diverse set of DWI sequences from various scanners (of course it's impossible to handle all variants).

HTH,
Steve

On Thu, Feb 2, 2017 at 10:12 AM, Felix <[hidden email]> wrote:
Many thanks for your answer Steve.

Is there any other way, apart from DWIConvert, to convert dicom series to
nrrd using command line?

ADC images from the Ivy GAP collection in the TCIA, when converted using
DWIConvert, behave in a quite strange manner. DWIConvert returns a nift file
per dicom file in the folder.

By the way, I agree, nifti standard is very cumbersome.



--
View this message in context: http://slicer-users.65878.n3.nabble.com/off-topic-qform-matrix-tp4031694p4031697.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: off-topic qform matrix

Felix
This post has NOT been accepted by the mailing list yet.
Hi again,

After further investigating this issue, I have found something strange in the way that Slices saves nifti files.

The ROI volume information is shown in this image.

Volume Information in Slicer (ROI)

If I save the file (nii.gz format) and I read it (I've tried it using several programs, matlab and different R packages) then I always get this matrix

qform(fileWrittenBySlicer) =  
             [,1]              [,2]             [,3]          [,4]
[1,] -0.89478517  0.0707415 -0.2624871  97.34348
[2,] -0.07867593 -0.8626230  1.5926364  99.60878
[3,] -0.01896173  0.2409711  5.7783430 -66.21708
[4,]  0.00000000  0.0000000  0.0000000   1.00000

And if I multiply the rows of IJK2RASmatrix shown in the image by the pixel spacing and then append the final displacement column and the final (0,0,0,1) row I get:

            [,1]                 [,2]              [,3]           [,4]
[1,] -0.89475391  0.07070703 -0.03935156  97.343
[2,] -0.07870312 -0.86258984  0.23853516  99.609
[3,] -0.12659057  1.60908017  5.77816969 -66.217
[4,]  0.00000000  0.00000000  0.00000000   1.000

As you can see the orientation information written in the file and that  shown on the GUI do not match.

Is this a bug or am I missing something?

Reply | Threaded
Open this post in threaded view
|

Re: off-topic qform matrix

Felix
In reply to this post by Steve Pieper-2
Hi again,

After further investigating this issue, I have found something strange in
the way that Slices saves nifti files.

The ROI volume information is shown in this image.

<http://slicer-users.65878.n3.nabble.com/file/n4031712/ROIslicer.png>

If I save the file (nii.gz format) and I read it (I've tried it using
several programs, matlab and different R packages) then I always get this
matrix

qform(fileWrittenBySlicer) =  
             [,1]              [,2]             [,3]          [,4]
[1,] -0.89478517  0.0707415 -0.2624871  97.34348
[2,] -0.07867593 -0.8626230  1.5926364  99.60878
[3,] -0.01896173  0.2409711  5.7783430 -66.21708
[4,]  0.00000000  0.0000000  0.0000000   1.00000

And if I multiply the rows of IJK2RASmatrix shown in the image by the pixel
spacing and then append the final displacement column and the final
(0,0,0,1) row I get:

            [,1]                 [,2]              [,3]           [,4]
[1,] -0.89475391  0.07070703 -0.03935156  97.343
[2,] -0.07870312 -0.86258984  0.23853516  99.609
[3,] -0.12659057  1.60908017  5.77816969 -66.217
[4,]  0.00000000  0.00000000  0.00000000   1.000

As you can see the orientation information written in the file and that
shown on the GUI do not match.

Is this a bug or am I missing something?





--
View this message in context: http://slicer-users.65878.n3.nabble.com/off-topic-qform-matrix-tp4031694p4031712.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: off-topic qform matrix

Steve Pieper-2
Hi -

Slicer uses ITK to read and write formats like nifti and it seems to work pretty well.  Maybe you could doublecheck using a small ITK C++ program or SimpleITK in python independent of Slicer and see what you find.

Good luck and let us know what you figure out,
Steve

On Fri, Feb 3, 2017 at 4:09 PM, Felix <[hidden email]> wrote:
Hi again,

After further investigating this issue, I have found something strange in
the way that Slices saves nifti files.

The ROI volume information is shown in this image.

<http://slicer-users.65878.n3.nabble.com/file/n4031712/ROIslicer.png>

If I save the file (nii.gz format) and I read it (I've tried it using
several programs, matlab and different R packages) then I always get this
matrix

qform(fileWrittenBySlicer) =
             [,1]              [,2]             [,3]          [,4]
[1,] -0.89478517  0.0707415 -0.2624871  97.34348
[2,] -0.07867593 -0.8626230  1.5926364  99.60878
[3,] -0.01896173  0.2409711  5.7783430 -66.21708
[4,]  0.00000000  0.0000000  0.0000000   1.00000

And if I multiply the rows of IJK2RASmatrix shown in the image by the pixel
spacing and then append the final displacement column and the final
(0,0,0,1) row I get:

            [,1]                 [,2]              [,3]           [,4]
[1,] -0.89475391  0.07070703 -0.03935156  97.343
[2,] -0.07870312 -0.86258984  0.23853516  99.609
[3,] -0.12659057  1.60908017  5.77816969 -66.217
[4,]  0.00000000  0.00000000  0.00000000   1.000

As you can see the orientation information written in the file and that
shown on the GUI do not match.

Is this a bug or am I missing something?





--
View this message in context: http://slicer-users.65878.n3.nabble.com/off-topic-qform-matrix-tp4031694p4031712.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: off-topic qform matrix

inorton
In reply to this post by Felix
Suggested reading is this page: https://www.slicer.org/wiki/Coordinate_systems

Note that the IJKtoRAS displayed in Slicer is your self-calculated matrix multiplied by the inverse of the spacing vector:

julia> a = [  -0.89475391  0.07070703 -0.03935156
              -0.07870312 -0.86258984  0.23853516
              -0.12659057  1.60908017  5.77816969 ];

julia> a * 1./[.8984, .8984, 5.9995]
3×3 Array{Float64,2}:
 -0.995942    0.0787033  -0.0438018
 -0.0876037  -0.96014     0.265511
 -0.0211002   0.268202    0.963109



On Fri, Feb 3, 2017 at 4:09 PM, Felix <[hidden email]> wrote:
Hi again,

After further investigating this issue, I have found something strange in
the way that Slices saves nifti files.

The ROI volume information is shown in this image.

<http://slicer-users.65878.n3.nabble.com/file/n4031712/ROIslicer.png>

If I save the file (nii.gz format) and I read it (I've tried it using
several programs, matlab and different R packages) then I always get this
matrix

qform(fileWrittenBySlicer) =
             [,1]              [,2]             [,3]          [,4]
[1,] -0.89478517  0.0707415 -0.2624871  97.34348
[2,] -0.07867593 -0.8626230  1.5926364  99.60878
[3,] -0.01896173  0.2409711  5.7783430 -66.21708
[4,]  0.00000000  0.0000000  0.0000000   1.00000

And if I multiply the rows of IJK2RASmatrix shown in the image by the pixel
spacing and then append the final displacement column and the final
(0,0,0,1) row I get:

            [,1]                 [,2]              [,3]           [,4]
[1,] -0.89475391  0.07070703 -0.03935156  97.343
[2,] -0.07870312 -0.86258984  0.23853516  99.609
[3,] -0.12659057  1.60908017  5.77816969 -66.217
[4,]  0.00000000  0.00000000  0.00000000   1.000

As you can see the orientation information written in the file and that
shown on the GUI do not match.

Is this a bug or am I missing something?





--
View this message in context: http://slicer-users.65878.n3.nabble.com/off-topic-qform-matrix-tp4031694p4031712.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: off-topic qform matrix

Felix
This post has NOT been accepted by the mailing list yet.
This is the report: I'm testing the conversion from DICOM to nifti using DWIConvert.

You can download these dicom images from the TCIA, Ivy GAP collection, patient W2, series 500 using the TCIA explorer module or using the GUI provided by TCIA's web.

Dicom tags related to geometrical aspects:

(0018,0050) Slice Thickness                5.000000
(0018,0088) Spacing Between Slices 6.000000
(0020,0037) Image Orientation (Patient) 0.996604\0.0823383\0\-0.0823383\0.996604\0


This is the conversion sentence:

c:\>slicer --launch DWIConvert --conversionMode DicomToFSL  --outputVolume ADCSlicer.nii --inputDicomDirectory C:\Temp\W2_500_DICOM --outputDirectory ./ --echo >> ConversionSlicer.log

This is the important content of ConversionSlicer.log file:

=================== this->m_SlicesPerVolume:25
Dicom images are ordered in a volume interleaving way.
ImageOrientationPatient (0020:0037): LPS Orientation Matrix
0.996604 -0.0823383 0
0.0823383 0.996604 -0
0 0 0.999999

this->m_SpacingMatrix
0.9375 0 0
0 0.9375 0
0 0 5

NRRDSpaceDirection
0.934316 -0.0771922 0
0.0771922 0.934316 0
0 0 5

Slice 0: -109.284 -161.358 -82.5368
Slice 1: -109.284 -161.358 -76.5368
Slice order is IS
Number of Slices: 25
Number of Volume: 1
Number of Slices in each volume: 25
B-value: 1000; diffusion direction: 0, 0, 0
Scale Factor for Multiple BValues: 0 -- sqrt( 1000 / 1000 ) = 1


The first thing that catches my attention is that the pixel spacing is 5 mm instead of 6 mm which is the true IS spacing among the centers of voxels in adjacent slices.

I have converted these files using dcm2niix also: dcm2niix -f ADCdcm2niix -o ./ C:\Temp\W2_500_DICOM which reports:

....
Slice thickness (mm): 5.000000
Slice spacing (mm): 6.000000
Image columns: 256
Image rows: 256
Voxel size x (mm): 0.9375
Voxel size y (mm): 0.9375
....


If you load both volumes on slicer the volume converted with DWIConvert appears upside down and you cannot superpose them because regions do not match.  If your make the conversion using DWIConvert with two steps,DicomToNrrd and then NrrdToFSL, then you get the volume correctly oriented but clearly compressed. Changing the z pixel spacing from 5 to 6 mm solves this issue.

Taking this Z pixel spacing mismatch into account I draw a labelmap using that 2-step DWIConverted volume as master volume, then I save that labelmap using nii format and try to map it over the other one using the information provided in the saved file with a R script.

Qaternions saved (b,c,d): (0,0, -0.9991508)

Qform (ROI over 2 steps  DWIconverted volume) :
            [,1]        [,2] [,3]     [,4]
[1,] -0.93431626  0.07719193    0 109.2840
[2,] -0.07719193 -0.93431626    0 161.3580
[3,]  0.00000000  0.00000000    5 -82.5368
[4,]  0.00000000  0.00000000    0   1.0000

If I fix the position [3,3] changing its value from 5 to 6, the modified positions of the ROI using  qform(ADCdcm2niix)^-1*qform(ROIover2StepsDWIConverted) match perfectly over the volume converted with dcm2niix.

I'm going to perform further investigations, if I find something interesting I'll inform you.
Reply | Threaded
Open this post in threaded view
|

Re: off-topic qform matrix

Felix
In reply to this post by inorton
This is the report: I'm testing the conversion from DICOM to nifti using
DWIConvert.

You can download these dicom images from the TCIA, Ivy GAP collection,
patient W2, series 500 using the TCIA explorer module or using the GUI
provided by TCIA's web.

Dicom tags related to geometrical aspects:

/(0018,0050) Slice Thickness                5.000000
(0018,0088) Spacing Between Slices 6.000000
(0020,0037) Image Orientation (Patient)
0.996604\0.0823383\0\-0.0823383\0.996604\0/

This is the conversion sentence:

c:\>slicer --launch DWIConvert --conversionMode DicomToFSL  --outputVolume
ADCSlicer.nii --inputDicomDirectory C:\Temp\W2_500_DICOM --outputDirectory
./ --echo >> ConversionSlicer.log

This is the important content of ConversionSlicer.log file:

/=================== this->m_SlicesPerVolume:25
Dicom images are ordered in a volume interleaving way.
ImageOrientationPatient (0020:0037): LPS Orientation Matrix
0.996604 -0.0823383 0
0.0823383 0.996604 -0
0 0 0.999999

this->m_SpacingMatrix
0.9375 0 0
0 0.9375 0
0 0 5

NRRDSpaceDirection
0.934316 -0.0771922 0
0.0771922 0.934316 0
0 0 5

Slice 0: -109.284 -161.358 -82.5368
Slice 1: -109.284 -161.358 -76.5368
Slice order is IS
Number of Slices: 25
Number of Volume: 1
Number of Slices in each volume: 25
B-value: 1000; diffusion direction: 0, 0, 0
Scale Factor for Multiple BValues: 0 -- sqrt( 1000 / 1000 ) = 1/

The first thing that catches my attention is that the pixel spacing is 5 mm
instead of 6 mm which is the true IS spacing among the centers of voxels in
adjacent slices.

I have converted these files using dcm2niix also: dcm2niix -f ADCdcm2niix -o
./ C:\Temp\W2_500_DICOM which reports:
/
....
Slice thickness (mm): 5.000000
Slice spacing (mm): 6.000000
Image columns: 256
Image rows: 256
Voxel size x (mm): 0.9375
Voxel size y (mm): 0.9375
....
/

If you load both volumes on slicer the volume converted with DWIConvert
appears upside down and you cannot superpose them because regions do not
match.  If your make the conversion using DWIConvert with two
steps,DicomToNrrd and then NrrdToFSL, then you get the volume correctly
oriented but clearly compressed. Changing the z pixel spacing from 5 to 6 mm
solves this issue.

Taking this Z pixel spacing mismatch into account I draw a labelmap using
that 2-step DWIConverted volume as master volume, then I save that labelmap
using nii format and try to map it over the other one using the information
provided in the saved file with a R script.

Qaternions saved (b,c,d): (0,0, -0.9991508)

Qform (ROI over 2 steps  DWIconverted volume) :
            [,1]        [,2] [,3]     [,4]
[1,] -0.93431626  0.07719193    0 109.2840
[2,] -0.07719193 -0.93431626    0 161.3580
[3,]  0.00000000  0.00000000    5 -82.5368
[4,]  0.00000000  0.00000000    0   1.0000

If I fix the position [3,3] changing its value from 5 to 6, the modified
positions of the ROI using
qform(ADCdcm2niix)^-1*qform(ROIover2StepsDWIConverted) match perfectly over
the volume converted with dcm2niix.

I'm going to perform further investigations, if I find something interesting
I'll inform you.




--
View this message in context: http://slicer-users.65878.n3.nabble.com/off-topic-qform-matrix-tp4031694p4031726.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: off-topic qform matrix

Steve Pieper-2
Hi Felix - 

Thanks for the detailed analysis - it does look like a bug in DWIConvert if it is using the slice thickness instead of the distance between slices (there's discussion of that topic here [1] in the context of segmentations).

DWIConvert is part of the BRAINSTools package [2] so I'd say this [3] is the right place to file an issue.  Is it possible for you to include an example dataset to reproduce the issue?

-Steve


[1] http://dclunie.blogspot.com/2013/10/how-thick-am-i-sad-story-of-lonely-slice.html




On Tue, Feb 7, 2017 at 1:37 PM, Felix <[hidden email]> wrote:
This is the report: I'm testing the conversion from DICOM to nifti using
DWIConvert.

You can download these dicom images from the TCIA, Ivy GAP collection,
patient W2, series 500 using the TCIA explorer module or using the GUI
provided by TCIA's web.

Dicom tags related to geometrical aspects:

/(0018,0050)    Slice Thickness                 5.000000
(0018,0088)     Spacing Between Slices  6.000000
(0020,0037)     Image Orientation (Patient)
0.996604\0.0823383\0\-0.0823383\0.996604\0/

This is the conversion sentence:

c:\>slicer --launch DWIConvert --conversionMode DicomToFSL  --outputVolume
ADCSlicer.nii --inputDicomDirectory C:\Temp\W2_500_DICOM --outputDirectory
./ --echo >> ConversionSlicer.log

This is the important content of ConversionSlicer.log file:

/=================== this->m_SlicesPerVolume:25
Dicom images are ordered in a volume interleaving way.
ImageOrientationPatient (0020:0037): LPS Orientation Matrix
0.996604 -0.0823383 0
0.0823383 0.996604 -0
0 0 0.999999

this->m_SpacingMatrix
0.9375 0 0
0 0.9375 0
0 0 5

NRRDSpaceDirection
0.934316 -0.0771922 0
0.0771922 0.934316 0
0 0 5

Slice 0: -109.284 -161.358 -82.5368
Slice 1: -109.284 -161.358 -76.5368
Slice order is IS
Number of Slices: 25
Number of Volume: 1
Number of Slices in each volume: 25
B-value: 1000; diffusion direction: 0, 0, 0
Scale Factor for Multiple BValues: 0 -- sqrt( 1000 / 1000 ) = 1/

The first thing that catches my attention is that the pixel spacing is 5 mm
instead of 6 mm which is the true IS spacing among the centers of voxels in
adjacent slices.

I have converted these files using dcm2niix also: dcm2niix -f ADCdcm2niix -o
./ C:\Temp\W2_500_DICOM which reports:
/
....
Slice thickness (mm): 5.000000
Slice spacing (mm): 6.000000
Image columns: 256
Image rows: 256
Voxel size x (mm): 0.9375
Voxel size y (mm): 0.9375
....
/

If you load both volumes on slicer the volume converted with DWIConvert
appears upside down and you cannot superpose them because regions do not
match.  If your make the conversion using DWIConvert with two
steps,DicomToNrrd and then NrrdToFSL, then you get the volume correctly
oriented but clearly compressed. Changing the z pixel spacing from 5 to 6 mm
solves this issue.

Taking this Z pixel spacing mismatch into account I draw a labelmap using
that 2-step DWIConverted volume as master volume, then I save that labelmap
using nii format and try to map it over the other one using the information
provided in the saved file with a R script.

Qaternions saved (b,c,d): (0,0, -0.9991508)

Qform (ROI over 2 steps  DWIconverted volume) :
            [,1]        [,2] [,3]     [,4]
[1,] -0.93431626  0.07719193    0 109.2840
[2,] -0.07719193 -0.93431626    0 161.3580
[3,]  0.00000000  0.00000000    5 -82.5368
[4,]  0.00000000  0.00000000    0   1.0000

If I fix the position [3,3] changing its value from 5 to 6, the modified
positions of the ROI using
qform(ADCdcm2niix)^-1*qform(ROIover2StepsDWIConverted) match perfectly over
the volume converted with dcm2niix.

I'm going to perform further investigations, if I find something interesting
I'll inform you.




--
View this message in context: http://slicer-users.65878.n3.nabble.com/off-topic-qform-matrix-tp4031694p4031726.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: off-topic qform matrix

O'Donnell, Lauren J., Ph.D.
Dear Steve and Felix,

This may relate to a bug I previously reported here about "slice gap is ignored on Siemens DWI"


I agree that reporting directly in DWIConvert is a good idea.

Lauren

Lauren J. O’Donnell, Ph.D.
Assistant Professor, Harvard Medical School
http://scholar.harvard.edu/laurenjodonnell
1249 Boylston St., Room #210
Boston, Massachusetts 02215
[hidden email]


On Feb 7, 2017, at 1:56 PM, Steve Pieper <[hidden email]> wrote:

Hi Felix - 

Thanks for the detailed analysis - it does look like a bug in DWIConvert if it is using the slice thickness instead of the distance between slices (there's discussion of that topic here [1] in the context of segmentations).

DWIConvert is part of the BRAINSTools package [2] so I'd say this [3] is the right place to file an issue.  Is it possible for you to include an example dataset to reproduce the issue?

-Steve


[1] http://dclunie.blogspot.com/2013/10/how-thick-am-i-sad-story-of-lonely-slice.html




On Tue, Feb 7, 2017 at 1:37 PM, Felix <[hidden email]> wrote:
This is the report: I'm testing the conversion from DICOM to nifti using
DWIConvert.

You can download these dicom images from the TCIA, Ivy GAP collection,
patient W2, series 500 using the TCIA explorer module or using the GUI
provided by TCIA's web.

Dicom tags related to geometrical aspects:

/(0018,0050)    Slice Thickness                 5.000000
(0018,0088)     Spacing Between Slices  6.000000
(0020,0037)     Image Orientation (Patient)
0.996604\0.0823383\0\-0.0823383\0.996604\0/

This is the conversion sentence:

c:\>slicer --launch DWIConvert --conversionMode DicomToFSL  --outputVolume
ADCSlicer.nii --inputDicomDirectory C:\Temp\W2_500_DICOM --outputDirectory
./ --echo >> ConversionSlicer.log

This is the important content of ConversionSlicer.log file:

/=================== this->m_SlicesPerVolume:25
Dicom images are ordered in a volume interleaving way.
ImageOrientationPatient (0020:0037): LPS Orientation Matrix
0.996604 -0.0823383 0
0.0823383 0.996604 -0
0 0 0.999999

this->m_SpacingMatrix
0.9375 0 0
0 0.9375 0
0 0 5

NRRDSpaceDirection
0.934316 -0.0771922 0
0.0771922 0.934316 0
0 0 5

Slice 0: -109.284 -161.358 -82.5368
Slice 1: -109.284 -161.358 -76.5368
Slice order is IS
Number of Slices: 25
Number of Volume: 1
Number of Slices in each volume: 25
B-value: 1000; diffusion direction: 0, 0, 0
Scale Factor for Multiple BValues: 0 -- sqrt( 1000 / 1000 ) = 1/

The first thing that catches my attention is that the pixel spacing is 5 mm
instead of 6 mm which is the true IS spacing among the centers of voxels in
adjacent slices.

I have converted these files using dcm2niix also: dcm2niix -f ADCdcm2niix -o
./ C:\Temp\W2_500_DICOM which reports:
/
....
Slice thickness (mm): 5.000000
Slice spacing (mm): 6.000000
Image columns: 256
Image rows: 256
Voxel size x (mm): 0.9375
Voxel size y (mm): 0.9375
....
/

If you load both volumes on slicer the volume converted with DWIConvert
appears upside down and you cannot superpose them because regions do not
match.  If your make the conversion using DWIConvert with two
steps,DicomToNrrd and then NrrdToFSL, then you get the volume correctly
oriented but clearly compressed. Changing the z pixel spacing from 5 to 6 mm
solves this issue.

Taking this Z pixel spacing mismatch into account I draw a labelmap using
that 2-step DWIConverted volume as master volume, then I save that labelmap
using nii format and try to map it over the other one using the information
provided in the saved file with a R script.

Qaternions saved (b,c,d): (0,0, -0.9991508)

Qform (ROI over 2 steps  DWIconverted volume) :
            [,1]        [,2] [,3]     [,4]
[1,] -0.93431626  0.07719193    0 109.2840
[2,] -0.07719193 -0.93431626    0 161.3580
[3,]  0.00000000  0.00000000    5 -82.5368
[4,]  0.00000000  0.00000000    0   1.0000

If I fix the position [3,3] changing its value from 5 to 6, the modified
positions of the ROI using
qform(ADCdcm2niix)^-1*qform(ROIover2StepsDWIConverted) match perfectly over
the volume converted with dcm2niix.

I'm going to perform further investigations, if I find something interesting
I'll inform you.




--
View this message in context: http://slicer-users.65878.n3.nabble.com/off-topic-qform-matrix-tp4031694p4031726.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ

_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: off-topic qform matrix

Felix
Done, you can follow it on [3] from Steve's post.

Dicom files that I mention from TCIA are public, anonymous and can be
downloaded if you wish to repeat the process.  :)



--
View this message in context: http://slicer-users.65878.n3.nabble.com/off-topic-qform-matrix-tp4031694p4031730.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: off-topic qform matrix

Felix
This post has NOT been accepted by the mailing list yet.
In reply to this post by O'Donnell, Lauren J., Ph.D.
Done, you can follow it on [3] from Steve's post.

Dicom files that I mention from TCIA are public, anonymous and can be downloaded if you wish to repeat the process.  :)