18 ms·
Dicom File Format Basics
- SubiculumCode 4y agoI always convert dicoms to nifti format. Is there any advantage not to??
- queuebert 4y agoI have a funny (or sad, really) DICOM story. I wrote my own DICOM parser in Rust, and I kept encountering a bug where the parsing would fail on a small subset of files in my database. What you need to know is that DICOM tags have 16-bit group and element values that uniquely identify what the tag contains, and tags that begin with the group 0xfffe are very special, comprising a small set of field delimiters. Well, the brilliant minds at Codonics decided to use the special group 0xfffe for their private, vendor-specific fields at the end of the file. When parsing a file those private fields would look like delimiters and ruin the logic. So because of that one particular vendor, I have to check both the group and element of every special tag in every file I parse to make sure it isn't one of their special ones. Whereas, if they had followed the standard, I would only need to check the groups for the value 0xfffe. Thanks, guys!
- rurban 4y agoThanks for the pedicom hack tip, I was not aware of it. Will add a check against the DOS-Header (4d 5a 90 00) magic immediately. https://github.com/d00rt/pedicom https://github.com/d00rt/pedicom
- etaioinshrdlu 4y agoThe amount of redundant scientific/medical/industrial image file formats is amazing. Just off the top of my head there is DICOM, FITS, NIFTI, NRRD, plus TIFF. They all have the basic property of having raster data of arbitrary channels/depth plus a whole bunch of metadata. It feels like every new industry I work with I discover they have their own redundant image format.
- quasarj 4y agoYep. Quit making new ones!
- greatgib 4y agoVery nicely written article. I guess that it is pleasant to read even if we don't have to work with the Dicom format. The explanation of TLV could be interesting also in itself.
- vladsiv 4y agoThank you, I really appreciate it!
- brnt 4y agoThe problem with extensibility is that everyone does! Manufacturers will dump in all sorts of tags, and check for them, when you read in, but the won't tell you what they are and how you might calculate their supersecret checksums (for safety!). Dicom Compliance is a well paying job.
- queuebert 4y agoI have some DICOM experience. How does one go about getting these compliance jobs?
- mattkrause 4y agoI had a good snicker at the "Basics" in the title for exactly this reason!
- vladsiv 4y ago> Manufacturers will dump in all sorts of tags, and check for them, when you read in, but the won't tell you what they are True. As far as I know it could be also used for a vendor lock-in. If you export DICOM files from X, you have to use software Y. Since they are dumping all sorts of private tags which you don't know anything about.
- danielheath 4y agoIn practice, the files can be viewed just fine in any standard-compliant viewer without any awareness of custom tags. Source: I wrote the DICOM viewer & anonymizer for Radiopaedia (okay, most of the heavy lifting is done by cornerstone.js).
- juliansark 4y agoMy amazing experience with DICOM, an open standard with viewer software on SourceForge, is that I once took pictures in the format to a locally renowned neurologist. She plugged my USB stick into her Windows XP workstation, ca. 2019, without the slightest hesitation, then proceeded to claim not to know what DICOM is, and to ask me why I didn't bring her either the proprietary viewer program, or JPEGs. Had I brought the viewer, she would have probably launched the .exe with equally no hesitation. At least in these parts of the woods, this once again confirmed to me that medicine and IT usually exist at opposite ends of a spectrum.
- badsectoracula 4y ago> Had I brought the viewer, she would have probably launched the .exe with equally no hesitation. At least in these parts of the woods, this once again confirmed to me that medicine and IT usually exist at opposite ends of a spectrum. Well, on the other hand she'd be able to do what she needed without any other distractions - and in case you happened to break the machine, you'd be around to slap or pay up for the fixes :-P. At the end of the day for most people computers are there to help their jobs.
- VikingCoder 4y agoThis is like a restaurant that has a QR code on the table instead of a menu. Yes, it's absolutely possible for someone to use the QR code to fetch the menu from a website using their phone. But unless you do it often, you just don't even know how to do it. Doctors are insulated from DICOM the same way that most humans don't normally type "h t t p : / /" They just click on links and things show up for them.
- classichasclass 4y agoMy clinical work is in TB control and we read a lot of chest X-rays and CT scans. I'm very used to DICOM and I have my personal preferences for DICOM viewers, but outside of an actual radiology suite most docs will just use whatever viewer came on the disc, if there's one at all. And that's largely true for the ones I've worked with in this field, too. That said, I was in IT before I got my MD.
- petercooper 4y agoCoincidentally, for me, I had an MRI yesterday and they always give me access to the DICOM files so it's interesting to know more about them. "Horos" is a really good viewer if you want something for managing and viewing entire sets of such images, especially as it can create 3D visualizations of all the 2D slices which results in fun/creepy pictures of my brain to show off.
- stronglikedan 4y agoI recently had some imaging done as well, and they gave me a DVD with the images. Now I just have to find a DVD player.
- BuildTheRobots 4y agoOnly supported on OSX. I'd be interested if anyone can recommend something similar for Windows and/or Linux.
- sbf501 4y agoEvery CDROM I've received after an MRI comes with a windows viewer on it. IN 2010 it was E Film Light, then DCSView, then DrayViewer, and today it is Radiant.
- pehtis 4y agoI'm using this one on macOS https://github.com/rordenlab/MRIcroGL https://github.com/rordenlab/MRIcroGL It is available for linux too.
- nick__m 4y agoI find https://www.slicer.org/ https://www.slicer.org/ awesome once you get past the initial learning curve.
- jphoward 4y agoRadiAnt is OK - it's got a trial license model but when the license expires you can request an extension for free (big WinRAR energy). There's nothing as good as Horos that is similarly free and open source, sadly. What you may prefer to do is use the excellent pydicom library for Python, which loads dicom files as numpy arrays, allowing you to convert to any other file format you fancy, whether that be image or video.
- zegerius 4y agoVery interesting! I have been working with medical information standards for a while now. Recently, I took an interest in DICOM and ways to modernize it. For example by introducing streaming, caching, moving metadata to a FHIR ImagingStudy resource. To me, specifically streaming and caching strategies to move the load of (often hopelessly legacy) hospital infrastructure are an interesting challenge.
- lostlogin 4y agoWhatever issues exist within DICOM are dwarfed by HL7 hell, and the point where the two specs meet can by awful. Between HL7 and vendors doing custom things with HL7 and DICOM, IT support in healthcare is always going to be desperately needed.
- notorandit 4y agoI still wonder how can DICOM be any better than PNG... But that is supposedly due to my ignorance.
- an1sotropy 4y agoThe information in a DICOM file is a huge huge superset of the information you'd typically find in a PNG, because the amount of metadata you want to tie to a medical image is enormous (e.g. what day, what scanner, which scan, which part of which scan, which radiology tech, which doctor, which patient, with which contrast agent, in what orientation). Even if you did contrive a way to pack that metadata into a PNG file (which is possible), you'd still need a way to unambiguously interpret all that metadata, and know that everything else in the healthcare world is going to interpret it the same way. That's one of the things that the DICOM standard covers.
- notorandit 4y agoAs you said, it is nothing you cannot put into a PNG metadata. Unambiguously? It is all about standard definition. XML, JSON, CSV, excel sheet...
- chadcmulligan 4y agoDICOM is a lot older than PNG, you can embed multiple images in a DICOM file using different formats - losless and lossy, formats like jpg, tiff and so on. It also includes a bunch of tags that describe the image, patient information, scanner it came from and so on.
- randomh3r0 4y agoIt also goes well beyond just talking about the imagery itself or the metadata surrounding it, and the standard contains its own network protocol effectively for transmitting data between PACS systems and other endpoints. (I recently worked in medical imaging for over 6 years and know DICOM fairly well, warts and all). That said, there are absolutely better ways of handling almost any of the cases DICOM supports, the issue is that there is almost no standard that is fully backwards compatible which supports everything DICOM does, so we're sorta shackled to it for better or worse. Otherwise you have to deal with trying to explain to underfunded clinics (not the Mayo or Cleveland type) around the world why their expensive machine that they bought second or third hand is no longer acceptable.
- kaibee 4y ago> The standard includes a file format definition and a network communications protocol that uses TCP/IP to communicate between systems. Is this as cursed as it sounds?
- quasarj 4y agoYes.
- haolez 4y agoIt's fully binary and is document as a Lisp, as far as I remember. It's very nightmarish, but it's from the 80s, so it has its merits for staying for so long.
- danielheath 4y agoThe file format is reasonably cursed (header fields to indicate endian-ness, multiple internal metadata tables, and it's a container format so you can encode the image data using any one of 6-8 codecs - or just include a link to the TCP stream). I haven't used the network protocol, but having some way to only bring the required pixel data across the network is pretty important - uncompressed CT scans are often hundreds of megabytes and the standard was developed before ethernet was widespread.
- evulhotdog 4y agoA standard uncompressed CT slice is ~512kb, so multiply that by the number of slices. Angiograms tend to be much larger as well.
- danielheath 4y agoI'm starting to see 1000-slice scans more often, but I hear 100-400 was more common back when size was a pressing concern.
- evulhotdog 4y agoApparently you haven’t seen what the Toshibas/Canons can pump out. Some can be 6000 slices or more.
- skywal_l 4y agoYou might be interested in a series of articles dealing with the multi planar rendering algorithm (starts at part 2): http://site.novidee.com/blog/blog-entry.html?article=20200912-from-DICOM-to-MPR-part2.html http://site.novidee.com/blog/blog-entry.html?article=2020091... How to render an MPR image (an arbitrary slice of 3D data volume) from scratch starting from the bare DICOM files.
- vladsiv 4y agoThanks! This is great, I'll definitely check it out in-depth.
- golf_mike 4y agoFor those who like to experiment a little, I can recommend firing up a jupyter notebook and explore the image data using pydicom and plotting it via matplotlib (or whatever plotting lib you fancy). For most CT and MRI data you will have a volume/voxels available and its pretty fun to slice'n dice your way through it by using list slices. Also all other data is available to inspect.
- mcluck 4y agoDICOM is a fun format to tinker with. The absolute basics of it are simple enough that I wrote a DICOM viewer in college for a class. All of the extensions mean you can get some really interesting data as well. The various number of attributes and unusual combinations make it a real pain if you're trying to implement it all from the ground up but I'd highly recommend anyone play with it.
- ml_giant 4y agoThere is also a file format called DICOS which is based off of DICOM which is used by the TSA and various inspection systems: https://www.nema.org/directory/nema-councils/imaging-and-communications-council/dicosusa https://www.nema.org/directory/nema-councils/imaging-and-com... If you've gone through security at a U.S. airport, the scanners use DICOS format to save scans of your baggage. Someone correct me if I am wrong though - it's possible only a subset of these machines use DICOS, I am not 100% sure.
- vladsiv 4y agoYes, I remember stumbling upon DICOS when I researched DICOM. Quite interesting application of the standard!