Hi,
I’m using Slicer (v5.8.1) for manual annotation of structural MRI nifti data (T1 + parcellations).
I’m loading T1 volume and freesurfer parcellations (both .nii.gz) via a selfmade startup script, but use the GUI for saving modified parcellations. Here, I use the “Segmentations” toolkit (selected in dropdown on top right), and there the “Export to files“ submenu on the left.
I select a new destination folder, and when I export my parcellation there, any dashes are removed from the filename.
This does not happen when saving e.g. a .nrrd file using the file → save dialog. What gives, and can I change this behavior somehow?
Please try to reproduce this with something that narrows down what’s different in your workflow from things anyone can reproduce with the standard Slicer. For example, if I save a SampleData volume that has dashes in the name to a nii.gz file the dashes are preserved. So there seems to be something unique in your data or workflow.
minimal reproduction example:
open slicer, use file → Download sample data → MRHead
switch to “Segment Editor” in top dropdown, create a segmentation with dashes in the name. select that segmentation, and MRHead as Source volume.
add a few segments and annotate something in them, eg with the 3d paintbrush.
switch to “Segmentations” in top dropdown, also set “Segmentation” to your newly made one, then go to “Export to files” in left toolbar, set file format to nifti, hit the export button.
For me, this produces a .nii file in my output folder that is named like my segmentation except dashes are removed, eg if my segmentation is called “foo-bar”, the file is then called “foobar.nii”
i hope this is clear to follow and reproduce.
Okay, yes, that is more clear, and I do see this issue. @lassoan may know why it works like this.
What you can do instead is export the Segmentation to a Labelmap and then you can export that to an nii.gz file with the dashes retained (you may still need to rename the exported labelmap).
I was able to resolve my particular issue by simply adapting a naming scheme with only underscores, which are not affected by this. Luckily the names were not set in stone.
I still wanted to bring up this behavior since I could not find documentation of it. Thank you for verifying/replicating the behavior for now.
Thanks for brining it up. If you want this issue to remain on the radar you can file an issue on github since those get reviewed. You can include a link back to this chat thread as part of the issue description.
It is a good catch, the regular expression that created a safe filename from a node name was incorrectly filtered out the dash character (due to a subtle inconsistency between the regular expression engine in Qt and kwsys). I’ve submitted a fix:
That said, I would recommend to save segmentations in Slicer (not export) and use terminologies to specify what each segment contains (instead of relying on some arbitraily chosen names). This representation is archival quality, can be used forever, for any projects, without ambiguity, and supports overlapping labels (and can be losslessly saved into standard DICOM segmentation objects). Then, when you want to use this data to train an AI model, you can specify a mapping from terminology code to label value. I recently gave mini-presentation on this topic, see the slides here - it explains some of the motivation includes links where you can learn more.