2
$\begingroup$

The 12.1 reimplementation of import for DICOM data seems to bring in the data from a single slice as a NumericArray, In the past, the data would be returned as a list of lists of numbers {{1,1,1,...},{2,2,2,,,},...}.

This change to an Experimental feature has broken a bit of really old code for me. I am wondering if there is a way to redefine the data import in a way that restores the behavior i have utilized in the past.

For example, in the past, to view non-planar image, i could just import the data from a list of files:

UseData=(Import[#,"Data"]&)/@UseFNList;

Then select the data to display in the list indices:

Print[ArrayPlot[UseData[[All,255,1;;255]]]];

The issue is from accessing the array. The command UseData[[All,255,1;;255]] results in an error:

Part::Cannot take positions 10 through 100 in {NumericArray[Type: UnsignedInteger, Length: 512],NumericArray[Type: UnsignedInteger, Length: 512],NumericArray[Type: UnsignedInteger, Length: 512],...}

It's not so bad, but now the import operation requires the additional step of applying Normal to the typed array:

UseData=(Normal[Import[#,"Data"]]&)/@UseFNList;

I can do a search and replace through all the libraries, but i am wondering if there is a smarter way to fix my issue. Any suggestions would be appreciated.

Thank you,

Mark

$\endgroup$
2
  • $\begingroup$ ArrayPlot usually works fine with NumericArray, it's surprising that it doesn't work here. $\endgroup$
    – MassDefect
    Apr 9, 2020 at 18:12
  • $\begingroup$ @MassDefect Thanks! The issue isn't from the use of ArrayPlot, it's from trying to view the array edge-on. I will clean up the question to make that more clear. $\endgroup$
    – xsk8rat
    Apr 11, 2020 at 1:42

1 Answer 1

3
$\begingroup$

If what you need is specifically to get "Data" in packed array ("list of numbers") instead of NumericArray, then I do not see any better solution than Normalizing. There is no Import element that would give exactly what you want.

As for

to view non-planar image, i could just import the data (...)

Perhaps Import[xxx.dcm, "Image"], which gives the Image object directly, would be a better choice here.

$\endgroup$
1
  • $\begingroup$ Thanks @raflac! That would import as a list of images. $\endgroup$
    – xsk8rat
    Apr 11, 2020 at 1:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.