converting .text to .dcm

435 views
Skip to first unread message

Rushabh Gujarathi

unread,
Jan 13, 2023, 10:00:14 AM1/13/23
to dcm4che
Hello all,

I have DICOM image in .text format.

The data in the .text is all  HEX
00 00 00 ..
..
..
44 FF

The files has image as well as the tags, I need help in converting this .text file to .dcm file

Thanks in advance.

Regards
Rushabh

Dr Suresh Viswanathan

unread,
Jan 18, 2023, 11:40:41 AM1/18/23
to dcm...@googlegroups.com
Have you tried renaming the file? Looks like you already have a DICOM file with a text extension. Technically, as per the standards, there is no defined file extension but by convention .dcm is used by many applications. 

Also do not save the file if you’ve opened it in a text editor since it may corrupt it by inserting LF/CR codes at the end of each line. 

On 13-Jan-2023, at 20:30, Rushabh Gujarathi <gujarathi...@gmail.com> wrote:

Hello all,
--
You received this message because you are subscribed to the Google Groups "dcm4che" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dcm4che+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dcm4che/f2d97a92-c827-420e-a22d-ba4c17cd788en%40googlegroups.com.

Stephen Douglas Scotti

unread,
Jan 19, 2023, 8:33:34 AM1/19/23
to dcm4che
If you have dcmtk installed:  https://dicom.offis.de/dcmtk.php.de

Try doing a dcmdump on the file.  You probably do not need the extension in that case, but maybe.

Dave Clunie has a number of tools:  http://www.dclunie.com/dicom3tools.html

Manual page for dcmdump:

https://support.dcmtk.org/docs/dcmdump.html

/sds

p.p...@synedra.com

unread,
Jan 19, 2023, 9:29:57 AM1/19/23
to dcm4che
Dicom files follow a binary format, not a text format. If you indeed have a text file with ASCII-Characters 0-9 and A-F, aka a hexdump, you would need to find a way to transfer the text representation of the bytes into actual bytes. This, however, is not a Dicom specific problem, and most likely won't be covered by any Dicom tool. I'd recommend searching the web for tools that can generate hexdumps. Chances are, they can transform dumps back to binary files, too.

Rushabh Gujarathi

unread,
Jan 19, 2023, 9:35:32 AM1/19/23
to dcm4che
Hello,

@Dr Suresh Viswanathan, thanks for the reply, what you are saying makes sense but the situation I am in is that I have dicom files in text format or to put it in other words, I am getting data for DICOM file in binary/hex format. To move forward, I will have to convert binary/Hex to .DCM.

@Stephen, thanks for the reply, I am actually looking for a java utility to the job, will surly check out what you have suggested.

Regards
Rushabh

Rushabh Gujarathi

unread,
Jan 19, 2023, 9:41:11 AM1/19/23
to dcm4che
Hi,

This where I am stuck, I am using Orthanc, which is a DICOM receiver, it has a DB as its backend, in which there is table which stores this data in binary format.
Using my code I am able get this binary data and convert it to hex or string and this where I am stuck.

For my experiment I did following:-
1.Took a DICOM file and opened it in notepad ++.
2. Converted the binary file that I had to text.
3. Compared #1 and #2, there were some visible difference and similarities, size and line count were same but quite a few characters were different.Probably due to UTF-8 decoding.

Stephen Douglas Scotti

unread,
Jan 19, 2023, 9:59:26 AM1/19/23
to dcm4che

If you are using Orthanc, it isn't really recommended that you access the DB directly outside of the Orthanc application.  Orthanc gives you the option of storing the DB Index and the "Storage" in multiple different ways, so it sounds like you opted to store the actual instance datasets in a MySQL, PostGres or maybe cloud storage DB.

You might want to read the Orthanc Book:

https://book.orthanc-server.com/users/rest.html#downloading-images

If you have the Orthanc uuid you can use curl from the CLI to fetch an instance into a .dcm file.

Also, there are multiple other ways to use the API to fetch data using the API without having to directly query the DB.

https://book.orthanc-server.com/users/rest.html#performing-finds-within-orthanc

Also see:

https://book.orthanc-server.com/faq/orthanc-storage.html

Direct access

Directly accessing the content of the OrthancStorage folder and the content of the SQLite/MySQL/PostgreSQL database is strongly discouraged for several reasons:


/sds

Rushabh Gujarathi

unread,
Jan 19, 2023, 11:41:55 AM1/19/23
to dcm4che
Hello stephen,

Thanks for the response, I am aware of the Orthanc API and also not accessing the DICOM via DB.
I can use OrthancStorage to get the DICOM images but I have an architecture limitation in implementing them, so I have to use DB to get the DICOM images.

Regards
Rushabh 

Dr Suresh Viswanathan

unread,
Jan 21, 2023, 6:48:57 AM1/21/23
to dcm...@googlegroups.com
Do you mind sharing the files as received without opening and saving them again?

Suresh 


On 19-Jan-2023, at 20:05, Rushabh Gujarathi <gujarathi...@gmail.com> wrote:

Hello,

Rushabh Gujarathi

unread,
Jan 21, 2023, 1:25:39 PM1/21/23
to dcm4che
Hi,

For that I would need to anonymise and send the data.

Reply all
Reply to author
Forward
0 new messages