"sara sacchi" <sara_...@hotmail.com> wrote in message <gi4496$5k$1...@fred.mathworks.com>...
-Jeff
"sara sacchi" <sara_...@hotmail.com> wrote in message <gj7sea$93r$1...@fred.mathworks.com>...
Sounds great - I am also really interested in how you did the multiframe dicomwrite to a single file.
Can you maybe upload your code or give a hint?
And yes, an implementation by MATLAB would be great.
"Jeffrey " <i...@removeforspam.jhu.edu> wrote in message <guf701$18r$1...@fred.mathworks.com>...
The rest of the functionality for a multiframe write is there, so once you implement the above changes, it seems to work fine. I'm no expert on dicom format and I don't know if the resulting dicom file meets dicom specs, but all I needed was the data and not the remaining dicom info, so this worked for me.
Great that you figured it out :) I've been trying to modify the functions according to your description but I can't get it to work. Could you maybe post the exact changes you made?
Many thanks,
M
Hi M,
First, I created a copy of the private directory .../toolbox/images/iptformats/private and dicomwrite so I didn't muck things up with the original version. Then, in the dicom_encode_jpeg_lossy.m file, I modified frames to reflect the true number of frames and added a for loop:
frames = size(X,4);
for p = 1:frames
tempfile = tempname;
imwrite(X(:,:,:,p), tempfile, 'jpeg');
.....
%frames = 1;
.....
end
Next, in dicomwrite.m I commented out the for loop that cycled through the frames, removed the dependency of X on p, and changed the destination to filename, all in the write_message subfunction:
.....
%for p = 1:num_frames
.....
[attrs, msg, status] = dicom_create_IOD(SOP_UID, X, map, ...
.....
[attrs, msg, status] = dicom_copy_IOD(X, map, ...
,....
destination = filename;
%destination = get_filename(filename, p, num_frames);
.....
%end
That was it. It seemed to work fine for me here, although I was using the 'copy' option. I didn't test it for the other options. It gave me one or two warnings on one of the dicom variables not being correct, but I was okay with that.
Hope this works for you!
-LB
Could you please give me more info on the code for multiframe dicomwrite. I am creating a multiframe dicom file with several tif images.
I tried the changes in the two functions as you mentioned but how am i suppose to add multiple frames using dicomwrite function( ie. in the programme code what is the syntax for adding multiple frames at a time). I am still ale to add only one frame.
Looking forward for your help.
Thank You
Kamlesh
"Lead Bucket" wrote in message <i256tn$gj5$1...@fred.mathworks.com>...
Just a clarification for Kamlesh: maybe you've already suceeded in making it work, but if not... see below!
The instructions that LB gave us are corrected, but the following oversight:
in the dicom_encode_jpeg_lossy.m file, also del line fragments{1}=..... need to be changed in order to take into account the p parameter.
See below.
frames = size(X,4);
for p = 1:frames
tempfile = tempname;
imwrite(X(:,:,:,p), tempfile, 'jpeg');
.....
fragments{p} = fread(fid, inf, 'uint8=>uint8');
%fragments{1} = fread(fid, inf, 'uint8=>uint8');
%frames = 1;
.....
end
Hoping this helps!
Thank you guys!
Best regards,
Sara.
"K P" <kamleshp...@gmail.com> wrote in message <ig2dh1$np7$1...@fred.mathworks.com>...
Thanks for the correcting my oversight Sara! Kamlesh, I think that should solve your problem. Sorry about the omission.
-LB
At least when I read this back in from MATLAB dicomread, this works and returns an 4 D arrray with my image data. The NEMA reader I have is complaining about not supporting jpeg.
If I don't do this, it won't work ... reading the file back in results in only a single frame and the NumberOfFrames field is missing from dicominfo. There may be a way to add the 'NumberOfFrames' field to the metadata, so you don't need a template file, but not sure if I have the time to bother with that.
Hello everyone, are you still working on this function?
I guess I kind of succeeded in the first part where I got a 1xp cell named fragments. Then I followed the instructions on dicomwrite modification and stopped with the following error reported:
Undefined function or method 'dicom_create_IOD' for input arguments of type 'cell'.
Can anybody tell me what I should do next? Is there anything wrong with my program? If not, how can I convert cell to dcm (or other formats recognizable)?
many thanks!
ZZ
Patrick, I'm not sure why NumberOfFrames is missing from dicominfo, mine seems to be retained. However, I do recall that I had an issue with dicomread when it tried to read multiframe dicom file and the dicom data did not contain an offset table. I think I mentioned this somewhere in another thread, but the basic problem was that dicomread looks for an offset table, and if none exists it assumes that there is only one image and just loads the first frame (it completely disregards NumberOfFrames).
I believe that no offset table is produced for the modifications I provided to dicomwrite, so the same problem may persist when you try to use dicomread. I've had to modify dicomread so that it uses NumberOfFrames to read in the frames. That will probably be an issue if NumberOfFrames doesn't exist for you. Perhaps your data is coming out junk due to one of these issues, but I'm really not that familiar with dicom data formats.
As for your NEMA reader, I am unfamiliar with that (I don't really know much about dicom files/formats either - its not my area of expertise), but I do recall that ImageJ has an issue with compressed JPEG in dicom files. Maybe its the same thing with your NEMA reader.
Yao - The issue might be that you are using the 'Create' option for 'CreateMode' (this is the default, by the way, if you don't specify 'Copy'). I always needed to use the 'Copy' option because Matlab does not support the data type I was working with (which was ultrasound data). I do get a few warnings about some of the attributes being wrong in the dicom info, but for my work I don't really need the dicom info, so its not an issue for me.
-LB