Skip to content
  • lassoan's avatar
    ENH: Improved node saving and loading · cfdf8cc5
    lassoan authored
    This commit contains two changes, which might have been delivered as two separate commits, but they have been implemented at the same time
    and modify the same files, therefore splitting them would be not easy.
    
    1. Storable node can decide what is the most appropriate storage node, based on the requested file name and storable node content.
    
    Implemented by adding vtkMRMLStorableNode::AddDefaultStorageNode, which creates most appropriate storage node class and adds it to the scene
    (similarly to vtkMRMLDisplayableNode::CreateDisplayNodes()). Also added vtkMRMLStorableNode::GetDefaultStorageNodeClassName(), which allows
    creating the right type of storage node depending on target filename and storable node content.
    
    Now there is no more need for the model storage node "special case" in vtkSlicerApplicationLogic::ProcessReadNodeData.
    
    Now current scene's CreateNodeInstance method can be used for storage node creation. The scene may contain customized default storage nodes
    (e.g., storage node that uses a customized file extension or compression option), which are now taken into account.
    For example, changing default model node saving extension can be achieved by this:
    
    msn=slicer.vtkMRMLModelStorageNode()
    msn.SetDefaultWriteFileExtension('stl')
    slicer.mrmlScene.AddDefaultNode(msn)
    
    Default nodes can be created from information stored in the application settings, so this allows
    specifying default file saving format in the application settings (this is how default view options are configured already).
    
    Having a method for creating and adding storage node as needed also simplifies vtkSlicerFiducialsLogic::AddFiducialList,
    vtkMRMLColorNode::ReadXMLAttributes, vtkMRMLSceneViewNode::ReadXMLAttributes, vtkMRMLApplicationLogic::SaveSceneToSlicerDataBundleDirectory, etc.
    
    2. Improved composite file extension support (.nii.gz, .seg.nrrd, ...)
    
    Suitable file reader list in "Add data dialog" is populated using the most specific matched extension's reader.
    For example, .nrrd is more specific than .*; .seg.nrrd is more specific than .nrrd. This allows correct deafult
    selection. This allowed removing workarounds and special cases added for composite image file extensions (such as .nii.gz)
    and .* wildcard. It also allows proper default selection for segmentation nodes (.seg.nrrd).
    In the future, it could be used for removing workarounds added for guessing labelmaps, annotation ROI nodes, etc
    (labelmap volumes could use .label.nrrd, annotation nodes could use something.roi.csv something.fid.csv, ... instead of
    using ambiguous and/or non-standard file extensions such as .acsv or .fcsv).
    
    Made file extension matching more robust: instead of using heuristics, such as assuming .gz means a composite file extension
    and collecting all possible extension from all storage nodes; now extensions are verified/matched/removed by the specific
    storage node that is responsible for reading/writing the node.
    
    git-svn-id: http://svn.slicer.org/Slicer4/trunk@25323 3bd1e089-480b-0410-8dfb-8563597acbee
    cfdf8cc5