Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jcfr opened this issue Jun 11, 2021 · 2 comments
Labels

Comments

@jcfr
Copy link
Collaborator

jcfr commented Jun 11, 2021

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

segFileName = "subject_hierarchy_export.SEG" + exporter.currentDateTime + ".dcm"

@property
def currentDateTime(self, outputFormat='%Y-%m-%d_%H%M%S'):
from datetime import datetime
return datetime.now().strftime(outputFormat)

@jcfr jcfr changed the title Exporting two segmentation node in a row in the same output directory overwrite the prevous one Exporting two segmentation nodes in a row in the same output directory overwrite the prevous one Jun 11, 2021
@jcfr jcfr added the bug label Jun 11, 2021
@fedorov
Copy link
Member

fedorov commented Jun 12, 2021

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

@lassoan
Copy link
Collaborator

lassoan commented Jun 12, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants