コード例 #1
0
        /// <summary>
        /// Load the Information Model by reading all the .DCM and .RAW files
        /// present in the given directory. The data read is normalised into the
        /// Information Model.
        /// </summary>
        /// <param name="dataDirectory">Source data directory containing the .DCm and .RAW files.</param>
        public override void LoadInformationModel(System.String dataDirectory)
        {
            DataDirectory = dataDirectory;
            DirectoryInfo directoryInfo = new DirectoryInfo(DataDirectory);

            foreach (FileInfo fileInfo in directoryInfo.GetFiles())
            {
                if ((fileInfo.Extension.ToLower().Equals(".dcm")) ||
                    (fileInfo.Extension.ToLower().Equals(".raw")) ||
                    (fileInfo.Extension == "") || (fileInfo.Extension == null))
                {
                    try
                    {
                        // read the DCM file

                        Dvtk.Sessions.ScriptSession dvtkScriptSession = new Dvtk.Sessions.ScriptSession();

                        String tempPath = Path.GetTempPath();

                        dvtkScriptSession.StorageMode          = Dvtk.Sessions.StorageMode.AsMedia;
                        dvtkScriptSession.DataDirectory        = tempPath;
                        dvtkScriptSession.ResultsRootDirectory = tempPath;

                        DvtkData.Media.DicomFile dvtkDataDicomFile = dvtkScriptSession.ReadFile(fileInfo.FullName);

                        // Add DICOM file to Information Model - but do not re-save in file
                        AddToInformationModel(dvtkDataDicomFile, false);
                    }
                    catch (Exception)
                    {
                        //Invalid DICOM File - will be skiped from QR information model.
                    }
                }
            }
        }
コード例 #2
0
ファイル: DicomFile.cs プロジェクト: top501/DVTK-1
        public void Read(String fullFileName, params String[] definitionFilesFullName)
        {
            DvtkData.Media.DicomFile dvtkDataDicomFile = null;

            if (!File.Exists(fullFileName))
            {
                throw new HliException("Dicom file or raw file \"" + fullFileName + "\" not found.");
            }

            String tempPath = Path.GetTempPath();

            Dvtk.Sessions.ScriptSession dvtkScriptSession = new Dvtk.Sessions.ScriptSession();

            dvtkScriptSession.StorageMode          = Dvtk.Sessions.StorageMode.AsMedia;
            dvtkScriptSession.DataDirectory        = tempPath;
            dvtkScriptSession.ResultsRootDirectory = tempPath;

            foreach (String definitionFileFullName in definitionFilesFullName)
            {
                dvtkScriptSession.DefinitionManagement.LoadDefinitionFile(definitionFileFullName);
            }

            dvtkDataDicomFile = dvtkScriptSession.ReadFile(fullFileName);

            this.dataSet.DvtkDataDataSet = dvtkDataDicomFile.DataSet;
            this.FileMetaInformation.DvtkDataFileMetaInformation = dvtkDataDicomFile.FileMetaInformation;
            this.dvtkDataFileHead = dvtkDataDicomFile.FileHead;
        }
コード例 #3
0
        /// <summary>
        /// Load the Information Model by reading all the .DCM and .RAW files
        /// present in the given directory. The data read is normalised into the
        /// Information Model.
        /// </summary>
        /// <param name="dataDirectory">Source data directory containing the .DCm and .RAW files.</param>
        public override void LoadInformationModel(System.String dataDirectory)
        {
            DataDirectory = dataDirectory;
            DirectoryInfo directoryInfo = new DirectoryInfo(DataDirectory);
            foreach (FileInfo fileInfo in directoryInfo.GetFiles())
            {
                if ((fileInfo.Extension.ToLower().Equals(".dcm")) ||
                    (fileInfo.Extension.ToLower().Equals(".raw")) ||
                    (fileInfo.Extension == "") || (fileInfo.Extension == null))
                {
                    try
                    {
                        // read the DCM file

                        Dvtk.Sessions.ScriptSession dvtkScriptSession = new Dvtk.Sessions.ScriptSession();

                        String tempPath = Path.GetTempPath();

                        dvtkScriptSession.StorageMode = Dvtk.Sessions.StorageMode.AsMedia;
                        dvtkScriptSession.DataDirectory = tempPath;
                        dvtkScriptSession.ResultsRootDirectory = tempPath;

                        DvtkData.Media.DicomFile dvtkDataDicomFile = dvtkScriptSession.ReadFile(fileInfo.FullName);

                        // Add DICOM file to Information Model - but do not re-save in file
                        AddToInformationModel(dvtkDataDicomFile, false);
                    }
                    catch (Exception)
                    {
                        //Invalid DICOM File - will be skiped from QR information model.
                    }
                }
            }
        }
