# File reader for "ITK-SnAP Label Description File"?

**URL:** https://discourse.itk.org/t/file-reader-for-itk-snap-label-description-file/7525
**Category:** Engineering
**Created:** [May 15, 2025, 10:06pm UTC](https://discourse.itk.org/t/file-reader-for-itk-snap-label-description-file/7525 "2025-05-15T22:06:59Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)
#### Post date: [May 15, 2025, 10:06pm UTC](https://discourse.itk.org/t/file-reader-for-itk-snap-label-description-file/7525/1 "2025-05-15T22:06:59Z")

</div>

Hi all,

Does ITK itself have a reader class for “ITK-SnAP Label Description File” files? Or does only ITK-SnAP have such a reader?

Thanks,

Sean

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [May 16, 2025, 1:07pm UTC](https://discourse.itk.org/t/file-reader-for-itk-snap-label-description-file/7525/2 "2025-05-16T13:07:58Z")

</div>

I think only SNAP has such a reader, though it is a rather simple format if I remember. Maybe a question for [ITK-SNAP mailing list](https://www.itksnap.org/pmwiki/pmwiki.php?n=MailingLists.MailingLists)?

---

<div class="post-metadata">

### Author: ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)
#### Post date: [May 16, 2025, 3:15pm UTC](https://discourse.itk.org/t/file-reader-for-itk-snap-label-description-file/7525/3 "2025-05-16T15:15:18Z")

</div>

Yes, it’s a simple format.

I can’t use ITK-SnAP since it’s GPL3 and I’m working on a commercial project. If I made a reader for this format, would it be interesting to have it in ITK?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [May 16, 2025, 3:23pm UTC](https://discourse.itk.org/t/file-reader-for-itk-snap-label-description-file/7525/4 "2025-05-16T15:23:43Z")

</div>

Where would such a reader live in ITK? It would make for a nice example, perhaps? Maybe it would make sense to add it to Slicer to read the “lookup tables”?

 ![Screenshot 2025-05-16 11.22.28](https://discourse.itk.org/uploads/default/original/2X/8/87746a84647f80dc345457f6f2f8e009f258bd09.png)

---

<div class="post-metadata">

### Author: ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)
#### Post date: [May 16, 2025, 4:35pm UTC](https://discourse.itk.org/t/file-reader-for-itk-snap-label-description-file/7525/5 "2025-05-16T16:35:28Z")

</div>

Basically, I’ll be implementing a reader class for this file format for my own app regardless, so I’m trying to decide if I should just implement it myself in our app, or contribute the implementation to ITK. As I need it in my app, it would need it as part of the ITK libraries, not in an example.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [May 16, 2025, 4:59pm UTC](https://discourse.itk.org/t/file-reader-for-itk-snap-label-description-file/7525/6 "2025-05-16T16:59:10Z")

</div>

That sound like application-specific functionality. I don’t mind having it in the main library, but adding code to the main repo requires some accompanying unit tests, and generally more effort. Maybe someone else can pitch in with opinion?

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.itk.org/user_avatar/discourse.itk.org/lassoan/32/27_2.png) [@lassoan](https://discourse.itk.org/u/lassoan)
#### Post date: [May 16, 2025, 7:19pm UTC](https://discourse.itk.org/t/file-reader-for-itk-snap-label-description-file/7525/7 "2025-05-16T19:19:58Z")

</div>

3D Slicer can already read ITKSnap label description files to get names and colors for segments via [ImportItkSnapLabel module](https://github.com/PerkLab/SlicerSandbox?tab=readme-ov-file#importitksnaplabel). All you need to do is install the Sandbox extension in Slicer and the ITKSnap label description files are automatically recognized and loaded as standard color tables. You can then save that in [color table CSV file format](https://slicer.readthedocs.io/en/latest/developer_guide/modules/colors.html#color-table-csv-file-format-csv).

This standard CSV file format is better to the ITKSnap label description file because:

- it is a simple standard CSV file that is easy to create/edit in Excel (single-line header, comma separator) and parse with any CSV parser
- it can store standard DICOM terminology (so you don’t need to worry about spelling differences, such as `kidney`, `Kidney`, `Kidneys`, `Left Kidney`, `Kidney (left)` or poorly defined meaning of segment names)

That said, the ITKSnap file format is trivial, and writing parsing code takes very little effort (in the Slicer extension it is [implemented in 22 lines of Python code](https://github.com/PerkLab/SlicerSandbox/blob/6c18371ac9cb0dfdf072d539db39751e9032208e/ImportItkSnapLabel/ImportItkSnapLabel.py#L119-L139) and any AI chatbot can write for you fully automatically in seconds).

If you want to spend some time with improving segmentation metadata support across various applications, then it would make sense to add the ITKSnap file reader to a Python package that can read/write various other segmentation representations, such as DICOM Segmentation Object, Slicer segmentation file (.seg.nrrd), and NRRD or NIFTI + color table CSV. For example, the [slicerio](https://pypi.org/project/slicerio/) Python package can alread read/write .seg.nrrd, so you could add support for the other file formats to it (if you send a pull request I can review and add to the package if looks good).
