Re: [Gdcm-hackers] Write tag with VR::OF, VR::OW
Cross-platform DICOM implementation
Brought to you by:
malat
|
From: <jor...@fr...> - 2011-05-26 12:56:55
|
> Works for me: > > http://gdcm.git.sourceforge.net/git/gitweb.cgi?p=gdcm/gdcm;a=commitdiff;h=ac003d4e0f0247f41ebd927729a4960b5ed059fa It works for me too. > What error are you getting ? I have not any error. In fact, I do not get the right result I am looking for. The Tag (0x0066,0x0016) is made for receive several float coordinates. Its length value has a maximum of 2^32 - 4 (near of VR::UT, see PS 3.5-2009 Table 6.2-1). But, VR::OF in GDCM has a length value of 4. So, I can not set a float array (eg: float array[] = { 15.2, -5, 167.3 }) in gdcm::Attribute<0x0066,0x0016>. After setting, this Attribute has the value 15.2. And it is the same problem with the Tag (0x0066,0x0023) and string of 16 bits words. > On Thu, May 26, 2011 at 1:05 PM, <jor...@fr...> wrote: > > Wow! Such a customer service, thank you very much Mathieu! > > > > Unfortunately, I still have a problem. It is on a Tag and its VM. > > Indeed, the Tag (0x0066,0x0016) is defined in the supplement 132 by : > > > > Tag : (0x0066,0x0016), VR : OF, VM : 1, Type : 1 > > > > But, how could I set with GDCM, a float array with a VM = 1 and not 1-n? > > > > Thanks again. > > > > Selon Mathieu Malaterre <mat...@gm...>: > > > >> Hi Jordi, > >> > >> Glad to see you are making progress. > >> > >> On Thu, May 26, 2011 at 9:37 AM, <jor...@fr...> wrote: > >> > My problem is 1 element of the input string is wrote (eg: > >> 175.6\25.1\-30\... > >> > give 175.6). > >> > >> ok > >> > >> > template <uint16_t GRP, uint16_t EL> > >> > static void setTagValue(const std::string & a_value, ::gdcm::DataSet > & > >> a_ds) > >> > { > >> > if(!a_value.empty()) > >> > { > >> > // Create a data element > >> > ::gdcm::Attribute<GRP,EL> gAt; > >> > > >> > ::gdcm::DataElement de( gAt.GetTag() ); > >> > de.SetByteValue(a_value.c_str(), a_value.size()); > >> > de.SetVR( gAt.GetVR() ); > >> > > >> > gAt.SetFromDataElement(de); > >> > > >> > a_ds.Insert( gAt.GetAsDataElement() ); > >> > } > >> > } > >> > >> I am quite lost here. You have two representation in GDCM: > >> gdcm::Attribute (or gdcm::Element for the more generic approach) and > >> gdcm::DataElement. > >> > >> gdcm::DataElement as the name indicates is the representation of a > >> DATA ELEMENT as per PS 3.5 specification. Which means that the > >> ByteValue contained in the DataElement will be *as stored* on the > >> disk. For instance a VR::US with value 512 will be stored as ByeValue > >> "0200" (use hexedit to see it). > >> > >> What does this means ? This means it is not very convinient to write > >> DICOM tag that are not ASCII based (eg, US, OF...). In this case you > >> have two approaches: > >> > >> The one derived from GDCM 1.x, where everything is a std::string, in > >> this case have a look at the gdcm::StringFilter class, you have the > >> ToString function which converts a DataElement Value into a 'viewable' > >> string (it will convert "0200" into 512) and the opposite: > >> StringFilter::FromString > >> > >> Now if you are programming in C++, you can take advantage of the > >> gdcm::Attribute class which will do this hard work for you: > >> > >> DataSet ds; > >> const float array[] = { 0, 1, 2, 3, 4 }; > >> gdcm::Attribute<0x5600,0x0020, gdcm::VR::OF, gdcm::VM::VM1_n> at; > >> at.SetValues( array, sizeof( array ) / sizeof( *array ) ); > >> ds.Insert( at.GetAsDataElement() ); > >> > >> This will store the array using the binary IEEE notation to disk as > expected. > >> > >> > >> HTH > >> -- > >> Mathieu > >> > > > > > > > > > > -- > Mathieu > |