Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
problem with dicomwrite

Subject: problem with dicomwrite

From: ucd puri

Date: 4 Apr, 2010 00:14:05

Message: 1 of 6

Hi, I am trying to write an array in dicom format using dicomwrite as below,

a=[1 2 3; 4 5 6; 7 8 9]; % where 'a' is a greyscale image originally.
dicomwrite( a , 'im1')

but now if i read this im1 file, i get very strange values something like
[ 65535 65535 65535; 65535 65535 65535;65535 65535 65535]

Please suggest.
Thx in advance.

Subject: problem with dicomwrite

From: Sadik

Date: 4 Apr, 2010 01:44:05

Message: 2 of 6

Hi,

If you look at the header [or the so-called metadata] of a dicom file using dicominfo, you should see a tag with name "Pixel Representation". If I remember correctly, a value of 1 says it is signed, and 0 says unsigned. When you write your dicom file, you should watch for this tag as far as I infer from your problem.

An example:

metadata = dicominfo('anyDicom.dcm'); % so that you have a sample metadata struct
metadata.PixelRepresentation = 1; % or 0, whichever you wish.
dicomwrite(myImage,'newDicom.dcm',metadata);

This is just an example. You may have to play with it. For example, you had better choose more carefully the dicom file from which you get the metadata, it should be close to that of your desired dicom.

Best.

Subject: problem with dicomwrite

From: ucd puri

Date: 4 Apr, 2010 20:41:05

Message: 3 of 6

Dear Sadik,
Thanks a lot for your reply.

I tried to play around with PixelRepresentation, but did not help much.
I am basically having a metadata of a PET image, and i am using 'CreateMode'='copy' to write the metadata as following

dicomwrite( mydata , 'filename' , metadata , 'CreateMode', 'Copy' )

Unfortunately, it did not help. Thats why i tried to write a very simple array, as i showed previously, but i am have the same problem. The dicom file that is written has values either 0 or 65535. I really dont understand the problem.

I appreciate any help.

Best Wishes
Tanuj

Subject: problem with dicomwrite

From: Sadik

Date: 4 Apr, 2010 21:11:06

Message: 4 of 6

Hi Tanuj,

1. What is the range of values in your image?

2. You could also try the following. You can save your image as an analyze file [that is, *.hdr] from within matlab [you can find such matlab functions on the net], and then you can open it with one of the freely available image viewers [for instance imagej] and finally, you can save your image as dicom using that image viewer.

Best.

Subject: problem with dicomwrite

From: Zack Li

Date: 20 May, 2010 15:52:04

Message: 5 of 6

I have similar problems before and I found that if you convert the data format by uint* and everything will be fine.

"ucd puri" <tanuj.puri@ucd.ie> wrote in message <hp8lkd$roq$1@fred.mathworks.com>...
> Hi, I am trying to write an array in dicom format using dicomwrite as below,
>
> a=[1 2 3; 4 5 6; 7 8 9]; % where 'a' is a greyscale image originally.
> dicomwrite( a , 'im1')
>
> but now if i read this im1 file, i get very strange values something like
> [ 65535 65535 65535; 65535 65535 65535;65535 65535 65535]
>
> Please suggest.
> Thx in advance.

Subject: problem with dicomwrite

From: robin

Date: 14 Feb, 2012 19:13:10

Message: 6 of 6

"Zack Li" <liubebo@gmail.com> wrote in message <ht3lr4$ffu$1@fred.mathworks.com>...
> I have similar problems before and I found that if you convert the data format by uint* and everything will be fine.
>
> "ucd puri" <tanuj.puri@ucd.ie> wrote in message <hp8lkd$roq$1@fred.mathworks.com>...
> > Hi, I am trying to write an array in dicom format using dicomwrite as below,
> >
> > a=[1 2 3; 4 5 6; 7 8 9]; % where 'a' is a greyscale image originally.
> > dicomwrite( a , 'im1')
> >
> > but now if i read this im1 file, i get very strange values something like
> > [ 65535 65535 65535; 65535 65535 65535;65535 65535 65535]
> >
> > Please suggest.
> > Thx in advance.

Can you explain what that means? I am having trouble changing my SeriesNumber and SeriesDescription.

Thanks!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us