/*******************************************************************************
 *  Copyright 2017-2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package cdac.medinfo.sdk.dcm30_04.dicommodel.modules;



import cdac.medinfo.sdk.dcm30_04.baselibs.DicomV3Factory;
import cdac.medinfo.sdk.dcm30_04.baselibs.MRImageAndSpectroscopyInstanceMacro;
import cdac.medinfo.sdk.dcm30_04.baselibs.MRSpectroscopyDescriptionMacro;
import cdac.medinfo.sdk.dcm30_04.baselibs.Tag;
import cdac.medinfo.sdk.dcm30_04.baselibs.VolumeLocalizationSequence;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataElement;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDicomValue;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITag;
import cdac.medinfo.sdk.dcm30_04.enums.EnumBaselineCorrection;
import cdac.medinfo.sdk.dcm30_04.enums.EnumDeCoupledNucleus;
import cdac.medinfo.sdk.dcm30_04.enums.EnumDeCoupling;
import cdac.medinfo.sdk.dcm30_04.enums.EnumDeCouplingMethod;
import cdac.medinfo.sdk.dcm30_04.enums.EnumFirstOrderPhaseCorrection;
import cdac.medinfo.sdk.dcm30_04.enums.EnumFrequencyCorrection;
import cdac.medinfo.sdk.dcm30_04.enums.EnumImageType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumTimeDomainFiltering;

import cdac.medinfo.sdk.dcm30_04.enums.EnumVolumeLocalizationTechnique;
import cdac.medinfo.sdk.dcm30_04.enums.EnumWaterReferencedPhaseCorrection;
import cdac.medinfo.sdk.dcm30_04.exceptions.ConditionFailedException;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidModuleException;
import cdac.medinfo.sdk.dcm30_04.exceptions.MandatoryMissingException;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;
import cdac.medinfo.sdk.dcm30_04.utils.ISingleCollection;
import cdac.medinfo.sdk.dcm30_04.utils.SingleCollection;

// TODO: Auto-generated Javadoc
/**
 \* This module specifies the attributes of the MR Spectroscopy Module.
 */
public class MRSpectroscopyModule extends Module   
{


	/**
	 * The obj single collection.
	 */
	public static ISingleCollection<ITag> objSingleCollection = null;



	/*
	 * MRSpectroscopyModule contians attributes from MR Image and MR Spectroscopy Instance Macro' & 
	 *  MR Spectroscopy Description Macro'
	 */

	/**
	 * The obj mr image and spectroscopy instance macro.
	 */
	MRImageAndSpectroscopyInstanceMacro objMRImageAndSpectroscopyInstanceMacro = null;

	/**
	 * The obj m spectroscopy description macro.
	 */
	MRSpectroscopyDescriptionMacro objMSpectroscopyDescriptionMacro = null;

	/**
	 * Instantiates a new mR spectroscopy module.
	 * 
	 * @param objIDataSet the obj i data set
	 */
	public MRSpectroscopyModule(IDataSet objIDataSet)
	{
		super(objIDataSet);
	}
	static
	{
		objSingleCollection = new SingleCollection<ITag>();
		objSingleCollection.add(new Tag(0x0008,0x0008));
		objSingleCollection.add(new Tag(0x0018,0x9052));
		objSingleCollection.add(new Tag(0x0018,0x9053));
		objSingleCollection.add(new Tag(0x0018,0x9054));
		objSingleCollection.add(new Tag(0x0018,0x9059));
		objSingleCollection.add(new Tag(0x0018,0x9060));
		objSingleCollection.add(new Tag(0x0018,0x9061));
		objSingleCollection.add(new Tag(0x0018,0x9062));
		objSingleCollection.add(new Tag(0x0018,0x9063));
		objSingleCollection.add(new Tag(0x0018,0x9065));
		objSingleCollection.add(new Tag(0x0018,0x9066));
		objSingleCollection.add(new Tag(0x0018,0x9067));
		objSingleCollection.add(new Tag(0x0018,0x9098));
		objSingleCollection.add(new Tag(0x0018,0x9101));
		objSingleCollection.add(new Tag(0x0018,0x9126));
		objSingleCollection.add(new Tag(0x0018,0x9198));
		objSingleCollection.add(new Tag(0x0018,0x9199));
		objSingleCollection.add(new Tag(0x0040,0x0556));
	}


