# "Adding data failed" message when opening MRML file

**URL:** https://discourse.slicer.org/t/adding-data-failed-message-when-opening-mrml-file/22801
**Category:** Support
**Tags:** data-loading, error
**Created:** [April 3, 2022, 7:40am UTC](https://discourse.slicer.org/t/adding-data-failed-message-when-opening-mrml-file/22801 "2022-04-03T07:40:20Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![DIV](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/div/32/12816_2.png) [@DIV](https://discourse.slicer.org/u/DIV)
#### Post date: [April 3, 2022, 7:40am UTC](https://discourse.slicer.org/t/adding-data-failed-message-when-opening-mrml-file/22801/1 "2022-04-03T07:40:21Z")

</div>

I have gotten a handful of “adding data failed” “Adding data failed” messages lately when opening individual `MRML` Scene files.

The problematic Scene files would have been created with somewhat older versions of 3D Slicer, _circa_ the second half of 2021.  
I had a handful of these messages with  
Slicer version: Slicer-4.13.0-2022-01-19  
Operating system: Windows 10 Enterprise x64

I have just updated to  
Slicer version: Slicer-4.13.0-2022-03-31  
and got another of these error messages, as below:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/7/c76571f77cabd6679de24c6b3c2ab8d2887256d8.png)  
And upon scrolling down:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/2/02b2f33bcc3886942ecc286bb4a81a7c14929cea.png)

I’m not sure what impact this has on what’s loaded. After I click OK, a whole lot of content (“data”?) is loaded, as I can see many objects in the **Data** module.  
I don’t know whether this is caused by a defect in the process of originally creating the `MRML` file (or other files referred to therein), a defect in the operation of reading the file, or perhaps a problem with my recent installations of 3D Slicer. I don’t have an idea of how to troubleshoot it either.  
I think all of the errors were practically the same, although I didn’t screenshot them all.

Further information:

- Slicer is installed at `E:\Program Files\Slicer 4.13.0-2022-03-31`;
- the `MRML` files are located on `D:`, several directories in, which I have mapped to `O:` to reduce the length of the path a bit; and
- `D:\D\P\S-0\[...]` does not exist in my directory structure (_maybe the statement in the error message isn’t supposed to be interpreted literally?_).

—DIV

---

