This toolbox can read and write medical imaging data in dicom format with the 'readImages' function. The output of this function is a structure containing attributes of the image or volume. This structure can then be used as input into other functions in the toolbox.
This toolbox supports:
- reading and writing of dicom data
- mapping of volume voxel locations
- oblique slice alignment and registration
- manual 3D image rotation
- selecting and extracting single voxel coordinates
- drawing 2D or 3D region-of-interest masks
- coregistered image viewing supports PET/CT and PET/MR
CT = readImages([CT_ImageDirectoryPath]);
PET = readImages([PET_ImageDirectoryPath]);
coords = VolumeViewer3D(PET,CT,'getCoords');
mask = VolumeViewer3D(PET,CT,'drawROI');
you can do this easily (e.g. if your mask has the same dimensions as PET.volumes):
mask = logical(mask);
Sorry Josh, i have presented my question badly. In fact, I have already my mask and I'd like to show it together with PET-CT scan,for example, with "contour" function. But i'm not sure where i should add these codes in your original codes.
Thank you :)
For example, say you want make a mask of an image 'Im', matching its dimensions, [imX, imY, imZ], for all pixels above 'threshold' in a 11x11x11 box centered on [x, y, z], you could do something like this:
mask = false(imX, imY, imZ);
mask(x - 5 : x + 5, y - 5 : y + 5, z - 5 : z + 5) = true;
mask = mask & Im > threshold;
Thanks for the reponse. I have fixed missed information in my dicom file :) And SUV works well! I'm now trying to add a contour mask on the image. Hope for suggestions, thank you :)
Thanks Yuntao. The viewer shows PET SUV by default, but it must have all the required information from the Dicom, i.e. injection and scan times, subject mass, image quantification units, and radiotracer. Put a breakpoint on the call to 'calculateSUV', then call it manually from the prompt. This will point to the problem.
Thank you Josh Schaefferkoetter. That's a great job which helps me a lot on my project. I think it will be better if the toolbox can also show the suv value :)
Amazing contribution Josh. This tool helped me a lot :)!
The function was looking for a dicom field that did not exist in those TCIA images. I added a check to avoid this - try the new version. Thanks for pointing this out.
Hi, nice toolbox!
I tried to read in an image from The Cancer Imaging Archive (TCIA) but was unable to. The message is 'File read error, try again with another file'. The message is repeated for any single slice I choose in the series.
The data can be retrieved here: https://public.cancerimagingarchive.net/ncia/externalLinks.jsf?collectionName=QIN-HEADNECK, Subject ID: QIN-HEADNECK-0003
Josh, thank you for the hint. I just doubled each font size and now I have a nice display. I am using your viewer on my iMac 27" with 2560 x 1440 pixels. The original fonts display was really tiny and hard to read. Now it works fine.
Thank your for this helpful toolbox which I am using for my research work!
Thanks for the feedback. The viewer was tested at high DPI and normal 1080 resolution. What size is your display?
The quick fix would be to do a ctrl-F search through VolumeViewer3D.m for 'FontSize' and change all the necessary field values. Let me know which value works best for the screen you are using.
Is there any chance to increase the font size of the sliders, value outputs and handles in the 3D Viewer window? Unfortunately on my machine everything is pretty small on the screen. But besides that drawback the 3D Viewer is superb!
I'll consider adding these to the next version. Thanks for the feedback!
Just in case it is useful for others,
With Matlab2014a I needed to add a try/catch in VolumeViewer3D.m (line 3372)
hAxOffset = 0.0005;
vAxOffset = 0.0005;
hAxOffset = 0.0007;
vAxOffset = 0.001;
Very useful tool. I had to adapt it to read GE images from the cancer imaging archive, because some tags in the dicom info are vendor-specific. I used the dictionary from https://www.mathworks.com/matlabcentral/fileexchange/42997-dicom-to-nifti-converter--nifti-tool-and-viewer
I changed in all cases:
dict = dicm_dict('GE');
meta = dicm_hdr([imageDir '\' imageFile], dict);
meta = dicominfo([imageDir '\' imageFile]);
Where/how should I share the data?
Thanks for the feedback. I wrote the code to prompt for new image data if any errors were found, this is convenient but makes it tricky to troubleshoot - maybe I'll think of a different way to handle this... In the meantime, if you can share your dicom data, I'll take a look.
Please ignore that last comment, I pressed enter by mistake. The current version does not seem to work for me, using the readImages function, even if I provide the directories it opens a file finder, and whenever I select a file it tells me there is a "File read error, try again with another file."
Hello, getting a file read error
The output variable is now initialized as a structure so should fix the problem. Let me know if it still doesn't work.
Looks nice program, but I have a similar problem as payam. After loading GE images with MATLAB 2015b:
Field assignment to a non-structure array object.
Error in VolumeViewer3D>parseInputs (line 397)
out.modality = 'VOL';
Error in VolumeViewer3D (line 36)
inStruct = parseInputs(varargin);
I loaded several PET studies from the TCIA site, including the phantom data, and found a small bug related to the GE and Philips series naming convention; I couldn't reproduce your error though. With which specific data sets were you having issues?
The toolbox seems good.
I have tried to read a PET volume from TCIA (www.cancerimagingarchive.net/) using readImages. I faced this error:
Field assignment to a non-structure array object.
Error in readImages (line 82)
out.nSeries = nSeries;
Also the same error for phantom images. I am using Matlab 2015b.
bug with reading dicom
small bug with writing dicom
fixed bug for reading dicom files with no extension
faster image coregistration
incomplete filename bug fix
ability to combine 2D and 3D, and volume and mask inputs
improved input handling
improved input and error handling
corrected dicom tag writing
UI formatted for high DPI displays
Ability to draw and output 2D or 3D mask
output structure initialization
GE and Philips series naming convention bug fix
fixed smoothing functionality
small bug fix
minor tweaks and enhancements
faster and more accurate interpolation
improved handling of large image matrices
faster and more efficient memory handling