pixmeo/osirix — pull request #8 by lgoldman (2013-07-30 18:16:09+00:00)
Title: Preserve image file name

OsiriX (5.6) had several problems when importing image files (e.g. jpg, tiff, etc.):

1) The original name of the file was replaced with an all-numeric file name of significance only to OsiriX.
2) All jpg image files -- regardless of name -- were merged into a single series -- with the patient name changing with each import.
3) Code to detect multi-image series imports (e.g. patient01.jpg, patient02.jpg) failed if the file name was numeric-only, and furthermore, the routine was dependent on Roman-alphabet file names.
4) Internally, there were type conflicts with the imageID field: NSStrings were interpreted as int without regard to meaning.

This patch, an extensive rewrite of the routines, attempts to fix these problems.

I have tried to make all of the routines conform to a basic pattern: detect parameters from the file, prepare the ID-fields, prepare the human-readable fields, set the DICOM elemets. The code uses NSScanner to detect numeric indexes at then end of file names for better non-Roman alphabet support.

Multi-image series imports seem to work now. Repeated imports of the same-name image file are merged together into a series so that historical versions of the file are available.

CAVEATS:

a) I am uncertain how to fill out DICOM element fields for non-DICOM files. In general, human-readable fields (Study Name, Study Description) use the original source file name stripped of the file extension. ID-fields (StudyID, SeriesID) use the original source file name including the extension. The UID fields (StudyUID) begin with the full source file name but add other qualifiers if applicable. If my guesses need refinement, let me know.

b) While I tested the code with .jpg, .tiff and .mov files, I do not have sample FVTiff or Biorad files, so these routines are _untested_. If you supply samples I can test the code for these file types.

c) When importing jpg files, Papyrus reports an error in the log:

*** DICOM Papyrus error - computed length is larger than remaining byte in the file !

Cannot fix this, since the source of Papyrus is not included with the OsiriX project.