Any way to generate raw files from DICOM?
DglyP opened this issue · 3 comments
I have not been able to find a way to export volume raw data from my DICOM images, so there is no way to use the VolumeAssetBuilder
I have not been able to find a way to export volume raw data from my DICOM images, so there is no way to use the VolumeAssetBuilder
Have you found any solution on this issue?
Currently working on a paper about this, will send you the link when done
I did this about two years ago, so I have no idea if it works now. But back then, I was able to use ImageJ to make the .raw files. Here's a step-by-step:
-
Download ImageJ. No extra plug-ins should be necessary.
-
Go to File > Import > Image Sequence, and click the first dicom slice in the folder where you stored your batch of slices for a particular organ/scan/area of interest. When preparing your dicoms, consider keeping the image resolution to 256x256 or lower, and 256 slices. You can load more into ImageJ of course, but when you export the .raw for use in Unity, larger dicoms tend to clog memory, and this might become a concern if you're shipping to mobile devices.
-
Go to Image > Type, and convert the image to 8-bit, if it's not already 8-bit. This relaxes memory constraints.
-
Go to Image > Properties, and change the units to pixels. Then change all the dimensions to 1, 1, and 1: pixel width, height, and voxel depth.
-
If you want to highlight different sections/densities of anatomy, go to Image > Adjust > Brightness/Contrast to play around with the curves. Of especial interest will likely be increasing the "minimum," which will get rid of skin/fat/muscle data, then denser things like bone data. Be sure to click "apply," to all images in the stack.
-
You can also fill parts of the image to get rid of any consistent artifacts with pure black. For example, your dicom may keep the back of the machine in its scan. Go to Image > Color > Color Picker to select a 0,0,0 black. Then select an area with the polygon/lasso tools to apply a fill uniformly to all slices in the image stack.
-
This part is also highly suggested to conserve memory and improve speed of the Unity game. Crop your image to something smaller using Image > Crop after selecting an area of interest with the polygon tool. Be sure to record the resolution, which you will need to know exactly to export the file correctly.
-
Alternatively, or in conjunction with step 7, use Image > Scale to rescale the image to something smaller. This will apply to all images in the stack.
-
When the dicom is edited to your liking, go to File > Save As > Raw Data. When naming the file, add a ".raw" at the end, or else Windows will not necessarily indicate that it is such. When doing this, you will be prompted with a few options, most important of which are the resolution of each image, and the number of slices. The number of slices, if too high or too low, will not ruin the file -- you will merely export only the first n images. If the resolution is wrong, the file is corrupted. Be sure to input the correct resolution.
-
Once imported into Unity, go to Window > Editor, and use the custom editor script, "VolumeAssetBuilder." Input the .raw file you imported into the window that pops up. Input the correct resolution and slice count. If the input is wrong, or at any point the right unit is not used to describe the pixel size and voxel depth in step 4, the renderer will fail.
-
Once the .asset file is made, select the VolumeRendering gameObject in the scene, and in the Volume input under Volume Rendering (Script) in the Inspector tab, input the .asset file.