![]() RuntimeError: Exception thrown in SimpleITK ImageFileWriter_Execute: D:\D\P\Slicer-0-build\ITK\Modules\IO\ImageBase\src\itkImageIOBase.cxx:698: Return _SimpleITK.ImageFileWriter_Execute(self, *args) Onexisting\\0000.dcm") # throws error as expectedįile "C:\Users\andra\AppData\Local\NA-MIC\Slicer 4.13.0-\lib\Python\lib\site-packages\simpleitk-2.1.1-p圓.6-win-amd64.egg\SimpleITK\extra.py", line 394, in WriteImageįile "C:\Users\andra\AppData\Local\NA-MIC\Slicer 4.13.0-\lib\Python\lib\site-packages\simpleitk-2.1.1-p圓.6-win-amd64.egg\SimpleITK\SimpleITK.py", line 7503, in Execute > sitk.WriteImage(slices, "C:\\tmp\\0000.dcm") # works fine > sitk.WriteImage(slices, "C:\\tmp\\0000.nrrd") # works fine > sitk.WriteImage(slices, "C:\\tmp\\0000.mhd") # works fine > slices = sitkUtils.PullVolumeFromSlicer(inputVolumeNode) > inputVolumeNode = SampleData.SampleDataLogic().downloadMRHead() The behavior using SimpleITK in latest Slicer Stable Release and in a recent Slicer Preview Release on Windows look good: > import SampleData I would recommend to start a discussion about this on the ITK forum. But I agree that it would be better if you got a more clear indication of error, such as returning an error code or throw an exception. Not creating a file at all is a robust way of indicating that something went wrong and SimpleITK may also log errors or set error codes somewhere. You need to generate new UIDs for some fields, while cross-referencing existing UIDs in other fields. You need to provide lots of required metadata to have a chance of generating a valid DICOM file. And if I am doing something wrong, then I feel that I at least deserve some kind of notice like: “ERROR: We disabled writing DICOM because !”.Ĭreation of valid DICOM files is very complex and not done very often. Overall, this is a very frustrating situation, because I had written a script that outputs DICOM files using SimpleITK (I am converting some MHDs to DICOM for further processing), and since SimpleITK is a part of Slicer, I assumed that I could run it in Slicer. ShNode.SetItemParent(volumeShItemID, studyItemID)Įxporter = DICOMScalarVolumePlugin.DICOMScalarVolumePluginClass()Įxportables = exporter.examineForExport(volumeShItemID) VolumeShItemID = shNode.GetItemByDataNode(volumeNode) StudyItemID = shNode.CreateStudyItem(patientItemID, "test study") PatientItemID = shNode.CreateSubjectItem(shNode.GetSceneItemID(), "test patient") # Create patient and study and put the volume under the study The only script example for exporting an image as DICOM is this, which starts with object types I don’t recognize and uses a bunch of functionality I was hoping to avoid: volumeNode = getNode("CTChest") mhd/.raw file pair to a DICOM series (I have the tags stored separately)?Ĭan someone please consider adding an error message to be printed when SimpleITK.WriteImage() fails? Is there a good way to export a SimpleITK image object as DICOM from Slicer? Or more generally to convert an. Has anyone else used SimpleITK ImageFileWriter/WriteImage to write DICOM files from Slicer scripts? Is there a way to fix the problem? ![]() Now I am afraid I will have to rewrite the script in order to use Slicer’s internal DICOM modules, which will require a few days of reading, probably. The script works perfectly on my laptop with a standalone SimpleITK library, but on my work desktop I cannot install standalone SimpleITK (ugh) so I thought I would try to run it inside of Slicer, which I am allowed to install. And if I am doing something wrong, then I feel that I at least deserve some kind of notice like: “ERROR: We disabled writing DICOM because !”. ![]() # using sitk.ImageFileWriter().Execute() gives the same behavior, incidentally Sitk.WriteImage(slices, "C:\\Users\\username\\test\\0000.dcm") # does nothing, gives no error message, just does nothing Sitk.WriteImage(slices, "C:\\Users\\username\\test\\0000.nrrd") # works fine Sitk.WriteImage(slices, "C:\\Users\\username\\test\\0000.mhd") # works fine This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.Here’s what’s happening (at the Slicer Python console): import SimpleITK as sitk
0 Comments
Leave a Reply. |