[ITK-users] Reading nifti files

Cyril Mory cyril.mory at creatis.insa-lyon.fr
Thu Mar 23 04:37:52 EDT 2017


Hi Tobias,

Indeed, I had a conversation with my (remote) colleague, and he admitted 
that he used only the sform in his code, and did not maintain the qform 
so that they match. And obviously, ITK was using the qform.

Thanks for your help,

Cyril


On 22/03/2017 12:06, Wood, Tobias wrote:
>
> Hi Cyril,
>
> I use NIFTI all the time, it generally works.
>
> Which transform in the header does your collaborator use? There are 
> (annoyingly) two in NIFTI, the qform and the sform. ITK generally uses 
> the qform, because the sform can include transformations (shears) that 
> the ITK Image class does not support (ITK as a whole supports them, 
> but in a different place). The easiest way I know to check this is 
> with FSL’s fslhd command, which will print out both.
>
> I know there were some changes to ITK’s NIFTI support very recently 
> (just before Christmas if my memory serves). Essentially, ITK now 
> follows the NIFTI standard exactly. One of the things the NIFTI 
> standard specifies is when to use the qform and when to use the sform. 
> Unfortunately, most other packages (and ITK previously) were very 
> relaxed about this and did not follow the spec, often doing things 
> like setting qform=sform or having an invalid combination of 
> qform_code/sform_code.
>
> I have a suspicion that your sforms/qforms are messed up. In which 
> case, the fslorient tool is your friend.
>
> On the other hand, I might be wrong entirely.
>
> Good luck,
>
> Toby
>
> On 17/03/2017, 15:46, "Insight-users on behalf of Cyril Mory" 
> <insight-users-bounces at itk.org <mailto:insight-users-bounces at itk.org> 
> on behalf of cyril.mory at creatis.insa-lyon.fr 
> <mailto:cyril.mory at creatis.insa-lyon.fr>> wrote:
>
> Thanks for this answer.
> By manipulation, I essentially mean reading a 6D .nii file, extracting 
> sub images, and writing them to .mhd format, hopefully keeping the 
> correct image information throughout the process.
> I'll see if my colleague can write to a more recent format, and 
> otherwise follow your advice about ReadUnknownImageType.
>
> Best,
> Cyril
>
> On 17/03/2017 16:34, Sarthak P wrote:
>
>     For NIfTI I/O, I'd suggest you stick to the latest tags as they up
>     to date regarding the latest standards.
>
>     What exactly do you mean my manipulation? There is an ITK filter
>     to change image information
>     (https://itk.org/Doxygen/html/classitk_1_1ChangeInformationImageFilter.html
>     <https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fitk.org%2FDoxygen%2Fhtml%2Fclassitk_1_1ChangeInformationImageFilter.html&data=01%7C01%7Ctobias.wood%40kcl.ac.uk%7C3654a392b8ba4569caae08d46d4cec6c%7C8370cf1416f34c16b83c724071654356%7C0&sdata=dBIaLuW9cuJJDxu%2BX0x4rWtiBGOASxpzLDv%2Fopw1BIg%3D&reserved=0>)
>     but that only happens AFTER itk::ImageFileReader has done its work.
>
>     Could you possibly try to get your collaborator to write a few
>     images using a latest variant of ITK (preferably version matched
>     with yours for consistency)? If not, then perhaps try to read the
>     information in the header using the example in
>     https://itk.org/Wiki/ITK/Examples/IO/ReadUnknownImageType
>     <https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fitk.org%2FWiki%2FITK%2FExamples%2FIO%2FReadUnknownImageType&data=01%7C01%7Ctobias.wood%40kcl.ac.uk%7C3654a392b8ba4569caae08d46d4cec6c%7C8370cf1416f34c16b83c724071654356%7C0&sdata=ljw8WLGmx8DhaWY6D4a1EGV5Jyp5QchPUvfK0Px%2Fo6Y%3D&reserved=0>
>     and then do comparisons between what you expect.
>
>     All the best,
>
>     S
>
>     On Fri, Mar 17, 2017 at 11:21 AM, Cyril Mory
>     <cyril.mory at creatis.insa-lyon.fr
>     <mailto:cyril.mory at creatis.insa-lyon.fr>> wrote:
>
>         Hi ITK users,
>
>         I have recently started working with nifti files, to
>         collaborate with a colleague that uses this format. But the
>         itk::ImageFileReader does not correctly open the nifti files I
>         have (image size, offset and direction matrix are wrong). I
>         use a recent version of ITK (commit from Feb 6 18:02:49 2017),
>         but my colleague has his own fork from nifti_reg, which is
>         several years old.
>
>         Two questions:
>         - Does someone have experience in manipulating nifti files
>         from ITK, and if so, is it supposed to work fine ?
>         - Have there been important modifications in the nifti format
>         in the last years, which the ITK reader would have followed,
>         and which could cause the issues I'm seeing when opening old
>         ones ?
>
>         Best regards,
>         Cyril
>         _____________________________________
>         Powered by www.kitware.com
>         <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com&data=01%7C01%7Ctobias.wood%40kcl.ac.uk%7C3654a392b8ba4569caae08d46d4cec6c%7C8370cf1416f34c16b83c724071654356%7C0&sdata=uur9nTdox7kHhrbmnKJDqM0YgQELo8xR9FsFm8arsbg%3D&reserved=0>
>
>         Visit other Kitware open-source projects at
>         http://www.kitware.com/opensource/opensource.html
>         <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com%2Fopensource%2Fopensource.html&data=01%7C01%7Ctobias.wood%40kcl.ac.uk%7C3654a392b8ba4569caae08d46d4cec6c%7C8370cf1416f34c16b83c724071654356%7C0&sdata=FZrXfS6b%2F7ydigP4WrlawiYQlBIEWkwky9HpMj0XGEQ%3D&reserved=0>
>
>         Kitware offers ITK Training Courses, for more information visit:
>         http://www.kitware.com/products/protraining.php
>         <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com%2Fproducts%2Fprotraining.php&data=01%7C01%7Ctobias.wood%40kcl.ac.uk%7C3654a392b8ba4569caae08d46d4cec6c%7C8370cf1416f34c16b83c724071654356%7C0&sdata=bbVRUclgLtPG3ePXn32qJOUFcxKCfgRa%2FI%2F7Gm1qONE%3D&reserved=0>
>
>         Please keep messages on-topic and check the ITK FAQ at:
>         http://www.itk.org/Wiki/ITK_FAQ
>         <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.itk.org%2FWiki%2FITK_FAQ&data=01%7C01%7Ctobias.wood%40kcl.ac.uk%7C3654a392b8ba4569caae08d46d4cec6c%7C8370cf1416f34c16b83c724071654356%7C0&sdata=hYirR9%2F2JGNfAmeIbWtejSZ3oOctiCjFzY3pFpI3z3I%3D&reserved=0>
>
>         Follow this link to subscribe/unsubscribe:
>         http://public.kitware.com/mailman/listinfo/insight-users
>         <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpublic.kitware.com%2Fmailman%2Flistinfo%2Finsight-users&data=01%7C01%7Ctobias.wood%40kcl.ac.uk%7C3654a392b8ba4569caae08d46d4cec6c%7C8370cf1416f34c16b83c724071654356%7C0&sdata=sCWoAvSF0JewswDVZUcmjLmhAOQ8SkRtsbm48uyBC34%3D&reserved=0>
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20170323/33f6584b/attachment.html>


More information about the Insight-users mailing list