Currently the AppliesTo method of the custom mime checks whether any of the supported extensions is found at the end of the given path. It only returns whether this is true or not, leaving the individual readers/writers to duplicate the code to get the matching extension and the filename without the extension.
Ideally this could be centralized in the custom mime type with the following functions:
string GetExtension( string path )
Which returns the matching extension (e.g. "nii.gz" for the file "/eve/foo.bar.nii.gz")
string GetFilename( string path )
which returns the filename minus the extension and directories (e.g. "foo.bar" for the file "/eve/foo.bar.nii.gz")
These functions as well as the existing AppliesTo function should share a helper function which provides all the relevant values, thus avoiding code duplication.
The suggested solution will always return the extension/filename as fits the *first* matching extension for a given mime type. Theoretically a mime type could contain several matching extensions (e.g. in the above case ".nii.gz" and ".bar.nii.gz") this is however unlikely and will not be handled unless a use case presents itself.