<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: [April 3, 2022, 1:09pm UTC](https://discourse.slicer.org/t/adding-data-failed-message-when-opening-mrml-file/22801/2 "2022-04-03T13:09:40Z")

</div>

The errors mean that there are storage nodes in the scene without associated segmentation files. The messages may refer to orphan nodes that are left behind in the scene due to previous failed saving operations or incomplete node deletion operations.

There is currently no automatic cleanup mechanisms (such as deletion of orphan nodes), but I’ve added a feature request for it:

> <https://github.com/Slicer/Slicer/issues/6298>
>
> The scene may contain unreferenced, invalid, and empty nodes due to module logic… errors, scene saving/loading errors, incomplete node deletions. 
> 
> These errors can cause warnings or errors at scene loading, causing distraction and making real scene errors harder to notice. 
> 
> \## Describe the solution you'd like
> 
> Perform automatic checks for common errors during scene loading&saving and either fix the errors automatically or by user confirmation (offer a list of nodes to remove using a checkable node list). 
> 
> \## Describe alternatives you've considered
> 
> Always automatically deleting all invalid nodes may not be desirable because some modules may want to keep around extra nodes, or a node load may fail because some network paths being temporarily not available. 
> 
> \## Additional context
> 
> Related user complaint: https://discourse.slicer.org/t/adding-data-failed-message-when-opening-mrml-file/22801?u=lassoan

Possible workarounds:

- Load all the data files instead of loading the scene file. This discards data that is stored in the scene file (relationship between nodes, display properties, etc).
- Edit the scene file (.mrml) in a text editor: remove lines that refer to problematic nodes.

---

<div class="post-metadata">

### Author: ![DIV](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/div/32/12816_2.png) [@DIV](https://discourse.slicer.org/u/DIV)
#### Post date: [April 3, 2022, 1:27pm UTC](https://discourse.slicer.org/t/adding-data-failed-message-when-opening-mrml-file/22801/3 "2022-04-03T13:27:04Z")

</div>

Hello, Andras.

Thanks for the suggestions.  
Actually, a while after I posted, I had a further idea that might fit with what you’re describing.

You might remember [a discussion](https://github.com/Slicer/Slicer/issues/6002) about objects being created ‘immediately’ even when the `Cancel` button was pressed.  
Maybe there was an empty segmentation called `Segmentation` already present, and I didn’t add any segments to it, because I instead created a new segmentation called (say) `Body parts` to contain the relevant segments.  
Would that cause the behaviours described?

In that case a clean-up of the unwanted `Segmentation` node could be desirable. (Or perhaps producing a more low-key warning, rather than a hyped-up “error” message.)  
But — if so — please keep in mind that the converse might also apply. Suppose I create one segmentation called `Heart parts` and then create several segments in it; then I create another segmentation called `Lung parts`, but before creating any segments in it I save the scene & all associated files, close 3D Slicer and go have lunch. When I come back and try to reload the scene file, I’ll expect to find the empty `Lung parts` segmentation; I wouldn’t want to get an error message, but nor would I like to find that an object I’ve expressly created has been covertly deleted.

Per your feature request, this might be a useful addition to the warning:

- “Warning, empty nodes found”
- specify details,
- give user option to fix ‘problem’ by deleting unused node, or ignore once, or ignore always,

—DIV

---

<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: [April 3, 2022, 1:39pm UTC](https://discourse.slicer.org/t/adding-data-failed-message-when-opening-mrml-file/22801/4 "2022-04-03T13:39:31Z")

</div>

If you can describe any specific scenario that produces invalid/orphan nodes (that cause errors after saving and loading the scene) then let us know and we should be able to fix it.

> [@DIV](#):
>
> “Warning, empty nodes found”

Empty nodes (e.g., markups without control points, segmentation without segments, empty segments, etc.) are not errors because these empty nodes are often used as templates. We don’t report them as errors. If you find that loading an empty node leads to a loading error then let us know.

> [@DIV](#):
>
> - specify details,
> - give user option to fix ‘problem’ by deleting unused node, or ignore once, or ignore always,

The [feature request](https://github.com/Slicer/Slicer/issues/6298) was submitted to cover these. Feel free to add more details.

---

<div class="post-metadata">

### Author: ![DIV](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/div/32/12816_2.png) [@DIV](https://discourse.slicer.org/u/DIV)
#### Post date: [April 3, 2022, 1:59pm UTC](https://discourse.slicer.org/t/adding-data-failed-message-when-opening-mrml-file/22801/5 "2022-04-03T13:59:56Z")

</div>

Thanks for the clarification. It seems that I misinterpreted the Github link preview, which literally mentioned “empty nodes”.

> [@lassoan](#):
>
> [Remove unused nodes from the scene · Issue #6298 · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/issues/6298)

I have had a quick look inside one offending `MRML` file [my reference: 00102].

This node produced the reported error:  
` <Segmentation id="vtkMRMLSegmentationNode1" name="Segmentation" hideFromEditors="false" selectable="true" selected="false" references="display:vtkMRMLSegmentationDisplayNode1;referenceImageGeometryRef:vtkMRMLScalarVolumeNode1;storage:vtkMRMLSegmentationStorageNode1;" userTags="" MasterRepresentationName="Binary labelmap" segmentListFilterEnabled="false" segmentListFilterOptions="" ></Segmentation>`

This node is OK, even though the encoding looks pretty much the same:  
`<Segmentation id="vtkMRMLSegmentationNode2" name="ContrastSegmentation" hideFromEditors="false" selectable="true" selected="false" references="display:vtkMRMLSegmentationDisplayNode2;referenceImageGeometryRef:vtkMRMLScalarVolumeNode1;storage:vtkMRMLSegmentationStorageNode2;" userTags="" MasterRepresentationName="Binary labelmap" segmentListFilterEnabled="false" segmentListFilterOptions="" ></Segmentation>`

`vtkMRMLSegmentationNode1` is only mentioned as above and here  
`<SubjectHierarchyItem id="181" dataNode="vtkMRMLSegmentationNode1" parent="3" type="Segmentations" expanded="true" attributes="VirtualBranch^1|"></SubjectHierarchyItem>`

On the other hand, `vtkMRMLSegmentationNode2` is mentioned as above and also within the `SegmentEditor` tag, and the `ScriptedModule` tag, and in  
` <SubjectHierarchyItem id="182" dataNode="vtkMRMLSegmentationNode2" parent="30" type="Segmentations" expanded="true" attributes="VirtualBranch^1|"> <SubjectHierarchyItem id="183" name="Rt ICA" parent="182" type="Segments" expanded="true" attributes="Level^VirtualBranch|segmentID^Segment_1|"></SubjectHierarchyItem> <SubjectHierarchyItem id="222" name="Confluence of sinuses" parent="182" type="Segments" expanded="true" attributes="Level^VirtualBranch|segmentID^Segment_2|"></SubjectHierarchyItem></SubjectHierarchyItem>`  
which shows the hierarchy of usage.

But still not sure what part of the encoding is producing an error, distinct from just an ‘empty’ node.

---

<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: [April 3, 2022, 2:23pm UTC](https://discourse.slicer.org/t/adding-data-failed-message-when-opening-mrml-file/22801/6 "2022-04-03T14:23:58Z")

</div>

If scene loading reports errors then the issue is most likely in the _segmentation storage_ nodes and not in the _segmentation_ nodes.

---

<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: [April 3, 2022, 3:10pm UTC](https://discourse.slicer.org/t/adding-data-failed-message-when-opening-mrml-file/22801/7 "2022-04-03T15:10:29Z")

</div>

I can only replicate the situation if I do the following:

- Launch Slicer, load MRHead, go to Segment Editor module (auto-creates “Segmentation” node), create new segmentation as “MySegmentation”, add a segment and paint in the slice views. Then go to “Save Data” and choose to select all items since the “Segmentation” node was not checked to save. Save and then close Slicer.
- From the saved location, delete the “Segmentation.seg.nrrd” file. Then launch Slicer, load the mrml scene and observe the same error as indicated by @DIV. In the Data module there is a “Segmentation” node, but it wasn’t the one actually saved as I had manually deleted that file from the saved location.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/7/d70d53ffd1cafbe95f2abfd9564cc94b6a73bd7c.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/3/f37f58626ae911ea3ea646a5bfba47b895164c6c.png)

---

<div class="post-metadata">

### Author: ![DIV](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/div/32/12816_2.png) [@DIV](https://discourse.slicer.org/u/DIV)
#### Post date: [April 4, 2022, 5:57am UTC](https://discourse.slicer.org/t/adding-data-failed-message-when-opening-mrml-file/22801/8 "2022-04-04T05:57:39Z")

</div>

> [@jamesobutler](#):
>
> I can only replicate the situation if I do the following:

Thanks for providing a concrete series of steps to replicate the issue, James.

For the record, I can confidently say that I didn’t knowingly delete any `*.seg.nrrd` file(s); however, potentially it might have been corrupted or gone missing for some unknown reason. As I mentioned though, it seems to have been not only with one single patient: there were a handful for which I believe this happened, which makes me think it was something ‘systematic’.  
I’m open to all possibilities: maybe 3D Slicer instructed the OS to write the file, but the OS didn’t obey, or it was blocked by an antivirus program that doesn’t trust `*.seg.nrrd` file(s) — not proposing those as explanations _per se_, just illustrating that I don’t know for sure it’s a 3D Slicer issue/bug.
