Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to generate raw files from DICOM? #9

Open
DglyP opened this issue Mar 5, 2019 · 3 comments
Open

Any way to generate raw files from DICOM? #9

DglyP opened this issue Mar 5, 2019 · 3 comments

Comments

@DglyP
Copy link

DglyP commented Mar 5, 2019

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

@Dafun1
Copy link

Dafun1 commented Sep 30, 2019

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?

@DglyP
Copy link
Author

DglyP commented Oct 21, 2019

Currently working on a paper about this, will send you the link when done

@malyalar
Copy link

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:

  1. Download ImageJ. No extra plug-ins should be necessary.

  2. 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.

  3. Go to Image > Type, and convert the image to 8-bit, if it's not already 8-bit. This relaxes memory constraints.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

  8. 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.

  9. 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.

  10. 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.

  11. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants