Export scene as dicom

Hi,

I am a bit new at using the Dicom export function and currently it gives the error:

Traceback (most recent call last):
File “”, line 2, in
TypeError: init() missing 1 required positional argument: ‘referenceFile’

When I try to export the scene into Dicom. I am aware that in this case it can only be opened with slicer but that is the point. I checked from the code of the export function that it should take the first file from the dicom database as the reference or you can specify a reference file but I do not see such option as the export scene freezes all options to begin with.

How do I solve this?

Thanks for reporting. Yes, it looks like this refactoring led to an argument mismatch between the dialog code and the python class. You could try going back to an earlier version of Slicer and it might work. @lassoan or @cpinter have you tried this feature lately?

@Pheasant you can call the exporter from Python with the needed argument - as you say it just needs to be a file from the study you want to export into.

We refactored the scene bundle export to use the export plugin infrastructure (using the first file in the DICOM database as a basis of the bundle just seemed very arbitrary). However, we forgot to remove the option from the top (and nobody reported it that it was broken until now).

You can choose Slicer data bundle export type to export a scene in a DICOM file:

image

The item that you right-click on will be used as a basis for the DICOM file, so if you don’t have anything loaded from DICOM then you first need to export something (e.g., a volume node) to DICOM and then load it into the scene. It is definitely not nice or convenient, there was just not a lot of interest in this feature to make it polished and easily usable for many workflows.

@Pheasant can you tell a bit about your workflow? How do you plan to use these scene bundle DICOM files?

@pieper @cpinter what do you think about removing the Export entire scene option from the top of the DICOM export dialog and just use export type selector instead?

Thank you @lassoan :+1:

Yes, I think coming up with something cleaner makes sense. Since the scene may not include anything loaded via dicom, it could be nice to be able to pick an instance to use as the source of metadata for the export, so that the exported scene gets associated with the desired study.

I’d also be curious to hear from @Pheasant how you might use this and how it works in actual practice.

Hi, thank you for the excellent response.

The main purpose of the DICOM export is storage. The place where we store data accepts only DICOM-format. The point would be to be able to store old works in a way that doesn’t require them to be saved locally. The workflow is something that is repeated regularly and the main use for Slicer is jumping from one mark up point to other to see specific parts of the brain. The scene has multiple markups in it.

I tried the save data bundle option but got a different error from it (I removed the paths and replaced them with * for this post):

Saving Image…

Saving scene into MRB…

Making dicom reference file…

Using reference file reference_file.dcm

Failed to export using plugin DICOMSlicerDataBundlePluginClass

Traceback (most recent call last):

File “”, line 3, in

File “*/DICOMSlicerDataBundlePlugin.py”, line 226, in export

exporter.export()

File “*\DICOMExportScene.py”, line 58, in export

success = self.createDICOMFileForScene()

File “*\DICOMExportScene.py”, line 119, in createDICOMFileForScene

dump = str(dumpByteArray.data(), encoding='utf-8')

UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xc4 in position 3173: invalid continuation byte

Should I try a different encoder? If so what would work in your opinion?

Agreed, this seems like an oversight. And one option fewer to handle for the user and for us.

I just tried the data bundle export using 5.0.2 on Windows and it worked for me. What Slicer version and OS do you use?

1 Like

I use 5.0.2 on Windows 10.

I did some tests on it and I didn’t get an error from selecting export scalar volume for the reference Dicom file. Then I loaded the exported file and used that as the reference for the Export as data bundle and it seems to work like that. I guess exporting it as scalar volume made the dicom file readable for it?

I think the reason might be that there are some characters (for example ä or ö) in the original Dicom file, I tried removing the ones that I noticed but it didn’t help though.

I am curious however about the reason for that exporting the scalar volume works well but not the data bundle one.

@Pheasant If it’s possible for you to create an mrb (no patient data) that fails to export to dicom for you then it could be tested on different machines for debugging.

That should be possible (I have some files from my own MRI so there shouldn’t be a problem).

I am a bit busy currently and I would like to anonymize them a bit so I can send them around tuesday. Where should I send it?

As long as you are comfortable, sharing your own MRI is fine. You can put them in a service like dropbox, google drive, etc. Share a link by direct message if you’d rather not make them public.

1 Like

Hi,

In the newest version when I try to import the scene to dicom. It only imports a screenshot of the dicom-module as seen on the linked picture i.e. that is the imported Dicom file.

You can un-toggle the “Show DICOM database” button to see the viewers instead of the DICOM database.

Thanks for the answer but the point would be to save the entire package as a dicom file i.e. so that the dicom file could be loaded and contain all the volumes and mark up points

This works well in the very latest Slicer Preview Releases.

Hi, I can’t seem to be able to get it to work in the lates preview release. So could you give me some instructions on how it works. It seems that the dicom module doesn’t even show any of the volumes loaded in.

I can confirm that exporting the scene to dicom and reloading works for me in the 5.2.1 release on Mac.

Steps are to right click in the Data module and pick Export to DICOM. In the dialog pick the data you want and select scene export and click the Export button. Data is then in database and can be reloaded.

Hi, Thank you I got it to work now.

However I noticed that I had to load the exported dicom series as a patient into the dicom database.

If I only dragged the created dicom file from the folders it ended up with the same problem as mentioned before as in it was just a screen shot. Even though the filesize would indicate it would be correct.

But it does work if you drag the main folder into slicer. But it would be great to know why just using the dicom file gives such a strange result.

Oh, I see what you are doing. Right, if you drag and drop the exported dicom Slicer will try to read it as a single frame secondary capture, because that’s what it technically “is”. The “data bundle” concept puts a zip file of the data from your scene into a private tag of the dicom header. We do this so that you can use conventional PACS or other dicom infrastructure to exchange data with other Slicer users.

This private tag is detected when you load the data in Slicer through the dicom module and the scene is unpacked and loaded. So if you want to drag-and-drop the file, you need to enter the DICOM module first so the file gets added to the database.

Thank you for the explanation. That makes sense then.