# Importing a large number of 2d DICOM images and generating a 3D image from them [closed]

I would like to construct a 3D image from 900 2D images in DICOM format in a folder. I am fairly new to mathematica and would greatly appreciate your help. I am currently using Mathematica 11. I used the following loop code to import all the images. Now the images are stored under the variable names imagevar[1], imagevar[2], imagevar[3] so on till imagevar[968]. Now I am trying to use Image3D to generate the 3d image from these variables and it is working when I incorporate the variables into into Image3D function individually (This is the code: Image3D[{imagevar[1],imagevar[2],....,imagevar[968]}] ) but this would take ridiculously long. . I tried using various loop methods to do it faster but it does not seem to work. Please explain how to generate the 3d image in a quick way. Thank you.

## closed as off-topic by m_goldberg, MarcoB, happy fish, yohbs, J. M. is away♦May 20 '17 at 6:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – m_goldberg, MarcoB, happy fish, yohbs, J. M. is away
If this question can be reworded to fit the rules in the help center, please edit the question.

• What FileNames["somePath/*.dcm"] returns for you? Is it a list of filenames? Also please upload somewhere a subset of your images in order to allow us to experiment with them. You can upload for example to sendspace.com or to filefactory.com. – Alexey Popkov May 17 '17 at 3:54
• Hello, I have edited the question and have figured out how to import these files. Please help. Thank you – Shriram Bobbili May 17 '17 at 18:09
• Without you supplying (a subset of) the images, it'd be hard to help you. – J. M. is away May 17 '17 at 18:14
• It looks like you want Image3D[Array[imagevar, 968]] – Simon Woods May 17 '17 at 18:37

Image3D@Array[imagevar, 968] (* or Image3D@Table[imagevar[k], {k,968}] etc.*)

1. Mathematica's Image3D is made for images and not for MRImages; when you load your data into an Image3D, it will normalize all of the values to be in the range of 0-1. For most MRI this doesn't matter, but if you are hoping to be rely on the voxel contrast to be a particular value (e.g., some programs rely on white matter voxels to be approximately a certain value), you'll lose that ability.
2. If you are dealing with brain data, then one way around this problem is to convert the file to a Nifti file (e.g., using FreeSurfer or some other free sofrware) then load it using the Neurotica package, which is freely available on github. If you've imported Neurotica, Import["someFile.nii", "NifTI"] will return an MRImage3D object (which is defined by the library); these objects imitate Image3D objects but store the original values instead of rescaled values. (They also have some reorientation functions defined on them if you are dealing with oriented brain data.) Note: Neurotica is a research toolkit I maintain; it's mostly for cortical surface analysis so the volumetric routines aren't well tested. I would only recommend this if you are dealing with brain data and want the original values preserved.
• You'll need to do something like Image3D[Array[imagevar, 100, {200,300}]] or `Image3D@Table[imagevar[k], {k, 200, 300}]; you can refer to this help page: reference.wolfram.com/language/ref/Array.html – nben May 20 '17 at 2:13