# Can't save into "Slicer Data Bundle" mode

**URL:** <https://discourse.slicer.org/t/cant-save-into-slicer-data-bundle-mode/245>\
**Category:** Support\
**Tags:** file-export\
**Created:** [May 2, 2017, 2:50pm UTC](https://discourse.slicer.org/t/cant-save-into-slicer-data-bundle-mode/245 "2017-05-02T14:50:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![finetjul](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/finetjul/32/146_2.png) [@finetjul](https://discourse.slicer.org/u/finetjul)\
**Post date:** [May 2, 2017, 2:50pm UTC](https://discourse.slicer.org/t/cant-save-into-slicer-data-bundle-mode/245/1 "2017-05-02T14:50:06Z")

</div>

Operating system: Windows 10  
Slicer version: 4.6.2 and nightly  
Expected behavior: Should be able to save scene into “Slicer Data Bundle”  
Actual behavior: Fails to save with error message: “Selected directory contains -2 files or directories. Please choose an empty directory.”

Some problems:  
[https://github.com/Slicer/Slicer/blob/eefeac9286f48552e8418a11f412b2823a09b407/Modules/Loadable/Data/qSlicerSceneWriter.cxx#L284](https://github.com/Slicer/Slicer/blob/eefeac9286f48552e8418a11f412b2823a09b407/Modules/Loadable/Data/qSlicerSceneWriter.cxx#L284) →   
On windows, there is no . and … folders:

[https://github.com/Slicer/Slicer/blob/eefeac9286f48552e8418a11f412b2823a09b407/Modules/Loadable/Data/qSlicerSceneWriter.cxx#L294](https://github.com/Slicer/Slicer/blob/eefeac9286f48552e8418a11f412b2823a09b407/Modules/Loadable/Data/qSlicerSceneWriter.cxx#L294) →   
breaks are missing

Bonus: In the file name column, “.\*” is enforced and wrongly suffixed onto the name.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [May 2, 2017, 3:34pm UTC](https://discourse.slicer.org/t/cant-save-into-slicer-data-bundle-mode/245/2 "2017-05-02T15:34:17Z")

</div>

I can’t replicate this.

Tried Windows 10, Slicer 4.6.2:

- start fresh slicer
- download MRHead
- save data bundle
- close scene
- reload scene

No error messages or abnormal behavior.

---

<div class="post-metadata">

**Author:** ![finetjul](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/finetjul/32/146_2.png) [@finetjul](https://discourse.slicer.org/u/finetjul)\
**Post date:** [May 2, 2017, 3:42pm UTC](https://discourse.slicer.org/t/cant-save-into-slicer-data-bundle-mode/245/3 "2017-05-02T15:42:01Z")

</div>

Thanks for trying it out.

Do you choose “Slicer Data Bundle” and not “Medical Reality Bundle”?  
Do you save into an empty folder ?

---

<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:** [May 2, 2017, 4:09pm UTC](https://discourse.slicer.org/t/cant-save-into-slicer-data-bundle-mode/245/4 "2017-05-02T16:09:20Z")

</div>

Medical Reality Bundle (.mrb) works well for me.  
If I select the “Slicer Data Bundle (\*)” option then I have the same issue.

Should we just remove the Slicer Data Bundle option?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [May 2, 2017, 4:19pm UTC](https://discourse.slicer.org/t/cant-save-into-slicer-data-bundle-mode/245/5 "2017-05-02T16:19:48Z")

</div>

Ah, no, I was using .mrb Medical Reality Bundle, the default. Right, if I  
pick Slicer Data Bundle I see the same errors you reported.

Hate to ask, but why does this second mode even exist?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [May 2, 2017, 7:29pm UTC](https://discourse.slicer.org/t/cant-save-into-slicer-data-bundle-mode/245/6 "2017-05-02T19:29:20Z")

</div>

@pieper Great question. Look like the functionality was first added in [https://github.com/Slicer/Slicer/commit/479f8c249](https://github.com/Slicer/Slicer/commit/479f8c249)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [May 3, 2017, 12:25am UTC](https://discourse.slicer.org/t/cant-save-into-slicer-data-bundle-mode/245/7 "2017-05-03T00:25:24Z")

</div>

@jcfr yes, the save to MRB code is something I added.

But the code Julien pointed to is something he committed [1] and it really doesn’t look like my code…

I’m not even sure what use case qSclicerSceneWriter::writeToDirectory is  
meant to support. The related issue it closes doesn’t really explain [2].

Anyway if that code path doesn’t work right and none of us use it we should  
simplify things by retiring it.

[1]  
[https://github.com/Slicer/Slicer/blame/eefeac9286f48552e8418a11f412b2823a09b407/Modules/Loadable/Data/qSlicerSceneWriter.cxx#L284](https://github.com/Slicer/Slicer/blame/eefeac9286f48552e8418a11f412b2823a09b407/Modules/Loadable/Data/qSlicerSceneWriter.cxx#L284)

[2] [http://na-mic.org/Bug/view.php?id=2097](http://na-mic.org/Bug/view.php?id=2097)

---

<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:** [May 3, 2017, 1:08am UTC](https://discourse.slicer.org/t/cant-save-into-slicer-data-bundle-mode/245/8 "2017-05-03T01:08:21Z")

</div>

qSlicerSceneWriter::writeToDirectory is mostly redundant:

- If user saves the scene using the Save data dialog then saving as mrml or mrb should cover all use cases.
- For single-click save operation for slicelets/custom applications we typically use applicationLogic.SaveSceneToSlicerDataBundleDirectory (it saves everything to a directory without creating a scene view and without zipping the results; [see for example here](https://github.com/SlicerIGT/SlicerIGT/blob/master/Guidelet/GuideletLib/Guidelet.py#L363-L381)).

As the method is not really needed, does not work correctly, and it would be difficult to make it robust and efficient (handle non-empty directory, overwriting files with the same name, etc), I think it would be a good idea to remove it (and the corresponding file format) from qSlicerSceneWriter.

---

<div class="post-metadata">

**Author:** ![finetjul](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/finetjul/32/146_2.png) [@finetjul](https://discourse.slicer.org/u/finetjul)\
**Post date:** [May 3, 2017, 6:30am UTC](https://discourse.slicer.org/t/cant-save-into-slicer-data-bundle-mode/245/9 "2017-05-03T06:30:40Z")

</div>

I’m fine if such option is removed. No problem.
