Export Deformation Field as Dicom

Dear all,

I am looking if 3D Slicer is capable of exporting Deformable Registration Objects as DICOM. Of course my first priority was to search your forum and see if anyone else had a similar request. Indeed I found a couple related issues (links below)

Following your suggestions on these threads I have downloaded the latest nightly build at that moment 4.11.0-2020-09-21 r29383 / c299952. Though I cannot find the proper way of using the DICOM Spatial Registration Object Import Export plugin. I have tried SAVE scene option and selected only the Deformation Grid but in the File format combo box I can’t see any DICOM option. Also some options are giving me error on saving (like MHA. MHD) while saving as h5 or txt works.
Also tried right click on scene → Dicom Export but again there when REG object is selected there are no Dicom Tags visible.
Am I doing something completely wrong here or the functionality is still not implemented?

Thank you for your patience, excellent work and assistance.
Kind regards
Yiannis

It sounds like you don’t have your registration transform under a patient and study. You either need to drag&drop it under an existing study (if your input came from DICOM you have it), or you need to create a new one. You need to do both in the Data module. To create a new patient right-click the empty space and choose Create new subject, and then Create new study under the new patient. Then when the transform is under a study, right-click the study and choose Export to DICOM. Make sure the REG plugin is selected on the bottom left. You can set DICOM tags in this window.

Dear cpinter,

Thanks for the quick reply. I have created manually a new patient/study/series tree like this
image

When selecting Export Dicom from the study I get the dialog below

And when I focus on the Deformable Reg node I get no options to select.

Do I need to install separately the REG plugin? I have installed SlicerRT and SlicerElastix extensions.

Thanks again for your help.

Kind regards
Yiannis

If the transforms are directly under the study then what happens?

The REG plugin is in SlicerRT.

Similar behavior

For some reason also I cannot drag and drop in the data tree control. When I click and drag is starting selecting other nodes also. (something different from my initial problem but thought to report it).

the tree that you see above is how is loaded by slicer and by default as I can see the REG is under the study and not the series. But again I don’t get the option to export.

Thanks

update: The drag and drop is now back and running. not sure what was wrong.

For some reason also I cannot drag and drop in the data tree control. When I click and drag is starting selecting other nodes also.

You can drag&drop in the Data module, and not in other views (@lassoan the same is happening in the DICOM module, and it’s quite annoying. We should do something with this, maybe just enable single selection, otherwise it seems like a bug that drag&drop is not enabled in those views. What do you think?)

Is there any error in your log? For example “Failed to find moving and/or fixed image for transform…”. Because the transform can only be exported to DICOM if it was created by one of Slicer’s registration modules and the proper references set.

Btw here’s a tutorial about DICOM SROs:
https://github.com/SlicerRt/SlicerRtDoc/blob/master/tutorials/SlicerRT_Tutorial_DICOMRegistrationObject.pptx

I remember I was surprised by disabled drag-and-drop, too. Could we just enable drag-and-drop in the subject hierarchy tree widget by default?

1 Like

Thanks for the tutorial, I will study it.
You are absolutely right on the reason of not exporting. I indeed have a “Failed to find moving…” error. And indeed also I am loading a DVF file from Varian Ethos manufacturer. So I assume that importing a DVF from another vendor means that I cannot export again? Is export only available for Slicer created fields?

Thanks again,
Yiannis

1 Like

We could probably automatically guess the two images from the scene (if there are multiple candidate image pairs then we could choose the first). Maybe we could also add the series instance uids of the fixed and moving image it to the list of editable DICOM fields in export dialog (just in case someone wants to select.a different one)? Or, could we add node reference selector in the DICOM export info window? @cpinter what do you think?

Yes probably that would be a good idea too

While reading the first part of your comment this was the idea that popped up in my head. Maybe we should allow series to define the necessary node references and expose them in the export dialog.

Another thing that many people miss is exporting from under a patient/study. There are many things to do in the DICOM export dialog. There may be a project in terms of which we can do some of these in a few months. I’ll ask.

For the specific issue of @iTheoch, what I’d suggest so that progress can be made is to set the node references manually. @lassoan there is a module exposing node references in one of the developer extensions right?
The two references that need to be set are

>>> slicer.vtkMRMLTransformNode.GetMovingNodeReferenceRole()
'spatialRegistrationMoving'
>>> slicer.vtkMRMLTransformNode.GetFixedNodeReferenceRole()
'spatialRegistrationFixed'

OK. I’ll try this and see if it works as expected or there are side effects that we haven’t thought about.

Sounds good. It would be nice to have node selectors and enumerated values. Maybe we could reuse parts of the CLI module widget factory.

Agreed.

Yes, “Node info” module in DebuggingTools extension can show node references (you cannot change them, but if the need to add/remove/modify node references comes up frequently enough then it should be easy to implement this).

1 Like

I’m about to push a PR. Do you have anyhing particular in mind that I should test?

1 Like

Nothing specific, just test drag-and-drop in DICOM module widget (I don’t expect any issues, as its role is essentially the same as in Data module), DICOM export dialog (probably we want to disable drag&drop there), and run the automatic tests. Models and Markups module widgets already have drag&drop enabled, so we don’t need to test there.

Hi both,
Thank you for looking at the issue. Is there anything I can do as it is now to apply the workaround or should I wait for some future nightly release version?

Regards
Yiannis

I added drag&drop to the data tree, see the pull request https://github.com/Slicer/Slicer/pull/5201

@iTheoch If you want, you can do everything from Python right now, but as @lassoan said we can help you do this from the UI after adding a small feature.

Hi both.
Thank you for your assistance and effort. I will check Python to see if I can work around the issue and will be looking forward for a future version.

Kind regards
Yiannis

Please note that you will need to have two volumes: both the fixed and the moving.

In order to set the references:

transformNode = getNode('TransformName') # Double-click node in Data module and copy-paste name
fixedVolumeNode = getNode('FixedVolumeName')
transformNode.SetNodeReferenceID(slicer.vtkMRMLTransformNode.GetFixedNodeReferenceRole(), fixedVolumeNode.GetID())
movingVolumeNode = getNode('MovingVolumeName')
transformNode.SetNodeReferenceID(slicer.vtkMRMLTransformNode.GetMovingNodeReferenceRole(), movingVolumeNode.GetID())

This should do it

Hi everyone,

I exported my DVFs to DICOM as reported in this topic, but I noticed that they have about 400 MB size. Is there any to make DVFs more lightweight? E.g. downsample the data before saving?

Dense displacement fields are usually this big, it should not cause issues.

You can resample transform using Transforms module → Convert, by specifying a downsampled volume as reference.

However, if you need lower resolution displacement field then probably you can get much better results if you use bspline transform. Bspline transform is the same as grid transform except it uses bspline interpolation instead of trilinear interpolation, therefore a smooth displacement field can be described with several magnitudes less control points.