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

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

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?

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?

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”?

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.

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?

3D Slicer can already read ITKSnap label description files to get names and colors for segments via ImportItkSnapLabel module. 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.

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 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 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).

1 Like