SimpleITK not working with any data type, be it 3D or 2D










0















I'm using SimpleITK to load in a layered tiff image, its a volumetric image having 30 planes/slices.



After playing around a lot with skimage and imageio Ive found out that SimpleITK is the best way to handle volumetric images but the problem is that none of the functions seem to work for my image.



img = sitk.ReadImage(path)


After reading the image in, I can easily convert it to numpy and even display it using sitk.Show() so its loading up properly. but any function I use on it such as:



img_s = sitk.CurvatureFlow(img, 0.125, 5)
# or
sitk.IntensityWindowing(img)
# or
img_m = sitk.ConnectedThreshold(img, (257,419,7))


gives the warning:




sitk::ERROR: Pixel type: vector of 16-bit unsigned integer is not
supported in 3D byclass itk::simple::




I tried casting to to any other datatype as well but I keep getting errors again:



img2 = sitk.Cast(img, sitk.sitkFloat32)



sitk::ERROR: Filter does not support casting from casting vector of
16-bit unsigned integer to 32-bit float




I tried a 2D variation as well of the above:



img_m = sitk.ConnectedThreshold(img2[:,:,7], [(257,419)])


but this time I got the error:




sitk::ERROR: Pixel type: vector of 64-bit float is not supported in 2D
byclass itk::simple::ConnectedThresholdImageFilter




Any idea what may be causing this?



P.S. I have read the question: SimpleITK N4BiasFieldCorrection, not working with any data type and I believe this is not a duplicate as his problem is solved by casting whereas mine does not work even for casting.



Thanks