コード例 #4
0
ファイル: DicomFile.cs プロジェクト: top501/DVTK-1
        /// <summary>
        /// Reads a file.
        /// </summary>
        /// <remarks>
        /// A new FileMetaInformation and DataSet object will be created inside this object. They will be
        /// filled with the content of the specified file.
        /// The FileMetaInformation and DataSet object previously used will not change (they will not be
        /// used anymore by this object) and can still be used outside this object if needed.
        ///
        /// Also see properties UnVrDefinitionLookUpWhenReading and StoreOBOFOWValuesWhenReading.
        ///
        /// If something goes wrong while reading the file, an exception is thrown.
        /// </remarks>
        /// <param name="fullFileName">The full file name.</param>
        /// <param name="dvtkScriptSession">The dvtk ScriptSession, from which the definition files to use for determining the attribute names are used.</param>
        private void Read(String fullFileName, Dvtk.Sessions.ScriptSession dvtkScriptSession)
        {
            // Create new FileMetaInformation and DataSet (depending on setting) objects.
            if (this.createNewDataSetObjectWhenReading)
            {
                this.dataSet = new DataSet();
            }

            // Throw an excpetion if the file doesn't exist.
            if (!File.Exists(fullFileName))
            {
                throw new HliException("File \"" + fullFileName + "\" not found.");
            }

            // Read the DicomFile using the supplied DicomThread.
            bool originalUnVrDefinitionLookUp = dvtkScriptSession.UnVrDefinitionLookUp;

            Dvtk.Sessions.StorageMode originalDvtkStorageMode = dvtkScriptSession.StorageMode;

            dvtkScriptSession.UnVrDefinitionLookUp = this.unVrDefinitionLookUpWhenReading;

            if (this.storeOBOFOWValuesWhenReading)
            {
                dvtkScriptSession.StorageMode = Dvtk.Sessions.StorageMode.AsDataSet;
            }
            else
            {
                dvtkScriptSession.StorageMode = Dvtk.Sessions.StorageMode.NoStorage;
            }

            DvtkData.Media.DicomFile dvtkDataDicomFile = dvtkScriptSession.ReadFile(fullFileName);

            if (dvtkDataDicomFile == null)
            {
                throw new HliException("Error while reading file \"" + fullFileName + "\".");
            }
            else
            {
                this.dataSet.DvtkDataDataSet = dvtkDataDicomFile.DataSet;
                this.FileMetaInformation     = new FileMetaInformation(dvtkDataDicomFile.FileMetaInformation, dvtkDataDicomFile.FileHead);
            }

            dvtkScriptSession.UnVrDefinitionLookUp = originalUnVrDefinitionLookUp;
            dvtkScriptSession.StorageMode          = originalDvtkStorageMode;
        }
コード例 #5
0
ファイル: DicomFile.cs プロジェクト: ewcasas/DVTK
        public void Read(String fullFileName, params String[] definitionFilesFullName)
        {
            DvtkData.Media.DicomFile dvtkDataDicomFile = null;

            if (!File.Exists(fullFileName))
            {
                throw new HliException("Dicom file or raw file \"" + fullFileName + "\" not found.");
            }

            String tempPath = Path.GetTempPath();

            Dvtk.Sessions.ScriptSession dvtkScriptSession = new Dvtk.Sessions.ScriptSession();

            dvtkScriptSession.StorageMode = Dvtk.Sessions.StorageMode.AsMedia;
            dvtkScriptSession.DataDirectory = tempPath;
            dvtkScriptSession.ResultsRootDirectory = tempPath;

            foreach(String definitionFileFullName in definitionFilesFullName)
            {
                dvtkScriptSession.DefinitionManagement.LoadDefinitionFile(definitionFileFullName);
            }

            dvtkDataDicomFile = dvtkScriptSession.ReadFile(fullFileName);

            this.dataSet.DvtkDataDataSet = dvtkDataDicomFile.DataSet;
            this.FileMetaInformation.DvtkDataFileMetaInformation = dvtkDataDicomFile.FileMetaInformation;
            this.dvtkDataFileHead = dvtkDataDicomFile.FileHead;
        }