QuantitativeReporting icon indicating copy to clipboard operation
QuantitativeReporting copied to clipboard

Exporting two segmentation nodes in a row in the same output directory overwrite the prevous one

Open jcfr opened this issue 4 years ago • 2 comments

Since the DICOM file name is initialized using the current date and time, exporting in the same directory overwrites the previous file.

https://github.com/QIICR/QuantitativeReporting/blob/87852c8460ed54de70e8c838f16ddf62da539546/DICOMPlugins/DICOMSegmentationPlugin.py#L351

https://github.com/QIICR/QuantitativeReporting/blob/87852c8460ed54de70e8c838f16ddf62da539546/DICOMPlugins/DICOMSegmentationPlugin.py#L437-L440

jcfr avatar Jun 11 '21 22:06 jcfr

Good catch! We should probably change the exporter to initialize the name of the file to the UID of the instance.

fedorov avatar Jun 12 '21 12:06 fedorov

Instance UID can be too long to be used as filename. We often had DICOM import failures when used DICOM UIDs directly for folder and file names due to the complete file path becoming longer than maximum path length.

When we create temporary filenames based on timestamp in Slicer, we typically add a 3-4 digit random number to the timestamp to keep the filename relatively short but prevent name clashes.

For cases when we want to separate DICOM files based on UIDs, we use an md5 hash, as it provides good separation but keeps the file path length in control. It is usable even when we build a folder structure from patient, study, series, instance ID.

Note that DICOM export plugins generally expect to get an empty output folder. For example, if I remember correctly, the DICOM RT export plugin uses image0001, image0002,... output filenames.

lassoan avatar Jun 12 '21 13:06 lassoan