zapaishchykova / SegmentationReview

Slicer3D extension for rating using Likert-type score Deep-learning generated segmentations, with segment editor functionality. Created to speed up the validation process done by a clinician - the dataset loads in one batch with no need to load masks and volumes separately.
MIT License
25 stars 9 forks source link

writing of extra file t.seg.nrrd #4

Closed deepakri201 closed 11 months ago

deepakri201 commented 1 year ago

Hi Anna,

I've been trying out your extension, thanks for this! I'm also interested in streamlining annotations in Slicer, for DICOM files. :)

I noticed that a t.seg.nrrd file is created when I click 'Overwrite Edited Mask'. I see in your code that you save the segmentation node as t.seg.nrrd, read it in, and write it out as nifti. Perhaps you could convert this seg node into a label map and save it directly out as nifti without the intermediate file.

Maybe something like this from the script repo:

Screen Shot 2023-06-09 at 6 46 15 PM

Thanks!

zapaishchykova commented 1 year ago

Hi Deepa! Thanks for your suggestion! I was not able to quickly find a way to directly save nii files. I see the script you attached also uses an intermediate file "-label.nrrd". Do you know if there is a way to directly save niftys?

deepakri201 commented 1 year ago

Hi Anna,

So I believe that slicer.util.saveNode works for both nrrd and nii.gz, so instead of: filepath = outputPath + "/" + referenceVolumeNode.GetName() + "-label.nrrd" You can instead do: filepath = outputPath + "/" + referenceVolumeNode.GetName() + "-label.nii.gz"

zapaishchykova commented 1 year ago

Yeah so that does not work, I have tried it awhile ago and just now, here is the log: [Python] Failed to save node to file [Python] Error: No writer found to write file .nii.gz of type SegmentationFile.

vprudente commented 1 year ago

Is there a functional reason why you convert the nrrd/save the nifti? Why not just save the segmentations as .seg.nrrd? I can think of a few benefits of using .seg.nrrd instead of nifti, such as preserving header/metadata, segmentation color

zapaishchykova commented 1 year ago

Good point, the only reason I can think of is the consistency between input and output. Also, nifty also saves headers with metadata (not the color tho)

vprudente commented 1 year ago

The inputs can be .nrrd files too (with the new mappings feature). Personally, I think the extension would benefit from saving the segmentations as .seg.nrrd. If nothing else, saves the overhead of re-saving the segmentations as niftis.

zapaishchykova commented 11 months ago

i have removed the t.seg.nrrd in the latest commit, saving only nifty files.