--[[
    This extraction script identifies the properties for ultrasound (US)
    images. In this version, only the cine/still property is extracted 
    as image description
    
     Cristian Bonciu,    July-September 2004        CREATED and  
     -	implemented the functionality from pseudo-code prototypes provided by Allan 
--]]

function RegisterProperties()
-- ////////////////////////////////////////////////////////////////////////////
-- This function is called automatically at load of script to register any
-- modality specific properties.  Prior to IP Library build 39 it must be 
-- present even if empty.
-- Modality specific property IDs (3711,1X01)- (3711,1XFF) range
--     If modality specific properties need to be defined, then replace X in the above 
--     numeric ranges with a value that is distinct from those used by other modalities.
-- ////////////////////////////////////////////////////////////////////////////
end

-- ////////////////////////////////////////////////////////////////////////////
-- US image description property strings 
-- ////////////////////////////////////////////////////////////////////////////

    CINE_DESC_VAL = "Cine"
    STILL_DESC_VAL = "Stills"    

-- ////////////////////////////////////////////////////////////////////////////
-- US properties extaction functions
-- ////////////////////////////////////////////////////////////////////////////

function ExtractImageDescriptionUS()
-- extract the image description as series description, or "STILLS" / "CINE" when the 
-- series description is not available 
	local imageDescProp = AttrValue:new()
	local seriesDescrAttr  = GetAttr(SERIES_DESC_TAG)
	if( seriesDescrAttr ) then
		imageDescProp = seriesDescrAttr
	else
		local frameTypeAttr = GetAttr(FRAME_TYPE_PROP)
                --frameTypeAttr:Dump("Retrieved MF attribute")
		if( frameTypeAttr:Get(1) == CINE_VAL ) then
			imageDescProp:AppendVal(CINE_DESC_VAL)
		else
			imageDescProp:AppendVal(STILL_DESC_VAL)
		end
	end
	SetAttr(SERIES_DESC_PROP, imageDescProp) -- add image description a property
    imageDescProp:Dump("US image description")
end

-- ////////////////////////////////////////////////////////////////////////////
-- extract US properties 
-- ////////////////////////////////////////////////////////////////////////////

function Execute()

    -- If this is the wrong script for the supplied image...
    if (not SanityOK("US")) then
      return nil
      -- =====================================================
    end

    -- Tag our output with the script version
    NewPropWithValue( MODALITY_SCRIPT_VER_PROP, "$Revision: 1 $ - $Modtime: 2/02/07 5:26p $ - US" )
    
    ExtractImageDescriptionUS()
end