	/**
	 * This method validates each Attribute in the Module according to the Type
	 * of the Attribute.Attributes are of 5 types.
	 * Type 1,Type 2 are Mandatory:
	 * Mandatory Attributes have to present in the Module.
	 * Type 1C,2C are Conditional:
	 * Conditional Attributes' presence depend on a condition.
	 * If the condition is satisfied the Attribute has to be present.
	 * Type 3 are Optional
	 * Optional Attributes can be added as and when required.
	 * 
	 * @return boolean - returns validation status as success or failure
	 * 
	 * @throws InvalidModuleException - If validation of Module fails
	 */
	public  boolean validateModule() throws InvalidModuleException
	{

		try
		{
			/*
			 * Validation Rules for Mandatory Elements
			 */
			if(!isPresent(0x0008,0x0008))
				throw new MandatoryMissingException("0x0008,0x0008");

			/*
			 * Conditional Elements are remaining   
			 */
			String strArrImagetype[] = getImageType();
			String strOriginal = EnumImageType.Value1.ORIGINAL.getValue();
			String strMixed = EnumImageType.Value1.MIXED.getValue();
			if(strArrImagetype[0].equalsIgnoreCase(strOriginal) && !isPresent(0x0018,0x9098))
				throw new ConditionFailedException("Element 0018,9098 is required if value of 0008,0008 is" 
						+ strOriginal);

			if((strArrImagetype[0].equalsIgnoreCase(strOriginal)|| strArrImagetype[0].equalsIgnoreCase(strMixed)))
			{
				if(!isPresent(0x0018, 0x9052))  
					throw new ConditionFailedException("Element 0018,9052 is required if value of 0008,0008 is" 
							+ strOriginal +"or" + strMixed);

				if(!isPresent(0x0018, 0x9053))  
					throw new ConditionFailedException("Element 0018,9053 is required if value of 0008,0008 is" 
							+ strOriginal +"or" + strMixed);

				if(!isPresent(0x0018, 0x9054))  
					throw new ConditionFailedException("Element 0018,9054 is required if value of 0008,0008 is" 
							+ strOriginal +"or" + strMixed);

				if(!isPresent(0x0018, 0x9059))  
					throw new ConditionFailedException("Element 0018,9059 is required if value of 0008,0008 is" 
							+ strOriginal +"or" + strMixed);

				if(!isPresent(0x0018, 0x9065))  
					throw new ConditionFailedException("Element 0018,9065 is required if value of 0008,0008 is" 
							+ strOriginal +"or" + strMixed);

				if(!isPresent(0x0018, 0x9066))  
					throw new ConditionFailedException("Element 0018,9066 is required if value of 0008,0008 is" 
							+ strOriginal +"or" + strMixed);

				if(!isPresent(0x0018, 0x9067))  
					throw new ConditionFailedException("Element 0018,9067 is required if value of 0008,0008 is" 
							+ strOriginal +"or" + strMixed);

				if(!isPresent(0x0018, 0x9101))  
					throw new ConditionFailedException("Element 0018,9101 is required if value of 0008,0008 is" 
							+ strOriginal +"or" + strMixed);

				if(!isPresent(0x0018, 0x9198))  
					throw new ConditionFailedException("Element 0018,9198 is required if value of 0008,0008 is" 
							+ strOriginal +"or" + strMixed);

				if(!isPresent(0x0018, 0x9199))  
					throw new ConditionFailedException("Element 0018,9199 is required if value of 0008,0008 is" 
							+ strOriginal +"or" + strMixed);
			}

			String strVolumeLocalizationTechnique = getVolumeLocalizationTechnique();
			String strNone = EnumVolumeLocalizationTechnique.NONE.getValue();
			if(!strVolumeLocalizationTechnique.equals(strNone)
					&& (strArrImagetype[0].equals(strOriginal)|| strArrImagetype[0].equals(strMixed))
					&& !isPresent(0x0018, 0x9126))
				throw new ConditionFailedException("Element 0018,9126 is required if value of 0008,0008 is" 
						+ strOriginal +"or" + strMixed);

			String tempStrDeCoupling = getDeCoupling();
			String strYES = EnumDeCoupling.YES.getValue();
			if(tempStrDeCoupling.equals(strYES) && !isPresent(0x0018,0x9060))
				throw new ConditionFailedException("Element 0018,9060 is required if value of 0x0018, 0x9059 is"
						+ strYES);

			if(tempStrDeCoupling.equals(strYES) && !isPresent(0x0018,0x9061))
				throw new ConditionFailedException("Element 0018,9061 is required if value of 0x0018, 0x9059 is"
						+ strYES);

			if(tempStrDeCoupling.equals(strYES) && !isPresent(0x0018,0x9062))
				throw new ConditionFailedException("Element 0018,9062 is required if value of 0x0018, 0x9059 is"
						+ strYES);

			if(tempStrDeCoupling.equals(strYES) && !isPresent(0x0018,0x9063))
				throw new ConditionFailedException("Element 0018,9063 is required if value of 0x0018, 0x9059 is"
						+ strYES);
		}
		catch(MandatoryMissingException mme)
		{
			if(DicomConfig.createInstance().isLoggingOn())
				DicomLogger.getLogger().log(mme.getMessage());

			
				throw new InvalidModuleException(this.getClass().getSimpleName(),mme);

		}
		return true;
	}

