# Problems using ImportOsirixROI from the Sandbox extension

**URL:** <https://discourse.slicer.org/t/problems-using-importosirixroi-from-the-sandbox-extension/31406>\
**Category:** Support\
**Tags:** python, extensions\
**Created:** [August 28, 2023, 7:11pm UTC](https://discourse.slicer.org/t/problems-using-importosirixroi-from-the-sandbox-extension/31406 "2023-08-28T19:11:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [August 28, 2023, 7:11pm UTC](https://discourse.slicer.org/t/problems-using-importosirixroi-from-the-sandbox-extension/31406/1 "2023-08-28T19:11:41Z")

</div>

I’ve just had a conversation with Dr. Ron Summers from NCI, who has been trying to use the [ImportOsirixROI function from the Sandbox extension](https://github.com/PerkLab/SlicerSandbox/tree/master/ImportOsirixROI). It is failing with the following error:

```auto
"[...]/AppData/Local/slicer.org/Slicer 5.4.0/slicer.org/Extensions-31938/Sandbox/lib/Slicer-5.4/qt-scripted-modules/ImportOsirixROI.py", line 284, in importOsirixRoiFileToSegmentation

[CRITICAL][Stream] 28.08.2023 11:25:17 [] (unknown:0) - inputRoiData = plistlib.readPlist(inputRoi)

[CRITICAL][Stream] 28.08.2023 11:25:17 [] (unknown:0) - AttributeError: module 'plistlib' has no attribute 'readPlist'

```

I have never used that extension. Can someone from the Sandbox extension team help here? @lassoan is this something you maintain?

---

<div class="post-metadata">

**Author:** ![rsummers](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@rsummers](https://discourse.slicer.org/u/rsummers)\
**Post date:** [August 28, 2023, 7:29pm UTC](https://discourse.slicer.org/t/problems-using-importosirixroi-from-the-sandbox-extension/31406/2 "2023-08-28T19:29:29Z")

</div>

Just to provide some background, I’m trying to import a flood-filled segmentation from Osirix into Slicer, and then output the segmentation as a NIFTI file.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [August 29, 2023, 1:13am UTC](https://discourse.slicer.org/t/problems-using-importosirixroi-from-the-sandbox-extension/31406/3 "2023-08-29T01:13:45Z")

</div>

It appears the `readPlist` method was removed from plistlib as mentioned in the Python 3.9 release notes [What’s New In Python 3.9 — Python 3.9.17 documentation](https://docs.python.org/3.9/whatsnew/3.9.html#removed) after having being marked deprecated in Python 3.4. The `load` method is the new method [plistlib — Generate and parse Apple .plist files — Python 3.9.17 documentation](https://docs.python.org/3.9/library/plistlib.html#plistlib.load). This should be an easy upgrade to the new API.

Slicer upgraded to Python 3.9 back in January 2022, so it appears this SlicerSandbox code has been broken for well over 1.5 years now.

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [September 1, 2023, 5:49pm UTC](https://discourse.slicer.org/t/problems-using-importosirixroi-from-the-sandbox-extension/31406/4 "2023-09-01T17:49:57Z")

</div>

I submitted the issue so this does not get lost.

> <https://github.com/PerkLab/SlicerSandbox/issues/22>
>
> As discussed in https://discourse.slicer.org/t/problems-using-importosirixroi-fr…om-the-sandbox-extension/31406, \`ImportOsirixROI\` functionality appears to be broken.
> 
> \`\`\`
> "\[...\]/AppData/Local/slicer.org/Slicer 5.4.0/slicer.org/Extensions-31938/Sandbox/lib/Slicer-5.4/qt-scripted-modules/ImportOsirixROI.py", line 284, in importOsirixRoiFileToSegmentation
> 
> \[CRITICAL\]\[Stream\] 28.08.2023 11:25:17 \[\] (unknown:0) - inputRoiData = plistlib.readPlist(inputRoi)
> 
> \[CRITICAL\]\[Stream\] 28.08.2023 11:25:17 \[\] (unknown:0) - AttributeError: module 'plistlib' has no attribute 'readPlist'
> \`\`\`

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 1, 2023, 9:10pm UTC](https://discourse.slicer.org/t/problems-using-importosirixroi-from-the-sandbox-extension/31406/5 "2023-09-01T21:10:15Z")

</div>

@fedorov thanks for reporting and @jamesobutler thanks for the investigation.

@rsummers It may be a simple fix, but I would like to test it with your data to make sure that I use the new plistlib API correctly. Could you upload some anonymized test segmentation to somewhere and post the link here?

---

<div class="post-metadata">

**Author:** ![Mathematinho](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mathematinho/32/9117_2.png) [@Mathematinho](https://discourse.slicer.org/u/Mathematinho)\
**Post date:** [October 20, 2023, 3:30pm UTC](https://discourse.slicer.org/t/problems-using-importosirixroi-from-the-sandbox-extension/31406/6 "2023-10-20T15:30:39Z")

</div>

I wonder if there is a temporary work around with and older version. I tried couple older version but none works.

---

<div class="post-metadata">

**Author:** ![mattflick](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@mattflick](https://discourse.slicer.org/u/mattflick)\
**Post date:** [November 13, 2023, 6:36pm UTC](https://discourse.slicer.org/t/problems-using-importosirixroi-from-the-sandbox-extension/31406/7 "2023-11-13T18:36:14Z")

</div>

Hi @lassoan, I’ve been attempting to update the script used to import Osirix ROIs to utilize the new plistlib methods (load and loads) in the relevant lines of code. Unfortunately this does not appear to be working when I run the script through the 3D slicer GUI, so I am wondering if you have made any progress on fixing this issue? The updated script I’ve tried is available here, in case it is helpful: [GitHub - flickmatt/3D-Slicer](https://github.com/flickmatt/3D-Slicer)

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 13, 2023, 9:32pm UTC](https://discourse.slicer.org/t/problems-using-importosirixroi-from-the-sandbox-extension/31406/8 "2023-11-13T21:32:11Z")

</div>

Thanks for the update @mattflick. Could you provide an example file that I can test with? (I only seem to have .json files and not binary plist files)