share|improve this question


























    0















    I'm using SimpleITK to load in a layered tiff image, its a volumetric image having 30 planes/slices.



    After playing around a lot with skimage and imageio Ive found out that SimpleITK is the best way to handle volumetric images but the problem is that none of the functions seem to work for my image.



    img = sitk.ReadImage(path)


    After reading the image in, I can easily convert it to numpy and even display it using sitk.Show() so its loading up properly. but any function I use on it such as:



    img_s = sitk.CurvatureFlow(img, 0.125, 5)
    # or
    sitk.IntensityWindowing(img)
    # or
    img_m = sitk.ConnectedThreshold(img, (257,419,7))


    gives the warning:




    sitk::ERROR: Pixel type: vector of 16-bit unsigned integer is not
    supported in 3D byclass itk::simple::




    I tried casting to to any other datatype as well but I keep getting errors again:



    img2 = sitk.Cast(img, sitk.sitkFloat32)



    sitk::ERROR: Filter does not support casting from casting vector of
    16-bit unsigned integer to 32-bit float




    I tried a 2D variation as well of the above:



    img_m = sitk.ConnectedThreshold(img2[:,:,7], [(257,419)])


    but this time I got the error:




    sitk::ERROR: Pixel type: vector of 64-bit float is not supported in 2D
    byclass itk::simple::ConnectedThresholdImageFilter




    Any idea what may be causing this?



    P.S. I have read the question: SimpleITK N4BiasFieldCorrection, not working with any data type and I believe this is not a duplicate as his problem is solved by casting whereas mine does not work even for casting.



    Thanks










    share|improve this question
























      0












      0








      0








      I'm using SimpleITK to load in a layered tiff image, its a volumetric image having 30 planes/slices.



      After playing around a lot with skimage and imageio Ive found out that SimpleITK is the best way to handle volumetric images but the problem is that none of the functions seem to work for my image.



      img = sitk.ReadImage(path)


      After reading the image in, I can easily convert it to numpy and even display it using sitk.Show() so its loading up properly. but any function I use on it such as:



      img_s = sitk.CurvatureFlow(img, 0.125, 5)
      # or
      sitk.IntensityWindowing(img)
      # or
      img_m = sitk.ConnectedThreshold(img, (257,419,7))


      gives the warning:




      sitk::ERROR: Pixel type: vector of 16-bit unsigned integer is not
      supported in 3D byclass itk::simple::




      I tried casting to to any other datatype as well but I keep getting errors again:



      img2 = sitk.Cast(img, sitk.sitkFloat32)



      sitk::ERROR: Filter does not support casting from casting vector of
      16-bit unsigned integer to 32-bit float




      I tried a 2D variation as well of the above:



      img_m = sitk.ConnectedThreshold(img2[:,:,7], [(257,419)])


      but this time I got the error:




      sitk::ERROR: Pixel type: vector of 64-bit float is not supported in 2D
      byclass itk::simple::ConnectedThresholdImageFilter




      Any idea what may be causing this?



      P.S. I have read the question: SimpleITK N4BiasFieldCorrection, not working with any data type and I believe this is not a duplicate as his problem is solved by casting whereas mine does not work even for casting.



      Thanks










      share|improve this question














      I'm using SimpleITK to load in a layered tiff image, its a volumetric image having 30 planes/slices.



      After playing around a lot with skimage and imageio Ive found out that SimpleITK is the best way to handle volumetric images but the problem is that none of the functions seem to work for my image.



      img = sitk.ReadImage(path)


      After reading the image in, I can easily convert it to numpy and even display it using sitk.Show() so its loading up properly. but any function I use on it such as:



      img_s = sitk.CurvatureFlow(img, 0.125, 5)
      # or
      sitk.IntensityWindowing(img)
      # or
      img_m = sitk.ConnectedThreshold(img, (257,419,7))


      gives the warning:




      sitk::ERROR: Pixel type: vector of 16-bit unsigned integer is not
      supported in 3D byclass itk::simple::




      I tried casting to to any other datatype as well but I keep getting errors again:



      img2 = sitk.Cast(img, sitk.sitkFloat32)



      sitk::ERROR: Filter does not support casting from casting vector of
      16-bit unsigned integer to 32-bit float




      I tried a 2D variation as well of the above:



      img_m = sitk.ConnectedThreshold(img2[:,:,7], [(257,419)])


      but this time I got the error:




      sitk::ERROR: Pixel type: vector of 64-bit float is not supported in 2D
      byclass itk::simple::ConnectedThresholdImageFilter




      Any idea what may be causing this?



      P.S. I have read the question: SimpleITK N4BiasFieldCorrection, not working with any data type and I believe this is not a duplicate as his problem is solved by casting whereas mine does not work even for casting.



      Thanks







      python python-3.x multidimensional-array itk simpleitk






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 16:12









      StuckInPhDStuckInPhD

      84032144




      84032144






















          1 Answer
          1






          active

          oldest

          votes


















          1














          It looks like your image has a vector pixel type. Many filters don't work on vector pixels. You would need to select one particular element of the vector to apply such filters.



          You can use the VectorIndexSelectionCastImageFilter or the function VectorIndexSelectionCast to extract a particular channel of the vector out to a scalar image.






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53285102%2fsimpleitk-not-working-with-any-data-type-be-it-3d-or-2d%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            It looks like your image has a vector pixel type. Many filters don't work on vector pixels. You would need to select one particular element of the vector to apply such filters.



            You can use the VectorIndexSelectionCastImageFilter or the function VectorIndexSelectionCast to extract a particular channel of the vector out to a scalar image.






            share|improve this answer



























              1














              It looks like your image has a vector pixel type. Many filters don't work on vector pixels. You would need to select one particular element of the vector to apply such filters.



              You can use the VectorIndexSelectionCastImageFilter or the function VectorIndexSelectionCast to extract a particular channel of the vector out to a scalar image.






              share|improve this answer

























                1












                1








                1







                It looks like your image has a vector pixel type. Many filters don't work on vector pixels. You would need to select one particular element of the vector to apply such filters.



                You can use the VectorIndexSelectionCastImageFilter or the function VectorIndexSelectionCast to extract a particular channel of the vector out to a scalar image.






                share|improve this answer













                It looks like your image has a vector pixel type. Many filters don't work on vector pixels. You would need to select one particular element of the vector to apply such filters.



                You can use the VectorIndexSelectionCastImageFilter or the function VectorIndexSelectionCast to extract a particular channel of the vector out to a scalar image.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 13 '18 at 20:13









                Dave ChenDave Chen

                14416




                14416



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53285102%2fsimpleitk-not-working-with-any-data-type-be-it-3d-or-2d%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

                    Museum of Modern and Contemporary Art of Trento and Rovereto