	/**
	 * Sets spectroscopy data characteristics.
	 * 
	 * @param arrImageType - String array of spectroscopy data.
	 */
	public void setImageType(String []arrImageType)
	{
		/*Accept Image identification characteristics in String Array format of type CS.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0008, 0x0008, DicomConstants.DCM_DT_CS, arrImageType);
	}

	/**
	 * Retrieves spectroscopy data characteristics.
	 * 
	 * @return String[] - String array of spectroscopy data.
	 */
	public String[] getImageType()
	{
		IDataElement objIDataElement = objIDataSet.getDataForTag(0x0008,0x0008);
		if(objIDataElement == null)
			return null;
		IDicomValue objIDicomValue = objIDataElement.getDicomValue();
		if(objIDicomValue == null)
			return null;
		if(objIDicomValue.getValue()==null)
			return null;
		return (String[])objIDicomValue.getValue();
	}

	/**
	 * Sets Precession frequency in MHz of the nucleus being addressed for each spectral axis.
	 * 
	 * @param arrdblTransmitterFrequency the arrdbl transmitter frequency
	 */
	public void setTransmitterFrequency(double[] arrdblTransmitterFrequency)
	{
		/*Accept value of TransmitterFrequency in double array format of type FD.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0018, 0x9098, DicomConstants.DCM_DT_FD, arrdblTransmitterFrequency);
	}

	/**
	 * Retrieves Precession frequency in MHz of the nucleus being addressed for each spectral axis.
	 * 
	 * @return the transmitter frequency
	 */
	public double[] getTransmitterFrequency()
	{
		Object objectValue = getValue(0x0018, 0x9098);
		if(objectValue!=null)
			return (double[])objectValue;
		return null;
	}

	/**
	 * Sets spectral width in Hz.
	 * 
	 * @param arrdblSpectralWidth the arrdbl spectral width
	 */
	public void setSpectralWidth(double[] arrdblSpectralWidth)
	{
		/*Accept value of SpectralWidth in double format of type FD.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0018, 0x9052, DicomConstants.DCM_DT_FD, arrdblSpectralWidth);
	}

	/**
	 * Retrieves spectral width in Hz.
	 * 
	 * @return the spectral width
	 */
	public double[] getSpectralWidth()
	{
		Object objectValue = getValue(0x0018, 0x9052);
		if(objectValue!=null)
			return (double[])objectValue;
		return null;
	}

	/**
	 * Sets the chemical shift at the transmitter frequency in ppm..
	 * 
	 * @param arrdblChemicalShiftReference the arrdbl chemical shift reference
	 */
	public void setChemicalShiftReference(double[] arrdblChemicalShiftReference)
	{
		/*Accept Chemical Shift Reference in double array format of type FD.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0018, 0x9053, DicomConstants.DCM_DT_FD, arrdblChemicalShiftReference);
	}

	/**
	 * Retrieves the chemical shift at the transmitter frequency in ppm.
	 * 
	 * @return the chemical shift reference
	 */
	public double[] getChemicalShiftReference()
	{
		Object objectValue = getValue(0x0018, 0x9053);
		if(objectValue!=null)
			return (double[])objectValue;
		return null;
	}

	/**
	 * Sets Name of volume localization technique used.
	 * 
	 * @param enumVolumeLocalizationTechnique the enum volume localization technique
	 */
	public void setVolumeLocalizationTechnique(EnumVolumeLocalizationTechnique enumVolumeLocalizationTechnique)
	{
		/*Accept VolumeLocalizationTechnique in Enumeration format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0018, 0x9054, DicomConstants.DCM_DT_CS, enumVolumeLocalizationTechnique.getValue());
	}


	/**
	 * Retrieves Name of volume localization technique used..
	 * 
	 * @return String - String array of spectroscopy data.
	 */
	public String getVolumeLocalizationTechnique()
	{
		IDataElement objIDataElement = objIDataSet.getDataForTag(0x0018,0x9054);
		if(objIDataElement == null)
			return null;
		IDicomValue objIDicomValue = objIDataElement.getDicomValue();
		if(objIDicomValue == null)
			return null;
		if(objIDicomValue.getValue()==null)
			return null;
		return objIDicomValue.getValue().toString();
	}

	/**
	 * Retrieves pre-initialized object of Volume Localization Sequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence
	 * 
	 * @return VolumeLocalizationSequence - instance of Volume Localization Sequence.
	 */
	public VolumeLocalizationSequence getVolumeLocalizationSequence()
	{
		VolumeLocalizationSequence objVolumeLocalizationSequence = (VolumeLocalizationSequence)getDicomValue(0x0018,0x9126);
		if(objVolumeLocalizationSequence == null)
		{
			/*
			 * If the sequence object is not present in the DataSet, a new sequence object is created and
			 * the TransferSyntax and DictionaryReader is set into it as it is set in the Module. This ensures that 
			 * the DataElements getting added in the DataSet follow the same TransferSyntax and use the same
			 * DictionaryReader object as that of the module.
			 */
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objVolumeLocalizationSequence = (VolumeLocalizationSequence)objDicomV3Factory.createSequence(0x0018,0x9126, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0018,0x9126, DicomConstants.DCM_DT_SQ, objVolumeLocalizationSequence.getValue());
		}
		return objVolumeLocalizationSequence;
	}

	/**
	 * Sets status of de-coupling.
	 * 
	 * @param enumDeCoupling the enum de coupling
	 */
	public void setDeCoupling(EnumDeCoupling enumDeCoupling)
	{
		/*Accept DeCoupling in Enumeration format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0018,0x9059, DicomConstants.DCM_DT_CS, enumDeCoupling.getValue());
	}

	/**
	 * Retrieves status of de-coupling.
	 * 
	 * @return String[] - String array of spectroscopy data.
	 */
	public String getDeCoupling()
	{
		IDataElement objIDataElement = objIDataSet.getDataForTag(0x0018,0x9059);
		if(objIDataElement == null)
			return null;
		IDicomValue objIDicomValue = objIDataElement.getDicomValue();
		if(objIDicomValue == null)
			return null;
		if(objIDicomValue.getValue()==null)
			return null;
		return objIDicomValue.getValue().toString();
	}

	/**
	 * Sets type of Nucleus being de-coupled.
	 * 
	 * @param enumDeCoupledNucleus the enum de coupled nucleus
	 */
	public void setDeCoupledNucleus(EnumDeCoupledNucleus[] enumDeCoupledNucleus)
	{
		/*Accept DeCoupled Nucleus in Enumeration format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		String[] strArrDeCoupledNucleus = getDeCoupledNucleus();
		for(int i=0;i < enumDeCoupledNucleus.length ; i++)
		{
			strArrDeCoupledNucleus[i] = enumDeCoupledNucleus[i].getValue();
		}
		addDataElement(0x0018,0x9060, DicomConstants.DCM_DT_CS, strArrDeCoupledNucleus);
	}

	/**
	 * Retrieves type of  Nucleus being de-coupled..
	 * 
	 * @return String[] - String array of spectroscopy data.
	 */
	public String[] getDeCoupledNucleus()
	{
		IDataElement objIDataElement = objIDataSet.getDataForTag(0x0018,0x9060);
		if(objIDataElement == null)
			return null;
		IDicomValue objIDicomValue = objIDataElement.getDicomValue();
		if(objIDicomValue == null)
			return null;
		if(objIDicomValue.getValue()==null)
			return null;
		return (String[])objIDicomValue.getValue();
	}

	/**
	 * Sets center frequency (Hz) for the decoupling.
	 * 
	 * @param arrdblDeCouplingFrequency the arrdbl de coupling frequency
	 */
	public void setDeCouplingFrequency(double[] arrdblDeCouplingFrequency)
	{
		/*Accept De Coupling Frequency in double array  format of type FD.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0018, 0x9061, DicomConstants.DCM_DT_FD, arrdblDeCouplingFrequency);
	}

	/**
	 * Retrieves center frequency (Hz) for the decoupling.
	 * 
	 * @return the de coupling frequency
	 */
	public double[] getDeCouplingFrequency()
	{
		Object objectValue = getValue(0x0018, 0x9061);
		if(objectValue!=null)
			return (double[])objectValue;
		return null;
	}

	/**
	 * Sets the de-coupling modulation scheme used.
	 * 
	 * @param enumDeCouplingMethod the enum de coupling method
	 */
	public void setDeCouplingMethod(EnumDeCouplingMethod enumDeCouplingMethod)
	{
		/*Accept Pixel Aspect Ratio in this image in short format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0018,0x9062, DicomConstants.DCM_DT_CS, enumDeCouplingMethod.getValue());
	}

	/**
	 * Retrieves the de-coupling modulation scheme used.
	 * 
	 * @return String[] - String array of spectroscopy data.
	 */
	public String getDeCouplingMethod()
	{
		IDataElement objIDataElement = objIDataSet.getDataForTag(0x0018,0x9062);
		if(objIDataElement == null)
			return null;
		IDicomValue objIDicomValue = objIDataElement.getDicomValue();
		if(objIDicomValue == null)
			return null;
		if(objIDicomValue.getValue()==null)
			return null;
		return objIDicomValue.getValue().toString();
	}

	/**
	 * Sets the chemical shift in ppm at the decoupling frequency.
	 * 
	 * @param arrdblDeCouplingChemicalShiftReference the arrdbl de coupling chemical shift reference
	 */
	public void setDeCouplingChemicalShiftReference(double[] arrdblDeCouplingChemicalShiftReference)
	{
		/*Accept Pixel Aspect Ratio in this image in short format of type FD.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0018, 0x9063, DicomConstants.DCM_DT_FD, arrdblDeCouplingChemicalShiftReference);
	}

	/**
	 * Retrieves the chemical shift in ppm at the decoupling frequency.
	 * 
	 * @return the de coupling chemical shift reference
	 */
	public double[] getDeCouplingChemicalShiftReference()
	{
		Object objectValue = getValue(0x0018, 0x9063);
		if(objectValue!=null)
			return (double[])objectValue;
		return null;
	}

	/**
	 * Sets time domain filtering or apodization applied.
	 * 
	 * @param enumTimeDomainFiltering the enum time domain filtering
	 */
	public void setTimeDomainFiltering(EnumTimeDomainFiltering []enumTimeDomainFiltering)
	{
		/* Accept Time Domain Filtering in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		String[] arrstrTimeDomainFiltering = new String[enumTimeDomainFiltering.length];
		for(int i=0;i < enumTimeDomainFiltering.length ; i++)
		{
			arrstrTimeDomainFiltering[i] = enumTimeDomainFiltering[i].getValue();
		}
		addDataElement(0x0018,0x9065, DicomConstants.DCM_DT_CS, arrstrTimeDomainFiltering);
	}

	/**
	 * Retrieves the de-coupling modulation scheme used.
	 * 
	 * @return String[] - String array of spectroscopy data.
	 */
	public String[] getTimeDomainFiltering()
	{
		IDataElement objIDataElement = objIDataSet.getDataForTag(0x0018,0x9065);
		if(objIDataElement == null)
			return null;
		IDicomValue objIDicomValue = objIDataElement.getDicomValue();
		if(objIDicomValue == null)
			return null;
		if(objIDicomValue.getValue()==null)
			return null;
		return (String[])objIDicomValue.getValue();
	}

	/**
	 * Sets Number of zero fills added to the time domain data before FT.
	 * 
	 * @param arrshNumberofZeroFills the arrsh numberof zero fills
	 */
	public void setNumberofZeroFills(short []arrshNumberofZeroFills)
	{
		/*Accept NumberofZeroFills in short array format of type US.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0018, 0x9066, DicomConstants.DCM_DT_US, arrshNumberofZeroFills);
	}

	/**
	 * Retrieves Number of zero fills added to the time domain data before FT.
	 * 
	 * @return Short[] - String array of spectroscopy data.
	 */
	public Short[] getNumberofZeroFills()
	{
		IDataElement objIDataElement = objIDataSet.getDataForTag(0x0018,0x9066);
		if(objIDataElement == null)
			return null;
		IDicomValue objIDicomValue = objIDataElement.getDicomValue();
		if(objIDicomValue == null)
			return null;
		if(objIDicomValue.getValue()==null)
			return null;
		return (Short[])objIDicomValue.getValue();
	}

	/**
	 * Sets baseline correction techniques.
	 * 
	 * @param enumBaselineCorrection - Enumeration for baseline correction techniques
	 */
	public void setBaselineCorrection(EnumBaselineCorrection enumBaselineCorrection)
	{
		/*Accept BaselineCorrection in Enumeration format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0018,0x9067, DicomConstants.DCM_DT_CS, enumBaselineCorrection.getValue());
	}

	/**
	 * Retrieves baseline correction techniques.
	 * 
	 * @return String - String value of baseline correction techniques.
	 */
	public String getBaselineCorrection()
	{
		IDataElement objIDataElement = objIDataSet.getDataForTag(0x0018,0x9067);
		if(objIDataElement == null)
			return null;
		IDicomValue objIDicomValue = objIDataElement.getDicomValue();
		if(objIDicomValue == null)
			return null;
		if(objIDicomValue.getValue()==null)
			return null;
		return objIDicomValue.getValue().toString();
	}

	/**
	 * Sets status of operations that were performed to correct resonant frequency of metabolite peaks due to B0 field
	 * inhomogeneities.
	 * 
	 * @param enumFrequencyCorrection - enumeration status of Frequency Correction
	 */
	public void setFrequencyCorrection(EnumFrequencyCorrection enumFrequencyCorrection)
	{
		/*Accept Frequency Correction in string format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0018,0x9101, DicomConstants.DCM_DT_CS, enumFrequencyCorrection.getValue());
	}

	/**
	 * Retrieves status of operations that were performed to correct resonant frequency of
	 * metabolite peaks due to B0 field inhomogeneities.
	 * 
	 * @return String - status of Frequency Correction.
	 */
	public String getFrequencyCorrection()
	{
		IDataElement objIDataElement = objIDataSet.getDataForTag(0x0018,0x9101);
		if(objIDataElement == null)
			return null;
		IDicomValue objIDicomValue = objIDataElement.getDicomValue();
		if(objIDicomValue == null)
			return null;
		if(objIDicomValue.getValue()==null)
			return null;
		return objIDicomValue.getValue().toString();
	}

	/**
	 * Sets status of a first order (frequency dependent) phase correction applied to the spectral data.
	 * 
	 * @param enumFirstOrderPhaseCorrection - enumeration status of first order (frequency dependent) phase correction
	 */
	public void setFirstOrderPhaseCorrection(EnumFirstOrderPhaseCorrection enumFirstOrderPhaseCorrection)
	{
		/*Accept First Order Phase Correction in Enumeration format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0018,0x9198, DicomConstants.DCM_DT_CS, enumFirstOrderPhaseCorrection.getValue());
	}

	/**
	 * Retrieves of a first order (frequency dependent) phase correction applied to the spectral data.
	 * 
	 * @return String - status of first order (frequency dependent) phase correction
	 */
	public String getFirstOrderPhaseCorrection()
	{
		IDataElement objIDataElement = objIDataSet.getDataForTag(0x0018,0x9198);
		if(objIDataElement == null)
			return null;
		IDicomValue objIDicomValue = objIDataElement.getDicomValue();
		if(objIDicomValue == null)
			return null;
		if(objIDicomValue.getValue()==null)
			return null;
		return objIDicomValue.getValue().toString();
	}


	/**
	 * Sets status of a Water Referenced Phase Correction.
	 * 
	 * @param enumWaterReferencedPhaseCorrection the enum water referenced phase correction
	 */
	public void setWaterReferencedPhaseCorrection(EnumWaterReferencedPhaseCorrection enumWaterReferencedPhaseCorrection)
	{
		/*Accept Water Referenced Phase Correction in string format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0018,0x9199, DicomConstants.DCM_DT_CS, enumWaterReferencedPhaseCorrection.getValue());
	}

	/**
	 * Retrieves status of a Water Referenced Phase Correction.
	 * 
	 * @return String - status of a Water Referenced Phase Correction.
	 */
	public String getWaterReferencedPhaseCorrection()
	{
		IDataElement objIDataElement = objIDataSet.getDataForTag(0x0018,0x9199);
		if(objIDataElement == null)
			return null;
		IDicomValue objIDicomValue = objIDataElement.getDicomValue();
		if(objIDicomValue == null)
			return null;
		if(objIDicomValue.getValue()==null)
			return null;
		return objIDicomValue.getValue().toString();
	}

	/**
	 * Returns instance of MRImageAndSpectroscopyInstanceMacro.
	 * 
	 * @return Instance of MRImageAndSpectroscopyInstanceMacro
	 */
	public MRImageAndSpectroscopyInstanceMacro getMRImageAndSpectroscopyInstanceMacro()
	{
		if(objMRImageAndSpectroscopyInstanceMacro == null)
		{
			objMRImageAndSpectroscopyInstanceMacro = new MRImageAndSpectroscopyInstanceMacro(objIDataSet,objIDictionaryReader);
		}
		return objMRImageAndSpectroscopyInstanceMacro;
	}

	/**
	 * Returns instance of MRSpectroscopyDescriptionMacro.
	 * 
	 * @return Instance of MRSpectroscopyDescriptionMacro
	 */
	public MRSpectroscopyDescriptionMacro getMRSpectroscopyDescriptionMacro()
	{
		if(objMSpectroscopyDescriptionMacro == null)
		{
			objMSpectroscopyDescriptionMacro = new MRSpectroscopyDescriptionMacro(objIDataSet,objIDictionaryReader);
		}
		return objMSpectroscopyDescriptionMacro;
	}
	/**
	 * Returns the collection of keys representing the DataElements that belong to this module.
	 * @return Collection of Tags - returns the collection of tags
	 */
	public ISingleCollection<ITag> getVectorOfKeys()
	{
		return objSingleCollection;
	}
}
