Open fedorov opened 6 years ago
+1, yes, that makes sense!
Right now everything is data driven with the % characters as escape sequences around dictionary terms. Maybe we should define a different escape characters (perhaps #image# or #series#) with meanings like number of the file in the sequence, or the number of the series in the study since ImageNumber and SeriesNumber are required to be unique.
Maybe better have some kind of suffix to the tag name that would indicate that unique values of the tag at a given level should be replaced with consecutive numbers? That way the script could maintain mapping at runtime, and do quick lookup instead of checking multiple files or doing multiple iterations over content (e.g., to get the number of series in study).
Another feature/idea could be to have a suffix to make a hash over the value of a given tag, and then take some small fixed number of characters from the signature to serve as a "unique" name within the level.
I like the idea of doing something automatic - what if at every level if you the target directory or file already exists then it starts autonumbering them. So you went to save image.dcm and it already existed you would rename the first one image-0000.dcm and then new one image-0001.dcm and then save them from there. The only drawback I see is that people might expect these to have been sorted e.g. by image position but they would not be.
It would be helpful if it was possible to automatically assign unique names to the sorted files in the bottom-level directory. InstanceNumber unfortunately is not always present. SOPInstanceUID is too long (which is related to a separate concern, since Windows users will quickly hit maximum path limit if using UIDs as directory components).
Would it make sense to have a mode where consecutive numbers are assigned to the files within the bottom level sorted directory?